]> Creatis software - cpPlugins.git/blobdiff - appli/PipelineEditor/PipelineEditor.cxx
Moved to version 1.0
[cpPlugins.git] / appli / PipelineEditor / PipelineEditor.cxx
index a4cd75e79a82be20ef74ed1d545da061eda89417..05dee60e955b10fb76b82e359eaa850c7f574fd0 100644 (file)
-#include "PipelineEditor.h"
-#include "ui_PipelineEditor.h"
-
-#include <QMessageBox>
-
-#include <cpPipelineEditor/Editor.h>
-#include <cpExtensions/QT/PropertyWidget.h>
+// =========================================================================
+// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+// =========================================================================
 
-#include <vtkImageData.h>
-#include <vtkPolyData.h>
-#include <vtkRenderWindowInteractor.h>
+#include "PipelineEditor.h"
+#include <QStandardPaths>
 
 // -------------------------------------------------------------------------
 PipelineEditor::
-PipelineEditor( int argc, char* argv[], QApplication* app, QWidget* parent )
-  : Superclass( argc, argv, app, parent ),
-    m_UI( new Ui::PipelineEditor )
+PipelineEditor( QWidget* parent )
+  : QMainWindow( parent ),
+    Ui::PipelineEditor( )
 {
-  // Basic configuration
-  this->m_UI->setupUi( this );
-  this->_Configure(
-    this->m_UI->LoadedPlugins,
-    this->m_UI->Viewer,
-    this->m_UI->Canvas->editor( )
-    );
-
-  // Connect actions to slots
-  this->connect(
-    this->m_UI->ButtonLoadPluginsFile, SIGNAL( clicked( ) ),
-    this, SLOT( _InteractiveLoadPlugins( ) )
-    );
-  this->connect(
-    this->m_UI->ButtonLoadPluginsPath, SIGNAL( clicked( ) ),
-    this, SLOT( _InteractiveLoadPluginsFromPath( ) )
-    );
-  this->connect(
-    this->m_UI->ActionOpenWorkspace, SIGNAL( triggered( ) ),
-    this, SLOT( _InteractiveLoadWorkspace( ) )
-    );
-  this->connect(
-    this->m_UI->ActionSaveWorkspace, SIGNAL( triggered( ) ),
-    this, SLOT( _InteractiveSaveWorkspace( ) )
-    );
-  this->connect(
-    this->m_UI->Canvas->editor( ),
-    SIGNAL( execFilter( const std::string& ) ),
-    this,
-    SLOT( _ExecFilter( const std::string& ) )
-    );
-  this->connect(
-    this->m_UI->Canvas->editor( ),
-    SIGNAL( showFilterOutput( const std::string&, const std::string& ) ),
-    this,
-    SLOT( _ShowFilterOutput( const std::string&, const std::string& ) )
-    );
-  this->connect(
-    this->m_UI->Canvas->editor( ),
-    SIGNAL( hideFilterOutput( const std::string&, const std::string& ) ),
-    this,
-    SLOT( _HideFilterOutput( const std::string&, const std::string& ) )
-    );
-  this->connect(
-    this->m_UI->Canvas->editor( ),
-    SIGNAL( visualPropertiesFilterOutput( const std::string&, const std::string& ) ),
-    this,
-    SLOT( _PropertiesFilterOutput( const std::string&, const std::string& ) )
-    );
+  this->setupUi( this );
 }
 
 // -------------------------------------------------------------------------
 PipelineEditor::
 ~PipelineEditor( )
 {
-  delete this->m_UI;
 }
 
 // -------------------------------------------------------------------------
