HistogramDialog.h

Go to the documentation of this file.
00001 
00002 #ifndef __HISTOGRAMSDIALOG__
00003 #define __HISTOGRAMSDIALOG__
00004 
00005 
00006 // ----------------------------------------------------------------------------
00007 // wx headers inclusion.
00008 // For compilers that support precompilation, includes <wx/wx.h>.
00009 // ----------------------------------------------------------------------------
00010 #include <wx/wxprec.h>
00011 #ifdef __BORLANDC__
00012 #pragma hdrstop
00013 #endif
00014 #ifndef WX_PRECOMP
00015 #include <wx/wx.h>
00016 #endif
00017 
00018  //---------------------
00019  // Includes
00020  //----------------------
00021  #include "HistogramWidget.h"
00022  #include "vtkImageData.h"      
00023  //#include <vector>
00024  #include <vtkPiecewiseFunction.h>
00025  #include <vtkColorTransferFunction.h>
00026  #include <vtkVolumeRayCastMapper.h>
00027  #include <vtkVolume.h>
00028  //#include "../wxMPRWidget.h"
00029 
00030 #include "HistogramDialogComboBoxItem.h"
00031 #include <wx/checkbox.h>
00032 #include <wx/statbmp.h>
00033 
00034 class HistogramDialog:public wxDialog
00035 {
00036 public:
00037         /*
00038          Constructor
00039         */
00040         HistogramDialog(wxWindow *parent,wxString title,vtkImageData* imageData,bool extracontrols=false);
00041         /*
00042          Constructor
00043         */
00044         HistogramDialog(wxWindow *parent,wxString title,bool extracontrols=false);
00045         ~HistogramDialog();
00046         /*
00047          Methods
00048         */
00049         /*
00050                 get number of points of the transference function
00051         */
00052         int getSizeTransferenceFunction();
00053         /*
00054                 get number of points of the barColor
00055         */
00056         int getSizeBarColor();
00057         /*
00058                 get a point of the transference function
00059         */
00060         void getTransferenceFunctionPoint(int index,int& x,int& y);
00061         /*
00062                 get a  color int the bqr color
00063         */
00064         void getDataBarColorPoint(int index,int&x, int& red,int& green,int& blue);
00065         /*
00066                 get a point of the Histogram
00067                 given the grey value
00068         */
00069         int getHistogramPoint(int gValue);
00070 
00071         //--------------------
00072         // bar Information
00073         //---------------------
00074         /*
00075          Get the porcentage of the positions of 
00076          the min,max and actual in the bar range
00077         */
00078         float getMaxShowedPorcentage();
00079         float getMinShowedPorcentage(); 
00080         float getActualShowedPorcentage();
00081 
00082         //---------------------------------------
00083         // setting data in transferences function
00084         // and in bar color
00085         //----------------------------------------
00086         /*
00087           Adds a point to the transference function
00088         */
00089         bool addPointToTransferenceFunction(double x, double y);
00090         /*
00091                 add a color point to the histogram
00092                 @param x the level of grey to which the color is assigned
00093                 @param red the level of red for the color
00094                 @param green the level of red for the color
00095                 @param blue the level of red for the color
00096         */
00097         bool addColorPoint(double x,int red,int green, int blue);
00098         //------------------------
00099         //Erase data
00100         //------------------------
00101         
00102         /*
00103          Erase all the points that are in the transference function
00104         */
00105         void erasePointsTransferenceFunction();
00106         void eraseColorPoints();
00107         //-------------------
00108         // Getter and setters
00109         //-------------------
00110 
00111         void setTransferenceFunctionHasPoints(bool hasPoints);
00112         void setTransferenceFunctionHasColor(bool hasColorPoints);
00113         
00114         //returns if the user has pressed refresh       
00115         
00116         bool getRefreshed();
00117         void setCTF(vtkColorTransferFunction* cf);
00118         void setTF(vtkPiecewiseFunction* tf);
00119         void setVolumeMapper(vtkVolumeRayCastMapper* volMapper);
00120         void setVolume(vtkVolume* vol);
00121         //void setMPR3Dview(wxVtkMPR3DView *wxvtkmpr3Dview1);
00122         //void setClipping3DView(wxVtkClipping3DView *wxvtkclipping3Dview1);
00123 
00124         //--------------------
00125         // plotter Information
00126         //---------------------
00127         void updatePlotter();
00128         
00129         //-----------------------
00130         //Handling events
00131         //-----------------------
00132 
00133         void OnSaveData(wxCommandEvent& event);
00134         void OnLoadData(wxCommandEvent& event);
00135         void OnRefreshBtn(wxCommandEvent& event);
00136         
00137 
00141         void initializeHistogram(vtkImageData* img);
00145         void GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value);
00146 
00151         void GetValuesColorPointsFunction(std::vector<double>& greylevel,
00152                                                                         std::vector<double>& red,
00153                                                                         std::vector<double>& green,
00154                                                                         std::vector<double>& blue);
00155         void SetFunctions(vtkPiecewiseFunction* _opac, vtkColorTransferFunction* _color);
00156 
00160         void setInfoPanExtraControls(std::vector<HistogramDialogComboBoxItem*> comboitems);
00161         
00162 
00166         void OnEditColorsCombo(wxCommandEvent& event);
00167         void OnDeleteColor(wxCommandEvent& event);
00168 
00169         std::vector<HistogramDialogComboBoxItem*> getComboBoxItems(){return _comboitems;}
00170 
00171         void UpdateCurrentComboElement();
00172         
00173 private:
00174         /*
00175         Histogram Widget
00176         */
00177         HistogramWidget*  histogramW;
00181         /*
00182          ok Button
00183         */
00184         //wxButton              *okBtn;
00185         wxBitmapButton          *okBtn;
00186         /*
00187          cancel Button
00188         */
00189         //wxButton              *cancelBtn;
00190         wxBitmapButton          *cancelBtn;
00191         /*
00192          save Button
00193         */
00194         wxButton                *saveDataBtn;   
00195         /*
00196         Load Button
00197         */
00198         wxButton                *loadDataBtn;
00199         /*
00200         Refresh Button
00201         */
00202         wxButton                *refreshBtn;
00203 
00204         wxPanel* _panextracontrols;
00205         
00206         
00207         // the user had pressed refresh
00208         bool refreshed;
00209         
00210         vtkColorTransferFunction                        *_ctfun;
00211         vtkPiecewiseFunction                            *_tfun;
00212         vtkVolumeRayCastMapper                          *volumeMapper; 
00213         vtkVolume                                                       *newvol;
00214 
00215         //things to refresh
00216         //wxVtkMPR3DView                                                *wxvtkmpr3Dview;
00217         //wxVtkClipping3DView                                   *wxvtkclipping3Dview;
00218 
00219         
00220         wxSizer* getControls(bool extracontrols = false);
00221 
00222         
00223         
00224 //      DECLARE_CLASS(HistogramDialog);
00225         // any class wishing to process wxWindows events must use this macro
00226         //DECLARE_EVENT_TABLE()
00227 
00228         void initializeHistogramDialog(bool extracontrols);
00229 
00230          wxPanel* getPanExtraControls();
00231 
00232          std::vector<wxBitmapButton*> bitmapbuttonsvect;
00233          std::vector<HistogramDialogComboBoxItem*> _comboitems;
00234 
00235          void setCurrentColorConfigurationIntoButton();
00236          void AddNewBitmapButton();
00237          wxSizer* getBitmapButtonDelete(wxBitmap bitmap);
00238          std::vector<wxBitmapButton*> _deletebuttonsvector;
00239 
00240          int _maxgreyvalue;
00241          int _currentcolorselectedbitmap;
00242 };
00243 
00244 #endif
00245 
00246 
00247 

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1