HistogramWidget.h

Go to the documentation of this file.
00001 
00002 
00003 #ifndef __HISTOGRAMW__
00004 #define __HISTOGRAMW__
00005 
00006 
00007 // ----------------------------------------------------------------------------
00008 // wx headers inclusion.
00009 // For compilers that support precompilation, includes <wx/wx.h>.
00010 // ----------------------------------------------------------------------------
00011 #include <wx/wxprec.h>
00012 #ifdef __BORLANDC__
00013 #pragma hdrstop
00014 #endif
00015 #ifndef WX_PRECOMP
00016 #include <wx/wx.h>
00017 #endif
00018 
00019 #include "marTypes.h"
00020 #include "pPlotter.h"
00021 #include "pFunctionPoint.h"
00022 #include  "vtkImageData.h"
00023 #include "pHistogram.h"
00024 #include "pPlotterScaleY.h"
00025 #include "pPlotterScaleX.h"
00026 
00027 //#define MAX 500
00028 #define NUM_POINTS 100
00029 #define WINDOW_SIZE 10
00030 
00031 class creaMaracasVisu_EXPORT HistogramWidget:public wxPanel
00032 {
00033 public:
00034         //---------------------
00035         // Constructor
00036         //----------------------
00037 
00038         //HistogramWidget( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int flag );
00039         
00040  
00041         HistogramWidget( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int flag,vtkImageData* imageData,int type);
00042 
00043         HistogramWidget( wxWindow *parent, wxWindowID id);
00044         
00045         ~HistogramWidget();
00046 
00047         /*
00048         Draw the histogram in the plotter
00049         */
00050         void drawHistogram();
00051         /*
00052         Draw the transference function in the plotter
00053         */
00054         void drawTransferenceFunction();
00055         /*
00056                 if the user resize the window   
00057         */
00058         void OnSize( wxSizeEvent &WXUNUSED(event) );
00059         //---------------------------------------
00060         // Get Information from the widget
00061         //---------------------------------------
00062         /*
00063                 get number of points of the transference function
00064         */
00065         int getSizeTransferenceFunction();
00066         /*
00067                 get number of points of the barColor
00068         */
00069         int getSizeBarColor();
00070         /*
00071                 get a point of the transference function
00072         */
00073         void getTransferenceFunctionPoint(int index,int& x,int& y);
00074         /*
00075                 get a  color int the bqr color
00076         */
00077         void getDataBarColorPoint(int index,int&x, int& red,int& green,int& blue);
00078         /*
00079                 get a point of the Histogram
00080                 given the grey value
00081         */
00082         int getHistogramPoint(int gValue);
00083 
00084         //--------------------
00085         // bar Information
00086         //---------------------
00087         /*
00088          Get the porcentage of the positions of 
00089          the min,max and actual in the bar range
00090         */
00091         float getMaxShowedPorcentage();
00092         float getMinShowedPorcentage(); 
00093         float getActualShowedPorcentage();      
00094 
00095         //---------------------------------------
00096         // setting data in transferences function
00097         // and in bar color
00098         //----------------------------------------
00099         /*
00100           Adds a point to the transference function
00101         */
00102         bool addPointToTransferenceFunction(double x, double y);
00103         /*
00104                 add a color point to the histogram
00105                 @param x the level of grey to which the color is assigned
00106                 @param red the level of red for the color
00107                 @param green the level of red for the color
00108                 @param blue the level of red for the color
00109         */
00110         bool addColorPoint(double x,int red,int green, int blue);
00111         //--------------------
00112         // plotter Information
00113         //---------------------
00114         void updatePlotter();
00115         
00116         //------------------------
00117         //Erase data
00118         //------------------------
00119         
00120 
00121         /*
00122          Erase all the points that are in the transference function
00123         */
00124         void erasePointsTransferenceFunction();
00125         /*
00126         Erase the  color points in the plotter
00127         */
00128         void eraseColorPoints();
00129 
00130         //-------------------
00131         // Getter and setters
00132         //-------------------
00133 
00134         void setTransferenceFunctionHasPoints(bool hasPoints);
00135         void setTransferenceFunctionHasColor(bool hasColorPoints);
00136         int getHistogramSize();
00137         void setType(int type);
00138 
00142         void initializeHistogram(vtkImageData* img);
00146         void GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value);
00147 
00152         void GetValuesColorPointsFunction(std::vector<double>& greylevel,
00153                                                                         std::vector<double>& red,
00154                                                                         std::vector<double>& green,
00155                                                                         std::vector<double>& blue);
00156 
00157 
00158         
00159 private:
00160         
00161          pHistogram* histogram;
00162          pPlotter* plotter;
00163          int idTransferenceFunction;
00164          int histogramSize;
00165          int idHistogram;
00166          /*
00167           if the image has already a transference
00168           function and color defines to that function
00169           we have to draw it in the widget
00170          */
00171          bool transferenceFunctionHasPoints;
00172          bool transferenceFunctionHasColor;
00173          wxPanel* getControls();
00174          /*
00175          * type=1 with transference function for moving
00176          * type=2 without transference function for moving
00177          */
00178          int type;      
00179          
00180          DECLARE_CLASS(HistogramWidget);
00181          //----------------------------------------------------------------------------
00182         // wxWidget macro use declaration for handdling events
00183         //----------------------------------------------------------------------------
00184         DECLARE_EVENT_TABLE()
00185         
00186 };
00187 #endif
00188 
00189 

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1