]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.h
Support #1768 CREATIS Licence insertion
[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         /**
217         Get Point list of the funcion
218         @param return points
219         */
220         virtual void GetPoints(wxList &points){}
221
222         /** Layer plot handler.
223         This implementation will plot the locus in the visible area and
224         put a label according to the aligment specified.
225         */
226         virtual void Plot(wxDC & dc, mpWindow & w);
227         /**
228         Let us Know if the user want to see the points of the function
229         of other color than the color of the lines
230         */
231         virtual void ifShowPoints(bool & show){}
232
233         /**
234         * Let us Know if the user has finished the drawing
235         * that starts before.
236         */
237         virtual void getDrawing(bool &draw){}
238         /*
239         * Gets the point of the mouse where the user is
240         */
241         virtual void getMousePoint(int &x,int &y){}
242         /**
243         * this method gets the direction of the drawing
244         */
245         virtual void getDirection(bool &dir){}
246         /**
247         * Get the number of points of the function
248         */
249         virtual void getSize(int &size){};
250
251 protected:
252         int m_flags; //!< Holds label alignment
253         /*
254         * Points of the function thats is drawing
255         */
256         wxList points;
257         /*
258         * the scale in x, with wich it must draw
259         */
260         double scaleX;
261         /*
262         * the scale in y, with wich it must draw
263         */
264         double scaleY;
265
266         /**
267         * offset X
268         */
269         int offsetX;
270         
271         /**
272         * offset Y
273         */
274         int offsetY;
275         
276
277         DECLARE_CLASS (pPlotterLayer)
278 };
279
280 #endif
281
282