]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx
#2844 creaMaracasVisu Feature New Normal - ManualPaint_model box, Refresh TransferF...
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxVtkMPR3DView.cxx
index ba470de5dbb039e7aba41c4190e5417975c26c5b..378dadec80206f992eda9fbe9c3a01ebb9a64f70 100644 (file)
@@ -180,44 +180,7 @@ void wxVtkMPR3DView::RemoveActor(vtkActor* actor)
        _wxvtk3Dbaseview->GetRenderer()->RemoveActor(actor);
 }
 
-//-------------------------------------------------------------------
-void wxVtkMPR3DView::ResetCamera(int* ext, double* origin,double* spc)
-{
-       if(ext == NULL){
-               _wxvtk3Dbaseview->GetRenderer()->ResetCamera ();
-               _wxvtk3Dbaseview->GetCamera()->Dolly(2.0);
-               
-//EED 21 mars 2012  FLIP probleme  ..PLOP..
-               _wxvtk3Dbaseview->GetCamera()->Roll(180);
-               _wxvtk3Dbaseview->GetCamera()->Yaw(180+30);
-               _wxvtk3Dbaseview->GetCamera()->Pitch(-22);
-               
-       }else{
-               
-               /*double x = (spc[0])*(origin[0]+(((double)ext[1]-(double)ext[0])/2.0));
-               double y = (spc[1])*(origin[1]+(double)ext[3]);
-               double z = (spc[2])*(origin[2]+(((double)ext[5]-(double)ext[4])/2.0));*/
-               /*double x0=(spc[0])*((double)ext[0]+origin[0]);
-               double x1=(spc[0])*((double)ext[1]+origin[0]);
-               double y0=(spc[1])*((double)ext[2]+origin[1]);
-               double y1=(spc[1])*((double)ext[3]+origin[1]);
-               double z0=(spc[2])*((double)ext[4]+origin[2]);
-               double z1=(spc[2])*((double)ext[5]+origin[2]);*/
-               
-               double x0=(spc[0])*((double)ext[0]);
-               double x1=(spc[0])*((double)ext[1]);
-               double y0=(spc[1])*((double)ext[2]);
-               double y1=(spc[1])*((double)ext[3]);
-               double z0=(spc[2])*((double)ext[4]);
-               double z1=(spc[2])*((double)ext[5]);
-
-               _wxvtk3Dbaseview->GetRenderer()->ResetCamera(x0,x1,y0,y1,z0,z1);
-               //_wxvtk3Dbaseview->GetCamera()->SetPosition(x,y,z);
-               _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
-               
-       }
-       
-}
+
 
 //-------------------------------------------------------------------
 void wxVtkMPR3DView::Configure()
@@ -232,32 +195,16 @@ void wxVtkMPR3DView::Configure()
 
        // Actors are added to the renderer.
        vtkActor* _outlineActor = _vtkmpr3Ddataviewer->GetOutlineActor();
+
+
        _wxvtk3Dbaseview->GetRenderer()->AddActor( _outlineActor );
+
 //     _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(0)  );    // _saggital
 //     _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(1)  );    // _axial
 //     _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(2)  );    // _coronal
 
 
-       // An initial camera view is created.  The Dolly() method moves
-       // the camera towards the FocalPoint, thereby enlarging the image.
-       _wxvtk3Dbaseview->GetRenderer()->SetActiveCamera(_wxvtk3Dbaseview->GetCamera());
-       this->ResetCamera();
-
-
-       // Set a background color for the renderer and set the size of the
-       // render window (expressed in pixels).
-       _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0.36 , 0.36 , 0.36 );
-//EED 23oct2010        _wxvtk3Dbaseview->GetRenWin()->SetSize(400, 400);
-
-       // Note that when camera movement occurs (as it does in the Dolly()
-       // method), the clipping planes often need adjusting. Clipping planes
-       // consist of two planes: near and far along the view direction. The
-       // near plane clips out objects in front of the plane; the far plane
-       // clips out objects behind the plane. This way only what is drawn
-       // between the planes is actually rendered.
-       _wxvtk3Dbaseview->GetRenderer()->ResetCameraClippingRange();
-
-
+       
        // vtkPointWidget
        //if(_myCallback!=NULL){
                //_myCallback->Delete();
