5 * \brief ClassThresholdImageViewPanel .
9 #include "ThresholdImageViewPanel.h"
14 ** Begin of the threshold panel
16 ThresholdImageViewPanel::ThresholdImageViewPanel(wxWindow* parent, int min, int max, int type)
17 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
19 _thresholdImageView = new ThresholdImageView();
21 // wxButton *thresholdGoBtn = new wxButton(this,wxID_ANY,_T("Show/Hide Color"), wxDefaultPosition, wxSize(200,30) );
24 _cb_ShowHide = new wxCheckBox(this, wxID_ANY, _T("Show/Hide layer") );
25 _cb_ShowHide->SetValue(_thresholdGo);
27 _interpolationCheckBox = new wxCheckBox(this, -1, _T("Image interpolation") );
28 _interpolationCheckBox->SetValue(true);
29 _opacity = new wxSlider(this, wxID_ANY, 6, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
32 // interfMainPanel::getInstance()->getImageRange(range);
34 // int min = (int)floor (range[0]);
35 // int max = (int)ceil (range[1]);
43 _mBarThreshold = new mBarRange(this,70,65);
44 _mBarThreshold->SetMin(0);
45 _mBarThreshold->SetStart(0);
46 _mBarThreshold-> SetOrientation( true );
47 _mBarThreshold-> setActiveStateTo(true);
48 _mBarThreshold-> setVisibleLabels( true );
49 _mBarThreshold-> setDeviceEndMargin(10);
50 _mBarThreshold-> setRepresentedValues( min , max );
51 _mBarThreshold-> setDeviceBlitStart(10,10);
52 _mBarThreshold-> setIfWithActualDrawed( false );
53 _mBarThreshold-> SetStart( min );
54 _mBarThreshold-> SetEnd( max );
58 Connect( _cb_ShowHide->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &ThresholdImageViewPanel::onThresholdShow );
59 Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ThresholdImageViewPanel::onThresholdInterpolation );
61 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
64 sizer -> Add( new wxStaticText(this,-1,_T("Image Threshold")) , 1, wxGROW );
65 sizer -> Add( _mBarThreshold, 1, wxGROW );
66 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
68 sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level")) , 1, wxGROW );
69 sizer -> Add( _opacity, 1, wxGROW );
70 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
71 sizer -> Add( _cb_ShowHide, 1, wxGROW );
72 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
73 sizer -> Add( _interpolationCheckBox, 1, wxGROW );
75 this->SetSizer( sizer );
76 this->SetAutoLayout( true );
80 //----------------------------------------------------------------------------
81 ThresholdImageViewPanel::~ThresholdImageViewPanel()
86 //----------------------------------------------------------------------------
87 void ThresholdImageViewPanel::SetThresholdImageView(ThresholdImageView* thresholdImageView)
89 _thresholdImageView = thresholdImageView;
93 //----------------------------------------------------------------------------
94 void ThresholdImageViewPanel::onThresholdChange(wxCommandEvent& event)
98 _thresholdImageView->SetminMaxValue( _mBarThreshold->GetStart(), _mBarThreshold->GetEnd() );
99 _thresholdImageView->onThresholdChange();
100 _thresholdImageView->GetwxVtkBaseView()->Refresh();
101 //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal << std::endl;
105 //----------------------------------------------------------------------------
106 void ThresholdImageViewPanel::onThresholdShow(wxCommandEvent& event)
108 _thresholdGo = _cb_ShowHide->GetValue();
111 _thresholdImageView->onThreshold();
115 _thresholdImageView->onThresholdRemove( );
117 _thresholdImageView->GetwxVtkBaseView()->Refresh();
120 //----------------------------------------------------------------------------
121 void ThresholdImageViewPanel::onThresholdStop()
125 _thresholdImageView->onThresholdRemove( );
130 //----------------------------------------------------------------------------
131 void ThresholdImageViewPanel::onThresholdInterpolation(wxCommandEvent& event)
133 _thresholdImageView->onThresholdInterpolation(_interpolationCheckBox->GetValue());
134 _thresholdImageView->GetwxVtkBaseView()->Refresh();
138 //----------------------------------------------------------------------------
139 void ThresholdImageViewPanel::onChangeOpacity(wxScrollEvent& event)
141 int opacity = _opacity->GetValue();
142 _thresholdImageView->onThresholdChangeOpacity(opacity);
143 _thresholdImageView->GetwxVtkBaseView()->Refresh();
147 //----------------------------------------------------------------------------
148 bool ThresholdImageViewPanel::IsVisible()
154 BEGIN_EVENT_TABLE(ThresholdImageViewPanel, wxPanel)
155 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_START, ThresholdImageViewPanel::onThresholdChange)
156 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_END, ThresholdImageViewPanel::onThresholdChange)
157 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_MOVED, ThresholdImageViewPanel::onThresholdChange)
158 EVT_SCROLL(ThresholdImageViewPanel::onChangeOpacity)