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
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
00032
00033
00034
00035
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 Connect( _opacity->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) &ThresholdImageViewPanel::onChangeOpacity );
00061
00062 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
00063 if (type==1)
00064 {
00065 sizer -> Add( new wxStaticText(this,-1,_T("Image Threshold")) , 1, wxGROW );
00066 sizer -> Add( _mBarThreshold, 1, wxGROW );
00067 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
00068 }
00069 sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level")) , 1, wxGROW );
00070 sizer -> Add( _opacity, 1, wxGROW );
00071 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
00072 sizer -> Add( _cb_ShowHide, 1, wxGROW );
00073 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
00074 sizer -> Add( _interpolationCheckBox, 1, wxGROW );
00075
00076 this->SetSizer( sizer );
00077 this->SetAutoLayout( true );
00078 this->Layout();
00079 }
00080
00081
00082 ThresholdImageViewPanel::~ThresholdImageViewPanel()
00083 {
00084 }
00085
00086
00087
00088 void ThresholdImageViewPanel::SetThresholdImageView(ThresholdImageView* thresholdImageView)
00089 {
00090 _thresholdImageView = thresholdImageView;
00091 }
00092
00093
00094
00095 void ThresholdImageViewPanel::onThresholdChange(wxCommandEvent& event)
00096 {
00097 if (_thresholdGo)
00098 {
00099 _thresholdImageView->SetminMaxValue( _mBarThreshold->GetStart(), _mBarThreshold->GetEnd() );
00100 _thresholdImageView->onThresholdChange();
00101 _thresholdImageView->GetwxVtkBaseView()->Refresh();
00102
00103 }
00104 }
00105
00106
00107 void ThresholdImageViewPanel::onThresholdShow(wxCommandEvent& event)
00108 {
00109 _thresholdGo = _cb_ShowHide->GetValue();
00110 if (_thresholdGo)
00111 {
00112 _thresholdImageView->onThreshold();
00113 }
00114 else
00115 {
00116 _thresholdImageView->onThresholdRemove( );
00117 }
00118 _thresholdImageView->GetwxVtkBaseView()->Refresh();
00119 }
00120
00121
00122 void ThresholdImageViewPanel::onThresholdStop()
00123 {
00124 if (_thresholdGo)
00125 {
00126 _thresholdImageView->onThresholdRemove( );
00127 _thresholdGo=false;
00128 }
00129 }
00130
00131
00132 void ThresholdImageViewPanel::onThresholdInterpolation(wxCommandEvent& event)
00133 {
00134 _thresholdImageView->onThresholdInterpolation(_interpolationCheckBox->GetValue());
00135 _thresholdImageView->GetwxVtkBaseView()->Refresh();
00136
00137 }
00138
00139
00140 void ThresholdImageViewPanel::onChangeOpacity(wxScrollEvent& event)
00141 {
00142 int opacity = _opacity->GetValue();
00143 _thresholdImageView->onThresholdChangeOpacity(opacity);
00144 _thresholdImageView->GetwxVtkBaseView()->Refresh();
00145 }
00146
00147
00148
00149 bool ThresholdImageViewPanel::IsVisible()
00150 {
00151 return _thresholdGo;
00152 }
00153
00154
00155 BEGIN_EVENT_TABLE(ThresholdImageViewPanel, wxPanel)
00156 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_START, ThresholdImageViewPanel::onThresholdChange)
00157 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_END, ThresholdImageViewPanel::onThresholdChange)
00158 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_MOVED, ThresholdImageViewPanel::onThresholdChange)
00159
00160
00161
00162
00163 END_EVENT_TABLE()
00164
00165
00166
00167
00168