X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FInterface%2FParametersQtDialog.cxx;h=90393ffc9150fe4e3daebfc167b8374d123a9fb4;hb=003b7bc4f88cbe4aa6cc27fcd16b8cda94eba9be;hp=12cca5d7b87a6b5ed3818a0085200fc2875aa6de;hpb=c0627ed97baf80b6751379801fc4d5c377b45467;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface/ParametersQtDialog.cxx b/lib/cpPlugins/Interface/ParametersQtDialog.cxx index 12cca5d..90393ff 100644 --- a/lib/cpPlugins/Interface/ParametersQtDialog.cxx +++ b/lib/cpPlugins/Interface/ParametersQtDialog.cxx @@ -17,6 +17,10 @@ #include // ------------------------------------------------------------------------- +#include +#include +#include + class SingleSeedCommand : public vtkCommand { @@ -25,10 +29,60 @@ public: { return( new SingleSeedCommand ); } virtual void Execute( vtkObject* caller, unsigned long eid, void* data ) { - if( eid != vtkCommand::PlacePointEvent ) + // Get seed, avoiding segfaults!!! + if( eid != vtkCommand::PlacePointEvent || this->Dialog == NULL ) + return; + vtkSeedWidget* widget = dynamic_cast< vtkSeedWidget* >( caller ); + if( widget == NULL ) + return; + vtkSeedRepresentation* rep = widget->GetSeedRepresentation( ); + if( rep == NULL ) + return; + if( rep->GetNumberOfSeeds( ) == 0 ) return; -#error ACA VOY + double seed[ 3 ]; + rep->GetSeedWorldPosition( 0, seed ); + + // Delete all seeds (remember that this command is just for one seed) + while( rep->GetNumberOfSeeds( ) > 0 ) + widget->DeleteSeed( 0 ); + + if( this->Dialog->getParameters( )->HasIndex( this->Name ) ) + { + } + else if( this->Dialog->getParameters( )->HasPoint( this->Name ) ) + { + this->Dialog->getParameters( )->SetPoint( this->Name, 3, seed ); + this->Dialog->syncParameters( ); + auto filter = this->Dialog->getParameters( )->GetProcessObject( ); + if( filter != NULL ) + { + auto plugins = filter->GetPlugins( ); + if( plugins != NULL ) + { + auto app = plugins->GetApplication( ); + if( app != NULL ) + app->UpdateActualFilter( ); + + } // fi + + } // fi + + } // fi } +protected: + SingleSeedCommand( ) + : vtkCommand( ), + Dialog( NULL ) + { + } + virtual ~SingleSeedCommand( ) + { + } + +public: + cpPlugins::Interface::ParametersQtDialog* Dialog; + std::string Name; }; // ------------------------------------------------------------------------- @@ -78,6 +132,22 @@ addInteractor( vtkRenderWindowInteractor* interactor ) this->m_Interactors.insert( interactor ); } +// ------------------------------------------------------------------------- +cpPlugins::Interface::ParametersQtDialog:: +TInteractors& cpPlugins::Interface::ParametersQtDialog:: +getInteractors( ) +{ + return( this->m_Interactors ); +} + +// ------------------------------------------------------------------------- +const cpPlugins::Interface::ParametersQtDialog:: +TInteractors& cpPlugins::Interface::ParametersQtDialog:: +getInteractors( ) const +{ + return( this->m_Interactors ); +} + // ------------------------------------------------------------------------- bool cpPlugins::Interface::ParametersQtDialog:: setParameters( Parameters* parameters ) @@ -149,6 +219,8 @@ setParameters( Parameters* parameters ) { vtkSmartPointer< SingleSeedCommand > command = vtkSmartPointer< SingleSeedCommand >::New( ); + command->Dialog = this; + command->Name = *nIt; auto iIt = this->m_Interactors.begin( ); for( ; iIt != this->m_Interactors.end( ); ++iIt )