]> Creatis software - creaVtk.git/commitdiff
#3474 PlaneWidget Box with representation:Wireframe and resolution
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 24 Nov 2021 10:36:40 +0000 (11:36 +0100)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 24 Nov 2021 10:36:40 +0000 (11:36 +0100)
bbtk_creaVtk_PKG/src/bbcreaVtkPlaneWidget.cxx
bbtk_creaVtk_PKG/src/bbcreaVtkPlaneWidget.h
lib/creaVtk/creaVtkPlaneWidget.cpp
lib/creaVtk/creaVtkPlaneWidget.h

index 41007234e9250e6e0d67f9e295301ca9187b7daf..833d6be9d99e7db0df9d39f0435e7920e68f00b1 100644 (file)
@@ -44,7 +44,6 @@ void PlaneWidget::Process()
 //    * TYPE is the C++ type of the input/output
 //      (the one provided in the attribute 'type' of the tag 'input')
 
-printf("EED void PlaneWidget::Process Start\n");
 
        if ((bbGetInputIn()==NULL) || (bbGetInputRenderer()==NULL))
        {
@@ -59,15 +58,13 @@ printf("EED void PlaneWidget::Process Start\n");
                _boxcreavtkplanewidget.SetResolution( bbGetInputResolution() );
                _boxcreavtkplanewidget.SetRenderer( bbGetInputRenderer() );
                _boxcreavtkplanewidget.SetRepresentation( bbGetInputRepresentation() );
-printf("EED void PlaneWidget::Process 1\n");
+               _boxcreavtkplanewidget.SetOrigin( bbGetInputOrigin() );
                _boxcreavtkplanewidget.Process();
-printf("EED void PlaneWidget::Process 2\n");
                
                bbSetOutputOut( _boxcreavtkplanewidget.GetPlaneSource()->GetOutput() );
                bbSetOutputCenter( _boxcreavtkplanewidget.GetCenter() );
                bbSetOutputNormal( _boxcreavtkplanewidget.GetNormal() );
        }
-printf("EED void PlaneWidget::Process End\n");
        
 }
 //===== 
index 02dcce08743fa91ffeda33a59d7d2798953f5d56..89881fb17650e328f2f0041b1e4aa3939fbcb378 100644 (file)
@@ -41,6 +41,7 @@ class bbcreaVtk_EXPORT PlaneWidget
   BBTK_DECLARE_INPUT(Resolution,int);
   BBTK_DECLARE_INPUT(Renderer,vtkRenderer*);
   BBTK_DECLARE_INPUT(Representation,int);
+  BBTK_DECLARE_INPUT(Origin,std::vector<double>);
   BBTK_DECLARE_OUTPUT(Out,vtkDataSet*);
   BBTK_DECLARE_OUTPUT(Center,std::vector<double>);
   BBTK_DECLARE_OUTPUT(Normal,std::vector<double>);
@@ -67,6 +68,7 @@ BBTK_CATEGORY("empty");
   BBTK_INPUT(PlaneWidget,Resolution,"Resolution (60 default)",int,"");
   BBTK_INPUT(PlaneWidget,Renderer,"vtkRenderer",vtkRenderer*,"");
   BBTK_INPUT(PlaneWidget,Representation,"(default 1) 0:OutLine 1:Wireframe 2:Surface",int,"");
+  BBTK_INPUT(PlaneWidget,Origin,"Origin [x,y,z]",std::vector<double>,"");
 
   BBTK_OUTPUT(PlaneWidget,Out,"Dynamic plane result from vtkPlaneSource",vtkDataSet*,"");
   BBTK_OUTPUT(PlaneWidget,Center,"Center of the plane",std::vector<double>,"");
index 609d425d34cfc8fe47cd95472cd2fdbc2a01a442..39cca10c7502c937298b74332a66cd9d1c81057c 100644 (file)
@@ -153,6 +153,10 @@ std::vector<double> creaVtkPlaneWidget::GetNormal()
        return vecNormal;
 }
 
+void creaVtkPlaneWidget::SetOrigin(std::vector<double> origin)
+{
+       _origin = origin;
+}
 
 //------------------------------------------------------------------------
 void creaVtkPlaneWidget::Process()
