]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / ThresholdImageView / ColorLayerImageViewPanel.cxx
1                                                                     
2
3 /**
4  *  \file 
5  *  \brief ClassThresholdImageViewPanel . 
6  */
7
8
9 #include "ColorLayerImageViewPanel.h"
10
11
12
13 /**
14  ** Begin of the threshold panel
15  **/
16 ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, int max, int type)
17 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
18 {
19         _colorLayerImageView = new ColorLayerImageView();
20
21         _btn_ReadImage = new wxButton(this, wxID_ANY, _T("Read Image") );
22         
23
24         _thresholdGo = true;
25         _cb_ShowHide = new wxCheckBox(this, wxID_ANY, _T("Show/Hide layer") );
26         _cb_ShowHide->SetValue(_thresholdGo);
27         
28         _interpolationCheckBox = new wxCheckBox(this, -1, _T("Image interpolation") );
29         _interpolationCheckBox->SetValue(true); 
30         _opacity = new wxSlider(this, wxID_ANY, 6, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
31         
32         if (type==0)
33         {
34         }
35         
36         if (type==1)
37         {
38         }
39         
40         
41         Connect( _btn_ReadImage->GetId(), wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &ColorLayerImageViewPanel::onReadImage ); 
42         Connect( _cb_ShowHide->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdShow ); 
43         Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdInterpolation );
44         Connect( _opacity->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) &ColorLayerImageViewPanel::onChangeOpacity );
45         
46         wxFlexGridSizer * sizer         = new wxFlexGridSizer(1);
47         if (type==1)
48         {
49                 sizer -> Add( new wxStaticText(this,-1,_T("Color Image Layer"))  , 1, wxGROW );
50                 sizer -> Add( _btn_ReadImage, 1, wxGROW );
51                 sizer -> Add( new wxStaticText(this,-1,_T(" "))  , 1, wxGROW );
52         }
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( _cb_ShowHide, 1, wxGROW );
57         sizer -> Add( new wxStaticText(this,-1,_T(" "))  , 1, wxGROW );
58         sizer -> Add( _interpolationCheckBox, 1, wxGROW );
59         
60         this->SetSizer( sizer );
61         this->SetAutoLayout( true );
62         this->Layout();
63 }
64
65 //----------------------------------------------------------------------------
66 ColorLayerImageViewPanel::~ColorLayerImageViewPanel()
67 {
68 }
69
70
71 //----------------------------------------------------------------------------
72 void ColorLayerImageViewPanel::SetColorLayerImageView(ColorLayerImageView* colorLayerImageView)
73 {
74         _colorLayerImageView = colorLayerImageView;
75 }
76
77 //----------------------------------------------------------------------------
78 void ColorLayerImageViewPanel::onReadImage(wxCommandEvent& event)
79 {
80         printf("EED UPS.... ");
81 }
82
83
84 //----------------------------------------------------------------------------
85 void ColorLayerImageViewPanel::onThresholdChange(wxCommandEvent& event)
86 {
87         if (_thresholdGo)
88         {
89                 _colorLayerImageView->onThresholdChange();
90                 _colorLayerImageView->GetwxVtkBaseView()->Refresh();
91                 //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal  << std::endl;
92         }
93 }
94
95 //----------------------------------------------------------------------------
96 void ColorLayerImageViewPanel::onThresholdShow(wxCommandEvent& event)
97 {
98         _thresholdGo = _cb_ShowHide->GetValue();
99         if (_thresholdGo)
100         {
101                 _colorLayerImageView->onThreshold();
102         }
103         else
104         {       
105                 _colorLayerImageView->onThresholdRemove( );
106         }
107         _colorLayerImageView->GetwxVtkBaseView()->Refresh();
108 }
109
110 //----------------------------------------------------------------------------
111 void ColorLayerImageViewPanel::onThresholdStop()
112 {
113         if (_thresholdGo)
114         {       
115                 _colorLayerImageView->onThresholdRemove( );
116                 _thresholdGo=false;             
117         }
118 }
119
120 //----------------------------------------------------------------------------
121 void ColorLayerImageViewPanel::onThresholdInterpolation(wxCommandEvent& event)
122 {
123         _colorLayerImageView->onThresholdInterpolation(_interpolationCheckBox->GetValue());
124         _colorLayerImageView->GetwxVtkBaseView()->Refresh();
125
126 }
127
128 //----------------------------------------------------------------------------
129 void ColorLayerImageViewPanel::onChangeOpacity(wxScrollEvent& event)
130 {
131         int opacity = _opacity->GetValue();
132         _colorLayerImageView->onThresholdChangeOpacity(opacity);
133         _colorLayerImageView->GetwxVtkBaseView()->Refresh();
134 }
135
136
137 //----------------------------------------------------------------------------
138 bool ColorLayerImageViewPanel::IsVisible()
139 {
140         return _thresholdGo;
141 }
142
143
144
145 // EOF
146