]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Sat, 26 Sep 2015 11:12:50 +0000 (13:12 +0200)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Sat, 26 Sep 2015 11:12:50 +0000 (13:12 +0200)
appli/ImageMPR/ImageMPR.cxx
appli/ImageMPR/ImageMPR.h
appli/ImageMPR/ImageMPR.ui

index 412b9ed48819c5a2974a21a2d3179e209a054c4b..24cfd389fe26e4882db063a79f1c76ded0e89b39 100644 (file)
@@ -47,6 +47,10 @@ ImageMPR::ImageMPR( QWidget* parent )
     this->m_UI->actionOpenInputImage, SIGNAL( triggered( ) ),
     this, SLOT( _triggered_actionOpenInputImage( ) )
     );
+  QObject::connect(
+    this->m_UI->actionOpenSegmentation, SIGNAL( triggered( ) ),
+    this, SLOT( _triggered_actionOpenSegmentation( ) )
+    );
   QObject::connect(
     this->m_UI->actionOpenInputPolyData, SIGNAL( triggered( ) ),
     this, SLOT( _triggered_actionOpenInputPolyData( ) )
@@ -227,6 +231,75 @@ _triggered_actionOpenInputImage( )
       );
 }
 
+// -------------------------------------------------------------------------
+void ImageMPR::
+_triggered_actionOpenSegmentation( )
+{
+  // Show dialog and check if it was accepted
+  QFileDialog dialog( this );
+  dialog.setFileMode( QFileDialog::ExistingFiles );
+  dialog.setDirectory( tr( "." ) );
+  dialog.setNameFilter(
+    tr( "Medical image files (*.mhd *.bin *.dcm);;All files (*)" )
+    );
+  dialog.setDefaultSuffix( tr( "mhd" ) );
+  if( !( dialog.exec( ) ) )
+    return;
+  
+  this->m_InputImage = NULL;
+
+  // Get a reader from plugins
+  TPluginFilter::Pointer reader =
+    this->m_Plugins.CreateProcessObject( this->m_ImageReaderClass );
+
+  // Configure reader
+  TParameters reader_params = reader->GetDefaultParameters( );
+  QStringList q_fnames = dialog.selectedFiles( );
+  QStringList::const_iterator qIt = q_fnames.begin( );
+  for( ; qIt != q_fnames.end( ); ++qIt )
+    reader_params.AddValueToStringList( "FileNames", qIt->toStdString( ) );
+  reader->SetParameters( reader_params );
+
+  // Execute and get error message, if any
+  QApplication::setOverrideCursor( Qt::WaitCursor );
+  this->setEnabled( false );
+  std::string err = reader->Update( );
+  QApplication::restoreOverrideCursor( );
+  this->setEnabled( true );
+
+  // Assign fresh image, if any
+  if( err == "" )
+  {
+    this->m_InputSegmentation = reader->GetOutput< TPluginImage >( 0 );
+    reader->DisconnectOutputs( );
+    if( this->m_InputSegmentation.IsNotNull( ) )
+    {
+      vtkImageData* vtk_id = this->m_InputSegmentation->GetVTKImageData( );
+      if( vtk_id != NULL )
+      {
+        /*
+          this->m_MPRObjects->SetImage( vtk_id );
+          this->m_MPRObjects->ResetCameras( );
+          this->m_MPRObjects->RenderAll( );
+        */
+      }
+      else
+        QMessageBox::critical(
+          this,
+          tr( "Error message" ),
+          tr( "Read image does not have a valid VTK converter." )
+          );
+
+    } // fi
+  }
+  else
+    QMessageBox::critical(
+      this,
+      tr( "Error reading single image" ),
+      tr( err.c_str( ) )
+      );
+}
+
 // -------------------------------------------------------------------------
 void ImageMPR::
 _triggered_actionOpenInputPolyData( )
index ba05de9f9de5c0f88264f967132f8b1c3c93b35a..1b568051e9f8f5b06f76fa5a8c5698a3b1ede21e 100644 (file)
@@ -55,6 +55,7 @@ protected:
 private slots:
   void _triggered_actionOpenPlugins( );
   void _triggered_actionOpenInputImage( );
+  void _triggered_actionOpenSegmentation( );
   void _triggered_actionOpenInputPolyData( );
   void _triggered_actionImageToImage( );
   void _triggered_actionImageToMesh( );
@@ -75,6 +76,7 @@ private:
 
   // Real data
   TPluginImage::Pointer m_InputImage;
+  TPluginImage::Pointer m_InputSegmentation;
   TPluginMesh::Pointer  m_InputMesh;
 
   // Visualization stuff
index 31ada1d8f978a6d22f790d6cda42a9a2c72a60b2..8e0ee04ffef39fdbb7949e0ec908201c52e7b15d 100644 (file)
      <x>0</x>
      <y>0</y>
      <width>718</width>
-     <height>25</height>
+     <height>27</height>
     </rect>
    </property>
    <widget class="QMenu" name="menuFile">
     <addaction name="actionOpenPlugins"/>
     <addaction name="separator"/>
     <addaction name="actionOpenInputImage"/>
+    <addaction name="actionOpenSegmentation"/>
     <addaction name="actionOpenInputPolyData"/>
     <addaction name="separator"/>
     <addaction name="actionExit"/>
     <string>dasdasd</string>
    </property>
   </action>
+  <action name="actionOpenSegmentation">
+   <property name="text">
+    <string>Open segmentation</string>
+   </property>
+  </action>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <customwidgets>