#include <QMessageBox>
+#include <cpPlugins/Image.h>
#include <cpPipelineEditor/Editor.h>
-#include <cpExtensions/QT/PropertyWidget.h>
#include <vtkImageData.h>
#include <vtkPolyData.h>
this->_ExecFilter( filter_name );
// Get output
- auto filter = this->m_Workspace.GetFilter( filter_name );
- if( filter != NULL )
+ auto output = this->m_Workspace.GetOutput( filter_name, output_name );
+ if( output == 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." )
+ QMessageBox::tr( "Unknown port name." )
);
+ return;
+
+ } // fi
+
+ // Create and associate actor
+ this->_Block( );
+ this->m_UI->Viewer->AddActor( output->CreateVTKActor( ) );
+ this->_UnBlock( );
}
// -------------------------------------------------------------------------
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!" )
- );
+ /* 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
+ } // fi
+ }
+ else
+ QMessageBox::critical(
+ this,
+ QMessageBox::tr( "Error showing data" ),
+ QMessageBox::tr( "No known VTK conversion!" )
+ );
+
+ } // fi
+ */
}
// eof - $RCSfile$
+++ /dev/null
-#include <cpExtensions/QT/PropertyWidget.h>
-
-#ifdef cpExtensions_QT4
-
-#include <QColorDialog>
-#include <vtkActor.h>
-#include <vtkMapper.h>
-#include <vtkProp.h>
-#include <vtkProperty.h>
-#include <vtkRenderWindow.h>
-
-#include <cpExtensions/ui_PropertyWidget.h>
-
-// -------------------------------------------------------------------------
-cpExtensions::QT::PropertyWidget::
-PropertyWidget( QWidget* parent )
- : QWidget( parent ),
- m_UI( new Ui::PropertyWidget ),
- m_Prop( NULL ),
- m_Window( NULL )
-{
- this->m_UI->setupUi( this );
- this->connect(
- this->m_UI->m_Color, SIGNAL( clicked( ) ),
- this, SLOT( _Color( ) )
- );
- this->connect(
- this->m_UI->m_Opacity, SIGNAL( valueChanged( int ) ),
- this, SLOT( _Opacity( int ) )
- );
- this->connect(
- this->m_UI->m_LineWidth, SIGNAL( valueChanged( double ) ),
- this, SLOT( _LineWidth( double ) )
- );
- this->connect(
- this->m_UI->m_PointSize, SIGNAL( valueChanged( double ) ),
- this, SLOT( _PointSize( double ) )
- );
-}
-
-// -------------------------------------------------------------------------
-cpExtensions::QT::PropertyWidget::
-~PropertyWidget( )
-{
- delete this->m_UI;
-}
-
-// -------------------------------------------------------------------------
-vtkProp* cpExtensions::QT::PropertyWidget::
-GetProp( )
-{
- return( this->m_Prop );
-}
-
-// -------------------------------------------------------------------------
-vtkRenderWindow* cpExtensions::QT::PropertyWidget::
-GetRenderWindow( )
-{
- return( this->m_Window );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::PropertyWidget::
-SetProp( vtkProp* p )
-{
- this->m_Prop = p;
- if( this->m_Prop == NULL )
- return;
-
- auto actor = dynamic_cast< vtkActor* >( this->m_Prop );
- if( actor == NULL )
- return;
-
- double opacity = actor->GetProperty( )->GetOpacity( );
- double lw = actor->GetProperty( )->GetLineWidth( );
- double ps = actor->GetProperty( )->GetPointSize( );
- opacity *= this->m_UI->m_Opacity->maximum( );
-
- this->m_UI->m_Opacity->setValue( opacity );
- this->m_UI->m_LineWidth->setValue( lw );
- this->m_UI->m_PointSize->setValue( ps );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::PropertyWidget::
-SetRenderWindow( vtkRenderWindow* w )
-{
- this->m_Window = w;
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::PropertyWidget::
-_Color( )
-{
- if( this->m_Prop == NULL )
- return;
-
- auto actor = dynamic_cast< vtkActor* >( this->m_Prop );
- if( actor == NULL )
- return;
-
- double rgb[ 3 ];
- actor->GetProperty( )->GetColor( rgb );
- QColor color =
- QColorDialog::getColor(
- QColor( rgb[ 0 ] * 255, rgb[ 1 ] * 255, rgb[ 2 ] * 255 ),
- this,
- "Select Color",
- QColorDialog::DontUseNativeDialog
- );
- if( color.isValid( ) )
- {
- rgb[ 0 ] = double( color.red( ) ) / double( 255 );
- rgb[ 1 ] = double( color.green( ) ) / double( 255 );
- rgb[ 2 ] = double( color.blue( ) ) / double( 255 );
- actor->GetMapper( )->ScalarVisibilityOff( );
- actor->GetProperty( )->SetColor( rgb );
- actor->Modified( );
- if( this->m_Window != NULL )
- this->m_Window->Render( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::PropertyWidget::
-_Opacity( int o )
-{
- if( this->m_Prop == NULL )
- return;
-
- auto actor = dynamic_cast< vtkActor* >( this->m_Prop );
- if( actor == NULL )
- return;
- double v = double( o ) / double( this->m_UI->m_Opacity->maximum( ) );
- actor->GetProperty( )->SetOpacity( v );
- actor->Modified( );
- if( this->m_Window != NULL )
- this->m_Window->Render( );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::PropertyWidget::
-_LineWidth( double lw )
-{
- if( this->m_Prop == NULL )
- return;
-
- auto actor = dynamic_cast< vtkActor* >( this->m_Prop );
- if( actor == NULL )
- return;
- actor->GetProperty( )->SetLineWidth( lw );
- actor->Modified( );
- if( this->m_Window != NULL )
- this->m_Window->Render( );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::PropertyWidget::
-_PointSize( double ps )
-{
- if( this->m_Prop == NULL )
- return;
-
- auto actor = dynamic_cast< vtkActor* >( this->m_Prop );
- if( actor == NULL )
- return;
- actor->GetProperty( )->SetPointSize( ps );
- actor->Modified( );
- if( this->m_Window != NULL )
- this->m_Window->Render( );
-}
-
-#endif // cpExtensions_QT4
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __CPEXTENSIONS__QT__PROPERTYWIDGET__H__
-#define __CPEXTENSIONS__QT__PROPERTYWIDGET__H__
-
-#include <cpExtensions/Config.h>
-
-#ifdef cpExtensions_QT4
-
-#include <QWidget>
-
-// -------------------------------------------------------------------------
-class vtkProp;
-class vtkRenderWindow;
-
-namespace Ui
-{
- class PropertyWidget;
-}
-
-// -------------------------------------------------------------------------
-namespace cpExtensions
-{
- namespace QT
- {
- /**
- */
- class cpExtensions_EXPORT PropertyWidget
- : public QWidget
- {
- Q_OBJECT;
-
- public:
- typedef PropertyWidget Self;
-
- public:
- explicit PropertyWidget( QWidget* parent = 0 );
- virtual ~PropertyWidget( );
-
- vtkProp* GetProp( );
- vtkRenderWindow* GetRenderWindow( );
- void SetProp( vtkProp* p );
- void SetRenderWindow( vtkRenderWindow* w );
-
- protected slots:
- void _Color( );
- void _Opacity( int o );
- void _LineWidth( double lw );
- void _PointSize( double ps );
-
- protected:
- Ui::PropertyWidget* m_UI;
- vtkProp* m_Prop;
- vtkRenderWindow* m_Window;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // cpExtensions_QT4
-
-#endif // __CPEXTENSIONS__QT__PROPERTYWIDGET__H__
-
-// eof - $RCSfile$
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>PropertyWidget</class>
- <widget class="QWidget" name="PropertyWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>595</width>
- <height>125</height>
- </rect>
- </property>
- <property name="minimumSize">
- <size>
- <width>595</width>
- <height>125</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>595</width>
- <height>125</height>
- </size>
- </property>
- <property name="windowTitle">
- <string>Form</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QPushButton" name="m_Color">
- <property name="text">
- <string>Color</string>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QLabel" name="label">
- <property name="minimumSize">
- <size>
- <width>54</width>
- <height>21</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>54</width>
- <height>21</height>
- </size>
- </property>
- <property name="text">
- <string>Opacity:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QSlider" name="m_Opacity">
- <property name="maximum">
- <number>100</number>
- </property>
- <property name="value">
- <number>100</number>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_4">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QLabel" name="label_2">
- <property name="minimumSize">
- <size>
- <width>71</width>
- <height>21</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>71</width>
- <height>21</height>
- </size>
- </property>
- <property name="text">
- <string>Line width:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QDoubleSpinBox" name="m_LineWidth">
- <property name="maximum">
- <double>100.000000000000000</double>
- </property>
- <property name="singleStep">
- <double>1.000000000000000</double>
- </property>
- <property name="value">
- <double>1.000000000000000</double>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_3">
- <item>
- <widget class="QLabel" name="label_3">
- <property name="minimumSize">
- <size>
- <width>67</width>
- <height>21</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>67</width>
- <height>21</height>
- </size>
- </property>
- <property name="text">
- <string>Point size:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QDoubleSpinBox" name="m_PointSize">
- <property name="maximum">
- <double>100.000000000000000</double>
- </property>
- <property name="singleStep">
- <double>1.000000000000000</double>
- </property>
- <property name="value">
- <double>1.000000000000000</double>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </item>
- </layout>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
this->m_UI->setupUi( this );
// Configure VTK widgets
- this->m_VTK[ 0 ] = this->m_UI->VTK01;
- this->m_VTK[ 1 ] = this->m_UI->VTK00;
- this->m_VTK[ 2 ] = this->m_UI->VTK10;
- this->m_VTK[ 3 ] = this->m_UI->VTK11;
+ this->m_VTK[ 0 ] = this->m_UI->VTK_X;
+ this->m_VTK[ 1 ] = this->m_UI->VTK_Y;
+ this->m_VTK[ 2 ] = this->m_UI->VTK_Z;
+ this->m_VTK[ 3 ] = this->m_UI->VTK_3D;
for( unsigned int i = 0; i < 4; ++i )
{
void cpExtensions::QT::SimpleMPRWidget::
SetMainImage( vtkImageData* image )
{
+ this->Clear( );
for( unsigned int i = 0; i < 3; ++i )
{
- this->m_2DSlices[ i ] = vtkSmartPointer< TActors >::New( );
+ this->m_2DSlices[ i ] = vtkSmartPointer< TSliceActors >::New( );
this->m_2DSlices[ i ]->SetInputData( image, i );
this->m_2DSlices[ i ]->PushInto( this->m_Renderers[ i ] );
this->m_VTK[ i ]->GetRenderWindow( )->GetInteractor( )->
SetInteractorStyle( this->m_2DSlices[ i ]->GetStyle( ) );
- this->m_3DSlices[ i ] = vtkSmartPointer< TActors >::New( );
+ this->m_3DSlices[ i ] = vtkSmartPointer< TSliceActors >::New( );
this->m_3DSlices[ i ]->SetInputData( image, i );
this->m_3DSlices[ i ]->PushInto( this->m_Renderers[ 3 ] );
this->m_3DSlices[ i ]->SetStyle(
);
} // rof
+ this->_AssociateSlices( );
+}
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+SetMainActor( vtkImageActor* actor )
+{
+ this->Clear( );
+ vtkImageData* image = NULL;
for( unsigned int i = 0; i < 3; ++i )
{
- for( unsigned int j = 0; j < 3; ++j )
+ this->m_2DSlices[ i ] = vtkSmartPointer< TSliceActors >::New( );
+ if( i == 0 )
{
- if( i != j )
- this->m_2DSlices[ i ]->AssociateSlice( this->m_2DSlices[ j ] );
- this->m_2DSlices[ i ]->AssociateSlice( this->m_3DSlices[ j ] );
-
- } // rof
+ this->m_2DSlices[ i ]->SetInputActor( actor, i );
+ image = this->m_2DSlices[ i ]->GetInputData( );
+ }
+ else
+ this->m_2DSlices[ i ]->SetInputData( image, i );
+ this->m_2DSlices[ i ]->PushInto( this->m_Renderers[ i ] );
+ this->m_VTK[ i ]->GetRenderWindow( )->GetInteractor( )->
+ SetInteractorStyle( this->m_2DSlices[ i ]->GetStyle( ) );
- } // rof
- for( unsigned int i = 0; i < 3; ++i )
- {
- this->m_2DSlices[ i ]->GetStyle( )->
- SetCurrentRenderer( this->m_Renderers[ i ] );
- this->m_Renderers[ i ]->ResetCamera( );
- this->m_VTK[ i ]->GetRenderWindow( )->Render( );
+ this->m_3DSlices[ i ] = vtkSmartPointer< TSliceActors >::New( );
+ this->m_3DSlices[ i ]->SetInputData( image, i );
+ this->m_3DSlices[ i ]->PushInto( this->m_Renderers[ 3 ] );
+ this->m_3DSlices[ i ]->SetStyle(
+ dynamic_cast< vtkInteractorStyle* >(
+ this->m_Renderers[ 3 ]->GetRenderWindow( )->
+ GetInteractor( )->GetInteractorStyle( )
+ )
+ );
} // rof
- this->m_Renderers[ 3 ]->ResetCamera( );
- this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
+ this->_AssociateSlices( );
}
// -------------------------------------------------------------------------
void cpExtensions::QT::SimpleMPRWidget::
-AddMesh( vtkPolyData* mesh )
+AddImage( vtkImageData* image )
{
- PolyDataActor a;
- a.Configure( mesh );
- this->m_PolyDatas[ mesh ] = a;
- this->m_Renderers[ 3 ]->AddViewProp( a.Actor );
+ std::cerr << "SimpleMPR: adding image" << std::endl;
+ std::exit( 1 );
+}
- bool has_main_image = false;
- for( unsigned int i = 0; i < 3; ++i )
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+AddImageActor( vtkImageActor* actor )
+{
+ unsigned int i = 0;
+ bool cont = true;
+ while( i < 3 && cont )
{
if( this->m_2DSlices[ i ].GetPointer( ) != NULL )
{
- if( this->m_2DSlices[ i ]->GetInputData( ) != NULL )
+ if( this->m_2DSlices[ i ]->GetImageActor( ) != NULL )
{
- has_main_image = true;
- this->m_2DSlices[ i ]->AddMesh( mesh );
- this->m_2DSlices[ i ]->Render( );
-
- } // fi
+ // TODO: add image actor
+ }
+ else
+ cont = false;
} // fi
+ i++;
} // rof
- if( !has_main_image )
- this->m_Renderers[ 3 ]->ResetCamera( );
- this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
+
+ // Add if no actors were found
+ if( cont )
+ this->SetMainActor( actor );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+AddMesh( vtkPolyData* mesh )
+{
+ std::cerr << "SimpleMPR: adding mesh" << std::endl;
+ std::exit( 1 );
+ /* TODO
+ PolyDataActor a;
+ a.Configure( mesh );
+ this->m_PolyDatas[ mesh ] = a;
+ this->m_Renderers[ 3 ]->AddViewProp( a.Actor );
+
+ bool has_main_image = false;
+ for( unsigned int i = 0; i < 3; ++i )
+ {
+ if( this->m_2DSlices[ i ].GetPointer( ) != NULL )
+ {
+ if( this->m_2DSlices[ i ]->GetInputData( ) != NULL )
+ {
+ has_main_image = true;
+ this->m_2DSlices[ i ]->AddMesh( mesh );
+ this->m_2DSlices[ i ]->Render( );
+
+ } // fi
+
+ } // fi
+
+ } // rof
+ if( !has_main_image )
+ this->m_Renderers[ 3 ]->ResetCamera( );
+ this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
+ */
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+AddMeshActor( vtkActor* actor )
+{
+ std::cerr << "SimpleMPR: adding mesh actor" << std::endl;
+ std::exit( 1 );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+AddActor( vtkProp* actor )
+{
+ auto ia = dynamic_cast< vtkImageActor* >( actor );
+ if( ia == NULL )
+ {
+ auto ma = dynamic_cast< vtkActor* >( actor );
+ if( ma != NULL )
+ this->AddMeshActor( ma );
+ }
+ else
+ this->AddImageActor( ia );
}
// -------------------------------------------------------------------------
}
// -------------------------------------------------------------------------
-std::vector< std::pair< vtkImageActor*, vtkRenderer* > >
-cpExtensions::QT::SimpleMPRWidget::
-GetMainImageActors( )
+vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget::
+GetRenderWindow( unsigned int i )
{
- std::vector< std::pair< vtkImageActor*, vtkRenderer* > > actors;
- for( unsigned int i = 0; i < 3; ++i )
+ if( i < 4 )
{
- actors.push_back(
- std::pair< vtkImageActor*, vtkRenderer* >(
- this->m_2DSlices[ i ]->GetImageActor( ),
- this->m_Renderers[ i ]
- )
- );
- actors.push_back(
- std::pair< vtkImageActor*, vtkRenderer* >(
- this->m_3DSlices[ i ]->GetImageActor( ),
- this->m_Renderers[ 3 ]
- )
- );
-
- } // rof
- return( actors );
+ if( this->m_Renderers[ i ].GetPointer( ) != NULL )
+ return( this->m_Renderers[ i ]->GetRenderWindow( ) );
+ else
+ return( NULL );
+ }
+ else
+ return( NULL );
}
// -------------------------------------------------------------------------
-vtkActor* cpExtensions::QT::SimpleMPRWidget::
-GetActor( vtkPolyData* mesh )
+/* TODO
+ std::vector< std::pair< vtkImageActor*, vtkRenderer* > >
+ cpExtensions::QT::SimpleMPRWidget::
+ GetMainImageActors( )
+ {
+ std::vector< std::pair< vtkImageActor*, vtkRenderer* > > actors;
+ for( unsigned int i = 0; i < 3; ++i )
+ {
+ actors.push_back(
+ std::pair< vtkImageActor*, vtkRenderer* >(
+ this->m_2DSlices[ i ]->GetImageActor( ),
+ this->m_Renderers[ i ]
+ )
+ );
+ actors.push_back(
+ std::pair< vtkImageActor*, vtkRenderer* >(
+ this->m_3DSlices[ i ]->GetImageActor( ),
+ this->m_Renderers[ 3 ]
+ )
+ );
+
+ } // rof
+ return( actors );
+ }
+*/
+
+// -------------------------------------------------------------------------
+/* TODO
+ vtkActor* cpExtensions::QT::SimpleMPRWidget::
+ GetActor( vtkPolyData* mesh )
+ {
+ auto i = this->m_PolyDatas.find( mesh );
+ if( i != this->m_PolyDatas.end( ) )
+ return( i->second.Actor.GetPointer( ) );
+ else
+ return( NULL );
+ }
+*/
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+_AssociateSlices( )
{
- auto i = this->m_PolyDatas.find( mesh );
- if( i != this->m_PolyDatas.end( ) )
- return( i->second.Actor.GetPointer( ) );
- else
- return( NULL );
+ for( unsigned int i = 0; i < 3; ++i )
+ {
+ for( unsigned int j = 0; j < 3; ++j )
+ {
+ if( i != j )
+ this->m_2DSlices[ i ]->AssociateSlice( this->m_2DSlices[ j ] );
+ this->m_2DSlices[ i ]->AssociateSlice( this->m_3DSlices[ j ] );
+
+ } // rof
+
+ } // rof
+ for( unsigned int i = 0; i < 3; ++i )
+ {
+ this->m_2DSlices[ i ]->GetStyle( )->
+ SetCurrentRenderer( this->m_Renderers[ i ] );
+ this->m_Renderers[ i ]->ResetCamera( );
+ this->m_VTK[ i ]->GetRenderWindow( )->Render( );
+
+ } // rof
+ this->m_Renderers[ 3 ]->ResetCamera( );
+ this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
}
// -------------------------------------------------------------------------
public:
typedef SimpleMPRWidget Self;
- typedef cpExtensions::Visualization::ImageSliceActors TActors;
+ typedef cpExtensions::Visualization::ImageSliceActors TSliceActors;
/**
*/
// 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( vtkActor* actor );
+ void AddActor( vtkProp* actor );
// Visual objects
vtkRenderWindowInteractor* GetInteractor( unsigned int i );
vtkRenderer* GetRenderer( unsigned int i );
- std::vector< std::pair< vtkImageActor*, vtkRenderer* > >
- GetMainImageActors( );
- vtkActor* GetActor( vtkPolyData* mesh );
+ vtkRenderWindow* GetRenderWindow( unsigned int i );
+ /* TODO
+ std::vector< std::pair< vtkImageActor*, vtkRenderer* > >
+ GetMainImageActors( );
+ vtkActor* GetActor( vtkPolyData* mesh );
+ */
+
+ protected:
+ void _AssociateSlices( );
private slots:
void _SyncBottom( int a, int b );
Ui::SimpleMPRWidget* m_UI;
QVTKWidget* m_VTK[ 4 ];
- vtkSmartPointer< vtkRenderer > m_Renderers[ 4 ];
- vtkSmartPointer< TActors > m_2DSlices[ 3 ];
- vtkSmartPointer< TActors > m_3DSlices[ 3 ];
+ vtkSmartPointer< vtkRenderer > m_Renderers[ 4 ];
+ vtkSmartPointer< TSliceActors > m_2DSlices[ 3 ];
+ vtkSmartPointer< TSliceActors > m_3DSlices[ 3 ];
std::map< vtkPolyData*, PolyDataActor > m_PolyDatas;
};
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
- <widget class="QVTKWidget" name="VTK00" native="true">
+ <widget class="QVTKWidget" name="VTK_Y">
<property name="minimumSize">
<size>
<width>200</width>
</size>
</property>
</widget>
- <widget class="QVTKWidget" name="VTK01" native="true">
+ <widget class="QVTKWidget" name="VTK_X">
<property name="minimumSize">
<size>
<width>200</width>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
- <widget class="QVTKWidget" name="VTK10" native="true">
+ <widget class="QVTKWidget" name="VTK_Z">
<property name="minimumSize">
<size>
<width>200</width>
</size>
</property>
</widget>
- <widget class="QVTKWidget" name="VTK11" native="true">
+ <widget class="QVTKWidget" name="VTK_3D">
<property name="minimumSize">
<size>
<width>200</width>
<customwidget>
<class>QVTKWidget</class>
<extends>QWidget</extends>
- <header location="global">QVTKWidget.h</header>
+ <header>QVTKWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
this->_ConfigureInput( orientation );
}
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+SetInputActor( vtkProp* actor, int orientation )
+{
+ auto real_actor = dynamic_cast< vtkImageActor* >( actor );
+ if( real_actor == NULL )
+ return;
+ auto real_mapper =
+ dynamic_cast< vtkImageSliceMapper* >( real_actor->GetMapper( ) );
+ if( real_mapper == NULL )
+ return;
+ this->m_Mapper = real_mapper;
+ this->_ConfigureInput( orientation );
+}
+
// -------------------------------------------------------------------------
vtkImageData* cpExtensions::Visualization::ImageSliceActors::
GetInputData( )
void Clear( );
void SetInputConnection( vtkAlgorithmOutput* aout, int orientation );
void SetInputData( vtkImageData* data, int orientation );
+ void SetInputActor( vtkProp* actor, int orientation );
vtkImageData* GetInputData( );
vtkImageActor* GetImageActor( );
eventFilter( QObject* obj, QEvent* event )
{
return( true ); // -> Block all events
- /* NOTE: correct implementation:
+ /* NOTE: this should be the correct implementation:
switch( event->type( ) )
{
//list event you want to prevent here ...
}
// -------------------------------------------------------------------------
-void cpPlugins::DataObject::
-AddVTKActor( vtkProp* actor, vtkRenderer* renderer )
+vtkProp* cpPlugins::DataObject::
+CreateVTKActor( )
{
- if( actor != NULL && renderer != NULL )
- {
- TDataView v;
- v.Actor = actor;
- v.Renderer = renderer;
- this->m_Actors.insert( v );
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::DataObject::
-ClearVTKActors( )
-{
- this->m_Actors.clear( );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::DataObject::
-RenderVTKActors( )
-{
- for( auto i = this->m_Actors.begin( ); i != this->m_Actors.end( ); ++i )
- i->Renderer->GetRenderWindow( )->Render( );
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::DataObject::TDataViews::
-iterator cpPlugins::DataObject::
-BeginVTKActors( )
-{
- return( this->m_Actors.begin( ) );
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::DataObject::TDataViews::
-iterator cpPlugins::DataObject::
-EndVTKActors( )
-{
- return( this->m_Actors.end( ) );
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::DataObject::TDataViews::
-const_iterator cpPlugins::DataObject::
-BeginVTKActors( ) const
-{
- return( this->m_Actors.begin( ) );
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::DataObject::TDataViews::
-const_iterator cpPlugins::DataObject::
-EndVTKActors( ) const
-{
- return( this->m_Actors.end( ) );
+ return( NULL );
}
// -------------------------------------------------------------------------
#define __CPPLUGINS__DATAOBJECT__H__
#include <cpPlugins/Object.h>
-#include <set>
-#include <vtkProp.h>
-#include <vtkRenderer.h>
+
+// Some forward declarations
+class vtkProp;
namespace cpPlugins
{
itkTypeMacro( DataObject, Object );
cpPlugins_Id_Macro( DataObject, Object );
- struct TDataView
- {
- vtkSmartPointer< vtkProp > Actor;
- vtkSmartPointer< vtkRenderer > Renderer;
- bool operator<( const TDataView& b ) const
- { return( this->Actor.GetPointer( ) < b.Actor.GetPointer( ) ); }
- };
- typedef std::set< TDataView > TDataViews;
-
public:
ProcessObject* GetSource( );
const ProcessObject* GetSource( ) const;
virtual DataObjectVisualizationQtDialog* CreateQtDialog( );
// VTK actors
- virtual void AddVTKActor( vtkProp* actor, vtkRenderer* renderer );
- virtual void ClearVTKActors( );
- virtual void RenderVTKActors( );
- TDataViews::iterator BeginVTKActors( );
- TDataViews::iterator EndVTKActors( );
- TDataViews::const_iterator BeginVTKActors( ) const;
- TDataViews::const_iterator EndVTKActors( ) const;
+ virtual vtkProp* CreateVTKActor( );
protected:
DataObject( );
protected:
ProcessObject* m_Source;
- TDataViews m_Actors;
};
} // ecapseman
void cpPlugins::DataObjectVisualizationQtDialog::
_configureForImage( )
{
+ /* TODO
auto image = this->m_DataObject->GetVTK< vtkImageData >( );
auto aIt = this->m_DataObject->BeginVTKActors( );
if( image == NULL || aIt == this->m_DataObject->EndVTKActors( ) )
op_layout->addWidget( op_label );
op_layout->addWidget( op_sld );
this->m_ToolsLayout->addLayout( op_layout );
+*/
}
// -------------------------------------------------------------------------
void cpPlugins::DataObjectVisualizationQtDialog::
_configureForMesh( )
{
+ /* TODO
auto mesh = this->m_DataObject->GetVTK< vtkPolyData >( );
auto aIt = this->m_DataObject->BeginVTKActors( );
if( mesh == NULL || aIt == this->m_DataObject->EndVTKActors( ) )
op_layout->addWidget( op_label );
op_layout->addWidget( op_sld );
this->m_ToolsLayout->addLayout( op_layout );
+*/
}
// -------------------------------------------------------------------------
void cpPlugins::DataObjectVisualizationQtDialog::
_setWindow( double w )
{
+ /* TODO
if( this->m_DataObject == NULL )
return;
auto aIt = this->m_DataObject->BeginVTKActors( );
} // rof
this->_render( );
+*/
}
// -------------------------------------------------------------------------
void cpPlugins::DataObjectVisualizationQtDialog::
_setLevel( double l )
{
+ /* TODO
if( this->m_DataObject == NULL )
return;
auto aIt = this->m_DataObject->BeginVTKActors( );
} // rof
this->_render( );
+*/
}
// -------------------------------------------------------------------------
void cpPlugins::DataObjectVisualizationQtDialog::
_render( )
{
+ /* TODO
if( this->m_DataObject == NULL )
return;
this->m_DataObject->RenderVTKActors( );
+*/
}
// -------------------------------------------------------------------------
void cpPlugins::DataObjectVisualizationQtDialog::
_sldOpacity( int v )
{
+ /* TODO
if( this->m_DataObject == NULL )
return;
auto* sld = this->findChild< QSlider* >( "op_sld" );
} // rof
this->_render( );
+*/
}
// -------------------------------------------------------------------------
void cpPlugins::DataObjectVisualizationQtDialog::
_scalarVisibility( int v )
{
+ /* TODO
if( this->m_DataObject == NULL )
return;
auto* btn = this->findChild< QPushButton* >( "color_button" );
} // rof
this->_render( );
+*/
}
// -------------------------------------------------------------------------
void cpPlugins::DataObjectVisualizationQtDialog::
_color( )
{
+ /* TODO
if( this->m_DataObject == NULL )
return;
auto* btn = this->findChild< QPushButton* >( "color_button" );
this->_scalarVisibility( 0 );
} // fi
+*/
}
#endif // cpPlugins_QT4
#include <cpPlugins/Image.h>
+#include <vtkImageActor.h>
+#include <vtkImageSliceMapper.h>
+
// -------------------------------------------------------------------------
void cpPlugins::Image::
SetITK( itk::LightObject* o )
std::exit( 1 );
}
+// -------------------------------------------------------------------------
+vtkProp* cpPlugins::Image::
+CreateVTKActor( )
+{
+ vtkImageSliceMapper* mapper = vtkImageSliceMapper::New( );
+ vtkImageActor* actor = vtkImageActor::New( );
+ mapper->SetInputData( this->GetVTK< vtkImageData >( ) );
+ actor->SetMapper( mapper );
+ mapper->Delete( );
+ return( actor );
+}
+
// -------------------------------------------------------------------------
cpPlugins::Image::
Image( )
virtual void SetITK( itk::LightObject* o ) ITK_OVERRIDE;
virtual void SetVTK( vtkObjectBase* o ) ITK_OVERRIDE;
+ virtual vtkProp* CreateVTKActor( ) ITK_OVERRIDE;
+
protected:
Image( );
virtual ~Image( );
return( f );
}
+// -------------------------------------------------------------------------
+cpPlugins::DataObject* cpPlugins::Workspace::
+GetOutput( const std::string& filter, const std::string& output )
+{
+ auto f = this->GetFilter( filter );
+ if( f != NULL )
+ return( f->GetOutput( output ) );
+ else
+ return( NULL );
+}
+
+// -------------------------------------------------------------------------
+const cpPlugins::DataObject* cpPlugins::Workspace::
+GetOutput( const std::string& filter, const std::string& output ) const
+{
+ auto f = this->GetFilter( filter );
+ if( f != NULL )
+ return( f->GetOutput( output ) );
+ else
+ return( NULL );
+}
+
// -------------------------------------------------------------------------
bool cpPlugins::Workspace::
HasFilter( const std::string& name ) const
// Filter management
ProcessObject* GetFilter( const std::string& name );
const ProcessObject* GetFilter( const std::string& name ) const;
+ DataObject* GetOutput(
+ const std::string& filter, const std::string& output
+ );
+ const DataObject* GetOutput(
+ const std::string& filter, const std::string& output
+ ) const;
bool HasFilter( const std::string& name ) const;
ProcessObject* CreateFilter(
const std::string& category,