@@ -338,6 +285,30 @@ void wxVtkMPR3DView::Configure()
 
 // PlaneWidget
 
+
+// An initial camera view is created.  The Dolly() method moves
+       // the camera towards the FocalPoint, thereby enlarging the image.
+//     _wxvtk3Dbaseview->GetRenderer()->SetActiveCamera(_wxvtk3Dbaseview->GetCamera());
+
+       // Note that when camera movement occurs (as it does in the Dolly()
+       // method), the clipping planes often need adjusting. Clipping planes
+       // consist of two planes: near and far along the view direction. The
+       // near plane clips out objects in front of the plane; the far plane
+       // clips out objects behind the plane. This way only what is drawn
+       // between the planes is actually rendered.
+
+//EED 27/05/2013
+//     _wxvtk3Dbaseview->GetRenderer()->ResetCameraClippingRange();
+
+//EED 27/05/2013
+//      this->ResetCamera();
+       _wxvtk3Dbaseview->ResetCamera();
+
+       // Set a background color for the renderer and set the size of the
+       // render window (expressed in pixels).
+       _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0.36 , 0.36 , 0.36 );
+//EED 23oct2010        _wxvtk3Dbaseview->GetRenWin()->SetSize(400, 400);
+
 }
 
 //-------------------------------------------------------------------
