]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotter.h
#3262 creaMaracasVisu Feature New Normal - Export LookupTable fron ColorLayerImageV...
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / pPlotter / pPlotter.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 #ifndef __pPlotter_h__
27 #define __pPlotter_h__
28
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
47 #include "pColorBar.h"
48 #include "mBarRange.h"
49 #include "mathplot.h"
50 #include "pFunctionPoint.h"
51 #include "pGraphicalFunction.h"
52 #include "pPlotterLayer.h"
53 #include "pPlotterWindow.h"
54 #include "pPlotterScaleY.h"
55 #include "pPlotterScaleX.h"
56 #include <iostream>
57 #include <vector>
58
59 //-------------------------------------------------------------------------------------------------------------
60 // Enum declarations
61 //-------------------------------------------------------------------------------------------------------------
62 /** Command IDs used by pColorPoint */
63
64 //--------------------------------------------------------------------------------------------
65 // Class definition
66 //--------------------------------------------------------------------------------------------
67
68 /*
69 * Represents the integrated plotter that consists of the a drawing area, and control bars (min-max bar, degrade bar)
70 */
71 /** @file pPlotter.h */
72 class pPlotter : public wxPanel{
73
74 public:
75
76         //------------------------------------------------------------------------------------------------------------
77         // Constructors & Destructors
78         //------------------------------------------------------------------------------------------------------------
79         /*
80         * Creates an integrated plotter instance 
81         * @param *parent Container window
82         */
83         pPlotter (wxWindow *parent,int nWidth, int nHeight);
84
85         ~pPlotter ();
86
87     //----------------------------------------------------------------------------------------
88         // Methods definition
89         //----------------------------------------------------------------------------------------
90
91         // Plotter received events      
92         void            onChangeFunction (wxCommandEvent& event);
93         void            onAddedPoint_Plotter (wxCommandEvent& event);
94         void            onRemovedPoint_Plotter (wxCommandEvent& event);
95         void            onMovePoint_Plotter (wxCommandEvent& event);
96         void            onGuideLines (wxCommandEvent& event);
97
98         // Color bar received events
99         void            onAdded_ColorPoint ( wxCommandEvent& event );
100         void            onRemoved_ColorPoint ( wxCommandEvent& event );
101         void            onMoved_ColorPoint( wxCommandEvent& event );
102         void            onChanged_ColorPoint( wxCommandEvent& event );
103         void            onColorBar( wxCommandEvent& event );
104
105         // Min-Max Barrange received events
106         void         onBarrange(wxCommandEvent& event);
107         void         onActualChange_Bar(wxCommandEvent& event);
108         void         onStartChange_Bar(wxCommandEvent& event);
109         void         onEndChange_Bar(wxCommandEvent& event);
110         void         onSelectionEnd(wxCommandEvent& event);
111         void         onMovedBar(wxCommandEvent& event);
112
113         /*
114         * Method for sending a text message to the container window
115         * @param theText Is the text of the message
116         */
117         void             sendTMessage(wxString theText);
118
119         // Other methods
120         wxWindow*       initialize(wxWindow *parent);
121
122         /*
123         * Sets the text message
124         * @param nMessage Is the text message to set
125         */
126         void setTextMessage(wxString nMessage);
127
128         /*
129         * Gets the text message
130         * @param text Is the actual text message 
131         */
132         wxString getTextMessage();
133         /**
134         * Creates and returns a graphical funcion according to the indicated vectors.
135         */
136         pGraphicalFunction* getFunctionForVectors( double* vectorX, int sizeX,double * vectorY, int sizeY );
137         /**
138         * Add a function to the plotter
139         * when the function doesnt come from window
140         */
141         int addFunction(pGraphicalFunction * function);
142         /*
143          Set Type
144         */
145         void setType(int t);
146         /*
147          Get a function in the plotter given the index
148         */
149         pGraphicalFunction* getFunction(int index);
150         
151         /*
152                 if the user resize the window   
153         */
154         void OnSize( wxSizeEvent &WXUNUSED(event) );
155         /*
156          Get a function in the plotter given the index
157         */
158         //pGraphicalFunction* getFunction(int index);
159         
160         /*
161           move the functions that the user wants to move
162           and that were setted in functionsToMove
163           @param porcentageMinX:the porcentage that the minShowed
164           of the funcntions have to be move
165           @param porcentageMaxX:the porcentage that the maxShowed
166           of the funcntions have to be move
167
168         */
169         void moveFunctions(float porcentageMinX,float porcentageMaxX);
170
171         /*
172          Adds  function to move with the bar min max
173         */
174         int addFunctionToMove(pGraphicalFunction * function);
175         /*
176         Set the bars according to the actual function 
177         */
178
179         void setAll();
180         /*
181         * deletes the function from the plotter
182         */
183         //bool deleteFunction(pGraphicalFunction* function);
184
185         
186         //--------------------
187         // Color information
188         //---------------------
189
190         /**
191                 Returns the number of points that the bar color has
192         */
193         int getColorPointsSize();
194
195         /*
196          Get the RGB values of the color point that is in the
197          index given
198         */
199         void getBarColorDataAt(int index,double&x,int& red,int& green,int& blue);
200         /*
201          add a color Point 
202          returns true if the point was succesfully added
203          PRE: 0<=red<=255 0<=green<=255 0<=blue<=255
204         */
205         bool addColorPoint (int x,int red,int green, int blue);
206
207         void eraseColorPoints();
208
209                 
210         //--------------------
211         // bar Information
212         //---------------------
213         float getMaxShowedPorcentage();
214         float getMinShowedPorcentage(); 
215         float getActualShowedPorcentage();      
216         //--------------------
217         // plotter Information
218         //---------------------
219         void setActual(pGraphicalFunction* nActual);
220         void update();
221         
222         //----------------------------
223         //Handling Options Menu
224         //----------------------------
225         /*
226         if any parameter is true, is going to be remove from the popUp menu
227         */
228         void setPopUpMenu(bool startD,bool stopD,bool smooth,bool line, bool zoomIn,
229                                           bool zoomOut,bool showPoints,bool noShowPoints,bool changeColor, bool addP,
230                                           bool delPoint,bool load,bool save);
231
232
233         /**
234         **      Returns two vectors, the grey level of the point and its value, the value is between [0,1]
235         **/
236         void GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value, int histogramsize);
237
238         /**
239         **      Returns two vectors, the grey level of the point and its value, the red, green
240         **      and blue value is between [0,1]
241         **/
242         void GetValuesColorPointsFunction(std::vector<double>& greylevel,
243                                                                         std::vector<double>& red,
244                                                                         std::vector<double>& green,
245                                                                         std::vector<double>& blue);
246         
247         //----------------------------------------------------------------------------------------
248         // Attributes declration
249         //----------------------------------------------------------------------------------------
250 private: 
251
252         /*
253         * Represents the plotter widget drawing area
254         */
255         pPlotterWindow  *m_plot;
256         /*
257         * Represents the color bar instance
258         */
259         pColorBar       *color_bar;
260         /*
261         * Represents the barrange instance
262         */
263         mBarRange       *barrange;
264         /*
265         * Represents the pointer to the actual funtion in the unified plotter
266         */
267         pGraphicalFunction* actualFunction;
268
269         /*
270         * Represents the text message 
271         */
272         wxString text;
273
274         /*
275         * Declaring the existence of the class
276         */
277         DECLARE_CLASS (pPlotter)
278         /*
279         * Declaring the use of events
280         */
281         DECLARE_EVENT_TABLE()
282 };
283
284 #endif
285
286