@@ -160,36 +164,41 @@ void creaVtkPlaneWidget::Process()
     if ((GetActive()==true) && (GetRenderer()!=NULL))
     { 
 
-//EED 2017-01-01 Migration VTK7
-#if VTK_MAJOR_VERSION <= 5
-       _vPlaneWidget->SetInput( GetImage() );
-#else
-       _vPlaneWidget->SetInputData( GetImage() );
-#endif
-       _vPlaneWidget->SetInteractor( GetRenderer()->GetRenderWindow()->GetInteractor() );
-       _vPlaneWidget->NormalToXAxisOn();
-       _vPlaneWidget->NormalToZAxisOn();
-       _vPlaneWidget->SetResolution(_resolution);
-       if (_representation==0){ _vPlaneWidget->SetRepresentationToOutline();   }
-       if (_representation==1){ _vPlaneWidget->SetRepresentationToWireframe(); }
-       if (_representation==2){ _vPlaneWidget->SetRepresentationToSurface();   }
-       _vPlaneWidget->SetPlaceFactor(1); //defini zoom initial
-       _vPlaneWidget->SetHandleSize(0.5); 
-       _vPlaneWidget->On();
-       if (_firsttime==true )  
-       { 
-               _firsttime = false;
-               _vPlaneWidget->PlaceWidget();
-               creaVtkCallbackPlaneWidget *creavtkcallbackplanewidget = creaVtkCallbackPlaneWidget::New();
-               creavtkcallbackplanewidget->creavtkplanewidget   = this ;
-               _vPlaneWidget->AddObserver( vtkCommand::InteractionEvent , creavtkcallbackplanewidget );
-               _vPlaneWidget->AddObserver( vtkCommand::StartInteractionEvent , creavtkcallbackplanewidget );
-               _vPlaneWidget->AddObserver( vtkCommand::EnableEvent , creavtkcallbackplanewidget );
-       }
-       UpdatePlane();
+       //EED 2017-01-01 Migration VTK7
+       #if VTK_MAJOR_VERSION <= 5
+               _vPlaneWidget->SetInput( GetImage() );
+       #else
+               _vPlaneWidget->SetInputData( GetImage() );
+       #endif
+               _vPlaneWidget->SetInteractor( GetRenderer()->GetRenderWindow()->GetInteractor() );
+               _vPlaneWidget->NormalToXAxisOn();
+               _vPlaneWidget->NormalToZAxisOn();
+               _vPlaneWidget->SetResolution(_resolution);
+               if (_representation==0){ _vPlaneWidget->SetRepresentationToOutline();   }
+               if (_representation==1){ _vPlaneWidget->SetRepresentationToWireframe(); }
+               if (_representation==2){ _vPlaneWidget->SetRepresentationToSurface();   }
+               _vPlaneWidget->SetPlaceFactor(1); //defini zoom initial
+               _vPlaneWidget->SetHandleSize(0.01); 
+               _vPlaneWidget->On();
+               _vPlaneWidget->Print(std::cout);
+               if (_origin.size()==3)
+               {
+                       _vPlaneWidget->SetCenter( _origin[0] , _origin[1] , _origin[2] );
+               } // if _origin
+               if (_firsttime==true )  
+               { 
+                       _firsttime = false;
+                       _vPlaneWidget->PlaceWidget();
+                       creaVtkCallbackPlaneWidget *creavtkcallbackplanewidget  = creaVtkCallbackPlaneWidget::New();
+                       creavtkcallbackplanewidget->creavtkplanewidget                  = this ;
+                       _vPlaneWidget->AddObserver( vtkCommand::InteractionEvent , creavtkcallbackplanewidget );
+                       _vPlaneWidget->AddObserver( vtkCommand::StartInteractionEvent , creavtkcallbackplanewidget );
+                       _vPlaneWidget->AddObserver( vtkCommand::EnableEvent , creavtkcallbackplanewidget );
+               }
+               UpdatePlane();
     } else {
-       _vPlaneWidget->Off();
-    }
+               _vPlaneWidget->Off();
+    } // if Active Render
 }
 
 
index 2e87e48d9c6c82a6fcd6d3b0010175ff0997b199..043132e302edc7b5436a7a654c4e2cff69344a61 100644 (file)
@@ -83,6 +83,8 @@ public :
   std::vector<double> GetCenter();
   std::vector<double> GetNormal();
 
+       void SetOrigin( std::vector<double> origin);
+
   void                   Process();
   void                   UpdatePlane();
   virtual void           Execute();
@@ -98,12 +100,13 @@ protected:
 //Methods and attributes only visible by this class
 //---------------------------------------------
 private:
-       bool            _firsttime;
-       bool            _active;
-       vtkImageData    *_image;
-       vtkRenderer     *_renderer;
-       int             _resolution;
-       int             _representation;
+       bool                            _firsttime;
+       bool                            _active;
+       vtkImageData*           _image;
+       vtkRenderer     *               _renderer;
+       int                             _resolution;
+       int                             _representation;
+       std::vector<double> _origin;
 
        vtkPlaneWidget *_vPlaneWidget;
         vtkPlaneSource *_vPlaneSource;