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 # ------------------------------------------------------------------------ */
28 #ifndef __HISTOGRAMW__
29 #define __HISTOGRAMW__
32 // ----------------------------------------------------------------------------
33 // wx headers inclusion.
34 // For compilers that support precompilation, includes <wx/wx.h>.
35 // ----------------------------------------------------------------------------
36 #include <wx/wxprec.h>
46 #include "pFunctionPoint.h"
47 #include "vtkImageData.h"
48 #include "pHistogram.h"
49 #include "pPlotterScaleY.h"
50 #include "pPlotterScaleX.h"
53 #define NUM_POINTS 100
54 #define WINDOW_SIZE 10
56 class creaMaracasVisu_EXPORT HistogramWidget:public wxPanel
59 //---------------------
61 //----------------------
63 //HistogramWidget( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int flag );
66 HistogramWidget( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int flag,vtkImageData* imageData,int type);
68 HistogramWidget( wxWindow *parent, wxWindowID id);
73 Draw the histogram in the plotter
77 Draw the transference function in the plotter
79 void drawTransferenceFunction();
81 if the user resize the window
83 void OnSize( wxSizeEvent &WXUNUSED(event) );
84 //---------------------------------------
85 // Get Information from the widget
86 //---------------------------------------
88 get number of points of the transference function
90 int getSizeTransferenceFunction();
92 get number of points of the barColor
94 int getSizeBarColor();
96 get a point of the transference function
98 void getTransferenceFunctionPoint(int index,int& x,int& y);
100 get a color int the bqr color
102 void getDataBarColorPoint(int index,int&x, int& red,int& green,int& blue);
104 get a point of the Histogram
107 int getHistogramPoint(int gValue);
109 //--------------------
111 //---------------------
113 Get the porcentage of the positions of
114 the min,max and actual in the bar range
116 float getMaxShowedPorcentage();
117 float getMinShowedPorcentage();
118 float getActualShowedPorcentage();
120 //---------------------------------------
121 // setting data in transferences function
123 //----------------------------------------
125 Adds a point to the transference function
127 bool addPointToTransferenceFunction(double x, double y);
129 add a color point to the histogram
130 @param x the level of grey to which the color is assigned
131 @param red the level of red for the color
132 @param green the level of red for the color
133 @param blue the level of red for the color
135 bool addColorPoint(double x,int red,int green, int blue);
136 //--------------------
137 // plotter Information
138 //---------------------
139 void updatePlotter();
141 //------------------------
143 //------------------------
147 Erase all the points that are in the transference function
149 void erasePointsTransferenceFunction();
151 Erase the color points in the plotter
153 void eraseColorPoints();
155 //-------------------
156 // Getter and setters
157 //-------------------
159 void setTransferenceFunctionHasPoints(bool hasPoints);
160 void setTransferenceFunctionHasColor(bool hasColorPoints);
161 int getHistogramSize();
162 void setType(int type);
165 ** Initialize the histogram
167 void initializeHistogram(vtkImageData* img);
169 ** Returns two vectors, the grey level of the point and its value, the value is between [0,1]
171 void GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value);
174 ** Returns two vectors, the grey level of the point and its value, the red, green
175 ** and blue value is between [0,1]
177 void GetValuesColorPointsFunction(std::vector<double>& greylevel,
178 std::vector<double>& red,
179 std::vector<double>& green,
180 std::vector<double>& blue);
186 pHistogram* histogram;
188 int idTransferenceFunction;
192 if the image has already a transference
193 function and color defines to that function
194 we have to draw it in the widget
196 bool transferenceFunctionHasPoints;
197 bool transferenceFunctionHasColor;
198 wxPanel* getControls();
200 * type=1 with transference function for moving
201 * type=2 without transference function for moving
205 DECLARE_CLASS(HistogramWidget);
207 //----------------------------------------------------------------------------
208 // wxWidget macro use declaration for handdling events
209 //----------------------------------------------------------------------------
210 DECLARE_EVENT_TABLE()