]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasRenderTabbedPanel.cpp
#3474 Refresh optimization DrawAxisTree3D Box
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxMaracasRenderTabbedPanel.cpp
index 414d660457c238c15199755903562a620d53f2c9..4cf5975c072369e3069f6a248f5b02da903b7e88 100644 (file)
@@ -1,33 +1,64 @@
+/*# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+#                        pour la Sant�)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+#  This software is governed by the CeCILL-B license under French law and
+#  abiding by the rules of distribution of free software. You can  use,
+#  modify and/ or redistribute the software under the terms of the CeCILL-B
+#  license as circulated by CEA, CNRS and INRIA at the following URL
+#  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+#  or in the file LICENSE.txt.
+#
+#  As a counterpart to the access to the source code and  rights to copy,
+#  modify and redistribute granted by the license, users are provided only
+#  with a limited warranty  and the software's author,  the holder of the
+#  economic rights,  and the successive licensors  have only  limited
+#  liability.
+#
+#  The fact that you are presently reading this means that you have had
+#  knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------ */
+
 #include "wxMaracasRenderTabbedPanel.h"
-#include "HistogramDialogComboBox.h"
 
+#include "HistogramDialogComboBox.h"
 #include "wxMaracasMultipleVolumeRendererPanel.h"
 #include "wxMaracasSurfaceRenderingPanel.h"
 #include "wxMaracasSurfaceRenderingProp3DMHD.h"
-#include "wxMaracasMultipleVolumeRendererManagerData.h"
+#include "volumerenderermanagerdata.h"
 #include "wxMaracasDialog_NViewers.h"
+#include "wxVtkMPR3DViewCntrlPanel.h"
 
 #include <wx/colordlg.h>
 #include <wx/button.h> 
-
+#include <vtkProp3D.h>
 #include <OpenImage.xpm>
+
 #include "Color.xpm"
-#include "creaSystem.h"
+//#include "creaSystem.h"
 
-#include <vtkProp3D.h>
-#include "wxVtkMPR3DViewCntrlPanel.h"
+#include "creaWx.h"
+
+       BEGIN_EVENT_TABLE( wxMaracasRenderTabbedPanel, wxPanel )
+               EVT_MENU( 12121, wxMaracasRenderTabbedPanel::OnRefreshView )
+               //EVT_MENU( 12122, wxMaracasRenderTabbedPanel::OnDClickLeft  )
+       END_EVENT_TABLE( );
 
 /**
 ** Class constructor
 **/
 wxMaracasRenderTabbedPanel::wxMaracasRenderTabbedPanel(wxWindow* parent, int id, wxVtk3DBaseView* _baseView)
