fa0eedfc35b2f88bc1b14e379908f5841b9e107e
[GPU.git] / Image.cpp
1 #include <iostream>
2 #include <assert.h>
3 #include <math.h>
4
5 #include "Image.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 Image::Image(Animable_I* ptrAnimable,ColorRGB_01* ptrColorTitreRGB) :
37 ImageMOOs_A(ptrAnimable->getW(), ptrAnimable->getH())
38 {
39 this->ptrAnimable = ptrAnimable;
40 this->ptrColorTitreRGB=ptrColorTitreRGB;
41
42 this->valueNames = ptrAnimable->getNames();
43 this->values = new float[this->valueNames.size()];
44 }
45
46 Image::~Image(void)
47 {
48 delete ptrAnimable;
49 }
50
51 /**
52 * Override
53 */
54 void Image::animationStep(bool& isNeedUpdateView)
55 {
56 // cout << "[CBI] : Image : animationStep" <<endl;
57
58 ptrAnimable->animationStep();
59 isNeedUpdateView = true; // true par default
60 }
61
62 /**
63 * Override
64 */
65 void Image::fillImageGL(uchar4* ptrDevImageGL, int w, int h)
66 {
67 // cout << "[CBI] : Image : fillImageGL" <<endl;
68
69 ptrAnimable->runGPU(ptrDevImageGL);
70 }
71
72 /**
73 * Override
74 */
75 void Image::paintPrimitives(Graphic2Ds& graphic2D) // redefinition
76 {
77 const Font_A* ptrfont = graphic2D.getFont(TIMES_ROMAN_24);
78
79 float r = ptrColorTitreRGB->r;
80 float g = ptrColorTitreRGB->g;
81 float b = ptrColorTitreRGB->b;
82 graphic2D.setColorRGB(r, g, b);
83
84 // top
85 {
86 string title;
87 this->ptrAnimable->getValues(this->values);
88 for (int i = 0; i < this->valueNames.size(); i++)
89 {
90 if (i != 0)
91 title += ", ";
92 title += this->valueNames[i];
93 title += StringTools::toString(this->values[i]);
94 }
95 graphic2D.drawTitleTop(title, ptrfont);
96 }
97
98 // bottom
99 {
100 string title = ptrAnimable->getTitle();
101 graphic2D.drawTitleBottom(title, ptrfont);
102 }
103 }
104
105 /*--------------------------------------*\
106 |* Private *|
107 \*-------------------------------------*/
108
109 /*----------------------------------------------------------------------*\
110 |* End *|
111 \*---------------------------------------------------------------------*/