-#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