5 * \brief ClassThresholdImageViewPanel .
9 #include "ThresholdImageViewPanel.h"
14 ** Begin of the threshold panel
16 ThresholdImageViewPanel::ThresholdImageViewPanel(wxWindow* parent)
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) );
22 _interpolationCheckBox = new wxCheckBox(this, -1, _T("Image interpolation") );
23 _interpolationCheckBox->SetValue(true);
24 _opacity = new wxSlider(this, wxID_ANY, 6, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
28 // interfMainPanel::getInstance()->getImageRange(range);
30 int min = (int)floor (range[0]);
31 int max = (int)ceil (range[1]);
33 _mBarThreshold = new mBarRange(this,70,65);
34 _mBarThreshold->SetMin(0);
35 _mBarThreshold->SetStart(0);
36 _mBarThreshold-> SetOrientation( true );
37 _mBarThreshold-> setActiveStateTo(true);
38 _mBarThreshold-> setVisibleLabels( true );
39 _mBarThreshold-> setDeviceEndMargin(10);
40 _mBarThreshold-> setRepresentedValues( min , max );
41 _mBarThreshold-> setDeviceBlitStart(10,10);
42 _mBarThreshold-> setIfWithActualDrawed( false );
43 _mBarThreshold-> SetStart( min );
44 _mBarThreshold-> SetEnd( max );
46 Connect( thresholdGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &ThresholdImageViewPanel::onThresholdGo );
47 Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ThresholdImageViewPanel::onThresholdInterpolation );
49 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
50 sizer -> Add( new wxStaticText(this,-1,_T("Image Threshold")) , 1, wxGROW );
51 sizer -> Add( _mBarThreshold, 1, wxGROW );
52 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
53 sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level")) , 1, wxGROW );
54 sizer -> Add( _opacity, 1, wxGROW );
55 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
56 sizer -> Add( thresholdGoBtn, 1, wxGROW );
57 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
58 sizer -> Add( _interpolationCheckBox, 1, wxGROW );
60 this->SetSizer( sizer );
61 this->SetAutoLayout( true );
65 //----------------------------------------------------------------------------
66 ThresholdImageViewPanel::~ThresholdImageViewPanel(){
70 //----------------------------------------------------------------------------
71 void ThresholdImageViewPanel::SetThresholdImageView(ThresholdImageView* thresholdImageView)
73 _thresholdImageView = thresholdImageView;
77 //----------------------------------------------------------------------------
78 void ThresholdImageViewPanel::onThresholdChange(wxCommandEvent& event)
82 _thresholdImageView->onThresholdChange();
84 //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal << std::endl;
88 //----------------------------------------------------------------------------
89 void ThresholdImageViewPanel::onThresholdGo(wxCommandEvent& event)
93 _thresholdImageView->onThreshold();
98 _thresholdImageView->onThresholdRemove( );
103 //----------------------------------------------------------------------------
104 void ThresholdImageViewPanel::onThresholdStop()
108 _thresholdImageView->onThresholdRemove( );
113 //----------------------------------------------------------------------------
114 void ThresholdImageViewPanel::onThresholdInstantChange(double range[])
116 range[0] = _mBarThreshold->GetStart();
117 range[1] = _mBarThreshold->GetEnd();
120 //----------------------------------------------------------------------------
121 void ThresholdImageViewPanel::onThresholdInterpolation(wxCommandEvent& event)
123 _thresholdImageView->onThresholdInterpolation(_interpolationCheckBox->GetValue());
126 //----------------------------------------------------------------------------
127 void ThresholdImageViewPanel::onChangeOpacity(wxScrollEvent& event)
129 int opacity = _opacity->GetValue();
130 _thresholdImageView->onThresholdChangeOpacity(opacity);
135 BEGIN_EVENT_TABLE(ThresholdImageViewPanel, wxPanel)
136 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_START, ThresholdImageViewPanel::onThresholdChange)
137 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_END, ThresholdImageViewPanel::onThresholdChange)
138 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_MOVED, ThresholdImageViewPanel::onThresholdChange)
139 EVT_SCROLL(ThresholdImageViewPanel::onChangeOpacity)