void ImageMPR::
_aOpenImage( )
{
- // Clear all, since we are loading the main image
- if( this->m_Objects.size( ) > 0 )
- {
- this->m_UI->MPR->ClearAll( );
- this->m_Objects.clear( );
-
- } // fi
-
// Read and show image, if possible
TPlugins::TImage::Pointer image;
if( this->m_Plugins->ReadImage( image, true ) )
{
vtkImageData* vimage = image->GetVTK< vtkImageData >( );
if( vimage == NULL )
+ {
QMessageBox::critical(
this,
QMessageBox::tr( "Error showing image." ),
"Image was read, but no valid VTK conversion was found."
)
);
+ return;
+ }
else
- this->m_UI->MPR->ShowImage( vimage, image->GetName( ) );
+ {
+ // Since we are opening an image, clear all
+ this->m_UI->MPR->DeleteAllData( );
+ this->m_Objects.clear( );
- // Keep a track on a local data tree
- this->m_Objects[ image->GetName( ) ] =
- TTreeNode( "", image.GetPointer( ) );
+ // Update references
+ std::string name = image->GetName( );
+ this->m_Objects[ name ] = TTreeNode( "", image.GetPointer( ) );
+ this->m_UI->MPR->AddImage( vimage, name );
+ this->m_UI->MPR->ShowData( name );
+
+ } // fi
} // fi
}
void ImageMPR::
_aOpenDICOMSeries( )
{
- // Clear all, since we are loading the main image
- if( this->m_Objects.size( ) > 0 )
- {
- this->m_UI->MPR->ClearAll( );
- this->m_Objects.clear( );
-
- } // fi
-
// Read and show image, if possible
TPlugins::TImage::Pointer image;
if( this->m_Plugins->ReadDicomSeries( image ) )
{
vtkImageData* vimage = image->GetVTK< vtkImageData >( );
if( vimage == NULL )
+ {
QMessageBox::critical(
this,
QMessageBox::tr( "Error showing image." ),
"Image was read, but no valid VTK conversion was found."
)
);
+ return;
+ }
else
- this->m_UI->MPR->ShowImage( vimage, image->GetName( ) );
+ {
+ // Since we are opening an image, clear all
+ this->m_UI->MPR->DeleteAllData( );
+ this->m_Objects.clear( );
- // Keep a track on a local data tree
- this->m_Objects[ image->GetName( ) ] =
- TTreeNode( "", image.GetPointer( ) );
+ // Update references
+ std::string name = image->GetName( );
+ this->m_Objects[ name ] = TTreeNode( "", image.GetPointer( ) );
+ this->m_UI->MPR->AddImage( vimage, name );
+ this->m_UI->MPR->ShowData( name );
+
+ } // fi
} // fi
}
void ImageMPR::
_execPlugin( )
{
- // Get filter name
+ // Get filter's name and category
QAction* action = dynamic_cast< QAction* >( this->sender( ) );
if( action == NULL )
return;
std::string filter_name = action->text( ).toStdString( );
// Create filter
- TPlugins::TProcessObject::Pointer filter;
- if( !( this->m_Plugins->CreateFilter( filter, filter_name ) ) )
+ if( !( this->m_Plugins->CreateFilter( this->m_ActiveFilter, filter_name ) ) )
{
QMessageBox::critical(
this,
std::string( "\"defined." )
).c_str( ) )
);
+ this->m_ActiveFilter = NULL;
return;
} // fi
// Configure filter
- if( !( filter->ExecConfigurationDialog( this ) ) )
+ this->m_ActiveFilter->AddInteractor( this->m_UI->MPR->GetInteractor( 0 ) );
+ this->m_ActiveFilter->AddInteractor( this->m_UI->MPR->GetInteractor( 1 ) );
+ this->m_ActiveFilter->AddInteractor( this->m_UI->MPR->GetInteractor( 2 ) );
+ this->m_ActiveFilter->AddInteractor( this->m_UI->MPR->GetInteractor( 3 ) );
+
+ TPlugins::TProcessObject::DialogResult res =
+ this->m_ActiveFilter->ExecConfigurationDialog( this );
+ if( res == TPlugins::TProcessObject::DialogResult_Cancel )
+ {
+ this->m_ActiveFilter = NULL;
return;
+ } // fi
+
// Assign inputs
std::string data_name = this->m_UI->MPR->GetSelectedData( );
- std::vector< std::string > inputs_names = filter->GetInputsNames( );
+ std::vector< std::string > inputs_names =
+ this->m_ActiveFilter->GetInputsNames( );
if( inputs_names.size( ) == 1 )
{
TTree::iterator iIt = this->m_Objects.find( data_name );
tr( "Error configuring filter" ),
tr( "No valid input found. Please select a valid input." )
);
+ this->m_ActiveFilter = NULL;
return;
} //fi
- filter->SetInput( inputs_names[ 0 ], iIt->second.second );
+ this->m_ActiveFilter->SetInput( inputs_names[ 0 ], iIt->second.second );
}
else if( inputs_names.size( ) > 1 )
{
} // fi
// 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( ) )
- );
- return;
-
- } // fi
+ /*
+ if( res == TPlugins::TProcessObject::DialogResult_NoModal )
+ {
+ this->_Block( );
+ std::string filter_err = this->m_ActiveFilter->Update( );
+ this->_Unblock( );
+ if( filter_err != "" )
+ {
+ QMessageBox::critical(
+ this,
+ tr( "Error executing" ),
+ tr( filter_err.c_str( ) )
+ );
+ this->m_ActiveFilter = NULL;
+ return;
- // 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;
+ } // fi
- TPlugins::TImage* image = filter->GetOutput< TPlugins::TImage >( *oIt );
- if( image != NULL )
+ // Get outputs
+ std::vector< std::string > outputs_names = filter->GetOutputsNames( );
+ for(
+ auto oIt = outputs_names.begin( );
+ oIt != outputs_names.end( );
+ ++oIt
+ )
{
- if( filter_cate == "ImageToBinaryImageFilter" )
- {
- this->m_UI->MPR->ShowImage(
- image->GetVTK< vtkImageData >( ),
- out_name,
- data_name, 1, 0, 0
- );
- }
- else if( filter_cate == "ImageToImageFilter" )
+ std::string out_name = filter_name + "_" + *oIt;
+
+ TPlugins::TImage* image =
+ this->m_ActiveFilter->GetOutput< TPlugins::TImage >( *oIt );
+ if( image != NULL )
{
+ 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
- // Keep a track on a local data tree and go to next output
- this->m_Objects[ out_name ] = TTreeNode( data_name, image );
- continue;
+ TPlugins::TMesh* mesh = filter->GetOutput< TPlugins::TMesh >( *oIt );
+ if( mesh != NULL )
+ {
+ // Show mesh
+ this->_Block( );
+ this->m_UI->MPR->ShowMesh(
+ mesh->GetVTK< vtkPolyData >( ),
+ out_name,
+ data_name
+ );
+ this->_Unblock( );
- } // fi
+ // Keep a track on a local data tree and go to next output
+ this->m_Objects[ out_name ] = TTreeNode( data_name, mesh );
+ continue;
- TPlugins::TMesh* mesh = filter->GetOutput< TPlugins::TMesh >( *oIt );
- if( mesh != NULL )
- {
- // Show mesh
- this->_Block( );
- this->m_UI->MPR->ShowMesh(
- mesh->GetVTK< vtkPolyData >( ),
- out_name,
- data_name
- );
- this->_Unblock( );
+ } // fi
- // Keep a track on a local data tree and go to next output
- this->m_Objects[ out_name ] = TTreeNode( data_name, mesh );
- continue;
+ } // rof
- } // fi
+ // No-modal filters just exists for one usage
+ this->m_ActiveFilter = NULL;
- } // rof
+ } // fi
+ */
}
// -------------------------------------------------------------------------