]> Creatis software - cpPlugins.git/blobdiff - plugins/Widgets/SeedWidget.cxx
...
[cpPlugins.git] / plugins / Widgets / SeedWidget.cxx
index dc5b6a56ad596abb5927fa8d75a444e309a6a14e..cc589b1509679bbfb868ba70523f9262c080921b 100644 (file)
@@ -1,4 +1,4 @@
-#include <plugins/Widgets/SeedWidget.h>
+#include <Widgets/SeedWidget.h>
 
 #include <cpPlugins/DataObjects/Image.h>
 #include <cpPlugins/DataObjects/Mesh.h>
@@ -26,6 +26,28 @@ Clear( )
 void cpPluginsWidgets::SeedWidget::
 SetEnabled( bool v )
 {
+  for( auto w = this->m_Widgets.begin( ); w != this->m_Widgets.end( ); ++w )
+  {
+    if( v ) w->second->RestartInteraction( );
+    else    w->second->CompleteInteraction( );
+    w->second->SetEnabled( v );
+    w->second->Render( );
+
+  } // rof
+}
+
+// -------------------------------------------------------------------------
+bool cpPluginsWidgets::SeedWidget::
+GetEnabled( ) const
+{
+  if( this->m_Widgets.size( ) > 0 )
+  {
+    auto i = this->m_Widgets.begin( );
+    TWidget* w = const_cast< TWidget* >( i->second.GetPointer( ) );
+    return( w->GetEnabled( ) != 0 );
+  }
+  else
+    return( false );
 }
 
 // -------------------------------------------------------------------------
@@ -130,7 +152,6 @@ _GD0_Image( vtkImageData* image )
           act->AddObserver( vtkCommand::InteractionEvent, this->m_Command );
           wdg->AddObserver( vtkCommand::PlacePointEvent, this->m_Command );
           wdg->AddObserver( vtkCommand::CursorChangedEvent, this->m_Command );
-          wdg->EnabledOn( );
           this->m_Widgets[ *inIt ] = wdg;
 
         } // fi
@@ -143,34 +164,38 @@ _GD0_Image( vtkImageData* image )
     std::string text = this->m_Parameters.GetString( "Text" );
     std::vector< std::string > tok1, tok2;
     cpExtensions::Tokenize( tok1, text, "#" );
-    for( auto t1 = tok1.begin( ); t1 != tok1.end( ); ++t1 )
+    if( tok1.size( ) > seeds->GetPoints( )->GetNumberOfPoints( ) )
     {
-      if( *t1 != "" )
+      for( auto t1 = tok1.begin( ); t1 != tok1.end( ); ++t1 )
       {
-        cpExtensions::Tokenize( tok2, *t1, " " );
-        double x[ 3 ];
-        for( unsigned int d = 0; d < 3; ++d )
+        if( *t1 != "" )
         {
-          if( d < tok2.size( ) )
+          cpExtensions::Tokenize( tok2, *t1, " " );
+          double x[ 3 ];
+          for( unsigned int d = 0; d < 3; ++d )
           {
-            std::istringstream str( tok2[ d ] );
-            str >> x[ d ];
-          }
-          else
-            x[ d ] = double( 0 );
-
-        } // rof
+            if( d < tok2.size( ) )
+            {
+              std::istringstream str( tok2[ d ] );
+              str >> x[ d ];
+            }
+            else
+              x[ d ] = double( 0 );
+
+          } // rof
+
+          seeds->GetPoints( )->InsertNextPoint( x );
+          seeds->GetVerts( )->InsertNextCell( 1 );
+          seeds->GetVerts( )->InsertCellPoint(
+            seeds->GetPoints( )->GetNumberOfPoints( ) - 1
+            );
+          seeds->Modified( );
 
-        seeds->GetPoints( )->InsertNextPoint( x );
-        seeds->GetVerts( )->InsertNextCell( 1 );
-        seeds->GetVerts( )->InsertCellPoint(
-          seeds->GetPoints( )->GetNumberOfPoints( ) - 1
-          );
-        seeds->Modified( );
+        } // fi
 
-      } // fi
+      } // rof
 
-    } // rof
+    } // fi
   }
   else
   {