]> Creatis software - cpPlugins.git/blobdiff - appli/examples/plugins/ShowImage.cxx
Start contour tracer widget debugging: change interactor style.
[cpPlugins.git] / appli / examples / plugins / ShowImage.cxx
index a339de20881b70ced457cb10078bb0ac72e2e729..3b9c9ddf78ab6269c575c22daa4ef7eaf7e28947 100644 (file)
@@ -3,6 +3,7 @@
 #ifdef cpExtensions_QT4
 
 #include <cpExtensions/QT/SimpleMPRWidget.h>
+#include <cpExtensions/QT/ImageWidget.h>
 #include <cpPlugins/Interface/Workspace.h>
 
 #include <QApplication>
@@ -18,6 +19,8 @@
 int main( int argc, char* argv[] )
 {
 #ifdef cpExtensions_QT4
+  typedef cpPlugins::Interface::Plugins   _TPlugins;
+  typedef cpPlugins::Interface::Workspace _TWorkspace;
 
   // Manage inputs
   if( argc < 2 )
@@ -28,12 +31,11 @@ int main( int argc, char* argv[] )
   } // fi
 
   // Create interface
-  cpPlugins::Interface::Plugins::Pointer interface =
-    cpPlugins::Interface::Plugins::New( );
+  _TPlugins::Pointer plugins = _TPlugins::New( );
   try
   {
-    interface->LoadEnvironments( );
-    interface->GuessPlugins( );
+    plugins->LoadEnvironments( );
+    plugins->GuessPlugins( );
   }
   catch( std::exception& err )
   {
@@ -43,7 +45,6 @@ int main( int argc, char* argv[] )
   } // yrt
 
   // Create workspace
-  typedef cpPlugins::Interface::Workspace _TWorkspace;
   _TWorkspace::Pointer ws = _TWorkspace::New( );
   ws->PrintExecutionOn( );
 
@@ -67,14 +68,10 @@ int main( int argc, char* argv[] )
 
   // Configure viewer
   auto image = reader->GetOutputData< vtkImageData >( "Output" );
-  switch( image->GetDataDimension( ) )
+  auto dim = image->GetDataDimension( );
+  switch( dim )
   {
-  case 2:
-  {
-    return( 0 );
-  }
-  break;
-  case 3:
+  case 2: case 3:
   {
     // Qt initialization
     QApplication app( argc, argv );
@@ -82,13 +79,26 @@ int main( int argc, char* argv[] )
     wnd.setGeometry( 0, 0, 1024, 768 );
 
     // Create main widget
-    cpExtensions::QT::SimpleMPRWidget view( &wnd );
-    view.SetImage( image, "image" );
+    QWidget* wdg = NULL;
+    if( dim == 2 )
+    {
+      auto view = new cpExtensions::QT::ImageWidget( &wnd );
+      view->SetImage( image, 2, "image" );
+      wdg = view;
+    }
+    else
+    {
+      /* TODO
+         auto view = new cpExtensions::QT::SimpleMPRWidget( &wnd );
+         view->SetImage( image, "image" );
+         wdg = view;
+      */
+
+    } // fi
 
     // Start application and show data
-    wnd.setCentralWidget( &view );
+    wnd.setCentralWidget( wdg );
     wnd.show( );
-
     return( app.exec( ) );
   }
   break;
@@ -98,7 +108,7 @@ int main( int argc, char* argv[] )
     return( 1 );
   }
   break;
-    
+
   } // hctiws
 #else // cpExtensions_QT4
   return( 0 );