vtkSmartPointer< vtkPointHandleRepresentation3D > rep =
vtkSmartPointer< vtkPointHandleRepresentation3D >::New( );
- rep->SetDisplayPosition( pos );
+ rep->SetWorldPosition( pos );
rep->GetProperty( )->SetColor( 1, 0, 0 );
rep->ActiveRepresentationOff( );
rep->SetPointPlacer( placer );
#include <iostream>
#include <string>
+#include <vtkImageActorPointPlacer.h>
#include <vtkPointHandleRepresentation3D.h>
#include <vtkProperty.h>
#include <vtkRenderer.h>
image_actors->AddInputData( image->GetVTK< vtkImageData >( ), 2 );
image_actors->PushActorsInto( window );
+ vtkSmartPointer< vtkImageActorPointPlacer > placer =
+ vtkSmartPointer< vtkImageActorPointPlacer >::New( );
+ placer->SetImageActor( image_actors->GetImageActor( 0 ) );
+
// Create the widget and its representation
vtkSmartPointer< vtkPointHandleRepresentation3D > handle =
vtkSmartPointer< vtkPointHandleRepresentation3D >::New( );
handle->GetProperty( )->SetColor( 1, 0, 0 );
+ handle->SetPointPlacer( placer );
vtkSmartPointer< vtkSeedRepresentation > rep =
vtkSmartPointer< vtkSeedRepresentation >::New( );
rep->SetHandleRepresentation( handle );
this->AddItem( this->m_PlaneActor );
}
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+AssociateSlice( Self* slice )
+{
+ this->m_AssociatedSlices.push_back( slice );
+ this->Modified( );
+}
+
// -------------------------------------------------------------------------
vtkInteractorStyle* cpExtensions::Visualization::ImageSliceActors::
GetStyle( )
return( this->m_Style.GetPointer( ) );
}
+// -------------------------------------------------------------------------
+vtkImageData* cpExtensions::Visualization::ImageSliceActors::
+GetInputImage( unsigned int id )
+{
+ vtkAlgorithmOutput* aout = this->m_ImageMaps[ id ]->GetOutputPort( );
+ vtkImageData* image = dynamic_cast< vtkImageData* >(
+ aout->GetProducer( )->GetOutputDataObject( aout->GetIndex( ) )
+ );
+ return( image );
+}
+
+// -------------------------------------------------------------------------
+const vtkImageData* cpExtensions::Visualization::ImageSliceActors::
+GetInputImage( unsigned int id ) const
+{
+ vtkAlgorithmOutput* aout = this->m_ImageMaps[ id ]->GetOutputPort( );
+ const vtkImageData* image = dynamic_cast< const vtkImageData* >(
+ aout->GetProducer( )->GetOutputDataObject( aout->GetIndex( ) )
+ );
+ return( image );
+}
+
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
PushActorsInto( vtkRenderWindow* window, bool force_style )
{
+ this->m_Window = window;
if( window == NULL )
return;
vtkRenderWindowInteractor* rwi = window->GetInteractor( );
vtkRenderer* renderer = window->GetRenderers( )->GetFirstRenderer( );
if( rwi == NULL || renderer == NULL )
return;
-
+
// Update style
if( this->m_Style.GetPointer( ) != NULL && force_style )
rwi->SetInteractorStyle( this->m_Style );
while( prop = this->GetNextProp( ) )
renderer->AddViewProp( prop );
renderer->Modified( );
+ if( !force_style )
+ {
+ renderer->RemoveViewProp( this->m_CursorActor );
+ renderer->RemoveViewProp( this->m_TextActor );
+
+ } // fi
// Configure camera
vtkCamera* camera = renderer->GetActiveCamera( );
d_ext[ axis << 1 ] = slice;
d_ext[ ( axis << 1 ) + 1 ] = slice;
+ std::cout
+ << d_ext[ 0 ] << " "
+ << d_ext[ 1 ] << " "
+ << d_ext[ 2 ] << " "
+ << d_ext[ 3 ] << " "
+ << d_ext[ 4 ] << " "
+ << d_ext[ 5 ] << " : "
+ << axis << std::endl;
+
// Change visualization extent
for( unsigned int i = 0; i < nImages; ++i )
{
// Prevent obscuring voxels by offsetting the plane geometry
double xbnds[ ] =
{
- ori[ 0 ] + ( spac[ 0 ] * double( ext[ 0 ] ) ),
- ori[ 0 ] + ( spac[ 0 ] * double( ext[ 1 ] ) )
+ ori[ 0 ] + ( spac[ 0 ] * double( d_ext[ 0 ] ) ),
+ ori[ 0 ] + ( spac[ 0 ] * double( d_ext[ 1 ] ) )
};
double ybnds[ ] =
{
- ori[ 1 ] + ( spac[ 1 ] * double( ext[ 2 ] ) ),
- ori[ 1 ] + ( spac[ 1 ] * double( ext[ 3 ] ) )
+ ori[ 1 ] + ( spac[ 1 ] * double( d_ext[ 2 ] ) ),
+ ori[ 1 ] + ( spac[ 1 ] * double( d_ext[ 3 ] ) )
};
double zbnds[ ] =
{
- ori[ 2 ] + ( spac[ 2 ] * double( ext[ 4 ] ) ),
- ori[ 2 ] + ( spac[ 2 ] * double( ext[ 5 ] ) )
+ ori[ 2 ] + ( spac[ 2 ] * double( d_ext[ 4 ] ) ),
+ ori[ 2 ] + ( spac[ 2 ] * double( d_ext[ 5 ] ) )
};
if( spac[ 0 ] < double( 0 ) )
void cpExtensions::Visualization::ImageSliceActors::
Render( )
{
- vtkInteractorStyle* style = this->GetStyle( );
- if( style == NULL )
- return;
- vtkRenderWindowInteractor* rwi = style->GetInteractor( );
- if( rwi != NULL )
- rwi->Render( );
+ if( this->m_Window != NULL )
+ this->m_Window->Render( );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
ResetCamera( )
{
- vtkInteractorStyle* style = this->GetStyle( );
- if( style == NULL )
- return;
- vtkRenderWindowInteractor* rwi = style->GetInteractor( );
- if( rwi == NULL )
- return;
- vtkRenderWindow* rw = rwi->GetRenderWindow( );
- if( rw == NULL )
+ if( this->m_Window == NULL )
return;
- vtkRenderer* renderer = rw->GetRenderers( )->GetFirstRenderer( );
+ vtkRenderer* renderer =
+ this->m_Window->GetRenderers( )->GetFirstRenderer( );
if( renderer != NULL )
renderer->ResetCamera( );
}
cpExtensions::Visualization::ImageSliceActors::
ImageSliceActors( )
: Superclass( ),
+ m_Window( NULL ),
m_Interpolate( false )
{
this->Clear( );
if( slice > actors->GetSliceNumberMaxValue( ) )
slice = actors->GetSliceNumberMaxValue( );
actors->SetSliceNumber( slice );
- actors->Render( );
+ auto a = actors->m_AssociatedSlices.begin( );
+ for( ; a != actors->m_AssociatedSlices.end( ); ++a )
+ {
+ ( *a )->SetSliceNumber( slice );
+ ( *a )->Render( );
+
+ } // rof
+ actors->Render( );
+
// Associate objects
auto i = actors->m_RenderCommands.begin( );
for( ; i != actors->m_RenderCommands.end( ); ++i )
class vtkAlgorithmOutput;
class vtkImageData;
class vtkLookupTable;
+class vtkRenderer;
// -------------------------------------------------------------------------
namespace cpExtensions
void AddInputData( vtkImageData* data, int axis = 2 );
void Clear( );
+ void AssociateSlice( Self* slice );
+
+ vtkImageData* GetInputImage( unsigned int id );
+ const vtkImageData* GetInputImage( unsigned int id ) const;
+
vtkInteractorStyle* GetStyle( );
const vtkInteractorStyle* GetStyle( ) const;
protected:
vtkSmartPointer< TStyle > m_Style;
+ vtkRenderWindow* m_Window;
// Multiple actors
std::vector< vtkSmartPointer< vtkImageMapToColors > > m_ImageMaps;
std::vector< vtkSmartPointer< vtkImageActor > > m_ImageActors;
bool m_Interpolate;
+ // Associated slices
+ std::vector< Self* > m_AssociatedSlices;
+
// Window-Level values
double m_MinWindow, m_MaxWindow;
double m_MinLevel, m_MaxLevel;
this->Slices[ 0 ][ 0 ]->PushActorsInto( x, true );
this->Slices[ 0 ][ 1 ]->PushActorsInto( y, true );
this->Slices[ 0 ][ 2 ]->PushActorsInto( z, true );
+ this->Slices[ 1 ][ 0 ]->PushActorsInto( w, false );
+ this->Slices[ 1 ][ 1 ]->PushActorsInto( w, false );
+ this->Slices[ 1 ][ 2 ]->PushActorsInto( w, false );
- vtkRenderer* wren =
- ( w != NULL )? w->GetRenderers( )->GetFirstRenderer( ): NULL;
- vtkRenderer* rends[ ] =
- {
- ( x != NULL )? x->GetRenderers( )->GetFirstRenderer( ): NULL,
- ( y != NULL )? y->GetRenderers( )->GetFirstRenderer( ): NULL,
- ( z != NULL )? z->GetRenderers( )->GetFirstRenderer( ): NULL
- };
- for( int i = 0; i < 3; ++i )
- {
- if( rends[ i ] != NULL )
- for( int j = 0; j < 3; ++j )
- if( i != j )
- rends[ i ]->AddActor( this->Slices[ 0 ][ j ]->GetPlaneActor( ) );
- if( wren != NULL )
- {
- for(
- unsigned int k = 0;
- k < this->Slices[ 1 ][ i ]->GetNumberOfImageActors( );
- ++k
- )
- wren->AddActor( this->Slices[ 1 ][ i ]->GetImageActor( k ) );
- wren->AddActor( this->Slices[ 1 ][ i ]->GetPlaneActor( ) );
+ /*
- } // fi
+ this->Slices[ 0 ][ 0 ]->PushActorsInto( y, false );
+ this->Slices[ 0 ][ 0 ]->PushActorsInto( z, false );
- } // rof
- if( wren != NULL )
- wren->AddActor( this->ImageOutlineActor );
+ this->Slices[ 0 ][ 1 ]->PushActorsInto( x, false );
+ this->Slices[ 0 ][ 1 ]->PushActorsInto( z, false );
- for( unsigned int j = 0; j < 3; ++j )
- {
- /* TODO
- ImageInteractorStyle* st =
- dynamic_cast< ImageInteractorStyle* >( this->Slices[ 0 ][ j ]->GetStyle( ) );
- if( w != NULL )
- st->AssociateInteractor( w->GetInteractor( ) );
- for( unsigned int l = 0; l < 3; ++l )
- if( j != l )
- st->AssociateInteractor(
- this->Slices[ 0 ][ l ]->GetStyle( )->GetInteractor( )
- );
- */
+ this->Slices[ 0 ][ 2 ]->PushActorsInto( x, false );
+ this->Slices[ 0 ][ 2 ]->PushActorsInto( y, false );
- } // rof
+ vtkRenderer* wren =
+ ( w != NULL )? w->GetRenderers( )->GetFirstRenderer( ): NULL;
+ if( wren != NULL )
+ wren->AddActor( this->ImageOutlineActor );
+ */
}
// -------------------------------------------------------------------------
this->Slices[ 0 ][ 0 ]->PopActorsFrom( x );
this->Slices[ 0 ][ 1 ]->PopActorsFrom( y );
this->Slices[ 0 ][ 2 ]->PopActorsFrom( z );
+ this->Slices[ 1 ][ 0 ]->PopActorsFrom( w );
+ this->Slices[ 1 ][ 1 ]->PopActorsFrom( w );
+ this->Slices[ 1 ][ 2 ]->PopActorsFrom( w );
vtkRenderer* wren =
( w != NULL )? w->GetRenderers( )->GetFirstRenderer( ): NULL;
- vtkRenderer* rends[ ] =
- {
- ( x != NULL )? x->GetRenderers( )->GetFirstRenderer( ): NULL,
- ( y != NULL )? y->GetRenderers( )->GetFirstRenderer( ): NULL,
- ( z != NULL )? z->GetRenderers( )->GetFirstRenderer( ): NULL
- };
- for( int i = 0; i < 3; ++i )
- {
- if( rends[ i ] != NULL )
- for( int j = 0; j < 3; ++j )
- if( i != j )
- rends[ i ]->RemoveActor( this->Slices[ 0 ][ j ]->GetPlaneActor( ) );
- if( wren != NULL )
- {
- for(
- unsigned int k = 0;
- k < this->Slices[ 1 ][ i ]->GetNumberOfImageActors( );
- ++k
- )
- wren->RemoveActor( this->Slices[ 1 ][ i ]->GetImageActor( k ) );
- wren->RemoveActor( this->Slices[ 1 ][ i ]->GetPlaneActor( ) );
-
- } // fi
-
- } // rof
if( wren != NULL )
wren->RemoveActor( this->ImageOutlineActor );
void cpExtensions::Visualization::MPRActors::
SetSlice( const int& axis, const int& slice )
{
- vtkImageData* image = this->_Image( 0 );
+ vtkImageData* image = this->Slices[ 0 ][ 0 ]->GetInputImage( 0 );
if( image == NULL )
return;
void cpExtensions::Visualization::MPRActors::
SetSlice( const int& axis, const double& slice )
{
- vtkImageData* image = this->_Image( 0 );
+ vtkImageData* image = this->Slices[ 0 ][ 0 ]->GetInputImage( 0 );
if( image == NULL )
return;
for( unsigned int j = 0; j < 3; ++j )
this->Slices[ i ][ j ] = vtkSmartPointer< ImageSliceActors >::New( );
- /*
- this->Slices[ 0 ][ 0 ]->AssociateSlice( this->Slices[ 1 ][ 0 ] );
- this->Slices[ 0 ][ 1 ]->AssociateSlice( this->Slices[ 1 ][ 1 ] );
- this->Slices[ 0 ][ 2 ]->AssociateSlice( this->Slices[ 1 ][ 2 ] );
- */
- /*
- this->Slices[ 0 ][ 0 ]->AddSlicesCommand( TSlicesCommand command, void* data );
- AddWindowLevelCommand( TWindowLevelCommand command, void* data );
- AddRenderCommand
- */
+ this->Slices[ 0 ][ 0 ]->AssociateSlice( this->Slices[ 1 ][ 0 ] );
+ this->Slices[ 0 ][ 1 ]->AssociateSlice( this->Slices[ 1 ][ 1 ] );
+ this->Slices[ 0 ][ 2 ]->AssociateSlice( this->Slices[ 1 ][ 2 ] );
- /* TODO
- this->Slices[ 0 ][ 0 ]->SetSlicesCommand( Self::_SetSlices, this );
- this->Slices[ 0 ][ 1 ]->SetSlicesCommand( Self::_SetSlices, this );
- this->Slices[ 0 ][ 2 ]->SetSlicesCommand( Self::_SetSlices, this );
- */
-}
-
-// -------------------------------------------------------------------------
-cpExtensions::Visualization::MPRActors::
-~MPRActors( )
-{
-}
-
-// -------------------------------------------------------------------------
-vtkImageData* cpExtensions::Visualization::MPRActors::
-_Image( unsigned int i ) const
-{
- /*
- if( i < this->ImageMaps.size( ) )
+ for( unsigned int i = 0; i < 3; ++ i )
{
- vtkAlgorithm* algo = this->ImageMaps[ i ]->GetInputAlgorithm( );
- vtkInformation* info = algo->GetOutputInformation( 0 );
- return(
- vtkImageData::SafeDownCast(
- info->Get( vtkDataObject::DATA_OBJECT( ) )
- )
+ this->Slices[ 0 ][ i ]->AddRenderCommand(
+ Self::_RenderCommand, this
);
- }
- else
- */
- return( NULL );
+ this->Slices[ 0 ][ i ]->AddWindowLevelCommand(
+ Self::_WindowLevelCommand, this
+ );
+ // this->Slices[ 0 ][ i ]->AddSlicesCommand( Self::_SlicesCommand, this );
+
+ } // rof
}
// -------------------------------------------------------------------------
-void cpExtensions::Visualization::MPRActors::
-_Update( unsigned int i )
+cpExtensions::Visualization::MPRActors::
+~MPRActors( )
{
- /*
- // Check if the input has been configured
- vtkImageData* image = this->_Image( i );
- if( image == NULL )
- return;
- this->ImageMaps[ i ]->Update( );
-
- for( int j = 0; j < 2; ++j )
- {
- for( int k = 0; k < 3; ++k )
- {
- this->Slices[ j ][ k ]->AddInputConnection(
- this->ImageMaps[ i ]->GetOutputPort( ), k
- );
- this->Slices[ j ][ k ]->UpdateText( );
-
- // Add all of slice's props
- this->Slices[ j ][ k ]->InitTraversal( );
- vtkProp* prop = this->Slices[ j ][ k ]->GetNextProp( );
- while( prop != NULL )
- {
- this->AddItem( prop );
- prop = this->Slices[ j ][ k ]->GetNextProp( );
-
- } // elihw
-
- } // rof
-
- } // rof
-
- if( i == 0 )
- {
- // Create 3D outline
- double bb[ 6 ];
- image->GetBounds( bb );
-
- vtkSmartPointer< vtkOutlineSource > img_ol =
- vtkSmartPointer< vtkOutlineSource >::New( );
- img_ol->SetBounds( bb );
-
- vtkSmartPointer< vtkPolyDataMapper > img_ol_mapper =
- vtkSmartPointer< vtkPolyDataMapper >::New( );
- img_ol_mapper->SetInputConnection( img_ol->GetOutputPort( ) );
- this->ImageOutlineActor->SetMapper( img_ol_mapper );
- this->ImageOutlineActor->GetProperty( )->SetColor( 1, 1, 1 );
- this->ImageOutlineActor->GetProperty( )->SetLineWidth( 1 );
-
- this->AddItem( this->ImageOutlineActor );
-
- } // fi
- */
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
_WindowLevelCommand( double window, double level, void* data )
{
+ MPRActors* actors = reinterpret_cast< MPRActors* >( data );
+ if( actors == NULL )
+ return;
+ actors->Slices[ 0 ][ 0 ]->Render( );
+ actors->Slices[ 0 ][ 1 ]->Render( );
+ actors->Slices[ 0 ][ 2 ]->Render( );
+ actors->Slices[ 1 ][ 0 ]->Render( );
+ actors->Slices[ 1 ][ 1 ]->Render( );
+ actors->Slices[ 1 ][ 2 ]->Render( );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
_RenderCommand( void* data )
{
+ MPRActors* actors = reinterpret_cast< MPRActors* >( data );
+ if( actors == NULL )
+ return;
+ actors->Slices[ 0 ][ 0 ]->Render( );
+ actors->Slices[ 0 ][ 1 ]->Render( );
+ actors->Slices[ 0 ][ 2 ]->Render( );
+ actors->Slices[ 1 ][ 0 ]->Render( );
+ actors->Slices[ 1 ][ 1 ]->Render( );
+ actors->Slices[ 1 ][ 2 ]->Render( );
}
// eof - $RCSfile$
MPRActors( );
virtual ~MPRActors( );
- vtkImageData* _Image( unsigned int i ) const;
- void _Update( unsigned int i );
-
static void _SlicesCommand( double* pos, int axis, void* data );
- static void _WindowLevelCommand( double window, double level, void* data );
+ static void _WindowLevelCommand(
+ double window, double level, void* data
+ );
static void _RenderCommand( void* data );
private:
SET(
LIB_QT_Headers
ParametersListWidget.h
+ ParametersQtDialog.h
BaseMPRWindow.h
)
SET(
LIB_QT_Sources
ParametersListWidget.cxx
+ ParametersQtDialog.cxx
BaseMPRWindow.cxx
)
SET(
#ifdef cpPlugins_Interface_QT4
#include <limits>
-#include <vector>
#include <cpPlugins/Interface/ParametersListWidget.h>
+
+#include <vtkSmartPointer.h>
+#include <cpExtensions/Interaction/SeedWidget.h>
+#include <vtkPointHandleRepresentation3D.h>
+#include <vtkProperty.h>
+#include <vtkSeedRepresentation.h>
+
#include <QCheckBox>
-#include <QDialog>
#include <QDialogButtonBox>
#include <QDoubleSpinBox>
#include <QHBoxLayout>
-#include <QLabel>
#include <QLineEdit>
#include <QWidget>
// -------------------------------------------------------------------------
-bool cpPlugins::Interface::
-ParametersQtDialog(
- Parameters* parameters, const std::string& title, QWidget* parent
- )
+cpPlugins::Interface::ParametersQtDialog::
+ParametersQtDialog( QWidget* parent, Qt::WindowFlags f )
+ : QDialog( parent, f ),
+ m_Parameters( NULL ),
+ m_IsModal( false ),
+ m_Interactor( NULL )
{
- // Create dialog with a simple layout
- QDialog* dlg = new QDialog( parent );
- dlg->setWindowFlags( Qt::FramelessWindowHint );
- dlg->setWindowFlags( Qt::WindowTitleHint );
- QGridLayout* gridLayout = new QGridLayout( dlg );
- QVBoxLayout* verticalLayout = new QVBoxLayout( );
+ this->m_Title = new QLabel( this );
+ this->m_Title->setText( "Parameters dialog title" );
- // Put a title
- QLabel* dlg_title = new QLabel( dlg );
- dlg_title->setText( title.c_str( ) );
- verticalLayout->addWidget( dlg_title );
+ this->m_MainLayout = new QGridLayout( this );
+ this->m_ToolsLayout = new QVBoxLayout( );
+ this->m_ToolsLayout->addWidget( this->m_Title );
+ this->m_MainLayout->addLayout( this->m_ToolsLayout, 0, 0, 1, 1 );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::ParametersQtDialog::
+~ParametersQtDialog( )
+{
+ delete this->m_Title;
+ delete this->m_MainLayout;
+ delete this->m_ToolsLayout;
+
+ for( unsigned int i = 0; i < this->m_Widgets.size( ); ++i )
+ this->m_Widgets[ i ]->Delete( );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::ParametersQtDialog::
+IsModal( ) const
+{
+ return( this->m_IsModal );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::
+Parameters* cpPlugins::Interface::ParametersQtDialog::
+getParameters( ) const
+{
+ return( this->m_Parameters );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ParametersQtDialog::
+setInteractor( vtkRenderWindowInteractor* interactor )
+{
+ this->m_Interactor = interactor;
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::ParametersQtDialog::
+setParameters( Parameters* parameters )
+{
+ this->m_IsModal = true;
+ this->m_Parameters = parameters;
+ if( this->m_Parameters == NULL )
+ return( false );
// Put values
std::vector< std::string > names;
- parameters->GetNames( names );
+ this->m_Parameters->GetNames( names );
std::vector< std::string >::const_iterator nIt = names.begin( );
for( ; nIt != names.end( ); ++nIt )
{
- Parameters::Type pt = parameters->GetType( *nIt );
+ Parameters::Type pt = this->m_Parameters->GetType( *nIt );
+
+ QWidget* w_input = NULL;
+ if( pt == Parameters::String )
+ {
+ QLineEdit* v_string = new QLineEdit( this );
+ v_string->setText( "Enter some text!!!" );
+ w_input = v_string;
+ }
+ else if( pt == Parameters::Bool )
+ {
+ QCheckBox* v_bool = new QCheckBox( this );
+ v_bool->setText( "[ON/OFF]" );
+ v_bool->setChecked( this->m_Parameters->GetBool( *nIt ) );
+ w_input = v_bool;
+ }
+ else if( pt == Parameters::Uint )
+ {
+ QSpinBox* v_uint = new QSpinBox( this );
+ v_uint->setMinimum( 0 );
+ v_uint->setMaximum( std::numeric_limits< int >::max( ) );
+ v_uint->setValue( this->m_Parameters->GetUint( *nIt ) );
+ w_input = v_uint;
+ }
+ else if( pt == Parameters::Int )
+ {
+ QSpinBox* v_int = new QSpinBox( this );
+ v_int->setMinimum( -std::numeric_limits< int >::max( ) );
+ v_int->setMaximum( std::numeric_limits< int >::max( ) );
+ v_int->setValue( this->m_Parameters->GetInt( *nIt ) );
+ w_input = v_int;
+ }
+ else if( pt == Parameters::Real )
+ {
+ QDoubleSpinBox* v_double = new QDoubleSpinBox( this );
+ v_double->setDecimals( 3 );
+ v_double->setMinimum( -std::numeric_limits< double >::max( ) );
+ v_double->setMaximum( std::numeric_limits< double >::max( ) );
+ v_double->setValue( this->m_Parameters->GetReal( *nIt ) );
+ w_input = v_double;
+ }
+ else if(
+ pt == Parameters::StringList ||
+ pt == Parameters::IntList ||
+ pt == Parameters::UintList ||
+ pt == Parameters::RealList
+ )
+ {
+ cpPlugins::Interface::ParametersListWidget* l_double =
+ new cpPlugins::Interface::ParametersListWidget( *nIt, this );
+ w_input = l_double;
+ }
+ else if( pt == Parameters::Point || pt == Parameters::Index )
+ {
+ if( this->m_Interactor != NULL )
+ {
+ // Create a point widget and its representation
+ vtkSmartPointer< vtkPointHandleRepresentation3D > handle =
+ vtkSmartPointer< vtkPointHandleRepresentation3D >::New( );
+ handle->GetProperty( )->SetColor( 1, 0, 0 );
+ vtkSmartPointer< vtkSeedRepresentation > rep =
+ vtkSmartPointer< vtkSeedRepresentation >::New( );
+ rep->SetHandleRepresentation( handle );
+
+ cpExtensions::Interaction::SeedWidget* widget =
+ cpExtensions::Interaction::SeedWidget::New( );
+ widget->SetInteractor( this->m_Interactor );
+ widget->SetRepresentation( rep );
+ widget->On( );
+
+ this->m_Widgets.push_back( widget );
+ this->m_IsModal = false;
+
+ } // fi
+
+ } // fi
+
+ // Ok, a representation was created
+ if( w_input != NULL )
+ {
+ w_input->setObjectName( QString( nIt->c_str( ) ) );
+
+ QHBoxLayout* new_layout = new QHBoxLayout( );
+ QLabel* label = new QLabel( this );
+ label->setText( QString( nIt->c_str( ) ) );
+ new_layout->addWidget( label );
+ new_layout->addWidget( w_input );
+ this->m_ToolsLayout->addLayout( new_layout );
+
+ } // fi
+
+ } // rof
+ return( this->m_IsModal );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ParametersQtDialog::
+setTitle( const std::string& title )
+{
+ this->m_Title->setText( title.c_str( ) );
+}
+
+// -------------------------------------------------------------------------
+int cpPlugins::Interface::ParametersQtDialog::
+exec( )
+{
+ if( !this->m_IsModal )
+ return( 0 );
+
+ // Add buttons
+ QDialogButtonBox* bb = new QDialogButtonBox(
+ QDialogButtonBox::Ok | QDialogButtonBox::Cancel
+ );
+ QObject::connect( bb, SIGNAL( accepted( ) ), this, SLOT( accept( ) ) );
+ QObject::connect( bb, SIGNAL( rejected( ) ), this, SLOT( reject( ) ) );
+ this->m_ToolsLayout->addWidget( bb );
+
+ return( this->QDialog::exec( ) );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ParametersQtDialog::
+show( )
+{
+ if( this->m_IsModal )
+ return;
+
+ this->QDialog::show( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ParametersQtDialog::
+syncParameters( )
+{
+ std::cout << "TODO: SyncParameters" << std::endl;
+}
+
+
+
+
+
+
+
+
/* TODO
enum Type
{
- Bool,
Index,
Point,
StringList,
UintList,
IndexList,
PointList,
+ Choices,
NoType
};
*/
+/*
+bool cpPlugins::Interface::
+ParametersQtDialog(
+ Parameters* parameters, const std::string& title, QWidget* parent
+ )
+{
+ // Create dialog with a simple layout
+ QDialog* dlg = new QDialog( parent );
+ dlg->setWindowFlags( Qt::FramelessWindowHint );
+ dlg->setWindowFlags( Qt::WindowTitleHint );
+ QGridLayout* gridLayout = new QGridLayout( dlg );
+ QVBoxLayout* verticalLayout = new QVBoxLayout( );
+
+ // Put a title
+ QLabel* dlg_title = new QLabel( dlg );
+ dlg_title->setText( title.c_str( ) );
+ verticalLayout->addWidget( dlg_title );
+
+ // Put values
+ std::vector< std::string > names;
+ this->m_Parameters->GetNames( names );
+ std::vector< std::string >::const_iterator nIt = names.begin( );
+ for( ; nIt != names.end( ); ++nIt )
+ {
+ Parameters::Type pt = this->m_Parameters->GetType( *nIt );
+
QWidget* w_input = NULL;
if( pt == Parameters::String )
{
{
QCheckBox* v_bool = new QCheckBox( dlg );
v_bool->setText( "[ON/OFF]" );
- v_bool->setChecked( parameters->GetBool( *nIt ) );
+ v_bool->setChecked( this->m_Parameters->GetBool( *nIt ) );
w_input = v_bool;
}
else if( pt == Parameters::Uint )
QSpinBox* v_uint = new QSpinBox( dlg );
v_uint->setMinimum( 0 );
v_uint->setMaximum( std::numeric_limits< int >::max( ) );
- v_uint->setValue( parameters->GetUint( *nIt ) );
+ v_uint->setValue( this->m_Parameters->GetUint( *nIt ) );
w_input = v_uint;
}
else if( pt == Parameters::Int )
QSpinBox* v_int = new QSpinBox( dlg );
v_int->setMinimum( -std::numeric_limits< int >::max( ) );
v_int->setMaximum( std::numeric_limits< int >::max( ) );
- v_int->setValue( parameters->GetInt( *nIt ) );
+ v_int->setValue( this->m_Parameters->GetInt( *nIt ) );
w_input = v_int;
}
else if( pt == Parameters::Real )
v_double->setDecimals( 3 );
v_double->setMinimum( -std::numeric_limits< double >::max( ) );
v_double->setMaximum( std::numeric_limits< double >::max( ) );
- v_double->setValue( parameters->GetReal( *nIt ) );
+ v_double->setValue( this->m_Parameters->GetReal( *nIt ) );
w_input = v_double;
}
else if(
nIt = names.begin( );
for( ; nIt != names.end( ); ++nIt )
{
- Parameters::Type pt = parameters->GetType( *nIt );
+ Parameters::Type pt = this->m_Parameters->GetType( *nIt );
if( pt == Parameters::String )
{
QLineEdit* v_string = dlg->findChild< QLineEdit* >( nIt->c_str( ) );
if( v_string != NULL )
- parameters->SetString( *nIt, v_string->text( ).toStdString( ) );
+ this->m_Parameters->SetString( *nIt, v_string->text( ).toStdString( ) );
}
else if( pt == Parameters::Bool )
{
QCheckBox* v_bool = dlg->findChild< QCheckBox* >( nIt->c_str( ) );
if( v_bool != NULL )
- parameters->SetBool( *nIt, v_bool->isChecked( ) );
+ this->m_Parameters->SetBool( *nIt, v_bool->isChecked( ) );
}
else if( pt == Parameters::Uint )
{
QSpinBox* v_uint = dlg->findChild< QSpinBox* >( nIt->c_str( ) );
if( v_uint != NULL )
- parameters->SetUint( *nIt, v_uint->value( ) );
+ this->m_Parameters->SetUint( *nIt, v_uint->value( ) );
}
else if( pt == Parameters::Int )
{
QSpinBox* v_int = dlg->findChild< QSpinBox* >( nIt->c_str( ) );
if( v_int != NULL )
- parameters->SetInt( *nIt, v_int->value( ) );
+ this->m_Parameters->SetInt( *nIt, v_int->value( ) );
}
else if( pt == Parameters::Real )
{
QDoubleSpinBox* v_double =
dlg->findChild< QDoubleSpinBox* >( nIt->c_str( ) );
if( v_double != NULL )
- parameters->SetReal( *nIt, v_double->value( ) );
+ this->m_Parameters->SetReal( *nIt, v_double->value( ) );
}
else if(
pt == Parameters::StringList ||
{
std::vector< std::string > values = l_double->GetStringValues( );
for( int r = 0; r < values.size( ); ++r )
- parameters->AddToStringList( *nIt, values[ r ] );
+ this->m_Parameters->AddToStringList( *nIt, values[ r ] );
}
else if( pt == Parameters::IntList )
{
std::vector< int > values = l_double->GetIntValues( );
for( int r = 0; r < values.size( ); ++r )
- parameters->AddToIntList( *nIt, values[ r ] );
+ this->m_Parameters->AddToIntList( *nIt, values[ r ] );
}
else if( pt == Parameters::UintList )
{
std::vector< unsigned int > values = l_double->GetUintValues( );
for( int r = 0; r < values.size( ); ++r )
- parameters->AddToUintList( *nIt, values[ r ] );
+ this->m_Parameters->AddToUintList( *nIt, values[ r ] );
}
else if( pt == Parameters::RealList )
{
std::vector< double > values = l_double->GetDoubleValues( );
for( int r = 0; r < values.size( ); ++r )
- parameters->AddToRealList( *nIt, values[ r ] );
+ this->m_Parameters->AddToRealList( *nIt, values[ r ] );
} // fi
} // rof
return( true );
}
+*/
#endif // cpPlugins_Interface_QT4
#include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
#include <cpPlugins/Interface/Parameters.h>
-class QWidget;
+#include <vector>
+
+#include <QDialog>
+#include <QGridLayout>
+#include <QLabel>
+#include <QVBoxLayout>
+
+class vtkAbstractWidget;
+class vtkRenderWindowInteractor;
namespace cpPlugins
{
namespace Interface
{
- bool cpPlugins_Interface_EXPORT ParametersQtDialog(
- Parameters* parameters,
- const std::string& title,
- QWidget* parent = NULL
- );
+ /**
+ */
+ class cpPlugins_Interface_EXPORT ParametersQtDialog
+ : public QDialog
+ {
+ Q_OBJECT;
+
+ public:
+ ParametersQtDialog( QWidget* parent = 0, Qt::WindowFlags f = 0 );
+ virtual ~ParametersQtDialog( );
+
+ bool IsModal( ) const;
+ Parameters* getParameters( ) const;
+ void setInteractor( vtkRenderWindowInteractor* interactor );
+ bool setParameters( Parameters* parameters );
+ void setTitle( const std::string& title );
+
+ virtual int exec( );
+ virtual void show( );
+ void syncParameters( );
+
+ protected:
+ Parameters* m_Parameters;
+ QLabel* m_Title;
+ QGridLayout* m_MainLayout;
+ QVBoxLayout* m_ToolsLayout;
+ bool m_IsModal;
+
+ vtkRenderWindowInteractor* m_Interactor;
+ std::vector< vtkAbstractWidget* > m_Widgets;
+ };
+
+ /* TODO
+ bool cpPlugins_Interface_EXPORT ParametersQtDialog(
+ Parameters* parameters,
+ const std::string& title,
+ QWidget* parent = NULL
+ );
+ */
} // ecapseman
#ifdef cpPlugins_Interface_QT4
- r = cpPlugins::Interface::ParametersQtDialog(
+ if( this->m_ParametersDialog == NULL )
+ {
+ this->m_ParametersDialog = new ParametersQtDialog( parent );
+ this->m_ParametersDialog->setTitle(
+ this->GetClassName( ) + std::string( " basic configuration" )
+ );
+ this->m_ParametersDialog->setParameters( this->m_Parameters );
+
+ } // fi
+
+ if( !( this->m_ParametersDialog->IsModal( ) ) )
+ {
+ this->m_ParametersDialog->show( );
+ r = true;
+ }
+ else
+ r = ( this->m_ParametersDialog->exec( ) == 1 );
+ /*
+ r = cpPlugins::Interface::ParametersQtDialog(
this->m_Parameters,
this->GetClassName( ) + std::string( " basic configuration" ),
parent
);
- /*
if( r )
// TODO: !!! this->m_Parameters = parameters;
*/
ProcessObject( )
: Superclass( ),
m_ITKObject( NULL ),
- m_VTKObject( NULL )
+ m_VTKObject( NULL ),
+ m_ParametersDialog( NULL )
{
this->m_Parameters = TParameters::New( );
}
cpPlugins::Interface::ProcessObject::
~ProcessObject( )
{
+ if( this->m_ParametersDialog == NULL )
+ delete this->m_ParametersDialog;
}
// -------------------------------------------------------------------------
#ifdef cpPlugins_Interface_QT4
class QWidget;
#else
-typedef char QWidget
+typedef char QWidget;
#endif // cpPlugins_Interface_QT4
#include <itkProcessObject.h>
{
namespace Interface
{
+#ifdef cpPlugins_Interface_QT4
+ class ParametersQtDialog;
+#else
+ typedef char ParametersQtDialog;
+#endif // cpPlugins_Interface_QT4
+
/**
*/
class cpPlugins_Interface_EXPORT ProcessObject
vtkSmartPointer< vtkAlgorithm > m_VTKObject;
Parameters::Pointer m_Parameters;
+ ParametersQtDialog* m_ParametersDialog;
typedef std::map< std::string, DataObject::Pointer > _TDataContainer;
_TDataContainer m_Inputs;