Cleanage.
[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->valueNames = ptrAnimable->getNames();
46 this->values = new float[this->valueNames.size()];
47
48 setEnableDomaineOverlay(true);
49 }
50
51 ImageFonctionel::~ImageFonctionel(void)
52 {
53 delete this->ptrAnimable;
54 delete[] this->values;
55 }
56
57 /**
58 * Override
59 */
60 void ImageFonctionel::animationStep(bool& isNeedUpdateView)
61 {
62 // cout << "[CBI] : Image : animationStep" <<endl;
63
64 ptrAnimable->animationStep();
65 isNeedUpdateView = true; // true par default
66 }
67
68 /**
69 * Override
70 */
71 void ImageFonctionel::fillImageGL(uchar4* ptrDevImageGL, int w, int h, const DomaineMath& domaineMath) // override
72 {
73 // cout << "[CBI] : Image : fillImageGL" <<endl;
74
75 ptrAnimable->runGPU(ptrDevImageGL, domaineMath);
76 }
77
78 /**
79 * Override
80 */
81 void ImageFonctionel::paintPrimitives(Graphic2Ds& graphic2D) // redefinition
82 {
83 const Font_A* ptrfont = graphic2D.getFont(TIMES_ROMAN_24);
84
85 float r = ptrColorTitreRGB->r;
86 float g = ptrColorTitreRGB->g;
87 float b = ptrColorTitreRGB->b;
88 graphic2D.setColorRGB(r, g, b);
89
90 // top
91 {
92 string title;
93 this->ptrAnimable->getValues(this->values);
94 for (int i = 0; i < this->valueNames.size(); i++)
95 {
96 if (i != 0)
97 title += ", ";
98 title += this->valueNames[i];
99 title += StringTools::toString(this->values[i]);
100 }
101 graphic2D.drawTitleTop(title, ptrfont);
102 }
103
104 // bottom
105 {
106 string title = ptrAnimable->getTitle();
107 graphic2D.drawTitleBottom(title, ptrfont);
108 }
109 }
110
111 /*--------------------------------------*\
112 |* Private *|
113 \*-------------------------------------*/
114
115 /*----------------------------------------------------------------------*\
116 |* End *|
117 \*---------------------------------------------------------------------*/