);
// Connect actions to slots
+ this->connect(
+ this->m_UI->ActionBackgroundMPR, SIGNAL( triggered( ) ),
+ this, SLOT( _ActionBackgroundMPR( ) )
+ );
+ this->connect(
+ this->m_UI->ActionBackground3D, SIGNAL( triggered( ) ),
+ this, SLOT( _ActionBackground3D( ) )
+ );
this->connect(
this->m_UI->ButtonLoadPluginsFile, SIGNAL( clicked( ) ),
this, SLOT( _InteractiveLoadPlugins( ) )
delete this->m_UI;
}
+// -------------------------------------------------------------------------
+void PipelineEditor::
+_ActionBackgroundMPR( )
+{
+ this->_BackgroundProperties( 4 );
+}
+
+// -------------------------------------------------------------------------
+void PipelineEditor::
+_ActionBackground3D( )
+{
+ this->_BackgroundProperties( 3 );
+}
+
// -------------------------------------------------------------------------
void PipelineEditor::
_ShowFilterOutput(
const std::string& filter_name, const std::string& output_name
)
{
- // Update filter, if needed
this->_ExecFilter( filter_name );
-
- // Get output
- auto output = this->m_Workspace.GetOutput( filter_name, output_name );
- if( output == NULL )
- {
- QMessageBox::critical(
- this,
- QMessageBox::tr( "Error showing data" ),
- QMessageBox::tr( "Unknown port name." )
- );
- return;
-
- } // fi
-
- // Create and associate actor
- this->_Block( );
- this->m_UI->Viewer->AddActor( output->GetVTKActor( ) );
- this->_UnBlock( );
+ this->_ShowData( filter_name, output_name );
}
// -------------------------------------------------------------------------
const std::string& filter_name, const std::string& output_name
)
{
- // 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 );
-
- } // fi
-
- } // fi
- */
+ this->_HideData( filter_name, output_name );
}
// -------------------------------------------------------------------------
const std::string& filter_name, const std::string& output_name
)
{
- /* TODO
- 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
- */
+ this->_DataProperties( filter_name, output_name );
}
// eof - $RCSfile$
virtual ~PipelineEditor( );
protected slots:
+ void _ActionBackgroundMPR( );
+ void _ActionBackground3D( );
void _ShowFilterOutput(
const std::string& filter_name, const std::string& output_name
);
} // yrt
this->m_UI->Viewer->SetMainImage(
- this->m_Reader->GetOutputData< vtkImageData >( "Output" )
+ this->m_Reader->GetOutputData< vtkImageData >( "Output" ),
+ "MainImage"
);
}
#ifdef cpExtensions_QT4
#include <cpExtensions/ui_SimpleMPRWidget.h>
+#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
// -------------------------------------------------------------------------
cpExtensions::QT::SimpleMPRWidget::
~SimpleMPRWidget( )
{
+ this->Clear( );
delete this->m_UI;
}
this->m_3DSlices[ i ]->Clear( );
} // rof
- this->m_PolyDatas.clear( );
+ this->m_NamedActors.clear( );
}
// -------------------------------------------------------------------------
void cpExtensions::QT::SimpleMPRWidget::
-SetMainImage( vtkImageData* image )
+SetMainImage( vtkImageData* image, const std::string& name )
{
this->Clear( );
for( unsigned int i = 0; i < 3; ++i )
)
);
+ this->m_NamedActors[ name ].insert(
+ this->m_2DSlices[ i ]->GetImageActor( )
+ );
+ this->m_NamedActors[ name ].insert(
+ this->m_3DSlices[ i ]->GetImageActor( )
+ );
+
} // rof
this->_AssociateSlices( );
}
// -------------------------------------------------------------------------
void cpExtensions::QT::SimpleMPRWidget::
-SetMainActor( vtkImageActor* actor )
+SetMainActor( vtkImageActor* actor, const std::string& name )
{
this->Clear( );
vtkImageData* image = NULL;
)
);
+ this->m_NamedActors[ name ].insert(
+ this->m_2DSlices[ i ]->GetImageActor( )
+ );
+ this->m_NamedActors[ name ].insert(
+ this->m_3DSlices[ i ]->GetImageActor( )
+ );
+
} // rof
this->_AssociateSlices( );
}
// -------------------------------------------------------------------------
void cpExtensions::QT::SimpleMPRWidget::
-AddImage( vtkImageData* image )
+AddImage( vtkImageData* image, const std::string& name )
{
std::cerr << "SimpleMPR: adding image" << std::endl;
std::exit( 1 );
// -------------------------------------------------------------------------
void cpExtensions::QT::SimpleMPRWidget::
-AddImageActor( vtkImageActor* actor )
+AddImageActor( vtkImageActor* actor, const std::string& name )
{
unsigned int i = 0;
bool cont = true;
// Add if no actors were found
if( cont )
- this->SetMainActor( actor );
+ this->SetMainActor( actor, name );
}
// -------------------------------------------------------------------------
void cpExtensions::QT::SimpleMPRWidget::
-AddMesh( vtkPolyData* mesh )
+AddMesh( vtkPolyData* mesh, const std::string& name )
{
std::cerr << "SimpleMPR: adding mesh" << std::endl;
std::exit( 1 );
// -------------------------------------------------------------------------
void cpExtensions::QT::SimpleMPRWidget::
-AddMeshActor( vtkProp3D* actor )
+AddMeshActor( vtkProp3D* actor, const std::string& name )
{
if( actor != NULL )
{
this->m_Renderers[ 3 ]->AddViewProp( actor );
this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
+ this->m_NamedActors[ name ].insert( actor );
} // fi
}
// -------------------------------------------------------------------------
void cpExtensions::QT::SimpleMPRWidget::
-AddActor( vtkProp* actor )
+AddActor( vtkProp* actor, const std::string& name )
{
auto ia = dynamic_cast< vtkImageActor* >( actor );
if( ia == NULL )
{
auto ma = dynamic_cast< vtkActor* >( actor );
if( ma != NULL )
- this->AddMeshActor( ma );
+ this->AddMeshActor( ma, name );
}
else
- this->AddImageActor( ia );
+ this->AddImageActor( ia, name );
+}
+
+// -------------------------------------------------------------------------
+const cpExtensions::QT::SimpleMPRWidget::
+TActors& cpExtensions::QT::SimpleMPRWidget::
+GetActors( const std::string& name ) const
+{
+ static const TActors empty;
+ auto i = this->m_NamedActors.find( name );
+ if( i != this->m_NamedActors.end( ) )
+ return( i->second );
+ else
+ return( empty );
}
// -------------------------------------------------------------------------
#ifdef cpExtensions_QT4
#include <map>
+#include <set>
#include <QWidget>
-#include <vtkPolyDataNormals.h>
-#include <vtkQuadricLODActor.h>
-#include <vtkRenderer.h>
-#include <vtkStripper.h>
+#include <vtkProp.h>
#include <vtkSmartPointer.h>
#include <cpExtensions/Visualization/ImageSliceActors.h>
public:
typedef SimpleMPRWidget Self;
- typedef cpExtensions::Visualization::ImageSliceActors TSliceActors;
-
- /**
- */
- struct PolyDataActor
+ struct TActorCmp
{
- vtkSmartPointer< vtkPolyData > Data;
- vtkSmartPointer< vtkPolyDataNormals > Normals;
- vtkSmartPointer< vtkStripper > Stripper;
- vtkSmartPointer< vtkPolyDataMapper > Mapper;
- vtkSmartPointer< vtkActor > Actor;
-
- void Configure( vtkPolyData* data )
- {
- this->Data = data;
- double r[ 2 ];
- this->Data->GetScalarRange( r );
-
- this->Normals = vtkSmartPointer< vtkPolyDataNormals >::New( );
- this->Stripper = vtkSmartPointer< vtkStripper >::New( );
- this->Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
- this->Normals->SetInputData( this->Data );
- this->Normals->SetFeatureAngle( 60.0 );
- this->Stripper->SetInputConnection(
- this->Normals->GetOutputPort( )
- );
- this->Mapper->SetInputConnection(
- this->Stripper->GetOutputPort( )
- );
- this->Mapper->UseLookupTableScalarRangeOff( );
- this->Mapper->SetScalarRange( r[ 0 ], r[ 1 ] );
-
- unsigned long nPolys = this->Data->GetNumberOfPolys( );
- if( nPolys < cpExtensions_MAX_POLYS )
- {
- this->Actor = vtkSmartPointer< vtkActor >::New( );
- this->Actor->SetMapper( this->Mapper );
- }
- else
- {
- vtkSmartPointer< vtkQuadricLODActor > actor =
- vtkSmartPointer< vtkQuadricLODActor >::New( );
- actor->SetMapper( this->Mapper );
- actor->DeferLODConstructionOff( );
- this->Actor = actor.GetPointer( );
-
- } // fi
- }
+ bool operator()(
+ const vtkSmartPointer< vtkProp >& a,
+ const vtkSmartPointer< vtkProp >& b
+ ) const
+ { return( a.GetPointer( ) < b.GetPointer( ) ); }
};
+ typedef std::set< vtkSmartPointer< vtkProp >, TActorCmp > TActors;
+ typedef std::map< std::string, TActors > TNamedActors;
+ typedef cpExtensions::Visualization::ImageSliceActors TSliceActors;
public:
explicit SimpleMPRWidget( QWidget* parent = 0 );
// Data management
void Clear( );
- void SetMainImage( vtkImageData* image );
- void SetMainActor( vtkImageActor* actor );
- void AddImage( vtkImageData* image );
- void AddImageActor( vtkImageActor* actor );
- void AddMesh( vtkPolyData* mesh );
- void AddMeshActor( vtkProp3D* actor );
- void AddActor( vtkProp* actor );
+ void SetMainImage( vtkImageData* image, const std::string& name );
+ void SetMainActor( vtkImageActor* actor, const std::string& name );
+ void AddImage( vtkImageData* image, const std::string& name );
+ void AddImageActor( vtkImageActor* actor, const std::string& name );
+ void AddMesh( vtkPolyData* mesh, const std::string& name );
+ void AddMeshActor( vtkProp3D* actor, const std::string& name );
+ void AddActor( vtkProp* actor, const std::string& name );
+ const TActors& GetActors( const std::string& name ) const;
// Visual objects
vtkRenderWindowInteractor* GetInteractor( unsigned int i );
vtkRenderer* GetRenderer( unsigned int i );
vtkRenderWindow* GetRenderWindow( unsigned int i );
- /* TODO
- std::vector< std::pair< vtkImageActor*, vtkRenderer* > >
- GetMainImageActors( );
- vtkActor* GetActor( vtkPolyData* mesh );
- */
protected:
void _AssociateSlices( );
vtkSmartPointer< TSliceActors > m_2DSlices[ 3 ];
vtkSmartPointer< TSliceActors > m_3DSlices[ 3 ];
- std::map< vtkPolyData*, PolyDataActor > m_PolyDatas;
+ TNamedActors m_NamedActors;
};
} // ecapseman
#include <cpPipelineEditor/BaseQtMainWindow.h>
#include <cpExtensions/QT/SimpleMPRWidget.h>
+#include <cpPlugins/ActorPropertiesQtDialog.h>
#include <cpPipelineEditor/Editor.h>
+#include <vtkRenderer.h>
#include <QApplication>
+#include <QColorDialog>
#include <QDir>
#include <QFileDialog>
#include <QFileInfo>
m_Application( app ),
m_PluginsPath( "." ),
m_TreeWidget( NULL ),
- m_Editor( NULL )
+ m_Editor( NULL ),
+ m_MPR( NULL )
{
this->m_Interface.GuessAccesiblePlugins( );
this->m_Editor->setWorkspace( &( this->m_Workspace ) );
if( mpr != NULL )
this->m_Workspace.SetMPRViewer( mpr );
+ this->m_MPR = mpr;
}
// -------------------------------------------------------------------------
);
}
+// -------------------------------------------------------------------------
+void cpPipelineEditor::BaseQtMainWindow::
+_ShowData( const std::string& filter_name, const std::string& output_name )
+{
+ if( this->m_MPR == NULL )
+ return;
+ auto output = this->m_Workspace.GetOutput( filter_name, output_name );
+ if( output != NULL )
+ {
+ this->_Block( );
+ auto actor = output->GetVTKActor( );
+ if( actor != NULL )
+ {
+ this->m_MPR->AddActor(
+ actor, output_name + std::string( "@" ) + filter_name
+ );
+ this->_UnBlock( );
+ }
+ else
+ {
+ this->_UnBlock( );
+ QMessageBox::critical(
+ this,
+ QMessageBox::tr( "Error showing data" ),
+ QMessageBox::tr( "Unknown VTK conversion." )
+ );
+
+ } // fi
+ }
+ else
+ QMessageBox::critical(
+ this,
+ QMessageBox::tr( "Error showing data" ),
+ QMessageBox::tr( "Unknown port name." )
+ );
+}
+
+// -------------------------------------------------------------------------
+void cpPipelineEditor::BaseQtMainWindow::
+_HideData( const std::string& filter, const std::string& output )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPipelineEditor::BaseQtMainWindow::
+_DataProperties(
+ const std::string& filter_name, const std::string& output_name
+ )
+{
+ if( this->m_MPR == NULL )
+ return;
+ auto output = this->m_Workspace.GetOutput( filter_name, output_name );
+ if( output != NULL )
+ {
+ this->_Block( );
+ auto actors = this->m_MPR->GetActors(
+ output_name + std::string( "@" ) + filter_name
+ );
+ auto dlg = new cpPlugins::ActorPropertiesQtDialog( NULL );
+ for( auto i = actors.begin( ); i != actors.end( ); ++i )
+ dlg->addActor( *i );
+ dlg->addRenderWindow( this->m_MPR->GetRenderWindow( 0 ) );
+ dlg->addRenderWindow( this->m_MPR->GetRenderWindow( 1 ) );
+ dlg->addRenderWindow( this->m_MPR->GetRenderWindow( 2 ) );
+ dlg->addRenderWindow( this->m_MPR->GetRenderWindow( 3 ) );
+ this->_UnBlock( );
+ dlg->exec( );
+ }
+ else
+ QMessageBox::critical(
+ this,
+ QMessageBox::tr( "Error showing data" ),
+ QMessageBox::tr( "Unknown port name." )
+ );
+}
+
+// -------------------------------------------------------------------------
+void cpPipelineEditor::BaseQtMainWindow::
+_BackgroundProperties( unsigned int i )
+{
+ QColor color =
+ QColorDialog::getColor(
+ QColor( 0, 0, 0 ),
+ this,
+ "Select Color",
+ QColorDialog::DontUseNativeDialog
+ );
+ if( color.isValid( ) )
+ {
+ double r = double( color.red( ) ) / double( 255 );
+ double g = double( color.green( ) ) / double( 255 );
+ double b = double( color.blue( ) ) / double( 255 );
+ if( i >= 4 )
+ {
+ unsigned int maxId = ( i == 4 )? 3: 4;
+ for( unsigned int j = 0; j < maxId; ++j )
+ {
+ auto ren = this->m_MPR->GetRenderer( j );
+ if( ren != NULL )
+ {
+ ren->SetBackground( r, g, b );
+ ren->Render( );
+
+ } // fi
+
+ } // rof
+ }
+ else
+ {
+ auto ren = this->m_MPR->GetRenderer( i );
+ if( ren != NULL )
+ {
+ ren->SetBackground( r, g, b );
+ ren->Render( );
+
+ } // fi
+
+ } // fi
+
+ } // fi
+}
+
// -------------------------------------------------------------------------
void cpPipelineEditor::BaseQtMainWindow::
_InteractiveLoadPlugins( )
void _LoadWorkspace( const std::string& filename );
void _SaveWorkspace( const std::string& filename );
+ void _ShowData(
+ const std::string& filter_name, const std::string& output_name
+ );
+ void _HideData(
+ const std::string& filter_name, const std::string& output_name
+ );
+ void _DataProperties(
+ const std::string& filter_name, const std::string& output_name
+ );
+ void _BackgroundProperties( unsigned int i );
+
protected slots:
void _InteractiveLoadPlugins( );
void _InteractiveLoadPluginsFromPath( );
QTreeWidget* m_TreeWidget;
Editor* m_Editor;
+ cpExtensions::QT::SimpleMPRWidget* m_MPR;
};
} // ecapseman
#include "Block.h"\r
#include "Editor.h"\r
\r
-#include <cpPlugins/DataObjectVisualizationQtDialog.h>\r
-\r
#include <QGraphicsScene>\r
#include <QGraphicsSceneContextMenuEvent>\r
#include <QFontMetrics>\r
}\r
else if( selectedAction == propertiesAction )\r
{\r
- auto filter = this->m_Block->filter( );\r
- auto name = this->name( ).toStdString( );\r
- if( filter != NULL )\r
- {\r
- auto output = filter->GetOutput( name );\r
- if( output != NULL )\r
- {\r
- auto dlg = output->CreateQtDialog( );\r
- dlg->exec( );\r
-\r
- } // fi\r
-\r
- } // fi\r
+ this->m_Block->editor( )->visualPropertiesOutputData(\r
+ this->m_Block->namePort( ).toStdString( ),\r
+ this->name( ).toStdString( )\r
+ );\r
\r
} // fi\r
}\r
-#include <cpPlugins/DataObjectVisualizationQtDialog.h>
+#include <cpPlugins/ActorPropertiesQtDialog.h>
+#ifdef cpPlugins_QT4
+
+#include <vtkActor.h>
+#include <vtkAxesActor.h>
#include <vtkImageActor.h>
#include <vtkImageData.h>
#include <vtkImageProperty.h>
#include <vtkMapper.h>
-#include <vtkPolyData.h>
#include <vtkProperty.h>
-#ifdef cpPlugins_QT4
-
#include <QCheckBox>
#include <QColorDialog>
#include <QDoubleSpinBox>
#include <QSlider>
// -------------------------------------------------------------------------
-cpPlugins::DataObjectVisualizationQtDialog::
-DataObjectVisualizationQtDialog( QWidget* parent, Qt::WindowFlags f )
+cpPlugins::ActorPropertiesQtDialog::
+ActorPropertiesQtDialog( QWidget* parent, Qt::WindowFlags f )
: QDialog( parent, f ),
- m_DataObject( NULL ),
m_WidgetsUpdated( false )
{
this->m_Title = new QLabel( this );
}
// -------------------------------------------------------------------------
-cpPlugins::DataObjectVisualizationQtDialog::
-~DataObjectVisualizationQtDialog( )
+cpPlugins::ActorPropertiesQtDialog::
+~ActorPropertiesQtDialog( )
{
+ this->m_Actors.clear( );
+ this->m_Windows.clear( );
delete this->m_Title;
delete this->m_ToolsLayout;
delete this->m_MainLayout;
}
// -------------------------------------------------------------------------
-cpPlugins::DataObject* cpPlugins::DataObjectVisualizationQtDialog::
-getDataObject( ) const
+bool cpPlugins::ActorPropertiesQtDialog::
+addActor( vtkProp* obj )
{
- return( this->m_DataObject );
+ if( obj == NULL )
+ return( false );
+
+ if( this->m_Actors.size( ) > 0 )
+ {
+ bool s = this->_addActor< vtkAxesActor >( obj );
+ if( !s ) s = this->_addActor< vtkImageActor >( obj );
+ if( !s ) s = this->_addActor< vtkActor >( obj );
+ return( s );
+ }
+ else
+ {
+ this->m_Actors.insert( obj );
+ this->m_WidgetsUpdated = false;
+ return( true );
+
+ } // fi
}
// -------------------------------------------------------------------------
-bool cpPlugins::DataObjectVisualizationQtDialog::
-setDataObject( DataObject* obj )
+bool cpPlugins::ActorPropertiesQtDialog::
+addRenderWindow( vtkRenderWindow* win )
{
- if( this->m_DataObject != NULL || obj == NULL )
+ if( win == NULL )
return( false );
- this->m_DataObject = obj;
+ this->m_Windows.insert( win );
this->m_WidgetsUpdated = false;
return( true );
}
// -------------------------------------------------------------------------
-int cpPlugins::DataObjectVisualizationQtDialog::
+int cpPlugins::ActorPropertiesQtDialog::
exec( )
{
this->_updateWidgets( );
}
// -------------------------------------------------------------------------
-void cpPlugins::DataObjectVisualizationQtDialog::
+void cpPlugins::ActorPropertiesQtDialog::
_addButtons( )
{
// Add buttons
this->m_Buttons, SIGNAL( rejected( ) ), this, SLOT( reject( ) )
);
this->m_ToolsLayout->addWidget( this->m_Buttons );
- // TODO: this->updateView( );
this->m_WidgetsUpdated = true;
}
// -------------------------------------------------------------------------
-void cpPlugins::DataObjectVisualizationQtDialog::
+void cpPlugins::ActorPropertiesQtDialog::
_updateWidgets( )
{
- if( this->m_WidgetsUpdated || this->m_DataObject == NULL )
+ if( this->m_WidgetsUpdated || this->m_Actors.size( ) == 0 )
return;
+ bool s = this->_configureForAxes( );
+ if( !s ) s = this->_configureForImage( );
+ if( !s ) s = this->_configureForMesh( );
+ this->_addButtons( );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::ActorPropertiesQtDialog::
+_configureForAxes( )
+{
+ if( this->m_Actors.size( ) == 0 )
+ return( false );
+ auto actor =
+ dynamic_cast< vtkAxesActor* >( this->m_Actors.begin( )->GetPointer( ) );
+ if( actor == NULL )
+ return( false );
// Set dialog title
std::stringstream title;
- title
- << "Parameters for an object of class \""
- << this->m_DataObject->GetClassName( )
- << "\"";
+ title << "Parameters for an object of class \"Axes\"";
this->m_Title->setText( title.str( ).c_str( ) );
- // Configure particular objects
- this->_configureForImage( );
- this->_configureForMesh( );
-
- // Update values
- this->_addButtons( );
+ return( true );
}
// -------------------------------------------------------------------------
-void cpPlugins::DataObjectVisualizationQtDialog::
+bool cpPlugins::ActorPropertiesQtDialog::
_configureForImage( )
{
- /* TODO
- auto image = this->m_DataObject->GetVTK< vtkImageData >( );
- auto aIt = this->m_DataObject->BeginVTKActors( );
- if( image == NULL || aIt == this->m_DataObject->EndVTKActors( ) )
- return;
- auto actor = dynamic_cast< vtkImageActor* >( aIt->Actor.GetPointer( ) );
+ if( this->m_Actors.size( ) == 0 )
+ return( false );
+ auto actor =
+ dynamic_cast< vtkImageActor* >( this->m_Actors.begin( )->GetPointer( ) );
if( actor == NULL )
- return;
-
+ return( false );
+ auto image = actor->GetInput( );
+ if( image == NULL )
+ return( false );
+
+ // Get properties
+ auto prop = actor->GetProperty( );
double r[ 2 ];
image->GetScalarRange( r );
double w = actor->GetProperty( )->GetColorWindow( );
double l = actor->GetProperty( )->GetColorLevel( );
double sw = double( 1000 ) * w / ( r[ 1 ] - r[ 0 ] );
double sl = double( 1000 ) * ( l - r[ 0 ] ) / ( r[ 1 ] - r[ 0 ] );
- double op = double( 10 ) * actor->GetProperty( )->GetOpacity( );
+ double op = double( 10 ) * prop->GetOpacity( );
+
+ // Set dialog title
+ std::stringstream title;
+ title << "Parameters for an object of class \"Image\"";
+ this->m_Title->setText( title.str( ).c_str( ) );
+ // Create widgets
QDoubleSpinBox* win_box = new QDoubleSpinBox( this );
win_box->setObjectName( "win_box" );
win_box->setDecimals( 3 );
op_layout->addWidget( op_label );
op_layout->addWidget( op_sld );
this->m_ToolsLayout->addLayout( op_layout );
-*/
+
+ return( true );
}
// -------------------------------------------------------------------------
-void cpPlugins::DataObjectVisualizationQtDialog::
+bool cpPlugins::ActorPropertiesQtDialog::
_configureForMesh( )
{
- /* TODO
- auto mesh = this->m_DataObject->GetVTK< vtkPolyData >( );
- auto aIt = this->m_DataObject->BeginVTKActors( );
- if( mesh == NULL || aIt == this->m_DataObject->EndVTKActors( ) )
- return;
- auto actor = dynamic_cast< vtkActor* >( aIt->Actor.GetPointer( ) );
+ if( this->m_Actors.size( ) == 0 )
+ return( false );
+ auto actor =
+ dynamic_cast< vtkActor* >( this->m_Actors.begin( )->GetPointer( ) );
if( actor == NULL )
- return;
+ return( false );
+ auto prop = actor->GetProperty( );
+ // Set dialog title
+ std::stringstream title;
+ title << "Parameters for an object of class \"Mesh\"";
+ this->m_Title->setText( title.str( ).c_str( ) );
+
+ // Input boxes
QSpinBox* ps_box = new QSpinBox( this );
ps_box->setObjectName( "ps_box" );
ps_box->setMinimum( 1 );
ps_box->setMaximum( 100 );
- ps_box->setValue( actor->GetProperty( )->GetPointSize( ) );
+ ps_box->setValue( prop->GetPointSize( ) );
ps_box->connect(
ps_box, SIGNAL( valueChanged( int ) ),
this, SLOT( _boxPointSize( int ) )
lw_box->setObjectName( "lw_box" );
lw_box->setMinimum( 1 );
lw_box->setMaximum( 100 );
- lw_box->setValue( actor->GetProperty( )->GetLineWidth( ) );
+ lw_box->setValue( prop->GetLineWidth( ) );
lw_box->connect(
lw_box, SIGNAL( valueChanged( int ) ),
this, SLOT( _boxLineWidth( int ) )
this->m_ToolsLayout->addLayout( sv_layout );
double cr, cg, cb;
- actor->GetProperty( )->GetColor( cr, cg, cb );
+ prop->GetColor( cr, cg, cb );
cr *= double( 255 );
cg *= double( 255 );
cb *= double( 255 );
op_sld->setObjectName( "op_sld" );
op_sld->setRange( 0, 10 );
op_sld->setValue(
- ( unsigned int )( actor->GetProperty( )->GetOpacity( ) * double( 10 ) )
+ ( unsigned int )( prop->GetOpacity( ) * double( 10 ) )
);
op_sld->connect(
op_sld, SIGNAL( valueChanged( int ) ),
op_layout->addWidget( op_label );
op_layout->addWidget( op_sld );
this->m_ToolsLayout->addLayout( op_layout );
-*/
+
+ return( true );
}
// -------------------------------------------------------------------------
-void cpPlugins::DataObjectVisualizationQtDialog::
+void cpPlugins::ActorPropertiesQtDialog::
_setWindow( double w )
{
- /* TODO
- if( this->m_DataObject == NULL )
+ if( this->m_Actors.size( ) == 0 )
return;
- auto aIt = this->m_DataObject->BeginVTKActors( );
- for( ; aIt != this->m_DataObject->EndVTKActors( ); ++aIt )
+ auto aIt = this->m_Actors.begin( );
+ for( ; aIt != this->m_Actors.end( ); ++aIt )
{
- auto actor = dynamic_cast< vtkImageActor* >( aIt->Actor.GetPointer( ) );
+ auto actor = dynamic_cast< vtkImageActor* >( aIt->GetPointer( ) );
if( actor != NULL )
{
actor->GetProperty( )->SetColorWindow( w );
} // rof
this->_render( );
-*/
}
// -------------------------------------------------------------------------
-void cpPlugins::DataObjectVisualizationQtDialog::
+void cpPlugins::ActorPropertiesQtDialog::
_setLevel( double l )
{
- /* TODO
- if( this->m_DataObject == NULL )
+ if( this->m_Actors.size( ) == 0 )
return;
- auto aIt = this->m_DataObject->BeginVTKActors( );
- for( ; aIt != this->m_DataObject->EndVTKActors( ); ++aIt )
+ auto aIt = this->m_Actors.begin( );
+ for( ; aIt != this->m_Actors.end( ); ++aIt )
{
- auto actor = dynamic_cast< vtkImageActor* >( aIt->Actor.GetPointer( ) );
+ auto actor = dynamic_cast< vtkImageActor* >( aIt->GetPointer( ) );
if( actor != NULL )
{
actor->GetProperty( )->SetColorLevel( l );
} // rof
this->_render( );
-*/
}
// -------------------------------------------------------------------------
-void cpPlugins::DataObjectVisualizationQtDialog::
+void cpPlugins::ActorPropertiesQtDialog::
_render( )
{
- /* TODO
- if( this->m_DataObject == NULL )
- return;
- this->m_DataObject->RenderVTKActors( );
-*/
+ for( auto i = this->m_Windows.begin( ); i != this->m_Windows.end( ); ++i )
+ ( *i )->Render( );
+}
+
+// -------------------------------------------------------------------------
+template< class _TActor >
+bool cpPlugins::ActorPropertiesQtDialog::
+_addActor( vtkProp* obj )
+{
+ auto new_obj = dynamic_cast< _TActor* >( obj );
+ auto pre_obj =
+ dynamic_cast< _TActor* >( this->m_Actors.begin( )->GetPointer( ) );
+ if( new_obj != NULL && pre_obj != NULL )
+ {
+ this->m_Actors.insert( obj );
+ this->m_WidgetsUpdated = false;
+ return( true );
+ }
+ else
+ return( false );
}
// -------------------------------------------------------------------------
-void cpPlugins::DataObjectVisualizationQtDialog::
+void cpPlugins::ActorPropertiesQtDialog::
_boxWindow( double v )
{
auto* box = this->findChild< QDoubleSpinBox* >( "win_box" );
}
// -------------------------------------------------------------------------
-void cpPlugins::DataObjectVisualizationQtDialog::
+void cpPlugins::ActorPropertiesQtDialog::
_sldWindow( int v )
{
auto* box = this->findChild< QDoubleSpinBox* >( "win_box" );
}
// -------------------------------------------------------------------------
-void cpPlugins::DataObjectVisualizationQtDialog::
+void cpPlugins::ActorPropertiesQtDialog::
_boxLevel( double v )
{
auto* box = this->findChild< QDoubleSpinBox* >( "lev_box" );
}
// -------------------------------------------------------------------------
-void cpPlugins::DataObjectVisualizationQtDialog::
+void cpPlugins::ActorPropertiesQtDialog::
_sldLevel( int v )
{
auto* box = this->findChild< QDoubleSpinBox* >( "lev_box" );
}
// -------------------------------------------------------------------------
-void cpPlugins::DataObjectVisualizationQtDialog::
+void cpPlugins::ActorPropertiesQtDialog::
_sldOpacity( int v )
{
- /* TODO
- if( this->m_DataObject == NULL )
+ if( this->m_Actors.size( ) == 0 )
return;
auto* sld = this->findChild< QSlider* >( "op_sld" );
if( sld == NULL )
double max = double( sld->maximum( ) );
double s = ( double( v ) - min ) / ( max - min );
- auto aIt = this->m_DataObject->BeginVTKActors( );
- for( ; aIt != this->m_DataObject->EndVTKActors( ); ++aIt )
+ auto aIt = this->m_Actors.begin( );
+ for( ; aIt != this->m_Actors.end( ); ++aIt )
{
- auto ia = dynamic_cast< vtkImageActor* >( aIt->Actor.GetPointer( ) );
- auto ma = dynamic_cast< vtkActor* >( aIt->Actor.GetPointer( ) );
+ auto ia = dynamic_cast< vtkImageActor* >( aIt->GetPointer( ) );
+ auto ma = dynamic_cast< vtkActor* >( aIt->GetPointer( ) );
if( ia != NULL )
{
ia->GetProperty( )->SetOpacity( s );
} // rof
this->_render( );
-*/
}
// -------------------------------------------------------------------------
-void cpPlugins::DataObjectVisualizationQtDialog::
+void cpPlugins::ActorPropertiesQtDialog::
_boxPointSize( int v )
{
}
// -------------------------------------------------------------------------
-void cpPlugins::DataObjectVisualizationQtDialog::
+void cpPlugins::ActorPropertiesQtDialog::
_boxLineWidth( int v )
{
}
// -------------------------------------------------------------------------
-void cpPlugins::DataObjectVisualizationQtDialog::
+void cpPlugins::ActorPropertiesQtDialog::
_scalarVisibility( int v )
{
- /* TODO
- if( this->m_DataObject == NULL )
+ if( this->m_Actors.size( ) == 0 )
return;
auto* btn = this->findChild< QPushButton* >( "color_button" );
auto* chk = this->findChild< QCheckBox* >( "sv_box" );
rgb[ 1 ] = double( color.green( ) ) / double( 255 );
rgb[ 2 ] = double( color.blue( ) ) / double( 255 );
- auto aIt = this->m_DataObject->BeginVTKActors( );
- for( ; aIt != this->m_DataObject->EndVTKActors( ); ++aIt )
+ auto aIt = this->m_Actors.begin( );
+ for( ; aIt != this->m_Actors.end( ); ++aIt )
{
- auto ma = dynamic_cast< vtkActor* >( aIt->Actor.GetPointer( ) );
+ auto ma = dynamic_cast< vtkActor* >( aIt->GetPointer( ) );
if( ma != NULL )
{
if( !( chk->isChecked( ) ) )
} // rof
this->_render( );
-*/
}
// -------------------------------------------------------------------------
-void cpPlugins::DataObjectVisualizationQtDialog::
+void cpPlugins::ActorPropertiesQtDialog::
_color( )
{
- /* TODO
- if( this->m_DataObject == NULL )
+ if( this->m_Actors.size( ) == 0 )
return;
auto* btn = this->findChild< QPushButton* >( "color_button" );
auto* chk = this->findChild< QCheckBox* >( "sv_box" );
this->_scalarVisibility( 0 );
} // fi
-*/
}
#endif // cpPlugins_QT4
-#ifndef __CPPLUGINS__DATAOBJECTVISUALIZATIONQTDIALOG__H__
-#define __CPPLUGINS__DATAOBJECTVISUALIZATIONQTDIALOG__H__
+#ifndef __CPPLUGINS__ACTORPROPERTIESQTDIALOG__H__
+#define __CPPLUGINS__ACTORPROPERTIESQTDIALOG__H__
#include <cpPlugins/Config.h>
#ifdef cpPlugins_QT4
-#include <cpPlugins/DataObject.h>
-
#include <set>
+#include <vtkProp.h>
+#include <vtkRenderWindow.h>
+#include <vtkSmartPointer.h>
#include <QApplication>
#include <QDialog>
#include <QLabel>
#include <QVBoxLayout>
+class vtkProp;
+
namespace cpPlugins
{
/**
*/
- class cpPlugins_EXPORT DataObjectVisualizationQtDialog
+ class cpPlugins_EXPORT ActorPropertiesQtDialog
: public QDialog
{
Q_OBJECT;
public:
- DataObjectVisualizationQtDialog(
+ template< class _TObj >
+ struct TCmp
+ {
+ bool operator()(
+ const vtkSmartPointer< _TObj >& a,
+ const vtkSmartPointer< _TObj >& b ) const
+ { return( a.GetPointer( ) < b.GetPointer( ) ); }
+ };
+ typedef vtkSmartPointer< vtkProp > TActor;
+ typedef vtkSmartPointer< vtkRenderWindow > TRenderWindow;
+ typedef std::set< TActor, TCmp< vtkProp > > TActors;
+ typedef std::set< TRenderWindow, TCmp< vtkRenderWindow > > TWindows;
+
+ public:
+ ActorPropertiesQtDialog(
QWidget* parent = 0, Qt::WindowFlags f = 0
);
- virtual ~DataObjectVisualizationQtDialog( );
-
- DataObject* getDataObject( ) const;
- virtual bool setDataObject( DataObject* obj );
+ virtual ~ActorPropertiesQtDialog( );
+ virtual bool addActor( vtkProp* obj );
+ virtual bool addRenderWindow( vtkRenderWindow* win );
virtual int exec( );
protected:
virtual void _addButtons( );
virtual void _updateWidgets( );
- virtual void _configureForImage( );
- virtual void _configureForMesh( );
+ virtual bool _configureForAxes( );
+ virtual bool _configureForImage( );
+ virtual bool _configureForMesh( );
void _setWindow( double w );
void _setLevel( double l );
void _render( );
+ template< class _TActor >
+ inline bool _addActor( vtkProp* obj );
+
protected slots:
void _boxWindow( double v );
void _sldWindow( int v );
*/
protected:
- DataObject* m_DataObject;
+ TActors m_Actors;
+ TWindows m_Windows;
bool m_WidgetsUpdated;
QLabel* m_Title;
QGridLayout* m_MainLayout;
#endif // cpPlugins_QT4
-#endif // __CPPLUGINS__DATAOBJECTVISUALIZATIONQTDIALOG__H__
+#endif // __CPPLUGINS__ACTORPROPERTIESQTDIALOG__H__
// eof - $RCSfile$
)
SET(
lib_QT_Headers
- DataObjectVisualizationQtDialog.h
+ ActorPropertiesQtDialog.h
ParametersQtDialog.h
)
SET(
lib_QT_Sources
- DataObjectVisualizationQtDialog.cxx
+ ActorPropertiesQtDialog.cxx
ParametersQtDialog.cxx
)
SET(
#include <cpPlugins/DataObject.h>
#include <cpPlugins/ProcessObject.h>
-#include <cpPlugins/DataObjectVisualizationQtDialog.h>
#include <itkDataObject.h>
#include <vtkImageData.h>
#include <vtkPolyData.h>
this->Modified( );
}
-// -------------------------------------------------------------------------
-cpPlugins::DataObjectVisualizationQtDialog* cpPlugins::DataObject::
-CreateQtDialog( )
-{
-#ifdef cpPlugins_QT4
- DataObjectVisualizationQtDialog* dlg = NULL;
- if( QApplication::instance( ) != NULL )
- {
- dlg = new DataObjectVisualizationQtDialog( );
- dlg->setDataObject( this );
-
- } // fi
- return( dlg );
-#else // cpPlugins_QT4
- return( NULL );
-#endif // cpPlugins_QT4
-}
-
// -------------------------------------------------------------------------
vtkProp* cpPlugins::DataObject::
GetVTKActor( )
{
// Some forward declarations
class ProcessObject;
- class DataObjectVisualizationQtDialog;
/**
*/
void DisconnectFromPipeline( );
- // Qt dialog creation
- virtual DataObjectVisualizationQtDialog* CreateQtDialog( );
-
// VTK actors
vtkProp* GetVTKActor( );
const vtkProp* GetVTKActor( ) const;
#include <vtkCommand.h>
#include <vtkProperty.h>
+#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <cpExtensions/QT/SimpleMPRWidget.h>