return( "cpPlugins::Interface::Workspace: No valid workspace" );
std::stringstream err;
- // Read plugins files
- TiXmlElement* plugins = root->FirstChildElement( "plugins" );
- while( plugins != NULL )
- {
- const char* value = plugins->Attribute( "filename" );
- if( value != NULL )
- {
- if( !( this->LoadPlugins( value ) ) )
- err << "no valid plugins file \"" << value << "\"" << std::endl;
-
- } // fi
- plugins = plugins->NextSiblingElement( "plugins" );
-
- } // elihw
-
- // Read plugins paths
- plugins = root->FirstChildElement( "plugins_dir" );
- while( plugins != NULL )
- {
- const char* value = plugins->Attribute( "path" );
- if( value != NULL )
- {
- int recursive;
- if( plugins->QueryIntAttribute( "recursive", &recursive ) != TIXML_SUCCESS )
- recursive = 0;
- if( !( this->LoadPluginsPath( value, recursive == 1 ) ) )
- err << "No valid plugins path \"" << value << "\"" << std::endl;
-
- } // fi
- plugins = plugins->NextSiblingElement( "plugins_dir" );
-
- } // elihw
-
// Read filters
TiXmlElement* filter = root->FirstChildElement( "filter" );
while( filter != NULL )
{
const char* class_value = filter->Attribute( "class" );
const char* name_value = filter->Attribute( "name" );
+ float viewX = float( 0 ), viewY = float( 0 );
+ filter->QueryFloatAttribute( "ViewX", &viewX );
+ filter->QueryFloatAttribute( "ViewY", &viewY );
if( class_value != NULL && name_value != NULL )
{
if( this->CreateFilter( class_value, name_value ) )
{
- // Read parameters
- TParameters* parameters = this->GetParameters( name_value );
- TiXmlElement* param = filter->FirstChildElement( "parameter" );
- while( param != NULL )
- {
- const char* param_name = param->Attribute( "name" );
- const char* param_type = param->Attribute( "type" );
- if( param_name != NULL && param_type != NULL )
- {
- std::string param_type_str( param_type );
- const char* value = param->Attribute( "value" );
- if( value != NULL )
- {
- std::istringstream value_str( value );
- if( param_type_str == "String" )
- parameters->SetString( param_name, value );
- else if( param_type_str == "Bool" )
- parameters->SetBool( param_name, value[ 0 ] != '0' );
- else if( param_type_str == "Int" )
- {
- TParameters::TInt v;
- value_str >> v;
- parameters->SetInt( param_name, v );
- }
- else if( param_type_str == "Uint" )
- {
- TParameters::TUint v;
- value_str >> v;
- parameters->SetUint( param_name, v );
- }
- else if( param_type_str == "Real" )
- {
- TParameters::TReal v;
- value_str >> v;
- parameters->SetReal( param_name, v );
- }
- /* TODO
- else if( param_type_str == "Index" )
- else if( param_type_str == "Point" )
- else if( param_type_str == "Vector" )
- */
- }
- else
- {
- if( param_type_str == "StringList" )
- {
- TiXmlElement* item = param->FirstChildElement( "item" );
- while( item != NULL )
- {
- value = item->Attribute( "value" );
- if( value != NULL )
- parameters->AddToStringList( param_name, value );
- item = item->NextSiblingElement( "item" );
+ TFilter* new_filter = this->GetFilter( name_value );
+ new_filter->SetViewCoords( viewX, viewY );
- } // elihw
- }
- else if( param_type_str == "BoolList" )
- {
- TiXmlElement* item = param->FirstChildElement( "item" );
- while( item != NULL )
- {
- value = item->Attribute( "value" );
- if( value != NULL )
- parameters->AddToBoolList( param_name, value[ 0 ] != '0' );
- item = item->NextSiblingElement( "item" );
-
- } // elihw
- }
- else if( param_type_str == "IntList" )
- {
- TiXmlElement* item = param->FirstChildElement( "item" );
- while( item != NULL )
- {
- value = item->Attribute( "value" );
- if( value != NULL )
- {
- std::istringstream value_str( value );
- TParameters::TInt v;
- value_str >> v;
- parameters->AddToIntList( param_name, v );
-
- } // fi
- item = item->NextSiblingElement( "item" );
-
- } // elihw
- }
- else if( param_type_str == "UintList" )
- {
- TiXmlElement* item = param->FirstChildElement( "item" );
- while( item != NULL )
- {
- value = item->Attribute( "value" );
- if( value != NULL )
- {
- std::istringstream value_str( value );
- TParameters::TUint v;
- value_str >> v;
- parameters->AddToUintList( param_name, v );
-
- } // fi
- item = item->NextSiblingElement( "item" );
-
- } // elihw
- }
- else if( param_type_str == "RealList" )
- {
- TiXmlElement* item = param->FirstChildElement( "item" );
- while( item != NULL )
- {
- value = item->Attribute( "value" );
- if( value != NULL )
- {
- std::istringstream value_str( value );
- TParameters::TReal v;
- value_str >> v;
- parameters->AddToRealList( param_name, v );
-
- } // fi
- item = item->NextSiblingElement( "item" );
-
- } // elihw
- }
- /* TODO
- else if( param_type_str == "IndexList" )
- else if( param_type_str == "PointList" )
- else if( param_type_str == "VectorList" )
- else if( param_type_str == "Choices" );
- */
- } // fi
-
- } // fi
- param = param->NextSiblingElement( "parameter" );
-
- } // elihw
+ // Read parameters
+ TParameters* parameters = new_filter->GetParameters( );
+ parameters->FromXML( filter );
}
else
err
} // elihw
- // Read filters
+ // Read connections
TiXmlElement* connection = root->FirstChildElement( "connection" );
while( connection != NULL )
{
} // elihw
+ // Read exposed inputs
+ TiXmlElement* port = root->FirstChildElement( "exposed_input_port" );
+ while( port != NULL )
+ {
+ this->ExposeInputPort(
+ port->Attribute( "port_name" ),
+ port->Attribute( "filter" ),
+ port->Attribute( "filter_port_name" )
+ );
+ port = port->NextSiblingElement( "exposed_input_port" );
+
+ } // elihw
+
+ // Read exposed outputs
+ port = root->FirstChildElement( "exposed_output_port" );
+ while( port != NULL )
+ {
+ this->ExposeOutputPort(
+ port->Attribute( "port_name" ),
+ port->Attribute( "filter" ),
+ port->Attribute( "filter_port_name" )
+ );
+ port = port->NextSiblingElement( "exposed_output_port" );
+
+ } // elihw
+
// Finish and return
delete doc;
return( err.str( ) );
TiXmlDocument* doc = new TiXmlDocument( );
TiXmlElement* root = new TiXmlElement( "cpPlugins_Workspace" );
- // Save plugins
- for(
- auto plugIt = this->m_LoadedPlugins.begin( );
- plugIt != this->m_LoadedPlugins.end( );
- ++plugIt
- )
- {
- TiXmlElement* plugin = new TiXmlElement( "plugins" );
- plugin->SetAttribute( "filename", plugIt->c_str( ) );
- root->LinkEndChild( plugin );
-
- } // rof
-
// Save vertices
auto vIt = this->m_Graph->BeginVertices( );
for( ; vIt != this->m_Graph->EndVertices( ); ++vIt )
auto data = dynamic_cast< TData* >( vIt->second.GetPointer( ) );
if( filter != NULL )
{
+ TiXmlElement* e = new TiXmlElement( "filter" );
+ e->SetAttribute( "class", filter->GetClassName( ) );
+ e->SetAttribute( "name", vIt->first.c_str( ) );
+ e->SetAttribute( "ViewX", filter->GetViewX( ) );
+ e->SetAttribute( "ViewY", filter->GetViewY( ) );
+
+ const TParameters* params = filter->GetParameters( );
+ params->ToXML( e );
+
+ root->LinkEndChild( e );
}
else if( data != NULL )
{
+ // TODO
} // fi
} // rof
+ // Save connections
+ auto mIt = this->m_Graph->BeginEdgesRows( );
+ for( ; mIt != this->m_Graph->EndEdgesRows( ); ++mIt )
+ {
+ auto rIt = mIt->second.begin( );
+ for( ; rIt != mIt->second.end( ); ++rIt )
+ {
+ auto eIt = rIt->second.begin( );
+ for( ; eIt != rIt->second.end( ); ++eIt )
+ {
+ TiXmlElement* conn = new TiXmlElement( "connection" );
+ TiXmlElement* orig = new TiXmlElement( "origin" );
+ TiXmlElement* dest = new TiXmlElement( "destination" );
+ orig->SetAttribute( "filter", mIt->first.c_str( ) );
+ orig->SetAttribute( "name", eIt->first.c_str( ) );
+ dest->SetAttribute( "filter", rIt->first.c_str( ) );
+ dest->SetAttribute( "name", eIt->second.c_str( ) );
+
+ conn->LinkEndChild( orig );
+ conn->LinkEndChild( dest );
+ root->LinkEndChild( conn );
+
+ } // rof
+
+ } // rof
+
+ } // rof
+
+ // Save exposed ports
+ auto eipIt = this->m_ExposedInputPorts.begin( );
+ for( ; eipIt != this->m_ExposedInputPorts.end( ); ++eipIt )
+ {
+ TiXmlElement* port = new TiXmlElement( "exposed_input_port" );
+ port->SetAttribute( "port_name", eipIt->first.c_str( ) );
+ port->SetAttribute( "filter", eipIt->second.first.c_str( ) );
+ port->SetAttribute( "filter_port_name", eipIt->second.second.c_str( ) );
+ root->LinkEndChild( port );
+
+ } // rof
+
+ auto eopIt = this->m_ExposedOutputPorts.begin( );
+ for( ; eopIt != this->m_ExposedOutputPorts.end( ); ++eopIt )
+ {
+ TiXmlElement* port = new TiXmlElement( "exposed_output_port" );
+ port->SetAttribute( "port_name", eopIt->first.c_str( ) );
+ port->SetAttribute( "filter", eopIt->second.first.c_str( ) );
+ port->SetAttribute( "filter_port_name", eopIt->second.second.c_str( ) );
+ root->LinkEndChild( port );
+
+ } // rof
+
// Physical write and return
doc->LinkEndChild( root );
doc->SaveFile( fname.c_str( ) );