@@ -419,6 +390,9 @@ vtkImagePlaneWidget* wxVtkMPR3DView::GetPlaneWidget(unsigned char activationkey,
 //-------------------------------------------------------------------
 void wxVtkMPR3DView::SetFreePlanesOrtho()
 {
+
+       
+
        _planeWidgetX->SetPlaneOrientationToXAxes();
        _planeWidgetY->SetPlaneOrientationToYAxes();
        _planeWidgetZ->SetPlaneOrientationToZAxes();
@@ -432,13 +406,44 @@ void wxVtkMPR3DView::FreePlaneVisible(int plane, bool ok)
 {
        if(_planeWidgetX)
        {
-               if ((plane==1) && (ok==true)) _planeWidgetX->EnabledOn();
-               if ((plane==2) && (ok==true)) _planeWidgetY->EnabledOn();
-               if ((plane==3) && (ok==true)) _planeWidgetZ->EnabledOn();
+               if (ok==true)
+               {
+//EED 21/07/2013
+//                     1. Make backup of actors
+//                     2. Putting out all the actors
+//                     3. Add vtkImagageActor in first place
+//                     4. Putting again the originals actors
+//                     5. Refresh
+
+                       // step 1, step 2
+                       vtkActorCollection *tmpCollection    = vtkActorCollection::New();
+                       vtkActorCollection *collectionActors =  _wxvtk3Dbaseview->GetRenderer()->GetActors();
+                       int i,size=collectionActors->GetNumberOfItems();
+                       for (i=0; i<size; i++)
+                       {
+                               tmpCollection->AddItem ( (vtkActor*)collectionActors->GetItemAsObject(0)  );                    
+                               _wxvtk3Dbaseview->GetRenderer()->RemoveActor( (vtkProp*)tmpCollection->GetItemAsObject(i) );
+                       } // for
+
+                       // step 3
+                       if ((plane==1) && (ok==true)) _planeWidgetX->EnabledOn();
+                       if ((plane==2) && (ok==true)) _planeWidgetY->EnabledOn();
+                       if ((plane==3) && (ok==true)) _planeWidgetZ->EnabledOn();
+
+                       // step 4
+                        for (i=0; i<size; i++)
+                       {
+                               _wxvtk3Dbaseview->GetRenderer()->AddActor( (vtkProp*)tmpCollection->GetItemAsObject(i) );
+                       } // for
+                       tmpCollection->Delete();
+
+                       // step 5 Refresh
+                       _wxvtk3Dbaseview->GetRenderer()->GetRenderWindow()->Render();
+               } // if ok
                if ((plane==1) && (ok==false)) _planeWidgetX->EnabledOff();
                if ((plane==2) && (ok==false)) _planeWidgetY->EnabledOff();
                if ((plane==3) && (ok==false)) _planeWidgetZ->EnabledOff();
-       }
+       } // if  _planeWidgetX
 }
 
 //-------------------------------------------------------------------
@@ -470,7 +475,7 @@ void wxVtkMPR3DView::setColorTransferFunction(vtkColorTransferFunction* colortab
 //-------------------------------------------------------------------
 void wxVtkMPR3DView::Refresh()   // virtual
 {
-       _vtkmpr3Ddataviewer     ->      Refresh();
+       _vtkmpr3Ddataviewer->Refresh();
        if (_wxvtkmpr3DviewCntrlPanel!=NULL)
        {
                _wxvtkmpr3DviewCntrlPanel->Refresh();
@@ -509,18 +514,27 @@ void wxVtkMPR3DView::RefreshView()   // virtual
        if ((normal[0]==1)&&(normal[1]==0)&&(normal[2]==0))
        {
                _planeWidgetX->SetSlicePosition( x*spc[0] );
+//EED 2016/02/19
+//             _planeWidgetX->GetReslice()->SetInterpolate( _vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetInterpolate() );
+               _planeWidgetX->GetTexture()->SetInterpolate( _vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetInterpolate() );
        }
        // FreePlaneY
        _planeWidgetY->GetNormal(normal);
        if ((normal[0]==0)&&(normal[1]==1)&&(normal[2]==0))
        {
                _planeWidgetY->SetSlicePosition( y*spc[1] );
+//EED 2016/02/19
+               _planeWidgetY->GetReslice()->SetInterpolate( _vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetInterpolate() );
+               _planeWidgetY->GetTexture()->SetInterpolate( _vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetInterpolate() );
        }
        // FreePlaneZ
        _planeWidgetZ->GetNormal(normal);
        if ((normal[0]==0)&&(normal[1]==0)&&(normal[2]==1))
        {
                _planeWidgetZ->SetSlicePosition( z*spc[2] );
+//EED 2016/02/19
+               _planeWidgetZ->GetReslice()->SetInterpolate( _vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetInterpolate() );
+               _planeWidgetZ->GetTexture()->SetInterpolate( _vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetInterpolate() );
        }
                
        x=x*spc[0];
@@ -555,7 +569,8 @@ vtkMPR3DDataViewer* wxVtkMPR3DView::GetVtkMPR3DDataViewer()
 //-------------------------------------------------------------------
 wxVtk3DBaseView* wxVtkMPR3DView::GetWxvtk3Dbaseview() throw (char*)
 {
-       if(_wxvtk3Dbaseview==NULL){
+       if(_wxvtk3Dbaseview==NULL)
+       {
                throw "wxVtk3DBaseView* wxVtkMPR3DView::GetWxvtk3Dbaseview() _wxvtk3Dbaseview=NULL";
        }
        return _wxvtk3Dbaseview;
@@ -576,7 +591,42 @@ void wxVtkMPR3DView::VisibleImageActor(int idPosition, bool visible){
                if (visible==false){
                        _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkmpr3Ddataviewer->GetImageActor(idPosition)  );
                } else {
+//EED 21/07/2013
+//                     1. Make backup of actors
+//                     2. Putting out all the actors
+//                     3. Add vtkImagageActor in first place
+//                     4. Putting again the originals actors
+//                     5. Refresh
+
+//EED 4 nov 2015  (For Estelle)
+// This works in ViewerNV with nTymeView=6
+// Because the others modules (5) generate also more actors with an OutLineFilter -> Actor
+//showOutlineActor(false);
+
+                       // step 1, step 2
+                       vtkActorCollection *tmpCollection    = vtkActorCollection::New();
+                       vtkActorCollection *collectionActors =  _wxvtk3Dbaseview->GetRenderer()->GetActors();
+                       int i,size=collectionActors->GetNumberOfItems();
+                       for (i=0; i<size; i++)
+                       {
+                               printf(" wxVtkMPR3DView::VisibleImageActor %d\n" , i);
+                               tmpCollection->AddItem ( (vtkActor*)collectionActors->GetItemAsObject(0)  );                    
+                               _wxvtk3Dbaseview->GetRenderer()->RemoveActor( (vtkProp*)tmpCollection->GetItemAsObject(i) );
+                       } // for
+
+                       // step 3
                        _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(idPosition)  );
+
+                       // step 4
+                        for (i=0; i<size; i++)
+                       {
+                               _wxvtk3Dbaseview->GetRenderer()->AddActor( (vtkProp*)tmpCollection->GetItemAsObject(i) );
+                       } // for
+                       tmpCollection->Delete();
+
+                       // step 5 Refresh
+                       _wxvtk3Dbaseview->GetRenderer()->GetRenderWindow()->Render();
+
                }
                _vtkmpr3Ddataviewer->SetVisiblePosition(idPosition,visible);
        }
@@ -615,6 +665,7 @@ void wxVtkMPR3DView::VisiblePlaneWidget( bool visible )
 //CPR: Method added 30 Nov 2009
 void wxVtkMPR3DView::showOutlineActor(bool value)
 {
+
        vtkActor* _outlineActor = _vtkmpr3Ddataviewer->GetOutlineActor();
        if(value == true)
        {
@@ -624,6 +675,7 @@ void wxVtkMPR3DView::showOutlineActor(bool value)
        {
                _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _outlineActor );
        }
+
 }
 
 //-------------------------------------------------------------------
@@ -781,7 +833,6 @@ void wxVtkMPR3DView::TestLoic2()
         vtkPlane *slicePlane = vtkPlane::New();
                                this->_planeWidget->GetPlane( slicePlane );
 
-
         vtkCutter* sliceCutter = vtkCutter::New();
                vtkImageData *vtkimagedata =  this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
                 sliceCutter->SetInput( vtkimagedata );
@@ -790,7 +841,6 @@ void wxVtkMPR3DView::TestLoic2()
 //EED
 //        vtkLookupTable *lut = BuildHueWeightBaseMap();
 
-
         vtkPolyDataMapper *slice = vtkPolyDataMapper::New();
                 slice->SetInput( sliceCutter->GetOutput() );
         double range[2];
@@ -810,12 +860,9 @@ void wxVtkMPR3DView::TestLoic2()
                 contourMapper->SetScalarRange( range );
   //              contourMapper->SetLookupTable( lut );
 
-
         vtkActor *contourActor = vtkActor::New();
                 contourActor->SetMapper( contourMapper );
 
-
-
  // The usual rendering stuff.
   vtkCamera *camera = vtkCamera::New();
       camera->SetPosition(1,1,1);
@@ -841,5 +888,25 @@ void wxVtkMPR3DView::TestLoic2()
   iren->Start();
 }
 
+//-------------------------------------------------------------------
+void wxVtkMPR3DView::SetBackGroundType(int type)
+{
+       if (_wxvtk3Dbaseview!=NULL)
+       {
+               if (type==0)
+               {
+                       _wxvtk3Dbaseview->GetRenderer()->GradientBackgroundOff();
+                       _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0 , 0 , 0 );
+               } // if type
+               if (type==1)
+               {
+                       _wxvtk3Dbaseview->GetRenderer()->GradientBackgroundOn();
+                       _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0.33 , 0.33 , 0.33 );
+                       _wxvtk3Dbaseview->GetRenderer()->SetBackground2( 0.66 , 0.66 , 0.66 );
+               } // if type
+               _wxvtk3Dbaseview->Refresh();
+       }// if _wxvtk3Dbaseview
+       
+}