From 628503854743434655e81a0b11c9b9955315608e Mon Sep 17 00:00:00 2001 From: nri Date: Fri, 16 May 2003 12:53:06 +0000 Subject: [PATCH] NRI : First integration. --- src/GraphBase/DataFlowBase_Base.cxx | 36 + src/GraphBase/DataFlowBase_Base.hxx | 166 ++ src/GraphBase/DataFlowBase_ComputingNode.cxx | 1028 ++++++++++ src/GraphBase/DataFlowBase_ComputingNode.hxx | 291 +++ src/GraphBase/DataFlowBase_DataNode.cxx | 143 ++ src/GraphBase/DataFlowBase_DataNode.hxx | 94 + src/GraphBase/DataFlowBase_DataPort.cxx | 241 +++ src/GraphBase/DataFlowBase_DataPort.hxx | 53 + src/GraphBase/DataFlowBase_EndOfLoopNode.cxx | 73 + src/GraphBase/DataFlowBase_EndOfLoopNode.hxx | 45 + .../DataFlowBase_EndOfSwitchNode.cxx | 73 + .../DataFlowBase_EndOfSwitchNode.hxx | 45 + src/GraphBase/DataFlowBase_FactoryNode.cxx | 194 ++ src/GraphBase/DataFlowBase_FactoryNode.hxx | 80 + src/GraphBase/DataFlowBase_GOTONode.cxx | 112 ++ src/GraphBase/DataFlowBase_GOTONode.hxx | 83 + src/GraphBase/DataFlowBase_Graph.cxx | 1763 +++++++++++++++++ src/GraphBase/DataFlowBase_Graph.hxx | 272 +++ src/GraphBase/DataFlowBase_InLineNode.cxx | 177 ++ src/GraphBase/DataFlowBase_InLineNode.hxx | 90 + src/GraphBase/DataFlowBase_InPort.cxx | 52 + src/GraphBase/DataFlowBase_InPort.hxx | 89 + src/GraphBase/DataFlowBase_LoadXml.cxx | 63 + src/GraphBase/DataFlowBase_LoopNode.cxx | 126 ++ src/GraphBase/DataFlowBase_LoopNode.hxx | 93 + src/GraphBase/DataFlowBase_OutPort.cxx | 144 ++ src/GraphBase/DataFlowBase_OutPort.hxx | 93 + src/GraphBase/DataFlowBase_Port.cxx | 193 ++ src/GraphBase/DataFlowBase_Port.hxx | 118 ++ src/GraphBase/DataFlowBase_PortsOfNode.cxx | 538 +++++ src/GraphBase/DataFlowBase_PortsOfNode.hxx | 90 + src/GraphBase/DataFlowBase_Service.cxx | 50 + src/GraphBase/DataFlowBase_Service.hxx | 63 + .../DataFlowBase_ServicesParameter.hxx | 35 + src/GraphBase/DataFlowBase_SwitchNode.cxx | 72 + src/GraphBase/DataFlowBase_SwitchNode.hxx | 45 + src/GraphBase/DataFlowBase_XmlHandler.cxx | 1079 ++++++++++ src/GraphBase/DataFlowBase_XmlHandler.hxx | 83 + src/GraphBase/Makefile.in | 88 + .../SuperVisionBase_CheckOfUndefined.cxx | 13 + src/SUPERVGUI/Makefile.in | 87 + src/SUPERVGUI/SUPERVGUI.cxx | 636 ++++++ src/SUPERVGUI/SUPERVGUI.h | 98 + src/SUPERVGUI/SUPERVGUI_Array.cxx | 265 +++ src/SUPERVGUI/SUPERVGUI_Array.h | 73 + src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx | 457 +++++ src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.h | 106 + src/SUPERVGUI/SUPERVGUI_ComputeNode.cxx | 145 ++ src/SUPERVGUI/SUPERVGUI_ComputeNode.h | 46 + src/SUPERVGUI/SUPERVGUI_ControlNode.cxx | 439 ++++ src/SUPERVGUI/SUPERVGUI_ControlNode.h | 126 ++ src/SUPERVGUI/SUPERVGUI_CtrlLink.cxx | 45 + src/SUPERVGUI/SUPERVGUI_CtrlLink.h | 37 + src/SUPERVGUI/SUPERVGUI_Def.h | 214 ++ src/SUPERVGUI/SUPERVGUI_Graph.cxx | 593 ++++++ src/SUPERVGUI/SUPERVGUI_Graph.h | 97 + src/SUPERVGUI/SUPERVGUI_GraphNode.cxx | 419 ++++ src/SUPERVGUI/SUPERVGUI_GraphNode.h | 81 + src/SUPERVGUI/SUPERVGUI_Information.cxx | 240 +++ src/SUPERVGUI/SUPERVGUI_Information.h | 40 + src/SUPERVGUI/SUPERVGUI_Label.cxx | 38 + src/SUPERVGUI/SUPERVGUI_Label.h | 33 + src/SUPERVGUI/SUPERVGUI_Link.cxx | 799 ++++++++ src/SUPERVGUI/SUPERVGUI_Link.h | 142 ++ src/SUPERVGUI/SUPERVGUI_Main.cxx | 1083 ++++++++++ src/SUPERVGUI/SUPERVGUI_Main.h | 137 ++ src/SUPERVGUI/SUPERVGUI_Node.cxx | 473 +++++ src/SUPERVGUI/SUPERVGUI_Node.h | 152 ++ src/SUPERVGUI/SUPERVGUI_Notification.cxx | 313 +++ src/SUPERVGUI/SUPERVGUI_Notification.h | 104 + src/SUPERVGUI/SUPERVGUI_Port.cxx | 501 +++++ src/SUPERVGUI/SUPERVGUI_Port.h | 174 ++ src/SUPERVGUI/SUPERVGUI_Python.cxx | 99 + src/SUPERVGUI/SUPERVGUI_Python.h | 33 + src/SUPERVGUI/SUPERVGUI_Service.cxx | 664 +++++++ src/SUPERVGUI/SUPERVGUI_Service.h | 159 ++ src/SUPERVGUI/SUPERVGUI_View.cxx | 174 ++ src/SUPERVGUI/SUPERVGUI_View.h | 69 + src/SUPERVGUI/SUPERVGUI_icons.po | 14 + src/SUPERVGUI/SUPERVGUI_msg_en.po | 578 ++++++ src/SUPERVGUI/SUPERVGUI_msg_fr.po | 421 ++++ src/Supervision/CNode_Impl.cxx | 1315 ++++++++++++ src/Supervision/CNode_Impl.hxx | 199 ++ src/Supervision/ELNode_Impl.cxx | 94 + src/Supervision/ELNode_Impl.hxx | 62 + src/Supervision/ESNode_Impl.cxx | 100 + src/Supervision/ESNode_Impl.hxx | 61 + src/Supervision/FNode_Impl.cxx | 151 ++ src/Supervision/FNode_Impl.hxx | 78 + src/Supervision/GNode_Impl.cxx | 156 ++ src/Supervision/GNode_Impl.hxx | 104 + src/Supervision/Graph_Impl.cxx | 1199 +++++++++++ src/Supervision/Graph_Impl.hxx | 162 ++ src/Supervision/INode_Impl.cxx | 328 +++ src/Supervision/INode_Impl.hxx | 88 + src/Supervision/LNode_Impl.cxx | 170 ++ src/Supervision/LNode_Impl.hxx | 84 + src/Supervision/Link_Impl.cxx | 195 ++ src/Supervision/Link_Impl.hxx | 78 + src/Supervision/Makefile.in | 79 + src/Supervision/Port_Impl.cxx | 380 ++++ src/Supervision/Port_Impl.hxx | 94 + src/Supervision/SNode_Impl.cxx | 97 + src/Supervision/SNode_Impl.hxx | 62 + src/Supervision/SuperV.py | 1139 +++++++++++ src/Supervision/SuperV_CheckOfUndefined.cxx | 28 + src/Supervision/SuperV_Impl.cxx | 531 +++++ src/Supervision/SuperV_Impl.hxx | 109 + src/Supervision/Value_Impl.cxx | 322 +++ src/Supervision/Value_Impl.hxx | 74 + src/Supervision/batchmode_SuperV.py | 1160 +++++++++++ 111 files changed, 27289 insertions(+) create mode 100644 src/GraphBase/DataFlowBase_Base.cxx create mode 100644 src/GraphBase/DataFlowBase_Base.hxx create mode 100644 src/GraphBase/DataFlowBase_ComputingNode.cxx create mode 100644 src/GraphBase/DataFlowBase_ComputingNode.hxx create mode 100644 src/GraphBase/DataFlowBase_DataNode.cxx create mode 100644 src/GraphBase/DataFlowBase_DataNode.hxx create mode 100644 src/GraphBase/DataFlowBase_DataPort.cxx create mode 100644 src/GraphBase/DataFlowBase_DataPort.hxx create mode 100644 src/GraphBase/DataFlowBase_EndOfLoopNode.cxx create mode 100644 src/GraphBase/DataFlowBase_EndOfLoopNode.hxx create mode 100644 src/GraphBase/DataFlowBase_EndOfSwitchNode.cxx create mode 100644 src/GraphBase/DataFlowBase_EndOfSwitchNode.hxx create mode 100644 src/GraphBase/DataFlowBase_FactoryNode.cxx create mode 100644 src/GraphBase/DataFlowBase_FactoryNode.hxx create mode 100644 src/GraphBase/DataFlowBase_GOTONode.cxx create mode 100644 src/GraphBase/DataFlowBase_GOTONode.hxx create mode 100644 src/GraphBase/DataFlowBase_Graph.cxx create mode 100644 src/GraphBase/DataFlowBase_Graph.hxx create mode 100644 src/GraphBase/DataFlowBase_InLineNode.cxx create mode 100644 src/GraphBase/DataFlowBase_InLineNode.hxx create mode 100644 src/GraphBase/DataFlowBase_InPort.cxx create mode 100644 src/GraphBase/DataFlowBase_InPort.hxx create mode 100644 src/GraphBase/DataFlowBase_LoadXml.cxx create mode 100644 src/GraphBase/DataFlowBase_LoopNode.cxx create mode 100644 src/GraphBase/DataFlowBase_LoopNode.hxx create mode 100644 src/GraphBase/DataFlowBase_OutPort.cxx create mode 100644 src/GraphBase/DataFlowBase_OutPort.hxx create mode 100644 src/GraphBase/DataFlowBase_Port.cxx create mode 100644 src/GraphBase/DataFlowBase_Port.hxx create mode 100644 src/GraphBase/DataFlowBase_PortsOfNode.cxx create mode 100644 src/GraphBase/DataFlowBase_PortsOfNode.hxx create mode 100644 src/GraphBase/DataFlowBase_Service.cxx create mode 100644 src/GraphBase/DataFlowBase_Service.hxx create mode 100644 src/GraphBase/DataFlowBase_ServicesParameter.hxx create mode 100644 src/GraphBase/DataFlowBase_SwitchNode.cxx create mode 100644 src/GraphBase/DataFlowBase_SwitchNode.hxx create mode 100644 src/GraphBase/DataFlowBase_XmlHandler.cxx create mode 100755 src/GraphBase/DataFlowBase_XmlHandler.hxx create mode 100644 src/GraphBase/Makefile.in create mode 100644 src/GraphBase/SuperVisionBase_CheckOfUndefined.cxx create mode 100644 src/SUPERVGUI/Makefile.in create mode 100644 src/SUPERVGUI/SUPERVGUI.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI.h create mode 100644 src/SUPERVGUI/SUPERVGUI_Array.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_Array.h create mode 100644 src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.h create mode 100644 src/SUPERVGUI/SUPERVGUI_ComputeNode.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_ComputeNode.h create mode 100644 src/SUPERVGUI/SUPERVGUI_ControlNode.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_ControlNode.h create mode 100644 src/SUPERVGUI/SUPERVGUI_CtrlLink.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_CtrlLink.h create mode 100644 src/SUPERVGUI/SUPERVGUI_Def.h create mode 100644 src/SUPERVGUI/SUPERVGUI_Graph.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_Graph.h create mode 100644 src/SUPERVGUI/SUPERVGUI_GraphNode.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_GraphNode.h create mode 100644 src/SUPERVGUI/SUPERVGUI_Information.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_Information.h create mode 100644 src/SUPERVGUI/SUPERVGUI_Label.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_Label.h create mode 100644 src/SUPERVGUI/SUPERVGUI_Link.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_Link.h create mode 100644 src/SUPERVGUI/SUPERVGUI_Main.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_Main.h create mode 100644 src/SUPERVGUI/SUPERVGUI_Node.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_Node.h create mode 100644 src/SUPERVGUI/SUPERVGUI_Notification.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_Notification.h create mode 100644 src/SUPERVGUI/SUPERVGUI_Port.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_Port.h create mode 100644 src/SUPERVGUI/SUPERVGUI_Python.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_Python.h create mode 100644 src/SUPERVGUI/SUPERVGUI_Service.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_Service.h create mode 100644 src/SUPERVGUI/SUPERVGUI_View.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_View.h create mode 100644 src/SUPERVGUI/SUPERVGUI_icons.po create mode 100644 src/SUPERVGUI/SUPERVGUI_msg_en.po create mode 100644 src/SUPERVGUI/SUPERVGUI_msg_fr.po create mode 100644 src/Supervision/CNode_Impl.cxx create mode 100644 src/Supervision/CNode_Impl.hxx create mode 100644 src/Supervision/ELNode_Impl.cxx create mode 100644 src/Supervision/ELNode_Impl.hxx create mode 100644 src/Supervision/ESNode_Impl.cxx create mode 100644 src/Supervision/ESNode_Impl.hxx create mode 100644 src/Supervision/FNode_Impl.cxx create mode 100644 src/Supervision/FNode_Impl.hxx create mode 100644 src/Supervision/GNode_Impl.cxx create mode 100644 src/Supervision/GNode_Impl.hxx create mode 100644 src/Supervision/Graph_Impl.cxx create mode 100644 src/Supervision/Graph_Impl.hxx create mode 100644 src/Supervision/INode_Impl.cxx create mode 100644 src/Supervision/INode_Impl.hxx create mode 100644 src/Supervision/LNode_Impl.cxx create mode 100644 src/Supervision/LNode_Impl.hxx create mode 100644 src/Supervision/Link_Impl.cxx create mode 100644 src/Supervision/Link_Impl.hxx create mode 100755 src/Supervision/Makefile.in create mode 100644 src/Supervision/Port_Impl.cxx create mode 100644 src/Supervision/Port_Impl.hxx create mode 100644 src/Supervision/SNode_Impl.cxx create mode 100644 src/Supervision/SNode_Impl.hxx create mode 100644 src/Supervision/SuperV.py create mode 100755 src/Supervision/SuperV_CheckOfUndefined.cxx create mode 100644 src/Supervision/SuperV_Impl.cxx create mode 100644 src/Supervision/SuperV_Impl.hxx create mode 100644 src/Supervision/Value_Impl.cxx create mode 100644 src/Supervision/Value_Impl.hxx create mode 100644 src/Supervision/batchmode_SuperV.py diff --git a/src/GraphBase/DataFlowBase_Base.cxx b/src/GraphBase/DataFlowBase_Base.cxx new file mode 100644 index 0000000..ede6362 --- /dev/null +++ b/src/GraphBase/DataFlowBase_Base.cxx @@ -0,0 +1,36 @@ +using namespace std; +//============================================================================= +// File : DataFlowBase_Base.cxx +// Created : 2002 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#include "DataFlowBase_Base.hxx" + +char *SuperVision_Version = "1.04" ; + +char *NULLSTRING = "" ; + +char *FACTORYSERVER = "localhost/FactoryServer" ; + +GraphBase::Base::Base() { + _prof_debug = NULL ; + _fdebug = NULL ; +} + +void GraphBase::Base::SetDebug( CORBA::ORB_ptr ORB , + int * theprof_debug , ostream * thefdebug ) { + _Orb = CORBA::ORB::_duplicate( ORB ) ; + _prof_debug = theprof_debug ; + _fdebug = thefdebug ; +} + +char * GraphBase::Base::ObjectToString( CORBA::Object_ptr obj ) const { + return _Orb->object_to_string( obj ); +} + +CORBA::Object_ptr GraphBase::Base::StringToObject( char * obj ) const { + return _Orb->string_to_object( obj ); +} diff --git a/src/GraphBase/DataFlowBase_Base.hxx b/src/GraphBase/DataFlowBase_Base.hxx new file mode 100644 index 0000000..dafa25a --- /dev/null +++ b/src/GraphBase/DataFlowBase_Base.hxx @@ -0,0 +1,166 @@ +//============================================================================= +// File : DataFlowBase_Base.hxx +// Created : 2002 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#ifndef _DATAFLOW_BASE_HXX +#define _DATAFLOW_BASE_HXX + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "CORBA.h" + +#include +#include CORBA_CLIENT_HEADER(SUPERV) + +#include "utilities.h" +#include "OpUtil.hxx" + +#include "SALOME_NamingService.hxx" + +extern char *SuperVision_Version ; + +extern char *NULLSTRING ; + +extern char *FACTORYSERVER ; + +inline char * my_strdup( const char * s ) { + if (s == NULL) return NULL; + + size_t l = strlen(s) + 1; + char * t = new char[l]; + strcpy(t, s); + return t; +} + +enum StatusOfPort { NotConnected , PortConnected , PortAndDataConnected , + DataConnected } ; + +namespace GraphBase { + + struct SCoord { + long theX ; + long theY ; + }; + + typedef vector ListOfCoords; + + typedef string FuncName ; + + typedef vector< FuncName > ListOfFuncName ; + + typedef vector ListOfPythonFunctions ; + + struct NodeParameter { + SALOME_ModuleCatalog::ServicesParameter theInParameter ; + SALOME_ModuleCatalog::ServicesParameter theOutParameter ; + }; + + typedef vector ListOfParameters; + + struct SNode { + string theComponentName ; + string theInterfaceName ; + string theName ; + SUPERV::KindOfNode theKind ; + string theCoupledNode ; + SALOME_ModuleCatalog::Service theService ; + ListOfParameters theListOfParameters ; + ListOfFuncName theListOfFuncName ; + ListOfPythonFunctions theListOfPythonFunctions ; + SUPERV::SDate theFirstCreation ; + SUPERV::SDate theLastModification ; + string theEditorRelease ; + string theAuthor ; + string theContainer; + string theComment; + SCoord theCoords ; + }; + + typedef vector ListOfNodes; + + struct ServicesData { + SALOME_ModuleCatalog::ServicesParameter aDataParameter ; + CORBA::Any aDataValue; + }; + + typedef vector ListOfServicesData; + + struct SLink { + string FromNodeName ; + string FromServiceParameterName ; + string ToNodeName ; + string ToServiceParameterName ; + CORBA::Any aLinkValue; + ListOfCoords aListOfCoords ; + }; + + typedef vector ListOfLinks; + + struct SGraph { + SNode Info ; + ListOfNodes Nodes ; + ListOfLinks Links ; + ListOfLinks Datas ; + }; + + typedef vector ListOfGraphs; + + class Base { + + private: + + CORBA::ORB_ptr _Orb ; + + public: + + int * _prof_debug; + ostream * _fdebug; + + Base() ; + virtual ~Base() {} ; + + void SetDebug( CORBA::ORB_ptr ORB , + int * prof_debug , ostream * fdebug ) ; + + char * ObjectToString( CORBA::Object_ptr obj ) const ; + CORBA::Object_ptr StringToObject(char * obj ) const ; + + } ; +# ifdef _DEBUG_ + +# define cdebug \ + if ( GraphBase::Base::_prof_debug ) \ + *GraphBase::Base::_fdebug << " " /*<< setw(3*(*GraphBase::Base::_prof_debug)) */<< " " + +# define cdebug_in \ + if ( GraphBase::Base::_prof_debug ) \ + *GraphBase::Base::_fdebug << endl << "-->" /*<< setw(3*((*GraphBase::Base::_prof_debug)++)) */<< " " + +# define cdebug_out \ + if ( GraphBase::Base::_prof_debug ) \ + *GraphBase::Base::_fdebug << endl << "<--" /*<< setw(3*(--(*GraphBase::Base::_prof_debug)))*/ << " " +# else + +# define cdebug while (false) std::cerr +# define cdebug_in cdebug +# define cdebug_out cdebug +# define debugFile(x) + +# endif + +} ; + +#endif diff --git a/src/GraphBase/DataFlowBase_ComputingNode.cxx b/src/GraphBase/DataFlowBase_ComputingNode.cxx new file mode 100644 index 0000000..6889c90 --- /dev/null +++ b/src/GraphBase/DataFlowBase_ComputingNode.cxx @@ -0,0 +1,1028 @@ +using namespace std; +//============================================================================= +// File : DataFlowBase_Node.cxx +// Created : 2002 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#include +#include + +#include "DataFlowBase_InLineNode.hxx" +#include "DataFlowBase_LoopNode.hxx" + +static void InitFields( SUPERV::KindOfNode &_Kind , + SUPERV::SDate &_FirstCreation , + SUPERV::SDate &_LastModification , + char * &_EditorRelease , + char * &_Author , + char * &_Comment , + bool &_HeadNode , + bool &_GeneratedName , + int &_ConnectedInPortsNumber , + int &_DecrConnectedInPortsNumber, + int &_LinkedNodesSize , + int &_SubGraphNumber ) { + time_t T = time(NULL); + struct tm * Tm = localtime(&T); + + _Kind = SUPERV::DataFlowNode ; + + _FirstCreation.Second = _LastModification.Second = Tm->tm_sec; + _FirstCreation.Minute = _LastModification.Minute = Tm->tm_min; + _FirstCreation.Hour = _LastModification.Hour = Tm->tm_hour; + _FirstCreation.Day = _LastModification.Day = Tm->tm_mday; + _FirstCreation.Month = _LastModification.Month = Tm->tm_mon + 1; + _FirstCreation.Year = _LastModification.Year = Tm->tm_year + 1900; + + _EditorRelease = new char[ strlen( SuperVision_Version ) + 1 ] ; + strcpy( _EditorRelease , SuperVision_Version ) ; + _Author = NULLSTRING ; +// _Computer = new char[ strlen( FACTORYSERVER ) + 1 ] ; +// strcpy( _Computer , FACTORYSERVER ) ; + _Comment = NULLSTRING ; + + _SubGraphNumber = 0 ; + _HeadNode = false ; + _GeneratedName = false ; + + _ConnectedInPortsNumber = 0 ; + _DecrConnectedInPortsNumber = 0 ; + _LinkedNodesSize = 0 ; + _SubGraphNumber = 0 ; +} + +GraphBase::ComputingNode::ComputingNode() : + GraphBase::PortsOfNode::PortsOfNode() { + + InitFields( _Kind , + _FirstCreation , + _LastModification , + _EditorRelease , + _Author , + _Comment , + _HeadNode , + _GeneratedName , + _ConnectedInPortsNumber , + _DecrConnectedInPortsNumber , + _LinkedNodesSize , + _SubGraphNumber ) ; + _NamingService = NULL ; + _Node = SUPERV::CNode::_nil() ; + _InNode = NULL ; + _ThreadNo = pthread_self() ; + _Name = NULL ; + cdebug << "GraphBase::Node::Node " << this + << " _Name " + << (void *) _Name << " " << _Name << " _Comment " + << (void *) _Comment << " " << _Comment << " " << endl ; + +} + +GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char * aDataFlowName , + int * Graph_prof_debug , + ostream * Graph_fdebug ) : + GraphBase::PortsOfNode::PortsOfNode( aDataFlowName ) { + + InitFields( _Kind , + _FirstCreation , + _LastModification , + _EditorRelease , + _Author , + _Comment , + _HeadNode , + _GeneratedName , + _ConnectedInPortsNumber , + _DecrConnectedInPortsNumber , + _LinkedNodesSize , + _SubGraphNumber ) ; + + _ORB = CORBA::ORB::_duplicate( ORB ) ; + _NamingService = ptrNamingService ; + _Graph_prof_debug = Graph_prof_debug ; + _Graph_fdebug = Graph_fdebug ; + _Node = SUPERV::CNode::_nil() ; + _InNode = NULL ; + _ThreadNo = pthread_self() ; + + if ( aDataFlowName && strlen( aDataFlowName ) ) { + _Name = new char[ strlen( aDataFlowName )+1 ] ; + strcpy( _Name , aDataFlowName ) ; + } + else + _Name = NULL ; + if ( Graph_prof_debug ) { + SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; +// MESSAGE( "Invalid DataFlow Name." ); + } + cdebug << "GraphBase::ComputingNode::ComputingNode " << this + << "' _Name " + << (void *) _Name << " '" << _Name << " _Comment " + << (void *) _Comment << " " << _Comment << " " << _FirstCreation + << " " << _LastModification << endl ; +} + +GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const SALOME_ModuleCatalog::Service& aService , + const char *NodeName , + const SUPERV::KindOfNode akind , + const SUPERV::SDate NodeFirstCreation , + const SUPERV::SDate NodeLastModification , + const char * NodeEditorRelease , + const char * NodeAuthor , + const char * NodeComment , + const bool GeneratedName , + const long X , + const long Y , + int * Graph_prof_debug , + ostream * Graph_fdebug ) : + GraphBase::PortsOfNode::PortsOfNode() { + + _ORB = CORBA::ORB::_duplicate( ORB ) ; + _NamingService = ptrNamingService ; + _Graph_prof_debug = Graph_prof_debug ; + _Graph_fdebug = Graph_fdebug ; + _Node = SUPERV::CNode::_nil() ; + _InNode = NULL ; + _ThreadNo = pthread_self() ; + + _Kind = akind ; + + time_t T = time(NULL); + struct tm * Tm = localtime(&T); + + _FirstCreation.Second = _LastModification.Second = Tm->tm_sec; + _FirstCreation.Minute = _LastModification.Minute = Tm->tm_min; + _FirstCreation.Hour = _LastModification.Hour = Tm->tm_hour; + _FirstCreation.Day = _LastModification.Day = Tm->tm_mday; + _FirstCreation.Month = _LastModification.Month = Tm->tm_mon + 1; + _FirstCreation.Year = _LastModification.Year = Tm->tm_year + 1900; + + if ( NodeEditorRelease ) { + _EditorRelease = new char[ strlen( NodeEditorRelease ) + 1 ] ; + strcpy( _EditorRelease , NodeEditorRelease ) ; + } + else { + _EditorRelease = new char[ strlen( SuperVision_Version ) + 1 ] ; + strcpy( _EditorRelease , SuperVision_Version ) ; + } + + if ( NodeAuthor ) { + _Author = new char[ strlen( NodeAuthor ) + 1 ] ; + strcpy( _Author , NodeAuthor ) ; + } + else + _Author = NULLSTRING ; + + if ( NodeComment ) { + _Comment = new char[ strlen( NodeComment ) + 1 ] ; + strcpy( _Comment , NodeComment ) ; + } + else + _Comment = NULLSTRING ; + + _SubGraphNumber = 0 ; + _HeadNode = false ; + _GeneratedName = GeneratedName ; + + const char *aNodeName = NodeName ; + _Name = new char[strlen(aNodeName)+1]; + strcpy(_Name , aNodeName); + + _ConnectedInPortsNumber = 0 ; + _DecrConnectedInPortsNumber = 0 ; + _LinkedNodesSize = 0 ; + + _X = X ; + _Y = Y ; + + if ( Graph_prof_debug ) + SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; + +// if ( !IsOneOfInLineNodes() ) { + DefPortsOfNode( ORB , aService , NamePtr() , Kind() , + IsDataFlowNode() || IsComputingNode() || + IsFactoryNode() , // DataFlowOrComputing + IsLoopNode() || IsEndLoopNode() , // WithInLoop + IsComputingNode() || IsFactoryNode() ||// WithInGate + IsInLineNode() || IsLoopNode() || IsSwitchNode() || + IsEndSwitchNode() , +// IsGOTONode() || IsEndLoopNode() || IsEndSwitchNode() , + IsComputingNode() || IsFactoryNode() || // WithOutGate + IsInLineNode() || IsSwitchNode() || IsGOTONode() , +// IsEndLoopNode() || IsEndSwitchNode() , + Graph_prof_debug , Graph_fdebug ) ; +// } + + cdebug_in << "GraphBase::ComputingNode::ComputingNode(" << aService.ServiceName << "," + << aNodeName << "," << akind + << "," << NodeComment << ")" << endl; + + cdebug << "GraphBase::ComputingNode::ComputingNode " << this + << " _Name " + << (void *) _Name << " '" << _Name << "' _Comment " + << (void *) _Comment << " " << _Comment << " " + << " KindOfNode " << _Kind + << " ServiceName " << ServiceName() << " In(" << ServiceInParameter().length() + << ") Out(" << ServiceOutParameter().length() << ")" << endl ; + + cdebug_out << "GraphBase::ComputingNode::ComputingNode" << endl; +} + +GraphBase::ComputingNode::~ComputingNode() { + cdebug << "GraphBase::ComputingNode::~ComputingNode " << this + << " _Name " + << (void *) _Name << " " << _Name << " _Comment " + << (void *) _Comment << " " << _Comment << " " << endl ; +// if ( _ComponentName != NULLSTRING ) +// delete [] _ComponentName ; +// delete [] _Name ; +// delete [] _EditorRelease ; +// if ( _Author != NULLSTRING ) +// delete [] _Author ; +// if ( _Computer != FACTORYSERVER ) +// delete [] _Computer; +// if ( _Comment != NULLSTRING ) +// delete [] _Comment; +} + +bool GraphBase::ComputingNode::Name( const char * aName) { + if ( _Name ) { + cdebug << "GraphBase::ComputingNode::ReName " << _Name << " --> " << aName << endl ; + delete [] _Name ; + } + _Name = new char[strlen(aName)+1] ; + strcpy( _Name , aName ) ; + return true ; +} + +SUPERV::SDate GraphBase::ComputingNode::FirstCreation () const { + cdebug << "GraphBase::ComputingNode::FirstCreation " + << "' _Name " << _Name << " " << _FirstCreation << " " + << _LastModification << endl ; + return _FirstCreation; +} + +SUPERV::SDate GraphBase::ComputingNode::LastModification () const { + return _LastModification ; +} + +bool GraphBase::ComputingNode::Kind(const SUPERV::KindOfNode aKind) { + _Kind = aKind ; + return true ; +} + +void GraphBase::ComputingNode::FirstCreation(const SUPERV::SDate aDate ) { + _FirstCreation = aDate ; +} + +void GraphBase::ComputingNode::LastModification(const SUPERV::SDate aDate ) { + _LastModification = aDate ; +} + +bool GraphBase::ComputingNode::EditorRelease(const char * c){ + if ( _EditorRelease && _EditorRelease != NULLSTRING ) + delete _EditorRelease; + _EditorRelease = my_strdup(c); + return true ; +} + +bool GraphBase::ComputingNode::Author(const char * a) { + if ( _Author && _Author != NULLSTRING ) + delete _Author; + _Author = my_strdup(a); + return true ; +} + +bool GraphBase::ComputingNode::Comment(const char *c) { + cdebug_in << "GraphBase::ComputingNode::Comment" << endl; + if ( _Comment != NULLSTRING ) + delete [] _Comment; + _Comment = my_strdup(c); + cdebug_out << "GraphBase::ComputingNode::Comment" << endl; + return true ; +} + +void GraphBase::ComputingNode::NodePort( const char * NodeName , + const char * ServiceParameterName , + char ** aNode , char ** aPort ) { + if ( strcmp( NodeName , Name() ) ) { + *aNode = my_strdup( NodeName ) ; + *aPort = my_strdup( ServiceParameterName ) ; + } + else { + char * BPort = strchr( ServiceParameterName , '\\' ) ; + if ( BPort ) { + int len = BPort - ServiceParameterName ; + *aNode = new char [ len + 1 ] ; + strncpy( *aNode , ServiceParameterName , len ) ; + (*aNode)[ len ] = '\0' ; + *aPort = my_strdup( &BPort[ 1 ] ) ; + } + else { + *aNode = my_strdup( NULLSTRING ) ; + *aPort = my_strdup( NULLSTRING ) ; + } + } +} + +bool GraphBase::ComputingNode::IsLinked(const char * ToServiceParameterName ) { + bool RetVal = false ; + const GraphBase::InPort * thePort = GetInPort( ToServiceParameterName ) ; + if ( thePort ) { + RetVal = thePort->IsConnected() ; + } + else { + const GraphBase::OutPort * thePort = GetOutPort( ToServiceParameterName ) ; + if ( thePort ) { + RetVal = thePort->IsConnected() ; + } + } + return RetVal ; +} + +bool GraphBase::ComputingNode::HasInput(const char * ToServiceParameterName ) { + bool RetVal = false ; + const GraphBase::InPort * thePort = GetInPort( ToServiceParameterName ) ; + if ( IsDataFlowNode() && thePort ) { + RetVal = true ; + } + else if ( thePort ) { + RetVal = thePort->IsDataConnected() ; + } + else { + const GraphBase::OutPort * thePort = GetOutPort( ToServiceParameterName ) ; + if ( thePort ) { + RetVal = thePort->IsDataConnected() ; + } + } + return RetVal ; +} + +GraphBase::SNode * GraphBase::ComputingNode::GetInfo() { + cdebug_in << "GraphBase::ComputingNode::GetInfo" << endl; + GraphBase::SNode * Info = new GraphBase::SNode ; +// Info->theComponentName = ComponentName() ; +// Info->theInterfaceName = InterfaceName() ; + Info->theName = Name() ; + Info->theKind = Kind() ; + Info->theService = *GetService() ; +// Info->theListOfParameters = *GetListOfParameters() ; + Info->theFirstCreation = FirstCreation() ; + Info->theLastModification = LastModification() ; + Info->theEditorRelease = EditorRelease() ; + Info->theAuthor = Author() ; +// Info->theContainer = Computer() ; + Info->theComment = Comment() ; + Info->theCoords.theX = GraphBase::ComputingNode::XCoordinate() ; + Info->theCoords.theY = GraphBase::ComputingNode::YCoordinate() ; + cdebug_out << "GraphBase::ComputingNode::GetInfo" << endl; + return Info ; +} + +GraphBase::InPort * GraphBase::ComputingNode::AddInPort( const char * InputParameterName , + const char * InputParameterType ) { + return GraphBase::PortsOfNode::AddInPort( _ORB , NamePtr() , + Kind() , + InputParameterName , + InputParameterType , + _Graph_prof_debug , _Graph_fdebug ) ; +} +GraphBase::OutPort * GraphBase::ComputingNode::AddOutPort( const char * OutputParameterName , + const char * OutputParameterType ) { + return GraphBase::PortsOfNode::AddOutPort( _ORB , NamePtr() , + Kind() , + OutputParameterName , + OutputParameterType , + _Graph_prof_debug , _Graph_fdebug ) ; +} + +void GraphBase::ComputingNode::AddLink( GraphBase::ComputingNode * ToNode ) { + int index = GetLinkedNodeIndex( ToNode->Name() ) ; + if ( index < 0 ) { + cdebug << Name() << "->GraphBase::ComputingNode::AddLinkedNode( " << ToNode->Name() + << " ) new LinkedNode " << endl ; + _LinkedNodes.resize( _LinkedNodesSize+1 ) ; + _LinkedInPortsNumber.resize( _LinkedNodesSize+1 ) ; + _LinkedNodes[ _LinkedNodesSize ] = ToNode ; + _LinkedInPortsNumber[ _LinkedNodesSize ] = 1 ; + SetLinkedNodeIndex( ToNode->Name() , _LinkedNodesSize ) ; + index = _LinkedNodesSize ; + _LinkedNodesSize++ ; + } + else { + cdebug << Name() << "->GraphBase::ComputingNode::AddLinkedNode( " << ToNode->Name() + << " ) old LinkedNode " << _LinkedNodes[index ]->Name() << endl ; + _LinkedInPortsNumber[ index ] += 1 ; + } + cdebug << Name() << "->GraphBase::ComputingNode::AddLinkedNode( " << ToNode->Name() + << " ) LinkedNodesSize " << _LinkedNodesSize << " [ " << index + << " ] _LinkedInPortsNumber " << _LinkedInPortsNumber[ index ] + << " ConnectedInPortsNumber " << ToNode->ConnectedInPortsNumber() + << " + 1 Service " << ServiceName() << endl ; + ToNode->IncrConnectedInPortsNumber() ; +} + +void GraphBase::ComputingNode::RemoveLink( GraphBase::ComputingNode * ToNode ) { + int index = GetLinkedNodeIndex( ToNode->Name() ) ; + if ( index >= 0 ) { + cdebug << "GraphBase::ComputingNode::RemoveLink( to " << ToNode->Name() << " from " + << Name() << " index : " << index << " ConnectedInPortsNumber " + << ToNode->ConnectedInPortsNumber() - 1 << " LinkedInPortsNumber " + << _LinkedInPortsNumber[ index ] << " - 1" << endl ; + ToNode->DecrConnectedInPortsNumber() ; + _LinkedInPortsNumber[ index ] -= 1 ; + if ( _LinkedInPortsNumber[ index ] == 0 ) { + _LinkedNodesSize-- ; + cdebug << "GraphBase::ComputingNode::RemoveLink new LinkedNodesSize " + << _LinkedNodesSize << " " << ToNode->Name() << " removed from " + << " linkednodes of " << Name() << endl ; + int i ; + for ( i = index ; i < _LinkedNodesSize ; i++ ) { + _LinkedNodes[ i ] = _LinkedNodes[ i+1 ] ; + _LinkedInPortsNumber[ i ] = _LinkedInPortsNumber[ i+1 ] ; + SetLinkedNodeIndex( _LinkedNodes[ i ]->Name() , i ) ; + } + DelLinkedNodeIndex( ToNode->Name() ) ; + _LinkedNodes.resize( _LinkedNodesSize+1 ) ; + _LinkedInPortsNumber.resize( _LinkedNodesSize+1 ) ; + } + } + else { + cdebug << " Error index " << index << endl ; + } +} + +void GraphBase::ComputingNode::ReNameLink( const char* OldNodeName , + const char* NewNodeName ) { + cdebug_in << "GraphBase::ComputingNode::ReNameLink (" << OldNodeName << " , " + << NewNodeName << ")" << endl; + int index = GetLinkedNodeIndex( OldNodeName ) ; + if ( index >= 0 ) { + _MapOfLinkedNodes.erase( OldNodeName ) ; + SetLinkedNodeIndex( NewNodeName , index ) ; + } + cdebug_out << "GraphBase::ComputingNode::ReNameLink" << endl ; +} + +#if 0 +const GraphBase::ListOfParameters * GraphBase::ComputingNode::GetListOfParameters() const { + GraphBase::ListOfParameters * aListOfParameters = new GraphBase::ListOfParameters ; + if ( IsInLineNode() || IsGOTONode() ) { + unsigned int i; + for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) { + const InPort * anInPort = GetNodeInPort( i ) ; + if ( anInPort->IsBus() ) { + int size = aListOfParameters->size() ; + aListOfParameters->resize( size + 1 ) ; + (*aListOfParameters)[size].theInParameter.Parametername = anInPort->PortName() ; + (*aListOfParameters)[size].theInParameter.Parametertype = anInPort->PortType() ; + const OutPort * anOutPort = GetNodeOutPort( anInPort->PortIndex() ) ; + (*aListOfParameters)[size].theOutParameter.Parametername = anOutPort->PortName() ; + (*aListOfParameters)[size].theOutParameter.Parametertype = anOutPort->PortType() ; + } + } + } + return aListOfParameters ; +} +#endif + +bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & info , + const char * ComponentName , + const char * InterfaceName , + const char * Computer , + const char * CoupledNode , + const ListOfFuncName FuncNames , + const ListOfPythonFunctions PythonFunctions , + int XCoordinate , int YCoordinate ) const { + QDomElement node = Graph.createElement( "node" ) ; + info.appendChild( node ) ; + QDomElement componentname = Graph.createElement( "component-name" ) ; + QDomText aField ; + if ( strlen( ComponentName ) ) { +// f << Tabs << "" << ComponentName << "" +// << endl ; +// componentname.setNodeValue( ComponentName ) ; + aField = Graph.createTextNode( ComponentName ) ; + } + else { +// f << Tabs << "?" << endl ; +// componentname.setNodeValue( "?" ) ; + aField = Graph.createTextNode( "?" ) ; + } + node.appendChild( componentname ) ; + componentname.appendChild( aField ) ; + + QDomElement interfacename = Graph.createElement("interface-name") ; + if ( strlen( InterfaceName ) ) { +// f << Tabs << "" << InterfaceName << "" +// << endl ; +// interfacename.setAttribute("name" , InterfaceName ) ; + aField = Graph.createTextNode( InterfaceName ) ; + } + else { +// f << Tabs << "?" << endl ; +// interfacename.setAttribute("name" , "?" ) ; + aField = Graph.createTextNode( "?" ) ; + } + node.appendChild(interfacename) ; + interfacename.appendChild( aField ) ; + +// f << Tabs << "" << Name() << "" << endl ; + QDomElement nodename = Graph.createElement("node-name") ; + aField = Graph.createTextNode( Name() ) ; + node.appendChild( nodename ) ; + nodename.appendChild( aField ) ; + +// f << Tabs << "" << (int ) Kind() << "" << endl ; + QDomElement kind = Graph.createElement( "kind" ) ; + QString aKind ; + aKind = aKind.setNum( Kind() ) ; + aField = Graph.createTextNode( aKind ) ; + node.appendChild( kind ) ; + kind.appendChild( aField ) ; + + QDomElement couplednode = Graph.createElement("coupled-node") ; + if ( IsGOTONode() || IsLoopNode() || IsEndLoopNode() || + IsSwitchNode() || IsEndSwitchNode() ) { +// f << Tabs << "" << CoupledNode << "" +// << endl ; + aField = Graph.createTextNode( CoupledNode ) ; + } + else { +// f << Tabs << "?" << endl ; + aField = Graph.createTextNode( "?" ) ; + } + node.appendChild(couplednode) ; + couplednode.appendChild( aField ) ; + +// f << Tabs << "" << endl ; + QDomElement service = Graph.createElement("service") ; + node.appendChild(service) ; + QDomElement servicename = Graph.createElement("service-name") ; + if ( strlen( ServiceName() ) ) { +// f << Tabs << " " << ServiceName() << "" << endl ; + aField = Graph.createTextNode( ServiceName() ) ; + } + else { +// f << Tabs << " ?" << endl ; + aField = Graph.createTextNode( "?" ) ; + } + service.appendChild(servicename) ; + servicename.appendChild( aField ) ; + +// f << Tabs << " " << endl ; + QDomElement inParameterlist = Graph.createElement("inParameter-list") ; + service.appendChild(inParameterlist) ; + unsigned int i; + for ( i = 0 ; i < ServiceInParameter().length() ; i++ ) { +// f << Tabs << " " << endl ; + QDomElement inParameter = Graph.createElement("inParameter") ; + inParameterlist.appendChild(inParameter) ; +// f << Tabs << " " +// << ServiceInParameter()[i].Parametertype << "" +// << endl ; + QDomElement inParametertype = Graph.createElement("inParameter-type") ; + // mpv: Linux 8.0 compiler compatibility +// aField = Graph.createTextNode( (char *)ServiceInParameter()[i].Parametertype ) ; + aField = Graph.createTextNode( strdup(ServiceInParameter()[i].Parametertype) ) ; + inParameter.appendChild(inParametertype) ; + inParametertype.appendChild( aField ) ; +// f << Tabs << " " +// << ServiceInParameter()[i].Parametername << "" +// << endl ; + QDomElement inParametername = Graph.createElement("inParameter-name") ; + // mpv: Linux 8.0 compiler compatibility +// aField = Graph.createTextNode( (char *) ServiceInParameter()[i].Parametername ) ; + aField = Graph.createTextNode( strdup(ServiceInParameter()[i].Parametername) ) ; + inParameter.appendChild(inParametername) ; + inParametername.appendChild( aField ) ; +// f << Tabs << " " << endl ; + } +// f << Tabs << " " << endl ; +// f << Tabs << " " << endl ; + QDomElement outParameterlist = Graph.createElement("outParameter-list") ; + service.appendChild(outParameterlist) ; + for ( i = 0 ; i < ServiceOutParameter().length() ; i++ ) { +// f << Tabs << " " << endl ; + QDomElement outParameter = Graph.createElement("outParameter") ; + outParameterlist.appendChild(outParameter) ; +// f << Tabs << " " +// << ServiceOutParameter()[i].Parametertype << "" +// << endl ; + QDomElement outParametertype = Graph.createElement("outParameter-type") ; + // mpv: Linux 8.0 compiler compatibility +// aField = Graph.createTextNode( (char *) ServiceOutParameter()[i].Parametertype ) ; + aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametertype) ) ; + outParameter.appendChild(outParametertype) ; + outParametertype.appendChild( aField ) ; +// f << Tabs << " " +// << ServiceOutParameter()[i].Parametername << "" +// << endl ; + QDomElement outParametername = Graph.createElement("outParameter-name") ; + // mpv: Linux 8.0 compiler compatibility +// aField = Graph.createTextNode( (char *) ServiceOutParameter()[i].Parametername ) ; + aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametername) ) ; + outParameter.appendChild(outParametername) ; + outParametername.appendChild( aField ) ; +// f << Tabs << " " << endl ; + } +// f << Tabs << " " << endl ; +// f << Tabs << "" << endl ; + +// f << Tabs << "" << endl ; + QDomElement Parameterlist = Graph.createElement("Parameter-list") ; + node.appendChild( Parameterlist ) ; +#if 0 + if ( IsInLineNode() || IsGOTONode() || + IsLoopNode() || IsEndLoopNode() || + IsSwitchNode() || IsEndSwitchNode() ) { + unsigned int i; + for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) { + const InPort * anInPort = GetNodeInPort( i ) ; + if ( anInPort->IsBus() ) { + f << Tabs << " " << endl ; + f << Tabs << " " + << anInPort->PortType() << "" + << endl ; + f << Tabs << " " + << anInPort->PortName() << "" + << endl ; + f << Tabs << " " << endl ; + const OutPort * anOutPort = GetNodeOutPort( anInPort->PortIndex() ) ; + f << Tabs << " " << endl ; + f << Tabs << " " + << anOutPort->PortType() << "" + << endl ; + f << Tabs << " " + << anOutPort->PortName() << "" + << endl ; + f << Tabs << " " << endl ; + } + } + } +#endif +// f << Tabs << "" << endl ; + +// f << Tabs << "" << endl ; + QDomElement PyFunctionlist = Graph.createElement("PyFunction-list") ; + node.appendChild( PyFunctionlist ) ; + for ( i = 0 ; i < PythonFunctions.size() ; i++ ) { +// f << Tabs << " " << endl ; + QDomElement PyFunction = Graph.createElement("PyFunction") ; + PyFunctionlist.appendChild( PyFunction ) ; + int j ; + for ( j = 0 ; j < (*PythonFunctions[i]).length() ; j++ ) { + if ( j == 0 ) { +// if ( i == 0 ) { +// f << Tabs << " " << FuncNames[i].c_str() +// << "" << endl ; + QDomElement FuncName = Graph.createElement("FuncName") ; + aField = Graph.createTextNode( FuncNames[i].c_str() ) ; + PyFunction.appendChild( FuncName ) ; + FuncName.appendChild( aField ) ; +// } +// else if ( i == 1 ) { +// f << Tabs << " " << FuncNames[i].c_str() +// << "" << endl ; +// } +// else if ( i == 2 ) { +// f << Tabs << " " << FuncNames[i].c_str() +// << "" << endl ; +// } + } +// f << Tabs << " " << (*PythonFunctions[i])[j] +// << "" << endl ; + QDomElement PyFunc = Graph.createElement("PyFunc") ; + QDomCDATASection aCDATA ; + // mpv: Linux 8.0 compiler compatibility +// char * aCDATAChar = (char *) (*PythonFunctions[i])[j] ; + char * aCDATAChar = strdup ((*PythonFunctions[i])[j]) ; + int i ; + for ( i = 0 ; i < strlen( aCDATAChar ) ; i++ ) { + if ( aCDATAChar[ i ] != ' ' ) { + break ; + } + } + if ( i == strlen( aCDATAChar ) ) { + aCDATA = Graph.createCDATASection( "?" ) ; + } + else { + aCDATA = Graph.createCDATASection( aCDATAChar ) ; + } + PyFunction.appendChild( PyFunc ) ; + PyFunc.appendChild( aCDATA ) ; + } +// f << Tabs << " " << endl ; + } +// f << Tabs << "" << endl ; + +// f << Tabs << "" << FirstCreation() << "" +// << endl ; + QDomElement creationdate = Graph.createElement("creation-date") ; + char fdate[30] ; + sprintf( fdate , "%d/%d/%d - %d:%d:%d" , FirstCreation().Day , FirstCreation().Month , FirstCreation().Year , FirstCreation().Hour , FirstCreation().Minute , FirstCreation().Second ) ; + aField = Graph.createTextNode( fdate ) ; + node.appendChild( creationdate ) ; + creationdate.appendChild( aField ) ; +// f << Tabs << "" << LastModification() +// << "" << endl ; + QDomElement lastmodificationdate = Graph.createElement("lastmodification-date") ; + char ldate[30] ; + sprintf( ldate , "%d/%d/%d - %d:%d:%d" , LastModification().Day , LastModification().Month , LastModification().Year , LastModification().Hour , LastModification().Minute , LastModification().Second ) ; + aField = Graph.createTextNode( ldate ) ; + node.appendChild( lastmodificationdate ) ; + lastmodificationdate.appendChild( aField ) ; +// f << Tabs << "" << EditorRelease() << "" +// << endl ; + QDomElement editorrelease = Graph.createElement("editor-release") ; + aField = Graph.createTextNode( EditorRelease() ) ; + node.appendChild( editorrelease ) ; + editorrelease.appendChild( aField ) ; + QDomElement author = Graph.createElement("author") ; + if ( strlen( Author() ) ) { +// f << Tabs << "" << Author() << "" << endl ; + aField = Graph.createTextNode( Author() ) ; + } + else { +// f << Tabs << "?" << endl ; + aField = Graph.createTextNode( "?" ) ; + } + node.appendChild( author ) ; + author.appendChild( aField ) ; + QDomElement container = Graph.createElement("container") ; + if ( IsFactoryNode() && strlen( Computer) ) { +// f << Tabs << "" << Computer << "" << endl ; + aField = Graph.createTextNode( Computer ) ; + } + else { +// f << Tabs << "?" << endl ; + aField = Graph.createTextNode( "?" ) ; + } + node.appendChild( container ) ; + container.appendChild( aField ) ; + QDomElement comment = Graph.createElement("comment") ; + if ( strlen( Comment() ) ) { +// f << Tabs << "" << Comment() << "" << endl ; + aField = Graph.createTextNode( Comment() ) ; + } + else { +// f << Tabs << "?" << endl ; + aField = Graph.createTextNode( "?" ) ; + } + node.appendChild( comment ) ; + comment.appendChild( aField ) ; +// f << Tabs << "" << XCoordinate << "" << endl ; + QDomElement xposition = Graph.createElement("x-position") ; + QString aXCoordinate ; + aXCoordinate = aKind.setNum( XCoordinate ) ; + aField = Graph.createTextNode( aXCoordinate ) ; + node.appendChild( xposition ) ; + xposition.appendChild( aField ) ; +// f << Tabs << "" << YCoordinate << "" << endl ; + QDomElement yposition = Graph.createElement("y-position") ; + QString aYCoordinate ; + aYCoordinate = aKind.setNum( YCoordinate ) ; + aField = Graph.createTextNode( aYCoordinate ) ; + node.appendChild( yposition ) ; + yposition.appendChild( aField ) ; + return true ; +} + +bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , + const char * ComponentName , + const char * InterfaceName , + const char * Computer , + const GraphBase::InLineNode * aCoupledNode , + const ListOfFuncName FuncNames , + const ListOfPythonFunctions PythonFunctions , + int XCoordinate , int YCoordinate ) const { + if ( IsDataFlowNode() ) { + f << Name() << " = Graph( '" << Name() << "' )" << endl ; + } + else if ( IsComputingNode() ) { + int i ; + f << Name() << "_ServiceinParameter = []" << endl ; + for ( i = 0 ; i < ServiceInParameter().length() ; i++ ) { + f << Name() << "_ServiceinParameter.append( SALOME_ModuleCatalog.ServicesParameter( '" + << ServiceInParameter()[i].Parametertype << "' , '" + << ServiceInParameter()[i].Parametername << "' ) )" << endl ; + } + f << Name() << "_ServiceoutParameter = []" << endl ; + for ( i = 0 ; i < ServiceOutParameter().length() ; i++ ) { + f << Name() << "_ServiceoutParameter.append( SALOME_ModuleCatalog.ServicesParameter( '" + << ServiceOutParameter()[i].Parametertype << "' , '" + << ServiceOutParameter()[i].Parametername << "' ) )" << endl ; + } + f << Name() << "_Service = SALOME_ModuleCatalog.Service( '" << ServiceName() + << "' , " << Name() << "_ServiceinParameter" << " , " + << Name() << "_ServiceoutParameter" << " , 0 )" << endl ; + f << Name() << " = " << aGraphName << ".CNode( " << Name() << "_Service" << " )" + << endl ; + } + else if ( IsFactoryNode() ) { + f << Name() << " = " << aGraphName << ".FNode( '" << ComponentName + << "' , '" << InterfaceName << "' , '" << ServiceName() << "' )" + << endl ; + } + else { + f << "Py" << Name() << " = []" << endl ; + int i ; + SUPERV::ListOfStrings aPyFunc ; + if ( PythonFunctions.size() ) { + aPyFunc = *PythonFunctions[0] ; + for ( i = 0 ; i < aPyFunc.length() ; i++ ) { + f << "Py" << Name() << ".append( '" << aPyFunc[i] << "' )" << endl ; + } + } + if ( IsInLineNode() ) { + f << Name() << " = " << aGraphName << ".INode( '" << FuncNames[0].c_str() << "' , Py" + << Name() << " )" << endl ; + } + else if ( IsGOTONode() ) { + if ( aCoupledNode ) { + f << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py" + << Name() << " , '" << aCoupledNode->Name() << "' )" << endl ; + } + else { + f << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py" + << Name() << " , '' )" << endl ; + } + } + else { +// char * EndName = NULL ; +// EndName = new char[ 3 + strlen( Name() ) + 1 ] ; +// strcpy( EndName , "End" ) ; +// strcat( EndName , Name() ) ; + char * EndName = aCoupledNode->Name() ; + if ( IsLoopNode() ) { + SUPERV::ListOfStrings aPyMore = *PythonFunctions[1] ; + SUPERV::ListOfStrings aPyNext = *PythonFunctions[2] ; + f << "PyMore" << Name() << " = []" << endl ; + for ( i = 0 ; i < aPyMore.length() ; i++ ) { + f << "PyMore" << Name() << ".append( '" << aPyMore[i] << "' )" << endl ; + } + f << "PyNext" << Name() << " = []" << endl ; + for ( i = 0 ; i < aPyNext.length() ; i++ ) { + f << "PyNext" << Name() << ".append( '" << aPyNext[i] << "' )" << endl ; + } + f << Name() << "," << EndName << " = " << aGraphName << ".LNode( '" + << FuncNames[0].c_str() << "' , Py" << Name() << " , '" + << FuncNames[1].c_str() << "' , PyMore" << Name() + << " , '" << FuncNames[2].c_str() << "' , PyNext" + << Name() << " )" << endl ; + f << EndName << ".SetName( '" << aCoupledNode->Name() << "' )" << endl ; + f << EndName << ".SetAuthor( '" << aCoupledNode->Author() << "' )" << endl ; + f << EndName << ".SetComment( '" << aCoupledNode->Comment() << "' )" << endl ; + f << EndName << ".Coords( " << aCoupledNode->XCoordinate() << " , " + << aCoupledNode->YCoordinate() << " )" << endl ; + } + else if ( IsSwitchNode() ) { + f << Name() << "," << EndName << " = " << aGraphName << ".SNode( '" + << FuncNames[0].c_str() << "' , Py" << Name() << " )" << endl ; + f << EndName << ".SetName( '" << aCoupledNode->Name() << "' )" << endl ; + f << EndName << ".SetAuthor( '" << aCoupledNode->Author() << "' )" << endl ; + f << EndName << ".SetComment( '" << aCoupledNode->Comment() << "' )" << endl ; + f << EndName << ".Coords( " << aCoupledNode->XCoordinate() << " , " + << aCoupledNode->YCoordinate() << " )" << endl ; + SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ; + f << "Py" << aCoupledNode->Name() << " = []" << endl ; + for ( i = 0 ; i < aPyFunc.length() ; i++ ) { + f << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )" + << endl ; + } + f << EndName << ".SetPyFunction( 'End" << FuncNames[0].c_str() << "' , Py" << aCoupledNode->Name() << " )" << endl ; + for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) { + const GraphBase::InPort * anInPort = aCoupledNode->GetNodeInPort(i) ; + if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) { + f << EndName << ".InPort( '" << anInPort->PortName() + << "' , '" << anInPort->PortType() << "' )" << endl ; + } + } + for ( i = 0 ; i < aCoupledNode->GetNodeOutPortsSize() ; i++ ) { + const GraphBase::OutPort * anOutPort = aCoupledNode->GetNodeOutPort(i) ; + if ( anOutPort->IsInLine() ) { + f << EndName << ".OutPort( '" << anOutPort->PortName() + << "' , '" << anOutPort->PortType() << "' )" << endl ; + } + } + } + delete [] EndName ; + } + for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) { + const GraphBase::InPort * anInPort = GetNodeInPort(i) ; + if ( anInPort->IsInLine() ) { + f << Name() << ".InPort( '" << anInPort->PortName() << "' , '" + << anInPort->PortType() << "' )" << endl ; + } + } + for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) { + const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ; + if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) { + f << Name() << ".OutPort( '" << anOutPort->PortName() + << "' , '" << anOutPort->PortType() << "' )" << endl ; + } + } + } + + f << Name() << ".SetName( '" << Name() << "' )" << endl ; + f << Name() << ".SetAuthor( '" << Author() << "' )" << endl ; + if ( IsFactoryNode() ) { + f << Name() << ".SetContainer( '" << Computer << "' )" << endl ; + } + f << Name() << ".SetComment( '" << Comment() << "' )" << endl ; + f << Name() << ".Coords( " << XCoordinate << " , " << YCoordinate << " )" << endl ; + +#if 0 + if ( IsLoopNode() || IsSwitchNode() ) { + f << EndName << ".SetName( '" << CoupledNode + << "' )" << endl ; + f << EndName << ".SetAuthor( '" << CoupledNode->Author() + << "' )" << endl ; + f << EndName << ".SetComment( '" << CoupledNode->Comment() + << "' )" << endl ; + f << EndName << ".Coords( " << CoupledNode->XCoordinate() << " , " + << CoupledNode->YCoordinate() << " )" << endl ; + unsigned int i; + for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) { + const InPort * anInPort = GetNodeInPort( i ) ; + if ( anInPort->IsBus() ) { + const OutPort * anOutPort = GetNodeOutPort( anInPort->PortIndex() ) ; + f << Name() << ".BusPorts( '" << anInPort->PortName() << "' , '" + << anInPort->PortType() << "' , '" << anOutPort->PortName() + << "' , '" << anOutPort->PortType() << "' )" << endl ; + } + } + } +#endif + return true ; +} + +void GraphBase::ComputingNode::NodeInfo(ostrstream & s) const { + int i ; + s << *this ; + ListPorts( s , true ) ; + s << ends ; +} + +ostream & operator<< (ostream & f,const GraphBase::ComputingNode & G) { +// f << "ComponentName " << G.ComponentName() << endl ; + if ( G.IsComputingNode() ) + f << "NodeName " << G.Name() << endl ; + else + f << "DataFlowName " << G.Name() << endl ; + f << "Kind " << G.Kind() << endl ; + f << "Service " << *G.GetService() ; + f << "FirstCreation " << G.FirstCreation () << endl ; + f << "LastModification " << G.LastModification() << endl ; + f << "EditorRelease " << G.EditorRelease() << endl ; + f << "Author " << G.Author() << endl ; +// f << "Computer " << G.Computer() << endl ; + f << "Comment " << G.Comment() << endl ; + f << endl ; + + return f; +} + +void GraphBase::ComputingNode::ListLinks(ostream &f ) const { + int i ; + for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) { + const GraphBase::OutPort* fromPort = GetNodeOutPort( i ) ; + if ( fromPort->IsPortConnected() ) { + int j ; + for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) { + if ( j == 0 ) + f << "FromNode " << Name() << endl ; + f << " FromServiceParameterName " + << fromPort->GetServicesParameter().Parametername ; + const GraphBase::InPort* toPort = fromPort->InPorts( j ) ; + f << " ToNode " << toPort->NodeName() ; + f << " ToServiceParameterName " + << toPort->GetServicesParameter().Parametername; + f << " Value " ; + fromPort->StringValue( f ) ; + f << endl ; + } + } + } +} + +ostream & operator<< (ostream &fOut,const SUPERV::SDate &D) { +// cdebug_in << "operator<< GraphEditor::Date" << endl; + + fOut << D.Day << "/" + << D.Month << "/" + << D.Year << " - " + << D.Hour << ":" + << D.Minute << ":" + << D.Second; + +// cdebug_out << "operator<< GraphEditor::Date" << endl; + return fOut; +} + diff --git a/src/GraphBase/DataFlowBase_ComputingNode.hxx b/src/GraphBase/DataFlowBase_ComputingNode.hxx new file mode 100644 index 0000000..9680028 --- /dev/null +++ b/src/GraphBase/DataFlowBase_ComputingNode.hxx @@ -0,0 +1,291 @@ +//============================================================================= +// File : DataFlowBase_ComputingNode.hxx +// Created : 2002 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#ifndef _DATAFLOWBASE_NODE_HXX +#define _DATAFLOWBASE_NODE_HXX + +#include "DataFlowBase_PortsOfNode.hxx" + +namespace GraphBase { + + class InLineNode ; + + class ComputingNode : public PortsOfNode { + + private: + + CORBA::ORB_ptr _ORB ; + SALOME_NamingService * _NamingService ; + int * _Graph_prof_debug ; + ostream * _Graph_fdebug ; + SUPERV::CNode_var _Node ; + void * _InNode ; // From GraphExecutor:: or GraphEditor:: + bool _ObjInterface ; + + pthread_t _ThreadNo ; + + char * _Name ; + SUPERV::KindOfNode _Kind ; + SUPERV::SDate _FirstCreation ; + SUPERV::SDate _LastModification ; + char * _EditorRelease ; + char * _Author ; + char * _Comment ; + + bool _HeadNode ; + int _LevelNumber ; + int _SubGraphNumber ; + bool _GeneratedName ; + + int _ConnectedInPortsNumber ; + int _DecrConnectedInPortsNumber ; + +// For generated NodeNames with ServiceName : number of Nodes using +// the same ServiceName. It is not the same Service if it belongs to +// a different Interface and/or a different Component ... + map< string , int > _MapOfServiceNames ; + +// Nodes with LinkedInPortsNumber InPort(s) linked to Outport(s) of this node : + map< string , int > _MapOfLinkedNodes ; + int _LinkedNodesSize ; + vector _LinkedNodes ; + vector _LinkedInPortsNumber ; + + protected: + + long _X ; + long _Y ; + + public: + + ComputingNode() ; + ComputingNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char * DataFlowName , + int * Graph_prof_debug = NULL , + ostream * Graph_fdebug = NULL ) ; + ComputingNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const SALOME_ModuleCatalog::Service& NodeService , + const char *NodeName , + const SUPERV::KindOfNode akind , + const SUPERV::SDate NodeFirstCreation , + const SUPERV::SDate NodeLastModification , + const char * NodeEditorRelease , + const char * NodeAuthor , + const char * NodeComment , + const bool GeneratedName , + const long X , + const long Y , + int * Graph_prof_debug = NULL , + ostream * Graph_fdebug = NULL ) ; + virtual ~ComputingNode() ; + + SALOME_NamingService * NamingService() const { + return _NamingService ; } ; + + SUPERV::CNode_var ObjRef() const { return _Node ; } ; + void SetObjRef(SUPERV::CNode_var aNode) { + _Node = aNode ; } ; + void InNode( void * anInNode ) { +// cdebug << "GraphBase::ComputingNode::InNode " << Name() << endl ; + _InNode = anInNode ; } ; + void * GetInNode() const { + return _InNode ; } ; + + void ObjInterface( bool k_interface ) { _ObjInterface = k_interface ; } ; + bool ObjInterface() { return _ObjInterface ; } ; + + pthread_t ThreadNo() { return _ThreadNo ; } ; + void ThreadNo( pthread_t aThread ) { _ThreadNo = aThread ; } ; + + char * Name() const { return my_strdup( _Name ) ; } ; + const char *const * NamePtr() const { return &_Name ; } ; + SUPERV::KindOfNode Kind() const { + return _Kind; } ; +// const SALOME_ModuleCatalog::Service * Service() const ; + SUPERV::SDate FirstCreation() const ; + SUPERV::SDate LastModification() const ; + char* Author() const { return my_strdup( _Author ) ; } ; + char* EditorRelease() const { return my_strdup( _EditorRelease ) ; } ; + char * Comment() const { return my_strdup( _Comment ) ; } ; + int XCoordinate() const { return _X ; } ; + int YCoordinate() const { return _Y ; } ; + + bool Name( const char * aName ) ; + bool Kind( SUPERV::KindOfNode aKind) ; +// void Service( const SALOME_ModuleCatalog::Service aService ) ; + void FirstCreation( const SUPERV::SDate aFirstCreation ) ; + void LastModification( const SUPERV::SDate aLastModification ) ; + bool Author( const char * anAuthor ) ; + bool EditorRelease( const char* anEditorRelease ) ; + bool Comment( const char *c ) ; + void Coordinates( const int X , const int Y ) { + _X = X ; _Y = Y ; } ; + + void NodePort( const char * NodeName , + const char * ServiceParameterName , + char ** aNode , char ** aPort ) ; + + bool IsLinked(const char * ToServiceParameterName ) ; + bool HasInput(const char * ToServiceParameterName ) ; + + GraphBase::SNode * GetInfo() ; + + const bool IsComputingNode() const { + return (_Kind == SUPERV::ComputingNode ) ; } ; + const bool IsFactoryNode() const { + return (_Kind == SUPERV::FactoryNode ) ; } ; + const bool IsOneOfGOTONodes() const { + return (_Kind == SUPERV::LoopNode || + _Kind == SUPERV::EndLoopNode || + _Kind == SUPERV::SwitchNode || + _Kind == SUPERV::EndSwitchNode || + _Kind == SUPERV::GOTONode ) ; } ; + const bool IsOneOfInLineNodes() const { + return (_Kind == SUPERV::InLineNode || IsOneOfGOTONodes() ) ; } ; + const bool IsInLineNode() const { + return (_Kind == SUPERV::InLineNode ) ; } ; + const bool IsDataFlowNode() const { + return (_Kind == SUPERV::DataFlowNode ) ; } ; + const bool IsLoopNode() const { + return (_Kind == SUPERV::LoopNode ) ; } ; + const bool IsEndLoopNode() const { + return (_Kind == SUPERV::EndLoopNode ) ; } ; + const bool IsSwitchNode() const { + return (_Kind == SUPERV::SwitchNode ) ; } ; + const bool IsEndSwitchNode() const { + return (_Kind == SUPERV::EndSwitchNode ) ; } ; + const bool IsGOTONode() const { + return (_Kind == SUPERV::GOTONode ) ; } ; + void HeadNode( bool aHeadNode ) { _HeadNode = aHeadNode ; } ; + const bool IsHeadNode() const { return _HeadNode ; } ; + + bool RemovePorts( const char* aNodeName ) ; + + InPort * AddInPort( const char * InputParameterName , + const char * InputParameterType ) ; + OutPort * AddOutPort( const char * OutputParameterName , + const char * OutputParameterType ) ; + + void AddLink( ComputingNode * aNode ) ; + void RemoveLink( ComputingNode * aNode ) ; + void ReNameLink( const char* OldNodeName , + const char* NewNodeName ) ; + + int GetServiceNameNumber( const char * name ) { + int num = _MapOfServiceNames[ name ] ; + if ( num == 0 ) { + _MapOfServiceNames[ name ] = 1 ; + } + else { + _MapOfServiceNames[ name ] = num + 1 ; + } + return _MapOfServiceNames[ name ] ; } ; + + void IncrConnectedInPortsNumber() { + cdebug << "IncrConnectedInPortsNumber " << Name() << " -> " + << _ConnectedInPortsNumber+1 << endl ; + _ConnectedInPortsNumber++ ; } ; + void DecrConnectedInPortsNumber() { + _ConnectedInPortsNumber-- ; } ; + int ConnectedInPortsNumber() const { + return _ConnectedInPortsNumber ; } ; + void ConnectedInPortsNumber( int c ) { + cdebug << "ConnectedInPortsNumber " << Name() << " -> " << c << endl ; + _ConnectedInPortsNumber = c ; } ; + + void IncrDecrConnectedInPortsNumber(const int cnt ) { + _DecrConnectedInPortsNumber += cnt ; } ; + bool DecrIncrDecrConnectedInPortsNumber() { + if ( _DecrConnectedInPortsNumber ) { + _ConnectedInPortsNumber = _ConnectedInPortsNumber - + _DecrConnectedInPortsNumber ; + _DecrConnectedInPortsNumber = 0 ; + return true ; + } + return false ; } ; + + int GetLinkedNodeIndex( const char * name ) { + int index = _MapOfLinkedNodes[ name ] -1 ; + if ( index >= 0 ) { + cdebug << "GetLinkedNodeIndex of " << name + << " in _MapOfLinkedNodes : " + << index << " Node " << hex << (void *) _LinkedNodes[ index ] + << dec << " '" << _LinkedNodes[ index ]->Name() << "'" + << endl ; + } + return index ; } ; + void SetLinkedNodeIndex( const char * name , const int index ) { + _MapOfLinkedNodes[ name ] = index +1 ; + cdebug << "SetLinkedNodeIndex of " << name << " in _MapOfLinkedNodes : " + << index << " Node " << hex << (void *) _LinkedNodes[ index ] + << dec << " '" << _LinkedNodes[ index ]->Name() << "'" + << " _MapOfLinkedNodes " << _MapOfLinkedNodes[ name ] - 1 + << endl ; + } ; + void DelLinkedNodeIndex( const char * name ) { + _MapOfLinkedNodes.erase( name ) ; } ; + int LinkedNodesSize() const { return _LinkedNodesSize ; } ; + ComputingNode * LinkedNodes( int i ) const { return _LinkedNodes[ i ] ; } ; + const int LinkedInPortsNumber( int i ) const { return _LinkedInPortsNumber[ i ] ; } ; + + int Level() { return _LevelNumber ; } ; + void Level( int LevelNumber ) { + _LevelNumber = LevelNumber ; } ; + int SubGraph() { return _SubGraphNumber ; } ; + void SubGraph( int SubGraphNumber ) { + _SubGraphNumber = SubGraphNumber ; } ; + +// const GraphBase::ListOfParameters * GetListOfParameters() const ; + + bool SaveXML( QDomDocument & Graph , QDomElement & info , + int X , int Y ) const { + ListOfFuncName aFuncNames ; + GraphBase::ListOfPythonFunctions aVoidList ; + return SaveXML( Graph , info , "" , "" , "" , "" , aFuncNames , aVoidList , + X , Y ) ; } ; + + bool SavePY( ostream &f , const char * aGraphName , + int X , int Y ) const { + ListOfFuncName aFuncNames ; + GraphBase::ListOfPythonFunctions aVoidList ; + return SavePY( f , aGraphName , "" , "" , "" , NULL , aFuncNames , aVoidList , + X , Y ) ; } ; +// bool SaveXML(ostream &f , char *Tabs , + bool SaveXML(QDomDocument & Graph , QDomElement & info , + const char * ComponentName , + const char * InterfaceName , + const char * Computer , + const char * CoupledNode , + const ListOfFuncName FuncNames , + const GraphBase::ListOfPythonFunctions PythonFunctions , + int X , int Y ) const ; + + bool SavePY(ostream &f , const char * aGraphName , + const char * ComponentName , + const char * InterfaceName , + const char * Computer , + const GraphBase::InLineNode * aCoupledNode , + const ListOfFuncName FuncNames , + const GraphBase::ListOfPythonFunctions PythonFunctions , + int X , int Y ) const ; + + void NodeInfo(ostrstream & s) const ; + + void ListLinks(ostream &f ) const ; + + }; + +}; + +ostream & operator<< (ostream &,const GraphBase::ComputingNode & N ); + +ostream & operator<< (ostream &,const SUPERV::SDate & D ); + +#endif diff --git a/src/GraphBase/DataFlowBase_DataNode.cxx b/src/GraphBase/DataFlowBase_DataNode.cxx new file mode 100644 index 0000000..fa17d1a --- /dev/null +++ b/src/GraphBase/DataFlowBase_DataNode.cxx @@ -0,0 +1,143 @@ +using namespace std; +//============================================================================= +// File : DataFlowBase_DataNode.cxx +// Created : 2002 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#include "DataFlowBase_DataNode.hxx" + +GraphBase::DataNode::DataNode() : + InLineNode() { + MESSAGE( "GraphBase::DataNode::DataNode" ); + _Created = false ; +} + +GraphBase::DataNode::DataNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char *DataFlowName ) : + InLineNode( ORB , ptrNamingService , DataFlowName ) { + MESSAGE( "GraphBase::DataNode::DataNode" ); + _Created = false ; +} + +GraphBase::DataNode::DataNode( + CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const SALOME_ModuleCatalog::Service& DataFlowService , + const char *DataFlowName , + const SUPERV::KindOfNode DataFlowkind , + const SUPERV::SDate DataFlowFirstCreation , + const SUPERV::SDate DataFlowLastModification , + const char * DataFlowEditorRelease , + const char * DataFlowAuthor , + const char * DataFlowComment ) : + InLineNode( ORB , ptrNamingService , DataFlowService , + DataFlowName , DataFlowkind , + DataFlowFirstCreation , DataFlowLastModification , + DataFlowEditorRelease , DataFlowAuthor , + DataFlowComment , false , 0 , 0) { +// MESSAGE( "GraphBase::DataNode::DataNode" ); +} + +GraphBase::DataNode::~DataNode() { +// MESSAGE( "GraphBase::DataNode::~DataNode" ); +} + +void GraphBase::DataNode::DataService( + CORBA::ORB_ptr ORB , + SALOME_ModuleCatalog::Service aService , + int * Graph_prof_debug , + ostream * Graph_fdebug ) { +// cout << "GraphBase::DataNode::DataService : DataFlowPortsOfNode of " +// << aService.ServiceName << endl ; +// DefPortsOfNode( aService , aService.ServiceName ) ; + DefPortsOfNode( ORB , aService , NamePtr() , Kind() , true , false , false , false , + Graph_prof_debug , Graph_fdebug ) ; + + if ( _Created ) + delete _DataFlowDataPorts ; + SALOME_ModuleCatalog::Service aReversedService ; + aReversedService.ServiceName = aService.ServiceName ; + aReversedService.ServiceinParameter = aService.ServiceoutParameter ; + aReversedService.ServiceoutParameter = aService.ServiceinParameter ; + _DataFlowDataPorts = new PortsOfNode() ; +// cout << "GraphBase::DataNode::DataService : Mirrored DataFlowPortsOfNode of " +// << aReversedService.ServiceName << endl ; + _DataFlowDataPorts->DefPortsOfNode( ORB , aReversedService , NamePtr() , + Kind() , true , false , false , false , + Graph_prof_debug , Graph_fdebug ) ; +// aReversedService.ServiceName ) ; + _Created = true ; +} + +int GraphBase::DataNode::CheckDataServerNodes() const { + + cdebug << "GraphBase::Graph::DataServerNodes ()" << endl; + + int i , ierr = 0 ; + + for ( i = 0 ; i < _DataFlowDataPorts->GetNodeOutPortsSize() ; i++ ) { + if ( !_DataFlowDataPorts->GetNodeOutPort(i)->IsDataConnected() ) { + cdebug << "InPort " << _DataFlowDataPorts->GetNodeOutPort(i)->PortName() + << " of DataFlow " << Name() << " has NO Data." << endl ; + ierr++ ; + } + else { + cdebug << "InPort " << _DataFlowDataPorts->GetNodeOutPort(i)->PortName() + << " of DataFlow " << Name() << " has Data : " +// << _DataFlowDataPorts->GetNodeOutPort(i)->Value() << " kind " +// << _DataFlowDataPorts->GetNodeOutPort(i)->Kind() + << endl ; + } + } + + for ( i = 0 ; i < _DataFlowDataPorts->GetNodeInPortsSize() ; i++ ) { + if ( !_DataFlowDataPorts->GetNodeInPort(i)->IsConnected() ) { + cdebug << "OutPort " << _DataFlowDataPorts->GetNodeInPort(i)->PortName() + << " of DataFlow " << Name() << " has Data " << endl ; +// ierr++ ; + } + else { + cdebug << "OutPort " << _DataFlowDataPorts->GetNodeInPort(i)->PortName() + << " of DataFlow " << Name() << " has NO Data : " +// << _DataFlowDataPorts->GetChangeNodeInPort(i)->GetLink()->Value() +// << " kind " +// << _DataFlowDataPorts->GetChangeNodeInPort(i)->GetLink()->Kind() + << endl ; + ierr++ ; + } + } + + if ( ierr ) { + cdebug << "Some Input Data missing in the DataFlow " << Name() << endl ; + } + + return ierr ; +} + +void GraphBase::DataNode::ListDatas(ostrstream & f ) const { + _DataFlowDataPorts->ListPorts( f , false ) ; +} + +void GraphBase::DataNode::DataNodeInfo(ostrstream & s ) const { + int i ; + s << *this ; + s << "Ports :" << endl ; + ListPorts( s , true ) ; + s << "Datas :" << endl ; + _DataFlowDataPorts->ListPorts( s , false ) ; + s << ends ; +} + +// inlined : +//GraphBase::OutPort * GraphBase::DataNode::GetChangeInDataNodePort( const char * DataFlowInPortName ) { +// return _DataFlowDataPorts->GetChangeOutPort( DataFlowInPortName ) ; +//} + +//GraphBase::InPort * GraphBase::DataNode::GetChangeOutDataNodePort( const char * DataFlowOutPortName ) { +// return _DataFlowDataPorts->GetChangeInPort( DataFlowOutPortName ) ; +//} + diff --git a/src/GraphBase/DataFlowBase_DataNode.hxx b/src/GraphBase/DataFlowBase_DataNode.hxx new file mode 100644 index 0000000..10509ef --- /dev/null +++ b/src/GraphBase/DataFlowBase_DataNode.hxx @@ -0,0 +1,94 @@ +//============================================================================= +// File : DataFlowBase_DataNode.hxx +// Created : 2002 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#ifndef _DATAFLOWBASE_DATANODE_HXX +#define _DATAFLOWBASE_DATANODE_HXX + +#include "DataFlowBase_InLineNode.hxx" + +namespace GraphBase { + + class DataNode : public InLineNode { + + private: + + GraphBase::PortsOfNode * _DataFlowDataPorts ; + bool _Created ; + + public: + + DataNode() ; + DataNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char *DataFlowName ) ; + DataNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const SALOME_ModuleCatalog::Service& DataFlowService , + const char *DataFlowName , + const SUPERV::KindOfNode DataFlowkind , + const SUPERV::SDate DataFlowFirstCreation , + const SUPERV::SDate DataFlowLastModification , + const char * DataFlowEditorRelease , + const char * DataFlowAuthor , + const char * DataFlowComment ) ; + virtual ~DataNode() ; + + void DataService( CORBA::ORB_ptr ORB , + const SALOME_ModuleCatalog::Service aService , + int * Graph_prof_debug , + ostream * Graph_fdebug ) ; + + int CheckDataServerNodes() const ; + +// Mirrored methods of _DataFlowDataPorts of DataNode : +// GetIn... gives the Out which is the input of InPort of the DataFlow +// GetOut... gives the In which gets the output of OutPort of the DataFlow + const int GetNodeInDataNodePortsSize() const { + return _DataFlowDataPorts->GetNodeOutPortsSize() ; } ; + const OutPort *GetNodeInDataNodePort(int i) const { + return _DataFlowDataPorts->GetNodeOutPort( i ) ; } ; + OutPort *GetChangeNodeInDataNodePort(int i) const { + return _DataFlowDataPorts->GetChangeNodeOutPort( i ) ; } ; + const int GetNodeOutDataNodePortsSize() const { + return _DataFlowDataPorts->GetNodeInPortsSize() ; } ; + const InPort *GetNodeOutDataNodePort(int i) const { + return _DataFlowDataPorts->GetNodeInPort( i ) ; } ; + InPort *GetChangeNodeOutDataNodePort(int i) const { + return _DataFlowDataPorts->GetChangeNodeInPort( i ) ; } ; + + OutPort * GetChangeInDataNodePort( const char * DataFlowInPortName ) { + return _DataFlowDataPorts->GetChangeOutPort( DataFlowInPortName ) ; } ; + InPort * GetChangeOutDataNodePort( const char * DataFlowOutPortName ) { + return _DataFlowDataPorts->GetChangeInPort( DataFlowOutPortName ) ; } ; + + void DataNodeInfo(ostrstream & s ) const ; + + void ListDatas(ostrstream & f) const ; + +// bool SaveXML( ostream &f , char *Tabs , + bool SaveXML( QDomDocument & Graph , QDomElement & info , + int X , int Y ) const { + GraphBase::ListOfFuncName aFuncNames ; + aFuncNames.resize( 0 ) ; + GraphBase::ListOfPythonFunctions aVoidList ; +// return GraphBase::ComputingNode::SaveXML( f , Tabs , "" , "" , "" , "" , + return GraphBase::ComputingNode::SaveXML( Graph , info , "" , "" , "" , "" , + aFuncNames , aVoidList , X , Y ) ; } ; + + bool SavePY( ostream &f , const char * aGraphName , + int X , int Y ) const { + GraphBase::ListOfFuncName aFuncNames ; + aFuncNames.resize( 0 ) ; + GraphBase::ListOfPythonFunctions aVoidList ; + return GraphBase::ComputingNode::SavePY( f , aGraphName , "" , "" , "" , NULL , + aFuncNames , aVoidList , X , Y ) ; } ; + } ; + +} ; + +#endif diff --git a/src/GraphBase/DataFlowBase_DataPort.cxx b/src/GraphBase/DataFlowBase_DataPort.cxx new file mode 100644 index 0000000..13ab608 --- /dev/null +++ b/src/GraphBase/DataFlowBase_DataPort.cxx @@ -0,0 +1,241 @@ +using namespace std; +//============================================================================= +// File : DataFlowBase_DataPort.cxx +// Created : 2002 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#include "DataFlowBase_DataPort.hxx" + +GraphBase::DataPort::DataPort( + const char *const * NodeName , + const SALOME_ModuleCatalog::ServicesParameter aserviceParameter ) : + Port( NodeName , aserviceParameter ) { + InitialValues( CORBA::Any() ) ; +} + +GraphBase::DataPort::~DataPort() { +} + +void GraphBase::DataPort::InitialValues(CORBA::Any aValue ) { + _theValue = new CORBA::Any( aValue ) ; + string _Type = CORBA::string_dup(GetServicesParameter().Parametertype) ; + const char * Type = _Type.c_str(); + CORBA::Any InitialValue ; + cdebug << "InitialValues " << NodeName() << " " << PortName() << " " << PortType() + << " : " ; + if ( !strcmp( Type , "string" ) ) { + cdebug << "string" << endl ; + InitialValue <<= (char *) NULL ; + } + else if ( !strcmp( Type , "double" ) ) { + cdebug << "double" << endl ; + InitialValue <<= 0. ; + } + else if ( !strcmp( Type , "long" ) ) { + cdebug << "long" << endl ; + InitialValue <<= (long ) 0 ; + } + else if ( !strcmp( Type , "objref" ) ) { + cdebug << "objref" << endl ; + InitialValue.replace(CORBA::_tc_Object, NULL); + } + else { + cdebug << "InitialValues ERROR (other) " << Type << endl ; + InitialValue <<= (long ) 0 ; + } + _InitialValue = new CORBA::Any( InitialValue ) ; + _Value = &_InitialValue ; +} + +void GraphBase::DataPort::Value( const CORBA::Any & aDataValue ) { + Value( new CORBA::Any( aDataValue ) ) ; +} + +void GraphBase::DataPort::Value( const CORBA::Any * aDataValue ) { + delete _theValue ; + _theValue = aDataValue ; + *_Value = aDataValue ; +// Done( true ) ; + +//#if 0 + cdebug << "NewValue " << NodeName() << " " << PortName() << " " << PortType() + << " : " << _Value << " *_Value " << *_Value << " " ; + switch (_theValue->type()->kind()) { + case CORBA::tk_string: { + char * t; + *_theValue >>= t; + cdebug << "Value( " << t << ") (string)"; + break; + } + case CORBA::tk_double: { + double d; + *_theValue >>= d; + cdebug << "Value( " << d << ") (double)"; + break; + } + case CORBA::tk_long: { + long l; + *_theValue >>= l; + cdebug << "Value( " << l << ") (long)"; + break; + } + case CORBA::tk_objref: { + cdebug << "Value( " << ") (object reference)"; + break; + } + default: { + cdebug << "Value" << " (other(tk_string,tk_double,tk_long,tk_objref)) ERROR"; + break; + } + } + cdebug << endl; +//#endif + +} + +void GraphBase::DataPort::Value( const CORBA::Any ** aDataSharedValue ) { + delete _theValue ; + _theValue = *aDataSharedValue ; + _Value = aDataSharedValue ; +// Done( true ) ; + +#if 0 + MESSAGE( NodePortName() << " : " << hex << _Value << " " ); + switch (_theValue->type()->kind()) { + case CORBA::tk_string: + char * t; + *_theValue >>= t; + MESSAGE( "Value( " << t << ") (string)"); + break; + case CORBA::tk_double: + double d; + *_theValue >>= d; + MESSAGE( "Value( " << d << ") (double)"); + break; + case CORBA::tk_long: + long l; + *_theValue >>= l; + MESSAGE( "Value( " << l << ") (long)"); + break; + case CORBA::tk_objref: + MESSAGE( "Value( " << ") (object reference)"); + break; + default: + MESSAGE( "Value" << " (other(tk_string,tk_double,tk_long,tk_objref)) ERROR"); + break; + } + MESSAGE(); +#endif +} + +CORBA::Any const * GraphBase::DataPort::Value() const { + const CORBA::Any *const Value = *_Value ; + CORBA::Any * theValue ; + cdebug << "Value " << NodeName() << " " << PortName() << " " << PortType() + << " _Value " << _Value << " *_Value " << *_Value << " " ; + if ( Done() ) { + theValue = new CORBA::Any( *Value ) ; + switch (theValue->type()->kind()) { + case CORBA::tk_string: { + char * t; + *theValue >>= t; + cdebug << "GraphBase::DataPort::Value() : " << t << " (string) " << endl; + break; + } + case CORBA::tk_double: { + double d; + *theValue >>= d; + cdebug << "GraphBase::DataPort::Value() : " << d << " (double) " << endl; + break; + } + case CORBA::tk_long: { + long l; + *theValue >>= l; + cdebug << "GraphBase::DataPort::Value() : " << l << " (long) " << endl; + break; + } + case CORBA::tk_objref: { + CORBA::Object_ptr obj ; + char * retstr ; + try { + *theValue >>= obj ; + retstr = ObjectToString( obj ); + cdebug << "GraphBase::DataPort::Value() : " << retstr + << "(object reference) " << endl; + } + catch( ... ) { + cdebug << "ToString( object ) Catched ERROR" << endl ; + } + break; + } + default: { + cdebug << "GraphBase::DataPort::Value() : " + << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR" << endl; + break; + } + } + } + else { + cdebug << "GraphBase::DataPort::InitialValue() " << endl; + theValue = new CORBA::Any( *Value ) ; + } + + return theValue ; +} + +bool GraphBase::DataPort::BoolValue() const { + bool RetVal = false ; + long val ; + if ( (*_Value)->type()->kind() == CORBA::tk_long ) { + **_Value >>= val ; + if ( val ) { + RetVal = true ; + } + } + return RetVal ; +} + +const CORBA::Any ** GraphBase::DataPort::ValuePtr() const { + return _Value ; +} + +void GraphBase::DataPort::StringValue(ostream & f ) const { + if ( Done() ) { + cdebug << "StringValue " << NodeName() << " " << PortName() << " " << PortType() + << " _Value " << _Value << " *_Value " + << *_Value << " " << endl ; + const CORBA::Any * theValue = *_Value ; + switch (theValue->type()->kind()) { + case CORBA::tk_string: + char * t; + *theValue >>= t; + f << t << " (string)" ; + break; + case CORBA::tk_double: + double d; + *theValue >>= d; + f << d << " (double)" ; + break; + case CORBA::tk_long: + long l; + *theValue >>= l; + f << l << " (long)" ; + break; + case CORBA::tk_objref: + f << "(object reference)" ; + break; + default: + f << "(other ERROR)" ; + break; + } + } + else { + f << "Default(undefined)" ; + } + +} + + diff --git a/src/GraphBase/DataFlowBase_DataPort.hxx b/src/GraphBase/DataFlowBase_DataPort.hxx new file mode 100644 index 0000000..a5f57fc --- /dev/null +++ b/src/GraphBase/DataFlowBase_DataPort.hxx @@ -0,0 +1,53 @@ +//============================================================================= +// File : DataFlowBase_DataPort.hxx +// Created : 2002 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#ifndef _DATAFLOWBASE_DATAPORT_HXX +#define _DATAFLOWBASE_DATAPORT_HXX + +#include "DataFlowBase_Port.hxx" + +namespace GraphBase { + + class DataPort : public Port { + + CORBA::Any const * _InitialValue ; + CORBA::Any const * _theValue ; + CORBA::Any const * * _Value ; + SUPERV::GraphState _State ; + bool _Done ; + + public : + + DataPort( const char *const * NodeName , + const SALOME_ModuleCatalog::ServicesParameter aserviceParameter ) ; + virtual ~DataPort() ; + + void InitialValues(CORBA::Any aValue ) ; + void Value (const CORBA::Any & aValue ) ; + void Value( const CORBA::Any * aValue ) ; + void Value( const CORBA::Any ** aValue ) ; + CORBA::Any const * Value() const ; + bool BoolValue() const ; + const CORBA::Any ** ValuePtr() const ; + + void State( SUPERV::GraphState aState ) { + _State = aState ; } ; + SUPERV::GraphState State() { return _State ; } ; + + void Done( bool aDone ) { +// cdebug << "ChgDone(.) " << NodeName() << " " << PortName() << " " +// << _Done << " -> " << aDone << endl ; + _Done = aDone ; } ; + const bool Done() const { return ( _Done ) ; } ; + + void StringValue(ostream & f) const ; + + } ; + +} ; +#endif diff --git a/src/GraphBase/DataFlowBase_EndOfLoopNode.cxx b/src/GraphBase/DataFlowBase_EndOfLoopNode.cxx new file mode 100644 index 0000000..f1931ff --- /dev/null +++ b/src/GraphBase/DataFlowBase_EndOfLoopNode.cxx @@ -0,0 +1,73 @@ +using namespace std; +//============================================================================= +// File : DataFlowBase_EndOfLoopNode.cxx +// Created : 2003 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#include +#include + +#include "DataFlowBase_EndOfLoopNode.hxx" + +GraphBase::EndOfLoopNode::EndOfLoopNode() : + GraphBase::GOTONode::GOTONode() { + + cdebug << "GraphBase::EndOfLoopNode::EndOfLoopNode " << this + << " _Name " << (void *) Name() << " " << Name() << " _Comment " + << (void *) Comment() << " " << Comment() << " " << endl ; + +} + +GraphBase::EndOfLoopNode::EndOfLoopNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char * FuncName , + const SUPERV::ListOfStrings & anInitPythonFunction , + const char *NodeName , + const SUPERV::KindOfNode akind , + const SUPERV::SDate NodeFirstCreation , + const SUPERV::SDate NodeLastModification , + const char * NodeEditorRelease , + const char * NodeAuthor , + const char * NodeComment , + const bool GeneratedName , + const long X , + const long Y , + int * Graph_prof_debug , + ostream * Graph_fdebug ) : + GraphBase::GOTONode::GOTONode( ORB , ptrNamingService , FuncName , + anInitPythonFunction , + NodeName , akind , NodeFirstCreation , + NodeLastModification , NodeEditorRelease , + NodeAuthor , NodeComment , GeneratedName , + X , Y , Graph_prof_debug , Graph_fdebug ) { + + cdebug_in << "GraphBase::EndOfLoopNode::EndOfLoopNode " << this + << "' _Name " << (void *) Name() << " '" << Name() << " _Comment " + << (void *) Comment() << " " << Comment() << " " + << " KindOfNode " << Kind() << " FuncName " << FuncName + << " ServiceName " << ServiceName() << " In(" + << ServiceInParameter().length() + << ") Out(" << ServiceOutParameter().length() << ")" << endl ; + + cdebug_out << "GraphBase::EndOfLoopNode::EndOfLoopNode" << endl; +} + +GraphBase::EndOfLoopNode::~EndOfLoopNode() { + cdebug << "GraphBase::Node::~Node " << this + << " _Name " << (void *) Name() << " " << Name() << " _Comment " + << (void *) Comment() << " " << Comment() << " " << endl ; +// if ( _ComponentName != NULLSTRING ) +// delete [] _ComponentName ; +// delete [] _Name ; +// delete [] _EditorRelease ; +// if ( _Author != NULLSTRING ) +// delete [] _Author ; +// if ( _Computer != FACTORYSERVER ) +// delete [] _Computer; +// if ( Comment() != NULLSTRING ) +// delete [] Comment(); +} + diff --git a/src/GraphBase/DataFlowBase_EndOfLoopNode.hxx b/src/GraphBase/DataFlowBase_EndOfLoopNode.hxx new file mode 100644 index 0000000..ac01c2e --- /dev/null +++ b/src/GraphBase/DataFlowBase_EndOfLoopNode.hxx @@ -0,0 +1,45 @@ +//============================================================================= +// File : DataFlowBase_EndOfLoopNode.hxx +// Created : 2003 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#ifndef _DATAFLOWBASE_ENDOFLOOPNODE_HXX +#define _DATAFLOWBASE_ENDOFLOOPNODE_HXX + +#include "DataFlowBase_GOTONode.hxx" + +namespace GraphBase { + + class EndOfLoopNode : public GOTONode { + + private: + + public: + + EndOfLoopNode() ; + EndOfLoopNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char * FuncName , + const SUPERV::ListOfStrings & , + const char *NodeName , + const SUPERV::KindOfNode akind , + const SUPERV::SDate NodeFirstCreation , + const SUPERV::SDate NodeLastModification , + const char * NodeEditorRelease , + const char * NodeAuthor , + const char * NodeComment , + const bool GeneratedName , + const long X , + const long Y , + int * Graph_prof_debug = NULL , + ostream * Graph_fdebug = NULL ) ; + virtual ~EndOfLoopNode() ; + + }; + +}; + +#endif diff --git a/src/GraphBase/DataFlowBase_EndOfSwitchNode.cxx b/src/GraphBase/DataFlowBase_EndOfSwitchNode.cxx new file mode 100644 index 0000000..266c91c --- /dev/null +++ b/src/GraphBase/DataFlowBase_EndOfSwitchNode.cxx @@ -0,0 +1,73 @@ +using namespace std; +//============================================================================= +// File : DataFlowBase_EndOfSwitchNode.cxx +// Created : 2003 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#include +#include + +#include "DataFlowBase_EndOfSwitchNode.hxx" + +GraphBase::EndOfSwitchNode::EndOfSwitchNode() : + GraphBase::GOTONode::GOTONode() { + + cdebug << "GraphBase::EndOfSwitchNode::EndOfSwitchNode " << this + << " _Name " << (void *) Name() << " " << Name() << " _Comment " + << (void *) Comment() << " " << Comment() << " " << endl ; + +} + +GraphBase::EndOfSwitchNode::EndOfSwitchNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char * FuncName , + const SUPERV::ListOfStrings & aPythonFunction , + const char *NodeName , + const SUPERV::KindOfNode akind , + const SUPERV::SDate NodeFirstCreation , + const SUPERV::SDate NodeLastModification , + const char * NodeEditorRelease , + const char * NodeAuthor , + const char * NodeComment , + const bool GeneratedName , + const long X , + const long Y , + int * Graph_prof_debug , + ostream * Graph_fdebug ) : + GraphBase::GOTONode::GOTONode( ORB , ptrNamingService , FuncName , + aPythonFunction , + NodeName , akind , NodeFirstCreation , + NodeLastModification , NodeEditorRelease , + NodeAuthor , NodeComment , GeneratedName , + X , Y , Graph_prof_debug , Graph_fdebug ) { + + cdebug_in << "GraphBase::EndOfSwitchNode::EndOfSwitchNode " << this + << "' _Name " << (void *) Name() << " '" << Name() << " _Comment " + << (void *) Comment() << " " << Comment() << " " + << " KindOfNode " << Kind() << " FuncName " << FuncName + << " ServiceName " << ServiceName() << " In(" + << ServiceInParameter().length() + << ") Out(" << ServiceOutParameter().length() << ")" << endl ; + + cdebug_out << "GraphBase::EndOfSwitchNode::EndOfSwitchNode" << endl; +} + +GraphBase::EndOfSwitchNode::~EndOfSwitchNode() { + cdebug << "GraphBase::EndOfSwitchNode::~EndOfSwitchNode " << this + << " _Name " << (void *) Name() << " " << Name() << " _Comment " + << (void *) Comment() << " " << Comment() << " " << endl ; +// if ( _ComponentName != NULLSTRING ) +// delete [] _ComponentName ; +// delete [] _Name ; +// delete [] _EditorRelease ; +// if ( _Author != NULLSTRING ) +// delete [] _Author ; +// if ( _Computer != FACTORYSERVER ) +// delete [] _Computer; +// if ( _Comment != NULLSTRING ) +// delete [] _Comment; +} + diff --git a/src/GraphBase/DataFlowBase_EndOfSwitchNode.hxx b/src/GraphBase/DataFlowBase_EndOfSwitchNode.hxx new file mode 100644 index 0000000..9ac1195 --- /dev/null +++ b/src/GraphBase/DataFlowBase_EndOfSwitchNode.hxx @@ -0,0 +1,45 @@ +//============================================================================= +// File : DataFlowBase_EndOfSwitchNode.hxx +// Created : 2003 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#ifndef _DATAFLOWBASE_ENDOFSWITCHNODE_HXX +#define _DATAFLOWBASE_ENDOFSWITCHNODE_HXX + +#include "DataFlowBase_GOTONode.hxx" + +namespace GraphBase { + + class EndOfSwitchNode : public GOTONode { + + private: + + public: + + EndOfSwitchNode() ; + EndOfSwitchNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char * FuncName , + const SUPERV::ListOfStrings & aPythonFunction , + const char *NodeName , + const SUPERV::KindOfNode akind , + const SUPERV::SDate NodeFirstCreation , + const SUPERV::SDate NodeLastModification , + const char * NodeEditorRelease , + const char * NodeAuthor , + const char * NodeComment , + const bool GeneratedName , + const long X , + const long Y , + int * Graph_prof_debug = NULL , + ostream * Graph_fdebug = NULL ) ; + virtual ~EndOfSwitchNode() ; + + }; + +}; + +#endif diff --git a/src/GraphBase/DataFlowBase_FactoryNode.cxx b/src/GraphBase/DataFlowBase_FactoryNode.cxx new file mode 100644 index 0000000..4dc6b87 --- /dev/null +++ b/src/GraphBase/DataFlowBase_FactoryNode.cxx @@ -0,0 +1,194 @@ +using namespace std; +//============================================================================= +// File : DataFlowBase_FactoryNode.cxx +// Created : 2003 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#include +#include + +#include "DataFlowBase_FactoryNode.hxx" + +static void InitFields( char * &_ComponentName , + char * &_InterfaceName , + char * &_Computer ) { + time_t T = time(NULL); + struct tm * Tm = localtime(&T); + + _ComponentName = NULLSTRING ; + _InterfaceName = NULLSTRING ; + + _Computer = FACTORYSERVER ; +} + +GraphBase::FactoryNode::FactoryNode() : + GraphBase::ComputingNode::ComputingNode() { + + InitFields( _ComponentName , + _InterfaceName , + _Computer ) ; + _Container = Engines::Container::_nil() ; + _ObjComponent = Engines::Component::_nil() ; + cdebug << "GraphBase::FactoryNode::FactoryNode " << this + << " _ComponentName " + << (void *) _ComponentName << " " << _ComponentName << " _Name " + << (void *) Name() << " " << Name() << " _Computer " + << (void *) _Computer << " " << _Computer << " _Comment " + << (void *) Comment() << " " << Comment() << " " << endl ; + +} + +GraphBase::FactoryNode::FactoryNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char * aDataFlowName , + int * Graph_prof_debug , + ostream * Graph_fdebug ) : + GraphBase::ComputingNode::ComputingNode( ORB , ptrNamingService , aDataFlowName , + Graph_prof_debug , Graph_fdebug ) { + + InitFields( _ComponentName , + _InterfaceName , + _Computer ) ; + + _Container = Engines::Container::_nil() ; + _ObjComponent = Engines::Component::_nil() ; + + cdebug << "GraphBase::FactoryNode::FactoryNode " << this + << " _ComponentName " + << (void *) _ComponentName << " '" << _ComponentName + << "' _InterfaceName " + << (void *) _InterfaceName << " '" << _InterfaceName << "' _Name " + << (void *) Name() << " '" << Name() << "' _Computer " + << (void *) _Computer << " " << _Computer << " _Comment " + << (void *) Comment() << " " << Comment() << " " << endl ; +} + +GraphBase::FactoryNode::FactoryNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const SALOME_ModuleCatalog::Service& aService , + const char *ComponentName , + const char* InterfaceName , + const char *NodeName , + const SUPERV::KindOfNode akind , + const SUPERV::SDate NodeFirstCreation , + const SUPERV::SDate NodeLastModification , + const char * NodeEditorRelease , + const char * NodeAuthor , + const char * NodeComputer , + const char * NodeComment , + const bool GeneratedName , + const long X , + const long Y , + int * Graph_prof_debug , + ostream * Graph_fdebug ) : + GraphBase::ComputingNode::ComputingNode( ORB , ptrNamingService , aService , + NodeName , akind , + NodeFirstCreation , NodeLastModification , + NodeEditorRelease , NodeAuthor , NodeComment , + GeneratedName , X , Y , + Graph_prof_debug , Graph_fdebug ) { + + _Container = Engines::Container::_nil() ; + _ObjComponent = Engines::Component::_nil() ; + + _ComponentName = new char[strlen(ComponentName)+1]; + strcpy(_ComponentName , ComponentName ) ; + + _InterfaceName = new char[strlen(InterfaceName)+1]; + strcpy(_InterfaceName , InterfaceName ) ; + + if ( NodeComputer ) { + _Computer = new char[ strlen( NodeComputer ) + 1 ] ; + strcpy( _Computer , NodeComputer ) ; + } + else + _Computer = FACTORYSERVER ; + + cdebug_in << "GraphBase::FactoryNode::FactoryNode(" << aService.ServiceName << "," + << ComponentName << "," << Name() << "," << akind + << "," << NodeComputer << "," << Comment() << ")" << endl; + + cdebug << "GraphBase::FactoryNode::FactoryNode " << this + << " _ComponentName " + << (void *) _ComponentName << " '" << _ComponentName + << "' _InterfaceName " + << (void *) _InterfaceName << " '" << _InterfaceName << "' _Name " + << (void *) Name() << " '" << Name() << "' _Computer " + << (void *) _Computer << " " << _Computer << " _Comment " + << (void *) Comment() << " " << Comment() << " " + << " KindOfNode " << Kind() + << " ServiceName " << ServiceName() << " In(" << ServiceInParameter().length() + << ") Out(" << ServiceOutParameter().length() << ")" << endl ; + + cdebug_out << "GraphBase::FactoryNode::FactoryNode" << endl; +} + +GraphBase::FactoryNode::~FactoryNode() { + cdebug << "GraphBase::Node::~Node " << this + << "_ComponentName " + << (void *) _ComponentName << " " << _ComponentName << " _Name " + << (void *) Name() << " " << Name() << " _Computer " + << (void *) _Computer << " " << _Computer << " _Comment " + << (void *) Comment() << " " << Comment() << " " << endl ; +// if ( _ComponentName != NULLSTRING ) +// delete [] _ComponentName ; +// delete [] _Name ; +// delete [] _EditorRelease ; +// if ( _Author != NULLSTRING ) +// delete [] _Author ; +// if ( _Computer != FACTORYSERVER ) +// delete [] _Computer; +// if ( _Comment != NULLSTRING ) +// delete [] _Comment; +} + +bool GraphBase::FactoryNode::ComponentName(const char * aComponentName) { + if ( _ComponentName && _ComponentName != NULLSTRING ) + delete [] _ComponentName ; + _ComponentName = new char[strlen(aComponentName)+1] ; + strcpy( _ComponentName , aComponentName ) ; + return true ; +} + +bool GraphBase::FactoryNode::InterfaceName(const char * anInterfaceName) { + if ( _InterfaceName && _InterfaceName != NULLSTRING ) + delete [] _InterfaceName ; + _InterfaceName = new char[strlen(anInterfaceName)+1] ; + strcpy( _InterfaceName , anInterfaceName ) ; + return true ; +} + +bool GraphBase::FactoryNode::Computer(const char *c) { + cdebug_in << "GraphBase::FactoryNode::Computer" << endl; + if ( _Computer != FACTORYSERVER ) + delete [] _Computer ; + _Computer = my_strdup(c); + cdebug_out << "GraphBase::FactoryNode::Computer" << endl; + return true ; +} + +//bool GraphBase::FactoryNode::SaveXML( ostream &f , char *Tabs , +bool GraphBase::FactoryNode::SaveXML( QDomDocument & Graph , QDomElement & info , + int XCoordinate , int YCoordinate ) const { + GraphBase::ListOfFuncName aFuncNames ; + GraphBase::ListOfPythonFunctions aVoidList ; +// return GraphBase::ComputingNode::SaveXML( f , Tabs , ComponentName() , + return GraphBase::ComputingNode::SaveXML( Graph , info , ComponentName() , + InterfaceName() , Computer() , "" , + aFuncNames , aVoidList , + XCoordinate , YCoordinate ) ; +} + +bool GraphBase::FactoryNode::SavePY(ostream &f , const char * aGraphName , + int XCoordinate , int YCoordinate ) const { + GraphBase::ListOfFuncName aFuncNames ; + GraphBase::ListOfPythonFunctions aVoidList ; + return GraphBase::ComputingNode::SavePY( f , aGraphName , ComponentName() , + InterfaceName() , Computer() , NULL , + aFuncNames , aVoidList , + XCoordinate , YCoordinate ) ; +} + diff --git a/src/GraphBase/DataFlowBase_FactoryNode.hxx b/src/GraphBase/DataFlowBase_FactoryNode.hxx new file mode 100644 index 0000000..d45dfbf --- /dev/null +++ b/src/GraphBase/DataFlowBase_FactoryNode.hxx @@ -0,0 +1,80 @@ +//============================================================================= +// File : DataFlowBase_FactoryNode.hxx +// Created : 2003 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#ifndef _DATAFLOWBASE_FACTORYNODE_HXX +#define _DATAFLOWBASE_FACTORYNODE_HXX + +#include "DataFlowBase_ComputingNode.hxx" + +namespace GraphBase { + + class FactoryNode : public ComputingNode { + + private: + + Engines::Container_var _Container ; + Engines::Component_var _ObjComponent ; + + char * _ComponentName ; + char * _InterfaceName ; + + char * _Computer ; + + public: + + FactoryNode() ; + FactoryNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char * DataFlowName , + int * Graph_prof_debug = NULL , + ostream * Graph_fdebug = NULL ) ; + FactoryNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const SALOME_ModuleCatalog::Service& NodeService , + const char *NodeComponentName , + const char* NodeInterfaceName , + const char *NodeName , + const SUPERV::KindOfNode akind , + const SUPERV::SDate NodeFirstCreation , + const SUPERV::SDate NodeLastModification , + const char * NodeEditorRelease , + const char * NodeAuthor , + const char * NodeComputer , + const char * NodeComment , + const bool GeneratedName , + const long X , + const long Y , + int * Graph_prof_debug = NULL , + ostream * Graph_fdebug = NULL ) ; + virtual ~FactoryNode() ; + + Engines::Container_var Container() const { return _Container ; } ; + void SetContainer(Engines::Container_var aContainer) { + _Container = aContainer ; } ; + Engines::Component_var Component() const { return _ObjComponent ; } ; + void SetComponent(Engines::Component_var anObjComponent) { + _ObjComponent = anObjComponent ; } ; + char * ComponentName() const { return my_strdup( _ComponentName ) ; } ; + char * InterfaceName() const { return my_strdup( _InterfaceName ) ; } ; + char * Computer() const { return my_strdup( _Computer ) ; } ; + + bool ComponentName( const char * aComponentName ) ; + bool InterfaceName( const char * anInterfaceName ) ; + bool Computer( const char *c ) ; + +// bool SaveXML( ostream &f , char *Tabs , + bool SaveXML( QDomDocument & Graph , QDomElement & info , + int XCoordinate , int YCoordinate ) const ; + bool SavePY( ostream &f , const char * aGraphName , + int XCoordinate , int YCoordinate ) const ; + + }; + +}; + +#endif diff --git a/src/GraphBase/DataFlowBase_GOTONode.cxx b/src/GraphBase/DataFlowBase_GOTONode.cxx new file mode 100644 index 0000000..9120aaa --- /dev/null +++ b/src/GraphBase/DataFlowBase_GOTONode.cxx @@ -0,0 +1,112 @@ +using namespace std; +//============================================================================= +// File : DataFlowBase_GOTONode.cxx +// Created : 2003 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#include +#include + +#include "DataFlowBase_GOTONode.hxx" + +GraphBase::GOTONode::GOTONode() : + GraphBase::InLineNode::InLineNode() { + + CoupledNode( NULL ) ; + cdebug << "GraphBase::GOTONode::GOTONode " << this + << " _Name " << (void *) Name() << " " << Name() << " _Comment " + << (void *) Comment() << " " << Comment() << " " << endl ; + +} + +GraphBase::GOTONode::GOTONode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char *FuncName , + const SUPERV::ListOfStrings & aPythonFunction , + const char *NodeName , + const SUPERV::KindOfNode akind , + const SUPERV::SDate NodeFirstCreation , + const SUPERV::SDate NodeLastModification , + const char * NodeEditorRelease , + const char * NodeAuthor , + const char * NodeComment , + const bool GeneratedName , + const long X , + const long Y , + int * Graph_prof_debug , + ostream * Graph_fdebug ) : + GraphBase::InLineNode::InLineNode( ORB , ptrNamingService , FuncName , aPythonFunction , + NodeName , akind , NodeFirstCreation , + NodeLastModification , NodeEditorRelease , + NodeAuthor , NodeComment , GeneratedName , + X , Y , Graph_prof_debug , Graph_fdebug ) { + + CoupledNode( NULL ) ; + cdebug_in << "GraphBase::GOTONode::GOTONode " << this + << "' _Name " << (void *) Name() << " '" << Name() << " _Comment " + << (void *) Comment() << " " << Comment() << " " + << " KindOfNode " << Kind() << " FuncName " << FuncName + << " ServiceName " << ServiceName() << " In(" + << ServiceInParameter().length() + << ") Out(" << ServiceOutParameter().length() << ")" << endl ; + + cdebug_out << "GraphBase::GOTONode::GOTONode" << endl; +} + +GraphBase::GOTONode::~GOTONode() { + cdebug << "GraphBase::GOTONode::~GOTONode " << this + << " _Name " << (void *) Name() << " " << Name() << " _Comment " + << (void *) Comment() << " " << Comment() << " " << endl ; +// if ( _ComponentName != NULLSTRING ) +// delete [] _ComponentName ; +// delete [] _Name ; +// delete [] _EditorRelease ; +// if ( _Author != NULLSTRING ) +// delete [] _Author ; +// if ( _Computer != FACTORYSERVER ) +// delete [] _Computer; +// if ( _Comment != NULLSTRING ) +// delete [] _Comment; +} + +//bool GraphBase::GOTONode::SaveXML( ostream &f , char *Tabs , +bool GraphBase::GOTONode::SaveXML( QDomDocument & Graph , QDomElement & info , + int XCoordinate , int YCoordinate ) const { + GraphBase::ListOfFuncName aFuncNames ; + GraphBase::ListOfPythonFunctions aPythonFunction ; + if ( PyFuncName() ) { + aFuncNames.resize( 1 ) ; + aFuncNames[0] = CORBA::string_dup( PyFuncName() ) ; + aPythonFunction.resize( 1 ) ; + aPythonFunction[0] = PythonFunction() ; + } + char * CoupledName = "" ; + if ( CoupledNode() ) { + CoupledName = CoupledNode()->Name() ; + } +// return GraphBase::ComputingNode::SaveXML( f , Tabs , "" , "" , "" , + return GraphBase::ComputingNode::SaveXML( Graph , info , "" , "" , "" , + CoupledName , + aFuncNames , aPythonFunction , + XCoordinate , YCoordinate ) ; +} + +bool GraphBase::GOTONode::SavePY( ostream &f , const char * aGraphName , + int XCoordinate , int YCoordinate ) const { + GraphBase::ListOfFuncName aFuncNames ; + GraphBase::ListOfPythonFunctions aPythonFunction ; + if ( PyFuncName() ) { + aFuncNames.resize( 1 ) ; + aFuncNames[0] = CORBA::string_dup( PyFuncName() ) ; + aPythonFunction.resize( 1 ) ; + aPythonFunction[0] = PythonFunction() ; + } + return GraphBase::ComputingNode::SavePY( f , aGraphName , "" , "" , "" , + CoupledNode() , + aFuncNames , aPythonFunction , + XCoordinate , YCoordinate ) ; +} + diff --git a/src/GraphBase/DataFlowBase_GOTONode.hxx b/src/GraphBase/DataFlowBase_GOTONode.hxx new file mode 100644 index 0000000..e644730 --- /dev/null +++ b/src/GraphBase/DataFlowBase_GOTONode.hxx @@ -0,0 +1,83 @@ +//============================================================================= +// File : DataFlowBase_GOTONode.hxx +// Created : 2003 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#ifndef _DATAFLOWBASE_GOTONODE_HXX +#define _DATAFLOWBASE_GOTONODE_HXX + +#include "DataFlowBase_InLineNode.hxx" + +namespace GraphBase { + + class GOTONode : public InLineNode { + + private: + + InLineNode * _CoupledNode ; + + public: + + GOTONode() ; + GOTONode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char * FuncName , + const SUPERV::ListOfStrings & PythonFunction , + const char *NodeName , + const SUPERV::KindOfNode akind , + const SUPERV::SDate NodeFirstCreation , + const SUPERV::SDate NodeLastModification , + const char * NodeEditorRelease , + const char * NodeAuthor , + const char * NodeComment , + const bool GeneratedName , + const long X , + const long Y , + int * Graph_prof_debug = NULL , + ostream * Graph_fdebug = NULL ) ; + virtual ~GOTONode() ; + + void CoupledNode( InLineNode * aCoupledNode ) { + cdebug << Name() << ".GraphBase::GOTONode::CoupledNode( " ; + if ( aCoupledNode ) { + cdebug << aCoupledNode->Name() ; + } + else { + cdebug << "NULL" ; + } + cdebug << " )" << endl ; + _CoupledNode = aCoupledNode ; } ; + const InLineNode * CoupledNode() const { + cdebug << Name() << ".GraphBase::GOTONode::CoupledNode() --> " ; + if ( _CoupledNode ) { + cdebug << _CoupledNode->Name() ; + } + else { + cdebug << "NULL" ; + } + cdebug << endl ; + return _CoupledNode ; } ; + InLineNode * CoupledNode() { + cdebug << Name() << ".GraphBase::GOTONode::CoupledNode() --> " ; + if ( _CoupledNode ) { + cdebug << _CoupledNode->Name() ; + } + else { + cdebug << "NULL" ; + } + cdebug << endl ; + return _CoupledNode ; } ; + +// bool SaveXML(ostream &f , char *Tabs , int X , int Y ) const ; + bool SaveXML(QDomDocument & Graph , QDomElement & info , int X , int Y ) const ; + + bool SavePY(ostream &f , const char * aGraphName , int X , int Y ) const ; + + }; + +}; + +#endif diff --git a/src/GraphBase/DataFlowBase_Graph.cxx b/src/GraphBase/DataFlowBase_Graph.cxx new file mode 100644 index 0000000..ad22c1d --- /dev/null +++ b/src/GraphBase/DataFlowBase_Graph.cxx @@ -0,0 +1,1763 @@ +using namespace std; +//============================================================================= +// File : DataFlowBase_Graph.cxx +// Created : 2001 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#include "DataFlowBase_Graph.hxx" + +#include "SALOME_LifeCycleCORBA.hxx" + +GraphBase::Graph::Graph() : + DataNode() { + cdebug << "GraphBase::Graph::Graph" << endl ; + _GraphNodesSize = 0 ; +} + +GraphBase::Graph::Graph( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char *DataFlowName , + const char * DebugFileName ) : + DataNode( ORB ,ptrNamingService , DataFlowName ) { + cdebug << "GraphBase::Graph::Graph" << endl ; + _Orb = CORBA::ORB::_duplicate( ORB ) ; + _GraphNodesSize = 0 ; + Set_prof_debug( ORB , DebugFileName ) ; +} + +GraphBase::Graph::Graph( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const SALOME_ModuleCatalog::Service& DataFlowService , + const char *DataFlowComponentName , + const char *DataFlowInterfaceName , + const char *DataFlowName , + const SUPERV::KindOfNode DataFlowkind , + const SUPERV::SDate DataFlowFirstCreation , + const SUPERV::SDate DataFlowLastModification , + const char * DataFlowEditorRelease , + const char * DataFlowAuthor , + const char * DataFlowComputer , + const char * DataFlowComment , + const char * DebugFileName ) : + DataNode( ORB , ptrNamingService , DataFlowService , + DataFlowName , DataFlowkind , + DataFlowFirstCreation , DataFlowLastModification , + DataFlowEditorRelease , DataFlowAuthor , DataFlowComment ) { + _Orb = CORBA::ORB::_duplicate( ORB ) ; + _GraphNodesSize = 0 ; + Set_prof_debug( ORB , DebugFileName ) ; + cdebug_in << "GraphBase::Graph::Graph" << endl ; + DataService( ORB , DataFlowService , Graph_prof_debug() , Graph_fdebug() ) ; + cdebug_out << "GraphBase::Graph::Graph" << endl ; +} + +GraphBase::Graph::~Graph() { + cdebug << "GraphBase::Graph::~Graph" << endl ; +} + +void GraphBase::Graph::Set_prof_debug( CORBA::ORB_ptr ORB , + const char * DebugFileName ) { + _Graph_prof_debug = 0 ; + if ( DebugFileName ) { + _Graph_fdebug = new ofstream( DebugFileName ); + MESSAGE( endl << "Trace redirected to file " << DebugFileName << endl) + } + else + _Graph_fdebug = &(std::cerr); + SetDebug( ORB , &_Graph_prof_debug , _Graph_fdebug ) ; +} + +GraphBase::SNode * GraphBase::Graph::GetInfo() const { + GraphBase::SNode * Info = new GraphBase::SNode ; + Info->theComponentName = "" ; + Info->theInterfaceName = "" ; + Info->theName = Name() ; + Info->theKind = Kind() ; + Info->theService = *GetService() ; + Info->theFirstCreation = FirstCreation() ; + Info->theLastModification = LastModification() ; + Info->theEditorRelease = EditorRelease() ; + Info->theAuthor = Author() ; + Info->theContainer = "" ; + Info->theComment = Comment() ; + Info->theCoords.theX = GraphBase::ComputingNode::XCoordinate() ; + Info->theCoords.theY = GraphBase::ComputingNode::YCoordinate() ; + return Info ; +} + +//---------------------------------------------------------------------- +// Function : GetNodes +// Purpose : get a nodes list +//---------------------------------------------------------------------- +GraphBase::ListOfNodes * GraphBase::Graph::GetNodes() const { + GraphBase::ListOfNodes * _list_nodes = + new GraphBase::ListOfNodes; + + // All the nodes from _InNodes are taken +// vector< InNode *> Nodes = InNodes() ; + + _list_nodes->resize( GraphNodesSize() ); + + int igoto ; + int ind ; + GraphBase::ComputingNode * aCNode = NULL ; + for ( igoto = 0 ; igoto < 2 ; igoto++ ) { + for ( ind = 0 ; ind < GraphNodesSize() ; ind++ ) { + aCNode = GraphNodes( ind ) ; + if ( ( igoto == 0 && !aCNode->IsGOTONode() ) || + ( igoto == 1 && aCNode->IsGOTONode() ) ) { + if ( aCNode->IsFactoryNode() ) { + GraphBase::FactoryNode * aFNode = (GraphBase::FactoryNode * ) aCNode ; + (*_list_nodes)[ind].theComponentName = CORBA::string_dup( aFNode->ComponentName()); + (*_list_nodes)[ind].theInterfaceName = CORBA::string_dup( aFNode->InterfaceName()); + } + else { + (*_list_nodes)[ind].theComponentName = CORBA::string_dup( "" ); + (*_list_nodes)[ind].theInterfaceName = CORBA::string_dup( "" ); + } + (*_list_nodes)[ind].theName = CORBA::string_dup( aCNode->Name() ); + (*_list_nodes)[ind].theKind = aCNode->Kind(); + if ( aCNode->IsInLineNode() ) { + GraphBase::InLineNode * aINode = (GraphBase::InLineNode * ) aCNode ; + (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ; + (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aINode->PyFuncName() ) ; + (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ; + (*_list_nodes)[ind].theListOfPythonFunctions[0] = aINode->PythonFunction() ; + } + if ( aCNode->IsGOTONode() ) { + GraphBase::GOTONode * aGNode = (GraphBase::GOTONode * ) aCNode ; + (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ; + (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aGNode->PyFuncName() ) ; + (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ; + (*_list_nodes)[ind].theListOfPythonFunctions[0] = aGNode->PythonFunction() ; + } + if ( aCNode->IsLoopNode() ) { + GraphBase::LoopNode * aLNode = (GraphBase::LoopNode * ) aCNode ; + (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aLNode->CoupledNode()->Name() ) ; + (*_list_nodes)[ind].theListOfFuncName.resize( 3 ) ; + (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aLNode->PyFuncName() ) ; + (*_list_nodes)[ind].theListOfFuncName[1] = CORBA::string_dup( aLNode->PyMoreName() ) ; + (*_list_nodes)[ind].theListOfFuncName[2] = CORBA::string_dup( aLNode->PyNextName() ) ; + (*_list_nodes)[ind].theListOfPythonFunctions.resize( 3 ) ; + (*_list_nodes)[ind].theListOfPythonFunctions[0] = aLNode->PythonFunction() ; + (*_list_nodes)[ind].theListOfPythonFunctions[1] = aLNode->MorePythonFunction() ; + (*_list_nodes)[ind].theListOfPythonFunctions[2] = aLNode->NextPythonFunction() ; + } + else if ( aCNode->IsSwitchNode() ) { + GraphBase::SwitchNode * aSNode = (GraphBase::SwitchNode * ) aCNode ; + (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aSNode->CoupledNode()->Name() ) ; + (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ; + (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aSNode->PyFuncName() ) ; + (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ; + (*_list_nodes)[ind].theListOfPythonFunctions[0] = aSNode->PythonFunction() ; + } + else if ( aCNode->IsEndLoopNode() ) { + GraphBase::EndOfLoopNode * aELNode = (GraphBase::EndOfLoopNode * ) aCNode ; + (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aELNode->CoupledNode()->Name() ) ; + (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ; + (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aELNode->PyFuncName() ) ; + (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ; + (*_list_nodes)[ind].theListOfPythonFunctions[0] = aELNode->PythonFunction() ; + } + else if ( aCNode->IsEndSwitchNode() ) { + GraphBase::EndOfSwitchNode * aESNode = (GraphBase::EndOfSwitchNode * ) aCNode ; + (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aESNode->CoupledNode()->Name() ) ; + (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ; + (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aESNode->PyFuncName() ) ; + (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ; + (*_list_nodes)[ind].theListOfPythonFunctions[0] = aESNode->PythonFunction() ; + } + else { + (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( "" ) ; + } + (*_list_nodes)[ind].theService = *aCNode->GetService(); +// (*_list_nodes)[ind].theListOfParameters = *aCNode->GetListOfParameters() ; + if ( aCNode->IsOneOfInLineNodes() ) { + GraphBase::InLineNode * aINode = (GraphBase::InLineNode * ) aCNode ; + GraphBase::LoopNode * aLNode = NULL ; + if ( aCNode->IsLoopNode() ) { + aLNode = (GraphBase::LoopNode * ) aCNode ; + (*_list_nodes)[ind].theListOfPythonFunctions.resize( 3 ) ; + (*_list_nodes)[ind].theListOfPythonFunctions[ 0 ] = aINode->PythonFunction() ; + (*_list_nodes)[ind].theListOfPythonFunctions[ 1 ] = aLNode->MorePythonFunction() ; + (*_list_nodes)[ind].theListOfPythonFunctions[ 2 ] = aLNode->NextPythonFunction() ; + } + else if ( aCNode->IsInLineNode() || aCNode->IsGOTONode() || + aCNode->IsSwitchNode() || aCNode->IsEndSwitchNode() ) { + (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ; + (*_list_nodes)[ind].theListOfPythonFunctions[ 0 ] = aINode->PythonFunction() ; + } + } + (*_list_nodes)[ind].theFirstCreation = aCNode->FirstCreation(); + (*_list_nodes)[ind].theLastModification = aCNode->LastModification(); + (*_list_nodes)[ind].theEditorRelease = CORBA::string_dup( aCNode->EditorRelease()); + (*_list_nodes)[ind].theAuthor = CORBA::string_dup( aCNode->Author()); + if ( aCNode->IsFactoryNode() ) { + GraphBase::FactoryNode * aFNode = (GraphBase::FactoryNode * ) aCNode ; + (*_list_nodes)[ind].theContainer = CORBA::string_dup( aFNode->Computer()); + } + else { + (*_list_nodes)[ind].theContainer = CORBA::string_dup( "" ); + } + (*_list_nodes)[ind].theComment = CORBA::string_dup( aCNode->Comment()); + (*_list_nodes)[ind].theCoords.theX = aCNode->XCoordinate(); + (*_list_nodes)[ind].theCoords.theY = aCNode->YCoordinate(); +#if 0 + int nports = 0 ; + int i ; + for ( i = 0 ; i < aCNode->GetNodeInPortsSize() ; i++ ) { + const GraphBase::InPort * anInPort = aCNode->GetNodeInPort( i ) ; + if ( anInPort->IsBus() ) { + nports += 1 ; + (*_list_nodes)[ind].theListOfParameters.resize( nports ) ; + (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametertype = CORBA::string_dup( anInPort->PortType() ) ; + (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametername = CORBA::string_dup( anInPort->PortName() ) ; + (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametertype = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortType() ) ; + (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametername = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortName() ) ; + } + } +#endif + } + } + } + return _list_nodes ; +} + + +//---------------------------------------------------------------------- +// Function : GetLinks +// Purpose : get a links list +//---------------------------------------------------------------------- +GraphBase::ListOfLinks * GraphBase::Graph::GetLinks() const { + GraphBase::ListOfLinks * _list_links = + new GraphBase::ListOfLinks; + +// All the links from _LinksList are taken +// vector< InNode *> Nodes = InNodes() ; + + int ind = 0 ; + int k ; + for ( k = 0 ; k < GraphNodesSize() ; k++ ) { + GraphBase::ComputingNode * aNode = GraphNodes( k ) ; + int i ; + for ( i = 0 ; i < aNode->GetNodeOutPortsSize() ; i++ ) { + const GraphBase::OutPort* fromPort = aNode->GetNodeOutPort( i ) ; +// cout << "GraphBase::Graph::GetLinks " << aNode->Name() << " " +// << fromPort->PortName() << " " << fromPort->IsPortConnected() +// << " " << fromPort->InPortsSize() << endl ; + if ( fromPort->IsPortConnected() ) { + int j ; + for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) { + _list_links->resize( ind+1 ); + (*_list_links)[ind].FromNodeName = CORBA::string_dup( aNode->Name() ); + (*_list_links)[ind].FromServiceParameterName = fromPort->GetServicesParameter().Parametername; + const GraphBase::InPort* toPort = fromPort->InPorts( j ) ; + (*_list_links)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() ); + (*_list_links)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername; + (*_list_links)[ind].aLinkValue = *fromPort->Value() ; + if ( toPort->IsEndSwitch() ) { + (*_list_links)[ind++].aListOfCoords = *(fromPort->Coords()) ; + } + else { + (*_list_links)[ind++].aListOfCoords = *(toPort->Coords()) ; + } + } + } + } + } + + return _list_links; +} + +GraphBase::ListOfGraphs * GraphBase::Graph::GetGraphs() const { + GraphBase::ListOfGraphs * _list_graphs = + new GraphBase::ListOfGraphs; + + return _list_graphs; +} + +GraphBase::SLink * GraphBase::Graph::GetLink( GraphBase::ComputingNode * aNode , + GraphBase::InPort* toPort ) { + GraphBase::SLink * _link = new GraphBase::SLink ; + GraphBase::OutPort* fromPort = toPort->GetOutPort() ; + _link->FromNodeName = CORBA::string_dup( fromPort->NodeName() ); + _link->FromServiceParameterName = fromPort->GetServicesParameter().Parametername; + _link->ToNodeName = CORBA::string_dup( toPort->NodeName() ); + _link->ToServiceParameterName = toPort->GetServicesParameter().Parametername; + CORBA::Any aSPValue = *fromPort->Value() ; + _link->aLinkValue = aSPValue; + _link->aListOfCoords = *(toPort->Coords()) ; + return _link; +} +//---------------------------------------------------------------------- +// Function : GetDatas +// Purpose : get the datas list +//---------------------------------------------------------------------- +GraphBase::ListOfLinks * GraphBase::Graph::GetDatas() const { + GraphBase::ListOfLinks * _list_datalinks = + new GraphBase::ListOfLinks; + + int ind = 0 ; + const GraphBase::DataNode * aDataNode = this ; + int i ; + for ( i = 0 ; i < aDataNode->GetNodeInDataNodePortsSize() ; i++ ) { + const GraphBase::OutPort* fromDataPort = aDataNode->GetNodeInDataNodePort( i ) ; + if ( fromDataPort->IsDataConnected() ) { + int j ; +//We may have SharedData as input of a DataFlow : same input for one or several +// input ports. Input(s) of a DataFlow match one or several output-virtual-dataport + for ( j = 0 ; j < fromDataPort->InPortsSize() ; j++ ) { + _list_datalinks->resize( ind+1 ); + (*_list_datalinks)[ind].FromNodeName = CORBA::string_dup( aDataNode->Name() ); + (*_list_datalinks)[ind].FromServiceParameterName = fromDataPort->GetServicesParameter().Parametername; + const GraphBase::InPort* toPort = fromDataPort->InPorts( j ) ; + (*_list_datalinks)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() ); + (*_list_datalinks)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername; + CORBA::Any aSPValue = *fromDataPort->Value() ; + (*_list_datalinks)[ind].aLinkValue = aSPValue; + (*_list_datalinks)[ind++].aListOfCoords = *(toPort->Coords()) ; + } + } + } + +#if 0 +// Output(s) of a DataFlow match only one input-virtual-dataport + for ( i = 0 ; i < aDataNode->GetNodeOutDataNodePortsSize() ; i++ ) { + GraphBase::InPort* toDataPort = aDataNode->GetChangeNodeOutDataNodePort( i ) ; + const GraphBase::OutPort* fromPort = toDataPort->GetLink() ; + if ( fromPort->IsDataConnected() ) { + _list_datalinks->length( ind+1 ); + _list_datalinks[ind].FromNodeName = CORBA::string_dup( fromPort->NodeName() ); + _list_datalinks[ind].FromServiceParameterName = fromPort->GetServicesParameter().Parametername; + _list_datalinks[ind].ToNodeName = CORBA::string_dup( aDataNode->Name() ); + _list_datalinks[ind].ToServiceParameterName = toDataPort->GetServicesParameter().Parametername; +// SALOME_SuperVisionBase::ServicesParameterValue aSPValue; + CORBA::Any aSPValue = *fromPort->Value() ; +// aSPValue.Value = CORBA::string_dup( fromPort->Value() ); +// aSPValue.Kind = fromPort->Kind(); + _list_datalinks[ind].aLinkValue = aSPValue; + _list_datalinks[ind++].aListOfCoords = toDataPort->Coords() ; + } + } +#endif + + return _list_datalinks ; +} + +bool GraphBase::Graph::AddNode( GraphBase::ComputingNode * aNode ) { + cdebug_in << "GraphBase::Graph::AddNode " << (void *) aNode << " " + << aNode->Name() << " " << aNode->ServiceName() << endl; + bool RetVal = false ; + int index = GetGraphNodeIndex( aNode->Name() ) ; + if ( index < 0 ) { + _GraphNodes.resize( _GraphNodesSize+1 ) ; + _GraphNodes[ _GraphNodesSize ] = aNode ; + SetGraphNodeIndex( aNode->Name() , _GraphNodesSize ) ; + _GraphNodesSize += 1 ; + RetVal = true ; + } +// cout << "GraphBase::Graph::AddNode(" << aNode->ComponentName() << " , " +// << aNode->Name() << ")" << endl; + int i ; + cdebug << "GraphBase::Graph::AddNode Known nodes :" << endl ; + for ( i = 0 ; i < _GraphNodesSize ; i++ ) { + cdebug << i << ". " << GetGraphNode( i )->Name() << " " + << _MapOfGraphNodes[ GetGraphNode( i )->Name() ] - 1 << endl ; + } + cdebug_out << "GraphBase::Graph::AddNode " << _GraphNodesSize << " Nodes. " + << aNode->ServiceName() << endl; + return RetVal ; +} + +bool GraphBase::Graph::ReNameNode( const char* OldNodeName , + const char* NewNodeName ) { + cdebug_in << "GraphBase::Graph::ReNameNode (" << OldNodeName << " , " + << NewNodeName << ")" << endl; + int i ; + bool RetVal = false ; + if ( !strcmp( OldNodeName , NewNodeName ) ) { + RetVal = true ; + } + else if ( strcmp( Name() , OldNodeName ) ) { + int index = GetGraphNodeIndex( OldNodeName ) ; + int newindex = GetGraphNodeIndex( NewNodeName ) ; + if ( index >= 0 && index < _GraphNodesSize && + ( newindex < 0 || newindex > _GraphNodesSize ) ) { + _GraphNodes[ index ]->Name( NewNodeName ) ; + _MapOfGraphNodes.erase( OldNodeName ) ; + SetGraphNodeIndex( NewNodeName , index ) ; + + GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ; + for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) { + cdebug << i << ". GraphBase::Graph::ReNameNode of LinkedNode : from " ; + GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ; + GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; + if ( anOutPort ) { + cdebug << anOutPort->NodeName() ; + } + else { + cdebug << "without link" ; + } + cdebug << " to " << i << ". " << anInPort->PortName() + << " of " << NewNodeName ; + if ( anInPort->IsConnected() ) { + if ( anOutPort->IsDataConnected() ) { + cdebug << " fromDataConnected " + << anOutPort->NodeName() + << endl ; + } + else { + GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ; + cdebug << " fromConnected " << FromNode->Name() << endl ; + FromNode->ReNameLink( OldNodeName , NewNodeName ) ; + } + char* OldNodePortName = new char[ strlen( OldNodeName ) + + strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 2 ] ; + char* NewNodePortName = new char[ strlen( NewNodeName ) + + strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 2 ] ; + strcpy( OldNodePortName , OldNodeName ) ; + strcat( OldNodePortName , "\\" ) ; + strcat( OldNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ; + strcpy( NewNodePortName , NewNodeName ) ; + strcat( NewNodePortName , "\\" ) ; + strcat( NewNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ; + RetVal = anOutPort->ReNameInPort( OldNodePortName , NewNodePortName ) ; + delete [] OldNodePortName ; + delete [] NewNodePortName ; + if ( !RetVal ) + break ; + } + else { + cdebug << " not connected" << endl ; + RetVal = true ; + } + } + RetVal = true ; + } + else { + cdebug << "Node not found" << endl ; + } + } + else { + RetVal = Name( NewNodeName ) ; + } + + cdebug_out << "GraphBase::Graph::ReNameNode" << endl; + return RetVal ; +} + +bool GraphBase::Graph::RemoveNode( const char* aNodeName ) { + cdebug_in << "GraphBase::Graph::RemoveNode (" << aNodeName << ")" << endl; + int i ; + bool RetVal = false ; + int index = GetGraphNodeIndex( aNodeName ) ; + GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ; + if ( aNode ) { + if ( aNode->GetNodeInPortsSize() ) { + for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) { + cdebug << i << ". GraphBase::Graph::RemoveNode of LinkedNode : from " ; + GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ; + GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; + if ( anOutPort ) { + cdebug << anOutPort->NodeName() ; + } + else { + cdebug << "without link" ; + } + cdebug << " to " << i << ". " << anInPort->PortName() + << " of " << aNodeName ; + if ( anInPort->IsConnected() ) { + if ( anOutPort->IsDataConnected() ) { + cdebug << " fromDataConnected " << anOutPort->NodeName() << endl ; + } + else { + GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ; + cdebug << " fromConnected " << FromNode->Name() << endl ; + FromNode->RemoveLink( aNode ) ; + } + RetVal = anOutPort->RemoveInPort( anInPort ) ; + if ( !RetVal ) + break ; + } + else { + cdebug << " not connected" << endl ; + RetVal = true ; + } + } + } + else { + RetVal = true ; + } + if ( RetVal ) { + for ( i = aNode->GetNodeOutPortsSize() - 1 ; i >= 0 ; i-- ) { + GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( i ) ; + cdebug << "GraphBase::Graph::Remove " <InPortsSize() + << " Links of OutPort : " << i << ". " + << *aNode->GetChangeNodeOutPort( i ) ; + int j ; + for ( j = anOutPort->InPortsSize() - 1 ; j >= 0 ; j-- ) { + cdebug << " to " << j << ". " << *anOutPort->InPorts( j ) + << endl ; + RetVal = anOutPort->ChangeInPorts( j )->RemoveOutPort() ; + if ( !RetVal ) + break ; + GraphBase::ComputingNode * ToNode = GetChangeGraphNode( anOutPort->InPorts( j )->NodeName() ) ; + aNode->RemoveLink( ToNode ) ; + RetVal = anOutPort->RemoveInPort( anOutPort->ChangeInPorts( j ) ) ; + if ( !RetVal ) + break ; + } +// RetVal = aNode->GetChangeNodeOutPort( j )->RemoveLinks() ; + if ( !RetVal ) + break ; + } + } +// RetVal = aNode->RemoveLinks() ; // In PortsOfNode + if ( RetVal ) { + delete aNode ; + _GraphNodesSize -= 1 ; + for ( i = index ; i < _GraphNodesSize ; i++ ) { + SetGraphNodeIndex( _GraphNodes[ i+1 ]->Name() , i ) ; + _GraphNodes[ i ] = _GraphNodes[ i+1 ] ; + } + _GraphNodes.resize( _GraphNodesSize+1 ) ; + _MapOfGraphNodes.erase( aNodeName ) ; + RetVal = true ; + } + } + else + cdebug << "Node not found" << endl ; + + cdebug_out << "GraphBase::Graph::RemoveNode" << endl; + return RetVal ; +} + +bool GraphBase::Graph::AddLink( + const char* FromNodeName , + const char* FromServiceParameterName , + const char* ToNodeName , + const char* ToServiceParameterName , + const CORBA::Any aValue ) { + bool RetVal ; + int index ; + cdebug_in << "GraphBase::Graph::AddLink(" << FromNodeName << "(" + << FromServiceParameterName << ") ---> " << ToNodeName << "(" + << ToServiceParameterName << ") )" << endl; + + GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ; + GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ; + + GraphBase::OutPort *fromPort = NULL ; + GraphBase::InPort *toPort = NULL ; + + if ( fromNode ) { + fromPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ; + if ( !fromPort ) { + cdebug << "AddLink fromPort " << FromServiceParameterName << " FromNode(" + << FromNodeName << ") not found." << endl ; + } + } + else { + cdebug << "AddLink FromNode " << FromNodeName << " not found." << endl ; + } + if ( toNode ) { + toPort = toNode->GetChangeInPort( ToServiceParameterName ) ; + if ( !toPort ) { + cdebug << "AddLink toPort " << ToServiceParameterName << " ToNode(" + << ToNodeName << ") not found." << endl ; + } + } + else { + cdebug << "AddLink toNode " << ToNodeName << " not found." << endl ; + } + + RetVal = AddLink( fromNode , fromPort , toNode , toPort ) ; + + if ( RetVal ) { + if ( fromPort->IsGate() && toPort->IsGate() ) { + CORBA::Any aValue ; + aValue <<= (long ) 1 ; + fromPort->Value( aValue ) ; + } + else { + const CORBA::Any * aDataValue = new CORBA::Any( aValue ) ; + fromPort->Value( aDataValue ) ; + } + } + + cdebug_out << "GraphBase::Graph::AddLink" << endl; + return RetVal ; +} + +bool GraphBase::Graph::AddLink( + GraphBase::ComputingNode *fromNode , + GraphBase::OutPort *fromPort , + GraphBase::ComputingNode *toNode , + GraphBase::InPort *toPort ) { + bool RetVal ; + + if ( !fromNode ) { + cdebug << "AddLink fromNode not found." << endl ; + return false ; + } + if ( !fromPort ) { + cdebug << "AddLink fromPort not found." << endl ; + return false ; + } + + if ( !toNode ) { + cdebug << "AddLink toNode not found." << endl ; + return false ; + } + if ( !toPort ) { + cdebug << "AddLink toPort not found." << endl ; + return false ; + } + + cdebug_in << "GraphBase::Graph::AddLink(" << fromNode->Name() << "(" + << fromPort->PortName() << ") ---> " << toNode->Name() << "(" + << toPort->PortName() << ") )" << endl; + if ( !fromNode->IsDataFlowNode() && !toNode->IsDataFlowNode() && + toPort->GetOutPort() ) { + if ( !strcmp( toPort->GetOutPort()->NodePortName() , + fromPort->NodePortName() ) ) { + cdebug << "Link already exists" << endl ; + cdebug_out << "GraphBase::Graph::AddLink" << endl; + return true ; + } + else if ( toPort->IsDataConnected() ) { + toPort->RemoveOutPort() ; + } + else if ( fromNode->IsGOTONode() ) { + if ( !RemoveLink( toPort->GetOutPort()->NodeName() , + toPort->GetOutPort()->PortName() , + toNode->Name() , toPort->PortName() ) ) { + cdebug << "RemoveLink(AddLink) toPort->GetOutPort()->NodeName() Error." + << endl ; + cdebug_out << "GraphBase::Graph::AddLink" << endl; + return false ; + } + if ( fromPort->InPortsSize() ) { + if ( !RemoveLink( fromNode->Name() , fromPort->PortName() , + fromPort->ChangeInPorts(0)->NodeName() , + fromPort->ChangeInPorts(0)->PortName() ) ) { + cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ; + cdebug_out << "GraphBase::Graph::AddLink" << endl; + return false ; + } + } + } + else if ( !toNode->IsEndSwitchNode() ) { + if ( !RemoveLink( fromNode->Name() , fromPort->PortName() , + toNode->Name() , toPort->PortName() ) ) { + cdebug << "RemoveLink(AddLink) toNode->IsEndSwitchNode Error." << endl ; + cdebug_out << "GraphBase::Graph::AddLink" << endl; + return false ; + } + } + } + else if ( fromNode->IsGOTONode() && fromPort->InPortsSize() ) { + if ( !RemoveLink( fromNode->Name() , fromPort->PortName() , + fromPort->ChangeInPorts(0)->NodeName() , + fromPort->ChangeInPorts(0)->PortName() ) ) { + cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ; + cdebug_out << "GraphBase::Graph::AddLink" << endl; + return false ; + } + } + + if ( toNode->IsEndSwitchNode() && !toPort->IsGate() ) { +// if ( !toPort->IsEndSwitch() || !fromPort->AddInPort( toPort ) ) { + if ( !fromPort->AddInPort( toPort ) ) { + cdebug << "toNode->IsEndSwitchNode() : !fromPort->AddInPort( toPort ) AddLink Error." + << endl ; + cdebug_out << "GraphBase::Graph::AddLink" << endl; + return false ; + } + toPort->Kind( SUPERV::EndSwitchParameter ) ; + } + else if ( !fromPort->AddInPort( toPort ) ) { // --> MapOfInports in the OutPort + cdebug << "!fromPort->AddLink Error." << endl ; + cdebug_out << "GraphBase::Graph::AddLink" << endl; + return false ; + } + + if ( fromNode->IsDataFlowNode() && toPort->IsDataConnected() ) { + toPort->RemoveOutPort() ; + } + + if ( fromNode->IsGOTONode() && ( !fromPort->IsGate() || !toPort->IsGate() || + toNode->IsEndLoopNode() || toNode->IsEndSwitchNode() ) ) { + cdebug << "toPort->AddLink Error( fromNode->IsGOTONode() && toNode->IsEndInLineNode() )." << endl ; + cdebug_out << "GraphBase::Graph::AddLink" << endl; + return false ; + } + else if ( !fromNode->IsSwitchNode() && fromPort->IsParam() && toPort->IsGate() ) { + cdebug << "toPort->AddLink Error( fromPort->IsParam() && toPort->IsGate())." << endl ; + cdebug_out << "GraphBase::Graph::AddLink" << endl; + return false ; + } + else if ( !toNode->IsEndSwitchNode() && !toNode->IsEndLoopNode() ) { + if ( !toPort->AddOutPort( fromPort ) ) { // --> Unique OutPort of the InPort + cdebug << "toPort->AddLink Error." << endl ; + cdebug_out << "GraphBase::Graph::AddLink" << endl; + return false ; + } + } + else { + toPort->AddOutPort( fromPort ) ; + } + + if ( ( fromNode->IsGOTONode() && toNode->IsOneOfInLineNodes() ) || + ( fromNode->IsEndLoopNode() && toNode->IsLoopNode() ) ) { + cdebug << "AddLink fromPort->PortStatus( PortConnected ) " + << "GOTONode/EndLoopNode-->InLineNode/LoopNode/SwitchNode " + << fromNode->Name() << " " << fromPort->PortName() + << " InLineNode/LoopNode_ConnectedInPortsNumber " + << toNode->ConnectedInPortsNumber() << endl; + if ( fromNode->IsGOTONode() ) { + fromPort->Kind( SUPERV::GOTOParameter ) ; + } + fromPort->PortStatus( PortConnected ); // GOTO - Loop + } + else if ( fromNode->IsDataFlowNode() || toNode->IsDataFlowNode() ) { + cdebug << "AddLink IsDataFlowNode fromPort->PortStatus( DataConnected ) " + << fromNode->Name() << " " << fromPort->PortName() << endl ; + fromPort->PortStatus( DataConnected ); + } + else { + cdebug << "AddLink fromPort->PortStatus( PortConnected ) & fromNode->toNode " + << fromNode->Name() << " " << fromPort->PortName() << endl; + fromPort->PortStatus( PortConnected ); + fromNode->AddLink( toNode ) ; + } + if ( fromNode->IsSwitchNode() ) { + if ( fromPort->IsInLine() && toPort->IsGate() ) { + fromPort->Kind( SUPERV::SwitchParameter ) ; + } + else if ( !fromPort->IsGate() && !toPort->IsGate() ){ + fromPort->Kind( SUPERV::InLineParameter ) ; + } + if ( fromPort->IsGate() && !toNode->IsEndSwitchNode() ) { + GraphBase::InLineNode * anEndSwitchNode ; + anEndSwitchNode = ((GraphBase::SwitchNode * ) fromNode)->CoupledNode() ; + GraphBase::InPort * anInPort = anEndSwitchNode->GetChangeNodeInPort(0) ; + GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; + if ( anOutPort && !strcmp( fromNode->Name() , anOutPort->NodeName() ) && + !strcmp( fromPort->PortName() , anOutPort->PortName() ) && + anOutPort->IsGate() ) { + if ( !RemoveLink( fromNode->Name() , anOutPort->PortName() , + anEndSwitchNode->Name() , + anEndSwitchNode->GetChangeNodeInPort(0)->PortName() ) ) { + cdebug << "AddLink Error Removelink ( Switch , Default , EndSwitch , Default )" + << endl ; + cdebug_out << "GraphBase::Graph::AddLink" << endl; + return false ; + } + } + } + } +// cdebug << fromNode->ServiceName() << " " << toNode->ServiceName() << endl ; + cdebug_out << "GraphBase::Graph::AddLink" << endl; + return true ; +} + +bool GraphBase::Graph::RemoveLink( const char* FromNodeName , + const char* FromServiceParameterName , + const char* ToNodeName , + const char* ToServiceParameterName ) { + cdebug_in << "GraphBase::Graph::RemoveLink to " << ToNodeName << "(" + << ToServiceParameterName << ")" << endl; + bool RetVal = false ; + GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ; + if ( toNode ) { + GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ; + if ( anInPort && ( anInPort->IsConnected() || + anInPort->IsDataConnected() ) ) { + GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; + RetVal = anOutPort->RemoveInPort( anInPort ) ; + anInPort->RemoveOutPort() ; + const char * FromNodeName = anOutPort->NodeName() ; + GraphBase::ComputingNode * fromNode = GetChangeGraphNode( FromNodeName ) ; + if ( fromNode ) { + fromNode->RemoveLink( toNode ) ; + } + if ( fromNode->IsSwitchNode() ) { + anOutPort->Kind( SUPERV::InLineParameter ) ; + } + } + } + cdebug_out << "GraphBase::Graph::RemoveLink " << RetVal << endl; + return RetVal ; +} + +bool GraphBase::Graph::GetLink(const char* ToNodeName , + const char* ToServiceParameterName , + char** FromNodeName , + char** FromServiceParameterName ) { + cdebug_in << "GraphBase::Graph::GetLink " << ToNodeName << "(" + << ToServiceParameterName << ")" << endl; + bool RetVal = false ; + GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ; + if ( toNode ) { + GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ; + if ( anInPort && anInPort->IsConnected() ) { + GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; + *FromNodeName = my_strdup( anOutPort->NodeName() ) ; + *FromServiceParameterName = my_strdup( anOutPort->PortName() ) ; + RetVal = true ; + } + } + cdebug_out << "GraphEditor::OutNode::GetLink " << RetVal << endl; + return RetVal ; +} + +bool GraphBase::Graph::AddInputData( const char* ToNodeName , + const char* ToServiceParameterName , + const CORBA::Any aValue ) { + bool RetVal = false ; + cdebug_in << "GraphBase::Graph::AddInputData(" << ToNodeName << "," + << ToServiceParameterName << " , Any " ; + switch (aValue.type()->kind()) { + case CORBA::tk_string: + char * t; + aValue >>= t; + cdebug << t << " (string) " ; + break; + case CORBA::tk_double: + double d; + aValue >>= d; + cdebug << d << " (double) " ; + break; + case CORBA::tk_long: + long l; + aValue >>= l; + cdebug << l << " (long) " ; + break; + case CORBA::tk_objref: + cdebug << "(object reference) " ; + break; + default: + cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR"; + break; + } + cdebug << ")" << endl; + + GraphBase::OutPort *fromDataNodePort = NULL ; + + GraphBase::ComputingNode *toNode ; + GraphBase::InPort *toPort ; + char *aNode ; + char *aPort ; + NodePort( ToNodeName , ToServiceParameterName , &aNode , &aPort ) ; + toNode = GetChangeGraphNode( aNode ) ; + if ( toNode ) { + toPort = toNode->GetChangeInPort( aPort ) ; + if ( toPort && !toPort->IsDataConnected() ) { + toPort->RemoveOutPort() ; + } + } + else { + toPort = NULL ; + } + delete aNode ; + delete aPort ; + +#if 0 + int i ; + for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) { + cdebug "GraphBase::Graph::AddInputData " << GetNodeOutDataNodePort(i) << endl ; + } + for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) { + cdebug "GraphBase::Graph::AddInputData " << GetNodeInDataNodePort(i) << endl ; + } +#endif + + if ( toNode && toPort ) { + fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ; + if ( fromDataNodePort && fromDataNodePort->GetInPort( toPort ) ) { + fromDataNodePort->RemoveInPort( toPort ) ; + } + cdebug << "Try AddLink " << toPort->NodePortName() << " : " << Name() << "( " + << fromDataNodePort->PortName() << " ) -->" << toNode->Name() << "( " + << toPort->PortName() << " )" << endl ; + RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort , + toNode , toPort ) ; + if ( RetVal ) { + fromDataNodePort->Value( aValue ) ; + } + } + else { + cdebug << "Node not found" << endl ; + } + + cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl; + return RetVal ; +} + +bool GraphBase::Graph::ChangeInputData( const char* ToNodeName , + const char* ToServiceParameterName , + const CORBA::Any aValue ) { + bool RetVal = false ; + cdebug_in << "GraphBase::Graph::ChangeInputData(" << ToNodeName << "," + << ToServiceParameterName << " Any " ; + switch (aValue.type()->kind()) { + case CORBA::tk_string: + char * t; + aValue >>= t; + cdebug << t << " (string) " ; + break; + case CORBA::tk_double: + double d; + aValue >>= d; + cdebug << d << " (double) " ; + break; + case CORBA::tk_long: + long l; + aValue >>= l; + cdebug << l << " (long) " ; + break; + case CORBA::tk_objref: + cdebug << "(object reference) " ; + break; + default: + cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR"; + break; + } + cdebug << ")" << endl; + + GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ; + + GraphBase::OutPort *fromPort = NULL ; + GraphBase::InPort *toPort = NULL ; + + if ( toNode ) { + toPort = toNode->GetChangeInPort( ToServiceParameterName ) ; + if ( toPort ) { + fromPort = toPort->GetOutPort(); + if ( fromPort ) { + RetVal = true ; + fromPort->Value( aValue ) ; + toPort->State( SUPERV::ReadyState ) ; + } + else { + cdebug << "ChangeInputData fromPort not found" << endl ; + } + } + else { + cdebug << "ChangeInputData toPort not found" << endl ; + } + } + else { + cdebug << "ChangeInputData Node not found" << endl ; + } + + cdebug_out << "GraphBase::Graph::ChangeInputData" << endl; + return RetVal ; +} + +bool GraphBase::Graph::AddInputData( + const char* ToNodeName1 , + const char* ToServiceParameterName1 , + const char* ToNodeName2 , + const char* ToServiceParameterName2 ) { + bool RetVal = false ; + cdebug_in << "GraphBase::Graph::AddInputSharedData(" << ToNodeName1 << "," + << ToServiceParameterName1 << ", " << ToNodeName2 << "," + << ToServiceParameterName2 << " )" << endl; + + GraphBase::ComputingNode *toNode1 = GetChangeGraphNode( ToNodeName1 ) ; + GraphBase::ComputingNode *toNode2 = GetChangeGraphNode( ToNodeName2 ) ; + + GraphBase::OutPort *fromDataNodePort1 = NULL ; + GraphBase::OutPort *fromDataNodePort2 = NULL ; + GraphBase::InPort *toPort1 = NULL ; + GraphBase::InPort *toPort2 = NULL ; + + if ( toNode1 && toNode2 ) { + toPort1 = toNode1->GetChangeInPort( ToServiceParameterName1 ) ; + toPort2 = toNode2->GetChangeInPort( ToServiceParameterName2 ) ; + fromDataNodePort1 = GraphBase::DataNode::GetChangeInDataNodePort( toPort1->NodePortName() ) ; +// const char* aDataValue = fromDataNodePort->Value() ; + const CORBA::Any ** aDataValue1 = fromDataNodePort1->ValuePtr() ; + fromDataNodePort2 = GraphBase::DataNode::GetChangeInDataNodePort( toPort2->NodePortName() ) ; + RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort1 , + toNode2 , toPort2 ) ; +// aDataValue ) ; + fromDataNodePort2->Value( aDataValue1 ) ; + } + else { + cdebug << "Node not found" << endl ; + } + + cdebug_out << "GraphBase::Graph::AddInputSharedData" << endl; + return RetVal ; +} + +bool GraphBase::Graph::AddInputData( const char* ToNodeName , + const char* ToServiceParameterName , + const CORBA::Any ** aValue ) { + bool RetVal = false ; + cdebug_in << "GraphBase::Graph::AddInputData(" << ToNodeName << "," + << ToServiceParameterName << " **Any " ; + const CORBA::Any theValue = **aValue ; + switch (theValue.type()->kind()) { + case CORBA::tk_string: + char * t; + theValue >>= t; + cdebug << t << " (string) " ; + break; + case CORBA::tk_double: + double d; + theValue >>= d; + cdebug << d << " (double) " ; + break; + case CORBA::tk_long: + long l; + theValue >>= l; + cdebug << l << " (long) " ; + break; + case CORBA::tk_objref: + cdebug << "(object reference) " ; + break; + default: + cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR"; + break; + } + cdebug << ")" << endl; + + GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ; + + GraphBase::OutPort *fromDataNodePort = NULL ; + GraphBase::InPort *toPort = NULL ; + + if ( toNode ) { + toPort = toNode->GetChangeInPort( ToServiceParameterName ) ; + fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ; + cdebug << "Try AddLink " << Name() << "( " << fromDataNodePort << " ) -->" + << toNode->Name() << "( " << toPort->PortName() << " )" << endl ; + RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort , + toNode , toPort ) ; + if ( RetVal ) { + fromDataNodePort->Value( aValue ) ; + } + } + else { + cdebug << "Node not found" << endl ; + } + + cdebug_out << "GraphBase::Graph::AddInputData" << endl; + return RetVal ; +} + +bool GraphBase::Graph::AddOutputData( + const char* FromNodeName , + const char* FromServiceParameterName , + const CORBA::Any aValue ) { +// const char* DataValue , +// const SUPERV::KindOfPortValue aKindOfPortValue ) { + bool RetVal = false ; + cdebug_in << "GraphBase::Graph::AddOutputData(" << FromNodeName << "," + << FromServiceParameterName +// << FromServiceParameterName << ", " << DataValue << "," +// << aKindOfPortValue + << ")" << endl; +#if 0 + GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ; + + GraphBase::OutPort *fromPort = NULL ; + GraphBase::InPort *toDataNodePort = NULL ; + + if ( fromNode ) { + fromPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ; + toDataNodePort = GraphBase::DataNode::GetChangeOutDataNodePort( fromPort->NodePortName() ) ; + RetVal = AddLink( fromNode , fromPort , + (GraphBase::ComputingNode * ) this , toDataNodePort , + aValue ) ; +// DataValue , aKindOfPortValue ) ; + } + else { + cdebug << "Node not found" << endl ; + } +#endif + cdebug_out << "GraphBase::Graph::AddOutputData" << endl; + return RetVal ; +} + +bool GraphBase::Graph::CreateService() { + cdebug_in << "GraphBase::Graph::CreateService" << endl; + + SALOME_ModuleCatalog::Service aService ; + int i , j ; + GraphBase::ComputingNode * iN ; + int dostore ; + int innbr ; + int outnbr ; + for ( dostore = 0 ; dostore <= 1 ; dostore++ ) { + if ( dostore == 1 ) { + aService.ServiceName = Name() ; + aService.ServiceinParameter.length( 0 ) ; + aService.ServiceinParameter.length( innbr ) ; + aService.ServiceoutParameter.length( 0 ) ; + aService.ServiceoutParameter.length( outnbr ) ; + } + innbr = 0 ; + outnbr = 0 ; + for ( i = 0 ; i < GraphNodesSize() ; i++ ) { + iN = GraphNodes( i ) ; + for ( j = 0 ; j < iN->GetNodeInPortsSize() ; j++ ) { + GraphBase::InPort *anInPort = iN->GetChangeNodeInPort(j) ; + if ( !anInPort->IsConnected() && !anInPort->IsGate() ) { +// !anInPort->IsLoop() ) { +// if ( !anInPort->IsGate() && !anInPort->IsConnected() && +// !( iN->IsLoopNode() && anInPort->IsBus() && anInPort->IsParam() )) { + if ( dostore == 0 ) { + cdebug << "CreateService " << iN->Name() << " Input port " + << anInPort->PortName() << " is NOT connected " ; + if ( anInPort->GetOutPort() ) { + cdebug << *(anInPort->GetOutPort()) ; + } + cdebug << endl ; + innbr += 1 ; + } + else { + aService.ServiceinParameter[innbr].Parametertype = CORBA::string_dup( anInPort->PortType() ) ; + aService.ServiceinParameter[innbr++].Parametername = CORBA::string_dup( anInPort->NodePortName() ) ; + } + } + } + if ( !iN->IsGOTONode() ) { + for ( j = 0 ; j < iN->GetNodeOutPortsSize() ; j++ ) { + GraphBase::OutPort *anOutPort = iN->GetChangeNodeOutPort(j) ; + if ( !anOutPort->IsGate() && +//!anOutPort->IsLoop() && +// !( iN->IsEndLoopNode() && anOutPort->IsBus() ) && + ( anOutPort->IsNotConnected() || anOutPort->IsDataConnected() ) ) { + if ( dostore == 0 ) { + outnbr += 1 ; + } + else { + aService.ServiceoutParameter[outnbr].Parametertype = CORBA::string_dup( anOutPort->PortType() ) ; + aService.ServiceoutParameter[outnbr++].Parametername = CORBA::string_dup( anOutPort->NodePortName() ) ; + } + } + } + } + } + } + +// MESSAGE( "DataFlowNode ServiceName " << aService.ServiceName ); +// for ( i = 0 ; i < innbr ; i++ ) { +// cout << "aService.ServiceinParameter[" << i << "].Parametertype " +// << aService.ServiceinParameter[i].Parametertype << endl ; +// cout << "aService.ServiceinParameter[" << i << "].Parametername " +// << aService.ServiceinParameter[i].Parametername << endl ; +// } +// for ( i = 0 ; i < outnbr ; i++ ) { +// cout << "aService.ServiceoutParameter[" << i << "].Parametertype " +// << aService.ServiceoutParameter[i].Parametertype << endl ; +// cout << "aService.ServiceoutParameter[" << i << "].Parametername " +// << aService.ServiceoutParameter[i].Parametername << endl ; +// } + + DataService( _Orb , aService , Graph_prof_debug() , Graph_fdebug() ) ; + +// Restore input datas : + for ( i = 0 ; i < GraphNodesSize() ; i++ ) { +// iN = (GraphEditor::InNode * ) GraphNodes( i ) ; + iN = GraphNodes( i ) ; + for ( j = 1 ; j < iN->GetNodeInPortsSize() ; j++ ) { + GraphBase::InPort *anInPort = iN->GetChangeNodeInPort(j) ; + if ( anInPort->IsDataConnected() ) { +// GraphBase::Graph::AddInputData( anInPort->NodeName() , + AddInputData( anInPort->NodeName() , + anInPort->PortName() , + anInPort->GetOutPort()->ValuePtr() ) ; + } + } + } + + cdebug_out << "GraphBase::Graph::CreateService" << endl; + return true ; +} + +bool GraphBase::Graph::InLineServices() { + cdebug_in << "GraphBase::Graph::InLineServices" << endl; + + int i , j ; + GraphBase::InLineNode * aINode ; + SALOME_ModuleCatalog::Service aService ; + for ( i = 0 ; i < GraphNodesSize() ; i++ ) { + aINode = (GraphBase::InLineNode * ) GraphNodes( i ) ; + if ( aINode->IsOneOfInLineNodes() ) { + cdebug << "GraphBase::Graph::InLineServices " << aINode->Name() << endl; + aService.ServiceName = aINode->ServiceName() ; + aService.ServiceinParameter.length( 0 ) ; + aService.ServiceoutParameter.length( 0 ) ; + int InService = 0 ; + for ( j = 0 ; j < aINode->GetNodeInPortsSize() ; j++ ) { + if ( aINode->GetChangeNodeInPort(j)->IsGate() || + aINode->GetChangeNodeInPort(j)->IsLoop() ) { + cdebug << "GraphBase::Graph::InLineServices In" << j << " " + << aINode->GetChangeNodeInPort(j)->Kind() << " " + << aINode->GetChangeNodeInPort(j)->PortType() << " " + << aINode->GetChangeNodeInPort(j)->PortName() << " ignored " + << aINode->GetChangeNodeInPort(j)->IsGate() << " " + << aINode->GetChangeNodeInPort(j)->IsLoop() << endl; + } + else { + aService.ServiceinParameter.length( InService+1 ) ; + aService.ServiceinParameter[InService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortType() ) ; + aService.ServiceinParameter[InService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ; + cdebug << "GraphBase::Graph::InLineServices In" << j << " " + << aINode->GetChangeNodeInPort(j)->Kind() << " " + << aINode->GetChangeNodeInPort(j)->PortType() << " " + << aINode->GetChangeNodeInPort(j)->PortName() << " " + << aINode->GetChangeNodeInPort(j)->IsGate() << " " + << aINode->GetChangeNodeInPort(j)->IsLoop() << endl; + } + } + int OutService = 0 ; + for ( j = 0 ; j < aINode->GetNodeOutPortsSize() ; j++ ) { + if ( aINode->GetChangeNodeOutPort(j)->IsGate() || + aINode->GetChangeNodeOutPort(j)->IsLoop() ) { + cdebug << "GraphBase::Graph::InLineServices Out" << j << " " + << aINode->GetChangeNodeOutPort(j)->Kind() << " " + << aINode->GetChangeNodeOutPort(j)->PortType() << " " + << aINode->GetChangeNodeOutPort(j)->PortName() << " ignored " + << aINode->GetChangeNodeOutPort(j)->IsGate() << " " + << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl; + } + else { + aService.ServiceoutParameter.length( OutService+1 ) ; + aService.ServiceoutParameter[OutService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortType() ) ; + aService.ServiceoutParameter[OutService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ; + cdebug << "GraphBase::Graph::InLineServices Out" << j << " " + << aINode->GetChangeNodeOutPort(j)->Kind() << " " + << aINode->GetChangeNodeOutPort(j)->PortType() << " " + << aINode->GetChangeNodeOutPort(j)->PortName() << " " + << aINode->GetChangeNodeOutPort(j)->IsGate() << " " + << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl; + } + } + aINode->SetService( aService ) ; + cdebug << "GraphBase::Graph::InLineServices" << *aINode->GetService() << endl; + } + } + + cdebug_out << "GraphBase::Graph::InLineServices" << endl; + return true ; +} + +bool GraphBase::Graph::Sort() { + int i ; + int j ; + int NotSortedNumber = GraphNodesSize() ; + bool NewSorted ; + if ( NotSortedNumber ) { + _LevelsNumber = 0 ; + _ParallelExecutionNodes = false ; + _Sorted.resize( GraphNodesSize() ) ; + _CnxInPortsNumber.resize( GraphNodesSize() ) ; + _DecrInPortsNumber.resize( GraphNodesSize() ) ; + if ( _NodesNumber.size() ) + _NodesNumber.resize( 0 ) ; + _SortedNodes.resize( 0 ) ; + for ( i = 0 ; i < GraphNodesSize() ; i++ ) { + _Sorted[ i ] = false ; + _CnxInPortsNumber[ i ] = GraphNodes( i )->ConnectedInPortsNumber() ; + _DecrInPortsNumber[ i ] = 0 ; + } + while ( NotSortedNumber ) { + NewSorted = false ; + for ( i = 0 ; i < GraphNodesSize() ; i++ ) { + cdebug << "Sort level " << _LevelsNumber << ". [" << i << "] " + << GraphNodes( i )->Name() << " count " + << _CnxInPortsNumber[ i ] << endl ; + if ( !_Sorted[ i ] && _CnxInPortsNumber[ i ] == 0 ) { +// All inputs of GraphNodes( i ) are available + if ( _NodesNumber.size() != _LevelsNumber+1 ) { + _NodesNumber.resize( _LevelsNumber+1 ) ; + _SortedNodes.resize( _LevelsNumber+1 ) ; + _NodesNumber[ _LevelsNumber ] = -1 ; + } + _NodesNumber[ _LevelsNumber ]++ ; + (_SortedNodes[ _LevelsNumber ]).resize( _NodesNumber[ _LevelsNumber ]+1 ) ; + (_SortedNodes[ _LevelsNumber ])[ _NodesNumber[ _LevelsNumber ] ] = GraphNodes( i ) ; + _Sorted[ i ] = true ; + NewSorted = true ; + cdebug << GraphNodes( i )->Name() << " belongs to level " + << _LevelsNumber << "." << endl ; + for ( j = 0 ; j < GraphNodes( i )->LinkedNodesSize() ; j++ ) { +// Outputs of GraphNodes( i ) will satisfy +// GraphNodes( i )->LinkedInPortsNumber( j ) InPorts of +// GraphNodes( i )->LinkedNodes( j ) + GraphBase::ComputingNode * aLinkedNode = GraphNodes( i )->LinkedNodes( j ) ; + int aLinkedInPortsNumber = GraphNodes( i )->LinkedInPortsNumber( j ) ; + cdebug << j << ". LinkedNode " << aLinkedNode->Name() ; + if ( !aLinkedNode->IsDataFlowNode() ) { + cdebug << " _DecrInPortsNumber[ " + << GetGraphNodeIndex( aLinkedNode->Name() ) + << " ] = " + << _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ] + << " += " << aLinkedInPortsNumber ; + _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ] += aLinkedInPortsNumber ; + } + cdebug << endl ; +// GraphNodes( i )->LinkedNodes( j )->IncrDecrConnectedInPortsNumber( GraphNodes( i )->LinkedInPortsNumber( j ) ) ; + } + } + } + if ( !NewSorted ) { + cdebug << "Loop detected level " << _LevelsNumber << endl ; + return false ; // Loop in the Graph + } + cdebug << "Bilan level " << _LevelsNumber << " : " << endl ; + bool ChangeCount = false ; + for ( i = 0 ; i < GraphNodesSize() ; i++ ) { +// if ( GraphNodes( i )->DecrIncrDecrConnectedInPortsNumber() ) { + if ( _DecrInPortsNumber[ i ] ) { + int prevcount = _CnxInPortsNumber[ i ] ; + _CnxInPortsNumber[ i ] -= _DecrInPortsNumber[ i ] ; + _DecrInPortsNumber[ i ] = 0 ; + ChangeCount = true ; + cdebug << " " << GraphNodes( i )->Name() << " count " << prevcount + << " --> new count " << _CnxInPortsNumber[ i ] << endl ; + } + } + if ( !ChangeCount ) + break ; + _LevelsNumber += 1 ; + } + _ThreadsMax = 0 ; + int AllSortedNodes = 0 ; + _HeadNodes = _SortedNodes[ 0 ] ; + _HeadNodesSize = _SortedNodes[ 0 ].size() ; + _QueueNodes = _SortedNodes[ _LevelsNumber ] ; + _QueueNodesSize = _SortedNodes[ _LevelsNumber ].size() ; + for ( i = 0 ; i < _QueueNodesSize ; i++ ) { + if ( !_QueueNodes[ i ]->IsGOTONode() ) { + break ; + } + } + if ( i == _QueueNodesSize && _LevelsNumber ) { + _QueueNodes = _SortedNodes[ _LevelsNumber - 1 ] ; + _QueueNodesSize = _SortedNodes[ _LevelsNumber - 1 ].size() ; + } + for ( i = 0 ; i <= _LevelsNumber ; i++ ) { + AllSortedNodes += _NodesNumber[ i ]+1 ; + if ( _NodesNumber[ i ] + 1 > _ThreadsMax ) + _ThreadsMax = _NodesNumber[ i ] + 1 ; + cdebug << _NodesNumber[ i ]+1 << " Nodes of level " << i << " : " + << (_SortedNodes[ i ])[ 0 ]->Name() << endl ; + for ( j = 1 ; j <= _NodesNumber[ i ] ; j++ ) { + _ParallelExecutionNodes = true ; + cdebug << " " << (_SortedNodes[ i ])[ j ]->Name() + << endl ; + } + } + if ( _ParallelExecutionNodes ) { + cdebug << "Parallel Execution Nodes detected." << endl ; + } + else { + cdebug << "No Parallel Execution Nodes detected." << endl ; + } + if ( AllSortedNodes != GraphNodesSize() ) { + cdebug << "Loop detected level " << _LevelsNumber << endl ; + return false ; // Loop in the Graph + } + + for ( i= 0 ; i <= _NodesNumber[ 0 ] ; i++ ) { + (_SortedNodes[ 0 ])[ i ]->HeadNode( true ) ; + } + + for ( i = 0 ; i <= _NodesNumber[ 0 ] ; i++ ) { + (_SortedNodes[ 0 ])[ i ]->Level( 0 ) ; + (_SortedNodes[ 0 ])[ i ]->SubGraph( i + 1 ) ; + } + for ( i = 1 ; i <= _LevelsNumber ; i++ ) { + for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) { + (_SortedNodes[ i ])[ j ]->Level( i ) ; + (_SortedNodes[ i ])[ j ]->SubGraph( 0 ) ; + } + } + bool Graphs = true ; + while ( Graphs ) { + for ( i = 0 ; i <= _LevelsNumber ; i++ ) { + for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) { + GraphBase::ComputingNode * aNode = (_SortedNodes[ i ])[ j ] ; + cdebug << "Graph " << aNode->SubGraph() << " " << aNode->Name() + << endl ; + int k ; + for ( k = 0 ; k < aNode->LinkedNodesSize() ; k++ ) { + if ( aNode->LinkedNodes( k )->SubGraph() ) { + if ( aNode->LinkedNodes( k )->SubGraph() != aNode->SubGraph() && + aNode->LinkedNodes( k )->Level() == aNode->Level()+1 ) { + aNode->SubGraph( aNode->LinkedNodes( k )->SubGraph() ) ; + cdebug << " Linked " << aNode->LinkedNodes( k )->Name() + << " Graph(" << aNode->LinkedNodes( k )->SubGraph() + << ") ==>" << endl ; + cdebug << " Graph " << aNode->SubGraph() << " for " + << aNode->Name() << " ==> again" << endl ; + int l ; + for ( l = 0 ; l < aNode->LinkedNodesSize() ; l++ ) { + aNode->LinkedNodes( l )->SubGraph( aNode->SubGraph() ) ; + } + Graphs = false ; + break ; + } + else { + cdebug << " Linked " << aNode->LinkedNodes( k )->Name() + << " Graph(" << aNode->LinkedNodes( k )->SubGraph() + << ") distance > 1 ignored" << endl ; + } + } + else { + cdebug << " Linked " << aNode->LinkedNodes( k )->Name() + << " GraphInit to " << aNode->SubGraph() << " from " + << aNode->Name() << endl ; + aNode->LinkedNodes( k )->SubGraph( aNode->SubGraph() ) ; + } + } + } + if ( !Graphs ) + break ; + } + if ( Graphs ) { + cdebug << endl << "Graphs result : " << endl ; + break ; + } + cdebug << endl << "One more time" << endl ; + Graphs = true ; + } + _GraphsNumber = 0 ; + int CurrGraphsNumber = 0; + int k ; + for ( k = 0 ; k <= _NodesNumber[ 0 ] ; k++ ) { + if ( (_SortedNodes[ 0 ])[ k ]->SubGraph() > CurrGraphsNumber ) { + CurrGraphsNumber = (_SortedNodes[ 0 ])[ k ]->SubGraph() ; + _GraphsNumber += 1 ; + for ( i = 0 ; i <= _LevelsNumber ; i++ ) { + for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) { + if ( (_SortedNodes[ i ])[ j ]->SubGraph() == CurrGraphsNumber ) { + (_SortedNodes[ i ])[ j ]->SubGraph( _GraphsNumber ) ; + cdebug << "GraphsNumber " << _GraphsNumber << " " << " Level " + << i << " : " << (_SortedNodes[ i ])[ j ]->Name() + << endl ; + } + } + } + } + } + } + + return true ; +} + +// Controle de la coherence des noeuds de calcul +// Enregistrement dans la liste des noeuds "tete" de graphe + +bool GraphBase::Graph::ComputingNodes() const { + bool RetVal = true ; + cdebug << "GraphExecutor::GraphControl::ComputingNodes ()" << endl; + +// list aComputingNodesList = _G->ComputingNodesList() ; +// list::iterator iN = aComputingNodesList.begin(); +// GraphEditor::Port * iP; + +// for (iN = _G->ComputingNodesList().begin(); iN !=_G->ComputingNodesList().end(); iN++) { +// while ( iN != aComputingNodesList.end() ) { + int i ; + GraphBase::ComputingNode * iN ; + for ( i = 0 ; i < GraphNodesSize() ; i++ ) { + iN = GraphNodes( i ) ; + // Tous les ports d'entree de tous les noeuds de calcul sont bien connectes + // Enregistrement eventuel dans la liste des noeuds "tete" de graphe +// if ((*iN)->GetNodeInPortsSize() == 0) +// _headNodes.push_front(*iN); + int j ; + for ( j = 1; j < iN->GetNodeInPortsSize() ; j++ ) { + const GraphBase::InPort *iP = iN->GetNodeInPort(j); + if ( !iP->IsConnected() ){ + cdebug << "Le port d'entree " << iP->PortName() + << " du noeud de calcul " << iN->Name() << " du graphe " + << Name() << " n'est pas connecte "<< endl; + RetVal = false ; + }; + + }; + + // Tous les noeuds de calcul ont au moins un port de sortie connecte + bool oneOutPortConnected = false; + for ( j = 1; j < iN->GetNodeOutPortsSize() ; j++) { + const GraphBase::OutPort *iP = iN->GetNodeOutPort(j); + if ( iP->IsPortConnected() || iP->IsDataConnected() ){ + oneOutPortConnected = true ; +// break; + } + else { + cdebug << "Le port de sortie " << iP->PortName() + << " du noeud de calcul " << iN->Name() << " du graphe " + << Name() << " n'est pas connecte "<< endl; + RetVal = false ; + } + }; + if (!oneOutPortConnected) { + cdebug << "Le noeud de calcul " << iN->Name() << " du graphe " + << Name() << " n'a aucun port de sortie connecte "<< endl; +// _computingError.push_front(2); + } + }; +// return _computingError.size () ; + return RetVal ; +} + +// Controle de la coherence des noeuds de calcul +// Enregistrement dans la liste des noeuds "tete" de graphe + +bool GraphBase::Graph::DataServerNodes() const { + + cdebug << "GraphBase::Graph::DataServerNodes ()" << endl; + +// const GraphExecutor::InNode *DataFlowDatas = GetDataFlowDatas() ; + int i , j , ierr = 0 ; + +// if ( DataFlowDatas == NULL ) { +// MESSAGE( "No input data available in the DataFlow " << _G->Name() ); +// return 0 ; +// } + +// const GraphExecutor::InNode *DataFlowNode = _G->GetDataFlowNode() ; +// MESSAGE( "DataServerNodes DataFlowNode : " << *DataFlowNode ); + +// MESSAGE( "DataServerNodes DataFlowDatas : " << *DataFlowDatas ); + +// cout are inversed because DataFlowDatas is a mirror node of the DataFlow + + ierr = CheckDataServerNodes() ; + +// list aComputingNodesList = _G->ComputingNodesList() ; +// list::iterator iN = aComputingNodesList.begin(); + if ( GraphNodesSize() == 0 ) { + ierr++ ; + } + else { + GraphBase::ComputingNode * iN ; + for ( i = 0 ; i < GraphNodesSize() ; i++ ) { + iN = GraphNodes( i ) ; +// while ( iN != aComputingNodesList.end() ) { + if ( iN->IsFactoryNode() ) { + GraphBase::FactoryNode * FiN = (GraphBase::FactoryNode * ) iN ; + if ( !strlen( FiN->Computer() ) ) { + cdebug << "ComputerName missing for node " << FiN->Name() ; + if ( !strlen( FiN->Computer() ) ) { + ierr++ ; + cdebug << endl ; + } + else { + cdebug << ". " << FiN->Computer() << " will be used." << endl ; + } + } + } +// For Outputs of the DataFlow : + for ( j = 0 ; j < iN->GetNodeOutPortsSize() ; j++ ) { + if ( !iN->GetNodeOutPort(j)->IsConnected() ) { + iN->AddLink( (GraphBase::ComputingNode *) this ) ; + } + } + } + } + +// Chaque noeud dataserver ne possede qu'un seul port entree ou sortie et il est bien connecte + +// list aDataServerNodesList = _G->DataServerNodesList() ; +// list::iterator it = aDataServerNodesList.begin() ; + +// for (it = _G->DataServerNodesList().begin(); it !=_G->DataServerNodesList().end(); it++){ +// while ( it != aDataServerNodesList.end() ) { +// if ( (*it)->GetNodeOutPortsSize() && (*it)->GetNodeInPortsSize() ) { +// cerr << "Erreur dans le noeud serveur de donnees " +// << (*it)->Name() << " du graphe " << _G->Name() << endl; +// cerr << "A la fois importation et exportation de donnees" << endl; +// _dataServerError.push_front(1); +// } + +// if ((*it)->GetNodeOutPortsSize()) { +// if ((*it)->GetNodeOutPortsSize()==1){ +// if ( (*it)->GetNodeOutPort(0)->IsPortConnected() ){ +// _headNodes.push_front(*it); +// } +// else { +// cerr << "Le port de sortie du noeud serveur de donnees " +// << (*it)->Name() << " du graphe " << _G->Name() +// << " n'est pas connecte "<< endl; +// _dataServerError.push_front(4); +// } +// } +// else { +// cerr << "Plus d'une donnee importee du noeud serveur de donnees " +// << (*it)->Name() << " du graphe " << _G->Name() << endl; +// _dataServerError.push_front(2); +// } +// } + +// if ((*it)->GetNodeInPortsSize()) { +// if ((*it)->GetNodeInPortsSize() > 1){ +// cerr << "Plus d'une donnee exportee vers le noeud serveur de donnees " +// << (*it)->Name() << " du graphe " << _G->Name() << endl; +// _dataServerError.push_front(3); +// } +// else +// if ( !(*it)->GetNodeInPort(0)->IsPortConnected() ){ +// cerr << "Le port d'entree du noeud serveur de donnees " +// << (*it)->Name() << " du graphe " << _G->Name() +// << " n'est pas connecte "<< endl; +// _dataServerError.push_front(5); +// } +// } +// it++ ; +// }; + +// return _dataServerError.size (); + return ( ierr == 0 ) ; +} + +SUPERV::GraphState GraphBase::Graph::PortState( + const char* NodeName , + const char* ServiceParameterName ) { + SUPERV::GraphState aRet = SUPERV::UndefinedState ; +// cdebug << "GraphBase::Graph::PortState( " << NodeName << " , " +// << ServiceParameterName << " )" << endl ; + + char *theNode ; + char *aPort ; + NodePort( NodeName , ServiceParameterName , &theNode , &aPort ) ; + + GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ; + if ( aNode ) { + GraphBase::OutPort *anOutPort ; + anOutPort = aNode->GetChangeOutPort( aPort ); + if ( anOutPort == NULL ) { + GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort ); + if ( anInPort ) + anOutPort = anInPort->GetOutPort() ; + else { + cdebug << "GraphBase::Graph::PortState OutPort/InPort not found --> " + << aRet << endl ; + } + } + if ( anOutPort ) { + aRet = anOutPort->State() ; +// cdebug << "GraphBase::Graph::PortState --> " << aRet << endl ; + } + } + else { + cdebug << "GraphBase::Graph::PortState Node not found --> " << aRet + << endl ; + } + delete theNode ; + delete aPort ; + return aRet ; +} + +const CORBA::Any * GraphBase::Graph::PortInData( const char* ToNodeName , + const char* ToServiceParameterName ) { + const CORBA::Any * aRet = new CORBA::Any() ; + char *theNode ; + char *aPort ; + cdebug_in << "GraphBase::Graph::PortData " << ToNodeName << " " + << ToServiceParameterName << endl ; + NodePort( ToNodeName , ToServiceParameterName , &theNode , &aPort ) ; + + GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ; + + if ( aNode ) { + GraphBase::OutPort *anOutPort = NULL ; + GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort ); + if ( anInPort ) { + anOutPort = anInPort->GetOutPort() ; + if ( anOutPort ) { + aRet = anOutPort->Value() ; + cdebug << "OutPort value " << anOutPort->NodeName() << "(" + << anOutPort->PortName() << ") --> InPort " << anInPort->NodeName() + << "(" << anInPort->PortName() << ")" << endl ; + } + } + } + delete theNode ; + delete aPort ; + cdebug_out << "GraphBase::Graph::PortData " << endl ; + return aRet ; +} + +const CORBA::Any * GraphBase::Graph::PortOutData( const char* FromNodeName , + const char* FromServiceParameterName ) { + const CORBA::Any * aRet = new CORBA::Any() ; + char *theNode ; + char *aPort ; + cdebug_in << "GraphBase::Graph::PortOutData " << FromNodeName << " " + << FromServiceParameterName << endl ; + NodePort( FromNodeName , FromServiceParameterName , &theNode , &aPort ) ; + + GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ; + + if ( aNode ) { + GraphBase::OutPort *anOutPort ; + anOutPort = aNode->GetChangeOutPort( aPort ); + if ( anOutPort ) + aRet = anOutPort->Value() ; + } + delete theNode ; + delete aPort ; + cdebug_out << "GraphBase::Graph::PortOutData " << endl ; + return aRet ; +} + +SUPERV::ListOfStrings * GraphBase::Graph::LevelNodes(long aLevel ) { + SUPERV::ListOfStrings_var RetVal = new SUPERV::ListOfStrings; + if ( aLevel >= 0 && aLevel <= _LevelsNumber ) { + int i ; + RetVal->length( _NodesNumber[ aLevel ] + 1 ); + for ( i= 0 ; i <= _NodesNumber[ aLevel ] ; i++ ) { + RetVal[i] = CORBA::string_dup( (_SortedNodes[ aLevel ])[ i ]->Name() ) ; + } + } + return ( RetVal._retn() ) ; +} + +bool GraphBase::Graph::StartComponent(const int aThread , + const char * aComputerContainer , + const char * ComponentName , + Engines::Container_var & myContainer , + Engines::Component_var & objComponent ) { + cdebug_in << aThread + << " GraphBase::Graph::StartComponent " << aComputerContainer + << " " << ComponentName << endl; + bool RetVal = true ; + + SALOME_LifeCycleCORBA LCC( NamingService() ) ; + objComponent = LCC.FindOrLoad_Component( aComputerContainer , + ComponentName ); + if ( CORBA::is_nil( objComponent ) ) { + cdebug_out << aThread + << " StartComponent cannot FindOrLoad " << aComputerContainer + << " " << ComponentName << endl; + return 0 ; + } + else { + myContainer = LCC.FindContainer( aComputerContainer ); + if ( CORBA::is_nil( myContainer ) ) { + cdebug_out << aThread + << " GraphBase::Graph::StartComponent myContainer = LCC.FindContainer( '" + << aComputerContainer << "' ) Container does not exist" + << endl ; + return 0 ; + } + } + cdebug_out << aThread << " GraphBase::Graph::StartComponent" << endl; + return RetVal ; +} + diff --git a/src/GraphBase/DataFlowBase_Graph.hxx b/src/GraphBase/DataFlowBase_Graph.hxx new file mode 100644 index 0000000..cafe53a --- /dev/null +++ b/src/GraphBase/DataFlowBase_Graph.hxx @@ -0,0 +1,272 @@ +//============================================================================= +// File : DataFlowBase_Graph.hxx +// Created : 2002 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#ifndef _DATAFLOWBASE_GRAPH_HXX +#define _DATAFLOWBASE_GRAPH_HXX + +#include "DataFlowBase_FactoryNode.hxx" +#include "DataFlowBase_LoopNode.hxx" +#include "DataFlowBase_EndOfLoopNode.hxx" +#include "DataFlowBase_SwitchNode.hxx" +#include "DataFlowBase_EndOfSwitchNode.hxx" +#include "DataFlowBase_DataNode.hxx" + +class Graph_Impl ; + +namespace GraphBase { + + class Graph : public DataNode { + + private: + + int _Graph_prof_debug; + ostream * _Graph_fdebug; + CORBA::ORB_ptr _Orb ; + SUPERV::Graph_var _Graph ; + Graph_Impl * _GraphImpl ; + +// Map of InNodes of the OutNode + map< string , int > _MapOfGraphNodes ; + long _GraphNodesSize ; + vector _Sorted ; + vector _GraphNodes ; + +// _SortedNodes[ _LevelsNumber ] : topological sort from 0 to _LevelsNumber +// _SortedNodes[ _level ][ _NodesNumber[ _level ] ] : _NodesNumber[ _level ] Nodes + int _LevelsNumber ; + int _ThreadsMax ; + int _GraphsNumber ; + vector _NodesNumber ; + vector > _SortedNodes ; + + vector _CnxInPortsNumber ; + vector _DecrInPortsNumber ; + + long _HeadNodesSize ; + vector _HeadNodes ; + long _QueueNodesSize ; + vector _QueueNodes ; + bool _ParallelExecutionNodes ; + + bool AddLink( GraphBase::ComputingNode *fromNode , + GraphBase::OutPort *fromPort , + GraphBase::ComputingNode *toNode , + GraphBase::InPort *toPort ) ; + + public: + + Graph() ; + Graph( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char *DataFlowName , + const char * DebugFileName ) ; + Graph( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const SALOME_ModuleCatalog::Service& DataFlowService , + const char *DataFlowComponentName , + const char *DataFlowInterfaceName , + const char *DataFlowName , + const SUPERV::KindOfNode DataFlowkind , + const SUPERV::SDate DataFlowFirstCreation , + const SUPERV::SDate DataFlowLastModification , + const char * DataFlowEditorRelease , + const char * DataFlowAuthor , + const char * DataFlowComputer , + const char * DataFlowComment , + const char * DebugFileName ) ; + virtual ~Graph() ; + + void Set_prof_debug( CORBA::ORB_ptr ORB , + const char * DebugFileName ) ; + int * Graph_prof_debug() { return &_Graph_prof_debug ; } ; + ostream * Graph_fdebug() { return _Graph_fdebug ; } ; + + SUPERV::Graph_var ObjRef() const { return _Graph ; } ; + void SetObjRef( SUPERV::Graph_var aGraph ) { + _Graph = aGraph ; } ; + Graph_Impl * ObjImpl() const { return _GraphImpl ; } ; + void SetObjImpl( Graph_Impl * aGraphImpl ) { + _GraphImpl = aGraphImpl ; } ; + + void AddLink( const char* FromNodeName , GraphBase::ComputingNode * anOutNode ) { + GetChangeGraphNode( FromNodeName )->AddLink( anOutNode ) ; } ; + + const int GetGraphNodeIndex( const char *name ) { + const int index = _MapOfGraphNodes[ name ] - 1 ; +// if ( index >= 0 ) +// cdebug << "GetGraphNodeIndex of " << name << " in _MapOfGraphNodes : " +// << index << " Node " << hex << (void *) _GraphNodes[ index ] +// << dec << " '" << _GraphNodes[ index ]->Name() << "'" << endl ; + return index ; } ; + void SetGraphNodeIndex( const char *name , const int index ) { + _MapOfGraphNodes[ name ] = index + 1 ; + cdebug << "SetGraphNodeIndex of " << name << " in _MapOfGraphNodes : " + << index << " Node " << hex << (void *) _GraphNodes[ index ] + << " '" << _GraphNodes[ index ]->Name() << "'" << endl ; + } ; + void DelGraphNodeIndex( const char *name ) { + _MapOfGraphNodes.erase( name ) ; } ; + const GraphBase::ComputingNode * GetGraphNode( const int index ) const { + const ComputingNode * aNode = GetChangeGraphNode( index ) ; + return aNode ; } ; + ComputingNode * GetChangeGraphNode( const int index ) const { + if ( index >= 0 && index < _GraphNodesSize ) { + ComputingNode * aNode = _GraphNodes[ index ] ; + return aNode ; + } + else + return NULL ; } ; + const ComputingNode * GetGraphNode( const char *name ) { + const ComputingNode * aNode = GetChangeGraphNode( name ) ; + return aNode ; } ; + ComputingNode * GetChangeGraphNode( const char *name ) { + int index = GetGraphNodeIndex( name ) ; + if ( index >= 0 && index < _GraphNodesSize ) { + ComputingNode * aNode = GetChangeGraphNode( index ) ; + return aNode ; + } + else + return NULL ; } ; + + const int GraphNodesSize() const { + return _GraphNodesSize ; } ; + ComputingNode * GraphNodes( int i ) const { + return _GraphNodes[ i ] ; } ; + + const int HeadNodesSize() const { + return _HeadNodesSize ; } ; + ComputingNode * HeadNodes( int i ) const { + return _HeadNodes[ i ] ; } ; + + const int QueueNodesSize() const { + return _QueueNodesSize ; } ; + ComputingNode * QueueNodes( int i ) const { + return _QueueNodes[ i ] ; } ; + + const GraphBase::InPort *GetInPort( const char* ToNodeName , + const char* ToServiceParameterName ) { + ComputingNode * aNode = GetChangeGraphNode( ToNodeName ) ; + if ( aNode ) { + return aNode->GetInPort(ToServiceParameterName); + } + else + return NULL ; } ; + GraphBase::InPort *GetChangeInPort( const char* ToNodeName , + const char* ToServiceParameterName ) { + ComputingNode * aNode = GetChangeGraphNode( ToNodeName ) ; + if ( aNode ) { + return aNode->GetChangeInPort(ToServiceParameterName); + } + else + return NULL ; } ; + GraphBase::OutPort *GetChangeOutPort( + const char* FromNodeName , + const char* FromServiceParameterName ) { + ComputingNode * aNode = GetChangeGraphNode( FromNodeName ) ; + if ( aNode ) { + return aNode->GetChangeOutPort( FromServiceParameterName ); + } + else + return NULL ; } ; + + SUPERV::GraphState PortState( const char* NodeName , + const char* ServiceParameterName ) ; + bool PortDone( const char* NodeName , + const char* ServiceParameterName ) { + bool aRet = false ; + SUPERV::GraphState aState = PortState( NodeName , + ServiceParameterName ) ; + if ( aState == SUPERV::DoneState ) + aRet = true ; + return aRet ; } ; + const CORBA::Any * PortInData( const char* ToNodeName , + const char* ToServiceParameterName ) ; + const CORBA::Any * PortOutData( const char* FromNodeName , + const char* FromServiceParameterName ) ; + + bool LoadXml( CORBA::ORB_ptr Orb , const char* anXmlFile , + GraphBase::SGraph & aDataFlow ) ; + + GraphBase::SNode * GetInfo() const ; + GraphBase::ListOfNodes * GetNodes() const ; + GraphBase::ListOfLinks * GetLinks() const ; + GraphBase::ListOfGraphs * GetGraphs() const ; + GraphBase::ListOfLinks * GetDatas() const ; +// SALOME_ModuleCatalog::Service * GetService() const ; + + bool AddNode( ComputingNode * aNode ) ; + bool RemoveNode( const char* NodeName ) ; + bool ReNameNode( const char* OldNodeName , + const char* NewNodeName ) ; + + bool AddLink( const char* FromNodeName , + const char* FromServiceParameterName , + const char* ToNodeName , + const char* ToServiceParameterName , + const CORBA::Any aValue ) ; + bool RemoveLink( const char* FromNodeName , + const char* FromServiceParameterName , + const char* ToNodeName , + const char* ToServiceParameterName ) ; + bool GetLink( const char* ToNodeName , + const char* ToServiceParameterName , + char** FromNodeName , + char** FromServiceParameterName ) ; + GraphBase::SLink * GetLink( GraphBase::ComputingNode * aNode , + GraphBase::InPort* toPort ) ; + + bool AddInputData( const char* ToNodeName , + const char* ToParameterName , + const CORBA::Any aValue ) ; + bool ChangeInputData( const char* ToNodeName , + const char* ToParameterName , + const CORBA::Any aValue ) ; + bool AddInputData( const char* ToNodeName1 , + const char* ToParameterName1 , + const char* ToNodeName2 , + const char* ToParameterName2 ) ; + + bool AddInputData( const char* ToNodeName , + const char* ToParameterName , + const CORBA::Any ** aValue ) ; + + bool AddOutputData( const char* FromNodeName , + const char* FromParameterName , + const CORBA::Any aValue ) ; + + bool CreateService() ; + bool InLineServices() ; + + bool Sort() ; + bool ComputingNodes() const ; + bool DataServerNodes() const ; + + long LevelMax() { + return _LevelsNumber + 1 ; } ; + SUPERV::ListOfStrings * LevelNodes(long aLevel ) ; + long ThreadsMax() { + return _ThreadsMax ; } ; + long GraphsNumber() { + return _GraphsNumber ; } ; + + int NodesNumber(const int aLevel ) { + return _NodesNumber[ aLevel ] ; } ; + GraphBase::ComputingNode * SortedNodes( const int aLevel , const int index ) { + return (_SortedNodes[ aLevel ])[ index ] ; } ; + + bool StartComponent( const int aThread , + const char * ComputerContainer , + const char * ComponentName , + Engines::Container_var & myContainer , + Engines::Component_var & objComponent ) ; + + }; + +}; + +#endif diff --git a/src/GraphBase/DataFlowBase_InLineNode.cxx b/src/GraphBase/DataFlowBase_InLineNode.cxx new file mode 100644 index 0000000..300e570 --- /dev/null +++ b/src/GraphBase/DataFlowBase_InLineNode.cxx @@ -0,0 +1,177 @@ +using namespace std; +//============================================================================= +// File : DataFlowBase_InLineNode.cxx +// Created : 2003 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#include +#include + +#include "DataFlowBase_InLineNode.hxx" + +GraphBase::InLineNode::InLineNode() : + GraphBase::ComputingNode::ComputingNode() { + _PythonFunction = SUPERV::ListOfStrings() ; +} + +GraphBase::InLineNode::InLineNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char * aDataFlowName , + int * Graph_prof_debug , + ostream * Graph_fdebug ) : + GraphBase::ComputingNode::ComputingNode( ORB , ptrNamingService , aDataFlowName , + Graph_prof_debug , Graph_fdebug ) { + _PythonFunction = SUPERV::ListOfStrings() ; + cdebug << "GraphBase::InLineNode::Node " << this + << "' _Name " + << (void *) Name() << " '" << Name() << " _Comment " + << (void *) Comment() << " " << Comment() << " " << endl ; +} + +GraphBase::InLineNode::InLineNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const SALOME_ModuleCatalog::Service& NodeService , + const char *NodeName , + const SUPERV::KindOfNode akind , + const SUPERV::SDate NodeFirstCreation , + const SUPERV::SDate NodeLastModification , + const char * NodeEditorRelease , + const char * NodeAuthor , + const char * NodeComment , + const bool GeneratedName , + const long X , + const long Y , + int * Graph_prof_debug , + ostream * Graph_fdebug ) : + GraphBase::ComputingNode::ComputingNode( ORB , ptrNamingService , + NodeService , + NodeName , akind , NodeFirstCreation , + NodeLastModification , + NodeEditorRelease , + NodeAuthor , NodeComment , GeneratedName , + X , Y , + Graph_prof_debug , Graph_fdebug ) { + _PythonFunction = SUPERV::ListOfStrings() ; + cdebug_in << "GraphBase::InLineNode::Node " << this + << "' _Name " + << (void *) Name() << " '" << Name() << " _Comment " + << (void *) Comment() << " " << Comment() << " " + << " KindOfNode " << Kind() + << " ServiceName " << ServiceName() << " In(" + << ServiceInParameter().length() + << ") Out(" << ServiceOutParameter().length() << ")" << endl ; + + cdebug_out << "GraphBase::InLineNode::Node" << endl; +} + +GraphBase::InLineNode::InLineNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char * FuncName , + const SUPERV::ListOfStrings & aPythonFunction , + const char *NodeName , + const SUPERV::KindOfNode akind , + const SUPERV::SDate NodeFirstCreation , + const SUPERV::SDate NodeLastModification , + const char * NodeEditorRelease , + const char * NodeAuthor , + const char * NodeComment , + const bool GeneratedName , + const long X , + const long Y , + int * Graph_prof_debug , + ostream * Graph_fdebug ) : + GraphBase::ComputingNode::ComputingNode( ORB , ptrNamingService , + SALOME_ModuleCatalog::Service() , + NodeName , akind , NodeFirstCreation , + NodeLastModification , NodeEditorRelease , + NodeAuthor , NodeComment , GeneratedName , + X , Y , + Graph_prof_debug , Graph_fdebug ) { + + cdebug_in << "GraphBase::InLineNode::Node " << this + << "' _Name " + << (void *) Name() << " '" << Name() << " _Comment " + << (void *) Comment() << " " << Comment() << " " + << " KindOfNode " << Kind() << " FuncName " << FuncName + << " ServiceName " << ServiceName() << " In(" + << ServiceInParameter().length() + << ") Out(" << ServiceOutParameter().length() << ")" << endl ; + + SetPythonFunction( FuncName , aPythonFunction ) ; + SALOME_ModuleCatalog::Service aNodeService ; + aNodeService.ServiceName = NodeName ; +// python -> service + SetService( aNodeService ) ; + cdebug_out << "GraphBase::InLineNode::Node" << endl; +} + +GraphBase::InLineNode::~InLineNode() { + cdebug << "GraphBase::InLineNode::~Node " << this + << " _Name " + << (void *) Name() << " " << Name() << " _Comment " + << (void *) Comment() << " " << Comment() << " " << endl ; +// if ( _ComponentName != NULLSTRING ) +// delete [] _ComponentName ; +// delete [] _Name ; +// delete [] _EditorRelease ; +// if ( _Author != NULLSTRING ) +// delete [] _Author ; +// if ( _Computer != FACTORYSERVER ) +// delete [] _Computer; +// if ( _Comment != NULLSTRING ) +// delete [] _Comment; +} + +void GraphBase::InLineNode::SetPythonFunction( const char * FuncName , + const SUPERV::ListOfStrings & aPythonFunction ) { + int i ; + cdebug << "GraphBase::InLineNode::PythonFunction length " << aPythonFunction.length() + << endl ; + _FuncName = my_strdup( FuncName ) ; + if ( ( aPythonFunction.length() == 0 ) || + ( aPythonFunction.length() == 1 && strlen( aPythonFunction[ 0 ] ) == 0 ) ) { + _PythonFunction.length( 0 ) ; + } + else { + _PythonFunction.length( aPythonFunction.length() ) ; + for ( i = 0 ; i < aPythonFunction.length() ; i++ ) { + cdebug << aPythonFunction[ i ] << endl ; + _PythonFunction[ i ] = CORBA::string_dup( aPythonFunction[ i ] ) ; + } + } +} + +//bool GraphBase::InLineNode::SaveXML( ostream &f , char *Tabs , +bool GraphBase::InLineNode::SaveXML( QDomDocument & Graph , QDomElement & info , + int XCoordinate , int YCoordinate ) const { + GraphBase::ListOfFuncName aFuncNames ; + GraphBase::ListOfPythonFunctions aPythonFunction ; + if ( PyFuncName() ) { + aFuncNames.resize( 1 ) ; + aFuncNames[0] = CORBA::string_dup( PyFuncName() ) ; + aPythonFunction.resize( 1 ) ; + aPythonFunction[0] = PythonFunction() ; + } +// return GraphBase::ComputingNode::SaveXML( f , Tabs , "" , "" , "" , "" , + return GraphBase::ComputingNode::SaveXML( Graph , info , "" , "" , "" , "" , + aFuncNames , aPythonFunction , + XCoordinate , YCoordinate ) ; +} + +bool GraphBase::InLineNode::SavePY(ostream &f , const char * aGraphName , + int XCoordinate , int YCoordinate ) const { + GraphBase::ListOfFuncName aFuncNames ; + GraphBase::ListOfPythonFunctions aPythonFunction ; + if ( PyFuncName() ) { + aFuncNames.resize( 1 ) ; + aFuncNames[0] = CORBA::string_dup( PyFuncName() ) ; + aPythonFunction.resize( 1 ) ; + aPythonFunction[0] = PythonFunction() ; + } + return GraphBase::ComputingNode::SavePY( f , aGraphName , "" , "" , "" , NULL , + aFuncNames , aPythonFunction , + XCoordinate , YCoordinate ) ; +} diff --git a/src/GraphBase/DataFlowBase_InLineNode.hxx b/src/GraphBase/DataFlowBase_InLineNode.hxx new file mode 100644 index 0000000..c2d7345 --- /dev/null +++ b/src/GraphBase/DataFlowBase_InLineNode.hxx @@ -0,0 +1,90 @@ +//============================================================================= +// File : DataFlowBase_InLineNode.hxx +// Created : 2003 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#ifndef _DATAFLOWBASE_INLINENODE_HXX +#define _DATAFLOWBASE_INLINENODE_HXX + +#include "Python.h" + +#include "DataFlowBase_ComputingNode.hxx" + +namespace GraphBase { + + class InLineNode : public ComputingNode { + + private: + + char * _FuncName ; + SUPERV::ListOfStrings _PythonFunction ; + PyObject * _MyPyRunMethod ; + + public: + + InLineNode() ; + InLineNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char * DataFlowName , + int * Graph_prof_debug = NULL , + ostream * Graph_fdebug = NULL ) ; + InLineNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const SALOME_ModuleCatalog::Service& NodeService , + const char *NodeName , + const SUPERV::KindOfNode akind , + const SUPERV::SDate NodeFirstCreation , + const SUPERV::SDate NodeLastModification , + const char * NodeEditorRelease , + const char * NodeAuthor , + const char * NodeComment , + const bool GeneratedName , + const long X , + const long Y , + int * Graph_prof_debug = NULL , + ostream * Graph_fdebug = NULL ) ; + InLineNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char * FuncName , + const SUPERV::ListOfStrings & aPythonFunction , + const char *NodeName , + const SUPERV::KindOfNode akind , + const SUPERV::SDate NodeFirstCreation , + const SUPERV::SDate NodeLastModification , + const char * NodeEditorRelease , + const char * NodeAuthor , + const char * NodeComment , + const bool GeneratedName , + const long X , + const long Y , + int * Graph_prof_debug = NULL , + ostream * Graph_fdebug = NULL ) ; + virtual ~InLineNode() ; + + void SetPythonFunction( const char * FuncName , + const SUPERV::ListOfStrings & aPythonFunction ) ; + const SUPERV::ListOfStrings * PythonFunction() const { + return &_PythonFunction ; } ; + char * PyFuncName() const { + return my_strdup( _FuncName ) ; } ; + void PyRunMethod( PyObject * MyPyRunMethod ) { + _MyPyRunMethod = MyPyRunMethod ; } ; + PyObject * PyRunMethod() { + return _MyPyRunMethod ; + } + + +// bool SaveXML( ostream &f , char *Tabs , + bool SaveXML( QDomDocument & Graph , QDomElement & info , + int XCoordinate , int YCoordinate ) const ; + bool SavePY( ostream &f , const char * aGraphName , + int XCoordinate , int YCoordinate ) const ; + + }; + +}; + +#endif diff --git a/src/GraphBase/DataFlowBase_InPort.cxx b/src/GraphBase/DataFlowBase_InPort.cxx new file mode 100644 index 0000000..98ba633 --- /dev/null +++ b/src/GraphBase/DataFlowBase_InPort.cxx @@ -0,0 +1,52 @@ +using namespace std; +//============================================================================= +// File : DataFlowBase_InPort.cxx +// Created : 2002 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#include "DataFlowBase_InPort.hxx" +#include "DataFlowBase_OutPort.hxx" + +char ** _PortStateName ; + +GraphBase::InPort::InPort( + const char *const * Name , + const SALOME_ModuleCatalog::ServicesParameter aserviceParameter , + const SUPERV::KindOfPort aKind) : + Port( Name , aserviceParameter ) { + _OutPort = NULL ; + _InitialOutPort = NULL ; + Kind( aKind ) ; +} + +//GraphBase::InPort::~InPort() { +// cout << "InPort::~InPort()" << endl ; +//} + +bool GraphBase::InPort::IsConnected() const { + return ( _OutPort != NULL && !_OutPort->IsDataConnected() ) ; +} + +bool GraphBase::InPort::IsDataConnected() const { + return ( _OutPort != NULL && _OutPort->IsDataConnected() ) ; +} + +void GraphBase::InPort::StringValue(ostream & f ) const { + if ( _OutPort ) + _OutPort->StringValue( f ) ; + else + f << "(undefined)" ; +} + +ostream & operator<< (ostream &f ,const GraphBase::InPort &P) { + f << P.PortName() << ", " + << "type : " << P.PortType() << ", " ; + f << "from " + << P.NodeName() << ", "; + + return f; +} + diff --git a/src/GraphBase/DataFlowBase_InPort.hxx b/src/GraphBase/DataFlowBase_InPort.hxx new file mode 100644 index 0000000..e425e48 --- /dev/null +++ b/src/GraphBase/DataFlowBase_InPort.hxx @@ -0,0 +1,89 @@ +//============================================================================= +// File : DataFlowBase_InPort.hxx +// Created : 2002 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#ifndef _DATAFLOWBASE_INPORT_HXX +#define _DATAFLOWBASE_INPORT_HXX + +#include "DataFlowBase_Port.hxx" + +namespace GraphBase { + + class OutPort ; + + class InPort : public Port { + + SUPERV::GraphState _State ; + OutPort * _OutPort ; + OutPort * _InitialOutPort ; + + public: + + InPort() { + cout << "InPort()" << endl ; + _State = SUPERV::UndefinedState ; + _OutPort = NULL ; + _InitialOutPort = NULL ; + } ; + InPort( const char *const * NodeName , + const SALOME_ModuleCatalog::ServicesParameter aserviceParameter , + const SUPERV::KindOfPort aKind = SUPERV::ServiceParameter ) ; + virtual ~InPort() { + cdebug << "GraphBase::InPort::~InPort " << PortName() << endl ; } ; + virtual void destroy() { + _OutPort = NULL ; + _InitialOutPort = NULL ; + cdebug << "GraphBase::InPort::destroy " << PortName() << " " + << NodeName() << endl ; } ; + + void State( SUPERV::GraphState aState ) { + cdebug << pthread_self() << " " << PortName() << " from " + << NodeName() << " SUPERV::GraphState " << _State << " " + << " --> " << aState << " _EndSwitchPort " + << IsEndSwitch() << endl ; + _State = aState ; } ; + SUPERV::GraphState State() { return _State ; } ; + + OutPort * GetOutPort() { + return _OutPort ; } ; + OutPort * GetOutPort() const { + return _OutPort ; } ; + bool IsConnected() const ; + bool IsDataConnected() const ; + bool AddOutPort( OutPort * anOutPort ) { + if ( _OutPort ) + return false ; + _OutPort = anOutPort ; + return true ; } ; + bool ChangeOutPort( OutPort * anOutPort ) { + if ( _InitialOutPort == NULL ) { + _InitialOutPort = _OutPort ; + } + _OutPort = anOutPort ; + return true ; } ; + bool InitialOutPort() { + if ( _InitialOutPort ) { + _OutPort = _InitialOutPort ; + _InitialOutPort = NULL ; + return true ; + } + return false ; } ; + bool RemoveOutPort() { + if ( _OutPort == NULL ) + return false ; + _OutPort = NULL ; + return RemoveCoords() ; } ; + + void StringValue(ostream & f ) const ; + + } ; + +} ; + +ostream & operator<< (ostream &,const GraphBase::InPort &); + +#endif diff --git a/src/GraphBase/DataFlowBase_LoadXml.cxx b/src/GraphBase/DataFlowBase_LoadXml.cxx new file mode 100644 index 0000000..4e63775 --- /dev/null +++ b/src/GraphBase/DataFlowBase_LoadXml.cxx @@ -0,0 +1,63 @@ +using namespace std; + +#include "DataFlowBase_XmlHandler.hxx" + +//#include +#include +#include + +// Pour Jean +// Fonction Load qui utilise un Parser de fichier xml de Dataflow +// Utilise DataFlowEditor_XmlHandler.hxx et .cxx + +//#include "SALOME_NamingService.hxx" + +//#include +//#include CORBA_CLIENT_HEADER(SALOME_SuperVision) + +#include "DataFlowBase_Graph.hxx" + +bool GraphBase::Graph::LoadXml( CORBA::ORB_ptr _Orb , + const char* myFileName , + GraphBase::SGraph & aDataFlow ) +{ + char * FileName = new char[ strlen( myFileName ) + 5 ] ; + strcpy( FileName , myFileName ) ; + QString aqstrFileName(FileName); + QFile afile( aqstrFileName); + + if ( !afile.exists() || !afile.open( IO_ReadOnly ) ) { + strcat( FileName , ".xml" ) ; + aqstrFileName = QString(FileName); + QFile afile( aqstrFileName ); + if ( !afile.exists() || !afile.open( IO_ReadOnly ) ) { + return false; + } + afile.close(); + } + else + afile.close(); + + QString qstrFileName(FileName); + QFile file( qstrFileName); + GraphBase::XmlHandler::XmlHandler * myXmlHandler = new GraphBase::XmlHandler::XmlHandler( _Orb , true ); + QXmlInputSource source( file ); + QXmlSimpleReader reader; + reader.setContentHandler( myXmlHandler ); + reader.setErrorHandler( myXmlHandler ); + bool ok = reader.parse( source ); + file.close(); + if ( !ok ) { +// QMessageBox::critical( 0, +// QString( "INF_PARSE_ERROR" ), +// QString( myXmlHandler->errorProtocol() ) ); + return false; + } + + aDataFlow = myXmlHandler->GetDataFlow() ; + delete myXmlHandler ; + // Dataflow is now loaded. + return true ; +} + + diff --git a/src/GraphBase/DataFlowBase_LoopNode.cxx b/src/GraphBase/DataFlowBase_LoopNode.cxx new file mode 100644 index 0000000..12d0f32 --- /dev/null +++ b/src/GraphBase/DataFlowBase_LoopNode.cxx @@ -0,0 +1,126 @@ +using namespace std; +//============================================================================= +// File : DataFlowBase_LoopNode.cxx +// Created : 2003 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#include +#include + +#include "DataFlowBase_LoopNode.hxx" + +GraphBase::LoopNode::LoopNode() : + GraphBase::GOTONode::GOTONode() { + + cdebug << "GraphBase::LoopNode::LoopNode " << this + << " _Name " << (void *) Name() << " " << Name() << " _Comment " + << (void *) Comment() << " " << Comment() << " " << endl ; + +} + +GraphBase::LoopNode::LoopNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char * InitName , + const SUPERV::ListOfStrings & anInitPythonFunction , + const char * MoreName , + const SUPERV::ListOfStrings & aMorePythonFunction , + const char * NextName , + const SUPERV::ListOfStrings & aNextPythonFunction , + const char *NodeName , + const SUPERV::KindOfNode akind , + const SUPERV::SDate NodeFirstCreation , + const SUPERV::SDate NodeLastModification , + const char * NodeEditorRelease , + const char * NodeAuthor , + const char * NodeComment , + const bool GeneratedName , + const long X , + const long Y , + int * Graph_prof_debug , + ostream * Graph_fdebug ) : + GraphBase::GOTONode::GOTONode( ORB , ptrNamingService , InitName , anInitPythonFunction , + NodeName , akind , NodeFirstCreation , + NodeLastModification , NodeEditorRelease , + NodeAuthor , NodeComment , GeneratedName , + X , Y , Graph_prof_debug , Graph_fdebug ) { + + cdebug_in << "GraphBase::LoopNode::LoopNode " << this + << "' _Name " << (void *) Name() << " '" << Name() << " _Comment " + << (void *) Comment() << " " << Comment() << " " + << " KindOfNode " << Kind() << " InitName " << InitName + << " MoreName " << MoreName << " NextName " << NextName + << " ServiceName " << ServiceName() << " In(" + << ServiceInParameter().length() + << ") Out(" << ServiceOutParameter().length() << ")" << endl ; + + cdebug << "GraphBase::LoopNode::LoopNode SetMorePythonFunction " << MoreName << " " + << aMorePythonFunction[0] << endl ; + SetMorePythonFunction( MoreName , aMorePythonFunction ) ; + cdebug << "GraphBase::LoopNode::LoopNode SetNextPythonFunction " << NextName << " " + << aNextPythonFunction[0] << endl ; + SetNextPythonFunction( NextName , aNextPythonFunction ) ; + + cdebug_out << "GraphBase::LoopNode::LoopNode" << endl; +} + +GraphBase::LoopNode::~LoopNode() { + cdebug << "GraphBase::Node::~Node " << this + << " _Name " << (void *) Name() << " " << Name() << " _Comment " + << (void *) Comment() << " " << Comment() << " " << endl ; +// if ( _ComponentName != NULLSTRING ) +// delete [] _ComponentName ; +// delete [] _Name ; +// delete [] _EditorRelease ; +// if ( _Author != NULLSTRING ) +// delete [] _Author ; +// if ( _Computer != FACTORYSERVER ) +// delete [] _Computer; +// if ( Comment() != NULLSTRING ) +// delete [] Comment(); +} + +//bool GraphBase::LoopNode::SaveXML( ostream &f , char *Tabs , +bool GraphBase::LoopNode::SaveXML( QDomDocument & Graph , QDomElement & info , + int XCoordinate , int YCoordinate ) { + GraphBase::ListOfPythonFunctions aPythonFunction ; + aPythonFunction.resize( 3 ) ; + aPythonFunction[0] = PythonFunction() ; + aPythonFunction[1] = MorePythonFunction() ; + aPythonFunction[2] = NextPythonFunction() ; + GraphBase::ListOfFuncName aFuncNames ; + aFuncNames.resize( 3 ) ; + aFuncNames[0] = CORBA::string_dup( PyFuncName() ) ; + aFuncNames[1] = CORBA::string_dup( PyMoreName() ) ; + aFuncNames[2] = CORBA::string_dup( PyNextName() ) ; + char * CoupledName = "" ; + if ( CoupledNode() ) { + CoupledName = CoupledNode()->Name() ; + } +// return GraphBase::ComputingNode::SaveXML( f , Tabs , "" , "" , "" , + return GraphBase::ComputingNode::SaveXML( Graph , info , "" , "" , "" , + CoupledName , + aFuncNames , aPythonFunction , + XCoordinate , YCoordinate ) ; +} + +bool GraphBase::LoopNode::SavePY( ostream &f , const char * aGraphName , + int XCoordinate , int YCoordinate ) { + GraphBase::ListOfPythonFunctions aPythonFunction ; + aPythonFunction.resize( 3 ) ; + aPythonFunction[0] = PythonFunction() ; + aPythonFunction[1] = MorePythonFunction() ; + aPythonFunction[2] = NextPythonFunction() ; + GraphBase::ListOfFuncName aFuncNames ; + aFuncNames.resize( 3 ) ; + aFuncNames[0] = CORBA::string_dup( PyFuncName() ) ; + aFuncNames[1] = CORBA::string_dup( PyMoreName() ) ; + aFuncNames[2] = CORBA::string_dup( PyNextName() ) ; + return GraphBase::ComputingNode::SavePY( f , aGraphName , "" , "" , "" , + CoupledNode() , + aFuncNames , aPythonFunction , + XCoordinate , YCoordinate ) ; +} + diff --git a/src/GraphBase/DataFlowBase_LoopNode.hxx b/src/GraphBase/DataFlowBase_LoopNode.hxx new file mode 100644 index 0000000..1939f73 --- /dev/null +++ b/src/GraphBase/DataFlowBase_LoopNode.hxx @@ -0,0 +1,93 @@ +//============================================================================= +// File : DataFlowBase_LoopNode.hxx +// Created : 2003 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#ifndef _DATAFLOWBASE_LOOPNODE_HXX +#define _DATAFLOWBASE_LOOPNODE_HXX + +#include "DataFlowBase_GOTONode.hxx" + +namespace GraphBase { + + class LoopNode : public GOTONode { + + private: + + char * _MoreName ; + SUPERV::ListOfStrings * _MorePythonFunction ; + PyObject * _MyPyMoreMethod ; + char * _NextName ; + SUPERV::ListOfStrings * _NextPythonFunction ; + PyObject * _MyPyNextMethod ; + + public: + + LoopNode() ; + LoopNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char * InitName , + const SUPERV::ListOfStrings & aInitPythonFunction , + const char * MoreName , + const SUPERV::ListOfStrings & aMorePythonFunction , + const char * NextName , + const SUPERV::ListOfStrings & aNextPythonFunction , + const char *NodeName , + const SUPERV::KindOfNode akind , + const SUPERV::SDate NodeFirstCreation , + const SUPERV::SDate NodeLastModification , + const char * NodeEditorRelease , + const char * NodeAuthor , + const char * NodeComment , + const bool GeneratedName , + const long X , + const long Y , + int * Graph_prof_debug = NULL , + ostream * Graph_fdebug = NULL ) ; + virtual ~LoopNode() ; + + void SetMorePythonFunction( const char * MoreName , + const SUPERV::ListOfStrings & aMorePythonFunction ) { + _MoreName = my_strdup( MoreName ) ; + _MorePythonFunction = new SUPERV::ListOfStrings( aMorePythonFunction ) ; } + SUPERV::ListOfStrings * MorePythonFunction() const { + SUPERV::ListOfStrings * aMorePythonFunction ; + aMorePythonFunction = new SUPERV::ListOfStrings( *_MorePythonFunction ) ; + return aMorePythonFunction ; } ; + char * PyMoreName() { + return my_strdup( _MoreName ) ; } ; + void PyMoreMethod( PyObject * MyPyMoreMethod ) { + _MyPyMoreMethod = MyPyMoreMethod ; } ; + PyObject * PyMoreMethod() { + return _MyPyMoreMethod ; + } + + void SetNextPythonFunction( const char * NextName , + const SUPERV::ListOfStrings & aNextPythonFunction ) { + _NextName = my_strdup( NextName ) ; + _NextPythonFunction = new SUPERV::ListOfStrings( aNextPythonFunction ) ; } + SUPERV::ListOfStrings * NextPythonFunction() const { + SUPERV::ListOfStrings * aNextPythonFunction ; + aNextPythonFunction = new SUPERV::ListOfStrings( *_NextPythonFunction ) ; + return aNextPythonFunction ; } ; + char * PyNextName() { + return my_strdup( _NextName ) ; } ; + void PyNextMethod( PyObject * MyPyNextMethod ) { + _MyPyNextMethod = MyPyNextMethod ; } ; + PyObject * PyNextMethod() { + return _MyPyNextMethod ; + } + +// bool SaveXML(ostream &f , char *Tabs , int X , int Y ) ; + bool SaveXML(QDomDocument & Graph , QDomElement & info , int X , int Y ) ; + + bool SavePY(ostream &f , const char * aGraphName , int X , int Y ) ; + + }; + +}; + +#endif diff --git a/src/GraphBase/DataFlowBase_OutPort.cxx b/src/GraphBase/DataFlowBase_OutPort.cxx new file mode 100644 index 0000000..4b7f834 --- /dev/null +++ b/src/GraphBase/DataFlowBase_OutPort.cxx @@ -0,0 +1,144 @@ +using namespace std; +//============================================================================= +// File : DataFlowBase_OutPort.cxx +// Created : 2002 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#include "DataFlowBase_OutPort.hxx" + +//GraphBase::OutPort::~OutPort() { +// In GraphExecutor::OutPort +// int i ; +// for ( i = 1 ; i <= _InPortsSize ; i++ ) { +// if ( !_InPorts[ i ]->RemoveLink() ) +// cout << "GraphBase::OutPort::~OutPort error " +// << _InPorts[ i ]->PortName() << endl ; +// } +//} + +bool GraphBase::OutPort::HasInPort() const { + return _InPortsSize != 0 ; +} + +const GraphBase::InPort * GraphBase::OutPort::GetInPort( + const GraphBase::InPort * toPort ) { + const GraphBase::InPort * anInPort = NULL ; + int index = _MapOfInPorts[ toPort->NodePortName() ] ; + if ( index > 0 && index <= _InPortsSize ) { + anInPort = _InPorts[ index-1 ] ; + if ( anInPort != toPort ) { + cout << "GraphBase::OutPort::GetInPort inconsistency toPort " + << hex << (void *) toPort << " != anInPort " << (void *) anInPort + << dec << endl ; + anInPort = NULL ; + } + } + return anInPort ; +} + +SUPERV::Link_var GraphBase::OutPort::InPortObjRef( + const GraphBase::InPort * toPort ) { + SUPERV::Link_var aLink = SUPERV::Link::_nil() ; + int index = _MapOfInPorts[ toPort->NodePortName() ] ; + if ( index > 0 && index <= _InPortsSize ) { + aLink = _Links[ index-1 ] ; + } + return aLink ; +} + +bool GraphBase::OutPort::AddInPort( GraphBase::InPort * toPort ) { + int index = _MapOfInPorts[ toPort->NodePortName() ] ; + if ( index > 0 && index <= _InPortsSize ) { + return false ; + } + _InPortsSize += 1 ; + _InPorts.resize( _InPortsSize ) ; + _MapOfInPorts[ toPort->NodePortName() ] = _InPortsSize ; + _InPorts[ _InPortsSize-1 ] = toPort ; + _Links.resize( _InPortsSize ) ; + _Links[ _InPortsSize-1 ] = SUPERV::Link::_nil() ; + cdebug << "OutPort " << NodeName() << "(" << PortName() << ") --> InPort " + << toPort->NodeName() << "(" << toPort->PortName() << ") SwitchPort " + << toPort->IsEndSwitch() << endl ; + return true ; +} + +bool GraphBase::OutPort::AddInPortObjRef( GraphBase::InPort * toPort , + SUPERV::Link_var aLink ) { + int index = _MapOfInPorts[ toPort->NodePortName() ] ; + if ( index <= 0 || index > _InPortsSize ) { + return false ; + } + _Links[ index - 1 ] = aLink ; + return true ; +} + +bool GraphBase::OutPort::RemoveInPort( GraphBase::InPort * toPort ) { + int i ; + int index = _MapOfInPorts[ toPort->NodePortName() ] ; + if ( index <= 0 || index > _InPortsSize ) { + cdebug << "GraphBase::OutPort::RemoveInPort Error " << NodePortName() + << " --> " << toPort->NodePortName() << endl ; + return false ; + } + _InPortsSize -= 1 ; + for ( i = index - 1 ; i < _InPortsSize ; i++ ) { + _MapOfInPorts[ _InPorts[ i+1 ]->NodePortName() ] = i + 1 ; + _InPorts[ i ] = _InPorts[ i+1 ] ; + _Links[ i ] = _Links[ i+1 ] ; + } + _InPorts.resize( _InPortsSize ) ; + _Links.resize( _InPortsSize ) ; + _MapOfInPorts.erase( toPort->NodePortName() ) ; + if ( _InPortsSize == 0 ) { + PortStatus(NotConnected ) ; + } + toPort->RemoveOutPort() ; + return true ; +} + +bool GraphBase::OutPort::ReNameInPort( const char* OldNodePortName , + const char* NewNodePortName ) { + int index = _MapOfInPorts[ OldNodePortName ] ; + if ( index <= 0 || index > _InPortsSize ) { + cdebug << "GraphBase::OutPort::ReNameLink Error " << OldNodePortName + << " --> " << NewNodePortName << " index " << index << endl ; + return false ; + } + _MapOfInPorts.erase( OldNodePortName ) ; + _MapOfInPorts[ NewNodePortName ] = index ; + return true ; +} + +#if 0 +bool GraphBase::OutPort::RemoveLinks() { + bool RetVal = true ; + int i ; + for ( i = 0 ; i < _InPortsSize ; i++ ) { + MESSAGE( " to " << *_InPorts[ i ] ); + RetVal = _InPorts[ i ]->RemoveLink() ; + if ( !RetVal ) + break ; + RetVal = RemoveLink( _InPorts[ i ] ) ; + if ( !RetVal ) + break ; + } + PortStatus(NotConnected ) ; + return RetVal ; +} +#endif + +ostream & operator<< (ostream &f ,const GraphBase::OutPort &P) +{ + f << P.PortName() << ", " + << "type : " << P.PortType() << ", " ; + + f << "from " + << P.NodeName() << ", "; + + return f; +} + diff --git a/src/GraphBase/DataFlowBase_OutPort.hxx b/src/GraphBase/DataFlowBase_OutPort.hxx new file mode 100644 index 0000000..35e73a2 --- /dev/null +++ b/src/GraphBase/DataFlowBase_OutPort.hxx @@ -0,0 +1,93 @@ +//============================================================================= +// File : DataFlowBase_OutPort.hxx +// Created : 2002 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#ifndef _DATAFLOWBASE_OUTPORT_HXX +#define _DATAFLOWBASE_OUTPORT_HXX + +#include "DataFlowBase_DataPort.hxx" +#include "DataFlowBase_InPort.hxx" + +namespace GraphBase { + + class OutPort : public DataPort { + + private: + + StatusOfPort _Connected ; + +// Inports connected to this OutPort + map< string , int > _MapOfInPorts ; + int _InPortsSize ; + vector _InPorts ; + vector _Links ; + + public: + + OutPort( const char *const * NodeName , + const SALOME_ModuleCatalog::ServicesParameter aserviceParameter , + const SUPERV::KindOfPort aKind = SUPERV::ServiceParameter ) : + DataPort( NodeName , aserviceParameter ) { + _Connected = NotConnected ; + _InPortsSize = 0 ; + Kind( aKind ) ; } ; + virtual ~OutPort() { + cdebug << "GraphBase::OutPort::~OutPort " << PortName() << endl ; } ; + virtual void destroy() { + int i ; + for ( i = 0 ; i < _InPortsSize ; i++ ) { + _MapOfInPorts.erase( _InPorts[ i ]->PortName() ) ; +// _InPorts[ i ]->destroy() ; BUG ... + _InPorts[ i ]->RemoveOutPort() ; + } + _InPorts.resize( 0 ) ; + cdebug << "GraphBase::OutPort::destroy " << PortName() << " " + << NodeName() << endl ; } ; + + const StatusOfPort PortStatus() const { + return _Connected; } ; + void PortStatus(StatusOfPort c) { _Connected = c; } ; + const bool IsNotConnected() const { + return ( _Connected == NotConnected ) ; } ; + const bool IsConnected() const { + return ( _Connected != NotConnected ) ; } ; + const bool IsPortConnected() const { + return ( _Connected == PortConnected || + _Connected == PortAndDataConnected ) ; } ; + const bool IsPortAndDataConnected() const { + return ( _Connected == PortAndDataConnected ) ; } ; + const bool IsDataConnected() const { + return ( _Connected == DataConnected ) ; } ; + + const int InPortsSize() const { + return _InPortsSize ; } ; + const InPort * InPorts( const int i ) const { + return _InPorts[ i ] ; } ; + InPort * ChangeInPorts( const int i ) { + return _InPorts[ i ] ; } ; + SUPERV::Link_var LinkObjRef( const int i ) const { + return _Links[ i ] ; } ; + +// bool RemoveLinks() ; + + bool HasInPort() const ; + const InPort * GetInPort( const InPort * toPort ) ; + SUPERV::Link_var InPortObjRef( const InPort * toPort ) ; + bool AddInPort( InPort * toPort ) ; + bool AddInPortObjRef( InPort * toPort , SUPERV::Link_var aLink ) ; + + bool RemoveInPort( InPort * toPort ) ; + bool ReNameInPort( const char* OldNodePortName , + const char* NewNodePortName ) ; + + } ; + +} ; + +ostream & operator<< (ostream &,const GraphBase::OutPort &); + +#endif diff --git a/src/GraphBase/DataFlowBase_Port.cxx b/src/GraphBase/DataFlowBase_Port.cxx new file mode 100644 index 0000000..e0395bc --- /dev/null +++ b/src/GraphBase/DataFlowBase_Port.cxx @@ -0,0 +1,193 @@ +using namespace std; +//============================================================================= +// File : DataFlowBase_Port.cxx +// Created : 2002 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#include "DataFlowBase_Port.hxx" + +//GraphBase::Port::~Port() { +// cout << "Port::~Port()" << endl ; +//} + +bool GraphBase::Port::AddCoord( const int nxy , const int *x , + const int *y ) { + int i ; + if ( IsEndSwitch() ) { + return false ; + } + else { + _X.resize( nxy ) ; + _Y.resize( nxy ) ; + for ( i = 0 ; i < nxy ; i++ ) { + _X[ i ] = x[ i ] ; + _Y[ i ] = y[ i ] ; + } + } + return true ; +} + +bool GraphBase::Port::AddCoord( const int index , + const int x , const int y ) { + if ( IsEndSwitch() ) { + return false ; + } + else { + if ( index <= 0 || index > _X.size()+1 ) + return false ; + _X.resize( _X.size()+1 ) ; + _Y.resize( _Y.size()+1 ) ; + int i ; + for ( i = _X.size() - 1 ; i >= index ; i-- ) { + _X[ i ] = _X[ i-1 ] ; + _Y[ i ] = _Y[ i-1 ] ; + } + _X[ index - 1 ] = x ; + _Y[ index - 1 ] = y ; +// cdebug << "AddCoord " << NodeName() << "(" << PortName() << ") [" +// << index-1 << "] " << x << " " << y << endl ; +// for ( i = 0 ; i < _X.size() ; i++ ) { +// cdebug << " [" << i << "] " << _X[ i ] << " " << _Y[ i ] << endl ; +// } + } + return true ; +} + +bool GraphBase::Port::ChangeCoord( const int index , + const int x , + const int y ) { + if ( IsEndSwitch() ) { + return false ; + } + else { + if ( index <= 0 || index > _X.size() ) + return false ; + _X[ index - 1 ] = x ; + _Y[ index - 1 ] = y ; +// cdebug << "ChangeCoord " << NodeName() << "(" << PortName() << ") [" +// << index-1 << "] " << x << " " << y << endl ; +// int i ; +// for ( i = 0 ; i < _X.size() ; i++ ) { +// cdebug << " [" << i << "] " << _X[ i ] << " " << _Y[ i ] << endl ; +// } + } + return true ; +} + +bool GraphBase::Port::RemoveCoord( const int index ) { + if ( IsEndSwitch() ) { + return false ; + } + else { + if ( index <= 0 || index > _X.size() ) + return false ; + int i ; + for ( i = index - 1 ; i < _X.size() - 1 ; i++ ) { + _X[ i ] = _X[ i+1 ] ; + _Y[ i ] = _Y[ i+1 ] ; + } + _X.resize( _X.size()-1 ) ; + _Y.resize( _Y.size()-1 ) ; + } + return true ; +} + +bool GraphBase::Port::RemoveCoords() { + if ( IsEndSwitch() ) { + return false ; + } + else { + _X.resize( 0 ) ; + _Y.resize( 0 ) ; + } + return true ; +} + +int GraphBase::Port::GetCoord() const { + int npt ; + if ( IsEndSwitch() ) { + return false ; + } + else { + npt = _X.size() ; + } + return npt ; +} + +bool GraphBase::Port::GetCoord( int *x , int *y ) const { + int i ; + if ( IsEndSwitch() ) { + return false ; + } + else { + for ( i = 0 ; i < _X.size() ; i++ ) { + x[ i ] = _X[ i ] ; + y[ i ] = _Y[ i ] ; + } + } + return true ; +} + +const GraphBase::ListOfCoords * GraphBase::Port::Coords() const { + GraphBase::ListOfCoords * _list_Coords = new GraphBase::ListOfCoords ; + int i ; + if ( !IsEndSwitch() ) { + _list_Coords->resize( _X.size() ); + for ( i = 0 ; i < _X.size() ; i++ ) { + (*_list_Coords)[ i ].theX = _X[ i ] ; + (*_list_Coords)[ i ].theY = _Y[ i ] ; + } + } + return _list_Coords ; +} + +bool GraphBase::Port::GetCoord( const int index , long &x , long &y ) const { + if ( IsEndSwitch() ) { + return false ; + } + else { + if ( index <= 0 || index > _X.size() ) + return false ; + x = _X[ index - 1 ] ; + y = _Y[ index - 1 ] ; +// cdebug << "GetCoord " << NodeName() << "(" << PortName() << ") [" +// << index-1 << "] " << x << " " << y << endl ; +// int i ; +// for ( i = 0 ; i < _X.size() ; i++ ) { +// cdebug << " [" << i << "] " << _X[ i ] << " " << _Y[ i ] << endl ; +// } + } + return true ; +} + +ostream & operator<< (ostream & f ,const SUPERV::KindOfPort & s ) { + switch (s) { + case SUPERV::ServiceParameter : + f << "ServiceParameter"; + break; + case SUPERV::GateParameter : + f << "GateParameter"; + break; + case SUPERV::LoopParameter : + f << "LoopParameter"; + break; + case SUPERV::InLineParameter : + f << "InLineParameter"; + break; + case SUPERV::SwitchParameter : + f << "SwitchParameter"; + break; + case SUPERV::EndSwitchParameter : + f << "EndSwitchParameter"; + break; + default : + f << "UnknownKindOfPort"; + break; + } + + return f; +} + diff --git a/src/GraphBase/DataFlowBase_Port.hxx b/src/GraphBase/DataFlowBase_Port.hxx new file mode 100644 index 0000000..ceb5b7c --- /dev/null +++ b/src/GraphBase/DataFlowBase_Port.hxx @@ -0,0 +1,118 @@ +//============================================================================= +// File : DataFlowBase_Port.hxx +// Created : 2002 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#ifndef _DATAFLOWBASE_PORT_HXX +#define _DATAFLOWBASE_PORT_HXX + +#include +#include + +#include "DataFlowBase_ServicesParameter.hxx" + +namespace GraphBase { + + class Port : public ServicesParameter { + + const char *const * _NodeName ; + SUPERV::Port_var _Port ; + SUPERV::KindOfPort _KindOfPort ; + + vector _X ; + vector _Y ; + + public: + + Port() { + cout << "Port()" << endl ; + _NodeName = NULL ; + _Port = SUPERV::Port::_nil() ; + _KindOfPort = SUPERV::UndefinedParameter ; + } ; + Port( const char *const * NodeName , + const SALOME_ModuleCatalog::ServicesParameter aserviceParameter , + const SUPERV::KindOfPort aKindOfPort = SUPERV::ServiceParameter ) : + ServicesParameter( aserviceParameter ) { + _NodeName = NodeName ; + _Port = SUPERV::Port::_nil() ; + _KindOfPort = aKindOfPort ; + } ; + virtual ~Port() { + cdebug << "~Port" << endl ; } ; + + SUPERV::Port_var ObjRef() const { return _Port ; } ; + void ObjRef(SUPERV::Port_var aPort) { + _Port = aPort ; } ; + + const char * NodeName() const { return *_NodeName ; } ; + const char * NodePortName() const { +// cout << "NodePortName " << hex << (void *) _NodeName << " " +// << dec << _NodeName << endl ; + char * _NodePortName = new char [ strlen( *_NodeName ) + + strlen( ServicesParameterName() ) + 3 ] ; + strcpy( _NodePortName , *_NodeName ) ; + strcat( _NodePortName , "\\" ) ; + strcat( _NodePortName , ServicesParameterName() ) ; +// strcat( _NodePortName , "\\" ) ; + return _NodePortName ; } ; + + const char * PortName() const { + if ( this == NULL ) + return NULLSTRING ; + return ServicesParameterName() ; } ; + const char * PortType() const { return ServicesParameterType() ; } ; + + void Kind( SUPERV::KindOfPort aKindOfPort ) { + if ( _KindOfPort == SUPERV::GateParameter && aKindOfPort == SUPERV::InLineParameter ) { + cdebug << "GraphBase::Port::Kind " << _KindOfPort << " --> " << aKindOfPort + << endl ; + } + _KindOfPort = aKindOfPort ; } ; + const SUPERV::KindOfPort Kind() const { return _KindOfPort ; } ; + bool IsParam() const { + return _KindOfPort == SUPERV::ServiceParameter ; } ; + bool IsGate() const { + return _KindOfPort == SUPERV::GateParameter || + _KindOfPort == SUPERV::GOTOParameter ; } ; + bool IsInLine() const { + return _KindOfPort == SUPERV::InLineParameter ; } ; + bool IsLoop() const { + return _KindOfPort == SUPERV::LoopParameter ; } ; + bool IsSwitch() const { + return _KindOfPort == SUPERV::SwitchParameter ; } ; + bool IsEndSwitch() const { + return _KindOfPort == SUPERV::EndSwitchParameter ; } ; + bool IsGOTO() const { + return _KindOfPort == SUPERV::GOTOParameter ; } ; +// bool IsBus() const { return ( ( _KindOfPort == SUPERV::InLineParameter ) || +// ( _PortIndex != -1 ) ) ; } ; + +// void PortIndex( const int anIndex ) { +// _PortIndex = anIndex ; } ; +// const int PortIndex() const { +// return _PortIndex ; } ; + + + bool AddCoord( const int nxy , const int *x , const int *y ) ; + bool AddCoord( const int index , const int x , const int y ) ; + bool ChangeCoord( const int index , + const int x , + const int y ) ; + bool RemoveCoord( const int index ) ; + bool RemoveCoords() ; + int GetCoord() const ; + bool GetCoord( int *x , int *y ) const ; + const GraphBase::ListOfCoords * Coords() const ; + bool GetCoord( const int index , long &x , long &y ) const ; + + } ; + +} ; + +ostream & operator<< (ostream &,const SUPERV::KindOfPort &); + +#endif diff --git a/src/GraphBase/DataFlowBase_PortsOfNode.cxx b/src/GraphBase/DataFlowBase_PortsOfNode.cxx new file mode 100644 index 0000000..fb98961 --- /dev/null +++ b/src/GraphBase/DataFlowBase_PortsOfNode.cxx @@ -0,0 +1,538 @@ +using namespace std; +//============================================================================= +// File : DataFlowBase_PortsOfNode.cxx +// Created : 2002 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#include "DataFlowBase_PortsOfNode.hxx" + +GraphBase::PortsOfNode::PortsOfNode() : + GraphBase::Service::Service( SALOME_ModuleCatalog::Service() ) { + cdebug << "GraphBase::PortsOfNode::PortsOfNode " << this + << endl ; + _NodeInPortsSize = 0 ; + _NodeOutPortsSize = 0 ; +} + +GraphBase::PortsOfNode::PortsOfNode( const char *DataFlowName ) : + GraphBase::Service::Service( SALOME_ModuleCatalog::Service() ) { + cdebug << "GraphBase::PortsOfNode::PortsOfNode " << this + << endl ; + _NodeInPortsSize = 0 ; + _NodeOutPortsSize = 0 ; +} + +GraphBase::PortsOfNode::~PortsOfNode() { + cdebug << "GraphBase::PortsOfNode::~PortsOfNode " << this + << endl ; +// int i ; +// for ( i = 0 ; i < _NodeInPortsSize ; i++ ) { +// delete _NodeInPorts[ i ] ; +// } +// for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) { +// delete _NodeOutPorts[ i ] ; +// } +} + +void GraphBase::PortsOfNode::DefPortsOfNode( + CORBA::ORB_ptr ORB , + const SALOME_ModuleCatalog::Service& aService , + const char *const * NodeName , + const SUPERV::KindOfNode aKind , + const bool DataFlowOrComputing , + const bool WithInLoop , + const bool WithInGate , + const bool WithOutGate , + int * Graph_prof_debug , + ostream * Graph_fdebug ) { + int i ; + cdebug_in << "DefPortsOfNode : " << *NodeName << endl ; + SUPERV::KindOfPort aPortKind = SUPERV::ServiceParameter ; + if ( aKind == SUPERV::InLineNode ) { + aPortKind = SUPERV::InLineParameter ; + } + else if ( aKind == SUPERV::LoopNode || aKind == SUPERV::EndLoopNode ) { + aPortKind = SUPERV::InLineParameter ; + } + else if ( aKind == SUPERV::SwitchNode || aKind == SUPERV::EndSwitchNode ) { + aPortKind = SUPERV::InLineParameter ; + } + else if ( aKind == SUPERV::GOTONode ) { + aPortKind = SUPERV::InLineParameter ; + } + for ( i = 0 ; i < _NodeInPortsSize ; i++ ) { + cdebug << "DefPortsOfNode delete In" << i << ". " << _NodeInPorts[i] + << endl ; + _MapOfNodeInPorts.erase( _NodeInPorts[i]->PortName() ) ; + delete _NodeInPorts[i] ; + } + _NodeInPorts.resize( 0 ); + for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) { + cdebug << "DefPortsOfNode delete Out" << i << ". " << _NodeOutPorts[i]->PortName() + << endl ; + _MapOfNodeOutPorts.erase( _NodeOutPorts[i]->PortName() ) ; + delete _NodeOutPorts[i] ; + } + _NodeOutPorts.resize( 0 ); + + SetService( aService ) ; + + int iVec = 0 ; + _NodeInPortsSize = aService.ServiceinParameter.length() ; + if ( WithInGate ) { + SALOME_ModuleCatalog::ServicesParameter anInGateParameter ; + _NodeInPortsSize = _NodeInPortsSize + 1 ; + iVec += 1 ; + char *aParametername = "InGate" ; + if ( aKind == SUPERV::EndSwitchNode ) { + aParametername = "Default" ; + } + anInGateParameter.Parametertype = CORBA::string_dup( "bool" ) ; + anInGateParameter.Parametername = CORBA::string_dup( aParametername ) ; + _NodeInPorts.resize( _NodeInPortsSize ); + _MapOfNodeInPorts[ aParametername ] = iVec ; + _NodeInPorts[iVec-1] = new GraphBase::InPort( NodeName , anInGateParameter , + SUPERV::GateParameter ); +// _NodeInPorts[iVec-1]->Kind( SUPERV::GateParameter ) ; + _NodeInPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; + cdebug << "DefPortsOfNode : " << "_MapOfNodeInPorts[ " << aParametername + << " ] = " << iVec << " " << _NodeInPorts[iVec-1]->Kind() << " " + << _NodeInPorts[iVec-1] << endl ; + } + if ( WithInLoop ) { + SALOME_ModuleCatalog::ServicesParameter anInLoopParameter ; + _NodeInPortsSize = _NodeInPortsSize + 1 ; + iVec += 1 ; + char *aParametername = "InitLoop" ; + if ( aKind == SUPERV::EndLoopNode ) { + aParametername = "DoLoop" ; + } + anInLoopParameter.Parametertype = CORBA::string_dup( "bool" ) ; + anInLoopParameter.Parametername = CORBA::string_dup( aParametername ) ; + if ( _NodeInPortsSize > _NodeInPorts.size() ) { + _NodeInPorts.resize( _NodeInPortsSize ); + } + _MapOfNodeInPorts[ aParametername ] = iVec ; + _NodeInPorts[iVec-1] = new GraphBase::InPort( NodeName , anInLoopParameter , + SUPERV::LoopParameter ); +// _NodeInPorts[iVec-1]->Kind( SUPERV::LoopParameter ) ; + _NodeInPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; + cdebug << "DefPortsOfNode : " << "_MapOfNodeInPorts[ " << aParametername + << " ] = " << iVec << " " << _NodeInPorts[iVec-1]->Kind() << " " + << _NodeInPorts[iVec-1] << endl ; + } + if ( _NodeInPortsSize > _NodeInPorts.size() ) { + _NodeInPorts.resize(_NodeInPortsSize); + } + cdebug << "NodeInPortsSize " << _NodeInPortsSize << endl ; + for ( i = iVec ; i < _NodeInPortsSize ; i++ ) { + string _aParametername = CORBA::string_dup(aService.ServiceinParameter[i-iVec].Parametername) ; + const char *aParametername = _aParametername.c_str() ; + if ( _MapOfNodeInPorts[ aParametername ] ) { + if ( !DataFlowOrComputing && + !strcmp( aParametername , "InGate" ) ) { + } + else { + cdebug << "Error, Parametername duplicated : " << aParametername + << endl ; + } + } + else { + _MapOfNodeInPorts[ aParametername ] = i+1 ; + cdebug << "DefPortsOfNode : " << "_MapOfNodeInPorts[ " << aParametername + << " ] = " << i+1 << endl ; + const SALOME_ModuleCatalog::ServicesParameter aServiceParameter = aService.ServiceinParameter[i-iVec] ; + _NodeInPorts[i] = new GraphBase::InPort( NodeName , aServiceParameter , + aPortKind ); + _NodeInPorts[i]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; + cdebug << i << ". " << *_NodeInPorts[i] << " " << _NodeInPorts[i]->Kind() << endl ; + } + } + + iVec = 0 ; + _NodeOutPortsSize = aService.ServiceoutParameter.length() ; + if ( WithOutGate ) { + SALOME_ModuleCatalog::ServicesParameter anOutGateParameter ; + _NodeOutPortsSize = _NodeOutPortsSize + 1 ; + iVec += 1 ; + char *aParametername = "OutGate" ; + if ( aKind == SUPERV::SwitchNode ) { + aParametername = "Default" ; + } + anOutGateParameter.Parametertype = CORBA::string_dup( "bool" ) ; + anOutGateParameter.Parametername = CORBA::string_dup( aParametername ) ; + _NodeOutPorts.resize(_NodeOutPortsSize); + _MapOfNodeOutPorts[ aParametername ] = iVec ; + _NodeOutPorts[iVec-1] = new GraphBase::OutPort( NodeName , anOutGateParameter , + SUPERV::GateParameter ); +// _NodeOutPorts[iVec-1]->Kind( SUPERV::GateParameter ) ; + _NodeOutPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; + cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername + << " ] = " << iVec << " " << _NodeOutPorts[iVec-1]->Kind() << " " + << _NodeOutPorts[iVec-1] << endl ; + } + if ( WithInLoop ) { + SALOME_ModuleCatalog::ServicesParameter anOutLoopParameter ; + _NodeOutPortsSize = _NodeOutPortsSize + 1 ; + iVec += 1 ; + char *aParametername = "DoLoop" ; + anOutLoopParameter.Parametertype = CORBA::string_dup( "bool" ) ; + anOutLoopParameter.Parametername = CORBA::string_dup( aParametername ) ; + if ( _NodeOutPortsSize > _NodeOutPorts.size() ) { + _NodeOutPorts.resize(_NodeOutPortsSize); + } + _MapOfNodeOutPorts[ aParametername ] = iVec ; + _NodeOutPorts[iVec-1] = new GraphBase::OutPort( NodeName , anOutLoopParameter , + SUPERV::LoopParameter ); +// _NodeOutPorts[iVec-1]->Kind( SUPERV::LoopParameter ) ; + _NodeOutPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; + cdebug << "DefPortsOfNode : " << "_MapOfNodeInPorts[ " << aParametername + << " ] = " << iVec << " " << _NodeOutPorts[iVec-1]->Kind() << " " + << _NodeOutPorts[iVec-1] << endl ; + } + if ( _NodeOutPortsSize > _NodeOutPorts.size() ) { + _NodeOutPorts.resize(_NodeOutPortsSize); + } + cdebug << "NodeOutPortsSize " << _NodeOutPortsSize << endl ; + for ( i = iVec ; i < _NodeOutPortsSize ; i++ ) { + string _aParametername = CORBA::string_dup(aService.ServiceoutParameter[i-iVec].Parametername) ; + const char *aParametername = _aParametername.c_str() ; + if ( _MapOfNodeOutPorts[ aParametername ] ) { + if ( !DataFlowOrComputing && + !strcmp( aParametername , "OutGate" ) ) { + } + else { + cdebug << "Error, Parametername duplicated : " << aParametername + << endl ; + } + } + else { + _MapOfNodeOutPorts[ aParametername ] = i+1 ; + cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername + << " ] = " << i+1 << endl ; + const SALOME_ModuleCatalog::ServicesParameter aServiceParameter = aService.ServiceoutParameter[i-iVec] ; + _NodeOutPorts[i] = new GraphBase::OutPort( NodeName , aServiceParameter , + aPortKind ); + _NodeOutPorts[i]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; + cdebug << i << ". " << *_NodeOutPorts[i] << " " << _NodeOutPorts[i]->Kind() << endl ; + } + } + cdebug_out << "DefPortsOfNode : " << *NodeName << endl ; +} + +GraphBase::InPort * GraphBase::PortsOfNode::AddInPort( + CORBA::ORB_ptr ORB , + const char *const * NodeName , + const SUPERV::KindOfNode aKind , + const char * InputParameterName , + const char * InputParameterType , + int * Graph_prof_debug , + ostream * Graph_fdebug ) { + cdebug_in << "DefPortsOfNode::InPort : " << *NodeName << " " << aKind << " " + << InputParameterName << " " << InputParameterType << endl ; + GraphBase::InPort * anInPort = NULL ; + if ( aKind == SUPERV::InLineNode || aKind == SUPERV::LoopNode || + aKind == SUPERV::EndLoopNode || aKind == SUPERV::SwitchNode || + aKind == SUPERV::EndSwitchNode || aKind == SUPERV::GOTONode ) { + SUPERV::KindOfPort aPortKind = SUPERV::InLineParameter ; + if ( aKind == SUPERV::EndSwitchNode ) { + aPortKind = SUPERV::EndSwitchParameter ; + } + anInPort = GetChangeInPort( InputParameterName ) ; + if ( anInPort == NULL ) { + _NodeInPortsSize = _NodeInPortsSize + 1 ; + _NodeInPorts.resize(_NodeInPortsSize); + _MapOfNodeInPorts[ InputParameterName ] = _NodeInPortsSize ; + SALOME_ModuleCatalog::ServicesParameter aServiceParameter ; + aServiceParameter.Parametername = InputParameterName ; + aServiceParameter.Parametertype = InputParameterType ; + SUPERV::KindOfPort aPortKind = SUPERV::ServiceParameter ; + _NodeInPorts[_NodeInPortsSize-1] = new GraphBase::InPort( NodeName , + aServiceParameter , + aPortKind ) ; + _NodeInPorts[_NodeInPortsSize-1]->Kind( SUPERV::InLineParameter ) ; + _NodeInPorts[_NodeInPortsSize-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; + anInPort = _NodeInPorts[_NodeInPortsSize-1] ; + } + else { + cdebug << "InPort already exists" << endl ; + } + } + cdebug_out << "DefPortsOfNode::InPort _NodeInPortsSize " << _NodeInPortsSize + << " " << anInPort->Kind() << endl ; + return anInPort ; +} + +GraphBase::OutPort * GraphBase::PortsOfNode::AddOutPort( + CORBA::ORB_ptr ORB , + const char *const * NodeName , + const SUPERV::KindOfNode aKind , + const char * OutputParameterName , + const char * OutputParameterType , + int * Graph_prof_debug , + ostream * Graph_fdebug ) { + cdebug_in << "DefPortsOfNode::OutPort : " << *NodeName << " " << aKind << " " + << OutputParameterName << " " << OutputParameterType << endl ; + GraphBase::OutPort * anOutPort = NULL ; + if ( aKind == SUPERV::InLineNode || aKind == SUPERV::LoopNode || + aKind == SUPERV::EndLoopNode || aKind == SUPERV::SwitchNode || + aKind == SUPERV::EndSwitchNode || aKind == SUPERV::GOTONode ) { + SUPERV::KindOfPort aPortKind = SUPERV::InLineParameter ; + anOutPort = GetChangeOutPort( OutputParameterName ) ; + if ( anOutPort == NULL ) { + _NodeOutPortsSize = _NodeOutPortsSize + 1 ; + _NodeOutPorts.resize(_NodeOutPortsSize); + _MapOfNodeOutPorts[ OutputParameterName ] = _NodeOutPortsSize ; + SALOME_ModuleCatalog::ServicesParameter aServiceParameter ; + aServiceParameter.Parametername = OutputParameterName ; + aServiceParameter.Parametertype = OutputParameterType ; + _NodeOutPorts[_NodeOutPortsSize-1] = new GraphBase::OutPort( NodeName , + aServiceParameter , + aPortKind ); + _NodeOutPorts[_NodeOutPortsSize-1]->Kind( SUPERV::InLineParameter ) ; + _NodeOutPorts[_NodeOutPortsSize-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; + anOutPort = _NodeOutPorts[_NodeOutPortsSize-1] ; + } + else { + cdebug << "OutPort already exists" << endl ; + } + } + cdebug_out << "DefPortsOfNode::OutPort _NodeOutPortsSize " + << _NodeOutPortsSize << " " << anOutPort->Kind() << endl ; + return anOutPort ; +} + +void GraphBase::PortsOfNode::DelInPort( const char * InputParameterName ) { + cdebug << "DefPortsOfNode::DelInPort : " << InputParameterName << endl ; + int index = _MapOfNodeInPorts[ InputParameterName ] -1 ; + if ( index >= 0 ) { + cdebug << "DefPortsOfNode::DelInPort : _NodeInPorts[" << index << "] " + << _NodeInPorts[ index ]->PortName() << " " + << _NodeInPorts[ index ]->NodeName() << endl ; + _MapOfNodeInPorts.erase( InputParameterName ) ; + _NodeInPorts[ index ]->destroy() ; + int i ; + for ( i = index ; i < _NodeInPortsSize - 1 ; i++ ) { + _MapOfNodeInPorts.erase( _NodeInPorts[ i+1 ]->PortName() ) ; + _MapOfNodeInPorts[ _NodeInPorts[ i+1 ]->PortName() ] = i+1 ; + _NodeInPorts[ i ] = _NodeInPorts[ i+1 ] ; + } + _NodeInPortsSize = _NodeInPortsSize - 1 ; + _NodeInPorts.resize( _NodeInPortsSize ) ; + for ( i = 0 ; i < _NodeInPortsSize ; i++ ) { + cdebug << "DefPortsOfNode::DelInPort ListOfInPorts : _NodeInPorts[" << i << "] " + << _NodeInPorts[ i ]->PortName() << " " + << _NodeInPorts[ i ]->NodeName() << endl ; + } + } + else { + cdebug << "DefPortsOfNode::DelInPort : index out of range ERROR " << index + << endl ; + } +} + +void GraphBase::PortsOfNode::DelOutPort( const char * OutputParameterName ) { + cdebug << "DefPortsOfNode::DelOutPort : " << OutputParameterName << endl ; + int index = _MapOfNodeOutPorts[ OutputParameterName ] - 1 ; + if ( index >= 0 ) { + cdebug << "DefPortsOfNode::DelOutPort : _NodeOutPorts[" << index << "] " + << _NodeOutPorts[ index ]->PortName() << " " + << _NodeOutPorts[ index ]->NodeName() << endl ; + _MapOfNodeOutPorts.erase( OutputParameterName ) ; + _NodeOutPorts[ index ]->destroy() ; + int i ; + for ( i = index ; i < _NodeOutPortsSize ; i++ ) { + _MapOfNodeOutPorts.erase( _NodeOutPorts[ i+1 ]->PortName() ) ; + _MapOfNodeOutPorts[ _NodeOutPorts[ i+1 ]->PortName() ] = i+1 ; + _NodeOutPorts[ i ] = _NodeOutPorts[ i+1 ] ; + } + _NodeOutPortsSize = _NodeOutPortsSize - 1 ; + _NodeOutPorts.resize( _NodeOutPortsSize ) ; + for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) { + cdebug << "DefPortsOfNode::DelOutPort ListOfOutPorts : _NodeOutPorts[" << i + << "] " << _NodeOutPorts[ i ]->PortName() << " " + << _NodeOutPorts[ i ]->NodeName() << endl ; + } + } + else { + cdebug << "DefPortsOfNode::DelOutPort : index out of range ERROR " << index + << endl ; + } +} + +#if 0 +void GraphBase::PortsOfNode::InOutPort( GraphBase::InPort * InputPort , + GraphBase::OutPort * OutputPort ) { + cdebug_in << "DefPortsOfNode::InOutPort : " << InputPort->PortName() + << " " << OutputPort->PortName() << endl ; + InputPort->PortIndex( _MapOfNodeOutPorts[ OutputPort->PortName() ] - 1 ) ; + OutputPort->PortIndex( _MapOfNodeInPorts[ InputPort->PortName() ] - 1 ) ; + cdebug_out << "DefPortsOfNode::InOutPort " << InputPort->PortIndex() + << " " << OutputPort->PortIndex() << endl ; +} +#endif + +const GraphBase::InPort *GraphBase::PortsOfNode::GetInPort( const char *name) { + return GetChangeInPort( name ) ; +} + +const GraphBase::OutPort *GraphBase::PortsOfNode::GetOutPort( const char *name) { + return GetChangeOutPort( name ) ; +} + +GraphBase::InPort *GraphBase::PortsOfNode::GetChangeInPort( const char *name) { +// cdebug_in << "GraphBase::PortsOfNode::GetChangePort " << name <<" " << way +// << endl; + + GraphBase::InPort * pP = NULL; + if ( !_MapOfNodeInPorts.empty() ) { + int i = _MapOfNodeInPorts[ name ] ; +// cout << "GraphBase::PortsOfNode::GetChangeInPort _MapOfNodeInPorts[ " +// << name << " ] : " << i-1 << " " << _NodeInPorts[ i-1 ]->NodeName() +// << endl ; + if ( i > 0 ) + pP = _NodeInPorts[ i-1 ] ; + } +// cdebug_out << "GraphBase::PortsOfNode::GetChangeInPort " << endl; + + return pP; +} + +GraphBase::OutPort *GraphBase::PortsOfNode::GetChangeOutPort( const char *name ) { +// cdebug_in << "GraphBase::PortsOfNode::GetChangePort " << name <<" " << way +// << endl; + + GraphBase::OutPort * pP = NULL; + if ( !_MapOfNodeOutPorts.empty() ) { + int i = _MapOfNodeOutPorts[ name ] ; +// cout << "GraphBase::PortsOfNode::GetChangeOutPort _MapOfNodeOutPorts[ " +// << name << " ] : " << i-1 << " " << _NodeOutPorts[ i-1 ]->NodeName() +// << endl ; + if ( i > 0 ) + pP = _NodeOutPorts[ i-1 ] ; + } +// cdebug_out << "GraphBase::PortsOfNode::GetChangeOutPort " << endl; + + return pP; +} + +#if 0 +bool GraphBase::PortsOfNode::RemoveLinks() { + int RetVal = true ; + int i ; + for ( i = 0 ; i < _NodeInPortsSize ; i++ ) { + cdebug << "GraphBase::PortsOfNode::RemoveLinks of InPorts : " + << *_NodeInPorts[ i ] ; + if ( _NodeInPorts[ i ]->IsConnected() ) { + RetVal = _NodeInPorts[ i ]->GetLink()->RemoveLink( _NodeInPorts[ i ] ) ; + cdebug << " from " + << *_NodeInPorts[ i ]->GetLink() ; + } + else { + cdebug << " not connected" ; + } + cdebug << endl ; + if ( !RetVal ) + break ; + } + if ( RetVal ) { + for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) { + cdebug << "GraphBase::PortsOfNode::RemoveLinks of OutPort : " + << *_NodeOutPorts[ i ] ; + RetVal = _NodeOutPorts[ i ]->RemoveLinks() ; + if ( !RetVal ) + break ; + } + } + return RetVal ; +} +#endif + +void GraphBase::PortsOfNode::ListPorts( ostrstream & f, + const bool klink ) const { + + int i ; + + f << " Input Ports : " ; + if ( klink ) { + f << GetNodeInPortsSize() << " port" + << (GetNodeInPortsSize() > 1 ? "s" : "") << endl; + + for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) { + f << " Port " +// << hex << GetNodeInPort(i) << dec << " " + << *(GetNodeInPort(i)) << " " ; + GetNodeInPort(i)->StringValue( f ) ; + f << endl; + } + + f << " Output Ports : " ; + } + + f << GetNodeOutPortsSize() << " port" + << (GetNodeOutPortsSize() > 1 ? "s" : "") << endl; + + for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) { + f << " Port " +// << hex << GetNodeOutPort(i) << dec << " " + << *(GetNodeOutPort(i)) << " " ; + GetNodeOutPort(i)->StringValue( f ) ; + f << endl; + } + + if ( !klink ) { + f << " Output Ports : " ; + f << GetNodeInPortsSize() << " port" + << (GetNodeInPortsSize() > 1 ? "s" : "") << endl; + + for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) { + f << " Port " +// << hex << GetNodeInPort(i) << dec << " " + << *(GetNodeInPort(i)) << " " ; + GetNodeInPort(i)->StringValue( f ) ; + f << endl; + } + } + +} + +ostream & operator<< (ostream & f ,const SUPERV::KindOfNode & s ) { + switch (s) { + case SUPERV::ComputingNode : + f << "ComputingNode"; + break; + case SUPERV::FactoryNode : + f << "FactoryNode"; + break; + case SUPERV::InLineNode : + f << "InLineNode"; + break; + case SUPERV::DataFlowNode : + f << "DataFlowNode"; + break; + case SUPERV::LoopNode : + f << "LoopNode"; + break; + case SUPERV::EndLoopNode : + f << "EndLoopNode"; + break; + case SUPERV::SwitchNode : + f << "SwitchNode"; + break; + case SUPERV::EndSwitchNode : + f << "EndSwitchNode"; + break; + case SUPERV::GOTONode : + f << "GOTONode"; + break; + default : + f << "UnknownKindOfNode"; + break; + } + + return f; +} + diff --git a/src/GraphBase/DataFlowBase_PortsOfNode.hxx b/src/GraphBase/DataFlowBase_PortsOfNode.hxx new file mode 100644 index 0000000..0e29234 --- /dev/null +++ b/src/GraphBase/DataFlowBase_PortsOfNode.hxx @@ -0,0 +1,90 @@ +//============================================================================= +// File : DataFlowBase_PortsOfNode.hxx +// Created : 2002 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#ifndef _DATAFLOWBASE_PORTSOFNODE_HXX +#define _DATAFLOWBASE_PORTSOFNODE_HXX + +#include "DataFlowBase_Service.hxx" + +#include "DataFlowBase_InPort.hxx" +#include "DataFlowBase_OutPort.hxx" + +namespace GraphBase { + + class PortsOfNode : public Service { + + private: + +// Only For getting Ports of InNodes and OutNode + map< string , int > _MapOfNodeInPorts ; + int _NodeInPortsSize ; + vector _NodeInPorts; + + map< string , int > _MapOfNodeOutPorts ; + int _NodeOutPortsSize ; + vector _NodeOutPorts; + + public: + + PortsOfNode() ; + PortsOfNode( const char *DataFlowName ) ; + virtual ~PortsOfNode() ; + + void DefPortsOfNode( CORBA::ORB_ptr ORB , + const SALOME_ModuleCatalog::Service& NodeService , + const char *const * NodeName , + const SUPERV::KindOfNode aKind , + const bool DataFlowOrComputing , + const bool WithGateArg , + const bool WithInGate , const bool WithOutGate , + int * Graph_prof_debug , + ostream * Graph_fdebug ) ; + + InPort * AddInPort( CORBA::ORB_ptr ORB , + const char *const * NodeName , + const SUPERV::KindOfNode aKind , + const char * InputParameterName , + const char * InputParameterType , + int * Graph_prof_debug , + ostream * Graph_fdebug ) ; + OutPort * AddOutPort( CORBA::ORB_ptr ORB , + const char *const * NodeName , + const SUPERV::KindOfNode aKind , + const char * OutputParameterName , + const char * InputParameterType , + int * Graph_prof_debug , + ostream * Graph_fdebug ) ; +// void InOutPort( InPort * InputPort , OutPort * OutputPort ) ; + + void DelInPort( const char * InputParameterName ) ; + void DelOutPort( const char * OutputParameterName ) ; + + const int GetNodeInPortsSize() const { return _NodeInPortsSize ; } ; + const InPort *GetNodeInPort(int i) const { + return _NodeInPorts[i] ; } ; + InPort *GetChangeNodeInPort(int i) const { + return _NodeInPorts[i] ; } ; + const int GetNodeOutPortsSize() const { return _NodeOutPortsSize ; } ; + const OutPort *GetNodeOutPort(int i) const { + return _NodeOutPorts[i] ; } ; + OutPort *GetChangeNodeOutPort(int i) const { + return _NodeOutPorts[i] ; } ; + + const InPort *GetInPort( const char *name ) ; + const OutPort *GetOutPort( const char *name ) ; + InPort *GetChangeInPort( const char *name ) ; + OutPort *GetChangeOutPort( const char *name ) ; + + void ListPorts( ostrstream & , const bool klink = true ) const ; + }; + +}; + +ostream & operator<< (ostream &,const SUPERV::KindOfNode &); + +#endif diff --git a/src/GraphBase/DataFlowBase_Service.cxx b/src/GraphBase/DataFlowBase_Service.cxx new file mode 100644 index 0000000..4740e49 --- /dev/null +++ b/src/GraphBase/DataFlowBase_Service.cxx @@ -0,0 +1,50 @@ +using namespace std; +//============================================================================= +// File : DataFlowBase_Service.cxx +// Created : 2002 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#include "DataFlowBase_Service.hxx" + +void GraphBase::Service::SetService( const SALOME_ModuleCatalog::Service aService ) { + _Service.ServiceName = CORBA::string_dup( aService.ServiceName ) ; + _Service.ServiceinParameter.length( aService.ServiceinParameter.length() ) ; + _Service.ServiceoutParameter.length( aService.ServiceoutParameter.length() ) ; + int i ; + for ( i = 0 ; i < _Service.ServiceinParameter.length() ; i++ ) { + _Service.ServiceinParameter[ i ].Parametertype = CORBA::string_dup( aService.ServiceinParameter[ i ].Parametertype ) ; + _Service.ServiceinParameter[ i ].Parametername = CORBA::string_dup( aService.ServiceinParameter[ i ].Parametername ) ; + } + for ( i = 0 ; i < _Service.ServiceoutParameter.length() ; i++ ) { + _Service.ServiceoutParameter[ i ].Parametertype = CORBA::string_dup( aService.ServiceoutParameter[ i ].Parametertype ) ; + _Service.ServiceoutParameter[ i ].Parametername = CORBA::string_dup( aService.ServiceoutParameter[ i ].Parametername ) ; + } + cdebug << "GraphBase::Service::SetService : " << _Service << endl ; + _Instance = 0 ; +} + +ostream & operator<< (ostream & f ,const SALOME_ModuleCatalog::Service & s ) { + f << "Name " << s.ServiceName << endl ; + int i ; + for ( i = 0 ; i < s.ServiceinParameter.length() ; i++ ) { + if ( i == 0 ) + f << " Inparameters " << i ; + else + f << " " << i ; + f << ". " << s.ServiceinParameter[i].Parametername + << ". " << s.ServiceinParameter[i].Parametertype << endl ; + } + for ( i = 0 ; i < s.ServiceoutParameter.length() ; i++ ) { + if ( i == 0 ) + f << " Outparameters " << i ; + else + f << " " << i ; + f << ". " << s.ServiceoutParameter[i].Parametername + << ". " << s.ServiceoutParameter[i].Parametertype << endl ; + } + return f; +} + diff --git a/src/GraphBase/DataFlowBase_Service.hxx b/src/GraphBase/DataFlowBase_Service.hxx new file mode 100644 index 0000000..d558fc6 --- /dev/null +++ b/src/GraphBase/DataFlowBase_Service.hxx @@ -0,0 +1,63 @@ +//============================================================================= +// File : DataFlowBase_Service.hxx +// Created : 2002 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#ifndef _DATAFLOWBASE_SERVICE_HXX +#define _DATAFLOWBASE_SERVICE_HXX + +#include "DataFlowBase_ServicesParameter.hxx" + +ostream & operator<< (ostream & f ,const SALOME_ModuleCatalog::Service & s ) ; + +namespace GraphBase { + + class Service : public Base { + + SALOME_ModuleCatalog::Service _Service ; + int _Instance ; + + public: + + Service( const SALOME_ModuleCatalog::Service aService ) { + SetService( aService ) ; + cdebug << "GraphBase::Service::Service : " << _Service << endl ; + } ; + Service( const char * aServiceName ) { + _Service.ServiceName = CORBA::string_dup( aServiceName ) ; + cdebug << "GraphBase::Service::Service : " << _Service << endl ; + _Instance = 0 ; } ; + virtual ~Service() { + MESSAGE( "GraphBase::Service::~Service" ); + } ; + + void SetService( const SALOME_ModuleCatalog::Service aService ) ; + + const SALOME_ModuleCatalog::Service * GetService() const { + cdebug << "GraphBase::Service::GetService : " << _Service << endl ; + return &_Service ; } ; + const char * ServiceName() const { +// cdebug << "ServiceName " << hex << (void *) _Service.ServiceName +// << dec << " = " << _Service.ServiceName << endl ; + return _Service.ServiceName ; } ; + const SALOME_ModuleCatalog::ListOfServicesParameter ServiceInParameter() const { + return _Service.ServiceinParameter ; } ; + const SALOME_ModuleCatalog::ListOfServicesParameter ServiceOutParameter() const { + return _Service.ServiceoutParameter ; } ; + + const int Instances() const { return _Instance ; } ; + int NewInstance() { _Instance += 1 ; + return _Instance ; } ; + void Instance( int AddInst = 1 ) { if ( AddInst == 1 ) + _Instance += 1 ; + else + _Instance = AddInst ; } ; + + } ; + +} ; + +#endif diff --git a/src/GraphBase/DataFlowBase_ServicesParameter.hxx b/src/GraphBase/DataFlowBase_ServicesParameter.hxx new file mode 100644 index 0000000..33bb756 --- /dev/null +++ b/src/GraphBase/DataFlowBase_ServicesParameter.hxx @@ -0,0 +1,35 @@ +#ifndef _DATAFLOWBASE_SERVICESPARAMETER_HXX +#define _DATAFLOWBASE_SERVICESPARAMETER_HXX + +#include "DataFlowBase_Base.hxx" + +namespace GraphBase { + + class ServicesParameter : public Base { + + SALOME_ModuleCatalog::ServicesParameter _ServicesParameter ; + + public: + + ServicesParameter() { + cout << "ServicesParameter()" << endl ; + _ServicesParameter.Parametername = (char *) NULL ; + _ServicesParameter.Parametertype = (char *) NULL ; + } ; + ServicesParameter( const SALOME_ModuleCatalog::ServicesParameter aserviceParameter ) { + _ServicesParameter = aserviceParameter ; } ; + virtual ~ServicesParameter() { +// cout << "ServicesParameter::~ServicesParameter()" << endl ; + } ; + const SALOME_ModuleCatalog::ServicesParameter & GetServicesParameter() const { + return _ServicesParameter ; } ; + const char * ServicesParameterName() const { + return _ServicesParameter.Parametername ; } ; + const char * ServicesParameterType() const { + return _ServicesParameter.Parametertype ; } ; + + } ; + +} ; + +#endif diff --git a/src/GraphBase/DataFlowBase_SwitchNode.cxx b/src/GraphBase/DataFlowBase_SwitchNode.cxx new file mode 100644 index 0000000..45cf94a --- /dev/null +++ b/src/GraphBase/DataFlowBase_SwitchNode.cxx @@ -0,0 +1,72 @@ +using namespace std; +//============================================================================= +// File : DataFlowBase_SwitchNode.cxx +// Created : 2003 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#include +#include + +#include "DataFlowBase_SwitchNode.hxx" + +GraphBase::SwitchNode::SwitchNode() : + GraphBase::GOTONode::GOTONode() { + + cdebug << "GraphBase::SwitchNode::SwitchNode " << this + << " _Name " << (void *) Name() << " " << Name() << " _Comment " + << (void *) Comment() << " " << Comment() << " " << endl ; + +} + +GraphBase::SwitchNode::SwitchNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char * FuncName , + const SUPERV::ListOfStrings & aPythonFunction , + const char *NodeName , + const SUPERV::KindOfNode akind , + const SUPERV::SDate NodeFirstCreation , + const SUPERV::SDate NodeLastModification , + const char * NodeEditorRelease , + const char * NodeAuthor , + const char * NodeComment , + const bool GeneratedName , + const long X , + const long Y , + int * Graph_prof_debug , + ostream * Graph_fdebug ) : + GraphBase::GOTONode::GOTONode( ORB , ptrNamingService , FuncName , aPythonFunction , + NodeName , akind , NodeFirstCreation , + NodeLastModification , NodeEditorRelease , + NodeAuthor , NodeComment , GeneratedName , + X , Y , Graph_prof_debug , Graph_fdebug ) { + + cdebug_in << "GraphBase::SwitchNode::SwitchNode " << this + << "' _Name " << (void *) Name() << " '" << Name() << " _Comment " + << (void *) Comment() << " " << Comment() << " " + << " KindOfNode " << Kind() << " FuncName " << FuncName + << " ServiceName " << ServiceName() << " In(" + << ServiceInParameter().length() + << ") Out(" << ServiceOutParameter().length() << ")" << endl ; + + cdebug_out << "GraphBase::SwitchNode::SwitchNode" << endl; +} + +GraphBase::SwitchNode::~SwitchNode() { + cdebug << "GraphBase::SwitchNode::~SwitchNode " << this + << " _Name " << (void *) Name() << " " << Name() << " _Comment " + << (void *) Comment() << " " << Comment() << " " << endl ; +// if ( _ComponentName != NULLSTRING ) +// delete [] _ComponentName ; +// delete [] _Name ; +// delete [] _EditorRelease ; +// if ( _Author != NULLSTRING ) +// delete [] _Author ; +// if ( _Computer != FACTORYSERVER ) +// delete [] _Computer; +// if ( _Comment != NULLSTRING ) +// delete [] _Comment; +} + diff --git a/src/GraphBase/DataFlowBase_SwitchNode.hxx b/src/GraphBase/DataFlowBase_SwitchNode.hxx new file mode 100644 index 0000000..e5e7b2b --- /dev/null +++ b/src/GraphBase/DataFlowBase_SwitchNode.hxx @@ -0,0 +1,45 @@ +//============================================================================= +// File : DataFlowBase_SwitchNode.hxx +// Created : 2003 +// Author : Jean Rahuel, CEA +// Project : SALOME +// $Header: +//============================================================================= + +#ifndef _DATAFLOWBASE_SWITCHNODE_HXX +#define _DATAFLOWBASE_SWITCHNODE_HXX + +#include "DataFlowBase_GOTONode.hxx" + +namespace GraphBase { + + class SwitchNode : public GOTONode { + + private: + + public: + + SwitchNode() ; + SwitchNode( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char * FuncName , + const SUPERV::ListOfStrings & PythonFunction , + const char *NodeName , + const SUPERV::KindOfNode akind , + const SUPERV::SDate NodeFirstCreation , + const SUPERV::SDate NodeLastModification , + const char * NodeEditorRelease , + const char * NodeAuthor , + const char * NodeComment , + const bool GeneratedName , + const long X , + const long Y , + int * Graph_prof_debug = NULL , + ostream * Graph_fdebug = NULL ) ; + virtual ~SwitchNode() ; + + }; + +}; + +#endif diff --git a/src/GraphBase/DataFlowBase_XmlHandler.cxx b/src/GraphBase/DataFlowBase_XmlHandler.cxx new file mode 100644 index 0000000..4b26c8a --- /dev/null +++ b/src/GraphBase/DataFlowBase_XmlHandler.cxx @@ -0,0 +1,1079 @@ +using namespace std; +//============================================================================= +// File : DataFlowBase_XmlHandler.cxx +// Created : Thu Sept 13 14:20:36 2001 +// Author : Arnaud RES +// Project : SALOME +// Copyright : CEA +// $Header$ + +//#include "SALOME_NamingService.hxx" + +//#include +//#include CORBA_CLIENT_HEADER(SALOME_SuperVision) + +//#include "DataFlow_debug.hxx" + +#include "DataFlowBase_XmlHandler.hxx" + +#include +//#include +#include + +#define TRACE 0 + +//static string NULLSTRING = string("") ; + +GraphBase::XmlHandler::XmlHandler( CORBA::ORB_ptr Orb , + const bool aConstructor ) : + _Orb( Orb ) , dataflowxml(false), depth(0), constructor(aConstructor) { + int i ; + for ( i = 0 ; i < maxlevel ; i++ ) { + fieldname[i] = NULLSTRING ; + fieldvalue[i] = NULLSTRING ; + step[i] = 0 ; + } + VXSize = 0 ; +} + +GraphBase::XmlHandler::XmlHandler() {} + +GraphBase::XmlHandler::~XmlHandler() {} + +QString GraphBase::XmlHandler::errorProtocol() +{ + return errorProt; +} + +bool GraphBase::XmlHandler::startDocument() +{ + // at the beginning of parsing: do some initialization + errorProt = ""; + return TRUE; +} + +bool GraphBase::XmlHandler::startElement( const QString&, const QString&, + const QString& qName, + const QXmlAttributes& atts ) { + // do different actions depending on the name of the tag and the + // state you are in + +#if TRACE + MESSAGE( "====================startElement " << depth << " " << qName) + +#endif + if ( qName == "dataflow" && depth == 0 ) { + // Dataflow detected + dataflowxml = TRUE; + } + if ( dataflowxml ) { + fieldname[depth++] = qName ; + } + if ( depth == maxlevel+1 ) + return false ; + return dataflowxml ; + +} + +static bool returnfalse( GraphBase::XmlHandler *myXmlHandler , + const char *msg , + const QString& qName ) { + MESSAGE( "returnfalse ERROR qName " << qName << " " << msg + << " fieldname " << myXmlHandler->getfieldname(myXmlHandler->getdepth()) + << " fieldvalue '" + << myXmlHandler->getfieldvalue(myXmlHandler->getdepth()) << "'" ) + return false ; +} + +bool GraphBase::XmlHandler::endElement( const QString&, + const QString&, + const QString& qName) { + + if ( !dataflowxml || + ( qName != QString( fieldname[depth].c_str() ) && + fieldvalue[depth] != NULLSTRING ) ) { + MESSAGE( "endElement ERROR " << dataflowxml << " qName " << qName + << " fieldname" << fieldname[depth] << " fieldvalue " + << fieldvalue[depth] ) + return returnfalse( this , "top" , qName ) ; + } + if ( fieldvalue[depth] == NULLSTRING ) + depth -= 1 ; + +#if TRACE + MESSAGE( " ==========endElement step[" << depth << "]=" + << step[depth] << " qName " << qName << " fieldvalue '" + << fieldvalue[depth] << "'") +#endif + switch ( depth ) { + case 0 : { + if ( step[depth] == 0 && qName == "dataflow" ) { + dataflowxml = false ; + } + else + return returnfalse( this , "depth0" , qName ) ; + break ; + } + + case 1 : { + switch ( step[depth] ) { + case 0 : + if ( qName == "info-list" ) { +// aDataFlow.Info = aNode ; + step[depth]++ ; + } + else + return returnfalse( this , "depth1-0" , qName ) ; + break ; + case 1 : + if ( qName == "node-list" ) { +// node-list ok + step[depth]++ ; + step[3] = 16 ; + step[4] = 3 ; + } + else + return returnfalse( this , "depth1-1" , qName ) ; + break ; + case 2 : + if ( qName == "link-list" ) { + step[depth]++ ; + } + else + return returnfalse( this , "depth1-2" , qName ) ; + break ; + case 3 : + if ( qName == "data-list" ) { + step[depth]++ ; + } + else + return returnfalse( this , "depth1-3" , qName ) ; + break ; + default: + return returnfalse( this , "depth1-d" , qName ) ; + break ; + } + break ; + } + + case 2 : { + switch ( step[depth] ) { + case 0 : + if ( qName == "node" ) { +// Node ok + if ( step[1] == 0 ) { + aDataFlow.Info = aNode ; + } + else if ( step[1] == 1 ) { + int sizenode = aDataFlow.Nodes.size() ; + aDataFlow.Nodes.resize( sizenode+1 ) ; + aDataFlow.Nodes[ sizenode ] = aNode ; + } + step[3] = 0 ; + aNode.theService.ServiceinParameter.length( 0 ) ; + aNode.theService.ServiceoutParameter.length( 0 ) ; + aNode.theListOfParameters.resize( 0 ) ; + aNode.theListOfFuncName.resize( 0 ) ; + aNode.theListOfPythonFunctions.resize( 0 ) ; + break ; + } + else if ( qName == "link" || qName == "data" ) { + step[depth]++ ; + } + else { + return returnfalse( this , "depth2-0" , qName ) ; + break ; + } + case 1 : + if ( qName == "link" ) { + int sizelink = aDataFlow.Links.size() ; + aDataFlow.Links.resize( sizelink+1 ) ; + aDataFlow.Links[ sizelink ] = aLink ; + if ( VXSize ) { + aDataFlow.Links[ sizelink ].aListOfCoords.resize( VXSize ) ; + int ic ; + for ( ic = 0 ; ic < VXSize ; ic++ ) { + aDataFlow.Links[ sizelink ].aListOfCoords[ ic ].theX = VX[ic] ; + aDataFlow.Links[ sizelink ].aListOfCoords[ ic ].theY = VY[ic] ; + } + } + VXSize = 0 ; + step[3] = 16 ; + break ; + } + else if ( qName == "data" ) { + step[depth]++ ; + } + else { + return returnfalse( this , "depth2-1" , qName ) ; + break ; + } + case 2 : + if ( qName == "data" ) { +// Data ok + if ( constructor ) { + int sizedata = aDataFlow.Datas.size() ; + aDataFlow.Datas.resize( sizedata+1 ) ; + aDataFlow.Datas[ sizedata ] = aLink ; + if ( VXSize ) { + aDataFlow.Datas[ sizedata ].aListOfCoords.resize( VXSize ) ; + int ic ; + for ( ic = 0 ; ic < VXSize ; ic++ ) { + aDataFlow.Datas[ sizedata ].aListOfCoords[ ic ].theX = VX[ic] ; + aDataFlow.Datas[ sizedata ].aListOfCoords[ ic ].theY = VY[ic] ; + } + } + } + VXSize = 0 ; + step[3] = 16 ; + } + else + return returnfalse( this , "depth2-2" , qName ) ; + break ; + default: + return returnfalse( this , "depth2-d" , qName ) ; + break ; + } + break ; + } + + case 3 : { + switch ( step[depth] ) { + case 0 : + if ( qName == "component-name" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth3-0" , qName ) ; + if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) + aNode.theComponentName = fieldvalue[depth].c_str() ; + else + aNode.theComponentName = "" ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + } + else + return returnfalse( this , "depth3-0" , qName ) ; + break ; + case 1 : + if ( qName == "interface-name" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth3-1" , qName ) ; + if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) + aNode.theInterfaceName = fieldvalue[depth].c_str() ; + else + aNode.theInterfaceName = "" ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + } + else + return returnfalse( this , "depth3-1" , qName ) ; + break ; + case 2 : + if ( qName == "node-name" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth3-2" , qName ) ; + aNode.theName = fieldvalue[depth].c_str() ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + } + else + return returnfalse( this , "depth3-2" , qName ) ; + break ; + case 3 : + if ( qName == "kind" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth3-3" , qName ) ; +// kind ok + sscanf( fieldvalue[depth].c_str() ,"%d" , &aNode.theKind ) ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + step[4] = 0 ; + } + else + return returnfalse( this , "depth3-3" , qName ) ; + break ; + case 4 : + if ( qName == "coupled-node" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth3-4" , qName ) ; + if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) + aNode.theCoupledNode = fieldvalue[depth].c_str() ; + else + aNode.theCoupledNode = "" ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + break ; + } + else + step[depth]++ ; +// return returnfalse( this , "depth3-4" , qName ) ; +// break ; + case 5 : + if ( qName == "service" ) { + if ( fieldvalue[depth] != NULLSTRING ) + return returnfalse( this , "depth3-5" , qName ) ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + step[4] = 6; + step[5] = 4 ; +// service ok + } + else + return returnfalse( this , "depth3-5" , qName ) ; + break ; + case 6 : + if ( qName == "Parameter-list" ) { + if ( fieldvalue[depth] != NULLSTRING ) + return returnfalse( this , "depth3-6" , qName ) ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + step[4] = 8 ; + step[5] = 8 ; +// Parameter-list ok + break ; + } + else + step[depth]++ ; + step[5] = 0 ; + step[6] = 0 ; +// NO Parameter-list +// return returnfalse( this , "depth3-6" , qName ) ; +// break ; + case 7 : + if ( qName == "PyFunction-list" ) { + if ( fieldvalue[depth] != NULLSTRING ) + return returnfalse( this , "depth3-7" , qName ) ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + step[5] = 0 ; + step[6] = 0 ; +// Parameter-list ok + break ; + } + else + step[depth]++ ; + step[5] = 0 ; + step[6] = 0 ; +// NO PyFunction-list +// return returnfalse( this , "depth3-7" , qName ) ; +// break ; + case 8 : + if ( qName == "creation-date" ) { + SUPERV::SDate D ; + char Date[23] ; + strcpy( Date , fieldvalue[depth].c_str() ) ; + int i ; + for ( i = 0 ; i < strlen(Date) ; i++ ) { + if ( Date[i] == '/' || Date[i] == '-' || Date[i] == ':' ) + Date[i] = ' ' ; + } +// MESSAGE( "Date(" << Date << ")" ); + int Day , Month , Year , Hour , Minute , Second ; + sscanf( Date ,"%d%d%d%d%d%d" , &Day , + &Month , + &Year , + &Hour , + &Minute , + &Second ) ; + D.Day = Day ; + D.Month = Month ; + D.Year = Year ; + D.Hour = Hour ; + D.Minute = Minute ; + D.Second = Second ; + aNode.theFirstCreation = D ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + } + else + return returnfalse( this , "depth3-8" , qName ) ; + break ; + case 9 : + if ( qName == "lastmodification-date" ) { + SUPERV::SDate D ; + char Date[23] ; + strcpy( Date , fieldvalue[depth].c_str() ) ; + int i ; + for ( i = 0 ; i < strlen(Date) ; i++ ) { + if ( Date[i] == '/' || Date[i] == '-' || Date[i] == ':' ) + Date[i] = ' ' ; + } +// MESSAGE( "Date(" << Date << ")" ); + int Day , Month , Year , Hour , Minute , Second ; + sscanf( Date ,"%d%d%d%d%d%d" , &Day , + &Month , + &Year , + &Hour , + &Minute , + &Second ) ; + D.Day = Day ; + D.Month = Month ; + D.Year = Year ; + D.Hour = Hour ; + D.Minute = Minute ; + D.Second = Second ; + aNode.theLastModification = D ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + } + else + return returnfalse( this , "depth3-9" , qName ) ; + break ; + case 10 : + if ( qName == "editor-release" ) { + aNode.theEditorRelease = fieldvalue[depth].c_str() ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + } + else + return returnfalse( this , "depth3-10" , qName ) ; + break ; + case 11 : + if ( qName == "author" ) { + if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) + aNode.theAuthor = fieldvalue[depth].c_str() ; + else + aNode.theAuthor = "" ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + } + else + return returnfalse( this , "depth3-11" , qName ) ; + break ; + case 12 : + if ( qName == "container" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth3-12" , qName ) ; +// computer ok + if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) + aNode.theContainer = fieldvalue[depth].c_str() ; + else + aNode.theContainer = "" ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + } + else + return returnfalse( this , "depth3-12" , qName ) ; + break ; + case 13 : + if ( qName == "comment" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth3-13" , qName ) ; +// comment ok + if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) + aNode.theComment = fieldvalue[depth].c_str() ; + else + aNode.theComment = "" ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + } + else + return returnfalse( this , "depth3-13" , qName ) ; + break ; + case 14 : + if ( qName == "x-position" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth3-14" , qName ) ; + sscanf( fieldvalue[depth].c_str() , "%d" , &aNode.theCoords.theX ) ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; +// x-position ok + } + else + return returnfalse( this , "depth3-14" , qName ) ; + break ; + case 15 : + if ( qName == "y-position" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth3-15" , qName ) ; + sscanf( fieldvalue[depth].c_str() , "%d" , &aNode.theCoords.theY ) ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; +// y-position ok + } + else + return returnfalse( this , "depth3-15" , qName ) ; + break ; + case 16 : + if ( qName == "fromnode-name" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth3-16" , qName ) ; + if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) + aLink.FromNodeName = fieldvalue[depth].c_str() ; + else + aLink.FromNodeName = "" ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + step[4] = 3 ; + } + else + return returnfalse( this , "depth3-16" , qName ) ; + break ; + case 17 : + if ( qName == "fromserviceparameter-name" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth3-17" , qName ) ; + aLink.FromServiceParameterName = fieldvalue[depth].c_str() ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + } + else + return returnfalse( this , "depth3-17" , qName ) ; + break ; + case 18 : + if ( qName == "tonode-name" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth3-18" , qName ) ; + if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) + aLink.ToNodeName = fieldvalue[depth].c_str() ; + else + aLink.ToNodeName = "" ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + } + else + return returnfalse( this , "depth3-18" , qName ) ; + break ; + case 19 : + if ( qName == "toserviceparameter-name" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth3-19" , qName ) ; + aLink.ToServiceParameterName = fieldvalue[depth].c_str() ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + } + else + return returnfalse( this , "depth3-19" , qName ) ; + step[5] = 2 ; + break ; + case 20 : + if ( qName == "data-value" ) { + if ( fieldvalue[depth] != NULLSTRING ) + return returnfalse( this , "depth3-20" , qName ) ; +// data-value ok + step[depth]++ ; +// step[4] = 3 ; + break ; + } + else + step[depth]++ ; +// return returnfalse( this , "depth3-20" , qName ) ; +// break ; + case 21 : + if ( qName == "coord-list" ) { + if ( fieldvalue[depth] != NULLSTRING ) + return returnfalse( this , "depth3-21" , qName ) ; +// coord-list ok + step[depth] = 14 ; + step[4] = 5 ; + } + else + return returnfalse( this , "depth3-21" , qName ) ; + break ; + default: + return returnfalse( this , "depth3-d" , qName ) ; + break ; + } + break ; + } + + + case 4 : { + switch ( step[depth] ) { + case 0 : + if ( qName == "service-name" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth4-0" , qName ) ; + if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) + aNode.theService.ServiceName = fieldvalue[depth].c_str() ; + else + aNode.theService.ServiceName = "" ; + aNode.theService.ServiceinParameter.length( 0 ) ; + aNode.theService.ServiceoutParameter.length( 0 ) ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + } + else + return returnfalse( this , "depth4-0" , qName ) ; + break ; + case 1 : + if ( qName == "inParameter-list" ) { + if ( fieldvalue[depth] != NULLSTRING ) + return returnfalse( this , "depth4-1" , qName ) ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + step[5] = 1 ; + step[6] = 2 ; // First outParameter +// inParameterlist ok + } + else + return returnfalse( this , "depth4-1" , qName ) ; + break ; + case 2 : + if ( qName == "outParameter-list" ) { + if ( fieldvalue[depth] != NULLSTRING ) + return returnfalse( this , "depth4-2" , qName ) ; + fieldvalue[depth] = NULLSTRING ; + step[depth] = 0 ; +// outParameterlist ok + step[5] = 0 ; + step[6] = 0 ; + } + else + return returnfalse( this , "depth4-2" , qName ) ; + break ; + case 3 : + if ( qName == "value-type" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth4-3" , qName ) ; + int Kind ; + sscanf( fieldvalue[depth].c_str() , "%d" , &Kind ) ; +// switch ( D.Value.type()->kind() ) { + aLink.aLinkValue = CORBA::Any() ; + switch ( Kind ) { + case CORBA::tk_string: { + aLink.aLinkValue <<= (char *) NULL ; + char * t; + aLink.aLinkValue >>= t; +#if TRACE + MESSAGE( t << " (string)" ); +#endif + break; + } + case CORBA::tk_double: { + aLink.aLinkValue <<= (double ) 0. ; + double d; + aLink.aLinkValue >>= d; +#if TRACE + MESSAGE( d << " (double)" ); +#endif + break; + } + case CORBA::tk_long: { + aLink.aLinkValue <<= (long ) 0 ; + long l; + aLink.aLinkValue >>= l; +#if TRACE + MESSAGE( l << " (long)" ); +#endif + break; + } + case CORBA::tk_objref: { + aLink.aLinkValue.replace(CORBA::_tc_Object, NULL); +#if TRACE + MESSAGE( " (object reference)" ); +#endif + break; + } + default: + MESSAGE( "(other ERROR)" ); + } + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + break ; + } + else + step[depth]++ ; +// return returnfalse( this , "depth4-3" , qName ) ; +// break ; + case 4 : + if ( qName == "value" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth4-4" , qName ) ; + if ( !strcmp( fieldvalue[depth].c_str() , "?" ) ) { +// aLink.aLinkValue.Value = fieldvalue[depth].c_str() ; + aLink.aLinkValue = CORBA::Any() ; // ??? + } + else { + switch ( aLink.aLinkValue.type()->kind() ) { + case CORBA::tk_string: { + aLink.aLinkValue <<= fieldvalue[depth].c_str() ; + char * t; + aLink.aLinkValue >>= t; +#if TRACE + MESSAGE( t << " (string)" ); +#endif + break; + } + case CORBA::tk_double: { + double d; + sscanf( fieldvalue[depth].c_str() , "%lf" , &d ) ; + aLink.aLinkValue <<= d; +#if TRACE + MESSAGE( d << " (double)" ); +#endif + break; + } + case CORBA::tk_long: { + long l; + sscanf( fieldvalue[depth].c_str() , "%ld" , &l ) ; + aLink.aLinkValue <<= l; +#if TRACE + MESSAGE( l << " (long)" ); +#endif + break; + } + case CORBA::tk_objref: { + CORBA::Object_ptr ObjRef ; + const char * IORObjRef = fieldvalue[depth].c_str() ; + ObjRef = _Orb->string_to_object( IORObjRef ) ; + aLink.aLinkValue <<= ObjRef; +#if TRACE + MESSAGE( IORObjRef << "(object reference)" ); +#endif + break; + } + default: { + aLink.aLinkValue <<= _Orb->string_to_object( fieldvalue[depth].c_str() ) ; + MESSAGE( "(other ERROR)" ); + } + } + } + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + step[5] = 2 ; + break ; + } + else + step[depth]++ ; +// return returnfalse( this , "depth4-4" , qName ) ; +// break ; + case 5 : + if ( qName == "coord" ) { + if ( fieldvalue[depth] != NULLSTRING ) + return returnfalse( this , "depth4-5" , qName ) ; + if ( VXSize == VX.size() ) { + VX.resize( VX.size() + 10 ) ; + VY.resize( VY.size() + 10 ) ; + } + VX[ VXSize ] = X ; + VY[ VXSize ] = Y ; + VXSize++ ; + step[5] = 2 ; + } + else + return returnfalse( this , "depth4-5" , qName ) ; + break ; + case 6 : + if ( qName == "inParameter" ) { + if ( fieldvalue[depth] != NULLSTRING ) + return returnfalse( this , "depth4-6" , qName ) ; + int size = aNode.theListOfParameters.size() ; + aNode.theListOfParameters.resize( size+1 ) ; + aNode.theListOfParameters[size].theInParameter = aParameter ; + step[depth]++ ; +// One more aParameter input + } + else + return returnfalse( this , "depth4-6" , qName ) ; + break ; + case 7 : + if ( qName == "outParameter" ) { + if ( fieldvalue[depth] != NULLSTRING ) + return returnfalse( this , "depth4-7" , qName ) ; + int size = aNode.theListOfParameters.size() ; + aNode.theListOfParameters[size-1].theOutParameter = aParameter ; +// One more aParameter output + step[4] = 6 ; + step[5] = 4 ; + } + else + return returnfalse( this , "depth4-7" , qName ) ; + break ; + case 8 : + if ( qName == "PyFunction" ) { + if ( fieldvalue[depth] != NULLSTRING ) + return returnfalse( this , "depth4-8" , qName ) ; +// One more PyFunction + step[4] = 8 ; + step[5] = 8 ; + } + else + return returnfalse( this , "depth4-8" , qName ) ; + break ; + default: + return returnfalse( this , "depth4-d" , qName ) ; + break ; + } + break ; + } + + + case 5 : { + switch ( step[depth] ) { + case 0 : + if ( qName == "inParameter" ) { + if ( fieldvalue[depth] != NULLSTRING ) + return returnfalse( this , "depth5-0" , qName ) ; + fieldvalue[depth] = NULLSTRING ; + int size = aNode.theService.ServiceinParameter.length() ; + aNode.theService.ServiceinParameter.length( size+1 ) ; + aNode.theService.ServiceinParameter[size] = aParameter ; +// One more aParameter input + step[6] = 0 ; // Next one + } + else + return returnfalse( this , "depth5-0" , qName ) ; + break ; + case 1 : + if ( qName == "outParameter" ) { + if ( fieldvalue[depth] != NULLSTRING ) + return returnfalse( this , "depth5-1" , qName ) ; + fieldvalue[depth] = NULLSTRING ; + int size = aNode.theService.ServiceoutParameter.length() ; + aNode.theService.ServiceoutParameter.length( size+1 ) ; + aNode.theService.ServiceoutParameter[size] = aParameter ; +// One more aParameter Output + step[6] = 2 ; // Next one + } + else + return returnfalse( this , "depth5-1" , qName ) ; + break ; + case 2 : + if ( qName == "x" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth5-2" , qName ) ; + sscanf( fieldvalue[depth].c_str() , "%d" , &X ) ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + } + else + return returnfalse( this , "depth5-2" , qName ) ; + break ; + case 3 : + if ( qName == "y" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth5-3" , qName ) ; + sscanf( fieldvalue[depth].c_str() , "%d" , &Y ) ; + fieldvalue[depth] = NULLSTRING ; + } + else + return returnfalse( this , "depth5-3" , qName ) ; + break ; + case 4 : + if ( qName == "inParameter-type" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth5-4" , qName ) ; + aParameter.Parametertype = fieldvalue[depth].c_str() ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + } + else + return returnfalse( this , "depth5-4" , qName ) ; + break ; + case 5 : + if ( qName == "inParameter-name" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth5-5" , qName ) ; + aParameter.Parametername = fieldvalue[depth].c_str() ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + } + else + return returnfalse( this , "depth5-5" , qName ) ; + break ; + case 6 : + if ( qName == "outParameter-type" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth5-6" , qName ) ; + aParameter.Parametertype = fieldvalue[depth].c_str() ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + } + else + return returnfalse( this , "depth5-6" , qName ) ; + break ; + case 7 : + if ( qName == "outParameter-name" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth5-7" , qName ) ; + aParameter.Parametername = fieldvalue[depth].c_str() ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + } + else + return returnfalse( this , "depth5-7" , qName ) ; + break ; + case 8 : + if ( qName == "FuncName" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth5-8" , qName ) ; + int l = aNode.theListOfFuncName.size() ; + aNode.theListOfFuncName.resize( l+1 ) ; + aNode.theListOfFuncName[ l ] = fieldvalue[depth].c_str() ; + aNode.theListOfPythonFunctions.resize( l+1 ) ; + aNode.theListOfPythonFunctions[ l ] = new SUPERV::ListOfStrings() ; +#if TRACE + MESSAGE( " ==========theListOfFuncName/theListOfPythonFunctions size " + << l+1 ) +#endif + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + } + else + return returnfalse( this , "depth5-8" , qName ) ; + break ; + case 9 : + if ( qName == "PyFunc" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth5-9" , qName ) ; + int l = aNode.theListOfPythonFunctions.size() - 1 ; + SUPERV::ListOfStrings aPythonFunction = *aNode.theListOfPythonFunctions[ l ] ; + int ll = aPythonFunction.length() ; + aPythonFunction.length( ll+1 ) ; + if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) { + aPythonFunction[ ll ] = fieldvalue[depth].c_str() ; + } + else { + aPythonFunction[ ll ] = NULLSTRING ; + } + if ( ll ) { + aNode.theListOfPythonFunctions.resize( l ) ; + aNode.theListOfPythonFunctions.resize( l+1 ) ; + } + aNode.theListOfPythonFunctions[ l ] = new SUPERV::ListOfStrings( aPythonFunction ) ; +#if TRACE + MESSAGE( " ==========theListOfPythonFunctions[" << l << "] size " << ll+1 + << " [" << ll << "] = " << aPythonFunction[ ll ] ) +#endif + fieldvalue[depth] = NULLSTRING ; +// step[depth]++ ; + } + else + return returnfalse( this , "depth5-9" , qName ) ; + break ; + default: + return returnfalse( this , "depth5-d" , qName ) ; + break ; + } + break ; + } + + case 6 : { + switch ( step[depth] ) { + case 0 : + if ( qName == "inParameter-type" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth6-0" , qName ) ; + aParameter.Parametertype = fieldvalue[depth].c_str() ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + } + else + return returnfalse( this , "depth6-0" , qName ) ; + break ; + case 1 : + if ( qName == "inParameter-name" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth6-1" , qName ) ; + aParameter.Parametername = fieldvalue[depth].c_str() ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + } + else + return returnfalse( this , "depth6-1" , qName ) ; + break ; + case 2 : + if ( qName == "outParameter-type" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth6-2" , qName ) ; + aParameter.Parametertype = fieldvalue[depth].c_str() ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + } + else + return returnfalse( this , "depth6-2" , qName ) ; + break ; + case 3 : + if ( qName == "outParameter-name" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth6-3" , qName ) ; + aParameter.Parametername = fieldvalue[depth].c_str() ; + fieldvalue[depth] = NULLSTRING ; + step[depth]++ ; + } + else + return returnfalse( this , "depth6-3" , qName ) ; + break ; + default: + return returnfalse( this , "depth6-d" , qName ) ; + break ; + } + break ; + } + } + + return TRUE; +} + + +bool GraphBase::XmlHandler::characters( const QString& ch ) { + // we are not interested in whitespaces + QString ch_simplified = ch.simplifyWhiteSpace(); + if ( ch_simplified.isEmpty() ) { + return TRUE; + } + depth -= 1 ; +#if TRACE + MESSAGE( "characters step[" << depth << "]=" << step[depth] + << " ch " << ch << " fieldvalue_must_be_NULL " << fieldvalue[depth] ) +#endif + if ( depth < 0 || fieldvalue[depth] != NULLSTRING ) + return returnfalse( this , "characters " , ch ) ; + + fieldvalue[depth] = ch ; + return TRUE; +} + + +QString GraphBase::XmlHandler::errorString() { + cout << "the document is not in the quote file format" << endl ; + return "the document is not in the quote file format"; +} + + +bool GraphBase::XmlHandler::fatalError( const QXmlParseException& exception ) { + errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) + .arg( exception.message() ) + .arg( exception.lineNumber() ) + .arg( exception.columnNumber() ); + cout << "GraphBase::XmlHandler::fatalError " << errorProt.latin1() << endl ; + return QXmlDefaultHandler::fatalError( exception ); +} + +#if 0 +SALOME_SuperVision::Date GraphBase::XmlHandler::StringToDate( QString& myStrDate) const +{ + SALOME_SuperVision::Date aDate; + QString qstrDate(myStrDate); + QString qstrTemp; + + // Date + int iPos = qstrDate.find("/"); + qstrTemp = qstrDate.left(iPos).stripWhiteSpace(); + aDate.Day = qstrTemp.toShort(); + qstrDate = qstrDate.right(qstrDate.length()-iPos); + iPos = qstrDate.find("/"); + qstrTemp = qstrDate.left(iPos).stripWhiteSpace(); + aDate.Month = qstrTemp.toShort(); + qstrDate = qstrDate.right(qstrDate.length()-iPos); + iPos = qstrDate.find(" "); + qstrTemp = qstrDate.left(iPos).stripWhiteSpace(); + aDate.Year = qstrTemp.toShort(); + + // Time + qstrDate = qstrDate.right(qstrDate.length()-iPos); + iPos = qstrDate.find(":"); + qstrTemp = qstrDate.left(iPos).stripWhiteSpace(); + aDate.Hour = qstrTemp.toShort(); + qstrDate = qstrDate.right(qstrDate.length()-iPos); + iPos = qstrDate.find(":"); + qstrTemp = qstrDate.left(iPos).stripWhiteSpace(); + aDate.Minute = qstrTemp.toShort(); + qstrDate = qstrDate.right(qstrDate.length()-iPos).stripWhiteSpace(); + aDate.Second = qstrDate.toShort(); + + return aDate; +} +#endif + + diff --git a/src/GraphBase/DataFlowBase_XmlHandler.hxx b/src/GraphBase/DataFlowBase_XmlHandler.hxx new file mode 100755 index 0000000..23eefac --- /dev/null +++ b/src/GraphBase/DataFlowBase_XmlHandler.hxx @@ -0,0 +1,83 @@ +//============================================================================= +// File : GraphBase_XmlHandler.hxx +// Created : Thu Jun 14 14:02:23 2001 +// Author : Arnaud RES +// Project : SALOME +// Copyright : CEA +// $Header$ + +#define INCLUDE_MENUITEM_DEF +#define QT_ALTERNATE_QTSMANIP + +#include +#include +#include +#include + +//#include +//#include CORBA_CLIENT_HEADER(SALOME_SuperVision) + +#include "DataFlowBase_Graph.hxx" + +#define maxlevel 7 + +namespace GraphBase { + + class XmlHandler : public QXmlDefaultHandler { + + CORBA::ORB_ptr _Orb ; + bool dataflowxml ; + string fieldname[maxlevel] ; + string fieldvalue[maxlevel] ; + long step[maxlevel] ; + long depth ; + bool constructor ; + GraphBase::SNode aNode ; + SALOME_ModuleCatalog::ServicesParameter aParameter ; + SUPERV::ListOfStrings aPythonFunction ; + GraphBase::SLink aLink ; +// SALOME_SuperVisionBase::ServicesParameterValue aLinkValue ; + CORBA::Any aLinkValue ; + int X ; + int Y ; + int VXSize ; + vector VX ; + vector VY ; + QString errorProt; + + GraphBase::SGraph aDataFlow ; + + public: + + XmlHandler(); + XmlHandler( CORBA::ORB_ptr Orb , const bool aConstructor ); + virtual ~XmlHandler(); + + GraphBase::SGraph & GetDataFlow() { + return aDataFlow ; } ; + + // return the error protocol if parsing failed + QString errorProtocol(); + + // overloaded handler functions + bool startDocument(); + bool startElement( const QString& namespaceURI, const QString& localName, + const QString& qName, const QXmlAttributes& atts ); + bool endElement( const QString& namespaceURI, const QString& localName, + const QString& qName ); + bool characters( const QString& ch ); + + QString errorString(); + + bool fatalError (const QXmlParseException& exception); + + SUPERV::SDate StringToDate( QString& qstrDate) const; + + const long getdepth() const { return depth ; } ; + const string getfieldname( const long adepth ) const { return fieldname[adepth] ; } ; + const string getfieldvalue( const long adepth ) const { return fieldvalue[adepth] ; } ; + + }; + +} ; + diff --git a/src/GraphBase/Makefile.in b/src/GraphBase/Makefile.in new file mode 100644 index 0000000..6b44cf6 --- /dev/null +++ b/src/GraphBase/Makefile.in @@ -0,0 +1,88 @@ +#============================================================================== +# File : Makefile.in +# Created : aug 21 2001 +# Author : , CEA +# Project : SALOME +# Copyright : CEA 2001 +# $Header: +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +EXPORT_HEADERS = \ + DataFlowBase_Base.hxx \ + DataFlowBase_ServicesParameter.hxx \ + DataFlowBase_Port.hxx \ + DataFlowBase_DataPort.hxx \ + DataFlowBase_InPort.hxx \ + DataFlowBase_OutPort.hxx \ + DataFlowBase_Service.hxx \ + DataFlowBase_PortsOfNode.hxx \ + DataFlowBase_ComputingNode.hxx \ + DataFlowBase_FactoryNode.hxx \ + DataFlowBase_InLineNode.hxx \ + DataFlowBase_GOTONode.hxx \ + DataFlowBase_LoopNode.hxx \ + DataFlowBase_EndOfLoopNode.hxx \ + DataFlowBase_SwitchNode.hxx \ + DataFlowBase_EndOfSwitchNode.hxx \ + DataFlowBase_DataNode.hxx \ + DataFlowBase_XmlHandler.hxx \ + DataFlowBase_Graph.hxx + +# Libraries targets +LIB = libSalomeSuperVisionBase.la +LIB_SRC = \ + DataFlowBase_Base.cxx \ + DataFlowBase_Port.cxx \ + DataFlowBase_DataPort.cxx \ + DataFlowBase_InPort.cxx \ + DataFlowBase_OutPort.cxx \ + DataFlowBase_Service.cxx \ + DataFlowBase_PortsOfNode.cxx \ + DataFlowBase_ComputingNode.cxx \ + DataFlowBase_FactoryNode.cxx \ + DataFlowBase_InLineNode.cxx \ + DataFlowBase_GOTONode.cxx \ + DataFlowBase_LoopNode.cxx \ + DataFlowBase_EndOfLoopNode.cxx \ + DataFlowBase_SwitchNode.cxx \ + DataFlowBase_EndOfSwitchNode.cxx \ + DataFlowBase_DataNode.cxx \ + DataFlowBase_XmlHandler.cxx \ + DataFlowBase_LoadXml.cxx \ + DataFlowBase_Graph.cxx + +LIB_CLIENT_IDL = Logger.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_Component.idl \ + SALOMEDS.idl \ + SUPERV.idl \ + SALOMEDS_Attributes.idl \ + SALOME_Exception.idl +# Executables targets +BIN = SuperVisionBase_CheckOfUndefined +BIN_SRC = +BIN_SERVER_IDL = + +CPPFLAGS+= $(PYTHON_INCLUDES) $(QT_MT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) \ + -I${KERNEL_ROOT_DIR}/include/salome +CXXFLAGS= -g -D_DEBUG_ -D__x86__ -D__linux__ -ftemplate-depth-42 \ + -I${KERNEL_ROOT_DIR}/include/salome +#LDFLAGS= -L../../../lib $(CORBA_LIBS) -lomniORB3 -ltcpwrapGK -lomniDynamic3 -lomnithread -lCOS3 -lCOSDynamic3 -lSalomeNS -lSalomeLifeCycleCORBA -lOpUtil -lSalomeLoggerServer -lc $(PYTHON_LIBS) $(QT_MT_LIBS) $(OGL_LIBS) +LDFLAGS= $(CORBA_LIBS) -lomniORB3 -ltcpwrapGK -lomniDynamic3 -lomnithread -lCOS3 \ + -lCOSDynamic3 -lSalomeNS -lSalomeLifeCycleCORBA -lOpUtil -lSalomeLoggerServer \ + -lc $(QT_MT_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome + +LIBS += -L../../lib/salome + +@CONCLUDE@ + + diff --git a/src/GraphBase/SuperVisionBase_CheckOfUndefined.cxx b/src/GraphBase/SuperVisionBase_CheckOfUndefined.cxx new file mode 100644 index 0000000..5050f68 --- /dev/null +++ b/src/GraphBase/SuperVisionBase_CheckOfUndefined.cxx @@ -0,0 +1,13 @@ +using namespace std; +#include +#include +#include + +#include "DataFlowBase_Base.hxx" +#include "DataFlowBase_Graph.hxx" + +int main(int argc, char **argv) { +// debugFile("TestSuperVision.log"); + return 0; +} + diff --git a/src/SUPERVGUI/Makefile.in b/src/SUPERVGUI/Makefile.in new file mode 100644 index 0000000..cb275f6 --- /dev/null +++ b/src/SUPERVGUI/Makefile.in @@ -0,0 +1,87 @@ +##============================================================================== +# File : Makefile.in +# Created : aug 29 16:50:13 CEA 2001 +# Author : Arnaud RES, OPENCASCADE +# Project : SALOME +# Copyright : CEA 2001 +# $Header: +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@ + + +@COMMENCE@ + +# exported header files +EXPORT_HEADERS = SUPERVGUI.h + +# .po files to transform in .qm +PO_FILES = \ + SUPERVGUI_icons.po \ + SUPERVGUI_msg_en.po \ + SUPERVGUI_msg_fr.po + +# Libraries targets + +LIB = libSUPERVGUI.la + +LIB_SRC = SUPERVGUI.cxx \ + SUPERVGUI_Service.cxx \ + SUPERVGUI_Python.cxx \ + SUPERVGUI_Information.cxx \ + SUPERVGUI_Notification.cxx \ + SUPERVGUI_Main.cxx \ + SUPERVGUI_View.cxx \ + SUPERVGUI_Graph.cxx \ + SUPERVGUI_Array.cxx \ + SUPERVGUI_Node.cxx \ + SUPERVGUI_GraphNode.cxx \ + SUPERVGUI_ComputeNode.cxx \ + SUPERVGUI_ControlNode.cxx \ + SUPERVGUI_Port.cxx \ + SUPERVGUI_BrowseNodeDlg.cxx \ + SUPERVGUI_Link.cxx \ + SUPERVGUI_CtrlLink.cxx \ + SUPERVGUI_Label.cxx + +LIB_MOC = SUPERVGUI.h \ + SUPERVGUI_Service.h \ + SUPERVGUI_Python.h \ + SUPERVGUI_Information.h \ + SUPERVGUI_Notification.h \ + SUPERVGUI_Main.h \ + SUPERVGUI_View.h \ + SUPERVGUI_Graph.h \ + SUPERVGUI_Array.h \ + SUPERVGUI_Node.h \ + SUPERVGUI_GraphNode.h \ + SUPERVGUI_ComputeNode.h \ + SUPERVGUI_ControlNode.h \ + SUPERVGUI_Port.h \ + SUPERVGUI_BrowseNodeDlg.h \ + SUPERVGUI_Link.h \ + SUPERVGUI_Label.h + +LIB_CLIENT_IDL = SALOMEDS.idl \ + SALOMEDS_Attributes.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_Component.idl \ + SUPERV.idl \ + SALOME_Exception.idl + +LIB_SERVER_IDL = + +CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) \ + -ftemplate-depth-42 -I${KERNEL_ROOT_DIR}/include/salome +LDFLAGS+=$(QT_MT_LIBS) $(OCC_LIBS) $(VTK_LIBS) $(OGL_LIBS) \ + -lSalomeGUI -lSalomeNS -lqsplitterP \ + -lSalomeLifeCycleCORBA -lSalomeNotification -lSUPERVGraph \ + -L${KERNEL_ROOT_DIR}/lib/salome + +LIBS+= $(PYTHON_LIBS) + +@CONCLUDE@ diff --git a/src/SUPERVGUI/SUPERVGUI.cxx b/src/SUPERVGUI/SUPERVGUI.cxx new file mode 100644 index 0000000..7316204 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI.cxx @@ -0,0 +1,636 @@ +using namespace std; +// File : SUPERVGUI.cxx +// Created : 31 octobre 2001 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGUI +// Copyright : CEA + +#include "SUPERVGUI.h" + +#include "QAD_Resource.h" +#include "QAD_FileDlg.h" +#include "QAD_Application.h" +#include "QAD_StudyFrame.h" +#include "QAD_RightFrame.h" +#include "QAD_LeftFrame.h" +#include "QAD_ViewFrame.h" +#include "QAD_ObjectBrowser.h" +#include "QAD_ObjectBrowserItem.h" +#include "SALOME_Selection.h" +#include "SALOMEGUI_NameDlg.h" +#include "Utils_ORB_INIT.hxx" +#include "SALOME_ListIteratorOfListIO.hxx" +#include "SALOME_InteractiveObject.hxx" +#include +#include "SALOMEGUI_ImportOperation.h" + +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + + +int SUPERVGUI::factory = 0; +SUPERVGUI Supervision; + + +SUPERVGUI::SUPERVGUI(): QObject(), + desktop(0), + study(0), + engine(0), + browser(0) + //info(0) +{ + Trace("SUPERVGUI::SUPERVGUI") + if (factory==0) { + factory = 1; + MESSAGE("SUPERVGUI Info : factory build"); + } else { + MESSAGE("SUPERVGUI Error : another call to factory constructor"); + }; +} + +SUPERVGUI::~SUPERVGUI() { + Trace("SUPERVGUI::~SUPERVGUI") + if (factory==1) { + factory = 0; + //info->close(); + browser->close(); + MESSAGE("SUPERVGUI Info : factory destroy"); + } else { + MESSAGE("SUPERVGUI Error : another call to factory destructor"); + }; +} + +void SUPERVGUI::init(QAD_Desktop* parent) { + Trace("SUPERVGUI::init") + if (desktop==0) { + desktop = parent; + study = desktop->getActiveStudy(); + SALOME_NamingService* namingService = desktop->getNameService(); + loadEngine(namingService); + browser = new SUPERVGUI_Service(namingService); + //info = new SUPERVGUI_Information(); + cursor = desktop->cursor(); + connect(desktop->getMainFrame(), SIGNAL(windowActivated(QWidget*)), this, SLOT(setMain(QWidget*))); + }; +} + + +QAD_StudyFrame* SUPERVGUI::createGraph() { + QAD_StudyFrame* aStudyFrame = study->newWindow3d(study->getNextStudyFrameName(), + VIEW_GRAPHSUPERV, false); + if (aStudyFrame) { + connect(aStudyFrame, + SIGNAL(sfBeforeStudyFrameClosing(QAD_StudyFrame*)), + &Supervision, + SLOT(onGraphClosed(QAD_StudyFrame*))); + } + return aStudyFrame; +} + + + +void SUPERVGUI::loadEngine(SALOME_NamingService* namingService) { + Trace("SUPERVGUI::loadEngine") + SALOME_LifeCycleCORBA LCC(namingService); + Engines::Component_var objComponent = LCC.FindOrLoad_Component("SuperVisionContainer", "SUPERV"); + if (CORBA::is_nil(objComponent)) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_LOAD_SUPERV")); + return; + }; + + SUPERV::SuperG_var aSuperVisionComponent; + aSuperVisionComponent = SUPERV::SuperG::_narrow(objComponent); + if (CORBA::is_nil(aSuperVisionComponent)) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_NARROW_SUPERV")); + return; + }; + + engine = new SUPERV::SuperG_var; + *engine = aSuperVisionComponent; +} +/* +bool SUPERVGUI::information(SUPERV_CNode node, bool isReadOnly) { + Trace("SUPERVGUI::information") + return(info->run(node, isReadOnly)); +} +*/ +void SUPERVGUI::putInfo(const char* mess) { + Trace("SUPERVGUI::putInfo") + desktop->putInfo(mess); +} + +QAD_Desktop* SUPERVGUI::getDesktop() { + Trace("SUPERVGUI::getDesktop") + return(desktop); +} + +SUPERV_Engine SUPERVGUI::getEngine() { + Trace("SUPERVGUI::getEngine") + return(engine); +} + +SUPERVGUI_Service* SUPERVGUI::getBrowser() { + Trace("SUPERVGUI::getBrowser") + return(browser); +} + +QCursor SUPERVGUI::getCursor() { + Trace("SUPERVGUI::getCursor") + return(cursor); +} + +SUPERVGUI_Main* SUPERVGUI::getMain() { + Trace("SUPERVGUI::getMain") + return main; +} + + +void SUPERVGUI::registerGraph(QString theName, SUPERVGUI_Main* theGraph){ + theGraph->setHashCode(theName); + myGraphList.append(theGraph); +} + + +void SUPERVGUI::unregisterGraph(SUPERVGUI_Main* theGraph) { + SUPERVGUI_Main* aMain; + for (aMain = myGraphList.first(); aMain; aMain = myGraphList.next()) { + if (aMain == theGraph) + myGraphList.remove(aMain); + } +} + + +bool SUPERVGUI::isContains(QAD_Study* theStudy, const QString theKey) { + SUPERVGUI_Main* aMain; + for (aMain = myGraphList.first(); aMain; aMain = myGraphList.next()) { + if ((aMain->getStudy() == theStudy) && (aMain->getHashCode() == theKey)) + return true; + } + return false; +} + + +void SUPERVGUI::onGraphClosed(QAD_StudyFrame* theStudyFrame) { + QAD_ViewFrame* viewFrame = theStudyFrame->getRightFrame()->getViewFrame(); + if(SUPERVGraph_ViewFrame* supervFrame = dynamic_cast(viewFrame)){ + disconnect(theStudyFrame, 0 , this, 0); + SUPERVGraph_View* view = supervFrame->getViewWidget(); + SUPERVGUI_Main* aGraph = dynamic_cast(view); + if (aGraph) { + unregisterGraph(aGraph); + } + } +} + +void SUPERVGUI::setMain(QWidget* w) { + main = 0; + QAD_StudyFrame* aStudyFrame = dynamic_cast(w); + if (!aStudyFrame) return; + + study = aStudyFrame->getStudy(); + if (!study) return; + + QAD_ViewFrame* viewFrame = aStudyFrame->getRightFrame()->getViewFrame(); + if(SUPERVGraph_ViewFrame* supervFrame = dynamic_cast(viewFrame)){ + SUPERVGraph_View* view = supervFrame->getViewWidget(); + if (view) + main = dynamic_cast(view); + } + Trace("SUPERVGUI::setMain - main: "<GraphE(f); + //QFileInfo aFile(f); + //aGraph->SetName(aFile.baseName()); + if (SUPERV_isNull(aGraph)) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f)); + return; + } + + QAD_StudyFrame* aStudyFrame = createGraph(); + SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast + (aStudyFrame->getRightFrame()->getViewFrame()); + if(aViewFrame) { + main = new SUPERVGUI_Main(aViewFrame, desktop, aGraph); + registerGraph(f, main); + study->showFrame(aStudyFrame); + } + } +} + +void SUPERVGUI::displayDataflow() { + Trace("SUPERVGUI::displayDataflow"); + QAD_ObjectBrowser* aBrowser = ((QAD_StudyFrame*)(desktop->getMainFrame()->activeWindow()))->getLeftFrame()->getObjectBrowser(); + SUPERV_Graph aDataFlow; + QString aIORName; + + QAD_ObjectBrowserItem* item = (QAD_ObjectBrowserItem*)(aBrowser->getListView()->currentItem()); + SALOMEDS::SObject_var aObj = desktop->getActiveStudy()->getStudyDocument()->FindObjectID(item->getEntry().latin1()); + SALOMEDS::GenericAttribute_var anAttr; + if (aObj->FindAttribute(anAttr, "AttributeIOR")) { + SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + Standard_CString ior = anIOR->Value(); + aIORName = ior; + if (isContains(study, aIORName)) { + if (QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), + tr("MSG_GRAPH_DISPLAYED").arg(""), + QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) + return; + } + aDataFlow = (*Supervision.getEngine())->getGraph(ior); + if (SUPERV_isNull(aDataFlow)) { + QMessageBox::warning(0, tr("ERROR"), tr("MSG_ACCESS_BAD_IOR")); + return; + } + } + QAD_StudyFrame* aStudyFrame = createGraph(); + SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast + (aStudyFrame->getRightFrame()->getViewFrame()); + if(aViewFrame) { + main = new SUPERVGUI_Main(aViewFrame, desktop, aDataFlow); + main->setAsFromStudy(true); + registerGraph(aIORName, main); + study->showFrame(aStudyFrame); + } +} + + +void SUPERVGUI::renameDataflow() { + SALOME_Selection* Sel = SALOME_Selection::Selection( study->getSelection() ); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for ( ; It.More(); It.Next() ) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + + SALOMEDS::Study_var aStudy = study->getStudyDocument(); + SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + if ( !obj->_is_nil() ) { + if (obj->FindAttribute(anAttr, "AttributeName")) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + QString nm = QString( aName->Value() ); + bool ok = FALSE; + nm = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), nm ); + if ( !nm.isEmpty() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + study->renameIObject( IObject, nm ); + QApplication::restoreOverrideCursor(); + } + } + } + } +} + + +void SUPERVGUI::exportDataflow() { + Trace("SUPERVGUI::exportDataflow") + if (main==0) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_EXPORT")); + } else { + QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), + "", + "*.xml", + tr("TTL_EXPORT_DATAFLOW"), + false); + if (!f.isEmpty()) { + if (main->exportDataflow(f)) { + unregisterGraph(main); + registerGraph(f, main); + } + } + } +} + +void SUPERVGUI::newDataflow() { + Trace("SUPERVGUI::editDataflow"); + QAD_StudyFrame* aStudyFrame = createGraph(); + SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast + (aStudyFrame->getRightFrame()->getViewFrame()); + if(aViewFrame){ + main = new SUPERVGUI_Main(aViewFrame, desktop, false); + main->addNode(); + study->showFrame(aStudyFrame); + } +} + +void SUPERVGUI::modifyDataflow() { + Trace("SUPERVGUI::modifyDataflow") + QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), + "", + "*.xml", + tr("Modify Dataflow"), + true); + if (!f.isEmpty()){ + if (isContains(study, f)) { + if (QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), + tr("MSG_GRAPH_DISPLAYED").arg(f), + QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) + return; + } + + SUPERV_Graph aGraph = (*Supervision.getEngine())->Graph(f); + //QFile aFile(f); + //aGraph->SetName(aFile.name()); + if (SUPERV_isNull(aGraph)) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f)); + return; + } + + QAD_StudyFrame* aStudyFrame = createGraph(); + SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast + (aStudyFrame->getRightFrame()->getViewFrame()); + if(aViewFrame) { + main = new SUPERVGUI_Main(aViewFrame, desktop, aGraph); + registerGraph(f, main); + study->showFrame(aStudyFrame); + } + } +} + +void SUPERVGUI::reloadDataflow() { + Trace("SUPERVGUI::reloadDataflow") + if (main==0) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_RELOAD")); + } else { + main->sync(); + }; +} + +void SUPERVGUI::runDataflow() { + Trace("SUPERVGUI::runDataflow") + if (main==0) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_RUN")); + } else { + main->run(); + }; +} + +void SUPERVGUI::stepByStep() { + Trace("SUPERVGUI::stepByStep") + if (main==0) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_RUN")); + } else { + main->startExecute(); + } +} + +void SUPERVGUI::killDataflow() { + Trace("SUPERVGUI::killDataflow") + if (main==0) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_KILL")); + } else { + main->kill(); + }; +} + +void SUPERVGUI::suspendResumeDataflow() { + Trace("SUPERVGUI::suspendResumeDataflow") + if (main==0) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_SUSPEND")); + } else { + main->suspendResume(); + }; +} + +void SUPERVGUI::showComponents() { + Trace("SUPERVGUI::showComponents"); + if (main==0) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_ADD")); + } else { + if (main->isEditable()) + main->addNode(); + else + QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOTEDITABLE")); + } +} + +void SUPERVGUI::customPopup(QPopupMenu* popup) { + Trace("SUPERVGUI::customPopup"); + if(popup->count() > 3) { + // Temporary code: is to be deleted soon + popup->removeItem(QAD_Display_Popup_ID); + popup->removeItem(QAD_DisplayOnly_Popup_ID); + popup->removeItem(QAD_Erase_Popup_ID); + int id = popup->idAt(popup->count() - 1); + if (id < 0 && id != -1) popup->removeItem(id); // separator + // Temporary code end + } + SALOME_Selection* Sel = SALOME_Selection::Selection(study->getSelection() ); + if ((Sel==NULL) || (Sel->IObjectCount() == 0)) return; + + Handle(SALOME_InteractiveObject) anIObj = Sel->firstIObject(); + + // insert SUPERV-specific popup items here + + bool isDataflow, ownObj; + whatIsSelected(anIObj, ownObj, isDataflow); + + if (isDataflow) { + popup->insertItem(tr( "MSG_RENAME" ), this, SLOT(renameDataflow())); + popup->insertItem("Display", this, SLOT(displayDataflow())); + popup->insertSeparator(); + } + if (ownObj) + popup->insertItem(tr("MSG_DELETE"), this, SLOT(deleteObject())); +} + + + +/** Returns: + theIsOwner = true if Selected object belongs to Suipervision. + theIsDataflow = true if Selected object is Dataflow +*/ +void SUPERVGUI::whatIsSelected(const Handle(SALOME_InteractiveObject)& theObj, bool& theIsOwner, bool& theIsDataflow) { + theIsOwner = false; + theIsDataflow = false; + + if (theObj.IsNull()) return; + + SALOMEDS::Study_var aStudy = study->getStudyDocument(); + SALOMEDS::SObject_var obj = aStudy->FindObjectID( theObj->getEntry() ); + + if ( !obj->_is_nil() ) { + SALOMEDS::SComponent_var comp = obj->GetFatherComponent(); + if ( !comp->_is_nil() ) { + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + if (comp->FindAttribute(anAttr, "AttributeName")) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + QString compName(aName->Value()); + if (compName.compare(STUDY_SUPERVISION) == 0) { + SALOMEDS::GenericAttribute_var anAttr; + if (obj->FindAttribute(anAttr, "AttributeIOR")) { + SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + SUPERV_Graph aDataFlow = (*Supervision.getEngine())->getGraph(anIOR->Value()); + if (!SUPERV_isNull(aDataFlow)) + theIsDataflow = true; + } + CORBA::String_var anObjectID = obj->GetID(); + CORBA::String_var aComponentID = comp->GetID(); + if (strcmp(anObjectID, aComponentID)) theIsOwner = true; + } + } + } + } +} + + +void SUPERVGUI::deleteObject() { + SALOME_Selection* Sel = SALOME_Selection::Selection(study->getSelection() ); + if ((Sel==NULL) || (Sel->IObjectCount() == 0)) return; + + Handle(SALOME_InteractiveObject) anIObj = Sel->firstIObject(); + bool aIsOwner, aIsDataflow; + whatIsSelected(anIObj, aIsOwner, aIsDataflow); + + if (!aIsOwner) return; + + if (QMessageBox::warning(QAD_Application::getDesktop(), + tr("WARNING"), + tr("MSG_ASK_DELETE"), + QMessageBox::No, + QMessageBox::Yes) == QMessageBox::No) + return; + + SALOMEDS::Study_var aStudy = study->getStudyDocument(); + SALOMEDS::SObject_var aObj = aStudy->FindObjectID( anIObj->getEntry() ); + if (!aObj->_is_nil()) { + if (aIsDataflow) { + SALOMEDS::GenericAttribute_var anAttr; + if (aObj->FindAttribute(anAttr, "AttributeIOR")) { + SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + QString ior = anIOR->Value(); + + SUPERVGUI_Main* aMain; + for (aMain = myGraphList.first(); aMain; aMain = myGraphList.next()) { + if ((aMain->getStudy() == study) && (aMain->getHashCode() == ior)) { + aMain->setAsFromStudy(false); + break; + } + } + } + } + QAD_Operation* op = new SALOMEGUI_ImportOperation( study ); + SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder(); + op->start(); + aBuilder->RemoveObjectWithChildren(aObj); + op->finish(); + } + Sel->ClearIObjects() ; +} + + + +void SUPERVGUI::activeStudyChanged() { + Trace("SUPERVGUI::activeStudyChanged"); + study = desktop->getActiveStudy(); +} + +extern "C" bool OnGUIEvent(int command, QAD_Desktop* parent) { + Supervision.init(parent); + switch (command) { + case 301: + Supervision.importDataflow(); + return(false); + + case 302: + Supervision.exportDataflow(); + return(false); + + case 303: + Supervision.newDataflow(); + return(false); + + case 304: + Supervision.modifyDataflow(); + return(false); + + case 305: + Supervision.reloadDataflow(); + return(false); + + case 306: + Supervision.runDataflow(); + return(false); + + case 307: + Supervision.killDataflow(); + return(false); + + case 308: + Supervision.suspendResumeDataflow(); + return(false); + + case 309: + Supervision.showComponents(); + return(false); + + case 310: + Supervision.stepByStep(); + return(false); + + default: + QMessageBox::warning(QAD_Application::getDesktop(), "Supervision Error", "Unknown Command From Salome"); + return(false); + + } +} + +extern "C" bool OnKeyPress(QKeyEvent* e, QAD_Desktop* parent, SUPERVGUI_Main* s) { + return(false); +} + +extern "C" bool OnMousePress(QMouseEvent* e, QAD_Desktop* parent, SUPERVGUI_Main* s) { + return(false); +} + +extern "C" bool OnMouseMove(QMouseEvent* e, QAD_Desktop* parent, SUPERVGUI_Main* s) { + return(false); +} + +extern "C" bool OnPopupGUIEvent(int theCommandID, QAD_Desktop* parent) { + return(false); +} + +extern "C" bool SetSettings(QAD_Desktop* parent) { + Trace("extern SUPERVGUI::SetSettings") + Supervision.init(parent); + return(true); +} + +extern "C" void definePopup(QString& theContext, QString& theParent, QString& theObject) { + theObject = ""; + theContext = ""; +} + +extern "C" bool customPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext, const QString& theParent, const QString& theObject) { + Supervision.init(parent); + Supervision.customPopup(popup); + return(true); +} + +extern "C" void activeStudyChanged(QAD_Desktop* parent) { + // Supervision.activeStudyChanged(); +} + +extern "C" int supportedViewType() +{ + return (int)VIEW_GRAPHSUPERV; +} diff --git a/src/SUPERVGUI/SUPERVGUI.h b/src/SUPERVGUI/SUPERVGUI.h new file mode 100644 index 0000000..93e1812 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI.h @@ -0,0 +1,98 @@ +// File : SUPERVGUI.h +// Created : 31 octobre 2001 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGUI +// Copyright : CEA + +#ifndef SUPERVGUI_H +#define SUPERVGUI_H + +// Acces a l'ihm de SALOME +// ----------------------- + +#include "QAD_Desktop.h" + + +#include "SUPERVGUI_Def.h" +#include "SUPERVGUI_Service.h" +#include "SUPERVGUI_Main.h" +//#include "SUPERVGUI_Information.h" + + +// Definition de la classe principale du module de supervision +// ----------------------------------------------------------- + +class SUPERVGUI: public QObject { + Q_OBJECT + + public: + SUPERVGUI(); + virtual ~SUPERVGUI(); + + QAD_Desktop* getDesktop(); + SUPERV_Engine getEngine(); + QAD_Study* getActiveStudy() + { return study; }; + + SUPERVGUI_Service* getBrowser(); + QCursor getCursor(); + //bool information(SUPERV_CNode node, bool isReadOnly); + void putInfo(const char* mess); + + void importDataflow(); + void exportDataflow(); + void newDataflow(); + void modifyDataflow(); + void reloadDataflow(); + void runDataflow(); + void stepByStep(); + void killDataflow(); + void suspendResumeDataflow(); + void showComponents(); + + void init(QAD_Desktop* parent); + SUPERVGUI_Main* getMain(); + void customPopup(QPopupMenu* popup); + void activeStudyChanged(); + + bool isContains(QAD_Study* theStudy, const QString theKey); + + void registerGraph(QString theName, SUPERVGUI_Main* theGraph); + void unregisterGraph(SUPERVGUI_Main* theGraph); + QAD_StudyFrame* createGraph(); + + /** Returns: + theIsOwner = true if Selected object belongs to Suipervision. + theIsDataflow = true if Selected object is Dataflow + */ + void whatIsSelected(const Handle(SALOME_InteractiveObject)& theObj, bool& theIsOwner, bool& theIsDataflow); + + private slots: + void setMain(QWidget* w); + void displayDataflow(); + void renameDataflow(); + void deleteObject(); + void onGraphClosed(QAD_StudyFrame* ); + + private: + void loadEngine(SALOME_NamingService* namingService); + + static int factory; + QAD_Desktop* desktop; + QAD_Study* study; + SUPERV_Engine engine; + SUPERVGUI_Service* browser; + //SUPERVGUI_Information* info; + QCursor cursor; + + SUPERVGUI_Main* main; // active main + QPtrList myGraphList; +}; + + +// Acces a l'instance unique de la classe du module de l'interface graphique de la supervision +// ------------------------------------------------------------------------------------------- +extern SUPERVGUI Supervision; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_Array.cxx b/src/SUPERVGUI/SUPERVGUI_Array.cxx new file mode 100644 index 0000000..6e533b4 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Array.cxx @@ -0,0 +1,265 @@ +using namespace std; +// File : SUPERVGUI_Array.cxx +// Created : 08 / 02 / 2002 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGUI +// Copyright : CEA + +#include "SUPERVGUI_Def.h" +#include "SUPERVGUI_Array.h" +#include "SUPERVGUI_Main.h" +#include "SUPERVGUI_ComputeNode.h" +#include "SUPERVGUI_BrowseNodeDlg.h" +#include +#include + +#define ADDNODES(NodesName) \ + ncols = nodes->NodesName.length(); \ + for (int co=0; coNodesName[co]); \ + x = 50 + co * (CELL_WIDTH + CELL_SPACE);\ + SUPERVGUI_Node* aNode = new SUPERVGUI_Cell(viewport(), main, aCNode); \ + ResizeGraph(aNode, x, y); \ + addChild(aNode, x, y); \ + } + + + +#define ADDCONTROLNODES(NodesName) \ + ncols = nodes->NodesName.length(); \ + x = 50; \ + for (int co=0; coNodesName[co]); \ + SUPERVGUI_Node* aNode = new SUPERVGUI_Cell(viewport(), main, aCNode); \ + ResizeGraph(aNode, x, y); \ + addChild(aNode, x, y); \ + x += (CELL_WIDTH + CELL_SPACE); \ + SUPERV_CNode aCNodeEnd = SUPERV::CNode::_narrow(nodes->NodesName[co]->Coupled()); \ + SUPERVGUI_Node* aNodeEnd = new SUPERVGUI_Cell(viewport(), main, aCNodeEnd); \ + ResizeGraph(aNodeEnd, x, y); \ + addChild(aNodeEnd, x, y); \ + x += (CELL_WIDTH + CELL_SPACE); \ + } + + + + +SUPERVGUI_Array::SUPERVGUI_Array(SUPERVGUI_Main* m): + SUPERVGUI_View(m) +{ + resizeContents(GRAPH_WIDTH, GRAPH_HEIGHT); + setName("TableView"); + hide(); +} + +SUPERVGUI_Array::~SUPERVGUI_Array() { + Trace("SUPERVGUI_Array::~SUPERVGUI_Array") +} + +bool SUPERVGUI_Array::create() { + Trace("SUPERVGUI_Array::create"); + SUPERV_Nodes nodes = main->getDataflow()->Nodes(); + int aCount = 0; + aCount += nodes->CNodes.length(); + aCount += nodes->FNodes.length(); + aCount += nodes->INodes.length(); + aCount += nodes->GNodes.length(); + aCount += nodes->LNodes.length(); + aCount += nodes->SNodes.length(); + if (aCount == 0) { + show(); + return true; + } + + //SUPERV_Nodes nodes; + SUPERVGUI_Cell* cell; + QString aLabel; + int x, y; + int nligs = main->getDataflow()->LevelMax(); + int ncols = main->getDataflow()->ThreadsMax(); + + // there is no any calculations + if (ncols == 0) return false; + + for (int co=0; cosetAlignment(QLabel::AlignCenter | QLabel::AlignVCenter); + aTitle->setLineWidth(1); + aTitle->setPaletteBackgroundColor(MAIN_TITLE); + aTitle->setMinimumSize(CELL_WIDTH, CELL_HEIGHT); + aTitle->setFrameStyle(QFrame::Panel | QFrame::Plain); + addChild(aTitle, 50 + co * (CELL_WIDTH + CELL_SPACE), 20); + } + for (int li=0; li<=nligs; li++) { + nodes = main->getDataflow()->LevelNodes(li); + y = 60 + li * (CELL_HEIGHT + CELL_SPACE); + ADDNODES(CNodes); + ADDNODES(FNodes); + ADDNODES(INodes); + ADDNODES(GNodes); + ADDCONTROLNODES(LNodes); + ADDCONTROLNODES(SNodes); + } + nodeX = 50; + nodeY = y + CELL_HEIGHT*2; + + show(); + return true; +} + +void SUPERVGUI_Array::destroy() { + Trace("SUPERVGUI_Array::destroy") + hide(); + + SUPERVGUI_Cell* cell; + QObjectList* ihmList = queryList("SUPERVGUI_Cell"); + QObjectListIt i(*ihmList); + + while ((cell=(SUPERVGUI_Cell*)i.current()) != 0) { + ++i; + cell->updateStudy(); + cell->close(true); + }; + + delete ihmList; +} + +void SUPERVGUI_Array::sync() { + Trace("SUPERVGUI_Array::sync") + if (SUPERV_isNull(main->getDataflow())) return; + + SUPERVGUI_Cell* cell; + QObjectList* ihmList = queryList("SUPERVGUI_Cell"); + QObjectListIt i(*ihmList); + while ((cell=(SUPERVGUI_Cell*)i.current()) != 0) { + ++i; + cell->sync(); + } + delete ihmList; +} + +SUPERVGUI_Node* SUPERVGUI_Array::addNode(SUPERV_CNode node) { + Trace("SUPERVGUI_Array::Array") + SUPERVGUI_Node* n = new SUPERVGUI_ComputeNode(viewport(), main, node); + ResizeGraph(n, nodeX, nodeY); + addChild(n, nodeX, nodeY); + nodeX += NODE_DX; + nodeY += NODE_DY; + n->sync(); + return(n); +} + +void SUPERVGUI_Array::contentsMousePressEvent(QMouseEvent* e) { + Trace("SUPERVGUI_Array::contentsMousePressEvent") + if (e->button() == RightButton) { + myPopup->exec(e->globalPos()); + }; +} + + + + + +// ------------------------------------ +// Cell widget of the table +// ------------------------------------ + + +SUPERVGUI_Cell::SUPERVGUI_Cell(QWidget* parent, SUPERVGUI_Main* m, SUPERV_CNode n): + SUPERVGUI_Node(parent, m, n), + guiNode(NULL) +{ + Trace("SUPERVGUI_Cell::SUPERVGUI_Cell"); + setLineWidth(2); + setFrameStyle(QFrame::Panel | QFrame::Raised); + + QHBoxLayout* aBox = new QHBoxLayout(this); + aBox->setMargin(3); + aBox->setSpacing(3); + component = new SUPERVGUI_Label(this, CELL_WIDTH_PART, LABEL_HEIGHT, myNode->Comment(), QLabel::AlignLeft); + connect(component, SIGNAL(MousePress(QMouseEvent*)), this, SLOT(showPopup(QMouseEvent*))); + + myTitle = new SUPERVGUI_Label(this, CELL_WIDTH_PART, LABEL_HEIGHT, name(), QLabel::AlignLeft); + connect(myTitle, SIGNAL(MousePress(QMouseEvent*)), this, SLOT(showPopup(QMouseEvent*))); + myTitle->setMinimumSize(CELL_WIDTH_PART, LABEL_HEIGHT); + myTitle->setMaximumSize(CELL_WIDTH_PART, LABEL_HEIGHT); + + // aBox->addWidget(service); + aBox->addWidget(myTitle); + aBox->addWidget(component); + + myStatus->reparent(this, pos()); + aBox->addWidget(myStatus); + + // QToolTip::add(service, myNode->Name()); + QToolTip::add(myTitle, myTitle->text()); + + myPopup->setItemEnabled(myDeleteItem, false); + adjustSize(); +} + +SUPERVGUI_Cell::~SUPERVGUI_Cell() { + Trace("SUPERVGUI_Cell::~SUPERVGUI_Cell"); + QToolTip::remove(myTitle); + if (guiNode != NULL) { + guiNode->close(); + } +} + +void SUPERVGUI_Cell::sync() { + Trace("SUPERVGUI_Cell::sync"); + if (myMain == NULL) return; + myTitle->setText(myNode->Name()); + component->setText(myNode->Comment()); + + if (guiNode != NULL) { + guiNode->sync(); + + SUPERVGUI_PortIn* pi; + QObjectList* ihmList = guiNode->queryList("SUPERVGUI_PortIn"); + QObjectListIt i(*ihmList); + while ((pi=(SUPERVGUI_PortIn*)i.current()) != 0) { + ++i; + pi->sync(); + } + delete ihmList; + + SUPERVGUI_PortOut* po; + ihmList = guiNode->queryList("SUPERVGUI_PortOut"); + i = *ihmList; + while ((po=(SUPERVGUI_PortOut*)i.current()) != 0) { + ++i; + po->sync(); + } + delete ihmList; + } + SUPERVGUI_Node::sync(); +} + + +void SUPERVGUI_Cell::updateStudy() +{ + Trace("SUPERVGUI_Cell::updateStudy") + if (guiNode != NULL) + { + SUPERVGUI_PortOut* po; + QObjectList* ihmList = guiNode->queryList("SUPERVGUI_PortOut"); + QObjectListIt i(*ihmList); + while ((po=(SUPERVGUI_PortOut*)i.current()) != 0) + { + ++i; + po->updateStudy(); + } + delete ihmList; + } +} + + +void SUPERVGUI_Cell::rename() { + SUPERVGUI_Node::rename(); + myTitle->setText(myNode->Name()); + // QToolTip::remove(myTitle); + //QToolTip::add(myTitle, myTitle->text()); +} diff --git a/src/SUPERVGUI/SUPERVGUI_Array.h b/src/SUPERVGUI/SUPERVGUI_Array.h new file mode 100644 index 0000000..e7f1819 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Array.h @@ -0,0 +1,73 @@ +// File : SUPERVGUI_Array.h +// Created : 08 / 02 / 2002 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGUI +// Copyright : CEA + +#ifndef SUPERVGUI_Array_H +#define SUPERVGUI_Array_H + +using namespace std; +#include "SUPERVGUI_Def.h" +#include +#include "SUPERVGUI_Node.h" +#include "SUPERVGUI_View.h" +#include "SUPERVGUI_Label.h" + +class SUPERVGUI_Main; + + +class SUPERVGUI_Array: public SUPERVGUI_View { + Q_OBJECT + + public: + SUPERVGUI_Array(SUPERVGUI_Main* m); + virtual ~SUPERVGUI_Array(); + + void sync(); + bool create(); + void destroy(); + + SUPERVGUI_Node* addNode(SUPERV_CNode node); + + private: + void contentsMousePressEvent(QMouseEvent* e); + + + int nodeX; + int nodeY; +}; + + + + + + + +class SUPERVGUI_Cell: public SUPERVGUI_Node { + Q_OBJECT + + public: + SUPERVGUI_Cell(QWidget* parent, SUPERVGUI_Main* m, SUPERV_CNode n); + virtual ~SUPERVGUI_Cell(); + + void sync(); + void hideAll() {}; + void showAll() {}; + + void updateStudy(); + + public slots: + virtual void rename(); + + private: + SUPERVGUI_Label* myTitle; + SUPERVGUI_Node* guiNode; + SUPERVGUI_Label* component; + //SUPERVGUI_Label* service; + + int myShowItem; +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx b/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx new file mode 100644 index 0000000..5ec6fac --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx @@ -0,0 +1,457 @@ +using namespace std; +// File : SUPERVGUI_BrowseNodeDlg.cxx +// Created : 10 / 01 / 2003 +// Author : Vitaly SMETANNIKOV +// Project : SALOME +// Module : SUPERVGUI +// Copyright : Open CASCADE + + +#include "SUPERVGUI_BrowseNodeDlg.h" +#include "SUPERVGUI_Node.h" +#include "SUPERVGUI.h" +#include +#include +#include +#include +#include +#include + +/** + * Constructor + */ +SUPERVGUI_PortField::SUPERVGUI_PortField( QWidget* theParent, SUPERV_Port thePort ) { + myPort = thePort; + myIsEditable = myPort->IsInput() && ( !myPort->IsLinked() ); + + QString aLabelTxt(myPort->Name()); + + SUPERV_CNode aNode = myPort->Node(); + SALOME_ModuleCatalog::Service* aService = aNode->Service(); + SALOME_ModuleCatalog::ListOfServicesParameter aList; + aList = (myPort->IsInput())? aService->ServiceinParameter : aService->ServiceoutParameter; + for (int i = 0; i < aList.length(); i++) { + SALOME_ModuleCatalog::ServicesParameter* aParam = &(aList[i]); + if (aLabelTxt == aParam->Parametername) { + aLabelTxt += QString(" (") + QString(aParam->Parametertype) + QString(")"); + break; + } + } + + aLabelTxt += QString(":"); + myLabel = new QLabel(aLabelTxt, theParent ); + + myValue = new QLineEdit( theParent ); + myLabel->setBuddy( myValue ); + if (!myIsEditable) { + myValue->setReadOnly( !myIsEditable ); + QPalette aPalette = myValue->palette(); + aPalette.setInactive(aPalette.disabled()); + aPalette.setActive(aPalette.disabled()); + myValue->setPalette(aPalette); + } + myValue->installEventFilter( this ); +} + +/** + * Sets value from text edit control to engine of port + */ +bool SUPERVGUI_PortField::setNewValue() { + if ( !myIsEditable ) return false; + + QString aTxt = myValue->text(); + if ( aTxt.isNull() || aTxt.isEmpty() ) return false; + + if ( aTxt.find( "Unknown" ) < 0 ) { + return myPort->Input( ( *Supervision.getEngine() )->StringValue( aTxt ) ); + } + return false; +} + +/** + * Event filter + */ +bool SUPERVGUI_PortField::eventFilter( QObject* o, QEvent* e ) +{ + if ( o == myValue ) { + if ( e->type() == QEvent::FocusIn ) { + emit activated(); + } + } + return QObject::eventFilter( o, e ); +} + + +/** + * Constructor + */ +SUPERVGUI_BrowseNodeDlg::SUPERVGUI_BrowseNodeDlg( SUPERVGUI_Node* theNode ) + : QDialog( theNode, 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +{ + myActiveField = 0; + setSizeGripEnabled( true ); + myNode = theNode; + myPortsList.setAutoDelete( true ); + + SUPERV_CNode aEngine = myNode->getEngine(); + mySelection = SALOME_Selection::Selection( Supervision.getActiveStudy()->getSelection() ); +// mySelection->ClearIObjects(); + + setName( "SUPERVGUI_BrowseNodeDlg" ); + setCaption( tr( "TIT_BROWSENODE" ) + aEngine->Name() ); + + QGridLayout* aBaseLayout = new QGridLayout( this ); + aBaseLayout->setMargin( 11 ); aBaseLayout->setSpacing( 6 ); + + QGroupBox* aInBox = new QGroupBox( 2, Qt::Horizontal, "Input", this ); + aInBox->setMargin( 11 ); + aBaseLayout->addWidget( aInBox, 0, 0 ); + + QGroupBox* aOutBox = new QGroupBox( 2, Qt::Horizontal, "Output", this); + aOutBox->setMargin( 11 ); + aBaseLayout->addWidget( aOutBox, 0, 1 ); + + myIsEditable = false; + int aPIcount = 0; + int aPOcount = 0; + SUPERV_Ports ports = aEngine->Ports(); + int n = ports->length(); + + for ( int i = 0; i < n; i++ ) { + if ( ports[i]->IsInput() ) { + if ( !ports[i]->IsGate() ) { // not a gate + SUPERVGUI_PortField* aField = new SUPERVGUI_PortField( aInBox, ports[i] ); + if ( aField->isEditable() ) myIsEditable = true; + myPortsList.append( aField ); + if ( !myActiveField ) + myActiveField = aField; + connect( aField, SIGNAL( activated() ), this, SLOT( onFieldActivated() ) ); + } + aPIcount++; + } + else { + if ( !ports[i]->IsGate() ) { // not a gate + myPortsList.append( new SUPERVGUI_PortField( aOutBox, ports[i] ) ); + } + aPOcount++; + } + } + + QGroupBox* aBtnBox = new QGroupBox( this ); + aBtnBox->setColumnLayout( 0, Qt::Vertical ); + aBtnBox->layout()->setSpacing( 0 ); + aBtnBox->layout()->setMargin( 0 ); + + QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() ); + aBtnLayout->setAlignment( Qt::AlignTop ); + aBtnLayout->setSpacing( 6 ); + aBtnLayout->setMargin( 11 ); + + if ( myIsEditable ) { + QLabel* aInfoLab = new QLabel( tr( "ENTER_OR_SELECT_LBL" ), this ); + aBaseLayout->addMultiCellWidget( aInfoLab, 1, 1, 0, 1 ); + + QPushButton* aOkBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox ); + connect( aOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); + aBtnLayout->addWidget( aOkBtn ); + aBaseLayout->addMultiCellWidget( aBtnBox, 2, 2, 0, 1 ); + } else + aBaseLayout->addMultiCellWidget( aBtnBox, 1, 1, 0, 1 ); + + aBtnLayout->addStretch(); + QPushButton* aCancelBtn = new QPushButton( myIsEditable ? tr( "BUT_CANCEL" ) : tr( "BUT_CLOSE" ), aBtnBox ); + aBtnLayout->addWidget( aCancelBtn ); + connect( aCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + + if ( !myIsEditable ) + aBtnLayout->addStretch(); + + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) ); + myNode->getMain()->lockedGraph(true); +} + +/** + * Destructor + */ +SUPERVGUI_BrowseNodeDlg::~SUPERVGUI_BrowseNodeDlg() { +} + +/** + * Set current values of editable ports + */ +void SUPERVGUI_BrowseNodeDlg::setValues() { + SUPERVGUI_PortField* aField; + for ( aField = myPortsList.first(); aField; aField = myPortsList.next() ) { + aField->updateGUI(); + } +} + +/** + * Set inputed values of editable ports and then closes and destroys dialog + */ +void SUPERVGUI_BrowseNodeDlg::accept() { + if ( myIsEditable ) { + SUPERVGUI_PortField* aField; + for ( aField = myPortsList.first(); aField; aField = myPortsList.next() ) { + aField->setNewValue(); + } + myNode->sync(); + } + myNode->getMain()->lockedGraph(false); + QDialog::accept(); + close(); +} + + +/** + * Closes and destroys dialog + */ +void SUPERVGUI_BrowseNodeDlg::reject() { + myNode->getMain()->lockedGraph(false); + QDialog::reject(); + close(); +} + +/** + * Update current values on show event + */ +void SUPERVGUI_BrowseNodeDlg::showEvent( QShowEvent* theEvent ) { + setValues(); + QDialog::showEvent( theEvent ); +} + +/** + * Slot, called when field is focused + */ +void SUPERVGUI_BrowseNodeDlg::onFieldActivated() +{ + SUPERVGUI_PortField* aField = (SUPERVGUI_PortField*)sender(); + myActiveField = (aField->isEditable())? aField : 0; +} + + + +/** + * Slot, called when selection is changed + */ +void SUPERVGUI_BrowseNodeDlg::onSelectionChanged() +{ + if ( myActiveField ) { + if( mySelection->IObjectCount() == 1 ) { + Handle( SALOME_InteractiveObject ) anIO = mySelection->firstIObject(); + if ( anIO->hasEntry() ) { + SALOMEDS::SObject_var aObj = Supervision.getActiveStudy()-> + getStudyDocument()->FindObjectID( anIO->getEntry() ); + + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + Standard_CString ior = ""; + + if (aObj->FindAttribute( anAttr, "AttributeIOR" ) ) { + anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr ); + ior = anIOR->Value(); + myActiveField->setData( ior ); + } + } + } + } +} + +/** + * Constructor + */ +SUPERVGUI_GetValueDlg::SUPERVGUI_GetValueDlg( SUPERVGUI_PortIn* thePort ) + : QDialog( thePort, 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +{ + myOKBtn = 0; + setSizeGripEnabled( true ); + myPort = thePort; + myPortESNode = 0; + + mySelection = SALOME_Selection::Selection( Supervision.getActiveStudy()->getSelection() ); +// mySelection->ClearIObjects(); + + setName( "SUPERVGUI_GetValueDlg" ); + setCaption( tr( "TIT_SETVALUE_PORT" ) ); + + QGridLayout* aBaseLayout = new QGridLayout( this ); + aBaseLayout->setMargin( 11 ); aBaseLayout->setSpacing( 6 ); + + QGroupBox* aBox = new QGroupBox( this ); + aBox->setColumnLayout( 0, Qt::Vertical ); + aBox->layout()->setSpacing( 0 ); aBox->layout()->setMargin( 0 ); + QGridLayout* aBoxLayout = new QGridLayout( aBox->layout() ); + aBoxLayout->setAlignment( Qt::AlignTop ); + aBoxLayout->setSpacing( 6 ); aBoxLayout->setMargin( 11 ); + aBaseLayout->addWidget( aBox, 0, 0 ); + aBox->setMinimumWidth( 200 ); + + QLabel* aInfoLab = new QLabel( tr( "ENTER_OR_SELECT_LBL" ), aBox ); + QFont fnt = aInfoLab->font(); fnt.setBold( true ); aInfoLab->setFont( fnt ); + aBoxLayout->addMultiCellWidget( aInfoLab, 0, 0, 0, 1 ); + myField = new SUPERVGUI_PortField( aBox, myPort->getPort() ); + bool myIsEditable = myField->isEditable(); + aBoxLayout->addWidget( myField->myLabel, 1, 0 ); + aBoxLayout->addWidget( myField->myValue, 1, 1 ); + + QGroupBox* aBtnBox = new QGroupBox( this ); + aBtnBox->setColumnLayout( 0, Qt::Vertical ); + aBtnBox->layout()->setSpacing( 0 ); aBtnBox->layout()->setMargin( 0 ); + QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() ); + aBtnLayout->setAlignment( Qt::AlignTop ); + aBtnLayout->setSpacing( 6 ); aBtnLayout->setMargin( 11 ); + + aBaseLayout->addWidget( aBtnBox, 1, 0 ); + + if ( myIsEditable ) { + myOKBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox ); + connect( myOKBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); + aBtnLayout->addWidget( myOKBtn ); + } + + aBtnLayout->addStretch(); + myCancelBtn = new QPushButton( myIsEditable ? tr( "BUT_CANCEL" ) : tr( "BUT_CLOSE" ), aBtnBox ); + aBtnLayout->addWidget( myCancelBtn ); + connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + + if ( !myIsEditable ) + aBtnLayout->addStretch(); + + myField->updateGUI(); + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) ); + myPort->getMain()->lockedGraph(true); +} + +/** + * Constructor + */ +SUPERVGUI_GetValueDlg::SUPERVGUI_GetValueDlg( SUPERVGUI_PortInESNode* thePort ) + : QDialog( thePort, 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +{ + myOKBtn = 0; + setSizeGripEnabled( true ); + myPort = 0; + myPortESNode = thePort; + + mySelection = SALOME_Selection::Selection( Supervision.getActiveStudy()->getSelection() ); +// mySelection->ClearIObjects(); + + setName( "SUPERVGUI_GetValueDlg" ); + setCaption( tr( "TIT_SETVALUE_PORT" ) ); + + QGridLayout* aBaseLayout = new QGridLayout( this ); + aBaseLayout->setMargin( 11 ); aBaseLayout->setSpacing( 6 ); + + QGroupBox* aBox = new QGroupBox( this ); + aBox->setColumnLayout( 0, Qt::Vertical ); + aBox->layout()->setSpacing( 0 ); aBox->layout()->setMargin( 0 ); + QGridLayout* aBoxLayout = new QGridLayout( aBox->layout() ); + aBoxLayout->setAlignment( Qt::AlignTop ); + aBoxLayout->setSpacing( 6 ); aBoxLayout->setMargin( 11 ); + aBaseLayout->addWidget( aBox, 0, 0 ); + aBox->setMinimumWidth( 200 ); + + QLabel* aInfoLab = new QLabel( tr( "ENTER_OR_SELECT_LBL" ), aBox ); + QFont fnt = aInfoLab->font(); fnt.setBold( true ); aInfoLab->setFont( fnt ); + aBoxLayout->addMultiCellWidget( aInfoLab, 0, 0, 0, 1 ); + myField = new SUPERVGUI_PortField( aBox, myPortESNode->getPort() ); + bool myIsEditable = myField->isEditable(); + aBoxLayout->addWidget( myField->myLabel, 1, 0 ); + aBoxLayout->addWidget( myField->myValue, 1, 1 ); + + QGroupBox* aBtnBox = new QGroupBox( this ); + aBtnBox->setColumnLayout( 0, Qt::Vertical ); + aBtnBox->layout()->setSpacing( 0 ); aBtnBox->layout()->setMargin( 0 ); + QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() ); + aBtnLayout->setAlignment( Qt::AlignTop ); + aBtnLayout->setSpacing( 6 ); aBtnLayout->setMargin( 11 ); + + aBaseLayout->addWidget( aBtnBox, 1, 0 ); + + if ( myIsEditable ) { + myOKBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox ); + connect( myOKBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); + aBtnLayout->addWidget( myOKBtn ); + } + + aBtnLayout->addStretch(); + myCancelBtn = new QPushButton( myIsEditable ? tr( "BUT_CANCEL" ) : tr( "BUT_CLOSE" ), aBtnBox ); + aBtnLayout->addWidget( myCancelBtn ); + connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + + if ( !myIsEditable ) + aBtnLayout->addStretch(); + + myField->updateGUI(); + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) ); + myPortESNode->getMain()->lockedGraph(true); +} + +/** + * Destructor + */ +SUPERVGUI_GetValueDlg::~SUPERVGUI_GetValueDlg() { +} + +/** + * Set entered value into port and then closes and destroys dialog + */ +void SUPERVGUI_GetValueDlg::accept() { + if ( myField->setNewValue() ) { + + if (myPort != 0) + myPort->sync(); + else + myPortESNode->sync(); + } + else { + if ( QMessageBox::warning( QAD_Application::getDesktop(), + tr( "ERROR" ), tr( "MSG_CANT_SETVAL" ), + QMessageBox::Retry, QMessageBox::Abort) == QMessageBox::Retry ) + return; + } + + if (myPort != 0) + myPort->getMain()->lockedGraph(false); + else + myPortESNode->getMain()->lockedGraph(false); + QDialog::accept(); + close(); +} + +/** + * Closes and destroys dialog + */ +void SUPERVGUI_GetValueDlg::reject() { + if (myPort != 0) + myPort->getMain()->lockedGraph(false); + else + myPortESNode->getMain()->lockedGraph(false); + QDialog::reject(); + close(); +} + +/** + * Slot, called when selection is changed + */ +void SUPERVGUI_GetValueDlg::onSelectionChanged() +{ + if( mySelection->IObjectCount() == 1 ) { + Handle( SALOME_InteractiveObject ) anIO = mySelection->firstIObject(); + if ( anIO->hasEntry() ) { + SALOMEDS::SObject_var aObj = Supervision.getActiveStudy()-> + getStudyDocument()->FindObjectID( anIO->getEntry() ); + + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + Standard_CString ior = ""; + + if (aObj->FindAttribute( anAttr, "AttributeIOR" ) ) { + anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr ); + ior = anIOR->Value(); + myField->setData( ior ); + } + } + } +} + diff --git a/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.h b/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.h new file mode 100644 index 0000000..e938934 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.h @@ -0,0 +1,106 @@ +// File : SUPERVGUI_BrowseNodeDlg.h +// Created : 10 / 01 / 2003 +// Author : Vitaly SMETANNIKOV +// Project : SALOME +// Module : SUPERVGUI +// Copyright : Open CASCADE + + +#ifndef SUPERVGUI_BrowseNodeDlg_H +#define SUPERVGUI_BrowseNodeDlg_H + +#include +#include "SUPERVGUI_Def.h" +#include "SUPERVGUI_Port.h" +#include "SALOME_Selection.h" + +class SUPERVGUI_Node; + +/** + * Class for ports values management (for internal using) + */ +class SUPERVGUI_PortField : public QObject { + + Q_OBJECT + +public: + SUPERVGUI_PortField( QWidget* theParent, SUPERV_Port thePort ); + virtual ~SUPERVGUI_PortField() {}; + + bool eventFilter( QObject* o, QEvent* e ); + + bool isEditable () { return myIsEditable; } + + void setData( const QString& data ) { myValue->setText( data ); myValue->home( false ); } + void updateGUI() { myValue->setText( myPort->ToString() ); } + + bool setNewValue(); + +signals : + void activated(); + +public: + SUPERV_Port myPort; + QLabel* myLabel; + QLineEdit* myValue; + bool myIsEditable; +}; + + +/** + * Browse Node Dialog box + */ +class SUPERVGUI_BrowseNodeDlg: public QDialog { + + Q_OBJECT + +public: + SUPERVGUI_BrowseNodeDlg( SUPERVGUI_Node* theNode ); + virtual ~SUPERVGUI_BrowseNodeDlg(); + + void setValues(); + +protected slots: + void accept(); + void reject(); + void onFieldActivated(); + void onSelectionChanged(); + +protected: + void showEvent( QShowEvent* theEvent ); + +private: + SUPERVGUI_Node* myNode; + bool myIsEditable; + QPtrList myPortsList; + SUPERVGUI_PortField* myActiveField; + SALOME_Selection* mySelection; +}; + +/** + * Get Value dialog box + */ +class SUPERVGUI_GetValueDlg: public QDialog { + Q_OBJECT + +public: +// SUPERVGUI_GetValueDlg( SUPERVGUI_Port thePort ); + SUPERVGUI_GetValueDlg( SUPERVGUI_PortIn* thePort ); + SUPERVGUI_GetValueDlg( SUPERVGUI_PortInESNode* thePort ); + ~SUPERVGUI_GetValueDlg(); + +private slots: + void accept(); + void reject(); + void onSelectionChanged(); + +private: + QPushButton* myOKBtn; + QPushButton* myCancelBtn; + SUPERVGUI_PortField* myField; + SUPERVGUI_PortIn* myPort; + SUPERVGUI_PortInESNode* myPortESNode; //last correction + SALOME_Selection* mySelection; +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_ComputeNode.cxx b/src/SUPERVGUI/SUPERVGUI_ComputeNode.cxx new file mode 100644 index 0000000..131d644 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_ComputeNode.cxx @@ -0,0 +1,145 @@ +using namespace std; +// File : SUPERVGUI_ComputeNode.cxx +// Created : 09 / 01 / 2003 +// Author : Vitaly SMETANNIKOV +// Project : SALOME +// Module : SUPERVGUI +// Copyright : Open CASCADE + + +#include "SUPERVGUI_ComputeNode.h" +#include "SUPERVGUI_Main.h" +#include +#include + + +SUPERVGUI_ComputeNode::SUPERVGUI_ComputeNode(QWidget* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode) +:SUPERVGUI_GraphNode(theParent, theMain, theNode) +{ + setLineWidth(2); + setFrameStyle(QFrame::Panel | QFrame::Raised); + + QGridLayout* aGridLayout = new QGridLayout(this, 0, 2, 3, 1); + + myTitle->setPaletteBackgroundColor(QColor(63, 213, 255)); + myTitle->reparent(this, pos()); + aGridLayout->addMultiCellWidget(myTitle, 0, 0, 0, 1); + + QString aComment(theNode->Comment()); + if (aComment.isNull() || aComment.isEmpty()) { + if (getNodeType() == SUPERV::FactoryNode) + aComment = QString(myNode->Service()->ServiceName) + QString(tr("COMMENT_FROM")) + + QString(getFactoryNode()->GetComponentName()); + else + //aComment = tr("COMMENT_PYTHON"); + aComment = tr("COMMENT_CNODE"); + theNode->SetComment(aComment.latin1()); + } + + myServiceBox = new QVBox(this, "service"); + myComment = new SUPERVGUI_Label(myServiceBox, LABEL_WIDTH, LABEL_HEIGHT, aComment, QLabel::AlignLeft); + connect(myComment, SIGNAL(MousePress(QMouseEvent*)), this, SLOT(showPopup(QMouseEvent*))); + QToolTip::add(myComment, myComment->text()); + aGridLayout->addMultiCellWidget(myServiceBox, 1, 1, 0, 1); + + myStatus->reparent(this, pos()); + myTime->reparent(this, pos()); + aGridLayout->addWidget(myStatus, 2, 0); + aGridLayout->addWidget(myTime, 2, 1); + + myPortsBox->reparent(this, pos()); + + aGridLayout->addMultiCellWidget(myPortsBox, 3, 3, 0, 1); + adjustSize(); + + myShowPopup = new QPopupMenu(this); + myServiceItem = myShowPopup->insertItem(tr("POP_SHOWTITLES"), this, SLOT(switchService())); + myPortsItem = myShowPopup->insertItem(tr("POP_SHOWPORTS"), this, SLOT(switchPorts())); + + myPopup->insertSeparator(); + myPopup->insertItem(tr("POP_SHOW"), myShowPopup); + myShowPopup->setItemChecked(myServiceItem, true); + myShowPopup->setItemChecked(myPortsItem, true); + + show(); +} + + +SUPERVGUI_ComputeNode::~SUPERVGUI_ComputeNode() { + QToolTip::remove(myComment); +} + + +void SUPERVGUI_ComputeNode::sync() +{ + Trace("SUPERVGUI_Node::sync"); + setName(myNode->Name()); + myTitle->setText(name()); + + myComment->setText(myNode->Comment()); + + bool editing = myMain->getDataflow()->IsEditing(); + myPopup->setItemEnabled(myKillItem, !editing); + if (myMain->isEditable()) { + myPopup->setItemEnabled(myRenameItem, editing); + myPopup->setItemEnabled(myDeleteItem, editing); + } + SUPERVGUI_GraphNode::sync(); +} + + + +/** + * Hides services info and ports + */ +void SUPERVGUI_ComputeNode::hideAll() { + myServiceBox->hide(); + myShowPopup->setItemChecked(myServiceItem, false); + myPortsBox->hide(); + myShowPopup->setItemChecked(myPortsItem, false); + + updateShape(); +} + + +/** + * Shows services info and ports + */ +void SUPERVGUI_ComputeNode::showAll() { + myServiceBox->show(); + myShowPopup->setItemChecked(myServiceItem, true); + myPortsBox->show(); + myShowPopup->setItemChecked(myPortsItem, true); + + updateShape(); +} + + +/** + * Switches visibility of Service names in the node + */ +void SUPERVGUI_ComputeNode::switchService() { + bool aIsVisible = myServiceBox->isVisible(); + if (aIsVisible) myServiceBox->hide(); + else myServiceBox->show(); + updateShape(); + myShowPopup->setItemChecked(myServiceItem, !aIsVisible); +} + + +/** + * Switches visibility of Ports in the node + */ +void SUPERVGUI_ComputeNode::switchPorts() { + bool aIsVisible = myPortsBox->isVisible(); + if (aIsVisible) myPortsBox->hide(); + else myPortsBox->show(); + updateShape(); + myShowPopup->setItemChecked(myPortsItem, !aIsVisible); +} + + +void SUPERVGUI_ComputeNode::updateShape() { + qApp->processEvents(); + adjustSize(); +} diff --git a/src/SUPERVGUI/SUPERVGUI_ComputeNode.h b/src/SUPERVGUI/SUPERVGUI_ComputeNode.h new file mode 100644 index 0000000..6b66111 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_ComputeNode.h @@ -0,0 +1,46 @@ +// File : SUPERVGUI_ComputeNode.h +// Created : 09 / 01 / 2003 +// Author : Vitaly SMETANNIKOV +// Project : SALOME +// Module : SUPERVGUI +// Copyright : Open CASCADE + + +#ifndef SUPERVGUI_ComputeNode_H +#define SUPERVGUI_ComputeNode_H + +#include "SUPERVGUI_GraphNode.h" + + +class SUPERVGUI_ComputeNode: public SUPERVGUI_GraphNode { + Q_OBJECT + + public: + SUPERVGUI_ComputeNode(QWidget* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode); + virtual ~SUPERVGUI_ComputeNode(); + + void sync(); + void hideAll(); + void showAll(); + virtual void updateShape(); + + public slots: + void switchService(); + void switchPorts(); + + + private: + QPopupMenu* myShowPopup; + int myServiceItem; + int myPortsItem; + + //int myPIcount; + //int myPOcount; + + SUPERVGUI_Label* myComment; + QVBox* myServiceBox; + //QFrame* myPortsBox; + //QGridLayout* myPortLayout; +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_ControlNode.cxx b/src/SUPERVGUI/SUPERVGUI_ControlNode.cxx new file mode 100644 index 0000000..5000ba0 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_ControlNode.cxx @@ -0,0 +1,439 @@ +using namespace std; +// File : SUPERVGUI_ControlNode.cxx +// Created : 14 / 01 / 2003 +// Author : Vitaly SMETANNIKOV +// Project : SALOME +// Module : SUPERVGUI +// Copyright : Open CASCADE + + +#include "SUPERVGUI_ControlNode.h" +#include +#include "SUPERVGUI_Main.h" +#include + +#define TITLECOLOR Qt::red.light() +#define BACKCOLOR Qt::cyan.light() + +//----------------------------------------------------------- +//******************* Start Node **************************** +//----------------------------------------------------------- +SUPERVGUI_StartControlNode::SUPERVGUI_StartControlNode(QWidget* theParent, SUPERVGUI_Main* theMain, + SUPERV_CNode theNode): + SUPERVGUI_GraphNode(theParent, theMain, theNode) +{ + setPaletteBackgroundColor(BACKCOLOR); + QGridLayout* aGridLayout = new QGridLayout(this, 0, 3, 0, 0); + aGridLayout->setColStretch(0, 1); + aGridLayout->setColStretch(1, 1); + aGridLayout->addColSpacing(2, LABEL_HEIGHT/2); + + myTitle->setAlignment(Qt::AlignHCenter); + myTitle->reparent(this, pos()); + myTitle->setPaletteBackgroundColor(TITLECOLOR); + + aGridLayout->addMultiCellWidget(myTitle, 0, 0, 0, 2); + + myPortsBox->reparent(this, pos()); + aGridLayout->addMultiCellWidget(myPortsBox, 1, 1, 0, 1); + + myStatus->reparent(this, pos()); + myTime->reparent(this, pos()); + aGridLayout->addWidget(myStatus, 2, 0); + aGridLayout->addMultiCellWidget(myTime, 2, 2, 1, 2); + + myPopup->insertSeparator(); + myPortsItem = myPopup->insertItem(tr("POP_HIDEPORTS"), this, SLOT(switchPorts())); + + adjustSize(); + setShape(); + show(); +} + + +void SUPERVGUI_StartControlNode::switchPorts() { + bool aIsVisible = myPortsBox->isVisible(); + if (aIsVisible) myPortsBox->hide(); + else myPortsBox->show(); + updateShape(); + myPopup->setItemChecked(myPortsItem, aIsVisible); +} + + +void SUPERVGUI_StartControlNode::hideAll() { + myPortsBox->hide(); + updateShape(); + myPopup->setItemChecked(myPortsItem, true); +} + + +void SUPERVGUI_StartControlNode::showAll() { + myPortsBox->show(); + updateShape(); + myPopup->setItemChecked(myPortsItem, false); +} + + +void SUPERVGUI_StartControlNode::rename() { + SUPERVGUI_Node::rename(); + QString aStr(tr("ENDNODE_PREFIX")); + aStr+=name(); + myEndNode->setNodeName(aStr); +} + + +void SUPERVGUI_StartControlNode::remove() { + myEndNode->deleteLinks(); + deleteLinks(); + myEndNode->getEngine()->destroy(); + myNode->destroy(); + myMain->getGraph()->deleteNode(myEndNode); + myMain->getGraph()->deleteNode(this); +} + + +void SUPERVGUI_StartControlNode::setEndNode(SUPERVGUI_EndControlNode* theEndNode) { + myEndNode = theEndNode; +} + + +void SUPERVGUI_StartControlNode::setShape() { + int aH = height(); + int aW = width(); + int aOffset = LABEL_HEIGHT/2; + QPointArray aArray(8); + aArray.setPoint(0, aOffset, aH); + aArray.setPoint(1, 0, aH-LABEL_HEIGHT); + aArray.setPoint(2, 0, LABEL_HEIGHT); + aArray.setPoint(3, aOffset, 0); + aArray.setPoint(4, aW, 0); + aArray.setPoint(5, aW-aOffset, LABEL_HEIGHT); + aArray.setPoint(6, aW-aOffset, aH-LABEL_HEIGHT); + aArray.setPoint(7, aW, aH); + QRegion aRegion(aArray); + + setMask(aRegion); +} + + +void SUPERVGUI_StartControlNode::updateShape() { + qApp->processEvents(); + adjustSize(); + setShape(); +} + + +void SUPERVGUI_StartControlNode::addOutputPort() { + SUPERVGUI_GraphNode::addOutputPort(); + myEndNode->updatePorts(); + myEndNode->updateShape(); + updateLinksPrs(true); + myEndNode->updateLinksPrs(true); +} + +void SUPERVGUI_StartControlNode::addInputPort() { + SUPERVGUI_GraphNode::addInputPort(); + myEndNode->updatePorts(); + myEndNode->updateShape(); + updateLinksPrs(true); + myEndNode->updateLinksPrs(true); +} + +void SUPERVGUI_StartControlNode::deletePort(SUPERVGUI_Port* thePort) { + if (getNodeType() == SUPERV::LoopNode) { + SUPERV_Port aPortEngine = thePort->getPort(); + QString aName(aPortEngine->Name()); + QString aNameIn = aName + "Input"; + QString aNameOut = aName + "Output"; + + SUPERVGUI_Port* aPort = (SUPERVGUI_Port*) child(aNameOut, "SUPERVGUI_Port"); + aPort->deleteLinks(); + aPort->close(true); + + aPort = (SUPERVGUI_Port*) child(aNameIn, "SUPERVGUI_Port"); + aPort->deleteLinks(); + aPort->close(true); + + aPort = (SUPERVGUI_Port*) myEndNode->child(aNameIn, "SUPERVGUI_Port"); + aPort->deleteLinks(); + aPort->close(true); + + aPort = (SUPERVGUI_Port*) myEndNode->child(aNameOut, "SUPERVGUI_Port"); + aPort->deleteLinks(); + aPort->close(true); + + myPIcount--; + myPOcount--; + myEndNode->getPIcount()--; + myEndNode->getPOcount()--; + + aPortEngine->destroy(); + updatePorts(); + updateShape(); + myEndNode->updatePorts(); + myEndNode->updateShape(); + } else { + SUPERVGUI_GraphNode::deletePort(thePort); + } +} + + +QPoint SUPERVGUI_StartControlNode::getOutConnectPnt() { + return QPoint(pos().x() + width() - LABEL_HEIGHT/2, + pos().y() + (height()/2)); +} + + +//----------------------------------------------------------- +//******************* End Node ****************************** +//----------------------------------------------------------- + +SUPERVGUI_EndControlNode::SUPERVGUI_EndControlNode(QWidget* theParent, SUPERVGUI_Main* theMain, + SUPERV_CNode theNode, SUPERVGUI_StartControlNode* theStart): + SUPERVGUI_GraphNode(theParent, theMain, theNode) +{ + myStartNode = theStart; + + setPaletteBackgroundColor(BACKCOLOR); + + QGridLayout* aGridLayout = new QGridLayout(this, 0, 3, 0, 0); + aGridLayout->setColStretch(1, 1); + aGridLayout->setColStretch(2, 1); + aGridLayout->addColSpacing(0, LABEL_HEIGHT/2); + + myTitle->setAlignment(Qt::AlignHCenter); + myTitle->reparent(this, pos()); + myTitle->setPaletteBackgroundColor(TITLECOLOR); + aGridLayout->addMultiCellWidget(myTitle, 0, 0, 0, 2); + + myPortsBox = new QFrame(this); + myPortLayout = new QGridLayout(myPortsBox, 0, 2, 0, 1); + + myPIcount = 0; + myPOcount = 0; + SUPERV_Ports ports = myNode->Ports(); + int n = ports->length(); + + for (int i=0; iIsInput()) { + myPortLayout->addWidget(new SUPERVGUI_PortIn(myPortsBox, myMain, ports[i]), + myPIcount, 0); + myPIcount++; + } else { + myPortLayout->addWidget(new SUPERVGUI_PortOut(myPortsBox, myMain, ports[i]), + myPOcount, 1, Qt::AlignRight); + myPOcount++; + } + } + aGridLayout->addMultiCellWidget(myPortsBox, 1, 1, 1, 2); + + myStatus->reparent(this, pos()); + myTime->reparent(this, pos()); + aGridLayout->addMultiCellWidget(myStatus, 2, 2, 0, 1); + aGridLayout->addWidget(myTime, 2, 2); + + adjustSize(); + setShape(); + + myPopup->removeItem(myRenameItem); + myPopup->removeItem(myDeleteItem); + myPopup->removeItem(mySeparatorId); + + myPopup->insertSeparator(); + myPortsItem = myPopup->insertItem(tr("POP_HIDEPORTS"), this, SLOT(switchPorts())); + myStartNode->setEndNode(this); + show(); +} + + +void SUPERVGUI_EndControlNode::switchPorts() { + bool aIsVisible = myPortsBox->isVisible(); + if (aIsVisible) myPortsBox->hide(); + else myPortsBox->show(); + updateShape(); + myPopup->setItemChecked(myPortsItem, aIsVisible); +} + +void SUPERVGUI_EndControlNode::hideAll() { + myPortsBox->hide(); + updateShape(); + myPopup->setItemChecked(myPortsItem, true); +} + + +void SUPERVGUI_EndControlNode::showAll() { + myPortsBox->show(); + updateShape(); + myPopup->setItemChecked(myPortsItem, false); +} + + +void SUPERVGUI_EndControlNode::setShape() { + int aH = height(); + int aW = width(); + int aOffset = LABEL_HEIGHT/2; + QPointArray aArray(8); + aArray.setPoint(0, 0, aH); + aArray.setPoint(1, aOffset, aH-LABEL_HEIGHT); + aArray.setPoint(2, aOffset, LABEL_HEIGHT); + aArray.setPoint(3, 0, 0); + aArray.setPoint(4, aW-aOffset, 0); + aArray.setPoint(5, aW, LABEL_HEIGHT); + aArray.setPoint(6, aW, aH-LABEL_HEIGHT); + aArray.setPoint(7, aW-aOffset, aH); + QRegion aRegion(aArray); + + setMask(aRegion); +} + + +void SUPERVGUI_EndControlNode::updateShape() { + qApp->processEvents(); + adjustSize(); + setShape(); +} + + +QPoint SUPERVGUI_EndControlNode::getInConnectPnt() { + return QPoint(pos().x() + LABEL_HEIGHT/2, + pos().y() + (height()/2)); +} + + +//----------------------------------------------------------- +//******************* GoTo Node ***************************** +//----------------------------------------------------------- +SUPERVGUI_GotoNode::SUPERVGUI_GotoNode(QWidget* theParent, SUPERVGUI_Main* theMain, + SUPERV_CNode theNode): + SUPERVGUI_GraphNode(theParent, theMain, theNode) +{ + setPaletteBackgroundColor(BACKCOLOR); + + QGridLayout* aGridLayout = new QGridLayout(this, 3, 2, 0, 0); + + myTitle->setAlignment(Qt::AlignHCenter); + myTitle->reparent(this, pos()); + myTitle->setPaletteBackgroundColor(Qt::green.light()); + aGridLayout->addMultiCellWidget(myTitle, 0, 0, 0, 1); + + myPortsBox->reparent(this, pos()); + aGridLayout->addMultiCellWidget(myPortsBox, 1, 1, 0, 1); + + myStatus->reparent(this, pos()); + myTime->reparent(this, pos()); + aGridLayout->addWidget(myStatus, 2, 0); + aGridLayout->addWidget(myTime, 2, 1); + + myPopup->insertSeparator(); + myPopup->insertItem("Link to Node...", this, SLOT(linkToNode())); + + adjustSize(); + setShape(); + show(); + + //SUPERV_Ports aPorts = getEngine()->Ports(); //existing + //int n = aPorts->length(); +} + + +void SUPERVGUI_GotoNode::setShape() { + int aH = height(); + int aW = width(); + QPointArray aArray(8); + aArray.setPoint(0, LABEL_HEIGHT, aH); + aArray.setPoint(1, 0, aH-LABEL_HEIGHT); + aArray.setPoint(2, 0, LABEL_HEIGHT); + aArray.setPoint(3, LABEL_HEIGHT, 0); + aArray.setPoint(4, aW-LABEL_HEIGHT, 0); + aArray.setPoint(5, aW, LABEL_HEIGHT); + aArray.setPoint(6, aW, aH-LABEL_HEIGHT); + aArray.setPoint(7, aW-LABEL_HEIGHT, aH); + QRegion aRegion(aArray); + + setMask(aRegion); +} + + +void SUPERVGUI_GotoNode::hideAll() { + myPortsBox->hide(); + updateShape(); + //myPopup->setItemChecked(myPortsItem, true); +} + + +void SUPERVGUI_GotoNode::showAll() { + myPortsBox->show(); + updateShape(); + //myPopup->setItemChecked(myPortsItem, false); +} + +void SUPERVGUI_GotoNode::updateShape() { + qApp->processEvents(); + adjustSize(); + setShape(); +} + + +void SUPERVGUI_GotoNode::linkToNode() { + SUPERVGUI_SelectInlineDlg* aDlg = new SUPERVGUI_SelectInlineDlg(getMain()); + if (aDlg->exec()) { + setLinkedNode((char*)aDlg->getName().latin1()); + myMain->getGraph()->sync(); + } + delete aDlg; +} + + +void SUPERVGUI_GotoNode::setLinkedNode(char* theNodeName) { + getGotoNode()->SetCoupled(theNodeName); +} + + + +//----------------------------------------------------------- +//*************** Select Inline node dialog****************** +//----------------------------------------------------------- + +SUPERVGUI_SelectInlineDlg::SUPERVGUI_SelectInlineDlg(SUPERVGUI_Main* theMain) + :QDialog(theMain, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +{ + setSizeGripEnabled( true ); + setCaption(tr("TIT_FUNC_PYTHON")); + QGridLayout* aMainLayout = new QGridLayout(this, 2, 2, 7, 4); + + QLabel* aLabel = new QLabel("Connect to", this ); + aMainLayout->addWidget(aLabel, 0, 0); + + myCombo = new QComboBox(this); + SUPERV_Nodes aNodesList = theMain->getDataflow()->Nodes(); + int i; + for (i = 0; i < aNodesList->INodes.length(); i++) { + myCombo->insertItem(QString(aNodesList->INodes[i]->Name())); + } + for (i = 0; i < aNodesList->LNodes.length(); i++) { + myCombo->insertItem(QString(aNodesList->LNodes[i]->Name())); + } + for (i = 0; i < aNodesList->SNodes.length(); i++) { + myCombo->insertItem(QString(aNodesList->SNodes[i]->Name())); + } + aMainLayout->addWidget(myCombo, 0, 1); + + QGroupBox* aBtnBox = new QGroupBox( this ); + aBtnBox->setColumnLayout( 0, Qt::Vertical ); + aBtnBox->layout()->setSpacing( 0 ); aBtnBox->layout()->setMargin( 0 ); + QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() ); + aBtnLayout->setAlignment( Qt::AlignTop ); + aBtnLayout->setSpacing( 6 ); aBtnLayout->setMargin( 11 ); + + QPushButton* aOKBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox ); + connect( aOKBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); + aBtnLayout->addWidget( aOKBtn ); + + aBtnLayout->addStretch(); + + QPushButton* aCancelBtn = new QPushButton( tr("BUT_CANCEL"), aBtnBox ); + connect( aCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + aBtnLayout->addWidget( aCancelBtn ); + + aMainLayout->addMultiCellWidget(aBtnBox, 1, 1, 0, 1); +} diff --git a/src/SUPERVGUI/SUPERVGUI_ControlNode.h b/src/SUPERVGUI/SUPERVGUI_ControlNode.h new file mode 100644 index 0000000..aad601a --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_ControlNode.h @@ -0,0 +1,126 @@ +// File : SUPERVGUI_ControlNode.h +// Created : 14 / 01 / 2003 +// Author : Vitaly SMETANNIKOV +// Project : SALOME +// Module : SUPERVGUI +// Copyright : Open CASCADE + +#ifndef SUPERVGUI_ControlNode_H +#define SUPERVGUI_ControlNode_H + +#include "SUPERVGUI_GraphNode.h" +#include +#include +#include + + +class SUPERVGUI_EndControlNode; + + +/** + * Start node of Switch and Loop + */ +class SUPERVGUI_StartControlNode: public SUPERVGUI_GraphNode { + Q_OBJECT + + public: + SUPERVGUI_StartControlNode(QWidget* theParent, SUPERVGUI_Main* theMain, + SUPERV_CNode theNode); + virtual ~SUPERVGUI_StartControlNode() {}; + + virtual void hideAll(); + virtual void showAll(); + virtual void updateShape(); + virtual void deletePort(SUPERVGUI_Port* thePort); + + void setEndNode(SUPERVGUI_EndControlNode* theEndNode); + + virtual QPoint getOutConnectPnt(); + + public slots: + void switchPorts(); + virtual void rename(); + virtual void remove(); + virtual void addInputPort(); + virtual void addOutputPort(); + + private: + void setShape(); + + SUPERVGUI_EndControlNode* myEndNode; + int myPortsItem; +}; + + + + +/** + * End node of Switch and Loop + */ +class SUPERVGUI_EndControlNode: public SUPERVGUI_GraphNode { + Q_OBJECT + + public: + SUPERVGUI_EndControlNode(QWidget* theParent, SUPERVGUI_Main* theMain, + SUPERV_CNode theNode, SUPERVGUI_StartControlNode* theStart); + virtual ~SUPERVGUI_EndControlNode() {}; + + virtual void hideAll(); + virtual void showAll(); + virtual void updateShape(); + + virtual QPoint getInConnectPnt(); + + public slots: + void switchPorts(); + + private: + void setShape(); + + SUPERVGUI_StartControlNode* myStartNode; + int myPortsItem; +}; + + +class SUPERVGUI_SelectInlineDlg: public QDialog { + Q_OBJECT + + public: + SUPERVGUI_SelectInlineDlg(SUPERVGUI_Main* theMain); + virtual ~SUPERVGUI_SelectInlineDlg() {}; + + QString getName() { return myCombo->currentText(); } + + private: + QComboBox* myCombo; +}; + + +/** + * GOTO node + */ +class SUPERVGUI_GotoNode: public SUPERVGUI_GraphNode { + Q_OBJECT + + public: + SUPERVGUI_GotoNode(QWidget* theParent, SUPERVGUI_Main* theMain, + SUPERV_CNode theNode); + virtual ~SUPERVGUI_GotoNode() {}; + + virtual void hideAll(); + virtual void showAll(); + virtual void updateShape(); + + void setLinkedNode(char* theNodeName); + + public slots: + void linkToNode(); + + private: + void setShape(); + + +}; + + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_CtrlLink.cxx b/src/SUPERVGUI/SUPERVGUI_CtrlLink.cxx new file mode 100644 index 0000000..c13e121 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_CtrlLink.cxx @@ -0,0 +1,45 @@ +using namespace std; +// File : SUPERVGUI_CtrlLink.cxx +// Created : 14 / 05 / 2003 +// Author : Vitaly SMETANNIKOV +// Project : SALOME +// Module : SUPERVGUI +// Copyright : Open CASCADE + + +#include "SUPERVGUI_CtrlLink.h" +#include "SUPERVGUI_Graph.h" +#include "SUPERVGUI_GraphNode.h" + +#define LINE_WIDTH 2 +#define DRAW_CLR Qt::black + +SUPERVGUI_CtrlLink::SUPERVGUI_CtrlLink(SUPERVGUI_Graph* theGraph, + SUPERVGUI_GraphNode* theFromNode, + SUPERVGUI_GraphNode* theToNode) +{ + myOutNode = theFromNode; + myInNode = theToNode; + myGraph = theGraph; +} + + + +void SUPERVGUI_CtrlLink::paint(QPainter* thePainter, bool toErase) { + if ((myGraph == NULL) || (myInNode == NULL) || (myOutNode == NULL)) + return; + thePainter->save(); + + QPen aDataPen; + aDataPen.setWidth(LINE_WIDTH); + if (toErase) { + aDataPen.setColor(myGraph->viewport()->paletteBackgroundColor()); + } else { + aDataPen.setColor(DRAW_CLR); + } + thePainter->setPen(aDataPen); + thePainter->moveTo(myOutNode->getOutConnectPnt()); + thePainter->lineTo(myInNode->getInConnectPnt()); + + thePainter->restore(); +} diff --git a/src/SUPERVGUI/SUPERVGUI_CtrlLink.h b/src/SUPERVGUI/SUPERVGUI_CtrlLink.h new file mode 100644 index 0000000..85aecef --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_CtrlLink.h @@ -0,0 +1,37 @@ +// File : SUPERVGUI_CtrlLink.h +// Created : 14 / 05 / 2003 +// Author : Vitaly SMETANNIKOV +// Project : SALOME +// Module : SUPERVGUI +// Copyright : Open CASCADE + + +#ifndef SUPERVGUI_CTRLLink_H +#define SUPERVGUI_CTRLLink_H + + +#include "SUPERVGUI_Def.h" + +class SUPERVGUI_Graph; +class SUPERVGUI_GraphNode; + +class SUPERVGUI_CtrlLink { +public: + SUPERVGUI_CtrlLink() { myOutNode=NULL; myInNode=NULL; myGraph=NULL; } + + SUPERVGUI_CtrlLink(SUPERVGUI_Graph* theGraph, + SUPERVGUI_GraphNode* theFromNode, + SUPERVGUI_GraphNode* theToNode); + + ~SUPERVGUI_CtrlLink() {}; + + + void paint(QPainter* thePainter, bool toErase); + +private: + SUPERVGUI_GraphNode* myOutNode; + SUPERVGUI_GraphNode* myInNode; + SUPERVGUI_Graph* myGraph; +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_Def.h b/src/SUPERVGUI/SUPERVGUI_Def.h new file mode 100644 index 0000000..64ae50c --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Def.h @@ -0,0 +1,214 @@ +// File : SUPERVGUI_Def.h +// Created : 18 / 11 / 2002 +// Author : Vitaly SMETANNIKOV +// Project : SALOME +// Module : SUPERVGUI +// Copyright : Open CASCADE + +#ifndef SUPERVGUI_DEF_H +#define SUPERVGUI_DEF_H + + +// Nom du noeud de supervision dans l'etude +// ---------------------------------------- + +#define STUDY_SUPERVISION "Supervision" + +#define STUDY_PORT_IN "In" +#define STUDY_PORT_OUT "Out" + +// Nom d'un nouveau Dataflow +// ------------------------- + +#define MAIN_NEW "aNewDataFlow" + +#define MAIN_COLOR QColor(165, 255, 176) +#define MAIN_TITLE QColor( 63, 213, 255) +#define MAIN_CTRL QColor(255, 108, 106) +#define MAIN_BACK QColor(NODE_RED, NODE_GREEN, NODE_BLUE) + +// Taille du dataflow sous forme de graphe +// --------------------------------------- + +#define GRAPH_WIDTH 3500 +#define GRAPH_HEIGHT 3500 + +#define GRAPH_MAX 245e5 + +// Taille du dataflow sous forme de tableau +// ---------------------------------------- + +#define ARRAY_WIDTH 1500 +#define ARRAY_HEIGHT 3000 + +#define CELL_WIDTH 270 +#define CELL_WIDTH_PART 90 +#define CELL_HEIGHT 25 + +#define CELL_SPACE 5 + +// Noeuds +// ------ +/* +NODE_Waiting "Waiting", 035, 192, 255, true, true, true, true bleu +NODE_Running "Running", 032, 210, 032, true, true, true, true vert +NODE_Suspended "Suspended", 255, 180, 000, false, true, true, true orange +NODE_Done "Finished", 255, 158, 255, true, false, true, false violet +NODE_Errored "Aborted", 255, 000, 000, true, false, true, false rouge +NODE_Killed "Killed", 255, 000, 000, true, false, b, !b rouge +NODE_Editing "", NODE_RED, NODE_GREEN, NODE_BLUE, true, false, true, false fond +*/ + + +#define NODE_RED 255 +#define NODE_GREEN 249 +#define NODE_BLUE 147 + +#define NODE_DX 35 +#define NODE_DY 40 + +// Ports +// ----- + +#define PORT_WIDTH 75 +#define PORT_HEIGHT 28 + +// Taille des points carres constituant les lignes entre les noeuds +// ---------------------------------------------------------------- + +#define POINT_SIZE 5 +#define POINT_SIZE_HALF 2 + +// Taille et couleurs des liens +// ---------------------------- + +#define LINK_WIDTH 2 + +#define LINK_DATA QColor( 0, 0, 0), LINK_WIDTH +#define LINK_CTRL MAIN_CTRL , LINK_WIDTH +#define LINK_SKCH QColor(255, 0, 230), LINK_WIDTH + +// Taille des labels des noeuds +// ---------------------------- + +#define LABEL_WIDTH 160 +#define LABEL_HEIGHT 20 + +// Taille de la boite de filtre de notification +// -------------------------------------------- + +#define NOTIFICATION_WIDTH 250 +#define NOTIFICATION_HEIGHT 450 + +// Names of control ports +// ------------------------- +#define OUTVOID "OutVoid" +#define INVOID "InVoid" + +// Convention pour la souris +// ------------------------- + +#define MouseNo (-2) + +// Trace pour l'aide a la mise au point +// ------------------------------------ + +//#define DEBUG_MODE_COMPIL + +#ifdef DEBUG_MODE_COMPIL + +#define Trace(m) MESSAGE(m); + +#else + +#define Trace(m) + +#endif + + +// Includes de base +// ---------------- + +#include + +// Includes Qt +// ----------- + +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +//VRV: porting on Qt 3.0.5 +#if QT_VERSION >= 0x030005 +#include +#endif +//VRV: porting on Qt 3.0.5 + +// Acces au moteur de supervision +// ------------------------------ + +#include "utilities.h" + +#include "SALOME_LifeCycleCORBA.hxx" +#include CORBA_CLIENT_HEADER(SUPERV) +#include CORBA_SERVER_HEADER(SALOMEDS) +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + +#define SUPERV_Engine SUPERV::SuperG_var* + +#define SUPERV_Graph SUPERV::Graph_var + +#define SUPERV_CNode SUPERV::CNode_var +#define SUPERV_FNode SUPERV::FNode_var +#define SUPERV_INode SUPERV::INode_var +#define SUPERV_SNode SUPERV::SNode_var +#define SUPERV_LNode SUPERV::LNode_var +#define SUPERV_GNode SUPERV::GNode_var +#define SUPERV_ELNode SUPERV::ELNode_var +#define SUPERV_ESNode SUPERV::ESNode_var + +#define SUPERV_Links SUPERV::ListOfLinks_var +#define SUPERV_Ports SUPERV::ListOfPorts_var +#define SUPERV_Nodes SUPERV::ListOfNodes_var +#define SUPERV_Strings SUPERV::ListOfStrings_var + +#define SUPERV_Link SUPERV::Link_var +#define SUPERV_Date SUPERV::SDate +#define SUPERV_Port SUPERV::Port_var + +#define SUPERV_Editing SUPERV::EditingState +#define SUPERV_Running SUPERV::RunningState +#define SUPERV_Suspend SUPERV::SuspendState +#define SUPERV_Done SUPERV::DoneState +#define SUPERV_Error SUPERV::ErrorState +#define SUPERV_Kill SUPERV::KillState +#define SUPERV_Stop SUPERV::StopState +#define SUPERV_Ready SUPERV::ReadyState +#define SUPERV_Waiting SUPERV::WaitingState + +//#define SUPERV_Event SUPERV::GraphEvent +//#define SUPERV_State SUPERV::GraphState + +#define SUPERV_isNull(oc) (CORBA::is_nil(oc)) + + +enum GraphViewType { GRAPH, CONTROLFLOW, TABLE }; +//enum NodeType { COMPUTE, SWITCH, LOOP, GOTO, LABEL }; + + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_Graph.cxx b/src/SUPERVGUI/SUPERVGUI_Graph.cxx new file mode 100644 index 0000000..470b883 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Graph.cxx @@ -0,0 +1,593 @@ +using namespace std; +// File : SUPERVGUI_Graph.cxx +// Created : 17 / 10 / 2001 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGUI +// Copyright : CEA + +#include "SUPERVGUI_Def.h" +#include "SUPERVGUI_Graph.h" +#include "SUPERVGUI_Main.h" +#include "SUPERVGUI_ComputeNode.h" +#include "SUPERVGUI_ControlNode.h" + + +//#define CHECKTIME + +#ifdef CHECKTIME +#include +#endif + + +#define UPDATECONTROLNODES(NodesName) \ + n = nodes->NodesName.length(); \ + for (int i=0; iNodesName[i]); \ + SUPERV_CNode aCNodeEnd = SUPERV::CNode::_narrow(nodes->NodesName[i]->Coupled()); \ + ihmNode = (SUPERVGUI_Node *)child(aCNode->Name(), "SUPERVGUI_Node"); \ + if (ihmNode == NULL) { \ + main->addControlNode(aCNode, aCNodeEnd, false); \ + } else { \ + ResizeGraph(ihmNode, aCNode->X(), aCNode->Y()); \ + moveChild(ihmNode, aCNode->X(), aCNode->Y()); \ + ihmList->removeRef(ihmNode); \ + ihmNode->sync(); \ + aEndNodePrs = (SUPERVGUI_EndControlNode*)child(aCNodeEnd->Name(), "SUPERVGUI_EndControlNode"); \ + ResizeGraph(aEndNodePrs, aCNodeEnd->X(), aCNodeEnd->Y()); \ + moveChild(aEndNodePrs, aCNodeEnd->X(), aCNodeEnd->Y()); \ + ihmList->removeRef(aEndNodePrs); \ + aEndNodePrs->sync(); \ + } \ + } + + +#define UPDATENODES(NodesName, FuncName) \ + n = nodes->NodesName.length(); \ + for (int i=0; iNodesName[i]); \ + ihmNode = (SUPERVGUI_Node *)child(aCNode->Name(), "SUPERVGUI_Node"); \ + if (ihmNode == NULL) { \ + main->FuncName(aCNode); \ + } else { \ + ResizeGraph(ihmNode, aCNode->X(), aCNode->Y()); \ + moveChild(ihmNode, aCNode->X(), aCNode->Y()); \ + ihmList->removeRef(ihmNode); \ + ihmNode->sync(); \ + } \ + } + + +SUPERVGUI_Graph::SUPERVGUI_Graph(SUPERVGUI_Main* m): + SUPERVGUI_View(m), + myNewLink(0) +{ + Trace("SUPERVGUI_Graph::SUPERVGUI_Graph"); + myIsControlView = false; + myLinksList.setAutoDelete(true); + viewport()->setMouseTracking(true); + + resizeContents(GRAPH_WIDTH, GRAPH_HEIGHT); + + if (SUPERV_isNull(main->getDataflow())) return; + + + //create sketching popup menu + mySketchPopup = new QPopupMenu(viewport()); + if (!mySketchPopup->isCheckable()) + mySketchPopup->setCheckable(true); + myDelPntItem = mySketchPopup->insertItem(tr("MSG_DEL_LAST_PNT"), this, SLOT(delLastPnt())); + mySketchPopup->insertItem(tr("MSG_DEL_LINK"), this, SLOT(delCreatingLink())); + myOrtoItem = mySketchPopup->insertItem(tr("MSG_ORTHO_LINE"), this, SLOT(setOrtho())); + + //create link popup menu + myLinkPopup = new QPopupMenu(viewport()); + myDelLinkItem = myLinkPopup->insertItem(tr("MSG_DELLINK"), this, SLOT(deleteLink())); + myAddLinkPntItem = myLinkPopup->insertItem(tr("MSG_ADD_POINT"), this, SLOT(addPoint())); + myDelLinkPntItem = myLinkPopup->insertItem(tr("MSG_DEL_POINT"), this, SLOT(deletePoint())); +} + + + +SUPERVGUI_Graph::~SUPERVGUI_Graph() { +} + +/** + * Synchronizes Graph presentation with internal graph structure + */ +void SUPERVGUI_Graph::sync() { + if (SUPERV_isNull(main->getDataflow())) return; + + myLinksList.clear(); + + SUPERVGUI_Node* ihmNode; + QObjectList* ihmList = queryList("SUPERVGUI_Node"); + SUPERV_Nodes nodes = main->getDataflow()->Nodes(); + + MESSAGE("CNodes="<CNodes.length()); + MESSAGE("FNodes="<FNodes.length()); + MESSAGE("INodes="<INodes.length()); + MESSAGE("GNodes="<GNodes.length()); + MESSAGE("LNodes="<LNodes.length()); + MESSAGE("SNodes="<SNodes.length()); + + int n; + UPDATENODES(CNodes, addComputeNode); + UPDATENODES(FNodes, addComputeNode); + UPDATENODES(INodes, addComputeNode); + UPDATENODES(GNodes, addGOTONode); + + SUPERVGUI_EndControlNode* aEndNodePrs; + UPDATECONTROLNODES(LNodes); + UPDATECONTROLNODES(SNodes); + + QObjectListIt i(*ihmList); + while ((ihmNode=(SUPERVGUI_Node*)i.current()) != 0) { + ++i; + ihmNode->close(true); + } + delete ihmList; + + ihmList = queryList("SUPERVGUI_GraphNode"); + i=(*ihmList); + SUPERVGUI_GraphNode* aGraphNode; + while ((aGraphNode=(SUPERVGUI_GraphNode*)i.current()) != 0) { + ++i; + aGraphNode->updateLinksPrs(); + } + delete ihmList; + + draw(); +} + + +/** + * Reimplemented for repainting links + */ +bool SUPERVGUI_Graph::eventFilter(QObject* object, QEvent* event) { + if (event->type() == QEvent::Paint) { + draw(); + return true; + } + return QScrollView::eventFilter(object, event); +} + + +/** + * Clears content of Graph (links) + */ +void SUPERVGUI_Graph::clearView() { + QPainter aPainter(viewport()); + aPainter.eraseRect(viewport()->rect()); +} + + +/** + * Draws links using off screen buffer + */ +void SUPERVGUI_Graph::draw() { +#ifdef CHECKTIME + struct timeb aTm1; + ftime(&aTm1); +#endif + if (myLinksList.count() == 0) { + return; + } + int aWidth = viewport()->width(); + int aHeight = viewport()->height(); + QPixmap aPixmap(aWidth, aHeight); + aPixmap.setOptimization(QPixmap::BestOptim); + aPixmap.fill(viewport()->paletteBackgroundColor()); + + QPainter aPainter(&aPixmap); + QPoint aPos = viewportToContents(viewport()->pos()); + + if (myIsControlView) { + SUPERVGUI_CtrlLink* aLink; + QMap::Iterator it; + for ( it = myCtrlLinks.begin(); it != myCtrlLinks.end(); ++it ) { + it.data().paint(&aPainter, false); + } + } else { + SUPERVGUI_Link* aLink; + for (aLink = myLinksList.first(); aLink; aLink = myLinksList.next()) { + aLink->isInRect(aPos.x(), aPos.y(), aWidth, aHeight); + if (aLink->isInRect(aPos.x(), aPos.y(), aWidth, aHeight)) { + aLink->paint(&aPainter, false); + } + } + } + bitBlt(viewport(), 0, 0, + &aPixmap, 0, 0, aWidth, aHeight, + Qt::CopyROP, true); + + if (myNewLink) { + myNewLink->repaintSketch(); + } +#ifdef CHECKTIME + struct timeb aTm2; + ftime(&aTm2); + ulong aTm = 1000*(aTm2.time-aTm1.time)+(aTm2.millitm-aTm1.millitm); + cout<<"### Time="<button() == Qt::RightButton) { + if (myNewLink) { + main->showPopup(mySketchPopup, e); + } else { + SUPERVGUI_Link* aLink = SUPERVGUI_Link::getSelectedLink(); + if (aLink && main->isEditable()) { + myLinkPopup->setItemEnabled(myAddLinkPntItem, + !aLink->haveSelectedPoint()); + myLinkPopup->setItemEnabled(myDelLinkPntItem, + aLink->haveSelectedPoint()); + + + if (!aLink->isESInputPort()) { + SUPERV::KindOfPort aOutType = aLink->getOutputPort()->getPort()->Kind(); + SUPERV::KindOfPort aInType = aLink->getInputPort()->getPort()->Kind(); + myLinkPopup->setItemEnabled(myDelLinkItem, + ((aOutType != SUPERV::LoopParameter) + && + (aInType != SUPERV::LoopParameter))); + } + + myMousePos = e->pos(); + mySelectedLink = aLink; + mySelectedPoint = mySelectedLink->getSelectedPoint(); + main->showPopup(myLinkPopup, e); + } else { + mySelectedLink = 0; + main->showPopup(myPopup, e); + } + } + } + emit mousePressed(e); + + SUPERVGUI_View::contentsMousePressEvent(e); +} + + +void SUPERVGUI_Graph::contentsMouseReleaseEvent(QMouseEvent* e) { + Trace("SUPERVGUI_Graph::contentsMouseReleaseEvent"); + if (myNewLink && (e->button() == Qt::LeftButton)) { + myNewLink->addTmpPoint(e->pos()); + mySketchPopup->setItemEnabled(myDelPntItem, true); + } + emit mouseReleased(e); + SUPERVGUI_View::contentsMouseReleaseEvent(e); +} + + +void SUPERVGUI_Graph::contentsMouseMoveEvent(QMouseEvent* e) { + Trace("SUPERVGUI_Graph::contentsMouseMoveEvent"); + if (myNewLink) { + myNewLink->drawTo(e->pos()); + } + emit mouseMoved(e); + SUPERVGUI_View::contentsMouseMoveEvent(e); +} + + +void SUPERVGUI_Graph::addPoint() { + mySelectedLink->addPoint(myMousePos.x(), myMousePos.y()); +} + + +void SUPERVGUI_Graph::deletePoint() { + mySelectedLink->removePoint(mySelectedPoint); +} + + +void SUPERVGUI_Graph::deleteLink() { + QString aName; + if (mySelectedLink->isESInputPort()) + aName = mySelectedLink->getInputPortES()->getPort()->Name(); + else + aName = mySelectedLink->getInputPort()->getPort()->Name(); + + if (aName != "Default") { + deleteLink(mySelectedLink); + mySelectedLink = 0; + repaintContents(); + } +} + + +void SUPERVGUI_Graph::deleteLink(SUPERVGUI_Link* theLink) { + theLink->destroyEngine(); + myLinksList.removeRef(theLink); + if (myLinksList.count() == 0) clearView(); +} + + +void SUPERVGUI_Graph::setAsFromStudy(bool theToStudy) { + SUPERVGUI_View::setAsFromStudy(theToStudy); + if (theToStudy) return; + + SUPERVGUI_PortOut* aPortOut; + QObjectList* aPortsList = queryList("SUPERVGUI_PortOut"); + QObjectListIt aPortIt(*aPortsList); + while ((aPortOut=(SUPERVGUI_PortOut*)aPortIt.current()) != 0) { + ++aPortIt; + if (aPortOut->isInStudy()) { + aPortOut->setStudyState(false); + aPortOut->sync(); + } + } + delete aPortsList; +} + + +/** + * Begins Link sketching + */ +void SUPERVGUI_Graph::sketchBegin(SUPERVGUI_Port* thePort) { + if (thePort == 0) return; + + SUPERV_Port aPort = thePort->getPort(); + myNewLink = new SUPERVGUI_Link(this); + mySketchPopup->setItemEnabled(myDelPntItem, false); + mySketchPopup->setItemChecked(myOrtoItem, myNewLink->isOrthoMode()); + + myNewLink->setBeginPort(thePort); + + if (aPort->IsInput()) { + if (aPort->Kind() == SUPERV::EndSwitchParameter + || + aPort->Node()->Kind() == SUPERV::EndSwitchNode) { + myNewLink->setInputPortES(dynamic_cast(thePort)); + } + else + myNewLink->setInputPort(dynamic_cast(thePort)); + } + else + myNewLink->setOutputPort(dynamic_cast(thePort)); +} + + +void SUPERVGUI_Graph::sketchEnd(SUPERVGUI_Port* thePort) { + if (!myNewLink) return; + + bool aIsInput = myNewLink->getBeginPort()->getPort()->IsInput(); + if (aIsInput && thePort->getPort()->IsInput() + || + !aIsInput && !thePort->getPort()->IsInput()) { + return; + } + + + SUPERV_Port aPort = thePort->getPort(); + if (aPort->IsInput()) { + + int aKind = myNewLink->getOutputPort()->getPort()->Kind(); + + if ((aPort->Kind() == SUPERV::EndSwitchParameter + || + aPort->Node()->Kind() == SUPERV::EndSwitchNode) + && + (aKind == SUPERV::InLineParameter || aKind == SUPERV::ServiceParameter)) + { + QString aName(aPort->Name()); + if (aName != "Default") + myNewLink->setInputPortES(dynamic_cast(thePort)); + } + else{ + if (aPort->IsLinked()) return; + + if (aKind == SUPERV::GateParameter || aPort->Kind() == SUPERV::GateParameter) { + if (aKind != aPort->Kind() && aKind != SUPERV::InLineParameter + && aPort->Kind() != SUPERV::InLineParameter) { + return; + } + else { //connection like Gate <--> Gate + myNewLink->setInputPort(dynamic_cast(thePort)); + } + } else { + myNewLink->setInputPort(dynamic_cast(thePort)); + } + } + + } else { + if (myNewLink->isESInputPort()) { + if(aPort->Kind() == SUPERV::InLineParameter || aPort->Kind() == SUPERV::ServiceParameter) + { + myNewLink->setOutputPort(dynamic_cast(thePort)); + } + else + return; + } + else { + int aKind = myNewLink->getInputPort()->getPort()->Kind(); + + if (aKind == SUPERV::GateParameter || aPort->Kind() == SUPERV::GateParameter) { + if (aKind != aPort->Kind() && aKind != SUPERV::InLineParameter + && aPort->Kind() != SUPERV::InLineParameter) { + return; + } + else //connection like Gate <--> Gate + myNewLink->setOutputPort(dynamic_cast(thePort)); + } else + myNewLink->setOutputPort(dynamic_cast(thePort)); + } + } + + if (myNewLink->isCreationComplete()) { // if everything is defined + if (myNewLink->createEngine()) { + myLinksList.append(myNewLink); + myNewLink = 0; + } else { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_LINK")); + delete myNewLink; + } + } +} + + +/** + * Returns true if presentation of link exists + */ +bool SUPERVGUI_Graph::isLinkPrsExists(SUPERV_Link theLink) { + SUPERVGUI_Link* aTmpLink; + for (aTmpLink = myLinksList.first(); aTmpLink; aTmpLink = myLinksList.next()) { + SUPERVGUI_PortOut* aOutPort = aTmpLink->getOutputPort(); + if (strcmp(aOutPort->getPort()->Node()->Name(), + theLink->OutPort()->Node()->Name()) == 0) { + QString aName(theLink->OutPort()->Name()); + aName += "Output"; + if (aOutPort->name() == aName) { + return true; + } + } + } + return false; +} + + +/** + * Creates link presentation from link engine + * Returns false if fails + */ +bool SUPERVGUI_Graph::createLinkPrs(SUPERV_Link theLink) { + SUPERVGUI_Link* aNewLink = new SUPERVGUI_Link(this, theLink); + + // Find output node + SUPERVGUI_Node* aOutNode = (SUPERVGUI_Node*) + child(theLink->OutPort()->Node()->Name(), "SUPERVGUI_Node"); + if (aOutNode) { + QString aName(theLink->OutPort()->Name()); + aName += "Output"; + SUPERVGUI_PortOut* aOutPort = (SUPERVGUI_PortOut*) + aOutNode->child(aName, "SUPERVGUI_PortOut"); + if (aOutPort) + aNewLink->setOutputPort(aOutPort); + else { + delete aNewLink; + return false; + } + } else { + delete aNewLink; + return false; + } + // Find input node + SUPERVGUI_Node* aInNode = (SUPERVGUI_Node*) + child(theLink->InPort()->Node()->Name(), "SUPERVGUI_Node"); + if (aInNode) { + QString aName(theLink->InPort()->Name()); + aName += "Input"; + if (theLink->InPort()->Kind() == SUPERV::EndSwitchParameter) { + //If input port is EndSwitchParameter + SUPERVGUI_PortInESNode* aInPortES =(SUPERVGUI_PortInESNode*) + aInNode->child(aName, "SUPERVGUI_PortInESNode"); //returns null + if (aInPortES) + aNewLink->setInputPortES(aInPortES); + else { + delete aNewLink; + return false; + } + } else { + SUPERVGUI_PortIn* aInPort =(SUPERVGUI_PortIn*) + aInNode->child(aName, "SUPERVGUI_PortIn"); + if (aInPort) + aNewLink->setInputPort(aInPort); + else { + delete aNewLink; + return false; + } + } + } else { + delete aNewLink; + return false; + } + aNewLink->setVisible(!myIsControlView); + myLinksList.append(aNewLink); + return true; +} + + +void SUPERVGUI_Graph::delLastPnt() { + if (myNewLink) { + myNewLink->delLastTmpPoint(); + } +} + +void SUPERVGUI_Graph::delCreatingLink() { + myNewLink->abortCreation(); + delete myNewLink; + myNewLink=0; + repaintContents(); +} + +void SUPERVGUI_Graph::setOrtho() { + if (myNewLink) { + bool aIsOrtho = !mySketchPopup->isItemChecked(myOrtoItem); + myNewLink->setOrthoMode(aIsOrtho); + mySketchPopup->setItemChecked(myOrtoItem, aIsOrtho); + } +} + + + +void SUPERVGUI_Graph::setFullView() { + QObjectList* aNodeList = queryList("SUPERVGUI_Node"); + QObjectListIt aIt(*aNodeList); + SUPERVGUI_Node* aNode; + while ((aNode=(SUPERVGUI_Node*)aIt.current()) != 0) { + ++aIt; + aNode->showAll(); + } + delete aNodeList; + + myCtrlLinks.clear(); + SUPERVGUI_Link* aLink; + for (aLink = myLinksList.first(); aLink; aLink = myLinksList.next()) { + aLink->setVisible(true); + } + draw(); + myIsControlView = false; +} + + +void SUPERVGUI_Graph::setControlView() { + QObjectList* aNodeList = queryList("SUPERVGUI_Node"); + QObjectListIt aIt(*aNodeList); + SUPERVGUI_Node* aNode; + while ((aNode=(SUPERVGUI_Node*)aIt.current()) != 0) { + ++aIt; + aNode->hideAll(); + } + delete aNodeList; + myCtrlLinks.clear(); + SUPERVGUI_Link* aLink; + for (aLink = myLinksList.first(); aLink; aLink = myLinksList.next()) { + aLink->setVisible(false); + + QString aOutName(aLink->getEngineLink()->OutPort()->Node()->Name()); + QString aInName(aLink->getEngineLink()->InPort()->Node()->Name()); + QString aKey = aOutName + aInName; + + if (!myCtrlLinks.contains(aKey)) { + SUPERVGUI_GraphNode* aOutNode = (SUPERVGUI_GraphNode*) + child(aOutName, "SUPERVGUI_GraphNode"); + if (!aOutNode) continue; + SUPERVGUI_GraphNode* aInNode = (SUPERVGUI_GraphNode*) + child(aInName, "SUPERVGUI_GraphNode"); + if (!aInNode) continue; + + myCtrlLinks[aKey] = SUPERVGUI_CtrlLink(this, aOutNode, aInNode); + } + } + draw(); + myIsControlView = true; +} + + +void SUPERVGUI_Graph::deleteNode(SUPERVGUI_Node* theNode) { + theNode->close(true); + draw(); +} + diff --git a/src/SUPERVGUI/SUPERVGUI_Graph.h b/src/SUPERVGUI/SUPERVGUI_Graph.h new file mode 100644 index 0000000..4edd8b5 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Graph.h @@ -0,0 +1,97 @@ +// File : SUPERVGUI_Graph.h +// Created : 17 / 10 / 2001 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGUI +// Copyright : CEA + +#ifndef SUPERVGUI_Graph_H +#define SUPERVGUI_Graph_H + +using namespace std; +//#include "SUPERVGUI.h" +#include "SUPERVGUI_View.h" +#include "SUPERVGUI_Node.h" +#include "SUPERVGUI_Link.h" +#include "SUPERVGUI_CtrlLink.h" +#include + + +class SUPERVGUI_Main; + +class SUPERVGUI_Graph: public SUPERVGUI_View { + Q_OBJECT + + public: + SUPERVGUI_Graph(SUPERVGUI_Main* m); + virtual ~SUPERVGUI_Graph(); + + void sync(); + void contentsMousePressEvent(QMouseEvent* e); + void contentsMouseReleaseEvent(QMouseEvent* e); + void contentsMouseMoveEvent(QMouseEvent* e); + + + virtual void setAsFromStudy(bool theToStudy); + + bool isLinkPrsExists(SUPERV_Link theLink); + bool createLinkPrs(SUPERV_Link theLink); + void removeLinks() + { myLinksList.clear(); }; + + void setFullView(); + void setControlView(); + bool isControlView() { return myIsControlView; } + + void deleteLink(SUPERVGUI_Link* theLink); + + void deleteNode(SUPERVGUI_Node* theNode); + + void draw(); + void clearView(); + +signals: + void mouseMoved(QMouseEvent* theEvent); + void mousePressed(QMouseEvent* theEvent); + void mouseReleased(QMouseEvent* theEvent); + +public slots: + void sketchBegin(SUPERVGUI_Port* thePort); + void sketchEnd(SUPERVGUI_Port* thePort); + + +private slots: + void addPoint(); + void deleteLink(); + void deletePoint(); + void delLastPnt(); + void delCreatingLink(); + void setOrtho(); + + protected: + bool eventFilter(QObject* object, QEvent* event); + + private: + + QPoint myMousePos; + SUPERVGUI_Link* mySelectedLink; + int mySelectedPoint; + + // Popup menu for link creation management + QPopupMenu* mySketchPopup; + int myDelPntItem; + int myOrtoItem; + + // Popup menu for link + QPopupMenu* myLinkPopup; + int myDelLinkPntItem; + int myAddLinkPntItem; + int myDelLinkItem; + + bool myIsControlView; + SUPERVGUI_Link* myNewLink; + QPtrList myLinksList; + QMap myCtrlLinks; +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_GraphNode.cxx b/src/SUPERVGUI/SUPERVGUI_GraphNode.cxx new file mode 100644 index 0000000..ad63444 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_GraphNode.cxx @@ -0,0 +1,419 @@ +using namespace std; +// File : SUPERVGUI_ComputeNode.cxx +// Created : 09 / 01 / 2003 +// Author : Vitaly SMETANNIKOV +// Project : SALOME +// Module : SUPERVGUI +// Copyright : Open CASCADE + +#include "SUPERVGUI_GraphNode.h" +#include "SUPERVGUI_Graph.h" +#include "SUPERVGUI_Main.h" + + +SUPERVGUI_GraphNode::SUPERVGUI_GraphNode(QWidget* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode) + :SUPERVGUI_Node(theParent, theMain, theNode), + MouseX(MouseNo), + MouseY(MouseNo) +{ + //disconnect(myTitle, 0, this, 0); + myTitle = new SUPERVGUI_Label(this, LABEL_WIDTH, LABEL_HEIGHT, name(), QLabel::AlignLeft); + myTitle->hide(); + connect(myTitle, SIGNAL(MousePress(QMouseEvent*)), this, SLOT(mouseTitlePress(QMouseEvent*))); + connect(myTitle, SIGNAL(MouseMove (QMouseEvent*)), this, SLOT(mouseTitleMove(QMouseEvent*))); + connect(myTitle, SIGNAL(MouseRelease(QMouseEvent*)), this, SLOT(mouseTitleRelease(QMouseEvent*))); + + myPortsBox = new QFrame(0); + myPortLayout = new QGridLayout(myPortsBox, 0, 2, 0, 1); + + myTimer = new QTimer(this); + connect(myTimer, SIGNAL(timeout()), this, SLOT(movingNode(/*QMouseEvent* e*/))); + myStopFlag = true; + + myX = -1; + myY = -1; + myDifX = 0; + myDifY = 0; + myFirstDifX = 0; + myFirstDifY = 0; + + myPIcount = 0; + myPOcount = 0; + SUPERV_Ports ports = myNode->Ports(); + int n = ports->length(); + + for (int i=0; iIsInput()) { + myPortLayout->addWidget(new SUPERVGUI_PortIn(myPortsBox, myMain, ports[i]), + myPIcount, 0); + myPIcount++; + } else { + myPortLayout->addWidget(new SUPERVGUI_PortOut(myPortsBox, myMain, ports[i]), + myPOcount, 1, Qt::AlignRight); + myPOcount++; + } + } +} + + + +SUPERVGUI_GraphNode::~SUPERVGUI_GraphNode() { +} + +void SUPERVGUI_GraphNode::mouseTitlePress(QMouseEvent* e) { + if (e->button() == RightButton) { + MouseLeft = 0; + showPopup(e); + } else { + MouseLeft = 1; + SUPERVGUI_Graph* sv = myMain->getGraph(); + MouseX = sv->childX(this) - e->globalX(); + MouseY = sv->childY(this) - e->globalY(); + } +} + +void SUPERVGUI_GraphNode::mouseTitleMove(QMouseEvent* e) { + Trace("SUPERVGUI_Node::moveAgain") + SUPERVGUI_Graph* sv = myMain->getGraph(); + + if ((MouseX == MouseNo) && (MouseY == MouseNo)) { + MouseX = sv->childX(this) - e->globalX(); + MouseY = sv->childY(this) - e->globalY(); + MouseLeft = (e->state() == RightButton? 0: 1); + }; + + if (MouseLeft == 1) { + + int x = e->globalX()+MouseX; + int y = e->globalY()+MouseY; + x = x<0? 0: x; + y = y<0? 0: y; + + if (x > myMain->getGraph()->horizontalScrollBar()->value() + + myMain->getGraph()->viewport()->width() - width()/2 + || + y > myMain->getGraph()->verticalScrollBar()->value() + + myMain->getGraph()->viewport()->height() - height()/2 + || + x < myMain->getGraph()->horizontalScrollBar()->value() + || + y < myMain->getGraph()->verticalScrollBar()->value()){ + if (!myTimer->isActive()) { + myX = x; + myY = y; + myDifX = x - myNode->X(); + myDifY = y - myNode->Y(); + myFirstDifX = myDifX; + myFirstDifY = myDifY; + } + + StartTimer(); + myStopFlag = false; + + if (x - myNode->X() > 15 && abs(myDifX) < abs(myDifY)) { + if (x > myMain->getGraph()->horizontalScrollBar()->value() + + myMain->getGraph()->viewport()->width() - width()/2) + myDifX = 5; // or another positive number + else { + //not out of the right boundary + sv->moveChild(this, x, myNode->Y()); //new X and old Y + myNode->Coords(x, myNode->Y()); + myX = x; + } + } + + if (x - myNode->X() < -15 && abs(myDifX) < abs(myDifY)) { + if(x < myMain->getGraph()->horizontalScrollBar()->value()) + myDifX = -5; //or another negative number + else { + //not out of the left boundary + sv->moveChild(this, x, myNode->Y()); //new X and old Y + myNode->Coords(x, myNode->Y()); + myX = x; + } + } + + if (y - myNode->Y() > 15 && abs(myDifX) > abs(myDifY)) { + if (y > myMain->getGraph()->verticalScrollBar()->value() + + myMain->getGraph()->viewport()->height() - height()/2) + myDifY = 5; //or another positive number + else { + //not out of the lower boundary + sv->moveChild(this, myNode->X(), y); //old X and new Y + myNode->Coords(myNode->X(), y); + myY = y; + } + } + + if (y - myNode->Y() < -15 && abs(myDifX) > abs(myDifY)) { + if (y < myMain->getGraph()->verticalScrollBar()->value()) + myDifY = -5; //or another negative number + else { + //not out of the upper boundary + sv->moveChild(this, myNode->X(), y); //old X and new Y + myNode->Coords(myNode->X(), y); + myY = y; + } + } + + } + else { + if ((myDifX*(x - myNode->X()) < 0 || myDifY*(y - myNode->Y()) < 0)) { + StopTimer(); + myStopFlag = true; + } + //for mouse moving to boundaries from outside space (chack then node must be move) + int xp1, yp1, xp2, yp2; + xp1 = myMain->getGraph()->horizontalScrollBar()->value(); + xp2 = myMain->getGraph()->horizontalScrollBar()->value() + + myMain->getGraph()->viewport()->width(); + yp1 = myMain->getGraph()->verticalScrollBar()->value(); + yp2 = myMain->getGraph()->verticalScrollBar()->value() + + myMain->getGraph()->viewport()->height(); + if (x >= xp1 + && x <= xp1+myMain->getGraph()->viewport()->visibleRect().width() + && y >= yp1 + && y <= yp1+myMain->getGraph()->viewport()->visibleRect().height()) { + sv->moveChild(this, x, y); + myNode->Coords(x, y); + } + + } + } +} + +void SUPERVGUI_GraphNode::mouseTitleRelease(QMouseEvent* e) { + StopTimer(); + myStopFlag = true; +} + +void SUPERVGUI_GraphNode::movingNode() { + SUPERVGUI_Graph* sv = myMain->getGraph(); + + myX = myX<0 ? 0: myX; + myY = myY<0 ? 0: myY; + + if (myDifX > 0) + myX = myX + 5; + if (myDifX < 0) + myX = myX - 5; + if (myDifY > 0) + myY = myY + 5; + if (myDifY < 0) + myY = myY - 5; + + myMain->getGraph()->ResizeGraph(this, myX, myY); + myMain->getGraph()->scrollBy( myX - myNode->X(), myY - myNode->Y() ); + sv->moveChild(this, myX, myY); + myNode->Coords(myX, myY); +} + +void SUPERVGUI_GraphNode::StartTimer() { + Trace("SUPERVGUI_Main::StartTimer") + if (!myTimer->isActive()) { + myTimer->start(170); + }; +} + +void SUPERVGUI_GraphNode::StopTimer() { + Trace("SUPERVGUI_Main::StopTimer") + if (myTimer->isActive()) { + myTimer->stop(); + }; +} + +void SUPERVGUI_GraphNode::deleteLinks() { + QObjectList* aList = queryList("SUPERVGUI_Port"); + SUPERVGUI_Port* aPort; + QObjectListIt aIt(*aList); + while ((aPort=(SUPERVGUI_Port*)aIt.current()) != 0) { + ++aIt; + aPort->deleteLinks(); + } + delete aList; +} + + +void SUPERVGUI_GraphNode::sync() { + SUPERVGUI_Node::sync(); + + SUPERVGUI_Port* pi; + QObjectList* ihmList = queryList("SUPERVGUI_Port"); + QObjectListIt i(*ihmList); + while ((pi=(SUPERVGUI_Port*)i.current()) != 0) { + ++i; + pi->sync(); + } + delete ihmList; +} + + +/** + * Creates presentation of links to In ports + * If toCheckExisting = false the links will be created without checking + * of their existing in Graph + * If toCheckExisting = true the existing of links will be checked before creation + */ +void SUPERVGUI_GraphNode::updateLinksPrs(bool toCheckExisting) { + SUPERVGUI_Graph* aGraph= myMain->getGraph(); + SUPERVGUI_PortIn* pi; + QObjectList* ihmList = queryList("SUPERVGUI_PortIn"); + QObjectListIt i(*ihmList); + while ((pi=(SUPERVGUI_PortIn*)i.current()) != 0) { + ++i; + if (pi->getPort()->IsLinked()) { + SUPERV_Link aLink = pi->getPort()->Link(); + if (toCheckExisting) { + if (aGraph->isLinkPrsExists(aLink)) + continue; + } + aGraph->createLinkPrs(aLink); + } + } + delete ihmList; + + //Find PortInESNode + SUPERVGUI_PortInESNode* piES; + QObjectList* ihmListES = queryList("SUPERVGUI_PortInESNode"); + QObjectListIt iES(*ihmListES); + while ((piES=(SUPERVGUI_PortInESNode*)iES.current()) != 0) { + ++iES; + if (piES->getPort()->IsLinked()) { + SUPERV_Links aLinks = piES->getPort()->Links(); + for (int j=0; jlength(); j++) { + if (toCheckExisting) { + if (aGraph->isLinkPrsExists(aLinks[j])) + continue; + } + aGraph->createLinkPrs(aLinks[j]); + } + } + } + delete ihmListES; +} + + +void SUPERVGUI_GraphNode::setNodeName(QString theName) { + SUPERVGUI_Node::setNodeName(theName); + myTitle->setText(name()); +} + + +void SUPERVGUI_GraphNode::deletePort(SUPERVGUI_Port* thePort) { + if (thePort->isA("SUPERVGUI_PortIn") || thePort->isA("SUPERVGUI_PortInESNode")) { + myPIcount--; + } + else { + myPOcount--; + } + thePort->deleteLinks(); + + thePort->getPort()->destroy(); + thePort->close(true); + updatePorts(); + updateShape(); +} + + +void SUPERVGUI_GraphNode::addInputPort() { + SUPERV_Port aPort = createInPort(); + if (aPort == NULL) return; + + if (getNodeType() == SUPERV::EndSwitchNode) { + SUPERVGUI_PortInESNode* aPortPrs = new SUPERVGUI_PortInESNode(myPortsBox, myMain, aPort); + myPortLayout->addWidget(aPortPrs, myPIcount, 0); + + if (myPortsBox->isVisible()) { + aPortPrs->show(); + } + } + else { + SUPERVGUI_PortIn* aPortPrs = new SUPERVGUI_PortIn(myPortsBox, myMain, aPort); + myPortLayout->addWidget(aPortPrs, myPIcount, 0); + + if (myPortsBox->isVisible()) { + aPortPrs->show(); + } + } + + myPIcount++; + updatePorts(); + updateShape(); +} + + +void SUPERVGUI_GraphNode::addOutputPort() { + SUPERV_Port aPort = createOutPort(); + if (aPort == NULL) return; + + SUPERVGUI_PortOut* aPortPrs = new SUPERVGUI_PortOut(myPortsBox, myMain, aPort); + myPortLayout->addWidget(aPortPrs, myPOcount, 1, Qt::AlignRight); + myPOcount++; + if (myPortsBox->isVisible()) { + aPortPrs->show(); + } + updatePorts(); + updateShape(); +} + + +void SUPERVGUI_GraphNode::updatePorts() { + bool isAdded = false; + SUPERV_Ports aPorts = getEngine()->Ports(); + int n = aPorts->length(); + SUPERVGUI_Port* aPortPrs; + bool aIsVisible = myPortsBox->isVisible(); + for (int i=0; i < n; i++) { + QString aName(aPorts[i]->Name()); + aName += (aPorts[i]->IsInput())? "Input":"Output"; + aPortPrs = (SUPERVGUI_Port*) child(aName, "SUPERVGUI_Port"); + if (aPortPrs == NULL) { + if (aPorts[i]->IsInput()) { + SUPERVGUI_PortIn* aPortIn = new SUPERVGUI_PortIn(myPortsBox, myMain, aPorts[i]); + myPortLayout->addWidget(aPortIn, myPIcount, 0); + if (aIsVisible) aPortIn->show(); + myPIcount++; + isAdded = true; + } else { + SUPERVGUI_PortOut* aPortOut = new SUPERVGUI_PortOut(myPortsBox, myMain, aPorts[i]); + myPortLayout->addWidget(aPortOut, myPOcount, 1, Qt::AlignRight); + if (aIsVisible) aPortOut->show(); + myPOcount++; + isAdded = true; + } + } + } + + QObjectList* aShownPortsList = queryList("SUPERVGUI_Port"); + QObjectListIt aLI(*aShownPortsList); + SUPERVGUI_Port* aVisPort; + + while ((aVisPort=(SUPERVGUI_Port*)aLI.current()) != 0) { + ++aLI; + QString aNameVisible(aVisPort->getPort()->Name()); + + bool aIsExists = false; + for (int i=0; i < n; i++) { + QString aName(aPorts[i]->Name()); + if (aName == aNameVisible) + aIsExists = true; + } + + if (!aIsExists) { //we have a visible object, which has no engine entity + aVisPort->close(true); + } + } +} + + +/** + * Returns coordinates of connection point in content coordinates + */ +QPoint SUPERVGUI_GraphNode::getInConnectPnt() { + return QPoint(pos().x(), + pos().y() + (height()/2)); +} +QPoint SUPERVGUI_GraphNode::getOutConnectPnt() { + return QPoint(pos().x() + width(), + pos().y() + (height()/2)); +} diff --git a/src/SUPERVGUI/SUPERVGUI_GraphNode.h b/src/SUPERVGUI/SUPERVGUI_GraphNode.h new file mode 100644 index 0000000..1b90258 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_GraphNode.h @@ -0,0 +1,81 @@ +// File : SUPERVGUI_GraphNode.h +// Created : 10 / 01 / 2003 +// Author : Vitaly SMETANNIKOV +// Project : SALOME +// Module : SUPERVGUI +// Copyright : Open CASCADE + + +#ifndef SUPERVGUI_GraphNode_H +#define SUPERVGUI_GraphNode_H + +#include "SUPERVGUI_Node.h" +#include + + +class SUPERVGUI_GraphNode: public SUPERVGUI_Node { + Q_OBJECT + + public: + SUPERVGUI_GraphNode(QWidget* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode); + virtual ~SUPERVGUI_GraphNode(); + + virtual void hideAll() {}; + virtual void showAll() {}; + + virtual void deleteLinks(); + virtual void sync(); + + virtual void updateLinksPrs(bool toCheckExisting = false); + virtual void setNodeName(QString aName); + + virtual void deletePort(SUPERVGUI_Port* thePort); + + virtual QPoint getInConnectPnt(); + virtual QPoint getOutConnectPnt(); + + virtual void updateShape() {}; + virtual void updatePorts(); + + int& getPIcount() + { return myPIcount;} + + int& getPOcount() + { return myPOcount;} + + public slots: + void mouseTitlePress(QMouseEvent* e); + void mouseTitleMove(QMouseEvent* e); + void mouseTitleRelease(QMouseEvent* e); + void movingNode(); + virtual void addInputPort(); + virtual void addOutputPort(); + +// virtual void addInputPortES(); +// virtual void addOutputPortES(); + + protected: + SUPERVGUI_Label* myTitle; + + QFrame* myPortsBox; + QGridLayout* myPortLayout; + QTimer* myTimer; + int myPIcount; + int myPOcount; + + private: + void StartTimer(); + void StopTimer(); + int MouseX; + int MouseY; + int MouseLeft; + int myX; + int myY; + int myDifX; + int myDifY; + int myFirstDifX; + int myFirstDifY; + bool myStopFlag; + +}; +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_Information.cxx b/src/SUPERVGUI/SUPERVGUI_Information.cxx new file mode 100644 index 0000000..7909d7c --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Information.cxx @@ -0,0 +1,240 @@ +using namespace std; +// File : SUPERVGUI_Information.cxx +// Created : 22 / 01 / 2002 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGUI +// Copyright : CEA + +#include "SUPERVGUI_Information.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" +#include +#include +#include +#include + + +/*! + Constructor +*/ +SUPERVGUI_Information::SUPERVGUI_Information(SUPERV_CNode node, bool isReadOnly) + : QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + Trace("SUPERVGUI_Information::SUPERVGUI_Information"); + setCaption( tr( "TLT_INFORMATIONS" ) ); + setSizeGripEnabled( true ); + myNode = node; + + QGridLayout* TopLayout = new QGridLayout( this ); + TopLayout->setSpacing( 6 ); + TopLayout->setMargin( 11 ); + + QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" ); + TopGroup->setColumnLayout(0, Qt::Vertical ); + TopGroup->layout()->setSpacing( 0 ); + TopGroup->layout()->setMargin( 0 ); + QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() ); + TopGroupLayout->setAlignment( Qt::AlignTop ); + TopGroupLayout->setSpacing( 6 ); + TopGroupLayout->setMargin( 11 ); + + QLabel* nameL = new QLabel( tr( "NAME_LBL" ), TopGroup ); + nameV = new QLineEdit( TopGroup ); + nameV->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + nameV->setMinimumSize( 200, 0 ); + nameV->setReadOnly( isReadOnly ); + nameV->setText( node->Name() ); + + QLabel* authL = new QLabel( tr( "AUTHOR_LBL" ), TopGroup); + authV = new QLineEdit( TopGroup ); + authV->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + authV->setMinimumSize( 200, 0 ); + authV->setReadOnly( isReadOnly ); + authV->setText( node->Author() ); + + + if (node->IsFactory()) { + contL = new QLabel( tr( "CONTAINER_LBL" ), TopGroup ); + contV = new QLineEdit( TopGroup ); + contV->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + contV->setMinimumSize( 200, 0 ); + } + QLabel* cdatL = new QLabel( tr( "DATE_CREATION_LBL" ), TopGroup ); + cdatV = new QLabel( TopGroup ); + cdatV->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + cdatV->setMinimumSize( 200, 0 ); + cdatV->setText( date( node->CreationDate() ) ); + + QLabel* udatL = new QLabel( tr( "DATE_MODIFICATION_LBL" ), TopGroup ); + udatV = new QLabel( TopGroup ); + udatV->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + udatV->setMinimumSize( 200, 0 ); + udatV->setText( date( node->LastUpdateDate() ) ); + + QLabel* commL = new QLabel( tr( "COMMENT_LBL" ), TopGroup); + commV = new QMultiLineEdit( TopGroup ); + commV->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + commV->setMinimumSize( 200, 100 ); + commV->setReadOnly( isReadOnly ); + commV->setText( node->Comment() ); + + TopGroupLayout->addWidget( nameL, 0, 0 ); + TopGroupLayout->addWidget( nameV, 0, 1 ); + TopGroupLayout->addWidget( authL, 1, 0 ); + TopGroupLayout->addWidget( authV, 1, 1 ); + if (node->IsFactory()) { + TopGroupLayout->addWidget( contL, 2, 0 ); + TopGroupLayout->addWidget( contV, 2, 1 ); + } + TopGroupLayout->addWidget( cdatL, 3, 0 ); + TopGroupLayout->addWidget( cdatV, 3, 1 ); + TopGroupLayout->addWidget( udatL, 4, 0 ); + TopGroupLayout->addWidget( udatV, 4, 1 ); + TopGroupLayout->addWidget( commL, 5, 0 ); + TopGroupLayout->addMultiCellWidget( commV, 5, 6, 1, 1 ); + TopGroupLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::Expanding ), 6, 0 ); + TopGroupLayout->setColStretch( 1, 5 ); + + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons ); + QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons ); + + GroupButtonsLayout->addWidget( okB, 0, 0 ); + GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + GroupButtonsLayout->addWidget( cancelB, 0, 2 ); + + TopLayout->addWidget( TopGroup, 0, 0 ); + TopLayout->addWidget( GroupButtons, 1, 0 ); + + connect( okB, SIGNAL( clicked() ), this, SLOT( okButton() ) ); + connect( cancelB, SIGNAL( clicked() ), this, SLOT( koButton() ) ); +} + +/*! + Destructor +*/ +SUPERVGUI_Information::~SUPERVGUI_Information() { + Trace("SUPERVGUI_Information::~SUPERVGUI_Information"); +} + +/*! + Executes dialog +*/ +/* +bool SUPERVGUI_Information::run( SUPERV_CNode node, bool isReadOnly ) { + Trace("SUPERVGUI_Information::run"); + nameV->setReadOnly( isReadOnly ); + authV->setReadOnly( isReadOnly ); + commV->setReadOnly( isReadOnly ); + + nameV->setText( node->Name() ); + authV->setText( node->Author() ); + commV->setText( node->Comment() ); + if (node->IsFactory()) { + SUPERV_FNode aFNode = SUPERV::FNode::_narrow(node); + contV->setText( aFNode->GetContainer()); + contL->show(); + contV->show(); + } + else { + contL->hide(); + contV->hide(); + } + qApp->processEvents(); + adjustSize(); + + //commV->setText( node->Comment() ); + cdatV->setText( date( node->CreationDate() ) ); + udatV->setText( date( node->LastUpdateDate() ) ); + + bool b1 = true; + bool b2 = true; + bool b3 = true; + bool b4 = true; + bool result = false; + if ( exec() == Accepted ) { + if (! isReadOnly ) { + //b3 = node->SetContainer( contV->text().latin1() ); + //} + //else { + if ( strcmp( node->Name(), nameV->text().latin1() ) != 0 ) { + b1 = node->SetName( nameV->text().latin1() ); + } + b2 = node->SetAuthor ( authV->text().latin1() ); + if (node->IsFactory()) { + SUPERV_FNode aFNode = SUPERV::FNode::_narrow(node); + b3 = aFNode->SetContainer( contV->text().latin1() ); + } + b4 = node->SetComment ( commV->text().latin1() ); + } + result = b1 && b2 && b3 && b4; + if ( !result ) { + QAD_MessageBox::warn1( this, tr( "ERROR" ), tr( "MSG_CANT_CHANGE_INFO" ), tr( "BUT_OK" ) ); + } + } + return result; + }*/ + +/*! + Returns string representation of date +*/ +QString SUPERVGUI_Information::date( SUPERV_Date d ) { + Trace("SUPERVGUI_Information::date"); + QString dt( "" ); + + if ( d.Day != 0 ) { + dt += ( char )( d.Day / 10 + 48 ); + dt += ( char )( d.Day % 10 + 48 ); + dt += '/'; + dt += ( char )( d.Month / 10 + 48 ); + dt += ( char )( d.Month % 10 + 48 ); + dt += '/'; + dt += ( char )( ( d.Year / 1000 ) %10 + 48 ); + dt += ( char )( ( d.Year / 100 ) % 10 + 48 ); + dt += ( char )( ( d.Year / 10 ) % 10 + 48 ); + dt += ( char )( d.Year %10 + 48 ); + dt += ' '; + dt += ( char )( d.Hour / 10 + 48 ); + dt += ( char )( d.Hour % 10 + 48 ); + dt += ':'; + dt += ( char )( d.Minute / 10 + 48 ); + dt += ( char )( d.Minute % 10 + 48 ); + dt += ':'; + dt += ( char )( d.Second / 10 + 48 ); + dt += ( char )( d.Second % 10 + 48 ); + }; + return( dt ); +} + +/*! + button slot +*/ +void SUPERVGUI_Information::okButton() { + Trace("SUPERVGUI_Information::okButton"); + myNode->SetName( nameV->text().latin1()); + myNode->SetAuthor( authV->text().latin1() ); + if (myNode->IsFactory()) { + SUPERV_FNode aFNode = SUPERV::FNode::_narrow(myNode); + aFNode->SetContainer( contV->text().latin1() ); + } + myNode->SetComment( commV->text().latin1() ); + accept(); +} + +/*! + button slot +*/ +void SUPERVGUI_Information::koButton() { + Trace("SUPERVGUI_Information::koButton"); + reject(); +} diff --git a/src/SUPERVGUI/SUPERVGUI_Information.h b/src/SUPERVGUI/SUPERVGUI_Information.h new file mode 100644 index 0000000..dfd9c72 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Information.h @@ -0,0 +1,40 @@ +// File : SUPERVGUI_Information.h +// Created : 22 / 01 / 2002 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGUI +// Copyright : CEA + +using namespace std; +#ifndef SUPERVGUI_Information_H +#define SUPERVGUI_Information_H + +#include "SUPERVGUI_Def.h" + +class SUPERVGUI_Information: public QDialog { + Q_OBJECT + + public: + SUPERVGUI_Information(SUPERV_CNode node, bool isReadOnly); + virtual ~SUPERVGUI_Information(); + + //bool run(SUPERV_CNode node, bool isReadOnly); + + private slots: + void okButton(); + void koButton(); + + private: + QString date(SUPERV_Date d); + + QLineEdit* nameV; + QLineEdit* authV; + QLineEdit* contV; + QLabel* contL; + QMultiLineEdit* commV; + QLabel* cdatV; + QLabel* udatV; + SUPERV_CNode myNode; +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_Label.cxx b/src/SUPERVGUI/SUPERVGUI_Label.cxx new file mode 100644 index 0000000..5c2e8d1 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Label.cxx @@ -0,0 +1,38 @@ +using namespace std; +// File : SUPERVGUI_Label.cxx +// Created : 24 / 10 / 2001 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGUI +// Copyright : CEA + +#include "SUPERVGUI_Label.h" +#include "SUPERVGUI_Def.h" + +SUPERVGUI_Label::SUPERVGUI_Label(QWidget* parent, int dx, int dy, const char* text, int a) + : QLabel(parent) { + Trace("SUPERVGUI_Label::SUPERVGUI_Label") + setMinimumSize(dx, dy); + setMaximumSize(dx, dy); + setText((QString)text); + setAlignment(a | QLabel::AlignVCenter); +} + +SUPERVGUI_Label::~SUPERVGUI_Label() { + Trace("SUPERVGUI_Label::~SUPERVGUI_Label") +} + +void SUPERVGUI_Label::mousePressEvent(QMouseEvent* e) { + Trace("SUPERVGUI_Label::mousePressEvent") + emit MousePress(e); +} + +void SUPERVGUI_Label::mouseReleaseEvent(QMouseEvent* e) { + Trace("SUPERVGUI_Label::mouseReleaseEvent") + emit MouseRelease(e); +} + +void SUPERVGUI_Label::mouseMoveEvent(QMouseEvent* e) { + Trace("SUPERVGUI_Label::mouseMoveEvent") + emit MouseMove(e); +} diff --git a/src/SUPERVGUI/SUPERVGUI_Label.h b/src/SUPERVGUI/SUPERVGUI_Label.h new file mode 100644 index 0000000..70e6daa --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Label.h @@ -0,0 +1,33 @@ +// File : SUPERVGUI_Label.h +// Created : 24 / 10 / 2001 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGUI +// Copyright : CEA + +//#include "SUPERVGUI.h" + +#ifndef SUPERVGUI_Label_H +#define SUPERVGUI_Label_H + +using namespace std; +#include + +class SUPERVGUI_Label: public QLabel { + Q_OBJECT + + public: + SUPERVGUI_Label(QWidget* parent, int dx, int dy, const char* text, int a); + virtual ~SUPERVGUI_Label(); + + void mousePressEvent(QMouseEvent* e); + void mouseReleaseEvent(QMouseEvent* e); + void mouseMoveEvent(QMouseEvent* e); + + signals: + void MousePress(QMouseEvent* e); + void MouseRelease(QMouseEvent* e); + void MouseMove(QMouseEvent* e); +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_Link.cxx b/src/SUPERVGUI/SUPERVGUI_Link.cxx new file mode 100644 index 0000000..dee8570 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Link.cxx @@ -0,0 +1,799 @@ +using namespace std; +// File : SUPERVGUI_Link.cxx +// Created : 20 / 12 / 2002 +// Author : Vitaly SMETANNIKOV +// Project : SALOME +// Module : SUPERVGUI +// Copyright : Open CASCADE + + + +#include "SUPERVGUI_Graph.h" +#include "SUPERVGUI_Main.h" +#include "SUPERVGUI_Link.h" + + + +#define SKETCH_CLR Qt::green +#define DRAW_CLR Qt::black +#define HLT_CLR Qt::magenta +#define CTRL_CLR Qt::red + +#define LINE_WIDTH 2 +#define PNT_SIZE 6 + + +// Prevents moving of several links at once +bool SUPERVGUI_Link::LinkIsMoving=false; + +bool SUPERVGUI_Link::OrthoMode = false; + +SUPERVGUI_Link* SUPERVGUI_Link::SelectedLink=0; + +/** + * Consructor: + * If link is NULL - this must be defined later + */ +SUPERVGUI_Link::SUPERVGUI_Link(SUPERVGUI_Graph* theGraph, SUPERV_Link theLink) { + myGraph = theGraph; + myEngine = theLink; + myPortIn = 0; + myPortInES = 0; + myPortOut = 0; + myStartPort = 0; + myHltPnt = -1; + myPntMovingState = false; + myPainter = 0; + myIsVisible = true; + myTmpPen.setColor(SKETCH_CLR); + myTmpPen.setWidth(LINE_WIDTH); + myIsSelected = false; + myTmpPoints.clear(); + + if (!SUPERV_isNull(myEngine)) + connectToEvents(); +} + + +//********************************************************************** +SUPERVGUI_Link::~SUPERVGUI_Link() { + if (!SUPERV_isNull(myEngine)) { + disconnect(myGraph, 0, this, 0); + } + if (SelectedLink == this) SelectedLink=0; + emit linkDeleted(this); +} + + +//********************************************************************** +void SUPERVGUI_Link::setInputPort(SUPERVGUI_PortIn* thePortIn) { + myPortIn = thePortIn; + myPortIn->setLinkPrs(this); +} + + +//********************************************************************** +void SUPERVGUI_Link::setInputPortES(SUPERVGUI_PortInESNode* thePortInES) { + myPortInES = thePortInES; + myPortInES->setLinkPrs(this); +} + +//********************************************************************** +bool SUPERVGUI_Link::isESInputPort() { + if (myPortInES) + return true; + else + return false; +} + +//********************************************************************** +void SUPERVGUI_Link::destroyEngine() { + if (!SUPERV_isNull(myEngine)) { + myEngine->destroy(); + } +} + +//********************************************************************** +void SUPERVGUI_Link::setOutputPort(SUPERVGUI_PortOut* thePortOut){ + myPortOut = thePortOut; + myPortOut->addLinkPrs(this); +} + + +//********************************************************************** +void SUPERVGUI_Link::addPoint(long theX, long theY) { + if (SUPERV_isNull(myEngine)) return; + + if (myEngine->CoordsSize() <= 0) { + myEngine->AddCoord(1, theX, theY); + return; + } else { + QPoint aPnt(theX, theY); + long aX, aY; + myEngine->Coords(1, aX, aY); + if (!isESInputPort()) { + if (distance(aPnt, myGraph->viewportToContents(myPortIn->getConnectPnt()), + QPoint(aX, aY)) <= 0) { + myEngine->AddCoord(1, theX, theY); + return; + } + } + else { + if (distance(aPnt, myGraph->viewportToContents(myPortInES->getConnectPnt()), + QPoint(aX, aY)) <= 0) { + myEngine->AddCoord(1, theX, theY); + return; + } + } + + int i = 2; + long aNextX, aNextY; + for (i = 2; i <= myEngine->CoordsSize(); i++) { + myEngine->Coords(i, aNextX, aNextY); + if (distance(aPnt, QPoint(aX, aY), + QPoint(aNextX, aNextY)) <= 0) { + myEngine->AddCoord(i, theX, theY); + return; + } + aX = aNextX; + aY = aNextY; + } + if (distance(aPnt, QPoint(aX, aY), + myGraph->viewportToContents(myPortOut->getConnectPnt())) <= 0) { + myEngine->AddCoord(myEngine->CoordsSize()+1, theX, theY); + return; + } + } + repaint(); +} + + +//********************************************************************** +/** + * Can be used only in Sketching mode + */ +void SUPERVGUI_Link::addTmpPoint(QPoint thePnt) { + if (OrthoMode) { + int aSize = myTmpPoints.size(); + QPoint aPrevPnt; + // Previous point + if (aSize > 0) + aPrevPnt = myTmpPoints[aSize-1]; + else + aPrevPnt = myStartPort->getConnectPnt(); + + // Next point + QPoint aNewPoint; + if (Abs(thePnt.x() - aPrevPnt.x()) > + Abs(thePnt.y() - aPrevPnt.y())) { + aNewPoint = QPoint(thePnt.x(), aPrevPnt.y()); + } else { + aNewPoint = QPoint(aPrevPnt.x(), thePnt.y()); + } + // repaint last line + + myPainter->drawLine(aPrevPnt, thePnt); + myPainter->moveTo(aPrevPnt); + myPainter->lineTo(aNewPoint); + myPainter->lineTo(thePnt); + + myTmpPoints.push_back(aNewPoint); + } else + myTmpPoints.push_back(thePnt); +} + + +//********************************************************************** +/** + * Can be used only in Sketching mode + */ +void SUPERVGUI_Link::delLastTmpPoint() { + int aSize = myTmpPoints.size(); + if (aSize > 0) { + QPoint aRemPnt = myTmpPoints[aSize-1]; + + QPoint aLastPnt; + if (aSize > 1) + aLastPnt = myTmpPoints[aSize-2]; + else + aLastPnt = myStartPort->getConnectPnt(); + + myPainter->moveTo(aLastPnt); + myPainter->lineTo(aRemPnt); + myPainter->lineTo(myPrevPoint); + + myPainter->drawLine(aLastPnt, myPrevPoint); + + myTmpPoints.pop_back(); + } +} + + +//********************************************************************** +void SUPERVGUI_Link::removeLastPoint() { + if (myEngine && (!SUPERV_isNull(myEngine))) + myEngine->RemoveCoord(myEngine->CoordsSize()); +} + + +//********************************************************************** +void SUPERVGUI_Link::removePoint(int thePnt) { + if ((thePnt > -1) && (!SUPERV_isNull(myEngine))) { + paint(true); + myEngine->RemoveCoord(thePnt); + paint(false); + } +} + +//********************************************************************** +/** + * Repaints the link + */ +void SUPERVGUI_Link::repaint() { + paint(true); + paint(false); +} + + +//********************************************************************** +/** + * Paints or erases the link + * if toErase = true then it draws link by background color + */ +void SUPERVGUI_Link::paint(bool toErase) { + if ((!myGraph) || (!myIsVisible)) return; + if (!myEngine && SUPERV_isNull(myEngine)) return; + // if (!isCreationComplete()) return; + + QPainter aPainter(myGraph->viewport()); + QPen aDataPen; + aDataPen.setWidth(LINE_WIDTH); + + if (toErase) { + aDataPen.setColor(myGraph->viewport()->paletteBackgroundColor()); + } else { + if (strcmp(myEngine->InPort()->Name(), "InVoid")==0) + aDataPen.setColor(CTRL_CLR); + else + aDataPen.setColor(DRAW_CLR); + } + aPainter.setPen(aDataPen); + drawLink(&aPainter); +} + + +//********************************************************************** +/** + * Defines a pen and draws link using given painter + */ +void SUPERVGUI_Link::paint(QPainter* thePainter, bool toErase) { + if ((!myGraph) || (!myIsVisible)) return; + if (!myEngine && SUPERV_isNull(myEngine)) return; + // if (!isCreationComplete()) return; + thePainter->save(); + + QPen aDataPen; + aDataPen.setWidth(LINE_WIDTH); + + if (toErase) { + aDataPen.setColor(myGraph->viewport()->paletteBackgroundColor()); + } else { + if (strcmp(myEngine->InPort()->Name(), "InVoid")==0) + aDataPen.setColor(CTRL_CLR); + else + aDataPen.setColor(DRAW_CLR); + } + thePainter->setPen(aDataPen); + drawLink(thePainter); + thePainter->restore(); +} + + +//********************************************************************** +/** + * Draws link using given painter + */ +void SUPERVGUI_Link::drawLink(QPainter* thePainter) { + if (!myIsVisible) return; + if (!isESInputPort()) + thePainter->moveTo(myPortIn->getConnectPnt()); + else + thePainter->moveTo(myPortInES->getConnectPnt()); + long aX, aY; + QPoint aPnt; + for (int i=0; i < myEngine->CoordsSize(); i++) { + myEngine->Coords(i+1, aX, aY); + aPnt = myGraph->contentsToViewport(QPoint(aX, aY)); + thePainter->lineTo(aPnt); + thePainter->drawEllipse(aPnt.x()-PNT_SIZE/2, aPnt.y()-PNT_SIZE/2, + PNT_SIZE, PNT_SIZE); + } + thePainter->lineTo(myPortOut->getConnectPnt()); +} + + +//********************************************************************** +/** + * Repaints whole link when it is sketching + */ +void SUPERVGUI_Link::repaintSketch() { + if (!myStartPort) return; + if (!myPainter) return; + + // myPainter->save(); + //myPainter->setRasterOp(Qt::CopyROP); + myPainter->moveTo(myStartPort->getConnectPnt()); + for (int i = 0; i< myTmpPoints.size(); i++) { + myPainter->lineTo(myGraph->contentsToViewport(myTmpPoints[i])); + } + myPainter->lineTo(myPrevPoint); + //myPainter->restore(); +} + + +//********************************************************************** +/** + * Drawing of non created link following to mouse pointer + */ +void SUPERVGUI_Link::drawTo(QPoint thePnt) { + if (!myStartPort) { + if (myPortIn) + myStartPort = myPortIn; + else if (myPortInES) + myStartPort = myPortInES; + else if (myPortOut) + myStartPort = myPortOut; + else + return; + } + if (!myPainter) { + myPainter = new QPainter(myGraph->viewport()); + myPainter->setPen(myTmpPen); + myPainter->setRasterOp(Qt::XorROP); + myPrevPoint = myStartPort->getConnectPnt(); + LinkIsMoving = true; + } + + long aX, aY; + + QPoint aStartPnt; + if (myTmpPoints.size() > 0) + aStartPnt = myGraph->contentsToViewport(myTmpPoints[myTmpPoints.size()-1]); + else + aStartPnt = myStartPort->getConnectPnt(); + + // erase old line + myPainter->drawLine(aStartPnt, myPrevPoint); + + // draw new line + QPoint aNewPoint = myGraph->contentsToViewport(thePnt); + myPainter->drawLine(aStartPnt, aNewPoint); + myPrevPoint = aNewPoint; + +} + + +//********************************************************************** +/** + * Set link non visible + */ +void SUPERVGUI_Link::setVisible(bool theVisible) { + myIsVisible = theVisible; + if (myIsVisible) { + connectToEvents(); + } else { + disconnect(myGraph, 0, this, 0); + } +} + + +//********************************************************************** +/** + * Checks full definition of the link + */ +bool SUPERVGUI_Link::isCreationComplete() { + bool aIsBoth = myPortIn && myPortOut; + if (myPortIn && myPortOut) { + SUPERV_Port aInPort = myPortIn->getPort(); + QString aInNodeName(aInPort->Node()->Name()); + SUPERV_Port aOutPort = myPortOut->getPort(); + QString aOutNodeName(aOutPort->Node()->Name()); + + return (aInNodeName != aOutNodeName); + } + else if (myPortInES && myPortOut) { + SUPERV_Port aInPortES = myPortInES->getPort(); + QString aInNodeName(aInPortES->Node()->Name()); + SUPERV_Port aOutPort = myPortOut->getPort(); + QString aOutNodeName(aOutPort->Node()->Name()); + + return (aInNodeName != aOutNodeName); + } + else + return false; +} + +//********************************************************************** +/** + * Abort creation of link + */ +void SUPERVGUI_Link::abortCreation() { + LinkIsMoving = false; +} + +//********************************************************************** +/** + * Final procedure of link creation + */ +bool SUPERVGUI_Link::createEngine() { + // clear temporary drawing + QPen aOldPen(myGraph->viewport()->paletteBackgroundColor(), LINE_WIDTH); + //check if myPainter not null + if (myPainter) { + myPainter->setPen(aOldPen); + myPainter->setRasterOp(Qt::CopyROP); + + QPoint aStartPnt; + if (myTmpPoints.size() > 0) + aStartPnt = myGraph->contentsToViewport(myTmpPoints[myTmpPoints.size()-1]); + else + aStartPnt = myStartPort->getConnectPnt(); + + myPainter->drawLine(aStartPnt, myPrevPoint); + + delete myPainter; + myPainter = 0; + } + + // Create engine + if (!isESInputPort()) + myEngine = myGraph->getMain()->getDataflow()-> + Link(myPortOut->getPort(), myPortIn->getPort()); + else + myEngine = myGraph->getMain()->getDataflow()-> + Link(myPortOut->getPort(), myPortInES->getPort()); + + if (SUPERV_isNull(myEngine)) return false; + + // remember all points + QPoint aPnt; + if (myStartPort == myPortOut) { + int aSize = myTmpPoints.size(); + for (int i = aSize; i > 0; i--) { + aPnt = myTmpPoints[i-1]; + myEngine->AddCoord(aSize+1-i, aPnt.x(), aPnt.y()); + } + } else { + for (int i = 0; i < myTmpPoints.size(); i++) { + aPnt = myTmpPoints[i]; + myEngine->AddCoord(i+1, aPnt.x(), aPnt.y()); + } + } + LinkIsMoving = false; + + // empty temporary resources + myTmpPoints.clear(); + myStartPort = 0; + connectToEvents(); + paint(false); + return true; +} + + + +//********************************************************************** +void SUPERVGUI_Link::onMouseMove(QMouseEvent * theEvent) { + if (myPntMovingState) { + drawSegments(); + + QPoint aPos = myGraph->contentsToViewport(theEvent->pos()); + int aX = (aPos.x() > 0)? aPos.x(): 1; + int aY = (aPos.y() > 0)? aPos.y(): 1; + aX = (aX < myGraph->contentsWidth())? aX: myGraph->contentsWidth()-1; + aY = (aY < myGraph->contentsHeight())? aY: myGraph->contentsHeight()-1; + + myMovedPnt = QPoint(aX, aY); + drawSegments(); + return; + } + + if (LinkIsMoving) return; + + // Points highlighting + QPoint aPos = theEvent->pos(); + if (myEngine->CoordsSize() > 0 ) { + long aX, aY; + bool aIsFound = false; + for (int i=0; i < myEngine->CoordsSize(); i++) { + myEngine->Coords(i+1, aX, aY); + if (distance(aX, aY, + aPos.x(), + aPos.y()) < (PNT_SIZE+2)) { + myHltPnt = i+1; + aIsFound = true; + break; + } + } + if (!aIsFound) myHltPnt = -1; + } + + // Highlight line + if (isSelected(aPos)) { + if (SelectedLink==0) { + QPen aNewPen(HLT_CLR, LINE_WIDTH); + QPainter aPainter(myGraph->viewport()); + aPainter.setPen(aNewPen); + drawLink(&aPainter); + myIsSelected = true; + SelectedLink = this; + } + } else if (myIsSelected) { + myIsSelected = false; + if (SelectedLink == this) SelectedLink = 0; + paint(false); + } +} + + +//********************************************************************** +/** + * For internal using only + * Draws segments by current Pen when point is moving + */ +void SUPERVGUI_Link::drawSegments() { + myPainter->drawLine(myBeforePnt, myMovedPnt); + myPainter->drawLine(myMovedPnt, myAfterPnt); + myPainter->drawEllipse(myMovedPnt.x()-PNT_SIZE/2, + myMovedPnt.y()-PNT_SIZE/2, + PNT_SIZE, PNT_SIZE); +} + + +//********************************************************************** +void SUPERVGUI_Link::onMousePress(QMouseEvent * theEvent) { + if (LinkIsMoving) { + return; + } + if (theEvent->button() != Qt::LeftButton) { + myHltPnt = -1; + return; + } + if (myHltPnt > -1) { // start point moving + if (myHltPnt == 1) { + if (!isESInputPort()) { + myBeforePnt = myPortIn->getConnectPnt(); + } + else { + myBeforePnt = myPortInES->getConnectPnt(); + } + } + else { + long aX, aY; + myEngine->Coords(myHltPnt-1, aX, aY); + myBeforePnt = myGraph->contentsToViewport(QPoint(aX, aY)); + } + if (myHltPnt == myEngine->CoordsSize()) + myAfterPnt = myPortOut->getConnectPnt(); + else { + long aX, aY; + myEngine->Coords(myHltPnt+1, aX, aY); + myAfterPnt = myGraph->contentsToViewport(QPoint(aX, aY)); + } + long aX, aY; + myEngine->Coords(myHltPnt, aX, aY); + myMovedPnt = myGraph->contentsToViewport(QPoint(aX, aY)); + + myPainter = new QPainter(myGraph->viewport()); + QPen aOldPen(myGraph->viewport()->paletteBackgroundColor(), LINE_WIDTH); + + myPainter->setPen(aOldPen); + drawSegments(); + + myPainter->setPen(myTmpPen); + myPainter->setRasterOp(Qt::XorROP); + drawSegments(); + + myPntMovingState = true; + LinkIsMoving = true; + } else if (myHltPnt > -1) + paint(false); +} + +//********************************************************************** +void SUPERVGUI_Link::onMouseRelease(QMouseEvent * theEvent){ + if (theEvent->button() != Qt::LeftButton) return; + + if (myPntMovingState) { + myPntMovingState = false; + LinkIsMoving = false; + drawSegments(); + delete myPainter; + myPainter = 0; + + int aX = (theEvent->pos().x() > 0)? theEvent->pos().x(): 1; + int aY = (theEvent->pos().y() > 0)? theEvent->pos().y(): 1; + aX = (aX < myGraph->contentsWidth())? aX: myGraph->contentsWidth()-1; + aY = (aY < myGraph->contentsHeight())? aY: myGraph->contentsHeight()-1; + myEngine->ChangeCoord(myHltPnt, aX, aY); + + paint(false); + } +} + +//********************************************************************** +/** + * Connects to the Graph mouse events + */ +void SUPERVGUI_Link::connectToEvents() { + connect(myGraph, SIGNAL(mouseMoved(QMouseEvent*)), + this, SLOT(onMouseMove(QMouseEvent*))); + + connect(myGraph, SIGNAL(mousePressed(QMouseEvent*)), + this, SLOT(onMousePress(QMouseEvent*))); + + connect(myGraph, SIGNAL(mouseReleased(QMouseEvent*)), + this, SLOT(onMouseRelease(QMouseEvent*))); +} + + +//********************************************************************** +bool SUPERVGUI_Link::isSelected(QPoint thePnt) { + if (myEngine->CoordsSize() == 0) { + if (!isESInputPort()) { + return (distance(thePnt, myGraph->viewportToContents(myPortOut->getConnectPnt()), + myGraph->viewportToContents(myPortIn->getConnectPnt())) <= 0); + } + else { + return (distance(thePnt, myGraph->viewportToContents(myPortOut->getConnectPnt()), + myGraph->viewportToContents(myPortInES->getConnectPnt())) <= 0); + } + } + else { + long aX, aY; + myEngine->Coords(1, aX, aY); + if (!isESInputPort()) { + if (distance(thePnt, myGraph->viewportToContents(myPortIn->getConnectPnt()), + QPoint(aX, aY)) <= 0) { + return true; + } + } + else { + if (distance(thePnt, myGraph->viewportToContents(myPortInES->getConnectPnt()), + QPoint(aX, aY)) <= 0) { + return true; + } + } + + int i = 2; + long aNextX, aNextY; + for (i = 2; i <= myEngine->CoordsSize(); i++) { + myEngine->Coords(i, aNextX, aNextY); + if (distance(thePnt, QPoint(aX, aY), + QPoint(aNextX, aNextY)) <= 0) { + return true; + } + aX = aNextX; + aY = aNextY; + } + if (distance(thePnt, QPoint(aX, aY), + myGraph->viewportToContents(myPortOut->getConnectPnt())) <= 0) { + return true; + } + } + return false; +} + + +//********************************************************************** +/** + * Returns true if at least one point is within the rect. + * Rect must be in contents coordinate space + */ +bool SUPERVGUI_Link::isInRect(int theX, int theY, int theW, int theH) { + QRect aRect(theX, theY, theW, theH); + if (aRect.contains(myGraph->viewportToContents(myPortOut->getConnectPnt()), true)) + return true; + + if (!isESInputPort()) { + if (aRect.contains(myGraph->viewportToContents(myPortIn->getConnectPnt()), true)) { + return true; + } + } + else { + if (aRect.contains(myGraph->viewportToContents(myPortInES->getConnectPnt()), true)) { + return true; + } + } + + long aX, aY; + QPoint aPrevPnt; + if (!isESInputPort()) + aPrevPnt = myGraph->viewportToContents(myPortIn->getConnectPnt()); + else + aPrevPnt = myGraph->viewportToContents(myPortInES->getConnectPnt()); + for (int i = 1; i <= myEngine->CoordsSize(); i++) { + myEngine->Coords(i, aX, aY); + if (aRect.contains(aX, aY, true)) + return true; + else { + QRect aTmpRect(QPoint(QMIN(aPrevPnt.x(), aX), + QMIN(aPrevPnt.y(), aY)), + QPoint(QMAX(aPrevPnt.x(), aX), + QMAX(aPrevPnt.y(), aY))); + if (aRect.intersects(aTmpRect)) + return true; + aPrevPnt = QPoint(aX, aY); + } + } + QPoint aLastPnt = myGraph->viewportToContents(myPortOut->getConnectPnt()); + QRect aLastRect(QPoint(QMIN(aPrevPnt.x(), aLastPnt.x()), + QMIN(aPrevPnt.y(), aLastPnt.y())), + QPoint(QMAX(aPrevPnt.x(), aLastPnt.x()), + QMAX(aPrevPnt.y(), aLastPnt.y()))); + if (aRect.intersects(aLastRect)) + return true; + + return false; +} + + +//********************************************************************** +/** + * Calculates distance between points + */ +int distance(int x1, int y1, int x2, int y2) { + int x = x2 - x1; + x = x * x; + int y = y2 - y1; + y = y * y; + return (int) sqrt(x + y); +} + + +//********************************************************************** +/** + * Finds distance between thePnt and line(thePntLn1, thePntLn2) + * Returned value is not an mathematical value - this is only estimation of + * of closing point to the line. 0 - means that point belongs to the line + */ +int distance(QPoint thePnt, QPoint thePntLn1, QPoint thePntLn2) { + int r, s; + int a, b, c; + + int px = thePnt.x(); + int py = thePnt.y(); + int lx = thePntLn1.x(); + int ly = thePntLn1.y(); + int nx = thePntLn2.x(); + int ny = thePntLn2.y(); + + r = px - lx; + r = r * r; + s = py - ly; + s = s * s; + a = (int) sqrt((float)(r + s)); + + r = px - nx; + r = r * r; + s = py - ny; + s = s * s; + b = (int) sqrt((float)(r + s)); + + r = nx - lx; + r = r * r; + s = ny - ly; + s = s * s; + c = (int) sqrt((float)(r + s)); + + return (a+b-c); +} + +void SUPERVGUI_Link::setBeginPort(SUPERVGUI_Port* theBeginPort) { + myBeginPort = theBeginPort; +} + +SUPERVGUI_Port* SUPERVGUI_Link::getBeginPort() { + return myBeginPort; +} + + diff --git a/src/SUPERVGUI/SUPERVGUI_Link.h b/src/SUPERVGUI/SUPERVGUI_Link.h new file mode 100644 index 0000000..13f724a --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Link.h @@ -0,0 +1,142 @@ +// File : SUPERVGUI_Link.h +// Created : 20 / 12 / 2002 +// Author : Vitaly SMETANNIKOV +// Project : SALOME +// Module : SUPERVGUI +// Copyright : Open CASCADE + +#ifndef SUPERVGUI_Link_H +#define SUPERVGUI_Link_H + +using namespace std; + +#include "SUPERVGUI_Def.h" +#include "SUPERVGUI_Port.h" +#include + +class SUPERVGUI_Graph; + +int distance(int x1, int y1, int x2, int y2); +int distance(QPoint thePnt, QPoint thePntLn1, QPoint thePntLn2); + + +class SUPERVGUI_Link: public QObject { + Q_OBJECT + +public: + SUPERVGUI_Link(SUPERVGUI_Graph* theGraph, SUPERV_Link theLink=0); + + virtual ~SUPERVGUI_Link(); + + void setBeginPort(SUPERVGUI_Port* theBeginPort); + SUPERVGUI_Port* getBeginPort(); + + void setInputPort(SUPERVGUI_PortIn* thePortIn); + SUPERVGUI_PortIn* getInputPort() + { return myPortIn; }; + + void setInputPortES(SUPERVGUI_PortInESNode* thePortInES); + SUPERVGUI_PortInESNode* getInputPortES() + { return myPortInES; }; + + bool isESInputPort(); + + void destroyEngine(); + + void setOutputPort(SUPERVGUI_PortOut* thePortOut); + SUPERVGUI_PortOut* getOutputPort() + { return myPortOut; }; + + void addPoint(long theX, long theY); + void removeLastPoint(); + + void repaint(); + void paint(bool toErase); + void paint(QPainter* thePainter, bool toErase); + void drawLink(QPainter* thePainter); + + bool isInRect(int theX, int theY, int theW, int theH); + + SUPERV_Link getEngineLink() + { return myEngine; }; + + void drawTo(QPoint thePnt); + void abortCreation(); + + void repaintSketch(); + void addTmpPoint(QPoint thePnt); + void delLastTmpPoint(); + + bool isCreationComplete(); + bool createEngine(); + + bool isSelected() + { return myIsSelected; }; + + bool haveSelectedPoint() + { return (myHltPnt > -1); }; + + int getSelectedPoint() + { return myHltPnt; }; + + void removePoint(int thePnt); + + void setVisible(bool theVisible); + + static void setOrthoMode(bool theIsOrtho) + { OrthoMode = theIsOrtho; }; + + static bool isOrthoMode() + { return OrthoMode; }; + + static SUPERVGUI_Link* getSelectedLink() + { return SelectedLink; }; + +signals: + void linkDeleted(SUPERVGUI_Link*); + +public slots: + void onMouseMove(QMouseEvent* theEvent); + void onMousePress(QMouseEvent* theEvent); + void onMouseRelease(QMouseEvent* theEvent); + + +private: + void connectToEvents(); + bool isSelected(QPoint thePnt); + + + SUPERVGUI_Graph* myGraph; + SUPERVGUI_Port* myBeginPort; + SUPERVGUI_PortIn* myPortIn; + SUPERVGUI_PortInESNode* myPortInES; + SUPERVGUI_PortOut* myPortOut; + + SUPERV_Link myEngine; + + QPoint myPrevPoint; // used for sketching only + QValueVector myTmpPoints; + SUPERVGUI_Port* myStartPort; + + QPen myTmpPen; + + // Points highlighting management + int myHltPnt; // number of point or -1 + + // Points moving management + void drawSegments(); + bool myPntMovingState; + QPoint myBeforePnt, myMovedPnt, myAfterPnt; + QPainter* myPainter; + + // Selection of Link + bool myIsSelected; + + bool myIsVisible; + + static bool OrthoMode; + static bool LinkIsMoving; + static SUPERVGUI_Link* SelectedLink; +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_Main.cxx b/src/SUPERVGUI/SUPERVGUI_Main.cxx new file mode 100644 index 0000000..94d901e --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Main.cxx @@ -0,0 +1,1083 @@ +using namespace std; +// File : SUPERVGUI_Main.cxx +// Created : 24 / 10 / 2001 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGUI +// Copyright : CEA + +#include "QAD_Splitter.h" +#include "QAD_LeftFrame.h" +#include "QAD_ObjectBrowser.h" +#include "QAD_ObjectBrowserItem.h" +#include "QAD_PyEditor.h" +#include "QAD_Message.h" +#include "QAD_FileDlg.h" +#include "QAD_Application.h" +#include "SUPERVGUI_Def.h" +#include "QAD_RightFrame.h" +#include "SUPERVGraph_ViewFrame.h" +#include +#include +#include "SUPERVGUI_Main.h" +#include "SUPERVGUI.h" +#include "SUPERVGUI_ComputeNode.h" +#include "SUPERVGUI_ControlNode.h" +#include "NOTIFICATION.hxx" +#include "SUPERVGUI_Notification.h" +#include "SALOMEGUI_ImportOperation.h" +#include "SUPERVGUI_Information.h" + + +SUPERVGUI_Main::SUPERVGUI_Main(SUPERVGraph_ViewFrame* theParent, QAD_Desktop* theDesktop, bool fromIOR) + : SUPERVGraph_View(theParent), + myLogged( false ), + myFiltered( false ), + myLogFileName( QString::null ), + myLogFile( NULL ), + myWarning( false ), + myStep( false ), + myTrace( false ), + myVerbose( false ) +{ + Trace("SUPERVGUI_Main::SUPERVGUI_Main (new)"); + theParent->setViewWidget(this); + if (fromIOR) { + //SUPERVGUI_Main* am = Supervision.getMain(); + QAD_ObjectBrowser* ob = ((QAD_StudyFrame*)(theDesktop->getMainFrame()->activeWindow()))->getLeftFrame()->getObjectBrowser(); + // if (am == 0) { + // ob = ((QAD_StudyFrame*)(theDesktop->getMainFrame()->activeWindow()))->getLeftFrame()->getObjectBrowser(); + //} else { + //ob = am->objectBrowser; + //}; + QAD_ObjectBrowserItem* item = (QAD_ObjectBrowserItem*)(ob->getListView()->currentItem()); + SALOMEDS::SObject_var obj = theDesktop->getActiveStudy()->getStudyDocument()->FindObjectID(item->getEntry().latin1()); + SALOMEDS::GenericAttribute_var anAttr; + if (obj->FindAttribute(anAttr, "AttributeIOR")) { + SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + Standard_CString ior = anIOR->Value(); + dataflow = (*Supervision.getEngine())->getGraph(ior); + if (SUPERV_isNull(dataflow)) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_ACCESS_BAD_IOR")); + close(); + } else { + init(theDesktop); + } + } else { + QMessageBox::warning(0, tr("ERROR"), tr("MSG_NOACCESS_BY_IOR")); + close(); + } + } else { + dataflow = (*Supervision.getEngine())->Graph(MAIN_NEW); + if (SUPERV_isNull(dataflow)) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_DF")); + close(); + } else { + init(theDesktop); + } + } +} + +SUPERVGUI_Main::SUPERVGUI_Main(SUPERVGraph_ViewFrame* theParent, QAD_Desktop* theDesktop, bool isModify, const char* f) + : SUPERVGraph_View(theParent), + myLogged( false ), + myFiltered( false ), + myLogFileName( QString::null ), + myLogFile( NULL ), + myWarning( false ), + myStep( false ), + myTrace( false ), + myVerbose( false ) +{ + Trace("SUPERVGUI_Main::SUPERVGUI_Main (file)") + theParent->setViewWidget(this); + if (isModify) { + dataflow = (*Supervision.getEngine())->Graph(f); + } else { + dataflow = (*Supervision.getEngine())->GraphE(f); + } + if (SUPERV_isNull(dataflow)) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f)); + close(); + } else { + init(theDesktop); + } +} + +SUPERVGUI_Main::SUPERVGUI_Main(SUPERVGraph_ViewFrame* theParent, QAD_Desktop* theDesktop, SUPERV_Graph cp) + : SUPERVGraph_View(theParent), + myLogged( false ), + myFiltered( false ), + myLogFileName( QString::null ), + myLogFile( NULL ), + myWarning( false ), + myStep( false ), + myTrace( false ), + myVerbose( false ) +{ + Trace("SUPERVGUI_Main::SUPERVGUI_Main (copy)"); + theParent->setViewWidget(this); + // dataflow = cp->Copy(); + dataflow = cp; + if (SUPERV_isNull(dataflow)) { + QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_COPY")); + close(); + } else { + init(theDesktop); + } +} + +void SUPERVGUI_Main::init(QAD_Desktop* theDesktop) { + Trace("SUPERVGUI_Main::init"); + if (theDesktop) myNService = theDesktop->getNameService(); + myHashCode = "New"; + myCopyNum = 0; + choosing = false; + myIsLocked = false; + + myIsKilled = false; + //myIsRunned = false; + myCurrentView = GRAPH; + myIsFromStudy = false; + study = theDesktop->getActiveStudy(); + timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(execute())); + + SALOMEDS::Study_var studyDoc = study->getStudyDocument(); + SALOMEDS::StudyBuilder_var builder = studyDoc->NewBuilder(); + SALOMEDS::SComponent_var father = studyDoc->FindComponent(STUDY_SUPERVISION); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributePixMap_var aPixmap; + if (father->_is_nil()) { + QAD_Operation* op = new SALOMEGUI_ImportOperation( study ); + op->start(); + father = builder->NewComponent(STUDY_SUPERVISION); + anAttr = builder->FindOrCreateAttribute(father, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + //aName->SetValue("Supervision"); + aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) ); + + anAttr = builder->FindOrCreateAttribute(father, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" ); + + builder->DefineComponentInstance(father, *Supervision.getEngine()); + op->finish(); + }; + + objectBrowser = study->getActiveStudyFrame()->getLeftFrame()->getObjectBrowser(); + + + graph = new SUPERVGUI_Graph(this); + array = new SUPERVGUI_Array(this); + + message = study->getActiveStudyFrame()->getRightFrame()->getMessage(); + notification = new NOTIFICATION_Consumer(); + + QBoxLayout * layout = new QVBoxLayout(this); + layout->setMargin(0); + layout->setSpacing(0); + layout->addWidget(graph); + layout->addWidget(array); + + sync(); + show(); + if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) { + myLogFile = fopen( myLogFileName.latin1(), "a" ); + if ( myLogFile == NULL ) + myLogged = false; + } +} + +SUPERVGUI_Main::~SUPERVGUI_Main() { + Trace("SUPERVGUI_Main::~SUPERVGUI_Main"); + if ( myLogFile != NULL) { + fclose( myLogFile ); + } + graph->removeLinks(); + delete notification; // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit + if (!SUPERV_isNull(dataflow)) { + if (dataflow->IsExecuting()) { + if (QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), + tr("MSG_DF_RUNNING"), + tr("MSG_DF_EXECUTION"), + tr("MSG_DF_KILL")) == 1) { + dataflow->Kill(); + } + } + } +} + +void SUPERVGUI_Main::StartTimer(const char* m) { + Trace("SUPERVGUI_Main::StartTimer") + if (!timer->isActive()) { + timer->start(5); + message->setMessage(m); + }; +} + +void SUPERVGUI_Main::StopTimer(const char* m) { + Trace("SUPERVGUI_Main::StopTimer") + if (timer->isActive()) { + timer->stop(); + syncNotification(); + message->setMessage(m); + sync(); + }; +} + +void SUPERVGUI_Main::filterNotification() { + Trace("SUPERVGUI_Main::filterNotification"); + SUPERVGUI_Notification* dlg = new SUPERVGUI_Notification(this); + dlg->setFiltered( myFiltered ); + dlg->setLogged( myLogged, myLogFileName ); + dlg->setWarning( myWarning ); + dlg->setStep( myStep ); + dlg->setTrace( myTrace ); + dlg->setVerbose( myVerbose ); + if ( dlg->exec() == QDialog::Accepted ) { + myLogged = dlg->getLogged(); + myLogFileName = dlg->getLogFile(); + myFiltered = dlg->getFiltered(); + myWarning = dlg->getWarning(); + myStep = dlg->getStep(); + myTrace = dlg->getTrace(); + myVerbose = dlg->getVerbose(); + delete dlg; + if ( myLogFile != NULL) { + fclose( myLogFile ); + } + myLogFile = NULL; + if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) { + myLogFile = fopen( myLogFileName.latin1(), "a" ); + if ( myLogFile == NULL ) { + myLogged = false; + QMessageBox::warning( QAD_Application::getDesktop(), tr("ERROR"), tr( "ERR_CANT_OPEN_LOG_FILE" ) ); + } + } + } +} + +void SUPERVGUI_Main::syncAsync() { + Trace("SUPERVGUI_Main::syncAsync") + QTimer::singleShot(1, this, SLOT(sync())); +} + + +/** + * Called by timer when dataflow is executing + */ +void SUPERVGUI_Main::execute() { + SUPERV_CNode aNode; + SUPERV::GraphEvent aEvent; + SUPERV::GraphState aState; + dataflow->EventNoW(aNode, aEvent, aState); + if ((aEvent == SUPERV::NoEvent) && (aState == SUPERV::NoState)) return; + + if (!SUPERV_isNull(aNode)) { + SUPERVGUI_Node* aNodePrs; + if (myCurrentView == TABLE) { + aNodePrs = (SUPERVGUI_Node*) array->child(aNode->Name(), "SUPERVGUI_Node"); + } else { + aNodePrs = (SUPERVGUI_Node*) graph->child(aNode->Name(), "SUPERVGUI_Node"); + } + if (aNodePrs) + aNodePrs->sync(); + } + switch (dataflow->State()) { + case SUPERV_Editing : + StopTimer(dataflow->IsReadOnly()? tr("MSG_GRAPH_READONLY"): tr("MSG_GRAPH_EDITING")); + break; + + case SUPERV_Suspend : + StopTimer(tr("MSG_GRAPH_SUSPENDED")); + break; + + case SUPERV_Done : + StopTimer(tr("MSG_GRAPH_FINISHED")); + break; + + case SUPERV_Error : + StopTimer(tr("MSG_GRAPH_ABORTED")); + break; + + case SUPERV_Kill : + StopTimer(tr("MSG_GRAPH_KILLED")); + break; + + } +} + + + +void SUPERVGUI_Main::sync() { + Trace("SUPERVGUI_Main::sync") + if ((SUPERV_isNull(dataflow))) return; + QString t = tr("GRAPH_TITLE"); + + t += dataflow->Name(); + setCaption(t); + + study->updateObjBrowser(); + if (myCurrentView == TABLE) { + array->sync(); + } else { + graph->sync(); + } +} + + +void SUPERVGUI_Main::showTable() { + if (myCurrentView == TABLE) return; + + if (array->create()) { + myCurrentView = TABLE; + graph->hide(); + } + sync(); +} + + +void SUPERVGUI_Main::showFullGraph() { + if (myCurrentView == TABLE) { + array->destroy(); + graph->show(); + } + myCurrentView = GRAPH; + graph->sync(); + graph->setFullView(); +} + + +void SUPERVGUI_Main::showContolFlow() { + if (myCurrentView == TABLE) { + array->destroy(); + graph->show(); + } + myCurrentView = CONTROLFLOW; + graph->sync(); + graph->setControlView(); +} + + +bool SUPERVGUI_Main::exportDataflow(QString theFile) { + Trace("SUPERVGUI_Main::exportDataflow"); + if ((SUPERV_isNull(dataflow))) return false; + + if (!theFile.isEmpty()) { + if (!dataflow->Export(theFile.latin1())) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_WRITING")); + return false; + } + } + return true; +} + +void SUPERVGUI_Main::insertFile() { + Trace("SUPERVGUI_Main::insertFile") + if ((SUPERV_isNull(dataflow))) return; + + QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), + "", + "*.xml", + tr("MSG_GRAPH_INSERT"), + true); + if (!f.isEmpty()) { + if (dataflow->Import(f.latin1())) { + if (myCurrentView == TABLE) { + array->destroy(); + array->create(); + } + sync(); + } else { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f)); + }; + }; +} + +void SUPERVGUI_Main::copy() { + Trace("SUPERVGUI_Main::copy"); + if (dataflow->ThreadsMax() == 0) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOTHING_COPY")); + return; + } + QAD_StudyFrame* aStudyFrame = Supervision.createGraph(); + SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast + (aStudyFrame->getRightFrame()->getViewFrame()); + if(aViewFrame){ + SUPERV_Graph aNewGraph = dataflow->Copy(); + QString aNewName(tr("MSG_COPY_PREFIX").arg(++myCopyNum)); + aNewName += dataflow->Name(); + aNewGraph->SetName(aNewName); + SUPERVGUI_Main* m = new SUPERVGUI_Main(aViewFrame, + Supervision.getDesktop(), + aNewGraph); + study->showFrame(aStudyFrame); + } +} + +void SUPERVGUI_Main::run() { + Trace("SUPERVGUI_Main::run") + if ((SUPERV_isNull(dataflow))) return; + + if (dataflow->IsEditing()) { + if (!dataflow->IsValid()) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTVALID")); + } else if (!dataflow->IsExecutable()) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE")); + } else { + myRunTime = QDateTime::currentDateTime(); + if (myIsKilled) { + //if (myIsRunned) { + if (!dataflow->ReRun()) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE")); + } else { + StartTimer(tr("MSG_GRAPH_STARTED")); + syncNotification(); + sync(); + } + } else { + if (!dataflow->Run()) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE")); + } else { + StartTimer(tr("MSG_GRAPH_STARTED")); + syncNotification(); + //myIsRunned = true; + sync(); + } + } + } + } else { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_RUNNING")); + } +} + + + +void SUPERVGUI_Main::startExecute() { + Trace("SUPERVGUI_Main::startExecute") + if ((SUPERV_isNull(dataflow))) return; + + if (dataflow->IsEditing()) { + if (!dataflow->IsValid()) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTVALID")); + } else if (!dataflow->IsExecutable()) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE")); + } else { + myRunTime = QDateTime::currentDateTime(); + if (myIsKilled) { + //if (myIsRunned) { + if (!dataflow->ReStart()) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE")); + } else { + StartTimer(tr("MSG_GRAPH_STARTED")); + syncNotification(); + } + } + else { + if (!dataflow->Start()) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE")); + } else { + StartTimer(tr("MSG_GRAPH_STARTED")); + syncNotification(); + } + } + } + } else { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_RUNNING")); + } +} + + +void SUPERVGUI_Main::kill() { + Trace("SUPERVGUI_Main::kill") + if ((SUPERV_isNull(dataflow))) return; + + if (dataflow->IsEditing()) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING")); + } else if (dataflow->Kill()) { + myIsKilled = true; + sync(); + } else { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANTKILL_DF")); + } +} + +void SUPERVGUI_Main::suspendResume() { + Trace("SUPERVGUI_Main::suspendResume") + if ((SUPERV_isNull(dataflow))) return; + + if (dataflow->IsEditing()) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING")); + } else if (dataflow->State() == SUPERV_Suspend) { + if (dataflow->Resume()) { + message->setMessage(tr("MSG_DF_RESUMED")); + sync(); + } else { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESUME")); + } + } else { + if (dataflow->Suspend()) { + sync(); + } else { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_SUSPEND")); + } + } +} + +void SUPERVGUI_Main::stopRestart() { // kloss : a reviser et a connecter dans le popup du dataflow (pas de creation de bouton) + Trace("SUPERVGUI_Main::stopRestart") + if ((SUPERV_isNull(dataflow))) return; + + if (dataflow->IsEditing()) { + QMessageBox::warning(0, tr("ERROR"), tr("MSG_DF_NOTRUNNING")); + } else if (dataflow->State() == SUPERV_Stop) { + if (dataflow->ReStart()) { + message->setMessage(tr("MSG_DF_RESTARTED")); + sync(); + } else { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESTART")); + }; + } else { + if (dataflow->Stop()) { + sync(); + } else { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_STOP")); + }; + }; +} + +void SUPERVGUI_Main::addNode() { + Trace("SUPERVGUI_Main::addNode"); + if (SUPERV_isNull(dataflow)) return; + + if (dataflow->IsExecuting()) { + if (QMessageBox::warning(QAD_Application::getDesktop(), + tr("WARNING"), tr("MSG_GRAPH_ISRUN"), + QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) { + return; + } else { + kill(); + } + } + Supervision.getBrowser()->choose(); +} + + + +/** + * Add Computation node + */ +void SUPERVGUI_Main::addComputeNode(SUPERV_CNode theNode) { + //cout<<"### X="<X()<<" Y="<Y()<viewport(), this, theNode); + graph->ResizeGraph(aNode, theNode->X(), theNode->Y()); + graph->addChild(aNode, theNode->X(), theNode->Y()); + aNode->sync(); + } + break; + case CONTROLFLOW: + { + SUPERVGUI_Node* aNode = new SUPERVGUI_ComputeNode(graph->viewport(), this, theNode); + aNode->hideAll(); + graph->ResizeGraph(aNode, theNode->X(), theNode->Y()); + graph->addChild(aNode, theNode->X(), theNode->Y()); + aNode->sync(); + } + break; + case TABLE: + array->destroy(); + array->create(); + break; + } +} + +/** + * Add GOTO node + */ +void SUPERVGUI_Main::addGOTONode(SUPERV_CNode theNode) { + switch (myCurrentView) { + case GRAPH: + { + SUPERVGUI_Node* aNode = new SUPERVGUI_GotoNode(graph->viewport(), this, theNode); + graph->ResizeGraph(aNode, theNode->X(), theNode->Y()); + graph->addChild(aNode, theNode->X(), theNode->Y()); + aNode->sync(); + } + break; + case CONTROLFLOW: + { + SUPERVGUI_Node* aNode = new SUPERVGUI_GotoNode(graph->viewport(), this, theNode); + aNode->hideAll(); + graph->ResizeGraph(aNode, theNode->X(), theNode->Y()); + graph->addChild(aNode, theNode->X(), theNode->Y()); + aNode->sync(); + } + break; + case TABLE: + array->destroy(); + array->create(); + break; + } +} + +/** + * Add Control node + */ +void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update) { + switch (myCurrentView) { + case GRAPH: + { + SUPERVGUI_StartControlNode* aStartPrs = + new SUPERVGUI_StartControlNode(graph->viewport(), this, theStartNode); + SUPERVGUI_EndControlNode* aEndPrs = + new SUPERVGUI_EndControlNode(graph->viewport(), this, theEndNode, aStartPrs); + + graph->ResizeGraph(aStartPrs, theStartNode->X(), theStartNode->Y()); + graph->addChild(aStartPrs, theStartNode->X(), theStartNode->Y()); + graph->ResizeGraph(aEndPrs, theEndNode->X(), theEndNode->Y()); + graph->addChild(aEndPrs, theEndNode->X(), theEndNode->Y()); + if (Update) { + aStartPrs->updateLinksPrs(); + aEndPrs->updateLinksPrs(); + } + aStartPrs->sync(); + aEndPrs->sync(); + graph->repaintContents(); + } + break; + case CONTROLFLOW: + { + SUPERVGUI_StartControlNode* aStartPrs = + new SUPERVGUI_StartControlNode(graph->viewport(), this, theStartNode); + SUPERVGUI_EndControlNode* aEndPrs = + new SUPERVGUI_EndControlNode(graph->viewport(), this, theEndNode, aStartPrs); + + aStartPrs->hideAll(); + aEndPrs->hideAll(); + + graph->ResizeGraph(aStartPrs, theStartNode->X(), theStartNode->Y()); + graph->addChild(aStartPrs, theStartNode->X(), theStartNode->Y()); + graph->ResizeGraph(aEndPrs, theEndNode->X(), theEndNode->Y()); + graph->addChild(aEndPrs, theEndNode->X(), theEndNode->Y()); + if (Update) { + aStartPrs->updateLinksPrs(); + aEndPrs->updateLinksPrs(); + } + aStartPrs->sync(); + aEndPrs->sync(); + graph->repaintContents(); + } + break; + case TABLE: + array->destroy(); + array->create(); + break; + } +} + + + +SUPERVGUI_Graph* SUPERVGUI_Main::getGraph() { + Trace("SUPERVGUI_Main::getGraph") + return(graph); +} + +SUPERVGUI_Array* SUPERVGUI_Main::getArray() { + Trace("SUPERVGUI_Main::getArray") + return(array); +} + +SUPERV_Graph SUPERVGUI_Main::getDataflow() { + Trace("SUPERVGUI_Main::getDataflow") + return(dataflow); +} + +QAD_Message* SUPERVGUI_Main::getMessage() { + Trace("SUPERVGUI_Main::getMessage") + return(message); +} + +QAD_Study* SUPERVGUI_Main::getStudy() { + Trace("SUPERVGUI_Main::getStudy") + return(study); +} + +bool SUPERVGUI_Main::isArrayShown() { + Trace("SUPERVGUI_Main::isArrayShown") + return(myCurrentView == TABLE); +} + +void SUPERVGUI_Main::showPopup(QPopupMenu* p, QMouseEvent* e) { + Trace("SUPERVGUI_Main::showPopup"); + // To check is Supervision active? + if (myIsLocked) return; + + if (QAD_Application::getDesktop()->getActiveComponent().compare(STUDY_SUPERVISION) !=0) return; + + checkIsInStudy(); + if (e->button() == RightButton) { + p->exec(e->globalPos()); + } +} + + + +void SUPERVGUI_Main::changeInformation() { + SUPERVGUI_Information* aDlg = new SUPERVGUI_Information(SUPERV::CNode::_narrow(dataflow), dataflow->IsReadOnly()); + if (aDlg->exec() ) + sync(); + delete aDlg; + /* Trace("SUPERVGUI_Main::changeInformation") + if (Supervision.information(SUPERV::CNode::_narrow(dataflow), dataflow->IsReadOnly())) { + sync(); + }*/ +} + +// returns false, if can't add dataflow into the study +bool SUPERVGUI_Main::addStudy() { + Trace("SUPERVGUI_Main::addStudy"); + if (myIsFromStudy) return false; + if ((SUPERV_isNull(dataflow))) return false; + + SALOMEDS::Study_var aStudy = study->getStudyDocument(); + SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIORAttr; + SALOMEDS::AttributePixMap_var aPixmap; + bool aLocked = aStudy->GetProperties()->IsLocked(); + QAD_Operation* op = new SALOMEGUI_ImportOperation( study ); + + // searching dataflow + SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR(dataflow->getIOR()); + if (aSO->_is_nil()) { // create new dataflow SObject + SALOMEDS::SComponent_ptr aComponent = aStudy->FindComponent(STUDY_SUPERVISION); + if (aComponent->_is_nil()) { // is supervision component not found, then create it + QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study ); + anOperation->start(); + if (aLocked) aStudy->GetProperties()->SetLocked(false); + aComponent = aBuilder->NewComponent(STUDY_SUPERVISION); + anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(STUDY_SUPERVISION); + + anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" ); + aBuilder->DefineComponentInstance(aComponent, *Supervision.getEngine()); + if (aLocked) aStudy->GetProperties()->SetLocked(true); + anOperation->finish(); + } + op->start(); + aSO = aBuilder->NewObject(aComponent); + anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(dataflow->Name()); + anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR"); + anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr); + anIORAttr->SetValue(dataflow->getIOR()); + op->finish(); + if (aLocked) return false; + } + + sync(); + Supervision.unregisterGraph(this); + Supervision.registerGraph(dataflow->getIOR(), this); + myIsFromStudy = true; + return true; +} + + +void SUPERVGUI_Main::chooseData(QListViewItem* item) { + Trace("SUPERVGUI_Main::chooseData") + if (choosing) { + QString id = ((QAD_ObjectBrowserItem*)item)->getEntry(); + if (!id.isEmpty()) { + SALOMEDS::SObject_var object = study->getStudyDocument()->FindObjectID(id.latin1()); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + Standard_CString ior = ""; + if (object->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + ior = anIOR->Value(); + portIn->setValue(ior); + + // stop selection + choosing = false; + setCursor(Supervision.getCursor()); + objectBrowser->setCursor(Supervision.getCursor()); + Supervision.putInfo(""); + } + } + } +} + +void SUPERVGUI_Main::setData(SUPERVGUI_PortIn* p) { + Trace("SUPERVGUI_Main::setData") + portIn = p; + choosing = true; + setCursor(forbiddenCursor); + objectBrowser->setCursor(pointingHandCursor); + Supervision.putInfo(tr("MSG_CHOOSE_DATA")); +} + +SALOMEDS::SObject_var SearchOrCreateSOWithName(const SALOMEDS::Study_var theStudy, + const SALOMEDS::SObject_var theSO, + const char* theName, + QAD_Operation* theOperation, + bool* theStarted) { + SALOMEDS::SObject_var aResult; + SALOMEDS::AttributeName_var aName; + SALOMEDS::GenericAttribute_var anAttr; + if (!*theStarted) { // optimisation + SALOMEDS::ChildIterator_var anIterator = theStudy->NewChildIterator(theSO); + for (; anIterator->More(); anIterator->Next()) { + if (anIterator->Value()->FindAttribute(anAttr, "AttributeName")) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + if (strcmp(aName->Value(), theName) == 0) { + aResult = anIterator->Value(); + break; + } + } + } + } + if (!aResult->_is_nil()) return aResult; + // add new SObject + if (!*theStarted) { + *theStarted = true; + theOperation->start(); + } + SALOMEDS::StudyBuilder_var aBuilder = theStudy->NewBuilder(); + aResult = aBuilder->NewObject(theSO); + anAttr = aBuilder->FindOrCreateAttribute(aResult, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(theName); + return aResult; +} + +bool SUPERVGUI_Main::putDataStudy(SUPERV_Port p, const char* inout) { + Trace("SUPERVGUI_Main::putDataStudy"); + + static bool isIn = false; + if (isIn) return true; else isIn = true; + + SALOMEDS::Study_var aStudy = study->getStudyDocument(); + SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIORAttr; + SALOMEDS::AttributePixMap_var aPixmap; + bool aTransaction = false; + bool aLocked = aStudy->GetProperties()->IsLocked(); + QAD_Operation* op = new SALOMEGUI_ImportOperation( study ); + + // searching dataflow + SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR(dataflow->getIOR()); + if (aSO->_is_nil()) { // create new dataflow SObject + SALOMEDS::SComponent_ptr aComponent = aStudy->FindComponent(STUDY_SUPERVISION); + if (aComponent->_is_nil()) { // is supervision component not found, then create it + QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study ); + anOperation->start(); + if (aLocked) aStudy->GetProperties()->SetLocked(false); + aComponent = aBuilder->NewComponent(STUDY_SUPERVISION); + anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(STUDY_SUPERVISION); + + anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" ); + aBuilder->DefineComponentInstance(aComponent, *Supervision.getEngine()); + if (aLocked) aStudy->GetProperties()->SetLocked(true); + anOperation->finish(); + } + aTransaction = true; + op->start(); + aSO = aBuilder->NewObject(aComponent); + anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(dataflow->Name()); + anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR"); + anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr); + anIORAttr->SetValue(dataflow->getIOR()); + } + aSO = SearchOrCreateSOWithName(aStudy, aSO, // get run time SO + QString("Run ") + myRunTime.toString() , op, &aTransaction); + aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Node()->Name(), op, &aTransaction); // get node SO + aSO = SearchOrCreateSOWithName(aStudy, aSO, inout, op, &aTransaction); // get in/out SO + aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Name(), op, &aTransaction); // get port SO + + if (aLocked) { + if (aTransaction) op->finish(); + isIn = false; + return false; + } + + anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR"); + anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr); + if (!aTransaction && strcmp(anIORAttr->Value(), p->ToString()) == 0) { + isIn = false; + return true; + } + // set object value to the study: if object is external, then put it with + // help of the specific component - owner + if (p->IsIOR()) { + // get according component driver for result object + SALOME_LifeCycleCORBA aLCC(myNService); + SUPERV_FNode aFNode = SUPERV::FNode::_narrow(p->Node()); + if (!aFNode->_is_nil()) { + Engines::Component_var aComponent = aLCC.FindOrLoad_Component(aFNode->GetContainer(), + aFNode->GetComponentName()); + SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aComponent); + if (!CORBA::is_nil(aDriver)) { // if driver was found, publish object + CORBA::Object_ptr anObject = new CORBA::Object(); + CORBA::Any* anAny = p->ToAny(); + (*anAny) >>= anObject; + + if (aDriver->CanPublishInStudy(anObject)) { + SALOMEDS::SObject_var aTmpSO; + if (!aTransaction) { + aTmpSO = aSO; + aTransaction = true; + op->start(); + } + aTmpSO = aDriver->PublishInStudy(aStudy, aTmpSO, anObject, ""); + aBuilder->Addreference(aSO, aTmpSO); + } else { // can't publish object: abort transaction + if (aTransaction) op->abort(); + isIn = false; + return false; + } + } + } + } else { + if (!aTransaction) { + aTransaction = true; + op->start(); + } + anIORAttr->SetValue(p->ToString()); // ior attribute already set for the prevoius condition + } + + if (aTransaction) op->finish(); + study->updateObjBrowser(); + isIn = false; + return true; +} + + +void SUPERVGUI_Main::ActivatePanning() +{ + if (graph->isVisible()) { + graph->ActivatePanning(); + } else if (array->isVisible()) { + array->ActivatePanning(); + } +} + + +void SUPERVGUI_Main::ResetView() +{ + if (graph->isVisible()) { + graph->ResetView(); + } else if (array->isVisible()) { + array->ResetView(); + } +} + + +void SUPERVGUI_Main::setAsFromStudy(bool theToStudy) { + myIsFromStudy = theToStudy; + graph->setAsFromStudy(theToStudy); + array->setAsFromStudy(theToStudy); +} + +void SUPERVGUI_Main::checkIsInStudy() { + if (!myIsFromStudy) return; + + SALOMEDS::Study_var aStudyDoc = study->getStudyDocument(); + SALOMEDS::SComponent_var aFatherLbl = aStudyDoc->FindComponent(STUDY_SUPERVISION); + SALOMEDS::ChildIterator_var aChildIterator = aStudyDoc->NewChildIterator(aFatherLbl); + SALOMEDS::SObject_var aDataflowLbl; + SALOMEDS::GenericAttribute_var anAttr; + + for (; aChildIterator->More(); aChildIterator->Next()) { + aDataflowLbl = aChildIterator->Value(); + if (!aDataflowLbl->FindAttribute(anAttr, "AttributeIOR")) + continue; + + SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + if (strcmp(anIOR->Value(), dataflow->getIOR()) == 0) return; + } + // This Graph considered as in study but in study it is not exists + Supervision.unregisterGraph(this); + setAsFromStudy(false); +} + +void SUPERVGUI_Main::syncNotification() { + char* graph; + char* node; + char* type; + char* message; + char* sender; + long counter; + char* date; + long stamp; + + while (notification->Receive(&graph, &node, &type, &message, &sender, &counter, &date, &stamp)) { + if (isFiltered(graph, node, type, message, sender, counter, date, stamp)) { + QString mess(""); + mess += "NOTIF: "; mess += graph; + mess += " / " ; mess += node; + mess += " / " ; mess += type; + mess += " / " ; mess += message; + getMessage()->setMessage(mess.latin1()); + }; + }; +} + +bool SUPERVGUI_Main::isFiltered(char* graph, char* node, char* type, char* message, + char* sender, long counter, char* date, long stamp) { + Trace("SUPERVGUI_Main::isFiltered"); + bool b = false; + if (strcmp(getDataflow()->Name(), graph) == 0) { + SUPERVGUI_Node* n; + QObjectList* nodes = queryList("SUPERVGUI_Node"); + QObjectListIt i(*nodes); + while ((n=(SUPERVGUI_Node*)i.current()) != 0) { + ++i; + if (strcmp(n->name(), node) == 0) { + if (strcmp(type, NOTIF_WARNING) == 0) { + b = n->isWarning(); + } else if (strcmp(type, NOTIF_STEP) == 0) { + b = n->isStep(); + } else if (strcmp(type, NOTIF_TRACE) == 0) { + b = n->isTrace(); + } else if (strcmp(type, NOTIF_VERBOSE) == 0) { + b = n->isVerbose(); + }; + break; + }; + }; + delete nodes; + if ( myLogged && myLogFile && ( ( !myFiltered ) || b ) ) { + fprintf( myLogFile, "NOTIF %ld\t%s\t%s\t%ld\t%s\t%s\t%s\t%s\n", stamp, date, sender, counter, graph, node, type, message ); + fflush( myLogFile ); + }; + }; + return( b ); +} + + + +void SUPERVGUI_Main::setPaletteBackgroundColor(const QColor& color) { + array->setPaletteBackgroundColor(color); + graph->setPaletteBackgroundColor(color); + + SUPERVGraph_View::setPaletteBackgroundColor(color); +} + diff --git a/src/SUPERVGUI/SUPERVGUI_Main.h b/src/SUPERVGUI/SUPERVGUI_Main.h new file mode 100644 index 0000000..7d3b1d3 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Main.h @@ -0,0 +1,137 @@ +// File : SUPERVGUI_Main.h +// Created : 24 / 10 / 2001 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGUI +// Copyright : CEA + +#ifndef SUPERVGUI_Main_H +#define SUPERVGUI_Main_H + +//#include "SUPERVGUI.h" +#include "SUPERVGraph_ViewFrame.h" +#include "SUPERVGUI_Array.h" +#include "SUPERVGUI_Graph.h" +#include "QAD_Desktop.h" +#include "SUPERVGUI_Port.h" + +class QAD_Study; +class QAD_ObjectBrowser; +class QAD_Message; +class NOTIFICATION_Consumer; + + +class SUPERVGUI_Main: public SUPERVGraph_View { + Q_OBJECT + + public: + SUPERVGUI_Main(SUPERVGraph_ViewFrame*, QAD_Desktop*, bool fromIOR); + SUPERVGUI_Main(SUPERVGraph_ViewFrame*, QAD_Desktop*, bool isModify, const char* filename); + SUPERVGUI_Main(SUPERVGraph_ViewFrame*, QAD_Desktop*, SUPERV_Graph); + virtual ~SUPERVGUI_Main(); + + void run(); + void startExecute(); + void kill(); + void suspendResume(); + void stopRestart(); + bool exportDataflow(QString theFile); + + bool putDataStudy(SUPERV_Port port, const char* inout); + void setData(SUPERVGUI_PortIn* p); + + SUPERVGUI_Graph* getGraph(); + SUPERVGUI_Array* getArray(); + SUPERV_Graph getDataflow(); + QAD_Message* getMessage(); + QAD_Study* getStudy(); + bool isArrayShown(); + void showPopup(QPopupMenu* p, QMouseEvent* e); + + void ActivatePanning(); + void ResetView(); + + void setHashCode(QString theCode) + { myHashCode = theCode; }; + + QString getHashCode() + { return myHashCode; }; + + + bool isEditable() + { if (SUPERV_isNull(dataflow)) return false; + return !dataflow->IsReadOnly(); }; + + bool isFromStudy() { return myIsFromStudy; } + void setAsFromStudy(bool theToStudy); + void checkIsInStudy(); + + void addComputeNode(SUPERV_CNode theNode); + void addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update); + void addGOTONode(SUPERV_CNode theNode); + + void setPaletteBackgroundColor(const QColor& color); + + void lockedGraph(bool theLock) { myIsLocked = theLock; } + bool isLocked() { return myIsLocked; } + + public slots: + void execute(); + void sync(); + void syncAsync(); + bool addStudy(); + void insertFile(); + void addNode(); + void changeInformation(); + void copy(); + void showTable(); + void showFullGraph(); + void showContolFlow(); + void filterNotification(); + + private slots: + void chooseData(QListViewItem* item); + + private: + void init(QAD_Desktop* parent); + void StartTimer(const char* m); + void StopTimer(const char* m); + void syncNotification(); + bool isFiltered(char* graph, char* node, char* type, char* message, char* sender, long counter, char* date, long stamp); + + SUPERV_Graph dataflow; + QAD_Study* study; + QAD_ObjectBrowser* objectBrowser; + QAD_Message* message; + SUPERVGUI_Graph* graph; + QTimer* timer; + + GraphViewType myCurrentView; + SUPERVGUI_Array* array; + + bool choosing; + SUPERVGUI_PortIn* portIn; + + QString myHashCode; + + bool myIsFromStudy; + int myCopyNum; + + SALOME_NamingService* myNService; + QDateTime myRunTime; // mpv 23.12.2002: we need time of running of dataflow + // for right Study document modification + /* notification data */ + NOTIFICATION_Consumer* notification; + bool myFiltered; + bool myLogged; + QString myLogFileName; + FILE* myLogFile; + bool myWarning; + bool myStep; + bool myTrace; + bool myVerbose; + bool myIsKilled; + bool myIsLocked; +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_Node.cxx b/src/SUPERVGUI/SUPERVGUI_Node.cxx new file mode 100644 index 0000000..417170a --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Node.cxx @@ -0,0 +1,473 @@ +using namespace std; +// File : SUPERVGUI_Node.cxx +// Created : 24 / 10 / 2001 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGUI +// Copyright : CEA + +#include "SUPERVGUI_Node.h" +#include "SUPERVGUI_Main.h" +#include "SUPERVGUI_Python.h" +#include "SUPERVGUI.h" +#include "SUPERVGUI_BrowseNodeDlg.h" +#include "SALOMEGUI_NameDlg.h" +#include "SUPERVGUI_Information.h" + +#include +#include +#include +#include +#include +#include + + + +SUPERVGUI_Node::SUPERVGUI_Node(QWidget* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode): + QFrame(theParent, "", WDestructiveClose), + myMain(theMain), + myNode(theNode), + warning(true), + step(true), + trace(true), + verbose(true), + aBrowseDlg(0) +{ + Trace("SUPERVGUI_Node::SUPERVGUI_Node"); + QPalette BackColor = QPalette(MAIN_BACK); + setPalette(BackColor); + + setName(myNode->Name()); + //myTitle = new SUPERVGUI_Label(0, LABEL_WIDTH, LABEL_HEIGHT, name(), QLabel::AlignLeft); + //connect(myTitle, SIGNAL(MousePress(QMouseEvent*)), this, SLOT(showPopup(QMouseEvent*))); + //myTitle->hide(); + + myStatus = new SUPERVGUI_Label(0, LABEL_WIDTH/2, LABEL_HEIGHT, "", QLabel::AlignHCenter); + myTime = new SUPERVGUI_Label(0, LABEL_WIDTH/2, LABEL_HEIGHT, "00:00:00", QLabel::AlignHCenter); + myStatus->hide(); + myTime->hide(); + + connect(myStatus, SIGNAL(MousePress(QMouseEvent*)), this, SLOT(showPopup(QMouseEvent*))); + connect(myTime, SIGNAL(MousePress(QMouseEvent*)), this, SLOT(showPopup(QMouseEvent*))); + + //create common popup + myPopup = new QPopupMenu(this); + if (myMain->isEditable()) { + myRenameItem = myPopup->insertItem(tr("MSG_RENAME"), this, SLOT(rename())); + myDeleteItem = myPopup->insertItem(tr("MSG_DELETE"), this, SLOT(remove())); + mySeparatorId = myPopup->insertSeparator(); + } + myPopup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse())); + myPopup->insertItem(tr("MSG_CHANGE_INFO"), this, SLOT(changeInformation())); + //myPopup->insertItem(tr("MSG_CONFIGURE"), this, SLOT(configure())); + + if (myMain->isEditable() && (getNodeType() != SUPERV::FactoryNode) + && (getNodeType() != SUPERV::ComputingNode)) { + if ((getNodeType() != SUPERV::EndLoopNode)) { + QPopupMenu* aAddPortMnu = new QPopupMenu(this); + aAddPortMnu->insertItem("Input", this, SLOT(addInputPort())); + if (getNodeType() != SUPERV::LoopNode) + aAddPortMnu->insertItem("Output", this, SLOT(addOutputPort())); + + myPopup->insertSeparator(); + if ((getNodeType() != SUPERV::EndSwitchNode)) + myPopup->insertItem("Edit Function", this, SLOT(editFunction())); + myPopup->insertItem("Add Port", aAddPortMnu); + } + } + + // create execution popup + myRunPopup = new QPopupMenu(this); + mySuspendItem = myRunPopup->insertItem(tr("MSG_SUSPEND"), this, SLOT(suspendResume())); + myKillItem = myRunPopup->insertItem(tr("MSG_KILL"), this, SLOT(kill())); + //myStopItem = myRunPopup->insertItem(tr("MSG_STOP"), this, SLOT(stopRestart())); + + setState(myNode->State()); +} + +SUPERVGUI_Node::~SUPERVGUI_Node() +{ + Trace("SUPERVGUI_Node::~SUPERVGUI_Node") +} + + +void SUPERVGUI_Node::sync() { + setState(myNode->State()); +} + + +void SUPERVGUI_Node::setState(SUPERV::GraphState theState) +{ + MESSAGE("NodeState="<changeItem(mySuspendItem, tr("MSG_SUSPEND")); + myRunPopup->setItemEnabled(mySuspendItem, true); + myRunPopup->setItemEnabled(myStopItem, false); + + switch (theState) { + case SUPERV_Waiting: + myStatus->setText("Waiting"); + myStatus->setPaletteBackgroundColor(QColor(35, 192, 255)); + break; + case SUPERV_Running: + myStatus->setText("Running"); + myStatus->setPaletteBackgroundColor(QColor(32,210,32)); + myRunPopup->changeItem(myStopItem, tr("MSG_STOP")); + myRunPopup->setItemEnabled(myStopItem, true); + break; + case SUPERV_Suspend: + case SUPERV::SuspendReadyState: + myStatus->setText("Suspended"); + myStatus->setPaletteBackgroundColor(QColor(255,180, 0)); + myRunPopup->changeItem(mySuspendItem, tr("MSG_RESUME")); + break; + case SUPERV_Done: + myStatus->setText("Finished"); + myStatus->setPaletteBackgroundColor(QColor(255, 158, 255)); + myRunPopup->setItemEnabled(mySuspendItem, false); + myRunPopup->changeItem(myStopItem, tr("MSG_RESTART")); + myRunPopup->setItemEnabled(myStopItem, true); + break; + case SUPERV_Error: + myStatus->setText("Aborted"); + myStatus->setPaletteBackgroundColor(red); + myRunPopup->setItemEnabled(mySuspendItem, false); + myRunPopup->changeItem(myStopItem, tr("MSG_RESTART")); + myRunPopup->setItemEnabled(myStopItem, true); + break; + case SUPERV_Kill: + myStatus->setText("Killed"); + myStatus->setPaletteBackgroundColor(red); + myRunPopup->setItemEnabled(mySuspendItem, false); + myRunPopup->changeItem(myStopItem, tr("MSG_RESTART")); + myRunPopup->setItemEnabled(myStopItem, true); + break; + default: + //cout<<"### Node state = "<setText("No Status"); + myStatus->setPaletteBackgroundColor(QColor(NODE_RED, NODE_GREEN, NODE_BLUE)); + myRunPopup->setItemEnabled(mySuspendItem, false); + break; + } + myTime->setPaletteBackgroundColor(myStatus->paletteBackgroundColor()); + int sec = 0; //myNode->getTime(); + // sec++; + char hms[9]; + int s = sec/3600; + hms[0]=(char)(((s/10)%10)+48); + hms[1]=(char)((s%10)+48); + hms[2]=':'; + sec = sec%3600; + s = sec/60; + hms[3]=(char)((s/10)+48); + hms[4]=(char)((s%10)+48); + hms[5]=':'; + sec = sec%60; + hms[6]=(char)((sec/10)+48); + hms[7]=(char)((sec%10)+48); + hms[8]='\0'; + myTime->setText(hms); +} + +void SUPERVGUI_Node::rename() +{ + QString nm = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), myNode->Name() ); + if ( !nm.isEmpty() ) { + setNodeName(nm); + } +} + + +void SUPERVGUI_Node::remove() { + Trace("SUPERVGUI_Node::remove"); + deleteLinks(); + myNode->destroy(); + myMain->getGraph()->deleteNode(this); +} + +void SUPERVGUI_Node::suspendResume() { + Trace("SUPERVGUI_Node::suspendResume"); + int n = queryList("SUPERVGUI_Node")->count(); + if (myNode->IsSuspended()) { + if (!((n==1)? myMain->getDataflow()->Resume() : myNode->Resume())) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESUMENODE")); + } + } else { + if (!((n==1)? myMain->getDataflow()->Suspend() : myNode->Suspend())) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_SUSPENDNODE")); + } else { + myStatus->setPaletteBackgroundColor(QColor(255,180, 0)); + myTime->setPaletteBackgroundColor(QColor(255,180, 0)); + } + } +} + +void SUPERVGUI_Node::kill() { + Trace("SUPERVGUI_Node::kill"); + int n = queryList("SUPERVGUI_Node")->count(); + if (!((n==1)? myMain->getDataflow()->Kill() : myNode->Kill())) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_KILLNODE")); + } else { + myStatus->setPaletteBackgroundColor(Qt::red); + myTime->setPaletteBackgroundColor(Qt::red); + } +} + +void SUPERVGUI_Node::stopRestart() { + Trace("SUPERVGUI_Node::stopRestart"); + + int n = queryList("SUPERVGUI_Node")->count(); + if ((myNode->State() == SUPERV_Stop) || (myNode->State() == SUPERV_Kill)) { + if (!((n==1)? myMain->getDataflow()->Run() : myNode->ReStart())) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESTARTNODE")); + } + } else { + if (!((n==1)? myMain->getDataflow()->Stop() : myNode->Stop())) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_STOPNODE")); + } + } +} + +void SUPERVGUI_Node::changeInformation() { + SUPERVGUI_Information* aDlg = new SUPERVGUI_Information(myNode, !myMain->isEditable()); + if (aDlg->exec() ) + sync(); + delete aDlg; + /* Trace("SUPERVGUI_Node::changeInformation") + if (Supervision.information(myNode, !myMain->isEditable())) { + myMain->syncAsync(); + };*/ +} + +void SUPERVGUI_Node::configure() { + Trace("SUPERVGUI_Node::configure") + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_NOT_IMPLEMENTED")); // kloss : a faire : lancer l'ihm DATA +} + +void SUPERVGUI_Node::showPython() { + Trace("SUPERVGUI_Node::showPython") + SUPERVGUI_Python cp(myMain->getStudy()->get_PyInterp(), !myMain->isEditable()); + cp.exec(); +} + +void SUPERVGUI_Node::showPopup(QMouseEvent* e) { + Trace("SUPERVGUI_Node::showPopup"); + if (myMain->getDataflow()->IsExecuting()) + myMain->showPopup(myRunPopup, e); + else + myMain->showPopup(myPopup, e); +} + + +void SUPERVGUI_Node::mousePressEvent(QMouseEvent* e) { + myMain->showPopup(myPopup, e); +} + + +bool SUPERVGUI_Node::isWarning() { + Trace("SUPERVGUI_Node::isWarning") + return(warning); +} + +bool SUPERVGUI_Node::isStep() { + Trace("SUPERVGUI_Node::isStep") + return(step); +} + +bool SUPERVGUI_Node::isTrace() { + Trace("SUPERVGUI_Node::isTrace") + return(trace); +} + +bool SUPERVGUI_Node::isVerbose() { + Trace("SUPERVGUI_Node::isVerbose") + return(verbose); +} + +void SUPERVGUI_Node::setWarning(bool b) { + Trace("SUPERVGUI_Node::setWarning") + warning = b; +} + +void SUPERVGUI_Node::setStep(bool b) { + Trace("SUPERVGUI_Node::setStep") + step = b; +} + +void SUPERVGUI_Node::setTrace(bool b) { + Trace("SUPERVGUI_Node::setTrace") + trace = b; +} + +void SUPERVGUI_Node::setVerbose(bool b) { + Trace("SUPERVGUI_Node::setVerbose") + verbose = b; +} + + +void SUPERVGUI_Node::browse() { + if ( !aBrowseDlg ) { + aBrowseDlg = new SUPERVGUI_BrowseNodeDlg(this); + aBrowseDlg->installEventFilter( this ); + } + if ( !aBrowseDlg->isVisible() ) + aBrowseDlg->show(); + else { + aBrowseDlg->raise(); + aBrowseDlg->setActiveWindow(); + aBrowseDlg->setFocus(); + } +} + +bool SUPERVGUI_Node::eventFilter( QObject* o, QEvent* e ) +{ + if ( o == aBrowseDlg && e->type() == QEvent::Close ) + aBrowseDlg = 0; + return QFrame::eventFilter( o, e ); +} + + +void SUPERVGUI_Node::setNodeName(QString aName) { + if ( myNode->SetName(aName.latin1())) { + setName(myNode->Name()); + //myTitle->setText(aName); + } else + QMessageBox::warning( QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_CANT_RENAMENODE" ) ); +} + + +SUPERV_Port SUPERVGUI_Node::createInPort() { + SUPERVGUI_PortParamsDlg* aDlg = new SUPERVGUI_PortParamsDlg(); + if (aDlg->exec()) { + SUPERV_INode aNode = getInlineNode(); + if (SUPERV_isNull(aNode)) { + MESSAGE("SUPERVGUI_Node::createInPort: Node is wrong type"); + return NULL; + } + SUPERV_Ports aPorts = aNode->Ports(); + for (int i=0; ilength(); i++) { + if (aDlg->getName() == QString(aPorts[i]->Name())){ + QMessageBox::warning(0, tr("ERROR"), tr("MSG_PORT_EXIST")); + return NULL; + } + } + SUPERV_Port aPort = aNode->InPort(aDlg->getName().latin1(), + aDlg->getType().latin1()); + delete aDlg; + return aPort; + } + delete aDlg; + return NULL; +} + + +SUPERV_Port SUPERVGUI_Node::createOutPort() { + SUPERVGUI_PortParamsDlg* aDlg = new SUPERVGUI_PortParamsDlg(); + if (aDlg->exec()) { + SUPERV_INode aNode = getInlineNode(); + if (SUPERV_isNull(aNode)) { + MESSAGE("SUPERVGUI_Node::createInPort: Node is wrong type"); + return NULL; + } + SUPERV_Ports aPorts = aNode->Ports(); + for (int i=0; ilength(); i++) { + if (aDlg->getName() == QString(aPorts[i]->Name())){ + QMessageBox::warning(0, tr("ERROR"), tr("MSG_PORT_EXIST")); + return NULL; + } + } + SUPERV_Port aPort = aNode->OutPort(aDlg->getName().latin1(), + aDlg->getType().latin1()); + delete aDlg; + return aPort; + } + delete aDlg; + return NULL; +} + + + +void SUPERVGUI_Node::addInputPort() { + createInPort(); +} + + +void SUPERVGUI_Node::addOutputPort() { + createOutPort(); +} + + +void SUPERVGUI_Node::editFunction() { + if (getNodeType() == SUPERV::LoopNode) { + SUPERVGUI_EditPythonDlg* aDlg = new SUPERVGUI_EditPythonDlg(true); + SUPERV_LNode aLNode = getLoopNode(); + aDlg->setInitFunction(aLNode->PyInit()); + aDlg->setMoreFunction(aLNode->PyMore()); + aDlg->setNextFunction(aLNode->PyNext()); + if (aDlg->exec()) { + aLNode->SetPyInit(aDlg->getInitFuncName().latin1(), (aDlg->getInitFunction()).in()); + aLNode->SetPyMore(aDlg->getMoreFuncName().latin1(), (aDlg->getMoreFunction()).in()); + aLNode->SetPyNext(aDlg->getNextFuncName().latin1(), (aDlg->getNextFunction()).in()); + } + delete aDlg; + } else { + SUPERVGUI_EditPythonDlg* aDlg = new SUPERVGUI_EditPythonDlg(); + SUPERV_INode aINode = getInlineNode(); + aDlg->setFunction(aINode->PyFunction()); + if (aDlg->exec()) { + aINode->SetPyFunction(aDlg->getFuncName().latin1(), (aDlg->getFunction()).in()); + } + delete aDlg; + } +} + + + + + + +/*! + * Port parameters dialog definition + */ + +SUPERVGUI_PortParamsDlg::SUPERVGUI_PortParamsDlg() + : QDialog(QAD_Application::getDesktop(), 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setSizeGripEnabled( true ); + setCaption("Port parameters"); + + QGridLayout* aBaseLayout = new QGridLayout( this ); + aBaseLayout->setMargin( 11 ); aBaseLayout->setSpacing( 6 ); + + QLabel* aNameLbl = new QLabel("Port Name", this ); + aBaseLayout->addWidget(aNameLbl, 0, 0); + + myNameTxt = new QLineEdit( this ); + aNameLbl->setBuddy( myNameTxt ); + aBaseLayout->addWidget(myNameTxt, 0, 1); + + QLabel* aTypeLbl = new QLabel("Value Type", this ); + aBaseLayout->addWidget(aTypeLbl, 1, 0); + + myTypeTxt = new QLineEdit( this ); + aTypeLbl->setBuddy( myTypeTxt ); + aBaseLayout->addWidget(myTypeTxt, 1, 1); + + QGroupBox* aBtnBox = new QGroupBox( this ); + aBtnBox->setColumnLayout( 0, Qt::Vertical ); + aBtnBox->layout()->setSpacing( 0 ); aBtnBox->layout()->setMargin( 0 ); + QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() ); + aBtnLayout->setAlignment( Qt::AlignTop ); + aBtnLayout->setSpacing( 6 ); aBtnLayout->setMargin( 11 ); + + aBaseLayout->addMultiCellWidget( aBtnBox, 2, 2, 0, 1 ); + + QPushButton* aOKBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox ); + connect( aOKBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); + aBtnLayout->addWidget( aOKBtn ); + + aBtnLayout->addStretch(); + + QPushButton* aCancelBtn = new QPushButton( tr("BUT_CANCEL"), aBtnBox ); + connect( aCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + aBtnLayout->addWidget( aCancelBtn ); +} diff --git a/src/SUPERVGUI/SUPERVGUI_Node.h b/src/SUPERVGUI/SUPERVGUI_Node.h new file mode 100644 index 0000000..7f60bbe --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Node.h @@ -0,0 +1,152 @@ +// File : SUPERVGUI_Node.h +// Created : 24 / 10 / 2001 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGUI +// Copyright : CEA + +#ifndef SUPERVGUI_Node_H +#define SUPERVGUI_Node_H + +using namespace std; +#include "SUPERVGUI_Def.h" +#include "SUPERVGUI_Label.h" +#include +#include "SUPERVGUI_BrowseNodeDlg.h" + +class SUPERVGUI_Main; + +class SUPERVGUI_Node: public QFrame { + Q_OBJECT + + public: + SUPERVGUI_Node(QWidget* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode); + virtual ~SUPERVGUI_Node(); + + bool eventFilter( QObject* o, QEvent* e ); + virtual void sync(); + + virtual void hideAll()=0; + virtual void showAll()=0; + virtual void deleteLinks() {}; + virtual void setNodeName(QString aName); + + SUPERV_CNode getEngine() + { return myNode; }; + + SUPERVGUI_Main* getMain() + { return myMain; }; + + bool isWarning(); + bool isStep(); + bool isTrace(); + bool isVerbose(); + + SUPERV::KindOfNode getNodeType() + { return myNode->Kind(); } + + SUPERV_CNode getComputingNode() + { return myNode; } + + SUPERV_FNode getFactoryNode() + { return SUPERV::FNode::_narrow(myNode); } + + SUPERV_INode getInlineNode() + { return SUPERV::INode::_narrow(myNode); } + + SUPERV_GNode getGotoNode() + { return SUPERV::GNode::_narrow(myNode); } + + SUPERV_LNode getLoopNode() + { return SUPERV::LNode::_narrow(myNode); } + + SUPERV_ELNode getEndLoopNode() + { return SUPERV::ELNode::_narrow(myNode); } + + SUPERV_SNode getSwitchNode() + { return SUPERV::SNode::_narrow(myNode); } + + SUPERV_ESNode getEndSwitchNode() + { return SUPERV::ESNode::_narrow(myNode); } + + + SUPERV_Port createInPort(); + SUPERV_Port createOutPort(); + + protected: + void mousePressEvent(QMouseEvent* e); + + public slots: + void suspendResume(); + void kill(); + void stopRestart(); + void configure(); + void showPython(); + + virtual void rename(); + virtual void remove(); + void changeInformation(); + void browse(); + + void setWarning(bool b); + void setStep(bool b); + void setTrace(bool b); + void setVerbose(bool b); + void showPopup(QMouseEvent* e); + + virtual void addInputPort(); + virtual void addOutputPort(); + virtual void editFunction(); + + protected: + virtual void setState(SUPERV::GraphState theState); + + SUPERV_CNode myNode; + SUPERVGUI_Main* myMain; + + //SUPERVGUI_Label* myTitle; + SUPERVGUI_Label* myTime; + SUPERVGUI_Label* myStatus; + + QPopupMenu* myPopup; + QPopupMenu* myRunPopup; + int myKillItem; + int mySuspendItem; + int myStopItem; + int myRenameItem; + int myDeleteItem; + int mySeparatorId; + + SUPERVGUI_BrowseNodeDlg* aBrowseDlg; + + private: + + bool warning; + bool step; + bool trace; + bool verbose; +}; + + + +/*! + * Port parameters dialog definition + */ +class SUPERVGUI_PortParamsDlg: public QDialog { + Q_OBJECT + + public: + SUPERVGUI_PortParamsDlg(); + ~SUPERVGUI_PortParamsDlg() {}; + + QString getName() { return myNameTxt->text(); } + QString getType() { return myTypeTxt->text(); } + + private: + QLineEdit* myNameTxt; + QLineEdit* myTypeTxt; +}; + + + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_Notification.cxx b/src/SUPERVGUI/SUPERVGUI_Notification.cxx new file mode 100644 index 0000000..05e8293 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Notification.cxx @@ -0,0 +1,313 @@ +using namespace std; +// File : SUPERVGUI_Notification.cxx +// Created : 21 / 02 / 2002 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGUI +// Copyright : CEA + +#include "SUPERVGUI_Notification.h" +#include "QAD_Message.h" +#include "QAD_FileDlg.h" +#include "SUPERVGUI_Node.h" +#include "SUPERVGUI_Main.h" +#include "NOTIFICATION.hxx" +#include +#include +#include + +#define SPACING_SIZE 6 +#define MARGIN_SIZE 11 +#define MAX( x, y ) ( x ) > ( y ) ? ( x ) : ( y ) +#define DLG_SIZE_WIDTH 300 +#define DLG_SIZE_HEIGHT 300 + +/****************************************** + * Notification settings dialog box + ******************************************/ +/*! + Constructor +*/ +SUPERVGUI_Notification::SUPERVGUI_Notification( SUPERVGUI_Main* m ) + : QDialog( QAD_Application::getDesktop(), "", TRUE, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), + myMain( m ) +{ + setCaption( tr( "TLT_FILTER_NOTIFY" ) ); + setSizeGripEnabled( TRUE ); + QVBoxLayout* topLayout = new QVBoxLayout( this ); + topLayout->setSpacing( SPACING_SIZE ); + topLayout->setMargin( MARGIN_SIZE ); + + /* Creating notofication widgets*/ + /* Top scroll view */ + myView = new QScrollView( this ); +// myView->setMinimumSize( NOTIFICATION_WIDTH, NOTIFICATION_HEIGHT ); + myBox = new QVBox( myView ); + myBox->setMargin( MARGIN_SIZE ); + myBox->setSpacing( SPACING_SIZE ); + QFrame* lin; + + /* Notification logging */ + QLabel* logg = new QLabel( tr( "NOTIFICATION_LOGGING_LBL" ), myBox ); + QFont fnt = logg->font(); fnt.setBold( true ); logg->setFont( fnt ); + QWidget* dumb = new QWidget( myBox ); + QHBoxLayout* dumbLayout = new QHBoxLayout( dumb ); dumbLayout->setMargin( 0 ); dumbLayout->setSpacing( SPACING_SIZE ); + myLogCheck = new QCheckBox( tr( "SAVE_LOG_LBL" ), dumb ); + myFileEdit = new QLineEdit( dumb ); + myFileEdit->setMinimumSize( 200, 0 ); + myBrowseBtn = new QPushButton( tr( "BUT_BROWSE"), dumb ); + dumbLayout->addWidget( myLogCheck ); + dumbLayout->addWidget( myFileEdit ); + dumbLayout->addWidget( myBrowseBtn ); + myFilterCheck = new QCheckBox( tr( "FILTER_LOG_LBL" ), myBox ); + + lin = new QFrame( myBox ); + lin->setFrameStyle( QFrame::HLine | QFrame::Plain ); + + /* dataflow notification */ + myMainNotif = new SUPERVGUI_NotifWidget( myBox, QString( myMain->getDataflow()->Name() ) ); + myMainNotif->setWarning( false ); + myMainNotif->setStep( false ); + myMainNotif->setTrace( false ); + myMainNotif->setVerbose( false ); + + /* nodes notification */ + QObjectList* ihmList = myMain->getGraph()->queryList( "SUPERVGUI_Node" ); + QObjectListIt i( *ihmList ); + SUPERVGUI_Node* theNode; + while ( ( theNode = ( ( SUPERVGUI_Node* )i.current() ) ) != 0) { + lin = new QFrame( myBox ); + lin->setFrameStyle( QFrame::HLine | QFrame::Plain ); + + SUPERVGUI_NotifWidget* nw = new SUPERVGUI_NotifWidget( myBox, theNode ); + nw->setWarning( theNode->isWarning() ); + nw->setStep( theNode->isStep() ); + nw->setTrace( theNode->isTrace() ); + nw->setVerbose( theNode->isVerbose() ); + myNotifList.append( nw ); + ++i; + }; + delete ihmList; + + QWidget* dumb1 = new QWidget( myBox ); + myBox->setStretchFactor( dumb1, 10 ); + + myView->addChild( myBox, 0, 0 ); + myView->setResizePolicy( QScrollView::AutoOneFit ); + + int w = myLogCheck->sizeHint().width() + myFileEdit->minimumSize().width() + myBrowseBtn->sizeHint().width() + SPACING_SIZE * 2; + w = MAX( w, logg->sizeHint().width() ); + w = MAX( w, myMainNotif->sizeHint().width() ); + w = MAX( w, myFilterCheck->sizeHint().width() ); + myView->setMinimumWidth( w + MARGIN_SIZE * 4 ); + + /* OK/Cancel buttons */ + QGroupBox* GroupButtons = new QGroupBox( this ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); GroupButtons->layout()->setMargin( 0 ); + QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( SPACING_SIZE ); + GroupButtonsLayout->setMargin( MARGIN_SIZE ); + myOkBtn = new QPushButton( tr( "BUT_OK" ), GroupButtons, "buttonOk" ); + myOkBtn->setAutoDefault( TRUE ); + myOkBtn->setDefault( TRUE ); + GroupButtonsLayout->addWidget( myOkBtn ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons, "buttonCancel" ); + myCancelBtn->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( myCancelBtn ); + + topLayout->addWidget( myView ); + topLayout->addWidget( GroupButtons ); + + connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + connect( myLogCheck, SIGNAL( clicked() ), this, SLOT( loggedClicked() ) ); + connect( myBrowseBtn, SIGNAL( clicked() ), this, SLOT( browseClicked() ) ); + + QString file = QString( "/tmp/Notif_" ); + file += myMain->getDataflow()->Name(); + file += ".log"; + myFileEdit->setText( file ); + + loggedClicked(); + resize( MAX( w + MARGIN_SIZE * 4, DLG_SIZE_WIDTH ), DLG_SIZE_HEIGHT ); +} + +/*! + Destructor +*/ +SUPERVGUI_Notification::~SUPERVGUI_Notification() +{ +} + +/*! + button slot +*/ +void SUPERVGUI_Notification::accept() +{ + Trace("SUPERVGUI_Notification::accept"); + for ( int i = 0; i < myNotifList.count(); i++ ) { + if ( myNotifList.at( i )->getNode() ) { + myNotifList.at( i )->getNode()->setWarning( myNotifList.at( i )->getWarning() ); + myNotifList.at( i )->getNode()->setStep( myNotifList.at( i )->getStep() ); + myNotifList.at( i )->getNode()->setTrace( myNotifList.at( i )->getTrace() ); + myNotifList.at( i )->getNode()->setVerbose( myNotifList.at( i )->getVerbose() ); + } + } + QDialog::accept(); +} + +/*! + button slot +*/ +void SUPERVGUI_Notification::reject() +{ + Trace("SUPERVGUI_Notification::reject"); + QDialog::reject(); +} + +/*! + Called when check box is clicked +*/ +void SUPERVGUI_Notification::loggedClicked() +{ + myFileEdit->setEnabled( myLogCheck->isChecked() ); + myBrowseBtn->setEnabled( myLogCheck->isChecked() ); + myFilterCheck->setEnabled( myLogCheck->isChecked() ); +} + +/*! + button slot +*/ +void SUPERVGUI_Notification::browseClicked() +{ + QString fn = QAD_FileDlg::getFileName( this, + myFileEdit->text(), + tr( "ALL_FILES" ), + tr( "CHOOSE_LOG_FILES_TLT" ), + false ); + if ( !fn.isEmpty() ) + myFileEdit->setText( fn ); +} + +/*! + Set/get methods +*/ +bool SUPERVGUI_Notification::getLogged() +{ + return myLogCheck->isChecked(); +} +void SUPERVGUI_Notification::setLogged( bool on, QString logFile ) +{ + myLogCheck->setChecked( on ); + if ( !logFile.isNull() ) { + myFileEdit->setText( logFile ); + myFileEdit->home( false ); + } + loggedClicked(); +} +QString SUPERVGUI_Notification::getLogFile() +{ + return myFileEdit->text().stripWhiteSpace(); +} +bool SUPERVGUI_Notification::getFiltered() +{ + return myFilterCheck->isChecked(); +} +void SUPERVGUI_Notification::setFiltered( bool on ) +{ + myFilterCheck->setChecked( on ); +} +bool SUPERVGUI_Notification::getWarning() +{ + return myMainNotif->getWarning(); +} +void SUPERVGUI_Notification::setWarning( bool on ) +{ + myMainNotif->setWarning( on ); +} +bool SUPERVGUI_Notification::getStep() +{ + return myMainNotif->getStep(); +} +void SUPERVGUI_Notification::setStep( bool on ) +{ + myMainNotif->setStep( on ); +} +bool SUPERVGUI_Notification::getTrace() +{ + return myMainNotif->getTrace(); +} +void SUPERVGUI_Notification::setTrace( bool on ) +{ + myMainNotif->setTrace( on ); +} +bool SUPERVGUI_Notification::getVerbose() +{ + return myMainNotif->getVerbose(); +} +void SUPERVGUI_Notification::setVerbose( bool on ) +{ + myMainNotif->setVerbose( on ); +} + +/****************************************** + * Widget containing title and checkboxes + ******************************************/ +/*! + Constructor +*/ +SUPERVGUI_NotifWidget::SUPERVGUI_NotifWidget( QWidget* parent, SUPERVGUI_Node* n ) + : QWidget( parent ), myNode ( n ) +{ + init(); +} +/*! + Another constructor +*/ +SUPERVGUI_NotifWidget::SUPERVGUI_NotifWidget( QWidget* parent, QString title ) + : QWidget( parent ), myNode ( 0 ), myTitle( title ) +{ + init(); +} +/*! + Destructor +*/ +SUPERVGUI_NotifWidget::~SUPERVGUI_NotifWidget() +{ +} +/*! + Creates widget's layout +*/ +void SUPERVGUI_NotifWidget::init() +{ + QGridLayout* topLayout = new QGridLayout( this ); + topLayout->setMargin( 0 ); + topLayout->setSpacing( SPACING_SIZE ); + + QLabel* tltLab = new QLabel( this ); + if ( myNode ) + tltLab->setText( myNode->name() ); + else + tltLab->setText( myTitle ); + QFont fnt = tltLab->font(); fnt.setBold( true ); tltLab->setFont( fnt ); + + myWarningCheck = new QCheckBox( tr( NOTIF_WARNING ), this ); + myStepCheck = new QCheckBox( tr( NOTIF_STEP ), this ); + myTraceCheck = new QCheckBox( tr( NOTIF_TRACE ), this ); + myVerboseCheck = new QCheckBox( tr( NOTIF_VERBOSE ), this ); + + topLayout->addMultiCellWidget( tltLab, 0, 0, 0, 4 ); + topLayout->addWidget( myWarningCheck, 1, 1 ); + topLayout->addWidget( myStepCheck, 1, 2 ); + topLayout->addWidget( myTraceCheck, 1, 3 ); + topLayout->addWidget( myVerboseCheck, 1, 4 ); + topLayout->addColSpacing( 0, 15 ); + topLayout->setColStretch( 1, 5 ); + topLayout->setColStretch( 2, 5 ); + topLayout->setColStretch( 3, 5 ); + topLayout->setColStretch( 4, 5 ); +} + diff --git a/src/SUPERVGUI/SUPERVGUI_Notification.h b/src/SUPERVGUI/SUPERVGUI_Notification.h new file mode 100644 index 0000000..3c5f93a --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Notification.h @@ -0,0 +1,104 @@ +// File : SUPERVGUI_Notification.h +// Created : 21 / 02 / 2002 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGUI +// Copyright : CEA + +#ifndef SUPERVGUI_Notification_H +#define SUPERVGUI_Notification_H + +using namespace std; +#include "SUPERVGUI_Def.h" +#include +#include +#include +#include +#include +#include + +class SUPERVGUI_Main; +class SUPERVGUI_Node; +class SUPERVGUI_NotifWidget; + +class SUPERVGUI_Notification: public QDialog +{ + Q_OBJECT + +public: + SUPERVGUI_Notification(SUPERVGUI_Main* m); + ~SUPERVGUI_Notification(); + + bool getLogged(); + void setLogged( bool on, QString logFile = QString::null ); + QString getLogFile(); + bool getFiltered(); + void setFiltered( bool on ); + bool getWarning(); + void setWarning( bool on ); + bool getStep(); + void setStep( bool on ); + bool getTrace(); + void setTrace( bool on ); + bool getVerbose(); + void setVerbose( bool on ); + +private slots: + void accept(); + void reject(); + void loggedClicked(); + void browseClicked(); + +private: + SUPERVGUI_Main* myMain; + QScrollView* myView; + QVBox* myBox; + QPushButton* myOkBtn; + QPushButton* myCancelBtn; + QCheckBox* myLogCheck; + QCheckBox* myFilterCheck; + QLineEdit* myFileEdit; + QPushButton* myBrowseBtn; + SUPERVGUI_NotifWidget* myMainNotif; + QList myNotifList; +}; + +class SUPERVGUI_NotifWidget : public QWidget +{ +public: + SUPERVGUI_NotifWidget( QWidget* parent, SUPERVGUI_Node* n ); + SUPERVGUI_NotifWidget( QWidget* parent, QString title ); + ~SUPERVGUI_NotifWidget(); + + SUPERVGUI_Node* getNode() { return myNode; } + + bool getWarning() { return myWarningCheck->isChecked(); } + bool getStep() { return myStepCheck->isChecked(); } + bool getTrace() { return myTraceCheck->isChecked(); } + bool getVerbose() { return myVerboseCheck->isChecked(); } + + void setWarning( bool on ) { myWarningCheck->setChecked( on ); } + void setStep( bool on ) { myStepCheck->setChecked( on ); } + void setTrace( bool on ) { myTraceCheck->setChecked( on ); } + void setVerbose( bool on ) { myVerboseCheck->setChecked( on ); } + +private: + void init(); + +private: + QString myTitle; + SUPERVGUI_Node* myNode; + QCheckBox* myWarningCheck; + QCheckBox* myStepCheck; + QCheckBox* myTraceCheck; + QCheckBox* myVerboseCheck; +}; + +#endif + + + + + + + diff --git a/src/SUPERVGUI/SUPERVGUI_Port.cxx b/src/SUPERVGUI/SUPERVGUI_Port.cxx new file mode 100644 index 0000000..2d6d977 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Port.cxx @@ -0,0 +1,501 @@ +using namespace std; +// File : SUPERVGUI_Port.cxx +// Created : 25 / 10 / 2001 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGUI +// Copyright : CEA + +#include "SUPERVGUI_Port.h" +#include "SUPERVGUI_Def.h" +#include "SUPERVGUI_Main.h" +#include "SUPERVGUI_Link.h" +#include "SUPERVGUI.h" +#include "SUPERVGUI_BrowseNodeDlg.h" +#include "QAD_LeftFrame.h" +#include "QAD_ObjectBrowser.h" +#include +#include "SUPERVGUI_GraphNode.h" + + +// Port en general +// --------------- + +SUPERVGUI_Port::SUPERVGUI_Port(QWidget* parent, SUPERVGUI_Main* m, SUPERV_Port p): + SUPERVGUI_Label(parent, PORT_WIDTH, PORT_HEIGHT, "", QLabel::AlignLeft | QLabel::AlignVCenter), + main(m), + port(p) +{ + Trace("SUPERVGUI_Port::SUPERVGUI_Port"); + myName = port->Name(); + QString aName(port->Name()); + aName += (port->IsInput())? "Input":"Output"; + setName(aName); + + if (myName.compare(OUTVOID) == 0) + setAlignment(QLabel::AlignRight | QLabel::AlignVCenter); + + if (port->IsParam() || port->IsInLine()) + setText(myName + "=" + port->ToString()); + else + setText(myName); + + setLineWidth(1); + setMidLineWidth(2); + setFrameShape(QLabel::Box); + setFrameShadow(QLabel::Plain); + + popup = new QPopupMenu(this); + if (main->isEditable()) { + mySketchItem = popup->insertItem(tr("MSG_SKETCH_LINK"), this, SLOT(sketchLink())); + popup->insertSeparator(); + } + if (port->IsInLine()) { + myDelItem = popup->insertItem(tr("ITM_DEL_PORT"), this, SLOT(deletePort())); + } + connect(this, SIGNAL(MousePress(QMouseEvent*)), this, SLOT(showPopup(QMouseEvent*))); + connect(this, SIGNAL(MouseRelease(QMouseEvent*)), this, SLOT(endSketch())); +} + +SUPERVGUI_Port::~SUPERVGUI_Port() { + Trace("SUPERVGUI_Port::~SUPERVGUI_Port") +} + +SUPERV_Port SUPERVGUI_Port::getPort() { + Trace("SUPERVGUI_Port::getPort") + return(port); +} + +void SUPERVGUI_Port::showPopup(QMouseEvent* e) { + Trace("SUPERVGUI_Port::showPopup"); + if (e->button() != RightButton) return; + if (main->getDataflow()->IsExecuting()) + popup->setItemEnabled(mySketchItem, false); + else + if (!port->IsInput() //output port + || + port->IsInput() && (!port->IsLinked() //not linked input port + || + port->Kind() == SUPERV::EndSwitchParameter)) { //input port of EndSwitch node + popup->setItemEnabled(mySketchItem, true); + } + + main->showPopup(popup, e); +} + + +QPoint SUPERVGUI_Port::getConnectPnt() { + return QPoint(0,0); +} + + +void SUPERVGUI_Port::sync() { + if (port->IsParam() || port->IsInLine()) + setText(myName + "=" + port->ToString()); + else + setText(myName); + +} + + +void SUPERVGUI_Port::sketchLink() { + main->getGraph()->sketchBegin(this); + if (port->IsInput()) + setLineWidth(1); +} + +void SUPERVGUI_Port::endSketch() { + main->getGraph()->sketchEnd(this); + if (port->IsInput() && port->IsLinked()) + setLineWidth(1); +} + + +void SUPERVGUI_Port::deletePort() { + SUPERVGUI_GraphNode* aNode = (SUPERVGUI_GraphNode* )main->getGraph()->child(port->Node()->Name(), "SUPERVGUI_GraphNode"); + if (aNode) { + aNode->deletePort(this); + } +} + + + + +//*********************************************************** +// Port d'entree +// ------------- + +SUPERVGUI_PortIn::SUPERVGUI_PortIn(QWidget* parent, SUPERVGUI_Main* m, SUPERV_Port p) + : SUPERVGUI_Port(parent, m, p), myDlg( 0 ) +{ + Trace("SUPERVGUI_PortIn::SUPERVGUI_PortIn"); + myLinkPrs = 0; + // link->move(0, height()/2-POINT_SIZE_HALF); + + bool editing = port->IsInput() && ( !port->IsLinked() ); //main->isEditable(); +// bool linked = port->IsLinked(); +// bool b = (!linked) && editing; + if ((!port->IsGate()) && editing ) { + psc = popup->insertItem(tr("MSG_SETVALUE"), this, SLOT(setInput())); + } + browser = popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse())); +} + +SUPERVGUI_PortIn::~SUPERVGUI_PortIn() { + Trace("SUPERVGUI_PortIn::~SUPERVGUI_PortIn"); +} + + +bool SUPERVGUI_PortIn::eventFilter( QObject* o, QEvent* e ) +{ + if ( o == myDlg && e->type() == QEvent::Close ) + myDlg = 0; + return SUPERVGUI_Port::eventFilter( o, e ); +} + + +void SUPERVGUI_PortIn::deleteLinks() { + if (myLinkPrs) { + disconnect(myLinkPrs, 0, this, 0); + main->getGraph()->deleteLink(myLinkPrs); + myLinkPrs = 0; + } +} + + +void SUPERVGUI_PortIn::sync() { + SUPERVGUI_Port::sync(); + if (port->IsLinked()) { + popup->setItemEnabled(browser, port->State() == SUPERV_Ready); + } else { + if (port->HasInput()) { + popup->setItemEnabled(browser, true); + setLineWidth(2); + } else { + popup->setItemEnabled(browser, false); + setLineWidth(1); + } + } +} + +void SUPERVGUI_PortIn::setValue(const char* d) { + Trace("SUPERVGUI_PortIn::setValue") + if (port->Input((*Supervision.getEngine())->StringValue(d))) { + sync(); + } else { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_SETVAL")); + }; +} + +void SUPERVGUI_PortIn::setInput() { + Trace("SUPERVGUI_PortIn::setInput"); + if ( !myDlg ) { + myDlg = new SUPERVGUI_GetValueDlg(this); + myDlg->installEventFilter( this ); + } + if ( !myDlg->isVisible() ) + myDlg->show(); + else { + myDlg->raise(); + myDlg->setActiveWindow(); + myDlg->setFocus(); + } +} + +void SUPERVGUI_PortIn::browse() { + Trace("SUPERVGUI_PortIn::browse") + QString mess(tr("MSG_IPORT_VAL")); + mess += port->ToString(); + QMessageBox::information(QAD_Application::getDesktop(), tr("MSG_INFO"), mess); +} + + + +/** + * Returns coordinates of connection point in content coordinates + */ +QPoint SUPERVGUI_PortIn::getConnectPnt() { + // Parent widget is internal node frame + // parent of parent is node it self + QWidget* aNode = parentWidget()->parentWidget(); + QPoint aPnt(aNode->pos()); // position of the node + + if (parentWidget()->isVisible()) { + aPnt += parentWidget()->pos(); + return QPoint(aPnt.x() + pos().x(), + aPnt.y() + (pos().y() + height()/2)); + } + return QPoint(aPnt.x(), + aPnt.y() + (aNode->height()/2)); +} + +void SUPERVGUI_PortIn::setLinkPrs(SUPERVGUI_Link* theLink) { + myLinkPrs = theLink; + connect(myLinkPrs, SIGNAL(linkDeleted(SUPERVGUI_Link*)), + this, SLOT(onDeleteLink(SUPERVGUI_Link*))); + popup->setItemEnabled(mySketchItem, false); +} + +void SUPERVGUI_PortIn::onDeleteLink(SUPERVGUI_Link*) { + disconnect(myLinkPrs, 0, this, 0); + myLinkPrs = 0; + popup->setItemEnabled(psc, true); + if (port->HasInput()) + setLineWidth(2); + if (main->isEditable()) { + popup->setItemEnabled(mySketchItem, true); + } else { + popup->setItemEnabled(mySketchItem, false); + } +} + + + +//*********************************************************** +// Port de sortie +// -------------- + +SUPERVGUI_PortOut::SUPERVGUI_PortOut(QWidget* parent, SUPERVGUI_Main* m, SUPERV_Port p): + SUPERVGUI_Port(parent, m, p), + study(false) +{ + Trace("SUPERVGUI_PortOut::SUPERVGUI_PortOut") + // link->move(width()-POINT_SIZE, height()/2-POINT_SIZE_HALF); + myLinksList.setAutoDelete(false); + + if (!port->IsGate()) { + pls = popup->insertItem(tr("MSG_PUT_INSTUDY"), this, SLOT(toStudy())); + } + browser = popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse())); + + if (!main->getDataflow()->IsReadOnly()) { + popup->setItemEnabled(mySketchItem, true); + } else { + popup->setItemEnabled(mySketchItem, false); + } +} + +SUPERVGUI_PortOut::~SUPERVGUI_PortOut() { + Trace("SUPERVGUI_PortOut::~SUPERVGUI_PortOut"); +} + +void SUPERVGUI_PortOut::sync() { + Trace("SUPERVGUI_PortOut::sync") + SUPERVGUI_Port::sync(); + + bool ok = (port->State() == SUPERV_Ready); + popup->setItemEnabled(browser, ok); + if (study && ok) { + study = main->putDataStudy(port, STUDY_PORT_OUT); + } + + if (study) { + setLineWidth(2); + popup->changeItem(pls, tr("MSG_NOT_INSTUDY")); + } else { + setLineWidth(1); + popup->changeItem(pls, tr("MSG_PUT_INSTUDY")); + } + +} + +void SUPERVGUI_PortOut::updateStudy() { + Trace("SUPERVGUI_PortOut::updateStudy") + SUPERVGUI_Node* aNode = (SUPERVGUI_Node* )main->getGraph()->child(port->Node()->Name(), "SUPERVGUI_Node"); + if (aNode) + ((SUPERVGUI_PortOut*)aNode->child(port->Name(), "SUPERVGUI_PortOut"))->study = study; + else + { + aNode = (SUPERVGUI_Node* )main->getArray()->child(port->Node()->Name(), "SUPERVGUI_Node"); + if (aNode) + ((SUPERVGUI_PortOut*)aNode->child(port->Name(), "SUPERVGUI_PortOut"))->study = study; + } +} + +void SUPERVGUI_PortOut::toStudy() { + Trace("SUPERVGUI_PortOut::toStudy") + if (!main->isFromStudy()) { + if (main->addStudy()) main->setAsFromStudy(true); + } + if (!main->getStudy()->getStudyDocument()->GetProperties()->IsLocked()) study = !study; + sync(); +} + +void SUPERVGUI_PortOut::browse() { + Trace("SUPERVGUI_PortOut::browse") + QString mess(tr("MSG_OPORT_VAL")); + mess += port->ToString(); + QMessageBox::information(QAD_Application::getDesktop(), tr("MSG_INFO"), mess); +} + + +/** + * Returns coordinates of connection point in scroll view content coordinates + */ +QPoint SUPERVGUI_PortOut::getConnectPnt() { + // Parent widget is internal node frame + // parent of parent is node it self + QWidget* aNode = parentWidget()->parentWidget(); + QPoint aPnt(aNode->pos()); // position of the node + if (parentWidget()->isVisible()) { + aPnt += parentWidget()->pos(); + return QPoint(aPnt.x() + pos().x() + width(), + aPnt.y() + (pos().y() + height()/2)); + } + return QPoint(aPnt.x() + aNode-> width(), + aPnt.y() + (aNode->height()/2)); +} + + +void SUPERVGUI_PortOut::addLinkPrs(SUPERVGUI_Link* theLink) { + myLinksList.append(theLink); + connect(theLink, SIGNAL(linkDeleted(SUPERVGUI_Link*)), + this, SLOT(onDeleteLink(SUPERVGUI_Link*))); +} + + +void SUPERVGUI_PortOut::onDeleteLink(SUPERVGUI_Link* theLink) { + disconnect(theLink, 0, this, 0); + myLinksList.remove(theLink); +} + + +void SUPERVGUI_PortOut::deleteLinks() { + if (myLinksList.count() > 0) { + SUPERVGUI_Link* aLink; + while (aLink = myLinksList.last()) { + disconnect(aLink, 0, this, 0); + myLinksList.remove(aLink); + main->getGraph()->deleteLink(aLink); + } + } +} + + + +//*********************************************************** +// Input Port of EndSwitch Node +// ---------------------------- +SUPERVGUI_PortInESNode::SUPERVGUI_PortInESNode(QWidget* parent, SUPERVGUI_Main* m, SUPERV_Port p) + : SUPERVGUI_Port(parent, m, p), myDlg( 0 ) +{ + Trace("SUPERVGUI_PortInESNode::SUPERVGUI_PortInESNode"); + myLinksList.setAutoDelete(false); + + bool editing = port->IsInput() && ( !port->IsLinked() ); //main->isEditable(); + if ((!port->IsGate()) && editing ) { + psc = popup->insertItem(tr("MSG_SETVALUE"), this, SLOT(setInput())); + } + browser = popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse())); +} + +SUPERVGUI_PortInESNode::~SUPERVGUI_PortInESNode() { + Trace("SUPERVGUI_PortInESNode::~SUPERVGUI_PortInESNode"); +} + +bool SUPERVGUI_PortInESNode::eventFilter( QObject* o, QEvent* e ) { + if ( o == myDlg && e->type() == QEvent::Close ) + myDlg = 0; + return SUPERVGUI_Port::eventFilter( o, e ); +} + +void SUPERVGUI_PortInESNode::sync() { + SUPERVGUI_Port::sync(); + if (port->IsLinked()) { + popup->setItemEnabled(browser, port->State() == SUPERV_Ready); + } else { + if (port->HasInput()) { + popup->setItemEnabled(browser, true); + setLineWidth(2); + } else { + popup->setItemEnabled(browser, false); + setLineWidth(1); + } + } +} + +void SUPERVGUI_PortInESNode::setValue(const char* d) { + Trace("SUPERVGUI_PortIn::setValue") + if (port->Input((*Supervision.getEngine())->StringValue(d))) { + sync(); + } else { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_SETVAL")); + }; +} + +/** + * Returns coordinates of connection point in content coordinates + */ +QPoint SUPERVGUI_PortInESNode::getConnectPnt() { + QWidget* aNode = parentWidget()->parentWidget(); + QPoint aPnt(aNode->pos()); + + if (parentWidget()->isVisible()) { + aPnt += parentWidget()->pos(); + return QPoint(aPnt.x() + pos().x(), + aPnt.y() + (pos().y() + height()/2)); + } + return QPoint(aPnt.x(), + aPnt.y() + (aNode->height()/2)); +} + +void SUPERVGUI_PortInESNode::setLinkPrs(SUPERVGUI_Link* theLink) { + myLinksList.append(theLink); + connect(theLink, SIGNAL(linkDeleted(SUPERVGUI_Link*)), + this, SLOT(onDeleteLink(SUPERVGUI_Link*))); +} + +void SUPERVGUI_PortInESNode::deleteLinks() { + if (myLinksList.count() > 0) { + SUPERVGUI_Link* aLink; + while (aLink = myLinksList.last()) { + disconnect(aLink, 0, this, 0); + myLinksList.remove(aLink); + main->getGraph()->deleteLink(aLink); + } + } +} + +void SUPERVGUI_PortInESNode::setInput() { + Trace("SUPERVGUI_PortInESNode::setInput"); + if ( !myDlg ) { + myDlg = new SUPERVGUI_GetValueDlg(this); + myDlg->installEventFilter( this ); + } + if ( !myDlg->isVisible() ) + myDlg->show(); + else { + myDlg->raise(); + myDlg->setActiveWindow(); + myDlg->setFocus(); + } +} + +void SUPERVGUI_PortInESNode::browse() { + Trace("SUPERVGUI_PortInESNode::browse") + QString mess(tr("MSG_IPORT_VAL")); + mess += port->ToString(); + QMessageBox::information(QAD_Application::getDesktop(), tr("MSG_INFO"), mess); +} + + +void SUPERVGUI_PortInESNode::onDeleteLink(SUPERVGUI_Link* theLink) { + disconnect(theLink, 0, this, 0); + myLinksList.remove(theLink); + + if (myLinksList.count() == 0) { + popup->setItemEnabled(psc, true); + } else { + popup->setItemEnabled(psc, false); + } + + if (port->HasInput()) + setLineWidth(2); + + if (main->isEditable()) { + popup->setItemEnabled(mySketchItem, true); + } else { + popup->setItemEnabled(mySketchItem, false); + } +} + diff --git a/src/SUPERVGUI/SUPERVGUI_Port.h b/src/SUPERVGUI/SUPERVGUI_Port.h new file mode 100644 index 0000000..bb6d488 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Port.h @@ -0,0 +1,174 @@ +// File : SUPERVGUI_Port.h +// Created : 25 / 10 / 2001 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGUI +// Copyright : CEA + +#ifndef SUPERVGUI_Port_H +#define SUPERVGUI_Port_H + +//#include "SUPERVGUI_Point.h" +#include "SUPERVGUI_Label.h" +#include "SUPERVGUI_Def.h" +#include "SALOME_Selection.h" + +class SUPERVGUI_Main; +class SUPERVGUI_Link; + +class SUPERVGUI_Port: public SUPERVGUI_Label { + Q_OBJECT + + public: + SUPERVGUI_Port(QWidget* parent, SUPERVGUI_Main* m, SUPERV_Port p); + virtual ~SUPERVGUI_Port(); + + SUPERV_Port getPort(); + + virtual QPoint getConnectPnt(); + virtual void deleteLinks() = 0; + virtual void sync(); + + SUPERVGUI_Main* getMain() { return main;} + + private slots: + void sketchLink(); + void endSketch(); + + protected slots: + virtual void deletePort(); + + protected: + SUPERVGUI_Main* main; + SUPERV_Port port; + + QPopupMenu* popup; + int mySketchItem; + int myDelItem; + int browser; + + SALOME_Selection* mySelection; + + QString myName; + + private slots: + void showPopup(QMouseEvent* e); +}; + + + + +class SUPERVGUI_GetValueDlg; +class SUPERVGUI_PortIn: public SUPERVGUI_Port { + Q_OBJECT + + public: + SUPERVGUI_PortIn(QWidget* parent, SUPERVGUI_Main* m, SUPERV_Port p); + virtual ~SUPERVGUI_PortIn(); + + bool eventFilter( QObject* o, QEvent* e ); + + void sync(); + void setValue(const char* id); + virtual QPoint getConnectPnt(); + + void setLinkPrs(SUPERVGUI_Link* theLink); + + SUPERVGUI_Link* getLinkPrs() + { return myLinkPrs; }; + + void deleteLinks(); + + private slots: + void setInput(); + void browse(); + void onDeleteLink(SUPERVGUI_Link*); + + + private: + int psd; + int psc; + SUPERVGUI_Link* myLinkPrs; + SUPERVGUI_GetValueDlg* myDlg; +}; + + + + + +class SUPERVGUI_PortOut: public SUPERVGUI_Port { + Q_OBJECT + + public: + SUPERVGUI_PortOut(QWidget* parent, SUPERVGUI_Main* m, SUPERV_Port p); + virtual ~SUPERVGUI_PortOut(); + + void sync(); + void updateStudy(); + bool isInStudy() { return study; }; + void setStudyState(bool theIsInStudy) { study = theIsInStudy; }; + virtual QPoint getConnectPnt(); + + void addLinkPrs(SUPERVGUI_Link* theLink); + + SUPERVGUI_Link* getLinkPrs(int theNum) + { return myLinksList.at(theNum); }; + + int getLinkPrsCount() + { return myLinksList.count(); }; + + void deleteLinks(); + + private slots: + void toStudy(); + void browse(); + + void sketch(QMouseEvent* e); + void onDeleteLink(SUPERVGUI_Link*); + + + private: + int pls; + bool study; + QPtrList myLinksList; +}; + + +class SUPERVGUI_PortInESNode: public SUPERVGUI_Port { + Q_OBJECT + + public: + SUPERVGUI_PortInESNode(QWidget* parent, SUPERVGUI_Main* m, SUPERV_Port p); + virtual ~SUPERVGUI_PortInESNode(); + + bool eventFilter( QObject* o, QEvent* e ); + + void sync(); + void setValue(const char* id); + virtual QPoint getConnectPnt(); + + void setLinkPrs(SUPERVGUI_Link* theLink); + + SUPERVGUI_Link* getLinkPrs(int theNum) + { return myLinksList.at(theNum); }; + + int getLinkPrsCount() + { return myLinksList.count(); }; + + void deleteLinks(); + + + private slots: + void setInput(); + void browse(); + void onDeleteLink(SUPERVGUI_Link*); + + + private: +// int psd; + int psc; + QPtrList myLinksList; + SUPERVGUI_GetValueDlg* myDlg; + +}; +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_Python.cxx b/src/SUPERVGUI/SUPERVGUI_Python.cxx new file mode 100644 index 0000000..b307d89 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Python.cxx @@ -0,0 +1,99 @@ +using namespace std; +// File : SUPERVGUI_Python.cxx +// Created : 18 / 06 / 2002 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGUI +// Copyright : CEA + +#include "SUPERVGUI_Def.h" +#include "QAD_PyEditor.h" +#include "QAD_PyInterp.h" +#include "QAD_Application.h" +#include "SUPERVGUI_Python.h" +#include +#include +#include + +#define MARGIN_SIZE 11 +#define SPACING_SIZE 6 +#define MIN_PYTHON_WIDTH 300 +#define MIN_PYTHON_HEIGHT 200 + +/*! + Constructor +*/ +SUPERVGUI_Python::SUPERVGUI_Python(QAD_PyInterp* pi, bool isReadOnly) + : QDialog( 0, "", TRUE, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), + py_int( pi ) +{ + Trace("SUPERVGUI_Python::SUPERVGUI_Python"); + setCaption("Python Control Code"); + setSizeGripEnabled( TRUE ); + + QVBoxLayout* topLayout = new QVBoxLayout( this ); + topLayout->setMargin( MARGIN_SIZE ); topLayout->setSpacing( SPACING_SIZE ); + + edit = new QMultiLineEdit( this ); + edit->setPalette( QAD_Application::getPalette( true ) ); + edit->setReadOnly( isReadOnly ); + edit->setMinimumSize( MIN_PYTHON_WIDTH, MIN_PYTHON_HEIGHT ); + + QGroupBox* GroupButtons = new QGroupBox( this ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); GroupButtons->layout()->setMargin( 0 ); + QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( SPACING_SIZE ); + GroupButtonsLayout->setMargin( MARGIN_SIZE ); + + if ( !isReadOnly ) { + ok = new QPushButton( tr( "BUT_OK" ), GroupButtons, "buttonOk" ); + ok->setAutoDefault( TRUE ); ok->setDefault( TRUE ); + GroupButtonsLayout->addWidget( ok ); + connect( ok, SIGNAL( clicked() ), this, SLOT( accept() ) ); + } + GroupButtonsLayout->addStretch(); + ko = new QPushButton( isReadOnly ? tr( "BUT_CLOSE" ) : tr( "BUT_CANCEL" ), GroupButtons, "buttonCancel" ); + ko->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( ko ); + connect( ko, SIGNAL( clicked() ), this, SLOT( reject() ) ); + if ( isReadOnly ) { + GroupButtonsLayout->addStretch(); + } + topLayout->addWidget( edit ); + topLayout->addWidget( GroupButtons ); +} + +/*! + Destructor +*/ +SUPERVGUI_Python::~SUPERVGUI_Python() { + Trace("SUPERVGUI_Python::~SUPERVGUI_Python") +} + +/*! + button slot +*/ +void SUPERVGUI_Python::accept() { + Trace("SUPERVGUI_Python::okButton"); + QDialog::accept(); + qApp->processEvents(); + int n = edit->numLines(); + for ( int li = 0; li < n; li++ ) { + QString ligne = edit->textLine( li ); + if ( !ligne.isEmpty() ) { + if ( py_int->run( ligne.latin1() ) ) { + QMessageBox::warning(0, "Supervision Error", "Can't Reload Python Code"); + } + } + } +} + +/*! + button slot +*/ +void SUPERVGUI_Python::reject() { + Trace("SUPERVGUI_Python::koButton"); + QDialog::reject(); +} diff --git a/src/SUPERVGUI/SUPERVGUI_Python.h b/src/SUPERVGUI/SUPERVGUI_Python.h new file mode 100644 index 0000000..5549e8b --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Python.h @@ -0,0 +1,33 @@ +// File : SUPERVGUI_Python.h +// Created : 18 / 06 / 2002 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGUI +// Copyright : CEA + +#ifndef SUPERVGUI_Python_H +#define SUPERVGUI_Python_H + +using namespace std; +#include "SUPERVGUI_Def.h" +#include "QAD_PyInterp.h" + +class SUPERVGUI_Python: public QDialog { + Q_OBJECT + + public: + SUPERVGUI_Python(QAD_PyInterp* pi, bool isReadOnly); + virtual ~SUPERVGUI_Python(); + + private slots: + void accept(); + void reject(); + + private: + QAD_PyInterp* py_int; + QMultiLineEdit* edit; + QPushButton* ok; + QPushButton* ko; +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_Service.cxx b/src/SUPERVGUI/SUPERVGUI_Service.cxx new file mode 100644 index 0000000..dbed346 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Service.cxx @@ -0,0 +1,664 @@ +using namespace std; +// File : SUPERVGUI_Service.cxx +// Created : 7 / 11 / 2001 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGUI +// Copyright : CEA + +#include "SUPERVGUI_Service.h" +#include "SUPERVGUI_Main.h" +#include "SUPERVGUI.h" +#include "QAD_Tools.h" +#include "QAD_FileDlg.h" + +#include "SALOME_NamingService.hxx" +#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog) +#include +#include + + +static const char * ComponentIcon[] = { +"20 20 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" .................. ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" .................. ", +" . . . ", +" . . . ", +" ... ... ... ", +" .. .. .. .. .. .. ", +" . . . . . . ", +" .. .. .. .. .. .. ", +" ... ... ... "}; + + +static const char * InterfaceIcon[] = { +"20 20 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" .. ", +" ...... ", +" .. .. ", +" . . ", +".......... .. ", +" . . ", +" .. .. ", +" ...... ", +" .. ", +" ", +" ", +" ", +" ", +" ", +" "}; + + + + +SUPERVGUI_Service::SUPERVGUI_Service(SALOME_NamingService* ns): + QDialog(QAD_Application::getDesktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), + naming(ns) +{ + setSizeGripEnabled( true ); + setCaption(tr("TIT_SERVICES")); + + QVBoxLayout* aMainLayout = new QVBoxLayout(this, 7, 4); + + myTabPane = new QTabWidget(this); + connect(myTabPane, SIGNAL(currentChanged(QWidget *)), this, SLOT(tabChanged(QWidget *))); + + // Create Tab for Corba services + QWidget* aCorbaPane = new QWidget(myTabPane); + QVBoxLayout* aBaseLayoutV= new QVBoxLayout(aCorbaPane, 0, 4); + aBaseLayoutV->setMargin(5); + aBaseLayoutV->setSpacing(10); + + QHBoxLayout* aBaseLayout = new QHBoxLayout(aCorbaPane); //!! + + components = new QListView(aCorbaPane); + components->addColumn(tr("COL_COMPONENTS")); + components->addColumn(tr("COL_PORTTYPE")); + components->addColumn(tr("COL_PORTWAY")); + components->setColumnAlignment(1, AlignLeft); + components->setColumnAlignment(2, AlignLeft); + components->setColumnAlignment(3, AlignLeft); + components->setSelectionMode(QListView::Extended); + components->setRootIsDecorated(true); +// aBaseLayout->addWidget(components); + aBaseLayoutV->addWidget(components); //!! + + //QHGroupBox* aAddBox = new QHGroupBox(tr("TIT_ADDNODE"), aCorbaPane); //!! + //aAddBox->setInsideSpacing(20); //!! + + QPushButton* aComputeCBtn = new QPushButton(tr("TIT_ADDCNODE"), aCorbaPane); //!! + connect(aComputeCBtn, SIGNAL(clicked()), this, SLOT(addComputeNode())); //!! + aComputeCBtn->setDefault(false); + + QPushButton* aComputeBtn = new QPushButton(tr("TIT_ADDFNODE"), aCorbaPane); + connect(aComputeBtn, SIGNAL(clicked()), this, SLOT(addFactoryNode())); + aComputeBtn->setDefault(true); + + aBaseLayout->addWidget(aComputeBtn); + aBaseLayout->addWidget(aComputeCBtn); //!! + + aBaseLayoutV->insertLayout(-1, aBaseLayout); + myTabPane->addTab(aCorbaPane, tr("MODULES_PANE")); + + + // Create Tab for Python services + QWidget* aPythonPane = new QWidget(myTabPane); + QVBoxLayout* aPythonLayout = new QVBoxLayout(aPythonPane, 0, 4); + aPythonLayout->setMargin(5); + aPythonLayout->setSpacing(10); + + // Type pane + QHGroupBox* aAddBox2 = new QHGroupBox(tr("TIT_ADDNODE"), aPythonPane); + aAddBox2->setInsideSpacing(20); + + QLabel* aTypeLbl = new QLabel(tr("LBL_NODETYPE"), aAddBox2); + + myTypeCombo = new QComboBox(aAddBox2); + myTypeCombo->insertItem("Computation"); + myTypeCombo->insertItem("Switch"); + myTypeCombo->insertItem("Loop"); + myTypeCombo->insertItem("GoTo"); + //myTypeCombo->insertItem("Label"); + connect(myTypeCombo, SIGNAL(activated(int)), this, SLOT(typeNodeSelected(int))); + + aPythonLayout->addWidget(aAddBox2); + + // Edit pane + myStackWidget = new QWidgetStack(aPythonPane); + + // other pane + myScriptPane = new SUPERVGUI_PythonEditPane(myStackWidget); + myOtherId = myStackWidget->addWidget(myScriptPane); + + // loop pane + QTabWidget* aLoopTabPane = new QTabWidget(myStackWidget); + myInitPane = new SUPERVGUI_PythonEditPane(myStackWidget); + aLoopTabPane->addTab(myInitPane, "Init"); + + myMorePane = new SUPERVGUI_PythonEditPane(myStackWidget); + aLoopTabPane->addTab(myMorePane, "More"); + + myNextPane = new SUPERVGUI_PythonEditPane(myStackWidget); + aLoopTabPane->addTab(myNextPane, "Next"); + myLoopId = myStackWidget->addWidget(aLoopTabPane); + + myStackWidget->raiseWidget(myOtherId); + + aPythonLayout->addWidget(myStackWidget, 1); + + // Create button + QPushButton* aCreateBtn = new QPushButton(tr("TIT_ADDNODE"), aPythonPane); + connect(aCreateBtn, SIGNAL(clicked()), this, SLOT(addInlineNode())); + aPythonLayout->addWidget(aCreateBtn); + + myTabPane->addTab(aPythonPane, tr("INLINE_PANE")); + + aMainLayout->addWidget(myTabPane); + + // Close button + QHBox* aBtnBox = new QHBox(this); + QHBoxLayout* aBtnLayout = new QHBoxLayout(aBtnBox->layout()); + aBtnLayout->addStretch(); + + QPushButton* aCloseBtn = new QPushButton(tr("BUT_CLOSE"), aBtnBox); + connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(reject())); + + aMainLayout->addWidget(aBtnBox); + + initialise(); + myX = 0; + myY = 0; + myIsInline = false; +} + + + +void SUPERVGUI_Service::initialise() { + CORBA::Object_ptr obj = naming->Resolve("/Kernel/ModulCatalog"); + SALOME_ModuleCatalog::ModuleCatalog_var *aModuleCatalog = new SALOME_ModuleCatalog::ModuleCatalog_var; + *aModuleCatalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj); + if (CORBA::is_nil(*aModuleCatalog)) { + setCaption("Error in Connexion to omniNames with '/Kernel/ModulCatalog'"); + return; + } + + QAD_ResourceMgr* aResMgr = QAD_Desktop::createResourceManager(); + + SALOME_ModuleCatalog::ListOfComponents_var lComponents = (*aModuleCatalog)->GetComponentList(); + long nbComp = lComponents->length(); + for (int i=0; iGetComponent((char *)lComponents[i]); + QListViewItem* myComponentItem = new QListViewItem(components, (char*)lComponents[i]); + myComponentItem->setSelectable(false); + QString aIconName = C->component_icone(); + if (!aIconName.isEmpty()) { + QString resDir = aResMgr->findFile(aIconName, C->componentname()) ; + if (resDir) { + resDir = QAD_Tools::addSlash(resDir); + QPixmap aIcone(resDir + aIconName); + QIconSet aIconSet(aIcone); + myComponentItem->setPixmap(0, aIconSet.pixmap(QIconSet::Small, QIconSet::Normal)); + } else { + myComponentItem->setPixmap(0, ComponentIcon); + } + } else { + myComponentItem->setPixmap(0, ComponentIcon); + } + SALOME_ModuleCatalog::ListOfInterfaces* lInterfaces = C->GetInterfaceList(); + long nbInterf = lInterfaces->length(); + for (int j=0; jGetInterface((char*)(*lInterfaces)[j]); + QListViewItem* myInterfaceItem = new QListViewItem(myComponentItem, (char*)Interface->interfacename); + myInterfaceItem->setSelectable(false); + myInterfaceItem->setPixmap(0, InterfaceIcon); + + long nbServices = Interface->interfaceservicelist.length(); + for (int k=0; kinterfaceservicelist[k]); + QListViewItem* myServiceItem = new QListViewItem(myInterfaceItem, (char*)Service->ServiceName); + myServiceItem->setSelectable(true); + components->ensureItemVisible(myServiceItem); + + long nbPortsOut = Service->ServiceoutParameter.length(); + for (int m=0; mServiceoutParameter[m]); + QListViewItem* myPortOutItem = new QListViewItem(myServiceItem, (char*)PortOut->Parametername, (char*)PortOut->Parametertype, "Out"); + myPortOutItem->setSelectable(false); + } + + long nbPortsIn = Service->ServiceinParameter.length(); + for (int l=0; lServiceinParameter[l]); + QListViewItem* myPortInItem = new QListViewItem(myServiceItem, (char*)PortIn->Parametername, (char*)PortIn->Parametertype, "In"); + myPortInItem->setSelectable(false); + } + } + } + } +} + + + +SUPERVGUI_Service::~SUPERVGUI_Service() { + Trace("SUPERVGUI_Service::~SUPERVGUI_Service") +} + +void SUPERVGUI_Service::addComputeNode() { + SUPERVGUI_Main* aMain = Supervision.getMain(); + if (aMain==0) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW")); + } else { + CORBA::Object_ptr obj = naming->Resolve("/Kernel/ModulCatalog"); + SALOME_ModuleCatalog::ModuleCatalog_var* aModuleCatalog = new SALOME_ModuleCatalog::ModuleCatalog_var; + *aModuleCatalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj); + if (CORBA::is_nil(*aModuleCatalog)) { + QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE")); + } else { + QListViewItem* item; + bool b = false; + QListViewItemIterator i(components); + for (; i.current(); ++i) { + item = i.current(); + if (item->isSelected()) { + const char* service = item->text(0).latin1(); + const char* interface = item->parent()->text(0).latin1(); + const char* component = item->parent()->parent()->text(0).latin1(); + SALOME_ModuleCatalog::Acomponent_ptr myComponent = (*aModuleCatalog)->GetComponent(component); + if (myComponent==NULL) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE")); + } else { + const SALOME_ModuleCatalog::Service* myService = myComponent->GetService(interface, service); + b = true; + + SUPERV_CNode node = aMain->getDataflow()->CNode(*myService); + if (CORBA::is_nil(node)) { + QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); + return; + } + node->Coords(myX, myY); + myX += NODE_DX; + myY += NODE_DY; + aMain->addComputeNode(SUPERV::CNode::_narrow(node)); + } + } + } + if (!b) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NONODE_TOADD")); + } + } + } +} + +void SUPERVGUI_Service::addFactoryNode() { + SUPERVGUI_Main* aMain = Supervision.getMain(); + if (aMain==0) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW")); + } else { + CORBA::Object_ptr obj = naming->Resolve("/Kernel/ModulCatalog"); + SALOME_ModuleCatalog::ModuleCatalog_var* aModuleCatalog = new SALOME_ModuleCatalog::ModuleCatalog_var; + *aModuleCatalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj); + if (CORBA::is_nil(*aModuleCatalog)) { + QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE")); + } else { + QListViewItem* item; + bool b = false; + QListViewItemIterator i(components); + for (; i.current(); ++i) { + item = i.current(); + if (item->isSelected()) { + const char* service = item->text(0).latin1(); + const char* interface = item->parent()->text(0).latin1(); + const char* component = item->parent()->parent()->text(0).latin1(); + SALOME_ModuleCatalog::Acomponent_ptr myComponent = (*aModuleCatalog)->GetComponent(component); + if (myComponent==NULL) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE")); + } else { + const SALOME_ModuleCatalog::Service* myService = myComponent->GetService(interface, service); + b = true; + + SUPERV_FNode node = aMain->getDataflow()->FNode(component, interface, *myService); + if (CORBA::is_nil(node)) { + QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); + return; + } + node->Coords(myX, myY); + myX += NODE_DX; + myY += NODE_DY; + aMain->addComputeNode(SUPERV::CNode::_narrow(node)); + } + } + } + if (!b) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NONODE_TOADD")); + } + } + } +} + + +void SUPERVGUI_Service::addInlineNode() { + SUPERVGUI_Main* aMain = Supervision.getMain(); + if (aMain==0) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW")); + } else { + int aSel = myTypeCombo->currentItem(); + switch (aSel) { + case 0: // Computation + if (myScriptPane->isDefined()) { + SUPERV_INode aNode = aMain->getDataflow()->INode(myScriptPane->getFuncName().latin1(), + (myScriptPane->getFunction()).in()); + if (CORBA::is_nil(aNode)) { + QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); + return; + } + aNode->Coords(myX, myY); + myX += NODE_DX; + myY += NODE_DY; + aMain->addComputeNode(SUPERV::CNode::_narrow(aNode)); + } + break; + + case 1: // Switch + if (myScriptPane->isDefined()) { + SUPERV_INode aEndNode; + SUPERV_SNode aStartNode = aMain->getDataflow()->SNode(myScriptPane->getFuncName().latin1(), + (myScriptPane->getFunction()).in(), + aEndNode); + if (CORBA::is_nil(aStartNode) || CORBA::is_nil(aEndNode)) { + QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); + return; + } + aStartNode->Coords(myX, myY); + aEndNode->Coords(myX + LABEL_WIDTH*2, myY); + myX += NODE_DX; + myY += NODE_DY; + aMain->addControlNode(SUPERV::CNode::_narrow(aStartNode), SUPERV::CNode::_narrow(aEndNode), true); + } + break; + + case 2: // Loop + { + SUPERV_INode aEndNode; + SUPERV_LNode aStartNode = aMain->getDataflow()->LNode(myInitPane->getFuncName().latin1(), (myInitPane->getFunction()).in(), + myMorePane->getFuncName().latin1(), (myMorePane->getFunction()).in(), + myNextPane->getFuncName().latin1(), (myNextPane->getFunction()).in(), + aEndNode); + if (CORBA::is_nil(aStartNode) || CORBA::is_nil(aEndNode)) { + QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); + return; + } + aStartNode->Coords(myX, myY); + aEndNode->Coords(myX + LABEL_WIDTH*2, myY); + myX += NODE_DX; + myY += NODE_DY; + aMain->addControlNode(SUPERV::CNode::_narrow(aStartNode), SUPERV::CNode::_narrow(aEndNode), true); + } + break; + + case 3: // GoTo + { + SUPERV_GNode aGotoNode; + if (myScriptPane->isDefined()) + aGotoNode = aMain->getDataflow()->GNode(myScriptPane->getFuncName().latin1(), + (myScriptPane->getFunction()).in(), ""); + else + aGotoNode = aMain->getDataflow()->GNode("GoTo", (myScriptPane->getFunction()).in(), ""); + if (CORBA::is_nil(aGotoNode)) { + QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); + return; + } + aGotoNode->Coords(myX, myY); + myX += NODE_DX; + myY += NODE_DY; + aMain->addGOTONode(SUPERV::GNode::_narrow(aGotoNode)); + } + break; + } + } +} + + + +void SUPERVGUI_Service::typeNodeSelected(int theRow) { + if (theRow == 2) + myStackWidget->raiseWidget(myLoopId); + else + myStackWidget->raiseWidget(myOtherId); +} + + + +void SUPERVGUI_Service::choose() { + Trace("SUPERVGUI_Service::choose") + show(); + raise(); +} + + +void SUPERVGUI_Service::showEvent(QShowEvent* theEvent) { + SUPERVGUI_Main* aMain = Supervision.getMain(); + if (aMain && (!aMain->isArrayShown())) { + aMain->getGraph()->viewportToContents(0, 0, myX, myY); + } + QDialog::showEvent(theEvent); +} + + +void SUPERVGUI_Service::tabChanged(QWidget* theWidget) { + myIsInline = (myTabPane->currentPageIndex() == 1); +} + + + +//***************************************************** +// Pane for Python script editing +//***************************************************** +SUPERVGUI_PythonEditPane::SUPERVGUI_PythonEditPane(QWidget* theParent) + : QFrame(theParent), + myIStream(0) +{ + QGridLayout* aEditLayout = new QGridLayout(this, 2, 4); + + // First row + QPushButton* aLoadBtn = new QPushButton(tr("BUT_LOAD"), this); + connect(aLoadBtn, SIGNAL(clicked()), this, SLOT(loadFile())); + + aEditLayout->addWidget(aLoadBtn, 0, 2); + + myNextBtn = new QPushButton(tr("BUT_NEXT"), this); + myNextBtn->setEnabled(false); + connect(myNextBtn, SIGNAL(clicked()), this, SLOT(readFunction())); + + aEditLayout->addWidget(myNextBtn, 0, 3); + + //Second row + myText = new QTextEdit(this); + myText->setWordWrap(QTextEdit::FixedColumnWidth); + myText->setWrapColumnOrWidth(80); + + aEditLayout->addMultiCellWidget(myText, 1, 1, 0, 3); +} + + +/** + * Load existing Python script + */ +void SUPERVGUI_PythonEditPane::loadFile() { + QString aFileName = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), + "", + "*.py", + tr("TIT_LOADSCRIPT"), + true); + if (aFileName.isEmpty()) return; + + myFile = new QFile(aFileName); + if (!myFile->open(IO_ReadOnly)) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), + tr("MSG_CANT_LOADSCRIPT")); + return; + } + myIStream = new QTextStream(myFile); + + if (myIStream->atEnd()) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), + tr("MSG_EMTY_FILE")); + myNextBtn->setEnabled(false); + delete myIStream; + myIStream = 0; + myFile->close(); + delete myFile; + return; + } + myNextBtn->setEnabled(true); + readFunction(); +} + + +/** + * Finds and Reads a function from current position in the opened file + */ +void SUPERVGUI_PythonEditPane::readFunction() { + if (!myIStream) return; + + while (!myIStream->atEnd()) { + QString aLine = myIStream->readLine(); + if (aLine.isNull()) return; + + // find first function + int aDefPos = aLine.find("def"); + if (aDefPos == 0) { // only not a class members + myText->clear(); + // find name + /*int aStart = aLine.find(" ", aDefPos); + int aEnd = aLine.find("(", aStart); + QString aName = aLine.mid(aStart, (aEnd-aStart)); + aName = aName.stripWhiteSpace(); + myNameEdt->setText(aName);*/ + + // find input params + /*aStart = aEnd+1; + aEnd = aLine.find(")", aStart); + QString aParams = aLine.mid(aStart, (aEnd-aStart)); + aParams = aParams.stripWhiteSpace(); + myParamEdt->setText(aParams);*/ + + myText->append(aLine); + // read body + QString aBodyLine = myIStream->readLine(); + while ((!aBodyLine.isNull()) && aBodyLine[0].isSpace()) { + myText->append(aBodyLine); + aBodyLine = myIStream->readLine(); + } + return; + } + } + QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), + tr("MSG_NOMORE_FUNCTIONS")); + delete myIStream; + myIStream = 0; + myNextBtn->setEnabled(false); + myFile->close(); + delete myFile; +} + + +QString SUPERVGUI_PythonEditPane::getFuncName() { + QString aName(""); + for (int i=0; i < myText->paragraphs(); i++) { + QString aLine = myText->text(i); + int aDefPos = aLine.find("def"); + if (aDefPos == 0) { + int aStart = aLine.find(" ", aDefPos); + int aEnd = aLine.find("(", aStart); + QString aName = aLine.mid(aStart, (aEnd-aStart)); + return aName.stripWhiteSpace(); + } + } + return aName; +} + + +SUPERV_Strings SUPERVGUI_PythonEditPane::getFunction() { + SUPERV_Strings aStrings = new SUPERV::ListOfStrings(); + aStrings->length(myText->paragraphs()); + for (int i=0; i < myText->paragraphs(); i++) { + aStrings[i] = CORBA::string_dup(myText->text(i).latin1()); + } + return aStrings._retn(); +} + + +void SUPERVGUI_PythonEditPane::setFunction(SUPERV_Strings theStr) { + int aLen = theStr->length(); + for (int i=0; i < aLen; i++) + myText->append(QString(theStr[i])); +} + + + +/*! + * Edit Python dialog + */ +SUPERVGUI_EditPythonDlg::SUPERVGUI_EditPythonDlg(bool isLoop) + :QDialog(QAD_Application::getDesktop(), 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +{ + setSizeGripEnabled( true ); + setCaption(tr("TIT_FUNC_PYTHON")); + resize( 500, 250 ); + QVBoxLayout* aMainLayout = new QVBoxLayout(this, 7, 4); + if (isLoop) { + QTabWidget* aLoopTabPane = new QTabWidget(this); + myInitPane = new SUPERVGUI_PythonEditPane(this); + aLoopTabPane->addTab(myInitPane, "Init"); + + myMorePane = new SUPERVGUI_PythonEditPane(this); + aLoopTabPane->addTab(myMorePane, "More"); + + myNextPane = new SUPERVGUI_PythonEditPane(this); + aLoopTabPane->addTab(myNextPane, "Next"); + + aMainLayout->addWidget(aLoopTabPane); + } else { + myEditPane = new SUPERVGUI_PythonEditPane(this); + aMainLayout->addWidget(myEditPane); + } + QGroupBox* aBtnBox = new QGroupBox( this ); + aBtnBox->setColumnLayout( 0, Qt::Vertical ); + aBtnBox->layout()->setSpacing( 0 ); aBtnBox->layout()->setMargin( 0 ); + QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() ); + aBtnLayout->setAlignment( Qt::AlignTop ); + aBtnLayout->setSpacing( 6 ); aBtnLayout->setMargin( 11 ); + + QPushButton* aOKBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox ); + connect( aOKBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); + aBtnLayout->addWidget( aOKBtn ); + + aBtnLayout->addStretch(); + + QPushButton* aCancelBtn = new QPushButton( tr("BUT_CANCEL"), aBtnBox ); + connect( aCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + aBtnLayout->addWidget( aCancelBtn ); + + aMainLayout->addWidget(aBtnBox); +} diff --git a/src/SUPERVGUI/SUPERVGUI_Service.h b/src/SUPERVGUI/SUPERVGUI_Service.h new file mode 100644 index 0000000..3857650 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Service.h @@ -0,0 +1,159 @@ +// File : SUPERVGUI_Service.h +// Created : 7 / 11 / 2001 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGUI +// Copyright : CEA + +#ifndef SUPERVGUI_Service_H +#define SUPERVGUI_Service_H + +using namespace std; +#include "SUPERVGUI_Def.h" +#include +#include +#include + + +//***************************************************** +// Pane for Python script editing +//***************************************************** +class SUPERVGUI_PythonEditPane: public QFrame { + Q_OBJECT + + public: + SUPERVGUI_PythonEditPane(QWidget* theParent); + ~SUPERVGUI_PythonEditPane() {}; + + QString getFuncName(); + + bool isDefined() + { return (myText->paragraphs() > 1); } + + SUPERV_Strings getFunction(); + void setFunction(SUPERV_Strings theStr); + + public slots: + void loadFile(); + void readFunction(); + + private: + + //QLineEdit* myNameEdt; + //QLineEdit* myParamEdt; + QTextEdit* myText; + //QLineEdit* myOutParamEdt; + QPushButton* myNextBtn; + + QTextStream* myIStream; + QFile* myFile; +}; + + +//***************************************************** +// Dialog box for node creation +//***************************************************** + +class SUPERVGUI_Service: public QDialog { + Q_OBJECT + + public: + SUPERVGUI_Service(SALOME_NamingService* ns); + ~SUPERVGUI_Service(); + + void choose(); + + protected: + void showEvent(QShowEvent* theEvent); + + private: + void initialise(); + + private slots: + void tabChanged(QWidget *); + void addComputeNode(); + void addFactoryNode(); + void addInlineNode(); + void typeNodeSelected(int theRow); + + private: + QListView* components; + SALOME_NamingService* naming; + int myX, myY; + QWidgetStack* myStackWidget; + int myLoopId; + int myOtherId; + + SUPERVGUI_PythonEditPane* myScriptPane; + + SUPERVGUI_PythonEditPane* myInitPane; + SUPERVGUI_PythonEditPane* myMorePane; + SUPERVGUI_PythonEditPane* myNextPane; + + QTabWidget* myTabPane; + bool myIsInline; + + QComboBox* myTypeCombo; +}; + +/*! + * Edit Python dialog + */ +class SUPERVGUI_EditPythonDlg: public QDialog { + Q_OBJECT + + public: + SUPERVGUI_EditPythonDlg(bool isLoop = false); + ~SUPERVGUI_EditPythonDlg() {}; + + // Not Loop functions + QString getFuncName() + { return myEditPane->getFuncName(); } + + bool isDefined() + { return myEditPane->isDefined(); } + + SUPERV_Strings getFunction() + { return myEditPane->getFunction(); } + + void setFunction(SUPERV_Strings theStr) + { myEditPane->setFunction(theStr); } + + // Init functions + QString getInitFuncName() + { return myInitPane->getFuncName(); } + + SUPERV_Strings getInitFunction() + { return myInitPane->getFunction(); } + + void setInitFunction(SUPERV_Strings theStr) + { myInitPane->setFunction(theStr); } + + // More functions + QString getMoreFuncName() + { return myMorePane->getFuncName(); } + + SUPERV_Strings getMoreFunction() + { return myMorePane->getFunction(); } + + void setMoreFunction(SUPERV_Strings theStr) + { myMorePane->setFunction(theStr); } + + // Next functions + QString getNextFuncName() + { return myNextPane->getFuncName(); } + + SUPERV_Strings getNextFunction() + { return myNextPane->getFunction(); } + + void setNextFunction(SUPERV_Strings theStr) + { myNextPane->setFunction(theStr); } + + private: + SUPERVGUI_PythonEditPane* myEditPane; + SUPERVGUI_PythonEditPane* myInitPane; + SUPERVGUI_PythonEditPane* myMorePane; + SUPERVGUI_PythonEditPane* myNextPane; +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_View.cxx b/src/SUPERVGUI/SUPERVGUI_View.cxx new file mode 100644 index 0000000..e1a875a --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_View.cxx @@ -0,0 +1,174 @@ +using namespace std; +// File : SUPERVGUI_View.cxx +// Created : 24 / 10 / 2002 +// Author : Vitaly SMETANNIKOV +// Project : SALOME +// Module : SUPERVGUI +// Copyright : Open CASCADE + + +#include "SUPERVGUI_View.h" +#include "SUPERVGUI_Main.h" +#include "QAD_Config.h" + + + +#if QT_VERSION >= 0x030005 +QCursor panCursor(Qt::SizeAllCursor); +#else +QCursor panCursor(SizeAllCursor); +#endif + +SUPERVGUI_View::SUPERVGUI_View(SUPERVGUI_Main* theMain): + QScrollView(theMain, 0, Qt::WRepaintNoErase), + main(theMain) +{ + myIsPanActivated = false; + myAddStudyItem = 0; + myDx = 0; + myDx = 0; + myLastX = 0; + myLastY = 0; + myIsDragging = false; + myCursor = cursor(); + +// myLastMinVisX = horizontalScrollBar()->value(); //viewport()->x(); +// myLastMinVisY = verticalScrollBar()->value(); //viewport()->y(); + + myPopup = new QPopupMenu(viewport()); + + if (main->isEditable()) { + myPopup->insertItem(tr("MSG_ADD_NODE"), main, SLOT(addNode())); + myPopup->insertItem(tr("MSG_INS_FILE"), main, SLOT(insertFile())); + myPopup->insertSeparator(); + } + + myViewPopup = new QPopupMenu(viewport()); + myViewPopup->insertItem(tr("POP_FULLVIEW"), main, SLOT(showFullGraph())); + myViewPopup->insertItem(tr("POP_CONTROLVIEW"), main, SLOT(showContolFlow())); + myViewPopup->insertItem(tr("POP_TABLEVIEW"), main, SLOT(showTable())); + + myPopup->insertItem(tr("POP_VIEW"), myViewPopup); + myPopup->insertSeparator(); + + myAddStudyItem = myPopup->insertItem(tr("MSG_ADD_STUDY"), this, SLOT(addToStudy())); + myPopup->insertItem(tr("MSG_CHANGE_INFO"), main, SLOT(changeInformation())); + myPopup->insertSeparator(); + + myPopup->insertItem(tr("MSG_COPY_DATAFLOW"), main, SLOT(copy())); + myPopup->insertItem(tr("MSG_FILTER_NOTIFY"), main, SLOT(filterNotification())); + + QString aRed = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorRed"); + QString aGreen = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorGreen"); + QString aBlue = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorBlue"); + + if( (!aRed.isEmpty()) && (!aGreen.isEmpty()) && (!aBlue.isEmpty()) ) { + QColor aColor(aRed.toInt(), aGreen.toInt(), aBlue.toInt()); + setPaletteBackgroundColor(QColor(aRed.toInt(), aGreen.toInt(), aBlue.toInt())); + } else + setPaletteBackgroundColor(MAIN_COLOR); +} + + +SUPERVGUI_View::~SUPERVGUI_View() +{ +} + +void SUPERVGUI_View::viewportMousePressEvent(QMouseEvent* theEvent) +{ + myIsDragging = true; + myLastX = theEvent->globalX(); + myLastY = theEvent->globalY(); + + if (((theEvent->button() == Qt::MidButton)&&(theEvent->state() == Qt::ControlButton)) || myIsPanActivated) { + myCursor = cursor(); + setCursor(panCursor); + return; + } + QScrollView::viewportMousePressEvent(theEvent); +} + +void SUPERVGUI_View::viewportMouseMoveEvent(QMouseEvent* theEvent) +{ + if (myIsDragging && ((theEvent->state() == (Qt::ControlButton|Qt::MidButton)) || myIsPanActivated)) { + myDx = theEvent->globalX() - myLastX; + myDy = theEvent->globalY() - myLastY; + + myLastX = theEvent->globalX(); + myLastY = theEvent->globalY(); + + scrollBy(-myDx, -myDy); + return; + } + QScrollView::viewportMouseMoveEvent(theEvent); +} + + + +void SUPERVGUI_View::viewportMouseReleaseEvent(QMouseEvent* theEvent) +{ + myDx = 0; + myDx = 0; + myIsDragging = false; + myIsPanActivated = false; + setCursor(myCursor); + QScrollView::viewportMouseReleaseEvent(theEvent); +} + + +void SUPERVGUI_View::ActivatePanning() +{ + myIsPanActivated = true; +} + + +void SUPERVGUI_View::ResetView() +{ + setContentsPos(0,0); +} + + +void SUPERVGUI_View::setAsFromStudy(bool theToStudy) { + if (myAddStudyItem != 0) { + myPopup->setItemEnabled(myAddStudyItem, !theToStudy); + } +} + +void SUPERVGUI_View::addToStudy() { + if (main->addStudy()) main->setAsFromStudy(true); +} + +void SUPERVGUI_View::setPaletteBackgroundColor(const QColor& color) { + viewport()->setPaletteBackgroundColor(color); + QScrollView::setPaletteBackgroundColor(color.light()); + repaintContents(); +} + +void SUPERVGUI_View::ResizeGraph ( QWidget * theChild, int theX, int theY ) { + + int aGraphWidth = contentsWidth(); + int aGraphHeight = contentsHeight(); + if (theX > (contentsWidth() - theChild->width())) { + myLastX = theX; + myDx = theChild->width(); + aGraphWidth = theX + theChild->width(); + } + if (theY > (contentsHeight() - theChild->height())) { + myLastY = theY; + myDy = theChild->height(); + aGraphHeight = theY + theChild->height(); + } + + setMaximumWidth(aGraphWidth); + setMaximumHeight(aGraphHeight); + + resizeContents(aGraphWidth, aGraphHeight); +} + +int SUPERVGUI_View::getLastX() { + return myLastX; +} + +int SUPERVGUI_View::getLastY() { + return myLastY; +} diff --git a/src/SUPERVGUI/SUPERVGUI_View.h b/src/SUPERVGUI/SUPERVGUI_View.h new file mode 100644 index 0000000..59176d6 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_View.h @@ -0,0 +1,69 @@ +// File : SUPERVGUI_View.h +// Created : 24 / 10 / 2002 +// Author : Vitaly SMETANNIKOV +// Project : SALOME +// Module : SUPERVGUI +// Copyright : Open CASCADE + + +#ifndef SUPERVGUI_View_H +#define SUPERVGUI_View_H + +//#include "SUPERVGUI.h" +#include +#include + +//VRV: porting on Qt 3.0.5 +#if QT_VERSION >= 0x030005 +#include +#endif +//VRV: porting on Qt 3.0.5 + +class SUPERVGUI_Main; + +class SUPERVGUI_View: public QScrollView { + Q_OBJECT + + public: + SUPERVGUI_View(SUPERVGUI_Main* theMain); + virtual ~SUPERVGUI_View(); + + SUPERVGUI_Main* getMain() { return main; }; + + virtual void ActivatePanning(); + virtual void ResetView(); + virtual void setAsFromStudy(bool theToStudy); + + void setPaletteBackgroundColor(const QColor& color); + + void ResizeGraph( QWidget * theChild, int theX, int theY ); + + int getLastX(); + int getLastY(); + + public slots: + void addToStudy(); + + protected: + void viewportMouseMoveEvent(QMouseEvent* theEvent); + void viewportMouseReleaseEvent(QMouseEvent* theEvent); + void viewportMousePressEvent(QMouseEvent* theEvent); + + SUPERVGUI_Main* main; + QPopupMenu* myPopup; + QPopupMenu* myViewPopup; + bool myIsPanActivated; + int myAddStudyItem; + + private: + int myDx; + int myDy; + int myLastX; + int myLastY; + bool myIsDragging; + QCursor myCursor; + + +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_icons.po b/src/SUPERVGUI/SUPERVGUI_icons.po new file mode 100644 index 0000000..3a7e789 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_icons.po @@ -0,0 +1,14 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" +# would be translated to "Pub", not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"POT-Creation-Date: 2001-09-11 12:08:44 PM CEST\n" +"PO-Revision-Date: YYYY-MM-DD\n" +"Last-Translator: FULLNAME \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + +#: QAD_ObjectBrowser.cxx:140 +msgid "ICON_OBJBROWSER_Supervision" +msgstr "Superv_tree_superv.png" \ No newline at end of file diff --git a/src/SUPERVGUI/SUPERVGUI_msg_en.po b/src/SUPERVGUI/SUPERVGUI_msg_en.po new file mode 100644 index 0000000..87feedc --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_msg_en.po @@ -0,0 +1,578 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" +# would be translated to "Pub", not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"POT-Creation-Date: 2001-09-11 12:08:44 PM CEST\n" +"PO-Revision-Date: YYYY-MM-DD\n" +"Last-Translator: FULLNAME \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + +#Title of error messages +msgid "ERROR" +msgstr "Error" + +#:SUPERVGUI_Main.cxx:246 +msgid "MSG_FILE_EXIST" +msgstr "File '%1' exists.\nReplace?" + +#:SUPERVGUI_Main.cxx:252 +msgid "MSG_BAD_WRITING" +msgstr "Bad Writing File" + +#:SUPERVGUI_Main.cxx:242 +msgid "TTL_EXPORT_DATAFLOW" +msgstr "Export Dataflow As..." + +#:SUPERVGUI_Main.cxx:41 +msgid "MSG_ACCESS_BAD_IOR" +msgstr "Can't Access Dataflow: bad IOR" + +#:SUPERVGUI_Main.cxx:47 +msgid "MSG_NOACCESS_BY_IOR" +msgstr "Can't Access Dataflow by IOR" + +#:SUPERVGUI_Main.cxx:53 +msgid "MSG_CANT_CREATE_DF" +msgstr "Can't Create a New Dataflow" + +#:SUPERVGUI_Main.cxx:72 +msgid "MSG_BAD_FILE" +msgstr "Bad File: %1" + +#:SUPERVGUI_Main.cxx:86 +msgid "MSG_CANT_COPY" +msgstr "Can't Copy Dataflow" + +#:SUPERVGUI_Main.cxx:102 +msgid "MSG_DEL_LAST_PNT" +msgstr "Delete Last Point" + +#:SUPERVGUI_Main.cxx:103 +msgid "MSG_DEL_LINK" +msgstr "Delete Link" + +#:SUPERVGUI_Main.cxx:104 +msgid "MSG_ORTHO_LINE" +msgstr "Ortho Mode" + +#:SUPERVGUI_Main.cxx:146 +msgid "WARNING" +msgstr "Supervision Warning" + +#:SUPERVGUI_Main.cxx:147 +msgid "MSG_DF_RUNNING" +msgstr "Dataflow Is Currently Running" + +#:SUPERVGUI_Main.cxx:148 +msgid "MSG_DF_EXECUTION" +msgstr "Background Execution" + +#:SUPERVGUI_Main.cxx:149 +msgid "MSG_DF_KILL" +msgstr "Kill Execution" + +#:SUPERVGUI_Main.cxx:185 +msgid "GRAPH_TITLE" +msgstr "Supervision: " + +#:SUPERVGUI_Main.cxx:195 +msgid "MSG_GRAPH_STARTED" +msgstr "===> Dataflow Execution is started" + +#:SUPERVGUI_Main.cxx:191 +msgid "MSG_GRAPH_READONLY" +msgstr "===> Dataflow is Read Only" + +#:SUPERVGUI_Main.cxx:191 +msgid "MSG_GRAPH_EDITING" +msgstr "===> Dataflow is Modifiable" + +#:SUPERVGUI_Main.cxx:200 +msgid "MSG_GRAPH_SUSPENDED" +msgstr "===> Dataflow Execution is Suspended" + +#:SUPERVGUI_Main.cxx:204 +msgid "MSG_GRAPH_FINISHED" +msgstr "===> Dataflow Execution is Finished" + +#:SUPERVGUI_Main.cxx:208 +msgid "MSG_GRAPH_ABORTED" +msgstr "===> Dataflow Execution is Aborted" + +#:SUPERVGUI_Main.cxx:212 +msgid "MSG_GRAPH_KILLED" +msgstr "===> Dataflow Execution is Killed" + +#:SUPERVGUI_Main.cxx:265 +msgid "MSG_GRAPH_INSERT" +msgstr "Insert a Dataflow" + +#:SUPERVGUI_Main.cxx:285 +msgid "MSG_DF_NOTVALID" +msgstr "Dataflow Not Valid" + +#:SUPERVGUI_Main.cxx:287 +msgid "MSG_DF_NOTEXECUTABLE" +msgstr "Dataflow Not Executable" + +#:SUPERVGUI_Main.cxx:289 +msgid "MSG_DF_BADEXECUTE" +msgstr "Dataflow Bad Execute" + +#:SUPERVGUI_Main.cxx:301 +msgid "MSG_DF_NOTRUNNING" +msgstr "Dataflow Is Not Running" + +#:SUPERVGUI_Main.cxx:305 +msgid "MSG_CANTKILL_DF" +msgstr "Can't Kill Dataflow" + +#:SUPERVGUI_Main.cxx:315 +msgid "MSG_DF_RESUMED" +msgstr "===> Dataflow Execution is Resumed" + +#:SUPERVGUI_Main.cxx:318 +msgid "MSG_CANT_RESUME" +msgstr "Can't Resume Dataflow" + +#:SUPERVGUI_Main.cxx:324 +msgid "MSG_CANT_SUSPEND" +msgstr "Can't Suspend Dataflow" + +#:SUPERVGUI_Main.cxx:335 +msgid "MSG_DF_RESTARTED" +msgstr "===> Dataflow Execution is Restarted" + +#:SUPERVGUI_Main.cxx:338 +msgid "MSG_CANT_RESTART" +msgstr "Can't Restart Dataflow" + +#:SUPERVGUI_Main.cxx:344 +msgid "MSG_CANT_STOP" +msgstr "Can't Stop Dataflow" + +#:SUPERVGUI_Main.cxx:477 +msgid "MSG_CHOOSE_OUTPUT" +msgstr "Choose an Output Port" + +#:SUPERVGUI_Main.cxx:477 +msgid "MSG_CHOOSE_INPUT" +msgstr "Choose an Input Port" + +#:SUPERVGUI_Main.cxx:486 +msgid "MSG_CANT_CREATE_LINK" +msgstr "Can't Create This Link" + +#:SUPERVGUI_Main.cxx:508 +msgid "MSG_CANT_CREATE_POINT" +msgstr "Can't Create Point(s) For This Link" + +#:SUPERVGUI_Main.cxx:541 +msgid "MSG_RIGHTLINE" +msgstr "Right Line" + +#:SUPERVGUI_Main.cxx:541 +msgid "MSG_FREEPOINT" +msgstr "Free Point" + +#:SUPERVGUI_Main.cxx:627 +msgid "MSG_CHOOSE_DATA" +msgstr "Choose a Data in Study" + +#:SUPERVGUI_Main.cxx:170 +msgid "MSG_GRAPH_DISPLAYED" +msgstr "The DataFlow %1 \nis already displayed. Open again?" + +#:SUPERVGUI_Main.cxx:627 +msgid "MSG_NOTHING_COPY" +msgstr "Nothing to copy." + +msgid "MSG_CANT_CHANGELINK" +msgstr "Can't Change Point Coordinates For a Link" + +msgid "MSG_CANT_CHANGE_COORDLINK" +msgstr "Can't Change Coordinates For a Link" + +msgid "MSG_CANT_DEL_POINT" +msgstr "Can't Delete this Point" + +msgid "MSG_CANT_ADD_POINT" +msgstr "Can't Add this Point" + +msgid "MSG_CANT_GET_LNKCOORD" +msgstr "Can't Get Coordinates From a Link" + +msgid "MSG_NOT_IMPLEMENTED" +msgstr "Not Yet Implemented" + +msgid "MSG_CANT_STOPNODE" +msgstr "Can't Stop Node" + +msgid "MSG_CANT_RESTARTNODE" +msgstr "Can't Restart Node" + +msgid "MSG_CANT_KILLNODE" +msgstr "Can't Kill Node" + +msgid "MSG_CANT_SUSPENDNODE" +msgstr "Can't Suspend Node" + +msgid "MSG_CANT_RESUMENODE" +msgstr "Can't Resume Node" + +msgid "MSG_CANT_RENAMENODE" +msgstr "Can't Rename this Node" + +msgid "MSG_CHANGE_NODENAME" +msgstr "Change the Name of a Node" + +msgid "MSG_ENTER_NODENAME" +msgstr "Please, Enter a Node Name" + +msgid "MSG_STOP" +msgstr "Stop" + +msgid "MSG_RESTART" +msgstr "Restart" + +msgid "MSG_SUSPEND" +msgstr "Suspend" + +msgid "MSG_RESUME" +msgstr "Resume" + +msgid "MSG_KILL" +msgstr "Kill" + +msgid "MSG_DELETE" +msgstr "Delete" + +msgid "MSG_RENAME" +msgstr "Rename" + +msgid "MSG_CONFIGURE" +msgstr "Configure" + +msgid "MSG_CHANGE_INFO" +msgstr "Change Informations" + +msgid "MSG_SHOW_PYTHON" +msgstr "Show Python" + +msgid "MSG_ADD_BEFORE" +msgstr "Add Before" + +msgid "MSG_ADD_AFTER" +msgstr "Add After" + +msgid "MSG_DEL_POINT" +msgstr "Delete Point" + +msgid "MSG_NONODE_TOADD" +msgstr "No Node to Add in Dataflow" + +msgid "MSG_CANT_CHOOSE_SERVICE" +msgstr "Can't Choose a Service in a Component" + +msgid "MSG_NO_SUPERVISION_WINDOW" +msgstr "No Supervision Window Selected to Add Nodes in a Dataflow" + +msgid "MSG_SKETCH_LINK" +msgstr "Sketch Link" + +msgid "MSG_FROMSTUDY" +msgstr "Set From Study" + +msgid "MSG_SETVALUE" +msgstr "Set Value" + +msgid "MSG_BROWSE" +msgstr "Browse" + +msgid "MSG_DELLINK" +msgstr "Delete Link" + +msgid "MSG_CANT_SETVAL" +msgstr "Can't Set Input Value" + +msgid "TIT_INPUT_PORT" +msgstr "Constant for Input Port" + +msgid "MSG_ENTER_VALUE" +msgstr "Please, Enter a Value" + +msgid "MSG_IPORT_VAL" +msgstr "Input Port Value : " + +msgid "MSG_OPORT_VAL" +msgstr "Output Port Value : " + +msgid "MSG_INFO" +msgstr "Information" + +msgid "MSG_TERMINATE" +msgstr "Terminate" + +msgid "MSG_SHOWDATA" +msgstr "Show Data" + +msgid "MSG_CALL_DATASHOW" +msgstr "Call data show as soon ..." + +msgid "MSG_PUT_INSTUDY" +msgstr "Put in Study" + +msgid "MSG_NOT_INSTUDY" +msgstr "Not in Study" + +msgid "MSG_GRAPH_ISRUN" +msgstr "Dataflow is still executing. Kill it?" + +msgid "MSG_NOWINDOW_TO_SUSPEND" +msgstr "No Supervision Window Selected to Suspend or Resume a Dataflow" + +msgid "MSG_NOWINDOW_TO_ADD" +msgstr "No Supervision Window Selected to add new components" + +msgid "MSG_NOWINDOW_TO_EXPORT" +msgstr "No Supervision Window Selected to Export a Dataflow" + +msgid "MSG_CANT_LOAD_SUPERV" +msgstr "Cannot Find or Load Supervision Component" + +msgid "MSG_CANT_NARROW_SUPERV" +msgstr "Cannot _narrow Supervision Component" + +msgid "MSG_NOWINDOW_TO_RELOAD" +msgstr "No Supervision Window Selected to Reload a Dataflow" + +msgid "MSG_NOWINDOW_TO_RUN" +msgstr "No Supervision Window Selected to Run a Dataflow" + +msgid "MSG_NOWINDOW_TO_KILL" +msgstr "No Supervision Window Selected to Kill a Dataflow" + +msgid "MSG_IMPORT" +msgstr "Import Dataflow" + +msgid "MSG_NOTEDITABLE" +msgstr "Current Dataflow is not editable" + +msgid "MSG_ADD_STUDY" +msgstr "Add in Study" + +msgid "MSG_NO_DELLINK" +msgstr "No Link to Delete" + +msgid "MSG_NO_LINK_ADDPNT" +msgstr "No Link to Add a Point" + +msgid "MSG_ADD_NODE" +msgstr "Add Node" + +msgid "MSG_ADD_POINT" +msgstr "Add Point" + +msgid "MSG_INS_FILE" +msgstr "Insert File" + +msgid "MSG_COPY_DATAFLOW" +msgstr "Copy Dataflow" + +msgid "MSG_SWITCH_ARRAY" +msgstr "Switch Array" + +msgid "MSG_FILTER_NOTIFY" +msgstr "Filter Notification" + +msgid "MSG_SWITCH_GRAPH" +msgstr "Switch Graph" + +msgid "MSG_COPY_PREFIX" +msgstr "Copy%1_Of" + +msgid "TIT_RENAME" +msgstr "Rename Dataflow" + +msgid "TLT_INFORMATIONS" +msgstr "Informations" + +msgid "NAME_LBL" +msgstr "Name:" + +msgid "AUTHOR_LBL" +msgstr "Author:" + +msgid "CONTAINER_LBL" +msgstr "Container:" + +msgid "DATE_CREATION_LBL" +msgstr "Created:" + +msgid "DATE_MODIFICATION_LBL" +msgstr "Updated:" + +msgid "COMMENT_LBL" +msgstr "Comment:" + +msgid "BUT_OK" +msgstr "&OK" + +msgid "BUT_CANCEL" +msgstr "&Cancel" + +msgid "MSG_CANT_CHANGE_INFO" +msgstr "Can't Change Informations" + +msgid "MSG_ASK_DELETE" +msgstr "Selected object and its subobjects will be deleted.\nContinue?" + +msgid "POP_VIEW" +msgstr "View" + +msgid "POP_FULLVIEW" +msgstr "Full" + +msgid "POP_CONTROLVIEW" +msgstr "Control" + +msgid "POP_TABLEVIEW" +msgstr "Table" + +msgid "POP_SHOW" +msgstr "Show" + +msgid "POP_SHOWTITLES" +msgstr "Comment" + +msgid "POP_SHOWPORTS" +msgstr "Ports" + +msgid "TIT_BROWSENODE" +msgstr "Browse Node " + +msgid "BUT_APPLY" +msgstr "Ok" + +msgid "BUT_CLOSE" +msgstr "Close" + +msgid "TIT_SETVALUE_PORT" +msgstr "Set Value" + +msgid "ENTER_OR_SELECT_LBL" +msgstr "Enter value or select any object from the study" + +msgid "TIT_SERVICES" +msgstr "Add Node" + +msgid "TLT_FILTER_NOTIFY" +msgstr "Filter Notification" + +msgid "COL_COMPONENTS" +msgstr "Components and services" + +msgid "NOTIFICATION_LOGGING_LBL" +msgstr "Notification Logging" + +msgid "SAVE_LOG_LBL" +msgstr "Save in File" + +msgid "FILTER_LOG_LBL" +msgstr "Filtered File" + +msgid "BUT_BROWSE" +msgstr "Browse" + +msgid "ALL_FILES" +msgstr "All files (*.*)" + +msgid "CHOOSE_LOG_FILES_TLT" +msgstr "Select log file" + +msgid "ERR_CANT_OPEN_LOG_FILE" +msgstr "Can't Open Log file" + +msgid "COL_PORTTYPE" +msgstr "Port type" + +msgid "COL_PORTWAY" +msgstr "Port way" + +msgid "TIT_ADDNODE" +msgstr "Add Node" + +msgid "TIT_ADDCNODE" +msgstr "Add Compute Node" + +msgid "TIT_ADDFNODE" +msgstr "Add Factory Node" + +msgid "BTN_FACTORYNODE" +msgstr "Factory" + +msgid "BTN_SWITCHNODE" +msgstr "Switch" + +msgid "BTN_LOOPNODE" +msgstr "Loop" + +msgid "MODULES_PANE" +msgstr "Factory" + +msgid "INLINE_PANE" +msgstr "Inline" + +msgid "ENDNODE_PREFIX" +msgstr "EndOf" + +msgid "BUT_LOAD" +msgstr "Load from file..." + +msgid "BUT_NEXT" +msgstr "Next Function" + +msgid "TIT_LOADSCRIPT" +msgstr "Load Script" + +msgid "MSG_CANT_LOADSCRIPT" +msgstr "Can't open file" + +msgid "MSG_EMTY_FILE" +msgstr "File is empty" + +msgid "MSG_NOMORE_FUNCTIONS" +msgstr "No more functions in this file" + +msgid "MSG_SCRIPTTIP" +msgstr "Define Name, Input and Output parameters, and body of function\nin fields below accordingly" + +msgid "POP_HIDEPORTS" +msgstr "Hide Ports" + +msgid "COMMENT_FROM" +msgstr " from " + +msgid "COMMENT_PYTHON" +msgstr "Python function" + +msgid "COMMENT_CNODE" +msgstr "Compute Node" + +msgid "TIT_FUNC_PYTHON" +msgstr "Edit function" + +msgid "LBL_NODETYPE" +msgstr "Node type" + +msgid "ITM_DEL_PORT" +msgstr "Delete" + +msgid "MSG_CANT_CREATE_NODE" +msgstr "Can't create node" + +msgid "MSG_PORT_EXIST" +msgstr "Port with such name already exists" + diff --git a/src/SUPERVGUI/SUPERVGUI_msg_fr.po b/src/SUPERVGUI/SUPERVGUI_msg_fr.po new file mode 100644 index 0000000..9489845 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_msg_fr.po @@ -0,0 +1,421 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" +# would be translated to "Pub", not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"POT-Creation-Date: 2001-09-11 12:08:44 PM CEST\n" +"PO-Revision-Date: YYYY-MM-DD\n" +"Last-Translator: FULLNAME \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + +#Title of error messages +msgid "ERROR" +msgstr "Supervision Error" + +#:SUPERVGUI_Main.cxx:246 +msgid "MSG_FILE_EXIST" +msgstr "File '%1' exists.\nReplace?" + +#:SUPERVGUI_Main.cxx:252 +msgid "MSG_BAD_WRITING" +msgstr "Bad Writing File" + +#:SUPERVGUI_Main.cxx:242 +msgid "TTL_EXPORT_DATAFLOW" +msgstr "Export Dataflow As..." + +#:SUPERVGUI_Main.cxx:41 +msgid "MSG_ACCESS_BAD_IOR" +msgstr "Can't Access Dataflow: bad IOR" + +#:SUPERVGUI_Main.cxx:47 +msgid "MSG_NOACCESS_BY_IOR" +msgstr "Can't Access Dataflow by IOR" + +#:SUPERVGUI_Main.cxx:53 +msgid "MSG_CANT_CREATE_DF" +msgstr "Can't Create a New Dataflow" + +#:SUPERVGUI_Main.cxx:72 +msgid "MSG_BAD_FILE" +msgstr "Bad File" + +#:SUPERVGUI_Main.cxx:86 +msgid "MSG_CANT_COPY" +msgstr "Can't Copy Dataflow" + +#:SUPERVGUI_Main.cxx:102 +msgid "MSG_DEL_LAST_PNT" +msgstr "Delete Last Point" + +#:SUPERVGUI_Main.cxx:103 +msgid "MSG_DEL_LINK" +msgstr "Delete Link" + +#:SUPERVGUI_Main.cxx:104 +msgid "MSG_ORTHO_LINE" +msgstr "Ortho Mode" + +#:SUPERVGUI_Main.cxx:146 +msgid "WARNING" +msgstr "Supervision Warning" + +#:SUPERVGUI_Main.cxx:147 +msgid "MSG_DF_RUNNING" +msgstr "Dataflow Is Currently Running" + +#:SUPERVGUI_Main.cxx:148 +msgid "MSG_DF_EXECUTION" +msgstr "Background Execution" + +#:SUPERVGUI_Main.cxx:149 +msgid "MSG_DF_KILL" +msgstr "Kill Execution" + +#:SUPERVGUI_Main.cxx:185 +msgid "GRAPH_TITLE" +msgstr "Supervision: " + +#:SUPERVGUI_Main.cxx:195 +msgid "MSG_GRAPH_STARTED" +msgstr "===> Dataflow Execution is started" + +#:SUPERVGUI_Main.cxx:191 +msgid "MSG_GRAPH_READONLY" +msgstr "===> Dataflow is Read Only" + +#:SUPERVGUI_Main.cxx:191 +msgid "MSG_GRAPH_EDITING" +msgstr "===> Dataflow is Modifiable" + +#:SUPERVGUI_Main.cxx:200 +msgid "MSG_GRAPH_SUSPENDED" +msgstr "===> Dataflow Execution is Suspended" + +#:SUPERVGUI_Main.cxx:204 +msgid "MSG_GRAPH_FINISHED" +msgstr "===> Dataflow Execution is Finished" + +#:SUPERVGUI_Main.cxx:208 +msgid "MSG_GRAPH_ABORTED" +msgstr "===> Dataflow Execution is Aborted" + +#:SUPERVGUI_Main.cxx:212 +msgid "MSG_GRAPH_KILLED" +msgstr "===> Dataflow Execution is Killed" + +#:SUPERVGUI_Main.cxx:265 +msgid "MSG_GRAPH_INSERT" +msgstr "Insert a Dataflow" + +#:SUPERVGUI_Main.cxx:285 +msgid "MSG_DF_NOTVALID" +msgstr "Dataflow Not Valid" + +#:SUPERVGUI_Main.cxx:287 +msgid "MSG_DF_NOTEXECUTABLE" +msgstr "Dataflow Not Executable" + +#:SUPERVGUI_Main.cxx:289 +msgid "MSG_DF_BADEXECUTE" +msgstr "Dataflow Bad Execute" + +#:SUPERVGUI_Main.cxx:301 +msgid "MSG_DF_NOTRUNNING" +msgstr "Dataflow Is Not Running" + +#:SUPERVGUI_Main.cxx:305 +msgid "MSG_CANTKILL_DF" +msgstr "Can't Kill Dataflow" + +#:SUPERVGUI_Main.cxx:315 +msgid "MSG_DF_RESUMED" +msgstr "===> Dataflow Execution is Resumed" + +#:SUPERVGUI_Main.cxx:318 +msgid "MSG_CANT_RESUME" +msgstr "Can't Resume Dataflow" + +#:SUPERVGUI_Main.cxx:324 +msgid "MSG_CANT_SUSPEND" +msgstr "Can't Suspend Dataflow" + +#:SUPERVGUI_Main.cxx:335 +msgid "MSG_DF_RESTARTED" +msgstr "===> Dataflow Execution is Restarted" + +#:SUPERVGUI_Main.cxx:338 +msgid "MSG_CANT_RESTART" +msgstr "Can't Restart Dataflow" + +#:SUPERVGUI_Main.cxx:344 +msgid "MSG_CANT_STOP" +msgstr "Can't Stop Dataflow" + +#:SUPERVGUI_Main.cxx:477 +msgid "MSG_CHOOSE_OUTPUT" +msgstr "Choose an Output Port" + +#:SUPERVGUI_Main.cxx:477 +msgid "MSG_CHOOSE_INPUT" +msgstr "Choose an Input Port" + +#:SUPERVGUI_Main.cxx:486 +msgid "MSG_CANT_CREATE_LINK" +msgstr "Can't Create This Link" + +#:SUPERVGUI_Main.cxx:508 +msgid "MSG_CANT_CREATE_POINT" +msgstr "Can't Create Point(s) For This Link" + +#:SUPERVGUI_Main.cxx:541 +msgid "MSG_RIGHTLINE" +msgstr "Right Line" + +#:SUPERVGUI_Main.cxx:541 +msgid "MSG_FREEPOINT" +msgstr "Free Point" + +#:SUPERVGUI_Main.cxx:627 +msgid "MSG_CHOOSE_DATA" +msgstr "Choose a Data in Study" + +#:SUPERVGUI_Main.cxx:170 +msgid "MSG_GRAPH_DISPLAYED" +msgstr "The DataFlow %1 \nis already displayed. Open again?" + +#:SUPERVGUI_Main.cxx:627 +msgid "MSG_NOTHING_COPY" +msgstr "Nothing to copy." + +msgid "MSG_CANT_CHANGELINK" +msgstr "Can't Change Point Coordinates For a Link" + +msgid "MSG_CANT_CHANGE_COORDLINK" +msgstr "Can't Change Coordinates For a Link" + +msgid "MSG_CANT_DEL_POINT" +msgstr "Can't Delete this Point" + +msgid "MSG_CANT_ADD_POINT" +msgstr "Can't Add this Point" + +msgid "MSG_CANT_GET_LNKCOORD" +msgstr "Can't Get Coordinates From a Link" + +msgid "MSG_NOT_IMPLEMENTED" +msgstr "Not Yet Implemented" + +msgid "MSG_CANT_STOPNODE" +msgstr "Can't Stop Node" + +msgid "MSG_CANT_RESTARTNODE" +msgstr "Can't Restart Node" + +msgid "MSG_CANT_KILLNODE" +msgstr "Can't Kill Node" + +msgid "MSG_CANT_SUSPENDNODE" +msgstr "Can't Suspend Node" + +msgid "MSG_CANT_RESUMENODE" +msgstr "Can't Resume Node" + +msgid "MSG_CANT_RENAMENODE" +msgstr "Can't Rename this Node" + +msgid "MSG_CHANGE_NODENAME" +msgstr "Change the Name of a Node" + +msgid "MSG_ENTER_NODENAME" +msgstr "Please, Enter a Node Name" + +msgid "MSG_STOP" +msgstr "Stop" + +msgid "MSG_RESTART" +msgstr "Restart" + +msgid "MSG_SUSPEND" +msgstr "Suspend" + +msgid "MSG_RESUME" +msgstr "Resume" + +msgid "MSG_KILL" +msgstr "Kill" + +msgid "MSG_DELETE" +msgstr "Delete" + +msgid "MSG_RENAME" +msgstr "Rename" + +msgid "MSG_CONFIGURE" +msgstr "Configure" + +msgid "MSG_CHANGE_INFO" +msgstr "Change Informations" + +msgid "MSG_SHOW_PYTHON" +msgstr "Show Python" + +msgid "MSG_ADD_BEFORE" +msgstr "Add Before" + +msgid "MSG_ADD_AFTER" +msgstr "Add After" + +msgid "MSG_DEL_POINT" +msgstr "Delete Point" + +msgid "MSG_NONODE_TOADD" +msgstr "No Node to Add in Dataflow" + +msgid "MSG_CANT_CHOOSE_SERVICE" +msgstr "Can't Choose a Service in a Component" + +msgid "MSG_NO_SUPERVISION_WINDOW" +msgstr "No Supervision Window Selected to Add Nodes in a Dataflow" + +msgid "MSG_SKETCH_LINK" +msgstr "Sketch Link" + +msgid "MSG_FROMSTUDY" +msgstr "Set From Study" + +msgid "MSG_SETVALUE" +msgstr "Set Value" + +msgid "MSG_BROWSE" +msgstr "Browse" + +msgid "MSG_DELLINK" +msgstr "Delete Link" + +msgid "MSG_CANT_SETVAL" +msgstr "Can't Set Input Value" + +msgid "TIT_INPUT_PORT" +msgstr "Constant for Input Port" + +msgid "MSG_ENTER_VALUE" +msgstr "Please, Enter a Value" + +msgid "MSG_IPORT_VAL" +msgstr "Input Port Value : " + +msgid "MSG_OPORT_VAL" +msgstr "Output Port Value : " + +msgid "MSG_INFO" +msgstr "Supervision Information" + +msgid "MSG_TERMINATE" +msgstr "Terminate" + +msgid "MSG_SHOWDATA" +msgstr "Show Data" + +msgid "MSG_CALL_DATASHOW" +msgstr "Call data show as soon ..." + +msgid "MSG_PUT_INSTUDY" +msgstr "Put in Study" + +msgid "MSG_NOT_INSTUDY" +msgstr "Not in Study" + +msgid "MSG_GRAPH_ISRUN" +msgstr "Dataflow is still executing. Kill it?" + +msgid "MSG_NOWINDOW_TO_SUSPEND" +msgstr "No Supervision Window Selected to Suspend or Resume a Dataflow" + +msgid "MSG_NOWINDOW_TO_ADD" +msgstr "No Supervision Window Selected to add new components" + +msgid "MSG_NOWINDOW_TO_EXPORT" +msgstr "No Supervision Window Selected to Export a Dataflow" + +msgid "MSG_CANT_LOAD_SUPERV" +msgstr "Cannot Find or Load Supervision Component" + +msgid "MSG_CANT_NARROW_SUPERV" +msgstr "Cannot _narrow Supervision Component" + +msgid "MSG_NOWINDOW_TO_RELOAD" +msgstr "No Supervision Window Selected to Reload a Dataflow" + +msgid "MSG_NOWINDOW_TO_RUN" +msgstr "No Supervision Window Selected to Run a Dataflow" + +msgid "MSG_NOWINDOW_TO_KILL" +msgstr "No Supervision Window Selected to Kill a Dataflow" + +msgid "MSG_IMPORT" +msgstr "Import Dataflow" + +msgid "MSG_NOTEDITABLE" +msgstr "Current Dataflow is not editable" + +msgid "MSG_ADD_STUDY" +msgstr "Add in Study" + +msgid "MSG_NO_DELLINK" +msgstr "No Link to Delete" + +msgid "MSG_NO_LINK_ADDPNT" +msgstr "No Link to Add a Point" + +msgid "MSG_ADD_NODE" +msgstr "Add Node" + +msgid "MSG_ADD_POINT" +msgstr "Add Point" + +msgid "MSG_INS_FILE" +msgstr "Insert File" + +msgid "MSG_COPY_DATAFLOW" +msgstr "Copy Dataflow" + +msgid "MSG_SWITCH_ARRAY" +msgstr "Switch Array" + +msgid "MSG_FILTER_NOTIFY" +msgstr "Filter Notification" + +msgid "MSG_SWITCH_GRAPH" +msgstr "Switch Graph" + +msgid "MSG_COPY_PREFIX" +msgstr "Copy%1_Of" + +msgid "TIT_RENAME" +msgstr "Rename Dataflow" + +msgid "MSG_ASK_DELETE" +msgstr "Selected object and its subobjects will be deleted.\nContinue?" + +msgid "POP_VIEW" +msgstr "View" + +msgid "POP_FULLVIEW" +msgstr "Full" + +msgid "POP_CONTROLVIEW" +msgstr "Control" + +msgid "POP_TABLEVIEW" +msgstr "Table" + +msgid "POP_SHOW" +msgstr "Show" + +msgid "POP_SHOWTITLES" +msgstr "Titles" + +msgid "POP_SHOWPORTS" +msgstr "Ports" diff --git a/src/Supervision/CNode_Impl.cxx b/src/Supervision/CNode_Impl.cxx new file mode 100644 index 0000000..a65f2f2 --- /dev/null +++ b/src/Supervision/CNode_Impl.cxx @@ -0,0 +1,1315 @@ +using namespace std; +//============================================================================= +// File : CNode_Impl.cxx +// Created : 2003 +// Author : Jean Rahuel +// Project : SALOME +// $Header: +//============================================================================= + +#include +#include +#include +#include + +#include "utilities.h" + +#include "Graph_Impl.hxx" + +#include "CNode_Impl.hxx" + +#include "Port_Impl.hxx" + +CNode_Impl::CNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + const char *aDataFlowName ) : + Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { +// MESSAGE("CNode_Impl::CNode_Impl activate object instanceName(" +// << instanceName << ") interfaceName(" << interfaceName << ") --> " +// << hex << (void *) this << dec ) +// _thisObj = this ; +// _id = _poa->activate_object(_thisObj); + MESSAGE( "CNode_Impl::CNode_Impl " << aDataFlowName << " " ); + beginService( "CNode_Impl::CNode_Impl" ); + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; + _DataFlowNode = NULL ; + _IsNode = false ; + endService( "CNode_Impl::CNode_Impl" ); +} + +CNode_Impl::CNode_Impl() { +} + +CNode_Impl::CNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + const SALOME_ModuleCatalog::Service &NodeService , + const char * NodeName , + const SUPERV::KindOfNode NodeKindOfNode , + const char * FuncName , + const SUPERV::ListOfStrings & PythonFunction ) : + Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { + beginService( "CNode_Impl::CNode_Impl" ); + if ( FuncName && NodeName ) { + cout << "CNode_Impl::CNode_Impl " << (void *) NodeName << " " << NodeName + << " " << strlen(NodeName) << " " << (void *) FuncName << " " << FuncName + << " " << strlen( FuncName ) << endl ; + } + if ( NodeKindOfNode == SUPERV::ComputingNode ) { + MESSAGE( "CNode_Impl::CNode_Impl " << FuncName << " _poa->activate_object" ); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + } + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; + _DataFlowEditor = DataFlowEditor ; + GraphBase::ListOfFuncName aFuncName ; + GraphBase::ListOfPythonFunctions aPythonFunction ; + if ( FuncName ) { + aFuncName.resize(1) ; + aFuncName[0] = my_strdup( FuncName ) ; + aPythonFunction.resize(1) ; + aPythonFunction[0] = &PythonFunction ; + } + _DataFlowNode = _DataFlowEditor->AddNode( NodeService , "" , "" , NodeName , + NodeKindOfNode , + aFuncName , + aPythonFunction ) ; + _IsNode = true ; + endService( "CNode_Impl::CNode_Impl" ); +} + +CNode_Impl::CNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + const SALOME_ModuleCatalog::Service &NodeService , + const char * NodeName , + const SUPERV::KindOfNode NodeKindOfNode , + const GraphBase::ListOfFuncName & aFuncName , + const GraphBase::ListOfPythonFunctions & aPythonFunction ) : + Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { + MESSAGE( NodeName << " " ); + beginService( "CNode_Impl::CNode_Impl" ); + if ( NodeName ) { + MESSAGE("CNode_Impl::CNode_Impl " << NodeName << " " << strlen( NodeName ) ) ; + } + if ( NodeKindOfNode == SUPERV::ComputingNode ) { + MESSAGE( "CNode_Impl::CNode_Impl " << aFuncName[0] << " _poa->activate_object" ); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + } + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; + _DataFlowEditor = DataFlowEditor ; + _DataFlowNode = _DataFlowEditor->AddNode( NodeService , "" , "" , NodeName , + NodeKindOfNode , + aFuncName , + aPythonFunction ) ; + _IsNode = true ; + endService( "CNode_Impl::CNode_Impl" ); +} + +CNode_Impl::CNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode ) : + Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { + MESSAGE( DataFlowNode->Name() << " " ); + beginService( "CNode_Impl::CNode_Impl" ); + if ( DataFlowNode->IsComputingNode() ) { + MESSAGE( "CNode_Impl::CNode_Impl _poa->activate_object" ); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + } + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; + _DataFlowEditor = DataFlowEditor ; + _DataFlowNode = DataFlowNode ; + _IsNode = true ; + endService( "CNode_Impl::CNode_Impl" ); +} + +CNode_Impl::~CNode_Impl() { + beginService( "CNode_Impl::~CNode_Impl" ); + endService( "CNode_Impl::~CNode_Impl" ); +} + +void CNode_Impl::destroy() { + beginService( "CNode_Impl::Destroy" ); + if ( _DataFlowEditor->IsEditing() ) { + if ( Delete() ) { + _DataFlowNode = NULL ; + _poa->deactivate_object(*_id) ; + CORBA::release(_poa) ; + delete(_id) ; + _thisObj->_remove_ref(); + } + } + endService( "CNode_Impl::Destroy" ); +} + +bool CNode_Impl::Delete() { + beginService( "CNode_Impl::Delete" ); + bool RetVal = false ; + if ( _DataFlowEditor->IsEditing() ) { + RetVal = _DataFlowEditor->RemoveNode( Name() ) ; + if ( RetVal ) + RetVal = _DataFlowEditor->IsValid() ; + } + endService( "CNode_Impl::Delete" ); + return RetVal ; +} + +SALOME_ModuleCatalog::Service * CNode_Impl::Service() { +// beginService( "CNode_Impl::Service" ); + SALOME_ModuleCatalog::Service * RetVal ; + if ( _IsNode ) { + RetVal = new SALOME_ModuleCatalog::Service( *_DataFlowNode->GetService() ) ; + } + else { + RetVal = new SALOME_ModuleCatalog::Service( *_DataFlowEditor->GetService() ) ; + } +// endService( "CNode_Impl::Service" ); + return RetVal ; +} + +char * CNode_Impl::Name() { +// beginService( "CNode_Impl::Name" ); + char * RetVal = NULL ; + if ( _IsNode ) { + RetVal = _DataFlowNode->Name() ; + } + else { + RetVal = _DataFlowEditor->Name() ; + } +// endService( "CNode_Impl::Name" ); + return CORBA::string_dup( RetVal ); +} +bool CNode_Impl::SetName( const char * aDataFlowName ) { +// beginService( "CNode_Impl::SetName" ); + bool RetVal = false ; + if ( _DataFlowEditor->IsEditing() ) { + if ( _IsNode ) { + RetVal = _DataFlowEditor->ReNameNode( _DataFlowNode->Name() , + aDataFlowName ) ; + } + else { + RetVal = _DataFlowEditor->Name( aDataFlowName ) ; + } + } +// endService( "CNode_Impl::SetName" ); + return RetVal ; +} +SUPERV::KindOfNode CNode_Impl::Kind() { +// beginService( "CNode_Impl::Kind" ); + SUPERV::KindOfNode RetVal = SUPERV::UnknownNode ; + if ( _IsNode ) { + RetVal = _DataFlowNode->Kind() ; + } + else { + RetVal = _DataFlowEditor->Kind() ; + } +// endService( "CNode_Impl::Kind" ); + return RetVal ; +} +bool CNode_Impl::IsGraph() { +// beginService( "CNode_Impl::IsGraph" ); + bool RetVal = false ; + if ( _IsNode ) { + RetVal = _DataFlowNode->IsDataFlowNode() ; + } + else { + RetVal = _DataFlowEditor->IsDataFlowNode() ; + } +// endService( "CNode_Impl::IsGraph" ); + return RetVal ; +} +bool CNode_Impl::IsComputing() { +// beginService( "CNode_Impl::IsComputing" ); + bool RetVal = SUPERV::UnknownNode ; + if ( _IsNode ) { + RetVal = _DataFlowNode->IsComputingNode() ; + } + else { + RetVal = _DataFlowEditor->IsComputingNode() ; + } +// endService( "CNode_Impl::IsComputing" ); + return RetVal ; +} +bool CNode_Impl::IsFactory() { +// beginService( "CNode_Impl::IsFactory" ); + bool RetVal = SUPERV::UnknownNode ; + if ( _IsNode ) { + RetVal = _DataFlowNode->IsFactoryNode() ; + } + else { + RetVal = _DataFlowEditor->IsFactoryNode() ; + } +// endService( "CNode_Impl::IsFactory" ); + return RetVal ; +} +bool CNode_Impl::IsInLine() { +// beginService( "CNode_Impl::IsInLine" ); + bool RetVal = SUPERV::UnknownNode ; + if ( _IsNode ) { + RetVal = _DataFlowNode->IsInLineNode() ; + } + else { + RetVal = _DataFlowEditor->IsInLineNode() ; + } +// endService( "CNode_Impl::IsInLine" ); + return RetVal ; +} +bool CNode_Impl::IsGOTO() { +// beginService( "CNode_Impl::IsGOTO" ); + bool RetVal = SUPERV::UnknownNode ; + if ( _IsNode ) { + RetVal = _DataFlowNode->IsGOTONode() ; + } + else { + RetVal = _DataFlowEditor->IsGOTONode() ; + } +// endService( "CNode_Impl::IsGOTO" ); + return RetVal ; +} +bool CNode_Impl::IsLoop() { +// beginService( "CNode_Impl::IsLoop" ); + bool RetVal = SUPERV::UnknownNode ; + if ( _IsNode ) { + RetVal = _DataFlowNode->IsLoopNode() ; + } + else { + RetVal = _DataFlowEditor->IsLoopNode() ; + } +// endService( "CNode_Impl::IsLoop" ); + return RetVal ; +} +bool CNode_Impl::IsEndLoop() { +// beginService( "CNode_Impl::IsEndLoop" ); + bool RetVal = SUPERV::UnknownNode ; + if ( _IsNode ) { + RetVal = _DataFlowNode->IsEndLoopNode() ; + } + else { + RetVal = _DataFlowEditor->IsEndLoopNode() ; + } +// endService( "CNode_Impl::IsEndLoop" ); + return RetVal ; +} +bool CNode_Impl::IsSwitch() { +// beginService( "CNode_Impl::IsSwitch" ); + bool RetVal = SUPERV::UnknownNode ; + if ( _IsNode ) { + RetVal = _DataFlowNode->IsSwitchNode() ; + } + else { + RetVal = _DataFlowEditor->IsSwitchNode() ; + } +// endService( "CNode_Impl::IsSwitch" ); + return RetVal ; +} +bool CNode_Impl::IsEndSwitch() { +// beginService( "CNode_Impl::IsEndSwitch" ); + bool RetVal = SUPERV::UnknownNode ; + if ( _IsNode ) { + RetVal = _DataFlowNode->IsEndSwitchNode() ; + } + else { + RetVal = _DataFlowEditor->IsEndSwitchNode() ; + } +// endService( "CNode_Impl::IsEndSwitch" ); + return RetVal ; +} + +SUPERV::SDate CNode_Impl::CreationDate() { +// beginService( "CNode_Impl::CreationDate" ); + SUPERV::SDate_var RetVal ; + if ( _IsNode ) { + RetVal = new SUPERV::SDate( _DataFlowNode->FirstCreation() ) ; + } + else { +// cout << " CNode_Impl::CreationDate " << _DataFlowEditor->FirstCreation() +// << endl ; + RetVal = new SUPERV::SDate( _DataFlowEditor->FirstCreation() ) ; + } +// endService( "CNode_Impl::CreationDate" ); + return (RetVal._retn()) ; +} +SUPERV::SDate CNode_Impl::LastUpdateDate() { +// beginService( "CNode_Impl::LastUpdateDate" ); + SUPERV::SDate_var RetVal ; + if ( _IsNode ) { + RetVal = new SUPERV::SDate( _DataFlowNode->LastModification() ) ; + } + else { + RetVal = new SUPERV::SDate( _DataFlowEditor->LastModification() ) ; + } +// endService( "CNode_Impl::LastUpdateDate" ); + return (RetVal._retn()) ; +} +char * CNode_Impl::Version() { +// beginService( "CNode_Impl::Version" ); + char * RetVal ; + if ( _IsNode ) { + RetVal = _DataFlowNode->EditorRelease() ; + } + else { + RetVal = _DataFlowEditor->EditorRelease() ; + } +// endService( "CNode_Impl::Version" ); + return CORBA::string_dup( RetVal ) ; +} +char * CNode_Impl::Author() { +// beginService( "CNode_Impl::Author" ); + char * RetVal ; + if ( _IsNode ) { + RetVal = _DataFlowNode->Author() ; + } + else { + RetVal = _DataFlowEditor->Author() ; + } +// endService( "CNode_Impl::Author" ); + return CORBA::string_dup( RetVal ) ; +} +bool CNode_Impl::SetAuthor( const char * aDataFlowAuthor ) { +// beginService( "CNode_Impl::SetAuthor" ); + bool RetVal = false ; + if ( _DataFlowEditor->IsEditing() ) { + if ( _IsNode ) { + RetVal = _DataFlowNode->Author( aDataFlowAuthor ) ; + } + else { + RetVal = _DataFlowEditor->Author( aDataFlowAuthor ) ; + } + } +// endService( "CNode_Impl::SetAuthor" ); + return RetVal ; +} +char * CNode_Impl::Comment() { +// beginService( "CNode_Impl::Comment" ); + char * RetVal ; + if ( _IsNode ) { + RetVal = _DataFlowNode->Comment() ; + } + else { + RetVal = _DataFlowEditor->Comment() ; + } +// endService( "CNode_Impl::Comment" ); + return CORBA::string_dup( RetVal ) ; +} +bool CNode_Impl::SetComment( const char * aDataFlowComment ) { +// beginService( "CNode_Impl::SetComment" ); + bool RetVal = false ; + if ( _DataFlowEditor->IsEditing() ) { + if ( _IsNode ) { + RetVal = _DataFlowNode->Comment( aDataFlowComment ) ; + } + else { + RetVal = _DataFlowEditor->Comment( aDataFlowComment ) ; + } + } +// endService( "CNode_Impl::SetComment" ); + return RetVal ; +} + +SUPERV::ListOfLinks * CNode_Impl::Links() { + beginService( "CNode_Impl::Links" ) ; + SUPERV::ListOfLinks_var RetVal = new SUPERV::ListOfLinks ; + if ( _DataFlowNode ) { + RetVal = DataFlowEditor()->ObjImpl()->Links( _DataFlowNode->ComputingNode() , NULL ) ; + } + endService( "CNode_Impl::Links" ) ; + return ( RetVal._retn() ) ; +} + +void CNode_Impl::Coords(long X , long Y ) { +// beginService( "CNode_Impl::Coords" ); + if ( _DataFlowEditor->IsEditing() ) { + if ( _IsNode ) { + ((GraphEditor::InNode *) _DataFlowNode)->Coordinates( X , Y ) ; + } + else { + _DataFlowEditor->Coordinates( X , Y ) ; + } + } +// endService( "CNode_Impl::Coords" ); +} +long CNode_Impl::X() { +// beginService( "CNode_Impl::X" ); + long RetVal ; + if ( _IsNode ) { + RetVal = _DataFlowNode->XCoordinate() ; + } + else { +// RetVal = _DataFlowEditor->XCoordinate() ; + RetVal = 0 ; + } +// endService( "CNode_Impl::X" ); + return RetVal ; +} +long CNode_Impl::Y() { +// beginService( "CNode_Impl::Y" ); + long RetVal ; + if ( _IsNode ) { + RetVal = _DataFlowNode->YCoordinate() ; + } + else { +// RetVal = _DataFlowEditor->YCoordinate() ; + RetVal = 0 ; + } +// endService( "CNode_Impl::Y" ); + return RetVal ; +} + +#if 0 +SUPERV::Link_ptr CNode_Impl::Link( const char * ToServiceParameterName , + const SUPERV::Value_ptr aValue ) { + beginService( "CNode_Impl::Link" ); + Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , + ToServiceParameterName , + aValue ) ; + PortableServer::ObjectId * id = myLink->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::Link_var iobject ; + iobject = SUPERV::Link::_narrow(obj) ; + endService( "CNode_Impl::Link" ); + return SUPERV::Link::_duplicate( iobject ) ; +} +#endif + +SUPERV::Port_ptr CNode_Impl::Port( const char * ServiceParameterName ) { + bool begin = true ; + Port_Impl * myPort = NULL ; + SUPERV::Port_var iobject = SUPERV::Port::_nil() ; + bool aninport ; + if ( _IsNode ) { + aninport = _DataFlowNode->GetInPort( ServiceParameterName ) ; + } + else { + aninport = _DataFlowEditor->GetInPort( ServiceParameterName ) ; + } + bool anoutport ; + if ( _IsNode ) { + anoutport = _DataFlowNode->GetOutPort( ServiceParameterName ) ; + } + else { + anoutport = _DataFlowEditor->GetOutPort( ServiceParameterName ) ; + } + if ( aninport ) { + GraphBase::InPort * anInPort ; + if ( _IsNode ) { + anInPort = _DataFlowNode->GetChangeInPort( ServiceParameterName ) ; + } + else { + anInPort = _DataFlowEditor->GetChangeInPort( ServiceParameterName ) ; + } + if ( CORBA::is_nil( anInPort->ObjRef() ) ) { + if ( begin ) { + beginService( "CNode_Impl::Port" ); + begin = false ; + } + bool hasinput ; + if ( _IsNode ) { + hasinput = _DataFlowNode->HasInput( anInPort->PortName() ) ; + } + else { + hasinput = _DataFlowEditor->HasInput( anInPort->PortName() ) ; + } + if ( hasinput ) { + const CORBA::Any * anAny = anInPort->GetOutPort()->Value() ; + myPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , +// ServiceParameterName , + (GraphBase::Port * ) anInPort , + true , + anAny ) ; + } + else { + myPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , +// ServiceParameterName ) ; + (GraphBase::Port * ) anInPort , + true ) ; + } + PortableServer::ObjectId * id = myPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::Port::_narrow(obj) ; + anInPort->ObjRef( SUPERV::Port::_duplicate( iobject ) ) ; + } + else { + iobject = anInPort->ObjRef() ; + } + } + else if ( anoutport ) { + GraphBase::OutPort * anOutPort ; + if ( _IsNode ) { + anOutPort = _DataFlowNode->GetChangeOutPort( ServiceParameterName ) ; + } + else { + anOutPort = _DataFlowEditor->GetChangeOutPort( ServiceParameterName ) ; + } + if ( CORBA::is_nil( anOutPort->ObjRef() ) ) { + if ( begin ) { + beginService( "CNode_Impl::Port" ); + begin = false ; + } + const CORBA::Any * anAny = anOutPort->Value() ; + myPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , +// ServiceParameterName , + (GraphBase::Port * ) anOutPort , + false , + anAny ) ; + PortableServer::ObjectId * id = myPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::Port::_narrow(obj) ; + anOutPort->ObjRef( SUPERV::Port::_duplicate( iobject ) ) ; + } + else { + iobject = anOutPort->ObjRef() ; + } + } + if ( !begin ) { + endService( "CNode_Impl::Port" ); + } + return SUPERV::Port::_duplicate( iobject ) ; +} + +SUPERV::Port_ptr CNode_Impl::Input( const char * ToServiceParameterName , + const SUPERV::Value_ptr aValue ) { + bool begin = true ; + SUPERV::Port_var iobject = SUPERV::Port::_nil() ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowEditor->IsEditing() ) { + bool sts = false ; + GraphBase::InPort * anInPort ; + if ( _IsNode ) { + sts = _DataFlowEditor->AddInputData( _DataFlowNode->Name() , + ToServiceParameterName , + *aValue->ToAny() ) ; + anInPort = _DataFlowNode->GetChangeInPort( ToServiceParameterName ) ; + } + else { + sts = _DataFlowEditor->AddInputData( _DataFlowEditor->Name() , + ToServiceParameterName , + *aValue->ToAny() ) ; + anInPort = _DataFlowEditor->GetChangeInPort( ToServiceParameterName ) ; + } + if ( sts && anInPort ) { + if ( CORBA::is_nil( anInPort->ObjRef() ) ) { + if ( begin ) { + beginService( "CNode_Impl::Input" ); + begin = false ; + } + Port_Impl * myPort ; + myPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , +// ToServiceParameterName , + (GraphBase::Port * ) anInPort , + true , + aValue->ToAny() ) ; + PortableServer::ObjectId * id = myPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::Port::_narrow(obj) ; + anInPort->ObjRef( SUPERV::Port::_duplicate( iobject ) ) ; + } + else { + iobject = anInPort->ObjRef() ; + } + } + } + else if ( _DataFlowExecutor ) { + bool sts = false ; + GraphBase::InPort * anInPort ; + if ( _IsNode ) { + sts = _DataFlowExecutor->ChangeInputData( _DataFlowEditor->Name() , + ToServiceParameterName , + *aValue->ToAny() ) ; + anInPort = _DataFlowNode->GetChangeInPort( ToServiceParameterName ) ; + } + else { + sts = _DataFlowExecutor->ChangeInputData( _DataFlowEditor->Name() , + ToServiceParameterName , + *aValue->ToAny() ) ; + anInPort = _DataFlowEditor->GetChangeInPort( ToServiceParameterName ) ; + } + if ( sts && anInPort ) { + if ( CORBA::is_nil( anInPort->ObjRef() ) ) { + if ( begin ) { + beginService( "CNode_Impl::Input" ); + begin = false ; + } + Port_Impl * myPort ; + myPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , +// ToServiceParameterName , + (GraphBase::Port * ) anInPort , + true , + aValue->ToAny() ) ; + PortableServer::ObjectId * id = myPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::Port::_narrow(obj) ; + anInPort->ObjRef( SUPERV::Port::_duplicate( iobject ) ) ; + } + else { + iobject = anInPort->ObjRef() ; + } + } + } + if ( !begin ) { + endService( "CNode_Impl::Input" ); + } + return SUPERV::Port::_duplicate( iobject ) ; +} + +SUPERV::ListOfPorts * CNode_Impl::Ports() { + bool begin = true ; + SUPERV::ListOfPorts_var RetVal = new SUPERV::ListOfPorts ; +// if ( !_DataFlowNode->IsDataFlowNode() ) { + if ( _IsNode ) { + int i , j ; + RetVal->length( _DataFlowNode->GetNodeInPortsSize() + + _DataFlowNode->GetNodeOutPortsSize() ) ; + for ( i = 0 ; i < _DataFlowNode->GetNodeInPortsSize() ; i++ ) { + GraphBase::InPort * anInPort = _DataFlowNode->GetChangeNodeInPort( i ) ; + if ( CORBA::is_nil( anInPort->ObjRef() ) ) { + if ( begin ) { + beginService( "CNode_Impl::Ports" ); + begin = false ; + } + Port_Impl * myPort ; + if ( _DataFlowNode->HasInput( anInPort->PortName() ) ) { + const CORBA::Any * anAny = anInPort->GetOutPort()->Value() ; + myPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , +// anInPort->PortName() , + (GraphBase::Port * ) anInPort , + true , + anAny ) ; + } + else { + myPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , +// anInPort->PortName() ) ; + (GraphBase::Port * ) anInPort , + true ) ; + } + PortableServer::ObjectId * id = myPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::Port_var iobject ; + iobject = SUPERV::Port::_narrow(obj) ; + RetVal[ i ] = SUPERV::Port::_duplicate( iobject ) ; + anInPort->ObjRef( SUPERV::Port::_duplicate( iobject ) ) ; + } + else { + RetVal[ i ] = SUPERV::Port::_duplicate( anInPort->ObjRef() ) ; + } + } + for ( i = 0 ; i < _DataFlowNode->GetNodeOutPortsSize() ; i++ ) { + GraphBase::OutPort * anOutPort = _DataFlowNode->GetChangeNodeOutPort( i ) ; + if ( CORBA::is_nil( anOutPort->ObjRef() ) ) { + if ( begin ) { + beginService( "CNode_Impl::Ports" ); + begin = false ; + } + const CORBA::Any * anAny = anOutPort->Value() ; + Port_Impl * myPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , +// anOutPort->PortName() , + (GraphBase::Port * ) anOutPort , + false , + anAny ) ; + PortableServer::ObjectId * id = myPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::Port_var iobject ; + iobject = SUPERV::Port::_narrow(obj) ; + RetVal[ _DataFlowNode->GetNodeInPortsSize() + i ] = SUPERV::Port::_duplicate( iobject ) ; + anOutPort->ObjRef( SUPERV::Port::_duplicate( iobject ) ) ; + } + else { + RetVal[ _DataFlowNode->GetNodeInPortsSize() + i ] = SUPERV::Port::_duplicate( anOutPort->ObjRef() ) ; + } + } + } + else { + if ( _DataFlowEditor->IsValid() ) { + int i , j ; + RetVal->length( _DataFlowEditor->GetNodeInDataNodePortsSize() + + _DataFlowEditor->GetNodeOutDataNodePortsSize() ) ; + for ( i = 0 ; i < _DataFlowEditor->GetNodeInDataNodePortsSize() ; i++ ) { + GraphBase::OutPort * anOutPort = _DataFlowEditor->GetChangeNodeInDataNodePort(i) ; + if ( CORBA::is_nil( anOutPort->ObjRef() ) ) { + if ( begin ) { + beginService( "CNode_Impl::Ports" ); + begin = false ; + } + Port_Impl * myPort ; + if ( anOutPort->IsDataConnected() ) { + const CORBA::Any * anAny = anOutPort->Value() ; + myPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , +// anOutPort->PortName() , + (GraphBase::Port * ) anOutPort , + true , + anAny ) ; + } + else { + myPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , +// anOutPort->PortName() ) ; + (GraphBase::Port * ) anOutPort , + true ) ; + } + PortableServer::ObjectId * id = myPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::Port_var iobject ; + iobject = SUPERV::Port::_narrow(obj) ; + RetVal[ i ] = SUPERV::Port::_duplicate( iobject ) ; + anOutPort->ObjRef( SUPERV::Port::_duplicate( iobject ) ) ; + } + else { + RetVal[ i ] = SUPERV::Port::_duplicate( anOutPort->ObjRef() ) ; + } + } + j = _DataFlowEditor->GetNodeInDataNodePortsSize() ; + for ( i = 0 ; i < _DataFlowEditor->GetNodeOutDataNodePortsSize() ; i++ ) { + GraphBase::InPort * anInPort = _DataFlowEditor->GetChangeNodeOutDataNodePort(i) ; + if ( CORBA::is_nil( anInPort->ObjRef() ) ) { + if ( begin ) { + beginService( "CNode_Impl::Ports" ); + begin = false ; + } + Port_Impl * myPort ; + if ( anInPort->IsDataConnected() ) { + const CORBA::Any * anAny = anInPort->GetOutPort()->Value() ; + myPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , +// anInPort->PortName() , + (GraphBase::Port * ) anInPort , + false , + anAny ) ; + } + else { + myPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , +// anInPort->PortName() ) ; + anInPort , + false ) ; + } + PortableServer::ObjectId * id = myPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::Port_var iobject ; + iobject = SUPERV::Port::_narrow(obj) ; + RetVal[ j + i ] = SUPERV::Port::_duplicate( iobject ) ; + anInPort->ObjRef( SUPERV::Port::_duplicate( iobject ) ) ; + } + else { + RetVal[ j + i ] = SUPERV::Port::_duplicate( anInPort->ObjRef() ) ; + } + } + } + } + if ( !begin ) { + endService( "CNode_Impl::Ports" ); + } + return ( RetVal._retn() ) ; +} + +SUPERV::Link_ptr CNode_Impl::GetLink(const char * ToServiceParameterName ) { + bool begin = true ; + SUPERV::Link_var iobject = SUPERV::Link::_nil() ; + char* FromNodeName ; + char* FromServiceParameterName ; + bool status = _DataFlowEditor->GetLink( _DataFlowNode->Name() , + ToServiceParameterName , + & FromNodeName , + & FromServiceParameterName ) ; + if ( status ) { + GraphBase::InPort * anInPort = _DataFlowNode->GetChangeInPort( ToServiceParameterName ) ; + if ( anInPort->GetOutPort() ) { + GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; + if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) { + if ( begin ) { + beginService( "CNode_Impl::GetLink" ); + begin = false ; + } + Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , + ToServiceParameterName , + (GraphEditor::InNode *) _DataFlowEditor->GetChangeGraphNode( FromNodeName )->GetInNode() , + FromServiceParameterName , + true ) ; + PortableServer::ObjectId * id = myLink->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::Link::_narrow(obj) ; + anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ; + } + else { + iobject = anOutPort->InPortObjRef( anInPort ) ; + } + } + } + if ( !begin ) { + endService( "CNode_Impl::GetLink" ); + } + return SUPERV::Link::_duplicate( iobject ) ; +} + +long CNode_Impl::SubGraph() { +// beginService( "CNode_Impl::SubGraph" ); + long RetVal = 0 ; + if ( _IsNode ) { + RetVal = _DataFlowNode->SubGraph() ; + } +// endService( "CNode_Impl::SubGraph" ); + return RetVal ; +} + +bool CNode_Impl::IsLinked(const char * ServiceParameterName ) { +// beginService( "CNode_Impl::IsLinked" ); + bool RetVal = _DataFlowNode->IsLinked( ServiceParameterName ) ; +// endService( "CNode_Impl::IsLinked" ); + return RetVal ; +} + +bool CNode_Impl::HasInput(const char * ServiceParameterName ) { +// beginService( "CNode_Impl::HasInput" ); + bool RetVal = _DataFlowNode->HasInput( ServiceParameterName ) ; +// endService( "CNode_Impl::HasInput" ); + return RetVal ; +} + +SUPERV::GraphState CNode_Impl::State() { +// beginService( "CNode_Impl::State" ); + SUPERV::GraphState RetVal = SUPERV::EditingState ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->State( Name() ) ; + } + else { + RetVal = _DataFlowExecutor->State() ; + } + } +// endService( "CNode_Impl::State" ); + return RetVal ; +} +long CNode_Impl::Thread() { +// beginService( "CNode_Impl::Thread" ); + long RetVal = 0 ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->Thread( Name() ) ; + } + else { + RetVal = _DataFlowExecutor->Thread() ; + } + } +// endService( "CNode_Impl::Thread" ); + return RetVal ; +} +SUPERV::AutomatonState CNode_Impl::AutoState() { +// beginService( "CNode_Impl::AutoState" ); + SUPERV::AutomatonState RetVal = SUPERV::UnKnownState ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->AutomatonState( Name() ) ; + } + else { + RetVal = _DataFlowExecutor->AutomatonState() ; + } + } +// endService( "CNode_Impl::AutoState" ); + return RetVal ; +} +SUPERV::ControlState CNode_Impl::Control() { +// beginService( "CNode_Impl::Control" ); + SUPERV::ControlState RetVal = SUPERV::VoidState ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->ControlState( Name() ) ; + } + else { + RetVal = _DataFlowExecutor->ControlState() ; + } + } +// endService( "CNode_Impl::Control" ); + return RetVal ; +} +void CNode_Impl::ControlClear() { +// beginService( "CNode_Impl::ControlClear" ); + SUPERV::ControlState RetVal = SUPERV::VoidState ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + _DataFlowExecutor->ControlClear( Name() ) ; + } + else { + _DataFlowExecutor->ControlClear() ; + } + } +// endService( "CNode_Impl::ControlClear" ); + return ; +} + +bool CNode_Impl::IsReady() { +// beginService( "CNode_Impl::IsReady" ); + bool RetVal = false ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->IsReady( Name() ) ; + } + else { + RetVal = _DataFlowExecutor->IsReady() ; + } + } +// endService( "CNode_Impl::IsReady" ); + return RetVal ; +} + +bool CNode_Impl::IsWaiting() { +// beginService( "CNode_Impl::IsWaiting" ); + bool RetVal = false ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->IsWaiting( Name() ) ; + } + else { + RetVal = _DataFlowExecutor->IsWaiting() ; + } + } +// endService( "CNode_Impl::IsWaiting" ); + return RetVal ; +} + +bool CNode_Impl::IsRunning() { +// beginService( "CNode_Impl::IsRunning" ); + bool RetVal = false ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->IsRunning( Name() ) ; + } + else { + RetVal = _DataFlowExecutor->IsRunning() ; + } + } +// endService( "CNode_Impl::IsRunning" ); + return RetVal ; +} + +bool CNode_Impl::IsDone() { +// beginService( "CNode_Impl::IsDone" ); + bool RetVal = false ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->IsDone( Name() ) ; + } + else { + RetVal = _DataFlowExecutor->IsDone() ; + } + } +// endService( "CNode_Impl::IsDone" ); + return RetVal ; +} + +bool CNode_Impl::IsSuspended() { +// beginService( "CNode_Impl::IsSuspended" ); + bool RetVal = false ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->IsSuspended( Name() ) ; + } + else { + RetVal = _DataFlowExecutor->IsSuspended() ; + } + } +// endService( "CNode_Impl::IsSuspended" ); + return RetVal ; +} + +bool CNode_Impl::ReadyW() { +// beginService( "CNode_Impl::ReadyW" ); + bool RetVal = false ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->ReadyWait( Name() ) ; + } + else { + RetVal = _DataFlowExecutor->ReadyWait() ; + } + } +// endService( "CNode_Impl::ReadyW" ); + return RetVal ; +} + +bool CNode_Impl::RunningW() { +// beginService( "CNode_Impl::RunningW" ); + bool RetVal = false ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->RunningWait( Name() ) ; + } + else { + RetVal = _DataFlowExecutor->RunningWait() ; + } + } +// endService( "CNode_Impl::RunningW" ); + return RetVal ; +} + +bool CNode_Impl::DoneW() { +// beginService( "CNode_Impl::DoneW" ); + bool RetVal = false ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->DoneWait( Name() ) ; + } + else { + RetVal = _DataFlowExecutor->DoneWait() ; + } + } +// endService( "CNode_Impl::DoneW" ); + return RetVal ; +} + +bool CNode_Impl::SuspendedW() { +// beginService( "CNode_Impl::SuspendedW" ); + bool RetVal = false ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->SuspendedWait( Name() ) ; + } + else { + RetVal = _DataFlowExecutor->SuspendedWait() ; + } + } +// endService( "CNode_Impl::SuspendedW" ); + return RetVal ; +} + +void CNode_Impl::ping() { +// beginService( "CNode_Impl::ping" ); + bool RetVal = false ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->Ping( Name() ) ; + } + else { + RetVal = false ; + } + } +// endService( "CNode_Impl::ping" ); + return ; +} + +bool CNode_Impl::ContainerKill() { + beginService( "CNode_Impl::ContainerKill" ); + bool RetVal = false ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor && _DataFlowEditor->IsExecuting() ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->ContainerKill( Name() ) ; + } + else { + RetVal = _DataFlowExecutor->ContainerKill() ; + } + } + endService( "CNode_Impl::ContainerKill" ); + return RetVal ; +} +bool CNode_Impl::Kill() { +// beginService( "CNode_Impl::Kill" ); + bool RetVal = false ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->Kill( Name() ) ; + } + else { + RetVal = _DataFlowExecutor->Kill() ; + } + } +// endService( "CNode_Impl::Kill" ); + return RetVal ; +} +bool CNode_Impl::KillDone() { +// beginService( "CNode_Impl::KillDone" ); + bool RetVal = false ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->KillDone( Name() ) ; + } + } +// endService( "CNode_Impl::KillDone" ); + return RetVal ; +} +bool CNode_Impl::Stop() { +// beginService( "CNode_Impl::Stop" ); + bool RetVal ; // = _DataFlowExecutor->Stop() ; +// endService( "CNode_Impl::Stop" ); + return RetVal ; +} +bool CNode_Impl::Suspend() { +// beginService( "CNode_Impl::Suspend" ); + bool RetVal = false ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->Suspend( Name() ) ; + } + else { + RetVal = _DataFlowExecutor->Suspend() ; + } + } +// endService( "CNode_Impl::Suspend" ); + return RetVal ; +} +bool CNode_Impl::SuspendDone() { +// beginService( "CNode_Impl::SuspendDone" ); + bool RetVal = false ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->SuspendDone( Name() ) ; + } + else { + RetVal = _DataFlowExecutor->SuspendDone() ; + } + } +// endService( "CNode_Impl::SuspendDone" ); + return RetVal ; +} +bool CNode_Impl::Resume() { +// beginService( "CNode_Impl::Resume" ); + bool RetVal = false ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->Resume( Name() ) ; + } + else { + RetVal = _DataFlowExecutor->Resume() ; + } + } +// endService( "CNode_Impl::Resume" ); + return RetVal ; +} + +bool CNode_Impl::ReRun() { + beginService( "CNode_Impl::ReRun" ); + bool RetVal = false ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->Run( Name() , Name() , false ) ; + } + else { + RetVal = _DataFlowExecutor->Run( false ) ; + } + } + endService( "CNode_Impl::ReRun" ); + return RetVal ; +} + +bool CNode_Impl::ReRunAt( const char * aNodeName ) { + beginService( "CNode_Impl::ReRunAt" ); + bool RetVal = false ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->Run( Name() , aNodeName , false ) ; + } + } + endService( "CNode_Impl::ReRunAt" ); + return RetVal ; +} + +bool CNode_Impl::ReStart() { + beginService( "CNode_Impl::ReStart" ); + bool RetVal = false ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->Run( Name() , Name() , true ) ; + } + else { + RetVal = _DataFlowExecutor->Run( true ) ; + } + } + endService( "CNode_Impl::ReStart" ); + return RetVal ; +} + +bool CNode_Impl::ReStartAt( const char * aNodeName ) { + beginService( "CNode_Impl::ReStartAt" ); + bool RetVal = false ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + if ( _IsNode ) { + RetVal = _DataFlowExecutor->Run( Name() , aNodeName , true ) ; + } + } + endService( "CNode_Impl::ReStartAt" ); + return RetVal ; +} + diff --git a/src/Supervision/CNode_Impl.hxx b/src/Supervision/CNode_Impl.hxx new file mode 100644 index 0000000..d6397a6 --- /dev/null +++ b/src/Supervision/CNode_Impl.hxx @@ -0,0 +1,199 @@ +//============================================================================= +// File : CNode_Impl.hxx +// Created : 2003 +// Author : Jean Rahuel +// Project : SALOME +// Copyright : CEA +// $Header: +//============================================================================= + +#ifndef _CNODE_IMPL_HXX_ +#define _CNODE_IMPL_HXX_ + +#include + +#include "CORBA.h" + +#include +#include "SALOME_Component_i.hxx" +#include "SALOME_LifeCycleCORBA.hxx" + +#include "DataFlowEditor_DataFlow.hxx" +#include "DataFlowExecutor_DataFlow.hxx" + +class CNode_Impl : public POA_SUPERV::CNode , + public Engines_Component_i { + private: + + CORBA::ORB_ptr _Orb ; + PortableServer::POA_ptr _Poa ; + PortableServer::ObjectId * _ContId ; + + GraphEditor::DataFlow * _DataFlowEditor ; + GraphEditor::InNode * _DataFlowNode ; + bool _IsNode ; + + public: + CNode_Impl(); + CNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + const char *aDataFlowName ) ; + CNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + const SALOME_ModuleCatalog::Service &NodeService , + const char * NodeName = NULL , + const SUPERV::KindOfNode NodeKindOfNode = SUPERV::ComputingNode , + const char * aFuncName = NULL , + const SUPERV::ListOfStrings & aPythonFunction = SUPERV::ListOfStrings() ) ; + CNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + const SALOME_ModuleCatalog::Service &NodeService , + const char * NodeName = NULL , + const SUPERV::KindOfNode NodeKindOfNode = SUPERV::InLineNode , + const GraphBase::ListOfFuncName & aFuncName = GraphBase::ListOfFuncName() , + const GraphBase::ListOfPythonFunctions & aPythonFunction = GraphBase::ListOfPythonFunctions() ) ; + CNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode ) ; + virtual ~CNode_Impl() ; + virtual void destroy() ; + virtual bool Delete() ; + + virtual void DataFlowEditor( GraphEditor::DataFlow * DataFlowEditor ) { + _DataFlowEditor = DataFlowEditor ; } ; + virtual GraphEditor::DataFlow * DataFlowEditor() { + return _DataFlowEditor ; } ; + virtual void DataFlowNode( GraphEditor::InNode * DataFlowNode ) { + _DataFlowNode = DataFlowNode ; } ; + virtual GraphEditor::InNode * DataFlowNode() { + return _DataFlowNode ; } ; + + virtual char * Name() ; + virtual bool SetName( const char * aDataFlowName ) ; + virtual SALOME_ModuleCatalog::Service * Service() ; + virtual SUPERV::KindOfNode Kind() ; + virtual SUPERV::SDate CreationDate() ; + virtual SUPERV::SDate LastUpdateDate() ; + virtual char * Version() ; + virtual char * Author() ; + virtual bool SetAuthor( const char * aDataFlowAuthor ) ; + virtual char * Comment() ; + virtual bool SetComment( const char * aDataFlowComment ) ; + + virtual GraphEditor::InNode * DataFlowNode() const { + return _DataFlowNode ; } ; + virtual GraphBase::ComputingNode * BaseNode() { + return _DataFlowNode->ComputingNode() ; } ; + + virtual SUPERV::CNode_var ObjRef() { + SUPERV::CNode_var iobject = SUPERV::GNode::_nil() ; + if ( _DataFlowNode && _IsNode ) { + iobject = SUPERV::CNode::_narrow( _DataFlowNode->ObjRef() ) ; + } + else { + iobject = SUPERV::CNode::_narrow( _DataFlowEditor->ObjRef() ) ; + } + return iobject ; } ; + virtual void SetObjRef(SUPERV::CNode_var aNode ) { + if ( _DataFlowNode && _IsNode ) { + _DataFlowNode->SetObjRef( aNode ) ; + } + else { + _DataFlowEditor->SetObjRef( SUPERV::Graph::_narrow( aNode ) ) ; + } } ; + + virtual void Coords( const long X , const long Y ) ; + virtual long X() ; + virtual long Y() ; + + virtual SUPERV::Port_ptr Port( const char * aParameterName ) ; + +// virtual bool BusPorts( const char * InputParameterName , +// const char * InputParameterType , +// const char * OutputParameterName , +// const char * OutputParameterType , +// SUPERV::Port_out InputPort , +// SUPERV::Port_out OutputPort ) ; + +// virtual SUPERV::Link_ptr Link( const char * ToServiceParameterName , +// const SUPERV::Value_ptr aValue ) ; + + virtual SUPERV::Port_ptr Input( const char * ToServiceParameterName , + const SUPERV::Value_ptr aValue ) ; + + virtual SUPERV::ListOfPorts * Ports() ; + + virtual SUPERV::ListOfLinks * Links() ; + + virtual SUPERV::Link_ptr GetLink( const char * ToServiceParameterName ) ; + + virtual bool IsGraph() ; + virtual bool IsComputing() ; + virtual bool IsFactory() ; + virtual bool IsInLine() ; + virtual bool IsGOTO() ; + virtual bool IsLoop() ; + virtual bool IsEndLoop() ; + virtual bool IsSwitch() ; + virtual bool IsEndSwitch() ; + + virtual long SubGraph() ; + + virtual bool IsLinked(const char * ToServiceParameterName ) ; + virtual bool HasInput(const char * ToServiceParameterName ) ; + +// virtual SUPERV::Link_ptr GetLink(const char * ToServiceParameterName ) ; +// virtual SUPERV::Value_ptr GetValue(const char * FromServiceParameterName ) ; + + virtual bool IsReady() ; + virtual bool IsWaiting() ; + virtual bool IsRunning() ; + virtual bool IsDone() ; + virtual bool IsSuspended() ; + + virtual SUPERV::GraphState State() ; + virtual SUPERV::ControlState Control() ; + virtual void ControlClear() ; + + virtual long Thread() ; + + virtual SUPERV::AutomatonState AutoState() ; + + virtual bool ReadyW() ; + virtual bool RunningW() ; + virtual bool DoneW() ; + virtual bool SuspendedW() ; + + virtual void ping() ; + virtual bool ContainerKill() ; + + virtual bool Kill() ; + virtual bool KillDone() ; + virtual bool Stop() ; + virtual bool Suspend() ; + virtual bool SuspendDone() ; + virtual bool Resume() ; + + virtual bool ReRun() ; + virtual bool ReRunAt( const char * aNodeName ) ; + virtual bool ReStart() ; + virtual bool ReStartAt( const char * aNodeName ) ; + +} ; + +#endif diff --git a/src/Supervision/ELNode_Impl.cxx b/src/Supervision/ELNode_Impl.cxx new file mode 100644 index 0000000..747e5d7 --- /dev/null +++ b/src/Supervision/ELNode_Impl.cxx @@ -0,0 +1,94 @@ +using namespace std; +//============================================================================= +// File : ELNode_Impl.cxx +// Created : Nov 2001 +// Author : Jean Rahuel +// Project : SALOME +// $Header: +//============================================================================= + +#include +#include +#include +#include + +#include "utilities.h" + +#include "ELNode_Impl.hxx" + +ELNode_Impl::ELNode_Impl() { +} + +ELNode_Impl::ELNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * aDataFlowEditor , + const char * EndName , + const SUPERV::KindOfNode NodeKindOfNode ) : +// Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { + GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , EndName , SUPERV::ListOfStrings() , NodeKindOfNode ) { +// MESSAGE( NodeName << " " ); + beginService( "ELNode_Impl::ELNode_Impl" ); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; +// DataFlowNode( DataFlowEditor()->AddNode( InitFunction , MoreFunction , NextFunction , +// NodeName , NodeKindOfNode ) ) ; +// DataFlowNode( DataFlowEditor()->AddNode( SALOME_ModuleCatalog::Service() , +// "" , "" , "" , +// NodeKindOfNode ) ) ; + endService( "ELNode_Impl::ELNode_Impl" ); +} + +ELNode_Impl::ELNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * aDataFlowEditor , + GraphEditor::InNode * aDataFlowNode ) : +// Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { + GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) { + MESSAGE( DataFlowNode()->Name() << " " ); + beginService( "ELNode_Impl::ELNode_Impl" ); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; + endService( "ELNode_Impl::ELNode_Impl" ); +} + +ELNode_Impl::~ELNode_Impl() { + beginService( "ELNode_Impl::~ELNode_Impl" ); + endService( "ELNode_Impl::~ELNode_Impl" ); +} + +void ELNode_Impl::destroy() { + beginService( "ELNode_Impl::Destroy" ); + if ( DataFlowEditor()->IsEditing() ) { + if ( Delete() ) { + _poa->deactivate_object(*_id) ; + CORBA::release(_poa) ; + delete(_id) ; + _thisObj->_remove_ref(); + } + } + endService( "ELNode_Impl::Destroy" ); +} + +bool ELNode_Impl::Delete() { +// beginService( "ELNode_Impl::Delete" ); + bool RetVal = false ; + if ( DataFlowEditor()->IsEditing() ) { + RetVal = DataFlowEditor()->RemoveNode( Name() ) ; + if ( RetVal ) + RetVal = DataFlowEditor()->IsValid() ; + } +// endService( "ELNode_Impl::Delete" ); + return RetVal ; +} diff --git a/src/Supervision/ELNode_Impl.hxx b/src/Supervision/ELNode_Impl.hxx new file mode 100644 index 0000000..682b204 --- /dev/null +++ b/src/Supervision/ELNode_Impl.hxx @@ -0,0 +1,62 @@ +//============================================================================= +// File : ELNode_Impl.hxx +// Created : 2003 +// Author : Jean Rahuel +// Project : SALOME +// Copyright : CEA +// $Header: +//============================================================================= + +#ifndef _ELNODE_IMPL_HXX_ +#define _ELNODE_IMPL_HXX_ + +#include + +#include "CORBA.h" + +#include +#include "SALOME_Component_i.hxx" +#include "SALOME_LifeCycleCORBA.hxx" + +#include "GNode_Impl.hxx" + +#include "Port_Impl.hxx" + +#include "DataFlowEditor_DataFlow.hxx" +#include "DataFlowExecutor_DataFlow.hxx" + +class ELNode_Impl : public GNode_Impl , + public POA_SUPERV::ELNode { + private: + + CORBA::ORB_ptr _Orb ; + PortableServer::POA_ptr _Poa ; + PortableServer::ObjectId * _ContId ; + + public: + ELNode_Impl(); + ELNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + const char * EndName , + const SUPERV::KindOfNode NodeKindOfNode = SUPERV::EndLoopNode ) ; + ELNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode ) ; + virtual ~ELNode_Impl() ; + virtual void destroy() ; + virtual bool Delete() ; + + virtual GraphBase::EndOfLoopNode * BaseNode() { + return DataFlowNode()->EndOfLoopNode() ; } ; + +} ; + +#endif diff --git a/src/Supervision/ESNode_Impl.cxx b/src/Supervision/ESNode_Impl.cxx new file mode 100644 index 0000000..cfaa8f3 --- /dev/null +++ b/src/Supervision/ESNode_Impl.cxx @@ -0,0 +1,100 @@ +using namespace std; +//============================================================================= +// File : ESNode_Impl.cxx +// Created : 2003 +// Author : Jean Rahuel +// Project : SALOME +// $Header: +//============================================================================= + +#include +#include +#include +#include + +#include "utilities.h" + +#include "ESNode_Impl.hxx" + +ESNode_Impl::ESNode_Impl() { +} + +ESNode_Impl::ESNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * aDataFlowEditor , + const char * FuncName , + const SUPERV::KindOfNode NodeKindOfNode ) : +// Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { + GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , FuncName , SUPERV::ListOfStrings() , NodeKindOfNode ) { +// MESSAGE( NodeName << " " ); + beginService( "ESNode_Impl::ESNode_Impl" ); + if ( FuncName ) { + cout << "ESNode_Impl::GNode_Impl " << (void *) FuncName << " " << FuncName + << " " << strlen( FuncName ) << endl ; + } + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; +// DataFlowNode( DataFlowEditor()->AddNode( NodeService , NodeComponentName , +// NodeInterfaceName , NodeName , +// NodeKindOfNode ) ) ; +// DataFlowNode( DataFlowEditor()->AddNode( SALOME_ModuleCatalog::Service() , +// "" , "" , "" , +// NodeKindOfNode ) ) ; + endService( "ESNode_Impl::ESNode_Impl" ); +} + +ESNode_Impl::ESNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * aDataFlowEditor , + GraphEditor::InNode * aDataFlowNode ) : +// Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { + GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) { + MESSAGE( DataFlowNode()->Name() << " " ); + beginService( "ESNode_Impl::ESNode_Impl" ); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; + endService( "ESNode_Impl::ESNode_Impl" ); +} + +ESNode_Impl::~ESNode_Impl() { + beginService( "ESNode_Impl::~ESNode_Impl" ); + endService( "ESNode_Impl::~ESNode_Impl" ); +} + +void ESNode_Impl::destroy() { + beginService( "ESNode_Impl::Destroy" ); + if ( DataFlowEditor()->IsEditing() ) { + if ( Delete() ) { + _poa->deactivate_object(*_id) ; + CORBA::release(_poa) ; + delete(_id) ; + _thisObj->_remove_ref(); + } + } + endService( "ESNode_Impl::Destroy" ); +} + +bool ESNode_Impl::Delete() { +// beginService( "ESNode_Impl::Delete" ); + bool RetVal = false ; + if ( DataFlowEditor()->IsEditing() ) { + RetVal = DataFlowEditor()->RemoveNode( Name() ) ; + if ( RetVal ) + RetVal = DataFlowEditor()->IsValid() ; + } +// endService( "ESNode_Impl::Delete" ); + return RetVal ; +} + diff --git a/src/Supervision/ESNode_Impl.hxx b/src/Supervision/ESNode_Impl.hxx new file mode 100644 index 0000000..809e8e2 --- /dev/null +++ b/src/Supervision/ESNode_Impl.hxx @@ -0,0 +1,61 @@ +//============================================================================= +// File : ESNode_Impl.hxx +// Created : 2003 +// Author : Jean Rahuel +// Project : SALOME +// Copyright : CEA 2003 +// $Header: +//============================================================================= + +#ifndef _ESNODE_IMPL_HXX_ +#define _ESNODE_IMPL_HXX_ + +#include + +#include "CORBA.h" + +#include +#include "SALOME_Component_i.hxx" +#include "SALOME_LifeCycleCORBA.hxx" + +#include "GNode_Impl.hxx" +#include "Port_Impl.hxx" + +#include "DataFlowEditor_DataFlow.hxx" +#include "DataFlowExecutor_DataFlow.hxx" + +class ESNode_Impl : public GNode_Impl , + public POA_SUPERV::ESNode { + private: + + CORBA::ORB_ptr _Orb ; + PortableServer::POA_ptr _Poa ; + PortableServer::ObjectId * _ContId ; + + public: + ESNode_Impl(); + ESNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + const char * FuncName , + const SUPERV::KindOfNode NodeKindOfNode = SUPERV::EndSwitchNode ) ; + ESNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode ) ; + virtual ~ESNode_Impl() ; + virtual void destroy() ; + virtual bool Delete() ; + + virtual GraphBase::EndOfSwitchNode * BaseNode() { + return DataFlowNode()->EndOfSwitchNode() ; } ; + +} ; + +#endif diff --git a/src/Supervision/FNode_Impl.cxx b/src/Supervision/FNode_Impl.cxx new file mode 100644 index 0000000..d9d29e2 --- /dev/null +++ b/src/Supervision/FNode_Impl.cxx @@ -0,0 +1,151 @@ +using namespace std; +//============================================================================= +// File : FNode_Impl.cxx +// Created : Nov 2001 +// Author : Jean Rahuel +// Project : SALOME +// $Header: +//============================================================================= + +#include +#include +#include +#include + +#include "utilities.h" + +#include "FNode_Impl.hxx" + +FNode_Impl::FNode_Impl() { +} + +FNode_Impl::FNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * aDataFlowEditor , + const SALOME_ModuleCatalog::Service &NodeService , + const char * NodeComponentName , + const char * NodeInterfaceName , + const char * NodeName , + const SUPERV::KindOfNode NodeKindOfNode ) : +// Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { + CNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , NodeService , NodeName , NodeKindOfNode , (char * ) NULL ) { + MESSAGE( NodeName << " " ); + beginService( "FNode_Impl::FNode_Impl" ); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; +// DataFlowNode( DataFlowEditor()->AddNode( NodeService , NodeComponentName , +// NodeInterfaceName , NodeName , +// NodeKindOfNode ) ) ; + DataFlowNode()->ComponentName( NodeComponentName ) ; + DataFlowNode()->InterfaceName( NodeInterfaceName ) ; + endService( "FNode_Impl::FNode_Impl" ); +} + +FNode_Impl::FNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * aDataFlowEditor , + GraphEditor::InNode * aDataFlowNode ) : +// Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { + CNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) { + MESSAGE( DataFlowNode()->Name() << " " ); + beginService( "FNode_Impl::FNode_Impl" ); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; + endService( "FNode_Impl::FNode_Impl" ); +} + +FNode_Impl::~FNode_Impl() { + beginService( "FNode_Impl::~Node_Impl" ); + endService( "FNode_Impl::~Node_Impl" ); +} + +void FNode_Impl::destroy() { + beginService( "FNode_Impl::Destroy" ); + if ( DataFlowEditor()->IsEditing() ) { + if ( Delete() ) { + _poa->deactivate_object(*_id) ; + CORBA::release(_poa) ; + delete(_id) ; + _thisObj->_remove_ref(); + } + } + endService( "FNode_Impl::Destroy" ); +} + +bool FNode_Impl::Delete() { +// beginService( "FNode_Impl::Delete" ); + bool RetVal = false ; + if ( DataFlowEditor()->IsEditing() ) { + RetVal = DataFlowEditor()->RemoveNode( Name() ) ; + if ( RetVal ) + RetVal = DataFlowEditor()->IsValid() ; + } +// endService( "FNode_Impl::Delete" ); + return RetVal ; +} + +char * FNode_Impl::GetComponentName() { +// beginService( "FNode_Impl::GetComponentName" ); + char * RetVal = DataFlowNode()->ComponentName() ; +// endService( "FNode_Impl::GetComponentName" ); + return CORBA::string_dup( RetVal ); +} +bool FNode_Impl::SetComponentName( const char * aComponentName ) { +// beginService( "FNode_Impl::SetComponentName" ); + bool RetVal = false ; + if ( DataFlowEditor()->IsEditing() ) { + RetVal = DataFlowNode()->ComponentName( aComponentName ) ; + } +// endService( "FNode_Impl::SetComponentName" ); + return RetVal ; +} +char * FNode_Impl::GetInterfaceName() { +// beginService( "FNode_Impl::GetInterfaceName" ); + char * RetVal = DataFlowNode()->InterfaceName() ; +// endService( "FNode_Impl::GetInterfaceName" ); + return CORBA::string_dup( RetVal ); +} +bool FNode_Impl::SetInterfaceName( const char * anInterfaceName ) { +// beginService( "FNode_Impl::SetInterfaceName" ); + bool RetVal = false ; + if ( DataFlowEditor()->IsEditing() ) { + RetVal = DataFlowNode()->InterfaceName( anInterfaceName ) ; + } +// endService( "FNode_Impl::SetInterfaceName" ); + return RetVal ; +} +char * FNode_Impl::GetContainer() { +// beginService( "FNode_Impl::GetContainer" ); + char * RetVal = DataFlowNode()->Computer() ; +// endService( "FNode_Impl::GetContainer" ); + return CORBA::string_dup( RetVal ) ; +} +bool FNode_Impl::SetContainer( const char * aDataFlowContainer ) { +// beginService( "FNode_Impl::SetContainer" ); + bool RetVal = false ; + GraphExecutor::DataFlow * _DataFlowExecutor = DataFlowEditor()->Executor() ; + if ( DataFlowEditor()->IsEditing() ) { + RetVal = DataFlowNode()->Computer( aDataFlowContainer ) ; + } + else if ( _DataFlowExecutor && ( _DataFlowExecutor->IsSuspended() || + _DataFlowExecutor->IsSuspended( DataFlowNode()->Name() ) ) ) { + if ( _DataFlowExecutor->GetChangeGraphNode( DataFlowNode()->Name() ) ) { + RetVal = ((GraphEditor::InNode * ) _DataFlowExecutor->GetChangeGraphNode( DataFlowNode()->Name() )->GetInNode())->Computer( aDataFlowContainer ) ; + } + } +// endService( "FNode_Impl::SetContainer" ); + return RetVal ; +} + diff --git a/src/Supervision/FNode_Impl.hxx b/src/Supervision/FNode_Impl.hxx new file mode 100644 index 0000000..fb5031e --- /dev/null +++ b/src/Supervision/FNode_Impl.hxx @@ -0,0 +1,78 @@ +//============================================================================= +// File : FNode_Impl.hxx +// Created : Nov 2001 +// Author : Jean Rahuel +// Project : SALOME +// Copyright : CEA 2001 +// $Header: +//============================================================================= + +#ifndef _FNODE_IMPL_HXX_ +#define _FNODE_IMPL_HXX_ + +#include + +#include "CORBA.h" + +#include +#include "SALOME_Component_i.hxx" +#include "SALOME_LifeCycleCORBA.hxx" + +#include "CNode_Impl.hxx" + +#include "Port_Impl.hxx" + +#include "DataFlowEditor_DataFlow.hxx" +#include "DataFlowExecutor_DataFlow.hxx" + +class FNode_Impl : public CNode_Impl , + public POA_SUPERV::FNode { + private: + + CORBA::ORB_ptr _Orb ; + PortableServer::POA_ptr _Poa ; + PortableServer::ObjectId * _ContId ; + + public: + FNode_Impl(); + FNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + const char *aDataFlowName ) ; + FNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + const SALOME_ModuleCatalog::Service &NodeService , + const char * NodeComponentName , + const char * NodeInterfaceName , + const char * NodeName = NULL , + const SUPERV::KindOfNode NodeKindOfNode = SUPERV::FactoryNode ) ; + FNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode ) ; + virtual ~FNode_Impl() ; + virtual void destroy() ; + virtual bool Delete() ; + + virtual char * GetComponentName() ; + virtual bool SetComponentName(const char *) ; + virtual char * GetInterfaceName() ; + virtual bool SetInterfaceName(const char *) ; + virtual char * GetContainer() ; + virtual bool SetContainer( const char * aDataFlowContainer ) ; + + virtual GraphBase::FactoryNode * BaseNode() { + return DataFlowNode()->FactoryNode() ; } ; + +} ; + +#endif diff --git a/src/Supervision/GNode_Impl.cxx b/src/Supervision/GNode_Impl.cxx new file mode 100644 index 0000000..d5c559f --- /dev/null +++ b/src/Supervision/GNode_Impl.cxx @@ -0,0 +1,156 @@ +using namespace std; +//============================================================================= +// File : GNode_Impl.cxx +// Created : 2003 +// Author : Jean Rahuel +// Project : SALOME +// $Header: +//============================================================================= + +#include +#include +#include +#include + +#include "utilities.h" + +#include "GNode_Impl.hxx" + +GNode_Impl::GNode_Impl() { +} + +GNode_Impl::GNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * aDataFlowEditor , + const char * FuncName , + const SUPERV::ListOfStrings & PythonFunction , + const SUPERV::KindOfNode NodeKindOfNode ) : +// Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { + INode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , FuncName , PythonFunction , NodeKindOfNode ) { +// MESSAGE( NodeName << " " ); + beginService( "GNode_Impl::GNode_Impl" ); + if ( FuncName ) { + cout << "GNode_Impl::GNode_Impl " << (void *) FuncName << " " << FuncName + << " " << strlen( FuncName ) << endl ; + } + if ( NodeKindOfNode == SUPERV::GOTONode ) { + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + } + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; +// DataFlowNode( DataFlowEditor()->AddNode( NodeService , NodeComponentName , +// NodeInterfaceName , NodeName , +// NodeKindOfNode ) ); +// DataFlowNode( DataFlowEditor()->AddNode( SALOME_ModuleCatalog::Service() , +// "" , "" , "" , +// NodeKindOfNode ) ) ; + endService( "GNode_Impl::GNode_Impl" ); +} + +GNode_Impl::GNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * aDataFlowEditor , + GraphBase::ListOfFuncName FuncNameList , + GraphBase::ListOfPythonFunctions PythonFunctionList , + const SUPERV::KindOfNode NodeKindOfNode ) : +// Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { + INode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , FuncNameList , PythonFunctionList , NodeKindOfNode ) { +// MESSAGE( NodeName << " " ); + beginService( "GNode_Impl::GNode_Impl" ); + if ( NodeKindOfNode == SUPERV::GOTONode ) { + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + } + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; +// DataFlowNode( DataFlowEditor()->AddNode( NodeService , NodeComponentName , +// NodeInterfaceName , NodeName , +// NodeKindOfNode ) ); +// DataFlowNode( DataFlowEditor()->AddNode( SALOME_ModuleCatalog::Service() , +// "" , "" , "" , +// NodeKindOfNode ) ) ; + endService( "GNode_Impl::GNode_Impl" ); +} + +GNode_Impl::GNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * aDataFlowEditor , + GraphEditor::InNode * aDataFlowNode ) : +// Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { + INode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) { + MESSAGE( DataFlowNode()->Name() << " " ); + beginService( "GNode_Impl::GNode_Impl" ); + if ( DataFlowNode()->IsGOTONode() ) { + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + } + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; + endService( "GNode_Impl::GNode_Impl" ); +} + +GNode_Impl::~GNode_Impl() { + beginService( "GNode_Impl::~GNode_Impl" ); + endService( "GNode_Impl::~GNode_Impl" ); +} + +void GNode_Impl::destroy() { + beginService( "GNode_Impl::Destroy" ); + if ( DataFlowEditor()->IsEditing() ) { + if ( Delete() ) { + _poa->deactivate_object(*_id) ; + CORBA::release(_poa) ; + delete(_id) ; + _thisObj->_remove_ref(); + } + } + endService( "GNode_Impl::Destroy" ); +} + +bool GNode_Impl::Delete() { +// beginService( "GNode_Impl::Delete" ); + bool RetVal = false ; + if ( DataFlowEditor()->IsEditing() ) { + RetVal = DataFlowEditor()->RemoveNode( Name() ) ; + if ( RetVal ) + RetVal = DataFlowEditor()->IsValid() ; + } +// endService( "GNode_Impl::Delete" ); + return RetVal ; +} + +SUPERV::INode_ptr GNode_Impl::Coupled() { + beginService( "GNode_Impl::Coupled" ); + SUPERV::INode_var iobject = SUPERV::INode::_nil() ; + if ( DataFlowNode()->CoupledNode() ) { + if ( CORBA::is_nil( DataFlowNode()->CoupledNode()->ObjRef() ) ) { + INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + (GraphEditor::InNode *) DataFlowNode()->CoupledNode()->GetInNode() ) ; + PortableServer::ObjectId * id = myNode->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::INode::_narrow(obj) ; + myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ; + } + else { + iobject = SUPERV::INode::_narrow( DataFlowNode()->CoupledNode()->ObjRef() ) ; + } + } + endService( "GNode_Impl::Coupled" ); + return SUPERV::INode::_duplicate( iobject ) ; +} + diff --git a/src/Supervision/GNode_Impl.hxx b/src/Supervision/GNode_Impl.hxx new file mode 100644 index 0000000..d645622 --- /dev/null +++ b/src/Supervision/GNode_Impl.hxx @@ -0,0 +1,104 @@ +//============================================================================= +// File : GNode_Impl.hxx +// Created : 2003 +// Author : Jean Rahuel +// Project : SALOME +// Copyright : CEA 2003 +// $Header: +//============================================================================= + +#ifndef _GNODE_IMPL_HXX_ +#define _GNODE_IMPL_HXX_ + +#include + +#include "CORBA.h" + +#include +#include "SALOME_Component_i.hxx" +#include "SALOME_LifeCycleCORBA.hxx" + +#include "INode_Impl.hxx" +#include "Port_Impl.hxx" + +#include "DataFlowEditor_DataFlow.hxx" +#include "DataFlowExecutor_DataFlow.hxx" + +class GNode_Impl : public INode_Impl , + public POA_SUPERV::GNode { + private: + + CORBA::ORB_ptr _Orb ; + PortableServer::POA_ptr _Poa ; + PortableServer::ObjectId * _ContId ; + + public: + GNode_Impl(); + GNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + const char * FuncName , + const SUPERV::ListOfStrings & PythonFunction , + const SUPERV::KindOfNode NodeKindOfNode = SUPERV::GOTONode ) ; + GNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphBase::ListOfFuncName FuncNameList , + GraphBase::ListOfPythonFunctions PythonFunctionList , + const SUPERV::KindOfNode NodeKindOfNode = SUPERV::GOTONode ) ; + GNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode ) ; + virtual ~GNode_Impl() ; + virtual void destroy() ; + virtual bool Delete() ; + + virtual bool SetCoupled( const char * anInLineNode ) { + GraphBase::InLineNode * CoupledINode = (GraphBase::InLineNode * ) DataFlowEditor()->GetGraphNode( anInLineNode ) ; + cout << Name() << ".SetCoupled " << anInLineNode << endl ; + if ( CoupledINode && ( IsGOTO() && + ( CoupledINode->IsInLineNode() || CoupledINode->IsLoopNode() || + CoupledINode->IsSwitchNode() ) ) || + ( !IsGOTO() && ( IsLoop() || IsSwitch() || + IsEndLoop() || IsEndSwitch() ) ) ) { + DataFlowNode()->CoupledNode( CoupledINode ) ; + if ( IsSwitch() ) { + DataFlowEditor()->AddLink( Name() , "Default" , + CoupledINode->Name() , "Default" ) ; + } + else if ( IsLoop() || IsEndLoop() ) { + DataFlowEditor()->AddLink( Name() , "DoLoop" , + CoupledINode->Name() , "DoLoop" ) ; + } + else if ( IsGOTO() ) { + DataFlowEditor()->AddLink( Name() , "OutGate" , + CoupledINode->Name() , "InGate" ) ; + } + cout << "SetCoupled " << CoupledINode->Name() << endl ; + return true ; + } + cout << Name() << ".SetCoupled ERROR " << anInLineNode << " " << CoupledINode + << " of " << Kind() ; + if ( CoupledINode ) { + cout << " kinfOkCoupled " << CoupledINode->Kind() ; + } + cout << endl ; + return false ; } ; + virtual SUPERV::INode_ptr Coupled() ; + + virtual GraphBase::GOTONode * BaseNode() { + return DataFlowNode()->GOTONode() ; } ; + +} ; + +#endif diff --git a/src/Supervision/Graph_Impl.cxx b/src/Supervision/Graph_Impl.cxx new file mode 100644 index 0000000..7b3a08c --- /dev/null +++ b/src/Supervision/Graph_Impl.cxx @@ -0,0 +1,1199 @@ +using namespace std; +//============================================================================= +// File : Graph_Impl.cxx +// Created : Nov 2001 +// Author : Jean Rahuel +// Project : SALOME +// $Header: +//============================================================================= + +#include +#include +#include +#include + +#include "utilities.h" + +#include "Graph_Impl.hxx" + +#include "DataFlowEditor_DataFlow.hxx" + +Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + const char *aDataFlowName ) : + INode_Impl(orb, poa, contId, instanceName, interfaceName, aDataFlowName) { +// MESSAGE("Graph_Impl::Graph_Impl activate object instanceName(" +// << instanceName << ") interfaceName(" << interfaceName << ") --> " +// << hex << (void *) this << dec ) + beginService( "Graph_Impl::Graph_Impl" ); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; + _ExecNumber = 0 ; + + string dbgfile = "/tmp/" ; + dbgfile += instanceName ; + dbgfile += "_" ; + int lenname = strlen( aDataFlowName ) ; + char * theDataFlowName = new char [ lenname+1 ] ; + strcpy( theDataFlowName , aDataFlowName ) ; + if ( aDataFlowName ) { + if ( lenname > 4 && !strcmp( &aDataFlowName[ lenname - 4 ] , ".xml" ) ) { + strncpy( theDataFlowName , &aDataFlowName[ 0 ] , lenname-4 ) ; + theDataFlowName[ lenname-4 ] = '\0' ; + int i ; + for ( i = lenname - 5 ; i >= 0 ; i-- ) { + if ( aDataFlowName[ i ] == '/' ) { + strncpy( theDataFlowName , &aDataFlowName[ i + 1 ] , lenname-5-i ) ; + theDataFlowName[ lenname-5-i ] = '\0' ; + break ; + } + } + } + else { + strcpy( theDataFlowName , &aDataFlowName[ 0 ] ) ; + } + dbgfile += theDataFlowName ; + } + dbgfile += ".log" ; + _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ; + strcpy( _DebugFileName , dbgfile.c_str() ) ; + + _NamingService = new SALOME_NamingService(orb); +// _DataFlowEditor = new SALOME_DataFlowEditor_impl( NS ) ; + GraphEditor::DataFlow * aDataFlowEditor = new GraphEditor::DataFlow( + _Orb , _NamingService , + theDataFlowName , + _DebugFileName ) ; + DataFlowEditor( aDataFlowEditor ) ; + DataFlowEditor()->SetObjImpl( this ) ; + _DataFlowExecutor = NULL ; +// _DataFlowDataNode = DataFlowEditor() ; + delete [] theDataFlowName ; + endService( "Graph_Impl::Graph_Impl" ); +} + +Graph_Impl::Graph_Impl() { +} + +Graph_Impl::~Graph_Impl() { + beginService( "Graph_Impl::~Graph_Impl" ); + endService( "Graph_Impl::~Graph_Impl" ); +} + +void Graph_Impl::destroy() { + beginService( "Graph_Impl::destroy" ); + _poa->deactivate_object(*_id) ; + CORBA::release(_poa) ; + delete(_id) ; + _thisObj->_remove_ref(); + endService( "Graph_Impl::destroy" ); +} + +char* Graph_Impl::getIOR() { + if (CORBA::is_nil(myServant)) { + PortableServer::ObjectId* id = getId(); + CORBA::Object_var obj; + obj = _poa->id_to_reference(*id); + myServant = SUPERV::Graph::_narrow(obj); + } + return(CORBA::string_dup(_Orb->object_to_string(myServant))); +} + +SUPERV::Graph_ptr Graph_Impl::Copy() { + beginService( "Graph_Impl::Copy" ); + Graph_Impl * myGraph ; + myGraph = new Graph_Impl( _Orb , _Poa, _ContId, + instanceName() , interfaceName() , + Name() ) ; + PortableServer::ObjectId * id = myGraph->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::Graph_var iobject ; + iobject = SUPERV::Graph::_narrow(obj) ; +// GraphBase::SGraph * aSGraph = aGraph->GetGraph() ; + GraphBase::SGraph * aSGraph = GetGraph() ; + myGraph->LoadGraph( aSGraph ) ; + endService( "Graph_Impl::Copy" ); + return SUPERV::Graph::_duplicate(iobject) ; +} + +void Graph_Impl::ReadOnly() { + DataFlowEditor()->ReadOnly() ; +} + +SUPERV::INode_ptr Graph_Impl::GetNode() { +// beginService( "Graph_Impl::GetNode" ); + PortableServer::ObjectId * id = getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::Graph_var iobject ; + iobject = SUPERV::Graph::_narrow(obj) ; +// endService( "Graph_Impl::GetNode" ); + return SUPERV::Graph::_duplicate(iobject) ; +} + +GraphBase::SGraph * Graph_Impl::GetGraph() { + return DataFlowEditor()->GetDataFlow() ; +} + +#if 0 +char * Graph_Impl::DataFlowInfo() { + beginService( "Graph_Impl::DataFlowInfo" ); + char * RetVal = DataFlowEditor()->DataFlowInfo() ; + endService( "Graph_Impl::DataFlowInfo" ); + return CORBA::string_dup( RetVal ) ; +} + +char * Graph_Impl::DataNodeInfo() { + beginService( "Graph_Impl::DataNodeInfo" ); + char * RetVal = DataFlowEditor()->DataNodeInfo() ; + endService( "Graph_Impl::DataNodeInfo" ); + return CORBA::string_dup( RetVal ) ; +} + +char * Graph_Impl::NodeInfo( const char * aNodeName ) { + beginService( "Graph_Impl::NodeInfo" ); + char * RetVal = DataFlowEditor()->NodeInfo( aNodeName ) ; + endService( "Graph_Impl::NodeInfo" ); + return CORBA::string_dup( RetVal ) ; +} +#endif + +bool Graph_Impl::LoadGraph(const GraphBase::SGraph * aDataFlow ) { +// beginService( "Graph_Impl::LoadGraph" ); + bool RetVal = false ; + if ( DataFlowEditor()->IsEditing() ) { + RetVal = DataFlowEditor()->LoadDataFlow( aDataFlow ) ; + } +// endService( "Graph_Impl::LoadGraph" ); + return RetVal ; +} + +bool Graph_Impl::Import(const char * aXmlFile ) { +// beginService( "Graph_Impl::Import" ); + bool RetVal = false ; + if ( DataFlowEditor()->IsEditing() ) { + RetVal = DataFlowEditor()->LoadXml( aXmlFile ) ; + } +// endService( "Graph_Impl::Import" ); + return RetVal ; +} + +bool Graph_Impl::Export(const char * anXmlFile ) { +// beginService( "Graph_Impl::Export" ); + char * aFile = new char [ strlen( anXmlFile ) + 5 ] ; + strcpy( aFile , anXmlFile ) ; + int len = strlen( aFile ) ; + if ( !strcmp( &aFile[ len - 4 ] , ".xml" ) ) { + } + else if ( !strcmp( &aFile[ len - 3 ] , ".py" ) ) { + strcpy( &aFile[ len - 3 ] , ".xml" ) ; + len = strlen( aFile ) ; + } + else { + strcat( aFile , ".xml" ) ; + len = strlen( aFile ) ; + } + bool RetVal = DataFlowEditor()->SaveXml( aFile ) ; + if ( RetVal ) { + strcpy( &aFile[ len - 4 ] , ".py" ) ; + RetVal = DataFlowEditor()->SavePy( aFile ) ; + } + delete [] aFile ; +// endService( "Graph_Impl::Export" ); + return RetVal ; +} + +#if 0 +GraphBase::ListOfNodes * Graph_Impl::GetNodes() { +// beginService( "Graph_Impl::GetNodes" ); + GraphBase::ListOfNodes * RetVal = DataFlowEditor()->GetNodes() ; +// endService( "Graph_Impl::GetNodes" ); + return RetVal ; +} +GraphBase::ListOfLinks * Graph_Impl::GetLinks() { +// beginService( "Graph_Impl::GetLinks" ); + GraphBase::ListOfLinks * RetVal = DataFlowEditor()->GetLinks() ; +// endService( "Graph_Impl::GetLinks" ); + return RetVal ; +} +GraphBase::ListOfLinks * Graph_Impl::GetDatas() { +// beginService( "Graph_Impl::GetDatas" ); + GraphBase::ListOfLinks * RetVal = DataFlowEditor()->GetDatas() ; +// endService( "Graph_Impl::GetDatas" ); + return RetVal ; +} +#endif + +SUPERV::CNode_ptr Graph_Impl::CNode( + const SALOME_ModuleCatalog::Service &NodeService ) { + beginService( "Graph_Impl::CNode" ); + SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ; + if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() ) { + CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + NodeService , (char * ) NULL , + SUPERV::ComputingNode , (char * ) NULL ) ; + if ( myNode->DataFlowNode() ) { + PortableServer::ObjectId * id = myNode->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::CNode::_narrow(obj) ; + myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ; + } + } + endService( "Graph_Impl::CNode" ); + return SUPERV::CNode::_duplicate( iobject ) ; +} + +SUPERV::FNode_ptr Graph_Impl::FNode( + const char * NodeComponentName , + const char * NodeInterfaceName , + const SALOME_ModuleCatalog::Service &NodeService ) { + beginService( "Graph_Impl::Node" ); + SUPERV::FNode_var iobject = SUPERV::FNode::_nil() ; + if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() ) { + FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + NodeService , + NodeComponentName , + NodeInterfaceName ) ; + if ( myNode->DataFlowNode() ) { + PortableServer::ObjectId * id = myNode->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::FNode::_narrow(obj) ; + myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ; + } + } + endService( "Graph_Impl::Node" ); + return SUPERV::FNode::_duplicate( iobject ) ; +} + +SUPERV::INode_ptr Graph_Impl::INode( const char * FuncName , + const SUPERV::ListOfStrings & PythonFuntion ) { + beginService( "Graph_Impl::INode" ); + SUPERV::INode_var iobject = SUPERV::INode::_nil() ; + if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() ) { + INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + FuncName , PythonFuntion , + SUPERV::InLineNode ) ; + if ( myNode->DataFlowNode() ) { + PortableServer::ObjectId * id = myNode->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::INode::_narrow(obj) ; + myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ; + } + } + endService( "Graph_Impl::INode" ); + return SUPERV::INode::_duplicate( iobject ) ; +} + + +SUPERV::GNode_ptr Graph_Impl::GNode( const char * FuncName , + const SUPERV::ListOfStrings & PythonFuntion , + const char * anInLineNode ) { + beginService( "Graph_Impl::GNode" ); + SUPERV::GNode_var iobject = SUPERV::GNode::_nil() ; + if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() ) { + GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + FuncName , PythonFuntion , + SUPERV::GOTONode ) ; + if ( myNode->DataFlowNode() ) { + PortableServer::ObjectId * id = myNode->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::GNode::_narrow(obj) ; + myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ; + if ( strlen( anInLineNode ) ) { + GraphBase::InLineNode * CoupledINode = (GraphBase::InLineNode * ) DataFlowEditor()->GetGraphNode( anInLineNode ) ; + if ( anInLineNode ) { + myNode->SetCoupled( anInLineNode ) ; + Link( myNode->Port( "OutGate" ) , CoupledINode->ObjRef()->Port( "InGate" ) ) ; + } + } + } + } + endService( "Graph_Impl::GNode" ); + return SUPERV::GNode::_duplicate( iobject ) ; +} + +SUPERV::LNode_ptr Graph_Impl::LNode( + const char * InitName , + const SUPERV::ListOfStrings & InitFunction , + const char * MoreName , + const SUPERV::ListOfStrings & MoreFunction , + const char * NextName , + const SUPERV::ListOfStrings & NextFunction , + SUPERV::INode_out anEndOfLoop ) { + beginService( "Graph_Impl::LNode" ); + SUPERV::LNode_var iobject = SUPERV::LNode::_nil() ; + SUPERV::ELNode_var iendobject = SUPERV::ELNode::_nil() ; + if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() ) { + GraphBase::ListOfFuncName FuncNameList ; + FuncNameList.resize(3) ; + FuncNameList[0] = InitName ; + FuncNameList[1] = MoreName ; + FuncNameList[2] = NextName ; + GraphBase::ListOfPythonFunctions PythonFunctionList ; + PythonFunctionList.resize(3) ; + PythonFunctionList[0] = &InitFunction ; + PythonFunctionList[1] = &MoreFunction ; + PythonFunctionList[2] = &NextFunction ; + LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + FuncNameList , PythonFunctionList , +// InitName , InitFunction , +// MoreName , MoreFunction , +// NextName , NextFunction , + SUPERV::LoopNode ) ; + if ( myNode->DataFlowNode() ) { + PortableServer::ObjectId * id = myNode->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::LNode::_narrow(obj) ; + myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ; + + SALOME_ModuleCatalog::Service aVoidService = SALOME_ModuleCatalog::Service() ; + char * anEndName ; + if ( strlen( InitName ) ) { + anEndName = new char( 3 + strlen( InitName ) + 1 ) ; + strcpy( anEndName , "End" ) ; + strcat( anEndName , InitName ) ; + } + else { + anEndName = new char( 3 + strlen( "Loop" ) + 1 ) ; + strcpy( anEndName , "EndLoop" ) ; + } + ELNode_Impl * myEndNode = new ELNode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + anEndName , + SUPERV::EndLoopNode ) ; + PortableServer::ObjectId * endid = myEndNode->getId() ; + CORBA::Object_var endobj = _poa->id_to_reference(*endid); + iendobject = SUPERV::ELNode::_narrow(endobj) ; + myEndNode->SetObjRef( SUPERV::ELNode::_duplicate( iendobject ) ) ; + myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ; + myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ; + Link( myNode->Port( "DoLoop" ) , myEndNode->Port( "DoLoop" ) ) ; + Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "InitLoop" ) ) ; + } + } + anEndOfLoop = SUPERV::ELNode::_duplicate( iendobject ) ; + endService( "Graph_Impl::LNode" ); + return SUPERV::LNode::_duplicate( iobject ) ; +} + +SUPERV::SNode_ptr Graph_Impl::SNode( + const char * FuncName , + const SUPERV::ListOfStrings & PythonFunction , + SUPERV::INode_out anEndOfSwitch ) { + beginService( "Graph_Impl::SNode" ); + SUPERV::SNode_var iobject = SUPERV::SNode::_nil() ; + SUPERV::ESNode_var iendobject = SUPERV::ESNode::_nil() ; + if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() ) { + SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + FuncName , PythonFunction , + SUPERV::SwitchNode ) ; + if ( myNode->DataFlowNode() ) { + PortableServer::ObjectId * id = myNode->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::SNode::_narrow(obj) ; + myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ; + + string anEndName = "End" ; + if ( strlen( FuncName ) ) { + anEndName += FuncName ; + } + else { + anEndName += "Switch" ; + } + cout << "Graph_Impl::SNode anEndName " << (void *) FuncName << " " << FuncName + << " " << strlen(FuncName) << " " << (void *) anEndName.c_str() << " " + << anEndName.c_str() << endl ; + ESNode_Impl * myEndNode = new ESNode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + anEndName.c_str() , + SUPERV::EndSwitchNode ) ; + cout << "Graph_Impl::SNode returned anEndName " << (void *) FuncName << " " + << FuncName << " " << strlen(FuncName) << " " << (void *) anEndName.c_str() + << " " << anEndName.c_str() << endl ; + PortableServer::ObjectId * endid = myEndNode->getId() ; + CORBA::Object_var endobj = _poa->id_to_reference(*endid); + iendobject = SUPERV::ESNode::_narrow(endobj) ; + myEndNode->SetObjRef( SUPERV::ESNode::_duplicate( iendobject ) ) ; + myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ; + myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ; + if ( !Link( myNode->Port( "Default" ) , myEndNode->Port( "Default" ) ) ) { + iobject = SUPERV::SNode::_nil() ; + iendobject = SUPERV::ESNode::_nil() ; + } + } + } + anEndOfSwitch = SUPERV::ESNode::_duplicate( iendobject ) ; + endService( "Graph_Impl::SNode" ); + return SUPERV::SNode::_duplicate( iobject ) ; +} + + +SUPERV::CNode_ptr Graph_Impl::GetNode(char const * aNodeName ) { +// beginService( "Graph_Impl::GetNode" ); + SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ; + if ( CORBA::is_nil( DataFlowEditor()->GetNode( aNodeName )->ObjRef() ) ) { + CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + DataFlowEditor()->GetNode( aNodeName ) ) ; + PortableServer::ObjectId * id = myNode->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::CNode::_narrow(obj) ; + myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ; + } + else { + iobject = DataFlowEditor()->GetNode( aNodeName )->ObjRef() ; + } +// endService( "Graph_Impl::GetNode" ); + return SUPERV::CNode::_duplicate( iobject ) ; +} + +SUPERV::Link_ptr Graph_Impl::Link( SUPERV::Port_ptr OutPort , + SUPERV::Port_ptr InPort ) { + beginService( "Graph_Impl::Link" ); + SUPERV::Link_var iobject = SUPERV::Link::_nil() ; + if ( DataFlowEditor()->IsEditing() && + !DataFlowEditor()->IsReadOnly() ) { + const char * DataFlowOutNodeName = OutPort->Node()->Name() ; + GraphEditor::InNode * DataFlowOutNode = DataFlowEditor()->GetNode( DataFlowOutNodeName ) ; + const char * DataFlowInNodeName = InPort->Node()->Name() ; + GraphEditor::InNode * DataFlowInNode = DataFlowEditor()->GetNode( DataFlowInNodeName ) ; + if ( DataFlowOutNode && DataFlowInNode ) { + Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + DataFlowInNode , + InPort->Name() , + DataFlowOutNode , + OutPort->Name() , + true ) ; + PortableServer::ObjectId * id = myLink->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::Link::_narrow(obj) ; +// iobject = InPort->Link() ; + } + } + endService( "Graph_Impl::Link" ); + return SUPERV::Link::_duplicate( iobject ) ; +} + +SUPERV::ListOfNodes_var Graph_Impl::SetNode( SUPERV::ListOfNodes_var RetVal , + GraphBase::ComputingNode * aNode ) { + int index = 0 ; + MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() ) ; + if ( aNode->IsComputingNode() ) { + index = RetVal->CNodes.length() ; + RetVal->CNodes.length( index+1 ); + } + else if ( aNode->IsFactoryNode() ) { + index = RetVal->FNodes.length() ; + RetVal->FNodes.length( index+1 ); + } + else if ( aNode->IsInLineNode() ) { + index = RetVal->INodes.length() ; + RetVal->INodes.length( index+1 ); + } + else if ( aNode->IsGOTONode() ) { + index = RetVal->GNodes.length() ; + RetVal->GNodes.length( index+1 ); + } + else if ( aNode->IsLoopNode() ) { + index = RetVal->LNodes.length() ; + RetVal->LNodes.length( index+1 ); + } + else if ( aNode->IsEndLoopNode() ) { + index = RetVal->ELNodes.length() ; + RetVal->ELNodes.length( index+1 ); + } + else if ( aNode->IsSwitchNode() ) { + index = RetVal->SNodes.length() ; + RetVal->SNodes.length( index+1 ); + } + else if ( aNode->IsEndSwitchNode() ) { + index = RetVal->ESNodes.length() ; + RetVal->ESNodes.length( index+1 ); + } + if ( CORBA::is_nil( aNode->ObjRef() ) ) { + if ( aNode->IsComputingNode() ) { + CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + (GraphEditor::InNode * ) aNode->GetInNode() ) ; + PortableServer::ObjectId * id = myNode->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::CNode_var iobject ; + iobject = SUPERV::CNode::_narrow(obj) ; + myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ; + RetVal->CNodes[index] = SUPERV::CNode::_duplicate( iobject ) ; + } + else if ( aNode->IsFactoryNode() ) { + FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + (GraphEditor::InNode * ) aNode->GetInNode() ) ; + PortableServer::ObjectId * id = myNode->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::FNode_var iobject ; + iobject = SUPERV::FNode::_narrow(obj) ; + myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ; + RetVal->FNodes[index] = SUPERV::FNode::_duplicate( iobject ) ; + } + else if ( aNode->IsInLineNode() ) { + INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + (GraphEditor::InNode * ) aNode->GetInNode() ) ; + PortableServer::ObjectId * id = myNode->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::INode_var iobject ; + iobject = SUPERV::INode::_narrow(obj) ; + myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ; + RetVal->INodes[index] = SUPERV::INode::_duplicate( iobject ) ; + } + else if ( aNode->IsGOTONode() ) { + GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + (GraphEditor::InNode * ) aNode->GetInNode() ) ; + PortableServer::ObjectId * id = myNode->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::GNode_var iobject ; + iobject = SUPERV::GNode::_narrow(obj) ; + myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ; + RetVal->GNodes[index] = SUPERV::GNode::_duplicate( iobject ) ; + } + else if ( aNode->IsLoopNode() ) { + LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + (GraphEditor::InNode * ) aNode->GetInNode() ) ; + PortableServer::ObjectId * id = myNode->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::LNode_var iobject ; + iobject = SUPERV::LNode::_narrow(obj) ; + myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ; + RetVal->LNodes[index] = SUPERV::LNode::_duplicate( iobject ) ; + } + else if ( aNode->IsEndLoopNode() ) { + ELNode_Impl * myNode = new ELNode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + (GraphEditor::InNode * ) aNode->GetInNode() ) ; + PortableServer::ObjectId * id = myNode->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::ELNode_var iobject ; + iobject = SUPERV::ELNode::_narrow(obj) ; + myNode->SetObjRef( SUPERV::ELNode::_duplicate( iobject ) ) ; + RetVal->ELNodes[index] = SUPERV::ELNode::_duplicate( iobject ) ; + } + else if ( aNode->IsSwitchNode() ) { + SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + (GraphEditor::InNode * ) aNode->GetInNode() ) ; + PortableServer::ObjectId * id = myNode->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::SNode_var iobject ; + iobject = SUPERV::SNode::_narrow(obj) ; + myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ; + RetVal->SNodes[index] = SUPERV::SNode::_duplicate( iobject ) ; + } + else if ( aNode->IsEndSwitchNode() ) { + ESNode_Impl * myNode = new ESNode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + (GraphEditor::InNode * ) aNode->GetInNode() ) ; + PortableServer::ObjectId * id = myNode->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::ESNode_var iobject ; + iobject = SUPERV::ESNode::_narrow(obj) ; + myNode->SetObjRef( SUPERV::ESNode::_duplicate( iobject ) ) ; + RetVal->ESNodes[index] = SUPERV::ESNode::_duplicate( iobject ) ; + } + } + else if ( aNode->IsComputingNode() ) { + RetVal->CNodes[index] = SUPERV::CNode::_duplicate( aNode->ObjRef() ) ; + } + else if ( aNode->IsFactoryNode() ) { + RetVal->FNodes[index] = SUPERV::FNode::_duplicate( SUPERV::FNode::_narrow( aNode->ObjRef() ) ) ; + } + else if ( aNode->IsInLineNode() ) { + RetVal->INodes[index] = SUPERV::INode::_duplicate( SUPERV::INode::_narrow( aNode->ObjRef() ) ) ; + } + else if ( aNode->IsGOTONode() ) { + RetVal->GNodes[index] = SUPERV::GNode::_duplicate( SUPERV::GNode::_narrow( aNode->ObjRef() ) ) ; + } + else if ( aNode->IsLoopNode() ) { + RetVal->LNodes[index] = SUPERV::LNode::_duplicate( SUPERV::LNode::_narrow( aNode->ObjRef() ) ) ; + } + else if ( aNode->IsEndLoopNode() ) { + RetVal->ELNodes[index] = SUPERV::ELNode::_duplicate( SUPERV::ELNode::_narrow( aNode->ObjRef() ) ) ; + } + else if ( aNode->IsSwitchNode() ) { + RetVal->SNodes[index] = SUPERV::SNode::_duplicate( SUPERV::SNode::_narrow( aNode->ObjRef() ) ) ; + } + else if ( aNode->IsEndSwitchNode() ) { + RetVal->ESNodes[index] = SUPERV::ESNode::_duplicate( SUPERV::ESNode::_narrow( aNode->ObjRef() ) ) ; + } + return ( RetVal._retn() ) ; +} + +SUPERV::ListOfNodes * Graph_Impl::Nodes() { + SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes; + beginService( "Graph_Impl::Nodes" ); + RetVal->CNodes.length(0) ; + RetVal->FNodes.length(0) ; + RetVal->INodes.length(0) ; + RetVal->LNodes.length(0) ; + RetVal->SNodes.length(0) ; + RetVal->GNodes.length(0) ; + int i ; + for ( i = 0 ; i < DataFlowEditor()->GraphNodesSize() ; i++ ) { + GraphBase::ComputingNode * aNode = DataFlowEditor()->GraphNodes( i ) ; + RetVal = SetNode( RetVal , aNode ) ; + } + MESSAGE("Graph_Impl::Nodes CNodes " << RetVal->CNodes.length() + << " FNodes " << RetVal->FNodes.length() + << " INodes " << RetVal->INodes.length() + << " GNodes " << RetVal->GNodes.length() + << " LNodes " << RetVal->LNodes.length() + << " ELNodes " << RetVal->ELNodes.length() + << " SNodes " << RetVal->SNodes.length() + << " ESNodes " << RetVal->ESNodes.length() ) ; + endService( "Graph_Impl::Nodes" ); + return ( RetVal._retn() ) ; +} + +SUPERV::ListOfLinks * Graph_Impl::GLinks() { + return Links( NULL , NULL ) ; +} + +SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode , + const char * anInputParam ) { + bool begin = true ; + SUPERV::ListOfLinks_var RetVal = new SUPERV::ListOfLinks ; + int i , j , countlink ; + countlink = 0 ; + for ( i = 0 ; i < DataFlowEditor()->GraphNodesSize() ; i++ ) { + GraphEditor::InNode * aNode = NULL ; + aNode = (GraphEditor::InNode * ) DataFlowEditor()->GraphNodes( i )->GetInNode() ; + bool ToProcess = false ; + if ( theNode == NULL ) { + ToProcess = true ; + } + else { + if ( !strcmp( theNode->Name() , aNode->Name() ) ) { + if ( !theNode->IsEndSwitchNode() ) { + ToProcess = true ; + } + } + else if ( theNode->IsEndSwitchNode() ) { + ToProcess = true ; + } + } + if ( ToProcess ) { + for ( j = 0 ; j < aNode->GetNodeInPortsSize() ; j++ ) { + GraphBase::InPort * anInPort = NULL ; + anInPort = aNode->GetChangeNodeInPort( j ) ; + if ( anInputParam == NULL || + !strcmp( anInPort->PortName() , anInputParam ) ) { + if ( anInPort->GetOutPort() ) { + GraphBase::OutPort * anOutPort = NULL ; + anOutPort = anInPort->GetOutPort() ; + if ( strcmp( anOutPort->NodeName() , Name() ) ) { + MESSAGE("Graph_Impl::Links " << anOutPort->NodeName() << "(" + << anOutPort->PortName() << ") --> " << aNode->Name() << "(" + << anInPort->PortName() << ")" ) ; + if ( theNode == NULL || + ( theNode != NULL && theNode->IsEndSwitchNode() && + !strcmp( theNode->Name() , aNode->Name() ) ) ) { + if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) { + if ( begin ) { + beginService( "Graph_Impl::ListOfLinks" ); + begin = false ; + } + GraphEditor::InNode * anOutNode = NULL ; + anOutNode = (GraphEditor::InNode * ) DataFlowEditor()->GetChangeGraphNode( anOutPort->NodeName() )->GetInNode() ; + if ( anOutNode ) { + Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + aNode , + anInPort->PortName() , + anOutNode , + anOutPort->PortName() , + false ) ; + PortableServer::ObjectId * id = myLink->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::Link_var iobject ; + iobject = SUPERV::Link::_narrow(obj) ; + RetVal->length( countlink + 1 ) ; + RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ; + anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ; + } + } + else { + RetVal->length( countlink + 1 ) ; + RetVal[ countlink++ ] = SUPERV::Link::_duplicate( anOutPort->InPortObjRef( anInPort ) ) ; + } + } + } + } + } + } + } + for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) { + GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j ) ; + int k ; + for ( k = 0 ; k < anOutPort->InPortsSize() ; k++ ) { + GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ; + GraphEditor::InNode * toNode = (GraphEditor::InNode * ) DataFlowEditor()->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ; + if ( theNode == NULL || + !strcmp( theNode->Name() , toNode->Name() ) || + !strcmp( theNode->Name() , aNode->Name() ) ) { + if ( theNode || ( toNode->IsEndSwitchNode() && !aNode->IsSwitchNode() ) ) { + if ( anInputParam == NULL || + !strcmp( anInPort->PortName() , anInputParam ) ) { + if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) { + if ( begin ) { + beginService( "Graph_Impl::ListOfLinks" ); + begin = false ; + } + Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + toNode , + anInPort->PortName() , + aNode , + anOutPort->PortName() , + false ) ; + PortableServer::ObjectId * id = myLink->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::Link_var iobject ; + iobject = SUPERV::Link::_narrow(obj) ; + RetVal->length( countlink + 1 ) ; + RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ; + anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ; + } + else { + RetVal->length( countlink + 1 ) ; + RetVal[ countlink++ ] = SUPERV::Link::_duplicate( anOutPort->InPortObjRef( anInPort ) ) ; + } + } + } + } + } + } + } + if ( !begin ) { + endService( "Graph_Impl::ListOfLinks" ); + } + return ( RetVal._retn() ) ; +} + +SUPERV::ListOfGraphs * Graph_Impl::Graphs() { +// beginService( "Graph_Impl::ListOfGraphs" ); + SUPERV::ListOfGraphs_var RetVal = new SUPERV::ListOfGraphs ; + MESSAGE( "Graph_Impl::Graphs not yet implemented" ); +// endService( "Graph_Impl::ListOfGraphs" ); + return ( RetVal._retn() ) ; +} + +Engines::Component_ptr Graph_Impl::ComponentRef( const char * aComputerContainer , + const char * aComponentName ) { + Engines::Container_var myContainer ; + Engines::Component_var objComponent ; + DataFlowEditor()->StartComponent( 0 , aComputerContainer , aComponentName , + myContainer , objComponent ) ; + return Engines::Component::_duplicate( objComponent ) ; +} + +bool Graph_Impl::IsValid() { +// beginService( "Graph_Impl::IsValid" ); + bool RetVal = DataFlowEditor()->IsValid() ; +// endService( "Graph_Impl::IsValid" ); + return RetVal ; +} +bool Graph_Impl::IsExecutable() { +// beginService( "Graph_Impl::IsExecutable" ); + bool RetVal = DataFlowEditor()->IsExecutable() ; +// endService( "Graph_Impl::IsExecutable" ); + return RetVal ; +} +bool Graph_Impl::IsDataFlow() { +// beginService( "Graph_Impl::IsDataFlow" ); + bool RetVal = false ; // = DataFlowEditor()->IsDataFlow() ; +// endService( "Graph_Impl::IsDataFlow" ); + return RetVal ; +} + +bool Graph_Impl::IsEditing() { +// beginService( "Graph_Impl::IsEditing" ); + bool RetVal = DataFlowEditor()->IsEditing() ; +// endService( "Graph_Impl::IsEditing" ); + return RetVal ; +} +bool Graph_Impl::IsExecuting() { +// beginService( "Graph_Impl::IsExecuting" ); + bool RetVal = !DataFlowEditor()->IsEditing() ; +// endService( "Graph_Impl::IsExecuting" ); + return RetVal ; +} + +bool Graph_Impl::IsReadOnly() { +// beginService( "Graph_Impl::IsExecuting" ); + bool RetVal = DataFlowEditor()->IsReadOnly() ; +// endService( "Graph_Impl::IsExecuting" ); + return RetVal ; +} + +long Graph_Impl::LevelMax() { +// beginService( "Graph_Impl::LevelMax" ); + long RetVal = DataFlowEditor()->LevelMax() ; +// endService( "Graph_Impl::LevelMax" ); + return RetVal ; +} +SUPERV::ListOfNodes * Graph_Impl::LevelNodes(long aLevel ) { +// beginService( "Graph_Impl::LevelNodes" ); + SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes; + int i ; + SUPERV::ListOfStrings_var Nodes = DataFlowEditor()->LevelNodes( aLevel ) ; +// RetVal->length( Nodes->length() ); + for ( i = 0 ; i < Nodes->length() ; i++ ) { +// char * aNode = Nodes[ i ] ; + GraphBase::ComputingNode * aNode = DataFlowEditor()->GetChangeGraphNode( Nodes[ i ] ) ; + RetVal = SetNode( RetVal , aNode ) ; +// cout << "Graph_Impl::LevelNodes( " << aLevel << " ) " << aNode->Name() << endl ; +// CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId , +// instanceName() , interfaceName() , +// DataFlowEditor() , +// (GraphEditor::InNode * ) DataFlowEditor()->GetChangeGraphNode( aNode )->GetInNode() ) ; +// PortableServer::ObjectId * id = myNode->getId() ; +// CORBA::Object_var obj = _poa->id_to_reference(*id); +// SUPERV::CNode_var iobject ; +// iobject = SUPERV::CNode::_narrow(obj) ; +// RetVal[i] = SUPERV::CNode::_duplicate( iobject ) ; + } +// endService( "Graph_Impl::LevelNodes" ); + return ( RetVal._retn() ) ; +} +long Graph_Impl::ThreadsMax() { +// beginService( "Graph_Impl::ThreadsMax" ); + long RetVal = DataFlowEditor()->ThreadsMax() ; +// endService( "Graph_Impl::ThreadsMax" ); + return RetVal ; +} +long Graph_Impl::GraphsNumber() { +// beginService( "Graph_Impl::GraphsNumber" ); + long RetVal = DataFlowEditor()->GraphsNumber() ; +// endService( "Graph_Impl::GraphsNumber" ); + return RetVal ; +} +long Graph_Impl::Threads() { +// beginService( "Node_Impl::Threads" ); + long RetVal = _DataFlowExecutor->Threads() ; +// endService( "Node_Impl::Threads" ); + return RetVal ; +} +long Graph_Impl::SuspendedThreads() { +// beginService( "Node_Impl::SuspendedThreads" ); + long RetVal = _DataFlowExecutor->SuspendedThreads() ; +// endService( "Node_Impl::SuspendedThreads" ); + return RetVal ; +} + +bool Graph_Impl::Begin() { + bool RetVal = false ; + if ( DataFlowEditor()->IsEditing() ) { + if ( _DataFlowExecutor ) { + MESSAGE( "Graph_Impl::Begin " << _DataFlowExecutor->Threads() << " threads" ) + if ( _DataFlowExecutor->Threads() ) { + _DataFlowExecutor->JoinedWait() ; + } + delete _DataFlowExecutor ; + _DataFlowExecutor = NULL ; + DataFlowEditor()->Executor( NULL ) ; + } + _ExecNumber += 1 ; + char ExecNumber[30] ; + sprintf( ExecNumber , "_%d" , _ExecNumber ) ; + int len = strlen( _DebugFileName ) ; + char * DebugFileName = new char [ len + strlen( ExecNumber ) + 6 ] ; + strncpy( DebugFileName , _DebugFileName , len - 4 ) ; + DebugFileName[ len - 4 ] = '\0' ; + strcat( DebugFileName , ExecNumber ) ; + strcat( DebugFileName , "_Exec.log" ) ; + GraphBase::SGraph * myGraph = DataFlowEditor()->GetDataFlow() ; + _DataFlowExecutor = new GraphExecutor::DataFlow( _Orb , _NamingService , + myGraph->Info.theName.c_str() , + DebugFileName ) ; + MESSAGE( "Graph_Impl::Begin : DataFlowExecutor created" ); + RetVal = _DataFlowExecutor->LoadDataFlow( *myGraph ) ; + if ( RetVal ) { + DataFlowEditor()->Executor( _DataFlowExecutor ) ; + } + } + return RetVal ; +} +bool Graph_Impl::Run() { + beginService( "Graph_Impl::Run" ); + bool RetVal = false ; + if ( DataFlowEditor()->IsEditing() ) { + RetVal = Begin() ; + } + else { + RetVal = true ; + } + if ( RetVal ) { + MESSAGE( "Graph_Impl::(Re)Run " ); + RetVal = ReRun() ; + } + endService( "Graph_Impl::Run" ); + return RetVal ; +} +bool Graph_Impl::Start() { + beginService( "Graph_Impl::Start" ); + bool RetVal = false ; + if ( DataFlowEditor()->IsEditing() ) { + RetVal = Begin() ; + } + else { + RetVal = true ; + } + if ( RetVal ) { + MESSAGE( "Graph_Impl::(Re)Start " ); + RetVal = ReStart() ; + } + endService( "Graph_Impl::Start" ); + return RetVal ; +} + +bool Graph_Impl::EventNoW( SUPERV::CNode_out aNode , + SUPERV::GraphEvent & anEvent , + SUPERV::GraphState & aState ) { + bool RetVal = false ; + char * aNodeName = NULL ; + SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ; + SUPERV::GraphState theState = SUPERV::UndefinedState ; + if ( !DataFlowEditor()->IsEditing() ) { + RetVal = _DataFlowExecutor->Event( & aNodeName , theEvent , theState , false ) ; +// endService( "Graph_Impl::Event" ); + if ( strlen( aNodeName ) ) { + if ( strcmp( aNodeName , Name() ) ) { + aNode = GetNode( aNodeName ) ; + } + else { + aNode = GetNode() ; + } + } + else { + aNode = SUPERV::Graph::_duplicate( NULL ) ; + } + } + anEvent = theEvent ; + aState = theState ; + return RetVal ; +} + +bool Graph_Impl::Event( SUPERV::CNode_out aNode , + SUPERV::GraphEvent & anEvent , + SUPERV::GraphState & aState ) { +// beginService( "Graph_Impl::Event" ); + bool RetVal = false ; + char * aNodeName = NULL ; + SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ; + SUPERV::GraphState theState = SUPERV::UndefinedState ; + if ( !DataFlowEditor()->IsEditing() ) { + RetVal = _DataFlowExecutor->Event( & aNodeName , theEvent , theState ) ; +// endService( "Graph_Impl::Event" ); + if ( strlen( aNodeName ) ) { + if ( strcmp( aNodeName , Name() ) ) { + aNode = GetNode( aNodeName ) ; + } + else { + aNode = GetNode() ; + } + } + else { + aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ; + } + } + anEvent = theEvent ; + aState = theState ; + return RetVal ; +} + +bool Graph_Impl::EventW( SUPERV::CNode_out aNode , + SUPERV::GraphEvent & anEvent , + SUPERV::GraphState & aState ) { +// beginService( "Graph_Impl::EventW" ); + bool RetVal = false ; + char * aNodeName = NULL ; + SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ; + SUPERV::GraphState theState = SUPERV::UndefinedState ; + if ( !DataFlowEditor()->IsEditing() ) { + RetVal = _DataFlowExecutor->EventW( & aNodeName , theEvent , theState ) ; + if ( RetVal && strcmp( aNodeName , Name() ) ) { + aNode = GetNode( aNodeName ) ; + } + else { + aNode = GetNode() ; + } + } + anEvent = theEvent ; + aState = theState ; +// endService( "Graph_Impl::EventW" ); + return RetVal ; +} + +long Graph_Impl::LastLevelDone() { +// beginService( "Graph_Impl::LastLevelDone" ); + long RetVal = _DataFlowExecutor->LastLevelDone() ; +// endService( "Graph_Impl::LastLevelDone" ); + return RetVal ; +} + +bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) { +// beginService( "Graph_Impl::Merge" ); + bool RetVal = false ; + if ( DataFlowEditor()->IsEditing() ) { + SUPERV::ListOfNodes * aGraphNodes = aGraph->Nodes() ; + SUPERV::ListOfLinks * aGraphLinks = aGraph->Links() ; + SUPERV::ListOfPorts * aGraphPorts = aGraph->Ports() ; + + int i ; + map< string , int > aMapOfNodes ; + for ( i = 0 ; i < aGraphNodes->CNodes.length() ; i++ ) { + SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ; + GraphEditor::InNode * myNode ; + GraphBase::ListOfFuncName aFuncName = GraphBase::ListOfFuncName() ; + GraphBase::ListOfPythonFunctions aPythonFunction = GraphBase::ListOfPythonFunctions() ; + myNode = DataFlowEditor()->AddNode( *(aNode->Service()) , + "" , + "" , + NULL , + SUPERV::ComputingNode , + aFuncName , + aPythonFunction , + aNode->CreationDate() , + aNode->LastUpdateDate() , + aNode->Version() , + aNode->Author() , + "" , + aNode->Comment() , + aNode->X() , + aNode->Y() ) ; + if ( myNode ) { + string * aNodetheName = new string( aNode->Name() ) ; + aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->GetGraphNodeIndex( myNode->Name() ) ; + delete aNodetheName ; + RetVal = true ; + } + else { + RetVal = false ; + break ; + } + } + for ( i = 0 ; i < aGraphNodes->FNodes.length() ; i++ ) { + SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ; + GraphEditor::InNode * myNode ; + GraphBase::ListOfFuncName aFuncName = GraphBase::ListOfFuncName() ; + GraphBase::ListOfPythonFunctions aPythonFunction = GraphBase::ListOfPythonFunctions() ; + myNode = DataFlowEditor()->AddNode( *(aNode->Service()) , + aNode->GetComponentName() , + aNode->GetInterfaceName() , + NULL , + SUPERV::ComputingNode , + aFuncName , + aPythonFunction , + aNode->CreationDate() , + aNode->LastUpdateDate() , + aNode->Version() , + aNode->Author() , + aNode->GetContainer() , + aNode->Comment() , + aNode->X() , + aNode->Y() ) ; + if ( myNode ) { + string * aNodetheName = new string( aNode->Name() ) ; + aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->GetGraphNodeIndex( myNode->Name() ) ; + delete aNodetheName ; + RetVal = true ; + } + else { + RetVal = false ; + break ; + } + } + if ( RetVal ) { + for ( i = 0 ; i < aGraphLinks->length() ; i++ ) { + SUPERV::Link_var aLink = (*aGraphLinks)[ i ] ; + SUPERV::Port_var OutPort = aLink->OutPort() ; + SUPERV::Port_var InPort = aLink->InPort() ; + string * aLinkFromNodeName = new string( OutPort->Node()->Name() ) ; + string * aLinkToNodeName = new string( InPort->Node()->Name() ) ; + RetVal = DataFlowEditor()->AddLink( DataFlowEditor()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() , + OutPort->Name() , + DataFlowEditor()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() , + InPort->Name() ) ; + delete aLinkFromNodeName ; + delete aLinkToNodeName ; + if ( !RetVal ) + break ; + int j ; + for ( j = 1 ; j <= aLink->CoordsSize() ; j++ ) { + long X , Y ; + RetVal = aLink->Coords( j , X , Y ) ; + if ( !RetVal ) + break ; + RetVal = DataFlowEditor()->AddLinkCoord( DataFlowEditor()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() , + OutPort->Name() , + DataFlowEditor()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() , + InPort->Name() , + j , X , Y ) ; + if ( !RetVal ) + break ; + } + } + if ( RetVal ) { + for ( i = 0 ; i < aGraphPorts->length() ; i++ ) { + SUPERV::Port_var aPort = (*aGraphPorts)[ i ] ; + if ( aPort->HasInput() ) { + char * aNode = new char[ strlen( aPort->Name() + 1 ) ] ; + strcpy( aNode , aPort->Name() ) ; + char * thePort = strchr( aNode , '\\' ) ; + thePort[ 0 ] = '\0' ; + RetVal = DataFlowEditor()->AddInputData( DataFlowEditor()->GetGraphNode( aMapOfNodes[ aNode ] )->Name() , + thePort + 1 , + *(aPort->ToAny()) ) ; + delete aNode ; + if ( !RetVal ) + break ; + } + } + } + } + } +// endService( "Graph_Impl::Merge" ); + return RetVal ; +} + diff --git a/src/Supervision/Graph_Impl.hxx b/src/Supervision/Graph_Impl.hxx new file mode 100644 index 0000000..54e06b8 --- /dev/null +++ b/src/Supervision/Graph_Impl.hxx @@ -0,0 +1,162 @@ +//============================================================================= +// File : Graph_Impl.hxx +// Created : Nov 2001 +// Author : Jean Rahuel +// Project : SALOME +// Copyright : CEA 2001 +// $Header: +//============================================================================= + +#ifndef _GRAPH_IMPL_HXX_ +#define _GRAPH_IMPL_HXX_ + +#include + +#include "CORBA.h" + +#include +#include "SALOME_Component_i.hxx" +#include "SALOME_LifeCycleCORBA.hxx" + +#include "Link_Impl.hxx" +#include "FNode_Impl.hxx" +#include "GNode_Impl.hxx" +#include "LNode_Impl.hxx" +#include "ELNode_Impl.hxx" +#include "SNode_Impl.hxx" +#include "ESNode_Impl.hxx" + +#include "DataFlowEditor_DataFlow.hxx" +#include "DataFlowExecutor_DataFlow.hxx" + +class Graph_Impl :public INode_Impl , + public POA_SUPERV::Graph { + private: + + CORBA::ORB_ptr _Orb ; + PortableServer::POA_ptr _Poa ; + PortableServer::ObjectId * _ContId ; + + SALOME_NamingService * _NamingService ; + char * _DebugFileName ; + + GraphExecutor::DataFlow * _DataFlowExecutor ; + + int _ExecNumber ; + SUPERV::Graph_var myServant; // mpv 23.12.2002: store servant of graph to get constant IOR + + public: + Graph_Impl(); + Graph_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + const char *aDataFlowName ) ; + virtual SUPERV::Graph_ptr Copy() ; + + virtual ~Graph_Impl() ; + virtual void destroy() ; + + virtual char* getIOR(); + + virtual void ReadOnly() ; + + virtual SUPERV::INode_ptr GetNode() ; + +// virtual char * DataFlowInfo() ; +// virtual char * DataNodeInfo() ; +// virtual char * NodeInfo( const char * aNodeName ) ; + + virtual GraphBase::SGraph * GetGraph() ; + + virtual bool LoadGraph(const GraphBase::SGraph *aGraph ) ; + virtual bool Import(const char * aXmlFile ) ; + + virtual bool Export(const char * aXmlFile ) ; + +#if 0 + virtual GraphBase::ListOfNodes * GetNodes() ; + virtual GraphBase::ListOfLinks * GetLinks() ; + virtual GraphBase::ListOfLinks * GetDatas() ; +#endif + + virtual SUPERV::CNode_ptr CNode( + const SALOME_ModuleCatalog::Service &NodeService ) ; + virtual SUPERV::FNode_ptr FNode( + const char * NodeComponentName , + const char * InterfaceName , + const SALOME_ModuleCatalog::Service &NodeService ) ; + virtual SUPERV::INode_ptr INode( + const char * FuncName , + const SUPERV::ListOfStrings & PythonFunction ) ; + virtual SUPERV::GNode_ptr GNode( + const char * FuncName , + const SUPERV::ListOfStrings & PythonFunction , + const char * anInLineNode ) ; + virtual SUPERV::LNode_ptr LNode( + const char * InitName , + const SUPERV::ListOfStrings & InitFunction , + const char * MoreName , + const SUPERV::ListOfStrings & MoreFunction , + const char * NextName , + const SUPERV::ListOfStrings & NextFunction , + SUPERV::INode_out anEndOfLoop ) ; + virtual SUPERV::SNode_ptr SNode( + const char * FuncName , + const SUPERV::ListOfStrings & PythonFunction , + SUPERV::INode_out anEndOfSwitch ) ; + + virtual SUPERV::CNode_ptr GetNode( const char * NodeName ); + + virtual SUPERV::Link_ptr Link( SUPERV::Port_ptr OutPort , + SUPERV::Port_ptr InPort ) ; + + virtual SUPERV::ListOfNodes_var Graph_Impl::SetNode( SUPERV::ListOfNodes_var RetVal , + GraphBase::ComputingNode * aNode ) ; + virtual SUPERV::ListOfNodes * Nodes() ; + virtual SUPERV::ListOfLinks * GLinks() ; + virtual SUPERV::ListOfLinks * Links( GraphBase::ComputingNode * aNode , + const char * anInputParam ) ; + virtual SUPERV::ListOfGraphs * Graphs() ; + + virtual Engines::Component_ptr ComponentRef( const char * aComputerContainer , + const char * aComponentName ) ; + + virtual bool IsValid() ; + virtual bool IsExecutable() ; + virtual bool IsDataFlow() ; + + virtual bool IsEditing() ; + virtual bool IsExecuting() ; + + virtual bool IsReadOnly() ; + + virtual long LevelMax() ; + virtual SUPERV::ListOfNodes * LevelNodes(long aLevel ) ; + virtual long ThreadsMax() ; + virtual long GraphsNumber() ; + virtual long Threads() ; + virtual long SuspendedThreads() ; + + virtual bool Begin() ; + virtual bool Run() ; + virtual bool Start() ; + virtual long LastLevelDone() ; + + virtual bool EventNoW( SUPERV::CNode_out aNode , + SUPERV::GraphEvent & anEvent , + SUPERV::GraphState & aState ) ; + virtual bool Event( SUPERV::CNode_out aNode , + SUPERV::GraphEvent & anEvent , + SUPERV::GraphState & aState ) ; + virtual bool EventW( SUPERV::CNode_out aNode , + SUPERV::GraphEvent & anEvent , + SUPERV::GraphState & aState ) ; + + virtual bool Merge(const SUPERV::Graph_ptr aGraph ) ; + +}; + + +#endif diff --git a/src/Supervision/INode_Impl.cxx b/src/Supervision/INode_Impl.cxx new file mode 100644 index 0000000..6c10a63 --- /dev/null +++ b/src/Supervision/INode_Impl.cxx @@ -0,0 +1,328 @@ +using namespace std; +//============================================================================= +// File : INode_Impl.cxx +// Created : 2003 +// Author : Jean Rahuel +// Project : SALOME +// Copyright : CEA +// $Header: +//============================================================================= + +#include +#include +#include +#include + +#include "utilities.h" + +#include "LNode_Impl.hxx" + +INode_Impl::INode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + const char *aDataFlowName ) : +// Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { + CNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowName ) { +// MESSAGE("INode_Impl::INode_Impl activate object instanceName(" +// << instanceName << ") interfaceName(" << interfaceName << ") --> " +// << hex << (void *) this << dec ) +// _thisObj = this ; +// _id = _poa->activate_object(_thisObj); + MESSAGE( "INode_Impl::INode_Impl " << aDataFlowName ); + beginService( "INode_Impl::INode_Impl" ); + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; + endService( "INode_Impl::INode_Impl" ); +} + +INode_Impl::INode_Impl() { +} + +INode_Impl::INode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * aDataFlowEditor , + const char * FuncName , + const SUPERV::ListOfStrings & aPythonFunction , + const SUPERV::KindOfNode NodeKindOfNode ) : +// Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { + CNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , SALOME_ModuleCatalog::Service() , FuncName , NodeKindOfNode , FuncName , aPythonFunction ) { + beginService( "INode_Impl::INode_Impl" ); + if ( FuncName ) { + cout << "INode_Impl::CNode_Impl " << (void *) FuncName << " " << FuncName + << " " << strlen( FuncName ) << endl ; + } + if ( NodeKindOfNode == SUPERV::InLineNode ) { + MESSAGE( "INode_Impl::INode_Impl " << FuncName << " _poa->activate_object" ); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + } + MESSAGE("INode_Impl::INode_Impl " << FuncName << " " << strlen( FuncName ) ) ; + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; +// DataFlowNode()->SetPythonFunction( FuncName , aPythonFunction ) ; + endService( "INode_Impl::INode_Impl" ); +} + +INode_Impl::INode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * aDataFlowEditor , + const GraphBase::ListOfFuncName FuncName , + const GraphBase::ListOfPythonFunctions aPythonFunction , + const SUPERV::KindOfNode NodeKindOfNode ) : +// Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { + CNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , SALOME_ModuleCatalog::Service() , FuncName[0].c_str() , NodeKindOfNode , FuncName , aPythonFunction ) { + beginService( "INode_Impl::INode_Impl" ); + if ( NodeKindOfNode == SUPERV::InLineNode ) { + MESSAGE( "INode_Impl::INode_Impl " << FuncName[0] << " _poa->activate_object" ); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + } + MESSAGE("INode_Impl::INode_Impl " << FuncName[0].c_str() << " " << strlen( FuncName[0].c_str() ) ) ; + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; +// DataFlowNode()->SetPythonFunction( FuncName , aPythonFunction ) ; + endService( "INode_Impl::INode_Impl" ); +} + +INode_Impl::INode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * aDataFlowEditor , + GraphEditor::InNode * aDataFlowNode ) : +// Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { + CNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) { + MESSAGE( DataFlowNode()->Name() << " " ); + beginService( "INode_Impl::INode_Impl" ); + if ( DataFlowNode()->IsInLineNode() ) { + MESSAGE( "INode_Impl::INode_Impl " << DataFlowNode()->PyFuncName() + << " _poa->activate_object" ); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + } + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; + endService( "INode_Impl::INode_Impl" ); +} + +INode_Impl::~INode_Impl() { + beginService( "INode_Impl::~INode_Impl" ); + endService( "INode_Impl::~INode_Impl" ); +} + +void INode_Impl::destroy() { + beginService( "INode_Impl::Destroy" ); + if ( DataFlowEditor()->IsEditing() ) { + if ( Delete() ) { + _poa->deactivate_object(*_id) ; + CORBA::release(_poa) ; + delete(_id) ; + _thisObj->_remove_ref(); + } + } + endService( "INode_Impl::Destroy" ); +} + +bool INode_Impl::Delete() { +// beginService( "INode_Impl::Delete" ); + bool RetVal = false ; + if ( DataFlowEditor()->IsEditing() ) { + RetVal = DataFlowEditor()->RemoveNode( Name() ) ; + if ( RetVal ) + RetVal = DataFlowEditor()->IsValid() ; + } +// endService( "INode_Impl::Delete" ); + return RetVal ; +} + +void INode_Impl::SetPyFunction( const char * FuncName , + const SUPERV::ListOfStrings & aPyFunction ) { + beginService( "INode_Impl::SetPyFunction" ); + if ( DataFlowEditor()->IsEditing() ) { + DataFlowNode()->SetPythonFunction( FuncName , aPyFunction ) ; + } + endService( "INode_Impl::SetPyFunction" ); + return ; +} + +SUPERV::ListOfStrings * INode_Impl::PyFunction() { + beginService( "INode_Impl::PyFunction" ); + SUPERV::ListOfStrings * aPyFunc = NULL ; + if ( DataFlowEditor()->IsEditing() ) { + aPyFunc = new SUPERV::ListOfStrings( *DataFlowNode()->PythonFunction() ) ; + } + else { + aPyFunc = new SUPERV::ListOfStrings() ; + } + endService( "INode_Impl::PyFunction" ); + return aPyFunc ; +} + +char * INode_Impl::PyFuncName() { + return CORBA::string_dup( DataFlowNode()->PyFuncName() ) ; +} + +SUPERV::Port_ptr INode_Impl::InPort( const char *aParameterName , + const char *aParameterType ) { + SUPERV::Port_ptr Inobject = SUPERV::Port::_nil() ; + SUPERV::Port_ptr Outobject = SUPERV::Port::_nil() ; + SUPERV::Port_ptr InEndobject = SUPERV::Port::_nil() ; + Port_Impl * myInPort = NULL ; + bool InPortCreated = false ; + GraphBase::InPort * anInPort = DataFlowNode()->GetChangeInPort( aParameterName ) ; + if ( anInPort == NULL && DataFlowNode()->IsOneOfInLineNodes() ) { + anInPort = DataFlowNode()->AddInPort( aParameterName , aParameterType ) ; + InPortCreated = true ; + } + if ( anInPort ) { + Inobject = anInPort->ObjRef() ; + if ( CORBA::is_nil( Inobject ) ) { + myInPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + DataFlowNode() , + (GraphBase::Port * ) anInPort , + true ) ; + if ( myInPort ) { + PortableServer::ObjectId * id = myInPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id) ; + Inobject = SUPERV::Port::_narrow(obj) ; + } + } + } + + if ( !CORBA::is_nil( Inobject ) && InPortCreated && + ( DataFlowNode()->IsLoopNode() || DataFlowNode()->IsEndLoopNode() || + DataFlowNode()->IsEndSwitchNode() ) ) { + Outobject = OutPort( aParameterName , aParameterType ) ; + if ( DataFlowNode()->IsLoopNode() ) { + LNode_Impl * myLoopNode = (LNode_Impl * ) this ; + InEndobject = myLoopNode->Coupled()->InPort( aParameterName , aParameterType ) ; + DataFlowEditor()->AddLink( Outobject->Node()->Name() , Outobject->Name() , + InEndobject->Node()->Name() , InEndobject->Name() ) ; + } + } + DataFlowEditor()->UnValid() ; + return SUPERV::Port::_duplicate( Inobject ) ; +} + +SUPERV::Port_ptr INode_Impl::OutPort( const char *aParameterName , + const char *aParameterType ) { + Port_Impl * myOutPort = NULL ; + SUPERV::Port_ptr Outobject = SUPERV::Port::_nil() ; + GraphBase::OutPort * anOutPort = DataFlowNode()->GetChangeOutPort( aParameterName ) ; + if ( anOutPort == NULL && DataFlowNode()->IsOneOfInLineNodes() ) { + anOutPort = DataFlowNode()->AddOutPort( aParameterName , aParameterType ) ; + } + if ( anOutPort ) { + Outobject = anOutPort->ObjRef() ; + if ( CORBA::is_nil( Outobject ) ) { + const CORBA::Any * anAny = anOutPort->Value() ; + myOutPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + DataFlowNode() , + (GraphBase::Port * ) anOutPort , + false , + anAny ) ; + if ( myOutPort ) { + PortableServer::ObjectId * id = myOutPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id) ; + Outobject = SUPERV::Port::_narrow(obj) ; + } + } + } + DataFlowEditor()->UnValid() ; + return SUPERV::Port::_duplicate( Outobject ); +} + +#if 0 +bool INode_Impl::BusPort( const char * InOutParameterName , + const char * InOutParameterType , + SUPERV::Port_out InputPort , + SUPERV::Port_out OutputPort ) { + return BusPorts( InOutParameterName , InOutParameterType , + InOutParameterName , InOutParameterType , + InputPort , OutputPort ) ; +} + +bool INode_Impl::BusPorts( const char * InputParameterName , + const char * InputParameterType , + const char * OutputParameterName , + const char * OutputParameterType , + SUPERV::Port_out InputPort , + SUPERV::Port_out OutputPort ) { + beginService( "INode_Impl::BusPorts" ); + bool RetVal = false ; + Port_Impl * myInPort = NULL ; + Port_Impl * myOutPort = NULL ; + SUPERV::Port_var Inobject = SUPERV::Port::_nil() ; + SUPERV::Port_var Outobject = SUPERV::Port::_nil() ; +// if ( DataFlowNode()->GetInPort( InputParameterName ) || +// DataFlowNode()->GetOutPort( OutputParameterName ) ) { +// } +// else { + GraphBase::InPort * anInPort = DataFlowNode()->AddInPort( InputParameterName , + InputParameterType ) ; + if ( anInPort ) { + myInPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + DataFlowNode() , +// InputParameterName ) ; + (GraphBase::Port * ) anInPort , + true ) ; + GraphBase::OutPort * anOutPort = DataFlowNode()->AddOutPort( OutputParameterName , + OutputParameterType ) ; + if ( anOutPort ) { + const CORBA::Any * anAny = anOutPort->Value() ; + myOutPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + DataFlowNode() , +// OutputParameterName , + (GraphBase::Port * ) anOutPort , + false , + anAny ) ; + DataFlowNode()->InOutPort( anInPort , anOutPort ) ; + RetVal = true ; + } + } +// } + if ( RetVal && myInPort && myOutPort ) { + if ( DataFlowNode()->CoupledNode() ) { + GraphBase::InPort * anInPort ; + anInPort = DataFlowNode()->CoupledNode()->AddInPort( OutputParameterName , + OutputParameterType ) ; + GraphBase::OutPort * anOutPort ; + anOutPort = DataFlowNode()->CoupledNode()->AddOutPort( InputParameterName , + InputParameterType ) ; + DataFlowNode()->CoupledNode()->InOutPort( anInPort , anOutPort ) ; + } + PortableServer::ObjectId * id = myInPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id) ; + Inobject = SUPERV::Port::_narrow(obj) ; + InputPort = SUPERV::Port::_duplicate( Inobject ) ; + id = myOutPort->getId() ; + obj = _poa->id_to_reference(*id); + Outobject = SUPERV::Port::_narrow(obj) ; + OutputPort = SUPERV::Port::_duplicate( Outobject ) ; + } + endService( "INode_Impl::BusPorts" ); + return RetVal ; +} +#endif + diff --git a/src/Supervision/INode_Impl.hxx b/src/Supervision/INode_Impl.hxx new file mode 100644 index 0000000..3fdfa10 --- /dev/null +++ b/src/Supervision/INode_Impl.hxx @@ -0,0 +1,88 @@ +//============================================================================= +// File : INode_Impl.hxx +// Created : 2003 +// Author : Jean Rahuel +// Project : SALOME +// Copyright : CEA +// $Header: +//============================================================================= + +#ifndef _INODE_IMPL_HXX_ +#define _INODE_IMPL_HXX_ + +#include + +#include "CORBA.h" + +#include +#include "SALOME_Component_i.hxx" +#include "SALOME_LifeCycleCORBA.hxx" + +#include "CNode_Impl.hxx" + +#include "Port_Impl.hxx" + +#include "DataFlowEditor_DataFlow.hxx" +#include "DataFlowExecutor_DataFlow.hxx" + +class INode_Impl : public CNode_Impl , + public POA_SUPERV::INode { + private: + + CORBA::ORB_ptr _Orb ; + PortableServer::POA_ptr _Poa ; + PortableServer::ObjectId * _ContId ; + + public: + INode_Impl(); + INode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + const char *aDataFlowName ) ; + INode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + const char * FuncName , + const SUPERV::ListOfStrings & PythonFunction , + const SUPERV::KindOfNode NodeKindOfNode = SUPERV::InLineNode ) ; + INode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + const GraphBase::ListOfFuncName FuncName , + const GraphBase::ListOfPythonFunctions PythonFunction , + const SUPERV::KindOfNode NodeKindOfNode = SUPERV::InLineNode ) ; + INode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode ) ; + virtual ~INode_Impl() ; + virtual void destroy() ; + virtual bool Delete() ; + + virtual void SetPyFunction( const char * FuncName , + const SUPERV::ListOfStrings & aPyFunction ) ; + virtual SUPERV::ListOfStrings * PyFunction() ; + virtual char * PyFuncName() ; + + virtual SUPERV::Port_ptr InPort( const char * aParameterName , + const char * aParameterType ) ; + virtual SUPERV::Port_ptr OutPort( const char * aParameterName , + const char * aParameterType ) ; + + virtual GraphBase::InLineNode * BaseNode() { + return DataFlowNode()->InLineNode() ; } ; + +} ; + +#endif diff --git a/src/Supervision/LNode_Impl.cxx b/src/Supervision/LNode_Impl.cxx new file mode 100644 index 0000000..6f06bf3 --- /dev/null +++ b/src/Supervision/LNode_Impl.cxx @@ -0,0 +1,170 @@ +using namespace std; +//============================================================================= +// File : LNode_Impl.cxx +// Created : Nov 2001 +// Author : Jean Rahuel +// Project : SALOME +// $Header: +//============================================================================= + +#include +#include +#include +#include + +#include "utilities.h" + +#include "LNode_Impl.hxx" + +LNode_Impl::LNode_Impl() { +} + +LNode_Impl::LNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * aDataFlowEditor , + GraphBase::ListOfFuncName FuncNameList , + GraphBase::ListOfPythonFunctions PythonFunctionList , +// const char * InitName , +// const SUPERV::ListOfStrings & anInitPythonFunction , +// const char * MoreName , +// const SUPERV::ListOfStrings & aMorePythonFunction , +// const char * NextName , +// const SUPERV::ListOfStrings & aNextPythonFunction , + const SUPERV::KindOfNode NodeKindOfNode ) : +// Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { +// GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , InitName , anInitPythonFunction , NodeKindOfNode ) { + GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , FuncNameList , PythonFunctionList , NodeKindOfNode ) { +// MESSAGE( NodeName << " " ); + beginService( "LNode_Impl::LNode_Impl" ); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; +// DataFlowNode()->SetPyMorePythonFunction( MoreName , aMorePythonFunction ) ; +// DataFlowNode()->SetPyNextPythonFunction( NextName , aNextPythonFunction ) ; + endService( "LNode_Impl::LNode_Impl" ); +} + +LNode_Impl::LNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * aDataFlowEditor , + GraphEditor::InNode * aDataFlowNode ) : +// Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { + GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) { + MESSAGE( DataFlowNode()->Name() << " " ); + beginService( "LNode_Impl::LNode_Impl" ); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; + endService( "LNode_Impl::LNode_Impl" ); +} + +LNode_Impl::~LNode_Impl() { + beginService( "LNode_Impl::~LNode_Impl" ); + endService( "LNode_Impl::~LNode_Impl" ); +} + +void LNode_Impl::destroy() { + beginService( "LNode_Impl::Destroy" ); + if ( DataFlowEditor()->IsEditing() ) { + if ( Delete() ) { + _poa->deactivate_object(*_id) ; + CORBA::release(_poa) ; + delete(_id) ; + _thisObj->_remove_ref(); + } + } + endService( "LNode_Impl::Destroy" ); +} + +bool LNode_Impl::Delete() { +// beginService( "LNode_Impl::Delete" ); + bool RetVal = false ; + if ( DataFlowEditor()->IsEditing() ) { + RetVal = DataFlowEditor()->RemoveNode( Name() ) ; + if ( RetVal ) + RetVal = DataFlowEditor()->IsValid() ; + } +// endService( "LNode_Impl::Delete" ); + return RetVal ; +} + +void LNode_Impl::SetPyInit( const char * InitName , + const SUPERV::ListOfStrings & aPyInit ) { + beginService( "LNode_Impl::SetPyInit" ); + SetPyFunction( InitName , aPyInit ) ; + endService( "LNode_Impl::SetPyInit" ); + return ; +} + +SUPERV::ListOfStrings * LNode_Impl::PyInit() { + SUPERV::ListOfStrings * aPythonFunction ; + beginService( "LNode_Impl::PyInit" ); + aPythonFunction = PyFunction() ; + endService( "LNode_Impl::PyInit" ); + return aPythonFunction ; +} + +char * LNode_Impl::PyInitName() { + beginService( "LNode_Impl::PyInitName" ); + char * RetVal = PyFuncName() ; + endService( "LNode_Impl::PyInitName" ); + return CORBA::string_dup( RetVal ) ; +} + +void LNode_Impl::SetPyMore( const char * MoreName , + const SUPERV::ListOfStrings & aPyMore ) { + beginService( "LNode_Impl::SetPyMore" ); + DataFlowNode()->SetPyMorePythonFunction( MoreName , aPyMore ) ; + endService( "LNode_Impl::SetPyMore" ); + return ; +} + +SUPERV::ListOfStrings * LNode_Impl::PyMore() { + SUPERV::ListOfStrings * aPythonFunction ; + beginService( "LNode_Impl::PyMore" ); + aPythonFunction = DataFlowNode()->PyMorePythonFunction() ; + endService( "LNode_Impl::PyMore" ); + return aPythonFunction ; +} + +char * LNode_Impl::PyMoreName() { + beginService( "LNode_Impl::PyMoreName" ); + char * RetVal = DataFlowNode()->PyMoreName() ; + endService( "LNode_Impl::PyMoreName" ); + return CORBA::string_dup( RetVal ) ; +} + +void LNode_Impl::SetPyNext( const char * NextName , + const SUPERV::ListOfStrings & aPyNext ) { + beginService( "LNode_Impl::SetPyNext" ); + DataFlowNode()->SetPyNextPythonFunction( NextName , aPyNext ) ; + endService( "LNode_Impl::SetPyNext" ); + return ; +} + +SUPERV::ListOfStrings * LNode_Impl::PyNext() { + SUPERV::ListOfStrings * aPythonFunction ; + beginService( "LNode_Impl::PyNext" ); + aPythonFunction = DataFlowNode()->PyNextPythonFunction() ; + endService( "LNode_Impl::PyNext" ); + return aPythonFunction ; +} + +char * LNode_Impl::PyNextName() { + beginService( "LNode_Impl::PyNextName" ); + char * RetVal = DataFlowNode()->PyNextName() ; + endService( "LNode_Impl::PyNextName" ); + return CORBA::string_dup( RetVal ); +} + + diff --git a/src/Supervision/LNode_Impl.hxx b/src/Supervision/LNode_Impl.hxx new file mode 100644 index 0000000..efe7a5f --- /dev/null +++ b/src/Supervision/LNode_Impl.hxx @@ -0,0 +1,84 @@ +//============================================================================= +// File : LNode_Impl.hxx +// Created : 2003 +// Author : Jean Rahuel +// Project : SALOME +// Copyright : CEA +// $Header: +//============================================================================= + +#ifndef _LNODE_IMPL_HXX_ +#define _LNODE_IMPL_HXX_ + +#include + +#include "CORBA.h" + +#include +#include "SALOME_Component_i.hxx" +#include "SALOME_LifeCycleCORBA.hxx" + +#include "GNode_Impl.hxx" + +#include "Port_Impl.hxx" + +#include "DataFlowEditor_DataFlow.hxx" +#include "DataFlowExecutor_DataFlow.hxx" + +class LNode_Impl : public GNode_Impl , + public POA_SUPERV::LNode { + private: + + CORBA::ORB_ptr _Orb ; + PortableServer::POA_ptr _Poa ; + PortableServer::ObjectId * _ContId ; + + public: + LNode_Impl(); + LNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphBase::ListOfFuncName FuncName , + GraphBase::ListOfPythonFunctions PythonFunction , +// const char * InitName , +// const SUPERV::ListOfStrings & InitFunction , +// const char * MoreName , +// const SUPERV::ListOfStrings & MoreFunction , +// const char * NextName , +// const SUPERV::ListOfStrings & NextFunction , + const SUPERV::KindOfNode NodeKindOfNode = SUPERV::LoopNode ) ; + LNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode ) ; + virtual ~LNode_Impl() ; + virtual void destroy() ; + virtual bool Delete() ; + + virtual void SetPyInit( const char * InitName , + const SUPERV::ListOfStrings & aPyMoreFunction ) ; + virtual SUPERV::ListOfStrings * PyInit() ; + virtual char * PyInitName() ; + + virtual void SetPyMore( const char * MoreName , + const SUPERV::ListOfStrings & aPyMoreFunction ) ; + virtual SUPERV::ListOfStrings * PyMore() ; + virtual char * PyMoreName() ; + + virtual void SetPyNext( const char * NextName , + const SUPERV::ListOfStrings & aPyNextFunction ) ; + virtual SUPERV::ListOfStrings * PyNext() ; + virtual char * PyNextName() ; + + virtual GraphBase::LoopNode * BaseNode() { + return DataFlowNode()->LoopNode() ; } ; + +} ; + +#endif diff --git a/src/Supervision/Link_Impl.cxx b/src/Supervision/Link_Impl.cxx new file mode 100644 index 0000000..f93996c --- /dev/null +++ b/src/Supervision/Link_Impl.cxx @@ -0,0 +1,195 @@ +using namespace std; +//============================================================================= +// File : Link_Impl.cxx +// Created : Nov 2001 +// Author : Jean Rahuel +// Project : SALOME +// $Header: +//============================================================================= + +#include +#include +#include +#include + +#include "utilities.h" + +#include "Link_Impl.hxx" + +Link_Impl::Link_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode , + const char *InputParameterName , + GraphEditor::InNode * DataFlowOutNode , + const char *OutputParameterName , + const bool Create ) : +// const SUPERV::Value_ptr aValue ) : + Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { +// MESSAGE("Link_Impl::Link_Impl activate object instanceName(" +// << instanceName << ") interfaceName(" << interfaceName << ") --> " +// << hex << (void *) this << dec ) + bool linksts ; + beginService( "Link_Impl::Link_Impl" ); + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; + _DataFlowEditor = DataFlowEditor ; + _DataFlowNode = DataFlowNode ; + _DataFlowNodeName = DataFlowNode->Name() ; + _InputParameterName = new char[ strlen( InputParameterName ) + 1 ] ; + strcpy( _InputParameterName , InputParameterName ) ; + _DataFlowOutNode = DataFlowOutNode ; + _DataFlowOutNodeName = DataFlowOutNode->Name() ; + _OutputParameterName = new char[ strlen( OutputParameterName ) + 1 ] ; + strcpy( _OutputParameterName , OutputParameterName ) ; + if ( Create ) { + linksts = _DataFlowEditor->AddLink( _DataFlowOutNode->Name() , + _OutputParameterName , + _DataFlowNode->Name() , + _InputParameterName ) ; + } + else { + char * DataFlowOutNodeName = NULL ; + char * OutParamName = NULL ; + linksts = _DataFlowEditor->GetLink( _DataFlowNode->Name() , + _InputParameterName , + &DataFlowOutNodeName , + &OutParamName ) ; + } + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + endService( "Link_Impl::Link_Impl" ); +} + +Link_Impl::Link_Impl() { +} + +Link_Impl::~Link_Impl() { + beginService( "Link_Impl::~Link_Impl" ); + endService( "Link_Impl::~Link_Impl" ); +} + +void Link_Impl::destroy() { + beginService( "Link_Impl::destroy" ); + Delete() ; + _poa->deactivate_object(*_id) ; + CORBA::release(_poa) ; + delete(_id) ; + _thisObj->_remove_ref(); + endService( "Link_Impl::destroy" ); +} + +bool Link_Impl::Delete() { +// beginService( "Link_Impl::Delete" ) ; + bool RetVal = _DataFlowEditor->RemoveLink( _DataFlowOutNode->Name() , + _OutputParameterName , + _DataFlowNode->Name() , + _InputParameterName ) ; +// endService( "Link_Impl::Delete" ); + return RetVal ; +} + +SUPERV::Port_ptr Link_Impl::InPort() { +// beginService( "Link_Impl::InPort" ); + GraphBase::InPort * anInPort = _DataFlowNode->GetChangeInPort( _InputParameterName ) ; + Port_Impl * myPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , +// _InputParameterName ) ; + (GraphBase::Port * ) anInPort , + true ) ; + PortableServer::ObjectId * id = myPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::Port_var iobject ; + iobject = SUPERV::Port::_narrow(obj) ; +// endService( "Link_Impl::InPort" ); + return SUPERV::Port::_duplicate( iobject ) ; +} + +SUPERV::Port_ptr Link_Impl::OutPort() { +// beginService( "Link_Impl::OutPort" ); + GraphBase::OutPort * anOutPort = _DataFlowOutNode->GetChangeOutPort( _OutputParameterName ) ; + Port_Impl * myPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowOutNode , +// _OutputParameterName ) ; + (GraphBase::Port * ) anOutPort , + false ) ; + PortableServer::ObjectId * id = myPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::Port_var iobject ; + iobject = SUPERV::Port::_narrow(obj) ; +// endService( "Link_Impl::OutPort" ); + return SUPERV::Port::_duplicate( iobject ) ; +} + +GraphBase::SLink * Link_Impl::Info() { +// beginService( "Link_Impl::Info" ); + char* FromNodeName ; + char* FromServiceParameterName ; + GraphBase::SLink * RetVal = _DataFlowEditor->GetLink( _DataFlowNode->ComputingNode() , + _InputParameterName ) ; +// endService( "Link_Impl::Info" ); + return RetVal ; +} + +long Link_Impl::CoordsSize() { +// beginService( "Link_Impl::CoordsSize" ) ; + long RetVal = _DataFlowEditor->GetLinkCoordSize( _DataFlowOutNode->Name() , + _OutputParameterName , + _DataFlowNode->Name() , + _InputParameterName ) ; +// endService( "Link_Impl::CoordsSize" ); + return RetVal ; +} +bool Link_Impl::AddCoord( const long index , + const long X , + const long Y ) { +// beginService( "Link_Impl::AddCoord" ) ; + bool RetVal = _DataFlowEditor->AddLinkCoord( _DataFlowOutNode->Name() , + _OutputParameterName , + _DataFlowNode->Name() , + _InputParameterName, + index , X , Y ) ; +// endService( "Link_Impl::AddCoord" ); + return RetVal ; +} +bool Link_Impl::ChangeCoord( const long index , + const long X , + const long Y ) { +// beginService( "Link_Impl::ChangeCoord" ) ; + bool RetVal = _DataFlowEditor->ChangeLinkCoord( _DataFlowOutNode->Name() , + _OutputParameterName , + _DataFlowNode->Name() , + _InputParameterName, + index , X , Y ) ; +// endService( "Link_Impl::ChangeCoord" ); + return RetVal ; +} +bool Link_Impl::RemoveCoord( const long index ) { +// beginService( "Link_Impl::RemoveCoord" ) ; + bool RetVal = _DataFlowEditor->RemoveLinkCoord( _DataFlowOutNode->Name() , + _OutputParameterName , + _DataFlowNode->Name() , + _InputParameterName, + index ) ; +// endService( "Link_Impl::RemoveCoord" ); + return RetVal ; +} +bool Link_Impl::Coords( const long index , long & X , long & Y ) { +// beginService( "Link_Impl::Coords" ) ; + bool RetVal = _DataFlowEditor->GetLinkCoord( _DataFlowOutNode->Name() , + _OutputParameterName , + _DataFlowNode->Name() , + _InputParameterName, + index , X , Y ) ; +// endService( "Link_Impl::Coords" ); + return RetVal ; +} + diff --git a/src/Supervision/Link_Impl.hxx b/src/Supervision/Link_Impl.hxx new file mode 100644 index 0000000..8cbd9e5 --- /dev/null +++ b/src/Supervision/Link_Impl.hxx @@ -0,0 +1,78 @@ +//============================================================================= +// File : Link_Impl.hxx +// Created : Nov 2001 +// Author : Jean Rahuel +// Project : SALOME +// Copyright : CEA 2001 +// $Header: +//============================================================================= + +#ifndef _LINK_IMPL_HXX_ +#define _LINK_IMPL_HXX_ + +#include + +#include "CORBA.h" + +#include +#include "SALOME_Component_i.hxx" +#include "SALOME_LifeCycleCORBA.hxx" + +#include "Value_Impl.hxx" +#include "Port_Impl.hxx" + +#include "DataFlowEditor_DataFlow.hxx" + +class Link_Impl : public POA_SUPERV::Link , + public Engines_Component_i { + private: + + CORBA::ORB_ptr _Orb ; + PortableServer::POA_ptr _Poa ; + PortableServer::ObjectId * _ContId ; + + GraphEditor::DataFlow * _DataFlowEditor ; + GraphEditor::InNode * _DataFlowNode ; + char * _DataFlowNodeName ; + char * _InputParameterName ; + GraphEditor::InNode * _DataFlowOutNode ; + char * _DataFlowOutNodeName ; + char * _OutputParameterName ; + + public: + Link_Impl(); + Link_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode , + const char *InputParameterName , + GraphEditor::InNode * DataFlowOutNode , + const char *OutputParameterName , + const bool Create ) ; + + virtual ~Link_Impl() ; + virtual void destroy() ; + virtual bool Delete() ; + + SUPERV::Port_ptr OutPort() ; + SUPERV::Port_ptr InPort() ; + + virtual GraphBase::SLink * Info() ; + + virtual long CoordsSize() ; + virtual bool AddCoord( const long index , + const long X , + const long Y ) ; + virtual bool ChangeCoord( const long index , + const long X , + const long Y ) ; + virtual bool RemoveCoord( const long index ) ; + virtual bool Coords( const long index , long & X , long & Y ) ; + + +} ; + +#endif diff --git a/src/Supervision/Makefile.in b/src/Supervision/Makefile.in new file mode 100755 index 0000000..0d249bb --- /dev/null +++ b/src/Supervision/Makefile.in @@ -0,0 +1,79 @@ +#============================================================================== +# File : Makefile.in +# Created : aug 21 2001 +# Author : , CEA +# Project : SALOME +# Copyright : CEA 2001 +# $Header: +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl + + +@COMMENCE@ + +EXPORT_PYSCRIPTS = SuperV.py batchmode_SuperV.py + +EXPORT_HEADERS = \ + SuperV_Impl.hxx \ + Graph_Impl.hxx \ + CNode_Impl.hxx \ + FNode_Impl.hxx \ + INode_Impl.hxx \ + GNode_Impl.hxx \ + LNode_Impl.hxx \ + ELNode_Impl.hxx \ + SNode_Impl.hxx \ + ESNode_Impl.hxx \ + Link_Impl.hxx \ + Value_Impl.hxx \ + Port_Impl.hxx +# Input_Impl.hxx \ + +# Libraries targets +LIB = libSUPERVEngine.la +LIB_SRC = Value_Impl.cxx \ + Port_Impl.cxx \ + Link_Impl.cxx \ + CNode_Impl.cxx \ + FNode_Impl.cxx \ + INode_Impl.cxx \ + GNode_Impl.cxx \ + LNode_Impl.cxx \ + ELNode_Impl.cxx \ + SNode_Impl.cxx \ + ESNode_Impl.cxx \ + Graph_Impl.cxx \ + SuperV_Impl.cxx +# Input_Impl.cxx \ + +LIB_CLIENT_IDL = SALOME_ModuleCatalog.idl \ + SALOME_Component.idl \ + SALOMEDS.idl \ + SUPERV.idl \ + SALOME_Exception.idl + +# Executables targets +#BIN = SuperV_CheckOfUndefined +BIN_SRC = +BIN_SERVER_IDL = + +CPPFLAGS+= $(PYTHON_INCLUDES) $(QT_MT_INCLUDES) $(VTK_INCLUDES) \ + $(OGL_INCLUDES) $(OCC_INCLUDES) \ + -I${KERNEL_ROOT_DIR}/include/salome +CXXFLAGS= -g -D_DEBUG_ -D__x86__ -D__linux__ -ftemplate-depth-42 \ + -I${KERNEL_ROOT_DIR}/include/salome +LDFLAGS+= -lSalomeSuperVisionEditor -lSalomeSuperVisionExecutor -lSalomeSuperVisionBase \ + -lSalomeContainer -lSalomeNotification -lSalomeDS -lSalomeNS -lSalomeLifeCycleCORBA \ + -lOpUtil -lRegistry -lSalomeHDFPersist -lSalomeLoggerServer \ + $(QT_MT_LIBS) $(OGL_LIBS) $(HDF5_LIBS) \ + -L${KERNEL_ROOT_DIR}/lib/salome + +#LDFLAGS+= -lSalomeSuperVisionEditor -lSalomeSuperVisionExecutor -lSalomeSuperVisionBase -lSalomeContainer -lSalomeNotification -lSalomeNS -lSalomeLifeCycleCORBA -lOpUtil -lRegistry -lSalomeHDFPersist -lSalomeLoggerServer $(QT_MT_LIBS) $(OGL_LIBS) $(HDF5_LIBS) + +@CONCLUDE@ + diff --git a/src/Supervision/Port_Impl.cxx b/src/Supervision/Port_Impl.cxx new file mode 100644 index 0000000..cd6b4dc --- /dev/null +++ b/src/Supervision/Port_Impl.cxx @@ -0,0 +1,380 @@ +using namespace std; +//============================================================================= +// File : Port_Impl.cxx +// Created : Nov 2001 +// Author : Jean Rahuel +// Project : SALOME +// $Header: +//============================================================================= + +#include +#include +#include +#include + +#include "utilities.h" + +#include "Graph_Impl.hxx" +#include "Port_Impl.hxx" + +Port_Impl::Port_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode , +// const char *ParameterName , + GraphBase::Port * DataFlowPort , + bool InputPort , + const CORBA::Any * anAny ) : +// const SUPERV::Value_ptr aValue ) : + Value_Impl(orb, poa, contId, instanceName, interfaceName, +// DataFlowEditor , DataFlowNode , ParameterName, aValue->ToAny() , + DataFlowEditor , DataFlowNode , DataFlowPort->PortName(), anAny , + false ) { +// MESSAGE("Value_Impl::Value_Impl activate object instanceName(" +// << instanceName << ") interfaceName(" << interfaceName << ") --> " +// << hex << (void *) this << dec ) + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + _DataFlowEditor = DataFlowEditor ; + _DataFlowNode = DataFlowNode ; +// _DataFlowPort = _DataFlowNode->GetChangeInPort( ParameterName ) ; + _DataFlowPort = DataFlowPort ; +// _InputPort = true ; + _InputPort = InputPort ; +// if ( _DataFlowPort == NULL ) { +// _DataFlowPort = _DataFlowNode->GetChangeOutPort( ParameterName ) ; +// _InputPort = false ; +// } + InPort( _InputPort ) ; +} + +Port_Impl::Port_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode , +// const char *ParameterName ) : + GraphBase::Port * DataFlowPort , + bool InputPort ) : + Value_Impl(orb, poa, contId, instanceName, interfaceName, + DataFlowEditor , DataFlowNode , DataFlowPort->PortName() , false ) { +// DataFlowEditor , DataFlowNode , ParameterName , false ) { +// MESSAGE("Value_Impl::Value_Impl activate object instanceName(" +// << instanceName << ") interfaceName(" << interfaceName << ") --> " +// << hex << (void *) this << dec ) + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + _DataFlowEditor = DataFlowEditor ; + _DataFlowNode = DataFlowNode ; +// _DataFlowPort = _DataFlowNode->GetChangeInPort( ParameterName ) ; + _DataFlowPort = DataFlowPort ; +// _InputPort = true ; + _InputPort = InputPort ; +// if ( _DataFlowPort == NULL ) { +// _DataFlowPort = _DataFlowNode->GetChangeOutPort( ParameterName ) ; +// _InputPort = false ; +// } + InPort( _InputPort ) ; +} + +Port_Impl::Port_Impl() { +} + +Port_Impl::~Port_Impl() { + beginService( "Port_Impl::~Port_Impl" ); + endService( "Port_Impl::~Port_Impl" ); +} + +void Port_Impl::destroy() { + beginService( "Port_Impl::destroy" ); + bool destroyed = false ; + if ( _DataFlowNode->IsOneOfInLineNodes() ) { + if ( _InputPort ) { + GraphBase::InPort * anInPort = (GraphBase::InPort * ) _DataFlowPort ; + if ( anInPort->GetOutPort() ) { + anInPort->GetOutPort()->RemoveInPort( anInPort ) ; + } + _DataFlowNode->DelInPort( _DataFlowPort->PortName() ) ; + if ( _DataFlowNode->IsLoopNode() ) { + _DataFlowNode->DelOutPort( _DataFlowPort->PortName() ) ; + _DataFlowNode->CoupledNode()->DelInPort( _DataFlowPort->PortName() ) ; + _DataFlowNode->CoupledNode()->DelOutPort( _DataFlowPort->PortName() ) ; + } + destroyed = true ; + } + else if ( !_DataFlowNode->IsLoopNode() ) { + _DataFlowNode->DelOutPort( _DataFlowPort->PortName() ) ; + destroyed = true ; + } + if ( destroyed ) { + _DataFlowEditor->UnValid() ; +// _DataFlowEditor->IsValid() ; + } + } + if ( destroyed ) { + _poa->deactivate_object(*_id) ; + CORBA::release(_poa) ; + delete(_id) ; + _thisObj->_remove_ref(); + } + endService( "Port_Impl::destroy" ); +} + +bool Port_Impl::Input( const SUPERV::Value_ptr aValue ) { + return Input( aValue->ToAny() ) ; +} + +bool Port_Impl::Input( const CORBA::Any * anAny ) { + beginService( "Port_Impl::Input" ); + bool RetVal = false ; + if ( _InputPort && _DataFlowEditor->IsEditing() ) { + RetVal = true ; + Value_Impl::Input( anAny ) ; + RetVal = _DataFlowEditor->AddInputData( _DataFlowNode->Name() , + _DataFlowPort->PortName() , + *anAny ) ; + } + else if ( _DataFlowEditor->IsExecuting() ) { + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; +// if ( _DataFlowExecutor && ( _DataFlowExecutor->IsSuspended() || +// _DataFlowExecutor->IsSuspended( _DataFlowNode->Name() ) ) ) { + if ( _DataFlowExecutor ) { + RetVal = _DataFlowExecutor->ChangeInputData( _DataFlowNode->Name() , + _DataFlowPort->PortName() , + *anAny ) ; + } + } + endService( "Port_Impl::Input" ); + return RetVal ; +} + +char * Port_Impl::Name() { +// beginService( "Port_Impl::Name" ) ; + const char * RetVal = _DataFlowPort->PortName() ; +// endService( "Port_Impl::Name" ) ; + return CORBA::string_dup( RetVal ) ; +} + +char * Port_Impl::Type() { +// beginService( "Port_Impl::Type" ) ; + const char * RetVal = _DataFlowPort->PortType() ; +// endService( "Port_Impl::Type" ) ; + return CORBA::string_dup( RetVal ) ; +} + +SUPERV::CNode_ptr Port_Impl::Node() { + bool begin = true ; + SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ; + if ( CORBA::is_nil( _DataFlowNode->ObjRef() ) ) { + if ( begin ) { + beginService( "Port_Impl::Node" ) ; + begin = false ; + } + CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode ) ; + PortableServer::ObjectId * id = myNode->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::CNode_var iobject ; + iobject = SUPERV::CNode::_narrow(obj) ; + myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ; + } + else { + iobject = _DataFlowNode->ObjRef() ; + } + if ( !begin ) { + endService( "Port_Impl::Node" ) ; + } + return SUPERV::CNode::_duplicate( iobject ) ; +} + +SUPERV::ListOfLinks * Port_Impl::Links() { + beginService( "Port_Impl::Links" ) ; + SUPERV::ListOfLinks_var RetVal = new SUPERV::ListOfLinks ; + RetVal = _DataFlowEditor->ObjImpl()->Links( _DataFlowNode->ComputingNode() , + _DataFlowPort->PortName() ) ; + endService( "Port_Impl::Links" ) ; + return ( RetVal._retn() ) ; +} + +SUPERV::Link_ptr Port_Impl::Link() { + bool begin = true ; + SUPERV::Link_var iobject = SUPERV::Link::_nil() ; + if ( _DataFlowNode->IsEndSwitchNode() ) { + beginService( "Port_Impl::Link" ) ; + begin = false ; + SUPERV::ListOfLinks_var Links = new SUPERV::ListOfLinks ; + cout << "Port_Impl::Link " << _DataFlowNode->Name() << " " + << _DataFlowPort->PortName() << endl ; + Links = _DataFlowEditor->ObjImpl()->Links( + _DataFlowNode->ComputingNode() , + _DataFlowPort->PortName() ) ; + if ( Links->length() ) { + iobject = Links[ 0 ] ; + } + } + else { + char * FromNodeName = NULL ; + char * FromServiceParameterName = NULL ; + bool status = _DataFlowEditor->GetLink( _DataFlowNode->Name() , + _DataFlowPort->PortName() , + & FromNodeName , + & FromServiceParameterName ) ; + if ( status ) { +// cout << "Port_Impl::Link " << FromNodeName << "(" +// << FromServiceParameterName << ") --> " << _DataFlowNode->Name() +// << "(" << _DataFlowPort->PortName() << ")" << endl ; +// SUPERV::Port_ptr theOutPort = Port( FromServiceParameterName ) ; + + GraphBase::InPort * anInPort = _DataFlowNode->GetChangeInPort( _DataFlowPort->PortName() ) ; + if ( anInPort->GetOutPort() ) { + GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; + if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) { + if ( begin ) { + beginService( "Port_Impl::Link" ) ; + begin = false ; + } + Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , + _DataFlowPort->PortName() , + (GraphEditor::InNode * ) _DataFlowEditor->GetChangeGraphNode( FromNodeName )->GetInNode() , + FromServiceParameterName , + false ) ; + PortableServer::ObjectId * id = myLink->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::Link::_narrow(obj) ; + anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ; + } + else { + iobject = anOutPort->InPortObjRef( anInPort ) ; + } + } + } + } + if ( !begin ) { + endService( "Port_Impl::Link" ) ; + } + return SUPERV::Link::_duplicate( iobject ) ; +} + +bool Port_Impl::IsInput() { +// beginService( "Port_Impl::IsInput" ) ; + bool RetVal = _InputPort ; +// endService( "Port_Impl::IsInput" ) ; + return RetVal ; +} + +bool Port_Impl::IsLinked() { +// beginService( "Port_Impl::IsLinked" ) ; + bool RetVal = true ; +#if 0 + if ( _DataFlowNode->IsEndSwitchNode() && _DataFlowPort->IsBus() ) { + } + else { +#endif + RetVal = _DataFlowNode->IsLinked( _DataFlowPort->PortName() ) ; +#if 0 + } +#endif +// endService( "Port_Impl::IsLinked" ) ; + return RetVal ; +} + +SUPERV::KindOfPort Port_Impl::Kind() { +// beginService( "Port_Impl::Kind" ) ; + SUPERV::KindOfPort RetVal = _DataFlowPort->Kind() ; +// endService( "Port_Impl::Kind" ) ; + return RetVal ; +} + +bool Port_Impl::IsParam() { +// beginService( "Port_Impl::IsParam" ) ; + bool RetVal = _DataFlowPort->IsParam() ; +// endService( "Port_Impl::IsParam" ) ; + return RetVal ; +} + +bool Port_Impl::IsGate() { +// beginService( "Port_Impl::IsGate" ) ; + bool RetVal = _DataFlowPort->IsGate() ; +// endService( "Port_Impl::IsGate" ) ; + return RetVal ; +} + +bool Port_Impl::IsInLine() { +// beginService( "Port_Impl::IsInLine" ) ; +// bool RetVal = _DataFlowPort->IsBus() ; + bool RetVal = _DataFlowPort->IsInLine() ; +// endService( "Port_Impl::IsInLine" ) ; + return RetVal ; +} + +bool Port_Impl::IsLoop() { +// beginService( "Port_Impl::IsLoop" ) ; + bool RetVal = _DataFlowPort->IsLoop() ; +// endService( "Port_Impl::IsLoop" ) ; + return RetVal ; +} + +bool Port_Impl::IsSwitch() { +// beginService( "Port_Impl::IsSwitch" ) ; + bool RetVal = _DataFlowPort->IsSwitch() ; +// endService( "Port_Impl::IsSwitch" ) ; + return RetVal ; +} + +bool Port_Impl::IsEndSwitch() { +// beginService( "Port_Impl::IsEndSwitch" ) ; + bool RetVal = _DataFlowPort->IsEndSwitch() ; +// endService( "Port_Impl::IsEndSwitch" ) ; + return RetVal ; +} + +bool Port_Impl::HasInput() { +// beginService( "Port_Impl::" ) ; + bool RetVal = _DataFlowNode->HasInput( _DataFlowPort->PortName() ) ; +// endService( "Port_Impl::" ) ; + return RetVal ; +} + +SUPERV::GraphState Port_Impl::State() { +// beginService( "Port_Impl::State" ); + SUPERV::GraphState RetVal = SUPERV::EditingState ; + if ( _DataFlowEditor ) { + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + RetVal = _DataFlowExecutor->State( _DataFlowPort->NodeName() , + _DataFlowPort->PortName() ) ; + } + } +// endService( "Port_Impl::State" ); + return RetVal ; +} + +bool Port_Impl::IsDone() { +// beginService( "Port_Impl::IsDone" ); + bool RetVal = false ; + if ( _DataFlowEditor ) { + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + RetVal = _DataFlowExecutor->IsDone( _DataFlowPort->NodeName() , + _DataFlowPort->PortName() ) ; + } + } +// endService( "Port_Impl::IsDone" ); + return RetVal ; +} diff --git a/src/Supervision/Port_Impl.hxx b/src/Supervision/Port_Impl.hxx new file mode 100644 index 0000000..8814a77 --- /dev/null +++ b/src/Supervision/Port_Impl.hxx @@ -0,0 +1,94 @@ +//============================================================================= +// File : Port_Impl.hxx +// Created : Nov 2001 +// Author : Jean Rahuel +// Project : SALOME +// Copyright : CEA 2001 +// $Header: +//============================================================================= + +#ifndef _PORT_IMPL_HXX_ +#define _PORT_IMPL_HXX_ + +#include + +#include "CORBA.h" + +#include +#include "SALOME_Component_i.hxx" +#include "SALOME_LifeCycleCORBA.hxx" + +#include "Value_Impl.hxx" +#include "Link_Impl.hxx" +#include "FNode_Impl.hxx" + +#include "DataFlowEditor_DataFlow.hxx" + +class Port_Impl : public Value_Impl , + public POA_SUPERV::Port { + private: + + CORBA::ORB_ptr _Orb ; + PortableServer::POA_ptr _Poa ; + PortableServer::ObjectId * _ContId ; + + GraphEditor::DataFlow * _DataFlowEditor ; + GraphEditor::InNode * _DataFlowNode ; + GraphBase::Port * _DataFlowPort ; + bool _InputPort ; + + public: + Port_Impl(); + Port_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode , + GraphBase::Port * DataFlowPort , + bool InputPort , +// const char *ParameterName , + const CORBA::Any * anAny ) ; + Port_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode , + GraphBase::Port * DataFlowPort , + bool InputPort ) ; +// const char *ParameterName ) ; + virtual ~Port_Impl() ; + virtual void destroy() ; + + virtual bool Input( const SUPERV::Value_ptr aValue ) ; + virtual bool Input( const CORBA::Any * anAny ) ; + + virtual char * Name() ; + virtual char * Type() ; + + virtual SUPERV::CNode_ptr Node() ; + + virtual SUPERV::Link_ptr Link() ; + virtual SUPERV::ListOfLinks * Links() ; + + virtual bool IsInput() ; + virtual bool IsLinked() ; + virtual bool HasInput() ; + + virtual SUPERV::KindOfPort Kind() ; + virtual bool IsParam() ; + virtual bool IsGate() ; + virtual bool IsInLine() ; + virtual bool IsLoop() ; + virtual bool IsSwitch() ; + virtual bool IsEndSwitch() ; + + virtual SUPERV::GraphState State() ; + virtual bool IsDone() ; + +} ; + +#endif diff --git a/src/Supervision/SNode_Impl.cxx b/src/Supervision/SNode_Impl.cxx new file mode 100644 index 0000000..6b9718c --- /dev/null +++ b/src/Supervision/SNode_Impl.cxx @@ -0,0 +1,97 @@ +using namespace std; +//============================================================================= +// File : SNode_Impl.cxx +// Created : 2003 +// Author : Jean Rahuel +// Project : SALOME +// $Header: +//============================================================================= + +#include +#include +#include +#include + +#include "utilities.h" + +#include "SNode_Impl.hxx" + +SNode_Impl::SNode_Impl() { +} + +SNode_Impl::SNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * aDataFlowEditor , + const char * FuncName , + const SUPERV::ListOfStrings & PythonFunction , + const SUPERV::KindOfNode NodeKindOfNode ) : +// Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { + GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , FuncName , PythonFunction , NodeKindOfNode ) { +// MESSAGE( NodeName << " " ); + beginService( "SNode_Impl::SNode_Impl" ); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; +// DataFlowNode( DataFlowEditor()->AddNode( NodeService , NodeComponentName , +// NodeInterfaceName , NodeName , +// NodeKindOfNode ) ) ; +// DataFlowNode( DataFlowEditor()->AddNode( SALOME_ModuleCatalog::Service() , +// "" , "" , "" , +// NodeKindOfNode ) ) ; + endService( "SNode_Impl::SNode_Impl" ); +} + +SNode_Impl::SNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * aDataFlowEditor , + GraphEditor::InNode * aDataFlowNode ) : +// Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { + GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) { + MESSAGE( DataFlowNode()->Name() << " " ); + beginService( "SNode_Impl::SNode_Impl" ); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; + endService( "SNode_Impl::SNode_Impl" ); +} + +SNode_Impl::~SNode_Impl() { + beginService( "SNode_Impl::~SNode_Impl" ); + endService( "SNode_Impl::~SNode_Impl" ); +} + +void SNode_Impl::destroy() { + beginService( "SNode_Impl::Destroy" ); + if ( DataFlowEditor()->IsEditing() ) { + if ( Delete() ) { + _poa->deactivate_object(*_id) ; + CORBA::release(_poa) ; + delete(_id) ; + _thisObj->_remove_ref(); + } + } + endService( "SNode_Impl::Destroy" ); +} + +bool SNode_Impl::Delete() { +// beginService( "SNode_Impl::Delete" ); + bool RetVal = false ; + if ( DataFlowEditor()->IsEditing() ) { + RetVal = DataFlowEditor()->RemoveNode( Name() ) ; + if ( RetVal ) + RetVal = DataFlowEditor()->IsValid() ; + } +// endService( "SNode_Impl::Delete" ); + return RetVal ; +} + diff --git a/src/Supervision/SNode_Impl.hxx b/src/Supervision/SNode_Impl.hxx new file mode 100644 index 0000000..1017995 --- /dev/null +++ b/src/Supervision/SNode_Impl.hxx @@ -0,0 +1,62 @@ +//============================================================================= +// File : SNode_Impl.hxx +// Created : 2003 +// Author : Jean Rahuel +// Project : SALOME +// Copyright : CEA 2003 +// $Header: +//============================================================================= + +#ifndef _SNODE_IMPL_HXX_ +#define _SNODE_IMPL_HXX_ + +#include + +#include "CORBA.h" + +#include +#include "SALOME_Component_i.hxx" +#include "SALOME_LifeCycleCORBA.hxx" + +#include "GNode_Impl.hxx" +#include "Port_Impl.hxx" + +#include "DataFlowEditor_DataFlow.hxx" +#include "DataFlowExecutor_DataFlow.hxx" + +class SNode_Impl : public GNode_Impl , + public POA_SUPERV::SNode { + private: + + CORBA::ORB_ptr _Orb ; + PortableServer::POA_ptr _Poa ; + PortableServer::ObjectId * _ContId ; + + public: + SNode_Impl(); + SNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + const char * FuncName , + const SUPERV::ListOfStrings & PythonFunction , + const SUPERV::KindOfNode NodeKindOfNode = SUPERV::SwitchNode ) ; + SNode_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode ) ; + virtual ~SNode_Impl() ; + virtual void destroy() ; + virtual bool Delete() ; + + virtual GraphBase::SwitchNode * BaseNode() { + return DataFlowNode()->SwitchNode() ; } ; + +} ; + +#endif diff --git a/src/Supervision/SuperV.py b/src/Supervision/SuperV.py new file mode 100644 index 0000000..a1028ee --- /dev/null +++ b/src/Supervision/SuperV.py @@ -0,0 +1,1139 @@ +#! /usr/bin/env python + +try : + from salome import orb + from salome import lcc + from salome import naming_service + from salome import CORBA + from salome import sg +except : + import curses + from LifeCycleCORBA import * + from SALOME_NamingServicePy import * + import SUPERV + import SUPERV_idl +# try : +# from libSuperVision_Swig import SuperV_Swig +# print 'SuperV_Swig imported' +# except : +# SuperV_Swig = None + orb = CORBA.ORB_init([''], CORBA.ORB_ID) + lcc = LifeCycleCORBA(orb) + naming_service = SALOME_NamingServicePy_i(orb) + +import os +import re +from types import * + +#try : +# SuperVision = SuperV_Swig( len(sys.argv) , sys.argv ) +# SuperVision.Swig = 1 +# print 'SuperV_Swig created' +#except : +# SuperVision = lcc.FindOrLoadComponent("SuperVisionContainer","SUPERV") +# SuperVision.Swig = 0 +# print 'Supervision Component loaded' + +SuperVision = lcc.FindOrLoadComponent("SuperVisionContainer","SUPERV") +SuperVision.Swig = 0 + +modulecatalog = naming_service.Resolve("/Kernel/ModulCatalog") + + + +def PortInputFloat(obj, x): + return obj.Input( SuperVision.AnyValue( CORBA.Any(CORBA.TC_double, x))) + +def PortInputLong(obj, x): + return obj.Input( SuperVision.AnyValue( CORBA.Any(CORBA.TC_long, x))) + +def PortInputObject(obj, x): + try: + return obj.Input( SuperVision.AnyValue( CORBA.Any(CORBA.TC_Object, x))) + except: + return obj.Input( SuperVision.AnyValue( x ) ) + +def PortInputString(obj, x): + return obj.Input( SuperVision.AnyValue( CORBA.Any(CORBA.TC_string, x))) + +def InputFloat(obj, nodein_port, x): + return obj.Input(nodein_port, SuperVision.AnyValue( CORBA.Any(CORBA.TC_double, x))) + +def InputLong(obj, nodein_port, x): + return obj.Input(nodein_port, SuperVision.AnyValue( CORBA.Any(CORBA.TC_long, x))) + +def InputObject(obj, nodein_port, x): + try: + return obj.Input(nodein_port, SuperVision.AnyValue( CORBA.Any(CORBA.TC_Object, x))) + except: + return obj.Input(nodein_port, SuperVision.AnyValue( x ) ) + +def InputString(obj, nodein_port, x): + return obj.Input(nodein_port, SuperVision.AnyValue( CORBA.Any(CORBA.TC_string, x))) + + + +typestring = re.compile(r"_[^_]+_([^_]+)_.*") + +def getRealArgs(self,args): + types = [] + realargs = [] + + try: + t = self.this + types.append(typestring.match(self).group(1)) + realargs.append(t) + except: + types.append(type(self)) + realargs.append(self) + for a in args: + try: + t = a.this + types.append(typestring.match(a).group(1)) + realargs.append(t) + except: + types.append(type(a)) + realargs.append(a) + + return tuple(types), tuple(realargs) + +bs_AddInput_valuedict = { + (InstanceType, FloatType) : PortInputFloat, + (InstanceType, IntType) : PortInputLong, + (InstanceType, StringType) : PortInputString, + (InstanceType, InstanceType) : PortInputObject, + (InstanceType, StringType, FloatType) : InputFloat, + (InstanceType, StringType, IntType) : InputLong, + (InstanceType, StringType, StringType) : InputString, + (InstanceType, StringType, InstanceType) : InputObject, + (InstanceType, StringType, ListType) : InputObject, +} + + +def Args( aService , aNodeName , verbose ): + lenin = len( aService.ServiceinParameter ) + infos = aNodeName + 'info = "' + infos = infos + 'NodeName : ' + aNodeName + '\\n' + infos = infos + 'ServiceName : ' + aService.ServiceName + '\\n' + infos = infos + 'PortNames : \\n' + defnames = aNodeName + " = " + "'" + aNodeName + "' ; " + i = 0 + while i < lenin : + argname = aNodeName + aService.ServiceinParameter[ i ].Parametername + valname = aNodeName + "\\\\" + valname = valname + aService.ServiceinParameter[ i ].Parametername + defnames = defnames + argname + " = " + "'" + valname + "' ; " + infos = infos + str(i) + '. ' + argname + ' : Input' + infos = infos + str(i) + ' ' + infos = infos + aService.ServiceinParameter[ i ].Parametername + ' ' + infos = infos + aService.ServiceinParameter[ i ].Parametertype + '\\n' + i = i + 1 + lenout = len( aService.ServiceoutParameter ) + i = 0 + while i < lenout : + argname = aNodeName + aService.ServiceoutParameter[ i ].Parametername + valname = aNodeName + "\\\\" + valname = valname + aService.ServiceoutParameter[ i ].Parametername + defnames = defnames + argname + " = " + "'" + valname + "' ; " + infos = infos + str(lenin+i) + '. ' + argname + ' : Output' + infos = infos + str(i) + ' ' + infos = infos + aService.ServiceoutParameter[ i ].Parametername + ' ' + infos = infos + aService.ServiceoutParameter[ i ].Parametertype + '\\n' + i = i + 1 + infos = infos + '"' + defnames = defnames + infos + if verbose : + defnames = defnames + " ; print " + aNodeName + "info" + return defnames + +def Service_Swig( aCatalogService ) : + aService = SuperVision.Service() + aService.ServiceName = aCatalogService.ServiceName + i = 0 + while i < len( aCatalogService.ServiceinParameter ) : + p = SuperVision.ServicesParameter( aCatalogService.ServiceinParameter[i].Parametertype , aCatalogService.ServiceinParameter[i].Parametername ) + SuperVision.AddInParameter( aService , p ) + i = i + 1 + i = 0 + while i < len( aCatalogService.ServiceoutParameter ) : + p = SuperVision.ServicesParameter( aCatalogService.ServiceoutParameter[i].Parametertype , aCatalogService.ServiceoutParameter[i].Parametername ) + SuperVision.AddOutParameter( aService , p ) + i = i + 1 + return aService + +########################################################## +class CNode: +########################################################## + def __init__( self , aNode , Verbose ): + self.N = aNode + self.N.Verbose = Verbose + def Name( self ): + return self.N.Name() + def Service( self ): + return self.N.Service() + def Kind( self ): + return self.N.Kind() + def CreationDate( self ): + return self.N.CreationDate() + def LastUpdateDate( self ): + return self.N.LastUpdateDate() + def Version( self ): + return self.N.Version() + def Author( self ): + return self.N.Author() + def Comment( self ): + return self.N.Comment() + + def SetName( self , aNewName ): + return self.N.SetName( aNewName ) + def SetAuthor( self , anAuthor ): + return self.N.SetAuthor( anAuthor ) + def SetComment( self , aComment ): + return self.N.SetComment( aComment ) + + def Print( self ): + print "Name ",self.N.Name() + if self.N.IsFactory() : + print "ComponentName ",self.N.GetComponentName() + print "InterfaceName ",self.N.GetInterfaceName() + aService = self.N.Service() + print "Service Name ",aService.ServiceName + lenin = len( aService.ServiceinParameter ) + print " ",lenin," input argument(s) :" + i = 0 + while i < lenin : + print " ",i,". ",aService.ServiceinParameter[ i ].Parametername," ",aService.ServiceinParameter[ i ].Parametertype + i = i + 1 + lenout = len( aService.ServiceoutParameter ) + print " ",lenout," output argument(s) :" + i = 0 + while i < lenout : + print " ",i,". ",aService.ServiceoutParameter[ i ].Parametername," ",aService.ServiceoutParameter[ i ].Parametertype + i = i + 1 + aKind = self.N.Kind() + print "KindOfNode",aKind + aFirstCreation = self.N.CreationDate() + print "Creation Date ",aFirstCreation.Day,"-",aFirstCreation.Month,"-",aFirstCreation.Year," ",aFirstCreation.Hour,":",aFirstCreation.Minute,":",aFirstCreation.Second + aLastModification = self.N.LastUpdateDate() + print "Update Date ",aLastModification.Day,"-",aLastModification.Month,"-",aLastModification.Year," ",aLastModification.Hour,":",aLastModification.Minute,":",aLastModification.Second + print "Version ",self.N.Version() + print "Author ",self.N.Author() + if self.N.IsFactory() : + print "Container ",self.N.GetContainer() + print "Comment ",self.N.Comment() + print "Coords ",self.N.X()," ",self.N.Y() + def Port( self , aPortName ): + aPort = self.N.Port( aPortName ) + if aPort != None : + myPort = Port( aPort , self.N.Verbose ) + return myPort + if self.N.Verbose : + print "Error while creating the Port : ",aPortName + return None + def Input( self , *args ): + types, realargs = getRealArgs(self.N,args) + fn = bs_AddInput_valuedict[types] + anInput = apply( fn, realargs) + if anInput != None : + myInput = Port( anInput , self.N.Verbose ) + return myInput + ErrMsg = "Failed to create the Input" + if self.N.Verbose : + print ErrMsg + return anInput +# def BusPort( self , InOutParameterName , InOutParameterType ): +# sts,inp,outp = self.N.BusPort( InOutParameterName , +# InOutParameterType ) +# inp = Port( inp , self.N.Verbose ) +# outp = Port( outp , self.N.Verbose ) +# return sts,inp,outp +# def BusPorts( self , InputParameterName , InputParameterType , +# OutputParameterName , OutputParameterType ): +# sts,inp,outp = self.N.BusPorts( InputParameterName , +# InputParameterType , +# OutputParameterName , +# OutputParameterType ) +# inp = Port( inp , self.N.Verbose ) +# outp = Port( outp , self.N.Verbose ) +# return sts,inp,outp + def Ports( self ): + ports = self.N.Ports() + i = 0 + while i < len( ports ) : + ports[ i ] = Port( ports[i] , self.N.Verbose ) + i = i + 1 + return ports + def ListPorts( self , *args ): + if len( args ) == 0 : + aName = self.N.Name() + else : + aName = args[ 0 ] + ports = self.N.Ports() + listofports = "" + if len( ports ) : + portsname = ports[ 0 ].Name() + bs = portsname.find('\\') + if bs != -1 : + portsname1,portsname2 = portsname.split('\\') + portsname = portsname1 + portsname2 + if ports[ 0 ].IsInput(): + listofports = aName + 'In' + portsname + else : + listofports = aName + 'Out' + portsname + i = 1 + while i < len( ports ) : + portsname = ports[ i ].Name() + bs = portsname.find('\\') + if bs != -1 : + portsname1,portsname2 = portsname.split('\\') + portsname = portsname1 + portsname2 + if ports[ i ].IsInput(): + listofports = listofports + ',' + aName + 'In' + portsname + else : + listofports = listofports + ',' + aName + 'Out' + portsname + i = i + 1 + print listofports + if len( ports ) == 1 : + listofports = "[" + listofports + "] = " + aName + ".Ports()" + else : + listofports = listofports + " = " + aName + ".Ports()" + return listofports + def PrintPorts( self ): + ports = self.N.Ports() + i = 0 + while i < len( ports ) : + Direction = "Out" + if ports[ i ].IsInput() : + Direction = "In" + print Direction,self.N.Name(),'(',ports[ i ].Name(),ports[ i ].Kind(),ports[ i ].Type(),') = ',ports[ i ].ToString() + i = i + 1 + def Links( self ) : + links = self.N.Links() + i = 0 + while i < len( links ) : + links[ i ] = Link( links[i] , self.N.Verbose ) + i = i + 1 + return links + def PrintLinks( self ): + links = self.Links() + i = 0 + while i < len( links ) : + links[i].Print() + i = i + 1 + def IsGraph( self ): + return self.N.IsGraph() + def IsComputing( self ): + return self.N.IsComputing() + def IsFactory( self ): + return self.N.IsFactory() + def IsInLine( self ): + return self.N.IsInLine() + def IsGOTO( self ): + return self.N.IsGOTO() + def IsLoop( self ): + return self.N.IsLoop() + def IsEndLoop( self ): + return self.N.IsEndLoop() + def IsSwitch( self ): + return self.N.IsSwitch() + def IsEndSwitch( self ): + return self.N.IsEndSwitch() + def SubGraph( self ): + return self.N.SubGraph() + def Thread( self ): + return self.N.Thread() + def IsWaiting( self ): + return self.N.IsWaiting() + def IsRunning( self ): + return self.N.IsRunning() + def IsDone( self ): + return self.N.IsDone() + def IsSuspended( self ): + return self.N.IsSuspended() + def State( self ): + return self.N.State() + def Control( self ): + return self.N.Control() + def ControlClear( self ): + return self.N.ControlClear() + def AutoState( self ): + return self.N.AutoState() + def ReadyW( self ): + return self.N.ReadyW() + def RunningW( self ): + return self.N.RunningW() + def DoneW( self ): + return self.N.DoneW() + def SuspendedW( self ): + return self.N.SuspendedW() + def ReRun( self ): + return self.N.ReRun() + def ReStart( self ): + return self.N.ReStart() + def ReRunAt( self , aNodeName ): + return self.N.ReRunAt( aNodeName ) + def ReStartAt( self , aNodeName ): + return self.N.ReStartAt( aNodeName ) + def Ping( self ): + return self.N.ping() + def Kill( self ): + return self.N.Kill() + def KillDone( self ): + return self.N.KillDone() + def Suspend( self ): + return self.N.Suspend() + def SuspendDone( self ): + return self.N.SuspendDone() + def Resume( self ): + return self.N.Resume() + def Stop( self ): + return self.N.Stop() + def Coords( self , X , Y ): + return self.N.Coords( X , Y ) + def X( self ): + return self.N.X() + def Y( self ): + return self.N.Y() + def destroy( self ): + self.N.destroy() + +########################################################## +class FNode(CNode): +########################################################## + def __init__( self , aNode , Verbose ): + self.N = aNode + self.N.Verbose = Verbose + def GetComponentName( self ): + return self.N.GetComponentName() + def GetInterfaceName( self ): + return self.N._get_interfaceName() + def GetContainer( self ): + return self.N.GetContainer() + def SetComponentName( self , aComponentName ): + return self.N.SetComponentName( aComponentName ) + def SetInterfaceName( self , anInterfaceName ): + return self.N.SetInterfaceName( anInterfaceName ) + def SetContainer( self , aComputer ): + return self.N.SetContainer( aComputer ) + +########################################################## +class INode(CNode): +########################################################## + def __init__( self , aNode , Verbose ): + self.N = aNode + self.N.Verbose = Verbose + def Edit( self , FuncName , PyFunc ) : + file = '/tmp/' + FuncName + '.py' + i = 0 + try : + fd = os.open( file , os.O_CREAT | os.O_WRONLY | os.O_TRUNC ) + while ( i < len( PyFunc ) ) : + os.write( fd , PyFunc[ i ] + '\n' ) + i = i + 1 + edit = '${EDITOR} ' + file + os.system( edit ) + fd = os.open( file , os.O_RDONLY ) + line = os.read( fd , 132 ) + res = '' + while len( line ) : + res = res + line + line = os.read( fd , 132 ) + PyFunc = res.splitlines() + i = 0 + while i < len( PyFunc ) : + print PyFunc[i] + i = i + 1 + except : + print "Open of",file,"failed." + return PyFunc + def SetPyFunction( self , FuncName , aPyFunction ): + return self.N.SetPyFunction( FuncName , aPyFunction ) + def PyFunction( self ): + return self.N.PyFunction() + def PyFuncName( self ): + return self.N.PyFuncName() + def EPyFunc( self ): + PyFunc = self.N.PyFunction() + PyFunc = self.Edit( self.N.PyFuncName() , PyFunc ) + self.N.SetPyFunction( self.N.PyFuncName() , PyFunc ) + def InPort( self , aParameterName , aParameterType ): + aPort = self.N.InPort( aParameterName , + aParameterType ) + if aPort != None : + myPort = Port( aPort , self.N.Verbose ) + return myPort + if self.N.Verbose : + print "Error while creating the Port : ",aParameterName + return None + def OutPort( self , aParameterName , aParameterType ): + aPort = self.N.OutPort( aParameterName , + aParameterType ) + if aPort != None : + myPort = Port( aPort , self.N.Verbose ) + return myPort + if self.N.Verbose : + print "Error while creating the Port : ",aParameterName + return None + +########################################################## +class GNode(INode): +########################################################## + def __init__( self , aNode , Verbose ): + self.N = aNode + self.N.Verbose = Verbose + def SetCoupled( self , anInLineNode ): + if self.N.IsGOTO() : + node = self.N.SetCoupled( anInLineNode ) + else : + node = None + return node + def Coupled( self ): + node = self.N.Coupled() + if node != None : + if node.IsInLine() : + node = INode( node , self.N.Verbose ) + elif node.IsLoop() : + node = LNode( node , self.N.Verbose ) + elif node.IsEndLoop() : + node = ELNode( node , self.N.Verbose ) + elif node.IsSwitch() : + node = SNode( node , self.N.Verbose ) + elif node.IsEndSwitch() : + node = ESNode( node , self.N.Verbose ) + return node + +########################################################## +class LNode(GNode): +########################################################## + def __init__( self , aNode , Verbose ): + self.N = aNode + self.N.Verbose = Verbose + def SetPyInit( self , InitName , aPyFunction ): + return self.N.SetPyInit( InitName , aPyFunction ) + def PyInit( self ): + return self.N.PyInit() + def PyInitName( self ) : + return self.N.PyInitName() + def EPyInit( self ): + PyFunc = self.N.PyFunction() + PyFunc = self.Edit( self.N.PyFuncName() , PyFunc ) + self.N.SetPyFunction( self.N.PyFuncName() , PyFunc ) + def SetPyMore( self , MoreName , aPyFunction ): + return self.N.SetPyMore( MoreName , aPyFunction ) + def PyMore( self ): + return self.N.PyMore() + def PyMoreName( self ) : + return self.N.PyMoreName() + def EPyMore( self ): + PyMore = self.N.PyMore() + PyMore = self.Edit( self.N.PyMoreName() , PyMore ) + self.N.SetPyMore( self.N.PyMoreName() , PyMore ) + def SetPyNext( self , NextName , aPyFunction ): + return self.N.SetPyNext( NextName , aPyFunction ) + def PyNext( self ): + return self.N.PyNext() + def PyNextName( self ) : + return self.N.PyNextName() + def EPyNext( self ): + PyNext = self.N.PyNext() + PyNext = self.Edit( self.N.PyNextName() , PyNext ) + self.N.SetPyNext( self.N.PyNextName() , PyNext ) + +########################################################## +class ELNode(GNode): +########################################################## + def __init__( self , aNode , Verbose ): + self.N = aNode + self.N.Verbose = Verbose + +########################################################## +class SNode(GNode): +########################################################## + def __init__( self , aNode , Verbose ): + self.N = aNode + self.N.Verbose = Verbose + +########################################################## +class ESNode(GNode): +########################################################## + def __init__( self , aNode , Verbose ): + self.N = aNode + self.N.Verbose = Verbose + +########################################################## +#class ServicesParameter_Swig : +########################################################## +# def __init__( self , aServicesParameter ): +# self.Parametertype = aServicesParameter.Parametertype +# self.Parametername = aServicesParameter.Parametername + +########################################################## +class Graph(INode): +########################################################## + def __init__( self , aName ): + try: + graph = SuperVision.Graph( aName ) + except: + try: + graph = aName.G.Copy() + except: + graph = None + if graph != None : + self.G = graph + self.G.Verbose = 1 + self.N = graph + self.N.Verbose = 1 + else : + print "Graph creation failed" + def CNode( self , *args ): + if len( args ) == 1 : + aService = args[ 0 ] + else : + aComponent = args[ 0 ] + anInterface = args[ 1 ] + aService = args[ 2 ] + NodeComponent = modulecatalog.GetComponent( aComponent ) + aService = NodeComponent.GetService( anInterface , aService ) + aNode = self.G.CNode( aService ) + if aNode != None : + myNode = CNode( aNode , self.G.Verbose ) + return myNode + ErrMsg = "Failed to create a Node with Service " + aService.ServiceName + if self.G.Verbose : + print ErrMsg + return aNode + def Node( self , aComponent , anInterface , aService ): + if SuperVision.Swig : + aService = Service_Swig( aService ) + return self.FNode( aComponent , anInterface , aService ) + def FNode( self , aComponent , anInterface , aService ): + NodeComponent = modulecatalog.GetComponent( aComponent ) + aService = NodeComponent.GetService( anInterface , aService ) + if SuperVision.Swig : + aService = Service_Swig( aService ) + aNode = self.G.FNode( aComponent , anInterface , aService ) + if aNode != None : + myNode = FNode( aNode , self.G.Verbose ) + return myNode + ErrMsg = "Failed to create a Node with Service " + aService.ServiceName + if self.G.Verbose : + print ErrMsg + return aNode + def INode( self , FuncName , aPythonFunction ): + aNode = self.G.INode( FuncName , aPythonFunction ) + if aNode != None : + myNode = INode( aNode , self.G.Verbose ) + return myNode + ErrMsg = "Failed to create a Node" + if self.G.Verbose : + print ErrMsg + return aNode + def GNode( self , FuncName , aPythonFunction , anINode ): + aNode = self.G.GNode( FuncName , aPythonFunction , anINode ) + if aNode != None : + myNode = GNode( aNode , self.G.Verbose ) + return myNode + ErrMsg = "Failed to create a Node" + if self.G.Verbose : + print ErrMsg + return aNode + def LNode( self , InitName , InitFunction , MoreName , MoreFunction , NextName , NextFunction ): + aNode,anEndOfLoop = self.G.LNode( InitName , InitFunction , MoreName , MoreFunction , NextName , NextFunction ) + if aNode != None : + myNode = LNode( aNode , self.G.Verbose ) + myEndOfLoop = INode( anEndOfLoop , self.G.Verbose ) + return myNode,myEndOfLoop + ErrMsg = "Failed to create a Node with Service " + aService.ServiceName + if self.G.Verbose : + print ErrMsg + return aNode + def SNode( self , FuncName , aPythonFunction ): + aNode,anEndOfSwitch = self.G.SNode( FuncName , aPythonFunction ) + if aNode != None : + myNode = SNode( aNode , self.G.Verbose ) + myEndOfSwitch = INode( anEndOfSwitch , self.G.Verbose ) + return myNode,myEndOfSwitch + ErrMsg = "Failed to create a Node" + if self.G.Verbose : + print ErrMsg + return aNode +# def LoopNode( self , aComponent , anInterface , aService , aNodeName ): +# NodeComponent = modulecatalog.GetComponent( aComponent ) +# aService = NodeComponent.GetService( anInterface , aService ) +# aNode,anEndNode = self.G.LoopNode( aComponent , anInterface , aService , aNodeName ) +# myNode = aNode +# myEndNode = anEndNode +# if aNode != None : +# myNode = Node( aNode , self.G.Verbose ) +# if anEndNode != None : +# myEndNode = Node( anEndNode , self.G.Verbose ) +# if ( aNode != None ) & ( anEndNode != None ) : +# return myNode,myEndNode +# ErrMsg = "Failed to create a Node with Service " + aService.ServiceName +# if self.G.Verbose : +# print ErrMsg +# return aNode,anEndNode +# def SwitchNode( self , aComponent , anInterface , aService , aNodeName ): +# NodeComponent = modulecatalog.GetComponent( aComponent ) +# aService = NodeComponent.GetService( anInterface , aService ) +# aNode,anEndNode = self.G.SwitchNode( aComponent , anInterface , aService , aNodeName ) +# myNode = aNode +# myEndNode = anEndNode +# if aNode != None : +# myNode = Node( aNode , self.G.Verbose ) +# if anEndNode != None : +# myEndNode = Node( anEndNode , self.G.Verbose ) +# if ( aNode != None ) & ( anEndNode != None ) : +# return myNode,myEndNode +# ErrMsg = "Failed to create a Node with Service " + aService.ServiceName +# if self.G.Verbose : +# print ErrMsg +# return aNode,anEndNode +# def LNode( self , aNodeName ): +# aNode = self.G.LNode( aNodeName ) +# if aNode != None : +# myNode = Node( aNode , self.G.Verbose ) +# return myNode +# ErrMsg = "Failed to create a Node with Service " + aService.ServiceName +# if self.G.Verbose : +# print ErrMsg +# return aNode +# def LService( self , aComponent , anInterface , aService ): +# NodeComponent = modulecatalog.GetComponent( aComponent ) +# aService = NodeComponent.GetService( anInterface , aService ) +# aNode = self.G.LService( aComponent , anInterface , aService ) +# if aNode != None : +# myNode = Node( aNode , self.G.Verbose ) +# return myNode +# ErrMsg = "Failed to create a Node with Service " + aService.ServiceName +# if self.G.Verbose : +# print ErrMsg +# return aNode +# def CNode( self , aNodeName ): +# aNode = self.G.CNode( aNodeName ) +# if aNode != None : +# myNode = Node( aNode , self.G.Verbose ) +# return myNode +# ErrMsg = "Failed to create a Node with Service " + aService.ServiceName +# if self.G.Verbose : +# print ErrMsg +# return aNode +# def CService( self , aComponent , anInterface , aService ): +# NodeComponent = modulecatalog.GetComponent( aComponent ) +# aService = NodeComponent.GetService( anInterface , aService ) +# aNode = self.G.CService( aComponent , anInterface , aService ) +# if aNode != None : +# myNode = Node( aNode , self.G.Verbose ) +# return myNode +# ErrMsg = "Failed to create a Node with Service " + aService.ServiceName +# if self.G.Verbose : +# print ErrMsg +# return aNode + def PrintService( self , aComponent , anInterface , aService ): + NodeComponent = modulecatalog.GetComponent( aComponent ) + aService = NodeComponent.GetService( anInterface , aService ) + print "ServiceName ",aService.ServiceName," :" + lenin = len( aService.ServiceinParameter ) + print " ",lenin," input argument(s) :" + i = 0 + while i < lenin : + print " ",i,". ",aService.ServiceinParameter[ i ].Parametername," ",aService.ServiceinParameter[ i ].Parametertype + i = i + 1 + lenout = len( aService.ServiceoutParameter ) + print " ",lenout," output argument(s) :" + i = 0 + while i < lenout : + print " ",i,". ",aService.ServiceoutParameter[ i ].Parametername," ",aService.ServiceoutParameter[ i ].Parametertype + i = i + 1 + def Link( self , aFromNodePort , aToNodePort ): + aLink = self.G.Link( aFromNodePort.P , aToNodePort.P ) + if aLink != None : + myLink = Link( aLink , self.G.Verbose ) + return myLink + ErrMsg = "Failed to create a Link from " + aFromNodePort.Node().Name() + "(" + aFromNodePort.Name() + ") to " + aToNodePort.Node().Name() + "(" + aToNodePort.Name() + ")" + if self.G.Verbose : + print ErrMsg + return aLink + def Import( self , anXmlFileName ): + return self.G.Import( anXmlFileName ) + def Export( self , anXmlFileName ): + return self.G.Export( anXmlFileName ) + def IsReadOnly( self ) : + return self.G.IsReadOnly() + def ComponentRef( self , aFactoryServer , aComponent ) : + return self.G.ComponentRef( aFactoryServer , aComponent ) + def IsValid( self ): + return self.G.IsValid() + def IsExecutable( self ): + return self.G.IsExecutable() + def IsEditing( self ): + return self.G.IsEditing() + def IsExecuting( self ): + return self.G.IsExecuting() + def LevelMax( self ): + return self.G.LevelMax() + def ThreadsMax( self ): + return self.G.ThreadsMax() + def GraphsNumber( self ): + return self.G.GraphsNumber() + def LevelNodes( self , aLevel ): + nodes = self.G.LevelNodes( aLevel ) + return self.nodesTuple( nodes ) + def Run( self , *args ): + self.S = -1 + aService = self.Service() + nargs = len( args ) + i = 0 + while nargs > 0 : + print aService.ServiceinParameter[ i ].Parametername," = ",args[i] + self.Input( aService.ServiceinParameter[ i ].Parametername , args[i] ) + i = i + 1 + nargs = nargs - 1 + return self.G.Run() + def Start( self , *args ): + self.S = -1 + aService = self.Service() + nargs = len( args ) + i = 0 + while nargs > 0 : + print aService.ServiceinParameter[ i ].Parametername," = ",args[i] + self.Input( aService.ServiceinParameter[ i ].Parametername , args[i] ) + i = i + 1 + nargs = nargs - 1 + return self.G.Start() + def Event( self ): + sts,aNode,anEvent,aState = self.G.Event() + self.S = sts + return sts,aNode,anEvent,aState + def EventNoW( self ): + sts,aNode,anEvent,aState = self.G.EventNoW() + self.S = sts + return sts,aNode,anEvent,aState + def EventW( self ): + sts,aNode,anEvent,aState = self.G.EventW() + self.S = sts + return sts,aNode,anEvent,aState + def NextW( self ): + if self.S != 0 : + sts,aNode,anEvent,aState = self.G.EventW() + self.S = sts + print sts,aNode.Thread(),aNode.SubGraph(),aNode.Name(),anEvent,aState + return sts + def Threads( self ): + return self.G.Threads() + def SuspendedThreads( self ): + return self.G.SuspendedThreads() + def LastLevelDone( self ): + return self.G.LastLevelDone() + def Verbose( self , verbose ): + preverbose = self.G.Verbose + self.G.Verbose = verbose + return preverbose + def Nodes( self ): + nodes = self.G.Nodes() + return self.nodesTuple( nodes ) + def nodesTuple( self , nodes ) : + n = len( nodes.CNodes ) + i = 0 + j = 0 + pynodes = [] + while i < n : + pynodes.append( CNode( nodes.CNodes[i] , self.G.Verbose ) ) + i = i + 1 + j = j + 1 + n = len( nodes.FNodes ) + i = 0 + while i < n : + pynodes.append( FNode( nodes.FNodes[i] , self.G.Verbose ) ) + i = i + 1 + j = j + 1 + n = len( nodes.INodes ) + i = 0 + while i < n : + pynodes.append( INode( nodes.INodes[i] , self.G.Verbose ) ) + i = i + 1 + j = j + 1 + n = len( nodes.GNodes ) + i = 0 + while i < n : + pynodes.append( GNode( nodes.GNodes[i] , self.G.Verbose ) ) + i = i + 1 + j = j + 1 + n = len( nodes.LNodes ) + i = 0 + while i < n : + pynodes.append( LNode( nodes.LNodes[i] , self.G.Verbose ) ) + i = i + 1 + j = j + 1 + n = len( nodes.ELNodes ) + i = 0 + while i < n : + pynodes.append( GNode( nodes.ELNodes[i] , self.G.Verbose ) ) + i = i + 1 + j = j + 1 + n = len( nodes.SNodes ) + i = 0 + while i < n : + pynodes.append( SNode( nodes.SNodes[i] , self.G.Verbose ) ) + i = i + 1 + j = j + 1 + n = len( nodes.ESNodes ) + i = 0 + while i < n : + pynodes.append( GNode( nodes.ESNodes[i] , self.G.Verbose ) ) + i = i + 1 + j = j + 1 + return pynodes + def ListNodes( self , *args ): + nodes = self.Nodes() + listofnodes = "" + if len( nodes ) : + listofnodes = nodes[ 0 ].Name() + i = 1 + while i < len( nodes ) : + listofnodes = listofnodes + ',' + nodes[ i ].Name() + i = i + 1 + print listofnodes + if len( args ) == 0 : + aName = self.N.Name() + else : + aName = args[ 0 ] + if len( nodes ) == 1 : + listofnodes = "[" + listofnodes + "] = " + aName + ".Nodes()" + else : + listofnodes = listofnodes + " = " + aName + ".Nodes()" + return listofnodes + def PrintNodes( self ): + nodes = self.Nodes() + n = len( nodes ) + i = 0 + while i < n : + print ' ' + nodes[ i ].Print() + i = i + 1 + def PrintThreads( self ): + nodes = self.Nodes() + i = 0 + while i < len( nodes ) : + print nodes[i].Name(),nodes[i].Thread(),nodes[i].State(),nodes[i].Control(),nodes[i].AutoState() + i = i + 1 + def GLinks( self ): + links = self.G.GLinks() + i = 0 + while i < len( links ) : + links[ i ] = Link( links[i] , self.G.Verbose ) + i = i + 1 + return links + def ListLinks( self , *args ): + links = self.G.GLinks() + if len( links ) : + listoflinks = links[ 0 ].InPort().Node().Name() + listoflinks = listoflinks + links[ 0 ].InPort().Name() + i = 1 + while i < len( links ) : + listoflinks = listoflinks + ',' + links[ i ].InPort().Node().Name() + listoflinks = listoflinks + links[ i ].InPort().Name() + i = i + 1 + print listoflinks + if len( args ) == 0 : + aName = self.N.Name() + else : + aName = args[ 0 ] + if len( links ) == 1 : + listoflinks = "[" + listoflinks + "] = " + aName + ".GLinks()" + else : + listoflinks = listoflinks + " = " + aName + ".GLinks()" + return listoflinks + def PrintLinks( self ): + links = self.G.GLinks() + i = 0 + while i < len( links ) : + Link( links[ i ] , self.G.Verbose ).Print() + i = i + 1 + def Graphs( self ): + graphs = self.G.Graphs() + outgraphs = graphs + i = 0 + while i < len( graphs ) : + outgraphs[ i ] = Graph( graphs[i].Name() , self.G.Verbose ) + outgraphs[ i ].Merge( graphs[i] ) + i = i + 1 + return outgraphs + def Copy( self ): + aCopy = self.G.Copy() + if aCopy != None: + myCopy = Graph( aCopy ) + return myCopy + ErrMsg = "Failed to get a Copy of " + self.G.Name() + if self.G.Verbose : + print ErrMsg + return aCopy + def Merge( self , aGraph ): + return self.G.Merge( aGraph.G ) + def Destroy( self ): + self.N.destroy() + +########################################################## +class GraphE(Graph): +########################################################## + def __init__( self , aName ): + graph = SuperVision.GraphE( aName ) + self.G = graph + self.G.Verbose = 1 + self.N = graph + self.N.Verbose = 1 + +########################################################## +class Value: +########################################################## + def __init__( self , aValue , Verbose ): + self.V = aValue + self.V.Verbose = Verbose + def ToString( self ): + return self.V.ToString() + def ToAny( self ): + return self.V.ToAny() + def Destroy( self ): + self.N.destroy() + +########################################################## +class Port: +########################################################## + def __init__( self , aPort , Verbose ): + self.P = aPort + self.P.Verbose = Verbose + def Input( self , *args ): + types, realargs = getRealArgs(self.P,args) + fn = bs_AddInput_valuedict[types] + anInput = apply( fn, realargs) + return anInput + def Node( self ): + aNode = self.P.Node() + if aNode != None : + if aNode.IsComputing() : + myNode = CNode( aNode , self.P.Verbose ) + elif aNode.IsFactory() : + myNode = FNode( aNode , self.P.Verbose ) + elif aNode.IsInLine() : + myNode = INode( aNode , self.P.Verbose ) + elif aNode.IsGOTO() : + myNode = GNode( aNode , self.P.Verbose ) + elif aNode.IsLoop() : + myNode = LNode( aNode , self.P.Verbose ) + elif aNode.IsEndLoop() : + myNode = ELNode( aNode , self.P.Verbose ) + elif aNode.IsSwitch() : + myNode = SNode( aNode , self.P.Verbose ) + elif aNode.IsEndSwitch() : + myNode = ESNode( aNode , self.P.Verbose ) + else : + myNode = None + return myNode + return aNode + def Name( self ): + return self.P.Name() + def Type( self ): + return self.P.Type() + def Link( self ): + aLink = self.P.Link() + if aLink != None : + myLink = Link( aLink , self.P.Verbose ) + return myLink + ErrMsg = "Failed to get a Link to " + self.P.Node().Name() + "(" + self.P.Name() + ")" + if self.P.Verbose : + print ErrMsg + return aLink + def Links( self ): + links = self.P.Links() + i = 0 + while i < len( links ) : + links[ i ] = Link( links[i] , self.P.Verbose ) + i = i + 1 + return links + def PrintLinks( self ): + links = self.P.Links() + i = 0 + while i < len( links ) : + Link( links[ i ] , self.P.Verbose ).Print() + i = i + 1 + def IsInput( self ): + return self.P.IsInput() + def IsLinked( self ): + return self.P.IsLinked() + def HasInput( self ): + return self.P.HasInput() + def Kind( self ) : + return self.P.Kind() + def IsParam( self ): + return self.P.IsParam() + def IsGate( self ): + return self.P.IsGate() + def IsLoop( self ): + return self.P.IsLoop() + def IsInLine( self ): + return self.P.IsInLine() + def IsSwitch( self ): + return self.P.IsSwitch() + def IsEndSwitch( self ): + return self.P.IsEndSwitch() +# def IsBus( self ): +# return self.P.IsBus() + def Done( self ): + return self.P.Done() + def State( self ): + return self.P.State() + def ToString( self ): + return self.P.ToString() + def ToAny( self ): + return self.P.ToAny() + def Print( self ): + if self.P.IsInput() : + if self.P.IsLinked() : + print "In",self.P.Node().Name(),'(',self.P.Name(),self.P.Kind(),self.P.Type(),') = ',self.P.ToString(),' from ',self.Link().OutPort().Print() + else : + print "In",self.P.Node().Name(),'(',self.P.Name(),self.P.Kind(),self.P.Type(),') = ',self.P.ToString() + else : + print "Out",self.P.Node().Name(),'(',self.P.Name(),self.P.Kind(),self.P.Type(),') = ',self.P.ToString() + def Destroy( self ): + self.P.destroy() + +########################################################## +class Link: +########################################################## + def __init__( self , aLink , Verbose ): + self.L = aLink + self.L.Verbose = Verbose + def OutPort( self ): + aPort = self.L.OutPort() + if aPort != None : + myPort = Port( aPort , self.L.Verbose ) + return myPort + if self.L.Verbose : + print "Error while getting the Port : " + return None + def InPort( self ): + aPort = self.L.InPort() + if aPort != None : + myPort = Port( aPort , self.L.Verbose ) + return myPort + if self.L.Verbose : + print "Error while getting the Port : " + return None + def Print( self ): + anOutPort = self.L.OutPort() + anInPort = self.L.InPort() + print anOutPort.Node().Name(),'(',anOutPort.Name(),' ',anOutPort.Kind(),') =',anOutPort.ToString(),' --> ',anInPort.Node().Name(),'(',anInPort.Name(),')',' ',anInPort.Kind() + def CoordsSize( self ): + return self.L.CoordsSize() + def AddCoord( self , index , X , Y ): + return self.L.AddCoord( index , X , Y ) + def ChangeCoord( self , index , X , Y ): + return self.L.ChangeCoord( index , X , Y ) + def RemoveCoord( self , index ): + return self.L.RemoveCoord( index ) + def Coords( self , index ): + return self.L.Coords( index ) + def destroy( self ): + self.L.destroy() + + diff --git a/src/Supervision/SuperV_CheckOfUndefined.cxx b/src/Supervision/SuperV_CheckOfUndefined.cxx new file mode 100755 index 0000000..cb4a489 --- /dev/null +++ b/src/Supervision/SuperV_CheckOfUndefined.cxx @@ -0,0 +1,28 @@ +using namespace std; +#include +#include +#include + +#include + +#include "DataFlowBase_Base.hxx" +#include "DataFlowBase_Graph.hxx" +#include "DataFlowExecutor_InNode.hxx" +#include "DataFlowExecutor_OutNode.hxx" +#include "DataFlowExecutor_DataFlow.hxx" +#include "DataFlowExecutor_DataFlow.lxx" +#include "DataFlowEditor_InNode.hxx" +#include "DataFlowEditor_OutNode.hxx" +#include "DataFlowEditor_DataFlow.hxx" +#include "DataFlowEditor_DataFlow.lxx" + +static PyMethodDef MethodPyVoidMethod[] = { + { NULL, NULL } +}; + +int main(int argc, char **argv) { + Py_Initialize() ; + Py_InitModule( "InitPyRunMethod" , MethodPyVoidMethod ) ; + return 0; +} + diff --git a/src/Supervision/SuperV_Impl.cxx b/src/Supervision/SuperV_Impl.cxx new file mode 100644 index 0000000..c369099 --- /dev/null +++ b/src/Supervision/SuperV_Impl.cxx @@ -0,0 +1,531 @@ +using namespace std; +//============================================================================= +// File : SuperV_Impl.cxx +// Created : Nov 2001 +// Author : Jean Rahuel +// Project : SALOME +// $Header$ +//============================================================================= + +#include +#include +#include + +#include +#include +#include + +#include "Python.h" + +#include "utilities.h" + +#include "SALOME_Container_i.hxx" + +#include "SuperV_Impl.hxx" + +#include "SALOMEDS_Attributes.hh" +#include +#include +#include "SALOMEDS_Tool.hxx" + +#include "Utils_CorbaException.hxx" + +#define STUDY_SUPERVISION "Supervision" + +SuperV_Impl::SuperV_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName +// , int argc , +// char ** argv + ) : + Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { + MESSAGE("SuperV_Impl::SuperV_Impl activate object instanceName(" + << instanceName << ") interfaceName(" << interfaceName << ") --> " + << hex << (void *) this << dec ) + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; +} + +SuperV_Impl::SuperV_Impl() { +} + +SuperV_Impl::~SuperV_Impl() { + beginService( "SuperV_Impl::~SuperV_Impl" ); + endService( "SuperV_Impl::~SuperV_Impl" ); +} + +void SuperV_Impl::Destroy() { + beginService( "SuperV_Impl::Destroy" ); + _poa->deactivate_object(*_id) ; + CORBA::release(_poa) ; + delete(_id) ; + _thisObj->_remove_ref(); + Py_Finalize(); + endService( "SuperV_Impl::Destroy" ); +} + +// void SuperV_Impl::Save(const char *IORSComponent, const char *aUrlOfFile) { +SALOMEDS::TMPFile* SuperV_Impl::Save(SALOMEDS::SComponent_ptr theComponent, + const char* theURL, + bool isMultiFile) { + SALOMEDS::TMPFile_var aStreamFile; + // Get a temporary directory to store a file + TCollection_AsciiString aTmpDir(""); + // Create a list to store names of created files + SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; + + CORBA::String_var myStudyName = strdup(SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL())); + + SALOMEDS::ChildIterator_var anIter = theComponent->GetStudy()->NewChildIterator(theComponent); + TColStd_SequenceOfAsciiString aFileNames; + TCollection_AsciiString aName; + + for(; anIter->More(); anIter->Next()) { + SALOMEDS::SObject_var aSO = anIter->Value(); + SALOMEDS::GenericAttribute_var anAttr; + if (aSO->FindAttribute(anAttr,"AttributeIOR")) { + aName = TCollection_AsciiString(myStudyName) + + TCollection_AsciiString("_SUPERVISION_") + + TCollection_AsciiString(aSO->Tag()) + + TCollection_AsciiString(".xml"); + aFileNames.Append(aName); + + // save to the file + CORBA::Object_var anObj = _orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value()) ; + SUPERV::Graph_var graph = SUPERV::Graph::_narrow(anObj); + if (aTmpDir.Length() == 0) + aTmpDir = (isMultiFile)?TCollection_AsciiString((char*)theURL):SALOMEDS_Tool::GetTmpDir(); + graph->Export((aTmpDir + aName).ToCString()); + } + } + + if (aFileNames.Length() == 0) return new SALOMEDS::TMPFile(0); + + aSeq->length(aFileNames.Length()); + int aCounter; + for(aCounter = aFileNames.Length(); aCounter > 0; aCounter--) + aSeq[aCounter-1] = CORBA::string_dup(aFileNames.Value(aCounter).ToCString()); + + // Conver a file to the byte stream + aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.ToCString(), aSeq.in(), isMultiFile); + // Remove the created file and tmp directory + if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true); + + // Add python files to the temporary files sequence + SALOMEDS::ListOfFileNames_var aPySeq = new SALOMEDS::ListOfFileNames; + aPySeq->length(aSeq->length()); + for(aCounter = aSeq->length(); aCounter > 0; aCounter--) { + char* aCName = CORBA::string_dup(aSeq[aCounter-1]); + int a = strlen(aCName); + aCName[a-3] = 'p';aCName[a-2] = 'y';aCName[a-1] = 0; + aPySeq[aCounter-1] = aCName; + } + // Remove the created file and tmp directory + SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aPySeq.in(), true); + // Return the created byte stream + return aStreamFile._retn(); +} + +// void SuperV_Impl::Load(const char* IORSComponent, const char* aUrlOfFile) { +CORBA::Boolean SuperV_Impl::Load(SALOMEDS::SComponent_ptr theComponent, + const SALOMEDS::TMPFile& theStream, + const char* theURL, + bool isMultiFile) { + // MESSAGE("SuperV_Impl::Load : IOR = " << IORSComponent << " , Url = " << aUrlOfFile); + // Get a temporary directory for a file + if (theStream.length() != 0) { + TCollection_AsciiString aTmpDir = (isMultiFile)?TCollection_AsciiString((char*)theURL):SALOMEDS_Tool::GetTmpDir(); + myStrURL = strdup(aTmpDir.ToCString()); + SALOMEDS_Tool::PutStreamToFiles(theStream, myStrURL, isMultiFile); + } + return true; +} + +void SuperV_Impl::Close(SALOMEDS::SComponent_ptr theComponent) { +// mpv 06.03.2003: bug SAL1508 - graphs will be destructed at the GUI-level at the supervision frame closing + +// SALOMEDS::ChildIterator_var anIter = theComponent->GetStudy()->NewChildIterator(theComponent); +// for(; anIter->More(); anIter->Next()) { +// SALOMEDS::SObject_var aSO = anIter->Value(); +// SALOMEDS::GenericAttribute_var anAttr; +// if (aSO->FindAttribute(anAttr,"AttributeIOR")) { +// CORBA::Object_var anObj = _orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value()) ; +// SUPERV::Graph_var graph = SUPERV::Graph::_narrow(anObj); +// graph->destroy(); +// } +// } +} + +char* SuperV_Impl::ComponentDataType() { + return(strdup("Supervision")); +} + +char* SuperV_Impl::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, + const char* IORString, + CORBA::Boolean isMultiFile) { + MESSAGE("SuperV_Impl::IORToLocalPersistentID: IOR:"<string_to_object(IORString) ; + if (CORBA::is_nil(anObj)) return CORBA::string_dup(IORString); + SUPERV::Graph_var aGraph = SUPERV::Graph::_narrow(anObj); + if (aGraph->_is_nil()) return CORBA::string_dup(IORString); + } catch (...) { + return CORBA::string_dup(IORString); + } + +// sprintf(aName, "%s_SUPERVISION_tmp_%d.xml",myStudyName,myCounter); + CORBA::String_var myStudyName = strdup(SALOMEDS_Tool::GetNameFromPath(theSObject->GetStudy()->URL())); + TCollection_AsciiString aName = TCollection_AsciiString(myStudyName) + + TCollection_AsciiString("_SUPERVISION_") + + TCollection_AsciiString(theSObject->Tag()) + + TCollection_AsciiString(".xml"); + return CORBA::string_dup(aName.ToCString()); +} + +char* SuperV_Impl::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, + const char* aLocalPersistentID, + CORBA::Boolean isMultiFile) + throw(SALOME::SALOME_Exception) +{ + MESSAGE("SuperV_Impl::LocalPersistentIDToIOR : IOR = " << aLocalPersistentID); + CORBA::String_var aFatherID = theSObject->GetFather()->GetID(); + CORBA::String_var aComponentID = theSObject->GetFatherComponent()->GetID(); + if (strcmp(aFatherID, aComponentID)) return CORBA::string_dup(aLocalPersistentID); + + string aStr(myStrURL); + aStr += string(aLocalPersistentID); + SUPERV::Graph_ptr graph = Graph(aStr.c_str()); + + if (graph->_is_nil()) + THROW_SALOME_CORBA_EXCEPTION("Unable to find graph in the file",SALOME::BAD_PARAM); + + SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; + aSeq->length(1); + aSeq[0]=aLocalPersistentID; + if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(myStrURL, aSeq.in(), true); + + return _Orb->object_to_string(graph); +} + +bool SuperV_Impl::CanPublishInStudy(CORBA::Object_ptr theIOR) { + SUPERV::Graph_var aGraph = SUPERV::Graph::_narrow(theIOR); + return !(aGraph->_is_nil()); +} + +SALOMEDS::SObject_ptr SuperV_Impl::PublishInStudy(SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject, + CORBA::Object_ptr theObject, + const char* theName) throw (SALOME::SALOME_Exception) { + SALOMEDS::SObject_var aResultSO; + + if(CORBA::is_nil(theObject)) return aResultSO._retn();; + + if(theStudy->_is_nil()) return aResultSO._retn();; + + SALOMEDS::StudyBuilder_var aBuilder = theStudy->NewBuilder(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIOR; + SALOMEDS::AttributePixMap_var aPixmap; + SALOMEDS::SComponent_var aFather = theStudy->FindComponent(STUDY_SUPERVISION); + + if (aFather->_is_nil()) { + aFather = aBuilder->NewComponent(STUDY_SUPERVISION); + anAttr = aBuilder->FindOrCreateAttribute(aFather, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(STUDY_SUPERVISION); + + anAttr = aBuilder->FindOrCreateAttribute(aFather, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" ); + + aBuilder->DefineComponentInstance(aFather, SuperG::_this()); + } + + SALOMEDS::SObject_var dataflowI; + SALOMEDS::ChildIterator_var dataflowS = theStudy->NewChildIterator(aFather); + + SUPERV::Graph_var aGraph = SUPERV::Graph::_narrow(theObject); + + const char* name = aGraph->Name(); + + if (CORBA::is_nil(theSObject)) { // if SObject is null, then searching for exist graph SObject + for (; dataflowS->More(); dataflowS->Next()) { + dataflowI = dataflowS->Value(); + if (dataflowI->FindAttribute(anAttr, "AttributeName")) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + if (strcmp(aName->Value(), name) == 0) { + aResultSO = dataflowI; + break; + } + } + } + } else { // else searching for referenced SObject + if (!theSObject->ReferencedObject(aResultSO)) + THROW_SALOME_CORBA_EXCEPTION("Publish in study supervision graph error",SALOME::BAD_PARAM); + } + + if (strlen(theName) != 0) name = theName; + if (CORBA::is_nil(aResultSO)) aResultSO = aBuilder->NewObject(aFather); + + aName = SALOMEDS::AttributeName::_narrow(aBuilder->FindOrCreateAttribute(aResultSO, "AttributeName")); + aName->SetValue(name); + anIOR = SALOMEDS::AttributeIOR::_narrow(aBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR")); + anIOR->SetValue(aGraph->getIOR()); +// aBuilder->Addreference(theSObject, aResultSO); + return aResultSO._retn(); +} + +CORBA::Boolean SuperV_Impl::CanCopy(SALOMEDS::SObject_ptr theObject) { + // Try to retrieve known by SUPERVISION component Graph by given IOR + SALOMEDS::GenericAttribute_var anAttr; + if (!theObject->FindAttribute(anAttr, "AttributeIOR")) return false; + try { + CORBA::Object_var anObj = _orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value()); + if (CORBA::is_nil(anObj)) return false; + else { + SUPERV::Graph_var aGraph = SUPERV::Graph::_narrow(anObj); + if (aGraph->_is_nil()) return false; + } + } catch (...) { + return false; + } + return true; +} + +SALOMEDS::TMPFile* SuperV_Impl::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) { + // Declare a sequence of the byte to store the copied object + SALOMEDS::TMPFile_var aStreamFile; + + // Try to get GEOM_Shape object by given SObject + SALOMEDS::GenericAttribute_var anAttr; + if (!theObject->FindAttribute(anAttr, "AttributeIOR")) return aStreamFile._retn(); + CORBA::String_var anIOR = strdup(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value()); + + bool isGraph = true; + SUPERV::Graph_var aGraph; + try { + CORBA::Object_var anObj = _orb->string_to_object(anIOR) ; + if (CORBA::is_nil(anObj)) isGraph = false; + else { + aGraph = SUPERV::Graph::_narrow(anObj); + if (aGraph->_is_nil()) isGraph = false; + } + } catch (...) { + isGraph = false; + } + + if (!isGraph) { // it's just a value, stored in the IOR attribute + int aLen = strlen(anIOR); + CORBA::Octet* anOctetBuf = (CORBA::Octet*)strdup(anIOR); + aStreamFile = SALOMEDS::TMPFile_var(new SALOMEDS::TMPFile(aLen, aLen, anOctetBuf, 1)); + return aStreamFile._retn(); + } + + // Get a temporary directory to store a temporary file + CORBA::String_var aTmpDir = SALOMEDS_Tool::GetTmpDir(); + // Create a list to store names of created files + SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; + aSeq->length(1); + aSeq[0] = strdup("_SUPERVISION_tmp.xml"); + char* aFullName = new char[strlen(aTmpDir)+strlen(aSeq[0])+1]; + strcpy(aFullName, aTmpDir); + strcpy(aFullName+strlen(aTmpDir), aSeq[0]); + aGraph->Export(strdup(aFullName)); + delete(aFullName); + + aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir, aSeq.in(), false); + SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aSeq.in(), true); + + // Assign an ID = 1 the the type SUPERV::Graph + theObjectID = 1; + + return aStreamFile._retn(); +} + +CORBA::Boolean SuperV_Impl::CanPaste(const char* theComponentName, CORBA::Long theObjectID) { + // The Supervision component can paste only objects copied by Supervision component + // and with the object type = 1 + if (strcmp(theComponentName, ComponentDataType()) != 0 || theObjectID != 1) return false; + return true; +} + +SALOMEDS::SObject_ptr SuperV_Impl::PasteInto(const SALOMEDS::TMPFile& theStream, + CORBA::Long theObjectID, + SALOMEDS::SObject_ptr theObject) { + SALOMEDS::SObject_var aResultSO; + + SALOMEDS::StudyBuilder_var aBuilder = theObject->GetStudy()->NewBuilder(); + + bool isGraph = (strcmp(theObject->GetFatherComponent()->GetID(),theObject->GetID()) == 0); + + if (!isGraph) { + SALOMEDS::AttributeIOR_var anIOR = + SALOMEDS::AttributeIOR::_narrow(aBuilder->FindOrCreateAttribute(theObject, "AttributeIOR")); + anIOR->SetValue((char*)theStream.NP_data()); + return SALOMEDS::SObject_var(theObject)._retn(); + } + if(CORBA::is_nil(theObject)) return aResultSO._retn(); + + CORBA::String_var aTmpDir = strdup(SALOMEDS_Tool::GetTmpDir()); + SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir, false); + char* aFullName = new char[strlen(aTmpDir)+strlen(aSeq[0])+1]; + strcpy(aFullName, aTmpDir); + strcpy(aFullName+strlen(aTmpDir), aSeq[0]); + SUPERV::Graph_ptr aGraph = Graph(strdup(aFullName)); + delete(aFullName); + + SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aSeq.in(), true); + + if (isGraph) { + aResultSO = aBuilder->NewObject(theObject); + } else { + aResultSO = theObject; + } + + SALOMEDS::AttributeIOR_var anIOR = + SALOMEDS::AttributeIOR::_narrow(aBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR")); + anIOR->SetValue(aGraph->getIOR()); + + return aResultSO._retn(); +} + +SUPERV::Value_ptr SuperV_Impl::StringValue( const char * aStrIOR ) { +// beginService( "Super_Impl::StringValue" ); + CORBA::Any * anAny = new CORBA::Any() ; + + try { + CORBA::Object_ptr obj = _Orb->string_to_object( aStrIOR ) ; + if ( obj ) { + *anAny <<= obj ; +// return(anAny); + } + } + catch ( CORBA::BAD_PARAM ) { + + long l; + double d; + if ( strchr( aStrIOR , '.' ) != NULL && + sscanf( aStrIOR , "%lf%*n", &d)) { + *anAny <<= d; +// MESSAGE( "Value( " << aStrIOR << " ) --> double " << d ); +// return(anAny); + } + else if (sscanf( aStrIOR , "%ld%*n", &l)) { + *anAny <<= l; +// MESSAGE( "Value( " << aStrIOR << " ) --> long " << l ); +// return(anAny); + } + else { + *anAny <<= aStrIOR ; +// MESSAGE( "Value( " << aStrIOR << " ) --> string " << aStrIOR ); + } + } + +// endService( "SuperV_Impl::StringValue" ); + return Value( anAny ) ; +} + +SUPERV::Value_ptr SuperV_Impl::AnyValue( const CORBA::Any & anAny ) { +// beginService( "Super_Impl::AnyValue" ); + CORBA::Any * aAny = new CORBA::Any( anAny ) ; +// endService( "SuperV_Impl::AnyValue" ); + return Value( aAny ) ; +} + +SUPERV::Value_ptr SuperV_Impl::Value( CORBA::Any * anAny ) { +// beginService( "Super_Impl::Value" ); + Value_Impl * myValue = new Value_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + NULL , NULL , NULL , anAny , true ) ; + PortableServer::ObjectId * id = myValue->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::Value_var iobject ; + iobject = SUPERV::Value::_narrow(obj) ; +// endService( "SuperV_Impl::Value" ); + return SUPERV::Value::_duplicate( iobject ) ; +} + +SUPERV::Graph_ptr SuperV_Impl::Graph(const char * aGraphName ) { + beginService( "SuperV_Impl::Graph" ); + bool created = true ; + Graph_Impl * myGraph ; + myGraph = new Graph_Impl( _Orb , _Poa, _ContId, + instanceName() , interfaceName() , aGraphName ) ; + int lenname = strlen( aGraphName ) ; + if ( lenname > 4 && !strcmp( &aGraphName[ lenname - 4 ] , ".xml" ) ) { + created = myGraph->Import( aGraphName ) ; + } + else { + myGraph->Import( (char * ) NULL ) ; + } + SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ; + if ( created ) { + PortableServer::ObjectId * id = myGraph->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::Graph::_narrow(obj) ; + myGraph->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ; + } + endService( "SuperV_Impl::Graph" ); + return SUPERV::Graph::_duplicate(iobject) ; +} + +SUPERV::Graph_ptr SuperV_Impl::GraphE(const char * aGraphName ) { + beginService( "SuperV_Impl::GraphE" ); + bool created = true ; + Graph_Impl * myGraph ; + myGraph = new Graph_Impl( _Orb , _Poa, _ContId, + instanceName() , interfaceName() , aGraphName ) ; + int lenname = strlen( aGraphName ) ; + if ( lenname > 4 && !strcmp( &aGraphName[ lenname - 4 ] , ".xml" ) ) { + created = myGraph->Import( aGraphName ) ; + } + else { + myGraph->Import( (char * ) NULL ) ; + } + SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ; + if ( created ) { + PortableServer::ObjectId * id = myGraph->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::Graph::_narrow(obj) ; + myGraph->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ; + } + myGraph->ReadOnly() ; + endService( "SuperV_Impl::GraphE" ); + return SUPERV::Graph::_duplicate(iobject) ; +} + +SUPERV::Graph_ptr SuperV_Impl::getGraph(const char* ior) { + SUPERV::Graph_var iobject = (SUPERV::Graph_var)NULL; + try { + CORBA::Object_ptr obj = _Orb->string_to_object(ior); + iobject = SUPERV::Graph::_narrow(obj); + } catch ( ... ) { + SUPERV::Graph_var iobject = (SUPERV::Graph_var)NULL; + }; + return(SUPERV::Graph::_duplicate(iobject)); +} + +PortableServer::ObjectId * SupervisionEngine_factory ( + CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName +// , int argc , +// char ** argv + ) { + MESSAGE("SuperV_factory SuperV (" + << instanceName << "," << interfaceName << ")"); + SuperV_Impl * mySuperV = new SuperV_Impl( orb , poa , contId , + instanceName, interfaceName +// , argc , argv + ); + return mySuperV->getId() ; +} diff --git a/src/Supervision/SuperV_Impl.hxx b/src/Supervision/SuperV_Impl.hxx new file mode 100644 index 0000000..1211ef7 --- /dev/null +++ b/src/Supervision/SuperV_Impl.hxx @@ -0,0 +1,109 @@ +//============================================================================= +// File : SuperV_Impl.hxx +// Created : jeu jui 30 12:28:30 CEST 2001 +// Author : Jean Rahuel +// Project : SALOME +// Copyright : CEA 2001 +// $Header$ +//============================================================================= + +#ifndef _SUPERV_IMPL_HXX_ +#define _SUPERV_IMPL_HXX_ + +#include + +#include "CORBA.h" + +#include +#include CORBA_SERVER_HEADER(SALOMEDS) +#include "SALOME_Component_i.hxx" +#include "SALOME_LifeCycleCORBA.hxx" + +#include "Graph_Impl.hxx" + +#include "DataFlowEditor_DataFlow.hxx" + +class SuperV_Impl : public POA_SUPERV::SuperG , + public Engines_Component_i { + private: + + CORBA::ORB_ptr _Orb ; + PortableServer::POA_ptr _Poa ; + PortableServer::ObjectId * _ContId ; + char *myStrURL; + + public: + SuperV_Impl(); + SuperV_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName +// , int argc , +// char ** argv + ) ; + + virtual ~SuperV_Impl() ; + virtual void Destroy() ; + +// void Save(const char* IORSComponent, const char* aUrlOfFile); +// void Load(const char* IORSComponent, const char* aUrlOfFile); + SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent, + const char* theURL, + bool isMultiFile); + CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent, + const SALOMEDS::TMPFile& theStream, + const char* theURL, + bool isMultiFile); + + void Close(SALOMEDS::SComponent_ptr theComponent); + char* ComponentDataType(); + + char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, + const char* IORString, + CORBA::Boolean isMultiFile); + char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, + const char* aLocalPersistentID, + CORBA::Boolean isMultiFile) + throw(SALOME::SALOME_Exception); + + char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, CORBA::Boolean isMultiFile); + char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, CORBA::Boolean isMultiFile); + + bool CanPublishInStudy(CORBA::Object_ptr theIOR); + SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject, + CORBA::Object_ptr theObject, + const char* theName) throw (SALOME::SALOME_Exception) ; + + CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject); + SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID); + CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID); + SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream, + CORBA::Long theObjectID, + SALOMEDS::SObject_ptr theObject); + + virtual SUPERV::Value_ptr StringValue( const char * aStrIOR ) ; + virtual SUPERV::Value_ptr AnyValue( const CORBA::Any & anAny ) ; + virtual SUPERV::Value_ptr Value( CORBA::Any * anAny ) ; + + virtual SUPERV::Graph_ptr Graph( const char * aDataFlowName ) ; + + virtual SUPERV::Graph_ptr GraphE( const char * aDataFlowName ) ; + + virtual SUPERV::Graph_ptr getGraph(const char* ior); + +}; + +extern "C" + PortableServer::ObjectId * SupervisionEngine_factory + ( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName +// , int argc , +// char ** argv + ) ; + +#endif diff --git a/src/Supervision/Value_Impl.cxx b/src/Supervision/Value_Impl.cxx new file mode 100644 index 0000000..69b5215 --- /dev/null +++ b/src/Supervision/Value_Impl.cxx @@ -0,0 +1,322 @@ +using namespace std; +//============================================================================= +// File : Value_Impl.cxx +// Created : Nov 2001 +// Author : Jean Rahuel +// Project : SALOME +// $Header: +//============================================================================= + +#include +#include +#include +#include + +#include "utilities.h" + +#include "Value_Impl.hxx" + +Value_Impl::Value_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode , + const char *ParameterName , + const CORBA::Any * anAny , + const bool activate ) : + Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { + if ( activate ) { +// MESSAGE("Value_Impl::Value_Impl activate object instanceName(" +// << instanceName << ") interfaceName(" << interfaceName << ") --> " +// << hex << (void *) this << dec ) + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + } + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; + _DataFlowEditor = DataFlowEditor ; + _DataFlowNode = DataFlowNode ; + if ( ParameterName != NULL ) { + _ParameterName = new char[ strlen( ParameterName ) + 1 ] ; + strcpy( _ParameterName , ParameterName ) ; + } + else { + _ParameterName = NULL ; + } + _InputValue = false ; + _Any = new CORBA::Any( *anAny ) ; +} + +Value_Impl::Value_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode , + const char *ParameterName , + const bool activate ) : + Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { + if ( activate ) { +// MESSAGE("Value_Impl::Value_Impl activate object instanceName(" +// << instanceName << ") interfaceName(" << interfaceName << ") --> " +// << hex << (void *) this << dec ) + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + } + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; + _DataFlowEditor = DataFlowEditor ; + _DataFlowNode = DataFlowNode ; + if ( ParameterName != NULL ) { + _ParameterName = new char[ strlen( ParameterName ) + 1 ] ; + strcpy( _ParameterName , ParameterName ) ; + } + else { + _ParameterName = NULL ; + } + _InputValue = false ; + _Any = new CORBA::Any() ; +} + +Value_Impl::Value_Impl() { +} + +Value_Impl::~Value_Impl() { + beginService( "Value_Impl::~Value_Impl" ); + endService( "Value_Impl::~Value_Impl" ); +} + +void Value_Impl::destroy() { + beginService( "Value_Impl::destroy" ); + _poa->deactivate_object(*_id) ; + CORBA::release(_poa) ; + delete(_id) ; + _thisObj->_remove_ref(); + endService( "Value_Impl::destroy" ); +} + +void Value_Impl::InPort( bool anInput ) { + _InputPort = anInput ; +} + +bool Value_Impl::Input( const CORBA::Any * anAny ) { +// _DataFlowEditor->AddInputData( _DataFlowNode->Name() , +// _ParameterName , +// *anAny ) ; + delete _Any ; + _Any = new CORBA::Any( *anAny ) ; + _InputValue = true ; + return true ; +} + +CORBA::Any * Value_Impl::ToAny() { + CORBA::Any * anAny ; + if ( _DataFlowEditor ) { + char * name ; + if ( _DataFlowNode ) { + name = _DataFlowNode->Name() ; + } + else { + name = _DataFlowEditor->Name() ; + } + if ( _InputPort ) { + if ( _DataFlowNode ) { + _InputValue = _DataFlowNode->HasInput( _ParameterName ) ; + } + else { + _InputValue = _DataFlowEditor->HasInput( _ParameterName ) ; + } + if ( _InputValue && _DataFlowEditor->IsEditing() ) { + anAny = new CORBA::Any( * _DataFlowEditor->GetInData( name , + _ParameterName ) ) ; + } + else { + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + anAny = new CORBA::Any( * _DataFlowExecutor->GetInData( name , + _ParameterName ) ) ; + } + else { + anAny = new CORBA::Any( *_Any ) ; + } + } + } + else { + if ( _InputValue && _DataFlowEditor->IsEditing() ) { + anAny = new CORBA::Any( * _DataFlowEditor->GetOutData( name , + _ParameterName ) ) ; + } + else { + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + anAny = new CORBA::Any( * _DataFlowExecutor->GetOutData( name , + _ParameterName ) ) ; + } + else { + anAny = new CORBA::Any( *_Any ) ; + } + } + } + } + else { + anAny = new CORBA::Any( *_Any ) ; + } + return anAny ; +} + +char * Value_Impl::ToString() { +// beginService( "Value_Impl::ToString" ); + CORBA::Any anAny = *ToAny() ; +// cout << "Value_Impl::ToString " << _DataFlowNode->Name() << " " +// << _ParameterName << " " ; + if ( _DataFlowEditor ) { + char * name ; + if ( _DataFlowNode ) { + name = _DataFlowNode->Name() ; + } + else { + name = _DataFlowEditor->Name() ; + } + if ( _InputPort ) { + if ( _DataFlowNode ) { + _InputValue = _DataFlowNode->HasInput( _ParameterName ) ; + } + else { + _InputValue = _DataFlowEditor->HasInput( _ParameterName ) ; + } + if ( _InputValue && _DataFlowEditor->IsEditing() ) { + anAny = * _DataFlowEditor->GetInData( name , + _ParameterName ) ; + } + else { + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + anAny = * _DataFlowExecutor->GetInData( name , + _ParameterName ) ; + } + } + } + else { + if ( _InputValue && _DataFlowEditor->IsEditing() ) { + anAny = * _DataFlowEditor->GetOutData( name , + _ParameterName ) ; + } + else { + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + anAny = * _DataFlowExecutor->GetOutData( name , + _ParameterName ) ; + } + } + } + } + char* retstr ; + switch (anAny.type()->kind()) { + case CORBA::tk_string: { + anAny >>= retstr; +// MESSAGE( "ToString( string ) " << retstr ); + break ; + } + case CORBA::tk_double: { + double d; + anAny >>= d; + retstr = new char[13]; + snprintf(retstr, 13, "%lf", d); +// MESSAGE( "ToString( double ) " << retstr ); + break ; + } + case CORBA::tk_long: { + long l; + anAny >>= l; + retstr = new char[13]; + snprintf(retstr, 13, "%ld", l); +// MESSAGE( "ToString( long ) " << retstr ); + break ; + } + case CORBA::tk_objref: { + CORBA::Object_ptr obj ; + try { + anAny >>= obj ; + retstr = _Orb->object_to_string(obj ); +// MESSAGE( "ToString( object ) " << retstr ); + } + catch ( ... ) { + retstr = "Unknown CORBA::Any Type" ; + } + break ; + } + default: { + retstr = "Unknown CORBA::Any Type" ; +// MESSAGE( retstr ); + break ; + } + } +// endService( "Value_Impl::ToString" ); + return CORBA::string_dup( retstr ) ; +} + +bool Value_Impl::IsIOR() { + CORBA::Any anAny = *ToAny() ; + if ( _DataFlowEditor ) { + char * name ; + if ( _DataFlowNode ) { + name = _DataFlowNode->Name() ; + } + else { + name = _DataFlowEditor->Name() ; + } + if ( _InputPort ) { + if ( _DataFlowNode ) { + _InputValue = _DataFlowNode->HasInput( _ParameterName ) ; + } + else { + _InputValue = _DataFlowEditor->HasInput( _ParameterName ) ; + } + if ( _InputValue && _DataFlowEditor->IsEditing() ) { + anAny = * _DataFlowEditor->GetInData( name , + _ParameterName ) ; + } + else { + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + anAny = * _DataFlowExecutor->GetInData( name , + _ParameterName ) ; + } + } + } + else { + if ( _InputValue && _DataFlowEditor->IsEditing() ) { + anAny = * _DataFlowEditor->GetOutData( name , + _ParameterName ) ; + } + else { + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + anAny = * _DataFlowExecutor->GetOutData( name , + _ParameterName ) ; + } + } + } + } + return(anAny.type()->kind() == CORBA::tk_objref); +} + +char* Value_Impl::ComponentDataType() { + GraphExecutor::DataFlow* _DataFlowExecutor = _DataFlowEditor->Executor(); + const GraphBase::ComputingNode* node = _DataFlowExecutor->GetGraphNode(_DataFlowNode->Name()); + if ( node->IsFactoryNode() ) { + Engines::Component_var compo = ((GraphBase::FactoryNode * ) node )->Component(); + if ( CORBA::is_nil( compo ) ) { + return ( strdup( "UnknownComponent" ) ) ; + } + else { + return ( strdup( compo->instanceName() ) ) ; + } + } + return ( strdup ( "UnknownComponent" ) ) ; +} diff --git a/src/Supervision/Value_Impl.hxx b/src/Supervision/Value_Impl.hxx new file mode 100644 index 0000000..8c2bb29 --- /dev/null +++ b/src/Supervision/Value_Impl.hxx @@ -0,0 +1,74 @@ +//============================================================================= +// File : Value_Impl.hxx +// Created : Nov 2001 +// Author : Jean Rahuel +// Project : SALOME +// Copyright : CEA 2001 +// $Header: +//============================================================================= + +#ifndef _VALUE_IMPL_HXX_ +#define _VALUE_IMPL_HXX_ + +#include + +#include "CORBA.h" + +#include +#include "SALOME_Component_i.hxx" +#include "SALOME_LifeCycleCORBA.hxx" + +#include "DataFlowEditor_DataFlow.hxx" + +class Value_Impl : public POA_SUPERV::Value , + public Engines_Component_i { + private: + + CORBA::ORB_ptr _Orb ; + PortableServer::POA_ptr _Poa ; + PortableServer::ObjectId * _ContId ; + + GraphEditor::DataFlow * _DataFlowEditor ; + GraphEditor::InNode * _DataFlowNode ; + char * _ParameterName ; + bool _InputPort ; + bool _InputValue ; + CORBA::Any * _Any ; + + public: + Value_Impl(); + Value_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode , + const char *ParameterName , + const CORBA::Any * anAny , + const bool activate ) ; + Value_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode , + const char *ParameterName , + const bool activate ) ; + + virtual ~Value_Impl() ; + virtual void destroy() ; + + virtual void InPort( bool anInput ) ; + + virtual bool Input( const CORBA::Any * anAny ) ; + + virtual CORBA::Any * ToAny() ; + virtual char * ToString() ; + virtual bool IsIOR() ; + virtual char* ComponentDataType() ; + +} ; + +#endif diff --git a/src/Supervision/batchmode_SuperV.py b/src/Supervision/batchmode_SuperV.py new file mode 100644 index 0000000..56ebb40 --- /dev/null +++ b/src/Supervision/batchmode_SuperV.py @@ -0,0 +1,1160 @@ +#! /usr/bin/env python + +try : + from batchmode_salome import orb + from batchmode_salome import lcc + from batchmode_salome import naming_service + from batchmode_salome import CORBA + from batchmode_salome import myStudy +except : + import curses + from LifeCycleCORBA import * + from SALOME_NamingServicePy import * + import SUPERV + import SUPERV_idl + from batchmode_salome import * +# try : +# from libSuperVision_Swig import SuperV_Swig +# print 'SuperV_Swig imported' +# except : +# SuperV_Swig = None + orb = CORBA.ORB_init([''], CORBA.ORB_ID) + lcc = LifeCycleCORBA(orb) + naming_service = SALOME_NamingServicePy_i(orb) + +import re +from types import * +import SALOMEDS + +#try : +# SuperVision = SuperV_Swig( len(sys.argv) , sys.argv ) +# SuperVision.Swig = 1 +# print 'SuperV_Swig created' +#except : +# SuperVision = lcc.FindOrLoadComponent("SuperVisionContainer","SUPERV") +# SuperVision.Swig = 0 +# print 'Supervision Component loaded' + +SuperVision = lcc.FindOrLoadComponent("SuperVisionContainer","SUPERV") +SuperVision.Swig = 0 + +modulecatalog = naming_service.Resolve("/Kernel/ModulCatalog") + +myBuilder = myStudy.NewBuilder() +father = myStudy.FindComponent("SUPERV") +if father is None: + father = myBuilder.NewComponent("SUPERV") + A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName"); + FName = A1._narrow(SALOMEDS.AttributeName) + FName.SetValue("Supervision") + A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap"); + aPixmap = A2._narrow(SALOMEDS.AttributePixMap); + aPixmap.SetPixMap( "ICON_OBJBROWSER_Supervision" ); + myBuilder.DefineComponentInstance(father,SuperVision) + + +def PortInputFloat(obj, x): + return obj.Input( SuperVision.AnyValue( CORBA.Any(CORBA.TC_double, x))) + +def PortInputLong(obj, x): + return obj.Input( SuperVision.AnyValue( CORBA.Any(CORBA.TC_long, x))) + +def PortInputObject(obj, x): + try: + return obj.Input( SuperVision.AnyValue( CORBA.Any(CORBA.TC_Object, x))) + except: + return obj.Input( SuperVision.AnyValue( x ) ) + +def PortInputString(obj, x): + return obj.Input( SuperVision.AnyValue( CORBA.Any(CORBA.TC_string, x))) + +def InputFloat(obj, nodein_port, x): + return obj.Input(nodein_port, SuperVision.AnyValue( CORBA.Any(CORBA.TC_double, x))) + +def InputLong(obj, nodein_port, x): + return obj.Input(nodein_port, SuperVision.AnyValue( CORBA.Any(CORBA.TC_long, x))) + +def InputObject(obj, nodein_port, x): + try: + return obj.Input(nodein_port, SuperVision.AnyValue( CORBA.Any(CORBA.TC_Object, x))) + except: + return obj.Input(nodein_port, SuperVision.AnyValue( x ) ) + +def InputString(obj, nodein_port, x): + return obj.Input(nodein_port, SuperVision.AnyValue( CORBA.Any(CORBA.TC_string, x))) + + +def addStudy(ior): + dataflow = SuperVision.getGraph(ior) + name=dataflow.Name() + itr = myStudy.NewChildIterator(father) + while itr.More(): + item=itr.Value() + res,A=item.FindAttribute("AttributeName") + if res: + aName = A._narrow(SALOMEDS.AttributeName) + if aName.Value() == name : + res, A = myBuilder.FindOrCreateAttribute(item, "AttributeIOR") + anIOR = A._narrow(SALOMEDS.AttributeIOR); + anIOR.SetValue(dataflow.getIOR()) + return + itr.Next() + obj = myBuilder.NewObject(father) + A=myBuilder.FindOrCreateAttribute(obj, "AttributeName") + aName=A._narrow(SALOMEDS.AttributeName) + aName.SetValue(name) + A=myBuilder.FindOrCreateAttribute(obj, "AttributeIOR") + anIOR = A._narrow(SALOMEDS.AttributeIOR) + anIOR.SetValue(dataflow.getIOR()) + +typestring = re.compile(r"_[^_]+_([^_]+)_.*") + +def getRealArgs(self,args): + types = [] + realargs = [] + + try: + t = self.this + types.append(typestring.match(self).group(1)) + realargs.append(t) + except: + types.append(type(self)) + realargs.append(self) + for a in args: + try: + t = a.this + types.append(typestring.match(a).group(1)) + realargs.append(t) + except: + types.append(type(a)) + realargs.append(a) + + return tuple(types), tuple(realargs) + +bs_AddInput_valuedict = { + (InstanceType, FloatType) : PortInputFloat, + (InstanceType, IntType) : PortInputLong, + (InstanceType, StringType) : PortInputString, + (InstanceType, InstanceType) : PortInputObject, + (InstanceType, StringType, FloatType) : InputFloat, + (InstanceType, StringType, IntType) : InputLong, + (InstanceType, StringType, StringType) : InputString, + (InstanceType, StringType, InstanceType) : InputObject, + (InstanceType, StringType, ListType) : InputObject, +} + + +def Args( aService , aNodeName , verbose ): + lenin = len( aService.ServiceinParameter ) + infos = aNodeName + 'info = "' + infos = infos + 'NodeName : ' + aNodeName + '\\n' + infos = infos + 'ServiceName : ' + aService.ServiceName + '\\n' + infos = infos + 'PortNames : \\n' + defnames = aNodeName + " = " + "'" + aNodeName + "' ; " + i = 0 + while i < lenin : + argname = aNodeName + aService.ServiceinParameter[ i ].Parametername + valname = aNodeName + "\\\\" + valname = valname + aService.ServiceinParameter[ i ].Parametername + defnames = defnames + argname + " = " + "'" + valname + "' ; " + infos = infos + str(i) + '. ' + argname + ' : Input' + infos = infos + str(i) + ' ' + infos = infos + aService.ServiceinParameter[ i ].Parametername + ' ' + infos = infos + aService.ServiceinParameter[ i ].Parametertype + '\\n' + i = i + 1 + lenout = len( aService.ServiceoutParameter ) + i = 0 + while i < lenout : + argname = aNodeName + aService.ServiceoutParameter[ i ].Parametername + valname = aNodeName + "\\\\" + valname = valname + aService.ServiceoutParameter[ i ].Parametername + defnames = defnames + argname + " = " + "'" + valname + "' ; " + infos = infos + str(lenin+i) + '. ' + argname + ' : Output' + infos = infos + str(i) + ' ' + infos = infos + aService.ServiceoutParameter[ i ].Parametername + ' ' + infos = infos + aService.ServiceoutParameter[ i ].Parametertype + '\\n' + i = i + 1 + infos = infos + '"' + defnames = defnames + infos + if verbose : + defnames = defnames + " ; print " + aNodeName + "info" + return defnames + +def Service_Swig( aCatalogService ) : + aService = SuperVision.Service() + aService.ServiceName = aCatalogService.ServiceName + i = 0 + while i < len( aCatalogService.ServiceinParameter ) : + p = SuperVision.ServicesParameter( aCatalogService.ServiceinParameter[i].Parametertype , aCatalogService.ServiceinParameter[i].Parametername ) + SuperVision.AddInParameter( aService , p ) + i = i + 1 + i = 0 + while i < len( aCatalogService.ServiceoutParameter ) : + p = SuperVision.ServicesParameter( aCatalogService.ServiceoutParameter[i].Parametertype , aCatalogService.ServiceoutParameter[i].Parametername ) + SuperVision.AddOutParameter( aService , p ) + i = i + 1 + return aService + +########################################################## +class CNode: +########################################################## + def __init__( self , aNode , Verbose ): + self.N = aNode + self.N.Verbose = Verbose + def Name( self ): + return self.N.Name() + def Service( self ): + return self.N.Service() + def Kind( self ): + return self.N.Kind() + def CreationDate( self ): + return self.N.CreationDate() + def LastUpdateDate( self ): + return self.N.LastUpdateDate() + def Version( self ): + return self.N.Version() + def Author( self ): + return self.N.Author() + def Comment( self ): + return self.N.Comment() + + def SetName( self , aNewName ): + return self.N.SetName( aNewName ) + def SetAuthor( self , anAuthor ): + return self.N.SetAuthor( anAuthor ) + def SetComment( self , aComment ): + return self.N.SetComment( aComment ) + + def Print( self ): + print "Name ",self.N.Name() + if self.N.IsFactory() : + print "ComponentName ",self.N.GetComponentName() + print "InterfaceName ",self.N.GetInterfaceName() + aService = self.N.Service() + print "Service Name ",aService.ServiceName + lenin = len( aService.ServiceinParameter ) + print " ",lenin," input argument(s) :" + i = 0 + while i < lenin : + print " ",i,". ",aService.ServiceinParameter[ i ].Parametername," ",aService.ServiceinParameter[ i ].Parametertype + i = i + 1 + lenout = len( aService.ServiceoutParameter ) + print " ",lenout," output argument(s) :" + i = 0 + while i < lenout : + print " ",i,". ",aService.ServiceoutParameter[ i ].Parametername," ",aService.ServiceoutParameter[ i ].Parametertype + i = i + 1 + aKind = self.N.Kind() + print "KindOfNode",aKind + aFirstCreation = self.N.CreationDate() + print "Creation Date ",aFirstCreation.Day,"-",aFirstCreation.Month,"-",aFirstCreation.Year," ",aFirstCreation.Hour,":",aFirstCreation.Minute,":",aFirstCreation.Second + aLastModification = self.N.LastUpdateDate() + print "Update Date ",aLastModification.Day,"-",aLastModification.Month,"-",aLastModification.Year," ",aLastModification.Hour,":",aLastModification.Minute,":",aLastModification.Second + print "Version ",self.N.Version() + print "Author ",self.N.Author() + if self.N.IsFactory() : + print "Container ",self.N.GetContainer() + print "Comment ",self.N.Comment() + print "Coords ",self.N.X()," ",self.N.Y() + def Port( self , aPortName ): + aPort = self.N.Port( aPortName ) + if aPort != None : + myPort = Port( aPort , self.N.Verbose ) + return myPort + if self.N.Verbose : + print "Error while creating the Port : ",aPortName + return None + def Input( self , *args ): + types, realargs = getRealArgs(self.N,args) + fn = bs_AddInput_valuedict[types] + anInput = apply( fn, realargs) + if anInput != None : + myInput = Port( anInput , self.N.Verbose ) + return myInput + ErrMsg = "Failed to create the Input" + if self.N.Verbose : + print ErrMsg + return anInput +# def BusPort( self , InOutParameterName , InOutParameterType ): +# sts,inp,outp = self.N.BusPort( InOutParameterName , +# InOutParameterType ) +# inp = Port( inp , self.N.Verbose ) +# outp = Port( outp , self.N.Verbose ) +# return sts,inp,outp +# def BusPorts( self , InputParameterName , InputParameterType , +# OutputParameterName , OutputParameterType ): +# sts,inp,outp = self.N.BusPorts( InputParameterName , +# InputParameterType , +# OutputParameterName , +# OutputParameterType ) +# inp = Port( inp , self.N.Verbose ) +# outp = Port( outp , self.N.Verbose ) +# return sts,inp,outp + def Ports( self ): + ports = self.N.Ports() + i = 0 + while i < len( ports ) : + ports[ i ] = Port( ports[i] , self.N.Verbose ) + i = i + 1 + return ports + def ListPorts( self , *args ): + if len( args ) == 0 : + aName = self.N.Name() + else : + aName = args[ 0 ] + ports = self.N.Ports() + listofports = "" + if len( ports ) : + portsname = ports[ 0 ].Name() + bs = portsname.find('\\') + if bs != -1 : + portsname1,portsname2 = portsname.split('\\') + portsname = portsname1 + portsname2 + listofports = aName + portsname + i = 1 + while i < len( ports ) : + portsname = ports[ i ].Name() + bs = portsname.find('\\') + if bs != -1 : + portsname1,portsname2 = portsname.split('\\') + portsname = portsname1 + portsname2 + listofports = listofports + ',' + aName + portsname + i = i + 1 + print listofports + if len( ports ) == 1 : + listofports = "[" + listofports + "] = " + aName + ".Ports()" + else : + listofports = listofports + " = " + aName + ".Ports()" + return listofports + def PrintPorts( self ): + ports = self.N.Ports() + i = 0 + while i < len( ports ) : + Direction = "Out" + if ports[ i ].IsInput() : + Direction = "In" + print Direction,self.N.Name(),'(',ports[ i ].Name(),ports[ i ].Kind(),ports[ i ].Type(),') = ',ports[ i ].ToString() + i = i + 1 + def Links( self ) : + links = self.N.Links() + i = 0 + while i < len( links ) : + links[ i ] = Link( links[i] , self.N.Verbose ) + i = i + 1 + return links + def PrintLinks( self ): + links = self.Links() + i = 0 + while i < len( links ) : + links[i].Print() + i = i + 1 + def IsGraph( self ): + return self.N.IsGraph() + def IsComputing( self ): + return self.N.IsComputing() + def IsFactory( self ): + return self.N.IsFactory() + def IsInLine( self ): + return self.N.IsInLine() + def IsGOTO( self ): + return self.N.IsGOTO() + def IsLoop( self ): + return self.N.IsLoop() + def IsEndLoop( self ): + return self.N.IsEndLoop() + def IsSwitch( self ): + return self.N.IsSwitch() + def IsEndSwitch( self ): + return self.N.IsEndSwitch() + def SubGraph( self ): + return self.N.SubGraph() + def Thread( self ): + return self.N.Thread() + def IsWaiting( self ): + return self.N.IsWaiting() + def IsRunning( self ): + return self.N.IsRunning() + def IsDone( self ): + return self.N.IsDone() + def IsSuspended( self ): + return self.N.IsSuspended() + def State( self ): + return self.N.State() + def Control( self ): + return self.N.Control() + def ControlClear( self ): + return self.N.ControlClear() + def AutoState( self ): + return self.N.AutoState() + def ReadyW( self ): + return self.N.ReadyW() + def RunningW( self ): + return self.N.RunningW() + def DoneW( self ): + return self.N.DoneW() + def SuspendedW( self ): + return self.N.SuspendedW() + def ReRun( self ): + return self.N.ReRun() + def ReStart( self ): + return self.N.ReStart() + def ReRunAt( self , aNodeName ): + return self.N.ReRunAt( aNodeName ) + def ReStartAt( self , aNodeName ): + return self.N.ReStartAt( aNodeName ) + def Ping( self ): + return self.N.ping() + def Kill( self ): + return self.N.Kill() + def KillDone( self ): + return self.N.KillDone() + def Suspend( self ): + return self.N.Suspend() + def SuspendDone( self ): + return self.N.SuspendDone() + def Resume( self ): + return self.N.Resume() + def Stop( self ): + return self.N.Stop() + def Coords( self , X , Y ): + return self.N.Coords( X , Y ) + def X( self ): + return self.N.X() + def Y( self ): + return self.N.Y() + def destroy( self ): + self.N.destroy() + +########################################################## +class FNode(CNode): +########################################################## + def __init__( self , aNode , Verbose ): + self.N = aNode + self.N.Verbose = Verbose + def GetComponentName( self ): + return self.N.ComponentName() + def GetInterfaceName( self ): + return self.N._get_interfaceName() + def GetContainer( self ): + return self.N.Container() + def SetComponentName( self , aComponentName ): + return self.N.SetComponentName( aComponentName ) + def SetInterfaceName( self , anInterfaceName ): + return self.N.SetInterfaceName( anInterfaceName ) + def SetContainer( self , aComputer ): + return self.N.SetContainer( aComputer ) + +########################################################## +class INode(CNode): +########################################################## + def __init__( self , aNode , Verbose ): + self.N = aNode + self.N.Verbose = Verbose + def Edit( self , FuncName , PyFunc ) : + file = '/tmp/' + FuncName + '.py' + i = 0 + fd = os.open( file , os.O_CREAT | os.O_WRONLY | os.O_TRUNC ) + while ( i < len( PyFunc ) ) : + os.write( fd , PyFunc[ i ] + '\n' ) + i = i + 1 + edit = '${EDITOR} ' + file + os.system( edit ) + fd = os.open( file , os.O_RDONLY ) + line = os.read( fd , 132 ) + res = '' + while len( line ) : + res = res + line + line = os.read( fd , 132 ) + PyFunc = res.splitlines() + i = 0 + while i < len( PyFunc ) : + print PyFunc[i] + i = i + 1 + return PyFunc + def SetPyFunction( self , FuncName , aPyFunction ): + return self.N.SetPyFunction( FuncName , aPyFunction ) + def PyFunction( self ): + return self.N.PyFunction() + def PyFuncName( self ): + return self.N.PyFuncName() + def EPyFunc( self ): + PyFunc = self.N.PyFunction() + PyFunc = self.Edit( self.N.PyFuncName() , PyFunc ) + self.N.SetPyFunction( self.N.PyFuncName() , PyFunc ) + def InPort( self , aParameterName , aParameterType ): + aPort = self.N.InPort( aParameterName , + aParameterType ) + if aPort != None : + myPort = Port( aPort , self.N.Verbose ) + return myPort + if self.N.Verbose : + print "Error while creating the Port : ",aParameterName + return None + def OutPort( self , aParameterName , aParameterType ): + aPort = self.N.OutPort( aParameterName , + aParameterType ) + if aPort != None : + myPort = Port( aPort , self.N.Verbose ) + return myPort + if self.N.Verbose : + print "Error while creating the Port : ",aParameterName + return None + +########################################################## +class GNode(INode): +########################################################## + def __init__( self , aNode , Verbose ): + self.N = aNode + self.N.Verbose = Verbose + def SetCoupled( self , anInLineNode ): + if self.N.IsGOTO() : + node = self.N.SetCoupled( anInLineNode ) + else : + node = None + return node + def Coupled( self ): + node = self.N.Coupled() + if node != None : + if node.IsInLine() : + node = INode( node , self.N.Verbose ) + elif node.IsLoop() : + node = LNode( node , self.N.Verbose ) + elif node.IsEndLoop() : + node = ELNode( node , self.N.Verbose ) + elif node.IsSwitch() : + node = SNode( node , self.N.Verbose ) + elif node.IsEndSwitch() : + node = ESNode( node , self.N.Verbose ) + return node + +########################################################## +class LNode(GNode): +########################################################## + def __init__( self , aNode , Verbose ): + self.N = aNode + self.N.Verbose = Verbose + def SetPyInit( self , InitName , aPyFunction ): + return self.N.SetPyInit( InitName , aPyFunction ) + def PyInit( self ): + return self.N.PyInit() + def PyInitName( self ) : + return self.N.PyInitName() + def EPyInit( self ): + PyFunc = self.N.PyFunction() + PyFunc = self.Edit( self.N.PyFuncName() , PyFunc ) + self.N.SetPyFunction( self.N.PyFuncName() , PyFunc ) + def SetPyMore( self , MoreName , aPyFunction ): + return self.N.SetPyMore( MoreName , aPyFunction ) + def PyMore( self ): + return self.N.PyMore() + def PyMoreName( self ) : + return self.N.PyMoreName() + def EPyMore( self ): + PyMore = self.N.PyMore() + PyMore = self.Edit( self.N.PyMoreName() , PyMore ) + self.N.SetPyMore( self.N.PyMoreName() , PyMore ) + def SetPyNext( self , NextName , aPyFunction ): + return self.N.SetPyNext( NextName , aPyFunction ) + def PyNext( self ): + return self.N.PyNext() + def PyNextName( self ) : + return self.N.PyNextName() + def EPyNext( self ): + PyNext = self.N.PyNext() + PyNext = self.Edit( self.N.PyNextName() , PyNext ) + self.N.SetPyNext( self.N.PyNextName() , PyNext ) + +########################################################## +class ELNode(GNode): +########################################################## + def __init__( self , aNode , Verbose ): + self.N = aNode + self.N.Verbose = Verbose + +########################################################## +class SNode(GNode): +########################################################## + def __init__( self , aNode , Verbose ): + self.N = aNode + self.N.Verbose = Verbose + +########################################################## +class ESNode(GNode): +########################################################## + def __init__( self , aNode , Verbose ): + self.N = aNode + self.N.Verbose = Verbose + +########################################################## +#class ServicesParameter_Swig : +########################################################## +# def __init__( self , aServicesParameter ): +# self.Parametertype = aServicesParameter.Parametertype +# self.Parametername = aServicesParameter.Parametername + +########################################################## +class Graph(INode): +########################################################## + def __init__( self , aName ): + try: + graph = SuperVision.Graph( aName ) + except: + try: + graph = aName.G.Copy() + except: + graph = None + if graph != None : + self.G = graph + self.G.Verbose = 1 + self.N = graph + self.N.Verbose = 1 + else : + print "Graph creation failed" + def CNode( self , *args ): + if len( args ) == 1 : + aService = args[ 0 ] + else : + aComponent = args[ 0 ] + anInterface = args[ 1 ] + aService = args[ 2 ] + NodeComponent = modulecatalog.GetComponent( aComponent ) + aService = NodeComponent.GetService( anInterface , aService ) + aNode = self.G.CNode( aService ) + if aNode != None : + myNode = CNode( aNode , self.G.Verbose ) + return myNode + ErrMsg = "Failed to create a Node with Service " + aService.ServiceName + if self.G.Verbose : + print ErrMsg + return aNode + def Node( self , aComponent , anInterface , aService ): + if SuperVision.Swig : + aService = Service_Swig( aService ) + return self.FNode( aComponent , anInterface , aService ) + def FNode( self , aComponent , anInterface , aService ): + NodeComponent = modulecatalog.GetComponent( aComponent ) + aService = NodeComponent.GetService( anInterface , aService ) + if SuperVision.Swig : + aService = Service_Swig( aService ) + aNode = self.G.FNode( aComponent , anInterface , aService ) + if aNode != None : + myNode = FNode( aNode , self.G.Verbose ) + return myNode + ErrMsg = "Failed to create a Node with Service " + aService.ServiceName + if self.G.Verbose : + print ErrMsg + return aNode + def INode( self , FuncName , aPythonFunction ): + aNode = self.G.INode( FuncName , aPythonFunction ) + if aNode != None : + myNode = INode( aNode , self.G.Verbose ) + return myNode + ErrMsg = "Failed to create a Node" + if self.G.Verbose : + print ErrMsg + return aNode + def GNode( self , FuncName , aPythonFunction , anINode ): + aNode = self.G.GNode( FuncName , aPythonFunction , anINode ) + if aNode != None : + myNode = GNode( aNode , self.G.Verbose ) + return myNode + ErrMsg = "Failed to create a Node" + if self.G.Verbose : + print ErrMsg + return aNode + def LNode( self , InitName , InitFunction , MoreName , MoreFunction , NextName , NextFunction ): + aNode,anEndOfLoop = self.G.LNode( InitName , InitFunction , MoreName , MoreFunction , NextName , NextFunction ) + if aNode != None : + myNode = LNode( aNode , self.G.Verbose ) + myEndOfLoop = INode( anEndOfLoop , self.G.Verbose ) + return myNode,myEndOfLoop + ErrMsg = "Failed to create a Node with Service " + aService.ServiceName + if self.G.Verbose : + print ErrMsg + return aNode + def SNode( self , FuncName , aPythonFunction ): + aNode,anEndOfSwitch = self.G.SNode( FuncName , aPythonFunction ) + if aNode != None : + myNode = SNode( aNode , self.G.Verbose ) + myEndOfSwitch = INode( anEndOfSwitch , self.G.Verbose ) + return myNode,myEndOfSwitch + ErrMsg = "Failed to create a Node" + if self.G.Verbose : + print ErrMsg + return aNode +# def LoopNode( self , aComponent , anInterface , aService , aNodeName ): +# NodeComponent = modulecatalog.GetComponent( aComponent ) +# aService = NodeComponent.GetService( anInterface , aService ) +# aNode,anEndNode = self.G.LoopNode( aComponent , anInterface , aService , aNodeName ) +# myNode = aNode +# myEndNode = anEndNode +# if aNode != None : +# myNode = Node( aNode , self.G.Verbose ) +# if anEndNode != None : +# myEndNode = Node( anEndNode , self.G.Verbose ) +# if ( aNode != None ) & ( anEndNode != None ) : +# return myNode,myEndNode +# ErrMsg = "Failed to create a Node with Service " + aService.ServiceName +# if self.G.Verbose : +# print ErrMsg +# return aNode,anEndNode +# def SwitchNode( self , aComponent , anInterface , aService , aNodeName ): +# NodeComponent = modulecatalog.GetComponent( aComponent ) +# aService = NodeComponent.GetService( anInterface , aService ) +# aNode,anEndNode = self.G.SwitchNode( aComponent , anInterface , aService , aNodeName ) +# myNode = aNode +# myEndNode = anEndNode +# if aNode != None : +# myNode = Node( aNode , self.G.Verbose ) +# if anEndNode != None : +# myEndNode = Node( anEndNode , self.G.Verbose ) +# if ( aNode != None ) & ( anEndNode != None ) : +# return myNode,myEndNode +# ErrMsg = "Failed to create a Node with Service " + aService.ServiceName +# if self.G.Verbose : +# print ErrMsg +# return aNode,anEndNode +# def LNode( self , aNodeName ): +# aNode = self.G.LNode( aNodeName ) +# if aNode != None : +# myNode = Node( aNode , self.G.Verbose ) +# return myNode +# ErrMsg = "Failed to create a Node with Service " + aService.ServiceName +# if self.G.Verbose : +# print ErrMsg +# return aNode +# def LService( self , aComponent , anInterface , aService ): +# NodeComponent = modulecatalog.GetComponent( aComponent ) +# aService = NodeComponent.GetService( anInterface , aService ) +# aNode = self.G.LService( aComponent , anInterface , aService ) +# if aNode != None : +# myNode = Node( aNode , self.G.Verbose ) +# return myNode +# ErrMsg = "Failed to create a Node with Service " + aService.ServiceName +# if self.G.Verbose : +# print ErrMsg +# return aNode +# def CNode( self , aNodeName ): +# aNode = self.G.CNode( aNodeName ) +# if aNode != None : +# myNode = Node( aNode , self.G.Verbose ) +# return myNode +# ErrMsg = "Failed to create a Node with Service " + aService.ServiceName +# if self.G.Verbose : +# print ErrMsg +# return aNode +# def CService( self , aComponent , anInterface , aService ): +# NodeComponent = modulecatalog.GetComponent( aComponent ) +# aService = NodeComponent.GetService( anInterface , aService ) +# aNode = self.G.CService( aComponent , anInterface , aService ) +# if aNode != None : +# myNode = Node( aNode , self.G.Verbose ) +# return myNode +# ErrMsg = "Failed to create a Node with Service " + aService.ServiceName +# if self.G.Verbose : +# print ErrMsg +# return aNode + def PrintService( self , aComponent , anInterface , aService ): + NodeComponent = modulecatalog.GetComponent( aComponent ) + aService = NodeComponent.GetService( anInterface , aService ) + print "ServiceName ",aService.ServiceName," :" + lenin = len( aService.ServiceinParameter ) + print " ",lenin," input argument(s) :" + i = 0 + while i < lenin : + print " ",i,". ",aService.ServiceinParameter[ i ].Parametername," ",aService.ServiceinParameter[ i ].Parametertype + i = i + 1 + lenout = len( aService.ServiceoutParameter ) + print " ",lenout," output argument(s) :" + i = 0 + while i < lenout : + print " ",i,". ",aService.ServiceoutParameter[ i ].Parametername," ",aService.ServiceoutParameter[ i ].Parametertype + i = i + 1 + def Link( self , aFromNodePort , aToNodePort ): + aLink = self.G.Link( aFromNodePort.P , aToNodePort.P ) + if aLink != None : + myLink = Link( aLink , self.G.Verbose ) + return myLink + ErrMsg = "Failed to create a Link from " + aFromNodePort.Node().Name() + "(" + aFromNodePort.Name() + ") to " + aToNodePort.Node().Name() + "(" + aToNodePort.Name() + ")" + if self.G.Verbose : + print ErrMsg + return aLink + def Import( self , anXmlFileName ): + return self.G.Import( anXmlFileName ) + def Export( self , anXmlFileName ): + return self.G.Export( anXmlFileName ) + def IsReadOnly( self ) : + return self.G.IsReadOnly() + def ComponentRef( self , aFactoryServer , aComponent ) : + return self.G.ComponentRef( aFactoryServer , aComponent ) + def IsValid( self ): + return self.G.IsValid() + def IsExecutable( self ): + return self.G.IsExecutable() + def IsEditing( self ): + return self.G.IsEditing() + def IsExecuting( self ): + return self.G.IsExecuting() + def LevelMax( self ): + return self.G.LevelMax() + def ThreadsMax( self ): + return self.G.ThreadsMax() + def GraphsNumber( self ): + return self.G.GraphsNumber() + def LevelNodes( self , aLevel ): + nodes = self.G.LevelNodes( aLevel ) + return self.nodesTuple( nodes ) + def Run( self , *args ): + self.S = -1 + aService = self.Service() + nargs = len( args ) + i = 0 + while nargs > 0 : + print aService.ServiceinParameter[ i ].Parametername," = ",args[i] + self.Input( aService.ServiceinParameter[ i ].Parametername , args[i] ) + i = i + 1 + nargs = nargs - 1 + return self.G.Run() + def Start( self , *args ): + self.S = -1 + aService = self.Service() + nargs = len( args ) + i = 0 + while nargs > 0 : + print aService.ServiceinParameter[ i ].Parametername," = ",args[i] + self.Input( aService.ServiceinParameter[ i ].Parametername , args[i] ) + i = i + 1 + nargs = nargs - 1 + return self.G.Start() + def Event( self ): + sts,aNode,anEvent,aState = self.G.Event() + self.S = sts + return sts,aNode,anEvent,aState + def EventW( self ): + sts,aNode,anEvent,aState = self.G.EventW() + self.S = sts + return sts,aNode,anEvent,aState + def NextW( self ): + if self.S != 0 : + sts,aNode,anEvent,aState = self.G.EventW() + self.S = sts + print sts,aNode.Thread(),aNode.SubGraph(),aNode.Name(),anEvent,aState + return sts + def Threads( self ): + return self.G.Threads() + def SuspendedThreads( self ): + return self.G.SuspendedThreads() + def LastLevelDone( self ): + return self.G.LastLevelDone() + def Verbose( self , verbose ): + preverbose = self.G.Verbose + self.G.Verbose = verbose + return preverbose + def Nodes( self ): + nodes = self.G.Nodes() + return self.nodesTuple( nodes ) + def nodesTuple( self , nodes ) : + n = len( nodes.CNodes ) + i = 0 + j = 0 + pynodes = [] + while i < n : + pynodes.append( CNode( nodes.CNodes[i] , self.G.Verbose ) ) + i = i + 1 + j = j + 1 + n = len( nodes.FNodes ) + i = 0 + while i < n : + pynodes.append( FNode( nodes.FNodes[i] , self.G.Verbose ) ) + i = i + 1 + j = j + 1 + n = len( nodes.INodes ) + i = 0 + while i < n : + pynodes.append( INode( nodes.INodes[i] , self.G.Verbose ) ) + i = i + 1 + j = j + 1 + n = len( nodes.GNodes ) + i = 0 + while i < n : + pynodes.append( GNode( nodes.GNodes[i] , self.G.Verbose ) ) + i = i + 1 + j = j + 1 + n = len( nodes.LNodes ) + i = 0 + while i < n : + pynodes.append( LNode( nodes.LNodes[i] , self.G.Verbose ) ) + i = i + 1 + j = j + 1 + n = len( nodes.ELNodes ) + i = 0 + while i < n : + pynodes.append( GNode( nodes.ELNodes[i] , self.G.Verbose ) ) + i = i + 1 + j = j + 1 + n = len( nodes.SNodes ) + i = 0 + while i < n : + pynodes.append( SNode( nodes.SNodes[i] , self.G.Verbose ) ) + i = i + 1 + j = j + 1 + n = len( nodes.ESNodes ) + i = 0 + while i < n : + pynodes.append( GNode( nodes.ESNodes[i] , self.G.Verbose ) ) + i = i + 1 + j = j + 1 + return pynodes + def ListNodes( self , *args ): + nodes = self.Nodes() + listofnodes = "" + if len( nodes ) : + listofnodes = nodes[ 0 ].Name() + i = 1 + while i < len( nodes ) : + listofnodes = listofnodes + ',' + nodes[ i ].Name() + i = i + 1 + print listofnodes + if len( args ) == 0 : + aName = self.N.Name() + else : + aName = args[ 0 ] + if len( nodes ) == 1 : + listofnodes = "[" + listofnodes + "] = " + aName + ".Nodes()" + else : + listofnodes = listofnodes + " = " + aName + ".Nodes()" + return listofnodes + def PrintNodes( self ): + nodes = self.Nodes() + n = len( nodes ) + i = 0 + while i < n : + print ' ' + nodes[i].Print() + i = i + 1 + def PrintThreads( self ): + nodes = self.Nodes() + i = 0 + while i < len( nodes ) : + print nodes[i].Name(),nodes[i].Thread(),nodes[i].State(),nodes[i].Control(),nodes[i].AutoState() + i = i + 1 + def GLinks( self ): + links = self.G.GLinks() + i = 0 + while i < len( links ) : + links[ i ] = Link( links[i] , self.G.Verbose ) + i = i + 1 + return links + def ListLinks( self , *args ): + links = self.G.GLinks() + if len( links ) : + listoflinks = links[ 0 ].InPort().Node().Name() + listoflinks = listoflinks + links[ 0 ].InPort().Name() + i = 1 + while i < len( links ) : + listoflinks = listoflinks + ',' + links[ i ].InPort().Node().Name() + listoflinks = listoflinks + links[ i ].InPort().Name() + i = i + 1 + print listoflinks + if len( args ) == 0 : + aName = self.N.Name() + else : + aName = args[ 0 ] + if len( links ) == 1 : + listoflinks = "[" + listoflinks + "] = " + aName + ".GLinks()" + else : + listoflinks = listoflinks + " = " + aName + ".GLinks()" + return listoflinks + def PrintLinks( self ): + links = self.G.GLinks() + i = 0 + while i < len( links ) : + Link( links[ i ] , self.G.Verbose ).Print() + i = i + 1 + def Graphs( self ): + graphs = self.G.Graphs() + outgraphs = graphs + i = 0 + while i < len( graphs ) : + outgraphs[ i ] = Graph( graphs[i].Name() , self.G.Verbose ) + outgraphs[ i ].Merge( graphs[i] ) + i = i + 1 + return outgraphs + def Copy( self ): + aCopy = self.G.Copy() + if aCopy != None: + myCopy = Graph( aCopy ) + return myCopy + ErrMsg = "Failed to get a Copy of " + self.G.Name() + if self.G.Verbose : + print ErrMsg + return aCopy + def Merge( self , aGraph ): + return self.G.Merge( aGraph.G ) + def Destroy( self ): + self.N.destroy() + +########################################################## +class GraphE(Graph): +########################################################## + def __init__( self , aName ): + graph = SuperVision.GraphE( aName ) + self.G = graph + self.G.Verbose = 1 + self.N = graph + self.N.Verbose = 1 + +########################################################## +class Value: +########################################################## + def __init__( self , aValue , Verbose ): + self.V = aValue + self.V.Verbose = Verbose + def ToString( self ): + return self.V.ToString() + def ToAny( self ): + return self.V.ToAny() + def Destroy( self ): + self.N.destroy() + +########################################################## +class Port: +########################################################## + def __init__( self , aPort , Verbose ): + self.P = aPort + self.P.Verbose = Verbose + def Input( self , *args ): + types, realargs = getRealArgs(self.P,args) + fn = bs_AddInput_valuedict[types] + anInput = apply( fn, realargs) + return anInput + def Node( self ): + aNode = self.P.Node() + if aNode != None : + if aNode.IsComputing() : + myNode = CNode( aNode , self.P.Verbose ) + elif aNode.IsFactory() : + myNode = FNode( aNode , self.P.Verbose ) + elif aNode.IsInLine() : + myNode = INode( aNode , self.P.Verbose ) + elif aNode.IsGOTO() : + myNode = GNode( aNode , self.P.Verbose ) + elif aNode.IsLoop() : + myNode = LNode( aNode , self.P.Verbose ) + elif aNode.IsEndLoop() : + myNode = ELNode( aNode , self.P.Verbose ) + elif aNode.IsSwitch() : + myNode = SNode( aNode , self.P.Verbose ) + elif aNode.IsEndSwitch() : + myNode = ESNode( aNode , self.P.Verbose ) + else : + myNode = None + return myNode + return aNode + def Name( self ): + return self.P.Name() + def Type( self ): + return self.P.Type() + def Link( self ): + aLink = self.P.Link() + if aLink != None : + myLink = Link( aLink , self.P.Verbose ) + return myLink + ErrMsg = "Failed to get a Link to " + self.P.Node().Name() + "(" + self.P.Name() + ")" + if self.P.Verbose : + print ErrMsg + return aLink + def Links( self ): + links = self.P.Links() + i = 0 + while i < len( links ) : + links[ i ] = Link( links[i] , self.P.Verbose ) + i = i + 1 + return links + def PrintLinks( self ): + links = self.P.Links() + i = 0 + while i < len( links ) : + Link( links[ i ] , self.P.Verbose ).Print() + i = i + 1 + def IsInput( self ): + return self.P.IsInput() + def IsLinked( self ): + return self.P.IsLinked() + def HasInput( self ): + return self.P.HasInput() + def Kind( self ) : + return self.P.Kind() + def IsParam( self ): + return self.P.IsParam() + def IsGate( self ): + return self.P.IsGate() + def IsLoop( self ): + return self.P.IsLoop() + def IsInLine( self ): + return self.P.IsInLine() + def IsSwitch( self ): + return self.P.IsSwitch() + def IsEndSwitch( self ): + return self.P.IsEndSwitch() +# def IsBus( self ): +# return self.P.IsBus() + def Done( self ): + return self.P.Done() + def State( self ): + return self.P.State() + def ToString( self ): + return self.P.ToString() + def ToAny( self ): + return self.P.ToAny() + def Print( self ): + if self.P.IsInput() : + if self.P.IsLinked() : + print "In",self.P.Node().Name(),'(',self.P.Name(),self.P.Kind(),self.P.Type(),') = ',self.P.ToString(),' from ',self.Link().OutPort().Print() + else : + print "In",self.P.Node().Name(),'(',self.P.Name(),self.P.Kind(),self.P.Type(),') = ',self.P.ToString() + else : + print "Out",self.P.Node().Name(),'(',self.P.Name(),self.P.Kind(),self.P.Type(),') = ',self.P.ToString() + def Destroy( self ): + self.P.destroy() + +########################################################## +class Link: +########################################################## + def __init__( self , aLink , Verbose ): + self.L = aLink + self.L.Verbose = Verbose + def OutPort( self ): + aPort = self.L.OutPort() + if aPort != None : + myPort = Port( aPort , self.L.Verbose ) + return myPort + if self.L.Verbose : + print "Error while getting the Port : " + return None + def InPort( self ): + aPort = self.L.InPort() + if aPort != None : + myPort = Port( aPort , self.L.Verbose ) + return myPort + if self.L.Verbose : + print "Error while getting the Port : " + return None + def Print( self ): + anOutPort = self.L.OutPort() + anInPort = self.L.InPort() + print anOutPort.Node().Name(),'(',anOutPort.Name(),' ',anOutPort.Kind(),') =',anOutPort.ToString(),' --> ',anInPort.Node().Name(),'(',anInPort.Name(),')',' ',anInPort.Kind() + def CoordsSize( self ): + return self.L.CoordsSize() + def AddCoord( self , index , X , Y ): + return self.L.AddCoord( index , X , Y ) + def ChangeCoord( self , index , X , Y ): + return self.L.ChangeCoord( index , X , Y ) + def RemoveCoord( self , index ): + return self.L.RemoveCoord( index ) + def Coords( self , index ): + return self.L.Coords( index ) + def destroy( self ): + self.L.destroy() + + -- 2.39.2