1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
30 * \brief ClassThresholdImageViewPanel .
34 #include "ThresholdImageViewPanel.h"
39 ** Begin of the threshold panel
41 ThresholdImageViewPanel::ThresholdImageViewPanel(wxWindow* parent, int min, int max, int start, int end, int type)
42 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
44 _thresholdImageView = new ThresholdImageView();
46 // wxButton *thresholdGoBtn = new wxButton(this,wxID_ANY,_T("Show/Hide Color"), wxDefaultPosition, wxSize(200,30) );
49 _cb_ShowHide = new wxCheckBox(this, wxID_ANY, _T("Show/Hide layer") );
50 _cb_ShowHide->SetValue(_thresholdGo);
52 _interpolationCheckBox = new wxCheckBox(this, -1, _T("Image interpolation") );
53 _interpolationCheckBox->SetValue(true);
54 _opacity = new wxSlider(this, wxID_ANY, 50, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
57 // interfMainPanel::getInstance()->getImageRange(range);
59 // int min = (int)floor (range[0]);
60 // int max = (int)ceil (range[1]);
68 _mBarThreshold = new mBarRange(this,70,65);
69 _mBarThreshold-> SetMin(0);
70 _mBarThreshold-> SetStart(0);
71 _mBarThreshold-> SetOrientation( true );
72 _mBarThreshold-> setActiveStateTo(true);
73 _mBarThreshold-> setVisibleLabels( true );
74 _mBarThreshold-> setDeviceEndMargin(10);
75 _mBarThreshold-> setRepresentedValues( min , max );
76 _mBarThreshold-> setDeviceBlitStart(10,10);
77 _mBarThreshold-> setIfWithActualDrawed( false );
78 _mBarThreshold-> SetStart( start );
79 _mBarThreshold-> SetEnd( end );
83 Connect( _cb_ShowHide->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &ThresholdImageViewPanel::onThresholdShow );
84 Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ThresholdImageViewPanel::onThresholdInterpolation );
85 Connect( _opacity->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) &ThresholdImageViewPanel::onChangeOpacity );
87 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
90 sizer -> Add( new wxStaticText(this,-1,_T("Image Threshold")) , 1, wxGROW );
91 sizer -> Add( _mBarThreshold, 1, wxGROW );
92 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
94 sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level")) , 1, wxGROW );
95 sizer -> Add( _opacity, 1, wxGROW );
96 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
97 sizer -> Add( _cb_ShowHide, 1, wxGROW );
98 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
99 sizer -> Add( _interpolationCheckBox, 1, wxGROW );
101 this->SetSizer( sizer );
102 this->SetAutoLayout( true );
106 //----------------------------------------------------------------------------
107 ThresholdImageViewPanel::~ThresholdImageViewPanel()
112 //----------------------------------------------------------------------------
113 void ThresholdImageViewPanel::SetThresholdImageView(ThresholdImageView* thresholdImageView)
115 _thresholdImageView = thresholdImageView;
119 //----------------------------------------------------------------------------
120 void ThresholdImageViewPanel::onThresholdChange(wxCommandEvent& event)
124 _thresholdImageView->SetminMaxValue( _mBarThreshold->GetStart(), _mBarThreshold->GetEnd() );
125 _thresholdImageView->onThresholdChange();
126 _thresholdImageView->GetwxVtkBaseView()->Refresh();
127 //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal << std::endl;
131 //----------------------------------------------------------------------------
132 void ThresholdImageViewPanel::onThresholdShow(wxCommandEvent& event)
134 _thresholdGo = _cb_ShowHide->GetValue();
137 _thresholdImageView->onThreshold();
141 _thresholdImageView->onThresholdRemove( );
143 _thresholdImageView->GetwxVtkBaseView()->Refresh();
146 //----------------------------------------------------------------------------
147 void ThresholdImageViewPanel::onThresholdStop()
151 _thresholdImageView->onThresholdRemove( );
156 //----------------------------------------------------------------------------
157 void ThresholdImageViewPanel::onThresholdInterpolation(wxCommandEvent& event)
159 _thresholdImageView->onThresholdInterpolation(_interpolationCheckBox->GetValue());
160 _thresholdImageView->GetwxVtkBaseView()->Refresh();
164 //----------------------------------------------------------------------------
165 void ThresholdImageViewPanel::onChangeOpacity(wxScrollEvent& event)
167 int opacity = _opacity->GetValue();
168 _thresholdImageView->onThresholdChangeOpacity(opacity);
169 _thresholdImageView->GetwxVtkBaseView()->Refresh();
173 //----------------------------------------------------------------------------
174 bool ThresholdImageViewPanel::IsVisible()
180 BEGIN_EVENT_TABLE(ThresholdImageViewPanel, wxPanel)
181 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_START, ThresholdImageViewPanel::onThresholdChange)
182 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_END, ThresholdImageViewPanel::onThresholdChange)
183 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_MOVED, ThresholdImageViewPanel::onThresholdChange)
186 // EVT_SCROLL(ThresholdImageViewPanel::onChangeOpacity)