]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.h
#3144 creaMaracasVisu Bug New Normal - changeWx28to30
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / pPlotter / pPlotterLayer.h
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26
27 #ifndef __pPlotterLayer_h__
28 #define __pPlotterLayer_h__
29 // ----------------------------------------------------------------------------
30 // WX headers inclusion.
31 // For compilers that support precompilation, includes <wx/wx.h>.
32 // ----------------------------------------------------------------------------
33
34 #include <wx/wxprec.h>
35 #ifdef __BORLANDC__
36 #pragma hdrstop
37 #endif
38 #ifndef WX_PRECOMP
39 #include <wx/wx.h>
40 #endif
41
42
43 //----------------------------------------------------------------------------
44 // Includes
45 //----------------------------------------------------------------------------
46 #include "mathplot.h"
47 #include "pFunctionPoint.h"
48 #include <vector>
49
50 #define MAX_POINTS 50
51 #define MOVE 5
52
53
54 //using namespace std;
55 //----------------------------------------------------------------------------
56 // Class definition
57 //----------------------------------------------------------------------------
58 class creaMaracasVisu_EXPORT pPlotterLayer: public mpLayer 
59 {
60
61 public:
62         /** @param name  Label
63         @param flags Label alignment, pass one of #mpALIGN_NE, #mpALIGN_NW, #mpALIGN_SW, #mpALIGN_SE.
64         */
65         pPlotterLayer(wxString name = wxEmptyString, int flags = mpALIGN_NE);
66         /*
67          it define the first point of the polygon for be drawing
68          returs true if the first and second point of the polygon are setted
69         */
70         bool initializePolygon(wxPoint* points,double x1, double y1,double x2, double y2);
71         /*
72         Draw the line from (x1,y1) to (x2,y2) only passing by the 
73         positive points in the line
74         */
75 void draw(wxDC & dc,mpWindow & w,double x1,double y1,double x2,double y2, int orgy);
76         
77         /**
78         * Draw the function with th spline points
79         *
80         */
81         void drawSplineCurve(wxDC & dc,mpWindow & w, int orgy);
82         
83         /**
84         * Draw the line between the last point of the function
85         * and the position of the mouse
86         */
87         void drawLineToMousePoint(wxDC & dc,mpWindow & w, int orgy);
88         /**
89         * Draw le lines between the points of the function
90         */
91         void drawFunction(wxDC & dc,mpWindow & w, int orgy);
92         /**
93         *  Draw the points of the function
94         */
95         void drawPoints(wxDC & dc,mpWindow & w, int orgy );
96         
97         /**
98          Get the value of the traslation
99         in the x-axis
100         */
101         virtual int getXTraslation()
102         {
103                 return -1;
104         }
105         /**
106          Get the type of the curve
107          1=normal function
108          2=Histogram
109         */
110         virtual int getmType()
111         {
112                 return -1;
113         }
114         /**
115         * get the maxShowed of the function in x and y
116         */
117         virtual void getMaxShowed(int & maxX, int &maxY)
118         {
119         }
120         /**
121         * get the minShowed of the function in x and y
122         */
123         virtual void getMinShowed(int & minX, int &minY)
124         {
125         }
126         
127         /**
128         Gets the x-offset of the zoom
129         in pixels
130         */
131         virtual int getOffsetPixelsXv(){return -1;}     
132         
133         
134         /**
135         Gets the Y-offset of the zoom
136         in pixels
137         */
138         virtual int getOffsetPixelsYv(){ return -1;}
139
140         
141         /*
142          returns the xSpline to plotter
143         */
144         virtual std::vector<double> getXSpline()
145         { 
146                 std::vector<double> v;
147                 return v;
148         }
149         /*
150          returns the ySpline to plotter
151         */
152         virtual std::vector<double> getYSpline()
153         { 
154                 std::vector<double> v;
155                 return v;
156         }
157
158         /**
159          Get the type of the curve
160          1=piecewise functio
161          2= smooth
162         */
163         virtual int vGetType()
164         { return -1;}
165
166
167         /**
168          Get _offsetX and _offsetY
169         */
170
171         virtual void getOffsets(int &offsetX,int &offSetY )
172         {}
173
174         /*
175         * Get the factor zoom
176         */
177         virtual void getFactorZoom(float & fz){}
178         /**
179         * if the function that is drawing is the actual
180         */
181         virtual void getIfActual(bool &actual){}
182         
183         
184         /**
185         * get the max of the function in x and y
186         */
187         virtual void getMax(int & maxX, int &maxY){}
188
189         /**
190         * Get screens of the function
191         */
192         virtual void  getScreens(int & scrX, int & scrY){}
193
194         /**
195         * Set screens value
196         */
197         virtual void setScreens(int scrX,int scrY){}
198
199         /**
200         * Let us know the scale of the function
201         */
202         virtual void getScales(double & scaleX,double & scaleY){}
203
204         /**
205         *Rewind the value of node
206         */
207         virtual void Rewind(){}
208
209         /** Get locus value for next N.
210         Override this function in your implementation.
211         @param x Returns X value
212         @param y Returns Y value
213         */
214         virtual bool GetNextXY(double & x, double & y){return false;}
215
216 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
217 #if wxMAJOR_VERSION <= 2
218         /**
219         Get Point list of the funcion
220         @param return points
221         */
222         virtual void GetPoints(wxList &points){}
223 #else
224         /**
225         Get Point list of the funcion
226         @param return points
227         */
228         virtual wxList* GetPointsPtr(){  }
229 #endif
230
231
232         /** Layer plot handler.
233         This implementation will plot the locus in the visible area and
234         put a label according to the aligment specified.
235         */
236         virtual void Plot(wxDC & dc, mpWindow & w);
237         /**
238         Let us Know if the user want to see the points of the function
239         of other color than the color of the lines
240         */
241         virtual void ifShowPoints(bool & show){}
242
243         /**
244         * Let us Know if the user has finished the drawing
245         * that starts before.
246         */
247         virtual void getDrawing(bool &draw){}
248         /*
249         * Gets the point of the mouse where the user is
250         */
251         virtual void getMousePoint(int &x,int &y){}
252         /**
253         * this method gets the direction of the drawing
254         */
255         virtual void getDirection(bool &dir){}
256         /**
257         * Get the number of points of the function
258         */
259         virtual void getSize(int &size){};
260
261 protected:
262         int m_flags; //!< Holds label alignment
263
264 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
265 #if wxMAJOR_VERSION <= 2
266         /*
267         * Points of the function thats is drawing
268         */
269         wxList points;
270 #else
271         //  use GetPointsPtr()
272 #endif
273
274         /*
275         * the scale in x, with wich it must draw
276         */
277         double scaleX;
278         /*
279         * the scale in y, with wich it must draw
280         */
281         double scaleY;
282
283         /**
284         * offset X
285         */
286         int offsetX;
287         
288         /**
289         * offset Y
290         */
291         int offsetY;
292         
293
294         DECLARE_CLASS (pPlotterLayer)
295 };
296
297 #endif
298
299