]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DViewCntrlPanel.cxx
#3418 creaMaracasVisu Feature New Normal - ManualPaint_model with openmp
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxVtkClipping3DViewCntrlPanel.cxx
index a8d15449e9a2b0b42b6e9a7cd1dba7f536e66941..2a587c97f4ad6a713d9dee8102c75dc349817d62 100644 (file)
@@ -1,3 +1,28 @@
+/*# ---------------------------------------------------------------------
+#
+# 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 "wxVtkClipping3DViewCntrlPanel.h"
 #include "wx/colordlg.h"
@@ -23,7 +48,6 @@ wxVtkClipping3DViewCntrlPanel::wxVtkClipping3DViewCntrlPanel(wxWindow *parent, w
                                        _surfC                  = new wxRadioButton(panel,-1,_T("C"));
                                        _surfD                  = new wxRadioButton(panel,-1,_T("D"));
 
-
        //RaC 03-2010 Divides in two panels thje last tab Surface/Volume
        //wxCheckBox            *ckVolum                = new wxCheckBox(panel,-1,_T("Vol"));
        wxCheckBox              *ckBoxSurface   = new wxCheckBox(panel,-1,_T("Surface Box"));
@@ -33,26 +57,30 @@ wxVtkClipping3DViewCntrlPanel::wxVtkClipping3DViewCntrlPanel(wxWindow *parent, w
 
                                        _color                  = new wxButton(panel,-1,_T(""));
                                        _visible                = new wxCheckBox(panel,-1,_T("Vis"));
-                                       _opacity                = new wxSlider(panel,-1,50,0,100, wxDefaultPosition, wxSize(800,40), wxSL_HORIZONTAL | wxSL_LABELS);
+//EED                                  _opacity                = new wxSlider(panel,-1,50,0,100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
+                                       _opacity                = new wxSlider(panel,-1,50,0,100, wxDefaultPosition, wxSize(300,110), wxSL_HORIZONTAL | wxSL_LABELS);
 
        wxStaticText    *isoValueTitle  = new wxStaticText(panel,-1,_T("isoValue"));
-                                       _isoValue               = new wxSlider(panel,-1,2000,110,2000, wxDefaultPosition, wxSize(800,40), wxSL_HORIZONTAL  |  wxSL_AUTOTICKS | wxSL_LABELS);
-
+//EED                                  _isoValue               = new wxSlider(panel,-1,2000,110,2000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL  |  wxSL_AUTOTICKS | wxSL_LABELS);
+                                       _isoValue               = new wxSlider(panel,-1,2000,110,2000, wxDefaultPosition, wxSize(300,110), wxSL_HORIZONTAL  |  wxSL_AUTOTICKS | wxSL_LABELS);
 
                                        _wireFrameRep   = new wxRadioButton(panel,-1,_T("WireFrame"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
                                        _surfaceRep             = new wxRadioButton(panel,-1,_T("Surface"));
 
-
        double range[2];
        vtkImageData *vtkimagedata = wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
        vtkimagedata->GetScalarRange( range );
        _isoValue->SetRange( (int)(range[1]*0.1) , (int)(range[1]) );
        _isoValue->SetValue( (int)(wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIsovalue(0)) );
 
-
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
        _isoValue->SetTickFreq(25,0);
+#else
+       // ..
+#endif
 
-       _isoValueSpin   = new wxSlider(panel , -1,5,1,10,wxDefaultPosition , wxSize(25,45), wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT  );
+       _isoValueSpin   = new wxSlider(panel , -1,5,1,10,wxDefaultPosition , wxDefaultSize, wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT  );
        _isoValueSpin->SetRange(1,8);
        _isoValueSpin->SetValue(5);
        Connect(_isoValueSpin->GetId()  , wxEVT_COMMAND_SLIDER_UPDATED   , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValueSpin );
@@ -157,11 +185,11 @@ wxVtkClipping3DViewCntrlPanel::wxVtkClipping3DViewCntrlPanel(wxWindow *parent, w
 
 
        sizerH1->Add( _surfA                                                                    , 1, wxALL|wxEXPAND, 0);
-       sizerH1->Add( new wxStaticText(panel, -1,_T("  "))                      , 1, wxALL|wxEXPAND, 0);
+       sizerH1->Add( new wxStaticText(panel, -1,_T("  "))              , 1, wxALL|wxEXPAND, 0);
        sizerH1->Add( _surfB                                                                    , 1, wxALL|wxEXPAND, 0);
-       sizerH1->Add( new wxStaticText(panel, -1,_T("  "))                      , 1, wxALL|wxEXPAND, 0);
+       sizerH1->Add( new wxStaticText(panel, -1,_T("  "))              , 1, wxALL|wxEXPAND, 0);
        sizerH1->Add( _surfC                                                                    , 1, wxALL|wxEXPAND, 0);
-       sizerH1->Add( new wxStaticText(panel, -1,_T("  "))                      , 1, wxALL|wxEXPAND, 0);
+       sizerH1->Add( new wxStaticText(panel, -1,_T("  "))              , 1, wxALL|wxEXPAND, 0);
        sizerH1->Add( _surfD                                                                    , 1, wxALL|wxEXPAND, 0);
        sizerH1->Add( new wxStaticText(panel, -1,_T("          "))      , 1, wxALL|wxEXPAND, 0);
        sizerH1->Add( ckBoxSurface                                                              , 1, wxALL|wxEXPAND, 0);
@@ -183,13 +211,17 @@ wxVtkClipping3DViewCntrlPanel::wxVtkClipping3DViewCntrlPanel(wxWindow *parent, w
        sizerH2->Add( _surfaceRep                               , 1,wxSHAPED | wxALIGN_CENTER_VERTICAL , 0);
        sizerH2->Add( new wxStaticText(panel, -1,_T("          "))                      , 1, wxALL|wxEXPAND, 0);
 
-       sizerH2->Add( _opacity                          , 1, wxALL|wxEXPAND, 0);
 
 
        sizerH3->Add( isoValueTitle                     , 1, wxALL|wxEXPAND, 0);
        sizerH3->Add( _isoValueSpin                     , 1, wxALL|wxEXPAND, 0);
        sizerH3->Add( _isoValue                         , 1, wxALL|wxEXPAND, 0);
 
+       sizerH3->Add( new wxStaticText(panel, -1,_T("      "))                  , 1, wxALL|wxEXPAND, 0);
+       sizerH3->Add( new wxStaticText(panel, -1,_T("Opacity:"))                        , 1, wxALL|wxEXPAND, 0);
+       sizerH3->Add( _opacity                          , 1, wxALL|wxEXPAND, 0);
+
+
 /*
        sizerH4->Add( ckBoxX            , 1, wxALL|wxEXPAND, 0);
        sizerH4->Add( text2                     , 1, wxALL|wxEXPAND, 0);
@@ -319,9 +351,14 @@ void wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame(wxCommandEv
                _wxvtkclipping3Dview->Refresh();
 
                wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
                _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
+#else
+               _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessWindowEvent(newevent1);
+#endif
 
-       }
+       } // if idTissue
 }
 
 //-------------------------------------------------------------------
@@ -331,7 +368,14 @@ void wxVtkClipping3DViewCntrlPanel::OnVisibleVolume(wxCommandEvent& event)
        _wxvtkclipping3Dview->Refresh();
 
        wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
+
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
        _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
+#else
+       _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessWindowEvent(newevent1);
+#endif
+
 }
 //-------------------------------------------------------------------
 void wxVtkClipping3DViewCntrlPanel::OnVisibleBoxSurface(wxCommandEvent& event)
@@ -342,7 +386,8 @@ void wxVtkClipping3DViewCntrlPanel::OnVisibleBoxSurface(wxCommandEvent& event)
 //-------------------------------------------------------------------
 void wxVtkClipping3DViewCntrlPanel::OnVisibleBoxVolume(wxCommandEvent& event)
 {
-       _wxvtkclipping3Dview->SetVisibleBoxVolume(event.IsChecked() );
+printf("EED ERROR JPReyes wxVtkClipping3DViewCntrlPanel::OnVisibleBoxVolume  calling   _wxvtkclipping3Dview->SetVisibleBoxVolume that not exists ...");
+//EED01July2011        _wxvtkclipping3Dview->SetVisibleBoxVolume(event.IsChecked() );
        //this->BoundingBoxChanged(event.IsChecked());
        _wxvtkclipping3Dview->Refresh();
 }
@@ -364,14 +409,18 @@ void wxVtkClipping3DViewCntrlPanel::OnColor(wxCommandEvent& event)
                        float b=dlgColour.GetColourData().GetColour().Blue()/255;
                        tmpActor->GetProperty()->SetColor( r , g , b );
                        _color->SetBackgroundColour(dlgColour.GetColourData().GetColour());
-
                        _wxvtkclipping3Dview->Refresh();
-
                        wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
                        _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
-               }
-       }
+#else
+                       _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessWindowEvent(newevent1);
+#endif
+               } // if ShowModal
+       } // if idTissue
 }
+
 //-------------------------------------------------------------------
 void wxVtkClipping3DViewCntrlPanel::OnVisibleSurface(wxCommandEvent& event)
 {
@@ -379,12 +428,15 @@ void wxVtkClipping3DViewCntrlPanel::OnVisibleSurface(wxCommandEvent& event)
        if (idTissue!=-1)
        {
                _wxvtkclipping3Dview->VisibleActor(idTissue, _visible->GetValue());
-
                _wxvtkclipping3Dview->Refresh();
-
                wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
                _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
-       }
+#else
+               _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessWindowEvent(newevent1);
+#endif
+       } // if idTissue
 }
 //-------------------------------------------------------------------
 void wxVtkClipping3DViewCntrlPanel::OnOpacity(wxScrollEvent& event)
@@ -396,12 +448,15 @@ void wxVtkClipping3DViewCntrlPanel::OnOpacity(wxScrollEvent& event)
                tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
                float opacity=_opacity->GetValue();
                tmpActor->GetProperty()->SetOpacity( opacity/100 );
-
                _wxvtkclipping3Dview->Refresh();
-
                wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
                _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
-       }
+#else
+               _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessWindowEvent(newevent1);
+#endif
+       } // if idTissue
 }
 
 //----------------------------------------------------------------------------
@@ -436,8 +491,15 @@ void wxVtkClipping3DViewCntrlPanel::OnIsoValue(wxScrollEvent& event)
                _wxvtkclipping3Dview->Refresh();
 
                wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
+
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
                _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
-       }
+#else
+               _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessWindowEvent(newevent1);
+#endif
+
+       } // if idTissue
 
 }
 //-------------------------------------------------------------------
@@ -452,7 +514,12 @@ void wxVtkClipping3DViewCntrlPanel::OnBtnCreateFileSTL(wxCommandEvent& event)
 
 
        wxString dirSTL = wxGetHomeDir( ) ;
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
        wxFileDialog dialog( this, _T("Choose a directory..."), dirSTL , _T(""), _T("*.*"), wxSAVE );
+#else
+       wxFileDialog dialog( this, _T("Choose a directory..."), dirSTL , _T(""), _T("*.*"), wxFD_SAVE );
+#endif
 
        if( dialog.ShowModal( ) == wxID_OK )
        {
@@ -470,23 +537,37 @@ void wxVtkClipping3DViewCntrlPanel::OnBtnCreateFileSTL(wxCommandEvent& event)
         vtkTriangleFilter *filtro = vtkTriangleFilter::New();
 
 
-               filtro->SetInput( this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueClipper(idTissue)->GetOutput() );
                vtkPolyDataConnectivityFilter *pdcf = vtkPolyDataConnectivityFilter::New();
-        pdcf->SetInput( filtro->GetOutput() );
         vtkClosePolyData *cpd = vtkClosePolyData::New();
+
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+               filtro->SetInput( this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueClipper(idTissue)->GetOutput() );
+        pdcf->SetInput( filtro->GetOutput() );
         cpd->SetInput( pdcf->GetOutput() );
+#else
+               filtro->SetInputConnection( this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueClipper(idTissue)->GetOutputPort() );
+        pdcf->SetInputConnection( filtro->GetOutputPort() );
+        cpd->SetInputConnection( pdcf->GetOutputPort() );
+#endif
 
-               // 1.2 se escribe a disco el archivo stl de la superficie interna
+               // 1.2 Write the stl file
         cpd->Update();
         vtkSTLWriter *writer = vtkSTLWriter::New();
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
         writer->SetInput( cpd->GetOutput() );
-               filename =prefix;
+#else
+        writer->SetInputConnection( cpd->GetOutputPort() );
+#endif
+
         writer->SetFileName(filename.c_str());
         writer->SetFileTypeToASCII();
         writer->Write();
         writer->Delete();
 
-
         filtro->Delete();
         cpd->Delete();
         pdcf->Delete();
@@ -498,7 +579,12 @@ void wxVtkClipping3DViewCntrlPanel::OnBtnCreateFileSTL(wxCommandEvent& event)
 //-------------------------------------------------------------------
 void wxVtkClipping3DViewCntrlPanel::OnBtnSaveRawVolume(wxCommandEvent& event)
 {
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
        wxFileDialog dialog(this, _T("Choose a file"), _T(""), _T(""), _T("*.maracas"), wxSAVE );
+#else
+       wxFileDialog dialog(this, _T("Choose a file"), _T(""), _T(""), _T("*.maracas"), wxFD_SAVE );
+#endif
        if (dialog.ShowModal() == wxID_OK)
        {
                std::string directory = (const char*) (dialog.GetDirectory().mb_str() );
@@ -642,7 +728,15 @@ void wxVtkClipping3DViewCntrlPanel::OnBtnVolumeFunctions(wxCommandEvent& event)
                        //_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions();
                        _wxvtkclipping3Dview->Refresh();
                        wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
+
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
                        _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
+#else
+                       _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessWindowEvent(newevent1);
+#endif
+
+
 
                        /*
                        volumeMapper->Update();
@@ -670,10 +764,10 @@ void wxVtkClipping3DViewCntrlPanel::OnBtnVolumeFunctions(wxCommandEvent& event)
                        size=greyctf->size();
                        for(i=0;i<size;i++)
                        {
-                               double grey2=(*greyctf)[i];
-                               double red =(*rctf)[i];
-                               double green =(*gctf)[i];
-                               double blue = (*bctf)[i];
+                               double grey2    = (*greyctf)[i];
+                               double red      = (*rctf)[i];
+                               double green    = (*gctf)[i];
+                               double blue     = (*bctf)[i];
                                ctfun->AddRGBPoint(grey2,red,green,blue);
                        }
 
@@ -683,7 +777,12 @@ void wxVtkClipping3DViewCntrlPanel::OnBtnVolumeFunctions(wxCommandEvent& event)
                        //_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions();
                        _wxvtkclipping3Dview->Refresh();
                        wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
                        _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
+#else
+                       _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessWindowEvent(newevent1);
+#endif
 
                        /*
                        volumeMapper->Update();
@@ -700,6 +799,8 @@ void wxVtkClipping3DViewCntrlPanel::OnBtnVolumeFunctions(wxCommandEvent& event)
 //-------------------------------------------------------------------
 void wxVtkClipping3DViewCntrlPanel::OnBtnMeshVTKLoad(wxCommandEvent& event)
 {
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
        wxFileDialog dialog(this, _T("Choose a file"), _T("c:/Maracas_configuration"),_T(""), _T("*.vtk"), wxOPEN);
        if (dialog.ShowModal() == wxID_OK)
        {
@@ -707,6 +808,18 @@ void wxVtkClipping3DViewCntrlPanel::OnBtnMeshVTKLoad(wxCommandEvent& event)
                _wxvtkclipping3Dview->Refresh();
                wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
                _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
-       }
+       } // if
+#else
+       wxFileDialog dialog(this, _T("Choose a file"), _T("c:/Maracas_configuration"),_T(""), _T("*.vtk"), wxFD_OPEN);
+       if (dialog.ShowModal() == wxID_OK)
+       {
+               _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadMeshVTK( dialog.GetPath().char_str() );
+               _wxvtkclipping3Dview->Refresh();
+               wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
+               _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessWindowEvent(newevent1);
+
+       } // if
+#endif
+
 }