From: Leonardo Florez-Valencia Date: Wed, 28 Oct 2015 03:24:43 +0000 (-0500) Subject: More tree visualization X-Git-Tag: v0.1~316 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=3633aade338a13bc83642e99e6d61b6499e4b3af;p=cpPlugins.git More tree visualization --- diff --git a/appli/ImageMPR/ImageMPR.cxx b/appli/ImageMPR/ImageMPR.cxx index 47c3622..69970b7 100644 --- a/appli/ImageMPR/ImageMPR.cxx +++ b/appli/ImageMPR/ImageMPR.cxx @@ -138,10 +138,13 @@ _aOpenPolyData( ) void ImageMPR:: _aSaveImage( ) { - /* - if( this->m_MainImage.IsNotNull( ) ) - this->m_Plugins->WriteImage( this->m_MainImage, true ); - */ + std::string data_name = this->m_UI->MPR->GetSelectedData( ); + TPlugins::TImage* image = dynamic_cast< TPlugins::TImage* >( + this->m_Objects[ data_name ].second.GetPointer( ) + ); + if( image == NULL ) + return; + this->m_Plugins->WriteImage( image, true ); } // ------------------------------------------------------------------------- @@ -154,6 +157,13 @@ _aSaveSegmentation( ) void ImageMPR:: _aSavePolyData( ) { + std::string data_name = this->m_UI->MPR->GetSelectedData( ); + TPlugins::TMesh* mesh = dynamic_cast< TPlugins::TMesh* >( + this->m_Objects[ data_name ].second.GetPointer( ) + ); + if( mesh == NULL ) + return; + this->m_Plugins->WriteMesh( mesh, true ); } // ------------------------------------------------------------------------- @@ -188,13 +198,6 @@ _aShowPlugins( ) void ImageMPR:: _execPlugin( ) { - /* - typedef std::map< std::string, TPlugins::TImage::Pointer > _TImages; - typedef std::map< std::string, TPlugins::TMesh::Pointer > _TMeshes; - - // Get selected data - // std::string data_name = this->m_UI->MPR->GetSelectedData( ); - // Get filter name QAction* action = dynamic_cast< QAction* >( this->sender( ) ); if( action == NULL ) @@ -222,159 +225,104 @@ _execPlugin( ) } // fi + // Configure filter + if( !( filter->ExecConfigurationDialog( this ) ) ) + return; + // Assign inputs + std::string data_name = this->m_UI->MPR->GetSelectedData( ); std::vector< std::string > inputs_names = filter->GetInputsNames( ); if( inputs_names.size( ) == 1 ) { - std::string data_name = this->m_UI->MPR->GetSelectedData( ); - _TImages::iterator iIt = this->m_Images.find( data_name ); - _TImages::iterator mIt = this->m_Meshes.find( data_name ); - filter->SetInput( inputs_names[ 0 ]); - } - else if( inputs_names.size( ) > 1 ) - { - } // fi - - // Get outputs - std::vector< std::string > outputs_names = filter->GetOutputsNames( ); - */ - - /* - - // Choose inputs - if( filter_cate == "ImageToMeshFilter" ) - { - // Check inputs - _TImages::iterator iIt = this->m_Images.find( data_name ); - if( iIt == this->m_Images.end( ) ) + TTree::iterator iIt = this->m_Objects.find( data_name ); + if( iIt == this->m_Objects.end( ) ) { QMessageBox::critical( this, - tr( "Error creating filter" ), - tr( "No valid input selected." ) + tr( "Error configuring filter" ), + tr( "No valid input found. Please select a valid input." ) ); return; - } // fi - - // Execute configuration dialog - if( !( filter->ExecConfigurationDialog( this ) ) ) - return; - - // Execute filter - filter->SetInput( "Input", iIt->second ); - this->_Block( ); - std::string filter_err = filter->Update( ); - this->_Unblock( ); - if( filter_err != "" ) - { - QMessageBox::critical( - this, - tr( "Error executing" ), - tr( filter_err.c_str( ) ) - ); - return; + } //fi + filter->SetInput( inputs_names[ 0 ], iIt->second.second ); + } + else if( inputs_names.size( ) > 1 ) + { + QMessageBox::critical( + this, + tr( "Error executing" ), + tr( "Filter has multiple inputs: NOT YET IMPLEMENTED!!!" ) + ); + return; - } // fi + } // fi - // Keep and show results - TPlugins::TMesh::Pointer mesh = - filter->GetOutput< TPlugins::TMesh >( "Output" ); - this->m_Meshes[ filter_name ] = mesh; - this->_Block( ); - this->m_UI->MPR->ShowMesh( - mesh->GetVTK< vtkPolyData >( ), - filter_name, - data_name + // Execute filter + this->_Block( ); + std::string filter_err = filter->Update( ); + this->_Unblock( ); + if( filter_err != "" ) + { + QMessageBox::critical( + this, + tr( "Error executing" ), + tr( filter_err.c_str( ) ) ); - this->_Unblock( ); + return; } // fi - */ - /* - if( this->m_Plugins->CreateFilter( filter, name ) ) - { - if( filter->ExecConfigurationDialog( this ) ) + // Get outputs + std::vector< std::string > outputs_names = filter->GetOutputsNames( ); + for( + auto oIt = outputs_names.begin( ); + oIt != outputs_names.end( ); + ++oIt + ) + { + std::string out_name = filter_name + "_" + *oIt; + + TPlugins::TImage* image = filter->GetOutput< TPlugins::TImage >( *oIt ); + if( image != NULL ) { - filter->SetInput( "Input", this->m_MainImage ); - this->_Block( ); - err = filter->Update( ); - this->_Unblock( ); - TPlugins::TMesh::Pointer mesh = - filter->GetOutput< TPlugins::TMesh >( "Output" ); - this->m_Meshes.push_back( mesh ); - mesh->CreateVTKActor( ); - vtkActor* actor = mesh->GetVTKActor( ); - if( actor != NULL ) - this->m_UI->MPR->Add3DActor( actor ); + if( filter_cate == "ImageToBinaryImageFilter" ) + { + this->m_UI->MPR->ShowImage( + image->GetVTK< vtkImageData >( ), + out_name, + data_name, 1, 0, 0 + ); + } + else if( filter_cate == "ImageToImageFilter" ) + { + } // fi + + // Keep a track on a local data tree and go to next output + this->m_Objects[ out_name ] = TTreeNode( data_name, image ); + continue; } // fi - - } // fi - } - else - QMessageBox::critical( - this, - tr( "Error creating filter" ), - tr( "No valid filter defined." ) - ); - */ - /* - if( name == "cpPlugins::BasicFilters::FloodFillImageFilter" ) - { - this->m_Flooding = true; - } - else + + TPlugins::TMesh* mesh = filter->GetOutput< TPlugins::TMesh >( *oIt ); + if( mesh != NULL ) { - this->m_Flooding = false; - this->m_UI->MPR->ExecuteFilter( - name, this->m_ImageLoaded, "SegmentedImage" - ); - - } // fi - */ - - // Configure filter - /* - TPluginFilter::Pointer filter = - this->m_Plugins.CreateProcessObject( name ); - bool dlg_ok = filter->ExecConfigurationDialog( NULL ); - if( !dlg_ok ) - return; + // Show mesh + this->_Block( ); + this->m_UI->MPR->ShowMesh( + mesh->GetVTK< vtkPolyData >( ), + out_name, + data_name + ); + this->_Unblock( ); - // Execute filter - QApplication::setOverrideCursor( Qt::WaitCursor ); - this->setEnabled( false ); - filter->SetInput( 0, this->m_Image ); - std::string err = filter->Update( ); - QApplication::restoreOverrideCursor( ); - this->setEnabled( true ); + // Keep a track on a local data tree and go to next output + this->m_Objects[ out_name ] = TTreeNode( data_name, mesh ); + continue; - // Update image - if( err == "" ) - { - TPluginImage* result = filter->GetOutput< TPluginImage >( 0 ); - result->DisconnectPipeline( ); - this->m_Image = result; - if( this->m_Image.IsNotNull( ) ) - this->m_MPRObjects->SetImage( - this->m_Image->GetVTK< vtkImageData >( ) - ); - MementoState(this->m_state, this->m_Image); - this->m_state++; - if (this->m_state > this->m_max_state) - { - this->m_max_state = this->m_state; - } - } - else - QMessageBox::critical( - this, - tr( "Error executing filter" ), - tr( err.c_str( ) ) - ); - */ + } // fi + + } // rof } // ------------------------------------------------------------------------- diff --git a/lib/cpExtensions/Visualization/ImageSliceActors.cxx b/lib/cpExtensions/Visualization/ImageSliceActors.cxx index e3a2ff0..450bdb6 100644 --- a/lib/cpExtensions/Visualization/ImageSliceActors.cxx +++ b/lib/cpExtensions/Visualization/ImageSliceActors.cxx @@ -307,8 +307,8 @@ PushActorsInto( vtkRenderWindow* window, bool force_style ) } else if( axis == 1 ) { - camera->SetPosition( double( 0 ), double( 1 ), double( 0 ) ); - camera->SetViewUp ( double( 0 ), double( 0 ), double( 1 ) ); + camera->SetPosition( double( 0 ), double( -1 ), double( 0 ) ); + camera->SetViewUp ( double( 0 ), double( 0 ), double( 1 ) ); } else // if( axis == 2 ) { diff --git a/lib/cpPlugins/Interface/BaseMPRWidget.cxx b/lib/cpPlugins/Interface/BaseMPRWidget.cxx index fece6b8..88e3b89 100644 --- a/lib/cpPlugins/Interface/BaseMPRWidget.cxx +++ b/lib/cpPlugins/Interface/BaseMPRWidget.cxx @@ -84,6 +84,13 @@ ShowImage( const double& r, const double& g, const double& b ) { + std::cout + << "BaseMPRWidget: " + << image << " " + << name << " " + << parent << " " + << r << " " << g << " " << b << std::endl; + return( false ); } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Interface/ParametersQtDialog.cxx b/lib/cpPlugins/Interface/ParametersQtDialog.cxx index 8a012b6..0891a2b 100644 --- a/lib/cpPlugins/Interface/ParametersQtDialog.cxx +++ b/lib/cpPlugins/Interface/ParametersQtDialog.cxx @@ -203,7 +203,8 @@ exec( ) this->m_ToolsLayout->addWidget( bb ); int ret = this->QDialog::exec( ); - this->syncParameters( ); + if( ret == 1 ) + this->syncParameters( ); return( ret ); } diff --git a/lib/cpPlugins/Interface/Plugins.cxx b/lib/cpPlugins/Interface/Plugins.cxx index b9dab29..45f5559 100644 --- a/lib/cpPlugins/Interface/Plugins.cxx +++ b/lib/cpPlugins/Interface/Plugins.cxx @@ -455,10 +455,10 @@ WriteMesh( TMesh* mesh, bool exec_qt ) { bool execute = true; if( exec_qt ) - execute = this->m_MeshReader->ExecConfigurationDialog( this->m_Widget ); + execute = this->m_MeshWriter->ExecConfigurationDialog( this->m_Widget ); if( execute ) { - this->m_MeshWriter->SetInput( 0, mesh ); + this->m_MeshWriter->SetInput( "Input", mesh ); this->BlockWidget( ); ret = this->m_MeshWriter->Update( ); this->UnblockWidget( ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx index 6bc538e..8e2f6fb 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx @@ -27,7 +27,7 @@ std::string cpPlugins::BasicFilters::OtsuThresholdImageFilter:: _GenerateData( ) { cpPlugins::Interface::Image* image = - this->GetInput< cpPlugins::Interface::Image >( 0 ); + this->GetInput< cpPlugins::Interface::Image >( "Input" ); if( image == NULL ) return( "OtsuThresholdImageFilter: No input image." ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.h b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.h index 5f216dd..671acb5 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.h +++ b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.h @@ -27,7 +27,7 @@ namespace cpPlugins ); cpPlugins_Id_Macro( cpPlugins::BasicFilters::OtsuThresholdImageFilter, - "ImageToImageFilter" + "ImageToBinaryImageFilter" ); protected: