]> Creatis software - cpPlugins.git/blobdiff - appli/PipelineEditor/PipelineEditor.cxx
Moved to version 1.0
[cpPlugins.git] / appli / PipelineEditor / PipelineEditor.cxx
index f49c2a43ad05d1f542d7da7e357c017944687740..05dee60e955b10fb76b82e359eaa850c7f574fd0 100644 (file)
-#include <PipelineEditor.h>
-#include <ui_PipelineEditor.h>
+// =========================================================================
+// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+// =========================================================================
 
-#include <cpPlugins/Utility.h>
-#include <cpExtensions/QT/SimpleMPRWidget.h>
-#include <cpExtensions/QT/ImageWidget.h>
-#include <cpExtensions/QT/ActorsWidgetInterface.h>
-#include <vtkImageData.h>
-#include <vtkPolyData.h>
+#include "PipelineEditor.h"
+#include <QStandardPaths>
 
 // -------------------------------------------------------------------------
 PipelineEditor::
-PipelineEditor( int argc, char* argv[], QWidget* parent )
-  : Superclass( argc, argv, parent ),
-    m_UI( new Ui::PipelineEditor )
+PipelineEditor( QWidget* parent )
+  : QMainWindow( parent ),
+    Ui::PipelineEditor( )
 {
-  // Basic configuration
-  this->m_BaseWindowTitle = "PipelineEditor - ";
-  this->m_UI->setupUi( this );
-  this->setCanvas( this->m_UI->Canvas );
-  this->setNavigator( this->m_UI->Navigator );
-  this->m_UI->Navigator->Update( );
-
-  // Connect slots <-> signals
-  cpBaseQtApplication_ConnectAction( actionLoadDirectory, _loadPluginsFromPath );
-  cpBaseQtApplication_ConnectAction( actionLoadLibrary, _loadPlugins );
-  cpBaseQtApplication_ConnectAction( actionOpenWorkspace, _loadWorkspace );
-  cpBaseQtApplication_ConnectAction( actionSaveWorkspace, _saveWorkspace );
-  cpBaseQtApplication_ConnectAction( actionSaveWorkspaceAs, _saveWorkspace );
-  cpBaseQtApplication_ConnectAction( actionActorsProperties, _actorsProperties );
-  this->m_UI->Canvas->connectOutputPortSlot(
-    this, SLOT( _slotView( const std::string&, bool ) )
-    );
-
-  // Load command-line given workspace (if any)
-  if( argc > 1 )
-    this->_loadWorkspace( argv[ 1 ] );
+  this->setupUi( this );
 }
 
 // -------------------------------------------------------------------------
 PipelineEditor::
 ~PipelineEditor( )
 {
-  delete this->m_UI;
 }
 
 // -------------------------------------------------------------------------
-void PipelineEditor::
-_slotView( const std::string& name, bool show )
-{
-  /* TODO
-     typedef cpExtensions::QT::ActorsWidgetInterface _TViewer;
-
-     // Get filter parameters
-     std::vector< std::string > tokens;
-     cpPlugins::Tokenize( tokens, name, "@" );
-     if( tokens.size( ) != 2 )
-     return;
-     auto filter_name = tokens[ 1 ];
-     auto output_name = tokens[ 0 ];
-
-     // Process data
-     if( show )
-     {
-     try
-     {
-     auto ws = this->workspace( this->m_ActiveWS );
-     auto filter = ws->GetFilter( filter_name );
-     cpBaseQtApplication_Execute( filter->Update( ) );
-     auto image = filter->GetOutputData< vtkImageData >( output_name );
-     auto mesh = filter->GetOutputData< vtkPolyData >( output_name );
-     _TViewer* viewer = NULL;
-     if( image != NULL )
-     {
-     int dim = image->GetDataDimension( );
-     if( dim == 2 )
-     viewer =
-     this->_configureViewer< cpExtensions::QT::ImageWidget >(
-     this->m_UI->Viewer
-     );
-     else if( dim == 3 )
-     viewer =
-     this->_configureViewer< cpExtensions::QT::SimpleMPRWidget >(
-     this->m_UI->Viewer
-     );
-     }
-     else if( mesh != NULL )
-     {
-     viewer =
-     this->_configureViewer< cpExtensions::QT::SimpleMPRWidget >(
-     this->m_UI->Viewer
-     );
+#include <QApplication>
+#include <QCommandLineOption>
+#include <QCommandLineParser>
 
-     } // fi
-     if(
-     dynamic_cast< QWidget* >( viewer ) !=
-     dynamic_cast< QWidget* >( this->m_UI->Viewer )
-     )
-     {
-     delete this->m_UI->Viewer;
-     this->m_UI->Viewer = dynamic_cast< QWidget* >( viewer );
-     this->m_UI->MainSplitter->insertWidget( 0, this->m_UI->Viewer );
-     this->setViewer( viewer );
-
-     } // fi
-     if( image != NULL )
-     {
-     this->m_Blocker.block( );
-     auto mpr = dynamic_cast< cpExtensions::QT::SimpleMPRWidget* >( viewer );
-     auto imv = dynamic_cast< cpExtensions::QT::ImageWidget* >( viewer );
-     if( mpr != NULL )
-     mpr->SetImage( image, name );
-     else if( imv != NULL )
-     imv->SetImage( image, name );
-     this->m_Blocker.unblock( );
-     }
-     else if( mesh != NULL )
-     {
-     this->m_Blocker.block( );
-     auto mpr = dynamic_cast< cpExtensions::QT::SimpleMPRWidget* >( viewer );
-     if( mpr != NULL )
-     mpr->Add( mesh, name );
-     this->m_Blocker.unblock( );
+int main( int argc, char* argv[] )
+{
+  // TODO: Q_INIT_RESOURCE(application);
 
-     } // fi
-     }
-     catch( std::exception& err )
-     {
-     QMessageBox::critical(
-     NULL,
-     QMessageBox::tr( "Error showing data" ),
-     QMessageBox::tr( err.what( ) )
-     );
+  QApplication app( argc, argv );
+  QCoreApplication::setOrganizationName( "Creatis-PUJ" );
+  QCoreApplication::setApplicationName( "cpPlugins_PipelineEditor" );
+  QCoreApplication::setApplicationVersion( "1.0.0" );
 
-     } // yrt
+  QCommandLineParser parser;
+  parser.setApplicationDescription( QCoreApplication::applicationName( ) );
+  parser.addHelpOption( );
+  parser.addVersionOption( );
+  parser.addPositionalArgument( "file", "The file to open." );
+  parser.process( app );
 
-     } // fi
+  PipelineEditor win;
+  /* TODO
+     if( !parser.positionalArguments( ).isEmpty( ) )
+     win.loadFile( parser.positionalArguments( ).first( ) );
   */
+  win.show( );
+  return( app.exec( ) );
 }
 
-// -------------------------------------------------------------------------
-#include <cpBaseQtApplication/MainHelper.h>
-cpBaseQtApplication_Main( PipelineEditor );
-cpBaseQtApplication_MainComplement;
-
 // eof - $RCSfile$