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