From: Leonardo Flórez-Valencia Date: Fri, 16 Sep 2016 21:00:40 +0000 (-0500) Subject: Visualization integration in a single interface. X-Git-Tag: v0.1~109 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=8a5ea31f638e60ee6708667e2dc71bafd0e899ee;p=cpPlugins.git Visualization integration in a single interface. --- diff --git a/appli/PipelineEditor/PipelineEditorMainWindow.cxx b/appli/PipelineEditor/PipelineEditorMainWindow.cxx index ddabd0e..eb7b985 100644 --- a/appli/PipelineEditor/PipelineEditorMainWindow.cxx +++ b/appli/PipelineEditor/PipelineEditorMainWindow.cxx @@ -24,6 +24,7 @@ PipelineEditorMainWindow( cpBaseQtApplication_ConnectAction( ActionAddEnvironmentPath, _addEnvironmentPaths ); cpBaseQtApplication_ConnectAction( ActionLoadPluginFile, _loadPlugins ); cpBaseQtApplication_ConnectAction( ActionLoadPluginDirectory, _loadPluginsFromPath ); + cpBaseQtApplication_ConnectAction( ActionActorsProperties, _actorsProperties ); } // ------------------------------------------------------------------------- diff --git a/appli/PipelineEditor/PipelineEditorMainWindow.ui b/appli/PipelineEditor/PipelineEditorMainWindow.ui index 8e257be..6a38074 100644 --- a/appli/PipelineEditor/PipelineEditorMainWindow.ui +++ b/appli/PipelineEditor/PipelineEditorMainWindow.ui @@ -39,6 +39,11 @@ 60 + + + 1 + + @@ -59,7 +64,7 @@ 0 0 640 - 22 + 25 @@ -82,7 +87,14 @@ + + + P&roperties + + + + @@ -147,6 +159,17 @@ Ctrl+F9 + + + &Actors + + + Actors properties + + + Ctrl+Shift+V + + diff --git a/lib/cpBaseQtApplication/MainWindow.cxx b/lib/cpBaseQtApplication/MainWindow.cxx index 81f24c0..67a3844 100644 --- a/lib/cpBaseQtApplication/MainWindow.cxx +++ b/lib/cpBaseQtApplication/MainWindow.cxx @@ -7,6 +7,7 @@ #include #include +#include #include @@ -439,6 +440,19 @@ _loadPluginsFromPath( ) this->_loadPluginsFromPath( d.selectedFiles( ).begin( )->toStdString( ) ); } +// ------------------------------------------------------------------------- +void cpBaseQtApplication::MainWindow:: +_actorsProperties( ) +{ + if( this->m_MPR != NULL ) + { + auto dlg = new cpExtensions::QT::ConfigurationChooser( this ); + dlg->setData( this->m_MPR ); + dlg->exec( ); + + } // fi +} + // ------------------------------------------------------------------------- /* TODO void cpBaseQtApplication::MainWindow:: diff --git a/lib/cpBaseQtApplication/MainWindow.h b/lib/cpBaseQtApplication/MainWindow.h index 1f2f2c2..9e2b607 100644 --- a/lib/cpBaseQtApplication/MainWindow.h +++ b/lib/cpBaseQtApplication/MainWindow.h @@ -125,6 +125,7 @@ namespace cpBaseQtApplication void _loadPlugins( ); void _loadPluginsFromPath( const std::string& path ); void _loadPluginsFromPath( ); + void _actorsProperties( ); /* TODO void _ClearWorkspace( ); diff --git a/lib/cpExtensions/QT/ActorsWidgetInterface.h b/lib/cpExtensions/QT/ActorsWidgetInterface.h new file mode 100644 index 0000000..ff8dc14 --- /dev/null +++ b/lib/cpExtensions/QT/ActorsWidgetInterface.h @@ -0,0 +1,68 @@ +#ifndef __cpExtensions__QT__ActorsWidgetInterface__h__ +#define __cpExtensions__QT__ActorsWidgetInterface__h__ + +#include + +#ifdef cpExtensions_QT4 + +#include +#include + +namespace cpExtensions +{ + namespace QT + { + /** + */ + class cpExtensions_EXPORT ActorsWidgetInterface + { + public: + typedef ActorsWidgetInterface Self; + + public: + ActorsWidgetInterface( ) { } + virtual ~ActorsWidgetInterface( ) { } + + virtual std::set< std::string > GetActorsNames( ) const = 0; + virtual bool IsWindowLevelImageActor( const std::string& name ) const = 0; + virtual bool IsLUTImageActor( const std::string& name ) const = 0; + virtual bool Is3DActor( const std::string& name ) const = 0; + + virtual void GetScalarRange( const std::string& name, double r[ 2 ] ) const = 0; + virtual void GetWindowLevel( const std::string& name, double wl[ 2 ] ) const = 0; + virtual double GetWindow( const std::string& name ) const = 0; + virtual double GetLevel( const std::string& name ) const = 0; + virtual char GetImageInterpolation( const std::string& name ) const = 0; + + virtual void GetColor( const std::string& name, double& r, double& g, double& b ) const = 0; + virtual double GetOpacity( const std::string& name ) const = 0; + virtual double GetPointSize( const std::string& name ) const = 0; + virtual double GetLineWidth( const std::string& name ) const = 0; + virtual int GetRepresentation( const std::string& name ) const = 0; + + virtual void SetScalarRange( const std::string& name, double r[ 2 ] ) = 0; + virtual void SetScalarRange( const std::string& name, double min, double max ) = 0; + virtual void SetWindowLevel( const std::string& name, double wl[ 2 ] ) = 0; + virtual void SetWindowLevel( const std::string& name, double w, double l ) = 0; + virtual void SetWindow( const std::string& name, double w ) = 0; + virtual void SetLevel( const std::string& name, double l ) = 0; + virtual void SetImageInterpolation( const std::string& name, char i ) = 0; + + virtual void SetColor( const std::string& name, double r, double g, double b ) = 0; + virtual void SetOpacity( const std::string& name, double o ) = 0; + virtual void SetPointSize( const std::string& name, double s ) = 0; + virtual void SetLineWidth( const std::string& name, double w ) = 0; + virtual void SetRepresentationToPoints( const std::string& name ) = 0; + virtual void SetRepresentationToSurface( const std::string& name ) = 0; + virtual void SetRepresentationToWireframe( const std::string& name ) = 0; + }; + + } // ecapseman + +} // ecapseman + +#endif // cpExtensions_QT4 + +#endif // __cpExtensions__QT__ActorsWidgetInterface__h__ + +// eof - $RCSfile$ diff --git a/lib/cpExtensions/QT/ConfigurationChooser.cxx b/lib/cpExtensions/QT/ConfigurationChooser.cxx index 13eef42..aea4abd 100644 --- a/lib/cpExtensions/QT/ConfigurationChooser.cxx +++ b/lib/cpExtensions/QT/ConfigurationChooser.cxx @@ -3,8 +3,8 @@ #ifdef cpExtensions_QT4 #include +#include #include -#include // ------------------------------------------------------------------------- cpExtensions::QT::ConfigurationChooser:: @@ -25,14 +25,28 @@ cpExtensions::QT::ConfigurationChooser:: // ------------------------------------------------------------------------- void cpExtensions::QT::ConfigurationChooser:: -setData( SimpleMPRWidget* data ) +setData( ActorsWidgetInterface* data ) { this->m_Data = data; if( this->m_Data != NULL ) { - auto wl_wdg = new WindowLevelImageConfiguration( this ); - wl_wdg->setData( data ); - this->m_UI->Configurations->addTab( wl_wdg, "Image" ); + auto actors = this->m_Data->GetActorsNames( ); + for( auto n = actors.begin( ); n != actors.end( ); ++n ) + { + if( this->m_Data->IsWindowLevelImageActor( *n ) ) + { + auto wl_wdg = new WindowLevelImageConfiguration( this ); + wl_wdg->setData( data, *n ); + this->m_UI->Configurations->addTab( wl_wdg, n->c_str( ) ); + } + else if( this->m_Data->IsLUTImageActor( *n ) ) + { + } + else if( this->m_Data->Is3DActor( *n ) ) + { + } // fi + + } // rof } // fi } diff --git a/lib/cpExtensions/QT/ConfigurationChooser.h b/lib/cpExtensions/QT/ConfigurationChooser.h index 7b5e783..4a9007b 100644 --- a/lib/cpExtensions/QT/ConfigurationChooser.h +++ b/lib/cpExtensions/QT/ConfigurationChooser.h @@ -15,7 +15,7 @@ namespace cpExtensions { namespace QT { - class SimpleMPRWidget; + class ActorsWidgetInterface; /** */ @@ -32,11 +32,11 @@ namespace cpExtensions explicit ConfigurationChooser( QWidget* parent = NULL, Qt::WindowFlags f = 0 ); virtual ~ConfigurationChooser( ); - void setData( SimpleMPRWidget* data ); + void setData( ActorsWidgetInterface* data ); protected: Ui::ConfigurationChooser* m_UI; - SimpleMPRWidget* m_Data; + ActorsWidgetInterface* m_Data; }; } // ecapseman diff --git a/lib/cpExtensions/QT/ImageWidget.cxx b/lib/cpExtensions/QT/ImageWidget.cxx index 35557f5..8a3d2c3 100644 --- a/lib/cpExtensions/QT/ImageWidget.cxx +++ b/lib/cpExtensions/QT/ImageWidget.cxx @@ -15,13 +15,6 @@ #include #include -/* TODO - #include - #include - #include - #include -*/ - // ------------------------------------------------------------------------- cpExtensions::QT::ImageWidget:: ImageWidget( QWidget* parent, Qt::WindowFlags f ) @@ -232,230 +225,6 @@ SetLineWidth( const std::string& name, double w ) this->Render( ); } - -/* TODO -// ------------------------------------------------------------------------- -vtkInteractorStyle* cpExtensions::QT::ImageWidget:: -GetInteractorStyle( ) -{ - return( this->m_ImageSliceStyle ); -} - -// ------------------------------------------------------------------------- -const vtkInteractorStyle* cpExtensions::QT::ImageWidget:: -GetInteractorStyle( ) const -{ - return( this->m_ImageSliceStyle ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::ImageWidget:: -SetImage( vtkImageData* image, int orientation, const std::string& name ) -{ - if( this->m_ImageName != "" ) - { - // TODO: Clear visualization - - } // fi - this->m_ImageName = name; - - this->GetActiveCamera( )->ParallelProjectionOn( ); - - this->m_ImageViewerActors = - vtkSmartPointer< cpExtensions::Visualization::ImageViewerActors >::New( ); - this->m_ImageViewerActors->SetImage( image, orientation ); - - this->m_ImageSliceStyle->SetActors( this->m_ImageViewerActors ); - - this->AddViewProp( - this->m_ImageViewerActors->GetWindowLevelImageActor( ), - this->m_ImageName - ); - this->AddAuxViewProps( this->m_ImageViewerActors, this->m_ImageName ); - this->ResetCamera( ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::ImageWidget:: -Add( vtkDataSet* data, const std::string& name ) -{ - auto image = dynamic_cast< vtkImageData* >( data ); - - if( image == NULL ) - { - if( this->m_ImageName == "" ) - this->SetImage( data, name ); - { - } // fi - return; - - } // fi - - if( this->m_ImageName == "" ) - return; - - if( this->m_ImageViewerActors.GetPointer( ) != NULL ) - { - if( this->m_ImageViewerActors->AddLUTImage( image ) > 0 ) - { - this->AddViewProp( - this->m_ImageViewerActors->GetLUTImageActor( ), - name - ); - this->Render( ); - - } // fi - - } // fi -} - -// ------------------------------------------------------------------------- -int cpExtensions::QT::ImageWidget:: -GetOrientation( ) const -{ - return( this->m_ImageViewerActors->GetOrientation( ) ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::ImageWidget:: -SetSliceNumber( int slice ) -{ - this->m_ImageViewerActors->SetSliceNumber( slice ); - this->Render( ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::ImageWidget:: -GetScalarRange( double r[ 2 ] ) const -{ - auto actor = this->m_ImageViewerActors->GetWindowLevelImageActor( ); - if( actor != NULL ) - actor->GetRange( r ); - else - r[ 0 ] = r[ 1 ] = double( 0 ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::ImageWidget:: -GetWindowLevel( double wl[ 2 ] ) const -{ - auto actor = this->m_ImageViewerActors->GetWindowLevelImageActor( ); - if( actor != NULL ) - { - wl[ 0 ] = actor->GetWindow( ); - wl[ 1 ] = actor->GetLevel( ); - } - else - wl[ 0 ] = wl[ 1 ] = double( 0 ); -} - -// ------------------------------------------------------------------------- -double cpExtensions::QT::ImageWidget:: -GetImageOpacity( ) const -{ - auto actor = this->m_ImageViewerActors->GetWindowLevelImageActor( ); - if( actor != NULL ) - return( actor->GetProperty( )->GetOpacity( ) ); - else - return( double( 0 ) ); -} - -// ------------------------------------------------------------------------- -unsigned char cpExtensions::QT::ImageWidget:: -GetImageInterpolation( ) const -{ - auto actor = this->m_ImageViewerActors->GetWindowLevelImageActor( ); - if( actor != NULL ) - { - int int_type = actor->GetProperty( )->GetInterpolationType( ); - char ret = 0; - switch( int_type ) - { - case VTK_NEAREST_INTERPOLATION: ret = 'N'; break; - case VTK_LINEAR_INTERPOLATION: ret = 'L'; break; - case VTK_CUBIC_INTERPOLATION: ret = 'C'; break; - default: ret = 0; break; - } // hctiws - return( ret ); - } - else - return( 0 ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::ImageWidget:: -SetScalarRange( double r[ 2 ] ) -{ - auto actor = this->m_ImageViewerActors->GetWindowLevelImageActor( ); - if( actor != NULL ) - { - actor->ConfigureWindowLevel( r[ 0 ], r[ 1 ] ); - this->Render( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::ImageWidget:: -SetWindowLevel( double wl[ 2 ] ) -{ - auto actor = this->m_ImageViewerActors->GetWindowLevelImageActor( ); - if( actor != NULL ) - { - actor->SetWindowLevel( wl[ 0 ], wl[ 1 ] ); - this->Render( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::ImageWidget:: -SetImageOpacity( double o ) -{ - auto actor = this->m_ImageViewerActors->GetWindowLevelImageActor( ); - if( actor != NULL ) - { - actor->GetProperty( )->SetOpacity( o ); - this->Render( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::ImageWidget:: -SetImageInterpolation( unsigned char i ) -{ - auto actor = this->m_ImageViewerActors->GetWindowLevelImageActor( ); - if( actor != NULL ) - { - int int_type = 0; - switch( i ) - { - case 'L': int_type = VTK_LINEAR_INTERPOLATION; break; - case 'C': int_type = VTK_CUBIC_INTERPOLATION; break; - default : int_type = VTK_NEAREST_INTERPOLATION; break; - } // hctiws - actor->GetProperty( )->SetInterpolationType( int_type ); - this->Render( ); - - } // fi -} - -// ------------------------------------------------------------------------- -vtkProp* cpExtensions::QT::ImageWidget:: -GetImageActor( ) -{ - return( this->m_ImageViewerActors->GetWindowLevelImageActor( ) ); -} - -// ------------------------------------------------------------------------- -const vtkProp* cpExtensions::QT::ImageWidget:: -GetImageActor( ) const -{ - return( this->m_ImageViewerActors->GetWindowLevelImageActor( ) ); -} -*/ - #endif // cpExtensions_QT4 // eof - $RCSfile$ diff --git a/lib/cpExtensions/QT/ImageWidget.h b/lib/cpExtensions/QT/ImageWidget.h index 3e3721e..6627610 100644 --- a/lib/cpExtensions/QT/ImageWidget.h +++ b/lib/cpExtensions/QT/ImageWidget.h @@ -56,30 +56,6 @@ namespace cpExtensions void SetColor( const std::string& name, double r, double g, double b ); void SetLineWidth( const std::string& name, double w ); - /* TODO - void SetImage( - vtkImageData* image, int orientation, const std::string& name - ); - - // TODO: std::vector< vtkProp* > GetActors( const std::string& name ) const; - int GetOrientation( ) const; - void SetSliceNumber( int slice ); - - - void GetScalarRange( double r[ 2 ] ) const; - void GetWindowLevel( double wl[ 2 ] ) const; - double GetImageOpacity( ) const; - unsigned char GetImageInterpolation( ) const; - - void SetScalarRange( double r[ 2 ] ); - void SetWindowLevel( double wl[ 2 ] ); - void SetImageOpacity( double o ); - void SetImageInterpolation( unsigned char i ); - - vtkProp* GetImageActor( ); - const vtkProp* GetImageActor( ) const; - */ - protected: std::string m_ImageName; @@ -90,15 +66,6 @@ namespace cpExtensions std::vector< TActor* > m_Actors; vtkSmartPointer< TStyle > m_Style; - - /* TODO - protected: - vtkSmartPointer< cpExtensions::Visualization::ImageViewerActors > - m_ImageViewerActors; - vtkSmartPointer< cpExtensions::Interaction::ImageSliceStyle > - m_ImageSliceStyle; - std::string m_ImageName; - */ }; } // ecapseman diff --git a/lib/cpExtensions/QT/MPR3DWidget.cxx b/lib/cpExtensions/QT/MPR3DWidget.cxx index b4224a7..718078f 100644 --- a/lib/cpExtensions/QT/MPR3DWidget.cxx +++ b/lib/cpExtensions/QT/MPR3DWidget.cxx @@ -10,23 +10,12 @@ #include #include -/* TODO - #include - #include - - #include -*/ - // ------------------------------------------------------------------------- cpExtensions::QT::MPR3DWidget:: MPR3DWidget( QWidget* parent, Qt::WindowFlags f ) : Superclass( parent, f ), m_ImageName( "" ) { - /* TODO - this->m_Actors = - vtkSmartPointer< cpExtensions::Visualization::MPR3DActors >::New( ); - */ } // ------------------------------------------------------------------------- @@ -151,84 +140,6 @@ SetSlicesNumbers( int x, int y, int z ) this->Render( ); } -// ------------------------------------------------------------------------- -/* -void cpExtensions::QT::MPR3DWidget:: -SetImage( vtkImageData* image, const std::string& name ) -{ - if( this->m_ImageName != "" ) - { - // TODO: Clear visualization - - } // fi - - this->m_Actors->SetImage( image ); - this->m_ImageName = name; - - vtkSmartPointer< vtkPropCollection > props = - vtkSmartPointer< vtkPropCollection >::New( ); - props->AddItem( this->m_Actors->GetWindowLevelImageActor( 0 ) ); - props->AddItem( this->m_Actors->GetWindowLevelImageActor( 1 ) ); - props->AddItem( this->m_Actors->GetWindowLevelImageActor( 2 ) ); - this->AddViewProps( props, name ); - this->AddAuxViewProp( this->m_Actors->GetImageOutlineActor( 0 ), name ); - this->AddAuxViewProp( this->m_Actors->GetImageOutlineActor( 1 ), name ); - this->AddAuxViewProp( this->m_Actors->GetImageOutlineActor( 2 ), name ); - this->ResetCamera( ); - this->Render( ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::MPR3DWidget:: -SetSliceNumber( int orientation, int slice ) -{ - this->m_Actors->SetSliceNumber( orientation, slice ); - this->Render( ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::MPR3DWidget:: -SetSlicesNumbers( int x, int y, int z ) -{ - this->m_Actors->SetSliceNumber( 0, x ); - this->m_Actors->SetSliceNumber( 1, y ); - this->m_Actors->SetSliceNumber( 2, z ); - this->Render( ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::MPR3DWidget:: -SetScalarRange( double r[ 2 ] ) -{ - this->m_Actors->SetScalarRange( r ); - this->Render( ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::MPR3DWidget:: -SetWindowLevel( double wl[ 2 ] ) -{ - this->m_Actors->SetWindowLevel( wl ); - this->Render( ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::MPR3DWidget:: -SetImageOpacity( double o ) -{ - this->m_Actors->SetImageOpacity( o ); - this->Render( ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::MPR3DWidget:: -SetImageInterpolation( unsigned char i ) -{ - this->m_Actors->SetImageInterpolation( i ); - this->Render( ); -} - */ - #endif // cpExtensions_QT4 // eof - $RCSfile$ diff --git a/lib/cpExtensions/QT/MPR3DWidget.h b/lib/cpExtensions/QT/MPR3DWidget.h index 667e0e2..b2edc14 100644 --- a/lib/cpExtensions/QT/MPR3DWidget.h +++ b/lib/cpExtensions/QT/MPR3DWidget.h @@ -49,27 +49,12 @@ namespace cpExtensions void SetSliceNumber( int orientation, int slice ); void SetSlicesNumbers( int x, int y, int z ); - /* TODO - void SetImage( vtkImageData* image, const std::string& name ); - - - void SetScalarRange( double r[ 2 ] ); - void SetWindowLevel( double wl[ 2 ] ); - void SetImageOpacity( double o ); - void SetImageInterpolation( unsigned char i ); - */ - protected: std::string m_ImageName; vtkSmartPointer< TWLActor > m_WLActors[ 3 ]; vtkSmartPointer< TOLActor > m_OLActors[ 3 ]; std::vector< TActor* > m_Actors; - - /* TODO - vtkSmartPointer< cpExtensions::Visualization::MPR3DActors > m_Actors; - std::string m_ImageName; - */ }; } // ecapseman diff --git a/lib/cpExtensions/QT/RendererWidget.cxx b/lib/cpExtensions/QT/RendererWidget.cxx index 251ecea..7b04041 100644 --- a/lib/cpExtensions/QT/RendererWidget.cxx +++ b/lib/cpExtensions/QT/RendererWidget.cxx @@ -4,15 +4,20 @@ #include #include +#include #include #include +#include #include #include +#include +#include // ------------------------------------------------------------------------- cpExtensions::QT::RendererWidget:: RendererWidget( QWidget* parent, Qt::WindowFlags f ) - : Superclass( parent, f ) + : Superclass( parent, f ), + Superclass2( ) { this->m_Renderer = vtkSmartPointer< vtkRenderer >::New( ); this->GetRenderWindow( )->AddRenderer( this->m_Renderer ); @@ -341,6 +346,640 @@ Render( ) this->GetRenderWindow( )->Render( ); } +// ------------------------------------------------------------------------- +std::set< std::string > cpExtensions::QT::RendererWidget:: +GetActorsNames( ) const +{ + std::set< std::string > names; + for( + auto p = this->m_ViewProps.begin( ); + p != this->m_ViewProps.end( ); + ++p + ) + names.insert( p->first ); + return( names ); +} + +// ------------------------------------------------------------------------- +bool cpExtensions::QT::RendererWidget:: +IsWindowLevelImageActor( const std::string& name ) const +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + auto a = it->second.begin( ); + if( a != it->second.end( ) ) + return( dynamic_cast< TWLActor* >( a->GetPointer( ) ) != NULL ); + else + return( false ); + } + else + return( false ); +} + +// ------------------------------------------------------------------------- +bool cpExtensions::QT::RendererWidget:: +IsLUTImageActor( const std::string& name ) const +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + auto a = it->second.begin( ); + if( a != it->second.end( ) ) + return( dynamic_cast< TLUTActor* >( a->GetPointer( ) ) != NULL ); + else + return( false ); + } + else + return( false ); +} + +// ------------------------------------------------------------------------- +bool cpExtensions::QT::RendererWidget:: +Is3DActor( const std::string& name ) const +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + auto a = it->second.begin( ); + if( a != it->second.end( ) ) + return( dynamic_cast< vtkActor* >( a->GetPointer( ) ) != NULL ); + else + return( false ); + } + else + return( false ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::RendererWidget:: +GetScalarRange( const std::string& name, double r[ 2 ] ) const +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + auto p = it->second.begin( ); + TWLActor* a = NULL; + while( a == NULL && p != it->second.end( ) ) + { + a = dynamic_cast< TWLActor* >( p->GetPointer( ) ); + p++; + + } // elihw + if( a != NULL ) + a->GetRange( r ); + + } // fi +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::RendererWidget:: +GetWindowLevel( const std::string& name, double wl[ 2 ] ) const +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + auto p = it->second.begin( ); + TWLActor* a = NULL; + while( a == NULL && p != it->second.end( ) ) + { + a = dynamic_cast< TWLActor* >( p->GetPointer( ) ); + p++; + + } // elihw + if( a != NULL ) + a->GetWindowLevel( wl ); + + } // fi +} + +// ------------------------------------------------------------------------- +double cpExtensions::QT::RendererWidget:: +GetWindow( const std::string& name ) const +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + auto p = it->second.begin( ); + TWLActor* a = NULL; + while( a == NULL && p != it->second.end( ) ) + { + a = dynamic_cast< TWLActor* >( p->GetPointer( ) ); + p++; + + } // elihw + if( a != NULL ) + return( a->GetWindow( ) ); + else + return( 0 ); + } + else + return( 0 ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::QT::RendererWidget:: +GetLevel( const std::string& name ) const +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + auto p = it->second.begin( ); + TWLActor* a = NULL; + while( a == NULL && p != it->second.end( ) ) + { + a = dynamic_cast< TWLActor* >( p->GetPointer( ) ); + p++; + + } // elihw + if( a != NULL ) + return( a->GetLevel( ) ); + else + return( 0 ); + } + else + return( 0 ); +} + +// ------------------------------------------------------------------------- +char cpExtensions::QT::RendererWidget:: +GetImageInterpolation( const std::string& name ) const +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + auto p = it->second.begin( ); + TWLActor* a = NULL; + while( a == NULL && p != it->second.end( ) ) + { + a = dynamic_cast< TWLActor* >( p->GetPointer( ) ); + p++; + + } // elihw + if( a != NULL ) + { + int int_type = a->GetProperty( )->GetInterpolationType( ); + char ret = 0; + switch( int_type ) + { + case VTK_NEAREST_INTERPOLATION: ret = 'N'; break; + case VTK_LINEAR_INTERPOLATION: ret = 'L'; break; + case VTK_CUBIC_INTERPOLATION: ret = 'C'; break; + default: ret = 0; break; + } // hctiws + return( ret ); + } + else + return( 0 ); + } + else + return( 0 ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::RendererWidget:: +GetColor( const std::string& name, double& r, double& g, double& b ) const +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + auto p = it->second.begin( ); + vtkActor* a = NULL; + while( a == NULL && p != it->second.end( ) ) + { + a = dynamic_cast< vtkActor* >( p->GetPointer( ) ); + p++; + + } // elihw + if( a != NULL ) + return( a->GetProperty( )->GetColor( r, g, b ) ); + + } // fi +} + +// ------------------------------------------------------------------------- +double cpExtensions::QT::RendererWidget:: +GetOpacity( const std::string& name ) const +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + auto p = it->second.begin( ); + vtkActor* a = NULL; + vtkImageSlice* s = NULL; + while( a == NULL && s == NULL && p != it->second.end( ) ) + { + a = dynamic_cast< vtkActor* >( p->GetPointer( ) ); + s = dynamic_cast< vtkImageSlice* >( p->GetPointer( ) ); + p++; + + } // elihw + if( a != NULL ) + return( a->GetProperty( )->GetOpacity( ) ); + else if( s != NULL ) + return( s->GetProperty( )->GetOpacity( ) ); + else + return( 0 ); + } + return( 0 ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::QT::RendererWidget:: +GetPointSize( const std::string& name ) const +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + auto p = it->second.begin( ); + vtkActor* a = NULL; + while( a == NULL && p != it->second.end( ) ) + { + a = dynamic_cast< vtkActor* >( p->GetPointer( ) ); + p++; + + } // elihw + if( a != NULL ) + return( a->GetProperty( )->GetPointSize( ) ); + else + return( 0 ); + } + return( 0 ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::QT::RendererWidget:: +GetLineWidth( const std::string& name ) const +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + auto p = it->second.begin( ); + vtkActor* a = NULL; + while( a == NULL && p != it->second.end( ) ) + { + a = dynamic_cast< vtkActor* >( p->GetPointer( ) ); + p++; + + } // elihw + if( a != NULL ) + return( a->GetProperty( )->GetLineWidth( ) ); + else + return( 0 ); + } + return( 0 ); +} + +// ------------------------------------------------------------------------- +int cpExtensions::QT::RendererWidget:: +GetRepresentation( const std::string& name ) const +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + auto p = it->second.begin( ); + vtkActor* a = NULL; + while( a == NULL && p != it->second.end( ) ) + { + a = dynamic_cast< vtkActor* >( p->GetPointer( ) ); + p++; + + } // elihw + if( a != NULL ) + return( a->GetProperty( )->GetRepresentation( ) ); + else + return( -1 ); + } + return( -1 ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::RendererWidget:: +SetScalarRange( const std::string& name, double r[ 2 ] ) +{ + this->SetScalarRange( name, r[ 0 ], r[ 1 ] ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::RendererWidget:: +SetScalarRange( const std::string& name, double min, double max ) +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + bool render = false; + for( auto p = it->second.begin( ); p != it->second.end( ); ++p ) + { + TWLActor* a = dynamic_cast< TWLActor* >( p->GetPointer( ) ); + if( a != NULL ) + { + render = true; + a->SetRange( min, max ); + + } // fi + + } // rof + if( render ) + this->Render( ); + + } // fi +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::RendererWidget:: +SetWindowLevel( const std::string& name, double wl[ 2 ] ) +{ + this->SetWindowLevel( name, wl[ 0 ], wl[ 1 ] ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::RendererWidget:: +SetWindowLevel( const std::string& name, double w, double l ) +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + bool render = false; + for( auto p = it->second.begin( ); p != it->second.end( ); ++p ) + { + TWLActor* a = dynamic_cast< TWLActor* >( p->GetPointer( ) ); + if( a != NULL ) + { + render = true; + a->SetWindowLevel( w, l ); + + } // fi + + } // rof + if( render ) + this->Render( ); + + } // fi +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::RendererWidget:: +SetWindow( const std::string& name, double w ) +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + bool render = false; + for( auto p = it->second.begin( ); p != it->second.end( ); ++p ) + { + TWLActor* a = dynamic_cast< TWLActor* >( p->GetPointer( ) ); + if( a != NULL ) + { + render = true; + a->SetWindow( w ); + + } // fi + + } // rof + if( render ) + this->Render( ); + + } // fi +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::RendererWidget:: +SetLevel( const std::string& name, double l ) +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + bool render = false; + for( auto p = it->second.begin( ); p != it->second.end( ); ++p ) + { + TWLActor* a = dynamic_cast< TWLActor* >( p->GetPointer( ) ); + if( a != NULL ) + { + render = true; + a->SetLevel( l ); + + } // fi + + } // rof + if( render ) + this->Render( ); + + } // fi +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::RendererWidget:: +SetImageInterpolation( const std::string& name, char i ) +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + bool render = false; + for( auto p = it->second.begin( ); p != it->second.end( ); ++p ) + { + TWLActor* a = dynamic_cast< TWLActor* >( p->GetPointer( ) ); + if( a != NULL ) + { + render = true; + int int_type = VTK_NEAREST_INTERPOLATION; + switch( i ) + { + case 'L': int_type = VTK_LINEAR_INTERPOLATION; break; + case 'C': int_type = VTK_CUBIC_INTERPOLATION; break; + default: int_type = VTK_NEAREST_INTERPOLATION; break; + } // hctiws + a->GetProperty( )->SetInterpolationType( int_type ); + + } // fi + + } // rof + if( render ) + this->Render( ); + + } // fi +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::RendererWidget:: +SetColor( const std::string& name, double r, double g, double b ) +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + bool render = false; + for( auto p = it->second.begin( ); p != it->second.end( ); ++p ) + { + vtkActor* a = dynamic_cast< vtkActor* >( p->GetPointer( ) ); + if( a != NULL ) + { + render = true; + a->GetProperty( )->SetColor( r, g, b ); + + } // fi + + } // rof + if( render ) + this->Render( ); + + } // fi +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::RendererWidget:: +SetOpacity( const std::string& name, double o ) +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + bool render = false; + for( auto p = it->second.begin( ); p != it->second.end( ); ++p ) + { + vtkActor* a = dynamic_cast< vtkActor* >( p->GetPointer( ) ); + vtkImageSlice* s = dynamic_cast< vtkImageSlice* >( p->GetPointer( ) ); + if( a != NULL ) + { + render = true; + a->GetProperty( )->SetOpacity( o ); + } + else if( s != NULL ) + { + render = true; + s->GetProperty( )->SetOpacity( o ); + + } // fi + + } // rof + if( render ) + this->Render( ); + + } // fi +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::RendererWidget:: +SetPointSize( const std::string& name, double s ) +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + bool render = false; + for( auto p = it->second.begin( ); p != it->second.end( ); ++p ) + { + vtkActor* a = dynamic_cast< vtkActor* >( p->GetPointer( ) ); + if( a != NULL ) + { + render = true; + a->GetProperty( )->SetPointSize( s ); + + } // fi + + } // rof + if( render ) + this->Render( ); + + } // fi +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::RendererWidget:: +SetLineWidth( const std::string& name, double w ) +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + bool render = false; + for( auto p = it->second.begin( ); p != it->second.end( ); ++p ) + { + vtkActor* a = dynamic_cast< vtkActor* >( p->GetPointer( ) ); + if( a != NULL ) + { + render = true; + a->GetProperty( )->SetLineWidth( w ); + + } // fi + + } // rof + if( render ) + this->Render( ); + + } // fi +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::RendererWidget:: +SetRepresentationToPoints( const std::string& name ) +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + bool render = false; + for( auto p = it->second.begin( ); p != it->second.end( ); ++p ) + { + vtkActor* a = dynamic_cast< vtkActor* >( p->GetPointer( ) ); + if( a != NULL ) + { + render = true; + a->GetProperty( )->SetRepresentationToPoints( ); + + } // fi + + } // rof + if( render ) + this->Render( ); + + } // fi +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::RendererWidget:: +SetRepresentationToSurface( const std::string& name ) +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + bool render = false; + for( auto p = it->second.begin( ); p != it->second.end( ); ++p ) + { + vtkActor* a = dynamic_cast< vtkActor* >( p->GetPointer( ) ); + if( a != NULL ) + { + render = true; + a->GetProperty( )->SetRepresentationToSurface( ); + + } // fi + + } // rof + if( render ) + this->Render( ); + + } // fi +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::RendererWidget:: +SetRepresentationToWireframe( const std::string& name ) +{ + auto it = this->m_ViewProps.find( name ); + if( it != this->m_ViewProps.end( ) ) + { + bool render = false; + for( auto p = it->second.begin( ); p != it->second.end( ); ++p ) + { + vtkActor* a = dynamic_cast< vtkActor* >( p->GetPointer( ) ); + if( a != NULL ) + { + render = true; + a->GetProperty( )->SetRepresentationToWireframe( ); + + } // fi + + } // rof + if( render ) + this->Render( ); + + } // fi +} + #endif // cpExtensions_QT4 // eof - $RCSfile$ diff --git a/lib/cpExtensions/QT/RendererWidget.h b/lib/cpExtensions/QT/RendererWidget.h index c90803b..256c5b1 100644 --- a/lib/cpExtensions/QT/RendererWidget.h +++ b/lib/cpExtensions/QT/RendererWidget.h @@ -5,6 +5,7 @@ #ifdef cpExtensions_QT4 +#include #include #include #include @@ -20,22 +21,33 @@ class vtkPropCollection; // ------------------------------------------------------------------------- namespace cpExtensions { + namespace Visualization + { + class LUTImageActor; + class WindowLevelImageActor; + } + namespace QT { /** */ class cpExtensions_EXPORT RendererWidget - : public cpExtensions_QVTKWidget + : public cpExtensions_QVTKWidget, + public ActorsWidgetInterface { Q_OBJECT; public: typedef RendererWidget Self; typedef cpExtensions_QVTKWidget Superclass; + typedef ActorsWidgetInterface Superclass2; typedef std::set< vtkSmartPointer< vtkProp > > TProps; typedef std::map< std::string, TProps > TPropCollection; + typedef cpExtensions::Visualization::LUTImageActor TLUTActor; + typedef cpExtensions::Visualization::WindowLevelImageActor TWLActor; + public: explicit RendererWidget( QWidget* parent = NULL, Qt::WindowFlags f = 0 @@ -78,6 +90,39 @@ namespace cpExtensions virtual void ResetCamera( ); virtual void Render( ); + virtual std::set< std::string > GetActorsNames( ) const cpExtensions_OVERRIDE; + virtual bool IsWindowLevelImageActor( const std::string& name ) const cpExtensions_OVERRIDE; + virtual bool IsLUTImageActor( const std::string& name ) const cpExtensions_OVERRIDE; + virtual bool Is3DActor( const std::string& name ) const cpExtensions_OVERRIDE; + + virtual void GetScalarRange( const std::string& name, double r[ 2 ] ) const cpExtensions_OVERRIDE; + virtual void GetWindowLevel( const std::string& name, double wl[ 2 ] ) const cpExtensions_OVERRIDE; + virtual double GetWindow( const std::string& name ) const cpExtensions_OVERRIDE; + virtual double GetLevel( const std::string& name ) const cpExtensions_OVERRIDE; + virtual char GetImageInterpolation( const std::string& name ) const cpExtensions_OVERRIDE; + + virtual void GetColor( const std::string& name, double& r, double& g, double& b ) const cpExtensions_OVERRIDE; + virtual double GetOpacity( const std::string& name ) const cpExtensions_OVERRIDE; + virtual double GetPointSize( const std::string& name ) const cpExtensions_OVERRIDE; + virtual double GetLineWidth( const std::string& name ) const cpExtensions_OVERRIDE; + virtual int GetRepresentation( const std::string& name ) const cpExtensions_OVERRIDE; + + virtual void SetScalarRange( const std::string& name, double r[ 2 ] ) cpExtensions_OVERRIDE; + virtual void SetScalarRange( const std::string& name, double min, double max ) cpExtensions_OVERRIDE; + virtual void SetWindowLevel( const std::string& name, double wl[ 2 ] ) cpExtensions_OVERRIDE; + virtual void SetWindowLevel( const std::string& name, double w, double l ) cpExtensions_OVERRIDE; + virtual void SetWindow( const std::string& name, double w ) cpExtensions_OVERRIDE; + virtual void SetLevel( const std::string& name, double l ) cpExtensions_OVERRIDE; + virtual void SetImageInterpolation( const std::string& name, char i ) cpExtensions_OVERRIDE; + + virtual void SetColor( const std::string& name, double r, double g, double b ) cpExtensions_OVERRIDE; + virtual void SetOpacity( const std::string& name, double o ) cpExtensions_OVERRIDE; + virtual void SetPointSize( const std::string& name, double s ) cpExtensions_OVERRIDE; + virtual void SetLineWidth( const std::string& name, double w ) cpExtensions_OVERRIDE; + virtual void SetRepresentationToPoints( const std::string& name ) cpExtensions_OVERRIDE; + virtual void SetRepresentationToSurface( const std::string& name ) cpExtensions_OVERRIDE; + virtual void SetRepresentationToWireframe( const std::string& name ) cpExtensions_OVERRIDE; + protected: vtkSmartPointer< vtkRenderer > m_Renderer; vtkSmartPointer< vtkOrientationMarkerWidget > m_Marker; diff --git a/lib/cpExtensions/QT/SimpleMPRWidget.cxx b/lib/cpExtensions/QT/SimpleMPRWidget.cxx index 665b0a1..b700b4e 100644 --- a/lib/cpExtensions/QT/SimpleMPRWidget.cxx +++ b/lib/cpExtensions/QT/SimpleMPRWidget.cxx @@ -17,6 +17,7 @@ cpExtensions::QT::SimpleMPRWidget:: SimpleMPRWidget( QWidget* parent, Qt::WindowFlags f ) : Superclass( parent, f ), + Superclass2( ), m_UI( new Ui::SimpleMPRWidget ), m_MainImageName( "" ) { @@ -70,10 +71,6 @@ SimpleMPRWidget( QWidget* parent, Qt::WindowFlags f ) this->m_UI->Bottom, SIGNAL( splitterMoved( int, int ) ), this, SLOT( _SyncTop( int, int ) ) ); - this->connect( - this->m_UI->ConfigurationButton, SIGNAL( clicked( ) ), - this, SLOT( _ConfigurationButton( ) ) - ); } // ------------------------------------------------------------------------- @@ -345,125 +342,287 @@ GetWRenderWindow( ) const // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: -GetScalarRange( double r[ 2 ] ) const +ResetCameras( ) +{ +/* + this->m_XImage->ResetCamera( ); + this->m_YImage->ResetCamera( ); + this->m_ZImage->ResetCamera( ); + this->m_3DView->ResetCamera( ); +*/ +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +Render( ) +{ +/* + this->m_XImage->Render( ); + this->m_YImage->Render( ); + this->m_ZImage->Render( ); + this->m_3DView->Render( ); +*/ +} + +// ------------------------------------------------------------------------- +std::set< std::string > cpExtensions::QT::SimpleMPRWidget:: +GetActorsNames( ) const +{ + std::set< std::string > names = this->m_XImage->GetActorsNames( ); + std::set< std::string > y = this->m_YImage->GetActorsNames( ); + std::set< std::string > z = this->m_ZImage->GetActorsNames( ); + std::set< std::string > w = this->m_3DView->GetActorsNames( ); + names.insert( y.begin( ), y.end( ) ); + names.insert( z.begin( ), z.end( ) ); + names.insert( w.begin( ), w.end( ) ); + return( names ); +} + +// ------------------------------------------------------------------------- +bool cpExtensions::QT::SimpleMPRWidget:: +IsWindowLevelImageActor( const std::string& name ) const +{ + return( this->m_XImage->IsWindowLevelImageActor( name ) ); +} + +// ------------------------------------------------------------------------- +bool cpExtensions::QT::SimpleMPRWidget:: +IsLUTImageActor( const std::string& name ) const +{ + return( this->m_XImage->IsLUTImageActor( name ) ); +} + +// ------------------------------------------------------------------------- +bool cpExtensions::QT::SimpleMPRWidget:: +Is3DActor( const std::string& name ) const +{ + return( + this->m_XImage->Is3DActor( name ) || this->m_3DView->Is3DActor( name ) + ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +GetScalarRange( const std::string& name, double r[ 2 ] ) const { -// this->m_XImage->GetScalarRange( r ); + this->m_XImage->GetScalarRange( name, r ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: -GetWindowLevel( double wl[ 2 ] ) const +GetWindowLevel( const std::string& name, double wl[ 2 ] ) const { -// this->m_XImage->GetWindowLevel( wl ); + this->m_XImage->GetWindowLevel( name, wl ); } // ------------------------------------------------------------------------- double cpExtensions::QT::SimpleMPRWidget:: -GetImageOpacity( ) const +GetWindow( const std::string& name ) const { -// return( this->m_XImage->GetImageOpacity( ) ); + return( this->m_XImage->GetWindow( name ) ); } // ------------------------------------------------------------------------- -unsigned char cpExtensions::QT::SimpleMPRWidget:: -GetImageInterpolation( ) const +double cpExtensions::QT::SimpleMPRWidget:: +GetLevel( const std::string& name ) const { -// return( this->m_XImage->GetImageInterpolation( ) ); + return( this->m_XImage->GetLevel( name ) ); +} + +// ------------------------------------------------------------------------- +char cpExtensions::QT::SimpleMPRWidget:: +GetImageInterpolation( const std::string& name ) const +{ + return( this->m_XImage->GetImageInterpolation( name ) ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: -SetScalarRange( double r[ 2 ] ) +GetColor( const std::string& name, double& r, double& g, double& b ) const { -/* - this->m_XImage->SetScalarRange( r ); - this->m_YImage->SetScalarRange( r ); - this->m_ZImage->SetScalarRange( r ); - this->m_3DView->SetScalarRange( r ); -*/ + this->m_XImage->GetColor( name, r, g, b ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::QT::SimpleMPRWidget:: +GetOpacity( const std::string& name ) const +{ + return( this->m_XImage->GetOpacity( name ) ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::QT::SimpleMPRWidget:: +GetPointSize( const std::string& name ) const +{ + return( this->m_XImage->GetPointSize( name ) ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::QT::SimpleMPRWidget:: +GetLineWidth( const std::string& name ) const +{ + return( this->m_XImage->GetLineWidth( name ) ); +} + +// ------------------------------------------------------------------------- +int cpExtensions::QT::SimpleMPRWidget:: +GetRepresentation( const std::string& name ) const +{ + return( this->m_XImage->GetRepresentation( name ) ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: -SetWindowLevel( double wl[ 2 ] ) +SetScalarRange( const std::string& name, double r[ 2 ] ) { -/* - this->m_XImage->SetWindowLevel( wl ); - this->m_YImage->SetWindowLevel( wl ); - this->m_ZImage->SetWindowLevel( wl ); - this->m_3DView->SetWindowLevel( wl ); -*/ + this->m_XImage->SetScalarRange( name, r ); + this->m_YImage->SetScalarRange( name, r ); + this->m_ZImage->SetScalarRange( name, r ); + this->m_3DView->SetScalarRange( name, r ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: -SetImageOpacity( double o ) +SetScalarRange( const std::string& name, double min, double max ) { -/* - this->m_XImage->SetImageOpacity( o ); - this->m_YImage->SetImageOpacity( o ); - this->m_ZImage->SetImageOpacity( o ); - this->m_3DView->SetImageOpacity( o ); -*/ + this->m_XImage->SetScalarRange( name, min, max ); + this->m_YImage->SetScalarRange( name, min, max ); + this->m_ZImage->SetScalarRange( name, min, max ); + this->m_3DView->SetScalarRange( name, min, max ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: -SetImageInterpolation( unsigned char i ) +SetWindowLevel( const std::string& name, double wl[ 2 ] ) { - /* - this->m_XImage->SetImageInterpolation( i ); - this->m_YImage->SetImageInterpolation( i ); - this->m_ZImage->SetImageInterpolation( i ); - this->m_3DView->SetImageInterpolation( i ); -*/ + this->m_XImage->SetWindowLevel( name, wl ); + this->m_YImage->SetWindowLevel( name, wl ); + this->m_ZImage->SetWindowLevel( name, wl ); + this->m_3DView->SetWindowLevel( name, wl ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: -ResetCameras( ) +SetWindowLevel( const std::string& name, double w, double l ) { -/* - this->m_XImage->ResetCamera( ); - this->m_YImage->ResetCamera( ); - this->m_ZImage->ResetCamera( ); - this->m_3DView->ResetCamera( ); -*/ + this->m_XImage->SetWindowLevel( name, w, l ); + this->m_YImage->SetWindowLevel( name, w, l ); + this->m_ZImage->SetWindowLevel( name, w, l ); + this->m_3DView->SetWindowLevel( name, w, l ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: -Render( ) +SetWindow( const std::string& name, double w ) { -/* - this->m_XImage->Render( ); - this->m_YImage->Render( ); - this->m_ZImage->Render( ); - this->m_3DView->Render( ); -*/ + this->m_XImage->SetWindow( name, w ); + this->m_YImage->SetWindow( name, w ); + this->m_ZImage->SetWindow( name, w ); + this->m_3DView->SetWindow( name, w ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: -_SyncBottom( int a, int b ) +SetLevel( const std::string& name, double l ) { - this->m_UI->Bottom->setSizes( this->m_UI->Top->sizes( ) ); + this->m_XImage->SetLevel( name, l ); + this->m_YImage->SetLevel( name, l ); + this->m_ZImage->SetLevel( name, l ); + this->m_3DView->SetLevel( name, l ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: -_SyncTop( int a, int b ) +SetImageInterpolation( const std::string& name, char i ) { - this->m_UI->Top->setSizes( this->m_UI->Bottom->sizes( ) ); + this->m_XImage->SetImageInterpolation( name, i ); + this->m_YImage->SetImageInterpolation( name, i ); + this->m_ZImage->SetImageInterpolation( name, i ); + this->m_3DView->SetImageInterpolation( name, i ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +SetColor( const std::string& name, double r, double g, double b ) +{ + this->m_XImage->SetColor( name, r, g, b ); + this->m_YImage->SetColor( name, r, g, b ); + this->m_ZImage->SetColor( name, r, g, b ); + this->m_3DView->SetColor( name, r, g, b ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +SetOpacity( const std::string& name, double o ) +{ + this->m_XImage->SetOpacity( name, o ); + this->m_YImage->SetOpacity( name, o ); + this->m_ZImage->SetOpacity( name, o ); + this->m_3DView->SetOpacity( name, o ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: -_ConfigurationButton( ) +SetPointSize( const std::string& name, double s ) { - auto dlg = new cpExtensions::QT::ConfigurationChooser( NULL ); - dlg->setData( this ); - dlg->exec( ); + this->m_XImage->SetPointSize( name, s ); + this->m_YImage->SetPointSize( name, s ); + this->m_ZImage->SetPointSize( name, s ); + this->m_3DView->SetPointSize( name, s ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +SetLineWidth( const std::string& name, double w ) +{ + this->m_XImage->SetLineWidth( name, w ); + this->m_YImage->SetLineWidth( name, w ); + this->m_ZImage->SetLineWidth( name, w ); + this->m_3DView->SetLineWidth( name, w ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +SetRepresentationToPoints( const std::string& name ) +{ + this->m_XImage->SetRepresentationToPoints( name ); + this->m_YImage->SetRepresentationToPoints( name ); + this->m_ZImage->SetRepresentationToPoints( name ); + this->m_3DView->SetRepresentationToPoints( name ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +SetRepresentationToSurface( const std::string& name ) +{ + this->m_XImage->SetRepresentationToSurface( name ); + this->m_YImage->SetRepresentationToSurface( name ); + this->m_ZImage->SetRepresentationToSurface( name ); + this->m_3DView->SetRepresentationToSurface( name ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +SetRepresentationToWireframe( const std::string& name ) +{ + this->m_XImage->SetRepresentationToWireframe( name ); + this->m_YImage->SetRepresentationToWireframe( name ); + this->m_ZImage->SetRepresentationToWireframe( name ); + this->m_3DView->SetRepresentationToWireframe( name ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +_SyncBottom( int a, int b ) +{ + this->m_UI->Bottom->setSizes( this->m_UI->Top->sizes( ) ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +_SyncTop( int a, int b ) +{ + this->m_UI->Top->setSizes( this->m_UI->Bottom->sizes( ) ); } #endif // cpExtensions_QT4 diff --git a/lib/cpExtensions/QT/SimpleMPRWidget.h b/lib/cpExtensions/QT/SimpleMPRWidget.h index 6403e45..6d32fc9 100644 --- a/lib/cpExtensions/QT/SimpleMPRWidget.h +++ b/lib/cpExtensions/QT/SimpleMPRWidget.h @@ -5,7 +5,7 @@ #ifdef cpExtensions_QT4 -// TODO: #include +#include #include #include #include @@ -29,13 +29,15 @@ namespace cpExtensions /** */ class cpExtensions_EXPORT SimpleMPRWidget - : public QWidget + : public QWidget, + public ActorsWidgetInterface { Q_OBJECT; public: - typedef SimpleMPRWidget Self; - typedef QWidget Superclass; + typedef SimpleMPRWidget Self; + typedef QWidget Superclass; + typedef ActorsWidgetInterface Superclass2; typedef vtkSmartPointer< vtkPropCollection > TProp; typedef std::set< TProp > TProps; @@ -74,27 +76,45 @@ namespace cpExtensions vtkRenderWindow* GetWRenderWindow( ); const vtkRenderWindow* GetWRenderWindow( ) const; - void GetScalarRange( double r[ 2 ] ) const; - void GetWindowLevel( double wl[ 2 ] ) const; - double GetImageOpacity( ) const; - unsigned char GetImageInterpolation( ) const; - - void SetScalarRange( double r[ 2 ] ); - void SetWindowLevel( double wl[ 2 ] ); - void SetImageOpacity( double o ); - void SetImageInterpolation( unsigned char i ); - - /* TODO - std::vector< vtkProp* > GetActors( const std::string& name ) const; - */ - void ResetCameras( ); void Render( ); + virtual std::set< std::string > GetActorsNames( ) const cpExtensions_OVERRIDE; + virtual bool IsWindowLevelImageActor( const std::string& name ) const cpExtensions_OVERRIDE; + virtual bool IsLUTImageActor( const std::string& name ) const cpExtensions_OVERRIDE; + virtual bool Is3DActor( const std::string& name ) const cpExtensions_OVERRIDE; + + virtual void GetScalarRange( const std::string& name, double r[ 2 ] ) const cpExtensions_OVERRIDE; + virtual void GetWindowLevel( const std::string& name, double wl[ 2 ] ) const cpExtensions_OVERRIDE; + virtual double GetWindow( const std::string& name ) const cpExtensions_OVERRIDE; + virtual double GetLevel( const std::string& name ) const cpExtensions_OVERRIDE; + virtual char GetImageInterpolation( const std::string& name ) const cpExtensions_OVERRIDE; + + virtual void GetColor( const std::string& name, double& r, double& g, double& b ) const cpExtensions_OVERRIDE; + virtual double GetOpacity( const std::string& name ) const cpExtensions_OVERRIDE; + virtual double GetPointSize( const std::string& name ) const cpExtensions_OVERRIDE; + virtual double GetLineWidth( const std::string& name ) const cpExtensions_OVERRIDE; + virtual int GetRepresentation( const std::string& name ) const cpExtensions_OVERRIDE; + + virtual void SetScalarRange( const std::string& name, double r[ 2 ] ) cpExtensions_OVERRIDE; + virtual void SetScalarRange( const std::string& name, double min, double max ) cpExtensions_OVERRIDE; + virtual void SetWindowLevel( const std::string& name, double wl[ 2 ] ) cpExtensions_OVERRIDE; + virtual void SetWindowLevel( const std::string& name, double w, double l ) cpExtensions_OVERRIDE; + virtual void SetWindow( const std::string& name, double w ) cpExtensions_OVERRIDE; + virtual void SetLevel( const std::string& name, double l ) cpExtensions_OVERRIDE; + virtual void SetImageInterpolation( const std::string& name, char i ) cpExtensions_OVERRIDE; + + virtual void SetColor( const std::string& name, double r, double g, double b ) cpExtensions_OVERRIDE; + virtual void SetOpacity( const std::string& name, double o ) cpExtensions_OVERRIDE; + virtual void SetPointSize( const std::string& name, double s ) cpExtensions_OVERRIDE; + virtual void SetLineWidth( const std::string& name, double w ) cpExtensions_OVERRIDE; + virtual void SetRepresentationToPoints( const std::string& name ) cpExtensions_OVERRIDE; + virtual void SetRepresentationToSurface( const std::string& name ) cpExtensions_OVERRIDE; + virtual void SetRepresentationToWireframe( const std::string& name ) cpExtensions_OVERRIDE; + private slots: void _SyncBottom( int a, int b ); void _SyncTop( int a, int b ); - void _ConfigurationButton( ); protected: Ui::SimpleMPRWidget* m_UI; diff --git a/lib/cpExtensions/QT/SimpleMPRWidget.ui b/lib/cpExtensions/QT/SimpleMPRWidget.ui index fec8855..3f0750e 100644 --- a/lib/cpExtensions/QT/SimpleMPRWidget.ui +++ b/lib/cpExtensions/QT/SimpleMPRWidget.ui @@ -6,8 +6,8 @@ 0 0 - 94 - 40 + 495 + 394 @@ -41,42 +41,6 @@ - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 20 - 20 - - - - - 20 - 20 - - - - ... - - - - - diff --git a/lib/cpExtensions/QT/WindowLevelImageConfiguration.cxx b/lib/cpExtensions/QT/WindowLevelImageConfiguration.cxx index c865f55..2c53bfe 100644 --- a/lib/cpExtensions/QT/WindowLevelImageConfiguration.cxx +++ b/lib/cpExtensions/QT/WindowLevelImageConfiguration.cxx @@ -9,7 +9,9 @@ cpExtensions::QT::WindowLevelImageConfiguration:: WindowLevelImageConfiguration( QWidget* parent, Qt::WindowFlags f ) : Superclass( parent, f ), - m_UI( new Ui::WindowLevelImageConfiguration ) + m_UI( new Ui::WindowLevelImageConfiguration ), + m_Data( NULL ), + m_Name( "" ) { this->m_UI->setupUi( this ); } @@ -23,16 +25,17 @@ cpExtensions::QT::WindowLevelImageConfiguration:: // ------------------------------------------------------------------------- void cpExtensions::QT::WindowLevelImageConfiguration:: -setData( SimpleMPRWidget* data ) +setData( ActorsWidgetInterface* data, const std::string& name ) { if( this->m_Data != data ) { this->m_Data = data; + this->m_Name = name; // Get data double range[ 2 ], win_lev[ 2 ]; - this->m_Data->GetScalarRange( range ); - this->m_Data->GetWindowLevel( win_lev ); + this->m_Data->GetScalarRange( this->m_Name, range ); + this->m_Data->GetWindowLevel( this->m_Name, win_lev ); // Intensity range this->m_UI->MinimumBox->setMinimum( -1000000 ); @@ -66,7 +69,7 @@ setData( SimpleMPRWidget* data ) this->m_UI->LevelSlider->setValue( l ); // Opacity - double o = this->m_Data->GetImageOpacity( ); + double o = this->m_Data->GetOpacity( this->m_Name ); o *= double( this->m_UI->OpacitySlider->maximum( ) ) - double( this->m_UI->OpacitySlider->minimum( ) ); @@ -74,7 +77,7 @@ setData( SimpleMPRWidget* data ) this->m_UI->OpacitySlider->setValue( o ); // Interpolation mode - switch( this->m_Data->GetImageInterpolation( ) ) + switch( this->m_Data->GetImageInterpolation( this->m_Name ) ) { case 'L': this->m_UI->InterpolatorBox->setCurrentIndex( 1 ); break; case 'C': this->m_UI->InterpolatorBox->setCurrentIndex( 2 ); break; @@ -125,7 +128,7 @@ _maximumValue( int v ) double range[ 2 ]; range[ 0 ] = double( this->m_UI->MinimumBox->value( ) ); range[ 1 ] = double( v ); - this->m_Data->SetScalarRange( range ); + this->m_Data->SetScalarRange( this->m_Name, range ); } // ------------------------------------------------------------------------- @@ -135,7 +138,7 @@ _minimumValue( int v ) double range[ 2 ]; range[ 0 ] = double( v ); range[ 1 ] = double( this->m_UI->MaximumBox->value( ) ); - this->m_Data->SetScalarRange( range ); + this->m_Data->SetScalarRange( this->m_Name, range ); } // ------------------------------------------------------------------------- @@ -145,7 +148,7 @@ _levelValue( int v ) double r[ 2 ]; double l, s; - this->m_Data->GetScalarRange( r ); + this->m_Data->GetScalarRange( this->m_Name, r ); if( this->sender( ) == this->m_UI->LevelSlider ) { s = double( v ) / double( this->m_UI->LevelSlider->maximum( ) ); @@ -166,10 +169,7 @@ _levelValue( int v ) this->m_UI->LevelBox->setValue( l ); this->m_UI->LevelBox->blockSignals( b ); - double wl[ 2 ]; - this->m_Data->GetWindowLevel( wl ); - wl[ 1 ] = l; - this->m_Data->SetWindowLevel( wl ); + this->m_Data->SetLevel( this->m_Name, l ); } // ------------------------------------------------------------------------- @@ -179,7 +179,7 @@ _windowValue( int v ) double r[ 2 ]; double w, s; - this->m_Data->GetScalarRange( r ); + this->m_Data->GetScalarRange( this->m_Name, r ); if( this->sender( ) == this->m_UI->WindowSlider ) { s = double( v ) / double( this->m_UI->WindowSlider->maximum( ) ); @@ -200,10 +200,7 @@ _windowValue( int v ) this->m_UI->WindowBox->setValue( w ); this->m_UI->WindowBox->blockSignals( b ); - double wl[ 2 ]; - this->m_Data->GetWindowLevel( wl ); - wl[ 0 ] = w; - this->m_Data->SetWindowLevel( wl ); + this->m_Data->SetWindow( this->m_Name, w ); } // ------------------------------------------------------------------------- @@ -217,7 +214,7 @@ _opacityValue( int v ) o /= double( this->m_UI->OpacitySlider->maximum( ) ) - double( this->m_UI->OpacitySlider->minimum( ) ); - this->m_Data->SetImageOpacity( o ); + this->m_Data->SetOpacity( this->m_Name, o ); } // fi } @@ -228,9 +225,9 @@ _interpolatorValue( int v ) { switch( v ) { - case 1 : this->m_Data->SetImageInterpolation( 'L' ); break; - case 2 : this->m_Data->SetImageInterpolation( 'C' ); break; - default : this->m_Data->SetImageInterpolation( 'N' ); break; + case 1 : this->m_Data->SetImageInterpolation( this->m_Name, 'L' ); break; + case 2 : this->m_Data->SetImageInterpolation( this->m_Name, 'C' ); break; + default : this->m_Data->SetImageInterpolation( this->m_Name, 'N' ); break; } // hctiws } diff --git a/lib/cpExtensions/QT/WindowLevelImageConfiguration.h b/lib/cpExtensions/QT/WindowLevelImageConfiguration.h index 665e741..c3984ca 100644 --- a/lib/cpExtensions/QT/WindowLevelImageConfiguration.h +++ b/lib/cpExtensions/QT/WindowLevelImageConfiguration.h @@ -15,7 +15,7 @@ namespace cpExtensions { namespace QT { - class SimpleMPRWidget; + class ActorsWidgetInterface; /** */ @@ -34,7 +34,7 @@ namespace cpExtensions ); virtual ~WindowLevelImageConfiguration( ); - void setData( SimpleMPRWidget* data ); + void setData( ActorsWidgetInterface* data, const std::string& name ); protected slots: void _maximumValue( int v ); @@ -46,7 +46,8 @@ namespace cpExtensions protected: Ui::WindowLevelImageConfiguration* m_UI; - SimpleMPRWidget* m_Data; + ActorsWidgetInterface* m_Data; + std::string m_Name; }; } // ecapseman