1 #include "wxMaracasSurfaceRenderingProp3D.h"
3 #include <wx/colordlg.h>
4 #include "wxMaracasSurfaceRendering.h"
5 #include "wxMaracasRendererView.h"
7 #include "vtkImageData.h"
9 #include <OpenImage.xpm>
14 ** Implementation of viewProp3D
16 wxMaracasSurfaceRenderingProp3D::wxMaracasSurfaceRenderingProp3D(wxWindow* parent, int propid, bool _isComplexBox, int _panID)
17 :wxMaracasSurfaceRenderingPanel(parent, propid, _isComplexBox, _panID){
24 wxMaracasSurfaceRenderingProp3D::~wxMaracasSurfaceRenderingProp3D(){
25 //wxMaracasSurfaceRendering::getInstance()->addRemoveActor(_propid, false);
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);
36 //wxMaracasSurfaceRendering::getInstance()->deleteActor(_propid);
40 ** Constructs the panel. Elements inside may change depending on which tipe of panel construction if being requested
42 void wxMaracasSurfaceRenderingProp3D::createControls(){
44 wxFlexGridSizer* sizersurfprop = new wxFlexGridSizer(1);
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);
55 sizersurfprop->Add(checkbox,wxFIXED_MINSIZE);
58 //this->addControl(checkbox);
59 wxFlexGridSizer* sizerbut = new wxFlexGridSizer(3);
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);
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);
71 sizersurfprop->Add(sizerbut,wxFIXED_MINSIZE);
72 //sizercolor->Add(checkbox,wxFIXED_MINSIZE);
73 //sizercolor->Add(_colorchoose,wxFIXED_MINSIZE);
74 //this->addControl(sizercolor);
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);
83 sizersurfprop->Add(sizeropacity,wxFIXED_MINSIZE);
85 this->addControl(sizersurfprop);
90 ** Method called by setting on or off the actor
92 void wxMaracasSurfaceRenderingProp3D::onCheckBoxChange(wxCommandEvent& event){
94 wxMaracasSurfaceRendering::getInstance()->addRemoveActor(this->getPropId(), checkbox->GetValue());
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);
106 double r = (double)(colour.Red())/255.0;
107 double g = (double)(colour.Green())/255.0;
108 double b = (double)(colour.Blue())/255.0;
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);
119 wxMaracasSurfaceRendering::getInstance()->changeColor(this->getPropId(),r,g,b);
123 /*void wxMaracasSurfaceRenderingProp3D::onActionButtonPressedEliminate( wxCommandEvent& event ){
128 ** Changes the opacity of an actor
130 void wxMaracasSurfaceRenderingProp3D::onOpacityRelease(wxScrollEvent& event ){
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());
141 wxMaracasSurfaceRendering::getInstance()->changeOpacity(this->getPropId(),opacity->GetValue());
145 /**Carolina Perez: Method recently added. Not functionalit yet
146 ** Loads the volume in a separate window
148 void wxMaracasSurfaceRenderingProp3D::onViewImage(wxCommandEvent& event){
149 printf("wxMaracasSurfaceRenderingProp3D->onViewImage: Test View Image");
150 vtkImageData* image = ((wxMaracasRendererView::getInstance())->getTabbedPanel(this->_propid))->getVolImage(this->_propid);