]> Creatis software - cpMesh.git/blobdiff - appli/InteractiveDeformableMeshSegmentation/MainWnd.cxx
QuadEdgeMesh ported to cpPlugins/Extensions
[cpMesh.git] / appli / InteractiveDeformableMeshSegmentation / MainWnd.cxx
index bde4b4a9fb7db8274b42c919958df94cc5b50269..bbb9080259e440d90b8cb61e27c95472e76b0bc4 100644 (file)
@@ -145,6 +145,10 @@ MainWnd::MainWnd( QWidget* parent )
 MainWnd::
 ~MainWnd( )
 {
+  // Close all connections
+  this->m_Plugins.UnloadAll( );
+
+  // Delete objects
   delete this->m_UI;
   if( this->m_InputImage != NULL ) delete this->m_InputImage;
   if( this->m_SegmentedImage != NULL ) delete this->m_SegmentedImage;
@@ -192,6 +196,7 @@ MainWnd::
 TPluginData* MainWnd::
 _LoadImage( const std::string& image_type, const std::string& image_dim )
 {
+/*
   // Show dialog and check if it was accepted
   QFileDialog dialog( this );
   dialog.setFileMode( QFileDialog::ExistingFiles );
@@ -223,7 +228,7 @@ _LoadImage( const std::string& image_type, const std::string& image_dim )
 
     TPlugin* reader =
       dynamic_cast< TPlugin* >(
-        this->m_Plugins.CreateObject( this->m_ImageReaderClassName )
+      this->m_Plugins.CreateObject( this->m_ImageReaderClassName )
         );
 
     TParameters reader_params = reader->GetDefaultParameters( );
@@ -260,15 +265,13 @@ _LoadImage( const std::string& image_type, const std::string& image_dim )
       return( ret );
 
     } // fi
-
-    /* TODO
        std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
        this->m_LastOpenedFile = fname;
-    */
     return( ret );
 
   } // fi
   return( ret );
+*/
 }
 
 // -------------------------------------------------------------------------
@@ -300,33 +303,51 @@ _UpdateEnabledFlags( )
 void MainWnd::
 _triggered_actionReloadPlugins( )
 {
-  this->m_Plugins.UnloadAll( );
+  if( this->_LoadPlugins( ) )
+  {
+    this->_UpdateEnabledFlags( );
+  }
+  else
+  {
+    QMessageBox::critical(
+      this,
+      tr( "Could not load plugins from given file." ),
+      tr( "Could not load plugins from given file." )
+      );
 
-  this->m_ImageReaderClassName = "";
-  this->m_ImageSeriesReaderClassName = "";
-  this->m_ImageWriterClassName = "";
+  } // fi
+  /*
+    this->m_Plugins.UnloadAll( );
 
-  std::ifstream in( this->m_PluginsConfigurationFile.c_str( ) );
-  if( in )
-  {
+    this->m_ImageReaderClassName = "";
+    this->m_ImageSeriesReaderClassName = "";
+    this->m_ImageWriterClassName = "";
+
+    std::ifstream in( this->m_PluginsConfigurationFile.c_str( ) );
+    if( in )
+    {
     std::string plugin;
     std::getline( in, plugin );
     while( !( in.eof( ) ) )
     {
-      if( this->m_Plugins.Load( plugin ) )
-      {
-        TPluginsInterface::TClassesIterator cIt =
-          this->m_Plugins.GetClasses( ).begin( );
-        TPluginsInterface::TClassesIterator end_cIt =
-          this->m_Plugins.GetClasses( ).end( );
-        for( ; cIt != end_cIt; ++cIt )
-        {
-          std::string c_name = cIt->first;
-          c_name = c_name.substr( c_name.find_last_of( ":" ) + 1 );
-          if( c_name == "ImageReader" )
-          {
+    if( this->m_Plugins.Load( plugin ) )
+    {
+    TPluginsInterface::TClassesIterator cIt =
+    this->m_Plugins.GetClasses( ).begin( );
+    TPluginsInterface::TClassesIterator end_cIt =
+    this->m_Plugins.GetClasses( ).end( );
+    for( ; cIt != end_cIt; ++cIt )
+    {
+    std::string c_name = cIt->first;
+    c_name = c_name.substr( c_name.find_last_of( ":" ) + 1 );
+    if( c_name == "ImageReader" )
+    {
             this->m_ImageReaderClassName = cIt->first;
           }
+          else if( c_name == "ImageSeriesReader" )
+          {
+            this->m_ImageSeriesReaderClassName = cIt->first;
+          }
           else if( c_name == "ImageWriter" )
           {
             this->m_ImageWriterClassName = cIt->first;
@@ -337,7 +358,6 @@ _triggered_actionReloadPlugins( )
           
         } // rof
 
-        /* TODO
            TFilterPlugins::TClassesIterator cIt =
            this->m_Plugins.BeginClasses( );
            for( ; cIt != this->m_Plugins.EndClasses( ); ++cIt )
@@ -369,7 +389,6 @@ _triggered_actionReloadPlugins( )
            } // fi
            delete filter;
            } // rof
-        */
       }
       else
       {
@@ -415,6 +434,7 @@ _triggered_actionReloadPlugins( )
 
   } // fi
   this->_UpdateEnabledFlags( );
+  */
 }
 
 // -------------------------------------------------------------------------
@@ -496,46 +516,6 @@ _triggered_actionOpenSegmentedImage( )
     this->m_UI->m_ZPlaneVTK->GetRenderWindow( )->Render( );
     this->_UpdateEnabledFlags( );
 
-    /*
-    this->m_ImageActors->Configure(
-    img->GetVTKImageData( ),
-      this->m_UI->m_XPlaneVTK->GetInteractor( ),
-      this->m_UI->m_YPlaneVTK->GetInteractor( ),
-      this->m_UI->m_ZPlaneVTK->GetInteractor( )
-      );
-    this->m_ImageActors->
-      AddAuxiliaryInteractor( this->m_UI->m_3DVTK->GetInteractor( ) );
-
-    // Associate actors
-    this->m_3DRenderer->AddActor(
-      this->m_ImageActors->GetImageOutlineActor( )
-      );
-    this->m_3DRenderer->AddActor(
-      this->m_ImageActors->GetXBoundsActor( )
-      );
-    this->m_3DRenderer->AddActor(
-      this->m_ImageActors->GetYBoundsActor( )
-      );
-    this->m_3DRenderer->AddActor(
-      this->m_ImageActors->GetZBoundsActor( )
-      );
-
-    // Reset all cameras
-    this->m_3DRenderer->ResetCamera( );
-    this->m_ImageActors->ResetCameras( );
-
-    // Ok, start!
-    this->m_UI->m_3DVTK->GetRenderWindow( )->Render( );
-    this->m_UI->m_XPlaneVTK->GetRenderWindow( )->Render( );
-    this->m_UI->m_YPlaneVTK->GetRenderWindow( )->Render( );
-    this->m_UI->m_ZPlaneVTK->GetRenderWindow( )->Render( );
-
-    // Update activations
-    this->_UpdateEnabledFlags( );
-    this->m_UI->actionNavigation->setChecked( true );
-    this->_triggered_actionSwitchMode( );
-    */
-
   } // fi
 }