-: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize)
+  : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize)
 {
        _id = id;
        baseView = _baseView;
        dialog = NULL;
 
-       volmanager = new wxMaracasMultipleVolumeRendererManager();
+        volmanager =      new VolumeRendererManager();
        surrendmanager1 = new wxMaracasSurfaceRenderingManager();
        surrendmanager2 = new wxMaracasSurfaceRenderingManager();
        surrendmanager3 = new wxMaracasSurfaceRenderingManager();
@@ -42,9 +73,13 @@ wxMaracasRenderTabbedPanel::~wxMaracasRenderTabbedPanel()
        //wxMaracasRenderTabbedPanel::getInstance()->addRemoveActorSA(_propid, false);
        //wxMaracasRenderTabbedPanel::getInstance()->addRemoveActorSB(_propid, false);
        //wxMaracasRenderTabbedPanel::getInstance()->addRemoveActorSC(_propid, false);
+       addRemoveActorMPR(false);
+       if( vtkmpr3Ddataviewer  )   { delete vtkmpr3Ddataviewer; }
+       if( mwxvtkmpr3Dview     )   { delete mwxvtkmpr3Dview;    }
+
        this->deleteVolume(_id);
        delete dialog;
-       delete wxtabs;  
+       delete wxtabs;
 }
 
 /**
@@ -57,17 +92,17 @@ void wxMaracasRenderTabbedPanel::createControls(vtkImageData* inImg, std::string
        wxFlexGridSizer* sizercheck = new wxFlexGridSizer(3);
        checkboxVol = new  wxCheckBox(this,-1,wxString(_T("Volume Rendering")));
        Connect(checkboxVol->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasRenderTabbedPanel::onCheckBoxVChange);   
-       checkboxVol->SetValue(true);    
+       checkboxVol->SetValue(false);   
        sizercheck->Add(checkboxVol, wxFIXED_MINSIZE);
 
        checkboxSA = new  wxCheckBox(this,-1,wxString(_T("Surface Rendering A")));
        Connect(checkboxSA->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasRenderTabbedPanel::onCheckBoxSAChange);   
-       checkboxSA->SetValue(true);     
+       checkboxSA->SetValue(false);    
        sizercheck->Add(checkboxSA, wxFIXED_MINSIZE);   
 
        checkboxViewer = new  wxCheckBox(this,-1,wxString(_T("MPR")));
        Connect(checkboxViewer->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasRenderTabbedPanel::onMPROptions);     
-       checkboxViewer->SetValue(false);
+       checkboxViewer->SetValue(true);
        sizercheck->Add(checkboxViewer, wxFIXED_MINSIZE);
 
        checkboxSB = new  wxCheckBox(this,-1,wxString(_T("Surface Rendering B")));
@@ -101,12 +136,12 @@ void wxMaracasRenderTabbedPanel::createControls(vtkImageData* inImg, std::string
                //vtkImageData* img3 = surrendmanager3->getImageData(pathfile);
                if(img!=NULL /*&& img1!=NULL && img2!=NULL && img3!=NULL*/)
                {
-                       addVolume(img, filename);
+                       addVolume(img,   filename);
                        addSurface1(img, filename);
                        addSurface2(img, filename);
                        addSurface3(img, filename);     
                        addMPROptions();
-                       volname = (wxString) filename;
+                       volname = crea::std2wx(filename);
                        wxtabs->Refresh();
                }
        }       
@@ -150,6 +185,9 @@ void wxMaracasRenderTabbedPanel::addVolume(vtkImageData* img, std::string datana
                        wxMaracasMultipleVolumeRendererPanel* controlpanV = new wxMaracasMultipleVolumeRendererPanel(wxtabs, _propidV, img, true);
                        wxtabs->AddPage(controlpanV, _T("Vol Rendering"), true);
                        controlpanV->updateVolume();
+                       wxtabs->GetPage(0)->Disable();
+
+                       volmanager->addRemoveActor(this->getPropIdV(), checkboxSC->GetValue());
                }
        }
        catch(char* str)
@@ -176,6 +214,9 @@ void wxMaracasRenderTabbedPanel::addSurface1(vtkImageData* img, std::string data
                        int maxiso = surrendmanager1->getMaxIsoValue(_propidSA);
                        ((wxMaracasSurfaceRenderingProp3DMHD*)controlpanSA)->createControls(maxiso);
                        wxtabs->AddPage(controlpanSA, _T("SR A"));
+                       wxtabs->GetPage(1)->Disable();
+
+                       surrendmanager1->addRemoveActor(this->getPropIdV(), checkboxSC->GetValue());
                }
        }
        catch(char* str)
@@ -203,6 +244,8 @@ void wxMaracasRenderTabbedPanel::addSurface2(vtkImageData* img, std::string data
                        wxtabs->AddPage(controlpanSB, _T("SR B"));
                        wxtabs->GetPage(2)->Disable();
 
+                       surrendmanager2->addRemoveActor(this->getPropIdV(), checkboxSC->GetValue());
+
                }
        }
        catch(char* str)
@@ -230,6 +273,8 @@ void wxMaracasRenderTabbedPanel::addSurface3(vtkImageData* img, std::string data
                        ((wxMaracasSurfaceRenderingProp3DMHD*)controlpanSC)->createControls(maxiso);
                        wxtabs->AddPage(controlpanSC, _T("SR C"));
                        wxtabs->GetPage(3)->Disable();
+
+                       surrendmanager3->addRemoveActor(this->getPropIdV(), checkboxSC->GetValue());
                }
        }
        catch(char* str)
