void ImageMPR::
UpdateActualFilter( )
{
- /* TODO
- if( !( this->m_Plugins->HasActiveFilter( ) ) )
- return;
+ if( !( this->m_Plugins.HasActiveFilter( ) ) )
+ return;
+
+ // Update filter
+ TPlugins::TStringContainer outputs;
+ if(
+ !(
+ this->m_Plugins.UpdateActiveFilter(
+ outputs, this->m_ActiveFilterMainInput
+ )
+ )
+ )
+ return;
+
+ // Show outputs
+ for( auto oIt = outputs.begin( ); oIt != outputs.end( ); ++oIt )
+ std::cout << *oIt << std::endl;
+ /* TODO
std::vector< std::string > outputs;
std::string err = this->m_Plugins->UpdateActiveFilter( outputs );
if( err == "" )
return;
// Get IO names
- TPlugins::TStringContainer inputs, outputs;
+ TPlugins::TStringContainer inputs;
this->m_Plugins.GetActiveFilterInputsNames( inputs );
- this->m_Plugins.GetActiveFilterOutputsNames( outputs );
// Configure inputs
if( inputs.size( ) > 1 )
// TODO
}
else if( inputs.size( ) == 1 )
+ {
+ this->m_ActiveFilterMainInput = this->m_UI->MPR->GetSelectedData( );
this->m_Plugins.ConnectInputInActiveFilter(
- this->m_UI->MPR->GetSelectedData( ), *( inputs.begin( ) )
+ this->m_ActiveFilterMainInput, *( inputs.begin( ) )
);
- // Configure outputs
- for( auto oIt = outputs.begin( ); oIt != outputs.end( ); ++oIt )
- this->m_Plugins.SetOutputNameInActiveFilter(
- filter_name + "_" + *oIt, *oIt
- );
+ } // fi
// Configure paramereters
auto dlg_res = this->m_Plugins.ConfigureActiveFilter( );
if( dlg_res == TPlugins::TProcessObject::DialogResult_Cancel )
{
+ // Just deactivate filter, since it was canceled
this->m_Plugins.DeactivateFilter( );
- // TODO
- }
-
-
- /*
- QMenu* menu = dynamic_cast< QMenu* >( action->parentWidget( ) );
- if( menu == NULL )
return;
- std::string filter_cate = menu->title( ).toStdString( );
-
- // Activate filter
- if( !( this->m_Plugins->ActivateFilter( filter_name ) ) )
- return;
-
- // Associate inputs
- std::vector< std::string > inputs =
- this->m_Plugins->GetActiveFilterInputsNames( );
- if( inputs.size( ) == 1 )
- {
- std::string data_name = this->m_UI->MPR->GetSelectedData( );
- this->m_Plugins->ConnectInputInActiveFilter( data_name, inputs[ 0 ] );
- }
- else if( inputs.size( ) > 1 )
- {
- QMessageBox::critical(
- this,
- tr( "Error executing" ),
- tr( "Filter has multiple inputs: NOT YET IMPLEMENTED!!!" )
- );
- return;
-
- } // fi
-
- // Associate outputs
- std::vector< std::string > outputs =
- this->m_Plugins->GetActiveFilterOutputsNames( );
- for( auto oIt = outputs.begin( ); oIt != outputs.end( ); ++oIt )
- this->m_Plugins->SetOutputNameInActiveFilter(
- filter_name + "_" + *oIt, *oIt
- );
-
- // Configure filter
- TPlugins::TProcessObject::DialogResult dlg_res =
- this->m_Plugins->ConfigureActiveFilter( );
- if( dlg_res == TPlugins::TProcessObject::DialogResult_Cancel )
- {
- this->m_Plugins->DeactivateFilter( );
- return;
-
- } // fi
-
- // Execute filter and associate outputs
- if( dlg_res == TPlugins::TProcessObject::DialogResult_NoModal )
- {
+ }
+ else if( dlg_res == TPlugins::TProcessObject::DialogResult_NoModal )
+ {
+ // Execute automatic filter and associate outputs
this->UpdateActualFilter( );
- this->m_Plugins->DeactivateFilter( );
+ this->m_Plugins.DeactivateFilter( );
- } // fi
- */
+ } // fi
}
// -------------------------------------------------------------------------
private:
Ui::ImageMPR* m_UI;
TPlugins m_Plugins;
+ std::string m_ActiveFilterMainInput;
// Objects
/*
SET(
EXAMPLES_PROGRAMS_WITH_PLUGINS
example_ReadWriteImage
+ example_MarchingCubes
#example_MPR
example_View2DImage
example_HandleWidget
example_SeedWidget
example_SphereWidget
example_Test_Memento
- ##example_MarchingCubes
##example_OtsuFilter
##example_RGBImageToHSVChannels
##example_RGBImageToYPbPrChannels
#include <iostream>
#include <string>
-#include <cpPlugins/Interface/Interface.h>
-#include <cpPlugins/Interface/ProcessObject.h>
+#include <cpPlugins/Interface/Plugins.h>
+// -------------------------------------------------------------------------
+typedef cpPlugins::Interface::Plugins TPlugins;
+
+// -------------------------------------------------------------------------
int main( int argc, char* argv[] )
{
- if( argc < 5 )
+ if( argc < 4 )
{
std::cerr
<< "Usage: " << argv[ 0 ]
<< " plugins_file"
- << " input_image value output_mesh" << std::endl;
+ << " input_image threshold output_image" << std::endl;
return( 1 );
} // fi
- // Create interface
- typedef cpPlugins::Interface::Interface TInterface;
- typedef TInterface::TClasses TClasses;
- TInterface plugins;
- if( !plugins.Load( argv[ 1 ] ) )
+ // Load plugins
+ cpPlugins::Interface::Plugins plugins;
+ if( !plugins.LoadPluginsPath( argv[ 1 ] ) )
{
std::cerr << "Failed to load plugins." << std::endl;
return( 1 );
} // fi
- // Create objects
- typedef cpPlugins::Interface::ProcessObject TProcessObject;
- typedef cpPlugins::Interface::DataObject TDataObject;
- typedef cpPlugins::Interface::Parameters TParameters;
- cpPlugins::Interface::ProcessObject::Pointer reader, writer, mc;
- reader = plugins.CreateProcessObject( "cpPlugins::ImageReader" );
- writer = plugins.CreateProcessObject( "cpPlugins::MeshWriter" );
- mc = plugins.CreateProcessObject( "cpPlugins::MarchingCubes" );
- if( reader.IsNull( ) || writer.IsNull( ) || mc.IsNull( ) )
+ // Associate filenames
+ std::vector< std::string > fnames;
+ for( int i = 2; i < argc - 2; ++i )
+ fnames.push_back( argv[ i ] );
+
+ // Read image
+ std::string filter = "cpPlugins::BasicFilters::MarchingCubes";
+ try
{
- std::cerr << "No suitable objects found in plugins." << std::endl;
- return( 1 );
+ std::string name = plugins.ReadImage( fnames, "" );
- } // fi
+ if( !( plugins.ActivateFilter( filter ) ) )
+ {
+ std::cerr << "Filter \"" << filter << "\" not found." << std::endl;
+ return( 1 );
- // Configure reader
- TParameters reader_params = reader->GetDefaultParameters( );
- for( int i = 2; i < argc - 2; ++i )
- reader_params.AddValueToStringList( "FileNames", argv[ i ] );
- reader->SetParameters( reader_params );
-
- // Configure marching cubes
- TParameters mc_params = mc->GetDefaultParameters( );
- mc_params.AddValueToRealList( "Thresholds", std::atof( argv[ argc - 2 ] ) );
- mc->SetParameters( mc_params );
-
- // Configure writer
- TParameters writer_params = writer->GetDefaultParameters( );
- writer_params.SetValueAsString( "FileName", argv[ argc - 1 ] );
- writer->SetParameters( writer_params );
-
- // Connect pipeline
- mc->SetInput( 0, reader->GetOutput< TDataObject >( 0 ) );
- writer->SetInput( 0, mc->GetOutput< TDataObject >( 0 ) );
-
- // Execute pipeline
- std::string err = writer->Update( );
- if( err != "" )
+ } // fi
+
+ // Connect IO objects
+ TPlugins::TStringContainer inputs, outputs;
+ plugins.GetActiveFilterInputsNames( inputs );
+ plugins.GetActiveFilterOutputsNames( outputs );
+
+ plugins.ConnectInputInActiveFilter( name, *( inputs.begin( ) ) );
+ //plugins.SetOutputNameInActiveFilter( "output_mesh", *( outputs.begin( ) ) );
+
+ // Configure filter
+ TPlugins::TParameters* params = plugins.GetActiveFilterParameters( );
+ params->AddToRealList( "Thresholds", std::atof( argv[ argc - 2 ] ) );
+
+ // Execute filter
+ TPlugins::TStringContainer generated_outputs;
+ if( !( plugins.UpdateActiveFilter( generated_outputs, name ) ) )
+ {
+ std::cerr << "Error using filter \"" << filter << "\"." << std::endl;
+ return( 1 );
+
+ } // fi
+
+ // Save mesh
+ std::string outmesh_name = *( generated_outputs.begin( ) );
+ if( !( plugins.WriteDataObject( argv[ argc - 1 ], outmesh_name ) ) )
+ {
+ std::cerr
+ << "Error writing result into \"" << argv[ argc - 1 ]
+ << "\"" << std::endl;
+ return( 1 );
+
+ } // fi
+ }
+ catch( std::exception& err )
{
- std::cerr << "ERROR: " << err << std::endl;
+ std::cerr << err.what( ) << std::endl;
return( 1 );
- } // fi
+ } // yrt
return( 0 );
}
#include <cstdlib>
#include <iostream>
#include <string>
+#include <vector>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
-#include <cpPlugins/Interface/Interface.h>
-#include <cpPlugins/Interface/ProcessObject.h>
+#include <cpPlugins/Interface/Plugins.h>
#include <cpPlugins/Interface/Image.h>
#include <cpExtensions/Visualization/ImageSliceActors.h>
// -------------------------------------------------------------------------
-typedef cpPlugins::Interface::Interface TInterface;
-typedef cpPlugins::Interface::ProcessObject TProcessObject;
-typedef cpPlugins::Interface::DataObject TDataObject;
-typedef cpPlugins::Interface::Image TImage;
-typedef cpPlugins::Interface::Parameters TParameters;
-typedef TInterface::TClasses TClasses;
-
+typedef cpPlugins::Interface::Plugins TPlugins;
+typedef cpPlugins::Interface::Image TImage;
typedef cpExtensions::Visualization::ImageSliceActors TSliceActors;
// -------------------------------------------------------------------------
{
std::cerr
<< "Usage: " << argv[ 0 ]
- << " plugins_file input_image [widget]"
+ << " plugins_file input_image"
<< std::endl;
return( 1 );
} // fi
- // Create interface
- TInterface plugins;
- if( !plugins.Load( argv[ 1 ] ) )
+ // Load plugins
+ cpPlugins::Interface::Plugins plugins;
+ if( !plugins.LoadPluginsPath( argv[ 1 ] ) )
{
std::cerr << "Failed to load plugins." << std::endl;
return( 1 );
} // fi
- // Create objects
- TProcessObject::Pointer reader;
- reader = plugins.CreateObject( "cpPlugins::IO::ImageReader" );
- if( reader.IsNull( ) )
- {
- std::cerr
- << "No suitable reader found in plugins." << std::endl
- << "Reader: " << reader.GetPointer( ) << std::endl
- << std::endl;
- return( 1 );
-
- } // fi
-
- // Configure reader
- TParameters* reader_params = reader->GetParameters( );
- if( argc > 4 )
+ // Associate filenames
+ std::vector< std::string > fnames;
+ for( int i = 2; i < argc; ++i )
+ fnames.push_back( argv[ i ] );
+
+ // Read image
+ std::string name = "";
+ try
{
- for( int i = 2; i < argc; ++i )
- reader_params->AddToStringList( "FileNames", argv[ i ] );
+ name = plugins.ReadImage( fnames, "" );
}
- else
- reader_params->AddToStringList( "FileNames", argv[ 2 ] );
-
- // Execute pipeline
- std::string err = reader->Update( );
- if( err != "" )
+ catch( std::exception& err )
{
- std::cerr << "ERROR: " << err << std::endl;
+ std::cerr << err.what( ) << std::endl;
return( 1 );
- } // fi
- TImage* image = reader->GetOutput< TImage >( "Output" );
+ } // yrt
+ TImage* image = plugins.GetData< TImage >( name );
// Configure visualization objects
vtkSmartPointer< vtkRenderer > renderer =
// Objects
os << indent << "Colors: " << std::endl;
- auto i = this->m_Colors.begin( );
- for( ; i != this->m_Colors.end( ); ++i )
+ auto i = this->Colors.begin( );
+ for( ; i != this->Colors.end( ); ++i )
os
<< indent << indent << i->first << " : ["
<< i->second.R << ", "
unsigned int cpExtensions::Visualization::ImageBlender::
GetNumberOfImages( ) const
{
- return( ( const_cast< Self* >( this ) )->GetNumberOfInputConnections( 0 ) );
-}
-
-// -------------------------------------------------------------------------
-const double& cpExtensions::Visualization::ImageBlender::
-GetMaxWindow( ) const
-{
- return( this->m_MaxWindow );
-}
-
-// -------------------------------------------------------------------------
-const double& cpExtensions::Visualization::ImageBlender::
-GetMaxLevel( ) const
-{
- return( this->m_MaxLevel );
-}
-
-// -------------------------------------------------------------------------
-const double& cpExtensions::Visualization::ImageBlender::
-GetMinWindow( ) const
-{
- return( this->m_MinWindow );
-}
-
-// -------------------------------------------------------------------------
-const double& cpExtensions::Visualization::ImageBlender::
-GetMinLevel( ) const
-{
- return( this->m_MinLevel );
-}
-
-// -------------------------------------------------------------------------
-const double& cpExtensions::Visualization::ImageBlender::
-GetWindow( ) const
-{
- return( this->m_Window );
-}
-
-// -------------------------------------------------------------------------
-const double& cpExtensions::Visualization::ImageBlender::
-GetLevel( ) const
-{
- return( this->m_Level );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageBlender::
-SetWindow( const double& w )
-{
- if( this->m_Window != w )
- {
- this->m_Window = w;
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageBlender::
-SetLevel( const double& l )
-{
- if( this->m_Level != l )
- {
- this->m_Level = l;
- this->Modified( );
-
- } // fi
+ return(
+ ( const_cast< Self* >( this ) )->GetNumberOfInputConnections( 0 )
+ );
}
// -------------------------------------------------------------------------
double& b
) const
{
- auto c = this->m_Colors.find( i );
- if( c != this->m_Colors.end( ) )
+ auto c = this->Colors.find( i );
+ if( c != this->Colors.end( ) )
{
r = c->second.R;
g = c->second.G;
const double& b
)
{
- this->m_Colors[ i ] = TColor( r, g, b );
+ this->Colors[ i ] = TColor( r, g, b );
this->Modified( );
}
cpExtensions::Visualization::ImageBlender::
ImageBlender( )
: Superclass( ),
- m_MaxWindow( double( 0 ) ),
- m_MaxLevel( double( 0 ) ),
- m_MinWindow( double( 0 ) ),
- m_MinLevel( double( 0 ) ),
- m_Window( double( 0 ) ),
- m_Level( double( 0 ) )
+ MaxWindow( double( 1 ) ),
+ MaxLevel( double( 1 ) ),
+ MinWindow( double( 0 ) ),
+ MinLevel( double( 0 ) ),
+ Window( double( 1 ) ),
+ Level( double( 0.5 ) )
{
this->SetNumberOfInputPorts( 1 );
}
this->m_Extent[ 5 ] += 1;
// Configure window/level
- double range[ 2 ];
- inData->GetScalarRange( range );
- this->m_MaxWindow = range[ 1 ] - range[ 0 ];
- this->m_MinWindow = this->m_MaxWindow * double( 1e-2 );
- this->m_MinLevel = range[ 0 ];
- this->m_MaxLevel = range[ 1 ];
- if( this->m_Window < this->m_MinWindow )
- this->m_Window = this->m_MinWindow;
- if( this->m_Window > this->m_MaxWindow )
- this->m_Window = this->m_MaxWindow;
- if( this->m_Level < this->m_MinLevel )
- this->m_Level = this->m_MinLevel;
- if( this->m_Level > this->m_MaxLevel )
- this->m_Level = this->m_MaxLevel;
- this->m_WLSlope = double( 1 ) / this->m_Window;
- this->m_WLOffset = double( 0.5 ) - ( this->m_Level / this->m_Window );
+ this->m_WLSlope = double( 1 ) / this->Window;
+ this->m_WLOffset = double( 0.5 ) - ( this->Level / this->Window );
// Configure output type
vtkDataObject::SetPointDataActiveScalarInfo(
outputVector->GetInformationObject( 0 ),
- VTK_UNSIGNED_CHAR, 4
+ VTK_UNSIGNED_CHAR, 3
);
return( 1 );
}
vtkImageData** inDatas,
int numInputs,
vtkImageData* outData,
- int outExt[6],
+ int outExt[ 6 ],
int id
)
{
int mType = inDatas[ 0 ]->GetScalarType( );
int mSize = inDatas[ 0 ]->GetScalarSize( );
- double r, g, b, a;
+ double r, g, b;
int e13 = this->m_Extent[ 1 ] * this->m_Extent[ 3 ];
for( int k = outExt[ 4 ]; k <= outExt[ 5 ]; ++k )
{
// Prepare color
r = g = b = v;
- a = _1;
// Blend colors
for( int i = 1; i < numInputs; ++i )
);
if( c > double( 0 ) )
{
- TColor rgb = this->m_Colors[ i ];
+ TColor rgb = this->Colors[ i ];
r *= rgb.R * rgb.N;
g *= rgb.G * rgb.N;
b *= rgb.B * rgb.N;
- a = _1;
} // fi
} // rof
// Update color
- int di4 = di << 2;
- oBuffer[ di4 + 0 ] = static_cast< unsigned char >( r * _255 );
- oBuffer[ di4 + 1 ] = static_cast< unsigned char >( g * _255 );
- oBuffer[ di4 + 2 ] = static_cast< unsigned char >( b * _255 );
- oBuffer[ di4 + 3 ] = static_cast< unsigned char >( a * _255 );
+ int di3 = di * 3;
+ oBuffer[ di3 + 0 ] = static_cast< unsigned char >( r * _255 );
+ oBuffer[ di3 + 1 ] = static_cast< unsigned char >( g * _255 );
+ oBuffer[ di3 + 2 ] = static_cast< unsigned char >( b * _255 );
} // rof
typedef ImageBlender Self;
vtkTypeMacro( ImageBlender, vtkThreadedImageAlgorithm );
+ vtkGetMacro( MaxWindow, double );
+ vtkGetMacro( MaxLevel, double );
+ vtkGetMacro( MinWindow, double );
+ vtkGetMacro( MinLevel, double );
+ vtkGetMacro( Window, double );
+ vtkGetMacro( Level, double );
+
+ vtkSetMacro( MaxWindow, double );
+ vtkSetMacro( MaxLevel, double );
+ vtkSetMacro( MinWindow, double );
+ vtkSetMacro( MinLevel, double );
+ vtkSetMacro( Window, double );
+ vtkSetMacro( Level, double );
+
public:
static Self* New( );
void PrintSelf( std::ostream& os, vtkIndent indent );
unsigned int GetNumberOfImages( ) const;
-
- const double& GetMaxWindow( ) const;
- const double& GetMaxLevel( ) const;
- const double& GetMinWindow( ) const;
- const double& GetMinLevel( ) const;
- const double& GetWindow( ) const;
- const double& GetLevel( ) const;
-
- void SetWindow( const double& w );
- void SetLevel( const double& l );
void SetWindowLevel( const double& w, const double& l );
void GetColor(
vtkImageData** inDatas,
int numInputs,
vtkImageData* outData,
- int outExt[6],
+ int outExt[ 6 ],
int id
);
this->N = std::sqrt( ( r * r ) + ( g * g ) + ( b * b ) );
}
};
- mutable std::map< unsigned int, TColor > m_Colors;
-
- double m_MaxWindow;
- double m_MaxLevel;
- double m_MinWindow;
- double m_MinLevel;
- double m_Window;
- double m_Level;
+ mutable std::map< unsigned int, TColor > Colors;
+
+ double MaxWindow;
+ double MaxLevel;
+ double MinWindow;
+ double MinLevel;
+ double Window;
+ double Level;
int m_Extent[ 6 ];
double m_WLSlope;
#ifdef cpPlugins_Interface_QT4
#include <cpPlugins/Interface/ui_BaseMPRWidget.h>
+#include <cpPlugins/Interface/DataObject.h>
+#include <cpPlugins/Interface/Image.h>
+#include <cpPlugins/Interface/Mesh.h>
#include <QTreeWidgetItem>
#include <vtkRendererCollection.h>
// -------------------------------------------------------------------------
bool cpPlugins::Interface::BaseMPRWidget::
-AddImage(
- vtkImageData* image, const std::string& name, const std::string& parent
+AddData(
+ cpPlugins::Interface::DataObject* data, const std::string& name,
+ const std::string& parent
)
{
if( name == "" )
return( false );
- if( parent == "" )
- this->DeleteAllData( );
-
auto iIt = this->m_Data.find( name );
if( iIt == this->m_Data.end( ) )
{
- // Update tree
if( parent != "" )
{
auto pIt = this->m_Data.find( parent );
- if( pIt != this->m_Data.end( ) )
- this->m_Tree[ name ] = parent;
- else
+ if( pIt == this->m_Data.end( ) )
return( false );
- }
- else
- this->m_MainImage = name;
-
+
+ } // fi
+
// Add new data
- Data nd;
- nd.Tag = Data::IMAGE;
- nd.Image = image;
- this->m_Data[ name ] = nd;
+ this->m_Data[ name ].SetSourceDataObject( data );
// Add to tree view
- this->_UpdateItem( name, parent );
+ this->_UpdateTreeItem( name, parent );
return( true );
}
else
// -------------------------------------------------------------------------
bool cpPlugins::Interface::BaseMPRWidget::
-AddMesh(
- vtkPolyData* mesh, const std::string& name, const std::string& parent
- )
+SetMainImage( const std::string& name )
{
- if( name == "" || parent == "" )
- return( false );
-
auto iIt = this->m_Data.find( name );
- if( iIt == this->m_Data.end( ) )
+ if( iIt != this->m_Data.end( ) )
{
- // Add new data
- Data nd;
- nd.Tag = Data::MESH;
- nd.Mesh.Configure( mesh );
- this->m_Data[ name ] = nd;
-
- // Update tree
- auto pIt = this->m_Data.find( parent );
- if( pIt != this->m_Data.end( ) )
- this->m_Tree[ name ] = parent;
+ if( iIt->second.Tag == Data::IMAGE )
+ {
+ this->m_MainImage = name;
+ return( true );
+ }
else
return( false );
-
- // Add to tree view
- this->_UpdateItem( name, parent );
- return( true );
}
else
return( false );
this->DeleteData( *dIt );
// Delete from tree widget
- QTreeWidgetItem* item = this->_FindItem( name );
+ QTreeWidgetItem* item = this->_FindItemInTree( name );
if( item != NULL )
this->m_UI->LoadedData->removeItemWidget( item, 0 );
// Reset main image, just in case
if( this->m_Data.size( ) == 0 )
this->m_MainImage = "";
-
+
} // fi
}
const std::string& name, const double& r, const double& g, const double& b
)
{
- auto iIt = this->m_Data.find( name );
- if( iIt == this->m_Data.end( ) )
+ /*
+ auto iIt = this->m_Data.find( name );
+ if( iIt == this->m_Data.end( ) )
return;
- if( iIt->second.Tag == Data::IMAGE )
- {
- }
- else if( iIt->second.Tag == Data::MESH )
- {
- } // fi
+ if( iIt->second.Tag == Data::IMAGE )
+ {
+ }
+ else if( iIt->second.Tag == Data::MESH )
+ {
+ } // fi
+ */
}
// -------------------------------------------------------------------------
if( iIt == this->m_Data.end( ) )
return;
- if( iIt->second.Tag == Data::IMAGE )
- {
+ /*
+ if( iIt->second.Tag == Data::IMAGE )
+ {
this->m_MPRObjects->AddImage( iIt->second.Image );
- }
- else if( iIt->second.Tag == Data::MESH )
- {
+ }
+ else if( iIt->second.Tag == Data::MESH )
+ {
vtkRenderer* ren =
- this->m_VTK[ 3 ]->GetRenderWindow( )->GetRenderers( )->GetFirstRenderer( );
+ this->m_VTK[ 3 ]->GetRenderWindow( )->GetRenderers( )->GetFirstRenderer( );
if( ren == NULL )
- return;
+ return;
ren->AddActor( iIt->second.GetMeshActor( ) );
this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
+ } // fi
+ */
+}
- } // fi
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::BaseMPRWidget::
+HideData( const std::string& name )
+{
}
// -------------------------------------------------------------------------
)
{
// Update tree view
- QTreeWidgetItem* new_item = this->_UpdateItem( name, parent );
+ QTreeWidgetItem* new_item = this->_UpdateTreeItem( name, parent );
if( new_item == NULL )
return( false );
)
{
// Update tree view
- QTreeWidgetItem* new_item = this->_UpdateItem( name, parent );
+ QTreeWidgetItem* new_item = this->_UpdateTreeItem( name, parent );
if( new_item == NULL )
return( false );
)
{
// Update tree view
- QTreeWidgetItem* new_item = this->_UpdateItem( name, parent );
+ QTreeWidgetItem* new_item = this->_UpdateTreeItem( name, parent );
if( new_item == NULL )
return( false );
// -------------------------------------------------------------------------
QTreeWidgetItem* cpPlugins::Interface::BaseMPRWidget::
-_FindItem( const std::string& name ) const
+_FindItemInTree( const std::string& name ) const
{
QList< QTreeWidgetItem* > items =
this->m_UI->LoadedData->findItems( name.c_str( ), Qt::MatchExactly );
// -------------------------------------------------------------------------
QTreeWidgetItem* cpPlugins::Interface::BaseMPRWidget::
-_UpdateItem( const std::string& name, const std::string& parent )
+_UpdateTreeItem( const std::string& name, const std::string& parent )
{
// Update tree view
QTreeWidgetItem* new_item = NULL;
if( parent != "" )
{
- QTreeWidgetItem* parent_item = this->_FindItem( parent );
+ QTreeWidgetItem* parent_item = this->_FindItemInTree( parent );
if( parent_item != NULL )
{
- QTreeWidgetItem* old_item = this->_FindItem( name );
+ QTreeWidgetItem* old_item = this->_FindItemInTree( name );
if( old_item == NULL )
{
new_item =
this->Actor->DeferLODConstructionOff( );
}
+// -------------------------------------------------------------------------
+cpPlugins::Interface::BaseMPRWidget::Data::
+Data( )
+{
+ this->Tag = Data::IMAGE;
+ this->Source = NULL;
+ this->Image = NULL;
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::BaseMPRWidget::Data::
+~Data( )
+{
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::BaseMPRWidget::
+Data& cpPlugins::Interface::BaseMPRWidget::Data::
+operator=( const Data& data )
+{
+ this->Tag = data.Tag;
+ this->Source = data.Source;
+ if( this->Tag == Data::IMAGE )
+ this->Image = data.Image;
+ else if( this->Tag == Data::MESH )
+ this->Mesh = data.Mesh;
+ return( *this );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::
+DataObject* cpPlugins::Interface::BaseMPRWidget::Data::
+GetSourceDataObject( )
+{
+ return( this->Source );
+}
+
+// -------------------------------------------------------------------------
+const cpPlugins::Interface::
+DataObject* cpPlugins::Interface::BaseMPRWidget::Data::
+GetSourceDataObject( ) const
+{
+ return( this->Source );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::BaseMPRWidget::Data::
+SetSourceDataObject( cpPlugins::Interface::DataObject* dobj )
+{
+ typedef cpPlugins::Interface::Image _TImage;
+ typedef cpPlugins::Interface::Mesh _TMesh;
+
+ this->Source = dobj;
+ _TImage* image = dynamic_cast< _TImage* >( dobj );
+ if( image != NULL )
+ {
+ this->Tag = Data::IMAGE;
+ this->Image = image->GetVTK< vtkImageData >( );
+ }
+ else
+ {
+ _TMesh* mesh = dynamic_cast< _TMesh* >( dobj );
+ if( mesh == NULL )
+ return;
+
+ this->Tag = Data::MESH;
+ this->Mesh.Configure( mesh->GetVTK< vtkPolyData >( ) );
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+vtkImageData* cpPlugins::Interface::BaseMPRWidget::Data::
+GetImage( )
+{
+ if( this->Tag == Data::IMAGE )
+ return( this->Image );
+ else
+ return( NULL );
+}
+
+// -------------------------------------------------------------------------
+vtkPolyData* cpPlugins::Interface::BaseMPRWidget::Data::
+GetMesh( )
+{
+ if( this->Tag == Data::MESH )
+ return( this->Mesh.Mesh );
+ else
+ return( NULL );
+}
+
+// -------------------------------------------------------------------------
+vtkProp* cpPlugins::Interface::BaseMPRWidget::Data::
+GetMeshActor( )
+{
+ if( this->Tag == Data::MESH )
+ return( this->Mesh.Actor );
+ else
+ return( NULL );
+}
+
#endif // cpPlugins_Interface_QT4
// eof - $RCSfile$
{
namespace Interface
{
+ // Some forward declarations
+ class DataObject;
+
/**
*/
class cpPlugins_Interface_EXPORT BaseMPRWidget
virtual ~BaseMPRWidget( );
// Data management
- bool AddImage(
- vtkImageData* image,
- const std::string& name,
- const std::string& parent = ""
- );
- bool AddMesh(
- vtkPolyData* mesh,
- const std::string& name,
+ bool AddData(
+ DataObject* data, const std::string& name,
const std::string& parent
);
+ bool SetMainImage( const std::string& name );
void DeleteData( const std::string& name );
void DeleteAllData( );
// Some visualization accessors
void SetDataColor(
const std::string& name,
- const double& r,
- const double& g,
- const double& b
+ const double& r, const double& g, const double& b
);
void ShowData( const std::string& name );
+ void HideData( const std::string& name );
vtkRenderWindowInteractor* GetInteractor( unsigned int i );
- /*
- bool ShowImage(
- vtkImageData* image,
- const std::string& name,
- const std::string& parent = ""
- );
- bool ShowImage(
- vtkImageData* image,
- const std::string& name,
- const std::string& parent,
- const double& r, const double& g, const double& b
- );
- bool ShowMesh(
- vtkPolyData* mesh,
- const std::string& name,
- const std::string& parent
- );
- bool ShowMesh(
- vtkPolyData* mesh,
- const std::string& name,
- const std::string& parent,
- const double& r, const double& g, const double& b
- );
- void ClearAll( );
- */
-
// Visual objects accessors
std::string GetSelectedData( ) const;
protected:
- QTreeWidgetItem* _FindItem( const std::string& name ) const;
- QTreeWidgetItem* _UpdateItem(
+ QTreeWidgetItem* _FindItemInTree( const std::string& name ) const;
+ QTreeWidgetItem* _UpdateTreeItem(
const std::string& name,
const std::string& parent
);
- /* TODO
- void _Add3DActor( vtkProp3D* prop );
- */
-
private slots:
void _SyncBottom( int a, int b );
void _SyncTop( int a, int b );
struct Data
{
enum { IMAGE, MESH } Tag;
+ DataObject* Source;
union
{
vtkImageData* Image;
PolyDataActor Mesh;
};
- Data( ) { }
- virtual ~Data( ) { }
-
- inline Data& operator=( const Data& data )
- {
- this->Tag = data.Tag;
- if( this->Tag == Data::IMAGE )
- this->Image = data.Image;
- else if( this->Tag == Data::MESH )
- this->Mesh = data.Mesh;
- return( *this );
- }
-
- inline vtkImageData* GetImage( )
- {
- if( this->Tag == Data::IMAGE )
- return( this->Image );
- else
- return( NULL );
- }
- inline vtkPolyData* GetMesh( )
- {
- if( this->Tag == Data::MESH )
- return( this->Mesh.Mesh );
- else
- return( NULL );
- }
- inline vtkProp* GetMeshActor( )
- {
- if( this->Tag == Data::MESH )
- return( this->Mesh.Actor );
- else
- return( NULL );
- }
+ Data( );
+ virtual ~Data( );
+
+ Data& operator=( const Data& data );
+
+ DataObject* GetSourceDataObject( );
+ const DataObject* GetSourceDataObject( ) const;
+ void SetSourceDataObject( DataObject* dobj );
+
+ vtkImageData* GetImage( );
+ vtkPolyData* GetMesh( );
+ vtkProp* GetMeshActor( );
};
std::string m_MainImage;
this->m_Providers[ cIt->second ]
);
if( provider != NULL )
- return( provider->create( ) );
+ {
+ cpPlugins::Interface::ProcessObject::Pointer po = provider->create( );
+ po->SetName( name );
+ return( po );
+
+ } // fi
} // fi
return( NULL );
// -------------------------------------------------------------------------
cpPlugins::Interface::Object::
Object( )
- : Superclass( )
+ : Superclass( ),
+ m_Name( "" )
{
}
{
TDataObject* dobj =
this->m_ActiveFilter->GetOutput< TDataObject >( *oIt );
+
+ if( std::string( dobj->GetName( ) ) == std::string( "" ) )
+ dobj->SetName(
+ this->m_ActiveFilter->GetName( ) + std::string( "_" ) + *oIt
+ );
this->_InsertNewData( dobj, parent );
outputs.insert( dobj->GetName( ) );
AddInteractor( vtkRenderWindowInteractor* interactor )
{
#ifdef cpPlugins_Interface_QT4
+ if( this->m_ParametersDialog == NULL )
+ this->m_ParametersDialog = new ParametersQtDialog( );
this->m_ParametersDialog->addInteractor( interactor );
#endif // cpPlugins_Interface_QT4
}