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 );
60 Connect( _opacity->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) &ThresholdImageViewPanel::onChangeOpacity );
62 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
65 sizer -> Add( new wxStaticText(this,-1,_T("Image Threshold")) , 1, wxGROW );
66 sizer -> Add( _mBarThreshold, 1, wxGROW );
67 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
69 sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level")) , 1, wxGROW );
70 sizer -> Add( _opacity, 1, wxGROW );
71 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
72 sizer -> Add( _cb_ShowHide, 1, wxGROW );
73 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
74 sizer -> Add( _interpolationCheckBox, 1, wxGROW );
76 this->SetSizer( sizer );
77 this->SetAutoLayout( true );
81 //----------------------------------------------------------------------------
82 ThresholdImageViewPanel::~ThresholdImageViewPanel()
87 //----------------------------------------------------------------------------
88 void ThresholdImageViewPanel::SetThresholdImageView(ThresholdImageView* thresholdImageView)
90 _thresholdImageView = thresholdImageView;
94 //----------------------------------------------------------------------------
95 void ThresholdImageViewPanel::onThresholdChange(wxCommandEvent& event)
99 _thresholdImageView->SetminMaxValue( _mBarThreshold->GetStart(), _mBarThreshold->GetEnd() );
100 _thresholdImageView->onThresholdChange();
101 _thresholdImageView->GetwxVtkBaseView()->Refresh();
102 //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal << std::endl;
106 //----------------------------------------------------------------------------
107 void ThresholdImageViewPanel::onThresholdShow(wxCommandEvent& event)
109 _thresholdGo = _cb_ShowHide->GetValue();
112 _thresholdImageView->onThreshold();
116 _thresholdImageView->onThresholdRemove( );
118 _thresholdImageView->GetwxVtkBaseView()->Refresh();
121 //----------------------------------------------------------------------------
122 void ThresholdImageViewPanel::onThresholdStop()
126 _thresholdImageView->onThresholdRemove( );
131 //----------------------------------------------------------------------------
132 void ThresholdImageViewPanel::onThresholdInterpolation(wxCommandEvent& event)
134 _thresholdImageView->onThresholdInterpolation(_interpolationCheckBox->GetValue());
135 _thresholdImageView->GetwxVtkBaseView()->Refresh();
139 //----------------------------------------------------------------------------
140 void ThresholdImageViewPanel::onChangeOpacity(wxScrollEvent& event)
142 int opacity = _opacity->GetValue();
143 _thresholdImageView->onThresholdChangeOpacity(opacity);
144 _thresholdImageView->GetwxVtkBaseView()->Refresh();
148 //----------------------------------------------------------------------------
149 bool ThresholdImageViewPanel::IsVisible()
155 BEGIN_EVENT_TABLE(ThresholdImageViewPanel, wxPanel)
156 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_START, ThresholdImageViewPanel::onThresholdChange)
157 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_END, ThresholdImageViewPanel::onThresholdChange)
158 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_MOVED, ThresholdImageViewPanel::onThresholdChange)
161 // EVT_SCROLL(ThresholdImageViewPanel::onChangeOpacity)