@@ -246,6 +291,27 @@ void wxMaracasRenderTabbedPanel::addSurface3(vtkImageData* img, std::string data
 **/
 void wxMaracasRenderTabbedPanel::addMPROptions()
 {
+       //Panel Construction
+       vtkMPRBaseData* mvtkmprbasedata = new vtkMPRBaseData(); 
+       marImageData*   marimagedata    = new marImageData( getVolImage() );                    
+       mvtkmprbasedata                                 ->SetMarImageData(marimagedata);
+       
+       mwxvtkmpr3Dview                                 = new wxVtkMPR3DView( baseView );
+
+       vtkmpr3Ddataviewer                              = new vtkMPR3DDataViewer();     
+
+       wxPanel                 *panelControl   = new wxPanel(wxtabs,-1);       
+       controlPanelMPR3D                               = mwxvtkmpr3Dview->CreateControlPanel(panelControl, true);
+
+       wxFlexGridSizer *sizerCtrol             = new wxFlexGridSizer(1);
+       sizerCtrol                                              ->Add(controlPanelMPR3D, 1, wxALL|wxEXPAND, 2);
+
+       panelControl->SetAutoLayout(true);
+       panelControl->SetSizer(sizerCtrol);
+       panelControl->SetSize(400,350);
+       panelControl->Layout();
+
+       //Configure MPR
        int x = 0,y = 0,z = 0;
        int ext[6];
        ext[0] = 0;
@@ -263,26 +329,6 @@ void wxMaracasRenderTabbedPanel::addMPROptions()
        spc[1] = 0;
        spc[2] = 0;
 
-       vtkMPRBaseData* mvtkmprbasedata = new vtkMPRBaseData(); 
-       marImageData* marimagedata              = new marImageData( getVolImage() );                    
-       mvtkmprbasedata->SetMarImageData(marimagedata);
-       
-       mwxvtkmpr3Dview                                 = new wxVtkMPR3DView( baseView );
-
-       vtkmpr3Ddataviewer                              = new vtkMPR3DDataViewer();     
-
-       wxPanel         *panelControl           = new wxPanel(wxtabs,-1);       
-       controlPanelMPR3D                               = mwxvtkmpr3Dview->CreateControlPanel(panelControl, true);
-
-       wxFlexGridSizer  *sizerCtrol    = new wxFlexGridSizer(1);
-       sizerCtrol->Add(controlPanelMPR3D, 1, wxALL|wxEXPAND, 2);
-
-       panelControl->SetAutoLayout(true);
-       panelControl->SetSizer(sizerCtrol);
-       panelControl->SetSize(400,350);
-       panelControl->Layout();
-
-
        if (mvtkmprbasedata!=NULL)
        {
                mvtkmprbasedata->Configure();
@@ -313,7 +359,9 @@ void wxMaracasRenderTabbedPanel::addMPROptions()
        }
 
        if (baseView!=NULL)     
+       {
                baseView                        ->Configure();  
+       }
 
        if (vtkmpr3Ddataviewer  !=NULL) 
        {
@@ -324,12 +372,20 @@ void wxMaracasRenderTabbedPanel::addMPROptions()
        { 
                mwxvtkmpr3Dview         ->SetVtkMPR3DDataViewer(vtkmpr3Ddataviewer);            
                mwxvtkmpr3Dview         ->Configure();
-               mwxvtkmpr3Dview         ->ResetCamera(ext,org,spc);
+//EED 27/05/2013
+               mwxvtkmpr3Dview         ->GetWxvtk3Dbaseview()->ResetCamera(ext ,spc);
+               vtkInteractorStyleBaseView* vtkInteractorBV = (vtkInteractorStyleBaseView*)mwxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetInteractorStyleBaseView();
+               vtkInteractorBV->AddParentToReport(this);
        }
 
+       int id = 4;
        wxtabs->AddPage(panelControl, _T("MPR"));
-       wxtabs->GetPage(4)->Disable();
-       mwxvtkmpr3Dview->showOutlineActor(false);
+       wxtabs->GetPage(id)->Enable();
+       wxtabs->SetSelection(id);
+
+       ((wxVtkMPR3DViewCntrlPanel*)controlPanelMPR3D)->SetVisibleZ(true);
+       ((wxVtkMPR3DViewCntrlPanel*)controlPanelMPR3D)->SetVisibleXYZ(true);
+       mwxvtkmpr3Dview->showOutlineBoxActor(true);
        mwxvtkmpr3Dview->Refresh();
                        
 }
@@ -418,7 +474,45 @@ void wxMaracasRenderTabbedPanel::addRemoveActorSC(int id, bool addremove)
                diag->ShowModal();
                delete diag;
        }
-}      
+}
+
+void wxMaracasRenderTabbedPanel::addRemoveActorMPR(bool addremove)
+{
+       int id = 4;
+       wxtabs->SetSelection(id);
+       if(addremove)
+       {
+               wxtabs->GetPage(id)->Enable();
+               bool valueX = ((wxVtkMPR3DViewCntrlPanel*) controlPanelMPR3D)->GetVisibleX();
+               bool valueY = ((wxVtkMPR3DViewCntrlPanel*) controlPanelMPR3D)->GetVisibleY();
+               bool valueZ = ((wxVtkMPR3DViewCntrlPanel*) controlPanelMPR3D)->GetVisibleZ();
+               bool valueXYZ = ((wxVtkMPR3DViewCntrlPanel*) controlPanelMPR3D)->GetVisibleXYZ();
+               bool valuePlane = ((wxVtkMPR3DViewCntrlPanel*) controlPanelMPR3D)->GetVisiblePlane();
+               mwxvtkmpr3Dview->VisibleImageActor( 0, valueX );
+               mwxvtkmpr3Dview->VisibleImageActor( 1, valueY );
+               mwxvtkmpr3Dview->VisibleImageActor( 2, valueZ );
+               mwxvtkmpr3Dview->VisiblePointWidget(valueXYZ);
+               mwxvtkmpr3Dview->VisiblePlaneWidget(valuePlane);
+               mwxvtkmpr3Dview->showOutlineBoxActor(true);
+               mwxvtkmpr3Dview->Refresh();
+       } else {
+               wxtabs->GetPage(id)->Disable();
+               mwxvtkmpr3Dview->VisiblePointWidget(false);
+               mwxvtkmpr3Dview->VisiblePlaneWidget(false);
+               mwxvtkmpr3Dview->VisibleImageActor(0, false );
+               mwxvtkmpr3Dview->VisibleImageActor(1, false );
+               mwxvtkmpr3Dview->VisibleImageActor(2, false );
+               mwxvtkmpr3Dview->showOutlineBoxActor(false);
+               mwxvtkmpr3Dview->Refresh();
+               wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
+               mwxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
+#else
+               mwxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessWindowEvent(newevent1);
+#endif
+       } // if
+}
 
 
 /**
@@ -444,7 +538,6 @@ void wxMaracasRenderTabbedPanel::SetValuesPointsFunction(int volid, std::vector<
                diag->ShowModal();
                delete diag;
        }
-       
 }
 
 /**
@@ -636,11 +729,9 @@ void wxMaracasRenderTabbedPanel::onCheckBoxSBChange(wxCommandEvent& event)
                if(checkboxSB->GetValue())
                {
                        wxtabs->GetPage(id)->Enable();
-               }
-               else
-               {       
+               } else {        
                        wxtabs->GetPage(id)->Disable();
-               }
+               } // if checkboxSB
        }
        catch(char* str){
                std::cout << "Exception : " << str << '\n';
@@ -683,30 +774,38 @@ void wxMaracasRenderTabbedPanel::onCheckBoxSCChange(wxCommandEvent& event)
 **/
 void wxMaracasRenderTabbedPanel::onMPROptions(wxCommandEvent& event)
 {
+       addRemoveActorMPR(checkboxViewer->IsChecked());
+       /*
        int id = 4;
        wxtabs->SetSelection(id);
        if(checkboxViewer->IsChecked())
        {
+               
                wxtabs->GetPage(id)->Enable();
 
                bool valueX = ((wxVtkMPR3DViewCntrlPanel*) controlPanelMPR3D)->GetVisibleX();
                bool valueY = ((wxVtkMPR3DViewCntrlPanel*) controlPanelMPR3D)->GetVisibleY();
                bool valueZ = ((wxVtkMPR3DViewCntrlPanel*) controlPanelMPR3D)->GetVisibleZ();
+               bool valueXYZ = ((wxVtkMPR3DViewCntrlPanel*) controlPanelMPR3D)->GetVisibleXYZ();
+               bool valuePlane = ((wxVtkMPR3DViewCntrlPanel*) controlPanelMPR3D)->GetVisiblePlane();
 
                mwxvtkmpr3Dview->VisibleImageActor( 0, valueX );
                mwxvtkmpr3Dview->VisibleImageActor( 1, valueY );
                mwxvtkmpr3Dview->VisibleImageActor( 2, valueZ );
+               mwxvtkmpr3Dview->VisiblePointWidget(valueXYZ);
+               mwxvtkmpr3Dview->VisiblePlaneWidget(valuePlane);
                mwxvtkmpr3Dview->showOutlineActor(true);
+               
                mwxvtkmpr3Dview->Refresh();
 
-               wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
-               mwxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
 
        }
        else
        {
                wxtabs->GetPage(id)->Disable();
 
+               mwxvtkmpr3Dview->VisiblePointWidget(false);
+               mwxvtkmpr3Dview->VisiblePlaneWidget(false);
                mwxvtkmpr3Dview->VisibleImageActor(0, false );
                mwxvtkmpr3Dview->VisibleImageActor(1, false );
                mwxvtkmpr3Dview->VisibleImageActor(2, false );
@@ -715,7 +814,21 @@ void wxMaracasRenderTabbedPanel::onMPROptions(wxCommandEvent& event)
 
                wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
                mwxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
-       }
+       }*/
+}
+
+
+void wxMaracasRenderTabbedPanel::OnRefreshView(wxCommandEvent & event) 
+{
+       printf("CPR wxMaracasRenderTabbedPanel::OnRefreshView \n");
+       mwxvtkmpr3Dview->RefreshView();
+       wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
+       mwxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
+#else
+       mwxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessWindowEvent(newevent1);
+#endif
 }
 
 /**
@@ -725,7 +838,7 @@ void wxMaracasRenderTabbedPanel::onOpenParameters(wxCommandEvent& event){
        if(dialog == NULL)
        {
                dialog = new wxMaracasRenderImageManagementPanel(this, volmanager, surrendmanager1, surrendmanager2, surrendmanager3, volname, _id);
-               dialog->SetSize(400, 580);
+               dialog->SetSize(460, 580);
                dialog->Show();
        }
        else if(dialog != NULL)
@@ -742,16 +855,19 @@ void wxMaracasRenderTabbedPanel::onOpenCutter(wxCommandEvent& event)
        vtkImageData* img = getVolImage();      
        std::vector<int> type;
        type.push_back(5);
-       type.push_back(0);
        type.push_back(1);
-       type.push_back(3);
+       type.push_back(2);
+       type.push_back(0);
        
        wxMaracasDialog_NViewers* dialog1 = new wxMaracasDialog_NViewers(this, img, &type, wxString(_T("Cut Module") ));
        //dialog1->SetSize(800, 700);
        
-       std::string path = crea::System::GetDllAppPath("bbcreaMaracasVisu.dll");
-       //cutter = new CutModel2MainPanel(dialog1, path);
-       
+       /**std::string path = crea::System::GetDllAppPath("bbcreaMaracasVisu.dll");
+       cutter = CutModelMainPanel::getInstance(dialog1->getinternalPanel(), path);
+       cutter->setRenderer( dialog1->getViewer()->GetwxVtkBaseView(1)->GetRenderer() );
+       cutter->setInteractor( dialog1->getViewer()->GetwxVtkBaseView(1)->GetWxVTKRenderWindowInteractor() );
+       cutter->setImageData(getVolImage());
+       **/
        //dialog1->AddPanel(cutter);
        dialog1->Show();
 }
@@ -807,4 +923,4 @@ vtkImageData* wxMaracasRenderTabbedPanel::getSurfCImage()
 int wxMaracasRenderTabbedPanel::getPropIdV()
 {
        return _id;
-}
\ No newline at end of file
+}