5 * \brief ClassThresholdImageViewPanel .
9 #include "ColorLayerImageViewPanel.h"
10 #include "OpenImageDialog.h"
14 ** Begin of the threshold panel
16 ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, int max, int type)
17 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
19 _colorLayerImageView = new ColorLayerImageView();
21 _btn_ReadImage = new wxButton(this, wxID_ANY, _T("Read Image") );
25 _cb_ShowHide = new wxCheckBox(this, wxID_ANY, _T("Show/Hide layer") );
26 _cb_ShowHide->SetValue(_thresholdGo);
28 _cb_SliceFixDinamic = new wxCheckBox(this, wxID_ANY, _T("Slice Fix/Dinamic") );
29 _cb_SliceFixDinamic->SetValue(true);
31 _sl_SliceImage = new wxSlider(this, wxID_ANY, 0, 1000, 1000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
32 _sl_SliceImage->Enable(false);
34 _interpolationCheckBox = new wxCheckBox(this, -1, _T("Image interpolation") );
35 _interpolationCheckBox->SetValue(true);
36 _opacity = new wxSlider(this, wxID_ANY, 6, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
47 Connect( _btn_ReadImage->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &ColorLayerImageViewPanel::onReadImage );
48 Connect( _cb_ShowHide->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdShow );
49 Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdInterpolation );
50 Connect( _opacity->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) &ColorLayerImageViewPanel::onChangeOpacity );
51 Connect( _cb_SliceFixDinamic->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceFixDinamic );
52 Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
53 Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_LINEUP , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
54 Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_LINEDOWN , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
55 Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_PAGEUP , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
56 Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_PAGEDOWN , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
59 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
62 sizer -> Add( new wxStaticText(this,-1,_T("Color Image Layer")) , 1, wxGROW );
63 sizer -> Add( _btn_ReadImage, 1, wxGROW );
64 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
66 sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level")) , 1, wxGROW );
67 sizer -> Add( _opacity, 1, wxGROW );
68 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
69 sizer -> Add( _cb_ShowHide, 1, wxGROW );
70 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
71 sizer -> Add( _interpolationCheckBox, 1, wxGROW );
73 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
74 sizer -> Add( new wxStaticText(this,-1,_T("Slice ")) , 1, wxGROW );
75 sizer -> Add( _sl_SliceImage, 1, wxGROW );
76 sizer -> Add( _cb_SliceFixDinamic, 1, wxGROW );
78 this->SetSizer( sizer );
79 this->SetAutoLayout( true );
83 //----------------------------------------------------------------------------
84 ColorLayerImageViewPanel::~ColorLayerImageViewPanel()
89 //----------------------------------------------------------------------------
90 void ColorLayerImageViewPanel::SetColorLayerImageView(ColorLayerImageView* colorLayerImageView)
92 _colorLayerImageView = colorLayerImageView;
95 //----------------------------------------------------------------------------
96 void ColorLayerImageViewPanel::onReadImage(wxCommandEvent& event)
99 // creaImageIO::WxSimpleDlg w(0,_T("Select your image"),"creaContours_Descriptor.dscp","creatisContours DB");
102 creaMaracasVisuKernel::OpenImageDialog diag = creaMaracasVisuKernel::OpenImageDialog();
103 _colorLayerImageView->SetImage( diag.getImageData() );
106 diag.getImageData()->GetWholeExtent(ext);
107 _sl_SliceImage->SetRange( 0 , ext[5]-ext[4] );
109 _colorLayerImageView->onThreshold();
110 _colorLayerImageView->GetwxVtkBaseView()->Refresh();
114 //----------------------------------------------------------------------------
115 void ColorLayerImageViewPanel::onThresholdChange(wxCommandEvent& event)
119 _colorLayerImageView->onThresholdChange();
120 _colorLayerImageView->GetwxVtkBaseView()->Refresh();
121 //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal << std::endl;
125 //----------------------------------------------------------------------------
126 void ColorLayerImageViewPanel::onThresholdShow(wxCommandEvent& event)
128 _thresholdGo = _cb_ShowHide->GetValue();
131 _colorLayerImageView->onThreshold();
135 _colorLayerImageView->onThresholdRemove( );
137 _colorLayerImageView->GetwxVtkBaseView()->Refresh();
140 //----------------------------------------------------------------------------
141 void ColorLayerImageViewPanel::onThresholdStop()
145 _colorLayerImageView->onThresholdRemove( );
150 //----------------------------------------------------------------------------
151 void ColorLayerImageViewPanel::onThresholdInterpolation(wxCommandEvent& event)
153 _colorLayerImageView->onThresholdInterpolation(_interpolationCheckBox->GetValue());
154 _colorLayerImageView->GetwxVtkBaseView()->Refresh();
158 //----------------------------------------------------------------------------
159 void ColorLayerImageViewPanel::onSliceFixDinamic(wxCommandEvent& event)
161 bool fixdin = _cb_SliceFixDinamic->GetValue();
162 _colorLayerImageView->SetSliceFixDinamic( fixdin );
165 _colorLayerImageView->SetZ2( _sl_SliceImage->GetValue() );
167 _sl_SliceImage->Enable(!fixdin);
168 _colorLayerImageView->onThreshold();
169 _colorLayerImageView->GetwxVtkBaseView()->Refresh();
172 //----------------------------------------------------------------------------
173 void ColorLayerImageViewPanel::onSliceImage(wxScrollEvent& event)
175 _colorLayerImageView->SetZ2( _sl_SliceImage->GetValue() );
176 _colorLayerImageView->onThreshold();
177 _colorLayerImageView->GetwxVtkBaseView()->Refresh();
180 //----------------------------------------------------------------------------
181 void ColorLayerImageViewPanel::onChangeOpacity(wxScrollEvent& event)
183 int opacity = _opacity->GetValue();
184 _colorLayerImageView->onThresholdChangeOpacity(opacity);
185 _colorLayerImageView->GetwxVtkBaseView()->Refresh();
189 //----------------------------------------------------------------------------
190 bool ColorLayerImageViewPanel::IsVisible()