-void PipelineEditor::
-_ShowFilterOutput(
-  const std::string& filter_name, const std::string& output_name
-  )
-{
-  // Update filter, if needed
-  this->_ExecFilter( filter_name );
-
-  // Get output
-  auto filter = this->m_Workspace.GetFilter( filter_name );
-  if( filter != NULL )
-  {
-    auto out = filter->GetOutput( output_name );
-    if( out != NULL )
-    {
-      auto id = out->GetVTK< vtkImageData >( );
-      auto md = out->GetVTK< vtkPolyData >( );
-      if( id != NULL )
-      {
-        this->_Block( );
-        this->m_UI->Viewer->Clear( );
-        this->m_UI->Viewer->SetMainImage( id );
-        auto actors = this->m_UI->Viewer->GetMainImageActors( );
-        out->ClearVTKActors( );
-        for( auto aIt = actors.begin( ); aIt != actors.end( ); ++aIt )
-          out->AddVTKActor( aIt->first, aIt->second );
-        this->_UnBlock( );
-      }
-      else if( md != NULL )
-      {
-        this->_Block( );
-        this->m_UI->Viewer->AddMesh( md );
-        out->AddVTKActor(
-          this->m_UI->Viewer->GetActor( md ),
-          this->m_UI->Viewer->GetRenderer( 3 )
-          );
-        this->_UnBlock( );
-      }
-      else
-        QMessageBox::critical(
-          this,
-          QMessageBox::tr( "Error showing data" ),
-          QMessageBox::tr( "No known VTK conversion!" )
-          );
-    }
-    else
-      QMessageBox::critical(
-        this,
-        QMessageBox::tr( "Error showing data" ),
-        QMessageBox::tr( "Unknown port name." )
-        );
-  }
-  else
-    QMessageBox::critical(
-      this,
-      QMessageBox::tr( "Error showing data" ),
-      QMessageBox::tr( "Unknown filter." )
-      );
-}
+#include <QApplication>
+#include <QCommandLineOption>
+#include <QCommandLineParser>
 
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_HideFilterOutput(
-  const std::string& filter_name, const std::string& output_name
-  )
+int main( int argc, char* argv[] )
 {
-  // Get output
-  /* TODO
-     auto filter = this->m_Workspace.GetFilter( filter_name );
-     if( filter != NULL )
-     {
-     auto output = filter->GetOutputData( output_name );
-     if( output != NULL )
-     {
-     std::string data_name = output_name + "@" + filter_name;
-     this->m_UI->Viewer->HideData( data_name );
+  // TODO: Q_INIT_RESOURCE(application);
 
-     } // fi
+  QApplication app( argc, argv );
+  QCoreApplication::setOrganizationName( "Creatis-PUJ" );
+  QCoreApplication::setApplicationName( "cpPlugins_PipelineEditor" );
+  QCoreApplication::setApplicationVersion( "1.0.0" );
 
-     } // fi
-  */
-}
+  QCommandLineParser parser;
+  parser.setApplicationDescription( QCoreApplication::applicationName( ) );
+  parser.addHelpOption( );
+  parser.addVersionOption( );
+  parser.addPositionalArgument( "file", "The file to open." );
+  parser.process( app );
 
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_PropertiesFilterOutput(
-  const std::string& filter_name, const std::string& output_name
-  )
-{
-  // Get output
-  auto filter = this->m_Workspace.GetFilter( filter_name );
-  if( filter != NULL )
-  {
-    auto output = filter->GetOutputData< vtkPolyData >( output_name );
-    if( output != NULL )
-    {
-      auto actor = this->m_UI->Viewer->GetActor( output );
-      if( actor != NULL )
-      {
-        cpExtensions::QT::PropertyWidget* wdg =
-          new cpExtensions::QT::PropertyWidget( NULL );
-        wdg->SetProp( actor );
-        wdg->SetRenderWindow(
-          this->m_UI->Viewer->GetInteractor( 3 )->GetRenderWindow( )
-          );
-        wdg->show( );
-
-      } // fi
-    }
-    else
-      QMessageBox::critical(
-        this,
-        QMessageBox::tr( "Error showing data" ),
-        QMessageBox::tr( "No known VTK conversion!" )
-        );
-
-  } // fi
+  PipelineEditor win;
+  /* TODO
+     if( !parser.positionalArguments( ).isEmpty( ) )
+     win.loadFile( parser.positionalArguments( ).first( ) );
+  */
+  win.show( );
+  return( app.exec( ) );
 }
 
 // eof - $RCSfile$