// SUPERV GraphEditor : contains classes that permit edition of graphs // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // // File : DataFlowEditor_DataFlow.lxx // Module : SUPERV #ifndef _DATAFLOWEDITOR_DATAFLOW_LXX #define _DATAFLOWEDITOR_DATAFLOW_LXX #include "DataFlowEditor_OutNode.hxx" inline void GraphEditor::DataFlow::ReadOnly() { _ReadOnly = true ; } inline char * GraphEditor::DataFlow::DataFlowInfo() { ostringstream s; IsValid() ; GraphEditor::DataFlow::DataFlow aDataFlow = *this ; s << aDataFlow << ends ; return CORBA::string_dup( s.str().c_str() ); } inline char * GraphEditor::DataFlow::DataNodeInfo() { ostringstream s; IsValid() ; Graph()->DataNodeInfo( s ) ; return CORBA::string_dup( s.str().c_str() ); } inline char * GraphEditor::DataFlow::NodeInfo( const char * aNodeName ) { ostringstream s; if ( Graph()->GetGraphNode( aNodeName ) ) Graph()->GetGraphNode( aNodeName )->NodeInfo( s ) ; else s << aNodeName << " not found" << ends ; return CORBA::string_dup( s.str().c_str() ); } inline bool GraphEditor::DataFlow::LoadDataFlow( const GraphBase::SGraph *aDataFlow ) { if ( _ReadOnly ) return false ; _EditedAfterExecution = true ; return GraphEditor::OutNode::LoadDataFlow( aDataFlow ) ; } ; inline bool GraphEditor::DataFlow::LoadXml( const char* myFileName ) { if ( _ReadOnly ) return false ; _EditedAfterExecution = true ; return GraphEditor::OutNode::LoadXml( myFileName ) ; } ; inline bool GraphEditor::DataFlow::LoadInfo( const GraphBase::SNode &aDataFlowInfo ) { if ( _ReadOnly ) return false ; _EditedAfterExecution = true ; return GraphEditor::OutNode::LoadInfo( aDataFlowInfo ) ; } ; inline bool GraphEditor::DataFlow::SaveXml(const char* myFileName ) { return GraphEditor::OutNode::SaveXml( myFileName ) ; } ; inline bool GraphEditor::DataFlow::SavePy(const char* myFileName ) { return GraphEditor::OutNode::SavePy( myFileName ) ; } ; // get all DataFlow informations (for a .XML file) : inline GraphBase::SGraph * GraphEditor::DataFlow::GetDataFlow() { return GraphEditor::OutNode::GetDataFlow() ; } ; // void DateModification() ; //inline GraphBase::SNode * GraphEditor::DataFlow::GetInfo() const { // return GraphEditor::OutNode::GetInfo() ; //} ; inline GraphBase::ListOfNodes * GraphEditor::DataFlow::GetNodes() const { return Graph()->GetNodes() ; } ; inline GraphBase::ListOfLinks * GraphEditor::DataFlow::GetLinks() const { return Graph()->GetLinks() ; } ; inline GraphBase::ListOfGraphs * GraphEditor::DataFlow::GetGraphs() const { return Graph()->GetGraphs() ; } ; inline GraphBase::ListOfLinks * GraphEditor::DataFlow::GetDatas() const { return Graph()->GetDatas() ; } ; inline const SALOME_ModuleCatalog::Service * GraphEditor::DataFlow::GetService() { IsValid() ; return Graph()->GetService() ; } ; inline GraphEditor::InNode * GraphEditor::DataFlow::AddNode( const SALOME_ModuleCatalog::Service& NodeService , const char* NodeComponentName , const char* NodeInterfaceName , const char* NodeName, const SUPERV::KindOfNode NodeKindOfNode, GraphBase::ListOfFuncName aFuncName , GraphBase::ListOfPythonFunctions aPythonFunction , const SUPERV::SDate NodeFirstCreation, const SUPERV::SDate NodeLastModification, const char * NodeEditorRelease, const char * NodeAuthor, const char * NodeComputer, const char * NodeComment, const int NodeX, const int NodeY) { if ( NodeName != NULLSTRING && strlen( NodeName ) ) { // MESSAGE( "--> GraphEditor::DataFlow::AddNode( " << NodeName << " )" ) ; // cout << "--> GraphEditor::DataFlow::AddNode( " << NodeName << " )" << endl ; cdebug_in << "GraphEditor::DataFlow::AddNode( " << NodeName << " )" << endl ; } else { // MESSAGE( "--> GraphEditor::DataFlow::AddNode( NULL )" ) ; // cout << "--> GraphEditor::DataFlow::AddNode( NULL )" << endl ; NodeName = NULLSTRING ; cdebug_in << "GraphEditor::DataFlow::AddNode( NULL )" << endl ; } if ( _ReadOnly ) { return (GraphEditor::InNode * ) NULL ; } _EditedAfterExecution = true ; GraphEditor::InNode * aNode = GraphEditor::OutNode::AddNode( NodeService , aFuncName , aPythonFunction , NodeComponentName , NodeInterfaceName , NodeName , NodeKindOfNode , NodeFirstCreation , NodeLastModification , NodeEditorRelease , NodeAuthor , NodeComputer , NodeComment , NodeX , NodeY ) ; // MESSAGE( "<-- GraphEditor::DataFlow::AddNode( " << aNode->Name() << " )" ) ; // cout << "<-- GraphEditor::DataFlow::AddNode( " << aNode->Name() << " )" << endl ; cdebug_out << "GraphEditor::DataFlow::AddNode( " << aNode->Name() << " )" << endl ; return aNode ; } ; inline GraphEditor::InNode * GraphEditor::DataFlow::GetNode( const char* NodeName ) { return GraphEditor::OutNode::GetNode( NodeName ) ; } ; inline bool GraphEditor::DataFlow::RemoveNode( const char* NodeName ) { if ( _ReadOnly ) { return false ; } _EditedAfterExecution = true ; return GraphEditor::OutNode::RemoveNode( NodeName ) ; } ; inline bool GraphEditor::DataFlow::ReNameNode( const char* OldNodeName , const char* NewNodeName ) { if ( _ReadOnly ) { return false ; } _EditedAfterExecution = true ; return GraphEditor::OutNode::ReNameNode( OldNodeName , NewNodeName ) ; } ; inline const SALOME_ModuleCatalog::Service * GraphEditor::DataFlow::NodeService( const char * aNodeName ) { if ( Graph()->GetGraphNode( aNodeName ) ) { return Graph()->GetGraphNode( aNodeName )->GetService() ; } return NULL ; } inline void GraphEditor::DataFlow::Coordinates( const int X , const int Y ) { _EditedAfterExecution = true ; return GraphEditor::OutNode::Coordinates( X , Y ) ; } ; inline const int GraphEditor::DataFlow::XCoordinate() { return GraphEditor::OutNode::XCoordinate() ; } ; inline const int GraphEditor::DataFlow::YCoordinate() { return GraphEditor::OutNode::YCoordinate() ; } ; inline void GraphEditor::DataFlow::Coordinates( const char* NodeName , const int X , const int Y ) { return GraphEditor::OutNode::Coordinates( NodeName , X , Y ) ; } ; inline const int GraphEditor::DataFlow::XCoordinate( const char* NodeName ) { return GraphEditor::OutNode::XCoordinate( NodeName ) ; } ; inline const int GraphEditor::DataFlow::YCoordinate( const char* NodeName ) { return GraphEditor::OutNode::YCoordinate( NodeName ) ; } ; inline const GraphBase::InPort *GraphEditor::DataFlow::GetInPort( const char *name ) { return GraphEditor::OutNode::GetInPort( name ) ; } inline const GraphBase::OutPort *GraphEditor::DataFlow::GetOutPort( const char *name ) { return GraphEditor::OutNode::GetOutPort( name ) ; } inline GraphBase::InPort *GraphEditor::DataFlow::GetChangeInPort( const char *name ) { return GraphEditor::OutNode::GetChangeInPort( name ) ; } inline GraphBase::OutPort *GraphEditor::DataFlow::GetChangeOutPort( const char *name ) { return GraphEditor::OutNode::GetChangeOutPort( name ) ; } inline bool GraphEditor::DataFlow::HasInput(const char * ToServiceParameterName ) { return GraphEditor::OutNode::HasInput( ToServiceParameterName ) ; } inline bool GraphEditor::DataFlow::AddLink( const char* FromNodeName , const char* FromServiceParameterName , const char* ToNodeName , const char* ToServiceParameterName , const CORBA::Any aValue ) { if ( !_ReadOnly ) { GraphEditor::InNode * aFromNode = GetNode( FromNodeName ) ; if ( aFromNode ) { GraphBase::OutPort * anOutPort = aFromNode->GetChangeOutPort( FromServiceParameterName ) ; if ( anOutPort ) { CORBA::Any const * theValue = anOutPort->Value() ; // Keep the type ! _EditedAfterExecution = true ; return GraphEditor::OutNode::AddLink( FromNodeName , FromServiceParameterName , ToNodeName , ToServiceParameterName , *theValue ) ; } } } return false ; } ; inline bool GraphEditor::DataFlow::GetLink(const char* ToNodeName , const char* ToServiceParameterName , char** FromNodeName , char** FromServiceParameterName ) { return GraphEditor::OutNode::GetLink( ToNodeName , ToServiceParameterName , FromNodeName , FromServiceParameterName ) ; } inline GraphBase::SLink * GraphEditor::DataFlow::GetLink( GraphBase::ComputingNode * aNode , const char* ToServiceParameterName ) { return Graph()->GetLink( aNode , aNode->GetChangeInPort( ToServiceParameterName ) ) ; } inline bool GraphEditor::DataFlow::AddLinkCoord( const char* FromNodeName , const char* FromServiceParameterName , const char* ToNodeName , const char* ToServiceParameterName , const int nXY , const int* X , const int* Y ) { _EditedAfterExecution = true ; return GraphEditor::OutNode::AddLinkCoord( FromNodeName , FromServiceParameterName , ToNodeName , ToServiceParameterName , nXY , X , Y ) ; } ; inline bool GraphEditor::DataFlow::AddLinkCoord( const char* FromNodeName , const char* FromServiceParameterName , const char* ToNodeName , const char* ToServiceParameterName , const int index , const int X , const int Y ) { _EditedAfterExecution = true ; return GraphEditor::OutNode::AddLinkCoord( FromNodeName , FromServiceParameterName , ToNodeName , ToServiceParameterName , index , X , Y ) ; } ; inline bool GraphEditor::DataFlow::ChangeLinkCoord( const char* FromNodeName , const char* FromServiceParameterName , const char* ToNodeName , const char* ToServiceParameterName , const int index , const int X , const int Y ) { _EditedAfterExecution = true ; return GraphEditor::OutNode::ChangeLinkCoord( FromNodeName , FromServiceParameterName , ToNodeName , ToServiceParameterName , index , X , Y ) ; } ; inline bool GraphEditor::DataFlow::RemoveLinkCoord( const char* FromNodeName , const char* FromServiceParameterName , const char* ToNodeName , const char* ToServiceParameterName , const int index ) { _EditedAfterExecution = true ; return GraphEditor::OutNode::RemoveLinkCoord( FromNodeName , FromServiceParameterName , ToNodeName , ToServiceParameterName , index ) ; } ; inline int GraphEditor::DataFlow::GetLinkCoordSize( const char* FromNodeName , const char* FromServiceParameterName , const char* ToNodeName , const char* ToServiceParameterName ) { return GraphEditor::OutNode::GetLinkCoordSize( FromNodeName , FromServiceParameterName , ToNodeName , ToServiceParameterName ) ; } ; inline bool GraphEditor::DataFlow::GetLinkCoord( const char* FromNodeName , const char* FromServiceParameterName , const char* ToNodeName , const char* ToServiceParameterName , int *X , int *Y ) { return GraphEditor::OutNode::GetLinkCoord( FromNodeName , FromServiceParameterName , ToNodeName , ToServiceParameterName , X , Y ) ; } ; inline bool GraphEditor::DataFlow::GetLinkCoord( const char* FromNodeName , const char* FromServiceParameterName , const char* ToNodeName , const char* ToServiceParameterName , const int index , long &X , long &Y ) { return GraphEditor::OutNode::GetLinkCoord( FromNodeName , FromServiceParameterName , ToNodeName , ToServiceParameterName , index , X , Y ) ; } ; inline bool GraphEditor::DataFlow::RemoveLink( const char* FromNodeName , const char* FromServiceParameterName , const char* ToNodeName , const char* ToServiceParameterName ) { if ( _ReadOnly ) { return false ; } _EditedAfterExecution = true ; return GraphEditor::OutNode::RemoveLink( FromNodeName , FromServiceParameterName , ToNodeName , ToServiceParameterName ) ; } ; inline bool GraphEditor::DataFlow::AddInputData( const char* ToNodeName , const char* ToParameterName , const CORBA::Any aValue ) { #if 0 GraphBase::Node *toNode ; GraphBase::InPort *toPort ; char *aNode ; char *aPort ; NodePort( ToNodeName , ToParameterName , &aNode , &aPort ) ; toNode = GetChangeGraphNode( aNode ) ; if ( toNode ) { toPort = toNode->GetChangeInPort( aPort ) ; if ( toPort && ( toPort->IsConnected() || toPort->IsDataConnected() ) ) { RemoveLink( toNode->Name() , toPort->PortName() ) ; } } else { toPort = NULL ; } delete aNode ; delete aPort ; #endif if ( !IsValid() ) { return false ; } return Graph()->AddInputData( ToNodeName , ToParameterName , aValue ) ; } ; inline bool GraphEditor::DataFlow::AddInputSharedData(const char* ToNodeName1 , const char* ToParameterName1 , const char* ToNodeName2 , const char* ToParameterName2 ) { if ( !IsValid() ) { return false ; } return GraphEditor::OutNode::AddInputData( ToNodeName1 , ToParameterName1 , ToNodeName2 , ToParameterName2 ) ; } ; inline const CORBA::Any *GraphEditor::DataFlow::GetInData( const char * ToNodeName , const char * ToParameterName ) { return GraphEditor::OutNode::GetInData( ToNodeName , ToParameterName ) ; } inline const CORBA::Any *GraphEditor::DataFlow::GetOutData( const char * FromNodeName , const char * FromParameterName ) { return GraphEditor::OutNode::GetOutData( FromNodeName , FromParameterName ) ; } inline bool GraphEditor::DataFlow::IsValid() { return GraphEditor::OutNode::IsValid() ; } inline bool GraphEditor::DataFlow::IsExecutable() { return GraphEditor::OutNode::IsExecutable() ; } inline bool GraphEditor::DataFlow::IsExecuting() { if ( _DataFlowExecutor ) { if ( _DataFlowExecutor->IsDone() ) { _Executing = false ; } else { _Executing = true ; } } else { _Executing = false ; } return _Executing ; } inline bool GraphEditor::DataFlow::IsEditing() { return !IsExecuting() ; } inline void GraphEditor::DataFlow::EditedAfterExecution(bool EditedAfterExecution ) { _EditedAfterExecution = EditedAfterExecution ; } inline bool GraphEditor::DataFlow::EditedAfterExecution() { return _EditedAfterExecution ; } inline bool GraphEditor::DataFlow::IsReadOnly() { return _ReadOnly ; } inline long GraphEditor::DataFlow::LevelMax() { if ( !IsValid() ) { return 0 ; } return Graph()->LevelMax() ; } inline SUPERV::ListOfStrings * GraphEditor::DataFlow::LevelNodes(long aLevel ) { if ( !IsValid() ) { return ((SUPERV::ListOfStrings * ) NULL ) ; } return Graph()->LevelNodes( aLevel ) ; } inline long GraphEditor::DataFlow::ThreadsMax() { if ( !IsValid() ) { return 0 ; } return Graph()->ThreadsMax() ; } inline long GraphEditor::DataFlow::SubGraphsNumber() { if ( !IsValid() ) { return 0 ; } return Graph()->SubGraphsNumber() ; } inline long GraphEditor::DataFlow::SubStreamGraphsNumber() { if ( !IsValid() ) { return 0 ; } return StreamGraph()->SubStreamGraphsNumber() ; } inline void GraphEditor::DataFlow::Executor( GraphExecutor::DataFlow * DataFlowExecutor ) { _Executing = true ; _DataFlowExecutor = DataFlowExecutor ; } inline GraphExecutor::DataFlow * GraphEditor::DataFlow::Executor() const { return _DataFlowExecutor ; } #endif