]> Creatis software - cpPlugins.git/blobdiff - plugins/Widgets/LineWidget.cxx
...
[cpPlugins.git] / plugins / Widgets / LineWidget.cxx
index f73e100ae28645067dad3862eabe5ad5840cd6b0..8887463e1252e9a175bdf7ac8cbdc9d2eafcf24b 100644 (file)
@@ -21,6 +21,13 @@ Clear( )
 void cpPluginsWidgets::LineWidget::
 SetEnabled( bool v )
 {
+  auto wdg = this->GetVTK< vtkLineWidget2 >( );
+  if( wdg != NULL )
+  {
+    wdg->SetEnabled( v );
+    wdg->GetInteractor( )->Render( );
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------
@@ -118,17 +125,23 @@ _GD_Image( vtkImageData* image )
   vtkSmartPointer< vtkLineWidget2 > wdg = this->GetVTK< vtkLineWidget2 >( );
   if( wdg.GetPointer( ) == NULL )
   {
-    auto rep = vtkSmartPointer< vtkLineRepresentation >::New( );
+    auto vIt = valid_props.begin( );
+    auto actor = dynamic_cast< vtkImageSlice* >( *( vIt->second.begin( ) ) );
+
+    double bnds[ 6 ];
+    actor->GetBounds( bnds );
+    double p0[ 3 ], p1[ 3 ];
+    p0[ 0 ] = bnds[ 0 ];
+    p0[ 1 ] = bnds[ 2 ];
+    p0[ 2 ] = bnds[ 4 ];
+    p1[ 0 ] = bnds[ 1 ];
+    p1[ 1 ] = bnds[ 3 ];
+    p1[ 2 ] = bnds[ 5 ];
 
-    /* TODO
-       p[ 0 ] = 0.0; p[ 1 ] = -1.0; p[ 2 ] = 0.0;
-       rep->SetPoint1WorldPosition( p );
-       p[ 0 ] = 0.0; p[ 1 ] =  1.0; p[ 2 ] = 0.0;
-       rep->SetPoint2WorldPosition( p );
-       rep->PlaceWidget( pl3d_block0->GetBounds( ) );
-       rep->GetPolyData( seeds );
-       rep->DistanceAnnotationVisibilityOn( );
-    */
+    auto rep = vtkSmartPointer< vtkLineRepresentation >::New( );
+    rep->SetPoint1WorldPosition( p0 );
+    rep->SetPoint2WorldPosition( p1 );
+    rep->PlaceWidget( bnds );
 
     wdg = this->_CreateVTK< vtkLineWidget2 >( );
     wdg->SetInteractor( valid_props.begin( )->first );