]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasSurfaceRenderingProp3D.cxx
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxMaracasSurfaceRenderingProp3D.cxx
1 #include "wxMaracasSurfaceRenderingProp3D.h"
2 #include "wxMaracasDialog_NViewers.h"
3
4 #include <wx/colordlg.h>
5 #include "wxMaracasSurfaceRendering.h"
6 #include "wxMaracasRendererView.h"
7
8 #include "vtkImageData.h"
9
10 #include <OpenImage.xpm>
11 #include <Add.xpm>
12 #include "Color.xpm"
13
14 /**
15 **      Implementation of viewProp3D
16 **/
17 wxMaracasSurfaceRenderingProp3D::wxMaracasSurfaceRenderingProp3D(wxWindow* parent, int propid, bool _isComplexBox, int _panID)
18 :wxMaracasSurfaceRenderingPanel(parent, propid, _isComplexBox, _panID){
19         createControls();       
20 }
21
22 /**
23 ** Panel Destructor
24 **/ 
25 wxMaracasSurfaceRenderingProp3D::~wxMaracasSurfaceRenderingProp3D(){    
26         //wxMaracasSurfaceRendering::getInstance()->addRemoveActor(_propid, false);
27         if(this->isComplex())
28         {       
29                 //if(this->getPanId() == 1)
30                 //      ((wxMaracasRenderTabbedPanel*)(wxMaracasRendererView::getInstance())->getTabbedPanel())->addRemoveActorSA(_propid, false);
31                 //if(this->getPanId() == 2)
32                 //      ((wxMaracasRenderTabbedPanel*)(wxMaracasRendererView::getInstance())->getTabbedPanel())->addRemoveActorSB(_propid, false);
33                 //if(this->getPanId() == 3)
34                 //      ((wxMaracasRenderTabbedPanel*)(wxMaracasRendererView::getInstance())->getTabbedPanel())->addRemoveActorSC(_propid, false);
35         }
36         //else
37                 //wxMaracasSurfaceRendering::getInstance()->deleteActor(_propid);
38 }
39
40 /**
41 ** Constructs the panel. Elements inside may change depending on which tipe of panel construction if being requested
42 **/
43 void wxMaracasSurfaceRenderingProp3D::createControls(){
44
45         wxFlexGridSizer* sizersurfprop = new wxFlexGridSizer(1);
46         
47         if(!isComplexBox) 
48         {
49                 //wxString choices[2];
50                 //choices[0] = wxString(_T("On"));
51                 //choices[1] = wxString(_T("Off"));
52                 wxFlexGridSizer* checkboxsizer = new wxFlexGridSizer(2);
53
54                 checkbox = new  wxCheckBox(this,-1,wxString(_T("Show Actor")));
55                 Connect(checkbox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onCheckBoxChange);  
56                 checkbox->SetValue(true);       
57                 checkboxsizer->Add(checkbox,wxFIXED_MINSIZE);
58                 /*
59                 checkboxsurface = new  wxCheckBox(this,-1,wxString(_T("Surface Box")));
60                 Connect(checkboxsurface->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onCheckBoxSurfaceChange);    
61                 checkboxsurface->SetValue(true);
62                 checkboxsizer->Add(checkboxsurface,wxFIXED_MINSIZE);
63                 */
64
65                 sizersurfprop->Add(checkboxsizer,wxFIXED_MINSIZE);
66         }
67
68         //this->addControl(checkbox);   
69         wxFlexGridSizer* sizerbut = new wxFlexGridSizer(3);
70
71         wxBitmap bitmap(Color_xpm);
72         _colorchoose = new wxBitmapButton(this, -1, bitmap,wxDefaultPosition,wxSize(30,30));    
73         Connect(_colorchoose->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onColorChange);                   
74         sizerbut->Add(_colorchoose,wxFIXED_MINSIZE);
75
76         /*
77         wxBitmap bitmap1(Add_xpm);
78         _viewimage = new wxBitmapButton(this, -1, bitmap1, wxDefaultPosition, wxSize(30,30));   
79         Connect(_viewimage->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onViewImage);                       
80         sizerbut->Add(_viewimage,wxFIXED_MINSIZE);
81         */
82         sizersurfprop->Add(sizerbut,wxFIXED_MINSIZE);
83         //sizercolor->Add(checkbox,wxFIXED_MINSIZE);
84         //sizercolor->Add(_colorchoose,wxFIXED_MINSIZE);
85         //this->addControl(sizercolor);
86
87         wxStaticText* label = new wxStaticText(this, -1, wxString(_T("Opacity")));              
88         opacity = new wxSlider(this, -1,100,0,100,wxDefaultPosition,wxDefaultSize,wxSL_HORIZONTAL|wxSL_LABELS); 
89         Connect(opacity->GetId(), wxEVT_SCROLL_CHANGED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onOpacityRelease);     
90         wxFlexGridSizer* sizeropacity = new wxFlexGridSizer(1,1,1);     
91         sizeropacity->Add(label,wxFIXED_MINSIZE);
92         sizeropacity->Add(opacity,wxFIXED_MINSIZE);
93
94         sizersurfprop->Add(sizeropacity,wxFIXED_MINSIZE);
95
96         this->addControl(sizersurfprop);
97         
98 }
99
100 /**
101 ** Method called by setting on or off the actor
102 **/
103 void wxMaracasSurfaceRenderingProp3D::onCheckBoxChange(wxCommandEvent& event){  
104         //if(!isComplexBox)
105         wxMaracasSurfaceRendering::getInstance()->addRemoveActor(this->getPropId(), checkbox->GetValue());      
106 }
107 void wxMaracasSurfaceRenderingProp3D::onCheckBoxSurfaceChange(wxCommandEvent& event){   
108         //if(!isComplexBox)
109         wxMaracasSurfaceRendering::getInstance()->addRemoveSurfaceBox(this->getPropId(), checkboxsurface->GetValue());  
110 }
111
112 /**
113 ** 
114 **/
115 void wxMaracasSurfaceRenderingProp3D::onColorChange(wxCommandEvent& event){
116         wxColourDialog* colourdiag = new wxColourDialog(this);
117         if(colourdiag->ShowModal()==wxID_OK){
118                 wxColour colour = colourdiag->GetColourData().GetColour();
119                 _colorchoose->SetBackgroundColour(colour);
120
121                 double r = (double)(colour.Red())/255.0;
122                 double g = (double)(colour.Green())/255.0;
123                 double b = (double)(colour.Blue())/255.0;
124                 
125                 if(this->isComplex()){
126                         if(this->getPanId() == 1)
127                                 ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeColorA(this->getPropId(), r, g, b);
128                         if(this->getPanId() == 2)
129                                 ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeColorB(this->getPropId(), r, g, b);
130                         if(this->getPanId() == 3)
131                                 ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeColorC(this->getPropId(), r, g, b);
132                 }
133                 else
134                         wxMaracasSurfaceRendering::getInstance()->changeColor(this->getPropId(),r,g,b);
135         }
136         delete colourdiag;
137 }
138 /*void wxMaracasSurfaceRenderingProp3D::onActionButtonPressedEliminate( wxCommandEvent& event ){        
139
140 }*/
141
142 /**
143 ** Changes the opacity of an actor
144 **/
145 void wxMaracasSurfaceRenderingProp3D::onOpacityRelease(wxScrollEvent& event ){
146
147         if(this->isComplex()){
148                 if(this->getPanId() == 1)
149                         ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeOpacityA(this->getPropId(),opacity->GetValue());
150                 if(this->getPanId() == 2)
151                         ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeOpacityB(this->getPropId(),opacity->GetValue());
152                 if(this->getPanId() == 3)
153                         ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeOpacityC(this->getPropId(),opacity->GetValue());
154         }
155         else
156                 wxMaracasSurfaceRendering::getInstance()->changeOpacity(this->getPropId(),opacity->GetValue());
157
158 }
159
160 /**Carolina Perez: Method recently added. Not functionalit yet
161 ** Loads the volume in a separate window
162 **/
163 void wxMaracasSurfaceRenderingProp3D::onViewImage(wxCommandEvent& event){       
164         vtkImageData* img;
165         if(this->isComplexBox){
166                 if(this->getPanId() == 1)
167                         img = (wxMaracasRendererView::getInstance())->getTabbedPanel(_propid)->getSurfAImage();
168                 if(this->getPanId() == 2)
169                         img = (wxMaracasRendererView::getInstance())->getTabbedPanel(_propid)->getSurfBImage();
170                 if(this->getPanId() == 3)
171                         img = (wxMaracasRendererView::getInstance())->getTabbedPanel(_propid)->getSurfCImage();
172                 
173                 std::vector<int> type;
174                 type.push_back(6);
175
176                 wxMaracasDialog_NViewers* dialog1 = new wxMaracasDialog_NViewers(this, img, &type, wxString(_T("Volume Visualization") ));
177                 dialog1->SetSize(730, 700);
178                 dialog1->Show();
179         }
180         else{   
181                 //vtkImageData* img = wxMaracasMultipleVolumeRendererView::getInstance()->getVolImage();
182         }
183 }