1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
26 #ifndef __pPlotter_h__
27 #define __pPlotter_h__
29 // --------------------------------------------------------------------------------------------
30 // WX headers inclusion.
31 // For compilers that support precompilation, includes <wx/wx.h>.
32 // --------------------------------------------------------------------------------------------
34 #include <wx/wxprec.h>
43 //--------------------------------------------------------------------------------------------
45 //--------------------------------------------------------------------------------------------
47 #include "pColorBar.h"
48 #include "mBarRange.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"
59 //-------------------------------------------------------------------------------------------------------------
61 //-------------------------------------------------------------------------------------------------------------
62 /** Command IDs used by pColorPoint */
64 //--------------------------------------------------------------------------------------------
66 //--------------------------------------------------------------------------------------------
69 * Represents the integrated plotter that consists of the a drawing area, and control bars (min-max bar, degrade bar)
71 /** @file pPlotter.h */
72 class pPlotter : public wxPanel{
76 //------------------------------------------------------------------------------------------------------------
77 // Constructors & Destructors
78 //------------------------------------------------------------------------------------------------------------
80 * Creates an integrated plotter instance
81 * @param *parent Container window
83 pPlotter (wxWindow *parent,int nWidth, int nHeight);
87 //----------------------------------------------------------------------------------------
89 //----------------------------------------------------------------------------------------
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);
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 );
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);
114 * Method for sending a text message to the container window
115 * @param theText Is the text of the message
117 void sendTMessage(wxString theText);
120 wxWindow* initialize(wxWindow *parent);
123 * Sets the text message
124 * @param nMessage Is the text message to set
126 void setTextMessage(wxString nMessage);
129 * Gets the text message
130 * @param text Is the actual text message
132 wxString getTextMessage();
134 * Creates and returns a graphical funcion according to the indicated vectors.
136 pGraphicalFunction* getFunctionForVectors( double* vectorX, int sizeX,double * vectorY, int sizeY );
138 * Add a function to the plotter
139 * when the function doesnt come from window
141 int addFunction(pGraphicalFunction * function);
147 Get a function in the plotter given the index
149 pGraphicalFunction* getFunction(int index);
152 if the user resize the window
154 void OnSize( wxSizeEvent &WXUNUSED(event) );
156 Get a function in the plotter given the index
158 //pGraphicalFunction* getFunction(int index);
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
169 void moveFunctions(float porcentageMinX,float porcentageMaxX);
172 Adds function to move with the bar min max
174 int addFunctionToMove(pGraphicalFunction * function);
176 Set the bars according to the actual function
181 * deletes the function from the plotter
183 //bool deleteFunction(pGraphicalFunction* function);
186 //--------------------
188 //---------------------
191 Returns the number of points that the bar color has
193 int getColorPointsSize();
196 Get the RGB values of the color point that is in the
199 void getBarColorDataAt(int index,double&x,int& red,int& green,int& blue);
202 returns true if the point was succesfully added
203 PRE: 0<=red<=255 0<=green<=255 0<=blue<=255
205 bool addColorPoint (int x,int red,int green, int blue);
207 void eraseColorPoints();
210 //--------------------
212 //---------------------
213 float getMaxShowedPorcentage();
214 float getMinShowedPorcentage();
215 float getActualShowedPorcentage();
216 //--------------------
217 // plotter Information
218 //---------------------
219 void setActual(pGraphicalFunction* nActual);
222 //----------------------------
223 //Handling Options Menu
224 //----------------------------
226 if any parameter is true, is going to be remove from the popUp menu
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);
234 ** Returns two vectors, the grey level of the point and its value, the value is between [0,1]
236 void GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value, int histogramsize);
239 ** Returns two vectors, the grey level of the point and its value, the red, green
240 ** and blue value is between [0,1]
242 void GetValuesColorPointsFunction(std::vector<double>& greylevel,
243 std::vector<double>& red,
244 std::vector<double>& green,
245 std::vector<double>& blue);
247 //----------------------------------------------------------------------------------------
248 // Attributes declration
249 //----------------------------------------------------------------------------------------
253 * Represents the plotter widget drawing area
255 pPlotterWindow *m_plot;
257 * Represents the color bar instance
259 pColorBar *color_bar;
261 * Represents the barrange instance
265 * Represents the pointer to the actual funtion in the unified plotter
267 pGraphicalFunction* actualFunction;
270 * Represents the text message
275 * Declaring the existence of the class
277 DECLARE_CLASS (pPlotter)
279 * Declaring the use of events
281 DECLARE_EVENT_TABLE()