af78e9e378df8bbe6d421ead6b807d279eab4d32
[GPU.git] / WCudaMSE / BilatTools_Cuda_Image / src / core / cudaImageTools / fonctionel / cpp / ImageFonctionel.cpp
1 #include <iostream>
2 #include <assert.h>
3 #include <math.h>
4
5 #include "ImageFonctionel.h"
6 #include "StringTools.h"
7 #include "MathTools.h"
8
9 using std::cout;
10 using std::endl;
11
12 /*----------------------------------------------------------------------*\
13 |* Declaration *|
14 \*---------------------------------------------------------------------*/
15
16 /*--------------------------------------*\
17 |* Imported *|
18 \*-------------------------------------*/
19
20 /*--------------------------------------*\
21 |* Public *|
22 \*-------------------------------------*/
23
24 /*--------------------------------------*\
25 |* Private *|
26 \*-------------------------------------*/
27
28 /*----------------------------------------------------------------------*\
29 |* Implementation *|
30 \*---------------------------------------------------------------------*/
31
32 /*--------------------------------------*\
33 |* Public *|
34 \*-------------------------------------*/
35
36 ImageFonctionel::ImageFonctionel(AnimableFonctionel_I* ptrAnimable, ColorRGB_01* ptrColorTitreRGB) :
37 ImageFonctionelMOOs_A(
38 ptrAnimable->getW(),
39 ptrAnimable->getH(),
40 *ptrAnimable->getDomaineMathInit()
41 )
42 {
43 this->ptrAnimable = ptrAnimable;
44 this->ptrColorTitreRGB = ptrColorTitreRGB;
45 this->tName = ptrAnimable->getTName();
46
47 setEnableDomaineOverlay(true);
48 }
49
50 ImageFonctionel::~ImageFonctionel(void)
51 {
52 delete ptrAnimable;
53 }
54
55 /**
56 * Override
57 */
58 void ImageFonctionel::animationStep(bool& isNeedUpdateView)
59 {
60 // cout << "[CBI] : Image : animationStep" <<endl;
61
62 ptrAnimable->animationStep();
63 isNeedUpdateView = true; // true par default
64 }
65
66 /**
67 * Override
68 */
69 void ImageFonctionel::fillImageGL(uchar4* ptrDevImageGL, int w, int h, const DomaineMath& domaineMath) // override
70 {
71 // cout << "[CBI] : Image : fillImageGL" <<endl;
72
73 ptrAnimable->runGPU(ptrDevImageGL, domaineMath);
74 }
75
76 /**
77 * Override
78 */
79 void ImageFonctionel::paintPrimitives(Graphic2Ds& graphic2D) // redefinition
80 {
81 const Font_A* ptrfont = graphic2D.getFont(TIMES_ROMAN_24);
82
83 float r = ptrColorTitreRGB->r;
84 float g = ptrColorTitreRGB->g;
85 float b = ptrColorTitreRGB->b;
86 graphic2D.setColorRGB(r, g, b);
87
88 // top
89 {
90 float t = ptrAnimable->getT();
91 string message = this->tName + StringTools::toString(t);
92 graphic2D.drawTitleTop(message, ptrfont);
93 }
94
95 // bottom
96 {
97 string title = ptrAnimable->getTitle();
98 graphic2D.drawTitleBottom(title, ptrfont);
99 }
100 }
101
102 /*--------------------------------------*\
103 |* Private *|
104 \*-------------------------------------*/
105
106 /*----------------------------------------------------------------------*\
107 |* End *|
108 \*---------------------------------------------------------------------*/