ThresholdImageViewPanel.cxx

Go to the documentation of this file.
00001                                                                     
00002 
00009 #include "ThresholdImageViewPanel.h"
00010 
00011 
00012 
00016 ThresholdImageViewPanel::ThresholdImageViewPanel(wxWindow* parent, int min, int max, int type)
00017 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
00018 {
00019         _thresholdImageView = new ThresholdImageView();
00020 
00021 //      wxButton *thresholdGoBtn = new wxButton(this,wxID_ANY,_T("Show/Hide Color"), wxDefaultPosition, wxSize(200,30) );
00022         
00023         _thresholdGo = true;
00024         _cb_ShowHide = new wxCheckBox(this, wxID_ANY, _T("Show/Hide layer") );
00025         _cb_ShowHide->SetValue(_thresholdGo);
00026         
00027         _interpolationCheckBox = new wxCheckBox(this, -1, _T("Image interpolation") );
00028         _interpolationCheckBox->SetValue(true); 
00029         _opacity = new wxSlider(this, wxID_ANY, 6, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
00030         
00031 //      double range[2];
00032 //      interfMainPanel::getInstance()->getImageRange(range);
00033         
00034 //      int min = (int)floor (range[0]);
00035 //      int max = (int)ceil (range[1]);
00036 
00037         if (type==0)
00038         {
00039         }
00040         
00041         if (type==1)
00042         {
00043                 _mBarThreshold  =  new mBarRange(this,70,65);
00044                 _mBarThreshold->SetMin(0);
00045                 _mBarThreshold->SetStart(0);
00046                 _mBarThreshold-> SetOrientation( true );
00047                 _mBarThreshold-> setActiveStateTo(true);
00048                 _mBarThreshold-> setVisibleLabels( true );
00049                 _mBarThreshold-> setDeviceEndMargin(10);
00050                 _mBarThreshold-> setRepresentedValues( min , max );
00051                 _mBarThreshold-> setDeviceBlitStart(10,10); 
00052                 _mBarThreshold-> setIfWithActualDrawed( false );
00053                 _mBarThreshold-> SetStart( min );
00054                 _mBarThreshold-> SetEnd( max );  
00055         }
00056         
00057         
00058         Connect( _cb_ShowHide->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &ThresholdImageViewPanel::onThresholdShow ); 
00059         Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ThresholdImageViewPanel::onThresholdInterpolation );
00060         
00061         wxFlexGridSizer * sizer         = new wxFlexGridSizer(1);
00062         if (type==1)
00063         {
00064                 sizer -> Add( new wxStaticText(this,-1,_T("Image Threshold"))  , 1, wxGROW );
00065                 sizer -> Add( _mBarThreshold, 1, wxGROW );
00066                 sizer -> Add( new wxStaticText(this,-1,_T(" "))  , 1, wxGROW );
00067         }
00068         sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level"))  , 1, wxGROW );
00069         sizer -> Add( _opacity, 1, wxGROW );
00070         sizer -> Add( new wxStaticText(this,-1,_T(" "))  , 1, wxGROW );
00071         sizer -> Add( _cb_ShowHide, 1, wxGROW );
00072         sizer -> Add( new wxStaticText(this,-1,_T(" "))  , 1, wxGROW );
00073         sizer -> Add( _interpolationCheckBox, 1, wxGROW );
00074         
00075         this->SetSizer( sizer );
00076         this->SetAutoLayout( true );
00077         this->Layout();
00078 }
00079 
00080 //----------------------------------------------------------------------------
00081 ThresholdImageViewPanel::~ThresholdImageViewPanel()
00082 {
00083 }
00084 
00085 
00086 //----------------------------------------------------------------------------
00087 void ThresholdImageViewPanel::SetThresholdImageView(ThresholdImageView* thresholdImageView)
00088 {
00089         _thresholdImageView = thresholdImageView;
00090 }
00091 
00092 
00093 //----------------------------------------------------------------------------
00094 void ThresholdImageViewPanel::onThresholdChange(wxCommandEvent& event)
00095 {
00096         if (_thresholdGo)
00097         {
00098                 _thresholdImageView->SetminMaxValue( _mBarThreshold->GetStart(), _mBarThreshold->GetEnd() );
00099                 _thresholdImageView->onThresholdChange();
00100                 _thresholdImageView->GetwxVtkBaseView()->Refresh();
00101                 //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal  << std::endl;
00102         }
00103 }
00104 
00105 //----------------------------------------------------------------------------
00106 void ThresholdImageViewPanel::onThresholdShow(wxCommandEvent& event)
00107 {
00108         _thresholdGo = _cb_ShowHide->GetValue();
00109         if (_thresholdGo)
00110         {
00111                 _thresholdImageView->onThreshold();
00112         }
00113         else
00114         {       
00115                 _thresholdImageView->onThresholdRemove( );
00116         }
00117         _thresholdImageView->GetwxVtkBaseView()->Refresh();
00118 }
00119 
00120 //----------------------------------------------------------------------------
00121 void ThresholdImageViewPanel::onThresholdStop()
00122 {
00123         if (_thresholdGo)
00124         {       
00125                 _thresholdImageView->onThresholdRemove( );
00126                 _thresholdGo=false;             
00127         }
00128 }
00129 
00130 //----------------------------------------------------------------------------
00131 void ThresholdImageViewPanel::onThresholdInterpolation(wxCommandEvent& event)
00132 {
00133         _thresholdImageView->onThresholdInterpolation(_interpolationCheckBox->GetValue());
00134         _thresholdImageView->GetwxVtkBaseView()->Refresh();
00135 
00136 }
00137 
00138 //----------------------------------------------------------------------------
00139 void ThresholdImageViewPanel::onChangeOpacity(wxScrollEvent& event)
00140 {
00141         int opacity = _opacity->GetValue();
00142         _thresholdImageView->onThresholdChangeOpacity(opacity);
00143         _thresholdImageView->GetwxVtkBaseView()->Refresh();
00144 }
00145 
00146 
00147 //----------------------------------------------------------------------------
00148 bool ThresholdImageViewPanel::IsVisible()
00149 {
00150         return _thresholdGo;
00151 }
00152 
00153 
00154 BEGIN_EVENT_TABLE(ThresholdImageViewPanel, wxPanel)
00155   EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_START, ThresholdImageViewPanel::onThresholdChange)
00156   EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_END, ThresholdImageViewPanel::onThresholdChange)
00157   EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_MOVED, ThresholdImageViewPanel::onThresholdChange)  
00158   EVT_SCROLL(ThresholdImageViewPanel::onChangeOpacity)
00159 END_EVENT_TABLE()
00160 
00161 
00162 
00163 // EOF
00164 

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1