]> Creatis software - cpPlugins.git/blobdiff - appli/examples/example_View2DImage.cxx
Binary image visualization improved.
[cpPlugins.git] / appli / examples / example_View2DImage.cxx
index cc8a3e6e1eb61869ef1ab76e7177a292f3fd92f9..fcf13147f275f9674fd0025545314f9cf31a909f 100644 (file)
@@ -29,7 +29,7 @@ int main( int argc, char* argv[] )
   {
     std::cerr
       << "Usage: " << argv[ 0 ]
-      << " plugins_file input_image"
+      << " plugins_file input_image [widget]"
       << std::endl;
     return( 1 );
 
@@ -59,8 +59,13 @@ int main( int argc, char* argv[] )
 
   // Configure reader
   TParameters* reader_params = reader->GetParameters( );
-  for( int i = 2; i < argc; ++i )
-    reader_params->AddToStringList( "FileNames", argv[ i ] );
+  if( argc > 4 )
+  {
+    for( int i = 2; i < argc; ++i )
+      reader_params->AddToStringList( "FileNames", argv[ i ] );
+  }
+  else
+    reader_params->AddToStringList( "FileNames", argv[ 2 ] );
 
   // Execute pipeline
   std::string err = reader->Update( );
@@ -90,17 +95,26 @@ int main( int argc, char* argv[] )
   // Create slice actors
   vtkSmartPointer< TSliceActors > image_actors =
     vtkSmartPointer< TSliceActors >::New( );
-  image_actors->AddInputData( image->GetVTK< vtkImageData >( ), 2 );
+  image_actors->AddInputData( image->GetVTK< vtkImageData >( ) );
+  image_actors->SetAxis( 2 );
   image_actors->PushActorsInto( window );
 
   // Activate seed widget
-  TSliceActors::TStyle* style =
-    dynamic_cast< TSliceActors::TStyle* >( image_actors->GetStyle( ) );
-  if( style != NULL )
-    style->SeedWidgetOn( );
+  if( argc == 4 )
+  {
+    TSliceActors::TStyle* style =
+      dynamic_cast< TSliceActors::TStyle* >( image_actors->GetStyle( ) );
+    if( style != NULL )
+    {
+      if( std::string( argv[ 3 ] ) == std::string( "seed" ) )
+        style->SeedWidgetOn( );
+
+    } // fi
+
+  } // fi
 
   // Begin interaction
-  renderer->ResetCamera( );
+  image_actors->ResetCamera( );
   window->Render( );
   interactor->Start( );