]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasSurfaceRenderingProp3D.cxx
addition of surface rendering, qt support
[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,1, wxGROW);
58
59
60                 if(wxMaracasSurfaceRendering::getInstance()->interactorSet()){
61                         checkboxsurface = new  wxCheckBox(this,-1,wxString(_T("Surface Box")));
62                         Connect(checkboxsurface->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onCheckBoxSurfaceChange);    
63                         checkboxsurface->SetValue(true);
64                         checkboxsizer->Add(checkboxsurface,1, wxGROW);
65                 }       
66
67
68                 sizersurfprop->Add(checkboxsizer,1, wxGROW);
69         }
70
71         //this->addControl(checkbox);   
72         wxFlexGridSizer* sizerbut = new wxFlexGridSizer(3);
73
74         wxBitmap bitmap(Color_xpm);
75         _colorchoose = new wxBitmapButton(this, -1, bitmap,wxDefaultPosition,wxSize(30,30));    
76         Connect(_colorchoose->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onColorChange);                   
77         sizerbut->Add(_colorchoose,1, wxGROW);
78
79         /*
80         wxBitmap bitmap1(Add_xpm);
81         _viewimage = new wxBitmapButton(this, -1, bitmap1, wxDefaultPosition, wxSize(30,30));   
82         Connect(_viewimage->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onViewImage);                       
83         sizerbut->Add(_viewimage,wxFIXED_MINSIZE);
84         */
85         sizersurfprop->Add(sizerbut,1, wxGROW);
86         //sizercolor->Add(checkbox,wxFIXED_MINSIZE);
87         //sizercolor->Add(_colorchoose,wxFIXED_MINSIZE);
88         //this->addControl(sizercolor);
89
90         wxStaticText* label = new wxStaticText(this, -1, wxString(_T("Opacity")));              
91         opacity = new wxSlider(this, -1,100,0,100,wxDefaultPosition,wxDefaultSize,wxSL_HORIZONTAL|wxSL_LABELS); 
92         Connect(opacity->GetId(), wxEVT_SCROLL_CHANGED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onOpacityRelease);     
93         wxFlexGridSizer* sizeropacity = new wxFlexGridSizer(1,1,1);     
94         sizeropacity->Add(label,1, wxGROW);
95         sizeropacity->Add(opacity,1, wxGROW);
96
97         sizersurfprop->Add(sizeropacity,1, wxGROW);
98
99         this->addControl(sizersurfprop);
100         
101 }
102
103 /**
104 ** Method called by setting on or off the actor
105 **/
106 void wxMaracasSurfaceRenderingProp3D::onCheckBoxChange(wxCommandEvent& event){  
107         //if(!isComplexBox)
108         wxMaracasSurfaceRendering::getInstance()->addRemoveActor(this->getPropId(), checkbox->GetValue());      
109 }
110 void wxMaracasSurfaceRenderingProp3D::onCheckBoxSurfaceChange(wxCommandEvent& event){   
111         //if(!isComplexBox)
112         wxMaracasSurfaceRendering::getInstance()->addRemoveSurfaceBox(this->getPropId(), checkboxsurface->GetValue());  
113 }
114
115 /**
116 ** 
117 **/
118 void wxMaracasSurfaceRenderingProp3D::onColorChange(wxCommandEvent& event){
119         wxColourDialog* colourdiag = new wxColourDialog(this);
120         if(colourdiag->ShowModal()==wxID_OK){
121                 wxColour colour = colourdiag->GetColourData().GetColour();
122                 _colorchoose->SetBackgroundColour(colour);
123
124                 double r = (double)(colour.Red())/255.0;
125                 double g = (double)(colour.Green())/255.0;
126                 double b = (double)(colour.Blue())/255.0;
127                 
128                 if(this->isComplex()){
129                         if(this->getPanId() == 1)
130                                 ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeColorA(this->getPropId(), r, g, b);
131                         if(this->getPanId() == 2)
132                                 ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeColorB(this->getPropId(), r, g, b);
133                         if(this->getPanId() == 3)
134                                 ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeColorC(this->getPropId(), r, g, b);
135                 }
136                 else
137                         wxMaracasSurfaceRendering::getInstance()->changeColor(this->getPropId(),r,g,b);
138         }
139         delete colourdiag;
140 }
141 /*void wxMaracasSurfaceRenderingProp3D::onActionButtonPressedEliminate( wxCommandEvent& event ){        
142
143 }*/
144
145 /**
146 ** Changes the opacity of an actor
147 **/
148 void wxMaracasSurfaceRenderingProp3D::onOpacityRelease(wxScrollEvent& event ){
149
150         if(this->isComplex()){
151                 if(this->getPanId() == 1)
152                         ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeOpacityA(this->getPropId(),opacity->GetValue());
153                 if(this->getPanId() == 2)
154                         ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeOpacityB(this->getPropId(),opacity->GetValue());
155                 if(this->getPanId() == 3)
156                         ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeOpacityC(this->getPropId(),opacity->GetValue());
157         }
158         else
159                 wxMaracasSurfaceRendering::getInstance()->changeOpacity(this->getPropId(),opacity->GetValue());
160
161 }
162
163 /**Carolina Perez: Method recently added. Not functionalit yet
164 ** Loads the volume in a separate window
165 **/
166 void wxMaracasSurfaceRenderingProp3D::onViewImage(wxCommandEvent& event){       
167         vtkImageData* img;
168         if(this->isComplexBox){
169                 if(this->getPanId() == 1)
170                         img = (wxMaracasRendererView::getInstance())->getTabbedPanel(_propid)->getSurfAImage();
171                 if(this->getPanId() == 2)
172                         img = (wxMaracasRendererView::getInstance())->getTabbedPanel(_propid)->getSurfBImage();
173                 if(this->getPanId() == 3)
174                         img = (wxMaracasRendererView::getInstance())->getTabbedPanel(_propid)->getSurfCImage();
175                 
176                 std::vector<int> type;
177                 type.push_back(6);
178
179                 wxMaracasDialog_NViewers* dialog1 = new wxMaracasDialog_NViewers(this, img, &type, wxString(_T("Volume Visualization") ));
180                 dialog1->SetSize(730, 700);
181                 dialog1->Show();
182         }
183         else{   
184                 //vtkImageData* img = wxMaracasMultipleVolumeRendererView::getInstance()->getVolImage();
185         }
186 }