]> Creatis software - creaImageIO.git/blob - src2/creaImageIOWxGimmickTools.cpp
*** empty log message ***
[creaImageIO.git] / src2 / creaImageIOWxGimmickTools.cpp
1 #include <creaImageIOWxGimmickTools.h>
2
3 namespace creaImageIO
4 {
5         /**
6         ** Begin of the threshold panel
7         **/
8         WxGimmickTools::WxGimmickTools(wxWindow* parent)
9         : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
10         {
11                 wxButton *thresholdGoBtn = new wxButton(this,wxID_ANY,_T("Add Fake Color"), wxDefaultPosition, wxSize(200,30) );
12                 wxButton *thresholdRemoveBtn = new wxButton(this,wxID_ANY,_T("Remove Fake Color"), wxDefaultPosition, wxSize(200,30) );
13                 _interpolationCheckBox = new wxCheckBox(this, -1, _T("Image interpolation") );
14                 _interpolationCheckBox->SetValue(true); 
15                 _opacity = new wxSlider(this, wxID_ANY, 6, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
16                 _thresholdGo = false;
17
18                 double range[2];
19                 interfMainPanel::getInstance()->getImageRange(range);
20                 
21                 int min = (int)floor (range[0]);
22                 int max = (int)ceil (range[1]);
23
24                 _mBarThreshold  =  new mBarRange(this,70,65);
25                 _mBarThreshold->SetMin(0);
26                 _mBarThreshold->SetStart(0);
27                 _mBarThreshold-> SetOrientation( true );
28                 _mBarThreshold-> setActiveStateTo(true);
29                 _mBarThreshold-> setVisibleLabels( true );
30                 _mBarThreshold-> setDeviceEndMargin(10);
31                 _mBarThreshold-> setRepresentedValues( min , max );
32                 _mBarThreshold-> setDeviceBlitStart(10,10); 
33                 _mBarThreshold-> setIfWithActualDrawed( false );
34                 _mBarThreshold-> SetStart( min );
35                 _mBarThreshold-> SetEnd( max );  
36                 
37                 Connect( thresholdGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxGimmickTools::onThresholdGo ); 
38                 Connect( thresholdRemoveBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxGimmickTools::onThresholdRemove );
39                 Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WxGimmickTools::onThresholdInterpolation );
40
41                 wxFlexGridSizer * sizer         = new wxFlexGridSizer(1);
42                 sizer -> Add( new wxStaticText(this,-1,_T("Image Threshold"))  , 1, wxGROW );
43                 sizer -> Add( _mBarThreshold, 1, wxGROW );
44                 sizer -> Add( new wxStaticText(this,-1,_T(" "))  , 1, wxGROW );
45                 sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level"))  , 1, wxGROW );
46                 sizer -> Add( _opacity, 1, wxGROW );
47                 sizer -> Add( new wxStaticText(this,-1,_T(" "))  , 1, wxGROW );
48                 sizer -> Add( thresholdGoBtn, 1, wxGROW );
49                 sizer -> Add( thresholdRemoveBtn, 1, wxGROW );
50                 sizer -> Add( new wxStaticText(this,-1,_T(" "))  , 1, wxGROW );
51                 sizer -> Add( _interpolationCheckBox, 1, wxGROW );
52
53                 this->SetSizer( sizer );
54                 this->SetAutoLayout( true );
55                 this->Layout();
56         }
57
58         WxGimmickTools::~WxGimmickTools(){
59         }
60
61
62
63         void WxGimmickTools::onThresholdChange(wxCommandEvent& event)
64         {
65                 if (_thresholdGo)
66                 {
67                         //interfMainPanel::getInstance()->onThresholdChange();
68                 }
69         }
70
71         void WxGimmickTools::onThresholdGo(wxCommandEvent& event)
72         {
73                 if (!_thresholdGo)
74                 {
75                         //interfMainPanel::getInstance()->onThreshold();
76                         _thresholdGo=true;
77                 }
78         }
79
80         void WxGimmickTools::onThresholdRemove(wxCommandEvent& event)
81         {
82                 if (_thresholdGo)
83                 {       
84                         //interfMainPanel::getInstance()->onThresholdRemove( );
85                         _thresholdGo=false;             
86                 }
87         }
88
89         void WxGimmickTools::onThresholdStop()
90         {
91                 if (_thresholdGo)
92                 {       
93                         //interfMainPanel::getInstance()->onThresholdRemove( );
94                         _thresholdGo=false;             
95                 }
96         }
97
98         void WxGimmickTools::onThresholdInstantChange(double range[])
99         {
100                 range[0] = _mBarThreshold->GetStart();
101                 range[1] = _mBarThreshold->GetEnd();
102         }
103
104         void WxGimmickTools::onThresholdInterpolation(wxCommandEvent& event)
105         {
106                 //interfMainPanel::getInstance()->onThresholdInterpolation(_interpolationCheckBox->GetValue());
107         }
108
109         void WxGimmickTools::onChangeOpacity(wxScrollEvent& event)
110         {
111                 int opacity = _opacity->GetValue();
112                 //interfMainPanel::getInstance()->onThresholdChangeOpacity(opacity);
113         }
114
115         BEGIN_EVENT_TABLE(WxGimmickTools, wxPanel)
116                 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_START, WxGimmickTools :: onThresholdChange)
117                 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_END, WxGimmickTools :: onThresholdChange)
118                 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_MOVED, WxGimmickTools :: onThresholdChange)   
119                 EVT_SCROLL(WxGimmickTools :: onChangeOpacity)
120         END_EVENT_TABLE()
121
122 } // EO namespace creaImageIO
123
124