1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 #include "wxMaracasSurfaceRenderingProp3D.h"
27 #include "wxMaracasDialog_NViewers.h"
29 #include <wx/colordlg.h>
30 #include "wxMaracasSurfaceRendering.h"
31 #include "wxMaracasRendererView.h"
33 #include "vtkImageData.h"
35 #include <OpenImage.xpm>
40 ** Implementation of viewProp3D
42 wxMaracasSurfaceRenderingProp3D::wxMaracasSurfaceRenderingProp3D(wxWindow* parent, int propid, bool _isComplexBox, int _panID)
43 :wxMaracasSurfaceRenderingPanel(parent, propid, _isComplexBox, _panID){
50 wxMaracasSurfaceRenderingProp3D::~wxMaracasSurfaceRenderingProp3D(){
51 //wxMaracasSurfaceRendering::getInstance()->addRemoveActor(_propid, false);
54 //if(this->getPanId() == 1)
55 // ((wxMaracasRenderTabbedPanel*)(wxMaracasRendererView::getInstance())->getTabbedPanel())->addRemoveActorSA(_propid, false);
56 //if(this->getPanId() == 2)
57 // ((wxMaracasRenderTabbedPanel*)(wxMaracasRendererView::getInstance())->getTabbedPanel())->addRemoveActorSB(_propid, false);
58 //if(this->getPanId() == 3)
59 // ((wxMaracasRenderTabbedPanel*)(wxMaracasRendererView::getInstance())->getTabbedPanel())->addRemoveActorSC(_propid, false);
62 //wxMaracasSurfaceRendering::getInstance()->deleteActor(_propid);
66 ** Constructs the panel. Elements inside may change depending on which tipe of panel construction if being requested
68 void wxMaracasSurfaceRenderingProp3D::createControls(){
70 wxFlexGridSizer* sizersurfprop = new wxFlexGridSizer(1);
74 //wxString choices[2];
75 //choices[0] = wxString(_T("On"));
76 //choices[1] = wxString(_T("Off"));
77 wxFlexGridSizer* checkboxsizer = new wxFlexGridSizer(2);
79 checkbox = new wxCheckBox(this,-1,wxString(_T("Show Actor")));
80 Connect(checkbox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onCheckBoxChange);
81 checkbox->SetValue(true);
82 checkboxsizer->Add(checkbox,1, wxGROW);
85 if(wxMaracasSurfaceRendering::getInstance()->interactorSet()){
86 checkboxsurface = new wxCheckBox(this,-1,wxString(_T("Surface Box")));
87 Connect(checkboxsurface->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onCheckBoxSurfaceChange);
88 checkboxsurface->SetValue(true);
89 checkboxsizer->Add(checkboxsurface,1, wxGROW);
93 sizersurfprop->Add(checkboxsizer,1, wxGROW);
96 //this->addControl(checkbox);
97 wxFlexGridSizer* sizerbut = new wxFlexGridSizer(3);
99 wxBitmap bitmap(Color_xpm);
100 _colorchoose = new wxBitmapButton(this, -1, bitmap,wxDefaultPosition,wxSize(30,30));
101 Connect(_colorchoose->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onColorChange);
102 sizerbut->Add(_colorchoose,1, wxGROW);
105 wxBitmap bitmap1(Add_xpm);
106 _viewimage = new wxBitmapButton(this, -1, bitmap1, wxDefaultPosition, wxSize(30,30));
107 Connect(_viewimage->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onViewImage);
108 sizerbut->Add(_viewimage,wxFIXED_MINSIZE);
110 sizersurfprop->Add(sizerbut,1, wxGROW);
111 //sizercolor->Add(checkbox,wxFIXED_MINSIZE);
112 //sizercolor->Add(_colorchoose,wxFIXED_MINSIZE);
113 //this->addControl(sizercolor);
115 wxStaticText* label = new wxStaticText(this, -1, wxString(_T("Opacity")));
116 opacity = new wxSlider(this, -1,100,0,100,wxDefaultPosition,wxDefaultSize,wxSL_HORIZONTAL|wxSL_LABELS);
117 Connect(opacity->GetId(), wxEVT_SCROLL_CHANGED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onOpacityRelease);
118 wxFlexGridSizer* sizeropacity = new wxFlexGridSizer(1,1,1);
119 sizeropacity->Add(label,1, wxGROW);
120 sizeropacity->Add(opacity,1, wxGROW);
122 sizersurfprop->Add(sizeropacity,1, wxGROW);
124 this->addControl(sizersurfprop);
129 ** Method called by setting on or off the actor
131 void wxMaracasSurfaceRenderingProp3D::onCheckBoxChange(wxCommandEvent& event){
133 wxMaracasSurfaceRendering::getInstance()->addRemoveActor(this->getPropId(), checkbox->GetValue());
135 void wxMaracasSurfaceRenderingProp3D::onCheckBoxSurfaceChange(wxCommandEvent& event){
137 wxMaracasSurfaceRendering::getInstance()->addRemoveSurfaceBox(this->getPropId(), checkboxsurface->GetValue());
143 void wxMaracasSurfaceRenderingProp3D::onColorChange(wxCommandEvent& event){
144 wxColourDialog* colourdiag = new wxColourDialog(this);
145 if(colourdiag->ShowModal()==wxID_OK){
146 wxColour colour = colourdiag->GetColourData().GetColour();
147 _colorchoose->SetBackgroundColour(colour);
149 double r = (double)(colour.Red())/255.0;
150 double g = (double)(colour.Green())/255.0;
151 double b = (double)(colour.Blue())/255.0;
153 if(this->isComplex()){
154 if(this->getPanId() == 1)
155 ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeColorA(this->getPropId(), r, g, b);
156 if(this->getPanId() == 2)
157 ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeColorB(this->getPropId(), r, g, b);
158 if(this->getPanId() == 3)
159 ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeColorC(this->getPropId(), r, g, b);
162 wxMaracasSurfaceRendering::getInstance()->changeColor(this->getPropId(),r,g,b);
166 /*void wxMaracasSurfaceRenderingProp3D::onActionButtonPressedEliminate( wxCommandEvent& event ){
171 ** Changes the opacity of an actor
173 void wxMaracasSurfaceRenderingProp3D::onOpacityRelease(wxScrollEvent& event ){
175 if(this->isComplex()){
176 if(this->getPanId() == 1)
177 ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeOpacityA(this->getPropId(),opacity->GetValue());
178 if(this->getPanId() == 2)
179 ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeOpacityB(this->getPropId(),opacity->GetValue());
180 if(this->getPanId() == 3)
181 ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeOpacityC(this->getPropId(),opacity->GetValue());
184 wxMaracasSurfaceRendering::getInstance()->changeOpacity(this->getPropId(),opacity->GetValue());
188 /**Carolina Perez: Method recently added. Not functionalit yet
189 ** Loads the volume in a separate window
191 void wxMaracasSurfaceRenderingProp3D::onViewImage(wxCommandEvent& event){
193 if(this->isComplexBox){
194 if(this->getPanId() == 1)
195 img = (wxMaracasRendererView::getInstance())->getTabbedPanel(_propid)->getSurfAImage();
196 if(this->getPanId() == 2)
197 img = (wxMaracasRendererView::getInstance())->getTabbedPanel(_propid)->getSurfBImage();
198 if(this->getPanId() == 3)
199 img = (wxMaracasRendererView::getInstance())->getTabbedPanel(_propid)->getSurfCImage();
201 std::vector<int> type;
204 wxMaracasDialog_NViewers* dialog1 = new wxMaracasDialog_NViewers(this, img, &type, wxString(_T("Volume Visualization") ));
205 dialog1->SetSize(730, 700);
209 //vtkImageData* img = wxMaracasMultipleVolumeRendererView::getInstance()->getVolImage();