Implémentation de RipplingMath.h
[GPU.git] / WCudaMSE / API_Bilat_Graph2D / INC / view / GLGraph.h
1 #ifndef GLGRAPH_H_
2 #define GLGRAPH_H_
3 #include "envGraph.h"
4 #include "Displayable_A.h"
5 #include "Viewport.h"
6 #include "GraphObserver_I.h"
7 #include "FigureVisitor.h"
8 #include "Graph.h"
9 #include "CurveParametric.h"
10 #include "CurveAnalytic.h"
11
12 #include "GLFigure.h"
13 #include "GLGraphRunnable.h"
14
15 #include <map>
16 using std::map;
17
18 #include <queue>
19 using std::queue;
20
21 #include <mutex>
22 #include <atomic>
23 //#include <boost/thread/mutex.hpp>
24 //#include <boost/atomic.hpp>
25
26 using std::mutex;
27 using std::atomic;
28
29 /*----------------------------------------------------------------------*\
30 |* Declaration *|
31 \*---------------------------------------------------------------------*/
32
33 /*--------------------------------------*\
34 |* Public *|
35 \*-------------------------------------*/
36
37 class CBI_GRAPH GLGraph: public GraphObserver_I, public Displayable_A, public FigureVisitor_I
38 {
39 public:
40 GLGraph(Graph* ptrGraph);
41
42 virtual ~GLGraph();
43
44 /*--------------------------------------*\
45 |* Methodes *|
46 \*-------------------------------------*/
47
48 /**
49 * Override
50 */
51 void init(Panel_A &panel);
52
53 /**
54 * Override
55 */
56 void reshape(Panel_A &panel, int w, int h);
57
58 /**
59 * Override
60 */
61 void display(Panel_A &panel);
62
63 /**
64 * Override
65 */
66 void release(Panel_A &panel);
67
68 /**
69 * Override
70 */
71 void onFigureAdd(Figure* ptrFigure);
72
73 /**
74 * Override
75 */
76 void onFigureRemove(Figure* ptrFigure);
77
78 /**
79 * Override
80 */
81 void update();
82
83 /**
84 * Override
85 * visit create the right GLPolylines
86 */
87 virtual void visit(CurveParametric* ptrPolylines);
88
89 /**
90 * Override
91 * visit create the right GLCurve
92 */
93 virtual void visit(CurveAnalytic* ptrCurve);
94
95 private:
96 void computeViewports(Panel_A &panel);
97
98 int computeTitleHeight(Panel_A &panel);
99
100 void drawGraph(Panel_A &panel);
101
102 void drawTitle(Panel_A &panel);
103
104 void drawLegend(Panel_A &panel);
105
106 void drawGraphCadre(Panel_A &panel);
107
108 void drawGraphGrid(Panel_A &panel);
109
110 void processQueue(Panel_A &panel);
111
112 void updateGL(Panel_A &panel);
113
114 const Font_A* loadFont(FontLoader_A* ptrFontLoader, Title* ptrTitle);
115
116 /*--------------------------------------*\
117 |* Get *|
118 \*-------------------------------------*/
119
120 public:
121
122 Viewport getPanelViewport() const;
123
124 Viewport getGraphViewport() const;
125
126 Viewport getTitleViewport() const;
127
128 Graph* getGraph() const;
129
130 /*--------------------------------------*\
131 |* Attributs *|
132 \*-------------------------------------*/
133
134 private:
135 // Inputs
136 Graph* ptrGraph;
137
138 // Tools
139 atomic<bool> isNeedUpdate;
140 map<Figure*, GLFigure*> mapFigureGL;
141 queue<GLGraphRunnable*> queueGLGraphRunnable;
142 Viewport viewportPanel; //in pixel
143 Viewport viewportGraph; //in pixel
144 Viewport viewportTitle; //in pixel
145
146 //Thread safe
147 mutex mutexQueue;
148 mutex mutexMapFigure;
149
150 static const int LEFT_MARGIN;
151 static const int RIGHT_MARGIN;
152 static const int TOP_MARGIN;
153 static const int BOTTOM_MARGIN;
154 static const int GRAPH_MARGIN;
155 static const float TITLE_V_SPACING;
156 };
157
158 #endif
159
160 /*----------------------------------------------------------------------*\
161 |* End *|
162 \*---------------------------------------------------------------------*/