]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasSurfaceRenderingProp3D.cxx
Diego Caceres: Changes in CMakeLists.txt.
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxMaracasSurfaceRenderingProp3D.cxx
index 6639e8532b5e884fe3c5142b6e9098153a28605b..8b8cf8b97f0e5237f3380f88a7913cf93c170a39 100644 (file)
 #include "wxMaracasSurfaceRenderingProp3D.h"
+#include "wxMaracasDialog_NViewers.h"
 
 #include <wx/colordlg.h>
 #include "wxMaracasSurfaceRendering.h"
+#include "wxMaracasRendererView.h"
+
+#include "vtkImageData.h"
+
 #include <OpenImage.xpm>
+#include <Add.xpm>
 #include "Color.xpm"
+
 /**
 **     Implementation of viewProp3D
 **/
-
-wxMaracasSurfaceRenderingProp3D::wxMaracasSurfaceRenderingProp3D(wxWindow* parent,int propid)
-:wxMaracasSurfaceRenderingPanel(parent, propid){
+wxMaracasSurfaceRenderingProp3D::wxMaracasSurfaceRenderingProp3D(wxWindow* parent, int propid, bool _isComplexBox, int _panID)
+:wxMaracasSurfaceRenderingPanel(parent, propid, _isComplexBox, _panID){
        createControls();       
 }
 
+/**
+** Panel Destructor
+**/ 
 wxMaracasSurfaceRenderingProp3D::~wxMaracasSurfaceRenderingProp3D(){   
        //wxMaracasSurfaceRendering::getInstance()->addRemoveActor(_propid, false);
-       wxMaracasSurfaceRendering::getInstance()->deleteActor(_propid);
+       if(this->isComplex())
+       {       
+               //if(this->getPanId() == 1)
+               //      ((wxMaracasRenderTabbedPanel*)(wxMaracasRendererView::getInstance())->getTabbedPanel())->addRemoveActorSA(_propid, false);
+               //if(this->getPanId() == 2)
+               //      ((wxMaracasRenderTabbedPanel*)(wxMaracasRendererView::getInstance())->getTabbedPanel())->addRemoveActorSB(_propid, false);
+               //if(this->getPanId() == 3)
+               //      ((wxMaracasRenderTabbedPanel*)(wxMaracasRendererView::getInstance())->getTabbedPanel())->addRemoveActorSC(_propid, false);
+       }
+       //else
+               //wxMaracasSurfaceRendering::getInstance()->deleteActor(_propid);
 }
 
+/**
+** Constructs the panel. Elements inside may change depending on which tipe of panel construction if being requested
+**/
 void wxMaracasSurfaceRenderingProp3D::createControls(){
 
-       wxFlexGridSizer* sizersurfprop = new wxFlexGridSizer(1,1,1);
+       wxFlexGridSizer* sizersurfprop = new wxFlexGridSizer(1);
        
-       wxString choices[2];
-       choices[0] = wxString(_T("On"));
-       choices[1] = wxString(_T("Off"));
-       checkbox = new  wxCheckBox(this,-1,wxString(_T("Show Actor")));
-       Connect(checkbox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onCheckBoxChange);  
-       checkbox->SetValue(true);       
+       if(!isComplexBox) 
+       {
+               //wxString choices[2];
+               //choices[0] = wxString(_T("On"));
+               //choices[1] = wxString(_T("Off"));
+               wxFlexGridSizer* checkboxsizer = new wxFlexGridSizer(2);
+
+               checkbox = new  wxCheckBox(this,-1,wxString(_T("Show Actor")));
+               Connect(checkbox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onCheckBoxChange);  
+               checkbox->SetValue(true);       
+               checkboxsizer->Add(checkbox,1, wxGROW);
+
 
-       sizersurfprop->Add(checkbox,wxFIXED_MINSIZE);
+               if(wxMaracasSurfaceRendering::getInstance()->interactorSet()){
+                       checkboxsurface = new  wxCheckBox(this,-1,wxString(_T("Surface Box")));
+                       Connect(checkboxsurface->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onCheckBoxSurfaceChange);    
+                       checkboxsurface->SetValue(true);
+                       checkboxsizer->Add(checkboxsurface,1, wxGROW);
+               }       
+
+
+               sizersurfprop->Add(checkboxsizer,1, wxGROW);
+       }
 
        //this->addControl(checkbox);   
-       
+       wxFlexGridSizer* sizerbut = new wxFlexGridSizer(3);
+
        wxBitmap bitmap(Color_xpm);
        _colorchoose = new wxBitmapButton(this, -1, bitmap,wxDefaultPosition,wxSize(30,30));    
        Connect(_colorchoose->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onColorChange);                   
-       sizersurfprop->Add(_colorchoose,wxFIXED_MINSIZE);       
+       sizerbut->Add(_colorchoose,1, wxGROW);
 
+       /*
+       wxBitmap bitmap1(Add_xpm);
+       _viewimage = new wxBitmapButton(this, -1, bitmap1, wxDefaultPosition, wxSize(30,30));   
+       Connect(_viewimage->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onViewImage);                       
+       sizerbut->Add(_viewimage,wxFIXED_MINSIZE);
+       */
+       sizersurfprop->Add(sizerbut,1, wxGROW);
        //sizercolor->Add(checkbox,wxFIXED_MINSIZE);
        //sizercolor->Add(_colorchoose,wxFIXED_MINSIZE);
        //this->addControl(sizercolor);
-       
-       
+
        wxStaticText* label = new wxStaticText(this, -1, wxString(_T("Opacity")));              
        opacity = new wxSlider(this, -1,100,0,100,wxDefaultPosition,wxDefaultSize,wxSL_HORIZONTAL|wxSL_LABELS); 
        Connect(opacity->GetId(), wxEVT_SCROLL_CHANGED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onOpacityRelease);     
        wxFlexGridSizer* sizeropacity = new wxFlexGridSizer(1,1,1);     
-       sizeropacity->Add(label,wxFIXED_MINSIZE);
-       sizeropacity->Add(opacity,wxFIXED_MINSIZE);
+       sizeropacity->Add(label,1, wxGROW);
+       sizeropacity->Add(opacity,1, wxGROW);
 
-       sizersurfprop->Add(sizeropacity,wxFIXED_MINSIZE);
+       sizersurfprop->Add(sizeropacity,1, wxGROW);
 
-       /**wxBitmap bitmap1(OpenImage_xpm);
-       _viewimage = new wxBitmapButton(this, -1, bitmap1, wxDefaultPosition, wxSize(30,30));   
-       Connect(_viewimage->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onViewImage);                       
-       sizersurfprop->Add(_viewimage,wxFIXED_MINSIZE); */
-       
-       //this->addControl(sizeropacity);
        this->addControl(sizersurfprop);
        
 }
+
+/**
+** Method called by setting on or off the actor
+**/
 void wxMaracasSurfaceRenderingProp3D::onCheckBoxChange(wxCommandEvent& event){ 
-       wxMaracasSurfaceRendering::getInstance()->addRemoveActor(this->getPropId(), checkbox->GetValue());
+       //if(!isComplexBox)
+       wxMaracasSurfaceRendering::getInstance()->addRemoveActor(this->getPropId(), checkbox->GetValue());      
+}
+void wxMaracasSurfaceRenderingProp3D::onCheckBoxSurfaceChange(wxCommandEvent& event){  
+       //if(!isComplexBox)
+       wxMaracasSurfaceRendering::getInstance()->addRemoveSurfaceBox(this->getPropId(), checkboxsurface->GetValue());  
 }
+
+/**
+** 
+**/
 void wxMaracasSurfaceRenderingProp3D::onColorChange(wxCommandEvent& event){
        wxColourDialog* colourdiag = new wxColourDialog(this);
        if(colourdiag->ShowModal()==wxID_OK){
@@ -74,7 +125,16 @@ void wxMaracasSurfaceRenderingProp3D::onColorChange(wxCommandEvent& event){
                double g = (double)(colour.Green())/255.0;
                double b = (double)(colour.Blue())/255.0;
                
-               wxMaracasSurfaceRendering::getInstance()->changeColor(this->getPropId(),r,g,b);
+               if(this->isComplex()){
+                       if(this->getPanId() == 1)
+                               ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeColorA(this->getPropId(), r, g, b);
+                       if(this->getPanId() == 2)
+                               ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeColorB(this->getPropId(), r, g, b);
+                       if(this->getPanId() == 3)
+                               ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeColorC(this->getPropId(), r, g, b);
+               }
+               else
+                       wxMaracasSurfaceRendering::getInstance()->changeColor(this->getPropId(),r,g,b);
        }
        delete colourdiag;
 }
@@ -82,17 +142,45 @@ void wxMaracasSurfaceRenderingProp3D::onColorChange(wxCommandEvent& event){
 
 }*/
 
+/**
+** Changes the opacity of an actor
+**/
 void wxMaracasSurfaceRenderingProp3D::onOpacityRelease(wxScrollEvent& event ){
 
-       wxMaracasSurfaceRendering::getInstance()->changeOpacity(this->getPropId(),opacity->GetValue());
+       if(this->isComplex()){
+               if(this->getPanId() == 1)
+                       ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeOpacityA(this->getPropId(),opacity->GetValue());
+               if(this->getPanId() == 2)
+                       ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeOpacityB(this->getPropId(),opacity->GetValue());
+               if(this->getPanId() == 3)
+                       ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeOpacityC(this->getPropId(),opacity->GetValue());
+       }
+       else
+               wxMaracasSurfaceRendering::getInstance()->changeOpacity(this->getPropId(),opacity->GetValue());
 
 }
 
+/**Carolina Perez: Method recently added. Not functionalit yet
+** Loads the volume in a separate window
+**/
 void wxMaracasSurfaceRenderingProp3D::onViewImage(wxCommandEvent& event){      
+       vtkImageData* img;
+       if(this->isComplexBox){
+               if(this->getPanId() == 1)
+                       img = (wxMaracasRendererView::getInstance())->getTabbedPanel(_propid)->getSurfAImage();
+               if(this->getPanId() == 2)
+                       img = (wxMaracasRendererView::getInstance())->getTabbedPanel(_propid)->getSurfBImage();
+               if(this->getPanId() == 3)
+                       img = (wxMaracasRendererView::getInstance())->getTabbedPanel(_propid)->getSurfCImage();
+               
+               std::vector<int> type;
+               type.push_back(6);
 
-       //if(mwxwidget->ShowModal()==wxID_OK){
-    
-       //      mwxwidget->Show(false);
-       //}     
-}
-
+               wxMaracasDialog_NViewers* dialog1 = new wxMaracasDialog_NViewers(this, img, &type, wxString(_T("Volume Visualization") ));
+               dialog1->SetSize(730, 700);
+               dialog1->Show();
+       }
+       else{   
+               //vtkImageData* img = wxMaracasMultipleVolumeRendererView::getInstance()->getVolImage();
+       }
+}
\ No newline at end of file