X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FQT%2FSimpleMPRWidget.h;h=bc07ed35eb766466bcec6e043967973226d0dd14;hb=61b3659afe961ed248f30e26f9ca8f28fcfafddc;hp=d5f33539fe0fb5cd29a0437fa32f65d55f3cc8ca;hpb=ebbbc4c90ed0e4814d360686e8d4b6aab509914c;p=cpPlugins.git diff --git a/lib/cpExtensions/QT/SimpleMPRWidget.h b/lib/cpExtensions/QT/SimpleMPRWidget.h index d5f3353..bc07ed3 100644 --- a/lib/cpExtensions/QT/SimpleMPRWidget.h +++ b/lib/cpExtensions/QT/SimpleMPRWidget.h @@ -1,109 +1,114 @@ -#ifndef __CPEXTENSIONS__QT__SIMPLEMPRWIDGET__H__ -#define __CPEXTENSIONS__QT__SIMPLEMPRWIDGET__H__ +#ifndef __cpExtensions__QT__SimpleMPRWidget__h__ +#define __cpExtensions__QT__SimpleMPRWidget__h__ #include - -#ifdef cpExtensions_QT4 - -#include +#include #include -#include -#include -#include -#include #include -#include - -#define cpExtensions_MAX_POLYS 65535 +#include +#include // ------------------------------------------------------------------------- -class QVTKWidget; +class vtkDataSet; +class vtkProp; +class vtkPropCollection; -namespace Ui -{ - class SimpleMPRWidget; -} +namespace Ui { class SimpleMPRWidget; } // ------------------------------------------------------------------------- namespace cpExtensions { namespace QT { + class MPR3DWidget; + class ImageWidget; + /** */ class cpExtensions_EXPORT SimpleMPRWidget - : public QWidget + : public QWidget, + public ActorsWidgetInterface { Q_OBJECT; public: - typedef SimpleMPRWidget Self; - - typedef cpExtensions::Visualization::ImageSliceActors TActors; - - /** - */ - struct PolyDataActor - { - vtkSmartPointer< vtkPolyData > Data; - vtkSmartPointer< vtkPolyDataNormals > Normals; - vtkSmartPointer< vtkStripper > Stripper; - vtkSmartPointer< vtkPolyDataMapper > Mapper; - vtkSmartPointer< vtkActor > Actor; - - void Configure( vtkPolyData* data ) - { - this->Data = data; - double r[ 2 ]; - this->Data->GetScalarRange( r ); - - this->Normals = vtkSmartPointer< vtkPolyDataNormals >::New( ); - this->Stripper = vtkSmartPointer< vtkStripper >::New( ); - this->Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( ); - this->Normals->SetInputData( this->Data ); - this->Normals->SetFeatureAngle( 60.0 ); - this->Stripper->SetInputConnection( - this->Normals->GetOutputPort( ) - ); - this->Mapper->SetInputConnection( - this->Stripper->GetOutputPort( ) - ); - this->Mapper->UseLookupTableScalarRangeOff( ); - this->Mapper->SetScalarRange( r[ 0 ], r[ 1 ] ); - - unsigned long nPolys = this->Data->GetNumberOfPolys( ); - if( nPolys < cpExtensions_MAX_POLYS ) - { - this->Actor = vtkSmartPointer< vtkActor >::New( ); - this->Actor->SetMapper( this->Mapper ); - } - else - { - vtkSmartPointer< vtkQuadricLODActor > actor = - vtkSmartPointer< vtkQuadricLODActor >::New( ); - actor->SetMapper( this->Mapper ); - actor->DeferLODConstructionOff( ); - this->Actor = actor.GetPointer( ); - - } // fi - } - }; + typedef SimpleMPRWidget Self; + typedef QWidget Superclass; + typedef ActorsWidgetInterface Superclass2; + + typedef vtkSmartPointer< vtkPropCollection > TProp; + typedef std::set< TProp > TProps; + + // typedef cpExtensions::Visualization::MeshActor TMeshActor; public: - explicit SimpleMPRWidget( QWidget* parent = 0 ); + explicit SimpleMPRWidget( QWidget* parent = NULL, Qt::WindowFlags f = 0 ); virtual ~SimpleMPRWidget( ); - // Data management - void Clear( ); - void SetMainImage( vtkImageData* image ); - void AddMesh( vtkPolyData* mesh ); - - // Visual objects - vtkRenderWindowInteractor* GetInteractor( unsigned int i ); - vtkRenderer* GetRenderer( unsigned int i ); - std::vector< std::pair< vtkImageActor*, vtkRenderer* > > - GetMainImageActors( ); - vtkActor* GetActor( vtkPolyData* mesh ); + void Configure( char q1, char q2, char q3, char q4 ); + + bool HasImage( ) const; + void SetImage( vtkImageData* image, const std::string& name ); + + bool Add( vtkDataSet* data, const std::string& name ); + + TProps GetViewProps( const std::string& name ) const; + TProps GetImageProps( ) const; + + vtkRenderWindowInteractor* GetXInteractor( ); + const vtkRenderWindowInteractor* GetXInteractor( ) const; + vtkRenderWindowInteractor* GetYInteractor( ); + const vtkRenderWindowInteractor* GetYInteractor( ) const; + vtkRenderWindowInteractor* GetZInteractor( ); + const vtkRenderWindowInteractor* GetZInteractor( ) const; + vtkRenderWindowInteractor* GetWInteractor( ); + const vtkRenderWindowInteractor* GetWInteractor( ) const; + + vtkRenderWindow* GetXRenderWindow( ); + const vtkRenderWindow* GetXRenderWindow( ) const; + vtkRenderWindow* GetYRenderWindow( ); + const vtkRenderWindow* GetYRenderWindow( ) const; + vtkRenderWindow* GetZRenderWindow( ); + const vtkRenderWindow* GetZRenderWindow( ) const; + vtkRenderWindow* GetWRenderWindow( ); + const vtkRenderWindow* GetWRenderWindow( ) const; + + void ResetCameras( ); + void Render( ); + + virtual std::set< vtkRenderWindowInteractor* > GetInteractors( ) const cpExtensions_OVERRIDE; + 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 ); @@ -111,21 +116,20 @@ namespace cpExtensions protected: Ui::SimpleMPRWidget* m_UI; - QVTKWidget* m_VTK[ 4 ]; - vtkSmartPointer< vtkRenderer > m_Renderers[ 4 ]; - vtkSmartPointer< TActors > m_2DSlices[ 3 ]; - vtkSmartPointer< TActors > m_3DSlices[ 3 ]; + ImageWidget* m_XImage; + ImageWidget* m_YImage; + ImageWidget* m_ZImage; + MPR3DWidget* m_3DView; - std::map< vtkPolyData*, PolyDataActor > m_PolyDatas; + std::string m_MainImageName; + vtkSmartPointer< vtkImageData > m_MainImage; }; } // ecapseman } // ecapseman -#endif // cpExtensions_QT4 - -#endif // __CPEXTENSIONS__QT__SIMPLEMPRWIDGET__H__ +#endif // __cpExtensions__QT__SimpleMPRWidget__h__ // eof - $RCSfile$