X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FQT%2FSimpleMPRWidget.cxx;h=7e338bc0b77c486e8f2c813f3f20383b838e0580;hb=f47059eb39b5c9eef5cd2ee1b6c013cd75eff97f;hp=a020fb9e3d7e0c80207922e3827ae2016e131279;hpb=b9fd406b0196ce00c4152da45572b8be3cb3c805;p=cpPlugins.git diff --git a/lib/cpExtensions/QT/SimpleMPRWidget.cxx b/lib/cpExtensions/QT/SimpleMPRWidget.cxx index a020fb9..7e338bc 100644 --- a/lib/cpExtensions/QT/SimpleMPRWidget.cxx +++ b/lib/cpExtensions/QT/SimpleMPRWidget.cxx @@ -6,6 +6,28 @@ #include #include +// ------------------------------------------------------------------------- +cpExtensions::QT::SimpleMPRWidget::_3DInteractorStyle* +cpExtensions::QT::SimpleMPRWidget::_3DInteractorStyle:: +New( ) +{ + return( new _3DInteractorStyle( ) ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget::_3DInteractorStyle:: +OnKeyPress( ) +{ + vtkRenderWindowInteractor* i = this->Interactor; + std::string key = i->GetKeySym( ); + if( key == "r" || key == "R" ) + { + this->CurrentRenderer->ResetCamera( ); + i->Render( ); + + } // fi +} + // ------------------------------------------------------------------------- cpExtensions::QT::SimpleMPRWidget:: SimpleMPRWidget( QWidget* parent ) @@ -19,7 +41,6 @@ SimpleMPRWidget( QWidget* parent ) this->m_VTK[ 1 ] = this->m_UI->VTK_Y; this->m_VTK[ 2 ] = this->m_UI->VTK_Z; this->m_VTK[ 3 ] = this->m_UI->VTK_3D; - for( unsigned int i = 0; i < 4; ++i ) { this->m_Renderers[ i ] = vtkSmartPointer< vtkRenderer >::New( ); @@ -27,6 +48,11 @@ SimpleMPRWidget( QWidget* parent ) AddRenderer( this->m_Renderers[ i ] ); } // rof + vtkSmartPointer< _3DInteractorStyle > style = + vtkSmartPointer< _3DInteractorStyle >::New( ); + this->m_VTK[ 3 ]->GetRenderWindow( )-> + GetInteractor( )->SetInteractorStyle( style ); + style->SetCurrentRenderer( this->m_Renderers[ 3 ] ); // Connect slots QObject::connect( @@ -214,9 +240,20 @@ AddMeshActor( vtkProp3D* actor, const std::string& name ) { if( actor != NULL ) { + std::cout << name << " " << actor << std::endl; + this->m_Renderers[ 3 ]->AddViewProp( actor ); this->m_VTK[ 3 ]->GetRenderWindow( )->Render( ); this->m_NamedActors[ name ].insert( actor ); + std::cout << "Size: " << this->m_NamedActors.size( ) << " " << this->m_NamedActors[ name ].size( ) << std::endl; + + + double bounds[ 6 ]; + this->m_Renderers[ 3 ]->ComputeVisiblePropBounds( bounds ); + std::cout + << bounds[ 0 ] << " " << bounds[ 1 ] << " " + << bounds[ 2 ] << " " << bounds[ 3 ] << " " + << bounds[ 4 ] << " " << bounds[ 5 ] << std::endl; } // fi } @@ -228,7 +265,7 @@ AddActor( vtkProp* actor, const std::string& name ) auto ia = dynamic_cast< vtkImageActor* >( actor ); if( ia == NULL ) { - auto ma = dynamic_cast< vtkActor* >( actor ); + auto ma = dynamic_cast< vtkProp3D* >( actor ); if( ma != NULL ) this->AddMeshActor( ma, name ); }