// Configure paramereters
auto dlg_res = this->m_Plugins.ConfigureActiveFilter( );
- if( dlg_res == TPlugins::TProcessObject::DialogResult_Cancel )
+ if( !dlg_res )
{
// Just deactivate filter, since it was canceled
this->m_Plugins.DeactivateFilter( );
return;
}
- else if( dlg_res == TPlugins::TProcessObject::DialogResult_NoModal )
+ else
{
// Execute automatic filter and associate outputs
this->UpdateActualFilter( );
#include <QFileDialog>
#include <QMessageBox>
+
+#include <vtkImageData.h>
+#include <vtkPolyData.h>
+
#include <cpPlugins/Interface/Workspace.h>
+#include <cpPlugins/Interface/DataObject.h>
// -------------------------------------------------------------------------
#define App_cpPipelineEditor_ConnectAction( ACTION ) \
- QObject::connect( \
+ this->connect( \
this->m_UI->Action##ACTION, SIGNAL( triggered( ) ), \
this, SLOT( _Action##ACTION( ) ) \
)
// -------------------------------------------------------------------------
#define App_cpPipelineEditor_ConnectButton( BUTTON ) \
- QObject::connect( \
+ this->connect( \
this->m_UI->Button##BUTTON, SIGNAL( clicked( ) ), \
this, SLOT( _Button##BUTTON( ) ) \
)
this->m_Workspace = new cpPlugins::Interface::Workspace( );
this->m_Workspace->SetPlugins( this->m_Plugins );
this->m_UI->Canvas->editor( )->setWorkspace( this->m_Workspace );
+ this->m_Workspace->AddInteractor( this->m_UI->Viewer->GetInteractor( 0 ) );
+ this->m_Workspace->AddInteractor( this->m_UI->Viewer->GetInteractor( 1 ) );
+ this->m_Workspace->AddInteractor( this->m_UI->Viewer->GetInteractor( 2 ) );
+ this->m_Workspace->AddInteractor( this->m_UI->Viewer->GetInteractor( 3 ) );
// Connect actions to slots
App_cpPipelineEditor_ConnectButton( LoadPluginsFile );
App_cpPipelineEditor_ConnectButton( LoadPluginsPath );
App_cpPipelineEditor_ConnectAction( OpenWorkspace );
App_cpPipelineEditor_ConnectAction( SaveWorkspace );
+ 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& ) )
+ );
}
// -------------------------------------------------------------------------
);
}
+
+// -------------------------------------------------------------------------
+void App_cpPipelineEditor::
+_ExecFilter( const std::string& filter_name )
+{
+ if( this->m_Workspace != NULL )
+ {
+ // Update filter, if needed
+ std::string err = this->m_Workspace->Execute( filter_name );
+ if( err != "" )
+ QMessageBox::critical(
+ this,
+ QMessageBox::tr( "Error executing filter" ),
+ QMessageBox::tr( err.c_str( ) )
+ );
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+void App_cpPipelineEditor::
+_ShowFilterOutput(
+ const std::string& filter_name, const std::string& output_name
+ )
+{
+ typedef cpPlugins::Interface::DataObject _TDataObject;
+
+ // Update filter, if needed
+ this->_ExecFilter( filter_name );
+
+ // Get output
+ auto filter = this->m_Workspace->GetFilter( filter_name );
+ if( filter != NULL )
+ {
+ auto output = filter->GetOutput< _TDataObject >( output_name );
+ if( output != NULL )
+ {
+ std::string data_name = output_name + "@" + filter_name;
+ if( this->m_UI->Viewer->AddData( output, data_name, "" ) )
+ {
+ if( this->m_UI->Viewer->GetNumberOfData( ) > 1 )
+ this->m_UI->Viewer->SetDataColor( data_name, 1, 0, 0 );
+ else
+ this->m_UI->Viewer->SetMainImage( data_name );
+ this->m_UI->Viewer->ShowData( data_name );
+ }
+ else
+ QMessageBox::critical(
+ this,
+ QMessageBox::tr( "Error showing data" ),
+ QMessageBox::tr( "No known VTK conversion!" )
+ );
+
+ } // fi
+
+ } // fi
+}
+
// eof - $RCSfile$
void _ButtonLoadPluginsPath( );
void _ActionOpenWorkspace( );
void _ActionSaveWorkspace( );
+ void _ExecFilter( const std::string& filter_name );
+ void _ShowFilterOutput(
+ const std::string& filter_name, const std::string& output_name
+ );
private:
Ui::App_cpPipelineEditor* m_UI;
<widget class="QWidget" name="MainWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
- <widget class="QSplitter" name="splitter">
+ <widget class="QSplitter" name="splitter_2">
<property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <enum>Qt::Vertical</enum>
</property>
- <widget class="QFrame" name="frame">
+ <widget class="cpPlugins::Interface::SimpleMPRWidget" name="Viewer" native="true">
<property name="minimumSize">
<size>
- <width>251</width>
- <height>331</height>
+ <width>0</width>
+ <height>200</height>
</size>
</property>
- <property name="frameShape">
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Raised</enum>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QGroupBox" name="groupBox">
- <property name="minimumSize">
- <size>
- <width>202</width>
- <height>67</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>202</width>
- <height>67</height>
- </size>
- </property>
- <property name="title">
- <string>Plugins</string>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QPushButton" name="ButtonLoadPluginsFile">
- <property name="minimumSize">
- <size>
- <width>85</width>
- <height>31</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>85</width>
- <height>31</height>
- </size>
- </property>
- <property name="text">
- <string>File</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="ButtonLoadPluginsPath">
- <property name="minimumSize">
- <size>
- <width>85</width>
- <height>31</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>85</width>
- <height>31</height>
- </size>
- </property>
- <property name="text">
- <string>Path</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QTreeWidget" name="LoadedPlugins">
- <property name="minimumSize">
- <size>
- <width>229</width>
- <height>0</height>
- </size>
- </property>
- <property name="dragEnabled">
- <bool>true</bool>
- </property>
- <property name="dragDropMode">
- <enum>QAbstractItemView::DragOnly</enum>
- </property>
- <column>
- <property name="text">
- <string>Loaded plugins</string>
- </property>
- </column>
- </widget>
- </item>
- </layout>
</widget>
- <widget class="cpPipelineEditor::Canvas" name="Canvas" native="true">
- <property name="minimumSize">
- <size>
- <width>500</width>
- <height>0</height>
- </size>
- </property>
- <property name="acceptDrops">
- <bool>true</bool>
+ <widget class="QSplitter" name="splitter">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
</property>
+ <widget class="QFrame" name="frame">
+ <property name="minimumSize">
+ <size>
+ <width>251</width>
+ <height>331</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="minimumSize">
+ <size>
+ <width>202</width>
+ <height>67</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>202</width>
+ <height>67</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>Plugins</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QPushButton" name="ButtonLoadPluginsFile">
+ <property name="minimumSize">
+ <size>
+ <width>85</width>
+ <height>31</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>85</width>
+ <height>31</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>File</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="ButtonLoadPluginsPath">
+ <property name="minimumSize">
+ <size>
+ <width>85</width>
+ <height>31</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>85</width>
+ <height>31</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Path</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTreeWidget" name="LoadedPlugins">
+ <property name="minimumSize">
+ <size>
+ <width>229</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="dragEnabled">
+ <bool>true</bool>
+ </property>
+ <property name="dragDropMode">
+ <enum>QAbstractItemView::DragOnly</enum>
+ </property>
+ <column>
+ <property name="text">
+ <string>Loaded plugins</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="cpPipelineEditor::Canvas" name="Canvas" native="true">
+ <property name="minimumSize">
+ <size>
+ <width>500</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="acceptDrops">
+ <bool>true</bool>
+ </property>
+ </widget>
</widget>
</widget>
</item>
<header>cpPipelineEditor/Canvas.h</header>
<container>1</container>
</customwidget>
+ <customwidget>
+ <class>cpPlugins::Interface::SimpleMPRWidget</class>
+ <extends>QWidget</extends>
+ <header location="global">cpPlugins/Interface/SimpleMPRWidget.h</header>
+ <container>1</container>
+ </customwidget>
</customwidgets>
<resources/>
<connections>
// -------------------------------------------------------------------------
void cpExtensions::Interaction::ImageInteractorStyle::
-GetSeed( unsigned int id, double pos[ 3 ] ) const
+GetSeedAsPoint( unsigned int id, double pos[ 3 ] ) const
{
if( this->m_SeedWidget != NULL )
this->m_SeedWidget->Representation->GetSeedWorldPosition( id, pos );
}
+// -------------------------------------------------------------------------
+void cpExtensions::Interaction::ImageInteractorStyle::
+GetSeedAsIndex( unsigned int id, int idx[ 3 ] ) const
+{
+ /* TODO
+ if( this->m_SeedWidget != NULL )
+ this->m_SeedWidget->Representation->GetSeedWorldPosition( id, pos );
+ */
+}
+
// -------------------------------------------------------------------------
cpExtensions::Interaction::ImageInteractorStyle::
ImageInteractorStyle( )
void SeedWidgetOff( );
void SetSeedWidgetCommand( vtkCommand* cmd );
unsigned int GetNumberOfSeeds( ) const;
- void GetSeed( unsigned int id, double pos[ 3 ] ) const;
+ void GetSeedAsPoint( unsigned int id, double pos[ 3 ] ) const;
+ void GetSeedAsIndex( unsigned int id, int pos[ 3 ] ) const;
protected:
ImageInteractorStyle( );
\r
#include "Port.h"\r
#include "Connection.h"\r
+#include "Editor.h"\r
\r
// -------------------------------------------------------------------------\r
cpPipelineEditor::Block::\r
m_VertMargin( 5 ),\r
m_NamePort( NULL ),\r
m_TypePort( NULL ),\r
- m_Filter( filter )\r
+ m_Filter( filter ),\r
+ m_Editor( NULL )\r
{\r
QPainterPath p;\r
p.addRoundedRect( -50, -15, 100, 30, 5, 5 );\r
{\r
}\r
\r
+// -------------------------------------------------------------------------\r
+cpPipelineEditor::Editor* cpPipelineEditor::Block::\r
+editor( )\r
+{\r
+ return( this->m_Editor );\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+const cpPipelineEditor::Editor* cpPipelineEditor::Block::\r
+editor( ) const\r
+{\r
+ return( this->m_Editor );\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+void cpPipelineEditor::Block::\r
+setEditor( cpPipelineEditor::Editor* editor )\r
+{\r
+ this->m_Editor = editor;\r
+}\r
+\r
// -------------------------------------------------------------------------\r
void cpPipelineEditor::Block::\r
setNamePort( const QString& txt )\r
auto res = this->m_Filter->ExecConfigurationDialog( NULL );\r
}\r
else if( selectedAction == updateAction )\r
- {\r
- } // fi\r
+ this->m_Editor->updateFilter( this->namePort( ).toStdString( ) );\r
}\r
\r
// eof - $RCSfile$\r
\r
namespace cpPipelineEditor\r
{\r
+ class Editor;\r
class Port;\r
class NamePort;\r
class TypePort;\r
);\r
virtual ~Block( );\r
\r
+ Editor* editor( );\r
+ const Editor* editor( ) const;\r
+ void setEditor( Editor* editor );\r
+\r
void setNamePort( const QString& txt );\r
InputPort* addInputPort( const QString& txt );\r
OutputPort* addOutputPort( const QString& txt );\r
const QStyleOptionGraphicsItem* option,\r
QWidget* widget\r
);\r
- \r
+\r
protected:\r
QVariant itemChange( GraphicsItemChange change, const QVariant& value );\r
void _setTypePort( const QString& txt );\r
std::map< std::string, OutputPort* > m_OutputPorts;\r
\r
TFilter* m_Filter;\r
+ Editor* m_Editor;\r
};\r
\r
} // ecapseman\r
#include <QGraphicsSceneResizeEvent>\r
#include <QGraphicsSceneWheelEvent>\r
#include <QInputDialog>\r
+#include <QMessageBox>\r
\r
#include "Port.h"\r
#include "Connection.h"\r
\r
// Add block\r
Block* b = new Block( f, 0, this->m_Scene );\r
+ b->setEditor( this );\r
b->setPos( pnt );\r
\r
// Mark exposed inputs\r
return( this->Superclass::eventFilter( o, e ) );\r
}\r
\r
+// -------------------------------------------------------------------------\r
+void cpPipelineEditor::Editor::\r
+updateFilter( const std::string& filter_name )\r
+{\r
+ emit execFilter( filter_name );\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+void cpPipelineEditor::Editor::\r
+showOutputData(\r
+ const std::string& filter_name, const std::string& output_name\r
+ )\r
+{\r
+ emit showFilterOutput( filter_name, output_name );\r
+}\r
+\r
// -------------------------------------------------------------------------\r
cpPipelineEditor_Editor_Callback_CODE( ContextMenu )\r
{\r
void install( QGraphicsScene* s );\r
bool eventFilter( QObject* o, QEvent* e );\r
\r
+ void updateFilter( const std::string& filter_name );\r
+ void showOutputData(\r
+ const std::string& filter_name,\r
+ const std::string& output_name\r
+ );\r
+\r
+ signals:\r
+ void execFilter( const std::string& filter_name );\r
+ void showFilterOutput(\r
+ const std::string& filter_name,\r
+ const std::string& output_name\r
+ );\r
+\r
private:\r
QGraphicsItem* itemAt( const QPointF& pos );\r
\r
#include "Port.h"\r
#include "Connection.h"\r
+#include "Block.h"\r
+#include "Editor.h"\r
\r
#include <QGraphicsScene>\r
+#include <QGraphicsSceneContextMenuEvent>\r
#include <QFontMetrics>\r
+#include <QMenu>\r
#include <QPainter>\r
#include <QPen>\r
\r
return( value );\r
}\r
\r
+// -------------------------------------------------------------------------\r
+void cpPipelineEditor::OutputPort::\r
+contextMenuEvent( QGraphicsSceneContextMenuEvent* evt )\r
+{\r
+ if( this->m_Block == NULL )\r
+ return;\r
+ \r
+ QMenu menu;\r
+ QAction* showAction = menu.addAction( "Show" );\r
+ QAction* hideAction = menu.addAction( "Hide" );\r
+ QAction* selectedAction = menu.exec( evt->screenPos( ) );\r
+\r
+ if( selectedAction == showAction )\r
+ {\r
+ this->m_Block->editor( )->showOutputData(\r
+ this->m_Block->namePort( ).toStdString( ),\r
+ this->name( ).toStdString( )\r
+ );\r
+ }\r
+ else if( selectedAction == hideAction )\r
+ {\r
+ } // fi\r
+}\r
+\r
// eof - $RCSfile$\r
QVariant itemChange( GraphicsItemChange change, const QVariant& value );\r
virtual void _updateLabels( );\r
\r
+ virtual void contextMenuEvent( QGraphicsSceneContextMenuEvent* evt );\r
+\r
protected:\r
QVector< Connection* > m_Connections;\r
};\r
if( i->second.first == Self::Y##List ) \
{ \
std::stringstream str; \
- str << i->second.second << "#" << v; \
+ if( i->second.second != "" ) \
+ str << i->second.second << "#"; \
+ str << v; \
i->second.second = str.str( ); \
} \
} \
#include <cpPlugins/Interface/Plugins.h>
#include <cpPlugins/Interface/BaseApplication.h>
+/* TODO
class SingleSeedCommand
: public vtkCommand
{
cpPlugins::Interface::ParametersQtDialog* Dialog;
std::string Name;
};
+*/
// -------------------------------------------------------------------------
cpPlugins::Interface::ParametersQtDialog::
ParametersQtDialog( QWidget* parent, Qt::WindowFlags f )
: QDialog( parent, f ),
- m_Parameters( NULL )
+ m_Parameters( NULL ),
+ m_Interactive( false )
{
this->m_Title = new QLabel( this );
this->m_Title->setText( "Parameters dialog title" );
return( this->m_Interactors );
}
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::ParametersQtDialog::
+isInteractive( ) const
+{
+ return( this->m_Interactive );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ParametersQtDialog::
+setInteractive( bool i )
+{
+ this->m_Interactive = i;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ParametersQtDialog::
+interactiveOn( )
+{
+ this->m_Interactive = true;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ParametersQtDialog::
+interactiveOff( )
+{
+ this->m_Interactive = false;
+}
+
// -------------------------------------------------------------------------
bool cpPlugins::Interface::ParametersQtDialog::
setParameters( Parameters* parameters )
this->m_Title->setText( title.str( ).c_str( ) );
// Put values
+ this->m_Widgets.clear( );
auto& raw_params = this->m_Parameters->GetRawParameters( );
for( auto pIt = raw_params.begin( ); pIt != raw_params.end( ); ++pIt )
{
#include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
#include <cpPlugins/Interface/Parameters.h>
-#include <cpExtensions/Interaction/ImageInteractorStyle.h>
#include <set>
+#include <vtkInteractorObserver.h>
+#include <vtkSmartPointer.h>
+
#include <QDialog>
#include <QDialogButtonBox>
#include <QGridLayout>
Q_OBJECT;
public:
- typedef cpExtensions::Interaction::ImageInteractorStyle TStyle;
-
typedef std::set< vtkRenderWindowInteractor* > TInteractors;
+ typedef
+ std::map< std::string, vtkSmartPointer< vtkInteractorObserver > >
+ TWidgets;
public:
ParametersQtDialog( QWidget* parent = 0, Qt::WindowFlags f = 0 );
void addInteractor( vtkRenderWindowInteractor* interactor );
TInteractors& getInteractors( );
const TInteractors& getInteractors( ) const;
+ bool isInteractive( ) const;
+ void setInteractive( bool i );
+ void interactiveOn( );
+ void interactiveOff( );
bool setParameters( Parameters* parameters );
virtual int exec( );
QDialogButtonBox* m_Buttons;
TInteractors m_Interactors;
+ TWidgets m_Widgets;
+ bool m_Interactive;
};
} // ecapseman
this->_ActivateIOFilter( "ImageReader" );
// Try to configure source
- if( this->ConfigureActiveFilter( ) == TProcessObject::DialogResult_Cancel )
+ if( !( this->ConfigureActiveFilter( ) ) )
{
this->DeactivateFilter( );
return( "" );
this->_ActivateIOFilter( "DicomSeriesReader" );
// Try to configure source
- if( this->ConfigureActiveFilter( ) == TProcessObject::DialogResult_Cancel )
+ if( !( this->ConfigureActiveFilter( ) ) )
{
this->DeactivateFilter( );
return( "" );
this->_ActivateIOFilter( "MeshReader" );
// Try to configure source
- if( this->ConfigureActiveFilter( ) == TProcessObject::DialogResult_Cancel )
+ if( !( this->ConfigureActiveFilter( ) ) )
{
this->DeactivateFilter( );
return( "" );
} // fi
// Try to configure source
- if( this->ConfigureActiveFilter( ) == TProcessObject::DialogResult_Cancel )
+ if( !( this->ConfigureActiveFilter( ) ) )
{
this->DeactivateFilter( );
return( false );
if( this->m_ActiveFilter.IsNotNull( ) )
return( this->m_ActiveFilter->ExecConfigurationDialog( this->m_Widget ) );
else
- return( TProcessObject::DialogResult_Cancel );
+ return( false );
}
// -------------------------------------------------------------------------
--- /dev/null
+#include <cpPlugins/Interface/PointList.h>
+
+// -------------------------------------------------------------------------
+unsigned long cpPlugins::Interface::PointList::
+GetNumberOfPoints( ) const
+{
+ return( this->m_NumberOfPoints );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::PointList::
+Clear( )
+{
+ this->m_ITKObject = NULL;
+ this->m_VTKObject = NULL;
+ this->m_NumberOfPoints = 0;
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::PointList::
+PointList( )
+ : Superclass( )
+{
+ this->Clear( );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::PointList::
+~PointList( )
+{
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPPLUGINS__INTERFACE__POINTLIST__H__
+#define __CPPLUGINS__INTERFACE__POINTLIST__H__
+
+#include <cpPlugins/Interface/DataObject.h>
+
+namespace cpPlugins
+{
+ namespace Interface
+ {
+ /**
+ */
+ class cpPlugins_Interface_EXPORT PointList
+ : public DataObject
+ {
+ public:
+ typedef PointList Self;
+ typedef DataObject Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro( PointList, DataObject );
+ cpPlugins_Id_Macro( PointList, DataObject );
+
+ public:
+ unsigned long GetNumberOfPoints( ) const;
+
+ void Clear( );
+
+ template< class P >
+ inline void AddPoint( const P& p );
+
+ template< class P >
+ inline P GetPoint( const unsigned long& i ) const;
+
+ protected:
+ PointList( );
+ virtual ~PointList( );
+
+ private:
+ // Purposely not implemented
+ PointList( const Self& );
+ Self& operator=( const Self& );
+
+ protected:
+ unsigned long m_NumberOfPoints;
+ };
+
+ } // ecapseman
+
+} // ecapseman
+
+#include <cpPlugins/Interface/PointList.hxx>
+
+#endif // __CPPLUGINS__INTERFACE__POINTLIST__H__
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPPLUGINS__INTERFACE__POINTLIST__HXX__
+#define __CPPLUGINS__INTERFACE__POINTLIST__HXX__
+
+#include <itkSimpleDataObjectDecorator.h>
+#include <utility>
+#include <vector>
+
+// -------------------------------------------------------------------------
+template< class P >
+void cpPlugins::Interface::PointList::
+AddPoint( const P& p )
+{
+ typedef itk::SimpleDataObjectDecorator< std::vector< P > > _T;
+
+ _T* container = NULL;
+ if( this->m_NumberOfPoints == 0 )
+ {
+ typename _T::Pointer obj = _T::New( );
+ container = obj.GetPointer( );
+ this->m_ITKObject = container;
+ }
+ else
+ container = dynamic_cast< _T* >( this->m_ITKObject.GetPointer( ) );
+
+ if( container != NULL )
+ {
+ container->Get( ).push_back( p );
+ this->m_NumberOfPoints += 1;
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+template< class P >
+P cpPlugins::Interface::PointList::
+GetPoint( const unsigned long& i ) const
+{
+ typedef itk::SimpleDataObjectDecorator< std::vector< P > > _T;
+
+ P ret;
+ if( i < this->m_NumberOfPoints )
+ {
+ _T* container = dynamic_cast< _T* >( this->m_ITKObject.GetPointer( ) );
+ if( container != NULL )
+ ret = container->Get( )[ i ];
+
+ } // fi
+ return( ret );
+}
+
+#endif // __CPPLUGINS__INTERFACE__POINTLIST__HXX__
+
+// eof - $RCSfile$
i->second->DisconnectPipeline( );
}
+// -------------------------------------------------------------------------
+const cpPlugins::Interface::ProcessObject::
+TInteractors& cpPlugins::Interface::ProcessObject::
+GetInteractors( ) const
+{
+ return( this->m_Interactors );
+}
+
// -------------------------------------------------------------------------
void cpPlugins::Interface::ProcessObject::
AddInteractor( vtkRenderWindowInteractor* interactor )
}
// -------------------------------------------------------------------------
-cpPlugins::Interface::ProcessObject::
-DialogResult cpPlugins::Interface::ProcessObject::
+bool cpPlugins::Interface::ProcessObject::
ExecConfigurationDialog( QWidget* parent )
{
- DialogResult r = Self::DialogResult_Cancel;
+ bool r = false;
#ifdef cpPlugins_Interface_QT4
this->m_ParametersDialog->setParent( NULL );
this->m_ParametersDialog->setParameters( this->m_Parameters );
- if( this->m_ParametersDialog->exec( ) == 1 )
- r = Self::DialogResult_NoModal;
- else
- r = Self::DialogResult_Cancel;
+ r = ( this->m_ParametersDialog->exec( ) == 1 );
}
else
- r = Self::DialogResult_Cancel;
-
+ r = false;
+
#endif // cpPlugins_Interface_QT4
return( r );
typedef Parameters TParameters;
typedef std::set< vtkRenderWindowInteractor* > TInteractors;
-
- enum DialogResult
- {
- DialogResult_NoModal = 0,
- DialogResult_Modal,
- DialogResult_Cancel
- };
+ typedef bool DialogResult;
public:
itkTypeMacro( ProcessObject, Object );
virtual std::string Update( );
virtual void DisconnectOutputs( );
+ virtual const TInteractors& GetInteractors( ) const;
virtual void AddInteractor( vtkRenderWindowInteractor* interactor );
- virtual DialogResult ExecConfigurationDialog( QWidget* parent );
+ virtual bool ExecConfigurationDialog( QWidget* parent );
template< class T >
inline T* GetITK( );
delete this->m_UI;
}
+// -------------------------------------------------------------------------
+unsigned int cpPlugins::Interface::SimpleMPRWidget::
+GetNumberOfData( ) const
+{
+ return( this->m_Data.size( ) );
+}
+
// -------------------------------------------------------------------------
bool cpPlugins::Interface::SimpleMPRWidget::
AddData(
virtual ~SimpleMPRWidget( );
// Data management
+ unsigned int GetNumberOfData( ) const;
bool AddData(
DataObject* data, const std::string& name,
const std::string& parent
protected:
static double cm_Colors[ 8 ][ 3 ];
- Ui::SimpleMPRWidget* m_UI;
+ Ui::SimpleMPRWidget* m_UI;
vtkSmartPointer< TMPRObjects > m_MPRObjects;
QVTKWidget* m_VTK[ 4 ];
if( f.IsNotNull( ) )
{
f->SetName( name );
+ for(
+ auto iIt = this->m_Interactors.begin( );
+ iIt != this->m_Interactors.end( );
+ ++iIt
+ )
+ f->AddInteractor( *iIt );
+
TObject::Pointer o = f.GetPointer( );
this->m_Graph->SetVertex( name, o );
return( true );
{
}
+// -------------------------------------------------------------------------
+const cpPlugins::Interface::Workspace::
+TInteractors& cpPlugins::Interface::Workspace::
+GetInteractors( ) const
+{
+ return( this->m_Interactors );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Workspace::
+AddInteractor( vtkRenderWindowInteractor* interactor )
+{
+ this->m_Interactors.insert( interactor );
+}
+
// -------------------------------------------------------------------------
bool cpPlugins::Interface::Workspace::
Connect(
// -------------------------------------------------------------------------
std::string cpPlugins::Interface::Workspace::
-Execute( QWidget* p )
+Execute( )
{
// Find sinks
std::set< std::string > sinks = this->m_Graph->GetSinks( );
std::string err = "";
for( auto sIt = sinks.begin( ); sIt != sinks.end( ); ++sIt )
{
- std::string lerr = this->Execute( *sIt, p );
+ std::string lerr = this->Execute( *sIt );
if( lerr != "" )
err += lerr + std::string( "\n" );
// -------------------------------------------------------------------------
std::string cpPlugins::Interface::Workspace::
-Execute( const std::string& name, QWidget* p )
+Execute( const std::string& name )
{
// Get filter
TFilter* f = this->GetFilter( name );
);
// Execute and return
- if( p != NULL )
- {
- auto diag_res = f->ExecConfigurationDialog( p );
- if( diag_res == TFilter::DialogResult_NoModal )
- return( f->Update( ) );
- else
- return( "" );
- }
- else
- return( f->Update( ) );
+ return( f->Update( ) );
}
// eof - $RCSfile$
// Some forward declarations
class QWidget;
+class vtkRenderWindowInteractor;
namespace cpPlugins
{
typedef std::set< std::string > TStringContainer;
typedef std::pair< std::string, std::string > TExposedPort;
typedef std::map< std::string, TExposedPort > TExposedPorts;
+ typedef std::set< vtkRenderWindowInteractor* > TInteractors;
// Graph type
typedef std::pair< std::string, std::string > TConnection;
);
void RemoveFilter( const std::string& name );
+ // Widgets management
+ virtual const TInteractors& GetInteractors( ) const;
+ virtual void AddInteractor( vtkRenderWindowInteractor* interactor );
+
// Connection management
bool Connect(
const std::string& orig_filter, const std::string& dest_filter,
const TData* GetExposedOutput( const std::string& name ) const;
// Pipeline execution
- std::string Execute( QWidget* p = NULL );
- std::string Execute( const std::string& name, QWidget* p = NULL );
+ std::string Execute( );
+ std::string Execute( const std::string& name );
protected:
// Plugins interface
typename TGraph::Pointer m_Graph;
TExposedPorts m_ExposedInputPorts;
TExposedPorts m_ExposedOutputPorts;
+
+ TInteractors m_Interactors;
};
} // ecapseman
if( nTotalSeeds < 2 )
{
double seed[ 3 ];
- istyle->GetSeed( s, seed );
+ istyle->GetSeedAsPoint( s, seed );
if( nTotalSeeds == 0 )
this->m_Filter->GetParameters( )->SetPoint( "Seed0", 3, seed );
else
} // rof
if( !at_least_one )
- return( Self::DialogResult_Cancel );
-
+ return( false );
+
// Create dialog
this->m_Dialog = new DoubleFloodImageFilter_Dialog( NULL, this );
this->m_Dialog->show( );
- return( Self::DialogResult_Modal );
+ return( true );
#else // cpPlugins_Interface_QT4
- return( Self::DialogResult_Cancel );
+ return( false );
#endif // cpPlugins_Interface_QT4
}
} // rof
if( iren == NULL )
- return( Self::DialogResult_Cancel );
-
+ return( false );
+
// Get bounding box
double bbox[ 6 ];
cpPlugins::Interface::Image* image =
} // fi
if( !input_found )
- return( Self::DialogResult_Cancel );
+ return( false );
// Create plane widget
if( this->m_PlaneWidget != NULL )
this->m_Dialog = new MacheteFilter_Dialog( NULL, this );
this->m_Dialog->show( );
- return( Self::DialogResult_Modal );
+ return( true );
#else // cpPlugins_Interface_QT4
- return( Self::DialogResult_Cancel );
+ return( false );
#endif // cpPlugins_Interface_QT4
}
SUBDIRS(
IO
BasicFilters
+ Widgets
)
## eof - $RCSfile$
#include <itkGDCMSeriesFileNames.h>
// -------------------------------------------------------------------------
-cpPlugins::IO::DicomSeriesReader::
-DialogResult cpPlugins::IO::DicomSeriesReader::
+bool cpPlugins::IO::DicomSeriesReader::
ExecConfigurationDialog( QWidget* parent )
{
- DialogResult r = Self::DialogResult_Cancel;
+ bool r = false;
#ifdef cpPlugins_Interface_QT4
dialog.setFileMode( QFileDialog::DirectoryOnly );
dialog.setDirectory( QFileDialog::tr( "." ) );
if( !dialog.exec( ) )
- return( Self::DialogResult_Cancel );
+ return( false );
// Prepare dialog
QApplication::setOverrideCursor( Qt::WaitCursor );
{
delete tree_widget;
delete tree_dialog;
- return( Self::DialogResult_Cancel );
+ return( false );
} // fi
parent->setEnabled( true );
if( tree_dialog->exec( ) == 0 )
- return( Self::DialogResult_Cancel );
+ return( false );
QTreeWidgetItem* item = tree_widget->currentItem( );
if( item != NULL )
std::string serie_dir = item_parent->text( 0 ).toStdString( );
std::string serie_id = item->text( 0 ).toStdString( );
serie_id = serie_id.substr( serie_id.find_first_of( " " ) + 1 );
- this->m_Parameters->ClearStringList( "FileNames" );
+ this->m_Parameters->ClearOpenFileNameList( "FileNames" );
const TStringList& names = found_files[ serie_dir ][ serie_id ];
for( unsigned int f = 0; f < names.size( ); ++f )
- this->m_Parameters->AddToStringList( "FileNames", names[ f ] );
+ this->m_Parameters->AddToOpenFileNameList( "FileNames", names[ f ] );
- r = Self::DialogResult_NoModal;
+ r = true;
QApplication::restoreOverrideCursor( );
if( parent != NULL )
cpPlugins_Id_Macro( cpPlugins::IO::DicomSeriesReader, IO );
public:
- virtual DialogResult ExecConfigurationDialog( QWidget* parent );
+ virtual bool ExecConfigurationDialog( QWidget* parent );
protected:
DicomSeriesReader( );
--- /dev/null
+SET(LIBRARY_NAME cpPluginsWidgets)
+
+## ===============
+## = Source code =
+## ===============
+
+FILE(GLOB LIB_HEADERS_H "*.h")
+FILE(GLOB LIB_HEADERS_HPP "*.hpp")
+FILE(GLOB LIB_HEADERS_HXX "*.hxx")
+FILE(GLOB LIB_SOURCES_C "*.c")
+FILE(GLOB LIB_SOURCES_CPP "*.cpp")
+FILE(GLOB LIB_SOURCES_CXX "*.cxx")
+
+## =====================
+## = Compilation rules =
+## =====================
+
+ADD_CUSTOM_COMMAND(
+ OUTPUT ${LIBRARY_NAME}_Host.cxx
+ DEPENDS ${cpPlugins_createHost_APP} ${LIB_HEADERS_H}
+ COMMAND ${cpPlugins_createHost_APP} ${LIBRARY_NAME}_Host.cxx cpPlugins::Widgets ${LIB_HEADERS_H}
+ )
+
+ADD_LIBRARY(
+ ${LIBRARY_NAME}
+ SHARED
+ ${LIBRARY_NAME}_Host.cxx
+ ${LIB_SOURCES_C}
+ ${LIB_SOURCES_CPP}
+ ${LIB_SOURCES_CXX}
+ )
+GENERATE_EXPORT_HEADER(
+ ${LIBRARY_NAME}
+ BASE_NAME ${LIBRARY_NAME}
+ EXPORT_MACRO_NAME ${LIBRARY_NAME}_EXPORT
+ EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/lib/cpPlugins/Widgets/${LIBRARY_NAME}_Export.h
+ STATIC_DEFINE ${LIBRARY_NAME}_BUILT_AS_STATIC
+ )
+TARGET_LINK_LIBRARIES(
+ ${LIBRARY_NAME}
+ cpPlugins_Interface
+ )
+
+## ========================
+## -- Installation rules --
+## ========================
+
+INSTALL(
+ TARGETS ${LIBRARY_NAME}
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib/static
+ )
+
+## eof - $RCSfile$
--- /dev/null
+#include "SeedWidget.h"
+
+#include <cpPlugins/Interface/Image.h>
+#include <cpPlugins/Interface/PointList.h>
+#include <cpExtensions/Interaction/ImageInteractorStyle.h>
+
+#include <vtkRenderWindowInteractor.h>
+
+// -------------------------------------------------------------------------
+cpPlugins::Widgets::SeedWidget::
+SeedWidget( )
+ : Superclass( ),
+ m_Configured( false )
+{
+ this->_AddInput( "ReferenceImage" );
+ this->_MakeOutput< cpPlugins::Interface::PointList >( "Output" );
+
+ this->m_Parameters->ConfigureAsBool( "SeedsAreInRealSpace" );
+ this->m_Parameters->SetBool( "SeedsAreInRealSpace", true );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Widgets::SeedWidget::
+~SeedWidget( )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::Widgets::SeedWidget::
+_GenerateData( )
+{
+ typedef itk::ImageBase< 2 > _2DImage;
+ typedef itk::ImageBase< 3 > _3DImage;
+
+ cpPlugins::Interface::Image* image =
+ this->GetInput< cpPlugins::Interface::Image >( "ReferenceImage" );
+ if( image == NULL )
+ return( "SeedWidget: No input image." );
+
+ itk::DataObject* itk_image = image->GetITK< _2DImage >( );
+ if( itk_image != NULL )
+ return( this->_GD0< _2DImage >( itk_image ) );
+ else
+ {
+ itk_image = image->GetITK< _3DImage >( );
+ if( itk_image != NULL )
+ return( this->_GD0< _3DImage >( itk_image ) );
+
+ } // fi
+
+ return( "SeedWidget: Input image dimension not supported." );
+}
+
+// -------------------------------------------------------------------------
+template< class I >
+std::string cpPlugins::Widgets::SeedWidget::
+_GD0( itk::DataObject* image )
+{
+ typedef cpExtensions::Interaction::ImageInteractorStyle _S;
+
+ I* base_image = dynamic_cast< I* >( image );
+ cpPlugins::Interface::PointList* out =
+ this->GetOutput< cpPlugins::Interface::PointList >( "Output" );
+ double aux_pnt[ 3 ];
+ unsigned int dim = ( I::ImageDimension < 3 )? I::ImageDimension: 3;
+
+ out->Clear( );
+ auto iIt = this->m_Interactors.begin( );
+ for( ; iIt != this->m_Interactors.end( ); ++iIt )
+ {
+ _S* s = dynamic_cast< _S* >( ( *iIt )->GetInteractorStyle( ) );
+ if( s != NULL )
+ {
+ if( this->m_Configured )
+ {
+ for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i )
+ {
+ s->GetSeedAsPoint( i, aux_pnt );
+ typename I::PointType seed;
+ for( unsigned int d = 0; d < dim; ++d )
+ seed[ d ] = aux_pnt[ d ];
+ out->AddPoint( seed );
+
+ } // rof
+ }
+ else
+ s->SeedWidgetOn( );
+
+ } // fi
+
+ } // rof
+ this->m_Configured = true;
+ return( "" );
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPPLUGINS__PLUGINS__SEEDWIDGET__H__
+#define __CPPLUGINS__PLUGINS__SEEDWIDGET__H__
+
+#include <cpPlugins/Widgets/cpPluginsWidgets_Export.h>
+#include <cpPlugins/Interface/ProcessObject.h>
+
+namespace cpPlugins
+{
+ namespace Widgets
+ {
+ /**
+ */
+ class cpPluginsWidgets_EXPORT SeedWidget
+ : public cpPlugins::Interface::ProcessObject
+ {
+ public:
+ typedef SeedWidget Self;
+ typedef cpPlugins::Interface::ProcessObject Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro( SeedWidget, cpPlugins::Interface::ProcessObject );
+ cpPlugins_Id_Macro( cpPlugins::Widgets::SeedWidget, Widgets );
+
+ protected:
+ SeedWidget( );
+ virtual ~SeedWidget( );
+
+ virtual std::string _GenerateData( );
+
+ template< class I >
+ inline std::string _GD0( itk::DataObject* image );
+
+ private:
+ // Purposely not implemented
+ SeedWidget( const Self& );
+ Self& operator=( const Self& );
+
+ protected:
+ bool m_Configured;
+ };
+
+ // ---------------------------------------------------------------------
+ CPPLUGINS_INHERIT_PROVIDER( SeedWidget );
+
+ } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__PLUGINS__SEEDWIDGET__H__
+
+// eof - $RCSfile$