From b7b531f894fd0a967071ce2b05e0ced7b4743f3b Mon Sep 17 00:00:00 2001 From: yfr Date: Tue, 20 Jul 2004 09:07:05 +0000 Subject: [PATCH] DCQ:prepare 2.0.0 --- examples/GraphMacroNodes.py | 1040 ++++++ examples/GraphMacroNodes.xml | 2788 +++++++++++++++++ examples/GraphTestMacroNodes.py | 309 ++ examples/MacroWithGeom.xml | 639 ++++ idl/SUPERV.idl | 111 +- resources/config | 1 - src/GraphBase/DataFlowBase_Base.hxx | 19 +- src/GraphBase/DataFlowBase_ComputingNode.cxx | 440 ++- src/GraphBase/DataFlowBase_ComputingNode.hxx | 44 +- src/GraphBase/DataFlowBase_DataNode.cxx | 79 +- src/GraphBase/DataFlowBase_DataNode.hxx | 9 +- src/GraphBase/DataFlowBase_DataPort.cxx | 63 +- src/GraphBase/DataFlowBase_FactoryNode.cxx | 3 +- src/GraphBase/DataFlowBase_FactoryNode.hxx | 1 + src/GraphBase/DataFlowBase_GOTONode.cxx | 81 + src/GraphBase/DataFlowBase_GOTONode.hxx | 74 +- src/GraphBase/DataFlowBase_Graph.cxx | 1034 +++--- src/GraphBase/DataFlowBase_Graph.hxx | 26 +- src/GraphBase/DataFlowBase_InLineNode.cxx | 11 +- src/GraphBase/DataFlowBase_InLineNode.hxx | 5 +- src/GraphBase/DataFlowBase_InPort.cxx | 118 +- src/GraphBase/DataFlowBase_InPort.hxx | 14 +- src/GraphBase/DataFlowBase_LoadXml.cxx | 51 +- src/GraphBase/DataFlowBase_OutPort.cxx | 44 +- src/GraphBase/DataFlowBase_OutPort.hxx | 17 +- src/GraphBase/DataFlowBase_Port.cxx | 24 + src/GraphBase/DataFlowBase_Port.hxx | 8 +- src/GraphBase/DataFlowBase_PortsOfNode.cxx | 326 +- src/GraphBase/DataFlowBase_PortsOfNode.hxx | 7 +- src/GraphBase/DataFlowBase_Service.cxx | 2 +- .../DataFlowBase_ServicesParameter.hxx | 2 + src/GraphBase/DataFlowBase_StreamGraph.cxx | 3 +- src/GraphBase/DataFlowBase_StreamGraph.hxx | 1 + src/GraphBase/DataFlowBase_StreamNode.cxx | 61 +- src/GraphBase/DataFlowBase_StreamNode.hxx | 86 +- src/GraphBase/DataFlowBase_XmlHandler.cxx | 120 +- src/GraphBase/DataFlowBase_XmlHandler.hxx | 18 +- src/GraphBase/Makefile.in | 10 +- src/SUPERVGUI/Makefile.in | 20 +- src/SUPERVGUI/SUPERVGUI.cxx | 6 +- src/SUPERVGUI/SUPERVGUI_Array.cxx | 58 +- src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx | 368 ++- src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.h | 71 +- src/SUPERVGUI/SUPERVGUI_Canvas.cxx | 338 ++ src/SUPERVGUI/SUPERVGUI_Canvas.h | 62 + src/SUPERVGUI/SUPERVGUI_CanvasControlNode.cxx | 251 ++ src/SUPERVGUI/SUPERVGUI_CanvasControlNode.h | 120 + .../SUPERVGUI_CanvasControlNodePrs.cxx | 348 ++ .../SUPERVGUI_CanvasControlNodePrs.h | 95 + src/SUPERVGUI/SUPERVGUI_CanvasLink.cxx | 564 ++++ src/SUPERVGUI/SUPERVGUI_CanvasLink.h | 166 + src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx | 583 ++++ src/SUPERVGUI/SUPERVGUI_CanvasNode.h | 121 + src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx | 980 ++++++ src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.h | 184 ++ src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx | 324 ++ src/SUPERVGUI/SUPERVGUI_CanvasPort.h | 142 + src/SUPERVGUI/SUPERVGUI_CanvasView.cxx | 599 ++++ src/SUPERVGUI/SUPERVGUI_CanvasView.h | 90 + src/SUPERVGUI/SUPERVGUI_Def.h | 12 +- src/SUPERVGUI/SUPERVGUI_Graph.cxx | 114 +- src/SUPERVGUI/SUPERVGUI_Graph.h | 22 - src/SUPERVGUI/SUPERVGUI_Link.cxx | 6 +- src/SUPERVGUI/SUPERVGUI_Link.h | 7 +- src/SUPERVGUI/SUPERVGUI_Main.cxx | 489 ++- src/SUPERVGUI/SUPERVGUI_Main.h | 40 + src/SUPERVGUI/SUPERVGUI_Node.h | 2 +- src/SUPERVGUI/SUPERVGUI_Port.cxx | 159 +- src/SUPERVGUI/SUPERVGUI_Port.h | 41 - src/SUPERVGUI/SUPERVGUI_Service.cxx | 134 +- src/SUPERVGUI/SUPERVGUI_Service.h | 5 + src/SUPERVGUI/SUPERVGUI_View.cxx | 5 +- src/SUPERVGUI/SUPERV_msg_en.po | 15 + 73 files changed, 12608 insertions(+), 1622 deletions(-) create mode 100644 examples/GraphMacroNodes.py create mode 100644 examples/GraphMacroNodes.xml create mode 100644 examples/GraphTestMacroNodes.py create mode 100755 examples/MacroWithGeom.xml delete mode 100644 resources/config create mode 100644 src/SUPERVGUI/SUPERVGUI_Canvas.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_Canvas.h create mode 100644 src/SUPERVGUI/SUPERVGUI_CanvasControlNode.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_CanvasControlNode.h create mode 100644 src/SUPERVGUI/SUPERVGUI_CanvasControlNodePrs.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_CanvasControlNodePrs.h create mode 100644 src/SUPERVGUI/SUPERVGUI_CanvasLink.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_CanvasLink.h create mode 100644 src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_CanvasNode.h create mode 100644 src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.h create mode 100644 src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_CanvasPort.h create mode 100644 src/SUPERVGUI/SUPERVGUI_CanvasView.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_CanvasView.h diff --git a/examples/GraphMacroNodes.py b/examples/GraphMacroNodes.py new file mode 100644 index 0000000..d917ab5 --- /dev/null +++ b/examples/GraphMacroNodes.py @@ -0,0 +1,1040 @@ + +# Generated python file of Graph GraphMacroNodes + +from SuperV import * + +# Graph creation of GraphMacroNodes +def DefGraphMacroNodes() : + GraphMacroNodes = Graph( 'GraphMacroNodes' ) + GraphMacroNodes.SetName( 'GraphMacroNodes' ) + GraphMacroNodes.SetAuthor( '' ) + GraphMacroNodes.SetComment( '' ) + GraphMacroNodes.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + Add = GraphMacroNodes.FNode( 'AddComponent' , 'AddComponent' , 'Add' ) + Add.SetName( 'Add' ) + Add.SetAuthor( '' ) + Add.SetContainer( 'FactoryServer' ) + Add.SetComment( '' ) + Add.Coords( 15 , 241 ) + IAddx = Add.GetInPort( 'x' ) + IAddy = Add.GetInPort( 'y' ) + IAddGate = Add.GetInPort( 'Gate' ) + OAddFuncValue = Add.GetOutPort( 'FuncValue' ) + OAddz = Add.GetOutPort( 'z' ) + OAddGate = Add.GetOutPort( 'Gate' ) + + Sub = GraphMacroNodes.FNode( 'SubComponent' , 'SubComponent' , 'Sub' ) + Sub.SetName( 'Sub' ) + Sub.SetAuthor( '' ) + Sub.SetContainer( 'FactoryServer' ) + Sub.SetComment( '' ) + Sub.Coords( 227 , 99 ) + ISubx = Sub.GetInPort( 'x' ) + ISuby = Sub.GetInPort( 'y' ) + ISubGate = Sub.GetInPort( 'Gate' ) + OSubz = Sub.GetOutPort( 'z' ) + OSubGate = Sub.GetOutPort( 'Gate' ) + + Mul = GraphMacroNodes.FNode( 'MulComponent' , 'MulComponent' , 'Mul' ) + Mul.SetName( 'Mul' ) + Mul.SetAuthor( '' ) + Mul.SetContainer( 'FactoryServer' ) + Mul.SetComment( '' ) + Mul.Coords( 443 , 278 ) + IMulx = Mul.GetInPort( 'x' ) + IMuly = Mul.GetInPort( 'y' ) + IMulGate = Mul.GetInPort( 'Gate' ) + OMulz = Mul.GetOutPort( 'z' ) + OMulGate = Mul.GetOutPort( 'Gate' ) + + Div = GraphMacroNodes.FNode( 'DivComponent' , 'DivComponent' , 'Div' ) + Div.SetName( 'Div' ) + Div.SetAuthor( '' ) + Div.SetContainer( 'FactoryServer' ) + Div.SetComment( '' ) + Div.Coords( 634 , 97 ) + IDivx = Div.GetInPort( 'x' ) + IDivy = Div.GetInPort( 'y' ) + IDivGate = Div.GetInPort( 'Gate' ) + ODivz = Div.GetOutPort( 'z' ) + ODivGate = Div.GetOutPort( 'Gate' ) + + # Creation of Macro Nodes + SyrStruct_1 = DefSyrStruct_1() + Macro_SyrStruct = GraphMacroNodes.GraphMNode( SyrStruct_1 ) + Macro_SyrStruct.SetName( 'Macro_SyrStruct' ) + Macro_SyrStruct.SetAuthor( '' ) + Macro_SyrStruct.SetComment( '' ) + Macro_SyrStruct.Coords( 0 , 0 ) + IMacro_SyrStructSyrComponent__aContainer = Macro_SyrStruct.GetInPort( 'SyrComponent__aContainer' ) + IMacro_SyrStructSyrComponent__aComponent = Macro_SyrStruct.GetInPort( 'SyrComponent__aComponent' ) + IMacro_SyrStructforN__N = Macro_SyrStruct.GetInPort( 'forN__N' ) + IMacro_SyrStructforN__K = Macro_SyrStruct.GetInPort( 'forN__K' ) + IMacro_SyrStructforN__min = Macro_SyrStruct.GetInPort( 'forN__min' ) + IMacro_SyrStructforN__max = Macro_SyrStruct.GetInPort( 'forN__max' ) + IMacro_SyrStructfori__i = Macro_SyrStruct.GetInPort( 'fori__i' ) + IMacro_SyrStructGate = Macro_SyrStruct.GetInPort( 'Gate' ) + OMacro_SyrStructEndOfforN__N = Macro_SyrStruct.GetOutPort( 'EndOfforN__N' ) + OMacro_SyrStructEndOfforN__K = Macro_SyrStruct.GetOutPort( 'EndOfforN__K' ) + OMacro_SyrStructEndOfforN__SyrComponent = Macro_SyrStruct.GetOutPort( 'EndOfforN__SyrComponent' ) + OMacro_SyrStructEndOfforN__min = Macro_SyrStruct.GetOutPort( 'EndOfforN__min' ) + OMacro_SyrStructEndOfforN__max = Macro_SyrStruct.GetOutPort( 'EndOfforN__max' ) + OMacro_SyrStructEndOfwhileNotOne__SyrComponent = Macro_SyrStruct.GetOutPort( 'EndOfwhileNotOne__SyrComponent' ) + OMacro_SyrStructEndOfwhileNotOne__N = Macro_SyrStruct.GetOutPort( 'EndOfwhileNotOne__N' ) + OMacro_SyrStructEndOffori__i = Macro_SyrStruct.GetOutPort( 'EndOffori__i' ) + OMacro_SyrStructEndOfwhileEven__SyrComponent = Macro_SyrStruct.GetOutPort( 'EndOfwhileEven__SyrComponent' ) + OMacro_SyrStructGate = Macro_SyrStruct.GetOutPort( 'Gate' ) + + SyrStruct_1_1 = DefSyrStruct_1_1() + Macro_SyrStruct_1 = GraphMacroNodes.GraphMNode( SyrStruct_1_1 ) + Macro_SyrStruct_1.SetName( 'Macro_SyrStruct_1' ) + Macro_SyrStruct_1.SetAuthor( '' ) + Macro_SyrStruct_1.SetComment( '' ) + Macro_SyrStruct_1.Coords( 0 , 0 ) + IMacro_SyrStruct_1SyrComponent__aContainer = Macro_SyrStruct_1.GetInPort( 'SyrComponent__aContainer' ) + IMacro_SyrStruct_1SyrComponent__aComponent = Macro_SyrStruct_1.GetInPort( 'SyrComponent__aComponent' ) + IMacro_SyrStruct_1forN__N = Macro_SyrStruct_1.GetInPort( 'forN__N' ) + IMacro_SyrStruct_1forN__K = Macro_SyrStruct_1.GetInPort( 'forN__K' ) + IMacro_SyrStruct_1forN__min = Macro_SyrStruct_1.GetInPort( 'forN__min' ) + IMacro_SyrStruct_1forN__max = Macro_SyrStruct_1.GetInPort( 'forN__max' ) + IMacro_SyrStruct_1fori__i = Macro_SyrStruct_1.GetInPort( 'fori__i' ) + IMacro_SyrStruct_1Gate = Macro_SyrStruct_1.GetInPort( 'Gate' ) + OMacro_SyrStruct_1EndOfforN__N = Macro_SyrStruct_1.GetOutPort( 'EndOfforN__N' ) + OMacro_SyrStruct_1EndOfforN__K = Macro_SyrStruct_1.GetOutPort( 'EndOfforN__K' ) + OMacro_SyrStruct_1EndOfforN__SyrComponent = Macro_SyrStruct_1.GetOutPort( 'EndOfforN__SyrComponent' ) + OMacro_SyrStruct_1EndOfforN__min = Macro_SyrStruct_1.GetOutPort( 'EndOfforN__min' ) + OMacro_SyrStruct_1EndOfforN__max = Macro_SyrStruct_1.GetOutPort( 'EndOfforN__max' ) + OMacro_SyrStruct_1EndOfwhileNotOne__SyrComponent = Macro_SyrStruct_1.GetOutPort( 'EndOfwhileNotOne__SyrComponent' ) + OMacro_SyrStruct_1EndOfwhileNotOne__N = Macro_SyrStruct_1.GetOutPort( 'EndOfwhileNotOne__N' ) + OMacro_SyrStruct_1EndOffori__i = Macro_SyrStruct_1.GetOutPort( 'EndOffori__i' ) + OMacro_SyrStruct_1EndOfwhileEven__SyrComponent = Macro_SyrStruct_1.GetOutPort( 'EndOfwhileEven__SyrComponent' ) + OMacro_SyrStruct_1Gate = Macro_SyrStruct_1.GetOutPort( 'Gate' ) + + # Creation of Links + LAddzSuby = GraphMacroNodes.Link( OAddz , ISuby ) + + LAddzMuly = GraphMacroNodes.Link( OAddz , IMuly ) + + LSubzMulx = GraphMacroNodes.Link( OSubz , IMulx ) + + LSubzDivx = GraphMacroNodes.Link( OSubz , IDivx ) + + LMulzDivy = GraphMacroNodes.Link( OMulz , IDivy ) + + # Input datas + IAddx.Input( 3 ) + IAddy.Input( 4.5 ) + ISubx.Input( 1.5 ) + IMacro_SyrStructSyrComponent__aContainer.Input( 'FactoryServer' ) + IMacro_SyrStructSyrComponent__aComponent.Input( 'SyrComponent' ) + IMacro_SyrStructforN__N.Input( 0 ) + IMacro_SyrStructforN__K.Input( 0 ) + IMacro_SyrStructforN__min.Input( 5 ) + IMacro_SyrStructforN__max.Input( 9 ) + IMacro_SyrStructfori__i.Input( 0 ) + IMacro_SyrStruct_1SyrComponent__aContainer.Input( 'FactoryServer' ) + IMacro_SyrStruct_1SyrComponent__aComponent.Input( 'SyrComponent' ) + IMacro_SyrStruct_1forN__N.Input( 0 ) + IMacro_SyrStruct_1forN__K.Input( 0 ) + IMacro_SyrStruct_1forN__min.Input( 5 ) + IMacro_SyrStruct_1forN__max.Input( 9 ) + IMacro_SyrStruct_1fori__i.Input( 0 ) + +# Output Ports of the graph + #OAddFuncValue = Add.GetOutPort( 'FuncValue' ) + #ODivz = Div.GetOutPort( 'z' ) + #OMacro_SyrStructEndOfforN__N = Macro_SyrStruct.GetOutPort( 'EndOfforN__N' ) + #OMacro_SyrStructEndOfforN__K = Macro_SyrStruct.GetOutPort( 'EndOfforN__K' ) + #OMacro_SyrStructEndOfforN__SyrComponent = Macro_SyrStruct.GetOutPort( 'EndOfforN__SyrComponent' ) + #OMacro_SyrStructEndOfforN__min = Macro_SyrStruct.GetOutPort( 'EndOfforN__min' ) + #OMacro_SyrStructEndOfforN__max = Macro_SyrStruct.GetOutPort( 'EndOfforN__max' ) + #OMacro_SyrStructEndOfwhileNotOne__SyrComponent = Macro_SyrStruct.GetOutPort( 'EndOfwhileNotOne__SyrComponent' ) + #OMacro_SyrStructEndOfwhileNotOne__N = Macro_SyrStruct.GetOutPort( 'EndOfwhileNotOne__N' ) + #OMacro_SyrStructEndOffori__i = Macro_SyrStruct.GetOutPort( 'EndOffori__i' ) + #OMacro_SyrStructEndOfwhileEven__SyrComponent = Macro_SyrStruct.GetOutPort( 'EndOfwhileEven__SyrComponent' ) + #OMacro_SyrStruct_1EndOfforN__N = Macro_SyrStruct_1.GetOutPort( 'EndOfforN__N' ) + #OMacro_SyrStruct_1EndOfforN__K = Macro_SyrStruct_1.GetOutPort( 'EndOfforN__K' ) + #OMacro_SyrStruct_1EndOfforN__SyrComponent = Macro_SyrStruct_1.GetOutPort( 'EndOfforN__SyrComponent' ) + #OMacro_SyrStruct_1EndOfforN__min = Macro_SyrStruct_1.GetOutPort( 'EndOfforN__min' ) + #OMacro_SyrStruct_1EndOfforN__max = Macro_SyrStruct_1.GetOutPort( 'EndOfforN__max' ) + #OMacro_SyrStruct_1EndOfwhileNotOne__SyrComponent = Macro_SyrStruct_1.GetOutPort( 'EndOfwhileNotOne__SyrComponent' ) + #OMacro_SyrStruct_1EndOfwhileNotOne__N = Macro_SyrStruct_1.GetOutPort( 'EndOfwhileNotOne__N' ) + #OMacro_SyrStruct_1EndOffori__i = Macro_SyrStruct_1.GetOutPort( 'EndOffori__i' ) + #OMacro_SyrStruct_1EndOfwhileEven__SyrComponent = Macro_SyrStruct_1.GetOutPort( 'EndOfwhileEven__SyrComponent' ) + return GraphMacroNodes + +# Graph creation of SyrStruct_1 +def DefSyrStruct_1() : + SyrStruct_1 = Graph( 'SyrStruct_1' ) + SyrStruct_1.SetName( 'SyrStruct_1' ) + SyrStruct_1.SetAuthor( 'JR' ) + SyrStruct_1.SetComment( 'Syracuse algorithm' ) + SyrStruct_1.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + m3 = SyrStruct_1.FNode( 'SyrComponent' , 'SyrComponent' , 'C_M3' ) + m3.SetName( 'm3' ) + m3.SetAuthor( '' ) + m3.SetContainer( 'localhost/FactoryServer' ) + m3.SetComment( 'C_M3 from SyrComponent' ) + m3.Coords( 672 , 28 ) + Im3anOddInteger = m3.GetInPort( 'anOddInteger' ) + Im3Gate = m3.GetInPort( 'Gate' ) + Om3anInteger = m3.GetOutPort( 'anInteger' ) + Om3Gate = m3.GetOutPort( 'Gate' ) + + m3incr = SyrStruct_1.FNode( 'SyrComponent' , 'SyrComponent' , 'C_INCR' ) + m3incr.SetName( 'm3incr' ) + m3incr.SetAuthor( '' ) + m3incr.SetContainer( 'localhost/FactoryServer' ) + m3incr.SetComment( 'C_INCR from SyrComponent' ) + m3incr.Coords( 898 , 29 ) + Im3incraCount = m3incr.GetInPort( 'aCount' ) + Im3incrGate = m3incr.GetInPort( 'Gate' ) + Om3incraNewCount = m3incr.GetOutPort( 'aNewCount' ) + Om3incrGate = m3incr.GetOutPort( 'Gate' ) + + incra = SyrStruct_1.FNode( 'SyrComponent' , 'SyrComponent' , 'C_INCR' ) + incra.SetName( 'incra' ) + incra.SetAuthor( '' ) + incra.SetContainer( 'localhost/FactoryServer' ) + incra.SetComment( 'C_INCR from SyrComponent' ) + incra.Coords( 803 , 195 ) + IincraaCount = incra.GetInPort( 'aCount' ) + IincraGate = incra.GetInPort( 'Gate' ) + OincraaNewCount = incra.GetOutPort( 'aNewCount' ) + OincraGate = incra.GetOutPort( 'Gate' ) + + div2 = SyrStruct_1.FNode( 'SyrComponent' , 'SyrComponent' , 'C_DIV2' ) + div2.SetName( 'div2' ) + div2.SetAuthor( '' ) + div2.SetContainer( 'localhost/FactoryServer' ) + div2.SetComment( 'C_DIV2 from SyrComponent' ) + div2.Coords( 810 , 435 ) + Idiv2anEvenInteger = div2.GetInPort( 'anEvenInteger' ) + Idiv2Gate = div2.GetInPort( 'Gate' ) + Odiv2anInteger = div2.GetOutPort( 'anInteger' ) + Odiv2Gate = div2.GetOutPort( 'Gate' ) + + incrb = SyrStruct_1.FNode( 'SyrComponent' , 'SyrComponent' , 'C_INCR' ) + incrb.SetName( 'incrb' ) + incrb.SetAuthor( '' ) + incrb.SetContainer( 'localhost/FactoryServer' ) + incrb.SetComment( 'C_INCR from SyrComponent' ) + incrb.Coords( 809 , 574 ) + IincrbaCount = incrb.GetInPort( 'aCount' ) + IincrbGate = incrb.GetInPort( 'Gate' ) + OincrbaNewCount = incrb.GetOutPort( 'aNewCount' ) + OincrbGate = incrb.GetOutPort( 'Gate' ) + + # Creation of InLine Nodes + PySyrComponent = [] + PySyrComponent.append( 'from LifeCycleCORBA import * ' ) + PySyrComponent.append( 'def SyrComponent( aContainer , aComponent ) : ' ) + PySyrComponent.append( ' orb = CORBA.ORB_init([], CORBA.ORB_ID) ' ) + PySyrComponent.append( ' lcc = LifeCycleCORBA(orb) ' ) + PySyrComponent.append( ' ComponentRef = lcc.FindOrLoadComponent( aContainer , aComponent ) ' ) + PySyrComponent.append( ' return ComponentRef ' ) + SyrComponent = SyrStruct_1.INode( 'SyrComponent' , PySyrComponent ) + SyrComponent.SetName( 'SyrComponent' ) + SyrComponent.SetAuthor( '' ) + SyrComponent.SetComment( 'SyrComponent( aContainer , aComponent )' ) + SyrComponent.Coords( 0 , 0 ) + ISyrComponentaContainer = SyrComponent.InPort( 'aContainer' , 'string' ) + ISyrComponentaComponent = SyrComponent.InPort( 'aComponent' , 'string' ) + ISyrComponentGate = SyrComponent.GetInPort( 'Gate' ) + OSyrComponentSyrComponentobjref = SyrComponent.OutPort( 'SyrComponentobjref' , 'objref' ) + OSyrComponentGate = SyrComponent.GetOutPort( 'Gate' ) + + # Creation of Loop Nodes + PyforN = [] + PyforN.append( 'def InitN( NN , K , SyrComponent , min , max ) : ' ) + PyforN.append( ' N = max ' ) + PyforN.append( ' if min > 0 : ' ) + PyforN.append( ' if max >= min : ' ) + PyforN.append( ' N = min ' ) + PyforN.append( ' return N,K,SyrComponent,min,max ' ) + PyMoreforN = [] + PyMoreforN.append( 'def MoreN( NN , KK , SyrComponent , min , max ) : ' ) + PyMoreforN.append( ' N = NN ' ) + PyMoreforN.append( ' OutLoop = 0 ' ) + PyMoreforN.append( ' if max > NN : ' ) + PyMoreforN.append( ' OutLoop = 1 ' ) + PyMoreforN.append( ' return OutLoop,N,0,SyrComponent,min,max ' ) + PyNextforN = [] + PyNextforN.append( 'def NextN( NN , KK , SyrComponent , min , max ) : ' ) + PyNextforN.append( ' N = NN + 1 ' ) + PyNextforN.append( ' K = KK ' ) + PyNextforN.append( ' return N,K,SyrComponent,min,max ' ) + forN,EndOfforN = SyrStruct_1.LNode( 'InitN' , PyforN , 'MoreN' , PyMoreforN , 'NextN' , PyNextforN ) + EndOfforN.SetName( 'EndOfforN' ) + EndOfforN.SetAuthor( '' ) + EndOfforN.SetComment( '' ) + EndOfforN.Coords( 1535 , 332 ) + PyEndOfforN = [] + EndOfforN.SetPyFunction( '' , PyEndOfforN ) + IforNInitLoop = forN.GetInPort( 'InitLoop' ) + IforNN = forN.InPort( 'N' , 'long' ) + IforNK = forN.InPort( 'K' , 'long' ) + IforNSyrComponent = forN.InPort( 'SyrComponent' , 'objref' ) + IforNmin = forN.InPort( 'min' , 'long' ) + IforNmax = forN.InPort( 'max' , 'long' ) + IforNGate = forN.GetInPort( 'Gate' ) + OforNDoLoop = forN.GetOutPort( 'DoLoop' ) + OforNN = forN.GetOutPort( 'N' ) + OforNK = forN.GetOutPort( 'K' ) + OforNSyrComponent = forN.GetOutPort( 'SyrComponent' ) + OforNmin = forN.GetOutPort( 'min' ) + OforNmax = forN.GetOutPort( 'max' ) + IEndOfforNDoLoop = EndOfforN.GetInPort( 'DoLoop' ) + IEndOfforNN = EndOfforN.GetInPort( 'N' ) + IEndOfforNK = EndOfforN.GetInPort( 'K' ) + IEndOfforNSyrComponent = EndOfforN.GetInPort( 'SyrComponent' ) + IEndOfforNmin = EndOfforN.GetInPort( 'min' ) + IEndOfforNmax = EndOfforN.GetInPort( 'max' ) + IEndOfforNGate = EndOfforN.GetInPort( 'Gate' ) + OEndOfforNDoLoop = EndOfforN.GetOutPort( 'DoLoop' ) + OEndOfforNN = EndOfforN.GetOutPort( 'N' ) + OEndOfforNK = EndOfforN.GetOutPort( 'K' ) + OEndOfforNSyrComponent = EndOfforN.GetOutPort( 'SyrComponent' ) + OEndOfforNmin = EndOfforN.GetOutPort( 'min' ) + OEndOfforNmax = EndOfforN.GetOutPort( 'max' ) + forN.SetName( 'forN' ) + forN.SetAuthor( '' ) + forN.SetComment( 'InitN , MoreN , NextN' ) + forN.Coords( 20 , 302 ) + + PywhileNotOne = [] + PywhileNotOne.append( 'import threading' ) + PywhileNotOne.append( 'import SyrComponent_idl' ) + PywhileNotOne.append( 'def InitNotOne( SyrComponent , N , K ) :' ) + PywhileNotOne.append( ' return SyrComponent,N,K' ) + PyMorewhileNotOne = [] + PyMorewhileNotOne.append( 'import SyrComponent_idl' ) + PyMorewhileNotOne.append( 'def MoreNotOne( SyrComponent , N , K ) :' ) + PyMorewhileNotOne.append( ' OutLoop = 1 - SyrComponent.C_ISONE( N )' ) + PyMorewhileNotOne.append( ' return OutLoop,SyrComponent,N,K ' ) + PyNextwhileNotOne = [] + PyNextwhileNotOne.append( 'import SyrComponent_idl' ) + PyNextwhileNotOne.append( 'def NextNotOne( SyrComponent , N , K ) :' ) + PyNextwhileNotOne.append( ' return SyrComponent,N,K' ) + whileNotOne,EndOfwhileNotOne = SyrStruct_1.LNode( 'InitNotOne' , PywhileNotOne , 'MoreNotOne' , PyMorewhileNotOne , 'NextNotOne' , PyNextwhileNotOne ) + EndOfwhileNotOne.SetName( 'EndOfwhileNotOne' ) + EndOfwhileNotOne.SetAuthor( '' ) + EndOfwhileNotOne.SetComment( '' ) + EndOfwhileNotOne.Coords( 1366 , 303 ) + PyEndOfwhileNotOne = [] + EndOfwhileNotOne.SetPyFunction( '' , PyEndOfwhileNotOne ) + IwhileNotOneInitLoop = whileNotOne.GetInPort( 'InitLoop' ) + IwhileNotOneSyrComponent = whileNotOne.InPort( 'SyrComponent' , 'objref' ) + IwhileNotOneN = whileNotOne.InPort( 'N' , 'long' ) + IwhileNotOneK = whileNotOne.InPort( 'K' , 'long' ) + IwhileNotOneGate = whileNotOne.GetInPort( 'Gate' ) + OwhileNotOneDoLoop = whileNotOne.GetOutPort( 'DoLoop' ) + OwhileNotOneSyrComponent = whileNotOne.GetOutPort( 'SyrComponent' ) + OwhileNotOneN = whileNotOne.GetOutPort( 'N' ) + OwhileNotOneK = whileNotOne.GetOutPort( 'K' ) + IEndOfwhileNotOneDoLoop = EndOfwhileNotOne.GetInPort( 'DoLoop' ) + IEndOfwhileNotOneSyrComponent = EndOfwhileNotOne.GetInPort( 'SyrComponent' ) + IEndOfwhileNotOneN = EndOfwhileNotOne.GetInPort( 'N' ) + IEndOfwhileNotOneK = EndOfwhileNotOne.GetInPort( 'K' ) + IEndOfwhileNotOneGate = EndOfwhileNotOne.GetInPort( 'Gate' ) + OEndOfwhileNotOneDoLoop = EndOfwhileNotOne.GetOutPort( 'DoLoop' ) + OEndOfwhileNotOneSyrComponent = EndOfwhileNotOne.GetOutPort( 'SyrComponent' ) + OEndOfwhileNotOneN = EndOfwhileNotOne.GetOutPort( 'N' ) + OEndOfwhileNotOneK = EndOfwhileNotOne.GetOutPort( 'K' ) + whileNotOne.SetName( 'whileNotOne' ) + whileNotOne.SetAuthor( '' ) + whileNotOne.SetComment( 'InitNotOne , MoreNotOne , NextNotOne' ) + whileNotOne.Coords( 212 , 274 ) + + Pyfori = [] + Pyfori.append( 'def Initfori( ii , K ) :' ) + Pyfori.append( ' return 1,0,K' ) + PyMorefori = [] + PyMorefori.append( 'def Morefori( ii , K ) :' ) + PyMorefori.append( ' OutLoop = 0' ) + PyMorefori.append( ' if 2 > ii :' ) + PyMorefori.append( ' OutLoop = 1' ) + PyMorefori.append( ' return OutLoop,ii,K' ) + PyNextfori = [] + PyNextfori.append( 'def Nextfori( ii , K ) :' ) + PyNextfori.append( ' ii = ii + 1' ) + PyNextfori.append( ' return ii,K' ) + fori,EndOffori = SyrStruct_1.LNode( 'Initfori' , Pyfori , 'Morefori' , PyMorefori , 'Nextfori' , PyNextfori ) + EndOffori.SetName( 'EndOffori' ) + EndOffori.SetAuthor( '' ) + EndOffori.SetComment( '' ) + EndOffori.Coords( 976 , 212 ) + PyEndOffori = [] + EndOffori.SetPyFunction( '' , PyEndOffori ) + IforiInitLoop = fori.GetInPort( 'InitLoop' ) + Iforii = fori.InPort( 'i' , 'long' ) + IforiK = fori.InPort( 'K' , 'long' ) + IforiGate = fori.GetInPort( 'Gate' ) + OforiDoLoop = fori.GetOutPort( 'DoLoop' ) + Oforii = fori.GetOutPort( 'i' ) + OforiK = fori.GetOutPort( 'K' ) + IEndOfforiDoLoop = EndOffori.GetInPort( 'DoLoop' ) + IEndOfforii = EndOffori.GetInPort( 'i' ) + IEndOfforiK = EndOffori.GetInPort( 'K' ) + IEndOfforiGate = EndOffori.GetInPort( 'Gate' ) + OEndOfforiDoLoop = EndOffori.GetOutPort( 'DoLoop' ) + OEndOfforii = EndOffori.GetOutPort( 'i' ) + OEndOfforiK = EndOffori.GetOutPort( 'K' ) + fori.SetName( 'fori' ) + fori.SetAuthor( '' ) + fori.SetComment( 'Initfori, Morefori, Nextfori' ) + fori.Coords( 635 , 212 ) + + PywhileEven = [] + PywhileEven.append( 'import SyrComponent_idl' ) + PywhileEven.append( 'def InitEven( SyrComponent , N , K ) :' ) + PywhileEven.append( ' return SyrComponent,N,K' ) + PyMorewhileEven = [] + PyMorewhileEven.append( 'import SyrComponent_idl' ) + PyMorewhileEven.append( 'def MoreEven( SyrComponent , N , K ) :' ) + PyMorewhileEven.append( ' OutLoop = SyrComponent.C_ISEVEN( N )' ) + PyMorewhileEven.append( ' return OutLoop,SyrComponent,N,K ' ) + PyNextwhileEven = [] + PyNextwhileEven.append( 'import SyrComponent_idl' ) + PyNextwhileEven.append( 'def NextEven( SyrComponent , N , K ) :' ) + PyNextwhileEven.append( ' return SyrComponent,N,K' ) + whileEven,EndOfwhileEven = SyrStruct_1.LNode( 'InitEven' , PywhileEven , 'MoreEven' , PyMorewhileEven , 'NextEven' , PyNextwhileEven ) + EndOfwhileEven.SetName( 'EndOfwhileEven' ) + EndOfwhileEven.SetAuthor( '' ) + EndOfwhileEven.SetComment( '' ) + EndOfwhileEven.Coords( 988 , 451 ) + PyEndOfwhileEven = [] + EndOfwhileEven.SetPyFunction( '' , PyEndOfwhileEven ) + IwhileEvenInitLoop = whileEven.GetInPort( 'InitLoop' ) + IwhileEvenSyrComponent = whileEven.InPort( 'SyrComponent' , 'objref' ) + IwhileEvenN = whileEven.InPort( 'N' , 'long' ) + IwhileEvenK = whileEven.InPort( 'K' , 'long' ) + IwhileEvenGate = whileEven.GetInPort( 'Gate' ) + OwhileEvenDoLoop = whileEven.GetOutPort( 'DoLoop' ) + OwhileEvenSyrComponent = whileEven.GetOutPort( 'SyrComponent' ) + OwhileEvenN = whileEven.GetOutPort( 'N' ) + OwhileEvenK = whileEven.GetOutPort( 'K' ) + IEndOfwhileEvenDoLoop = EndOfwhileEven.GetInPort( 'DoLoop' ) + IEndOfwhileEvenSyrComponent = EndOfwhileEven.GetInPort( 'SyrComponent' ) + IEndOfwhileEvenN = EndOfwhileEven.GetInPort( 'N' ) + IEndOfwhileEvenK = EndOfwhileEven.GetInPort( 'K' ) + IEndOfwhileEvenGate = EndOfwhileEven.GetInPort( 'Gate' ) + OEndOfwhileEvenDoLoop = EndOfwhileEven.GetOutPort( 'DoLoop' ) + OEndOfwhileEvenSyrComponent = EndOfwhileEven.GetOutPort( 'SyrComponent' ) + OEndOfwhileEvenN = EndOfwhileEven.GetOutPort( 'N' ) + OEndOfwhileEvenK = EndOfwhileEven.GetOutPort( 'K' ) + whileEven.SetName( 'whileEven' ) + whileEven.SetAuthor( '' ) + whileEven.SetComment( 'InitEven, MoreEven, NextEven' ) + whileEven.Coords( 632 , 451 ) + + # Creation of Switch Nodes + PyifNotEven = [] + PyifNotEven.append( 'import SyrComponent_idl' ) + PyifNotEven.append( 'def ifNotEven( SyrComponent , N , K ) :' ) + PyifNotEven.append( ' Even = SyrComponent.C_ISEVEN( N )' ) + PyifNotEven.append( ' Odd = 1 - Even' ) + PyifNotEven.append( ' return Odd,Even,SyrComponent,N,K' ) + ifNotEven,EndOfifNotEven = SyrStruct_1.SNode( 'ifNotEven' , PyifNotEven ) + EndOfifNotEven.SetName( 'EndOfifNotEven' ) + EndOfifNotEven.SetAuthor( '' ) + EndOfifNotEven.SetComment( '' ) + EndOfifNotEven.Coords( 1205 , 331 ) + PyEndOfifNotEven = [] + EndOfifNotEven.SetPyFunction( '' , PyEndOfifNotEven ) + IEndOfifNotEvenN = EndOfifNotEven.InPort( 'N' , 'long' ) + IEndOfifNotEvenK = EndOfifNotEven.InPort( 'K' , 'long' ) + IEndOfifNotEvenDefault = EndOfifNotEven.GetInPort( 'Default' ) + OEndOfifNotEvenN = EndOfifNotEven.OutPort( 'N' , 'long' ) + OEndOfifNotEvenK = EndOfifNotEven.OutPort( 'K' , 'long' ) + OEndOfifNotEvenGate = EndOfifNotEven.GetOutPort( 'Gate' ) + ifNotEven.SetName( 'ifNotEven' ) + ifNotEven.SetAuthor( '' ) + ifNotEven.SetComment( 'ifNotEven' ) + ifNotEven.Coords( 418 , 274 ) + IifNotEvenSyrComponent = ifNotEven.InPort( 'SyrComponent' , 'objref' ) + IifNotEvenN = ifNotEven.InPort( 'N' , 'long' ) + IifNotEvenK = ifNotEven.InPort( 'K' , 'long' ) + IifNotEvenGate = ifNotEven.GetInPort( 'Gate' ) + OifNotEvenOdd = ifNotEven.OutPort( 'Odd' , 'long' ) + OifNotEvenEven = ifNotEven.OutPort( 'Even' , 'long' ) + OifNotEvenSyrComponent = ifNotEven.OutPort( 'SyrComponent' , 'objref' ) + OifNotEvenN = ifNotEven.OutPort( 'N' , 'long' ) + OifNotEvenK = ifNotEven.OutPort( 'K' , 'long' ) + OifNotEvenDefault = ifNotEven.GetOutPort( 'Default' ) + + # Creation of Links + Lm3anIntegerm3incraCount = SyrStruct_1.Link( Om3anInteger , Im3incraCount ) + + Lm3incraNewCountEndOfifNotEvenN = SyrStruct_1.Link( Om3incraNewCount , IEndOfifNotEvenN ) + Lm3incraNewCountEndOfifNotEvenN.AddCoord( 1 , 1190 , 366 ) + Lm3incraNewCountEndOfifNotEvenN.AddCoord( 2 , 1191 , 109 ) + + LincraaNewCountEndOfforiK = SyrStruct_1.Link( OincraaNewCount , IEndOfforiK ) + + Ldiv2anIntegerEndOfwhileEvenN = SyrStruct_1.Link( Odiv2anInteger , IEndOfwhileEvenN ) + + LincrbaNewCountEndOfwhileEvenK = SyrStruct_1.Link( OincrbaNewCount , IEndOfwhileEvenK ) + LincrbaNewCountEndOfwhileEvenK.AddCoord( 1 , 988 , 543 ) + LincrbaNewCountEndOfwhileEvenK.AddCoord( 2 , 988 , 654 ) + + LSyrComponentSyrComponentobjrefforNSyrComponent = SyrStruct_1.Link( OSyrComponentSyrComponentobjref , IforNSyrComponent ) + LSyrComponentSyrComponentobjrefforNSyrComponent.AddCoord( 1 , 13 , 394 ) + LSyrComponentSyrComponentobjrefforNSyrComponent.AddCoord( 2 , 12 , 181 ) + LSyrComponentSyrComponentobjrefforNSyrComponent.AddCoord( 3 , 196 , 181 ) + LSyrComponentSyrComponentobjrefforNSyrComponent.AddCoord( 4 , 197 , 81 ) + + LforNNwhileNotOneN = SyrStruct_1.Link( OforNN , IwhileNotOneN ) + + LforNNEndOfforNN = SyrStruct_1.Link( OforNN , IEndOfforNN ) + + LforNKwhileNotOneK = SyrStruct_1.Link( OforNK , IwhileNotOneK ) + + LforNSyrComponentEndOfforNSyrComponent = SyrStruct_1.Link( OforNSyrComponent , IEndOfforNSyrComponent ) + + LforNSyrComponentwhileNotOneSyrComponent = SyrStruct_1.Link( OforNSyrComponent , IwhileNotOneSyrComponent ) + LforNSyrComponentwhileNotOneSyrComponent.AddCoord( 1 , 192 , 309 ) + LforNSyrComponentwhileNotOneSyrComponent.AddCoord( 2 , 191 , 394 ) + + LforNminEndOfforNmin = SyrStruct_1.Link( OforNmin , IEndOfforNmin ) + + LforNmaxEndOfforNmax = SyrStruct_1.Link( OforNmax , IEndOfforNmax ) + + LwhileNotOneSyrComponentEndOfwhileNotOneSyrComponent = SyrStruct_1.Link( OwhileNotOneSyrComponent , IEndOfwhileNotOneSyrComponent ) + + LwhileNotOneSyrComponentifNotEvenSyrComponent = SyrStruct_1.Link( OwhileNotOneSyrComponent , IifNotEvenSyrComponent ) + + LwhileNotOneNifNotEvenN = SyrStruct_1.Link( OwhileNotOneN , IifNotEvenN ) + + LwhileNotOneKifNotEvenK = SyrStruct_1.Link( OwhileNotOneK , IifNotEvenK ) + + LEndOfwhileNotOneKEndOfforNK = SyrStruct_1.Link( OEndOfwhileNotOneK , IEndOfforNK ) + + LforiiEndOfforii = SyrStruct_1.Link( Oforii , IEndOfforii ) + + LforiKincraaCount = SyrStruct_1.Link( OforiK , IincraaCount ) + + LEndOfforiKEndOfifNotEvenK = SyrStruct_1.Link( OEndOfforiK , IEndOfifNotEvenK ) + LEndOfforiKEndOfifNotEvenK.AddCoord( 1 , 1170 , 396 ) + LEndOfforiKEndOfifNotEvenK.AddCoord( 2 , 1169 , 275 ) + + LwhileEvenSyrComponentEndOfwhileEvenSyrComponent = SyrStruct_1.Link( OwhileEvenSyrComponent , IEndOfwhileEvenSyrComponent ) + + LwhileEvenNdiv2anEvenInteger = SyrStruct_1.Link( OwhileEvenN , Idiv2anEvenInteger ) + + LwhileEvenKincrbaCount = SyrStruct_1.Link( OwhileEvenK , IincrbaCount ) + LwhileEvenKincrbaCount.AddCoord( 1 , 796 , 655 ) + LwhileEvenKincrbaCount.AddCoord( 2 , 795 , 543 ) + + LEndOfwhileEvenNEndOfifNotEvenN = SyrStruct_1.Link( OEndOfwhileEvenN , IEndOfifNotEvenN ) + LEndOfwhileEvenNEndOfifNotEvenN.AddCoord( 1 , 1191 , 366 ) + LEndOfwhileEvenNEndOfifNotEvenN.AddCoord( 2 , 1191 , 513 ) + + LEndOfwhileEvenKEndOfifNotEvenK = SyrStruct_1.Link( OEndOfwhileEvenK , IEndOfifNotEvenK ) + LEndOfwhileEvenKEndOfifNotEvenK.AddCoord( 1 , 1169 , 395 ) + LEndOfwhileEvenKEndOfifNotEvenK.AddCoord( 2 , 1170 , 543 ) + + LifNotEvenOddm3Gate = SyrStruct_1.Link( OifNotEvenOdd , Im3Gate ) + LifNotEvenOddm3Gate.AddCoord( 1 , 593 , 141 ) + LifNotEvenOddm3Gate.AddCoord( 2 , 593 , 307 ) + + LifNotEvenOddforiGate = SyrStruct_1.Link( OifNotEvenOdd , IforiGate ) + + LifNotEvenEvenwhileEvenGate = SyrStruct_1.Link( OifNotEvenEven , IwhileEvenGate ) + LifNotEvenEvenwhileEvenGate.AddCoord( 1 , 593 , 576 ) + LifNotEvenEvenwhileEvenGate.AddCoord( 2 , 592 , 339 ) + + LifNotEvenSyrComponentwhileEvenSyrComponent = SyrStruct_1.Link( OifNotEvenSyrComponent , IwhileEvenSyrComponent ) + LifNotEvenSyrComponentwhileEvenSyrComponent.AddCoord( 1 , 586 , 486 ) + LifNotEvenSyrComponentwhileEvenSyrComponent.AddCoord( 2 , 587 , 367 ) + + LifNotEvenNwhileEvenN = SyrStruct_1.Link( OifNotEvenN , IwhileEvenN ) + LifNotEvenNwhileEvenN.AddCoord( 1 , 604 , 513 ) + LifNotEvenNwhileEvenN.AddCoord( 2 , 603 , 397 ) + + LifNotEvenNm3anOddInteger = SyrStruct_1.Link( OifNotEvenN , Im3anOddInteger ) + LifNotEvenNm3anOddInteger.AddCoord( 1 , 604 , 107 ) + LifNotEvenNm3anOddInteger.AddCoord( 2 , 604 , 395 ) + + LifNotEvenKwhileEvenK = SyrStruct_1.Link( OifNotEvenK , IwhileEvenK ) + LifNotEvenKwhileEvenK.AddCoord( 1 , 621 , 544 ) + LifNotEvenKwhileEvenK.AddCoord( 2 , 622 , 426 ) + + LifNotEvenKforiK = SyrStruct_1.Link( OifNotEvenK , IforiK ) + LifNotEvenKforiK.AddCoord( 1 , 622 , 275 ) + LifNotEvenKforiK.AddCoord( 2 , 622 , 426 ) + + LifNotEvenDefaultEndOfifNotEvenDefault = SyrStruct_1.Link( OifNotEvenDefault , IEndOfifNotEvenDefault ) + LifNotEvenDefaultEndOfifNotEvenDefault.AddCoord( 1 , 1204 , 429 ) + LifNotEvenDefaultEndOfifNotEvenDefault.AddCoord( 2 , 1203 , 12 ) + LifNotEvenDefaultEndOfifNotEvenDefault.AddCoord( 3 , 581 , 13 ) + LifNotEvenDefaultEndOfifNotEvenDefault.AddCoord( 4 , 581 , 458 ) + + LEndOfifNotEvenNEndOfwhileNotOneN = SyrStruct_1.Link( OEndOfifNotEvenN , IEndOfwhileNotOneN ) + + LEndOfifNotEvenKEndOfwhileNotOneK = SyrStruct_1.Link( OEndOfifNotEvenK , IEndOfwhileNotOneK ) + + # Input Ports of the graph + #ISyrComponentaContainer = SyrComponent.GetInPort( 'aContainer' ) + #ISyrComponentaComponent = SyrComponent.GetInPort( 'aComponent' ) + #IforNN = forN.GetInPort( 'N' ) + #IforNK = forN.GetInPort( 'K' ) + #IforNmin = forN.GetInPort( 'min' ) + #IforNmax = forN.GetInPort( 'max' ) + #Iforii = fori.GetInPort( 'i' ) + +# Output Ports of the graph + #OEndOfforNN = EndOfforN.GetOutPort( 'N' ) + #OEndOfforNK = EndOfforN.GetOutPort( 'K' ) + #OEndOfforNSyrComponent = EndOfforN.GetOutPort( 'SyrComponent' ) + #OEndOfforNmin = EndOfforN.GetOutPort( 'min' ) + #OEndOfforNmax = EndOfforN.GetOutPort( 'max' ) + #OEndOfwhileNotOneSyrComponent = EndOfwhileNotOne.GetOutPort( 'SyrComponent' ) + #OEndOfwhileNotOneN = EndOfwhileNotOne.GetOutPort( 'N' ) + #OEndOfforii = EndOffori.GetOutPort( 'i' ) + #OEndOfwhileEvenSyrComponent = EndOfwhileEven.GetOutPort( 'SyrComponent' ) + return SyrStruct_1 + +# Graph creation of SyrStruct_1_1 +def DefSyrStruct_1_1() : + SyrStruct_1_1 = Graph( 'SyrStruct_1_1' ) + SyrStruct_1_1.SetName( 'SyrStruct_1_1' ) + SyrStruct_1_1.SetAuthor( 'JR' ) + SyrStruct_1_1.SetComment( 'Syracuse algorithm' ) + SyrStruct_1_1.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + m3 = SyrStruct_1_1.FNode( 'SyrComponent' , 'SyrComponent' , 'C_M3' ) + m3.SetName( 'm3' ) + m3.SetAuthor( '' ) + m3.SetContainer( 'localhost/FactoryServer' ) + m3.SetComment( 'C_M3 from SyrComponent' ) + m3.Coords( 672 , 28 ) + Im3anOddInteger = m3.GetInPort( 'anOddInteger' ) + Im3Gate = m3.GetInPort( 'Gate' ) + Om3anInteger = m3.GetOutPort( 'anInteger' ) + Om3Gate = m3.GetOutPort( 'Gate' ) + + m3incr = SyrStruct_1_1.FNode( 'SyrComponent' , 'SyrComponent' , 'C_INCR' ) + m3incr.SetName( 'm3incr' ) + m3incr.SetAuthor( '' ) + m3incr.SetContainer( 'localhost/FactoryServer' ) + m3incr.SetComment( 'C_INCR from SyrComponent' ) + m3incr.Coords( 898 , 29 ) + Im3incraCount = m3incr.GetInPort( 'aCount' ) + Im3incrGate = m3incr.GetInPort( 'Gate' ) + Om3incraNewCount = m3incr.GetOutPort( 'aNewCount' ) + Om3incrGate = m3incr.GetOutPort( 'Gate' ) + + incra = SyrStruct_1_1.FNode( 'SyrComponent' , 'SyrComponent' , 'C_INCR' ) + incra.SetName( 'incra' ) + incra.SetAuthor( '' ) + incra.SetContainer( 'localhost/FactoryServer' ) + incra.SetComment( 'C_INCR from SyrComponent' ) + incra.Coords( 803 , 195 ) + IincraaCount = incra.GetInPort( 'aCount' ) + IincraGate = incra.GetInPort( 'Gate' ) + OincraaNewCount = incra.GetOutPort( 'aNewCount' ) + OincraGate = incra.GetOutPort( 'Gate' ) + + div2 = SyrStruct_1_1.FNode( 'SyrComponent' , 'SyrComponent' , 'C_DIV2' ) + div2.SetName( 'div2' ) + div2.SetAuthor( '' ) + div2.SetContainer( 'localhost/FactoryServer' ) + div2.SetComment( 'C_DIV2 from SyrComponent' ) + div2.Coords( 810 , 435 ) + Idiv2anEvenInteger = div2.GetInPort( 'anEvenInteger' ) + Idiv2Gate = div2.GetInPort( 'Gate' ) + Odiv2anInteger = div2.GetOutPort( 'anInteger' ) + Odiv2Gate = div2.GetOutPort( 'Gate' ) + + incrb = SyrStruct_1_1.FNode( 'SyrComponent' , 'SyrComponent' , 'C_INCR' ) + incrb.SetName( 'incrb' ) + incrb.SetAuthor( '' ) + incrb.SetContainer( 'localhost/FactoryServer' ) + incrb.SetComment( 'C_INCR from SyrComponent' ) + incrb.Coords( 809 , 574 ) + IincrbaCount = incrb.GetInPort( 'aCount' ) + IincrbGate = incrb.GetInPort( 'Gate' ) + OincrbaNewCount = incrb.GetOutPort( 'aNewCount' ) + OincrbGate = incrb.GetOutPort( 'Gate' ) + + # Creation of InLine Nodes + PySyrComponent = [] + PySyrComponent.append( 'from LifeCycleCORBA import * ' ) + PySyrComponent.append( 'def SyrComponent( aContainer , aComponent ) : ' ) + PySyrComponent.append( ' orb = CORBA.ORB_init([], CORBA.ORB_ID) ' ) + PySyrComponent.append( ' lcc = LifeCycleCORBA(orb) ' ) + PySyrComponent.append( ' ComponentRef = lcc.FindOrLoadComponent( aContainer , aComponent ) ' ) + PySyrComponent.append( ' return ComponentRef ' ) + SyrComponent = SyrStruct_1_1.INode( 'SyrComponent' , PySyrComponent ) + SyrComponent.SetName( 'SyrComponent' ) + SyrComponent.SetAuthor( '' ) + SyrComponent.SetComment( 'SyrComponent( aContainer , aComponent )' ) + SyrComponent.Coords( 0 , 0 ) + ISyrComponentaContainer = SyrComponent.InPort( 'aContainer' , 'string' ) + ISyrComponentaComponent = SyrComponent.InPort( 'aComponent' , 'string' ) + ISyrComponentGate = SyrComponent.GetInPort( 'Gate' ) + OSyrComponentSyrComponentobjref = SyrComponent.OutPort( 'SyrComponentobjref' , 'objref' ) + OSyrComponentGate = SyrComponent.GetOutPort( 'Gate' ) + + # Creation of Loop Nodes + PyforN = [] + PyforN.append( 'def InitN( NN , K , SyrComponent , min , max ) : ' ) + PyforN.append( ' N = max ' ) + PyforN.append( ' if min > 0 : ' ) + PyforN.append( ' if max >= min : ' ) + PyforN.append( ' N = min ' ) + PyforN.append( ' return N,K,SyrComponent,min,max ' ) + PyMoreforN = [] + PyMoreforN.append( 'def MoreN( NN , KK , SyrComponent , min , max ) : ' ) + PyMoreforN.append( ' N = NN ' ) + PyMoreforN.append( ' OutLoop = 0 ' ) + PyMoreforN.append( ' if max > NN : ' ) + PyMoreforN.append( ' OutLoop = 1 ' ) + PyMoreforN.append( ' return OutLoop,N,0,SyrComponent,min,max ' ) + PyNextforN = [] + PyNextforN.append( 'def NextN( NN , KK , SyrComponent , min , max ) : ' ) + PyNextforN.append( ' N = NN + 1 ' ) + PyNextforN.append( ' K = KK ' ) + PyNextforN.append( ' return N,K,SyrComponent,min,max ' ) + forN,EndOfforN = SyrStruct_1_1.LNode( 'InitN' , PyforN , 'MoreN' , PyMoreforN , 'NextN' , PyNextforN ) + EndOfforN.SetName( 'EndOfforN' ) + EndOfforN.SetAuthor( '' ) + EndOfforN.SetComment( '' ) + EndOfforN.Coords( 1535 , 332 ) + PyEndOfforN = [] + EndOfforN.SetPyFunction( '' , PyEndOfforN ) + IforNInitLoop = forN.GetInPort( 'InitLoop' ) + IforNN = forN.InPort( 'N' , 'long' ) + IforNK = forN.InPort( 'K' , 'long' ) + IforNSyrComponent = forN.InPort( 'SyrComponent' , 'objref' ) + IforNmin = forN.InPort( 'min' , 'long' ) + IforNmax = forN.InPort( 'max' , 'long' ) + IforNGate = forN.GetInPort( 'Gate' ) + OforNDoLoop = forN.GetOutPort( 'DoLoop' ) + OforNN = forN.GetOutPort( 'N' ) + OforNK = forN.GetOutPort( 'K' ) + OforNSyrComponent = forN.GetOutPort( 'SyrComponent' ) + OforNmin = forN.GetOutPort( 'min' ) + OforNmax = forN.GetOutPort( 'max' ) + IEndOfforNDoLoop = EndOfforN.GetInPort( 'DoLoop' ) + IEndOfforNN = EndOfforN.GetInPort( 'N' ) + IEndOfforNK = EndOfforN.GetInPort( 'K' ) + IEndOfforNSyrComponent = EndOfforN.GetInPort( 'SyrComponent' ) + IEndOfforNmin = EndOfforN.GetInPort( 'min' ) + IEndOfforNmax = EndOfforN.GetInPort( 'max' ) + IEndOfforNGate = EndOfforN.GetInPort( 'Gate' ) + OEndOfforNDoLoop = EndOfforN.GetOutPort( 'DoLoop' ) + OEndOfforNN = EndOfforN.GetOutPort( 'N' ) + OEndOfforNK = EndOfforN.GetOutPort( 'K' ) + OEndOfforNSyrComponent = EndOfforN.GetOutPort( 'SyrComponent' ) + OEndOfforNmin = EndOfforN.GetOutPort( 'min' ) + OEndOfforNmax = EndOfforN.GetOutPort( 'max' ) + forN.SetName( 'forN' ) + forN.SetAuthor( '' ) + forN.SetComment( 'InitN , MoreN , NextN' ) + forN.Coords( 20 , 302 ) + + PywhileNotOne = [] + PywhileNotOne.append( 'import threading' ) + PywhileNotOne.append( 'import SyrComponent_idl' ) + PywhileNotOne.append( 'def InitNotOne( SyrComponent , N , K ) :' ) + PywhileNotOne.append( ' return SyrComponent,N,K' ) + PyMorewhileNotOne = [] + PyMorewhileNotOne.append( 'import SyrComponent_idl' ) + PyMorewhileNotOne.append( 'def MoreNotOne( SyrComponent , N , K ) :' ) + PyMorewhileNotOne.append( ' OutLoop = 1 - SyrComponent.C_ISONE( N )' ) + PyMorewhileNotOne.append( ' return OutLoop,SyrComponent,N,K ' ) + PyNextwhileNotOne = [] + PyNextwhileNotOne.append( 'import SyrComponent_idl' ) + PyNextwhileNotOne.append( 'def NextNotOne( SyrComponent , N , K ) :' ) + PyNextwhileNotOne.append( ' return SyrComponent,N,K' ) + whileNotOne,EndOfwhileNotOne = SyrStruct_1_1.LNode( 'InitNotOne' , PywhileNotOne , 'MoreNotOne' , PyMorewhileNotOne , 'NextNotOne' , PyNextwhileNotOne ) + EndOfwhileNotOne.SetName( 'EndOfwhileNotOne' ) + EndOfwhileNotOne.SetAuthor( '' ) + EndOfwhileNotOne.SetComment( '' ) + EndOfwhileNotOne.Coords( 1366 , 303 ) + PyEndOfwhileNotOne = [] + EndOfwhileNotOne.SetPyFunction( '' , PyEndOfwhileNotOne ) + IwhileNotOneInitLoop = whileNotOne.GetInPort( 'InitLoop' ) + IwhileNotOneSyrComponent = whileNotOne.InPort( 'SyrComponent' , 'objref' ) + IwhileNotOneN = whileNotOne.InPort( 'N' , 'long' ) + IwhileNotOneK = whileNotOne.InPort( 'K' , 'long' ) + IwhileNotOneGate = whileNotOne.GetInPort( 'Gate' ) + OwhileNotOneDoLoop = whileNotOne.GetOutPort( 'DoLoop' ) + OwhileNotOneSyrComponent = whileNotOne.GetOutPort( 'SyrComponent' ) + OwhileNotOneN = whileNotOne.GetOutPort( 'N' ) + OwhileNotOneK = whileNotOne.GetOutPort( 'K' ) + IEndOfwhileNotOneDoLoop = EndOfwhileNotOne.GetInPort( 'DoLoop' ) + IEndOfwhileNotOneSyrComponent = EndOfwhileNotOne.GetInPort( 'SyrComponent' ) + IEndOfwhileNotOneN = EndOfwhileNotOne.GetInPort( 'N' ) + IEndOfwhileNotOneK = EndOfwhileNotOne.GetInPort( 'K' ) + IEndOfwhileNotOneGate = EndOfwhileNotOne.GetInPort( 'Gate' ) + OEndOfwhileNotOneDoLoop = EndOfwhileNotOne.GetOutPort( 'DoLoop' ) + OEndOfwhileNotOneSyrComponent = EndOfwhileNotOne.GetOutPort( 'SyrComponent' ) + OEndOfwhileNotOneN = EndOfwhileNotOne.GetOutPort( 'N' ) + OEndOfwhileNotOneK = EndOfwhileNotOne.GetOutPort( 'K' ) + whileNotOne.SetName( 'whileNotOne' ) + whileNotOne.SetAuthor( '' ) + whileNotOne.SetComment( 'InitNotOne , MoreNotOne , NextNotOne' ) + whileNotOne.Coords( 212 , 274 ) + + Pyfori = [] + Pyfori.append( 'def Initfori( ii , K ) :' ) + Pyfori.append( ' return 1,0,K' ) + PyMorefori = [] + PyMorefori.append( 'def Morefori( ii , K ) :' ) + PyMorefori.append( ' OutLoop = 0' ) + PyMorefori.append( ' if 2 > ii :' ) + PyMorefori.append( ' OutLoop = 1' ) + PyMorefori.append( ' return OutLoop,ii,K' ) + PyNextfori = [] + PyNextfori.append( 'def Nextfori( ii , K ) :' ) + PyNextfori.append( ' ii = ii + 1' ) + PyNextfori.append( ' return ii,K' ) + fori,EndOffori = SyrStruct_1_1.LNode( 'Initfori' , Pyfori , 'Morefori' , PyMorefori , 'Nextfori' , PyNextfori ) + EndOffori.SetName( 'EndOffori' ) + EndOffori.SetAuthor( '' ) + EndOffori.SetComment( '' ) + EndOffori.Coords( 976 , 212 ) + PyEndOffori = [] + EndOffori.SetPyFunction( '' , PyEndOffori ) + IforiInitLoop = fori.GetInPort( 'InitLoop' ) + Iforii = fori.InPort( 'i' , 'long' ) + IforiK = fori.InPort( 'K' , 'long' ) + IforiGate = fori.GetInPort( 'Gate' ) + OforiDoLoop = fori.GetOutPort( 'DoLoop' ) + Oforii = fori.GetOutPort( 'i' ) + OforiK = fori.GetOutPort( 'K' ) + IEndOfforiDoLoop = EndOffori.GetInPort( 'DoLoop' ) + IEndOfforii = EndOffori.GetInPort( 'i' ) + IEndOfforiK = EndOffori.GetInPort( 'K' ) + IEndOfforiGate = EndOffori.GetInPort( 'Gate' ) + OEndOfforiDoLoop = EndOffori.GetOutPort( 'DoLoop' ) + OEndOfforii = EndOffori.GetOutPort( 'i' ) + OEndOfforiK = EndOffori.GetOutPort( 'K' ) + fori.SetName( 'fori' ) + fori.SetAuthor( '' ) + fori.SetComment( 'Initfori, Morefori, Nextfori' ) + fori.Coords( 635 , 212 ) + + PywhileEven = [] + PywhileEven.append( 'import SyrComponent_idl' ) + PywhileEven.append( 'def InitEven( SyrComponent , N , K ) :' ) + PywhileEven.append( ' return SyrComponent,N,K' ) + PyMorewhileEven = [] + PyMorewhileEven.append( 'import SyrComponent_idl' ) + PyMorewhileEven.append( 'def MoreEven( SyrComponent , N , K ) :' ) + PyMorewhileEven.append( ' OutLoop = SyrComponent.C_ISEVEN( N )' ) + PyMorewhileEven.append( ' return OutLoop,SyrComponent,N,K ' ) + PyNextwhileEven = [] + PyNextwhileEven.append( 'import SyrComponent_idl' ) + PyNextwhileEven.append( 'def NextEven( SyrComponent , N , K ) :' ) + PyNextwhileEven.append( ' return SyrComponent,N,K' ) + whileEven,EndOfwhileEven = SyrStruct_1_1.LNode( 'InitEven' , PywhileEven , 'MoreEven' , PyMorewhileEven , 'NextEven' , PyNextwhileEven ) + EndOfwhileEven.SetName( 'EndOfwhileEven' ) + EndOfwhileEven.SetAuthor( '' ) + EndOfwhileEven.SetComment( '' ) + EndOfwhileEven.Coords( 988 , 451 ) + PyEndOfwhileEven = [] + EndOfwhileEven.SetPyFunction( '' , PyEndOfwhileEven ) + IwhileEvenInitLoop = whileEven.GetInPort( 'InitLoop' ) + IwhileEvenSyrComponent = whileEven.InPort( 'SyrComponent' , 'objref' ) + IwhileEvenN = whileEven.InPort( 'N' , 'long' ) + IwhileEvenK = whileEven.InPort( 'K' , 'long' ) + IwhileEvenGate = whileEven.GetInPort( 'Gate' ) + OwhileEvenDoLoop = whileEven.GetOutPort( 'DoLoop' ) + OwhileEvenSyrComponent = whileEven.GetOutPort( 'SyrComponent' ) + OwhileEvenN = whileEven.GetOutPort( 'N' ) + OwhileEvenK = whileEven.GetOutPort( 'K' ) + IEndOfwhileEvenDoLoop = EndOfwhileEven.GetInPort( 'DoLoop' ) + IEndOfwhileEvenSyrComponent = EndOfwhileEven.GetInPort( 'SyrComponent' ) + IEndOfwhileEvenN = EndOfwhileEven.GetInPort( 'N' ) + IEndOfwhileEvenK = EndOfwhileEven.GetInPort( 'K' ) + IEndOfwhileEvenGate = EndOfwhileEven.GetInPort( 'Gate' ) + OEndOfwhileEvenDoLoop = EndOfwhileEven.GetOutPort( 'DoLoop' ) + OEndOfwhileEvenSyrComponent = EndOfwhileEven.GetOutPort( 'SyrComponent' ) + OEndOfwhileEvenN = EndOfwhileEven.GetOutPort( 'N' ) + OEndOfwhileEvenK = EndOfwhileEven.GetOutPort( 'K' ) + whileEven.SetName( 'whileEven' ) + whileEven.SetAuthor( '' ) + whileEven.SetComment( 'InitEven, MoreEven, NextEven' ) + whileEven.Coords( 632 , 451 ) + + # Creation of Switch Nodes + PyifNotEven = [] + PyifNotEven.append( 'import SyrComponent_idl' ) + PyifNotEven.append( 'def ifNotEven( SyrComponent , N , K ) :' ) + PyifNotEven.append( ' Even = SyrComponent.C_ISEVEN( N )' ) + PyifNotEven.append( ' Odd = 1 - Even' ) + PyifNotEven.append( ' return Odd,Even,SyrComponent,N,K' ) + ifNotEven,EndOfifNotEven = SyrStruct_1_1.SNode( 'ifNotEven' , PyifNotEven ) + EndOfifNotEven.SetName( 'EndOfifNotEven' ) + EndOfifNotEven.SetAuthor( '' ) + EndOfifNotEven.SetComment( '' ) + EndOfifNotEven.Coords( 1205 , 331 ) + PyEndOfifNotEven = [] + EndOfifNotEven.SetPyFunction( '' , PyEndOfifNotEven ) + IEndOfifNotEvenN = EndOfifNotEven.InPort( 'N' , 'long' ) + IEndOfifNotEvenK = EndOfifNotEven.InPort( 'K' , 'long' ) + IEndOfifNotEvenDefault = EndOfifNotEven.GetInPort( 'Default' ) + OEndOfifNotEvenN = EndOfifNotEven.OutPort( 'N' , 'long' ) + OEndOfifNotEvenK = EndOfifNotEven.OutPort( 'K' , 'long' ) + OEndOfifNotEvenGate = EndOfifNotEven.GetOutPort( 'Gate' ) + ifNotEven.SetName( 'ifNotEven' ) + ifNotEven.SetAuthor( '' ) + ifNotEven.SetComment( 'ifNotEven' ) + ifNotEven.Coords( 418 , 274 ) + IifNotEvenSyrComponent = ifNotEven.InPort( 'SyrComponent' , 'objref' ) + IifNotEvenN = ifNotEven.InPort( 'N' , 'long' ) + IifNotEvenK = ifNotEven.InPort( 'K' , 'long' ) + IifNotEvenGate = ifNotEven.GetInPort( 'Gate' ) + OifNotEvenOdd = ifNotEven.OutPort( 'Odd' , 'long' ) + OifNotEvenEven = ifNotEven.OutPort( 'Even' , 'long' ) + OifNotEvenSyrComponent = ifNotEven.OutPort( 'SyrComponent' , 'objref' ) + OifNotEvenN = ifNotEven.OutPort( 'N' , 'long' ) + OifNotEvenK = ifNotEven.OutPort( 'K' , 'long' ) + OifNotEvenDefault = ifNotEven.GetOutPort( 'Default' ) + + # Creation of Links + Lm3anIntegerm3incraCount = SyrStruct_1_1.Link( Om3anInteger , Im3incraCount ) + + Lm3incraNewCountEndOfifNotEvenN = SyrStruct_1_1.Link( Om3incraNewCount , IEndOfifNotEvenN ) + Lm3incraNewCountEndOfifNotEvenN.AddCoord( 1 , 1190 , 366 ) + Lm3incraNewCountEndOfifNotEvenN.AddCoord( 2 , 1191 , 109 ) + + LincraaNewCountEndOfforiK = SyrStruct_1_1.Link( OincraaNewCount , IEndOfforiK ) + + Ldiv2anIntegerEndOfwhileEvenN = SyrStruct_1_1.Link( Odiv2anInteger , IEndOfwhileEvenN ) + + LincrbaNewCountEndOfwhileEvenK = SyrStruct_1_1.Link( OincrbaNewCount , IEndOfwhileEvenK ) + LincrbaNewCountEndOfwhileEvenK.AddCoord( 1 , 988 , 543 ) + LincrbaNewCountEndOfwhileEvenK.AddCoord( 2 , 988 , 654 ) + + LSyrComponentSyrComponentobjrefforNSyrComponent = SyrStruct_1_1.Link( OSyrComponentSyrComponentobjref , IforNSyrComponent ) + LSyrComponentSyrComponentobjrefforNSyrComponent.AddCoord( 1 , 13 , 394 ) + LSyrComponentSyrComponentobjrefforNSyrComponent.AddCoord( 2 , 12 , 181 ) + LSyrComponentSyrComponentobjrefforNSyrComponent.AddCoord( 3 , 196 , 181 ) + LSyrComponentSyrComponentobjrefforNSyrComponent.AddCoord( 4 , 197 , 81 ) + + LforNNwhileNotOneN = SyrStruct_1_1.Link( OforNN , IwhileNotOneN ) + + LforNNEndOfforNN = SyrStruct_1_1.Link( OforNN , IEndOfforNN ) + + LforNKwhileNotOneK = SyrStruct_1_1.Link( OforNK , IwhileNotOneK ) + + LforNSyrComponentEndOfforNSyrComponent = SyrStruct_1_1.Link( OforNSyrComponent , IEndOfforNSyrComponent ) + + LforNSyrComponentwhileNotOneSyrComponent = SyrStruct_1_1.Link( OforNSyrComponent , IwhileNotOneSyrComponent ) + LforNSyrComponentwhileNotOneSyrComponent.AddCoord( 1 , 192 , 309 ) + LforNSyrComponentwhileNotOneSyrComponent.AddCoord( 2 , 191 , 394 ) + + LforNminEndOfforNmin = SyrStruct_1_1.Link( OforNmin , IEndOfforNmin ) + + LforNmaxEndOfforNmax = SyrStruct_1_1.Link( OforNmax , IEndOfforNmax ) + + LwhileNotOneSyrComponentEndOfwhileNotOneSyrComponent = SyrStruct_1_1.Link( OwhileNotOneSyrComponent , IEndOfwhileNotOneSyrComponent ) + + LwhileNotOneSyrComponentifNotEvenSyrComponent = SyrStruct_1_1.Link( OwhileNotOneSyrComponent , IifNotEvenSyrComponent ) + + LwhileNotOneNifNotEvenN = SyrStruct_1_1.Link( OwhileNotOneN , IifNotEvenN ) + + LwhileNotOneKifNotEvenK = SyrStruct_1_1.Link( OwhileNotOneK , IifNotEvenK ) + + LEndOfwhileNotOneKEndOfforNK = SyrStruct_1_1.Link( OEndOfwhileNotOneK , IEndOfforNK ) + + LforiiEndOfforii = SyrStruct_1_1.Link( Oforii , IEndOfforii ) + + LforiKincraaCount = SyrStruct_1_1.Link( OforiK , IincraaCount ) + + LEndOfforiKEndOfifNotEvenK = SyrStruct_1_1.Link( OEndOfforiK , IEndOfifNotEvenK ) + LEndOfforiKEndOfifNotEvenK.AddCoord( 1 , 1170 , 396 ) + LEndOfforiKEndOfifNotEvenK.AddCoord( 2 , 1169 , 275 ) + + LwhileEvenSyrComponentEndOfwhileEvenSyrComponent = SyrStruct_1_1.Link( OwhileEvenSyrComponent , IEndOfwhileEvenSyrComponent ) + + LwhileEvenNdiv2anEvenInteger = SyrStruct_1_1.Link( OwhileEvenN , Idiv2anEvenInteger ) + + LwhileEvenKincrbaCount = SyrStruct_1_1.Link( OwhileEvenK , IincrbaCount ) + LwhileEvenKincrbaCount.AddCoord( 1 , 796 , 655 ) + LwhileEvenKincrbaCount.AddCoord( 2 , 795 , 543 ) + + LEndOfwhileEvenNEndOfifNotEvenN = SyrStruct_1_1.Link( OEndOfwhileEvenN , IEndOfifNotEvenN ) + LEndOfwhileEvenNEndOfifNotEvenN.AddCoord( 1 , 1191 , 366 ) + LEndOfwhileEvenNEndOfifNotEvenN.AddCoord( 2 , 1191 , 513 ) + + LEndOfwhileEvenKEndOfifNotEvenK = SyrStruct_1_1.Link( OEndOfwhileEvenK , IEndOfifNotEvenK ) + LEndOfwhileEvenKEndOfifNotEvenK.AddCoord( 1 , 1169 , 395 ) + LEndOfwhileEvenKEndOfifNotEvenK.AddCoord( 2 , 1170 , 543 ) + + LifNotEvenOddm3Gate = SyrStruct_1_1.Link( OifNotEvenOdd , Im3Gate ) + LifNotEvenOddm3Gate.AddCoord( 1 , 593 , 141 ) + LifNotEvenOddm3Gate.AddCoord( 2 , 593 , 307 ) + + LifNotEvenOddforiGate = SyrStruct_1_1.Link( OifNotEvenOdd , IforiGate ) + + LifNotEvenEvenwhileEvenGate = SyrStruct_1_1.Link( OifNotEvenEven , IwhileEvenGate ) + LifNotEvenEvenwhileEvenGate.AddCoord( 1 , 593 , 576 ) + LifNotEvenEvenwhileEvenGate.AddCoord( 2 , 592 , 339 ) + + LifNotEvenSyrComponentwhileEvenSyrComponent = SyrStruct_1_1.Link( OifNotEvenSyrComponent , IwhileEvenSyrComponent ) + LifNotEvenSyrComponentwhileEvenSyrComponent.AddCoord( 1 , 586 , 486 ) + LifNotEvenSyrComponentwhileEvenSyrComponent.AddCoord( 2 , 587 , 367 ) + + LifNotEvenNwhileEvenN = SyrStruct_1_1.Link( OifNotEvenN , IwhileEvenN ) + LifNotEvenNwhileEvenN.AddCoord( 1 , 604 , 513 ) + LifNotEvenNwhileEvenN.AddCoord( 2 , 603 , 397 ) + + LifNotEvenNm3anOddInteger = SyrStruct_1_1.Link( OifNotEvenN , Im3anOddInteger ) + LifNotEvenNm3anOddInteger.AddCoord( 1 , 604 , 107 ) + LifNotEvenNm3anOddInteger.AddCoord( 2 , 604 , 395 ) + + LifNotEvenKwhileEvenK = SyrStruct_1_1.Link( OifNotEvenK , IwhileEvenK ) + LifNotEvenKwhileEvenK.AddCoord( 1 , 621 , 544 ) + LifNotEvenKwhileEvenK.AddCoord( 2 , 622 , 426 ) + + LifNotEvenKforiK = SyrStruct_1_1.Link( OifNotEvenK , IforiK ) + LifNotEvenKforiK.AddCoord( 1 , 622 , 275 ) + LifNotEvenKforiK.AddCoord( 2 , 622 , 426 ) + + LifNotEvenDefaultEndOfifNotEvenDefault = SyrStruct_1_1.Link( OifNotEvenDefault , IEndOfifNotEvenDefault ) + LifNotEvenDefaultEndOfifNotEvenDefault.AddCoord( 1 , 1204 , 429 ) + LifNotEvenDefaultEndOfifNotEvenDefault.AddCoord( 2 , 1203 , 12 ) + LifNotEvenDefaultEndOfifNotEvenDefault.AddCoord( 3 , 581 , 13 ) + LifNotEvenDefaultEndOfifNotEvenDefault.AddCoord( 4 , 581 , 458 ) + + LEndOfifNotEvenNEndOfwhileNotOneN = SyrStruct_1_1.Link( OEndOfifNotEvenN , IEndOfwhileNotOneN ) + + LEndOfifNotEvenKEndOfwhileNotOneK = SyrStruct_1_1.Link( OEndOfifNotEvenK , IEndOfwhileNotOneK ) + + # Input Ports of the graph + #ISyrComponentaContainer = SyrComponent.GetInPort( 'aContainer' ) + #ISyrComponentaComponent = SyrComponent.GetInPort( 'aComponent' ) + #IforNN = forN.GetInPort( 'N' ) + #IforNK = forN.GetInPort( 'K' ) + #IforNmin = forN.GetInPort( 'min' ) + #IforNmax = forN.GetInPort( 'max' ) + #Iforii = fori.GetInPort( 'i' ) + +# Output Ports of the graph + #OEndOfforNN = EndOfforN.GetOutPort( 'N' ) + #OEndOfforNK = EndOfforN.GetOutPort( 'K' ) + #OEndOfforNSyrComponent = EndOfforN.GetOutPort( 'SyrComponent' ) + #OEndOfforNmin = EndOfforN.GetOutPort( 'min' ) + #OEndOfforNmax = EndOfforN.GetOutPort( 'max' ) + #OEndOfwhileNotOneSyrComponent = EndOfwhileNotOne.GetOutPort( 'SyrComponent' ) + #OEndOfwhileNotOneN = EndOfwhileNotOne.GetOutPort( 'N' ) + #OEndOfforii = EndOffori.GetOutPort( 'i' ) + #OEndOfwhileEvenSyrComponent = EndOfwhileEven.GetOutPort( 'SyrComponent' ) + return SyrStruct_1_1 + + +GraphMacroNodes = DefGraphMacroNodes() diff --git a/examples/GraphMacroNodes.xml b/examples/GraphMacroNodes.xml new file mode 100644 index 0000000..230ec63 --- /dev/null +++ b/examples/GraphMacroNodes.xml @@ -0,0 +1,2788 @@ + + + + + +? + ? + GraphMacroNodes + 1 + ? + +GraphMacroNodes + + +double + Add__x + +double + Add__y + +double + Sub__x + +string + Macro_SyrStruct__SyrComponent__aContainer + +string + Macro_SyrStruct__SyrComponent__aComponent + +long + Macro_SyrStruct__forN__N + +long + Macro_SyrStruct__forN__K + +long + Macro_SyrStruct__forN__min + +long + Macro_SyrStruct__forN__max + +long + Macro_SyrStruct__fori__i + +string + Macro_SyrStruct_1__SyrComponent__aContainer + +string + Macro_SyrStruct_1__SyrComponent__aComponent + +long + Macro_SyrStruct_1__forN__N + +long + Macro_SyrStruct_1__forN__K + +long + Macro_SyrStruct_1__forN__min + +long + Macro_SyrStruct_1__forN__max + +long + Macro_SyrStruct_1__fori__i + + +double + Add__FuncValue + +double + Div__z + +long + Macro_SyrStruct__EndOfforN__N + +long + Macro_SyrStruct__EndOfforN__K + +objref + Macro_SyrStruct__EndOfforN__SyrComponent + +long + Macro_SyrStruct__EndOfforN__min + +long + Macro_SyrStruct__EndOfforN__max + +objref + Macro_SyrStruct__EndOfwhileNotOne__SyrComponent + +long + Macro_SyrStruct__EndOfwhileNotOne__N + +long + Macro_SyrStruct__EndOffori__i + +objref + Macro_SyrStruct__EndOfwhileEven__SyrComponent + +long + Macro_SyrStruct_1__EndOfforN__N + +long + Macro_SyrStruct_1__EndOfforN__K + +objref + Macro_SyrStruct_1__EndOfforN__SyrComponent + +long + Macro_SyrStruct_1__EndOfforN__min + +long + Macro_SyrStruct_1__EndOfforN__max + +objref + Macro_SyrStruct_1__EndOfwhileNotOne__SyrComponent + +long + Macro_SyrStruct_1__EndOfwhileNotOne__N + +long + Macro_SyrStruct_1__EndOffori__i + +objref + Macro_SyrStruct_1__EndOfwhileEven__SyrComponent + + + 15/6/2004 - 10:28:51 + 15/6/2004 - 10:28:54 + 2.0 + ? + ? + ? + 0 + 0 + + +AddComponent + AddComponent + Add + 0 + ? + +Add + + +double + x + +double + y + + +double + FuncValue + +double + z + + + 15/6/2004 - 10:28:51 + 15/6/2004 - 10:28:51 + 2.0 + ? + FactoryServer + ? + 15 + 241 + +SubComponent + SubComponent + Sub + 0 + ? + +Sub + + +double + x + +double + y + + +double + z + + + 15/6/2004 - 10:28:51 + 15/6/2004 - 10:28:51 + 2.0 + ? + FactoryServer + ? + 227 + 99 + +MulComponent + MulComponent + Mul + 0 + ? + +Mul + + +double + x + +double + y + + +double + z + + + 15/6/2004 - 10:28:51 + 15/6/2004 - 10:28:51 + 2.0 + ? + FactoryServer + ? + 443 + 278 + +DivComponent + DivComponent + Div + 0 + ? + +Div + + +double + x + +double + y + + +double + z + + + 15/6/2004 - 10:28:51 + 15/6/2004 - 10:28:51 + 2.0 + ? + FactoryServer + ? + 634 + 97 + +? + ? + Macro_SyrStruct + 10 + SyrStruct_1 + +SyrStruct_1 + + +string + SyrComponent__aContainer + +string + SyrComponent__aComponent + +long + forN__N + +long + forN__K + +long + forN__min + +long + forN__max + +long + fori__i + + +long + EndOfforN__N + +long + EndOfforN__K + +objref + EndOfforN__SyrComponent + +long + EndOfforN__min + +long + EndOfforN__max + +objref + EndOfwhileNotOne__SyrComponent + +long + EndOfwhileNotOne__N + +long + EndOffori__i + +objref + EndOfwhileEven__SyrComponent + + + +? + + 15/6/2004 - 10:28:52 + 15/6/2004 - 10:28:52 + 2.0 + ? + ? + ? + 0 + 0 + +? + ? + Macro_SyrStruct_1 + 10 + SyrStruct_1_1 + +SyrStruct_1_1 + + +string + SyrComponent__aContainer + +string + SyrComponent__aComponent + +long + forN__N + +long + forN__K + +long + forN__min + +long + forN__max + +long + fori__i + + +long + EndOfforN__N + +long + EndOfforN__K + +objref + EndOfforN__SyrComponent + +long + EndOfforN__min + +long + EndOfforN__max + +objref + EndOfwhileNotOne__SyrComponent + +long + EndOfwhileNotOne__N + +long + EndOffori__i + +objref + EndOfwhileEven__SyrComponent + + + +? + + 15/6/2004 - 10:28:54 + 15/6/2004 - 10:28:54 + 2.0 + ? + ? + ? + 0 + 0 + + +Add + z + Sub + y + + +Add + z + Mul + y + + +Sub + z + Mul + x + + +Sub + z + Div + x + + +Mul + z + Div + y + + + +GraphMacroNodes + Add__x + Add + x + +7 + 3 + + +GraphMacroNodes + Add__y + Add + y + +7 + 4.5 + + +GraphMacroNodes + Sub__x + Sub + x + +7 + 1.5 + + +GraphMacroNodes + Macro_SyrStruct__SyrComponent__aContainer + Macro_SyrStruct + SyrComponent__aContainer + +18 + FactoryServer + + +GraphMacroNodes + Macro_SyrStruct__SyrComponent__aComponent + Macro_SyrStruct + SyrComponent__aComponent + +18 + SyrComponent + + +GraphMacroNodes + Macro_SyrStruct__forN__N + Macro_SyrStruct + forN__N + +3 + 0 + + +GraphMacroNodes + Macro_SyrStruct__forN__K + Macro_SyrStruct + forN__K + +3 + 0 + + +GraphMacroNodes + Macro_SyrStruct__forN__min + Macro_SyrStruct + forN__min + +3 + 5 + + +GraphMacroNodes + Macro_SyrStruct__forN__max + Macro_SyrStruct + forN__max + +3 + 9 + + +GraphMacroNodes + Macro_SyrStruct__fori__i + Macro_SyrStruct + fori__i + +3 + 0 + + +GraphMacroNodes + Macro_SyrStruct_1__SyrComponent__aContainer + Macro_SyrStruct_1 + SyrComponent__aContainer + +18 + FactoryServer + + +GraphMacroNodes + Macro_SyrStruct_1__SyrComponent__aComponent + Macro_SyrStruct_1 + SyrComponent__aComponent + +18 + SyrComponent + + +GraphMacroNodes + Macro_SyrStruct_1__forN__N + Macro_SyrStruct_1 + forN__N + +3 + 0 + + +GraphMacroNodes + Macro_SyrStruct_1__forN__K + Macro_SyrStruct_1 + forN__K + +3 + 0 + + +GraphMacroNodes + Macro_SyrStruct_1__forN__min + Macro_SyrStruct_1 + forN__min + +3 + 5 + + +GraphMacroNodes + Macro_SyrStruct_1__forN__max + Macro_SyrStruct_1 + forN__max + +3 + 9 + + +GraphMacroNodes + Macro_SyrStruct_1__fori__i + Macro_SyrStruct_1 + fori__i + +3 + 0 + + + + +? + ? + SyrStruct_1 + 1 + ? + +SyrStruct_1 + + +string + SyrComponent__aContainer + +string + SyrComponent__aComponent + +long + forN__N + +long + forN__K + +long + forN__min + +long + forN__max + +long + fori__i + + +long + EndOfforN__N + +long + EndOfforN__K + +objref + EndOfforN__SyrComponent + +long + EndOfforN__min + +long + EndOfforN__max + +objref + EndOfwhileNotOne__SyrComponent + +long + EndOfwhileNotOne__N + +long + EndOffori__i + +objref + EndOfwhileEven__SyrComponent + + + 15/6/2004 - 10:28:51 + 15/6/2004 - 10:28:52 + 2.0 + JR + ? + Syracuse algorithm + 0 + 0 + + +SyrComponent + SyrComponent + m3 + 0 + ? + +C_M3 + + +long + anOddInteger + + +long + anInteger + + + 15/6/2004 - 10:28:51 + 15/6/2004 - 10:28:51 + 2.0 + ? + localhost/FactoryServer + C_M3 from SyrComponent + 672 + 28 + +SyrComponent + SyrComponent + m3incr + 0 + ? + +C_INCR + + +long + aCount + + +long + aNewCount + + + 15/6/2004 - 10:28:51 + 15/6/2004 - 10:28:51 + 2.0 + ? + localhost/FactoryServer + C_INCR from SyrComponent + 898 + 29 + +SyrComponent + SyrComponent + incra + 0 + ? + +C_INCR + + +long + aCount + + +long + aNewCount + + + 15/6/2004 - 10:28:51 + 15/6/2004 - 10:28:51 + 2.0 + ? + localhost/FactoryServer + C_INCR from SyrComponent + 803 + 195 + +SyrComponent + SyrComponent + div2 + 0 + ? + +C_DIV2 + + +long + anEvenInteger + + +long + anInteger + + + 15/6/2004 - 10:28:51 + 15/6/2004 - 10:28:51 + 2.0 + ? + localhost/FactoryServer + C_DIV2 from SyrComponent + 810 + 435 + +SyrComponent + SyrComponent + incrb + 0 + ? + +C_INCR + + +long + aCount + + +long + aNewCount + + + 15/6/2004 - 10:28:51 + 15/6/2004 - 10:28:51 + 2.0 + ? + localhost/FactoryServer + C_INCR from SyrComponent + 809 + 574 + +? + ? + SyrComponent + 3 + ? + +SyrComponent + + +string + aContainer + +string + aComponent + + +objref + SyrComponentobjref + + + +SyrComponent + + + + + + + 15/6/2004 - 10:28:51 + 15/6/2004 - 10:28:51 + 2.0 + ? + ? + SyrComponent( aContainer , aComponent ) + 0 + 0 + +? + ? + forN + 4 + EndOfforN + +InitN + + +long + N + +long + K + +objref + SyrComponent + +long + min + +long + max + + +long + N + +long + K + +objref + SyrComponent + +long + min + +long + max + + + +InitN + + + 0 : ]]> + = min : ]]> + + + +MoreN + + + + NN : ]]> + + + +NextN + + + + + 15/6/2004 - 10:28:51 + 15/6/2004 - 10:28:51 + 2.0 + ? + ? + InitN , MoreN , NextN + 20 + 302 + +? + ? + EndOfforN + 5 + forN + +EndInitN + + +long + N + +long + K + +objref + SyrComponent + +long + min + +long + max + + +long + N + +long + K + +objref + SyrComponent + +long + min + +long + max + + + +? + + 15/6/2004 - 10:28:51 + 15/6/2004 - 10:28:51 + 2.0 + ? + ? + ? + 1535 + 332 + +? + ? + whileNotOne + 4 + EndOfwhileNotOne + +InitNotOne + + +objref + SyrComponent + +long + N + +long + K + + +objref + SyrComponent + +long + N + +long + K + + + +InitNotOne + + + + + +MoreNotOne + + + + + +NextNotOne + + + + 15/6/2004 - 10:28:52 + 15/6/2004 - 10:28:52 + 2.0 + ? + ? + InitNotOne , MoreNotOne , NextNotOne + 212 + 274 + +? + ? + EndOfwhileNotOne + 5 + whileNotOne + +EndInitNotOne + + +objref + SyrComponent + +long + N + +long + K + + +objref + SyrComponent + +long + N + +long + K + + + +? + + 15/6/2004 - 10:28:52 + 15/6/2004 - 10:28:52 + 2.0 + ? + ? + ? + 1366 + 303 + +? + ? + fori + 4 + EndOffori + +Initfori + + +long + i + +long + K + + +long + i + +long + K + + + +Initfori + + + +Morefori + + + ii :]]> + + + +Nextfori + + + + 15/6/2004 - 10:28:52 + 15/6/2004 - 10:28:52 + 2.0 + ? + ? + Initfori, Morefori, Nextfori + 635 + 212 + +? + ? + EndOffori + 5 + fori + +EndInitfori + + +long + i + +long + K + + +long + i + +long + K + + + +? + + 15/6/2004 - 10:28:52 + 15/6/2004 - 10:28:52 + 2.0 + ? + ? + ? + 976 + 212 + +? + ? + whileEven + 4 + EndOfwhileEven + +InitEven + + +objref + SyrComponent + +long + N + +long + K + + +objref + SyrComponent + +long + N + +long + K + + + +InitEven + + + + +MoreEven + + + + + +NextEven + + + + 15/6/2004 - 10:28:52 + 15/6/2004 - 10:28:52 + 2.0 + ? + ? + InitEven, MoreEven, NextEven + 632 + 451 + +? + ? + EndOfwhileEven + 5 + whileEven + +EndInitEven + + +objref + SyrComponent + +long + N + +long + K + + +objref + SyrComponent + +long + N + +long + K + + + +? + + 15/6/2004 - 10:28:52 + 15/6/2004 - 10:28:52 + 2.0 + ? + ? + ? + 988 + 451 + +? + ? + ifNotEven + 6 + EndOfifNotEven + +ifNotEven + + +objref + SyrComponent + +long + N + +long + K + + +long + Odd + +long + Even + +objref + SyrComponent + +long + N + +long + K + + + +ifNotEven + + + + + + 15/6/2004 - 10:28:52 + 15/6/2004 - 10:28:52 + 2.0 + ? + ? + ifNotEven + 418 + 274 + +? + ? + EndOfifNotEven + 7 + ifNotEven + +EndifNotEven + + +long + N + +long + K + + +long + N + +long + K + + + +? + + 15/6/2004 - 10:28:52 + 15/6/2004 - 10:28:52 + 2.0 + ? + ? + ? + 1205 + 331 + + +m3 + anInteger + m3incr + aCount + + +m3incr + aNewCount + EndOfifNotEven + N + + +1190 + 366 + +1191 + 109 + +incra + aNewCount + EndOffori + K + + +div2 + anInteger + EndOfwhileEven + N + + +incrb + aNewCount + EndOfwhileEven + K + + +988 + 543 + +988 + 654 + +SyrComponent + SyrComponentobjref + forN + SyrComponent + + +13 + 394 + +12 + 181 + +196 + 181 + +197 + 81 + +forN + DoLoop + EndOfforN + DoLoop + + +forN + N + whileNotOne + N + + +forN + N + EndOfforN + N + + +forN + K + whileNotOne + K + + +forN + SyrComponent + EndOfforN + SyrComponent + + +forN + SyrComponent + whileNotOne + SyrComponent + + +192 + 309 + +191 + 394 + +forN + min + EndOfforN + min + + +forN + max + EndOfforN + max + + +EndOfforN + DoLoop + forN + InitLoop + + +whileNotOne + DoLoop + EndOfwhileNotOne + DoLoop + + +whileNotOne + SyrComponent + EndOfwhileNotOne + SyrComponent + + +whileNotOne + SyrComponent + ifNotEven + SyrComponent + + +whileNotOne + N + ifNotEven + N + + +whileNotOne + K + ifNotEven + K + + +EndOfwhileNotOne + DoLoop + whileNotOne + InitLoop + + +EndOfwhileNotOne + K + EndOfforN + K + + +fori + DoLoop + EndOffori + DoLoop + + +fori + i + EndOffori + i + + +fori + K + incra + aCount + + +EndOffori + DoLoop + fori + InitLoop + + +EndOffori + K + EndOfifNotEven + K + + +1170 + 396 + +1169 + 275 + +whileEven + DoLoop + EndOfwhileEven + DoLoop + + +whileEven + SyrComponent + EndOfwhileEven + SyrComponent + + +whileEven + N + div2 + anEvenInteger + + +whileEven + K + incrb + aCount + + +796 + 655 + +795 + 543 + +EndOfwhileEven + DoLoop + whileEven + InitLoop + + +EndOfwhileEven + N + EndOfifNotEven + N + + +1191 + 366 + +1191 + 513 + +EndOfwhileEven + K + EndOfifNotEven + K + + +1169 + 395 + +1170 + 543 + +ifNotEven + Odd + m3 + Gate + + +593 + 141 + +593 + 307 + +ifNotEven + Odd + fori + Gate + + +ifNotEven + Even + whileEven + Gate + + +593 + 576 + +592 + 339 + +ifNotEven + SyrComponent + whileEven + SyrComponent + + +586 + 486 + +587 + 367 + +ifNotEven + N + whileEven + N + + +604 + 513 + +603 + 397 + +ifNotEven + N + m3 + anOddInteger + + +604 + 107 + +604 + 395 + +ifNotEven + K + whileEven + K + + +621 + 544 + +622 + 426 + +ifNotEven + K + fori + K + + +622 + 275 + +622 + 426 + +ifNotEven + Default + EndOfifNotEven + Default + + +1204 + 429 + +1203 + 12 + +581 + 13 + +581 + 458 + +EndOfifNotEven + N + EndOfwhileNotOne + N + + +EndOfifNotEven + K + EndOfwhileNotOne + K + + + + + +? + ? + SyrStruct_1_1 + 1 + ? + +SyrStruct_1_1 + + +string + SyrComponent__aContainer + +string + SyrComponent__aComponent + +long + forN__N + +long + forN__K + +long + forN__min + +long + forN__max + +long + fori__i + + +long + EndOfforN__N + +long + EndOfforN__K + +objref + EndOfforN__SyrComponent + +long + EndOfforN__min + +long + EndOfforN__max + +objref + EndOfwhileNotOne__SyrComponent + +long + EndOfwhileNotOne__N + +long + EndOffori__i + +objref + EndOfwhileEven__SyrComponent + + + 15/6/2004 - 10:28:52 + 15/6/2004 - 10:28:54 + 2.0 + JR + ? + Syracuse algorithm + 0 + 0 + + +SyrComponent + SyrComponent + m3 + 0 + ? + +C_M3 + + +long + anOddInteger + + +long + anInteger + + + 15/6/2004 - 10:28:53 + 15/6/2004 - 10:28:53 + 2.0 + ? + localhost/FactoryServer + C_M3 from SyrComponent + 672 + 28 + +SyrComponent + SyrComponent + m3incr + 0 + ? + +C_INCR + + +long + aCount + + +long + aNewCount + + + 15/6/2004 - 10:28:53 + 15/6/2004 - 10:28:53 + 2.0 + ? + localhost/FactoryServer + C_INCR from SyrComponent + 898 + 29 + +SyrComponent + SyrComponent + incra + 0 + ? + +C_INCR + + +long + aCount + + +long + aNewCount + + + 15/6/2004 - 10:28:53 + 15/6/2004 - 10:28:53 + 2.0 + ? + localhost/FactoryServer + C_INCR from SyrComponent + 803 + 195 + +SyrComponent + SyrComponent + div2 + 0 + ? + +C_DIV2 + + +long + anEvenInteger + + +long + anInteger + + + 15/6/2004 - 10:28:53 + 15/6/2004 - 10:28:53 + 2.0 + ? + localhost/FactoryServer + C_DIV2 from SyrComponent + 810 + 435 + +SyrComponent + SyrComponent + incrb + 0 + ? + +C_INCR + + +long + aCount + + +long + aNewCount + + + 15/6/2004 - 10:28:53 + 15/6/2004 - 10:28:53 + 2.0 + ? + localhost/FactoryServer + C_INCR from SyrComponent + 809 + 574 + +? + ? + SyrComponent + 3 + ? + +SyrComponent + + +string + aContainer + +string + aComponent + + +objref + SyrComponentobjref + + + +SyrComponent + + + + + + + 15/6/2004 - 10:28:53 + 15/6/2004 - 10:28:53 + 2.0 + ? + ? + SyrComponent( aContainer , aComponent ) + 0 + 0 + +? + ? + forN + 4 + EndOfforN + +InitN + + +long + N + +long + K + +objref + SyrComponent + +long + min + +long + max + + +long + N + +long + K + +objref + SyrComponent + +long + min + +long + max + + + +InitN + + + 0 : ]]> + = min : ]]> + + + +MoreN + + + + NN : ]]> + + + +NextN + + + + + 15/6/2004 - 10:28:53 + 15/6/2004 - 10:28:53 + 2.0 + ? + ? + InitN , MoreN , NextN + 20 + 302 + +? + ? + EndOfforN + 5 + forN + +EndInitN + + +long + N + +long + K + +objref + SyrComponent + +long + min + +long + max + + +long + N + +long + K + +objref + SyrComponent + +long + min + +long + max + + + +? + + 15/6/2004 - 10:28:53 + 15/6/2004 - 10:28:53 + 2.0 + ? + ? + ? + 1535 + 332 + +? + ? + whileNotOne + 4 + EndOfwhileNotOne + +InitNotOne + + +objref + SyrComponent + +long + N + +long + K + + +objref + SyrComponent + +long + N + +long + K + + + +InitNotOne + + + + + +MoreNotOne + + + + + +NextNotOne + + + + 15/6/2004 - 10:28:53 + 15/6/2004 - 10:28:53 + 2.0 + ? + ? + InitNotOne , MoreNotOne , NextNotOne + 212 + 274 + +? + ? + EndOfwhileNotOne + 5 + whileNotOne + +EndInitNotOne + + +objref + SyrComponent + +long + N + +long + K + + +objref + SyrComponent + +long + N + +long + K + + + +? + + 15/6/2004 - 10:28:53 + 15/6/2004 - 10:28:53 + 2.0 + ? + ? + ? + 1366 + 303 + +? + ? + fori + 4 + EndOffori + +Initfori + + +long + i + +long + K + + +long + i + +long + K + + + +Initfori + + + +Morefori + + + ii :]]> + + + +Nextfori + + + + 15/6/2004 - 10:28:53 + 15/6/2004 - 10:28:53 + 2.0 + ? + ? + Initfori, Morefori, Nextfori + 635 + 212 + +? + ? + EndOffori + 5 + fori + +EndInitfori + + +long + i + +long + K + + +long + i + +long + K + + + +? + + 15/6/2004 - 10:28:53 + 15/6/2004 - 10:28:53 + 2.0 + ? + ? + ? + 976 + 212 + +? + ? + whileEven + 4 + EndOfwhileEven + +InitEven + + +objref + SyrComponent + +long + N + +long + K + + +objref + SyrComponent + +long + N + +long + K + + + +InitEven + + + + +MoreEven + + + + + +NextEven + + + + 15/6/2004 - 10:28:53 + 15/6/2004 - 10:28:53 + 2.0 + ? + ? + InitEven, MoreEven, NextEven + 632 + 451 + +? + ? + EndOfwhileEven + 5 + whileEven + +EndInitEven + + +objref + SyrComponent + +long + N + +long + K + + +objref + SyrComponent + +long + N + +long + K + + + +? + + 15/6/2004 - 10:28:53 + 15/6/2004 - 10:28:53 + 2.0 + ? + ? + ? + 988 + 451 + +? + ? + ifNotEven + 6 + EndOfifNotEven + +ifNotEven + + +objref + SyrComponent + +long + N + +long + K + + +long + Odd + +long + Even + +objref + SyrComponent + +long + N + +long + K + + + +ifNotEven + + + + + + 15/6/2004 - 10:28:54 + 15/6/2004 - 10:28:54 + 2.0 + ? + ? + ifNotEven + 418 + 274 + +? + ? + EndOfifNotEven + 7 + ifNotEven + +EndifNotEven + + +long + N + +long + K + + +long + N + +long + K + + + +? + + 15/6/2004 - 10:28:54 + 15/6/2004 - 10:28:54 + 2.0 + ? + ? + ? + 1205 + 331 + + +m3 + anInteger + m3incr + aCount + + +m3incr + aNewCount + EndOfifNotEven + N + + +1190 + 366 + +1191 + 109 + +incra + aNewCount + EndOffori + K + + +div2 + anInteger + EndOfwhileEven + N + + +incrb + aNewCount + EndOfwhileEven + K + + +988 + 543 + +988 + 654 + +SyrComponent + SyrComponentobjref + forN + SyrComponent + + +13 + 394 + +12 + 181 + +196 + 181 + +197 + 81 + +forN + DoLoop + EndOfforN + DoLoop + + +forN + N + whileNotOne + N + + +forN + N + EndOfforN + N + + +forN + K + whileNotOne + K + + +forN + SyrComponent + EndOfforN + SyrComponent + + +forN + SyrComponent + whileNotOne + SyrComponent + + +192 + 309 + +191 + 394 + +forN + min + EndOfforN + min + + +forN + max + EndOfforN + max + + +EndOfforN + DoLoop + forN + InitLoop + + +whileNotOne + DoLoop + EndOfwhileNotOne + DoLoop + + +whileNotOne + SyrComponent + EndOfwhileNotOne + SyrComponent + + +whileNotOne + SyrComponent + ifNotEven + SyrComponent + + +whileNotOne + N + ifNotEven + N + + +whileNotOne + K + ifNotEven + K + + +EndOfwhileNotOne + DoLoop + whileNotOne + InitLoop + + +EndOfwhileNotOne + K + EndOfforN + K + + +fori + DoLoop + EndOffori + DoLoop + + +fori + i + EndOffori + i + + +fori + K + incra + aCount + + +EndOffori + DoLoop + fori + InitLoop + + +EndOffori + K + EndOfifNotEven + K + + +1170 + 396 + +1169 + 275 + +whileEven + DoLoop + EndOfwhileEven + DoLoop + + +whileEven + SyrComponent + EndOfwhileEven + SyrComponent + + +whileEven + N + div2 + anEvenInteger + + +whileEven + K + incrb + aCount + + +796 + 655 + +795 + 543 + +EndOfwhileEven + DoLoop + whileEven + InitLoop + + +EndOfwhileEven + N + EndOfifNotEven + N + + +1191 + 366 + +1191 + 513 + +EndOfwhileEven + K + EndOfifNotEven + K + + +1169 + 395 + +1170 + 543 + +ifNotEven + Odd + m3 + Gate + + +593 + 141 + +593 + 307 + +ifNotEven + Odd + fori + Gate + + +ifNotEven + Even + whileEven + Gate + + +593 + 576 + +592 + 339 + +ifNotEven + SyrComponent + whileEven + SyrComponent + + +586 + 486 + +587 + 367 + +ifNotEven + N + whileEven + N + + +604 + 513 + +603 + 397 + +ifNotEven + N + m3 + anOddInteger + + +604 + 107 + +604 + 395 + +ifNotEven + K + whileEven + K + + +621 + 544 + +622 + 426 + +ifNotEven + K + fori + K + + +622 + 275 + +622 + 426 + +ifNotEven + Default + EndOfifNotEven + Default + + +1204 + 429 + +1203 + 12 + +581 + 13 + +581 + 458 + +EndOfifNotEven + N + EndOfwhileNotOne + N + + +EndOfifNotEven + K + EndOfwhileNotOne + K + + diff --git a/examples/GraphTestMacroNodes.py b/examples/GraphTestMacroNodes.py new file mode 100644 index 0000000..ef35ea0 --- /dev/null +++ b/examples/GraphTestMacroNodes.py @@ -0,0 +1,309 @@ + +from SuperV import * + +GraphMacroNodes = Graph( '/home/Salome2/Ecole_Ete_a6/SUPERV_install/examples/GraphEssai.xml' ) + +GraphMacroNodes.PrintLinks() + +GraphMacroNodes.SetName('GraphMacroNodes') + +Macro_SyrStruct = GraphMacroNodes.MNode( '/home/Salome2/Ecole_Ete_a6/SUPERV_install/examples/SyrStruct.xml' ) + +Macro_SyrStruct.PrintPorts() + +GraphMacroNodes.PrintPorts() + +GraphMacroNodes.PrintLinks() + +GraphMacroNodes.Print() + +Macro_SyrStruct.Print() + +exec GraphMacroNodes.ListNodes('GraphMacroNodes') + +Macro_SyrStruct.Print() + +Macro_SyrStruct.IsMacro() +Macro_SyrStruct.IsFlowMacro() +Macro_SyrStruct.IsStreamMacro() + +SyrStruct = Macro_SyrStruct.FlowObjRef() + +SyrStruct.Print() + +SyrStruct.PrintPorts() + +SyrStruct.PrintLinks() + +SyrStruct.IsValid() +SyrStruct.IsExecutable() + +exec SyrStruct.ListNodes('SyrStruct') + +m3incr.Print() + +m3incr.PrintPorts() + +m3incr.PrintLinks() + +EndOffori.Print() + +EndOffori.PrintPorts() + +EndOffori.PrintLinks() + +EndOfwhileEven.Print() + +EndOfwhileEven.PrintPorts() + +EndOfwhileEven.PrintLinks() + +MSyrStruct = SyrStruct.FlowObjRef() + +MSyrStruct.Print() + +MSyrStruct.PrintPorts() + +GraphMacroNodes.IsValid() +GraphMacroNodes.IsExecutable() + +GraphMacroNodes.PrintPorts() + +Macro_SyrStruct_1 = GraphMacroNodes.MNode( '/home/Salome2/Ecole_Ete_a6/SUPERV_install/examples/SyrStruct.xml' ) + +Macro_SyrStruct_1.Print() + +Macro_SyrStruct_1.IsMacro() +Macro_SyrStruct_1.IsFlowMacro() +Macro_SyrStruct_1.IsStreamMacro() + +SyrStruct_1 = Macro_SyrStruct_1.FlowObjRef() + +SyrStruct_1.Print() + +GraphMacroNodes.IsValid() +GraphMacroNodes.IsExecutable() + +GraphMacroNodes.PrintPorts() + +MSyrStruct_1 = SyrStruct_1.FlowObjRef() + +MSyrStruct_1.Print() + +MSyrStruct_1.PrintPorts() + + + +GraphMacroNodes.Export( '/home/Salome2/Ecole_Ete_a6/SUPERV_build/examples/GraphMacroNodes.xml' ) + +SyrStruct.Name() +SyrStruct_1.Name() + +GraphMacroNodes.Run() + +GraphMacroNodes.DoneW() + +GraphMacroNodes.State() + +Macro_SyrStruct.State() + +Macro_SyrStruct_1.State() + + + + + +from SuperV import * + +GraphMacroNodes = Graph( '/home/Salome2/Ecole_Ete_a6/SUPERV_build/examples/GraphMacroNodes.xml' ) + +GraphMacroNodes.Name() + +GraphMacroNodes.Export( '/tmp/GraphMacroNodes.xml' ) + +exec GraphMacroNodes.ListNodes('GraphMacroNodes') + +GraphMacroNodes.PrintPorts() + +GraphMacroNodes.PrintLinks() + +Macro_SyrStruct.IsMacro() +Macro_SyrStruct.IsFlowMacro() +Macro_SyrStruct.IsStreamMacro() + +Macro_SyrStruct.Print() + +SyrStruct = Macro_SyrStruct.FlowObjRef() + +SyrStruct.Print() + +SyrStruct.PrintPorts() + +SyrStruct.PrintLinks() + +exec SyrStruct.ListNodes('SyrStruct') + +Macro_SyrStruct.IsMacro() +Macro_SyrStruct.IsFlowMacro() +Macro_SyrStruct.IsStreamMacro() + +Macro_SyrStruct.IsValid() + +Macro_SyrStruct.IsExecutable() + +Macro_SyrStruct_1.Print() + +SyrStruct_1 = Macro_SyrStruct_1.FlowObjRef() + +SyrStruct_1.Print() + +SyrStruct_1.PrintPorts() + +SyrStruct_1.PrintLinks() + +exec SyrStruct_1.ListNodes('SyrStruct_1') + +MSyrStruct = SyrStruct.FlowObjRef() + +MSyrStruct.Print() + +MSyrStruct_1 = SyrStruct_1.FlowObjRef() + +MSyrStruct_1.Print() + +GraphMacroNodes.Run() + +GraphMacroNodes.DoneW() + +GraphMacroNodes.State() + +Macro_SyrStruct.State() + +Macro_SyrStruct_1.State() + + + + +from SuperV import * + +from GraphMacroNodes import * + +GraphMacroNodes.IsExecutable() + +GraphMacroNodes.Run() + +exec GraphMacroNodes.ListNodes('GraphMacroNodes') + +SyrStruct = Macro_SyrStruct.FlowObjRef() + +SyrStruct.IsExecutable() + +GraphMacroNodes.DoneW() + +GraphMacroNodes.State() + +Macro_SyrStruct.State() + +Macro_SyrStruct_1.State() + +SyrStruct = Macro_SyrStruct.FlowObjRef() + +exec SyrStruct.ListNodes('SyrStruct') + +EndOfforN.State() + +SyrStruct.DoneW() + +SyrStruct.State() + +SyrStruct_1 = Macro_SyrStruct_1.FlowObjRef() + +exec SyrStruct_1.ListNodes('SyrStruct') + +EndOfforN.State() + +SyrStruct_1.DoneW() + +SyrStruct_1.State() + +SyrStruct.PrintPorts() + +Macro_SyrStruct.PrintPorts() + +GraphMacroNodes.PrintPorts() + +GraphMacroNodes.Run() + +GraphMacroNodes.DoneW() + +GraphMacroNodes.State() + +Macro_SyrStruct.State() + +Macro_SyrStruct_1.State() + + + + +SyrStruct.Export('/tmp/SubSyrStruct.xml') + + +SubSyrStruct = Graph('/tmp/SubSyrStruct.xml') + +SubSyrStruct.IsValid() + +SubSyrStruct.IsExecutable() + +SubSyrStruct.Run() + +SubSyrStruct.DoneW() + +SubSyrStruct.State() + +SubSyrStruct.PrintPorts() + + + + + +from SuperV import * + +from GraphMacroNodes import * + +exec GraphMacroNodes.ListNodes('GraphMacroNodes') + +SyrStruct = Macro_SyrStruct.FlowObjRef() + +exec SyrStruct.ListNodes('SyrStruct') + +Unused = SyrComponent.InPort('Unused','long') + +SyrComponent.PrintPorts() + +SyrComponent.Print() + +SyrStruct.IsValid() + +SyrStruct.PrintPorts() + +Macro_SyrStruct.PrintPorts() + +GraphMacroNodes.PrintPorts() + +Unused.Destroy() + +GraphMacroNodes.PrintPorts() + +Macro_SyrStruct.PrintPorts() + +SyrStruct.PrintPorts() + +GraphMacroNodes.Run() + +GraphMacroNodes.DoneW() + +GraphMacroNodes.State() + +Macro_SyrStruct.State() + +Macro_SyrStruct_1.State() diff --git a/examples/MacroWithGeom.xml b/examples/MacroWithGeom.xml new file mode 100755 index 0000000..ff3ad12 --- /dev/null +++ b/examples/MacroWithGeom.xml @@ -0,0 +1,639 @@ + + + + + +? + ? + GeomGraph_3 + 1 + ? + +GeomGraph_3 + + +double + MakeBox__x1 + +double + MakeBox__y1 + +double + MakeBox__z1 + +double + MakeBox__x2 + +double + MakeBox__y2 + +double + MakeBox__z2 + +double + MakeTranslation__x1 + +double + MakeTranslation__z1 + +double + MakeSphere__x1 + +double + MakeSphere__y1 + +double + MakeSphere__z1 + +double + MakeSphere__radius + +long + Macro_aNewDataFlow_1_5_1__sum__a + +long + Macro_aNewDataFlow_1_5_1__sum__b + + +GEOM_Shape + MakeFuse_1__shape + + + 13/3/2003 - 11:46:34 + 2/7/2004 - 11:13:17 + 1.04 + ? + ? + ? + 0 + 0 + + +GEOM + GEOM + MakeBox + 0 + ? + +MakeBox + + +double + x1 + +double + y1 + +double + z1 + +double + x2 + +double + y2 + +double + z2 + + +GEOM_Shape + shape + + + 2/7/2004 - 11:10:39 + 2/7/2004 - 11:10:39 + 1.04 + ? + localhost/FactoryServer + MakeBox from Geometry + 5 + 101 + +GEOM + GEOM + MakeCopy + 0 + ? + +MakeCopy + + +GEOM_Shape + shape1 + + +GEOM_Shape + shape + + + 2/7/2004 - 11:10:39 + 2/7/2004 - 11:10:39 + 1.04 + ? + localhost/FactoryServer + MakeCopy from Geometry + 235 + 77 + +GEOM + GEOM + MakeCopy_1 + 0 + ? + +MakeCopy + + +GEOM_Shape + shape1 + + +GEOM_Shape + shape + + + 2/7/2004 - 11:10:39 + 2/7/2004 - 11:10:39 + 1.04 + ? + localhost/FactoryServer + MakeCopy from Geometry + 249 + 371 + +GEOM + GEOM + MakeTranslation + 0 + ? + +MakeTranslation + + +GEOM_Shape + shape1 + +double + x1 + +double + y1 + +double + z1 + + +GEOM_Shape + shape + + + 2/7/2004 - 11:10:39 + 2/7/2004 - 11:10:39 + 1.04 + ? + localhost/FactoryServer + MakeTranslation from Geometry + 449 + 86 + +GEOM + GEOM + MakeFuse + 0 + ? + +MakeFuse + + +GEOM_Shape + shape1 + +GEOM_Shape + shape2 + + +GEOM_Shape + shape + + + 2/7/2004 - 11:10:39 + 2/7/2004 - 11:10:39 + 1.04 + ? + localhost/FactoryServer + MakeFuse from Geometry + 678 + 224 + +GEOM + GEOM + MakeFuse_1 + 0 + ? + +MakeFuse + + +GEOM_Shape + shape1 + +GEOM_Shape + shape2 + + +GEOM_Shape + shape + + + 2/7/2004 - 11:10:39 + 2/7/2004 - 11:10:39 + 1.04 + ? + localhost/FactoryServer + MakeFuse from Geometry + 909 + 340 + +GEOM + GEOM + MakeSphere + 0 + ? + +MakeSphere + + +double + x1 + +double + y1 + +double + z1 + +double + radius + + +GEOM_Shape + shape + + + 2/7/2004 - 11:10:39 + 2/7/2004 - 11:10:39 + 1.04 + ? + localhost/FactoryServer + MakeSphere from Geometry + 5 + 449 + +? + ? + Macro_aNewDataFlow_1_5_1 + 10 + aNewDataFlow_1_5_1 + +aNewDataFlow_1_5_1 + + +long + sum__a + +long + sum__b + + +int + Mult__b + + + +? + + 2/7/2004 - 11:11:42 + 2/7/2004 - 11:11:42 + 2.0 + ? + ? + Macro Node + 237 + 215 + + +MakeBox + shape + MakeCopy + shape1 + + +198 + 184 + +199 + 209 + +MakeBox + shape + MakeCopy_1 + shape1 + + +198 + 441 + +198 + 209 + +MakeCopy + shape + MakeTranslation + shape1 + + +MakeCopy_1 + shape + MakeFuse + shape2 + + +642 + 362 + +642 + 442 + +MakeTranslation + shape + MakeFuse + shape1 + + +643 + 330 + +644 + 195 + +MakeFuse + shape + MakeFuse_1 + shape1 + + +872 + 445 + +874 + 333 + +MakeSphere + shape + MakeFuse_1 + shape2 + + +872 + 474 + +871 + 552 + +Macro_aNewDataFlow_1_5_1 + Mult__b + MakeTranslation + y1 + + + +GeomGraph_3 + MakeBox__x1 + MakeBox + x1 + +7 + 0 + + +GeomGraph_3 + MakeBox__y1 + MakeBox + y1 + +7 + 0 + + +GeomGraph_3 + MakeBox__z1 + MakeBox + z1 + +7 + 0 + + +GeomGraph_3 + MakeBox__x2 + MakeBox + x2 + +7 + 50 + + +GeomGraph_3 + MakeBox__y2 + MakeBox + y2 + +7 + 50 + + +GeomGraph_3 + MakeBox__z2 + MakeBox + z2 + +7 + 50 + + +GeomGraph_3 + MakeTranslation__x1 + MakeTranslation + x1 + +7 + 25 + + +GeomGraph_3 + MakeTranslation__z1 + MakeTranslation + z1 + +7 + 25 + + +GeomGraph_3 + MakeSphere__x1 + MakeSphere + x1 + +7 + 0 + + +GeomGraph_3 + MakeSphere__y1 + MakeSphere + y1 + +7 + 0 + + +GeomGraph_3 + MakeSphere__z1 + MakeSphere + z1 + +7 + 0 + + +GeomGraph_3 + MakeSphere__radius + MakeSphere + radius + +7 + 12 + + +GeomGraph_3 + Macro_aNewDataFlow_1_5_1__sum__a + Macro_aNewDataFlow_1_5_1 + sum__a + +3 + 3 + + +GeomGraph_3 + Macro_aNewDataFlow_1_5_1__sum__b + Macro_aNewDataFlow_1_5_1 + sum__b + +3 + 7 + + + + +? + ? + aNewDataFlow_1_5_1 + 1 + ? + +aNewDataFlow_1_5_1 + + +long + sum__a + +long + sum__b + + +int + Mult__b + + + 25/6/2004 - 17:42:12 + 2/7/2004 - 11:11:42 + 2.0 + ? + ? + ? + 0 + 0 + + +? + ? + sum + 3 + ? + +sum + + +long + a + +long + b + + +long + s + + + +sum + + + 2/7/2004 - 11:11:42 + 2/7/2004 - 11:11:42 + 2.0 + ? + ? + Compute Node + 52 + 80 + +? + ? + Mult + 3 + ? + +Mult + + +int + a + + +int + b + + + +Mult + + + + 2/7/2004 - 11:11:42 + 2/7/2004 - 11:11:42 + 2.0 + ? + ? + Compute Node + 298 + 72 + + +sum + s + Mult + a + + diff --git a/idl/SUPERV.idl b/idl/SUPERV.idl index 4d3f195..59157a4 100644 --- a/idl/SUPERV.idl +++ b/idl/SUPERV.idl @@ -77,7 +77,7 @@ This enumeration contains a set of elements defining the type of the node. enum KindOfNode { FactoryNode , DataFlowGraph , ComputingNode , InLineNode , LoopNode , EndLoopNode , SwitchNode , EndSwitchNode , GOTONode , DataStreamGraph , - UnknownNode }; + MacroNode ,UnknownNode }; /*! This struct contains fields defining the date. @@ -142,8 +142,8 @@ This enumeration contains a set of elements defining the current state of the no interface ELNode ; interface SNode ; interface ESNode ; - interface StreamGraph ; interface Graph ; + interface StreamGraph ; typedef sequence ListOfCNodes ; typedef sequence ListOfFNodes ; @@ -153,7 +153,7 @@ This enumeration contains a set of elements defining the current state of the no typedef sequence ListOfELNodes ; typedef sequence ListOfSNodes ; typedef sequence ListOfESNodes ; - typedef sequence ListOfGraphs ; + typedef sequence ListOfGraphs ; /*! This struct contains fields defining different types of nodes. @@ -185,46 +185,6 @@ the user (Suspend, SuspendDone, Kill, etc...). ToSuspendState , ToSuspendDoneState , ToKillState , ToKillDoneState , ToStopState , NumberOfControlStates } ; -/*! -The AutomatonState is an internal state of the automaton of the Executor -of the %Supervision %Engine. It is used for inner debugging purposes only. -*/ - - enum AutomatonState { UnKnownState , - DataUndefState , - DataWaitingState , - DataReadyState , - SuspendedReadyState, - SuspendedReadyToResumeState , - ResumedReadyState , - KilledReadyState , - StoppedReadyState , - ExecutingState , - SuspendedExecutingState , - ResumedExecutingState , - KilledExecutingState , - StoppedExecutingState , - SuccessedExecutingState , - ErroredExecutingState , - SuspendedSuccessedState , - SuspendedErroredState, - ResumedSuccessedState , - ResumedErroredState , - KilledSuccessedState , - KilledErroredState , - StoppedSuccessedState , - StoppedErroredState , - SuccessedState , - ErroredState , - SuspendedState , - KilledState , - StoppedState , - SuspendedSuccessedToReStartState , - SuspendedErroredToReStartState , - ReRunnedState , - ReStartedState , - NumberOfAutomatonStates - } ; @@ -386,6 +346,11 @@ Allows to update the comments about this node(graph). */ SUPERV::StreamPort GetOutStreamPort( in string aParameterName ) ; +/*! + Returns true if a Node (or Graph) has StreamPorts +*/ + boolean HasStreamPort() ; + /*! Enters a value into an Input %Port */ @@ -412,14 +377,35 @@ Allows to update the comments about this node(graph). /*! Returns True if this node is a graph. -\note
A node of the graph can also represent in its turn another graph. */ boolean IsStreamGraph() ; /*! Returns True if this node is a graph. -\note
A node of the graph can also represent in its turn another graph. */ boolean IsGraph() ; + +/*! +Returns True if this node is a MacroNode of a DataFlowGraph or a DataStreamGraph. +*/ + boolean IsMacro() ; +/*! +Returns True if this node is a MacroNode of a DataFlowGraph. +*/ + boolean IsFlowMacro() ; +/*! +Returns True if this node is a MacroNode of a DataStreamGraph. +*/ + boolean IsStreamMacro() ; + +/*! +Returns True if this node is a Head Graph . +*/ + boolean IsHeadGraph() ; +/*! +Returns the MacroNode Level of this node. +*/ + long GraphLevel() ; + /*! Returns True if the node appears to be a %computing node. */ @@ -571,11 +557,6 @@ Restarts and suspends execution of the graph beginning from a definite node. */ boolean ReStartAt( in string aNodeName ); -/*! - Returns automaton execution state of the node(graph). -*/ - SUPERV::AutomatonState AutoState() ; - // Control state required : Kill, Suspend, Stop /*! Returns control state of the node(graph). @@ -770,7 +751,7 @@ This interface includes a set of methods used for management of the graphs in %S */ /////////////// - interface Graph : INode { + interface Graph : GNode { /////////////// /*! Creates a Computing Node in a Graph. @@ -804,6 +785,22 @@ This interface includes a set of methods used for management of the graphs in %S SUPERV::SNode SNode( in string FuncName , in ListOfStrings aPythonFunction , out SUPERV::INode anEndOfSwitch ) ; + /*! Creates a "MacroNode" node which corresponds to a Graph with a xml file + */ + SUPERV::Graph MNode( in string aXmlFileName ) ; + + /*! Creates a "MacroNode" node which corresponds to a Graph with a Graph + */ + SUPERV::Graph GraphMNode( in Graph aGraph ) ; + + /*! Returns a Graph of a "MacroNode" or a "MacroNode" of a Graph + */ + SUPERV::Graph FlowObjRef() ; + + /*! Returns a StreamGraph of a "MacroNode" or a "MacroNode" of a StreamGraph + */ + SUPERV::StreamGraph StreamObjRef() ; + /*! Returns an existing node with a definite name. \param aNodeName Name of the Node. */ @@ -975,6 +972,14 @@ This interface includes a set of methods used for management of the graphs in %S Allows to copy one graph into another. */ SUPERV::StreamGraph StreamCopy() ; + /*! Creates a "MacroNode" node which corresponds to a StreamGraph with a xml file + */ + SUPERV::StreamGraph StreamMNode( in string aXmlFileName ) ; + + /*! Creates a "MacroNode" node which corresponds to a StreamGraph with a Graph + */ + SUPERV::StreamGraph StreamGraphMNode( in StreamGraph aStreamGraph ) ; + /*! Creates a link connecting two ports (%Output %Port and %Input %Port) of the nodes in a Graph */ @@ -1247,6 +1252,10 @@ Returns True if the %Port appears to be an EndSwitch Node connected to several o */ boolean IsDone() ; +/*! deactivate the objref of a Port when its node is destroyed +*/ + void Remove() ; + } ; //////////////////// diff --git a/resources/config b/resources/config deleted file mode 100644 index 6925397..0000000 --- a/resources/config +++ /dev/null @@ -1 +0,0 @@ -language=en \ No newline at end of file diff --git a/src/GraphBase/DataFlowBase_Base.hxx b/src/GraphBase/DataFlowBase_Base.hxx index 905fd01..ebd1646 100644 --- a/src/GraphBase/DataFlowBase_Base.hxx +++ b/src/GraphBase/DataFlowBase_Base.hxx @@ -90,8 +90,9 @@ string DataStreamDependencyToString( const SALOME_ModuleCatalog::DataStreamDepen string DataStreamToString( const SALOME_ModuleCatalog::DataStreamType aDataStreamType ) ; -enum StatusOfPort { NotConnected , PortConnected , PortAndDataConnected , - DataConnected } ; +//enum StatusOfPort { NotConnected , PortConnected , PortAndDataConnected , +enum StatusOfPort { NotConnected , PortConnected , + DataConnected , ExternConnected } ; namespace GraphBase { @@ -149,7 +150,7 @@ namespace GraphBase { SCoord theCoords ; }; - typedef vector ListOfNodes; + typedef vector ListOfSNodes; struct ServicesData { SALOME_ModuleCatalog::ServicesParameter aDataParameter ; @@ -167,16 +168,16 @@ namespace GraphBase { ListOfCoords aListOfCoords ; }; - typedef vector ListOfLinks; + typedef vector ListOfSLinks; struct SGraph { SNode Info ; - ListOfNodes Nodes ; - ListOfLinks Links ; - ListOfLinks Datas ; + ListOfSNodes Nodes ; + ListOfSLinks Links ; + ListOfSLinks Datas ; }; - typedef vector ListOfGraphs; + typedef vector ListOfSGraphs; class Base { @@ -203,7 +204,7 @@ namespace GraphBase { // *GraphBase::Base::_fdebug << " " /*<< setw(3*(*GraphBase::Base::_prof_debug)) */<< " " -# define cdebug if ( GraphBase::Base::_fdebug ) *GraphBase::Base::_fdebug << " " << " " +# define cdebug if ( GraphBase::Base::_fdebug ) *GraphBase::Base::_fdebug << " " # define cdebug_in if ( GraphBase::Base::_fdebug ) *GraphBase::Base::_fdebug << endl << "-->" << " " diff --git a/src/GraphBase/DataFlowBase_ComputingNode.cxx b/src/GraphBase/DataFlowBase_ComputingNode.cxx index 4f04a80..1cce3b2 100644 --- a/src/GraphBase/DataFlowBase_ComputingNode.cxx +++ b/src/GraphBase/DataFlowBase_ComputingNode.cxx @@ -92,10 +92,12 @@ GraphBase::ComputingNode::ComputingNode() : GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB , SALOME_NamingService* ptrNamingService , const char * aDataFlowName , + const SUPERV::KindOfNode DataFlowkind , int * Graph_prof_debug , ofstream * Graph_fdebug ) : // GraphBase::PortsOfNode::PortsOfNode( aDataFlowName ) { - GraphBase::StreamNode::StreamNode( aDataFlowName ) { + GraphBase::StreamNode::StreamNode( aDataFlowName , DataFlowkind , + Graph_prof_debug , Graph_fdebug ) { // MESSAGE( "GraphBase::ComputingNode::ComputingNode " << aDataFlowName << " Graph_prof_debug " << Graph_prof_debug ) ; InitFields( //_Kind , @@ -113,7 +115,8 @@ GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB , //_LinkedNodesSize , //_SubGraphNumber ) ; - Kind( SUPERV::DataFlowGraph ) ; +// Kind( SUPERV::DataFlowGraph ) ; + Kind( DataFlowkind ) ; _ORB = CORBA::ORB::_duplicate( ORB ) ; _NamingService = ptrNamingService ; _Node = SUPERV::CNode::_nil() ; @@ -130,6 +133,7 @@ GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB , // else { // cout << "GraphBase::ComputingNode::ComputingNode NO SetDebug" << endl ; // } + DefPortsOfNode( ORB , SALOME_ModuleCatalog::Service() , NamePtr() , Kind() , Graph_prof_debug , Graph_fdebug ) ; cdebug << "GraphBase::ComputingNode::ComputingNode " << this << " Name '" << Name() << "' " << _FirstCreation << " " << _LastModification << endl ; @@ -151,7 +155,7 @@ GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB , int * Graph_prof_debug , ofstream * Graph_fdebug ) : // GraphBase::PortsOfNode::PortsOfNode() { - GraphBase::StreamNode::StreamNode( NodeName ) { + GraphBase::StreamNode::StreamNode( NodeName , akind , Graph_prof_debug , Graph_fdebug ) { _ORB = CORBA::ORB::_duplicate( ORB ) ; _NamingService = ptrNamingService ; @@ -304,15 +308,22 @@ void GraphBase::ComputingNode::NodePort( const char * 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 ] ) ; +// char * BPort = strchr( ServiceParameterName , '\\' ) ; + char * BPort = (char * ) ServiceParameterName ; + while ( ( BPort = strchr( BPort , '_' ) ) ) { + if ( BPort[1] == '_' ) { + int len = BPort - ServiceParameterName ; + *aNode = new char [ len + 1 ] ; + strncpy( *aNode , ServiceParameterName , len ) ; + (*aNode)[ len ] = '\0' ; + *aPort = my_strdup( &BPort[ 2 ] ) ; + break ; + } + else { + BPort = &BPort[2] ; + } } - else { + if ( BPort == NULL ) { *aNode = my_strdup( NULLSTRING ) ; *aPort = my_strdup( NULLSTRING ) ; } @@ -323,12 +334,12 @@ bool GraphBase::ComputingNode::IsLinked(const char * ToServiceParameterName ) { bool RetVal = false ; const GraphBase::InPort * thePort = GetInPort( ToServiceParameterName ) ; if ( thePort ) { - RetVal = thePort->IsConnected() ; + RetVal = thePort->IsPortConnected() ; } else { const GraphBase::OutPort * thePort = GetOutPort( ToServiceParameterName ) ; if ( thePort ) { - RetVal = thePort->IsConnected() ; + RetVal = thePort->IsPortConnected() ; } } return RetVal ; @@ -336,20 +347,23 @@ bool GraphBase::ComputingNode::IsLinked(const char * ToServiceParameterName ) { bool GraphBase::ComputingNode::HasInput(const char * ToServiceParameterName ) { bool RetVal = false ; - const GraphBase::InPort * thePort = GetInPort( ToServiceParameterName ) ; - if ( IsDataFlowNode() && thePort ) { + const GraphBase::InPort * theInPort = GetInPort( ToServiceParameterName ) ; +#if 0 + if ( IsDataFlowNode() && theInPort ) { RetVal = true ; } - else if ( thePort ) { -// cout << "GraphBase::ComputingNode::HasInput theInPort " << thePort << " " << thePort->PortName() << " of " -// << thePort->NodeName() << " IsDataConnected " << thePort->IsDataConnected() << " OutPort " -// << thePort->GetOutPort() << endl ; - RetVal = thePort->IsDataConnected() ; + else +#endif + if ( theInPort ) { +// cout << "GraphBase::ComputingNode::HasInput theInPort " << theInPort << " " << theInPort->PortName() << " of " +// << theInPort->NodeName() << " IsDataConnected " << theInPort->IsDataConnected() << " OutPort " +// << theInPort->GetOutPort() << endl ; + RetVal = theInPort->IsDataConnected() ; } else { - const GraphBase::OutPort * thePort = GetOutPort( ToServiceParameterName ) ; - if ( thePort ) { - RetVal = thePort->IsDataConnected() ; + const GraphBase::OutPort * theOutPort = GetOutPort( ToServiceParameterName ) ; + if ( theOutPort ) { + RetVal = theOutPort->IsDataConnected() ; } } return RetVal ; @@ -385,6 +399,161 @@ GraphBase::SNode * GraphBase::ComputingNode::GetInfo() { return Info ; } +void GraphBase::ComputingNode::SetMacroPorts( GraphBase::Graph * aGraph ) { + cdebug_in << "GraphBase::ComputingNode::SetMacroPorts fill ports of MacroNode" << endl; + int i ; + for ( i = 0 ; i < aGraph->GetNodeInPortsSize() ; i++ ) { + const GraphBase::InPort * anInPort = aGraph->GetNodeInPort( i ) ; + cdebug << "SetMacroPorts In" << i << " " << anInPort->PortName() << " " << anInPort->PortType() + << " " << anInPort->Kind() << endl ; + GraphBase::InPort * aNewInPort ; + if ( anInPort->IsDataStream() ) { + aNewInPort = AddInDataStreamPort( anInPort->PortName() , StringToDataStreamType( anInPort->PortType() ) , + anInPort->Dependency() , anInPort->Kind() ) ; + } + else if ( anInPort->IsParam() || anInPort->IsInLine() ) { + aNewInPort = AddInPort( anInPort->PortName() , anInPort->PortType() , anInPort->Kind() ) ; + } + } + for ( i = 0 ; i < aGraph->GetNodeOutPortsSize() ; i++ ) { + const GraphBase::OutPort * anOutPort = aGraph->GetNodeOutPort( i ) ; + cdebug << "SetMacroPorts Out" << i << " " << anOutPort->PortName() << " " << anOutPort->PortType() + << " " << anOutPort->Kind() << endl ; + if ( anOutPort->IsDataStream() ) { + AddOutDataStreamPort( anOutPort->PortName() , StringToDataStreamType( anOutPort->PortType() ) , + anOutPort->Dependency() , anOutPort->Kind() ) ; + } + else if ( anOutPort->IsParam() || anOutPort->IsInLine() ) { + AddOutPort( anOutPort->PortName() , anOutPort->PortType() , anOutPort->Kind() ) ; + } + } + cdebug_out << "GraphBase::ComputingNode::SetMacroPorts" << endl; +} + +void GraphBase::ComputingNode::UpdateMacroPorts( GraphBase::Graph * aGraph ) { + cdebug_in << "GraphBase::ComputingNode::UpdateMacroPorts fill ports of MacroNode from " + << aGraph->Name() << " InPorts(" << aGraph->GetNodeInPortsSize() << ") OutPorts(" + << aGraph->GetNodeInPortsSize() << ") to MacroNode " << Name() << " InPorts(" << GetNodeInPortsSize() + << ") OutPorts(" << GetNodeInPortsSize() << ")" << endl; + cdebug << Name() << " : " << *GetService() << endl ; + cdebug << aGraph->Name() << " : " << *aGraph->GetService() << endl ; + int i ; +// Loop over InPorts of MacroNode ; if it does not exist in the MacroGraph ===> DelInPort in the MacroNode + for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) { + GraphBase::InPort * anInPort = aGraph->GetChangeInPort( GetNodeInPort( i )->PortName() ) ; + if ( anInPort && !anInPort->IsGate() && !GetNodeInPort( i )->IsGate() ) { + if ( strcmp( GetNodeInPort( i )->PortType() , anInPort->PortType() ) ) { + cdebug << Name() << " " << GetNodeInPort( i )->PortName() << " " << GetNodeInPort( i )->PortType() + << " " << GetNodeInPort( i )->Kind() << " " << GetNodeInPort( i )->Dependency() << endl ; + cdebug << " <--> " << aGraph->Name() << " " << anInPort->PortName() << " " << anInPort->PortType() + << " " << anInPort->Kind() << " " << anInPort->Dependency() << endl ; + GetChangeNodeInPort( i )->PortType( (char * ) anInPort->PortType() ) ; + } + if ( GetNodeInPort( i )->Kind() != anInPort->Kind() ) { + cdebug << Name() << " " << GetNodeInPort( i )->PortName() << " " << GetNodeInPort( i )->PortType() + << " " << GetNodeInPort( i )->Kind() << " " << GetNodeInPort( i )->Dependency() << endl ; + cdebug << " <--> " << aGraph->Name() << " " << anInPort->PortName() << " " << anInPort->PortType() + << " " << anInPort->Kind() << " " << anInPort->Dependency() << endl ; + GetChangeNodeInPort( i )->Kind( anInPort->Kind() ) ; + } + if ( GetNodeInPort( i )->Dependency() != anInPort->Dependency() ) { + cdebug << Name() << " " << GetNodeInPort( i )->PortName() << " " << GetNodeInPort( i )->PortType() + << " " << GetNodeInPort( i )->Kind() << " " << GetNodeInPort( i )->Dependency() << endl ; + cdebug << " <--> " << aGraph->Name() << " " << anInPort->PortName() << " " << anInPort->PortType() + << " " << anInPort->Kind() << " " << anInPort->Dependency() << endl ; + GetChangeNodeInPort( i )->Dependency( anInPort->Dependency() ) ; + } + } + else if ( !GetNodeInPort( i )->IsGate() ) { + cdebug << "UpdateMacroPorts DelInPort In" << i << " " << GetNodeInPort( i )->PortName() << " " + << GetNodeInPort( i )->PortType() << " " << GetNodeInPort( i )->Kind() << endl ; + DelInPort( GetNodeInPort( i )->PortName() ) ; + } + } + int index ; +// Loop over InPorts of the MacroGraph : if it does not exist in the MacroNode ==> AddInPort in the MacroNode + for ( index = 0 ; index < aGraph->GetNodeInPortsSize() ; index++ ) { + GraphBase::InPort * anInPort = aGraph->GetChangeNodeInPort( index ) ; + GraphBase::InPort * aMacroInPort = GetChangeInPort( anInPort->PortName() ) ; + if ( !anInPort->IsGate() && + strcmp( GetChangeNodeInPort( index )->PortName() , anInPort->PortName() ) ) { + cdebug << "UpdateMacroPorts Add/MoveInPort In" << index << " " << anInPort->PortName() << " " + << anInPort->PortType() << " " << anInPort->Kind() << endl ; + if ( aMacroInPort ) { + MoveInPort( anInPort->PortName() , index ) ; + } + else { + AddInPort( anInPort->PortName() , anInPort->PortType() , anInPort->Kind() , index ) ; + } + } + } +// Loop over OutPorts of MacroNode ; if it does not exist in the MacroGraph ===> DelOutPort in the MacroNode + for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) { + GraphBase::OutPort * anOutPort = aGraph->GetChangeOutPort( GetNodeOutPort( i )->PortName() ) ; + if ( anOutPort && !anOutPort->IsGate() && !GetNodeOutPort( i )->IsGate() ) { + if ( strcmp( GetNodeOutPort( i )->PortType() , anOutPort->PortType() ) ) { + cdebug << Name() << " " << GetNodeOutPort( i )->PortName() << " " << GetNodeOutPort( i )->PortType() + << " " << GetNodeOutPort( i )->Kind() << " " << GetNodeOutPort( i )->Dependency() << endl ; + cdebug << " <--> " << aGraph->Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType() + << " " << anOutPort->Kind() << " " << anOutPort->Dependency() << endl ; + GetChangeNodeOutPort( i )->PortType( (char * ) anOutPort->PortType() ) ; + } + if ( GetNodeOutPort( i )->Kind() != anOutPort->Kind() ) { + cdebug << Name() << " " << GetNodeOutPort( i )->PortName() << " " << GetNodeOutPort( i )->PortType() + << " " << GetNodeOutPort( i )->Kind() << " " << GetNodeOutPort( i )->Dependency() << endl ; + cdebug << " <--> " << aGraph->Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType() + << " " << anOutPort->Kind() << " " << anOutPort->Dependency() << endl ; + GetChangeNodeOutPort( i )->Kind( anOutPort->Kind() ) ; + } + if ( GetNodeOutPort( i )->Dependency() != anOutPort->Dependency() ) { + cdebug << Name() << " " << GetNodeOutPort( i )->PortName() << " " << GetNodeOutPort( i )->PortType() + << " " << GetNodeOutPort( i )->Kind() << " " << GetNodeOutPort( i )->Dependency() << endl ; + cdebug << " <--> " << aGraph->Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType() + << " " << anOutPort->Kind() << " " << anOutPort->Dependency() << endl ; + GetChangeNodeOutPort( i )->Dependency( anOutPort->Dependency() ) ; + } + } + else if ( !GetNodeOutPort( i )->IsGate() ) { + cdebug << "UpdateMacroPorts DelOutPort Out" << i << " " << GetNodeOutPort( i )->PortName() << " " + << GetNodeOutPort( i )->PortType() << " " << GetNodeOutPort( i )->Kind() << endl ; + DelOutPort( GetNodeOutPort( i )->PortName() ) ; + } + } +// Loop over OutPorts of the MacroGraph : if it does not exist in the MacroNode ==> AddOutPort in the MacroNode + for ( index = 0 ; index < aGraph->GetNodeOutPortsSize() ; index++ ) { + GraphBase::OutPort * anOutPort = aGraph->GetChangeNodeOutPort( index ) ; + GraphBase::OutPort * aMacroOutPort = GetChangeOutPort( anOutPort->PortName() ) ; + if ( !anOutPort->IsGate() && strcmp( GetNodeOutPort( index )->PortName() , anOutPort->PortName() ) ) { + cdebug << "UpdateMacroPorts Add/MoveOutPort Out" << index << " " << anOutPort->PortName() << " " + << anOutPort->PortType() << " " << anOutPort->Kind() << endl ; + if ( aMacroOutPort ) { + MoveOutPort( anOutPort->PortName() , index ) ; + } + else { + AddOutPort( anOutPort->PortName() , anOutPort->PortType() , anOutPort->Kind() , index ) ; + } + } + } + cdebug_out << "GraphBase::ComputingNode::UpdateMacroPorts" << endl; +} + +void GraphBase::ComputingNode::SetMacroDatas( GraphBase::Graph * aGraph , + GraphBase::Graph * aGraphOfMacroGraph ) { + cdebug_in << "GraphBase::ComputingNode::SetMacroDatas fill inputs of MacroNode" << endl; + int i ; + for ( i = 0 ; i < aGraph->GetNodeInPortsSize() ; i++ ) { + const GraphBase::InPort * anInPort = aGraph->GetNodeInPort( i ) ; + GraphBase::OutPort * anOutPort = aGraph->GetChangeNodeInDataNodePort(i) ; + cdebug << " " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType() + << " " << anOutPort->Kind() << " " << anOutPort->PortStatus() << endl ; + if ( anOutPort->IsDataConnected() ) { + aGraphOfMacroGraph->AddInputData( Name() , anInPort->PortName() , *(anOutPort->Value()) ) ; + anOutPort->PortStatus( ExternConnected ) ; + } + } + cdebug_out << "GraphBase::ComputingNode::SetMacroDatas" << endl; +} + void GraphBase::ComputingNode::DelInPort( const char * InputParameterName ) { GraphBase::PortsOfNode::DelInPort( InputParameterName ) ; } @@ -394,26 +563,28 @@ void GraphBase::ComputingNode::DelOutPort( const char * OutputParameterName ) { GraphBase::InPort * GraphBase::ComputingNode::AddInPort( const char * InputParameterName , const char * InputParameterType , - const SUPERV::KindOfPort aKindOfPort ) { + const SUPERV::KindOfPort aKindOfPort , + int index ) { cdebug << "AddInPort " << Name() << " ConnectedInPortsNumber " << ConnectedInPortsNumber() << endl ; return GraphBase::PortsOfNode::AddInPort( _ORB , NamePtr() , Kind() , InputParameterName , InputParameterType , aKindOfPort , -// DataStreamInPortsNumber() , + index , _Graph_prof_debug , _Graph_fdebug ) ; } GraphBase::OutPort * GraphBase::ComputingNode::AddOutPort( const char * OutputParameterName , const char * OutputParameterType , - const SUPERV::KindOfPort aKindOfPort ) { + const SUPERV::KindOfPort aKindOfPort , + int index ) { cdebug << "AddOutPort " << Name() << " ConnectedInPortsNumber " << ConnectedInPortsNumber() << endl ; return GraphBase::PortsOfNode::AddOutPort( _ORB , NamePtr() , Kind() , OutputParameterName , OutputParameterType , aKindOfPort , -// DataStreamOutPortsNumber() , + index , _Graph_prof_debug , _Graph_fdebug ) ; } @@ -427,7 +598,8 @@ void GraphBase::ComputingNode::DelOutDataStreamPort( const char * OutputParamete GraphBase::InDataStreamPort * GraphBase::ComputingNode::AddInDataStreamPort( const char * InputParameterName , const SALOME_ModuleCatalog::DataStreamType InputParameterType , const SALOME_ModuleCatalog::DataStreamDependency aDependency , - const SUPERV::KindOfPort aKindOfPort ) { + const SUPERV::KindOfPort aKindOfPort , + int index ) { // IncrDataStreamInPorts() ; GraphBase::InDataStreamPort * aDataStreamPort ; aDataStreamPort = (GraphBase::InDataStreamPort * ) GraphBase::PortsOfNode::AddInPort( _ORB , NamePtr() , @@ -435,8 +607,9 @@ GraphBase::InDataStreamPort * GraphBase::ComputingNode::AddInDataStreamPort( con InputParameterName , DataStreamTypeToString( InputParameterType ).c_str() , aKindOfPort , -// DataStreamInPortsNumber() , - _Graph_prof_debug , _Graph_fdebug ) ; + index , + _Graph_prof_debug , + _Graph_fdebug ) ; aDataStreamPort->Dependency( aDependency ) ; if ( aDependency == SALOME_ModuleCatalog::DATASTREAM_TEMPORAL ) { aDataStreamPort->SetParams( SUPERV::TI , SUPERV::L1 , SUPERV::EXTRANULL ) ; @@ -446,7 +619,8 @@ GraphBase::InDataStreamPort * GraphBase::ComputingNode::AddInDataStreamPort( con GraphBase::OutDataStreamPort * GraphBase::ComputingNode::AddOutDataStreamPort( const char * OutputParameterName , const SALOME_ModuleCatalog::DataStreamType OutputParameterType , const SALOME_ModuleCatalog::DataStreamDependency aDependency , - const SUPERV::KindOfPort aKindOfPort ) { + const SUPERV::KindOfPort aKindOfPort , + int index ) { // IncrDataStreamOutPorts() ; GraphBase::OutDataStreamPort * aDataStreamPort ; aDataStreamPort = (GraphBase::OutDataStreamPort * ) GraphBase::PortsOfNode::AddOutPort( _ORB , NamePtr() , @@ -454,8 +628,9 @@ GraphBase::OutDataStreamPort * GraphBase::ComputingNode::AddOutDataStreamPort( c OutputParameterName , DataStreamTypeToString( OutputParameterType ).c_str() , aKindOfPort , -// DataStreamOutPortsNumber() , - _Graph_prof_debug , _Graph_fdebug ) ; + index , + _Graph_prof_debug , + _Graph_fdebug ) ; aDataStreamPort->Dependency( aDependency ) ; return aDataStreamPort ; } @@ -593,7 +768,7 @@ bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & inf QDomElement couplednode = Graph.createElement("coupled-node") ; if ( IsGOTONode() || IsLoopNode() || IsEndLoopNode() || - IsSwitchNode() || IsEndSwitchNode() ) { + IsSwitchNode() || IsEndSwitchNode() || IsMacroNode() ) { // f << Tabs << "" << CoupledNode << "" // << endl ; aField = Graph.createTextNode( CoupledNode ) ; @@ -620,6 +795,8 @@ bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & inf service.appendChild(servicename) ; servicename.appendChild( aField ) ; + cdebug << "SaveXML " << Name() << " In(" << ServiceInParameter().length() + << ") Out(" << ServiceOutParameter().length() << ")" << endl ; QDomElement inParameterlist = Graph.createElement("inParameter-list") ; service.appendChild(inParameterlist) ; unsigned int i; @@ -922,56 +1099,56 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , // san - Presumably, data stream graphs should be always saved with kind = DataStreamGraph // JR : the bug was at line 927 : && HasDataStream() != 0 was missing if ( IsDataFlowNode() || ( IsDataStreamNode() && HasDataStream() == 0 ) ) { - f << Name() << " = Graph( '" << Name() << "' )" << endl ; + f << " " << Name() << " = Graph( '" << Name() << "' )" << endl ; } else if ( IsDataStreamNode() && HasDataStream() != 0 ) { - f << Name() << " = StreamGraph( '" << Name() << "' )" << endl ; + f << " " << Name() << " = StreamGraph( '" << Name() << "' )" << endl ; long Timeout ; SUPERV::KindOfDataStreamTrace DataStreamTrace ; double DeltaTime ; ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ; - f << aGraphName << ".SetStreamParams( " << Timeout << " , SUPERV." << DataStreamTrace + f << " " << aGraphName << ".SetStreamParams( " << Timeout << " , SUPERV." << DataStreamTrace << " , " << DeltaTime << " )" << endl ; } else if ( IsComputingNode() ) { int i ; - f << Name() << "_ServiceinParameter = []" << endl ; + f << " " << Name() << "_ServiceinParameter = []" << endl ; for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) { - f << Name() << "_ServiceinParameter.append( SALOME_ModuleCatalog.ServicesParameter( '" + f << " " << Name() << "_ServiceinParameter.append( SALOME_ModuleCatalog.ServicesParameter( '" << ServiceInParameter()[i].Parametertype << "' , '" << ServiceInParameter()[i].Parametername << "' ) )" << endl ; } - f << Name() << "_ServiceoutParameter = []" << endl ; + f << " " << Name() << "_ServiceoutParameter = []" << endl ; for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) { - f << Name() << "_ServiceoutParameter.append( SALOME_ModuleCatalog.ServicesParameter( '" + f << " " << Name() << "_ServiceoutParameter.append( SALOME_ModuleCatalog.ServicesParameter( '" << ServiceOutParameter()[i].Parametertype << "' , '" << ServiceOutParameter()[i].Parametername << "' ) )" << endl ; } - f << Name() << "_ServiceinStreamParameter = []" << endl ; + f << " " << Name() << "_ServiceinStreamParameter = []" << endl ; for ( i = 0 ; i < (int ) ServiceInStreamParameter().length() ; i++ ) { - f << Name() << "_ServiceinStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog." + f << " " << Name() << "_ServiceinStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog." << ServiceInStreamParameter()[i].Parametertype << " , '" << ServiceInStreamParameter()[i].Parametername << "' , SALOME_ModuleCatalog." << ServiceInStreamParameter()[i].Parameterdependency << " ) )" << endl ; } - f << Name() << "_ServiceoutStreamParameter = []" << endl ; + f << " " << Name() << "_ServiceoutStreamParameter = []" << endl ; for ( i = 0 ; i < (int ) ServiceOutStreamParameter().length() ; i++ ) { - f << Name() << "_ServiceoutStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog." + f << " " << Name() << "_ServiceoutStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog." << ServiceOutStreamParameter()[i].Parametertype << " , '" << ServiceOutStreamParameter()[i].Parametername << "' , SALOME_ModuleCatalog." << ServiceOutStreamParameter()[i].Parameterdependency << " ) )" << endl ; } - f << Name() << "_Service = SALOME_ModuleCatalog.Service( '" << ServiceName() + f << " " << Name() << "_Service = SALOME_ModuleCatalog.Service( '" << ServiceName() << "' , " << Name() << "_ServiceinParameter" << " , " << Name() << "_ServiceoutParameter" << " , " << Name() << "_ServiceinStreamParameter" << " , " << Name() << "_ServiceoutStreamParameter" << " , 0 , 0 )" << endl ; - f << Name() << " = " << aGraphName << ".CNode( " << Name() << "_Service" << " )" + f << " " << Name() << " = " << aGraphName << ".CNode( " << Name() << "_Service" << " )" << endl ; } else if ( IsFactoryNode() ) { - f << Name() << " = " << aGraphName << ".FNode( '" << ComponentName + f << " " << Name() << " = " << aGraphName << ".FNode( '" << ComponentName << "' , '" << InterfaceName << "' , '" << ServiceName() << "' )" << endl ; } @@ -979,29 +1156,40 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , // It is done with LoopNode or SwitchNode with CoupledNode() } else { - f << "Py" << Name() << " = []" << endl ; + if ( !IsMacroNode() ) { + f << " " << "Py" << Name() << " = []" << endl ; + } int i ; SUPERV::ListOfStrings aPyFunc ; if ( PythonFunctions.size() ) { aPyFunc = *PythonFunctions[0] ; for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) { - f << "Py" << Name() << ".append( '" << aPyFunc[i] << "' )" << endl ; + f << " " << "Py" << Name() << ".append( '" << aPyFunc[i] << "' )" << endl ; } } if ( IsInLineNode() ) { - f << Name() << " = " << aGraphName << ".INode( '" << FuncNames[0].c_str() << "' , Py" + 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" + f << " " << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py" << Name() << " , '" << aCoupledNode->Name() << "' )" << endl ; } else { - f << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py" + f << " " << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py" << Name() << " , '' )" << endl ; } } + else if ( IsMacroNode() ) { + if ( aCoupledNode ) { + f << " " << aCoupledNode->Name() << " = Def" << aCoupledNode->Name() << "()" << endl ; + f << " " << Name() << " = " << aGraphName << ".GraphMNode( " << aCoupledNode->Name() << " )" << endl ; + } + else { + f << " " << Name() << " = " << aGraphName << ".GraphMNode( ? )" << endl ; + } + } else { // char * EndName = NULL ; // EndName = new char[ 3 + strlen( Name() ) + 1 ] ; @@ -1012,46 +1200,46 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , int i ; SUPERV::ListOfStrings aPyMore = *PythonFunctions[1] ; SUPERV::ListOfStrings aPyNext = *PythonFunctions[2] ; - f << "PyMore" << Name() << " = []" << endl ; + f << " " << "PyMore" << Name() << " = []" << endl ; for ( i = 0 ; i < (int ) aPyMore.length() ; i++ ) { - f << "PyMore" << Name() << ".append( '" << aPyMore[i] << "' )" << endl ; + f << " " << "PyMore" << Name() << ".append( '" << aPyMore[i] << "' )" << endl ; } - f << "PyNext" << Name() << " = []" << endl ; + f << " " << "PyNext" << Name() << " = []" << endl ; for ( i = 0 ; i < (int ) aPyNext.length() ; i++ ) { - f << "PyNext" << Name() << ".append( '" << aPyNext[i] << "' )" << endl ; + f << " " << "PyNext" << Name() << ".append( '" << aPyNext[i] << "' )" << endl ; } - f << Name() << "," << EndName << " = " << aGraphName << ".LNode( '" + 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() << " , " + 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 ; + f << " " << "Py" << aCoupledNode->Name() << " = []" << endl ; for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) { - f << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )" + f << " " << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )" << endl ; } - f << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ; + f << " " << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ; for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) { const GraphBase::InPort * anInPort = GetNodeInPort(i) ; cdebug << "Node " << Name() << " InPort " << anInPort->PortName() << " " << anInPort->Kind() << endl ; if ( anInPort->IsLoop() ) { - f << "I" << Name() << anInPort->PortName() << " = " + f << " " << "I" << Name() << anInPort->PortName() << " = " << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ; } else if ( anInPort->IsInLine() ) { - f << "I" << Name() << anInPort->PortName() << " = " + f << " " << "I" << Name() << anInPort->PortName() << " = " << Name() << ".InPort( '" << anInPort->PortName() << "' , '" << anInPort->PortType() << "' )" << endl ; } else if ( anInPort->IsDataStream() ) { - f << "I" << Name() << anInPort->PortName() << " = " << Name() + f << " " << "I" << Name() << anInPort->PortName() << " = " << Name() << ".InStreamPort( '" << anInPort->PortName() << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() ) << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ; @@ -1059,11 +1247,11 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , SUPERV::KindOfInterpolation aKindOfInterpolation ; SUPERV::KindOfExtrapolation aKindOfExtrapolation ; ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ; - f << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV." + f << " " << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV." << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ; } else if ( anInPort->IsGate() ) { - f << "I" << Name() << anInPort->PortName() << " = " + f << " " << "I" << Name() << anInPort->PortName() << " = " << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ; } } @@ -1072,17 +1260,17 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName() << " " << anOutPort->Kind() << endl ; if ( anOutPort->IsInLine() || anOutPort->IsLoop() ) { - f << "O" << Name() << anOutPort->PortName() << " = " + f << " " << "O" << Name() << anOutPort->PortName() << " = " << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ; } else if ( anOutPort->IsDataStream() ) { - f << "O" << Name() << anOutPort->PortName() << " = " << Name() + f << " " << "O" << Name() << anOutPort->PortName() << " = " << Name() << ".OutStreamPort( '" << anOutPort->PortName() << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() ) << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ; long aNumberOfValues ; aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ; - f << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )" + f << " " << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )" << endl ; } } @@ -1091,11 +1279,11 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , cdebug << "Node " << aCoupledNode->Name() << " InPort " << anInPort->PortName() << " " << anInPort->Kind() << endl ; if ( anInPort->IsInLine() || anInPort->IsLoop() || anInPort->IsGate() ) { - f << "I" << EndName << anInPort->PortName() << " = " << EndName + f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ; } else if ( anInPort->IsDataStream() ) { - f << "I" << EndName << anInPort->PortName() << " = " << EndName + f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName << ".InStreamPort( '" << anInPort->PortName() << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() ) << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ; @@ -1103,7 +1291,7 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , SUPERV::KindOfInterpolation aKindOfInterpolation ; SUPERV::KindOfExtrapolation aKindOfExtrapolation ; ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ; - f << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV." + f << " " << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV." << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ; } } @@ -1112,52 +1300,52 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , cdebug << "Node " << aCoupledNode->Name() << " OutPort " << anOutPort->PortName() << " " << anOutPort->Kind() << endl ; if ( anOutPort->IsInLine() || anOutPort->IsLoop() || anOutPort->IsGate() ) { - f << "O" << EndName << anOutPort->PortName() << " = " << EndName + f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ; } else if ( anOutPort->IsDataStream() ) { - f << "O" << EndName << anOutPort->PortName() << " = " << EndName + f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName << ".OutStreamPort( '" << anOutPort->PortName() << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() ) << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ; long aNumberOfValues ; aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ; - f << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )" + f << " " << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )" << endl ; } } } else if ( IsSwitchNode() ) { - f << Name() << "," << EndName << " = " << aGraphName << ".SNode( '" + 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() << " , " + 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 ; + f << " " << "Py" << aCoupledNode->Name() << " = []" << endl ; for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) { - f << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )" + f << " " << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )" << endl ; } - f << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ; + f << " " << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ; for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) { const GraphBase::InPort * anInPort = aCoupledNode->GetNodeInPort(i) ; cdebug << "Node " << aCoupledNode->Name() << " InPort " << anInPort->PortName() << " " << anInPort->Kind() << endl ; // if ( anInPort->IsGate() || anInPort->IsEndSwitch() ) { if ( anInPort->IsGate() ) { - f << "I" << EndName << anInPort->PortName() << " = " << EndName + f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ; } else if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) { - f << "I" << EndName << anInPort->PortName() << " = " << EndName + f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName << ".InPort( '" << anInPort->PortName() << "' , '" << anInPort->PortType() << "' )" << endl ; } else if ( anInPort->IsDataStream() ) { - f << "I" << EndName << anInPort->PortName() << " = " << EndName + f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName << ".InStreamPort( '" << anInPort->PortName() << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() ) << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ; @@ -1165,7 +1353,7 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , SUPERV::KindOfInterpolation aKindOfInterpolation ; SUPERV::KindOfExtrapolation aKindOfExtrapolation ; ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ; - f << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV." + f << " " << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV." << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ; } } @@ -1175,22 +1363,22 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , << " " << anOutPort->Kind() << endl ; // if ( anOutPort->IsGate() || anOutPort->IsEndSwitch() ) { if ( anOutPort->IsGate() ) { - f << "O" << EndName << anOutPort->PortName() << " = " << EndName + f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ; } else if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) { - f << "O" << EndName << anOutPort->PortName() << " = " << EndName + f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName << ".OutPort( '" << anOutPort->PortName() << "' , '" << anOutPort->PortType() << "' )" << endl ; } else if ( anOutPort->IsDataStream() ) { - f << "O" << EndName << anOutPort->PortName() << " = " << EndName + f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName << ".OutStreamPort( '" << anOutPort->PortName() << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() ) << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ; long aNumberOfValues ; aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ; - f << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )" + f << " " << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )" << endl ; } } @@ -1203,13 +1391,13 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , // It is done with LoopNode or SwitchNode with CoupledNode() } else { - f << Name() << ".SetName( '" << Name() << "' )" << endl ; - f << Name() << ".SetAuthor( '" << Author() << "' )" << endl ; + f << " " << Name() << ".SetName( '" << Name() << "' )" << endl ; + f << " " << Name() << ".SetAuthor( '" << Author() << "' )" << endl ; if ( IsFactoryNode() ) { - f << Name() << ".SetContainer( '" << Computer << "' )" << endl ; + f << " " << Name() << ".SetContainer( '" << Computer << "' )" << endl ; } - f << Name() << ".SetComment( '" << Comment() << "' )" << endl ; - f << Name() << ".Coords( " << XCoordinate << " , " << YCoordinate << " )" << endl ; + f << " " << Name() << ".SetComment( '" << Comment() << "' )" << endl ; + f << " " << Name() << ".Coords( " << XCoordinate << " , " << YCoordinate << " )" << endl ; if ( IsComputingNode() || IsFactoryNode() ) { int i ; @@ -1218,7 +1406,7 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , if ( !anInPort->IsDataStream() ) { cdebug << "Node " << Name() << " InPort " << anInPort->PortName() << " " << anInPort->Kind() << endl ; - f << "I" << Name() << anInPort->PortName() << " = " + f << " " << "I" << Name() << anInPort->PortName() << " = " << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ; } } @@ -1227,7 +1415,7 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , if ( !anOutPort->IsDataStream() ) { cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName() << " " << anOutPort->Kind() << endl ; - f << "O" << Name() << anOutPort->PortName() << " = " + f << " " << "O" << Name() << anOutPort->PortName() << " = " << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ; } } @@ -1236,30 +1424,42 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , int i ; for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) { const GraphBase::InPort * anInPort = GetNodeInPort(i) ; - cdebug << "Node " << Name() << " InPort " << anInPort->PortName() + cdebug << "ComputingNode::SavePY Node " << Name() << " InPort " << anInPort->PortName() << " " << anInPort->Kind() << endl ; - if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) { - f << "I" << Name() << anInPort->PortName() << " = " +// if ( anInPort->IsGate() || ( anInPort->IsInLine() && IsMacroNode() ) ) { + if ( anInPort->IsGate() || IsMacroNode() ) { + f << " " << "I" << Name() << anInPort->PortName() << " = " + << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ; + } + else if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) { + f << " " << "I" << Name() << anInPort->PortName() << " = " << Name() << ".InPort( '" << anInPort->PortName() << "' , '" << anInPort->PortType() << "' )" << endl ; } - else if ( anInPort->IsGate() ) { - f << "I" << Name() << anInPort->PortName() << " = " - << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ; + else { + cdebug << "Ignored " << Name() << " " << anInPort->PortName() << " " << anInPort->PortStatus() << endl ; +// f << " " << "I" << Name() << anInPort->PortName() << " = " +// << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ; } } for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) { const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ; - cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName() + cdebug << "ComputingNode::SavePY Node " << Name() << " OutPort " << anOutPort->PortName() << " " << anOutPort->Kind() << endl ; - if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) { - f << "O" << Name() << anOutPort->PortName() << " = " +// if ( anOutPort->IsGate() || ( anOutPort->IsInLine() && IsMacroNode() ) ) { + if ( anOutPort->IsGate() || IsMacroNode() ) { + f << " " << "O" << Name() << anOutPort->PortName() << " = " + << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ; + } + else if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) { + f << " " << "O" << Name() << anOutPort->PortName() << " = " << Name() << ".OutPort( '" << anOutPort->PortName() << "' , '" << anOutPort->PortType() << "' )" << endl ; } - else if ( anOutPort->IsGate() ) { - f << "O" << Name() << anOutPort->PortName() << " = " - << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ; + else { + cdebug << "Ignored " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortStatus() << endl ; +// f << " " << "O" << Name() << anOutPort->PortName() << " = " +// << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ; } } } @@ -1271,20 +1471,20 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , << " " << anInPort->Kind() << endl ; if ( anInPort->IsDataStream() ) { if ( IsOneOfInLineNodes() ) { - f << "I" << Name() << anInPort->PortName() << " = " + f << " " << "I" << Name() << anInPort->PortName() << " = " << Name() << ".InStreamPort( '" << anInPort->PortName() << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() ) << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ; } else { - f << "I" << Name() << anInPort->PortName() << " = " + f << " " << "I" << Name() << anInPort->PortName() << " = " << Name() << ".GetInStreamPort( '" << anInPort->PortName() << "' )" << endl ; } SUPERV::KindOfSchema aKindOfSchema ; SUPERV::KindOfInterpolation aKindOfInterpolation ; SUPERV::KindOfExtrapolation aKindOfExtrapolation ; ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ; - f << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV." + f << " " << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV." << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ; } } @@ -1294,18 +1494,18 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , << " " << anOutPort->Kind() << endl ; if ( anOutPort->IsDataStream() ) { if ( IsOneOfInLineNodes() ) { - f << "O" << Name() << anOutPort->PortName() << " = " + f << " " << "O" << Name() << anOutPort->PortName() << " = " << Name() << ".OutStreamPort( '" << anOutPort->PortName() << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() ) << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ; } else { - f << "O" << Name() << anOutPort->PortName() << " = " + f << " " << "O" << Name() << anOutPort->PortName() << " = " << Name() << ".GetOutStreamPort( '" << anOutPort->PortName() << "' )" << endl ; } long aNumberOfValues ; aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ; - f << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )" << endl ; + f << " " << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )" << endl ; } } } diff --git a/src/GraphBase/DataFlowBase_ComputingNode.hxx b/src/GraphBase/DataFlowBase_ComputingNode.hxx index 3458fa8..65e3848 100644 --- a/src/GraphBase/DataFlowBase_ComputingNode.hxx +++ b/src/GraphBase/DataFlowBase_ComputingNode.hxx @@ -18,6 +18,8 @@ namespace GraphBase { + class Graph ; + class InLineNode ; class ComputingNode : public StreamNode { @@ -75,8 +77,9 @@ namespace GraphBase { ComputingNode( CORBA::ORB_ptr ORB , SALOME_NamingService* ptrNamingService , const char * DataFlowName , - int * Graph_prof_debug = NULL , - ofstream * Graph_fdebug = NULL ) ; + const SUPERV::KindOfNode DataFlowkind , + int * Graph_prof_debug , + ofstream * Graph_fdebug ) ; ComputingNode( CORBA::ORB_ptr ORB , SALOME_NamingService* ptrNamingService , const SALOME_ModuleCatalog::Service& NodeService , @@ -175,15 +178,21 @@ namespace GraphBase { bool RemovePorts( const char* aNodeName ) ; + void SetMacroPorts( GraphBase::Graph * aGraph ) ; + void UpdateMacroPorts( GraphBase::Graph * aGraph ) ; + void SetMacroDatas( GraphBase::Graph * aGraph , GraphBase::Graph * aGraphOfMacroGraph ) ; + void DelInPort( const char * InputParameterName ) ; void DelOutPort( const char * OutputParameterName ) ; InPort * AddInPort( const char * InputParameterName , const char * InputParameterType , - const SUPERV::KindOfPort aKindOfPort ) ; + const SUPERV::KindOfPort aKindOfPort , + int index = -1 ) ; OutPort * AddOutPort( const char * OutputParameterName , const char * OutputParameterType , - const SUPERV::KindOfPort aKindOfPort ) ; + const SUPERV::KindOfPort aKindOfPort , + int index = -1 ) ; void DelInDataStreamPort( const char * InputParameterName ) ; void DelOutDataStreamPort( const char * OutputParameterName ) ; @@ -191,31 +200,36 @@ namespace GraphBase { InDataStreamPort * AddInDataStreamPort( const char * InputParameterName , const SALOME_ModuleCatalog::DataStreamType InputParameterType , const SALOME_ModuleCatalog::DataStreamDependency aDependency , - const SUPERV::KindOfPort aKindOfPort ) ; + const SUPERV::KindOfPort aKindOfPort , + int index = -1 ) ; OutDataStreamPort * AddOutDataStreamPort( const char * OutputParameterName , const SALOME_ModuleCatalog::DataStreamType OutputParameterType , const SALOME_ModuleCatalog::DataStreamDependency aDependency , - const SUPERV::KindOfPort aKindOfPort ) ; + const SUPERV::KindOfPort aKindOfPort , + int index = -1 ) ; // ComputingNode * LinkedNodes( int i ) const { return (GraphBase::ComputingNode *) GraphBase::StreamNode::LinkedNodes( i ) ; } ; - void AddLink( GraphBase::ComputingNode * ToNode ) { - GraphBase::StreamNode::AddLink( ToNode ) ; + void AddLinkedNode( GraphBase::ComputingNode * ToNode ) { + GraphBase::StreamNode::AddLinkedNode( ToNode ) ; cdebug << Name() << "->GraphBase::ComputingNode::AddLinkedNode( " << ToNode->Name() << ") ConnectedInPortsNumber " << ToNode->ConnectedInPortsNumber() << " + 1 Service " << ServiceName() << endl ; ToNode->IncrConnectedInPortsNumber() ; } ; - void RemoveLink( GraphBase::ComputingNode * ToNode ) { - if ( GraphBase::StreamNode::RemoveLink( ToNode ) ) { - cdebug << "GraphBase::StreamNode::RemoveLink to " << ToNode->Name() << " from " + bool RemoveLinkedNode( GraphBase::ComputingNode * ToNode ) { + bool RetVal = GraphBase::StreamNode::RemoveLinkedNode( ToNode ) ; + if ( RetVal ) { + cdebug << "GraphBase::StreamNode::RemoveLinkedNode to " << ToNode->Name() << " from " << Name() << " ConnectedInPortsNumber " << ToNode->ConnectedInPortsNumber() - 1 << endl ; - ToNode->DecrConnectedInPortsNumber() ; } } ; + ToNode->DecrConnectedInPortsNumber() ; + } + return RetVal ; } ; - void ReNameLink( const char* OldNodeName , - const char* NewNodeName ) { - GraphBase::StreamNode::ReNameLink( OldNodeName , NewNodeName ) ; } ; + void ReNameLinkedNode( const char* OldNodeName , + const char* NewNodeName ) { + GraphBase::StreamNode::ReNameLinkedNode( OldNodeName , NewNodeName ) ; } ; void IncrConnectedInPortsNumber() { cdebug << "IncrConnectedInPortsNumber " << Name() << " -> " diff --git a/src/GraphBase/DataFlowBase_DataNode.cxx b/src/GraphBase/DataFlowBase_DataNode.cxx index 8c4eecc..2ffb9ba 100644 --- a/src/GraphBase/DataFlowBase_DataNode.cxx +++ b/src/GraphBase/DataFlowBase_DataNode.cxx @@ -30,41 +30,44 @@ using namespace std; #include "DataFlowBase_DataNode.hxx" GraphBase::DataNode::DataNode() : - InLineNode() { + GOTONode() { MESSAGE( "GraphBase::DataNode::DataNode" ); _Created = false ; } GraphBase::DataNode::DataNode( CORBA::ORB_ptr ORB , SALOME_NamingService* ptrNamingService , - const char *DataFlowName ) : - InLineNode( ORB , ptrNamingService , DataFlowName ) { + const char *DataFlowName , + const SUPERV::KindOfNode DataFlowkind , + int * Graph_prof_debug , + ofstream * Graph_fdebug ) : + GOTONode( ORB , ptrNamingService , DataFlowName , DataFlowkind , Graph_prof_debug , Graph_fdebug ) { // MESSAGE( "GraphBase::DataNode::DataNode" ); cdebug << "GraphBase::DataNode::DataNode" << endl ; _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) { +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 ) : + GOTONode( ORB , ptrNamingService , + DataFlowName , SUPERV::ListOfStrings() , DataFlowName , DataFlowkind , + DataFlowFirstCreation , DataFlowLastModification , + DataFlowEditorRelease , DataFlowAuthor , + DataFlowComment , false , 0 , 0) { // MESSAGE( "GraphBase::DataNode::DataNode" ); } GraphBase::DataNode::~DataNode() { // MESSAGE( "GraphBase::DataNode::~DataNode" ); + cdebug << "GraphBase::DataNode::~DataNode" << endl ; } void GraphBase::DataNode::DataService( CORBA::ORB_ptr ORB , @@ -72,7 +75,7 @@ void GraphBase::DataNode::DataService( CORBA::ORB_ptr ORB , int * Graph_prof_debug , ofstream * Graph_fdebug ) { cdebug << "GraphBase::DataNode::DataService : DataFlowPortsOfNode of " - << aService.ServiceName << endl ; + << aService << endl ; DefPortsOfNode( ORB , aService , NamePtr() , Kind() , Graph_prof_debug , Graph_fdebug ) ; @@ -84,7 +87,7 @@ void GraphBase::DataNode::DataService( CORBA::ORB_ptr ORB , aReversedService.ServiceoutParameter = aService.ServiceinParameter ; _DataFlowDataPorts = new PortsOfNode() ; cdebug << "GraphBase::DataNode::DataService : Mirrored DataFlowPortsOfNode of " - << aReversedService.ServiceName << endl ; + << aReversedService << endl ; _DataFlowDataPorts->DefPortsOfNode( ORB , aReversedService , NamePtr() , Kind() , Graph_prof_debug , Graph_fdebug ) ; _Created = true ; @@ -92,7 +95,7 @@ void GraphBase::DataNode::DataService( CORBA::ORB_ptr ORB , int GraphBase::DataNode::CheckDataServerNodes() const { - cdebug << "GraphBase::Graph::DataServerNodes ()" << endl; + cdebug << "GraphBase::DataNode::CheckDataServerNodes :" << endl; int i , ierr = 0 ; @@ -101,13 +104,21 @@ int GraphBase::DataNode::CheckDataServerNodes() const { const GraphBase::OutPort * anOutPort = _DataFlowDataPorts->GetNodeOutPort(i) ; // if ( !anOutPort->IsGate() && !anOutPort->IsDataStream() && !anOutPort->IsDataConnected() ) { if ( !anOutPort->IsGate() && !anOutPort->IsDataConnected() ) { - cdebug << "InPort " << anOutPort->PortName() << " " << anOutPort->PortType() - << " of DataFlow " << Name() << " has NO Data." << endl ; - ierr++ ; + if ( anOutPort->IsExternConnected() && GraphMacroLevel() != 0 ) { + cdebug << "InPort " << anOutPort->PortName() << " " << anOutPort->PortType() << " " + << anOutPort->PortStatus() << " of DataFlow " << Name() + << " is ExternConnected. GraphMacroLevel " << GraphMacroLevel() << endl ; + } + else { + cdebug << "InPort " << anOutPort->PortName() << " " << anOutPort->PortType() << " " + << anOutPort->PortStatus() << " of DataFlow " << Name() << " has NO Data. GraphMacroLevel " + << GraphMacroLevel() << endl ; + ierr++ ; + } } else { - cdebug << "InPort " << anOutPort->PortName() << " " << anOutPort->PortType() - << " of DataFlow " << Name() << " has Data : " + cdebug << "InPort " << anOutPort->PortName() << " " << anOutPort->PortType() << " " + << anOutPort->PortStatus() << " of DataFlow " << Name() << " has Data : " // << _DataFlowDataPorts->GetNodeOutPort(i)->Value() << " kind " // << _DataFlowDataPorts->GetNodeOutPort(i)->Kind() << endl ; @@ -115,24 +126,18 @@ int GraphBase::DataNode::CheckDataServerNodes() const { } for ( i = 0 ; i < _DataFlowDataPorts->GetNodeInPortsSize() ; i++ ) { - if ( !_DataFlowDataPorts->GetNodeInPort(i)->IsConnected() ) { + if ( _DataFlowDataPorts->GetNodeInPort(i)->IsPortConnected() ) { cdebug << "OutPort " << _DataFlowDataPorts->GetNodeInPort(i)->PortName() - << " of DataFlow " << Name() << " has Data " << endl ; -// ierr++ ; + << " of DataFlow " << Name() << " is Connected" << endl ; } 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++ ; + << " of DataFlow " << Name() << " is NOT Connected" << endl ; } } if ( ierr ) { - cdebug << "Some Input Data missing in the DataFlow " << Name() << endl ; + cdebug << "In the DataFlow " << Name() << " " << ierr << " Some Input Data is missing" << endl ; } return ierr ; diff --git a/src/GraphBase/DataFlowBase_DataNode.hxx b/src/GraphBase/DataFlowBase_DataNode.hxx index a6a57b0..57be206 100644 --- a/src/GraphBase/DataFlowBase_DataNode.hxx +++ b/src/GraphBase/DataFlowBase_DataNode.hxx @@ -29,11 +29,11 @@ #ifndef _DATAFLOWBASE_DATANODE_HXX #define _DATAFLOWBASE_DATANODE_HXX -#include "DataFlowBase_InLineNode.hxx" +#include "DataFlowBase_GOTONode.hxx" namespace GraphBase { - class DataNode : public InLineNode { + class DataNode : public GOTONode { private: @@ -48,7 +48,10 @@ namespace GraphBase { DataNode() ; DataNode( CORBA::ORB_ptr ORB , SALOME_NamingService* ptrNamingService , - const char *DataFlowName ) ; + const char *DataFlowName , + const SUPERV::KindOfNode DataFlowkind , + int * Graph_prof_debug , + ofstream * Graph_fdebug ) ; DataNode( CORBA::ORB_ptr ORB , SALOME_NamingService* ptrNamingService , const SALOME_ModuleCatalog::Service& DataFlowService , diff --git a/src/GraphBase/DataFlowBase_DataPort.cxx b/src/GraphBase/DataFlowBase_DataPort.cxx index a4c3663..1f6d837 100644 --- a/src/GraphBase/DataFlowBase_DataPort.cxx +++ b/src/GraphBase/DataFlowBase_DataPort.cxx @@ -33,16 +33,19 @@ using namespace std; GraphBase::DataPort::DataPort() : Port() { pthread_mutex_init( &_MutexWait , NULL ) ; + _State = SUPERV::UndefinedState ; + _Done = false ; InitialValues( CORBA::Any() ) ; } -GraphBase::DataPort::DataPort( - const char *const * NodeName , - const SALOME_ModuleCatalog::ServicesParameter aserviceParameter , - const SUPERV::KindOfPort aKind , - const SALOME_ModuleCatalog::DataStreamDependency aDependency ) : - Port( NodeName , aserviceParameter , aKind , aDependency ) { +GraphBase::DataPort::DataPort( const char *const * NodeName , + const SALOME_ModuleCatalog::ServicesParameter aserviceParameter , + const SUPERV::KindOfPort aKind , + const SALOME_ModuleCatalog::DataStreamDependency aDependency ) : + Port( NodeName , aserviceParameter , aKind , aDependency ) { pthread_mutex_init( &_MutexWait , NULL ) ; + _State = SUPERV::UndefinedState ; + _Done = false ; InitialValues( CORBA::Any() ) ; } @@ -125,8 +128,8 @@ void GraphBase::DataPort::Value( const CORBA::Any * aDataValue ) { string _Type = CORBA::string_dup( GetServicesParameter().Parametertype ) ; const char * Type = _Type.c_str() ; _Value = &_theValue ; -// cdebug << "NewValue " << NodeName() << " " << PortName() << " " << PortType() -// << " : " << aDataValue << " kind " << aDataValue->type()->kind() << " " ; + cdebug << "NewValue " << NodeName() << " " << PortName() << " " << PortType() + << " : " << aDataValue << " kind " << aDataValue->type()->kind() << " " ; switch (aDataValue->type()->kind()) { // Input Value case CORBA::tk_string: { // Input string Value char * t; @@ -135,7 +138,7 @@ void GraphBase::DataPort::Value( const CORBA::Any * aDataValue ) { if ( !strcmp( Type , "string" ) ) { // SuperVision Value _theValue = aDataValue ; *_theValue >>= t; -// cdebug << " == Value( " << t << ") (string)"; + cdebug << " == Value( " << t << ") (string)"; } else { CORBA::Any * theValue = new CORBA::Any() ; @@ -145,14 +148,14 @@ void GraphBase::DataPort::Value( const CORBA::Any * aDataValue ) { sscanf( t , "%ld" , &l ) ; *theValue <<= l ; *theValue >>= l; -// cdebug << " --> Value( " << l << ") (long) kind " << theValue->type()->kind() ; + cdebug << " --> Value( " << l << ") (long) kind " << theValue->type()->kind() ; } else if ( !strcmp( Type , "float" ) || !strcmp( Type , "double" ) ) { double d ; sscanf( t , "%lf" , &d ) ; *theValue <<= d ; *theValue >>= d; -// cdebug << " --> Value( " << d << ") (double) kind " << theValue->type()->kind() ; + cdebug << " --> Value( " << d << ") (double) kind " << theValue->type()->kind() ; } else { // Default CORBA::Object_ptr ObjRef ; @@ -164,8 +167,8 @@ void GraphBase::DataPort::Value( const CORBA::Any * aDataValue ) { *theValue <<= CORBA::Object::_nil() ; } *theValue >>= ObjRef ; -// cdebug << " --> Value( " << ObjectToString( ObjRef ) << ") (object reference) kind " -// << theValue->type()->kind() ; + cdebug << " --> Value( " << ObjectToString( ObjRef ) << ") (object reference) kind " + << theValue->type()->kind() ; } _theValue = theValue ; *_Value = theValue ; @@ -175,13 +178,13 @@ void GraphBase::DataPort::Value( const CORBA::Any * aDataValue ) { case CORBA::tk_long: { // Input long Value long l; *aDataValue >>= l; -// cdebug << "Value( " << l << ") (long)"; + cdebug << "Value( " << l << ") (long)"; if ( !strcmp( Type , "boolean" ) || !strcmp( Type , "char" ) || !strcmp( Type , "short" ) || !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) { // SuperVision Value _theValue = aDataValue ; *_Value = aDataValue ; *_theValue >>= l; -// cdebug << " == Value( " << l << ") (long)"; + cdebug << " == Value( " << l << ") (long)"; } else { CORBA::Any * theValue = new CORBA::Any() ; @@ -191,20 +194,20 @@ void GraphBase::DataPort::Value( const CORBA::Any * aDataValue ) { *theValue <<= t ; char *tt ; *theValue >>= tt ; -// cdebug << " --> Value( " << t << ") (string) kind " << theValue->type()->kind() ; + cdebug << " --> Value( " << t << ") (string) kind " << theValue->type()->kind() ; } else if ( !strcmp( Type , "float" ) || !strcmp( Type , "double" ) ) { double d = l ; *theValue <<= d ; *theValue >>= d ; -// cdebug << " --> Value( " << d << ") (double) kind " << theValue->type()->kind() ; + cdebug << " --> Value( " << d << ") (double) kind " << theValue->type()->kind() ; } else { // Default CORBA::Object_ptr ObjRef ; *theValue <<= CORBA::Object::_nil() ; *theValue >>= ObjRef ; -// cdebug << " --> Value( " << ObjectToString( ObjRef ) << ") (object reference) kind " -// << theValue->type()->kind() ; + cdebug << " --> Value( " << ObjectToString( ObjRef ) << ") (object reference) kind " + << theValue->type()->kind() ; } _theValue = theValue ; *_Value = theValue ; @@ -214,12 +217,12 @@ void GraphBase::DataPort::Value( const CORBA::Any * aDataValue ) { case CORBA::tk_double: { // Input double Value double d; *aDataValue >>= d; -// cdebug << "Value( " << d << ") (double)"; + cdebug << "Value( " << d << ") (double)"; if ( !strcmp( Type , "float" ) || !strcmp( Type , "double" ) ) { // SuperVision Value _theValue = aDataValue ; *_Value = aDataValue ; *_theValue >>= d; -// cdebug << " == Value( " << d << ") (double)"; + cdebug << " == Value( " << d << ") (double)"; } else { CORBA::Any * theValue = new CORBA::Any() ; @@ -229,21 +232,21 @@ void GraphBase::DataPort::Value( const CORBA::Any * aDataValue ) { *theValue <<= t ; char *tt ; *theValue >>= tt ; -// cdebug << " --> Value( " << t << ") (string) kind " << theValue->type()->kind() ; + cdebug << " --> Value( " << t << ") (string) kind " << theValue->type()->kind() ; } else if ( !strcmp( Type , "boolean" ) || !strcmp( Type , "char" ) || !strcmp( Type , "short" ) || !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) { long l = (long ) d ; *theValue <<= l ; *theValue >>= l; -// cdebug << " --> Value( " << l << ") (long) kind " << theValue->type()->kind() ; + cdebug << " --> Value( " << l << ") (long) kind " << theValue->type()->kind() ; } else { // Default CORBA::Object_ptr ObjRef ; *theValue <<= CORBA::Object::_nil() ; *theValue >>= ObjRef ; -// cdebug << " --> Value( " << ObjectToString( ObjRef ) << ") (object reference) kind " -// << theValue->type()->kind() ; + cdebug << " --> Value( " << ObjectToString( ObjRef ) << ") (object reference) kind " + << theValue->type()->kind() ; } _theValue = theValue ; *_Value = theValue ; @@ -253,7 +256,7 @@ void GraphBase::DataPort::Value( const CORBA::Any * aDataValue ) { case CORBA::tk_objref: { // Input objref Value CORBA::Object_ptr obj ; *aDataValue >>= obj; -// cdebug << "Value( " << ObjectToString( obj ) << ") (object reference)"; + cdebug << "Value( " << ObjectToString( obj ) << ") (object reference)"; if ( strcmp( Type , "string" ) && strcmp( Type , "boolean" ) && strcmp( Type , "char" ) && strcmp( Type , "short" ) && strcmp( Type , "long" ) && @@ -261,27 +264,27 @@ void GraphBase::DataPort::Value( const CORBA::Any * aDataValue ) { _theValue = aDataValue ; *_Value = aDataValue ; *_theValue >>= obj; -// cdebug << " == Value( " << ObjectToString( obj ) << ") (object reference)"; + cdebug << " == Value( " << ObjectToString( obj ) << ") (object reference)"; } else { CORBA::Any * theValue = new CORBA::Any() ; if ( !strcmp( Type , "string" ) ) { *theValue <<= ObjectToString( obj ) ; *theValue >>= obj ; -// cdebug << " --> Value( " << ObjectToString( obj ) << ") (string) kind " << theValue->type()->kind() ; + cdebug << " --> Value( " << ObjectToString( obj ) << ") (string) kind " << theValue->type()->kind() ; } else if ( !strcmp( Type , "boolean" ) || !strcmp( Type , "char" ) || !strcmp( Type , "short" ) || !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) { long l = (long ) obj ; *theValue <<= l ; *theValue >>= l; -// cdebug << " --> Value( " << l << ") (long) kind " << theValue->type()->kind() ; + cdebug << " --> Value( " << l << ") (long) kind " << theValue->type()->kind() ; } else if ( !strcmp( Type , "float" ) || !strcmp( Type , "double" ) ) { double d = (double ) 0. ; *theValue <<= d ; *theValue >>= d; -// cdebug << " --> Value( " << d << ") (double) kind " << theValue->type()->kind() ; + cdebug << " --> Value( " << d << ") (double) kind " << theValue->type()->kind() ; } _theValue = theValue ; *_Value = theValue ; diff --git a/src/GraphBase/DataFlowBase_FactoryNode.cxx b/src/GraphBase/DataFlowBase_FactoryNode.cxx index 3095735..3f44450 100644 --- a/src/GraphBase/DataFlowBase_FactoryNode.cxx +++ b/src/GraphBase/DataFlowBase_FactoryNode.cxx @@ -44,9 +44,10 @@ GraphBase::FactoryNode::FactoryNode() : GraphBase::FactoryNode::FactoryNode( CORBA::ORB_ptr ORB , SALOME_NamingService* ptrNamingService , const char * aDataFlowName , + const SUPERV::KindOfNode DataFlowkind , int * Graph_prof_debug , ofstream * Graph_fdebug ) : - GraphBase::ComputingNode::ComputingNode( ORB , ptrNamingService , aDataFlowName , + GraphBase::ComputingNode::ComputingNode( ORB , ptrNamingService , aDataFlowName , DataFlowkind , Graph_prof_debug , Graph_fdebug ) { InitFields( _ComponentName , diff --git a/src/GraphBase/DataFlowBase_FactoryNode.hxx b/src/GraphBase/DataFlowBase_FactoryNode.hxx index e4d86a8..0212946 100644 --- a/src/GraphBase/DataFlowBase_FactoryNode.hxx +++ b/src/GraphBase/DataFlowBase_FactoryNode.hxx @@ -34,6 +34,7 @@ namespace GraphBase { FactoryNode( CORBA::ORB_ptr ORB , SALOME_NamingService* ptrNamingService , const char * DataFlowName , + const SUPERV::KindOfNode DataFlowkind , int * Graph_prof_debug = NULL , ofstream * Graph_fdebug = NULL ) ; FactoryNode( CORBA::ORB_ptr ORB , diff --git a/src/GraphBase/DataFlowBase_GOTONode.cxx b/src/GraphBase/DataFlowBase_GOTONode.cxx index e31dee6..530cd0e 100644 --- a/src/GraphBase/DataFlowBase_GOTONode.cxx +++ b/src/GraphBase/DataFlowBase_GOTONode.cxx @@ -19,6 +19,23 @@ GraphBase::GOTONode::GOTONode() : GraphBase::InLineNode::InLineNode() { CoupledNode( NULL ) ; + _CoupledNodeName = 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 *DataFlowName , + const SUPERV::KindOfNode DataFlowkind , + int * Graph_prof_debug , + ofstream * Graph_fdebug ) : + GraphBase::InLineNode::InLineNode( ORB , ptrNamingService , DataFlowName , DataFlowkind , Graph_prof_debug , Graph_fdebug ) { + + CoupledNode( NULL ) ; + _CoupledNodeName = NULL ; cdebug << "GraphBase::GOTONode::GOTONode " << this << " _Name " << (void *) Name() << " " << Name() << " _Comment " << (void *) Comment() << " " << Comment() << " " << endl ; @@ -48,6 +65,7 @@ GraphBase::GOTONode::GOTONode( CORBA::ORB_ptr ORB , X , Y , Graph_prof_debug , Graph_fdebug ) { CoupledNode( NULL ) ; + _CoupledNodeName = NULL ; cdebug_in << "GraphBase::GOTONode::GOTONode " << this << "' _Name " << (void *) Name() << " '" << Name() << " _Comment " << (void *) Comment() << " " << Comment() << " " @@ -75,6 +93,69 @@ GraphBase::GOTONode::~GOTONode() { // delete [] _Comment; } +void GraphBase::GOTONode::CoupledNode( GraphBase::InLineNode * aCoupledNode ) { + cdebug << this << " " << Name() << " GraphBase::GOTONode::CoupledNode( " ; + if ( aCoupledNode ) { + CoupledNodeName( aCoupledNode->Name() ) ; + cdebug << aCoupledNode->Name() ; + } + else { + cdebug << "NULL" ; + } + cdebug << " )" << endl ; + _CoupledNode = aCoupledNode ; +} + +const GraphBase::InLineNode * GraphBase::GOTONode::CoupledNode() const { + cdebug << this << " " << Name() << " GraphBase::GOTONode::CoupledNode() --> " ; + if ( _CoupledNode ) { + cdebug << _CoupledNode->Name() ; + } + else { + cdebug << "NULL" ; + } + cdebug << endl ; + return _CoupledNode ; +} + +GraphBase::InLineNode * GraphBase::GOTONode::CoupledNode() { + cdebug << this << " " << Name() << " GraphBase::GOTONode::CoupledNode() --> " ; + if ( _CoupledNode ) { + cdebug << _CoupledNode->Name() ; + } + else { + cdebug << "NULL" ; + } + cdebug << endl ; + return _CoupledNode ; +} + +void GraphBase::GOTONode::CoupledNodeName( const char * aCoupledNodeName ) { + if ( _CoupledNodeName ) { + delete [] _CoupledNodeName ; + } + _CoupledNodeName = new char [ strlen( aCoupledNodeName ) + 1 ] ; + strcpy( _CoupledNodeName , aCoupledNodeName ) ; + cdebug << this << " " << Name() << " GraphBase::GOTONode::CoupledNodeName() --> " ; + if ( _CoupledNodeName ) { + cdebug << _CoupledNodeName ; + } + else { + cdebug << "NULL" ; + } + cdebug << endl ; +} +char * GraphBase::GOTONode::CoupledNodeName() const { + cdebug << this << " " << Name() << " GraphBase::GOTONode::CoupledNodeName() --> " ; + if ( _CoupledNodeName ) { + cdebug << _CoupledNodeName ; + } + else { + cdebug << "NULL" ; + } + return my_strdup( _CoupledNodeName ) ; +} + //bool GraphBase::GOTONode::SaveXML( ostream &f , char *Tabs , bool GraphBase::GOTONode::SaveXML( QDomDocument & Graph , QDomElement & info , int XCoordinate , int YCoordinate ) const { diff --git a/src/GraphBase/DataFlowBase_GOTONode.hxx b/src/GraphBase/DataFlowBase_GOTONode.hxx index 97089aa..78316dc 100644 --- a/src/GraphBase/DataFlowBase_GOTONode.hxx +++ b/src/GraphBase/DataFlowBase_GOTONode.hxx @@ -20,59 +20,41 @@ namespace GraphBase { private: - InLineNode * _CoupledNode ; + InLineNode * _CoupledNode ; + char * _CoupledNodeName ; 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 , - ofstream * Graph_fdebug = NULL ) ; + SALOME_NamingService* ptrNamingService , + const char *DataFlowName , + const SUPERV::KindOfNode DataFlowkind , + int * Graph_prof_debug , + ofstream * Graph_fdebug ) ; + 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 , + ofstream * 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 ; } ; + void CoupledNode( InLineNode * aCoupledNode ) ; + const InLineNode * CoupledNode() const ; + InLineNode * CoupledNode() ; + void CoupledNodeName( const char * aCoupledNodeName ) ; + char * CoupledNodeName() const ; // bool SaveXML(ostream &f , char *Tabs , int X , int Y ) const ; bool SaveXML(QDomDocument & Graph , QDomElement & info , int X , int Y ) const ; diff --git a/src/GraphBase/DataFlowBase_Graph.cxx b/src/GraphBase/DataFlowBase_Graph.cxx index 2319b70..2a15de7 100644 --- a/src/GraphBase/DataFlowBase_Graph.cxx +++ b/src/GraphBase/DataFlowBase_Graph.cxx @@ -35,16 +35,19 @@ GraphBase::Graph::Graph() : DataNode() { cdebug << "GraphBase::Graph::Graph" << endl ; _GraphNodesSize = 0 ; + _GraphImpl = NULL ; } GraphBase::Graph::Graph( CORBA::ORB_ptr ORB , SALOME_NamingService* ptrNamingService , const char *DataFlowName , + const SUPERV::KindOfNode DataFlowkind , int * Graph_prof_debug , ofstream * Graph_fdebug ) : // const char * DebugFileName ) : - DataNode( ORB ,ptrNamingService , DataFlowName ) { + DataNode( ORB ,ptrNamingService , DataFlowName , DataFlowkind , Graph_prof_debug , Graph_fdebug ) { _Orb = CORBA::ORB::_duplicate( ORB ) ; + _GraphImpl = NULL ; Set_prof_debug( Graph_prof_debug , Graph_fdebug ) ; cdebug << "GraphBase::Graph::Graph( " << DataFlowName << ") GraphNodesSize() " << GraphNodesSize() << endl ; _GraphNodesSize = 0 ; @@ -72,6 +75,7 @@ GraphBase::Graph::Graph( CORBA::ORB_ptr ORB , DataFlowEditorRelease , DataFlowAuthor , DataFlowComment ) { _Orb = CORBA::ORB::_duplicate( ORB ) ; _GraphNodesSize = 0 ; + _GraphImpl = NULL ; Set_prof_debug( Graph_prof_debug , Graph_fdebug ) ; cdebug_in << "GraphBase::Graph::Graph" << endl ; DataService( ORB , DataFlowService , Graph_prof_debug , Graph_fdebug ) ; @@ -120,9 +124,8 @@ GraphBase::SNode * GraphBase::Graph::GetInfo() const { // Function : GetNodes // Purpose : get a nodes list //---------------------------------------------------------------------- -GraphBase::ListOfNodes * GraphBase::Graph::GetNodes() const { - GraphBase::ListOfNodes * _list_nodes = - new GraphBase::ListOfNodes; +GraphBase::ListOfSNodes * GraphBase::Graph::GetNodes() const { + GraphBase::ListOfSNodes * _list_nodes = new GraphBase::ListOfSNodes; cdebug_in << "GraphBase::Graph::GetNodes" << endl ; // All the nodes from _InNodes are taken @@ -149,7 +152,7 @@ GraphBase::ListOfNodes * GraphBase::Graph::GetNodes() const { } (*_list_nodes)[ind].theName = CORBA::string_dup( aCNode->Name() ); (*_list_nodes)[ind].theKind = aCNode->Kind(); - if ( aCNode->IsInLineNode() ) { + if ( aCNode->IsInLineNode() || aCNode->IsMacroNode() ) { GraphBase::InLineNode * aINode = (GraphBase::InLineNode * ) aCNode ; (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ; (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aINode->PyFuncName() ) ; @@ -199,6 +202,14 @@ GraphBase::ListOfNodes * GraphBase::Graph::GetNodes() const { (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ; (*_list_nodes)[ind].theListOfPythonFunctions[0] = aESNode->PythonFunction() ; } + else if ( aCNode->IsMacroNode() ) { + GraphBase::Graph * aGraph = (GraphBase::Graph * ) aCNode ; + (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aGraph->CoupledNode()->Name() ) ; + (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ; + (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aGraph->PyFuncName() ) ; + (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ; + (*_list_nodes)[ind].theListOfPythonFunctions[0] = aGraph->PythonFunction() ; + } else { (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( "" ) ; } @@ -353,9 +364,8 @@ GraphBase::ListOfNodes * GraphBase::Graph::GetNodes() const { // Function : GetLinks // Purpose : get a links list //---------------------------------------------------------------------- -GraphBase::ListOfLinks * GraphBase::Graph::GetLinks(bool AllLinks ) const { - GraphBase::ListOfLinks * _list_links = - new GraphBase::ListOfLinks; +GraphBase::ListOfSLinks * GraphBase::Graph::GetLinks(bool AllLinks ) const { + GraphBase::ListOfSLinks * _list_links = new GraphBase::ListOfSLinks; // All the links from _LinksList are taken // vector< InNode *> Nodes = InNodes() ; @@ -367,10 +377,10 @@ GraphBase::ListOfLinks * GraphBase::Graph::GetLinks(bool AllLinks ) const { int i ; for ( i = 0 ; i < fromNode->GetNodeOutPortsSize() ; i++ ) { const GraphBase::OutPort* fromPort = fromNode->GetNodeOutPort( i ) ; -// if ( fromPort->IsPortConnected() && ( !fromPort->IsLoop() || AllLinks ) ) { - int j ; - for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) { - const GraphBase::InPort* toPort = fromPort->InPorts( j ) ; + int j ; + for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) { + const GraphBase::InPort* toPort = fromPort->InPorts( j ) ; + if ( toPort->IsPortConnected() ) { // Desole pour ce cast mais avec les maps difficile de faire const ... const GraphBase::ComputingNode * toNode = ((GraphBase::Graph * ) this)->GetGraphNode( toPort->NodeName() ) ; if ( !(fromPort->IsLoop() && toPort->IsLoop() ) || AllLinks ) { @@ -391,23 +401,22 @@ GraphBase::ListOfLinks * GraphBase::Graph::GetLinks(bool AllLinks ) const { (*_list_links)[ind++].aListOfCoords = *(toPort->Coords()) ; } } - else { - cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " " - << fromPort->PortName() << " ) IsPortConnected" << fromPort->IsPortConnected() - << " --> " << toNode->Name() << "( " << toPort->PortName() << " ) " - << " " << fromPort->InPortsSize() << " ports ignored" << endl ; - } - } -// } + } + else { + cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " " + << fromPort->PortName() << " ) " << fromPort->PortStatus() + << " --> " << toPort->NodeName() << "( " << toPort->PortName() << " ) " + << " " << toPort->PortStatus() << " " << fromPort->InPortsSize() << " ports ignored" << endl ; + } + } } } return _list_links; } -GraphBase::ListOfGraphs * GraphBase::Graph::GetGraphs() const { - GraphBase::ListOfGraphs * _list_graphs = - new GraphBase::ListOfGraphs; +GraphBase::ListOfSGraphs * GraphBase::Graph::GetGraphs() const { + GraphBase::ListOfSGraphs * _list_graphs = new GraphBase::ListOfSGraphs; return _list_graphs; } @@ -429,29 +438,30 @@ GraphBase::SLink * GraphBase::Graph::GetLink( GraphBase::ComputingNode * aNode , // Function : GetDatas // Purpose : get the datas list //---------------------------------------------------------------------- -GraphBase::ListOfLinks * GraphBase::Graph::GetDatas() const { - GraphBase::ListOfLinks * _list_datalinks = - new GraphBase::ListOfLinks; +GraphBase::ListOfSLinks * GraphBase::Graph::GetDatas() const { + GraphBase::ListOfSLinks * _list_datalinks = new GraphBase::ListOfSLinks; 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 ; + if ( GraphMacroLevel() == 0 ) { + 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; + 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()) ; + (*_list_datalinks)[ind].aLinkValue = aSPValue; + (*_list_datalinks)[ind++].aListOfCoords = *(toPort->Coords()) ; + } } } } @@ -518,8 +528,7 @@ bool GraphBase::Graph::AddNode( GraphBase::ComputingNode * aNode ) { bool GraphBase::Graph::ReNameNode( const char* OldNodeName , const char* NewNodeName ) { - cdebug_in << "GraphBase::Graph::ReNameNode (" << OldNodeName << " , " - << NewNodeName << ")" << endl; + cdebug_in << "GraphBase::Graph::ReNameNode (" << OldNodeName << " , " << NewNodeName << ")" << endl; int i ; bool RetVal = false ; if ( !strcmp( OldNodeName , NewNodeName ) ) { @@ -536,31 +545,34 @@ bool GraphBase::Graph::ReNameNode( const char* OldNodeName , 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() ; + cdebug << i << ". " << aNode->Name() << " " << "GraphBase::Graph::ReNameNode of LinkedNode : from " ; if ( anOutPort ) { cdebug << anOutPort->NodeName() ; } else { cdebug << "without link" ; } - cdebug << " to " << i << ". " << anInPort->PortName() - << " of " << NewNodeName ; - if ( anInPort->IsConnected() ) { + cdebug << " to " << i << ". " << anInPort->PortName() << " of " << NewNodeName ; + if ( !anInPort->IsNotConnected() ) { if ( anOutPort->IsDataConnected() ) { - cdebug << " fromDataConnected " - << anOutPort->NodeName() - << endl ; + cdebug << " fromDataConnected " << anOutPort->NodeName() << endl ; } else { - GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ; - cdebug << " fromConnected " << FromNode->Name() << endl ; + GraphBase::ComputingNode * FromNode ; + if ( strcmp( anOutPort->NodeName() , Name() ) ) { + FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ; + } + else { + FromNode = this ; + } + cdebug << " fromConnected " << anOutPort->NodeName() << endl ; if ( anInPort->IsDataStream() ) { - FromNode->ReNameStreamLink( OldNodeName , NewNodeName ) ; + FromNode->ReNameStreamLinkedNode( OldNodeName , NewNodeName ) ; } else { - FromNode->ReNameLink( OldNodeName , NewNodeName ) ; + FromNode->ReNameLinkedNode( OldNodeName , NewNodeName ) ; } } char* OldNodePortName = new char[ strlen( OldNodeName ) + @@ -568,10 +580,12 @@ bool GraphBase::Graph::ReNameNode( const char* OldNodeName , char* NewNodePortName = new char[ strlen( NewNodeName ) + strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 2 ] ; strcpy( OldNodePortName , OldNodeName ) ; - strcat( OldNodePortName , "\\" ) ; +// strcat( OldNodePortName , "\\" ) ; + strcat( OldNodePortName , "_" ) ; strcat( OldNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ; strcpy( NewNodePortName , NewNodeName ) ; - strcat( NewNodePortName , "\\" ) ; +// strcat( NewNodePortName , "\\" ) ; + strcat( NewNodePortName , "_" ) ; strcat( NewNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ; RetVal = anOutPort->ReNameInPort( OldNodePortName , NewNodePortName ) ; delete [] OldNodePortName ; @@ -599,45 +613,55 @@ bool GraphBase::Graph::ReNameNode( const char* OldNodeName , } bool GraphBase::Graph::RemoveNode( const char* aNodeName ) { - cdebug_in << "GraphBase::Graph::RemoveNode (" << aNodeName << ")" << endl; + cdebug_in << "Graph::RemoveNode (" << aNodeName << ") " << LinkedNodesSize() << " LinkedNodes :" + << endl; int i ; bool RetVal = false ; int index = GetGraphNodeIndex( aNodeName ) ; GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ; + for ( i = 0 ; i < LinkedNodesSize() ; i++ ) { + cdebug << " " << i << ". " << LinkedNodes( i ) << endl ; + } if ( aNode ) { + cdebug << "Graph::RemoveNode " << aNode->GetNodeInPortsSize() << " InPorts " << aNode->GetNodeOutPortsSize() + << " OutPorts" << endl ; 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 ) ; + cdebug << "InPort" << i << ". " << aNodeName << "( " << anInPort->PortName() << ") " + << anInPort->PortStatus() << " <-- " ; GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; if ( anOutPort ) { - cdebug << anOutPort->NodeName() ; - } - else { - cdebug << "without link" ; + cdebug << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") " << anOutPort->PortStatus() ; } - cdebug << " to " << i << ". " << anInPort->PortName() - << " of " << aNodeName ; - if ( anInPort->IsConnected() ) { - if ( anOutPort->IsDataConnected() ) { - cdebug << " fromDataConnected " << anOutPort->NodeName() << endl ; + cdebug << endl ; + if ( !anInPort->IsNotConnected() ) { + RetVal = true ; + if ( anOutPort->IsDataConnected() || anOutPort->IsExternConnected() ) { + cdebug << " Data/Extern" << endl ; } else { GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ; - cdebug << " fromConnected " << FromNode->Name() << endl ; - if ( anInPort->IsDataStream() ) { - FromNode->RemoveStreamLink( aNode ) ; - } - else { - FromNode->RemoveLink( aNode ) ; + if ( !FromNode->IsGOTONode() ) { + if ( anInPort->IsDataStream() ) { + RetVal = FromNode->RemoveStreamLinkedNode( aNode ) ; + } + else { + RetVal = FromNode->RemoveLinkedNode( aNode ) ; + } + if ( !RetVal ) { + cdebug << "anOutPort->RemoveLinkedNode Error RetVal " << RetVal << endl ; + break ; + } } } RetVal = anOutPort->RemoveInPort( anInPort ) ; - if ( !RetVal ) + if ( !RetVal ) { + cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ; break ; + } } else { - cdebug << " not connected" << endl ; RetVal = true ; } } @@ -648,41 +672,47 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) { 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 ) ; + cdebug << "OutPort" << i << ". Remove " << anOutPort->InPortsSize() + << " InPortsof OutPort : " << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") " + << anOutPort->PortStatus() << " :" << endl ; 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() ) ; - if ( anOutPort->IsDataStream() ) { - aNode->RemoveStreamLink( ToNode ) ; - } - else { - aNode->RemoveLink( ToNode ) ; - } - RetVal = anOutPort->RemoveInPort( anOutPort->ChangeInPorts( j ) ) ; - if ( !RetVal ) - break ; - } -// RetVal = aNode->GetChangeNodeOutPort( j )->RemoveLinks() ; - if ( !RetVal ) + GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( j ) ; + cdebug << " to InPort" << j << ". " << anInPort->NodeName() << "( " << anInPort->PortName() << ") " + << anInPort->PortStatus() << endl ; + if ( !anInPort->IsExternConnected() ) { + GraphBase::ComputingNode * ToNode = GetChangeGraphNode( anInPort->NodeName() ) ; + RetVal = anInPort->RemoveOutPort() ; + if ( !RetVal ) { + cdebug << "anOutPort->RemoveOutPort Error RetVal " << RetVal << endl ; + break ; + } + if ( ( aNode->IsGOTONode() && ToNode->IsOneOfInLineNodes() ) || + ( aNode->IsEndLoopNode() && ToNode->IsLoopNode( ) ) ) { + } + else if ( anOutPort->IsDataStream() ) { + RetVal = aNode->RemoveStreamLinkedNode( ToNode ) ; + } + else { + RetVal = aNode->RemoveLinkedNode( ToNode ) ; + } + if ( !RetVal ) { + cdebug << "anOutPort->RemoveLinkedNode Error RetVal " << RetVal << endl ; + break ; + } + RetVal = anOutPort->RemoveInPort( anOutPort->ChangeInPorts( j ) ) ; + if ( !RetVal ) { + cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ; + break ; + } + } + } + if ( !RetVal ) { + cdebug << "Error RetVal " << RetVal << endl ; break ; + } } } -// RetVal = aNode->RemoveLinks() ; // In PortsOfNode -// if ( RetVal ) { -// if ( aNode->IsLoopNode() || aNode->IsEndLoopNode() || aNode->IsSwitchNode() || aNode->IsEndSwitchNode() ) { -// GraphBase::InLineNode * anInLineNode = ((GraphBase::GOTONode * ) aNode)->CoupledNode() ; -// if ( anInLineNode ) { -// RetVal = RemoveNode( anInLineNode->Name() ) ; -// } -// } -// } if ( RetVal ) { delete aNode ; _GraphNodesSize -= 1 ; @@ -696,23 +726,23 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) { } } else { - cdebug << "Node not found" << endl ; + cdebug << "Node not found ERROR " << index << endl ; } - cdebug_out << "GraphBase::Graph::RemoveNode" << endl; + cdebug_out << "GraphBase::Graph::RemoveNode " << RetVal << endl; return RetVal ; } bool GraphBase::Graph::AddLink( const char* FromNodeName , const char* FromServiceParameterName , const char* ToNodeName , - const char* ToServiceParameterName , - const CORBA::Any aValue ) { + const char* ToServiceParameterName ) { +// , const CORBA::Any aValue ) { bool RetVal ; // int index ; cdebug_in << "GraphBase::Graph::AddLink(" << FromNodeName << "(" << FromServiceParameterName << ") ---> " << ToNodeName << "(" - << ToServiceParameterName << ") )" << endl; + << ToServiceParameterName << ") , aValue )" << endl; GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ; GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ; @@ -749,10 +779,11 @@ bool GraphBase::Graph::AddLink( const char* FromNodeName , aValue <<= (long ) 1 ; fromPort->Value( aValue ) ; } - else { - const CORBA::Any * aDataValue = new CORBA::Any( aValue ) ; - fromPort->Value( aDataValue ) ; - } +// else { +// const CORBA::Any * aDataValue = new CORBA::Any( aValue ) ; +// fromPort->Value( aDataValue ) ; +// } +// fromPort->PortStatus( DataConnected ); } cdebug_out << "GraphBase::Graph::AddLink" << endl; @@ -794,8 +825,31 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode , } cdebug_in << "GraphBase::Graph::AddLink(" << fromNode->Name() << "(" - << fromPort->PortName() << ") ---> " << toNode->Name() << "(" - << toPort->PortName() << ") )" << endl; + << fromPort->PortName() << " " << fromPort->PortStatus() << ") ---> " << toNode->Name() << "(" + << toPort->PortName() << " " << toPort->PortStatus() << ") )" << endl; + if ( fromPort->IsDataConnected() || fromPort->IsExternConnected() ) { + if ( !fromPort->RemoveInPort() ) { // There is only one ===> RemoveOutPort() + cdebug_out << "GraphBase::Graph::AddLink(" << fromNode->Name() << "(" + << fromPort->PortName() << " " << fromPort->PortStatus() << ") RemoveInPort ERROR " << endl ; + return false ; + } + } + if ( toPort->IsDataConnected() || toPort->IsExternConnected() ) { + if ( !toPort->GetOutPort()->RemoveInPort() ) { // There is only one ===> RemoveOutPort() + cdebug_out << "GraphBase::Graph::AddLink(" << toNode->Name() << "(" + << toPort->PortName() << " " << toPort->PortStatus() << ") RemoveInPort ERROR " << endl ; + return false ; + } + } + else if ( toPort->IsPortConnected() && !toNode->IsEndSwitchNode() ) { + if ( !RemoveLink( toPort->GetOutPort()->NodeName() , + toPort->GetOutPort()->PortName() , + toNode->Name() , toPort->PortName() ) ) { + cdebug_out << "RemoveLink(AddLink) toPort->GetOutPort()->NodeName() RemoveLink Error." << endl ; + return false ; + } + } + if ( !fromNode->IsDataFlowNode() && !fromNode->IsDataStreamNode() && !toNode->IsDataFlowNode() && !toNode->IsDataStreamNode() && toPort->GetOutPort() ) { @@ -805,14 +859,14 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode , cdebug_out << "GraphBase::Graph::AddLink 1" << endl; return true ; } - else if ( toPort->IsDataConnected() ) { - toPort->RemoveOutPort() ; + else if ( toPort->IsDataConnected() || toPort->IsExternConnected() ) { + toPort->GetOutPort()->RemoveInPort( toPort ) ; //dbg } else if ( fromNode->IsGOTONode() ) { if ( !RemoveLink( toPort->GetOutPort()->NodeName() , toPort->GetOutPort()->PortName() , toNode->Name() , toPort->PortName() ) ) { - cdebug << "RemoveLink(AddLink) toPort->GetOutPort()->NodeName() Error." + cdebug << "RemoveLink(AddLink) Error." << endl ; cdebug_out << "GraphBase::Graph::AddLink" << endl; return false ; @@ -846,13 +900,22 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode , return false ; } } + else if ( ( fromNode->IsDataFlowNode() || fromNode->IsDataStreamNode() ) && + ( toPort->IsDataConnected() || toPort->IsExternConnected() ) ) { + fromPort->RemoveInPort( toPort ) ; //dbg + } + else if ( ( toNode->IsDataFlowNode() || toNode->IsDataStreamNode() ) && + ( fromPort->IsDataConnected() || fromPort->IsExternConnected() ) ) { + fromPort->RemoveInPort() ; // There is only one + } + 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; + cdebug_out << "GraphBase::Graph::AddLink 0" << endl; return false ; } if ( !toPort->IsDataStream() ) { @@ -861,30 +924,25 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode , } else if ( !fromPort->AddInPort( toPort ) ) { // --> MapOfInports in the OutPort cdebug << "!fromPort->AddLink Error." << endl ; - cdebug_out << "GraphBase::Graph::AddLink" << endl; + cdebug_out << "GraphBase::Graph::AddLink 0" << endl; return false ; } - if ( ( fromNode->IsDataFlowNode() || fromNode->IsDataStreamNode() ) && - 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; + cdebug_out << "GraphBase::Graph::AddLink 0" << 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; + cdebug_out << "GraphBase::Graph::AddLink 0" << 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; + cdebug_out << "GraphBase::Graph::AddLink 0" << endl; return false ; } } @@ -904,23 +962,27 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode , } fromPort->PortStatus( PortConnected ); // GOTO - Loop } - else if ( fromNode->IsDataFlowNode() || fromNode->IsDataStreamNode() || - toNode->IsDataFlowNode() || toNode->IsDataStreamNode() ) { - cdebug << "AddLink IsDataFlowNode fromPort->PortStatus( DataConnected ) " + else if ( fromNode->IsDataFlowNode() || fromNode->IsDataStreamNode() ) { + cdebug << "AddLink IsDataFlow/StreamNode fromPort->PortStatus( DataConnected ) : " << fromNode->Name() << " " << fromPort->PortName() << endl ; - fromPort->PortStatus( DataConnected ); + fromPort->PortStatus( ExternConnected ); + } + else if ( toNode->IsDataFlowNode() || toNode->IsDataStreamNode() ) { + cdebug << "AddLink IsDataFlow/StreamNode fromPort->PortStatus( ExternConnected ) : " + << fromNode->Name() << " " << fromPort->PortName() << endl ; + fromPort->PortStatus( ExternConnected ) ; } else { cdebug << "AddLink fromPort->PortStatus( PortConnected ) & fromNode->toNode " << fromNode->Name() << " " << fromPort->PortName() << " " - << fromPort->Kind() << " -> " << toNode->Name() << " " << " " - << toPort->PortName() << " " << toPort->Kind() << endl; + << fromPort->Kind() << " OldPortStatus " << fromPort->PortStatus() << " -> " << toNode->Name() + << " " << " " << toPort->PortName() << " " << toPort->Kind() << endl; fromPort->PortStatus( PortConnected ); if ( fromPort->IsDataStream() && toPort->IsDataStream() ) { - fromNode->AddStreamLink( toNode ) ; + fromNode->AddStreamLinkedNode( toNode ) ; } else { - fromNode->AddLink( toNode ) ; + fromNode->AddLinkedNode( toNode ) ; } } if ( fromNode->IsSwitchNode() ) { @@ -945,7 +1007,7 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode , anInPort->PortName() ) ) { cdebug << "AddLink Error Removelink ( Switch , Default , EndSwitch , Default )" << endl ; - cdebug_out << "GraphBase::Graph::AddLink" << endl; + cdebug_out << "GraphBase::Graph::AddLink 0" << endl; return false ; } } @@ -966,20 +1028,21 @@ bool GraphBase::Graph::RemoveLink( const char* FromNodeName , GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ; if ( toNode ) { GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ; - if ( anInPort && ( anInPort->IsConnected() || - anInPort->IsDataConnected() ) ) { + if ( anInPort && ( anInPort->IsPortConnected() || + anInPort->IsDataConnected() || + anInPort->IsExternConnected() ) ) { GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; - RetVal = anOutPort->RemoveInPort( anInPort ) ; - anInPort->RemoveOutPort() ; + RetVal = anOutPort->RemoveInPort( anInPort ) ; // ==> : +// anInPort->RemoveOutPort() ; const char * FromNodeName = anOutPort->NodeName() ; GraphBase::ComputingNode * fromNode = GetChangeGraphNode( FromNodeName ) ; if ( RetVal ) { if ( fromNode ) { if ( anInPort->IsDataStream() ) { - fromNode->RemoveStreamLink( toNode ) ; + fromNode->RemoveStreamLinkedNode( toNode ) ; } else { - fromNode->RemoveLink( toNode ) ; + fromNode->RemoveLinkedNode( toNode ) ; } } if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && !toNode->IsEndSwitchNode() ) { @@ -1002,22 +1065,22 @@ bool GraphBase::Graph::GetLink(const char* ToNodeName , GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ; if ( toNode ) { GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ; - if ( anInPort && anInPort->IsConnected() ) { + if ( anInPort && !anInPort->IsNotConnected() ) { GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; *FromNodeName = my_strdup( anOutPort->NodeName() ) ; *FromServiceParameterName = my_strdup( anOutPort->PortName() ) ; RetVal = true ; } else { - cdebug << "GraphEditor::OutNode::GetLink ERROR no InPort or NotConnected " << ToNodeName + cdebug << "GraphBase::Graph::GetLink ERROR no InPort or NotConnected " << ToNodeName << " " << ToServiceParameterName << " " << RetVal << endl; } } else { - cdebug << "GraphEditor::OutNode::GetLink ERROR no Node " << ToNodeName << " " << RetVal + cdebug << "GraphBase::Graph::GetLink ERROR no Node " << ToNodeName << " " << RetVal << endl; } -// cdebug_out << "GraphEditor::OutNode::GetLink " << RetVal << endl; +// cdebug_out << "GraphBase::Graph::GetLink " << RetVal << endl; return RetVal ; } @@ -1047,21 +1110,21 @@ bool GraphBase::Graph::AddInputData( const char* ToNodeName , cdebug << "(object reference) " ; break; default: - cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR"; + cdebug << "(other(tk_string(" << CORBA::tk_string << "),tk_double(" << CORBA::tk_double << "),tk_long(" + << CORBA::tk_long << "),tk_objref)(" << CORBA::tk_objref << ")) ERROR : " << aValue.type()->kind() ; break; } - cdebug << ")" << endl; - - GraphBase::OutPort *fromDataNodePort = NULL ; + cdebug << " ) in Graph " << Name() << endl; GraphBase::ComputingNode *toNode ; GraphBase::InPort *toPort ; - char *aNode ; - char *aPort ; - NodePort( ToNodeName , ToServiceParameterName , &aNode , &aPort ) ; - toNode = GetChangeGraphNode( aNode ) ; + char *aNodeName ; + char *aPortName ; + NodePort( ToNodeName , ToServiceParameterName , &aNodeName , &aPortName ) ; + toNode = GetChangeGraphNode( aNodeName ) ; + cdebug << "in Graph " << Name() << " aNodeName " << aNodeName << " aPortName " << aPortName << endl; if ( toNode ) { - toPort = toNode->GetChangeInPort( aPort ) ; + toPort = toNode->GetChangeInPort( aPortName ) ; if ( toPort && !toPort->IsDataConnected() ) { toPort->RemoveOutPort() ; } @@ -1069,20 +1132,17 @@ bool GraphBase::Graph::AddInputData( const char* ToNodeName , else { toPort = NULL ; } - delete aNode ; - delete aPort ; -#if 0 int i ; for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) { - cdebug "GraphBase::Graph::AddInputData " << GetNodeOutDataNodePort(i) << endl ; + cdebug "Graph::AddInputData In" << i << " " << *GetNodeOutDataNodePort(i) << endl ; } for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) { - cdebug "GraphBase::Graph::AddInputData " << GetNodeInDataNodePort(i) << endl ; + cdebug "Graph::AddInputData Out" << i << " " << *GetNodeInDataNodePort(i) << endl ; } -#endif if ( toNode && toPort ) { + GraphBase::OutPort *fromDataNodePort = NULL ; fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ; if ( fromDataNodePort && fromDataNodePort->GetInPort( toPort ) ) { fromDataNodePort->RemoveInPort( toPort ) ; @@ -1094,16 +1154,20 @@ bool GraphBase::Graph::AddInputData( const char* ToNodeName , toNode , toPort ) ; if ( RetVal ) { fromDataNodePort->Value( aValue ) ; + fromDataNodePort->PortStatus( DataConnected ) ; } } else { - cdebug << "Node not found" << endl ; + cdebug << "Node and/or Port not found : " << aNodeName << " " << aPortName << endl ; } + delete aNodeName ; + delete aPortName ; cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl; return RetVal ; } +// Used in the Executor in order to change an Input Value and ReRun bool GraphBase::Graph::ChangeInputData( const char * ToNodeName , const char * ToServiceParameterName , const CORBA::Any aValue ) { @@ -1147,6 +1211,7 @@ bool GraphBase::Graph::ChangeInputData( const char * ToNodeName , if ( fromPort ) { RetVal = true ; fromPort->Value( aValue ) ; + fromPort->PortStatus( DataConnected ) ; toPort->State( SUPERV::ReadyState ) ; } else { @@ -1165,50 +1230,13 @@ bool GraphBase::Graph::ChangeInputData( const char * ToNodeName , 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 ; -} - +// To restore InputData in CreateService 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 " ; + cdebug_in << "GraphBase::Graph::AddInputData( " << ToNodeName << " , " + << ToServiceParameterName << ", **Any " ; const CORBA::Any theValue = **aValue ; switch (theValue.type()->kind()) { case CORBA::tk_string: @@ -1233,14 +1261,13 @@ bool GraphBase::Graph::AddInputData( const char* ToNodeName , cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR"; break; } - cdebug << ")" << endl; + cdebug << ") of Graph " << Name() << endl; GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ; - GraphBase::OutPort *fromDataNodePort = NULL ; - GraphBase::InPort *toPort = NULL ; - if ( toNode ) { + GraphBase::InPort *toPort = NULL ; + GraphBase::OutPort *fromDataNodePort = NULL ; toPort = toNode->GetChangeInPort( ToServiceParameterName ) ; fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ; cdebug << "Try AddLink " << Name() << "( " << fromDataNodePort << " ) -->" @@ -1249,47 +1276,51 @@ bool GraphBase::Graph::AddInputData( const char* ToNodeName , toNode , toPort ) ; if ( RetVal ) { fromDataNodePort->Value( aValue ) ; + fromDataNodePort->PortStatus( DataConnected ) ; } } else { - cdebug << "Node not found" << endl ; + cdebug << "Node not found " << ToNodeName << " ERROR. Known nodes :" << endl ; + map< string , int >::iterator aMapOfGraphNodesIterator ; + int i = 0 ; + for ( aMapOfGraphNodesIterator = _MapOfGraphNodes.begin() ; + aMapOfGraphNodesIterator != _MapOfGraphNodes.end() ; aMapOfGraphNodesIterator++ ) { + cdebug << "MapOfGraphNodes " << i++ << " " << aMapOfGraphNodesIterator->first << " --> " + << aMapOfGraphNodesIterator->second << endl ; + } } - cdebug_out << "GraphBase::Graph::AddInputData" << endl; + cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << 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 ; +bool GraphBase::Graph::AddOutputData( const char* FromNodeName , + const char* FromServiceParameterName , + const CORBA::Any aValue ) { + bool RetVal = true ; cdebug_in << "GraphBase::Graph::AddOutputData(" << FromNodeName << "," - << FromServiceParameterName -// << FromServiceParameterName << ", " << DataValue << "," -// << aKindOfPortValue - << ")" << endl; -#if 0 + << FromServiceParameterName << ")" << endl; GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ; - GraphBase::OutPort *fromPort = NULL ; - GraphBase::InPort *toDataNodePort = NULL ; + GraphBase::OutPort *anOutPort = NULL ; if ( fromNode ) { - fromPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ; - toDataNodePort = GraphBase::DataNode::GetChangeOutDataNodePort( fromPort->NodePortName() ) ; - RetVal = AddLink( fromNode , fromPort , - (GraphBase::ComputingNode * ) this , toDataNodePort , - aValue ) ; -// DataValue , aKindOfPortValue ) ; + anOutPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ; +// toDataNodePort = GraphBase::DataNode::GetChangeOutDataNodePort( fromPort->NodePortName() ) ; +// RetVal = AddLink( fromNode , fromPort , +// (GraphBase::ComputingNode * ) this , toDataNodePort ) ; + anOutPort->Value( aValue ) ; + anOutPort->State( SUPERV::ReadyState ) ; + anOutPort->Done( true ) ; + cdebug << *anOutPort ; + anOutPort->StringValue( *_fdebug ) ; + cdebug << endl ; } else { cdebug << "Node not found" << endl ; + RetVal = false ; } -#endif - cdebug_out << "GraphBase::Graph::AddOutputData" << endl; + cdebug_out << "GraphBase::Graph::AddOutputData " << RetVal << endl; return RetVal ; } @@ -1320,17 +1351,40 @@ int GraphBase::Graph::GetServiceNameNumber( SALOME_ModuleCatalog::Service aServi return theService->NewInstance() ; } +void GraphBase::Graph::SetGraphPorts() { + cdebug_in << "GraphBase::Graph::SetGraphPorts fill ports of Graph" << endl; + int i ; + for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) { + GraphBase::OutPort * anOutPort = GetChangeNodeInDataNodePort( i ) ; + cdebug << "SetGraphPorts Out" << i << " " << anOutPort->PortName() << " " << anOutPort->PortType() + << " " << anOutPort->Kind() << " " << anOutPort->PortStatus() << " " << anOutPort->State() << endl ; + if ( !anOutPort->IsGate() ) { + anOutPort->PortStatus( ExternConnected ) ; + } + } + for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) { + GraphBase::InPort * anInPort = GetChangeNodeOutDataNodePort( i ) ; + cdebug << "SetGraphPorts In" << i << " " << anInPort->PortName() << " " << anInPort->PortType() + << " " << anInPort->Kind() << " " << anInPort->PortStatus() << " " << anInPort->State() << endl ; + if ( !anInPort->IsGate() ) { + GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; + anOutPort->PortStatus( ExternConnected ) ; + } + } + cdebug_out << "GraphBase::Graph::SetGraphPorts" << endl; +} + bool GraphBase::Graph::CreateService() { - cdebug_in << "GraphBase::Graph::CreateService" << endl; + cdebug_in << "GraphBase::Graph::CreateService " << Name() << " GraphMacroLevel : " << GraphMacroLevel() << endl; bool RetVal = true ; SALOME_ModuleCatalog::Service aService ; int i , j ; GraphBase::ComputingNode * aToNode ; int dostore ; - int innbr ; - int instreamnbr ; - int outnbr ; - int outstreamnbr ; + int innbr = 0 ; + int instreamnbr = 0 ; + int outnbr = 0 ; + int outstreamnbr = 0 ; vector< SUPERV::KindOfPort > InPortsKind ; vector< SALOME_ModuleCatalog::DataStreamDependency > InDataStreamDependency ; vector< SUPERV::KindOfSchema > InKindOfSchema ; @@ -1339,154 +1393,164 @@ bool GraphBase::Graph::CreateService() { vector< SUPERV::KindOfPort > OutPortsKind ; vector< SALOME_ModuleCatalog::DataStreamDependency > OutDataStreamDependency ; vector< long > OutNumberOfValues ; - for ( dostore = 0 ; dostore <= 2 ; dostore++ ) { - if ( dostore == 1 ) { - aService.ServiceName = Name() ; - aService.ServiceinParameter.length( 0 ) ; - aService.ServiceinParameter.length( innbr ) ; - aService.ServiceoutParameter.length( 0 ) ; - aService.ServiceoutParameter.length( outnbr ) ; - InPortsKind.resize( innbr ) ; - InDataStreamDependency.resize( innbr ) ; - InKindOfSchema.resize( innbr ) ; - InKindOfInterpolation.resize( innbr ) ; - InKindOfExtrapolation.resize( innbr ) ; - OutPortsKind.resize( outnbr ) ; - OutDataStreamDependency.resize( outnbr ) ; - OutNumberOfValues.resize( outnbr ) ; - } - else if ( dostore == 2 ) { - cdebug << "GraphBase::Graph::CreateService ->DataService innbr " << innbr << " instreamnbr " << instreamnbr << " outnbr " << outnbr - << " outstreamnbr " << outstreamnbr << endl ; - DataService( _Orb , aService , Graph_prof_debug() , Graph_fdebug() ) ; - aService.ServiceinParameter.length( innbr + instreamnbr ) ; - aService.ServiceoutParameter.length( outnbr + outstreamnbr ) ; - InPortsKind.resize( innbr + instreamnbr ) ; - InDataStreamDependency.resize( innbr + instreamnbr ) ; - InKindOfSchema.resize( innbr + instreamnbr ) ; - InKindOfInterpolation.resize( innbr + instreamnbr ) ; - InKindOfExtrapolation.resize( innbr + instreamnbr ) ; - OutPortsKind.resize( outnbr + outstreamnbr ) ; - OutDataStreamDependency.resize( outnbr + outstreamnbr ) ; - OutNumberOfValues.resize( outnbr + outstreamnbr ) ; - } - if ( dostore == 0 ) { - innbr = 0 ; - instreamnbr = 0 ; - outnbr = 0 ; - outstreamnbr = 0 ; - } - if ( dostore == 1 ) { - innbr = 0 ; - outnbr = 0 ; - } - for ( i = 0 ; i < GraphNodesSize() ; i++ ) { - aToNode = GraphNodes( i ) ; - for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) { - GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ; - bool isfromcouplednode = false ; - cdebug << "GraphBase::Graph::CreateService aToNode " << aToNode->Name() << " InPort" << j << endl ; - if ( anInPort->IsConnected() && anInPort->GetOutPort() ) { - GraphBase::ComputingNode * aFromNode = GetChangeGraphNode( anInPort->GetOutPort()->NodeName() ) ; - if ( aFromNode->IsEndLoopNode() && ((GraphBase::EndOfLoopNode * ) aFromNode)->CoupledNode() == aToNode ) { - isfromcouplednode = true ; +// if ( GraphMacroLevel() == 0 ) { + for ( dostore = 0 ; dostore <= 2 ; dostore++ ) { + if ( dostore == 1 ) { + aService.ServiceName = Name() ; + aService.ServiceinParameter.length( 0 ) ; + aService.ServiceinParameter.length( innbr ) ; + aService.ServiceoutParameter.length( 0 ) ; + aService.ServiceoutParameter.length( outnbr ) ; + InPortsKind.resize( innbr ) ; + InDataStreamDependency.resize( innbr ) ; + InKindOfSchema.resize( innbr ) ; + InKindOfInterpolation.resize( innbr ) ; + InKindOfExtrapolation.resize( innbr ) ; + OutPortsKind.resize( outnbr ) ; + OutDataStreamDependency.resize( outnbr ) ; + OutNumberOfValues.resize( outnbr ) ; + } + else if ( dostore == 2 ) { + cdebug << "GraphBase::Graph::CreateService ->DataService innbr " << innbr + << " instreamnbr " << instreamnbr << " outnbr " << outnbr + << " outstreamnbr " << outstreamnbr << endl ; + DataService( _Orb , aService , Graph_prof_debug() , Graph_fdebug() ) ; + aService.ServiceinParameter.length( innbr + instreamnbr ) ; + aService.ServiceoutParameter.length( outnbr + outstreamnbr ) ; + InPortsKind.resize( innbr + instreamnbr ) ; + InDataStreamDependency.resize( innbr + instreamnbr ) ; + InKindOfSchema.resize( innbr + instreamnbr ) ; + InKindOfInterpolation.resize( innbr + instreamnbr ) ; + InKindOfExtrapolation.resize( innbr + instreamnbr ) ; + OutPortsKind.resize( outnbr + outstreamnbr ) ; + OutDataStreamDependency.resize( outnbr + outstreamnbr ) ; + OutNumberOfValues.resize( outnbr + outstreamnbr ) ; + } + if ( dostore == 0 ) { + innbr = 0 ; + instreamnbr = 0 ; + outnbr = 0 ; + outstreamnbr = 0 ; + } + if ( dostore == 1 ) { + innbr = 0 ; + outnbr = 0 ; + } + for ( i = 0 ; i < GraphNodesSize() ; i++ ) { + aToNode = GraphNodes( i ) ; + for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) { + GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ; + bool isfromcouplednode = false ; + if ( !anInPort->IsNotConnected() ) { + const char * aFromNodeName = anInPort->GetOutPort()->NodeName() ; + GraphBase::ComputingNode * aFromNode = GetChangeGraphNode( aFromNodeName ) ; + cdebug << "GraphBase::Graph::CreateService aFromNodeName " << aFromNodeName << " aToNode " + << aToNode->Name() << " InPort" << j << " " << anInPort->PortName() << endl ; + if ( aFromNode && aFromNode->IsEndLoopNode() && + ((GraphBase::EndOfLoopNode * ) aFromNode)->CoupledNode() == aToNode ) { + isfromcouplednode = true ; + } } - } - if ( !anInPort->IsGate() && !anInPort->IsLoop() && - ( !anInPort->IsConnected() || ( anInPort->IsConnected() && isfromcouplednode ) ) ) { - if ( dostore == 0 ) { - cdebug << "CreateService " << aToNode->Name() << " Input port " - << anInPort->PortName() << " " << anInPort->Kind() << " is NOT connected " ; - if ( anInPort->GetOutPort() ) { - cdebug << "DataConnected from " << *(anInPort->GetOutPort() ) ; + if ( !anInPort->IsGate() && !anInPort->IsLoop() && + ( !anInPort->IsPortConnected() || + ( anInPort->IsPortConnected() && isfromcouplednode ) ) ) { + if ( dostore == 0 ) { + cdebug << "CreateService " << aToNode->Name() << " Input port " + << anInPort->PortName() << " " << anInPort->Kind() << " " << anInPort->PortStatus() ; + if ( anInPort->GetOutPort() ) { + cdebug << "DataConnected from " << *(anInPort->GetOutPort() ) ; + } + cdebug << endl ; + if ( anInPort->IsDataStream() ) { + instreamnbr += 1 ; + } + else { + innbr += 1 ; + } } - cdebug << endl ; - if ( anInPort->IsDataStream() ) { - instreamnbr += 1 ; + else if ( ( dostore == 1 && !anInPort->IsDataStream() ) || + ( dostore == 2 && anInPort->IsDataStream() ) ) { + aService.ServiceinParameter[innbr].Parametertype = CORBA::string_dup( anInPort->PortType() ) ; + aService.ServiceinParameter[innbr].Parametername = CORBA::string_dup( anInPort->NodePortName() ) ; + InPortsKind[ innbr ] = anInPort->Kind() ; + InDataStreamDependency[ innbr ] = anInPort->Dependency() ; + if ( dostore == 2 && anInPort->IsDataStream() ) { + ((GraphBase::InDataStreamPort * ) anInPort)->Params( InKindOfSchema[ innbr ] , + InKindOfInterpolation[ innbr ] , + InKindOfExtrapolation[ innbr ] ) ; + } + cdebug << "In" << innbr << " " << aService.ServiceinParameter[ innbr ].Parametername << " " + << anInPort->Kind() << " " << anInPort->PortStatus() << endl ; + innbr += 1 ; + } + } + else if ( dostore == 0 ) { + cdebug << "CreateService " << aToNode->Name() << " Input port " << anInPort->PortName() + << " " << anInPort->PortStatus() ; + if ( anInPort->IsPortConnected() ) { + cdebug << " is connected " ; } else { - innbr += 1 ; + cdebug << " is NOT connected " ; } - } - else if ( ( dostore == 1 && !anInPort->IsDataStream() ) || - ( dostore == 2 && anInPort->IsDataStream() ) ) { - aService.ServiceinParameter[innbr].Parametertype = CORBA::string_dup( anInPort->PortType() ) ; - aService.ServiceinParameter[innbr].Parametername = CORBA::string_dup( anInPort->NodePortName() ) ; - InPortsKind[ innbr ] = anInPort->Kind() ; - InDataStreamDependency[ innbr ] = anInPort->Dependency() ; - if ( dostore == 2 && anInPort->IsDataStream() ) { - ((GraphBase::InDataStreamPort * ) anInPort)->Params( InKindOfSchema[ innbr ] , - InKindOfInterpolation[ innbr ] , - InKindOfExtrapolation[ innbr ] ) ; + if ( anInPort->IsGate() ) { + cdebug << " IsGate " ; + } + if ( anInPort->GetOutPort() ) { + cdebug << "DataConnected from " << *(anInPort->GetOutPort()) ; } - cdebug << "In" << innbr << " " << aService.ServiceinParameter[ innbr ].Parametername << " " - << anInPort->Kind() << endl ; - innbr += 1 ; + else { + cdebug << "NOT DataConnected" ; + } + cdebug << endl ; } } - else if ( dostore == 0 ) { - cdebug << "CreateService " << aToNode->Name() << " Input port " << anInPort->PortName() ; - if ( anInPort->IsConnected() ) { - cdebug << " is connected " ; - } - else { - cdebug << " is NOT connected " ; - } - if ( anInPort->IsGate() ) { - cdebug << " IsGate " ; - } - if ( anInPort->GetOutPort() ) { - cdebug << "DataConnected from " << *(anInPort->GetOutPort()) ; - } - else { - cdebug << "NOT DataConnected" ; - } - cdebug << endl ; - } - } - GraphBase::ComputingNode * aFromNode = aToNode ; - for ( j = 0 ; j < aFromNode->GetNodeOutPortsSize() ; j++ ) { - GraphBase::OutPort *anOutPort = aFromNode->GetChangeNodeOutPort(j) ; -// cdebug << "CreateService Node " << aFromNode->Name() << ". Output port[" << j << "] "; -// if ( anOutPort ) { -// cdebug << anOutPort->PortName() << " " << anOutPort->ServicesParameterType() << endl ; -// } -// else { -// cdebug << " NULL" << endl ; -// } - if ( !aFromNode->IsGOTONode() ) { - if ( !anOutPort->IsGate() && - ( anOutPort->IsNotConnected() || anOutPort->IsDataConnected() ) ) { - if ( dostore == 0 ) { -// cdebug << "CreateService " << aFromNode->Name() << " Output port " -// << anOutPort->PortName() << endl ; - if ( anOutPort->IsDataStream() ) { - outstreamnbr += 1 ; + GraphBase::ComputingNode * aFromNode = aToNode ; + for ( j = 0 ; j < aFromNode->GetNodeOutPortsSize() ; j++ ) { + GraphBase::OutPort *anOutPort = aFromNode->GetChangeNodeOutPort(j) ; +// cdebug << "CreateService Node " << aFromNode->Name() << ". Output port[" << j << "] "; +// if ( anOutPort ) { +// cdebug << anOutPort->PortName() << " " << anOutPort->ServicesParameterType() << endl ; +// } +// else { +// cdebug << " NULL" << endl ; +// } + if ( !aFromNode->IsGOTONode() ) { + if ( !anOutPort->IsGate() && ( anOutPort->IsNotConnected() || anOutPort->IsDataConnected() ) || + anOutPort->IsExternConnected() ) { + if ( dostore == 0 ) { +// cdebug << "CreateService " << aFromNode->Name() << " Output port " +// << anOutPort->PortName() << " " << anOutPort->PortStatus() << endl ; + if ( anOutPort->IsDataStream() ) { + outstreamnbr += 1 ; + } + else { + outnbr += 1 ; + } } - else { + else if ( ( dostore == 1 && !anOutPort->IsDataStream() ) || + ( dostore == 2 && anOutPort->IsDataStream() ) ) { + aService.ServiceoutParameter[outnbr].Parametertype = CORBA::string_dup( anOutPort->PortType() ) ; + aService.ServiceoutParameter[outnbr].Parametername = CORBA::string_dup( anOutPort->NodePortName() ) ; + OutPortsKind[ outnbr ] = anOutPort->Kind() ; + OutDataStreamDependency[ outnbr ] = anOutPort->Dependency() ; + if ( dostore == 2 && anOutPort->IsDataStream() ) { + OutNumberOfValues[ outnbr ] = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ; + } +// cdebug << "Out" << outnbr << " " << aService.ServiceoutParameter[ outnbr ].Parametername << " " +// << anOutPort->Kind() << " " << anOutPort->PortStatus() << endl ; outnbr += 1 ; } } - else if ( ( dostore == 1 && !anOutPort->IsDataStream() ) || - ( dostore == 2 && anOutPort->IsDataStream() ) ) { - aService.ServiceoutParameter[outnbr].Parametertype = CORBA::string_dup( anOutPort->PortType() ) ; - aService.ServiceoutParameter[outnbr].Parametername = CORBA::string_dup( anOutPort->NodePortName() ) ; - OutPortsKind[ outnbr ] = anOutPort->Kind() ; - OutDataStreamDependency[ outnbr ] = anOutPort->Dependency() ; - if ( dostore == 2 && anOutPort->IsDataStream() ) { - OutNumberOfValues[ outnbr ] = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ; - } - cdebug << "Out" << outnbr << " " << aService.ServiceoutParameter[ outnbr ].Parametername << " " - << anOutPort->Kind() << endl ; - outnbr += 1 ; - } } } } } - } +// } - MESSAGE( "DataFlowNode ServiceName " << aService.ServiceName ); +#if 0 + cdebug << "DataFlowNode ServiceName " << aService.ServiceName << " InPorts " << innbr + << " OutPorts " << outnbr << endl ; for ( i = 0 ; i < innbr ; i++ ) { cdebug << "aService.ServiceinParameter[" << i << "].Parametertype " << aService.ServiceinParameter[i].Parametertype << " Parametername " @@ -1503,6 +1567,7 @@ bool GraphBase::Graph::CreateService() { cdebug << "NodeOutPort[" << i << "] " << *GetChangeNodeOutPort( i ) << endl ; } } +#endif // DataService( _Orb , aService , InPortsKind , OutPortsKind , Graph_prof_debug() , Graph_fdebug() ) ; for ( i = 0 ; i < innbr ; i++ ) { @@ -1515,13 +1580,14 @@ bool GraphBase::Graph::CreateService() { InKindOfInterpolation[ i ] , InKindOfExtrapolation[ i ] ) ; // NOT A BUG : AddOutPort for an inport (Reversed service) - anInPort = (GraphBase::InDataStreamPort * ) _DataFlowDataPorts->AddOutPort( _Orb , NamePtr() , - Kind() , - aService.ServiceinParameter[ i ].Parametername , - aService.ServiceinParameter[ i ].Parametertype , - SUPERV::DataStreamParameter , -// _DataFlowDataPorts->DataStreamOutPortsNumber() , - _Graph_prof_debug , _Graph_fdebug ) ; + anInPort = (GraphBase::InDataStreamPort * ) _DataFlowDataPorts->AddOutPort( + _Orb , NamePtr() , + Kind() , + aService.ServiceinParameter[ i ].Parametername , + aService.ServiceinParameter[ i ].Parametertype , + SUPERV::DataStreamParameter , + - 1 , + _Graph_prof_debug , _Graph_fdebug ) ; anInPort->Dependency( InDataStreamDependency[ i ] ) ; // Attention : revoir les reversed DataStreamPorts // anInPort->SetParams( InKindOfSchema[ i ] , @@ -1549,13 +1615,14 @@ bool GraphBase::Graph::CreateService() { SUPERV::DataStreamParameter ) ; anOutPort->NumberOfValues( OutNumberOfValues[ i ] ) ; // NOT A BUG : AddInPort for an outport (Reversed service) - anOutPort = (GraphBase::OutDataStreamPort * ) _DataFlowDataPorts->AddInPort( _Orb , NamePtr() , - Kind() , - aService.ServiceoutParameter[ i ].Parametername , - aService.ServiceoutParameter[ i ].Parametertype , - SUPERV::DataStreamParameter , -// _DataFlowDataPorts->DataStreamInPortsNumber() , - _Graph_prof_debug , _Graph_fdebug ) ; + anOutPort = (GraphBase::OutDataStreamPort * ) _DataFlowDataPorts->AddInPort( + _Orb , NamePtr() , + Kind() , + aService.ServiceoutParameter[ i ].Parametername , + aService.ServiceoutParameter[ i ].Parametertype , + SUPERV::DataStreamParameter , + - 1 , + _Graph_prof_debug , _Graph_fdebug ) ; anOutPort->Dependency( OutDataStreamDependency[ i ] ) ; // Attention : revoir les reversed DataStreamPorts // anOutPort->NumberOfValues( OutNumberOfValues[ i ] ) ; @@ -1575,7 +1642,7 @@ bool GraphBase::Graph::CreateService() { << endl ; } } -// Restore input datas : +// Restore input datas and links : DataStreamInPortsNumber( 0 ) ; DataStreamOutPortsNumber( 0 ) ; for ( i = 0 ; i < GraphNodesSize() ; i++ ) { @@ -1584,15 +1651,51 @@ bool GraphBase::Graph::CreateService() { DataStreamOutPortsNumber( DataStreamOutPortsNumber() + aToNode->DataStreamOutPortsNumber() ) ; for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) { GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ; - if ( anInPort->IsDataConnected() ) { - AddInputData( anInPort->NodeName() , - anInPort->PortName() , - anInPort->GetOutPort()->ValuePtr() ) ; + if ( !anInPort->IsGate() && anInPort->IsDataConnected() ) { + if ( !AddInputData( anInPort->NodeName() , + anInPort->PortName() , + anInPort->GetOutPort()->ValuePtr() ) ) { + cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") " + << anInPort->PortStatus() << " --> AddInputData ERROR" << endl ; + RetVal = false ; + } + else { + cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") " + << anInPort->PortStatus() << " --> AddInputData" << endl ; + } + } + else if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) { + if ( !AddLink( this , GetChangeInDataNodePort( anInPort->NodePortName() ) , aToNode , anInPort ) ) { + cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") " + << anInPort->PortStatus() << " --> AddInLink ERROR" << endl ; + RetVal = false ; + } + else { + cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") " + << anInPort->PortStatus() << " --> AddInLink" << endl ; + } + } + } + for ( j = 0 ; j < aToNode->GetNodeOutPortsSize() ; j++ ) { + GraphBase::OutPort *anOutPort = aToNode->GetChangeNodeOutPort(j) ; + cdebug << "CreateService Out" << j << " " << anOutPort->NodeName() << "(" << anOutPort->PortName() + << ") " << anOutPort->PortStatus() << " :" << endl ; + if ( !anOutPort->IsGate() && anOutPort->IsNotConnected() && !aToNode->IsGOTONode() ) { + GraphBase::InPort *anInPort = GetChangeOutDataNodePort( anOutPort->NodePortName() ) ; + if ( !AddLink( aToNode , anOutPort , this , anInPort ) ) { + cdebug << " --> " << Name() << "(" << anInPort->PortName() + << ") " << anInPort->PortStatus() << " AddOutLink ERROR" << endl ; + RetVal = false ; + } + else { + cdebug << " --> " << Name() << "(" << anInPort->PortName() + << ") " << anInPort->PortStatus() << " AddOutLink" << endl ; + } } } } - cdebug_out << "GraphBase::Graph::CreateService" << endl; + cdebug_out << "GraphBase::Graph::CreateService " << RetVal << endl; return RetVal ; } @@ -1605,9 +1708,8 @@ bool GraphBase::Graph::InLineServices() { SALOME_ModuleCatalog::Service aService ; for ( i = 0 ; i < GraphNodesSize() ; i++ ) { aINode = (GraphBase::InLineNode * ) GraphNodes( i ) ; -// if ( aINode->IsOneOfInLineNodes() || aINode->HasDataStream() ) { if ( aINode->IsOneOfInLineNodes() ) { - cdebug << "GraphBase::Graph::InLineServices " << aINode->Name() << endl; +// cdebug << "GraphBase::Graph::InLineServices " << aINode->Name() << endl; aService.ServiceName = aINode->ServiceName() ; aService.ServiceinParameter.length( 0 ) ; aService.ServiceoutParameter.length( 0 ) ; @@ -1616,14 +1718,15 @@ bool GraphBase::Graph::InLineServices() { int InService = 0 ; int InStreamService = 0 ; for ( j = 0 ; j < aINode->GetNodeInPortsSize() ; j++ ) { -// if ( aINode->GetChangeNodeInPort(j)->IsGate() || aINode->GetChangeNodeInPort(j)->IsLoop() || aINode->GetChangeNodeInPort(j)->IsDataStream() ) { if ( aINode->GetChangeNodeInPort(j)->IsGate() || aINode->GetChangeNodeInPort(j)->IsLoop() ) { +#if 0 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; +#endif } else if ( aINode->GetChangeNodeInPort(j)->IsDataStream() ) { aService.ServiceinDataStreamParameter.length( InStreamService+1 ) ; @@ -1631,23 +1734,27 @@ bool GraphBase::Graph::InLineServices() { aService.ServiceinDataStreamParameter[InStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ; aService.ServiceinDataStreamParameter[InStreamService++].Parameterdependency = aINode->GetChangeNodeInPort(j)->Dependency() ; aINode->IncrDataStreamInPorts() ; +#if 0 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; +#endif } 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() ) ; +#if 0 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; +#endif } } int OutService = 0 ; @@ -1655,12 +1762,14 @@ bool GraphBase::Graph::InLineServices() { for ( j = 0 ; j < aINode->GetNodeOutPortsSize() ; j++ ) { // if ( aINode->GetChangeNodeOutPort(j)->IsGate() || aINode->GetChangeNodeOutPort(j)->IsLoop() || aINode->GetChangeNodeOutPort(j)->IsDataStream() ) { if ( aINode->GetChangeNodeOutPort(j)->IsGate() || aINode->GetChangeNodeOutPort(j)->IsLoop() ) { +#if 0 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; +#endif } else if ( aINode->GetChangeNodeOutPort(j)->IsDataStream() ) { aService.ServiceoutDataStreamParameter.length( OutStreamService+1 ) ; @@ -1668,30 +1777,36 @@ bool GraphBase::Graph::InLineServices() { aService.ServiceoutDataStreamParameter[OutStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ; aService.ServiceoutDataStreamParameter[OutStreamService++].Parameterdependency = aINode->GetChangeNodeOutPort(j)->Dependency() ; aINode->IncrDataStreamOutPorts() ; +#if 0 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; +#endif } 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() ) ; +#if 0 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; +#endif } } aINode->SetService( aService ) ; if ( SetServiceOfMap( (GraphBase::Service * ) aINode ) ) { +#if 0 cdebug << "InLineServices SetServiceOfMap " << aINode->ServiceName() << " in MapOfServices" << " InStreamPort(" << aINode->DataStreamInPortsNumber() << ") OutStreamPort(" << aINode->DataStreamOutPortsNumber() << ")" << endl ; +#endif } // cdebug << "GraphBase::Graph::InLineServices" << *aINode->GetService() << endl; } @@ -1723,6 +1838,7 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) { // - Sorted = false : the node is not sorted // - CnxInPortsNumber = ConnectedInPortsNumber : the number of ports that wait for a value from a link // - DecrInPortsNumber = 0 : there is no value available. +#if 0 cdebug << "GraphBase::Graph::Sort initial values :" << endl ; for ( i = 0 ; i < GraphNodesSize() ; i++ ) { GraphBase::ComputingNode * aNode = GraphNodes( i ) ; @@ -1731,11 +1847,13 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) { cdebug << " " << aNode->LinkedNodes( j )->Name() << endl ; } } +#endif for ( i = 0 ; i < GraphNodesSize() ; i++ ) { _Sorted[ i ] = false ; _CnxInPortsNumber[ i ] = GraphNodes( i )->ConnectedInPortsNumber() ; _DecrInPortsNumber[ i ] = 0 ; - cdebug << "Sort Node [" << i << "] " << GraphNodes( i )->Name() << " initial count " << _CnxInPortsNumber[ i ] << endl ; +// cdebug << "Sort Node [" << i << "] " << GraphNodes( i )->Name() << " initial count " +// << _CnxInPortsNumber[ i ] << endl ; } // Nodes are linked ONLY if Ports are NOT DataStream for topological sort of node @@ -1762,7 +1880,7 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) { NewSorted = true ; NotSortedNumber -= 1 ; cdebug << GraphNodes( i )->Name() << " belongs to level " - << _LevelsNumber << "." << endl ; + << _LevelsNumber << ". " << GraphNodes( i )->LinkedNodesSize() << " linkednodes" << endl ; // GraphNodes( i ) has the state "AllDataReady". We simulate the end of its execution : // So we loop over all nodes that have a link from that node // And we increment the number of input ports of GraphNodes( i )->LinkedNodes( j ) that this @@ -1783,7 +1901,6 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) { _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ] += aLinkedInPortsNumber ; } cdebug << endl ; -// GraphNodes( i )->LinkedNodes( j )->IncrDecrConnectedInPortsNumber( GraphNodes( i )->LinkedInPortsNumber( j ) ) ; } } } @@ -1793,17 +1910,17 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) { cdebug << "Loop detected level " << _LevelsNumber << endl ; return false ; // Loop in the Graph } - cdebug << "Bilan level " << _LevelsNumber << " : " << endl ; +// cdebug << "Bilan level " << _LevelsNumber << " : " << endl ; bool ChangeCount = false ; // We update now the number of InPorts with a link that are waiting for a value for ( i = 0 ; i < GraphNodesSize() ; i++ ) { if ( _DecrInPortsNumber[ i ] ) { - int prevcount = _CnxInPortsNumber[ 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 ; +// cdebug << " " << GraphNodes( i )->Name() << " count " << prevcount +// << " --> new count " << _CnxInPortsNumber[ i ] << endl ; } } // If there is no loop and if the number of InPorts with a link that are waiting for a value @@ -1847,10 +1964,10 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) { } } if ( _ParallelExecutionNodes ) { - cdebug << "Parallel Execution Nodes detected." << endl ; +// cdebug << "Parallel Execution Nodes detected." << endl ; } else { - cdebug << "No Parallel Execution Nodes detected." << endl ; +// cdebug << "No Parallel Execution Nodes detected." << endl ; } if ( AllSortedNodes != GraphNodesSize() ) { cdebug << "Loop detected level " << _LevelsNumber << endl ; @@ -1899,19 +2016,19 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) { for ( i = 0 ; i <= _LevelsNumber ; i++ ) { for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) { GraphBase::ComputingNode * aNode = (_SortedNodes[ i ])[ j ] ; - cdebug << "SubGraph " << aNode->SubGraph() << " " << aNode->Name() - << endl ; +// cdebug << "SubGraph " << 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() - << " SubGraph(" << aNode->LinkedNodes( k )->SubGraph() - << ") ==>" << endl ; - cdebug << " SubGraph " << aNode->SubGraph() << " for " - << aNode->Name() << " ==> again" << endl ; +// cdebug << " Linked " << aNode->LinkedNodes( k )->Name() +// << " SubGraph(" << aNode->LinkedNodes( k )->SubGraph() +// << ") ==>" << endl ; +// cdebug << " SubGraph " << aNode->SubGraph() << " for " +// << aNode->Name() << " ==> again" << endl ; int l ; for ( l = 0 ; l < aNode->LinkedNodesSize() ; l++ ) { aNode->LinkedNodes( l )->SubGraph( aNode->SubGraph() ) ; @@ -1920,15 +2037,15 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) { break ; } else { - cdebug << " Linked " << aNode->LinkedNodes( k )->Name() - << " SubGraph(" << aNode->LinkedNodes( k )->SubGraph() - << ") distance > 1 ignored" << endl ; +// cdebug << " Linked " << aNode->LinkedNodes( k )->Name() +// << " SubGraph(" << aNode->LinkedNodes( k )->SubGraph() +// << ") distance > 1 ignored" << endl ; } } else { - cdebug << " Linked " << aNode->LinkedNodes( k )->Name() - << " GraphInit to " << aNode->SubGraph() << " from " - << aNode->Name() << endl ; +// cdebug << " Linked " << aNode->LinkedNodes( k )->Name() +// << " GraphInit to " << aNode->SubGraph() << " from " +// << aNode->Name() << endl ; aNode->LinkedNodes( k )->SubGraph( aNode->SubGraph() ) ; } } @@ -1937,10 +2054,10 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) { break ; } if ( Graphs ) { - cdebug << endl << "SubGraphs result : " << endl ; +// cdebug << endl << "SubGraphs result : " << endl ; break ; } - cdebug << endl << "One more time" << endl ; +// cdebug << endl << "One more time" << endl ; Graphs = true ; } // Make a sequential renumbering of SubGraphs : @@ -1955,27 +2072,26 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) { for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) { if ( (_SortedNodes[ i ])[ j ]->SubGraph() == CurrGraphsNumber ) { (_SortedNodes[ i ])[ j ]->SubGraph( _SubGraphsNumber ) ; - cdebug << "SubGraphsNumber " << _SubGraphsNumber << " " << " Level " - << i << " : " << (_SortedNodes[ i ])[ j ]->Name() - << endl ; +// cdebug << "SubGraphsNumber " << _SubGraphsNumber << " " << " Level " +// << i << " : " << (_SortedNodes[ i ])[ j ]->Name() +// << endl ; } } } } } - cdebug << endl << "Computation of SubStreamGraphs" << endl ; +// cdebug << endl << "Computation of SubStreamGraphs" << endl ; for ( i = 0 ; i < GraphNodesSize() ; i++ ) { GraphBase::ComputingNode * aNode = GraphNodes( i ) ; if ( aNode->SubStreamGraph() < 0 ) { - cdebug << "Graph " << aNode->SubStreamGraph() << " " << aNode->Name() - << " has NO streamport" << endl ; +// cdebug << "Graph " << aNode->Name() << " has NO streamport" << endl ; } else { - cdebug << aNode->Name() << " SubGraph " << aNode->SubGraph() << " --> " - << aNode->LinkedStreamNodesSize() << " LinkedStreamNodes :" << endl ; +// cdebug << aNode->Name() << " SubGraph " << aNode->SubGraph() << " --> " +// << aNode->LinkedStreamNodesSize() << " LinkedStreamNodes :" << endl ; for ( j = 0 ; j < aNode->LinkedStreamNodesSize() ; j++ ) { - cdebug << " " << aNode->LinkedStreamNodes( j )->Name() << endl ; +// cdebug << " " << aNode->LinkedStreamNodes( j )->Name() << endl ; } } } @@ -1989,14 +2105,14 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) { for ( jnode = 0 ; jnode <= _NodesNumber[ ilevel ] ; jnode++ ) { GraphBase::ComputingNode * aNode = (_SortedNodes[ ilevel ])[ jnode ] ; if ( aNode->SubStreamGraph() < 0 ) { - cdebug << "Graph " << aNode->SubStreamGraph() << " " << aNode->Name() - << " has NO streamport" << endl ; +// cdebug << "Graph " << aNode->SubStreamGraph() << " " << aNode->Name() +// << " has NO streamport" << endl ; } else { int CurStreamGraphsNumber ; if ( aNode->SubStreamGraph() > 0 ) { - cdebug << "SubStreamGraph " << aNode->SubStreamGraph() << " " << aNode->Name() - << " has streamport LinkedStreamNodesSize already in a SubStreamGraph" << endl ; +// cdebug << "SubStreamGraph " << aNode->SubStreamGraph() << " " << aNode->Name() +// << " has streamport LinkedStreamNodesSize already in a SubStreamGraph" << endl ; CurStreamGraphsNumber = aNode->SubStreamGraph() ; } else { @@ -2024,7 +2140,7 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) { } } // Make a sequential renumbering of SubGraphs : - cdebug << endl << "Last SubStreamGraphsNumber : " << SubStreamGraphsNumber << endl ; +// cdebug << endl << "Last SubStreamGraphsNumber : " << SubStreamGraphsNumber << endl ; int CurrStreamGraphsNumber = 0 ; int count = 0 ; for ( CurrStreamGraphsNumber = 0 ; CurrStreamGraphsNumber <= SubStreamGraphsNumber ; CurrStreamGraphsNumber++ ) { @@ -2036,19 +2152,19 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) { SearchCurrStreamGraphsNumber = false ; count = count + 1 ; if ( CurrStreamGraphsNumber != count ) { - cdebug << "CurrStreamGraphsNumber " << CurrStreamGraphsNumber << " count " << count - << " Level " << k << " n " << l << endl ; +// cdebug << "CurrStreamGraphsNumber " << CurrStreamGraphsNumber << " count " << count +// << " Level " << k << " n " << l << endl ; for ( i = k ; i <= _LevelsNumber ; i++ ) { for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) { if ( (_SortedNodes[ i ])[ j ]->SubStreamGraph() == CurrStreamGraphsNumber ) { (_SortedNodes[ i ])[ j ]->SubStreamGraph( count ) ; - cdebug << "SubStreamGraphsNumber " << CurrStreamGraphsNumber << " --> " << count << " " - << " Level " << i << " : " << (_SortedNodes[ i ])[ j ]->Name() << endl ; +// cdebug << "SubStreamGraphsNumber " << CurrStreamGraphsNumber << " --> " << count << " " +// << " Level " << i << " : " << (_SortedNodes[ i ])[ j ]->Name() << endl ; } else if ( (_SortedNodes[ i ])[ j ]->SubStreamGraph() > 0 ) { - cdebug << "SubStreamGraphsNumber " << (_SortedNodes[ i ])[ j ]->SubStreamGraph() - << " != " << CurrStreamGraphsNumber << " Level " << i << " : " - << (_SortedNodes[ i ])[ j ]->Name() << endl ; +// cdebug << "SubStreamGraphsNumber " << (_SortedNodes[ i ])[ j ]->SubStreamGraph() +// << " != " << CurrStreamGraphsNumber << " Level " << i << " : " +// << (_SortedNodes[ i ])[ j ]->Name() << endl ; } } } @@ -2058,7 +2174,7 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) { } } SubStreamGraphsNumber = count ; - cdebug << endl << "SubStreamGraphs result : " << SubStreamGraphsNumber << " SubStreamGraphs" << endl ; +// cdebug << endl << "SubStreamGraphs result : " << SubStreamGraphsNumber << " SubStreamGraphs" << endl ; // int CurrStreamGraphsNumber ; // for ( CurrStreamGraphsNumber = 1 ; CurrStreamGraphsNumber <= SubStreamGraphsNumber ; CurrStreamGraphsNumber++ ) { // for ( ilevel = 0 ; ilevel <= _LevelsNumber ; ilevel++ ) { @@ -2102,10 +2218,10 @@ bool GraphBase::Graph::ComputingNodes() const { int j ; for ( j = 1 ; j < aNode->GetNodeInPortsSize() ; j++ ) { const GraphBase::InPort *iP = aNode->GetNodeInPort(j); - if ( !iP->IsConnected() ){ - cdebug << "Le port d'entree " << iP->PortName() - << " du noeud de calcul " << aNode->Name() << " du graphe " - << Name() << " n'est pas connecte "<< endl; + if ( iP->IsNotConnected() ){ +// cdebug << "Le port d'entree " << iP->PortName() +// << " du noeud de calcul " << aNode->Name() << " du graphe " +// << Name() << " n'est pas connecte "<< endl; RetVal = false ; }; @@ -2120,15 +2236,15 @@ bool GraphBase::Graph::ComputingNodes() const { // break; } else { - cdebug << "Le port de sortie " << iP->PortName() - << " du noeud de calcul " << aNode->Name() << " du graphe " - << Name() << " n'est pas connecte "<< endl; +// cdebug << "Le port de sortie " << iP->PortName() +// << " du noeud de calcul " << aNode->Name() << " du graphe " +// << Name() << " n'est pas connecte "<< endl; RetVal = false ; } }; if (!oneOutPortConnected) { - cdebug << "Le noeud de calcul " << aNode->Name() << " du graphe " - << Name() << " n'a aucun port de sortie connecte "<< endl; +// cdebug << "Le noeud de calcul " << aNode->Name() << " du graphe " +// << Name() << " n'a aucun port de sortie connecte "<< endl; // _computingError.push_front(2); } }; @@ -2147,12 +2263,12 @@ bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) { GraphBase::LoopNode * aLoopNode = (GraphBase::LoopNode * ) aNode ; for ( j = 0 ; j < aLoopNode->GetNodeInPortsSize() ; j++ ) { GraphBase::InPort *anInPort = aLoopNode->GetChangeNodeInPort(j) ; - if ( !anInPort->IsGate() && !anInPort->IsConnected() && !anInPort->IsDataConnected() ) { + if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) { if ( !AddLink( aLoopNode->CoupledNode() , aLoopNode->CoupledNode()->GetChangeNodeOutPort( j ) , aLoopNode , anInPort ) ) { - cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->CoupledNode()->Name() - << "( " << aLoopNode->CoupledNode()->GetChangeNodeOutPort( j )->PortName() << " ) --> " - << aLoopNode->Name() << "( " << anInPort->PortName() << " )" << endl ; +// cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->CoupledNode()->Name() +// << "( " << aLoopNode->CoupledNode()->GetChangeNodeOutPort( j )->PortName() << " ) --> " +// << aLoopNode->Name() << "( " << anInPort->PortName() << " )" << endl ; RetVal = false ; } else { @@ -2162,12 +2278,12 @@ bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) { } for ( j = 0 ; j < aLoopNode->CoupledNode()->GetNodeInPortsSize() ; j++ ) { GraphBase::InPort *anInPort = aLoopNode->CoupledNode()->GetChangeNodeInPort( j ) ; - if ( !anInPort->IsConnected() && !anInPort->IsGate() ) { + if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) { if ( !AddLink( aLoopNode , aLoopNode->GetChangeNodeOutPort( j ) , aLoopNode->CoupledNode() , anInPort ) ) { - cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->Name() << "( " - << aLoopNode->GetChangeNodeOutPort( j )->PortName() << " ) --> " - << aLoopNode->CoupledNode()->Name() << "( " << anInPort->PortName() << " )" << endl ; +// cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->Name() << "( " +// << aLoopNode->GetChangeNodeOutPort( j )->PortName() << " ) --> " +// << aLoopNode->CoupledNode()->Name() << "( " << anInPort->PortName() << " )" << endl ; RetVal = false ; } else { @@ -2179,12 +2295,12 @@ bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) { else if ( aNode->IsGOTONode() ) { GraphBase::GOTONode * aGOTONode = (GraphBase::GOTONode * ) aNode ; GraphBase::OutPort *anOutGate = aGOTONode->GetChangeNodeOutGate() ; - if ( !anOutGate->IsConnected() ) { + if ( anOutGate->IsNotConnected() ) { if ( !AddLink( aGOTONode , anOutGate , aGOTONode->CoupledNode() , aGOTONode->CoupledNode()->GetChangeNodeInGate() ) ) { - cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aGOTONode->Name() << "( " - << anOutGate->PortName() << " ) --> " << aGOTONode->CoupledNode()->Name() << "( " - << aGOTONode->CoupledNode()->GetChangeNodeInGate()->PortName() << " )" << endl ; +// cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aGOTONode->Name() << "( " +// << anOutGate->PortName() << " ) --> " << aGOTONode->CoupledNode()->Name() << "( " +// << aGOTONode->CoupledNode()->GetChangeNodeInGate()->PortName() << " )" << endl ; RetVal = false ; } else { @@ -2234,24 +2350,24 @@ bool GraphBase::Graph::DataServerNodes() const { if ( aNode->IsFactoryNode() ) { GraphBase::FactoryNode * FaNode = (GraphBase::FactoryNode * ) aNode ; if ( !strlen( FaNode->Computer() ) ) { - cdebug << "ComputerName missing for node " << FaNode->Name() ; +// cdebug << "ComputerName missing for node " << FaNode->Name() ; if ( !strlen( FaNode->Computer() ) ) { ierr++ ; cdebug << endl ; } else { - cdebug << ". " << FaNode->Computer() << " will be used." << endl ; +// cdebug << ". " << FaNode->Computer() << " will be used." << endl ; } } } // For Outputs of the DataFlow : for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) { - if ( !aNode->GetNodeOutPort(j)->IsConnected() ) { + if ( aNode->GetNodeOutPort(j)->IsNotConnected() ) { if ( aNode->GetNodeOutPort(j)->IsDataStream() ) { - aNode->AddStreamLink( (GraphBase::ComputingNode *) this ) ; + aNode->AddStreamLinkedNode( (GraphBase::ComputingNode *) this ) ; } else { - aNode->AddLink( (GraphBase::ComputingNode *) this ) ; + aNode->AddLinkedNode( (GraphBase::ComputingNode *) this ) ; } } } diff --git a/src/GraphBase/DataFlowBase_Graph.hxx b/src/GraphBase/DataFlowBase_Graph.hxx index 16130df..35c07ad 100644 --- a/src/GraphBase/DataFlowBase_Graph.hxx +++ b/src/GraphBase/DataFlowBase_Graph.hxx @@ -101,6 +101,7 @@ namespace GraphBase { Graph( CORBA::ORB_ptr ORB , SALOME_NamingService* ptrNamingService , const char *DataFlowName , + const SUPERV::KindOfNode DataFlowkind , int * Graph_prof_debug , ofstream * Graph_fdebug ) ; // const char * DebugFileName ) ; @@ -137,8 +138,8 @@ namespace GraphBase { void SetObjImpl( Graph_Impl * aGraphImpl ) { _GraphImpl = aGraphImpl ; } ; - void AddLink( const char* FromNodeName , GraphBase::ComputingNode * anOutNode ) { - GetChangeGraphNode( FromNodeName )->AddLink( anOutNode ) ; } ; + void AddLinkedNode( const char* FromNodeName , GraphBase::ComputingNode * anOutNode ) { + GetChangeGraphNode( FromNodeName )->AddLinkedNode( anOutNode ) ; } ; const int GetGraphNodeIndex( const char *name ) { const int index = _MapOfGraphNodes[ name ] - 1 ; @@ -251,13 +252,13 @@ namespace GraphBase { const char* FromServiceParameterName ) ; bool LoadXml( CORBA::ORB_ptr Orb , const char* anXmlFile , - GraphBase::SGraph & aDataFlow ) ; + GraphBase::ListOfSGraphs & aListOfDataFlows ) ; GraphBase::SNode * GetInfo() const ; - GraphBase::ListOfNodes * GetNodes() const ; - GraphBase::ListOfLinks * GetLinks(bool AllLinks = false ) const ; - GraphBase::ListOfGraphs * GetGraphs() const ; - GraphBase::ListOfLinks * GetDatas() const ; + GraphBase::ListOfSNodes * GetNodes() const ; + GraphBase::ListOfSLinks * GetLinks(bool AllLinks = false ) const ; + GraphBase::ListOfSGraphs * GetGraphs() const ; + GraphBase::ListOfSLinks * GetDatas() const ; bool AddNode( ComputingNode * aNode ) ; bool RemoveNode( const char* NodeName ) ; @@ -267,8 +268,8 @@ namespace GraphBase { bool AddLink( const char* FromNodeName , const char* FromServiceParameterName , const char* ToNodeName , - const char* ToServiceParameterName , - const CORBA::Any aValue ) ; + const char* ToServiceParameterName ) ; +// , const CORBA::Any aValue ) ; bool RemoveLink( const char* FromNodeName , const char* FromServiceParameterName , const char* ToNodeName , @@ -286,11 +287,6 @@ namespace GraphBase { 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 ) ; @@ -299,6 +295,8 @@ namespace GraphBase { const char* FromParameterName , const CORBA::Any aValue ) ; + void SetGraphPorts() ; + bool CreateService() ; bool InLineServices() ; diff --git a/src/GraphBase/DataFlowBase_InLineNode.cxx b/src/GraphBase/DataFlowBase_InLineNode.cxx index d602ecf..4d763aa 100644 --- a/src/GraphBase/DataFlowBase_InLineNode.cxx +++ b/src/GraphBase/DataFlowBase_InLineNode.cxx @@ -17,17 +17,22 @@ using namespace std; GraphBase::InLineNode::InLineNode() : GraphBase::ComputingNode::ComputingNode() { + _FuncName = NULL ; _PythonFunction = SUPERV::ListOfStrings() ; + _MyPyRunMethod = NULL ; } GraphBase::InLineNode::InLineNode( CORBA::ORB_ptr ORB , SALOME_NamingService* ptrNamingService , const char * aDataFlowName , + const SUPERV::KindOfNode DataFlowkind , int * Graph_prof_debug , ofstream * Graph_fdebug ) : - GraphBase::ComputingNode::ComputingNode( ORB , ptrNamingService , aDataFlowName , + GraphBase::ComputingNode::ComputingNode( ORB , ptrNamingService , aDataFlowName , DataFlowkind , Graph_prof_debug , Graph_fdebug ) { + _FuncName = NULL ; _PythonFunction = SUPERV::ListOfStrings() ; + _MyPyRunMethod = NULL ; cdebug << "GraphBase::InLineNode::Node " << this << "' _Name " << (void *) Name() << " '" << Name() << " _Comment " @@ -57,6 +62,7 @@ GraphBase::InLineNode::InLineNode( CORBA::ORB_ptr ORB , NodeAuthor , NodeComment , GeneratedName , X , Y , Graph_prof_debug , Graph_fdebug ) { + _FuncName = NULL ; _PythonFunction = SUPERV::ListOfStrings() ; _MyPyRunMethod = NULL ; cdebug_in << "GraphBase::InLineNode::Node " << this @@ -104,8 +110,9 @@ GraphBase::InLineNode::InLineNode( CORBA::ORB_ptr ORB , << ServiceInParameter().length() << ") Out(" << ServiceOutParameter().length() << ")" << endl ; - _MyPyRunMethod = NULL ; + _FuncName = NULL ; SetPythonFunction( FuncName , aPythonFunction ) ; + _MyPyRunMethod = NULL ; SALOME_ModuleCatalog::Service aNodeService ; aNodeService.ServiceName = NodeName ; // python -> service diff --git a/src/GraphBase/DataFlowBase_InLineNode.hxx b/src/GraphBase/DataFlowBase_InLineNode.hxx index 903b6e4..ab18858 100644 --- a/src/GraphBase/DataFlowBase_InLineNode.hxx +++ b/src/GraphBase/DataFlowBase_InLineNode.hxx @@ -32,8 +32,9 @@ namespace GraphBase { InLineNode( CORBA::ORB_ptr ORB , SALOME_NamingService* ptrNamingService , const char * DataFlowName , - int * Graph_prof_debug = NULL , - ofstream * Graph_fdebug = NULL ) ; + const SUPERV::KindOfNode DataFlowkind , + int * Graph_prof_debug , + ofstream * Graph_fdebug ) ; InLineNode( CORBA::ORB_ptr ORB , SALOME_NamingService* ptrNamingService , const SALOME_ModuleCatalog::Service& NodeService , diff --git a/src/GraphBase/DataFlowBase_InPort.cxx b/src/GraphBase/DataFlowBase_InPort.cxx index 3089f38..a87227a 100644 --- a/src/GraphBase/DataFlowBase_InPort.cxx +++ b/src/GraphBase/DataFlowBase_InPort.cxx @@ -54,28 +54,124 @@ GraphBase::InPort::InPort( // cout << "InPort::~InPort()" << endl ; //} -bool GraphBase::InPort::IsConnected() const { - return ( _OutPort != NULL && !_OutPort->IsDataConnected() ) ; +const StatusOfPort GraphBase::InPort::PortStatus() const { + if ( GetOutPort() ) { + return GetOutPort()->PortStatus() ; + } + return NotConnected ; +} + +bool GraphBase::InPort::IsNotConnected() const { + return ( GetOutPort() == NULL || GetOutPort()->IsNotConnected() ) ; +} + +//bool GraphBase::InPort::IsConnected() const { +// return ( GetOutPort() && ( GetOutPort()->IsPortConnected() || GetOutPort()->IsExternConnected() ) ) ; +//} + +bool GraphBase::InPort::IsPortConnected() const { + return ( GetOutPort() && GetOutPort()->IsPortConnected() ) ; } bool GraphBase::InPort::IsDataConnected() const { - return ( _OutPort != NULL && _OutPort->IsDataConnected() ) ; + return ( GetOutPort() && GetOutPort()->IsDataConnected() ) ; +} + +bool GraphBase::InPort::IsExternConnected() const { + return ( GetOutPort() && GetOutPort()->IsExternConnected() ) ; } void GraphBase::InPort::StringValue(ostream & f ) const { - if ( _OutPort ) - _OutPort->StringValue( f ) ; + if ( GetOutPort() ) + GetOutPort()->StringValue( f ) ; else f << "(undefined)" ; } +bool GraphBase::InPort::RemoveOutPort() { +// Before to return the real status, callers should be checked ... + if ( _OutPort == NULL ) { + cdebug << "InPort::RemoveOutPort no OutPort in InPort " << PortName() << " of " << NodeName() << endl ; + return false ; + } + cdebug << "InPort::RemoveOutPort " << _OutPort->NodeName() << "(" << _OutPort->PortName() << ") --> " + << NodeName() << "(" << PortName() << ") in InPort " << PortName() << " of " << NodeName() << endl ; + _OutPort = NULL ; + if ( !IsEndSwitch() ) { + RemoveCoords() ; + } + return true ; +} + ostream & operator<< (ostream &f ,const GraphBase::InPort &P) { - f << P.PortName() << ", " - << "type : " << P.PortType() << ", " ; - f << "from " - << P.NodeName() << ", "; - f << "kind " - << P.Kind() << ", "; + f << P.PortName() << ", " << "type : " << P.PortType() << ", " << P.PortStatus() << ", " ; + f << "from Node " << P.NodeName() << ", "; + f << "kind " << P.Kind() << ", "; + f << "Status " << P.PortStatus() << ", "; + GraphBase::OutPort * anOutPort = P.GetOutPort() ; + if ( anOutPort ) { + f << "Linked from OutPort " << anOutPort->PortName() << ", " << "type : " << anOutPort->PortType() << ", " ; + f << "from Node " << anOutPort->NodeName() << ", "; + f << "kind " << anOutPort->Kind() << ", "; + f << "Status " << anOutPort->PortStatus() << ", "; + } + return f; +} + +ostream & operator<< (ostream &f ,const SUPERV::GraphState & aState ) { + switch (aState) { + case SUPERV::UndefinedState : + f << "UndefinedState"; + break; + case SUPERV::NoState : + f << "NoState"; + break; + case SUPERV::EditingState : + f << "EditingState"; + break; + case SUPERV::SuspendState : + f << "SuspendState"; + break; + case SUPERV::WaitingState : + f << "WaitingState"; + break; + case SUPERV::ReadyState : + f << "ReadyState"; + break; + case SUPERV::SuspendReadyState : + f << "SuspendReadyState"; + break; + case SUPERV::RunningState : + f << "RunningState"; + break; + case SUPERV::DoneState : + f << "DoneState"; + break; + case SUPERV::ErrorState : + f << "ErrorState"; + break; + case SUPERV::SuspendDoneState : + f << "SuspendDoneState"; + break; + case SUPERV::SuspendErroredState : + f << "SuspendErroredState"; + break; + case SUPERV::KillState : + f << "KillState"; + break; + case SUPERV::StopState : + f << "StopState"; + break; + case SUPERV::ReRunState : + f << "ReRunState"; + break; + case SUPERV::ReStartState : + f << "ReStartState"; + break; + default : + f << "SUPERV::GraphState_?"; + break; + } return f; } diff --git a/src/GraphBase/DataFlowBase_InPort.hxx b/src/GraphBase/DataFlowBase_InPort.hxx index 51224a3..467f360 100644 --- a/src/GraphBase/DataFlowBase_InPort.hxx +++ b/src/GraphBase/DataFlowBase_InPort.hxx @@ -70,8 +70,12 @@ namespace GraphBase { return _OutPort ; } ; OutPort * GetOutPort() const { return _OutPort ; } ; - bool IsConnected() const ; + const StatusOfPort PortStatus() const ; + bool IsNotConnected() const ; +// bool IsConnected() const ; + bool IsPortConnected() const ; bool IsDataConnected() const ; + bool IsExternConnected() const ; bool AddOutPort( OutPort * anOutPort ) { if ( _OutPort ) return false ; @@ -90,11 +94,7 @@ namespace GraphBase { return true ; } return false ; } ; - bool RemoveOutPort() { - if ( _OutPort == NULL ) - return false ; - _OutPort = NULL ; - return RemoveCoords() ; } ; + bool RemoveOutPort() ; void StringValue(ostream & f ) const ; @@ -104,4 +104,6 @@ namespace GraphBase { ostream & operator<< (ostream &,const GraphBase::InPort &); +ostream & operator<< (ostream &,const SUPERV::GraphState &); + #endif diff --git a/src/GraphBase/DataFlowBase_LoadXml.cxx b/src/GraphBase/DataFlowBase_LoadXml.cxx index 3fffa50..8cfa68d 100644 --- a/src/GraphBase/DataFlowBase_LoadXml.cxx +++ b/src/GraphBase/DataFlowBase_LoadXml.cxx @@ -44,45 +44,56 @@ using namespace std; bool GraphBase::Graph::LoadXml( CORBA::ORB_ptr _Orb , const char* myFileName , - GraphBase::SGraph & aDataFlow ) + GraphBase::ListOfSGraphs & ListOfDataFlows ) { char * FileName = new char[ strlen( myFileName ) + 5 ] ; strcpy( FileName , myFileName ) ; - QString aqstrFileName(FileName); - QFile afile( aqstrFileName); + QString aqstrFileName(FileName) ; + QFile afile( aqstrFileName) ; if ( !afile.exists() || !afile.open( IO_ReadOnly ) ) { strcat( FileName , ".xml" ) ; - aqstrFileName = QString(FileName); - QFile afile( aqstrFileName ); + aqstrFileName = QString(FileName) ; + QFile afile( aqstrFileName ) ; if ( !afile.exists() || !afile.open( IO_ReadOnly ) ) { - return false; + return false ; } - afile.close(); + afile.close() ; + } + else { + afile.close() ; } - else - afile.close(); QString qstrFileName(FileName); QFile file( qstrFileName); - GraphBase::XmlHandler::XmlHandler * myXmlHandler = new GraphBase::XmlHandler::XmlHandler( _Orb , true ); +// GraphBase::XmlHandler::XmlHandler * myXmlHandler = new GraphBase::XmlHandler::XmlHandler( _Orb , true ); QXmlInputSource source( file ); +// QXmlSimpleReader reader; +// reader.setContentHandler( myXmlHandler ); +// reader.setErrorHandler( myXmlHandler ); + + bool RetVal = true ; + int status = 1 ; + GraphBase::XmlHandler::XmlHandler * myXmlHandler = new GraphBase::XmlHandler::XmlHandler( _Orb , true ); 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; + status = reader.parse( source ) ; + if ( status == 1 ) { + ListOfDataFlows = myXmlHandler->ListOfDataFlows() ; + cdebug << "Graph::LoadXml " << ListOfDataFlows.size() << " Graphs" << endl ; + } + else { + delete myXmlHandler ; + cdebug << "Graph::LoadXml Graph status " << status << endl ; + RetVal = false ; } - - aDataFlow = myXmlHandler->GetDataFlow() ; delete myXmlHandler ; + + file.close(); +// delete myXmlHandler ; // Dataflow is now loaded. - return true ; + return RetVal ; } diff --git a/src/GraphBase/DataFlowBase_OutPort.cxx b/src/GraphBase/DataFlowBase_OutPort.cxx index 751d0df..f25acad 100644 --- a/src/GraphBase/DataFlowBase_OutPort.cxx +++ b/src/GraphBase/DataFlowBase_OutPort.cxx @@ -28,6 +28,7 @@ using namespace std; #include "DataFlowBase_OutPort.hxx" +#include "DataFlowBase_InPort.hxx" //GraphBase::OutPort::~OutPort() { // In GraphExecutor::OutPort @@ -50,9 +51,9 @@ const GraphBase::InPort * GraphBase::OutPort::GetInPort( 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 ; + //cout << "GraphBase::OutPort::GetInPort inconsistency toPort " +// << hex << (void *) toPort << " != anInPort " << (void *) anInPort +// << dec << endl ; anInPort = NULL ; } } @@ -96,14 +97,36 @@ bool GraphBase::OutPort::AddInPortObjRef( GraphBase::InPort * toPort , return true ; } +bool GraphBase::OutPort::RemoveInPort() { + if ( _InPortsSize != 1 ) { + return false ; + } + int index = 1 ; + GraphBase::InPort * toPort = _InPorts[ index - 1 ] ; + cdebug << "OutPort::RemoveInPort " << NodeName() << "( " << PortName() << " " << PortStatus() << " ) --> " + << toPort->NodeName() << "( " << toPort->PortName() << " " << toPort->PortStatus() + << " )" << endl ; + _InPortsSize -= 1 ; + _InPorts.resize( _InPortsSize ) ; + _Links.resize( _InPortsSize ) ; + _MapOfInPorts.erase( toPort->NodePortName() ) ; + if ( _InPortsSize == 0 ) { + PortStatus(NotConnected ) ; + } + toPort->RemoveOutPort() ; + 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 ; + cdebug << "GraphBase::OutPort::RemoveInPort Error " << NodeName() << "( " << PortName()<< " ) --> " + << toPort->NodeName() << "( " << toPort->PortName() << " )" << endl ; return false ; } + cdebug << "OutPort::RemoveInPort " << NodeName() << "(" << PortName() << ") --> " + << _InPorts[ index - 1 ]->NodeName() << "(" << _InPorts[ index - 1 ]->PortName() << ")" << endl ; _InPortsSize -= 1 ; for ( i = index - 1 ; i < _InPortsSize ; i++ ) { _MapOfInPorts[ _InPorts[ i+1 ]->NodePortName() ] = i + 1 ; @@ -153,13 +176,10 @@ bool GraphBase::OutPort::RemoveLinks() { ostream & operator<< (ostream &f ,const GraphBase::OutPort &P) { - f << P.PortName() << ", " - << "type : " << P.PortType() << ", " ; - f << "kind " - << P.Kind() << ", "; - f << "from " - << P.NodeName() << ", "; - + f << P.PortName() << ", " << "type : " << P.PortType() << ", " ; + f << "kind " << P.Kind() << ", "; + f << "Status " << P.PortStatus() << ", "; + f << "from Node " << P.NodeName() << ", "; return f; } diff --git a/src/GraphBase/DataFlowBase_OutPort.hxx b/src/GraphBase/DataFlowBase_OutPort.hxx index a6363d0..f708c27 100644 --- a/src/GraphBase/DataFlowBase_OutPort.hxx +++ b/src/GraphBase/DataFlowBase_OutPort.hxx @@ -70,20 +70,24 @@ namespace GraphBase { cdebug << "GraphBase::OutPort::destroy " << PortName() << " " << NodeName() << endl ; } ; +// PortStatus has a meaning : +// It is NotConnected or PortConnected or DataConnected or ExternConnected +// Even if an OutPort may be connected to several ports the PortStatus is unique 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 IsConnected() const { +// return ( _Connected == PortConnected || _Connected == ExternConnected ) ; } ; const bool IsPortConnected() const { - return ( _Connected == PortConnected || - _Connected == PortAndDataConnected ) ; } ; - const bool IsPortAndDataConnected() const { - return ( _Connected == PortAndDataConnected ) ; } ; + return ( _Connected == PortConnected ) ; } ; const bool IsDataConnected() const { return ( _Connected == DataConnected ) ; } ; + const bool IsExternConnected() const { + return ( _Connected == ExternConnected ) ; } ; +// const bool IsPortAndDataConnected() const { +// return ( _Connected == PortAndDataConnected ) ; } ; const int InPortsSize() const { return _InPortsSize ; } ; @@ -102,6 +106,7 @@ namespace GraphBase { bool AddInPort( InPort * toPort ) ; bool AddInPortObjRef( InPort * toPort , SUPERV::Link_var aLink ) ; + bool RemoveInPort() ; bool RemoveInPort( InPort * toPort ) ; bool ReNameInPort( const char* OldNodePortName , const char* NewNodePortName ) ; diff --git a/src/GraphBase/DataFlowBase_Port.cxx b/src/GraphBase/DataFlowBase_Port.cxx index 83ae029..7a6e685 100644 --- a/src/GraphBase/DataFlowBase_Port.cxx +++ b/src/GraphBase/DataFlowBase_Port.cxx @@ -222,3 +222,27 @@ ostream & operator<< (ostream & f ,const SALOME_ModuleCatalog::DataStreamDepende return f; } +ostream & operator<< (ostream & f ,const StatusOfPort & s ) { + switch (s) { + case NotConnected : + f << "NotConnected"; + break; + case PortConnected : + f << "PortConnected"; + break; +// case PortAndDataConnected : +// f << "PortAndDataConnected"; +// break; + case DataConnected : + f << "DataConnected"; + break; + case ExternConnected : + f << "ExternConnected"; + break; + default : + f << "UnknownStatusOfPort"; + break; + } + + return f; +} diff --git a/src/GraphBase/DataFlowBase_Port.hxx b/src/GraphBase/DataFlowBase_Port.hxx index c944750..44a93b7 100644 --- a/src/GraphBase/DataFlowBase_Port.hxx +++ b/src/GraphBase/DataFlowBase_Port.hxx @@ -82,9 +82,10 @@ namespace GraphBase { // cout << "NodePortName " << hex << (void *) _NodeName << " " // << dec << _NodeName << endl ; char * _NodePortName = new char [ strlen( *_NodeName ) + - strlen( ServicesParameterName() ) + 3 ] ; + strlen( ServicesParameterName() ) + 4 ] ; strcpy( _NodePortName , *_NodeName ) ; - strcat( _NodePortName , "\\" ) ; +// strcat( _NodePortName , "\\" ) ; + strcat( _NodePortName , "__" ) ; strcat( _NodePortName , ServicesParameterName() ) ; return _NodePortName ; } ; @@ -94,6 +95,7 @@ namespace GraphBase { return ServicesParameterName() ; } ; const char * PortType() const { return ServicesParameterType() ; } ; + void PortType(char * aParametertype ) { ServicesParameterType( aParametertype ) ; } ; void Kind( SUPERV::KindOfPort aKindOfPort ) { if ( _KindOfPort == SUPERV::GateParameter && aKindOfPort == SUPERV::InLineParameter ) { cdebug << "GraphBase::Port::Kind " << _KindOfPort << " --> " << aKindOfPort @@ -149,4 +151,6 @@ ostream & operator<< (ostream &,const SUPERV::KindOfPort &); ostream & operator<< (ostream &,const SALOME_ModuleCatalog::DataStreamDependency &); +ostream & operator<< (ostream &,const StatusOfPort &); + #endif diff --git a/src/GraphBase/DataFlowBase_PortsOfNode.cxx b/src/GraphBase/DataFlowBase_PortsOfNode.cxx index 73a084b..a1ffbf4 100644 --- a/src/GraphBase/DataFlowBase_PortsOfNode.cxx +++ b/src/GraphBase/DataFlowBase_PortsOfNode.cxx @@ -85,12 +85,14 @@ void GraphBase::PortsOfNode::DefPortsOfNode( (aKind == SUPERV::ComputingNode) || (aKind == SUPERV::FactoryNode) || (aKind == SUPERV::InLineNode) || (aKind == SUPERV::GOTONode) || (aKind == SUPERV::LoopNode) || (aKind == SUPERV::EndLoopNode) || - (aKind == SUPERV::SwitchNode) || (aKind == SUPERV::EndSwitchNode) ; + (aKind == SUPERV::SwitchNode) || (aKind == SUPERV::EndSwitchNode) || + (aKind == SUPERV::MacroNode) ; // WithOutGate : OutGate or Default const bool WithOutGate = (aKind == SUPERV::DataFlowGraph) || (aKind == SUPERV::DataStreamGraph) || (aKind == SUPERV::ComputingNode) || (aKind == SUPERV::FactoryNode) || (aKind == SUPERV::InLineNode) || (aKind == SUPERV::GOTONode) || - (aKind == SUPERV::SwitchNode) || (aKind == SUPERV::EndSwitchNode) ; + (aKind == SUPERV::SwitchNode) || (aKind == SUPERV::EndSwitchNode) || + (aKind == SUPERV::MacroNode) ; SUPERV::KindOfPort aPortKind = SUPERV::ServiceParameter ; if ( aKind == SUPERV::InLineNode ) { aPortKind = SUPERV::InLineParameter ; @@ -104,6 +106,9 @@ void GraphBase::PortsOfNode::DefPortsOfNode( else if ( aKind == SUPERV::GOTONode ) { aPortKind = SUPERV::InLineParameter ; } + else if ( aKind == SUPERV::MacroNode ) { + aPortKind = SUPERV::InLineParameter ; + } for ( i = 0 ; i < _NodeInPortsSize ; i++ ) { cdebug << "DefPortsOfNode delete In" << i << ". " << _NodeInPorts[i] << endl ; @@ -139,7 +144,6 @@ void GraphBase::PortsOfNode::DefPortsOfNode( _MapOfNodeInPorts[ aParametername ] = iVec ; _NodeInPorts[iVec-1] = new GraphBase::InPort( NodeName , anInLoopParameter , SUPERV::LoopParameter ); -// MESSAGE( "GraphBase::PortsOfNode::DefPortsOfNode " << aParametername << " --> SetDebug" ) ; _NodeInPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; cdebug << "DefPortsOfNode : " << "_MapOfNodeInPorts[ " << aParametername << " ] = " << iVec << " " << _NodeInPorts[iVec-1]->Kind() << " " @@ -163,14 +167,13 @@ void GraphBase::PortsOfNode::DefPortsOfNode( } else { _MapOfNodeInPorts[ aParametername ] = i+1 ; - cdebug << "DefPortsOfNode : " << "_MapOfNodeInPorts[ " << aParametername - << " ] = " << i+1 << endl ; +// cdebug << "DefPortsOfNode : " << "_MapOfNodeInPorts[ " << aParametername +// << " ] = " << i+1 << endl ; const SALOME_ModuleCatalog::ServicesParameter aServiceParameter = aService.ServiceinParameter[i-iVec] ; _NodeInPorts[i] = new GraphBase::InPort( NodeName , aServiceParameter , aPortKind ); -// MESSAGE( "GraphBase::PortsOfNode::DefPortsOfNode " << aParametername << " --> SetDebug" ) ; _NodeInPorts[i]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; - cdebug << i << ". " << *_NodeInPorts[i] << " " << _NodeInPorts[i]->Kind() << endl ; +// cdebug << i << ". " << *_NodeInPorts[i] << " " << _NodeInPorts[i]->Kind() << endl ; } } iVec += aService.ServiceinParameter.length() ; @@ -188,11 +191,10 @@ void GraphBase::PortsOfNode::DefPortsOfNode( _MapOfNodeInPorts[ aParametername ] = iVec ; _NodeInPorts[iVec-1] = new GraphBase::InPort( NodeName , anInGateParameter , SUPERV::GateParameter ); -// MESSAGE( "GraphBase::PortsOfNode::DefPortsOfNode " << aParametername << " --> SetDebug" ) ; _NodeInPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; - cdebug << "DefPortsOfNode : " << "_MapOfNodeInPorts[ " << aParametername - << " ] = " << iVec << " " << _NodeInPorts[iVec-1]->Kind() << " " - << _NodeInPorts[iVec-1] << endl ; +// cdebug << "DefPortsOfNode : " << "_MapOfNodeInPorts[ " << aParametername +// << " ] = " << iVec << " " << _NodeInPorts[iVec-1]->Kind() << " " +// << _NodeInPorts[iVec-1] << endl ; } iVec = 0 ; @@ -210,11 +212,10 @@ void GraphBase::PortsOfNode::DefPortsOfNode( _MapOfNodeOutPorts[ aParametername ] = iVec ; _NodeOutPorts[iVec-1] = new GraphBase::OutPort( NodeName , anOutLoopParameter , SUPERV::LoopParameter ); -// MESSAGE( "GraphBase::PortsOfNode::DefPortsOfNode " << aParametername << " --> SetDebug" ) ; _NodeOutPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; - cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername - << " ] = " << iVec << " " << _NodeOutPorts[iVec-1]->Kind() << " " - << _NodeOutPorts[iVec-1] << endl ; +// cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername +// << " ] = " << iVec << " " << _NodeOutPorts[iVec-1]->Kind() << " " +// << _NodeOutPorts[iVec-1] << endl ; } if ( _NodeOutPortsSize > (int ) _NodeOutPorts.size() ) { _NodeOutPorts.resize(_NodeOutPortsSize); @@ -233,15 +234,14 @@ void GraphBase::PortsOfNode::DefPortsOfNode( } } else { - cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername - << " ] = " << i+1 << endl ; +// cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername +// << " ] = " << i+1 << endl ; _MapOfNodeOutPorts[ aParametername ] = i+1 ; const SALOME_ModuleCatalog::ServicesParameter aServiceParameter = aService.ServiceoutParameter[i-iVec] ; _NodeOutPorts[i] = new GraphBase::OutPort( NodeName , aServiceParameter , aPortKind ); -// MESSAGE( "GraphBase::PortsOfNode::DefPortsOfNode " << aParametername << " --> SetDebug" ) ; _NodeOutPorts[i]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; - cdebug << i << ". " << *_NodeOutPorts[i] << " " << _NodeOutPorts[i]->Kind() << endl ; +// cdebug << i << ". " << *_NodeOutPorts[i] << " " << _NodeOutPorts[i]->Kind() << endl ; } } iVec += aService.ServiceoutParameter.length() ; @@ -259,11 +259,10 @@ void GraphBase::PortsOfNode::DefPortsOfNode( _MapOfNodeOutPorts[ aParametername ] = iVec ; _NodeOutPorts[iVec-1] = new GraphBase::OutPort( NodeName , anOutGateParameter , SUPERV::GateParameter ); -// MESSAGE( "GraphBase::PortsOfNode::DefPortsOfNode " << aParametername << " --> SetDebug" ) ; _NodeOutPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; - cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername - << " ] = " << iVec << " " << _NodeOutPorts[iVec-1]->Kind() << " " - << _NodeOutPorts[iVec-1] << endl ; +// cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername +// << " ] = " << iVec << " " << _NodeOutPorts[iVec-1]->Kind() << " " +// << _NodeOutPorts[iVec-1] << endl ; } cdebug_out << "DefPortsOfNode : " << *NodeName << endl ; } @@ -274,16 +273,17 @@ GraphBase::InPort * GraphBase::PortsOfNode::AddInPort( CORBA::ORB_ptr ORB , const char * InputParameterName , const char * InputParameterType , SUPERV::KindOfPort aKindOfPort , -// const int DataStreamInPortsNumber , + int index , int * Graph_prof_debug , ofstream * Graph_fdebug ) { // MESSAGE( "DefPortsOfNode " << *NodeName << " Graph_prof_debug " // << Graph_prof_debug << " _prof_debug " << _prof_debug ) ; - cdebug_in << "PortsOfNode::AddInPort : " << *NodeName << " " << aKindOfNode << " InputParameterName " << InputParameterName << " InputParameterType " - << InputParameterType << " aKindOfPort " << aKindOfPort << " DataStreamInPortsNumber " << DataStreamInPortsNumber() << " _NodeInPortsSize " - << _NodeInPortsSize << endl ; + cdebug_in << "PortsOfNode::AddInPort : " << *NodeName << " " << aKindOfNode << " InputParameterName " + << InputParameterName << " InputParameterType " << InputParameterType << " aKindOfPort " + << aKindOfPort << " DataStreamInPortsNumber " << DataStreamInPortsNumber() << " _NodeInPortsSize " + << _NodeInPortsSize << " index " << index << endl ; GraphBase::InPort * anInPort = NULL ; - int index = 0 ; +// int index = 0 ; anInPort = GetChangeInPort( InputParameterName ) ; if ( anInPort == NULL ) { _NodeInPortsSize = _NodeInPortsSize + 1 ; @@ -291,20 +291,22 @@ GraphBase::InPort * GraphBase::PortsOfNode::AddInPort( CORBA::ORB_ptr ORB , SALOME_ModuleCatalog::ServicesParameter aServiceParameter ; aServiceParameter.Parametername = CORBA::string_dup( InputParameterName ) ; aServiceParameter.Parametertype = CORBA::string_dup( InputParameterType ) ; - if ( aKindOfPort == SUPERV::DataStreamParameter ) { + if ( index != -1 ) { + } + else if ( aKindOfPort == SUPERV::DataStreamParameter ) { index = _NodeInPortsSize-2 ; IncrDataStreamInPorts() ; } else { index = _NodeInPortsSize-2 - DataStreamInPortsNumber() ; } -// if ( aKindOfNode != SUPERV::EndLoopNode ) { - int i ; - for ( i = _NodeInPortsSize - 2 ; i >= index ; i-- ) { - _NodeInPorts[ i + 1 ] = _NodeInPorts[ i ] ; // Gate - Default - _MapOfNodeInPorts.erase( _NodeInPorts[ i + 1 ]->PortName() ) ; - _MapOfNodeInPorts[ _NodeInPorts[ i + 1 ]->PortName() ] = i + 2 ; - } + if ( index >= 0 ) { + int i ; + for ( i = _NodeInPortsSize - 2 ; i >= index ; i-- ) { + _NodeInPorts[ i + 1 ] = _NodeInPorts[ i ] ; // Gate - Default + _MapOfNodeInPorts.erase( _NodeInPorts[ i + 1 ]->PortName() ) ; + _MapOfNodeInPorts[ _NodeInPorts[ i + 1 ]->PortName() ] = i + 2 ; + } _MapOfNodeInPorts[ InputParameterName ] = index + 1 ; if ( aKindOfPort == SUPERV::DataStreamParameter ) { _NodeInPorts[index] = new GraphBase::InDataStreamPort( NodeName , @@ -319,27 +321,22 @@ GraphBase::InPort * GraphBase::PortsOfNode::AddInPort( CORBA::ORB_ptr ORB , anInPort = _NodeInPorts[index] ; cdebug << "NodeInPorts[ " << index << " ]" << endl ; } -// else { // EndLoopNode -// _MapOfNodeInPorts[ InputParameterName ] = _NodeInPortsSize-1 + 1 ; -// _NodeInPorts[_NodeInPortsSize-1] = new GraphBase::InPort( NodeName , -// aServiceParameter ,// -// aKindOfPort ) ; -// MESSAGE( "GraphBase::PortsOfNode::AddInPort " << InputParameterName << " --> SetDebug" ) ; -// _NodeInPorts[_NodeInPortsSize-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; -// anInPort = _NodeInPorts[_NodeInPortsSize-1] ; -// cdebug << "NodeInPorts[ " << _NodeInPortsSize-1 << " ]" << endl ; -// } -// } + else { + cdebug << "GraphBase::PortsOfNode::AddInPort ERROR index " << index << " _NodeInPortsSize " + << _NodeInPortsSize << endl ; + } + } else { cdebug << "GraphBase::PortsOfNode::AddInPort InPort already exists" << endl ; anInPort->Kind( aKindOfPort ) ; } cdebug << "GraphBase::PortsOfNode::AddInPort index " << index << " _NodeInPortsSize " << _NodeInPortsSize << endl ; +//#if 0 int i ; for ( i = 0 ; i < _NodeInPortsSize ; i++ ) { cdebug << *NodeName << " _NodeInPorts[ " << i << " ] = " << _NodeInPorts[ i ]->PortName() << " _MapOfNodeInPorts[ " << _NodeInPorts[ i ]->PortName() << " ] = " - << _MapOfNodeInPorts[ _NodeInPorts[ i ]->PortName() ] - 1 << " " + << _MapOfNodeInPorts[ _NodeInPorts[ i ]->PortName() ] << " - 1 " << _NodeInPorts[ i ]->Kind() << " Dependency " << _NodeInPorts[ i ]->Dependency() ; if ( _NodeInPorts[ i ]->IsDataStream() ) { SUPERV::KindOfSchema aKindOfSchema ; @@ -348,8 +345,17 @@ GraphBase::InPort * GraphBase::PortsOfNode::AddInPort( CORBA::ORB_ptr ORB , ((GraphBase::InDataStreamPort * ) _NodeInPorts[ i ])->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ; cdebug << " " << aKindOfSchema << " " << aKindOfInterpolation << " " << aKindOfExtrapolation ; } - cdebug << endl ; + if ( _NodeInPorts[ i ]->GetOutPort() ) { + cdebug << " <--OutPort " << _NodeInPorts[ i ]->GetOutPort() + << " " << _NodeInPorts[ i ]->GetOutPort()->NodeName() + << "(" << _NodeInPorts[ i ]->GetOutPort()->PortName() << ")" ; + } + else { + cdebug << " <--NOOutPort " << _NodeInPorts[ i ]->GetOutPort() ; + } + cdebug << " " << _NodeInPorts[ i ]->PortStatus() << endl ; } +//#endif cdebug_out << "GraphBase::PortsOfNode::AddInPort _NodeInPortsSize " << _NodeInPortsSize << " " << anInPort->Kind() << endl ; return anInPort ; @@ -361,14 +367,15 @@ GraphBase::OutPort * GraphBase::PortsOfNode::AddOutPort( CORBA::ORB_ptr ORB , const char * OutputParameterName , const char * OutputParameterType , SUPERV::KindOfPort aKindOfPort , -// const int DataStreamOutPortsNumber , + int index , int * Graph_prof_debug , ofstream * Graph_fdebug ) { - cdebug_in << "GraphBase::PortsOfNode::AddOutPort : " << *NodeName << " " << aKindOfNode << " OutputParameterName " << OutputParameterName - << " OutputParameterType " << OutputParameterType << " aKindOfPort " << aKindOfPort << " DataStreamOutPortsNumber " << DataStreamOutPortsNumber() - << " _NodeOutPortsSize " << _NodeOutPortsSize << endl ; + cdebug_in << "GraphBase::PortsOfNode::AddOutPort : " << *NodeName << " " << aKindOfNode + << " OutputParameterName " << OutputParameterName << " OutputParameterType " << OutputParameterType + << " aKindOfPort " << aKindOfPort << " DataStreamOutPortsNumber " << DataStreamOutPortsNumber() + << " _NodeOutPortsSize " << _NodeOutPortsSize << " index " << index << endl ; GraphBase::OutPort * anOutPort = NULL ; - int index = 0 ; +// int index = 0 ; anOutPort = GetChangeOutPort( OutputParameterName ) ; if ( anOutPort == NULL ) { _NodeOutPortsSize = _NodeOutPortsSize + 1 ; @@ -376,7 +383,9 @@ GraphBase::OutPort * GraphBase::PortsOfNode::AddOutPort( CORBA::ORB_ptr ORB , SALOME_ModuleCatalog::ServicesParameter aServiceParameter ; aServiceParameter.Parametername = CORBA::string_dup( OutputParameterName ) ; aServiceParameter.Parametertype = CORBA::string_dup( OutputParameterType ) ; - if ( aKindOfPort == SUPERV::DataStreamParameter ) { + if ( index != -1 ) { + } + else if ( aKindOfPort == SUPERV::DataStreamParameter ) { index = _NodeOutPortsSize-2 ; IncrDataStreamOutPorts() ; } @@ -386,60 +395,78 @@ GraphBase::OutPort * GraphBase::PortsOfNode::AddOutPort( CORBA::ORB_ptr ORB , if ( aKindOfNode == SUPERV::LoopNode || aKindOfNode == SUPERV::EndLoopNode ) { index += 1 ; } -// if ( aKindOfNode != SUPERV::LoopNode && aKindOfNode != SUPERV::EndLoopNode ) { - int i ; - for ( i = _NodeOutPortsSize - 2 ; i >= index ; i-- ) { - _NodeOutPorts[ i + 1 ] = _NodeOutPorts[ i ] ; // Gate - Default - _MapOfNodeOutPorts.erase( _NodeOutPorts[ i + 1 ]->PortName() ) ; - _MapOfNodeOutPorts[ _NodeOutPorts[ i + 1 ]->PortName() ] = i + 2 ; - } - _MapOfNodeOutPorts[ OutputParameterName ] = index + 1 ; - if ( aKindOfPort == SUPERV::DataStreamParameter ) { - _NodeOutPorts[index] = new GraphBase::OutDataStreamPort( NodeName , + if ( index >= 0 ) { + int i ; + for ( i = _NodeOutPortsSize - 2 ; i >= index ; i-- ) { + _NodeOutPorts[ i + 1 ] = _NodeOutPorts[ i ] ; // Gate - Default + _MapOfNodeOutPorts.erase( _NodeOutPorts[ i + 1 ]->PortName() ) ; + _MapOfNodeOutPorts[ _NodeOutPorts[ i + 1 ]->PortName() ] = i + 2 ; + } + _MapOfNodeOutPorts[ OutputParameterName ] = index + 1 ; + if ( aKindOfPort == SUPERV::DataStreamParameter ) { + _NodeOutPorts[index] = new GraphBase::OutDataStreamPort( NodeName , aServiceParameter ) ; + } + else { + _NodeOutPorts[index] = new GraphBase::OutPort( NodeName , + aServiceParameter , + aKindOfPort ); + } +// MESSAGE( "GraphBase::PortsOfNode::AddOutPort " << OutputParameterName << " --> SetDebug" ) ; + _NodeOutPorts[index]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; + anOutPort = _NodeOutPorts[index] ; + cdebug << "NodeOutPorts[ " << index << " ]" << endl ; } else { - _NodeOutPorts[index] = new GraphBase::OutPort( NodeName , - aServiceParameter , - aKindOfPort ); + cdebug << "GraphBase::PortsOfNode::AddOutPort ERROR index " << index << " _NodeOutPortsSize " + << _NodeOutPortsSize << endl ; } -// MESSAGE( "GraphBase::PortsOfNode::AddOutPort " << OutputParameterName << " --> SetDebug" ) ; - _NodeOutPorts[index]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; - anOutPort = _NodeOutPorts[index] ; - cdebug << "NodeOutPorts[ " << index << " ]" << endl ; } -// else { // LoopNode || EndLoopNode -// _MapOfNodeOutPorts[ OutputParameterName ] = index + 2 ; -// _NodeOutPorts[index + 1] = new GraphBase::OutPort( NodeName , -// aServiceParameter , -// aKindOfPort ); -// MESSAGE( "GraphBase::PortsOfNode::AddOutPort " << OutputParameterName << " --> SetDebug" ) ; -// _NodeOutPorts[index + 1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; -// anOutPort = _NodeOutPorts[index + 1] ; -// cdebug << "NodeOutPorts[ " << index + 1 << " ]" << endl ; -// } -// } else { cdebug << "GraphBase::PortsOfNode::AddOutPort OutPort already exists" << endl ; anOutPort->Kind( aKindOfPort ) ; } cdebug << "GraphBase::PortsOfNode::AddOutPort index " << index << " _NodeOutPortsSize " << _NodeOutPortsSize << endl ; +//#if 0 int i ; for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) { cdebug << *NodeName << " _NodeOutPorts[ " << i << " ] = " << _NodeOutPorts[ i ]->PortName() << " _MapOfNodeOutPorts[ " << _NodeOutPorts[ i ]->PortName() << " ] = " - << _MapOfNodeOutPorts[ _NodeOutPorts[ i ]->PortName() ] - 1 << " " + << _MapOfNodeOutPorts[ _NodeOutPorts[ i ]->PortName() ] << " - 1 " << _NodeOutPorts[ i ]->Kind() << " Dependency " << _NodeOutPorts[ i ]->Dependency() ; if ( _NodeOutPorts[ i ]->IsDataStream() ) { cdebug << " NumberOfValues " << ((GraphBase::OutDataStreamPort * ) _NodeOutPorts[ i ])->NumberOfValues() ; } - cdebug << endl ; + cdebug << " " << _NodeOutPorts[ i ]->PortStatus() << endl ; } +//#endif cdebug_out << "GraphBase::PortsOfNode::AddOutPort _NodeOutPortsSize " << _NodeOutPortsSize << " " << anOutPort->Kind() << endl ; return anOutPort ; } +void GraphBase::PortsOfNode::MoveInPort( const char * InputParameterName , int toindex ) { + int fromindex = _MapOfNodeInPorts[ InputParameterName ] - 1 ; + GraphBase::InPort * anInPort = _NodeInPorts[ toindex ] ; + _NodeInPorts[ toindex ] = _NodeInPorts[ fromindex ] ; + _NodeInPorts[ fromindex ] = anInPort ; + _MapOfNodeInPorts.erase( _NodeInPorts[ toindex ]->PortName() ) ; + _MapOfNodeInPorts[ _NodeInPorts[ toindex ]->PortName() ] = toindex + 1 ; + _MapOfNodeInPorts.erase( _NodeInPorts[ fromindex ]->PortName() ) ; + _MapOfNodeInPorts[ _NodeInPorts[ fromindex ]->PortName() ] = fromindex + 1 ; +} + +void GraphBase::PortsOfNode::MoveOutPort( const char * OutputParameterName , int toindex ) { + int fromindex = _MapOfNodeOutPorts[ OutputParameterName ] - 1 ; + GraphBase::OutPort * anOutPort = _NodeOutPorts[ toindex ] ; + _NodeOutPorts[ toindex ] = _NodeOutPorts[ fromindex ] ; + _NodeOutPorts[ fromindex ] = anOutPort ; + _MapOfNodeOutPorts.erase( _NodeOutPorts[ toindex ]->PortName() ) ; + _MapOfNodeOutPorts[ _NodeOutPorts[ toindex ]->PortName() ] = toindex + 1 ; + _MapOfNodeOutPorts.erase( _NodeOutPorts[ fromindex ]->PortName() ) ; + _MapOfNodeOutPorts[ _NodeOutPorts[ fromindex ]->PortName() ] = fromindex + 1 ; +} + void GraphBase::PortsOfNode::DelInPort( const char * InputParameterName ) { cdebug << "DefPortsOfNode::DelInPort : " << InputParameterName << endl ; int index = _MapOfNodeInPorts[ InputParameterName ] -1 ; @@ -504,18 +531,6 @@ void GraphBase::PortsOfNode::DelOutPort( const char * OutputParameterName ) { } } -#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 ) ; } @@ -529,40 +544,33 @@ GraphBase::InPort *GraphBase::PortsOfNode::GetChangeInPort( const char * name) { GraphBase::InPort * pP = NULL; if ( !_MapOfNodeInPorts.empty() ) { - int i = 0 ; + int index = 0 ; if ( !strcmp( name , "InGate" ) ) { - i = _MapOfNodeInPorts[ "Gate" ] ; + index = _MapOfNodeInPorts[ "Gate" ] ; } else { - i = _MapOfNodeInPorts[ name ] ; + index = _MapOfNodeInPorts[ name ] ; } - if ( i > 0 ) { + if ( index > 0 ) { // cdebug << "GraphBase::PortsOfNode::GetChangeInPort _MapOfNodeInPorts[ " // << name << " ] : " << i-1 << " " << _NodeInPorts[ i-1 ]->NodeName() // << endl ; - pP = _NodeInPorts[ i-1 ] ; + pP = _NodeInPorts[ index-1 ] ; + } + else { + cdebug << "GraphBase::PortsOfNode::GetChangeInPort _MapOfNodeInPorts[ " + << name << " ] : " << index << " NOT FOUND. Known ports :" << endl ; +#if 1 + map< string , int >::iterator aMapOfNodeInPortsIterator ; + int i = 0 ; + for ( aMapOfNodeInPortsIterator = _MapOfNodeInPorts.begin() ; + aMapOfNodeInPortsIterator != _MapOfNodeInPorts.end() ; aMapOfNodeInPortsIterator++ ) { + cdebug << "MapOfNodeInPorts" << i++ << " " << aMapOfNodeInPortsIterator->first << " --> " + << aMapOfNodeInPortsIterator->second << endl ; + } +#endif } } -// if ( pP == NULL ) { -// int i ; -// for ( i = 0 ; i < _NodeInPortsSize ; i++ ) { -// cdebug << " _NodeInPorts[ " << i << " ] = " << _NodeInPorts[ i ]->PortName() -// << " _MapOfNodeInPorts[ " << _NodeInPorts[ i ]->PortName() << " ] = " -// << _MapOfNodeInPorts[ _NodeInPorts[ i ]->PortName() ] - 1 << " " -// << _NodeInPorts[ i ]->Kind() << " Dependency " << _NodeInPorts[ i ]->Dependency() ; -// if ( _NodeInPorts[ i ]->IsDataStream() ) { -// SUPERV::KindOfSchema aKindOfSchema ; -// SUPERV::KindOfInterpolation aKindOfInterpolation ; -// SUPERV::KindOfExtrapolation aKindOfExtrapolation ; -// ((GraphBase::InDataStreamPort * ) _NodeInPorts[ i ])->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ; -// cdebug << " " << aKindOfSchema << " " << aKindOfInterpolation << " " << aKindOfExtrapolation ; -// } -// if ( !strcmp( _NodeInPorts[ i ]->PortName() , name ) ) { -// cdebug << " ERROR" ; -// } -// cdebug << endl ; -// } -// } // cdebug_out << "GraphBase::PortsOfNode::GetChangeInPort " << endl; return pP; @@ -573,71 +581,34 @@ GraphBase::OutPort *GraphBase::PortsOfNode::GetChangeOutPort( const char * name GraphBase::OutPort * pP = NULL; if ( !_MapOfNodeOutPorts.empty() ) { - int i = 0 ; + int index = 0 ; if ( !strcmp( name , "OutGate" ) ) { - i = _MapOfNodeOutPorts[ "Gate" ] ; + index = _MapOfNodeOutPorts[ "Gate" ] ; } else { - i = _MapOfNodeOutPorts[ name ] ; + index = _MapOfNodeOutPorts[ name ] ; } - if ( i > 0 ) { + if ( index > 0 ) { // cdebug << "GraphBase::PortsOfNode::GetChangeOutPort _MapOfNodeOutPorts[ " // << name << " ] : " << i-1 << " " << _NodeOutPorts[ i-1 ]->NodeName() << endl ; - pP = _NodeOutPorts[ i-1 ] ; - } - } -// cdebug_out << "GraphBase::PortsOfNode::GetChangeOutPort " << endl; - -// if ( pP == NULL ) { -// int i ; -// for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) { -// cdebug << " _NodeOutPorts[ " << i << " ] = " << _NodeOutPorts[ i ]->PortName() -// << " _MapOfNodeOutPorts[ " << _NodeOutPorts[ i ]->PortName() << " ] = " -// << _MapOfNodeOutPorts[ _NodeOutPorts[ i ]->PortName() ] - 1 << " " -// << _NodeOutPorts[ i ]->Kind() << " Dependency " << _NodeOutPorts[ i ]->Dependency() ; -// if ( _NodeOutPorts[ i ]->IsDataStream() ) { -// cdebug << " NumberOfValues " << ((GraphBase::OutDataStreamPort * ) _NodeOutPorts[ i ])->NumberOfValues() ; -// } -// if ( !strcmp( _NodeOutPorts[ i ]->PortName() , name ) ) { -// cdebug << " ERROR" ; -// } -// cdebug << 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() ; + pP = _NodeOutPorts[ index-1 ] ; } 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 ; + cdebug << "GraphBase::PortsOfNode::GetChangeOutPort _MapOfNodeOutPorts[ " + << name << " ] : " << index << " NOT FOUND. Known ports :" << endl ; +#if 1 + map< string , int >::iterator aMapOfNodeOutPortsIterator ; + int i = 0 ; + for ( aMapOfNodeOutPortsIterator = _MapOfNodeOutPorts.begin() ; + aMapOfNodeOutPortsIterator != _MapOfNodeOutPorts.end() ; aMapOfNodeOutPortsIterator++ ) { + cdebug << "MapOfNodeInPorts" << i++ << " " << aMapOfNodeOutPortsIterator->first << " --> " + << aMapOfNodeOutPortsIterator->second << endl ; + } +#endif } } - return RetVal ; + return pP; } -#endif void GraphBase::PortsOfNode::ListPorts( ostream & f, const bool klink ) const { @@ -698,6 +669,9 @@ ostream & operator<< (ostream & f ,const SUPERV::KindOfNode & s ) { case SUPERV::InLineNode : f << "InLineNode"; break; + case SUPERV::MacroNode : + f << "MacroNode"; + break; case SUPERV::DataFlowGraph : f << "DataFlowGraph"; break; diff --git a/src/GraphBase/DataFlowBase_PortsOfNode.hxx b/src/GraphBase/DataFlowBase_PortsOfNode.hxx index de75d7c..547ee66 100644 --- a/src/GraphBase/DataFlowBase_PortsOfNode.hxx +++ b/src/GraphBase/DataFlowBase_PortsOfNode.hxx @@ -71,7 +71,7 @@ namespace GraphBase { const char * InputParameterName , const char * InputParameterType , SUPERV::KindOfPort aKindOfPort , -// const int DataStreamInPortsNumber , + int index , int * Graph_prof_debug , ofstream * Graph_fdebug ) ; OutPort * AddOutPort( CORBA::ORB_ptr ORB , @@ -80,10 +80,13 @@ namespace GraphBase { const char * OutputParameterName , const char * InputParameterType , SUPERV::KindOfPort aKindOfPort , -// const int DataStreamOutPortsNumber , + int index , int * Graph_prof_debug , ofstream * Graph_fdebug ) ; + void MoveInPort( const char * InputParameterName , int toindex ) ; + void MoveOutPort( const char * OutputParameterName , int toindex ) ; + void DelInPort( const char * InputParameterName ) ; void DelOutPort( const char * OutputParameterName ) ; diff --git a/src/GraphBase/DataFlowBase_Service.cxx b/src/GraphBase/DataFlowBase_Service.cxx index 9bc5788..1df079f 100644 --- a/src/GraphBase/DataFlowBase_Service.cxx +++ b/src/GraphBase/DataFlowBase_Service.cxx @@ -56,7 +56,7 @@ void GraphBase::Service::SetService( const SALOME_ModuleCatalog::Service aServic _Service.ServiceoutDataStreamParameter[ i ].Parametername = CORBA::string_dup( aService.ServiceoutDataStreamParameter[ i ].Parametername ) ; _Service.ServiceoutDataStreamParameter[ i ].Parameterdependency = aService.ServiceoutDataStreamParameter[ i ].Parameterdependency ; } - cdebug << "GraphBase::Service::SetService : " << _Service << endl ; +// cdebug << "GraphBase::Service::SetService : " << _Service << endl ; _Instance = 0 ; } diff --git a/src/GraphBase/DataFlowBase_ServicesParameter.hxx b/src/GraphBase/DataFlowBase_ServicesParameter.hxx index a14b68a..de653a1 100644 --- a/src/GraphBase/DataFlowBase_ServicesParameter.hxx +++ b/src/GraphBase/DataFlowBase_ServicesParameter.hxx @@ -56,6 +56,8 @@ namespace GraphBase { return _ServicesParameter.Parametername ; } ; const char * ServicesParameterType() const { return _ServicesParameter.Parametertype ; } ; + void ServicesParameterType(char * aParametertype ) { + _ServicesParameter.Parametertype = CORBA::string_dup( aParametertype ) ; } ; } ; diff --git a/src/GraphBase/DataFlowBase_StreamGraph.cxx b/src/GraphBase/DataFlowBase_StreamGraph.cxx index 240572b..f142364 100644 --- a/src/GraphBase/DataFlowBase_StreamGraph.cxx +++ b/src/GraphBase/DataFlowBase_StreamGraph.cxx @@ -39,11 +39,12 @@ GraphBase::StreamGraph::StreamGraph() : GraphBase::StreamGraph::StreamGraph( CORBA::ORB_ptr ORB , SALOME_NamingService* ptrNamingService , const char *DataFlowName , + const SUPERV::KindOfNode DataFlowkind , int * Graph_prof_debug , ofstream * Graph_fdebug ) : // const char * DebugFileName ) : // Graph( ORB ,ptrNamingService , DataFlowName , DebugFileName ) { - Graph( ORB ,ptrNamingService , DataFlowName , Graph_prof_debug , Graph_fdebug ) { + Graph( ORB ,ptrNamingService , DataFlowName , DataFlowkind , Graph_prof_debug , Graph_fdebug ) { _Timeout = 300 ; _DataStreamTrace = SUPERV::WithoutTrace ; _DeltaTime = 0 ; diff --git a/src/GraphBase/DataFlowBase_StreamGraph.hxx b/src/GraphBase/DataFlowBase_StreamGraph.hxx index 55d65b9..c33133a 100644 --- a/src/GraphBase/DataFlowBase_StreamGraph.hxx +++ b/src/GraphBase/DataFlowBase_StreamGraph.hxx @@ -38,6 +38,7 @@ namespace GraphBase { StreamGraph( CORBA::ORB_ptr ORB , SALOME_NamingService* ptrNamingService , const char * DataFlowName , + const SUPERV::KindOfNode DataFlowkind , int * Graph_prof_debug , ofstream * Graph_fdebug ) ; diff --git a/src/GraphBase/DataFlowBase_StreamNode.cxx b/src/GraphBase/DataFlowBase_StreamNode.cxx index 04d3176..c31485e 100644 --- a/src/GraphBase/DataFlowBase_StreamNode.cxx +++ b/src/GraphBase/DataFlowBase_StreamNode.cxx @@ -16,15 +16,25 @@ using namespace std; GraphBase::StreamNode::StreamNode() : GraphBase::PortsOfNode::PortsOfNode() { _Name = NULL ; + _Kind = SUPERV::UnknownNode ; _LinkedNodesSize = 0 ; _LinkedStreamNodesSize = 0 ; _HeadNode = false ; + _LevelNumber = -1 ; + _SortedIndex = -1 ; + _GraphEditor = NULL ; + _GraphExecutor = NULL ; + _GraphMacroNode = SUPERV::Graph::_nil() ; + _GraphMacroLevel = 0 ; _SubGraphNumber = 0 ; _SubStreamGraphNumber = 0 ; cdebug << "GraphBase::StreamNode::StreamNode " << this << " " << endl ; } -GraphBase::StreamNode::StreamNode( const char * NodeName ) : +GraphBase::StreamNode::StreamNode( const char * NodeName , + const SUPERV::KindOfNode DataFlowkind , + int * Graph_prof_debug , + ofstream * Graph_fdebug ) : GraphBase::PortsOfNode::PortsOfNode( NodeName ) { if ( NodeName != NULLSTRING && strlen( NodeName ) ) { _Name = new char[ strlen( NodeName )+1 ] ; @@ -33,9 +43,16 @@ GraphBase::StreamNode::StreamNode( const char * NodeName ) : else { _Name = NULLSTRING ; } + Kind( DataFlowkind ) ; _LinkedNodesSize = 0 ; _LinkedStreamNodesSize = 0 ; _HeadNode = false ; + _LevelNumber = -1 ; + _SortedIndex = -1 ; + _GraphEditor = NULL ; + _GraphExecutor = NULL ; + _GraphMacroNode = SUPERV::Graph::_nil() ; + _GraphMacroLevel = 0 ; _SubGraphNumber = 0 ; _SubStreamGraphNumber = 0 ; cdebug << "GraphBase::StreamNode::StreamNode " << NodeName << " " @@ -98,7 +115,7 @@ void GraphBase::StreamNode::SetSubStreamGraph( int SubStreamGraphsNumber , int & return ; } -void GraphBase::StreamNode::AddLink( GraphBase::StreamNode * ToNode ) { +void GraphBase::StreamNode::AddLinkedNode( GraphBase::StreamNode * ToNode ) { int index = GetLinkedNodeIndex( ToNode->Name() ) ; if ( index < 0 ) { cdebug << Name() << "->GraphBase::StreamNode::AddLinkedNode( " << ToNode->Name() @@ -121,16 +138,16 @@ void GraphBase::StreamNode::AddLink( GraphBase::StreamNode * ToNode ) { << " ] _LinkedInPortsNumber " << _LinkedInPortsNumber[ index ] << endl ; } -bool GraphBase::StreamNode::RemoveLink( GraphBase::StreamNode * ToNode ) { +bool GraphBase::StreamNode::RemoveLinkedNode( GraphBase::StreamNode * ToNode ) { int index = GetLinkedNodeIndex( ToNode->Name() ) ; if ( index >= 0 ) { - cdebug << "GraphBase::StreamNode::RemoveLink( to " << ToNode->Name() << " from " + cdebug << "GraphBase::StreamNode::RemoveLinkedNode( to " << ToNode->Name() << " from " << Name() << " index : " << index << " LinkedInPortsNumber " << _LinkedInPortsNumber[ index ] << " - 1" << endl ; _LinkedInPortsNumber[ index ] -= 1 ; if ( _LinkedInPortsNumber[ index ] == 0 ) { _LinkedNodesSize-- ; - cdebug << "GraphBase::StreamNode::RemoveLink new LinkedNodesSize " + cdebug << "GraphBase::StreamNode::RemoveLinkedNode new LinkedNodesSize " << _LinkedNodesSize << " " << ToNode->Name() << " removed from " << " linkednodes of " << Name() << endl ; int i ; @@ -145,12 +162,22 @@ bool GraphBase::StreamNode::RemoveLink( GraphBase::StreamNode * ToNode ) { } } else { - cdebug << " Error index " << index << endl ; + cdebug << "StreamNode::RemoveLinkedNode index Error " << Name() << " --> " << ToNode->Name() << " : " << index + << " _LinkedNodesSize " << _LinkedNodesSize << endl ; +#if 1 + map< string , int >::iterator aMapOfLinkedNodesIterator ; + int i = 0 ; + for ( aMapOfLinkedNodesIterator = _MapOfLinkedNodes.begin() ; + aMapOfLinkedNodesIterator != _MapOfLinkedNodes.end() ; aMapOfLinkedNodesIterator++ ) { + cdebug << "_MapOfLinkedNodes" << i++ << " " << aMapOfLinkedNodesIterator->first << " --> " + << aMapOfLinkedNodesIterator->second << endl ; + } +#endif } return (index >= 0 ) ; } -void GraphBase::StreamNode::ReNameLink( const char* OldNodeName , +void GraphBase::StreamNode::ReNameLinkedNode( const char* OldNodeName , const char* NewNodeName ) { cdebug_in << "GraphBase::StreamNode::ReNameLink (" << OldNodeName << " , " << NewNodeName << ")" << endl; @@ -163,10 +190,10 @@ void GraphBase::StreamNode::ReNameLink( const char* OldNodeName , cdebug_out << "GraphBase::StreamNode::ReNameLink" << endl ; } -void GraphBase::StreamNode::AddStreamLink( GraphBase::StreamNode * ToNode ) { +void GraphBase::StreamNode::AddStreamLinkedNode( GraphBase::StreamNode * ToNode ) { int index = GetLinkedStreamNodeIndex( ToNode->Name() ) ; if ( index < 0 ) { - cdebug_in << Name() << "->GraphBase::StreamNode::AddStreamLink( " << ToNode->Name() + cdebug_in << Name() << "->GraphBase::StreamNode::AddStreamLinkedNode( " << ToNode->Name() << " ) new LinkedNode " << endl ; _LinkedStreamNodes.resize( _LinkedStreamNodesSize+1 ) ; _LinkedInStreamPortsNumber.resize( _LinkedStreamNodesSize+1 ) ; @@ -177,7 +204,7 @@ void GraphBase::StreamNode::AddStreamLink( GraphBase::StreamNode * ToNode ) { _LinkedStreamNodesSize++ ; } else { - cdebug_in << Name() << "->GraphBase::StreamNode::AddStreamLink( " << ToNode->Name() + cdebug_in << Name() << "->GraphBase::StreamNode::AddStreamLinkedNode( " << ToNode->Name() << " ) old LinkedNode " << _LinkedStreamNodes[index ]->Name() << endl ; _LinkedInStreamPortsNumber[ index ] += 1 ; } @@ -186,16 +213,16 @@ void GraphBase::StreamNode::AddStreamLink( GraphBase::StreamNode * ToNode ) { << " ] _LinkedInStreamPortsNumber " << _LinkedInStreamPortsNumber[ index ] << endl ; } -bool GraphBase::StreamNode::RemoveStreamLink( GraphBase::StreamNode * ToNode ) { +bool GraphBase::StreamNode::RemoveStreamLinkedNode( GraphBase::StreamNode * ToNode ) { int index = GetLinkedStreamNodeIndex( ToNode->Name() ) ; if ( index >= 0 ) { - cdebug << "GraphBase::StreamNode::RemoveStreamLink( to " << ToNode->Name() << " from " + cdebug << "GraphBase::StreamNode::RemoveStreamLinkedNode( to " << ToNode->Name() << " from " << Name() << " index : " << index << " LinkedInStreamPortsNumber " << _LinkedInStreamPortsNumber[ index ] << " - 1" << endl ; _LinkedInStreamPortsNumber[ index ] -= 1 ; if ( _LinkedInStreamPortsNumber[ index ] == 0 ) { _LinkedStreamNodesSize-- ; - cdebug << "GraphBase::StreamNode::RemoveStreamLink new LinkedNodesSize " + cdebug << "GraphBase::StreamNode::RemoveStreamLinkedNode new LinkedNodesSize " << _LinkedStreamNodesSize << " " << ToNode->Name() << " removed from " << " linkednodes of " << Name() << endl ; int i ; @@ -210,14 +237,14 @@ bool GraphBase::StreamNode::RemoveStreamLink( GraphBase::StreamNode * ToNode ) { } } else { - cdebug << " Error index " << index << endl ; + cdebug << "StreamNode::RemoveStreamLinkedNode Error index " << index << endl ; } return (index >= 0 ) ; } -void GraphBase::StreamNode::ReNameStreamLink( const char* OldNodeName , +void GraphBase::StreamNode::ReNameStreamLinkedNode( const char* OldNodeName , const char* NewNodeName ) { - cdebug_in << "GraphBase::StreamNode::ReNameStreamLink (" << OldNodeName << " , " + cdebug_in << "GraphBase::StreamNode::ReNameStreamLinkedNode (" << OldNodeName << " , " << NewNodeName << ")" << endl; int index = GetLinkedStreamNodeIndex( OldNodeName ) ; if ( index >= 0 ) { @@ -225,6 +252,6 @@ void GraphBase::StreamNode::ReNameStreamLink( const char* OldNodeName , DelLinkedStreamNodeIndex( OldNodeName ) ; SetLinkedStreamNodeIndex( NewNodeName , index ) ; } - cdebug_out << "GraphBase::StreamNode::ReNameStreamLink" << endl ; + cdebug_out << "GraphBase::StreamNode::ReNameStreamLinkedNode" << endl ; } diff --git a/src/GraphBase/DataFlowBase_StreamNode.hxx b/src/GraphBase/DataFlowBase_StreamNode.hxx index 3a7b5b2..6b8a8ab 100644 --- a/src/GraphBase/DataFlowBase_StreamNode.hxx +++ b/src/GraphBase/DataFlowBase_StreamNode.hxx @@ -14,8 +14,22 @@ #include "DataFlowBase_PortsOfNode.hxx" +namespace GraphEditor { + + class DataFlow ; + +} + +namespace GraphExecutor { + + class DataFlow ; + +} + namespace GraphBase { + class Graph ; + class StreamNode : public PortsOfNode { private: @@ -40,6 +54,13 @@ namespace GraphBase { int _LevelNumber ; int _SortedIndex ; + GraphEditor::DataFlow * _GraphEditor ; + GraphExecutor::DataFlow * _GraphExecutor ; +// If DataFlowGraph/DataStreamGraph in another graph : +// the Graph if MacroNode and MacroNode if Graph + SUPERV::Graph_var _GraphMacroNode ; + + int _GraphMacroLevel ; int _SubGraphNumber ; int _SubStreamGraphNumber ; @@ -50,7 +71,10 @@ namespace GraphBase { StreamNode() ; - StreamNode( const char * NodeName ) ; + StreamNode( const char * NodeName , + const SUPERV::KindOfNode DataFlowkind , + int * Graph_prof_debug , + ofstream * Graph_fdebug ) ; StreamNode( int * Graph_prof_debug , ofstream * Graph_fdebug ) ; @@ -77,11 +101,14 @@ namespace GraphBase { Kind() == SUPERV::EndLoopNode || Kind() == SUPERV::SwitchNode || Kind() == SUPERV::EndSwitchNode || - Kind() == SUPERV::GOTONode ) ; } ; + Kind() == SUPERV::GOTONode || + Kind() == SUPERV::MacroNode ) ; } ; const bool IsOneOfInLineNodes() const { return (Kind() == SUPERV::InLineNode || IsOneOfGOTONodes() ) ; } ; const bool IsInLineNode() const { return (Kind() == SUPERV::InLineNode ) ; } ; + const bool IsMacroNode() const { + return (Kind() == SUPERV::MacroNode ) ; } ; const bool IsDataFlowNode() const { return (Kind() == SUPERV::DataFlowGraph ) ; } ; const bool IsDataStreamNode() const { @@ -154,7 +181,7 @@ namespace GraphBase { void HeadNode( bool aHeadNode ) { _HeadNode = aHeadNode ; } ; const bool IsHeadNode() const { return _HeadNode ; } ; - int Level() { return _LevelNumber ; } ; + int Level() const { return _LevelNumber ; } ; void Level( int LevelNumber ) { _LevelNumber = LevelNumber ; } ; @@ -165,24 +192,57 @@ namespace GraphBase { void SetSubStreamGraph( int SubStreamGraphsNumber , int & RetVal ) ; - int SubGraph() { return _SubGraphNumber ; } ; + void SetGraphEditor( GraphEditor::DataFlow * aGraphEditor ) { + cdebug << "SetGraphEditor this " << this << " " << Name() << " : " << aGraphEditor << endl ; + _GraphEditor = aGraphEditor ; } ; + GraphEditor::DataFlow * GraphEditor() const { + cdebug << "GraphEditor this " << this << " " << Name() << " : " << _GraphEditor << endl ; + return _GraphEditor ; } ; + + void SetGraphExecutor( GraphExecutor::DataFlow * aGraphExecutor ) { + cdebug << "SetGraphExecutor this " << this << " " << Name() << " : " << aGraphExecutor << endl ; + _GraphExecutor = aGraphExecutor ; } ; + GraphExecutor::DataFlow * GraphExecutor() const { + cdebug << "GraphExecutor this " << this << " " << Name() << " : " << _GraphExecutor << endl ; + return _GraphExecutor ; } ; + + void GraphMacroLevel( int aGraphMacroLevel ) { + cdebug << "GraphMacroLevel " << Name() << " " << aGraphMacroLevel << endl ; + _GraphMacroLevel = aGraphMacroLevel ; } ; + int GraphMacroLevel() const { + return _GraphMacroLevel ; } ; + + void MacroObject( SUPERV::Graph_var aGraphMacroNode ) { + if ( CORBA::is_nil( aGraphMacroNode ) ) { + cdebug << "MacroObject GraphMacroNode " << this << " " << Name() + << " MacroObject(nil object). Error" << endl ; + } + _GraphMacroNode = aGraphMacroNode ; } ; + SUPERV::Graph_var MacroObject() const { + if ( CORBA::is_nil( _GraphMacroNode ) ) { + cdebug << "MacroObject GraphMacroNode " << this << " " << Name() + << " returns nil object. Error" << endl ; + } + return _GraphMacroNode ; } ; + + int SubGraph() const { return _SubGraphNumber ; } ; void SubGraph( int SubGraphNumber ) { _SubGraphNumber = SubGraphNumber ; } ; - int SubStreamGraph() { return _SubStreamGraphNumber ; } ; + int SubStreamGraph() const { return _SubStreamGraphNumber ; } ; void SubStreamGraph( int SubStreamGraphNumber ) { _SubStreamGraphNumber = SubStreamGraphNumber ; } ; - void AddLink( StreamNode * aNode ) ; - bool RemoveLink( StreamNode * aNode ) ; - void ReNameLink( const char* OldNodeName , - const char* NewNodeName ) ; - - void AddStreamLink( StreamNode * aNode ) ; - bool RemoveStreamLink( StreamNode * aNode ) ; - void ReNameStreamLink( const char* OldNodeName , + void AddLinkedNode( StreamNode * aNode ) ; + bool RemoveLinkedNode( StreamNode * aNode ) ; + void ReNameLinkedNode( const char* OldNodeName , const char* NewNodeName ) ; + void AddStreamLinkedNode( StreamNode * aNode ) ; + bool RemoveStreamLinkedNode( StreamNode * aNode ) ; + void ReNameStreamLinkedNode( const char* OldNodeName , + const char* NewNodeName ) ; + }; }; diff --git a/src/GraphBase/DataFlowBase_XmlHandler.cxx b/src/GraphBase/DataFlowBase_XmlHandler.cxx index 01a298c..7578329 100644 --- a/src/GraphBase/DataFlowBase_XmlHandler.cxx +++ b/src/GraphBase/DataFlowBase_XmlHandler.cxx @@ -47,22 +47,27 @@ GraphBase::XmlHandler::XmlHandler( CORBA::ORB_ptr Orb , step[i] = 0 ; } VXSize = 0 ; + GraphsNumber = 0 ; } GraphBase::XmlHandler::XmlHandler() {} GraphBase::XmlHandler::~XmlHandler() {} -QString GraphBase::XmlHandler::errorProtocol() -{ - return errorProt; +QString GraphBase::XmlHandler::errorProtocol() { + return errorProt; } -bool GraphBase::XmlHandler::startDocument() -{ - // at the beginning of parsing: do some initialization - errorProt = ""; - return TRUE; +bool GraphBase::XmlHandler::startDocument() { + MESSAGE( "====================startDocument " ) ; +// at the beginning of parsing: do some initialization + errorProt = ""; + return TRUE; +} + +bool GraphBase::XmlHandler::endDocument() { + MESSAGE( "====================endDocument " ) ; + return TRUE; } bool GraphBase::XmlHandler::startElement( const QString&, const QString&, @@ -75,13 +80,26 @@ bool GraphBase::XmlHandler::startElement( const QString&, const QString&, MESSAGE( "====================startElement " << depth << " " << qName) #endif - if ( qName == "dataflow" && depth == 0 ) { + + if ( ( qName == "dataflow" || qName == "supergraph" ) && depth == 0 ) { // Dataflow detected + aListOfDataFlows.resize( GraphsNumber + 1 ) ; + int i ; + for ( i = 0 ; i < maxlevel ; i++ ) { + fieldname[i] = NULLSTRING ; + fieldvalue[i] = NULLSTRING ; + step[i] = 0 ; + } + VXSize = 0 ; dataflowxml = TRUE; } if ( dataflowxml ) { -// fieldname[depth++] = (const char * ) qName ; - fieldname[depth++] = qName.latin1() ; + if ( qName == "supergraph" ) { + fieldname[depth] = qName.latin1() ; + } + else { + fieldname[depth++] = qName.latin1() ; + } } if ( depth == maxlevel+1 ) return false ; @@ -103,16 +121,27 @@ bool GraphBase::XmlHandler::endElement( const QString&, const QString&, const QString& qName) { + if ( qName == "supergraph" ) { +#if TRACE + MESSAGE( " ====================endElement supergraph" ) ; +#endif + return TRUE ; + } + +// ERRORs : +// * On a eu endElement(dataflow) +// * Ou bien on a eu uniquement startElement(dataflow) et qName != fieldname et fieldvalue != NULLSTRING if ( !dataflowxml || ( qName != QString( fieldname[depth].c_str() ) && fieldvalue[depth] != NULLSTRING ) ) { - MESSAGE( "endElement ERROR " << dataflowxml << " qName " << qName - << " fieldname" << fieldname[depth] << " fieldvalue " + MESSAGE( "endElement ERROR dataflowxml " << dataflowxml << " qName " << qName + << " fieldname[" << depth << "] "<< fieldname[depth] << " fieldvalue " << fieldvalue[depth] ) return returnfalse( this , "top" , qName ) ; } - if ( fieldvalue[depth] == NULLSTRING ) + if ( fieldvalue[depth] == NULLSTRING ) { depth -= 1 ; + } #if TRACE MESSAGE( " ====================endElement step[" << depth << "]=" @@ -122,6 +151,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, switch ( depth ) { case 0 : { if ( step[depth] == 0 && qName == "dataflow" ) { + GraphsNumber += 1 ; dataflowxml = false ; } else @@ -133,7 +163,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, switch ( step[depth] ) { case 0 : if ( qName == "info-list" ) { -// aDataFlow.Info = aNode ; +// aListOfDataFlows[ GraphsNumber ].Info = aNode ; step[depth]++ ; } else @@ -176,12 +206,12 @@ bool GraphBase::XmlHandler::endElement( const QString&, if ( qName == "node" ) { // Node ok if ( step[1] == 0 ) { - aDataFlow.Info = aNode ; + aListOfDataFlows[ GraphsNumber ].Info = aNode ; } else if ( step[1] == 1 ) { - int sizenode = aDataFlow.Nodes.size() ; - aDataFlow.Nodes.resize( sizenode+1 ) ; - aDataFlow.Nodes[ sizenode ] = aNode ; + int sizenode = aListOfDataFlows[ GraphsNumber ].Nodes.size() ; + aListOfDataFlows[ GraphsNumber ].Nodes.resize( sizenode+1 ) ; + aListOfDataFlows[ GraphsNumber ].Nodes[ sizenode ] = aNode ; } step[3] = 0 ; aNode.theService.ServiceinParameter.length( 0 ) ; @@ -201,15 +231,15 @@ bool GraphBase::XmlHandler::endElement( const QString&, } case 1 : if ( qName == "link" ) { - int sizelink = aDataFlow.Links.size() ; - aDataFlow.Links.resize( sizelink+1 ) ; - aDataFlow.Links[ sizelink ] = aLink ; + int sizelink = aListOfDataFlows[ GraphsNumber ].Links.size() ; + aListOfDataFlows[ GraphsNumber ].Links.resize( sizelink+1 ) ; + aListOfDataFlows[ GraphsNumber ].Links[ sizelink ] = aLink ; if ( VXSize ) { - aDataFlow.Links[ sizelink ].aListOfCoords.resize( VXSize ) ; + aListOfDataFlows[ GraphsNumber ].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] ; + aListOfDataFlows[ GraphsNumber ].Links[ sizelink ].aListOfCoords[ ic ].theX = VX[ic] ; + aListOfDataFlows[ GraphsNumber ].Links[ sizelink ].aListOfCoords[ ic ].theY = VY[ic] ; } } VXSize = 0 ; @@ -227,15 +257,15 @@ bool GraphBase::XmlHandler::endElement( const QString&, if ( qName == "data" ) { // Data ok if ( constructor ) { - int sizedata = aDataFlow.Datas.size() ; - aDataFlow.Datas.resize( sizedata+1 ) ; - aDataFlow.Datas[ sizedata ] = aLink ; + int sizedata = aListOfDataFlows[ GraphsNumber ].Datas.size() ; + aListOfDataFlows[ GraphsNumber ].Datas.resize( sizedata+1 ) ; + aListOfDataFlows[ GraphsNumber ].Datas[ sizedata ] = aLink ; if ( VXSize ) { - aDataFlow.Datas[ sizedata ].aListOfCoords.resize( VXSize ) ; + aListOfDataFlows[ GraphsNumber ].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] ; + aListOfDataFlows[ GraphsNumber ].Datas[ sizedata ].aListOfCoords[ ic ].theX = VX[ic] ; + aListOfDataFlows[ GraphsNumber ].Datas[ sizedata ].aListOfCoords[ ic ].theY = VY[ic] ; } } } @@ -908,7 +938,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, fieldvalue[depth] = NULLSTRING ; step[depth]++ ; #if TRACE - cout << "InDataStreamParameter.inParameter-type " << anInDataStreamParameter.theDataStreamParameter.Parametertype << " step[" << depth << "]" << step[depth] << endl ; + //cout << "InDataStreamParameter.inParameter-type " << anInDataStreamParameter.theDataStreamParameter.Parametertype << " step[" << depth << "]" << step[depth] << endl ; #endif break ; } @@ -928,7 +958,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, } fieldvalue[depth] = NULLSTRING ; #if TRACE - cout << "InDataStreamParameter.inParameter-name " << anInDataStreamParameter.theDataStreamParameter.Parametername << " step[" << depth << "]" << step[depth] << endl ; + //cout << "InDataStreamParameter.inParameter-name " << anInDataStreamParameter.theDataStreamParameter.Parametername << " step[" << depth << "]" << step[depth] << endl ; #endif // step[depth]++ ; // step[depth] = 4 ; @@ -940,7 +970,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, sscanf( fieldvalue[depth].c_str() , "%d" , (int * ) &anInDataStreamParameter.theDataStreamParameter.Parameterdependency ) ; fieldvalue[depth] = NULLSTRING ; #if TRACE - cout << "InDataStreamParameter.inParameter-dependency " << anInDataStreamParameter.theDataStreamParameter.Parameterdependency << " step[" << depth << "]" + //cout << "InDataStreamParameter.inParameter-dependency " << anInDataStreamParameter.theDataStreamParameter.Parameterdependency << " step[" << depth << "]" << step[depth] << endl ; #endif // step[depth]++ ; @@ -953,7 +983,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, sscanf( fieldvalue[depth].c_str() , "%d" , (int * ) &anInDataStreamParameter.theKindOfSchema ) ; fieldvalue[depth] = NULLSTRING ; #if TRACE - cout << "InDataStreamParameter.inParameter-schema " << anInDataStreamParameter.theKindOfSchema << " step[" << depth << "]" + //cout << "InDataStreamParameter.inParameter-schema " << anInDataStreamParameter.theKindOfSchema << " step[" << depth << "]" << step[depth] << endl ; #endif // step[depth]++ ; @@ -966,7 +996,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, sscanf( fieldvalue[depth].c_str() , "%d" , (int * ) &anInDataStreamParameter.theKindOfInterpolation ) ; fieldvalue[depth] = NULLSTRING ; #if TRACE - cout << "InDataStreamParameter.inParameter-interpolation " << anInDataStreamParameter.theKindOfInterpolation << " step[" << depth << "]" + //cout << "InDataStreamParameter.inParameter-interpolation " << anInDataStreamParameter.theKindOfInterpolation << " step[" << depth << "]" << step[depth] << endl ; #endif // step[depth]++ ; @@ -981,7 +1011,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, // step[depth]++ ; step[depth] = 4 ; #if TRACE - cout << "InDataStreamParameter.inParameter-extrapolation " << anInDataStreamParameter.theKindOfExtrapolation << " step[" << depth << "]" + //cout << "InDataStreamParameter.inParameter-extrapolation " << anInDataStreamParameter.theKindOfExtrapolation << " step[" << depth << "]" << step[depth] << endl ; #endif break ; @@ -998,7 +1028,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, // step[depth]++ ; step[depth] = 7 ; #if TRACE - cout << "OutDataStreamParameter.outParameter-type " << anOutDataStreamParameter.theDataStreamParameter.Parametertype << " step[" << depth << "]" + //cout << "OutDataStreamParameter.outParameter-type " << anOutDataStreamParameter.theDataStreamParameter.Parametertype << " step[" << depth << "]" << step[depth] << endl ; #endif } @@ -1017,7 +1047,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, } fieldvalue[depth] = NULLSTRING ; #if TRACE - cout << "OutDataStreamParameter.outParameter-name " << anOutDataStreamParameter.theDataStreamParameter.Parametername << " step[" << depth << "]" + //cout << "OutDataStreamParameter.outParameter-name " << anOutDataStreamParameter.theDataStreamParameter.Parametername << " step[" << depth << "]" << step[depth] << endl ; #endif // step[depth]++ ; @@ -1029,7 +1059,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, sscanf( fieldvalue[depth].c_str() , "%d" , (int * ) &anOutDataStreamParameter.theDataStreamParameter.Parameterdependency ) ; fieldvalue[depth] = NULLSTRING ; #if TRACE - cout << "OutDataStreamParameter.outParameter-dependency " << anOutDataStreamParameter.theDataStreamParameter.Parameterdependency << " step[" << depth << "]" + //cout << "OutDataStreamParameter.outParameter-dependency " << anOutDataStreamParameter.theDataStreamParameter.Parameterdependency << " step[" << depth << "]" << step[depth] << endl ; #endif // step[depth]++ ; @@ -1043,7 +1073,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, // step[depth]++ ; step[depth] = 6 ; #if TRACE - cout << "OutDataStreamParameter.outParameter-values " << anOutDataStreamParameter.theNumberOfValues << " step[" << depth << "]" + //cout << "OutDataStreamParameter.outParameter-values " << anOutDataStreamParameter.theNumberOfValues << " step[" << depth << "]" << step[depth] << endl ; #endif } @@ -1165,7 +1195,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, } #if TRACE - cout << "return from endElement " << qName << " step[" << depth << "]" << step[depth] << endl ; + //cout << "return from endElement " << qName << " step[" << depth << "]" << step[depth] << endl ; #endif return TRUE; } @@ -1180,7 +1210,7 @@ bool GraphBase::XmlHandler::characters( const QString& ch ) { depth -= 1 ; #if TRACE MESSAGE( "characters step[" << depth << "]=" << step[depth] - << " ch " << ch << " fieldvalue_must_be_NULL " << fieldvalue[depth] ) + << " ch " << ch << " fieldvalue_must_be_NULL : '" << fieldvalue[depth] << "'" ) ; #endif if ( depth < 0 || fieldvalue[depth] != NULLSTRING ) return returnfalse( this , "characters " , ch ) ; @@ -1192,7 +1222,7 @@ bool GraphBase::XmlHandler::characters( const QString& ch ) { QString GraphBase::XmlHandler::errorString() { - cout << "the document is not in the quote file format" << endl ; + //cout << "the document is not in the quote file format" << endl ; return "the document is not in the quote file format"; } @@ -1202,7 +1232,7 @@ bool GraphBase::XmlHandler::fatalError( const QXmlParseException& exception ) { .arg( exception.message() ) .arg( exception.lineNumber() ) .arg( exception.columnNumber() ); - cout << "GraphBase::XmlHandler::fatalError " << errorProt.latin1() << endl ; + //cout << "GraphBase::XmlHandler::fatalError " << errorProt.latin1() << endl ; return QXmlDefaultHandler::fatalError( exception ); } diff --git a/src/GraphBase/DataFlowBase_XmlHandler.hxx b/src/GraphBase/DataFlowBase_XmlHandler.hxx index 5bfcdb9..d92285b 100755 --- a/src/GraphBase/DataFlowBase_XmlHandler.hxx +++ b/src/GraphBase/DataFlowBase_XmlHandler.hxx @@ -68,7 +68,8 @@ namespace GraphBase { vector VY ; QString errorProt; - GraphBase::SGraph aDataFlow ; + int GraphsNumber ; + GraphBase::ListOfSGraphs aListOfDataFlows ; public: @@ -76,23 +77,24 @@ namespace GraphBase { XmlHandler( CORBA::ORB_ptr Orb , const bool aConstructor ); virtual ~XmlHandler(); - GraphBase::SGraph & GetDataFlow() { - return aDataFlow ; } ; + GraphBase::ListOfSGraphs & ListOfDataFlows() { + return aListOfDataFlows ; } ; // return the error protocol if parsing failed QString errorProtocol(); // overloaded handler functions - bool startDocument(); + bool startDocument() ; + bool endDocument() ; bool startElement( const QString& namespaceURI, const QString& localName, - const QString& qName, const QXmlAttributes& atts ); + const QString& qName, const QXmlAttributes& atts ) ; bool endElement( const QString& namespaceURI, const QString& localName, - const QString& qName ); - bool characters( const QString& ch ); + const QString& qName ) ; + bool characters( const QString& ch ) ; QString errorString(); - bool fatalError (const QXmlParseException& exception); + bool fatalError( const QXmlParseException& exception); SUPERV::SDate StringToDate( QString& qstrDate) const; diff --git a/src/GraphBase/Makefile.in b/src/GraphBase/Makefile.in index ba02798..e321f12 100644 --- a/src/GraphBase/Makefile.in +++ b/src/GraphBase/Makefile.in @@ -56,8 +56,8 @@ EXPORT_HEADERS = \ DataFlowBase_EndOfSwitchNode.hxx \ DataFlowBase_DataNode.hxx \ DataFlowBase_XmlHandler.hxx \ - DataFlowBase_StreamGraph.hxx \ - DataFlowBase_Graph.hxx + DataFlowBase_Graph.hxx \ + DataFlowBase_StreamGraph.hxx # Libraries targets LIB = libSalomeSuperVisionBase.la @@ -83,8 +83,8 @@ LIB_SRC = \ DataFlowBase_DataNode.cxx \ DataFlowBase_XmlHandler.cxx \ DataFlowBase_LoadXml.cxx \ - DataFlowBase_StreamGraph.cxx \ - DataFlowBase_Graph.cxx + DataFlowBase_Graph.cxx \ + DataFlowBase_StreamGraph.cxx LIB_CLIENT_IDL = Logger.idl \ SALOME_ModuleCatalog.idl \ @@ -100,7 +100,7 @@ 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 -Wall \ +CXXFLAGS+= -g -D_DEBUG_ -D__x86__ -D__linux__ -ftemplate-depth-42 -Wall \ -I${KERNEL_ROOT_DIR}/include/salome LDFLAGS= -L../../lib/salome $(CORBA_LIBS) -lSalomeNS -lSalomeLifeCycleCORBA -lOpUtil -lSALOMELocalTrace \ -lc $(PYTHON_LIBS) $(QT_MT_LIBS) $(OGL_LIBS) \ diff --git a/src/SUPERVGUI/Makefile.in b/src/SUPERVGUI/Makefile.in index 1cb62bb..c73c06f 100644 --- a/src/SUPERVGUI/Makefile.in +++ b/src/SUPERVGUI/Makefile.in @@ -64,7 +64,15 @@ LIB_SRC = SUPERVGUI.cxx \ SUPERVGUI_BrowseNodeDlg.cxx \ SUPERVGUI_Link.cxx \ SUPERVGUI_CtrlLink.cxx \ - SUPERVGUI_Label.cxx + SUPERVGUI_Label.cxx \ + SUPERVGUI_CanvasView.cxx \ + SUPERVGUI_Canvas.cxx \ + SUPERVGUI_CanvasNode.cxx \ + SUPERVGUI_CanvasNodePrs.cxx \ + SUPERVGUI_CanvasControlNode.cxx \ + SUPERVGUI_CanvasControlNodePrs.cxx \ + SUPERVGUI_CanvasPort.cxx \ + SUPERVGUI_CanvasLink.cxx LIB_MOC = SUPERVGUI.h \ SUPERVGUI_Service.h \ @@ -82,7 +90,13 @@ LIB_MOC = SUPERVGUI.h \ SUPERVGUI_Port.h \ SUPERVGUI_BrowseNodeDlg.h \ SUPERVGUI_Link.h \ - SUPERVGUI_Label.h + SUPERVGUI_Label.h \ + SUPERVGUI_Canvas.h \ + SUPERVGUI_CanvasView.h \ + SUPERVGUI_CanvasNode.h \ + SUPERVGUI_CanvasControlNode.h \ + SUPERVGUI_CanvasPort.h \ + SUPERVGUI_CanvasLink.h LIB_CLIENT_IDL = SALOMEDS.idl \ SALOMEDS_Attributes.idl \ @@ -100,6 +114,6 @@ LDFLAGS+=$(QT_MT_LIBS) $(VTK_LIBS) $(OGL_LIBS) $(PYTHON_LIBS)\ -lSalomeLifeCycleCORBA -lSalomeNotification -lSUPERVGraph \ -L${KERNEL_ROOT_DIR}/lib/salome -LIBS+= $(PYTHON_LIBS) +LIBS+= @CONCLUDE@ diff --git a/src/SUPERVGUI/SUPERVGUI.cxx b/src/SUPERVGUI/SUPERVGUI.cxx index 64aa853..f622c04 100644 --- a/src/SUPERVGUI/SUPERVGUI.cxx +++ b/src/SUPERVGUI/SUPERVGUI.cxx @@ -74,7 +74,11 @@ SUPERVGUI::~SUPERVGUI() { factory = 0; //if (!engine->_is_nil()) CORBA::release(engine); //info->close(); - if (browser) browser->close(); + if (browser) { + if (browser->isVisible()) + browser->close(); + delete browser; + } MESSAGE("SUPERVGUI Info : factory destroy"); } else { MESSAGE("SUPERVGUI Error : another call to factory destructor"); diff --git a/src/SUPERVGUI/SUPERVGUI_Array.cxx b/src/SUPERVGUI/SUPERVGUI_Array.cxx index 9c89bd7..673793d 100644 --- a/src/SUPERVGUI/SUPERVGUI_Array.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Array.cxx @@ -37,11 +37,12 @@ using namespace std; #include #include -#define ADDNODES(NodesName) \ +#define ADDNODES(NodesName,LevelHasDiffNT) \ ncols = nodes->NodesName.length(); \ for (int co=0; coNodesName[co]); \ - x = 50 + co * (CELL_WIDTH + CELL_SPACE);\ + if (!LevelHasDiffNT) x = 50 + co * (CELL_WIDTH + CELL_SPACE); \ + else x += (CELL_WIDTH + CELL_SPACE); \ SUPERVGUI_Node* aNode = new SUPERVGUI_Cell(viewport(), main, aCNode); \ ResizeGraph(aNode, x, y); \ addChild(aNode, x, y); \ @@ -49,21 +50,22 @@ using namespace std; -#define ADDCONTROLNODES(NodesName) \ +#define ADDCONTROLNODES(NodesName,LevelHasDiffNT) \ ncols = nodes->NodesName.length(); \ - x = 50; \ + if (!LevelHasDiffNT) x = 50; \ + else x += (CELL_WIDTH + CELL_SPACE); \ 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); \ + y += (CELL_HEIGHT + CELL_SPACE); \ SUPERV_CNode aCNodeEnd = SUPERV::CNode::_narrow(nodes->NodesName[co]->Coupled()); \ SUPERVGUI_Node* aNodeEnd = new SUPERVGUI_CellEndControl(viewport(), main, aCNodeEnd, dynamic_cast(aNode)); \ ResizeGraph(aNodeEnd, x, y); \ addChild(aNodeEnd, x, y); \ x += (CELL_WIDTH + CELL_SPACE); \ - } + } @@ -115,15 +117,45 @@ bool SUPERVGUI_Array::create() { aTitle->setFrameStyle(QFrame::Panel | QFrame::Plain); addChild(aTitle, 50 + co * (CELL_WIDTH + CELL_SPACE), 20); } + y = 60; + bool LevelHasDiffNT = false; 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); + int aSumNum = nodes->CNodes.length()+nodes->FNodes.length()+nodes->INodes.length()+ + nodes->GNodes.length()+nodes->LNodes.length()+nodes->SNodes.length(); + if (nodes->CNodes.length() != 0 ) { + ADDNODES(CNodes,LevelHasDiffNT); + if (aSumNum > nodes->CNodes.length()) + LevelHasDiffNT = true; + } + if (nodes->FNodes.length() != 0 ) { + ADDNODES(FNodes,LevelHasDiffNT); + if (aSumNum > nodes->FNodes.length()) + LevelHasDiffNT = true; + } + if (nodes->INodes.length() != 0 ) { + ADDNODES(INodes,LevelHasDiffNT); + if (aSumNum > nodes->INodes.length()) + LevelHasDiffNT = true; + } + if (nodes->GNodes.length() != 0 ) { + ADDNODES(GNodes,LevelHasDiffNT); + if (aSumNum > nodes->GNodes.length()) + LevelHasDiffNT = true; + } + if (nodes->LNodes.length() != 0 ) { + ADDCONTROLNODES(LNodes,LevelHasDiffNT); + if (aSumNum > nodes->LNodes.length()) + LevelHasDiffNT = true; + } + if (nodes->SNodes.length() != 0 ) { + ADDCONTROLNODES(SNodes,LevelHasDiffNT); + if (aSumNum > nodes->SNodes.length()) + LevelHasDiffNT = true; + } + y += (CELL_HEIGHT + CELL_SPACE); + + LevelHasDiffNT = false; } nodeX = 50; nodeY = y + CELL_HEIGHT*2; diff --git a/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx b/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx index 97580c5..239575e 100644 --- a/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx +++ b/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx @@ -11,6 +11,9 @@ using namespace std; #include "SUPERVGUI_BrowseNodeDlg.h" #include "SUPERVGUI_Node.h" +#include "SUPERVGUI_CanvasNode.h" +#include "SUPERVGUI_Port.h" +#include "SUPERVGUI_CanvasPort.h" #include "SUPERVGUI.h" #include #include @@ -18,6 +21,7 @@ using namespace std; #include #include #include +#include /** * Constructor @@ -65,6 +69,7 @@ bool SUPERVGUI_PortField::setNewValue() { if ( aTxt.isNull() || aTxt.isEmpty() ) return false; if ( aTxt.find( "Unknown" ) < 0 ) { + //cout<<" ===> Set new value!"<Input( Supervision.getEngine()->StringValue( aTxt ) ); } return false; @@ -85,17 +90,41 @@ bool SUPERVGUI_PortField::eventFilter( QObject* o, QEvent* e ) /** - * Constructor + * Constructor (SUPERVGUI_Node) */ SUPERVGUI_BrowseNodeDlg::SUPERVGUI_BrowseNodeDlg( SUPERVGUI_Node* theNode ) : QDialog( theNode, 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +{ + myNode = theNode; + myNodeCanvas = 0; + + init(); +} + +/** + * Constructor (SUPERVGUI_CanvasNode) + */ +SUPERVGUI_BrowseNodeDlg::SUPERVGUI_BrowseNodeDlg( SUPERVGUI_CanvasNode* theNode ) + : QDialog( QAD_Application::getDesktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +{ + myNode = 0; + myNodeCanvas = theNode; + + init(); +} + +void SUPERVGUI_BrowseNodeDlg::init() { myActiveField = 0; setSizeGripEnabled( true ); - myNode = theNode; myPortsList.setAutoDelete( true ); - SUPERV_CNode aEngine = myNode->getEngine(); + SUPERV_CNode aEngine; + if (myNode != 0) + aEngine = myNode->getEngine(); + else + aEngine = myNodeCanvas->getEngine(); + mySelection = SALOME_Selection::Selection( Supervision.getActiveStudy()->getSelection() ); // mySelection->ClearIObjects(); @@ -169,7 +198,10 @@ SUPERVGUI_BrowseNodeDlg::SUPERVGUI_BrowseNodeDlg( SUPERVGUI_Node* theNode ) aBtnLayout->addStretch(); connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) ); - myNode->getMain()->lockedGraph(true); + if (myNode != 0) + myNode->getMain()->lockedGraph(true); + else + myNodeCanvas->getMain()->lockedGraph(true); } /** @@ -197,9 +229,17 @@ void SUPERVGUI_BrowseNodeDlg::accept() { for ( aField = myPortsList.first(); aField; aField = myPortsList.next() ) { aField->setNewValue(); } - myNode->sync(); + if (myNode != 0) + myNode->sync(); + else { + myNodeCanvas->sync(); + myNodeCanvas->getMain()->getCanvas()->update(); + } } - myNode->getMain()->lockedGraph(false); + if (myNode != 0) + myNode->getMain()->lockedGraph(false); + else + myNodeCanvas->getMain()->lockedGraph(false); QDialog::accept(); close(); } @@ -209,7 +249,10 @@ void SUPERVGUI_BrowseNodeDlg::accept() { * Closes and destroys dialog */ void SUPERVGUI_BrowseNodeDlg::reject() { - myNode->getMain()->lockedGraph(false); + if (myNode != 0) + myNode->getMain()->lockedGraph(false); + else + myNodeCanvas->getMain()->lockedGraph(false); QDialog::reject(); close(); } @@ -263,80 +306,48 @@ void SUPERVGUI_BrowseNodeDlg::onSelectionChanged() } /** - * Constructor + * Constructor (SUPERVGUI_PortIn) */ 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; + myPortCanvas = 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); + init(); } /** - * Constructor + * Constructor (SUPERVGUI_PortInESNode) */ 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; + myPortCanvas = 0; + + init(); +} + +/** + * Constructor (SUPERVGUI_CanvasPort) + */ +SUPERVGUI_GetValueDlg::SUPERVGUI_GetValueDlg( SUPERVGUI_CanvasPort* thePort ) + : QDialog( QAD_Application::getDesktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +{ + myPort = 0; + myPortESNode = 0; + myPortCanvas = thePort; + + init(); +} + +void SUPERVGUI_GetValueDlg::init() +{ + myOKBtn = 0; + setSizeGripEnabled( true ); mySelection = SALOME_Selection::Selection( Supervision.getActiveStudy()->getSelection() ); // mySelection->ClearIObjects(); @@ -359,7 +370,15 @@ SUPERVGUI_GetValueDlg::SUPERVGUI_GetValueDlg( SUPERVGUI_PortInESNode* thePort ) 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() ); + SUPERV_Port aEngine; + if (myPort != 0) + aEngine = myPort->getPort(); + else if (myPortESNode != 0) + aEngine = myPortESNode->getPort(); + else { + aEngine = myPortCanvas->getEngine(); + } + myField = new SUPERVGUI_PortField( aBox, aEngine ); bool myIsEditable = myField->isEditable(); aBoxLayout->addWidget( myField->myLabel, 1, 0 ); aBoxLayout->addWidget( myField->myValue, 1, 1 ); @@ -389,7 +408,12 @@ SUPERVGUI_GetValueDlg::SUPERVGUI_GetValueDlg( SUPERVGUI_PortInESNode* thePort ) myField->updateGUI(); connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) ); - myPortESNode->getMain()->lockedGraph(true); + if (myPort != 0) + myPort->getMain()->lockedGraph(true); + else if (myPortESNode != 0) + myPortESNode->getMain()->lockedGraph(true); + else + myPortCanvas->getMain()->lockedGraph(true); } /** @@ -406,8 +430,12 @@ void SUPERVGUI_GetValueDlg::accept() { if (myPort != 0) myPort->sync(); - else + else if (myPortESNode != 0) myPortESNode->sync(); + else { + myPortCanvas->sync(); + myPortCanvas->getMain()->getCanvas()->update(); + } } else { if ( QMessageBox::warning( QAD_Application::getDesktop(), @@ -418,8 +446,10 @@ void SUPERVGUI_GetValueDlg::accept() { if (myPort != 0) myPort->getMain()->lockedGraph(false); - else + else if (myPortESNode != 0) myPortESNode->getMain()->lockedGraph(false); + else + myPortCanvas->getMain()->lockedGraph(false); QDialog::accept(); close(); } @@ -430,8 +460,10 @@ void SUPERVGUI_GetValueDlg::accept() { void SUPERVGUI_GetValueDlg::reject() { if (myPort != 0) myPort->getMain()->lockedGraph(false); - else + else if (myPortESNode != 0) myPortESNode->getMain()->lockedGraph(false); + else + myPortCanvas->getMain()->lockedGraph(false); QDialog::reject(); close(); } @@ -463,3 +495,199 @@ void SUPERVGUI_GetValueDlg::onSelectionChanged() } } + + +// ---------------------------- +// Stream Ports +// ---------------------------- + +SUPERVGUI_StreamInDlg::SUPERVGUI_StreamInDlg(SUPERVGUI_StreamPortIn* thePort) + :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + myPort = thePort; + myPortCanvas = 0; + init(); +} + +SUPERVGUI_StreamInDlg::SUPERVGUI_StreamInDlg(SUPERVGUI_CanvasStreamPortIn* thePort) + :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + myPort = 0; + myPortCanvas = thePort; + init(); +} + +void SUPERVGUI_StreamInDlg::init() +{ + setSizeGripEnabled( true ); + setCaption( tr( "MSG_STREAM_DLG_TIT" ) ); + + QVBoxLayout* TopLayout = new QVBoxLayout( this, 11, 6 ); + + QFrame* aCtrlPane = new QFrame(this); + QGridLayout* aCtrlLayout = new QGridLayout( aCtrlPane, 4, 10 ); + + // Schema + QLabel* aSchemaLbl = new QLabel(tr("MSG_STREAM_SCHEMA"),aCtrlPane); + aCtrlLayout->addWidget(aSchemaLbl, 0, 0); + + mySchemaCombo = new QComboBox(aCtrlPane, "SchemaBox" ); + mySchemaCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + mySchemaCombo->insertItem("SCHENULL"); + mySchemaCombo->insertItem("TI"); + mySchemaCombo->insertItem("TF"); + mySchemaCombo->insertItem("DELTA"); + aCtrlLayout->addWidget(mySchemaCombo, 0, 1); + + // Interpolation + QLabel* aInterLbl = new QLabel(tr("MSG_STREAM_INTER"),aCtrlPane); + aCtrlLayout->addWidget(aInterLbl, 1, 0); + + myInterCombo = new QComboBox(aCtrlPane, "InterBox" ); + myInterCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myInterCombo->insertItem("INTERNULL"); + myInterCombo->insertItem("L0"); + myInterCombo->insertItem("L1"); + aCtrlLayout->addWidget(myInterCombo, 1, 1); + + // Extrapolation + QLabel* aExtraLbl = new QLabel(tr("MSG_STREAM_EXTRA"),aCtrlPane); + aCtrlLayout->addWidget(aExtraLbl, 2, 0); + + myExterCombo = new QComboBox(aCtrlPane, "ExtraBox" ); + myExterCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myExterCombo->insertItem("EXTRANULL"); + myExterCombo->insertItem("E0"); + myExterCombo->insertItem("E1"); + aCtrlLayout->addWidget(myExterCombo, 2, 1); + + TopLayout->addWidget( aCtrlPane ); + + // Buttons + 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( 5 ); + GroupButtonsLayout->setMargin( 8 ); + + 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( GroupButtons ); + + connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) ); + setData(); +} + +void SUPERVGUI_StreamInDlg::setData() { + SUPERV::KindOfSchema aSchema; + SUPERV::KindOfInterpolation aInterpolat; + SUPERV::KindOfExtrapolation aExtrapolat; + + if (myPort != 0) + myPort->getStreamPort()->Params(aSchema, aInterpolat, aExtrapolat); + else + myPortCanvas->getStreamEngine()->Params(aSchema, aInterpolat, aExtrapolat); + + mySchemaCombo->setCurrentItem((int)aSchema); + myInterCombo->setCurrentItem((int)aInterpolat); + myExterCombo->setCurrentItem((int)aExtrapolat); +} + +void SUPERVGUI_StreamInDlg::accept() { + if (myPort != 0) + myPort->getStreamPort()->SetParams((SUPERV::KindOfSchema) mySchemaCombo->currentItem(), + (SUPERV::KindOfInterpolation) myInterCombo->currentItem(), + (SUPERV::KindOfExtrapolation) myExterCombo->currentItem()); + else + myPortCanvas->getStreamEngine()->SetParams((SUPERV::KindOfSchema) mySchemaCombo->currentItem(), + (SUPERV::KindOfInterpolation) myInterCombo->currentItem(), + (SUPERV::KindOfExtrapolation) myExterCombo->currentItem()); + QDialog::accept(); +} + + +//------------------------------------------------------------------------- +SUPERVGUI_StreamOutDlg::SUPERVGUI_StreamOutDlg(SUPERVGUI_StreamPortOut* thePort) + :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + myPort = thePort; + myPortCanvas = 0; + init(); +} +SUPERVGUI_StreamOutDlg::SUPERVGUI_StreamOutDlg(SUPERVGUI_CanvasStreamPortOut* thePort) + :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + myPort = 0; + myPortCanvas = thePort; + init(); +} + +void SUPERVGUI_StreamOutDlg::init() +{ + setSizeGripEnabled( true ); + setCaption( tr( "MSG_STREAM_DLG_TIT" ) ); + + QVBoxLayout* TopLayout = new QVBoxLayout( this, 11, 6 ); + + QFrame* aCtrlPane = new QFrame(this); + QGridLayout* aCtrlLayout = new QGridLayout( aCtrlPane, 4, 10 ); + + QLabel* aLbl = new QLabel(tr("MSG_STREAM_LEVEL"),aCtrlPane); + aCtrlLayout->addWidget(aLbl, 0, 0); + + myValEdit = new QLineEdit( aCtrlPane, "ValEdit" ); + myValEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myValEdit->setValidator( new QIntValidator(this) ); + SUPERV_StreamPort aEngine; + if (myPort != 0) + aEngine = myPort->getStreamPort(); + else + aEngine = myPortCanvas->getStreamEngine(); + myValEdit->setText(QString("%1").arg(aEngine->NumberOfValues())); + aCtrlLayout->addWidget(myValEdit, 0, 1); + TopLayout->addWidget( aCtrlPane ); + + // Buttons + 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( 5 ); + GroupButtonsLayout->setMargin( 8 ); + + 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( GroupButtons ); + + connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + +void SUPERVGUI_StreamOutDlg::accept() { + int aRes = 0; + QString aStr = myValEdit->text(); + if (!aStr.isEmpty()) + aRes = aStr.toLong(); + if (myPort != 0) + myPort->getStreamPort()->SetNumberOfValues(aRes); + else + myPortCanvas->getStreamEngine()->SetNumberOfValues(aRes); + QDialog::accept(); +} + diff --git a/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.h b/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.h index 9575f2a..21526db 100644 --- a/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.h +++ b/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.h @@ -13,10 +13,8 @@ #include #include "SUPERVGUI_Def.h" -#include "SUPERVGUI_Port.h" #include "SALOME_Selection.h" -class SUPERVGUI_Node; /** * Class for ports values management (for internal using) @@ -52,12 +50,16 @@ public: /** * Browse Node Dialog box */ +class SUPERVGUI_Node; +class SUPERVGUI_CanvasNode; + class SUPERVGUI_BrowseNodeDlg: public QDialog { Q_OBJECT public: SUPERVGUI_BrowseNodeDlg( SUPERVGUI_Node* theNode ); + SUPERVGUI_BrowseNodeDlg( SUPERVGUI_CanvasNode* theNode ); virtual ~SUPERVGUI_BrowseNodeDlg(); void setValues(); @@ -72,7 +74,11 @@ protected: void showEvent( QShowEvent* theEvent ); private: + void init(); + SUPERVGUI_Node* myNode; + SUPERVGUI_CanvasNode* myNodeCanvas; + bool myIsEditable; QPtrList myPortsList; SUPERVGUI_PortField* myActiveField; @@ -82,6 +88,10 @@ private: /** * Get Value dialog box */ +class SUPERVGUI_PortIn; +class SUPERVGUI_PortInESNode; +class SUPERVGUI_CanvasPort; + class SUPERVGUI_GetValueDlg: public QDialog { Q_OBJECT @@ -89,6 +99,7 @@ public: // SUPERVGUI_GetValueDlg( SUPERVGUI_Port thePort ); SUPERVGUI_GetValueDlg( SUPERVGUI_PortIn* thePort ); SUPERVGUI_GetValueDlg( SUPERVGUI_PortInESNode* thePort ); + SUPERVGUI_GetValueDlg( SUPERVGUI_CanvasPort* thePort ); ~SUPERVGUI_GetValueDlg(); private slots: @@ -97,12 +108,66 @@ private slots: void onSelectionChanged(); private: + void init(); + QPushButton* myOKBtn; QPushButton* myCancelBtn; SUPERVGUI_PortField* myField; - SUPERVGUI_PortIn* myPort; + + SUPERVGUI_PortIn* myPort; SUPERVGUI_PortInESNode* myPortESNode; //last correction + SUPERVGUI_CanvasPort* myPortCanvas; + SALOME_Selection* mySelection; }; + +/** + * Stream Port Parameter dialog box + */ +class SUPERVGUI_StreamPortIn; +class SUPERVGUI_CanvasStreamPortIn; +class SUPERVGUI_StreamInDlg: public QDialog +{ + Q_OBJECT +public: + SUPERVGUI_StreamInDlg(SUPERVGUI_StreamPortIn* thePort); + SUPERVGUI_StreamInDlg(SUPERVGUI_CanvasStreamPortIn* thePort); + virtual ~SUPERVGUI_StreamInDlg() {}; + +protected slots: + void accept(); + +private: + void init(); + void setData(); + + SUPERVGUI_StreamPortIn* myPort; + SUPERVGUI_CanvasStreamPortIn* myPortCanvas; + QComboBox* mySchemaCombo; + QComboBox* myInterCombo; + QComboBox* myExterCombo; +}; + +class SUPERVGUI_StreamPortOut; +class SUPERVGUI_CanvasStreamPortOut; +class SUPERVGUI_StreamOutDlg: public QDialog +{ + Q_OBJECT +public: + SUPERVGUI_StreamOutDlg(SUPERVGUI_StreamPortOut* thePort); + SUPERVGUI_StreamOutDlg(SUPERVGUI_CanvasStreamPortOut* thePort); + virtual ~SUPERVGUI_StreamOutDlg() {}; + +protected slots: + void accept(); + +private: + void init(); + + SUPERVGUI_StreamPortOut* myPort; + SUPERVGUI_CanvasStreamPortOut* myPortCanvas; + QLineEdit* myValEdit; +}; + #endif diff --git a/src/SUPERVGUI/SUPERVGUI_Canvas.cxx b/src/SUPERVGUI/SUPERVGUI_Canvas.cxx new file mode 100644 index 0000000..3ca3595 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Canvas.cxx @@ -0,0 +1,338 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_Ganvas.cxx +// Author : Natalia KOPNOVA +// Module : SUPERV + +using namespace std; +#include "SUPERVGUI_Def.h" +#include "SUPERVGUI_Main.h" +#include "SUPERVGUI_CanvasNode.h" +#include "SUPERVGUI_CanvasPort.h" +#include "SUPERVGUI_CanvasLink.h" +#include "QAD_Config.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 = getNode(aCNode); \ + if (ihmNode == NULL) { \ + myMain->addControlNode(aCNode, aCNodeEnd, false); \ + } else { \ + ihmNode->move(aCNode->X(), aCNode->Y()); \ + ihmList->removeRef(ihmNode); \ + ihmNode->merge(); \ + ihmNode = getNode(aCNodeEnd); \ + ihmList->removeRef(ihmNode); \ + ihmNode->merge(); \ + } \ + } + +#define UPDATENODES(NodesName, FuncName) \ + n = nodes->NodesName.length(); \ + for (int i=0; iNodesName[i]); \ + ihmNode = getNode(aCNode); \ + if (ihmNode == NULL) { \ + myMain->FuncName(aCNode); \ + } else { \ + ihmNode->move(aCNode->X(), aCNode->Y()); \ + ihmList->removeRef(ihmNode); \ + ihmNode->merge(); \ + } \ + } + +#define UPDATELINK(Link) \ + ihmLink = getLink(Link.in()); \ + if (ihmLink == NULL) { \ + ihmLink = new SUPERVGUI_CanvasLink(this, myMain, Link.in()); \ + ihmLink->show(); \ + } \ + else { \ + ihmList->removeRef(ihmLink); \ + ihmLink->merge(); \ + } + +/* +#define UPDATESTREAMLINK(Link) \ + ihmLink = getLink(Link.in()); \ + if (ihmLink == NULL) { \ + ihmLink = new SUPERVGUI_CanvasStreamLink(this, myMain, Link.in()); \ + ihmLink->show(); \ + } \ + else { \ + ihmList->removeRef(ihmLink); \ + ihmLink->merge(); \ + } +*/ + + +SUPERVGUI_Canvas::SUPERVGUI_Canvas(SUPERVGUI_Main* m): + QCanvas(), + myMain(m) +{ + Trace("SUPERVGUI_Canvas::SUPERVGUI_Canvas"); + myIsControlView = false; + // resize(GRAPH_WIDTH, GRAPH_HEIGHT); + resize(800, 600); + setDoubleBuffering(true); + + QColor aColor(MAIN_COLOR); + 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()) ) + aColor = QColor(aRed.toInt(), aGreen.toInt(), aBlue.toInt()); + setBackgroundColor(aColor); +} + + +SUPERVGUI_Canvas::~SUPERVGUI_Canvas() { + QObjectList* aNodeList = queryList("SUPERVGUI_CanvasNode"); + QObjectListIt aIt(*aNodeList); + QObject* anObj; + while ((anObj = aIt.current()) != 0) { + ++aIt; + delete anObj; + } +} + +void SUPERVGUI_Canvas::addView(QCanvasView* theView) +{ + QCanvas::addView(theView); + theView->setPaletteBackgroundColor(backgroundColor().light(120)); +} + +void SUPERVGUI_Canvas::setFullView() +{ + myIsControlView = false; + updateNodes(true); + updateLinks(); + update(); +} + +void SUPERVGUI_Canvas::setControlView() +{ + myIsControlView = true; + updateNodes(false); + updateLinks(); + update(); +} + +void SUPERVGUI_Canvas::updateNodes(bool withPorts) +{ + QObjectList* aNodeList = queryList("SUPERVGUI_CanvasNode"); + QObjectListIt aIt(*aNodeList); + SUPERVGUI_CanvasNode* aNode; + while ((aNode=(SUPERVGUI_CanvasNode*)aIt.current()) != 0) { + ++aIt; + if (withPorts) + aNode->showAll(); + else + aNode->hideAll(); + } + delete aNodeList; +} + +void SUPERVGUI_Canvas::updateLinks() +{ + QObjectList* aLinkList = queryList("SUPERVGUI_CanvasLink"); + QObjectListIt aIt(*aLinkList); + SUPERVGUI_CanvasLink* aLink; + while ((aLink=(SUPERVGUI_CanvasLink*)aIt.current()) != 0) { + ++aIt; + aLink->merge(); + } + delete aLinkList; +} + +void SUPERVGUI_Canvas::sync() { + // cout << "===> SUPERVGUI_Canvas::sync()" << endl; + if (SUPERV_isNull(myMain->getDataflow())) return; + + SUPERVGUI_CanvasNode* ihmNode; + QObjectList* ihmList = queryList("SUPERVGUI_CanvasNode"); + QObjectListIt it(*ihmList); + while ((ihmNode=(SUPERVGUI_CanvasNode*)it.current()) != 0) { + ++it; + ihmNode->sync(); + } + delete ihmList; +} + +/** + * Synchronizes Graph presentation with internal graph structure + */ +void SUPERVGUI_Canvas::merge() { + // cout << "===> SUPERVGUI_Canvas::merge()" << endl; + if (SUPERV_isNull(myMain->getDataflow())) return; + + SUPERVGUI_CanvasNode* ihmNode; + QObjectList* ihmList = queryList("SUPERVGUI_CanvasNode"); + SUPERV_Nodes nodes = myMain->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()); + MESSAGE("Graphs="<Graphs.length()); + + int n; + //cout << " update nodes " << endl; + UPDATENODES(CNodes, addComputeNode); + UPDATENODES(FNodes, addComputeNode); + UPDATENODES(INodes, addComputeNode); + UPDATENODES(Graphs, addMacroNode); + UPDATENODES(GNodes, addGOTONode); + + //cout << " update control nodes " << endl; + UPDATECONTROLNODES(LNodes); + UPDATECONTROLNODES(SNodes); + + QObjectListIt it(*ihmList); + while ((ihmNode=(SUPERVGUI_CanvasNode*)it.current()) != 0) { + ++it; + ihmList->removeRef(ihmNode); + delete ihmNode; + } + delete ihmList; + + // update links + //cout << " update links " << endl; + SUPERVGUI_CanvasLink* ihmLink; + ihmList = queryList("SUPERVGUI_CanvasLink"); + /* + don't work... that's a pity! + */ + //SUPERV_Links links = myMain->getDataflow()->Links(); + SUPERV_Links links = myMain->getDataflow()->GLinks(); + //cout << "===> Number of links " << links->length() << endl; + for (int i = 0; i < links->length(); i++) { + UPDATELINK(links[i]); + } + + /* + SUPERV_StreamLinks slinks = myMain->getDataflow()->StreamLinks(); + //cout << "===> Number of stream links " << slinks->length() << endl; + for (int i = 0; i < slinks->length(); i++) { + UPDATELINK(slinks[i]); + } + */ + /* + if (myMain->getDataflow()->IsStreamGraph()) { + SUPERV_StreamGraph aSGraph = myMain->getDataflow()->ToStreamGraph(); + if (!SUPERV_isNull(aSGraph)) { + SUPERV_StreamLinks slinks = aSGraph->StreamLinks(); // <<- doesn't work!!! + //cout << "===> Number of stream links " << slinks->length() << endl; + for (int i = 0; i < slinks->length(); i++) { + UPDATELINK(slinks[i]); + } + } + } + */ + + // update stream links by old method until StreamLinks() fuction works + SUPERVGUI_CanvasPort* aPort; + QObjectList* aPortList = queryList("SUPERVGUI_CanvasPort"); + QObjectListIt aPortIt(*aPortList); + while ((aPort=(SUPERVGUI_CanvasPort*)aPortIt.current()) != 0) { + ++aPortIt; + if (aPort->getEngine()->IsInput() && aPort->getEngine()->IsLinked() + && aPort->getEngine()->Kind() == SUPERV::DataStreamParameter) { + if (aPort->getEngine()->Node()->Kind() == SUPERV::EndSwitchNode) { + SUPERV_Links aLinks = aPort->getEngine()->Links(); + for (int i = 0; i < aLinks->length(); i++) { + UPDATELINK(aLinks[i]); + } + } +// else if (aPort->isStream()) { +// SUPERV_StreamLink aStreamLink = ((SUPERVGUI_CanvasStreamPortIn*)aPort)->getStreamEngine()->StreamLink(); +// UPDATESTREAMLINK(aStreamLink); +// } + else { + SUPERV_Link aLink = aPort->getEngine()->Link(); + UPDATELINK(aLink); + } + } + } + delete aPortList; + + it = QObjectListIt(*ihmList); + while ((ihmLink=(SUPERVGUI_CanvasLink*)it.current()) != 0) { + ++it; + ihmList->removeRef(ihmLink); + delete ihmLink; + } + delete ihmList; + //cout << " merge done " << endl; +} + +void SUPERVGUI_Canvas::setAsFromStudy(bool theToStudy) +{ + if (theToStudy) return; + + SUPERVGUI_CanvasPortOut* aPortOut; + QObjectList* aPortList = queryList("SUPERVGUI_CanvasPortOut"); + QObjectListIt aPortIt(*aPortList); + while ((aPortOut=(SUPERVGUI_CanvasPortOut*)aPortIt.current()) != 0) { + ++aPortIt; + if (aPortOut->isInStudy()) { + aPortOut->setStudyState(theToStudy); + aPortOut->sync(); + } + } + delete aPortList; +} + +SUPERVGUI_CanvasNode* SUPERVGUI_Canvas::getNode(SUPERV::CNode_ptr theNode) const +{ + return (SUPERVGUI_CanvasNode*) + ((SUPERVGUI_Canvas*)this)->child(theNode->Name(), "SUPERVGUI_CanvasNode"); +} + +SUPERVGUI_CanvasPort* SUPERVGUI_Canvas::getPort(SUPERV::Port_ptr thePort) const +{ + SUPERVGUI_CanvasNode* aNode = getNode(thePort->Node()); + if (aNode == NULL) return NULL; + + return (SUPERVGUI_CanvasPort*) + aNode->child(getPortName(thePort), "SUPERVGUI_CanvasPort"); +} + +SUPERVGUI_CanvasLink* SUPERVGUI_Canvas::getLink(SUPERV::Link_ptr theLink) const +{ + return (SUPERVGUI_CanvasLink*) + ((SUPERVGUI_Canvas*)this)->child(getLinkName(theLink), "SUPERVGUI_CanvasLink"); +} + +QString SUPERVGUI_Canvas::getPortName(SUPERV::Port_ptr thePort) const +{ + QString aName(thePort->Name()); + if (thePort->IsInput()) aName = aName + ".In"; + else aName = aName + ".Out"; + return aName; +} + +QString SUPERVGUI_Canvas::getLinkName(SUPERV::Link_ptr theLink) const +{ + SUPERV_Port aInPort = theLink->InPort(); + SUPERV_Port aOutPort = theLink->OutPort(); + QString aName = + QString(aOutPort->Node()->Name()) + "." + + QString(aOutPort->Name()) + "-" + + QString(aInPort->Node()->Name()) + "." + + QString(aInPort->Name()); + return aName; +} diff --git a/src/SUPERVGUI/SUPERVGUI_Canvas.h b/src/SUPERVGUI/SUPERVGUI_Canvas.h new file mode 100644 index 0000000..10e82ed --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Canvas.h @@ -0,0 +1,62 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_Canvas.h +// Author : Natalia KOPNOVA +// Module : SUPERV + +#ifndef SUPERVGUI_Canvas_H +#define SUPERVGUI_Canvas_H + +using namespace std; +#include "SUPERVGUI_Def.h" +#include + +class SUPERVGUI_Main; +class SUPERVGUI_CanvasNode; +class SUPERVGUI_CanvasPort; +class SUPERVGUI_CanvasLink; + +class SUPERVGUI_Canvas: public QCanvas { + Q_OBJECT + + public: + + enum { + Rtti_Node = 10, + Rtti_LinkPoint = 11, + Rtti_LinkEdge = 12, + Rtti_Hook = 13 + }; + + SUPERVGUI_Canvas(SUPERVGUI_Main* m); + virtual ~SUPERVGUI_Canvas(); + + void merge(); + void sync(); + void setAsFromStudy(bool theToStudy); + + void addView(QCanvasView* theView); + + void setFullView(); + void setControlView(); + bool isControlView() { return myIsControlView; } + + SUPERVGUI_CanvasNode* getNode(SUPERV::CNode_ptr theNode) const; + SUPERVGUI_CanvasPort* getPort(SUPERV::Port_ptr thePort) const; + SUPERVGUI_CanvasLink* getLink(SUPERV::Link_ptr theLink) const; + + QString getPortName(SUPERV::Port_ptr thePort) const; + QString getLinkName(SUPERV::Link_ptr theLink) const; + + private: + void updateNodes(bool withPorts); + void updateLinks(); + + SUPERVGUI_Main* myMain; + bool myIsControlView; + +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasControlNode.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasControlNode.cxx new file mode 100644 index 0000000..21991ae --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_CanvasControlNode.cxx @@ -0,0 +1,251 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_CanvasControlNode.cxx +// Author : Natalia KOPNOVA +// Module : SUPERV + +using namespace std; +#include "SUPERVGUI_CanvasControlNode.h" +#include "SUPERVGUI_CanvasControlNodePrs.h" +#include "SUPERVGUI_Main.h" +#include "SUPERVGUI_Canvas.h" +#include "SUPERVGUI_ControlNode.h" // access to SelectInlineDlg + +#include "QAD_FileDlg.h" +#include "QAD_Application.h" + +//===================================================================== +// Compute node +//===================================================================== +SUPERVGUI_CanvasComputeNode::SUPERVGUI_CanvasComputeNode(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode): + SUPERVGUI_CanvasNode(theParent, theMain, theNode) +{ + Trace("SUPERVGUI_CanvasComputeNode::SUPERVGUI_CanvasComputeNode"); +} + +QPopupMenu* SUPERVGUI_CanvasComputeNode::getPopupMenu(QWidget* theParent) +{ + QPopupMenu* popup = SUPERVGUI_CanvasNode::getPopupMenu(theParent); + + QPopupMenu* aShowPopup = new QPopupMenu(theParent); + int anItem; + anItem = aShowPopup->insertItem(tr("POP_SHOWTITLES"), this, SLOT(switchLabel())); + aShowPopup->setItemChecked(anItem, getPrs()->isLabelVisible()); + anItem = aShowPopup->insertItem(tr("POP_SHOWPORTS"), this, SLOT(switchPorts())); + aShowPopup->setItemChecked(anItem, getPrs()->isPortVisible()); + + popup->insertSeparator(); + popup->insertItem(tr("POP_SHOW"), aShowPopup); + + return popup; +} + + +//===================================================================== +// Start control node +//===================================================================== +SUPERVGUI_CanvasStartNode::SUPERVGUI_CanvasStartNode(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode): + SUPERVGUI_CanvasNode(theParent, theMain, theNode), + myCoupled(0) +{ + Trace("SUPERVGUI_CanvasStartNode::SUPERVGUI_CanvasStartNode"); +} + +SUPERVGUI_CanvasNodePrs* SUPERVGUI_CanvasStartNode::createPrs() const +{ + return new SUPERVGUI_CanvasStartNodePrs(getMain()->getCanvas(), + (SUPERVGUI_CanvasStartNode*)this); +} + +bool SUPERVGUI_CanvasStartNode::setNodeName(QString aName) +{ + bool result = SUPERVGUI_CanvasNode::setNodeName(aName); + if (result && myCoupled) { + myCoupled->setNodeName(QString(tr("ENDNODE_PREFIX"))+aName); + } + return result; +} + +QPopupMenu* SUPERVGUI_CanvasStartNode::getPopupMenu(QWidget* theParent) +{ + QPopupMenu* popup = SUPERVGUI_CanvasNode::getPopupMenu(theParent); + + popup->insertSeparator(); + int anItem = popup->insertItem(tr("POP_HIDEPORTS"), this, SLOT(switchPorts())); + popup->setItemChecked(anItem, !getPrs()->isPortVisible()); + + return popup; +} + +void SUPERVGUI_CanvasStartNode::remove() +{ + SUPERVGUI_Canvas* aCanvas = getMain()->getCanvas(); + + setDestroyed(); + if (myCoupled) myCoupled->setDestroyed(); + + getEngine()->destroy(); + + if (myCoupled) delete myCoupled; + delete this; + + aCanvas->update(); +} + +void SUPERVGUI_CanvasStartNode::onDestroyed(QObject* theObject) +{ + if (!isIgnore) { + SUPERVGUI_CanvasNode::onDestroyed(theObject); + if (getEngine()->IsLoop()) merge(); + if (myCoupled) myCoupled->merge(); + } +} + +void SUPERVGUI_CanvasStartNode::addInputPort() +{ + SUPERVGUI_CanvasNode::addInputPort(); + if (getEngine()->IsLoop()) merge(); + if (myCoupled) myCoupled->merge(); +} + +void SUPERVGUI_CanvasStartNode::addOutputPort() +{ + SUPERVGUI_CanvasNode::addOutputPort(); + if (myCoupled) myCoupled->merge(); +} + +//===================================================================== +// End control node +//===================================================================== +SUPERVGUI_CanvasEndNode::SUPERVGUI_CanvasEndNode(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode, + SUPERVGUI_CanvasStartNode* theStart): + SUPERVGUI_CanvasNode(theParent, theMain, theNode), + myCoupled(theStart) +{ + Trace("SUPERVGUI_CanvasEndNode::SUPERVGUI_CanvasEndNode"); + myCoupled->setCoupled(this); +} + +SUPERVGUI_CanvasNodePrs* SUPERVGUI_CanvasEndNode::createPrs() const +{ + return new SUPERVGUI_CanvasEndNodePrs(getMain()->getCanvas(), + (SUPERVGUI_CanvasEndNode*)this); +} + +QPopupMenu* SUPERVGUI_CanvasEndNode::getPopupMenu(QWidget* theParent) +{ + QPopupMenu* popup = SUPERVGUI_CanvasNode::getPopupMenu(theParent); + + popup->insertSeparator(); + int anItem = popup->insertItem(tr("POP_HIDEPORTS"), this, SLOT(switchPorts())); + popup->setItemChecked(anItem, !getPrs()->isPortVisible()); + + return popup; +} + +void SUPERVGUI_CanvasEndNode::addInputPort() +{ + SUPERVGUI_CanvasNode::addInputPort(); + if (getEngine()->IsEndSwitch()) merge(); +} + + +//===================================================================== +// Goto control node +//===================================================================== +SUPERVGUI_CanvasGotoNode::SUPERVGUI_CanvasGotoNode(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode): + SUPERVGUI_CanvasNode(theParent, theMain, theNode) +{ + Trace("SUPERVGUI_CanvasGotoNode::SUPERVGUI_CanvasGotoNode"); +} + +SUPERVGUI_CanvasNodePrs* SUPERVGUI_CanvasGotoNode::createPrs() const +{ + return new SUPERVGUI_CanvasGotoNodePrs(getMain()->getCanvas(), + (SUPERVGUI_CanvasGotoNode*)this); +} + +QPopupMenu* SUPERVGUI_CanvasGotoNode::getPopupMenu(QWidget* theParent) +{ + QPopupMenu* popup = SUPERVGUI_CanvasNode::getPopupMenu(theParent); + + popup->insertSeparator(); + popup->insertItem("Link to Node...", this, SLOT(linkToNode())); + + popup->insertSeparator(); + int anItem = popup->insertItem(tr("POP_HIDEPORTS"), this, SLOT(switchPorts())); + popup->setItemChecked(anItem, !getPrs()->isPortVisible()); + + return popup; +} + +void SUPERVGUI_CanvasGotoNode::linkToNode() { + SUPERVGUI_SelectInlineDlg* aDlg = new SUPERVGUI_SelectInlineDlg(getMain()); + if (aDlg->exec()) { + QString aNodeName = aDlg->getName(); + getGotoNode()->SetCoupled(aNodeName.latin1()); + getMain()->getCanvas()->sync(); + } + delete aDlg; +} + +//===================================================================== +// Macro node +//===================================================================== +SUPERVGUI_CanvasMacroNode::SUPERVGUI_CanvasMacroNode(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode): + SUPERVGUI_CanvasComputeNode(theParent, theMain, theNode) +{ + Trace("SUPERVGUI_CanvasMacroNode::SUPERVGUI_CanvasMacroNode"); +} + +SUPERVGUI_CanvasNodePrs* SUPERVGUI_CanvasMacroNode::createPrs() const +{ + return new SUPERVGUI_CanvasMacroNodePrs(getMain()->getCanvas(), + (SUPERVGUI_CanvasMacroNode*)this); +} + +QPopupMenu* SUPERVGUI_CanvasMacroNode::getPopupMenu(QWidget* theParent) +{ + QPopupMenu* popup = SUPERVGUI_CanvasComputeNode::getPopupMenu(theParent); + + popup->insertSeparator(0); + popup->insertItem(tr("MSG_EXPORT"), this, SLOT(exportDataflow()), 0, -1, 0); + popup->insertItem("Open SubGraph", this, SLOT(openSubGraph()), 0, -1, 0); + + return popup; +} + +void SUPERVGUI_CanvasMacroNode::openSubGraph() +{ + getMain()->openSubGraph(getEngine()); +} + +void SUPERVGUI_CanvasMacroNode::exportDataflow() +{ + SUPERV_Graph aGraph; + if (getEngine()->IsMacro()) { + SUPERV_Graph aMacro = getMacroNode(); + if (aMacro->IsStreamMacro()) + aGraph = aMacro->StreamObjRef(); + else + aGraph = aMacro->FlowObjRef(); + } + if (SUPERV_isNull(aGraph)) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_EXPORT")); + return; + } + else { + QString aFileName = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), + "", + "*.xml", + tr("TTL_EXPORT_DATAFLOW"), + false); + if (!aFileName.isEmpty()) { + if (!aGraph->Export(aFileName.latin1())) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_WRITING")); + } + } + } +} diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasControlNode.h b/src/SUPERVGUI/SUPERVGUI_CanvasControlNode.h new file mode 100644 index 0000000..137836c --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_CanvasControlNode.h @@ -0,0 +1,120 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_CanvasControlNode.h +// Author : Natalia KOPNOVA +// Module : SUPERV + +#ifndef SUPERVGUI_CanvasControlNode_H +#define SUPERVGUI_CanvasControlNode_H + +using namespace std; +#include "SUPERVGUI_Def.h" +#include "SUPERVGUI_CanvasNode.h" + + +class SUPERVGUI_CanvasComputeNode : public SUPERVGUI_CanvasNode { + Q_OBJECT + + public: + SUPERVGUI_CanvasComputeNode(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode); + virtual ~SUPERVGUI_CanvasComputeNode() {} + + virtual QPopupMenu* getPopupMenu(QWidget* theParent); +}; + +class SUPERVGUI_CanvasMacroNode : public SUPERVGUI_CanvasComputeNode { + Q_OBJECT + + public: + SUPERVGUI_CanvasMacroNode(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode); + virtual ~SUPERVGUI_CanvasMacroNode() {} + + virtual QPopupMenu* getPopupMenu(QWidget* theParent); + + public slots: + void openSubGraph(); + void exportDataflow(); + + protected: + virtual SUPERVGUI_CanvasNodePrs* createPrs() const; +}; + + +class SUPERVGUI_CanvasEndNode; +class SUPERVGUI_CanvasStartNode : public SUPERVGUI_CanvasNode { + Q_OBJECT + + public: + SUPERVGUI_CanvasStartNode(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode); + virtual ~SUPERVGUI_CanvasStartNode() {} + + virtual bool setNodeName(QString aName); + + SUPERVGUI_CanvasEndNode* getCoupled() const { return myCoupled; } + + virtual QPopupMenu* getPopupMenu(QWidget* theParent); + + public slots: + virtual void remove(); + + virtual void addInputPort(); + virtual void addOutputPort(); + + protected: + virtual SUPERVGUI_CanvasNodePrs* createPrs() const; + + protected slots: + virtual void onDestroyed(QObject*); + + private: + friend class SUPERVGUI_CanvasEndNode; + void setCoupled(SUPERVGUI_CanvasEndNode* theEnd) { myCoupled = theEnd; } + + SUPERVGUI_CanvasEndNode* myCoupled; + +}; + + +class SUPERVGUI_CanvasEndNode : public SUPERVGUI_CanvasNode { + Q_OBJECT + + public: + SUPERVGUI_CanvasEndNode(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode, + SUPERVGUI_CanvasStartNode* theStart); + virtual ~SUPERVGUI_CanvasEndNode() {} + + SUPERVGUI_CanvasStartNode* getCoupled() const { return myCoupled; } + + virtual QPopupMenu* getPopupMenu(QWidget* theParent); + + public slots: + virtual void addInputPort(); + + protected: + virtual SUPERVGUI_CanvasNodePrs* createPrs() const; + + private: + SUPERVGUI_CanvasStartNode* myCoupled; + +}; + + +class SUPERVGUI_CanvasGotoNode : public SUPERVGUI_CanvasNode { + Q_OBJECT + + public: + SUPERVGUI_CanvasGotoNode(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode); + virtual ~SUPERVGUI_CanvasGotoNode() {} + + virtual QPopupMenu* getPopupMenu(QWidget* theParent); + + public slots: + void linkToNode(); + + protected: + virtual SUPERVGUI_CanvasNodePrs* createPrs() const; +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasControlNodePrs.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasControlNodePrs.cxx new file mode 100644 index 0000000..f88de0e --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_CanvasControlNodePrs.cxx @@ -0,0 +1,348 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_CanvasControlNodePrs.cxx +// Author : Natalia KOPNOVA +// Module : SUPERV + + +using namespace std; +#include "SUPERVGUI_CanvasControlNodePrs.h" +#include "SUPERVGUI_CanvasControlNode.h" +#include "SUPERVGUI_Canvas.h" + +#define SHIFT LABEL_HEIGHT/2 + +//===================================================================== +// Control node presentation +//===================================================================== +SUPERVGUI_CanvasControlNodePrs::SUPERVGUI_CanvasControlNodePrs(QCanvas* theCanvas, SUPERVGUI_CanvasNode* theNode): + SUPERVGUI_CanvasNodePrs(theCanvas, theNode) +{ + Trace("SUPERVGUI_CanvasControlNodePrs::SUPERVGUI_CanvasControlNodePrs"); + setLabelVisible(false); + setNodeColor(Qt::cyan.light()); +} + +void SUPERVGUI_CanvasControlNodePrs::hideAll() +{ + bool aDisp = isVisible(); + if (aDisp) hide(); + + setPortVisible(false); + + if (aDisp) { + show(); + canvas()->update(); + } +} + +void SUPERVGUI_CanvasControlNodePrs::showAll() +{ + bool aDisp = isVisible(); + if (aDisp) hide(); + + setPortVisible(true); + + if (aDisp) { + show(); + canvas()->update(); + } +} + +QRect SUPERVGUI_CanvasControlNodePrs::getStatusRect() const +{ + return QRect((int)x(), ((int)y())+getTitleHeight()+getLabelHeight()+ + getBodyHeight()+getGateHeight(), + width(), getStatusHeight()); +} + +QRect SUPERVGUI_CanvasControlNodePrs::getBodyRect() const +{ + return QRect((int)x(), ((int)y())+getTitleHeight()+getLabelHeight(), + width(), getBodyHeight()); +} + +QRect SUPERVGUI_CanvasControlNodePrs::getGateRect() const +{ + return QRect((int)x(), ((int)y())+getTitleHeight()+getLabelHeight()+getBodyHeight(), + width(), getGateHeight()); +} + +//===================================================================== +// Start control node presentation +//===================================================================== +SUPERVGUI_CanvasStartNodePrs::SUPERVGUI_CanvasStartNodePrs(QCanvas* theCanvas, SUPERVGUI_CanvasStartNode* theNode): + SUPERVGUI_CanvasControlNodePrs(theCanvas, theNode) +{ + Trace("SUPERVGUI_CanvasStartNodePrs::SUPERVGUI_CanvasStartNodePrs"); +} + +QPointArray SUPERVGUI_CanvasStartNodePrs::areaPoints() const +{ + int w = width(); + int h = height()+2; // add width of pen + + int h1 = getTitleHeight()+1; + int h2 = getStatusHeight()+1; + + QPointArray aPnts(8); + QPoint p((int)x(), (int)y()-1); + aPnts[0] = p + QPoint(0, h1); + aPnts[1] = p + QPoint(SHIFT, 0); + aPnts[2] = aPnts[1] + QPoint(w, 0); + aPnts[3] = aPnts[0] + QPoint(w, 0); + aPnts[4] = aPnts[3] + QPoint(0, h-h1-h2); + aPnts[5] = aPnts[2] + QPoint(0, h); + aPnts[6] = aPnts[1] + QPoint(0, h); + aPnts[7] = aPnts[0] + QPoint(0, h-h1-h2); + return aPnts; +} + +void SUPERVGUI_CanvasStartNodePrs::drawFrame(QPainter& thePainter) +{ + QRect r = getRect(); + + int h1 = getTitleHeight(); + int h2 = getStatusHeight(); + + QRect r0(r.x(), r.y()+h1, r.width(), r.height()-h1-h2); + + QBrush saved = thePainter.brush(); + thePainter.setBrush(NoBrush); + thePainter.drawRect(r0); + thePainter.setBrush(saved); +} + +void SUPERVGUI_CanvasStartNodePrs::drawTitleShape(QPainter& thePainter) +{ + QRect r = getTitleRect(); + int w = width()-1; + + QPointArray aPnts(4); + aPnts[0] = r.topLeft() + QPoint(0, r.height()); + aPnts[1] = r.topLeft() + QPoint(SHIFT, 0); + aPnts[2] = aPnts[1] + QPoint(w, 0); + aPnts[3] = aPnts[0] + QPoint(w, 0); + + thePainter.setBrush(Qt::red.light()); + thePainter.drawPolygon(aPnts); +} + +void SUPERVGUI_CanvasStartNodePrs::drawStatusShape(QPainter& thePainter) +{ + QRect r = getStatusRect(); + int w = width()-1; + + QPointArray aPnts(4); + aPnts[0] = r.topLeft() + QPoint(SHIFT, r.height()); + aPnts[1] = r.topLeft(); + aPnts[2] = aPnts[1] + QPoint(w, 0); + aPnts[3] = aPnts[0] + QPoint(w, 0); + + thePainter.drawPolygon(aPnts); +} + + +void SUPERVGUI_CanvasStartNodePrs::setState(SUPERV::GraphState theState) +{ + QRect r = getStatusRect(); + canvas()->setChanged(QRect(r.x(), r.y(), r.width()+SHIFT, r.height())); + SUPERVGUI_CanvasNodePrs::setState(theState); +} + + +//===================================================================== +// End control node presentation +//===================================================================== +SUPERVGUI_CanvasEndNodePrs::SUPERVGUI_CanvasEndNodePrs(QCanvas* theCanvas, SUPERVGUI_CanvasEndNode* theNode): + SUPERVGUI_CanvasControlNodePrs(theCanvas, theNode) +{ + Trace("SUPERVGUI_CanvasEndNodePrs::SUPERVGUI_CanvasEndNodePrs"); +} + +QPointArray SUPERVGUI_CanvasEndNodePrs::areaPoints() const +{ + int w = width(); + int h = height()+2; + + int h1 = getTitleHeight()+1; + int h2 = getStatusHeight()+1; + + QPointArray aPnts(8); + QPoint p((int)x(), (int)y()-1); + aPnts[0] = p + QPoint(0, h1); + aPnts[1] = p + QPoint(-SHIFT, 0); + aPnts[2] = aPnts[1] + QPoint(w, 0); + aPnts[3] = aPnts[0] + QPoint(w, 0); + aPnts[4] = aPnts[3] + QPoint(0, h-h1-h2); + aPnts[5] = aPnts[2] + QPoint(0, h); + aPnts[6] = aPnts[1] + QPoint(0, h); + aPnts[7] = aPnts[0] + QPoint(0, h-h1-h2); + return aPnts; +} + +void SUPERVGUI_CanvasEndNodePrs::drawFrame(QPainter& thePainter) +{ + QRect r = getRect(); + + int h1 = getTitleHeight(); + int h2 = getStatusHeight(); + + QRect r0(r.x(), r.y()+h1, r.width(), r.height()-h1-h2); + + QBrush saved = thePainter.brush(); + thePainter.setBrush(NoBrush); + thePainter.drawRect(r0); + thePainter.setBrush(saved); +} + +void SUPERVGUI_CanvasEndNodePrs::drawTitleShape(QPainter& thePainter) +{ + QRect r = getTitleRect(); + int w = width()-1; + + QPointArray aPnts(4); + aPnts[0] = r.topLeft() + QPoint(0, r.height()); + aPnts[1] = r.topLeft() + QPoint(-SHIFT, 0); + aPnts[2] = aPnts[1] + QPoint(w, 0); + aPnts[3] = aPnts[0] + QPoint(w, 0); + + thePainter.setBrush(Qt::red.light()); + thePainter.drawPolygon(aPnts); +} + +void SUPERVGUI_CanvasEndNodePrs::drawStatusShape(QPainter& thePainter) +{ + QRect r = getStatusRect(); + int w = width()-1; + + QPointArray aPnts(4); + aPnts[0] = r.topLeft() + QPoint(-SHIFT, r.height()); + aPnts[1] = r.topLeft(); + aPnts[2] = aPnts[1] + QPoint(w, 0); + aPnts[3] = aPnts[0] + QPoint(w, 0); + + thePainter.drawPolygon(aPnts); +} + +void SUPERVGUI_CanvasEndNodePrs::setState(SUPERV::GraphState theState) +{ + QRect r = getStatusRect(); + canvas()->setChanged(QRect(r.x()-SHIFT, r.y(), r.width()+SHIFT, r.height())); + SUPERVGUI_CanvasNodePrs::setState(theState); +} + +//===================================================================== +// Goto control node presentation +//===================================================================== +SUPERVGUI_CanvasGotoNodePrs::SUPERVGUI_CanvasGotoNodePrs(QCanvas* theCanvas, SUPERVGUI_CanvasGotoNode* theNode): + SUPERVGUI_CanvasControlNodePrs(theCanvas, theNode) +{ + Trace("SUPERVGUI_CanvasGotoNodePrs::SUPERVGUI_CanvasGotoNodePrs"); +} + +QPointArray SUPERVGUI_CanvasGotoNodePrs::areaPoints() const +{ + int w = width(); + int h = height()+2; + + int h1 = getTitleHeight()+1; + int h2 = getStatusHeight()+1; + + QPointArray aPnts(8); + QPoint p((int)x(), (int)y()-1); + aPnts[0] = p + QPoint(0, h1); + aPnts[1] = p + QPoint(SHIFT, 0); + aPnts[2] = aPnts[1] + QPoint(w-2*SHIFT, 0); + aPnts[3] = aPnts[0] + QPoint(w, 0); + aPnts[4] = aPnts[3] + QPoint(0, h-h1-h2); + aPnts[5] = aPnts[2] + QPoint(0, h); + aPnts[6] = aPnts[1] + QPoint(0, h); + aPnts[7] = aPnts[0] + QPoint(0, h-h1-h2); + return aPnts; +} + +void SUPERVGUI_CanvasGotoNodePrs::drawFrame(QPainter& thePainter) +{ + QRect r = getRect(); + + int h1 = getTitleHeight(); + int h2 = getStatusHeight(); + + QRect r0(r.x(), r.y()+h1, r.width(), r.height()-h1-h2); + + QBrush saved = thePainter.brush(); + thePainter.setBrush(NoBrush); + thePainter.drawRect(r0); + thePainter.setBrush(saved); +} + +void SUPERVGUI_CanvasGotoNodePrs::drawTitleShape(QPainter& thePainter) +{ + QRect r = getTitleRect(); + int w = width()-1; + + QPointArray aPnts(4); + aPnts[0] = r.topLeft() + QPoint(0, r.height()); + aPnts[1] = r.topLeft() + QPoint(SHIFT, 0); + aPnts[2] = aPnts[1] + QPoint(w-2*SHIFT, 0); + aPnts[3] = aPnts[0] + QPoint(w, 0); + + thePainter.setBrush(Qt::green.light()); + thePainter.drawPolygon(aPnts); +} + +void SUPERVGUI_CanvasGotoNodePrs::drawStatusShape(QPainter& thePainter) +{ + QRect r = getStatusRect(); + int w = width()-1; + + QPointArray aPnts(4); + aPnts[0] = r.topLeft() + QPoint(SHIFT, r.height()); + aPnts[1] = r.topLeft(); + aPnts[2] = aPnts[1] + QPoint(w, 0); + aPnts[3] = aPnts[0] + QPoint(w-2*SHIFT, 0); + + thePainter.drawPolygon(aPnts); +} + + +//===================================================================== +// Macro node presentation +//===================================================================== +SUPERVGUI_CanvasMacroNodePrs::SUPERVGUI_CanvasMacroNodePrs(QCanvas* theCanvas, SUPERVGUI_CanvasMacroNode* theNode): + SUPERVGUI_CanvasNodePrs(theCanvas, theNode) +{ + Trace("SUPERVGUI_CanvasControlNodePrs::SUPERVGUI_CanvasControlNodePrs"); + setNodeColor(QColor(255, 186, 149)); //QColor(255, 200, 170)); +} + +void SUPERVGUI_CanvasMacroNodePrs::drawFrame(QPainter& thePainter) +{ + SUPERVGUI_CanvasNodePrs::drawFrame(thePainter); + + QPen saved = thePainter.pen(); + thePainter.setPen(QPen(saved.color(), 2)); + + QRect r = getRect(); + thePainter.drawLine(r.left(), r.top(), r.left(), r.bottom()); + thePainter.drawLine(r.left()+3, r.top(), r.left()+3, r.bottom()); + thePainter.drawLine(r.right()-3, r.top(), r.right()-3, r.bottom()); + thePainter.drawLine(r.right(), r.top(), r.right(), r.bottom()); + thePainter.setPen(saved); +} + +QPointArray SUPERVGUI_CanvasMacroNodePrs::areaPoints() const +{ + int w = width()+2; // add width of pen + int h = height()+1; + + QPointArray aPnts(4); + aPnts[0] = QPoint((int)x()-1, (int)y()); + aPnts[1] = aPnts[0] + QPoint(w, 0); + aPnts[2] = aPnts[1] + QPoint(0, h); + aPnts[3] = aPnts[0] + QPoint(0, h); + return aPnts; +} diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasControlNodePrs.h b/src/SUPERVGUI/SUPERVGUI_CanvasControlNodePrs.h new file mode 100644 index 0000000..952ca9f --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_CanvasControlNodePrs.h @@ -0,0 +1,95 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_CanvasControlNodePrs.h +// Author : Natalia KOPNOVA +// Module : SUPERV + +#ifndef SUPERVGUI_CanvasControlNodePrs_H +#define SUPERVGUI_CanvasControlNodePrs_H + +using namespace std; +#include "SUPERVGUI_Def.h" +#include "SUPERVGUI_CanvasNodePrs.h" + + +class SUPERVGUI_CanvasControlNodePrs : public SUPERVGUI_CanvasNodePrs +{ + public: + SUPERVGUI_CanvasControlNodePrs(QCanvas* theCanvas, SUPERVGUI_CanvasNode* theNode); + virtual ~SUPERVGUI_CanvasControlNodePrs() {} + + virtual void hideAll(); + virtual void showAll(); + + virtual QRect getStatusRect() const; + virtual QRect getBodyRect() const; + virtual QRect getGateRect() const; +}; + +class SUPERVGUI_CanvasStartNode; +class SUPERVGUI_CanvasStartNodePrs : public SUPERVGUI_CanvasControlNodePrs +{ + public: + SUPERVGUI_CanvasStartNodePrs(QCanvas* theCanvas, SUPERVGUI_CanvasStartNode* theNode); + virtual ~SUPERVGUI_CanvasStartNodePrs() {} + + QPointArray areaPoints() const; + + virtual void setState(SUPERV::GraphState theState); + + protected: + virtual void drawFrame(QPainter& thePainter); + virtual void drawTitleShape(QPainter& thePainter); + virtual void drawStatusShape(QPainter& thePainter); +}; + +class SUPERVGUI_CanvasEndNode; +class SUPERVGUI_CanvasEndNodePrs : public SUPERVGUI_CanvasControlNodePrs +{ + public: + SUPERVGUI_CanvasEndNodePrs(QCanvas* theCanvas, SUPERVGUI_CanvasEndNode* theNode); + virtual ~SUPERVGUI_CanvasEndNodePrs() {} + + QPointArray areaPoints() const; + + virtual void setState(SUPERV::GraphState theState); + + protected: + virtual void drawFrame(QPainter& thePainter); + virtual void drawTitleShape(QPainter& thePainter); + virtual void drawStatusShape(QPainter& thePainter); +}; + +class SUPERVGUI_CanvasGotoNode; +class SUPERVGUI_CanvasGotoNodePrs : public SUPERVGUI_CanvasControlNodePrs +{ + public: + SUPERVGUI_CanvasGotoNodePrs(QCanvas* theCanvas, SUPERVGUI_CanvasGotoNode* theNode); + virtual ~SUPERVGUI_CanvasGotoNodePrs() {} + + QPointArray areaPoints() const; + + protected: + virtual void drawFrame(QPainter& thePainter); + virtual void drawTitleShape(QPainter& thePainter); + virtual void drawStatusShape(QPainter& thePainter); +}; + + +class SUPERVGUI_CanvasMacroNode; +class SUPERVGUI_CanvasMacroNodePrs : public SUPERVGUI_CanvasNodePrs +{ + public: + SUPERVGUI_CanvasMacroNodePrs(QCanvas* theCanvas, SUPERVGUI_CanvasMacroNode* theNode); + virtual ~SUPERVGUI_CanvasMacroNodePrs() {} + + QPointArray areaPoints() const; + + protected: + void drawFrame(QPainter& thePainter); + +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasLink.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasLink.cxx new file mode 100644 index 0000000..4ed27d1 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_CanvasLink.cxx @@ -0,0 +1,564 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_GanvasNodePrs.cxx +// Author : Natalia KOPNOVA +// Module : SUPERV + +using namespace std; +#include "SUPERVGUI_CanvasLink.h" +#include "SUPERVGUI_Canvas.h" +#include "SUPERVGUI_CanvasPort.h" +#include "SUPERVGUI_Main.h" + +//#define CHECKTIME + +#ifdef CHECKTIME +#include +#endif + +#define DRAW_COLOR Qt::black +#define SELECT_COLOR Qt::magenta +#define SKETCH_COLOR Qt::darkGreen +#define STREAM_COLOR Qt::darkRed // QColor(0, 64, 128) // Qt::blue + +#define LINE_WIDTH 1 + + +SUPERVGUI_CanvasLink::SUPERVGUI_CanvasLink(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::Link_ptr theLink): + QObject(theParent), + myMain(theMain), + myLink(0), + myInputPort(0), + myOutputPort(0), + myHilighted(false), + mySelectedItem(0) +{ + if (theLink && !SUPERV_isNull(theLink)) { + myLink = SUPERV::Link::_duplicate(theLink); + + SUPERVGUI_Canvas* aCanvas = myMain->getCanvas(); + setName(aCanvas->getLinkName(theLink)); + + myInputPort = aCanvas->getPort(myLink->InPort()); + if (myInputPort) myInputPort->addLink(this); + + myOutputPort = aCanvas->getPort(myLink->OutPort()); + if (myOutputPort) myOutputPort->addLink(this); + + if (myInputPort->isStream()) + myColor = STREAM_COLOR; + else + myColor = DRAW_COLOR; + } +} + +SUPERVGUI_CanvasLink::~SUPERVGUI_CanvasLink() +{ + for (QCanvasItemList::Iterator it = myPrs.begin(); it != myPrs.end(); ++it) { + (*it)->hide(); + delete *it; + } + if (myInputPort) myInputPort->removeLink(this); + if (myOutputPort) myOutputPort->removeLink(this); +} + +void SUPERVGUI_CanvasLink::createPrs() +{ + if (myLink && !SUPERV_isNull(myLink)) { + if (myInputPort) { + addPoint(myInputPort->getConnectionPoint()); + } + if (!myMain->getCanvas()->isControlView()) { + long x, y; + for (int i = 0; i < myLink->CoordsSize(); i++) { + myLink->Coords(i+1, x, y); + addPoint(QPoint(x, y), i+1); + } + } + if (myOutputPort) { + addPoint(myOutputPort->getConnectionPoint()); + } + } + setColor(myHilighted ? SELECT_COLOR : myColor); +} + +void SUPERVGUI_CanvasLink::addPoint(const QPoint& thePoint, const int& theIndex) +{ + SUPERVGUI_CanvasPointPrs* aPoint; + if (myPrs.empty()) { + aPoint = new SUPERVGUI_CanvasPointPrs(myMain->getCanvas(), this, theIndex); + aPoint->setColor(myColor); + aPoint->move(thePoint.x(), thePoint.y()); + } + else { + SUPERVGUI_CanvasPointPrs* aPrev = (SUPERVGUI_CanvasPointPrs*) myPrs.last(); + + SUPERVGUI_CanvasEdgePrs* anEdge = new SUPERVGUI_CanvasEdgePrs(myMain->getCanvas(), this); + anEdge->setColor(myColor); + myPrs.append(anEdge); + + aPoint = new SUPERVGUI_CanvasPointPrs(myMain->getCanvas(), this, theIndex); + aPoint->setColor(myColor); + aPoint->move(thePoint.x(), thePoint.y()); + + aPrev->setOutEdge(anEdge); + aPoint->setInEdge(anEdge); + } + myPrs.append(aPoint); +} + +void SUPERVGUI_CanvasLink::setSelectedObject(QCanvasItem* theItem, const QPoint& thePoint) +{ + mySelectedItem = theItem; + mySelectedPoint = thePoint; +} + +QPopupMenu* SUPERVGUI_CanvasLink::getPopupMenu(QWidget* theParent) +{ + QPopupMenu* popup = new QPopupMenu(theParent); + int anItem; + anItem = popup->insertItem(tr("MSG_DELLINK"), this, SLOT(remove())); + if (myInputPort && + (myInputPort->getEngine()->Kind() != SUPERV::EndSwitchParameter || + myInputPort->getEngine()->Node()->Kind() != SUPERV::EndSwitchNode)) + if (myInputPort->getEngine()->Kind() == SUPERV::LoopParameter || + myOutputPort && myOutputPort->getEngine()->Kind() == SUPERV::LoopParameter) + popup->setItemEnabled(anItem, false); + + popup->insertSeparator(); + if (mySelectedItem) { + anItem = popup->insertItem(tr("MSG_ADD_POINT"), this, SLOT(addPoint())); + if (mySelectedItem->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) + popup->setItemEnabled(anItem, false); + + anItem = popup->insertItem(tr("MSG_DEL_POINT"), this, SLOT(removePoint())); + if (mySelectedItem->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge) + popup->setItemEnabled(anItem, false); + } + return popup; +} + +void SUPERVGUI_CanvasLink::show() +{ + if (myPrs.isEmpty()) createPrs(); + + for (QCanvasItemList::Iterator it = myPrs.begin(); it != myPrs.end(); ++it) { + (*it)->show(); + } +} + +void SUPERVGUI_CanvasLink::merge() +{ + // remove old presentation + for (QCanvasItemList::Iterator it = myPrs.begin(); it != myPrs.end(); ++it) { + delete *it; + } + myPrs.clear(); + + // display a new one + show(); +} + +void SUPERVGUI_CanvasLink::setHilighted(bool state) +{ + myHilighted = state; + setColor(myHilighted ? SELECT_COLOR : myColor); + if (!myPrs.isEmpty()) { + bool disp = myPrs.first()->isVisible(); + if (disp) { + for (QCanvasItemList::Iterator it = myPrs.begin(); it != myPrs.end(); ++it) { + (*it)->hide(); (*it)->show(); + } + myMain->getCanvas()->update(); + } + } +} + +void SUPERVGUI_CanvasLink::moveByPort(SUPERVGUI_CanvasPort* thePort, int dx, int dy) +{ + if (myInputPort && myInputPort == thePort) { + myPrs.first()->moveBy(dx, dy); + return; + } + if (myOutputPort && myOutputPort == thePort) { + myPrs.last()->moveBy(dx, dy); + return; + } +} + +void SUPERVGUI_CanvasLink::moveByPort(SUPERVGUI_CanvasPort* thePort) +{ + QPoint p = thePort->getConnectionPoint(); + if (myInputPort && myInputPort == thePort) { + myPrs.first()->move(p.x(), p.y()); + return; + } + if (myOutputPort && myOutputPort == thePort) { + myPrs.last()->move(p.x(), p.y()); + return; + } +} + +void SUPERVGUI_CanvasLink::setColor(const QColor& theColor) +{ + for (QCanvasItemList::Iterator it = myPrs.begin(); it != myPrs.end(); ++it) { + if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) { + ((SUPERVGUI_CanvasPointPrs*)(*it))->setColor(theColor); + } + else if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge) { + ((SUPERVGUI_CanvasEdgePrs*)(*it))->setColor(theColor); + } + } +} + +void SUPERVGUI_CanvasLink::remove() { + QString aValue; + SUPERVGUI_CanvasPortIn* aPort = 0; + SUPERVGUI_Canvas* aCanvas = myMain->getCanvas(); + if (myLink && !SUPERV_isNull(myLink)) { + if (myInputPort) { + if (myInputPort->getEngine()->IsParam() || myInputPort->getEngine()->IsInLine()) { + aValue = QString(myInputPort->getEngine()->ToString()); + aPort = (SUPERVGUI_CanvasPortIn*) myInputPort; + } + } + myLink->destroy(); + } + delete this; + if (aPort && !aValue.isEmpty() && myMain->getDataflow()->GraphLevel() == 0) { + aPort->setValue(aValue); + } + aCanvas->update(); +} + +void SUPERVGUI_CanvasLink::addPoint() { + if (mySelectedItem && mySelectedItem->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge) { + SUPERVGUI_CanvasEdgePrs* anEdge = (SUPERVGUI_CanvasEdgePrs*) mySelectedItem; + + int anIndex = 1; + QCanvasItemList::Iterator it; + for (it = myPrs.begin(); it != myPrs.end(); ++it) { + if ((*it) == anEdge) break; + } + if (it != myPrs.begin()) { + --it; + SUPERVGUI_CanvasPointPrs* aPoint = (SUPERVGUI_CanvasPointPrs*) (*it); + anIndex = aPoint->getIndex()+1; + if (anIndex < 1) anIndex = 1; + } + if (myLink && !SUPERV_isNull(myLink)) + myLink->AddCoord(anIndex, mySelectedPoint.x(), mySelectedPoint.y()); + merge(); + myMain->getCanvas()->update(); + } +} + +void SUPERVGUI_CanvasLink::removePoint() { + if (mySelectedItem && mySelectedItem->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) { + SUPERVGUI_CanvasPointPrs* aPoint = (SUPERVGUI_CanvasPointPrs*) mySelectedItem; + if (myLink && !SUPERV_isNull(myLink)) + myLink->RemoveCoord(aPoint->getIndex()); + merge(); + myMain->getCanvas()->update(); + } +} + +/* +//=============================================================================== +// SUPERVGUI_CanvasStreamLink: new link to be created +//=============================================================================== +SUPERVGUI_CanvasStreamLink::SUPERVGUI_CanvasStreamLink(QObject* theParent, SUPERVGUI_Main* theMain, + SUPERV::StreamLink_ptr theLink): + SUPERVGUI_CanvasLink(theParent, theMain, theLink) +{ + if (theLink && !SUPERV_isNull(theLink)) { + myStreamLink = SUPERV::StreamLink::_duplicate(theLink); + } +} + + +void SUPERVGUI_CanvasStreamLink::remove() { + QString aValue; + SUPERVGUI_CanvasPortIn* aPort = 0; + SUPERVGUI_Canvas* aCanvas = getMain()->getCanvas(); + if (myStreamLink && !SUPERV_isNull(myStreamLink)) { + if (getInputPort()) { + if (getInputPort()->getEngine()->IsParam() || getInputPort()->getEngine()->IsInLine()) { + aPort = (SUPERVGUI_CanvasPortIn*) getInputPort(); + aValue = QString(aPort->getEngine()->ToString()); + } + } + myStreamLink->destroy(); + } + delete this; + if (aPort && !aValue.isEmpty()) { + aPort->setValue(aValue); + } + aCanvas->update(); +} +*/ + +//=============================================================================== +// SUPERVGUI_CanvasLinkBuilder: new link to be created +//=============================================================================== +SUPERVGUI_CanvasLinkBuilder::SUPERVGUI_CanvasLinkBuilder(QObject* theParent, SUPERVGUI_Main* theMain, + SUPERVGUI_CanvasPort* thePort): + SUPERVGUI_CanvasLink(theParent, theMain), + myPort(thePort), + myFloatingEdge(0) +{ + if (myPort) { + myPort->addLink(this); + addPoint(myPort->getConnectionPoint()); + } + myColor = SKETCH_COLOR; +} + +SUPERVGUI_CanvasLinkBuilder::~SUPERVGUI_CanvasLinkBuilder() +{ + if (myFloatingEdge) delete myFloatingEdge; + if (myPort) myPort->removeLink(this); +} + +bool SUPERVGUI_CanvasLinkBuilder::canCreateEngine(SUPERVGUI_CanvasPort* thePort) +{ + bool result = false; + if (thePort && myPort) { + SUPERVGUI_CanvasPort* aInPort; + SUPERVGUI_CanvasPort* aOutPort; + + // check if ports are couple of input and output + if (myPort->getEngine()->IsInput()) { + aInPort = myPort; + if (thePort->getEngine()->IsInput()) + return false; + aOutPort = thePort; + } + else { + aOutPort = myPort; + if (!thePort->getEngine()->IsInput()) + return false; + aInPort = thePort; + } + + // control if node is different + QString aInNode(aInPort->getEngine()->Node()->Name()); + QString aOutNode(aOutPort->getEngine()->Node()->Name()); + if (aInNode.compare(aOutNode) == 0) + return false; + + // control if no port is "Default" + QString aInName(aInPort->getEngine()->Name()); + QString aOutName(aOutPort->getEngine()->Name()); + if (aInName.compare("Default") == 0 || + aOutName.compare("Default") == 0) + return false; + + // control types of ports + int aInKind = aInPort->getEngine()->Kind(); + int aOutKind = aOutPort->getEngine()->Kind(); + + // connect stream port with stream port only + if ((aInKind == SUPERV::DataStreamParameter && aOutKind != SUPERV::DataStreamParameter) || + (aOutKind == SUPERV::DataStreamParameter && aInKind != SUPERV::DataStreamParameter)) + return false; + + // connect gate port with gate or inline port + if (aInKind == SUPERV::GateParameter || aOutKind == SUPERV::GateParameter) { + if (aInKind != aOutKind && + aInKind != SUPERV::InLineParameter && + aOutKind != SUPERV::InLineParameter) + return false; + } + + // control if port is already linked except for input port of end switch node + if (!(aInKind == SUPERV::EndSwitchParameter || + aInPort->getEngine()->Node()->Kind() == SUPERV::EndSwitchNode)) { + if (aInPort->getEngine()->IsLinked()) + return false; + } + result = true; + } + return result; +} + +void SUPERVGUI_CanvasLinkBuilder::setCoords(SUPERV::Link_ptr theLink) +{ + if (theLink) { + QCanvasItemList::Iterator it; + int anIndex = 1; + if (myPort->getEngine()->IsInput()) { + it = myPrs.begin(); ++it; // ignore the first point + for (; it != myPrs.end(); ++it) { + if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) { + theLink->AddCoord(anIndex++, (int)(*it)->x(), (int)(*it)->y()); + } + } + } + else { + it = myPrs.end(); --it; + for (; it != myPrs.begin(); --it) { + if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) { + theLink->AddCoord(anIndex++, (int)(*it)->x(), (int)(*it)->y()); + } + } + } + } +} + +void SUPERVGUI_CanvasLinkBuilder::addNextPoint(const QPoint& thePoint, bool theOrtho) +{ + if (myFloatingEdge) myFloatingEdge->hide(); + + if (!theOrtho || myPrs.empty()) { + addPoint(thePoint); + } + else { + SUPERVGUI_CanvasPointPrs* aPrev = (SUPERVGUI_CanvasPointPrs*) myPrs.last(); + int x = (int)aPrev->x(); int y = (int)aPrev->y(); + if (thePoint.x() != x && thePoint.y() != y) { + addPoint(QPoint(thePoint.x(), y), -2); + } + addPoint(thePoint); + } + show(); +} + +void SUPERVGUI_CanvasLinkBuilder::setFloatPoint(const QPoint& thePoint) +{ + if (!myFloatingEdge) { + myFloatingEdge = new QCanvasLine(getMain()->getCanvas()); + myFloatingEdge->setPen(QPen(myColor, LINE_WIDTH)); + } + if (!myPrs.empty()) { + myFloatingEdge->setPoints((int)myPrs.last()->x(), (int)myPrs.last()->y(), + thePoint.x(), thePoint.y()); + myFloatingEdge->show(); + } +} + +void SUPERVGUI_CanvasLinkBuilder::removeLastPoint() +{ + if (myPrs.count() > 1) { + QPoint aLast((int)myPrs.last()->x(), (int)myPrs.last()->y()); + QCanvasItemList::Iterator it = myPrs.end(); + bool removed = false; + --it; + for (; it != myPrs.begin(); --it) { + if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) { + SUPERVGUI_CanvasPointPrs* aPoint = (SUPERVGUI_CanvasPointPrs*) (*it); + if (aPoint->getIndex() == -1 && removed) break; + } + QCanvasItem* anItem = (*it); + it = myPrs.remove(it); + delete anItem; + removed = true; + } + if (removed) { + if (myFloatingEdge) { + QPoint aPoint = myFloatingEdge->endPoint(); + myFloatingEdge->setPoints((int)myPrs.last()->x(), (int)myPrs.last()->y(), + aPoint.x(), aPoint.y()); + } + else + setFloatPoint(aLast); + } + } +} + +void SUPERVGUI_CanvasLinkBuilder::moveByPort(SUPERVGUI_CanvasPort* thePort, int dx, int dy) +{ + if (myPort && myPort == thePort) { + myPrs.first()->moveBy(dx, dy); + return; + } +} + +void SUPERVGUI_CanvasLinkBuilder::moveByPort(SUPERVGUI_CanvasPort* thePort) +{ + QPoint p = thePort->getConnectionPoint(); + if (myPort && myPort == thePort) { + myPrs.first()->move(p.x(), p.y()); + return; + } +} + + +//=============================================================================== +// SUPERVGUI_CanvasPointPrs: link point presentation +//=============================================================================== +SUPERVGUI_CanvasPointPrs::SUPERVGUI_CanvasPointPrs(QCanvas* theCanvas, + SUPERVGUI_CanvasLink* theLink, + const int& theIndex): + QCanvasEllipse(theCanvas), + myLink(theLink), myIndex(theIndex), + myInEdge(0), myOutEdge(0), myMoving(false) +{ + setSize(POINT_SIZE, POINT_SIZE); + setZ(-1); +} + +int SUPERVGUI_CanvasPointPrs::rtti() const +{ + return SUPERVGUI_Canvas::Rtti_LinkPoint; +} + +void SUPERVGUI_CanvasPointPrs::setInEdge(SUPERVGUI_CanvasEdgePrs* theEdge) +{ + myInEdge = theEdge; + theEdge->setFromPoint((int)x(), (int)y()); +} + +void SUPERVGUI_CanvasPointPrs::setOutEdge(SUPERVGUI_CanvasEdgePrs* theEdge) +{ + myOutEdge = theEdge; + theEdge->setToPoint((int)x(), (int)y()); +} + +void SUPERVGUI_CanvasPointPrs::moveBy(double dx, double dy) +{ + QCanvasEllipse::moveBy(dx, dy); + if (myInEdge) myInEdge->setFromPoint((int)x(), (int)y()); + if (myOutEdge) myOutEdge->setToPoint((int)x(), (int)y()); + if (myIndex > 0 && isMoving()) { + myLink->getEngine()->ChangeCoord(myIndex, (int)x(), (int)y()); + } +} + +void SUPERVGUI_CanvasPointPrs::setColor(const QColor& theColor) +{ + setBrush(theColor); +} + +//=============================================================================== +// SUPERVGUI_CanvasEdgePrs: link edge presentation +//=============================================================================== +SUPERVGUI_CanvasEdgePrs::SUPERVGUI_CanvasEdgePrs(QCanvas* theCanvas, + SUPERVGUI_CanvasLink* theLink): + QCanvasLine(theCanvas), + myLink(theLink) +{ + setZ(-2); +} + +int SUPERVGUI_CanvasEdgePrs::rtti() const +{ + return SUPERVGUI_Canvas::Rtti_LinkEdge; +} + +void SUPERVGUI_CanvasEdgePrs::setFromPoint(int x, int y) +{ + setPoints(x, y, endPoint().x(), endPoint().y()); +} + +void SUPERVGUI_CanvasEdgePrs::setToPoint(int x, int y) +{ + setPoints(startPoint().x(), startPoint().y(), x, y); +} + +void SUPERVGUI_CanvasEdgePrs::setColor(const QColor& theColor) +{ + setPen(QPen(theColor, LINE_WIDTH)); +} diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasLink.h b/src/SUPERVGUI/SUPERVGUI_CanvasLink.h new file mode 100644 index 0000000..cb54d0c --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_CanvasLink.h @@ -0,0 +1,166 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_CanvasLink.h +// Author : Natalia KOPNOVA +// Module : SUPERV + +#ifndef SUPERVGUI_CanvasLink_H +#define SUPERVGUI_CanvasLink_H + +using namespace std; +#include "SUPERVGUI_Def.h" +#include +#include + +class SUPERVGUI_Main; +class SUPERVGUI_CanvasPort; + +class SUPERVGUI_CanvasLink : public QObject { + Q_OBJECT + + public: + SUPERVGUI_CanvasLink(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::Link_ptr theLink=0); + virtual ~SUPERVGUI_CanvasLink(); + + void show(); + void merge(); + + void setHilighted(bool state); + void setColor(const QColor& theColor); + + virtual void moveByPort(SUPERVGUI_CanvasPort* thePort); + virtual void moveByPort(SUPERVGUI_CanvasPort* thePort, int dx, int dy); + + SUPERV_Link getEngine() const { return myLink; } + SUPERVGUI_Main* getMain() const { return myMain; } + + SUPERVGUI_CanvasPort* getInputPort() const { return myInputPort; } + SUPERVGUI_CanvasPort* getOutputPort() const { return myOutputPort; } + + void setSelectedObject(QCanvasItem* theItem, const QPoint& thePoint); + virtual QPopupMenu* getPopupMenu(QWidget* theParent); + + public slots: + virtual void remove(); + void addPoint(); + void removePoint(); + + protected: + void addPoint(const QPoint& thePoint, const int& theIndex = -1); + + QColor myColor; + QCanvasItemList myPrs; + + private: + void createPrs(); + + SUPERV_Link myLink; + SUPERVGUI_Main* myMain; + + SUPERVGUI_CanvasPort* myInputPort; + SUPERVGUI_CanvasPort* myOutputPort; + + bool myHilighted; + QCanvasItem* mySelectedItem; + QPoint mySelectedPoint; +}; + +/* +class SUPERVGUI_CanvasStreamLink : public SUPERVGUI_CanvasLink { + Q_OBJECT + + public: + SUPERVGUI_CanvasStreamLink(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::StreamLink_ptr theLink=0); + ~SUPERVGUI_CanvasStreamLink() {} + + SUPERV_StreamLink getStreamEngine() const { return myStreamLink; } + + public slots: + virtual void remove(); + + private: + SUPERV_StreamLink myStreamLink; +}; +*/ + +class SUPERVGUI_CanvasLinkBuilder : public SUPERVGUI_CanvasLink { + Q_OBJECT + + public: + SUPERVGUI_CanvasLinkBuilder(QObject* theParent, SUPERVGUI_Main* theMain, SUPERVGUI_CanvasPort* thePort=0); + virtual ~SUPERVGUI_CanvasLinkBuilder(); + + bool canCreateEngine(SUPERVGUI_CanvasPort* thePort); + void setCoords(SUPERV::Link_ptr theLink); + + SUPERVGUI_CanvasPort* getStartPort() const { return myPort; } + + int getPointCount() const { return (int) (myPrs.count()/2); } + void addNextPoint(const QPoint& thePoint, bool theOrtho = false); + void setFloatPoint(const QPoint& thePoint); + void removeLastPoint(); + + virtual void moveByPort(SUPERVGUI_CanvasPort* thePort); + virtual void moveByPort(SUPERVGUI_CanvasPort* thePort, int dx, int dy); + + private: + SUPERVGUI_CanvasPort* myPort; + + QCanvasLine* myFloatingEdge; +}; + + +class SUPERVGUI_CanvasEdgePrs; +class SUPERVGUI_CanvasPointPrs : public QCanvasEllipse +{ + public: + SUPERVGUI_CanvasPointPrs(QCanvas* theCanvas, SUPERVGUI_CanvasLink* theLink, const int& theIndex = -1); + ~SUPERVGUI_CanvasPointPrs() {} + + SUPERVGUI_CanvasLink* getLink() const { return myLink; } + int getIndex() const { return myIndex; } + + void setInEdge(SUPERVGUI_CanvasEdgePrs* theEdge); + void setOutEdge(SUPERVGUI_CanvasEdgePrs* theEdge); + + void moveBy(double dx, double dy); + void setColor(const QColor& theColor); + + void setMoving(bool b) { myMoving = b; } + bool isMoving() const { return myMoving; } + + virtual int rtti() const; + + private: + SUPERVGUI_CanvasLink* myLink; + int myIndex; + bool myMoving; + + SUPERVGUI_CanvasEdgePrs* myInEdge; + SUPERVGUI_CanvasEdgePrs* myOutEdge; +}; + + +class SUPERVGUI_CanvasEdgePrs : public QCanvasLine +{ + public: + SUPERVGUI_CanvasEdgePrs(QCanvas* theCanvas, SUPERVGUI_CanvasLink* theLink); + ~SUPERVGUI_CanvasEdgePrs() {} + + SUPERVGUI_CanvasLink* getLink() const { return myLink; } + + void setFromPoint(int x, int y); + void setToPoint(int x, int y); + + void moveBy(double dx, double dy) {} + void setColor(const QColor& theColor); + + virtual int rtti() const; + + private: + SUPERVGUI_CanvasLink* myLink; +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx new file mode 100644 index 0000000..ce06ff8 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx @@ -0,0 +1,583 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_CanvasNode.cxx +// Author : Natalia KOPNOVA +// Module : SUPERV + +using namespace std; +#include "SUPERVGUI_CanvasNode.h" +#include "SUPERVGUI_CanvasNodePrs.h" +#include "SUPERVGUI_CanvasPort.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 "SUPERVGUI_CanvasControlNode.h" + +#include +*/ + +SUPERVGUI_CanvasNode::SUPERVGUI_CanvasNode(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode): + QObject(theParent), + myMain(theMain), + myNode(theNode), + myPrs(0), + myDestroyed(false), + warning(true), + step(true), + trace(true), + verbose(true), + myBrowseDlg(0) +{ + Trace("SUPERVGUI_CanvasNode::SUPERVGUI_CanvasNode"); + //cout << "===> SUPERVGUI_CanvasNode " << myNode->Name() << endl; + + setName(myNode->Name()); + + QString aComment(myNode->Comment()); + QString aNewComment = aComment; + if (getNodeType() == SUPERV::FactoryNode) { + aNewComment = QString(myNode->Service()->ServiceName) + + QString(tr("COMMENT_FROM")) + + QString(getFactoryNode()->GetComponentName()); + } + else if (myNode->IsMacro()) { + aNewComment = tr("COMMENT_MNODE"); + } + else { + aNewComment = tr("COMMENT_CNODE"); + } + if (aComment.isEmpty()) { + myNode->SetComment(aNewComment.latin1()); + } + + myLabelText = aNewComment; + + // create node ports + isIgnore = true; + //cout << " get port list... " ; + SUPERV_Ports aPortList = myNode->Ports(); + //cout << aPortList->length() << endl; + for (int i = 0; i < aPortList->length(); i++) { + createPort(aPortList[i].in()); + } + + //cout << " get stream port list... " ; + SUPERV_StreamPorts aStreamPortList = myNode->StreamPorts(); + //cout << aStreamPortList->length() << endl; + for (int i = 0; i < aStreamPortList->length(); i++) { + createStreamPort(aStreamPortList[i].in()); + } + + isIgnore = false; + //cout << "<=== SUPERVGUI_CanvasNode " << myNode->Name() << endl; +} + +SUPERVGUI_CanvasNode::~SUPERVGUI_CanvasNode() +{ + isIgnore = true; + if (myPrs) delete myPrs; +} + +void SUPERVGUI_CanvasNode::setDestroyed() +{ + myDestroyed = true; + getPrs()->hide(); +} + +SUPERVGUI_CanvasNodePrs* SUPERVGUI_CanvasNode::getPrs() const +{ + if (myPrs == 0) { + ((SUPERVGUI_CanvasNode*)this)->myPrs = createPrs(); + } + return myPrs; +} + +SUPERVGUI_CanvasNodePrs* SUPERVGUI_CanvasNode::createPrs() const +{ + return new SUPERVGUI_CanvasNodePrs(myMain->getCanvas(), (SUPERVGUI_CanvasNode*)this); +} + +void SUPERVGUI_CanvasNode::createPort(SUPERV::Port_ptr thePort) const +{ + SUPERVGUI_CanvasPort* aPort = 0; + if (thePort->IsInput()) + aPort = new SUPERVGUI_CanvasPortIn((SUPERVGUI_CanvasNode*)this, myMain, thePort); + else + aPort = new SUPERVGUI_CanvasPortOut((SUPERVGUI_CanvasNode*)this, myMain, thePort); + + if (aPort) { + connect(aPort, SIGNAL(destroyed(QObject*)), this, SLOT(onDestroyed(QObject*))); + if (!isIgnore) getPrs()->updatePorts(); + } +} + +void SUPERVGUI_CanvasNode::createStreamPort(SUPERV::StreamPort_ptr thePort) const +{ + SUPERVGUI_CanvasPort* aPort = 0; + if (thePort->IsInput()) + aPort = new SUPERVGUI_CanvasStreamPortIn((SUPERVGUI_CanvasNode*)this, myMain, thePort); + else + aPort = new SUPERVGUI_CanvasStreamPortOut((SUPERVGUI_CanvasNode*)this, myMain, thePort); + + if (aPort) { + connect(aPort, SIGNAL(destroyed(QObject*)), this, SLOT(onDestroyed(QObject*))); + if (!isIgnore) getPrs()->updatePorts(); + } +} + +void SUPERVGUI_CanvasNode::onDestroyed(QObject* theObject) +{ + if (!isIgnore) { + removeChild(theObject); // signal is sent before removing the object + getPrs()->updatePorts(); + } +} + +QPopupMenu* SUPERVGUI_CanvasNode::getPopupMenu(QWidget* theParent) +{ + QPopupMenu* popup = new QPopupMenu(theParent); + if (myMain->getDataflow()->IsExecuting()) { + popup->insertItem((myNode->IsSuspended()?tr("MSG_RESUME"):tr("MSG_SUSPEND")), + this, SLOT(suspendResume())); + popup->insertItem(tr("MSG_KILL"), this, SLOT(kill())); + } + else { + if (myMain->isEditable() && getNodeType() != SUPERV::EndLoopNode + && getNodeType() != SUPERV::EndSwitchNode) { + popup->insertItem(tr("MSG_RENAME"), this, SLOT(rename())); + popup->insertItem(tr("MSG_DELETE"), this, SLOT(remove())); + popup->insertSeparator(); + } + popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse())); + + if (getNodeType() != SUPERV::EndLoopNode && + getNodeType() != SUPERV::EndSwitchNode) + popup->insertItem(tr("MSG_CHANGE_INFO"), this, SLOT(changeInformation())); + + if (myMain->isEditable() && getNodeType() != SUPERV::FactoryNode + && getNodeType() != SUPERV::ComputingNode + && getNodeType() != SUPERV::EndLoopNode + && getNodeType() != SUPERV::MacroNode) { + QPopupMenu* addPortMenu = new QPopupMenu(theParent); + addPortMenu->insertItem("Input", this, SLOT(addInputPort())); + if (getNodeType() != SUPERV::LoopNode) + addPortMenu->insertItem("Output", this, SLOT(addOutputPort())); + + popup->insertSeparator(); + if ((getNodeType() != SUPERV::EndSwitchNode)) + popup->insertItem("Edit Function", this, SLOT(editFunction())); + popup->insertItem("Add Port", addPortMenu); + } + } + + return popup; +} + +void SUPERVGUI_CanvasNode::show() +{ + getPrs()->show(); +} + +void SUPERVGUI_CanvasNode::showAll() +{ + getPrs()->showAll(); +} + +void SUPERVGUI_CanvasNode::hideAll() +{ + getPrs()->hideAll(); +} + +void SUPERVGUI_CanvasNode::switchLabel() +{ + getPrs()->setLabelVisible(!getPrs()->isLabelVisible()); +} + +void SUPERVGUI_CanvasNode::switchPorts() +{ + getPrs()->setPortVisible(!getPrs()->isPortVisible()); +} + +void SUPERVGUI_CanvasNode::move(int x, int y) +{ + // myNode->Coords(x, y); // <<<- done inside Prs to reflect item movement by mouse press + if (x > GRAPH_MAX) x = (int) getPrs()->x(); + if (y > GRAPH_MAX) y = (int) getPrs()->y(); + getPrs()->move(x, y); +} + +void SUPERVGUI_CanvasNode::merge() +{ + //cout << "===> SUPERVGUI_CanvasNode::merge() " << myNode->Name() << endl; + // synchronize port list + bool update = false; + isIgnore = true; + SUPERVGUI_CanvasPort* aPort; + QObjectList* aPortList = queryList("SUPERVGUI_CanvasPort"); + //cout << " get port list... " ; + SUPERV_Ports aPorts = myNode->Ports(); + //cout << aPorts->length() << endl; + for (int i = 0; i < aPorts->length(); i++) { + aPort = (SUPERVGUI_CanvasPort*) + child(myMain->getCanvas()->getPortName(aPorts[i].in()), "SUPERVGUI_CanvasPort"); + if (aPort) { + //cout << " update port " << aPort->name() << endl; + aPortList->removeRef(aPort); + aPort->update(); + } + else { + //cout << " create port " << myMain->getCanvas()->getPortName(aPorts[i].in()) << endl; + createPort(aPorts[i].in()); + update = true; + } + } + + //cout << " get stream port list... " ; + SUPERV_StreamPorts aStreamPorts = myNode->StreamPorts(); + //cout << aStreamPorts->length() << endl; + for (int i = 0; i < aStreamPorts->length(); i++) { + aPort = (SUPERVGUI_CanvasPort*) + child(myMain->getCanvas()->getPortName(aStreamPorts[i].in()), "SUPERVGUI_CanvasPort"); + if (aPort) { + //cout << " update stream port " << aPort->name() << endl; + aPortList->removeRef(aPort); + aPort->update(); + } + else { + //cout << " create stream port " << myMain->getCanvas()->getPortName(aStreamPorts[i].in()) << endl; + createPort(aStreamPorts[i].in()); + update = true; + } + } + + //cout << " remove inexistant " << endl; + QObjectListIt it(*aPortList); + while ((aPort=(SUPERVGUI_CanvasPort*)it.current()) != 0) { + ++it; + aPortList->removeRef(aPort); + delete aPort; + update = true; + } + delete aPortList; + isIgnore = false; + if (update) getPrs()->updatePorts(); + + sync(); // update node state also +} + +void SUPERVGUI_CanvasNode::sync() +{ + //cout << "===> SUPERVGUI_CanvasNode::sync() " << myNode->Name() << ", state " << myNode->State() << endl; + + //if myNode is a MacroNode then set it state to state of its subgraph + if (myNode->IsMacro() && myMain->getDataflow()->IsExecuting()) { + // get SubGraph from MacroNode + SUPERV_Graph aMacro = SUPERV::Graph::_narrow(myNode); + if (!SUPERV_isNull(aMacro)) { + SUPERV_Graph aGraph; + if (aMacro->IsStreamMacro()) + aGraph = aMacro->StreamObjRef(); + else + aGraph = aMacro->FlowObjRef(); + if (!SUPERV_isNull(aGraph)) { + if (aGraph->State() != SUPERV::UndefinedState && aGraph->State() != SUPERV::NoState) + getPrs()->setState(aGraph->State()); + else + getPrs()->setState(myNode->State()); + } + } + } + else + getPrs()->setState(myNode->State()); + + // update child ports + const QObjectList* list = children(); + if (list) { + QObjectListIt it(*list); + while (QObject* obj = it.current()) { + ++it; + if (obj->inherits("SUPERVGUI_CanvasPort")) { + ((SUPERVGUI_CanvasPort*)obj)->sync(); + } + } + } +} + +void SUPERVGUI_CanvasNode::syncOnEvent(SUPERV::GraphState theStateFromEvent) +{ + getPrs()->setState(theStateFromEvent); +} + +bool SUPERVGUI_CanvasNode::setNodeName(QString aName) +{ + bool result = myNode->SetName(aName.latin1()); + if (result) { + setName(myNode->Name()); + getPrs()->updateInfo(); + // TODO: update name of all the links to this node + } + else { + QMessageBox::warning( QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_CANT_RENAMENODE" ) ); + } + return result; +} + +void SUPERVGUI_CanvasNode::rename() +{ + QString aName = SALOMEGUI_NameDlg::getName(QAD_Application::getDesktop(), myNode->Name()); + if (!aName.isEmpty()) { + setNodeName(aName); + } +} + +void SUPERVGUI_CanvasNode::remove() { + Trace("SUPERVGUI_CanvasNode::remove"); + SUPERVGUI_Canvas* aCanvas = myMain->getCanvas(); + setDestroyed(); + myNode->destroy(); + delete this; + aCanvas->update(); +} + +void SUPERVGUI_CanvasNode::suspendResume() { + Trace("SUPERVGUI_CanvasNode::suspendResume"); + int n = queryList("SUPERVGUI_CanvasNode")->count(); + if (myNode->IsSuspended()) { + if (!((n==1)? myMain->getDataflow()->Resume() : myNode->Resume())) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESUMENODE")); + } + else { + sync(); + myMain->getMyThread()->startThread(tr("MSG_NODE_RESUMED1")+myNode->Name()+tr("MSG_NODE_RESUMED2")); + } + } else { + if (!((n==1)? myMain->getDataflow()->Suspend() : myNode->Suspend())) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_SUSPENDNODE")); + } else { + syncOnEvent(SUPERV::SuspendReadyState); + myMain->getMyThread()->stopThread(tr("MSG_NODE_SUSPENDED1")+myNode->Name()+tr("MSG_NODE_SUSPENDED2")); + } + } +} + +void SUPERVGUI_CanvasNode::kill() { + Trace("SUPERVGUI_CanvasNode::kill"); + int n = queryList("SUPERVGUI_CanvasNode")->count(); + if (!((n==1)? myMain->getDataflow()->Kill() : myNode->Kill())) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_KILLNODE")); + } else { + syncOnEvent(SUPERV_Kill); + myMain->getMyThread()->stopThread(tr("MSG_NODE_KILLED1")+myNode->Name()+tr("MSG_NODE_KILLED2")); + } +} + +void SUPERVGUI_CanvasNode::stopRestart() { + Trace("SUPERVGUI_CanvasNode::stopRestart"); + + int n = queryList("SUPERVGUI_CanvasNode")->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_CanvasNode::changeInformation() { + SUPERVGUI_Information* aDlg = new SUPERVGUI_Information(myNode, !myMain->isEditable()); + if (aDlg->exec()) { + QString aName = myNode->Name(); + if (!aName.isEmpty() && myMain->isEditable()) + setNodeName(aName); + } + delete aDlg; +} + +void SUPERVGUI_CanvasNode::configure() +{ + Trace("SUPERVGUI_CanvasNode::configure"); + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_NOT_IMPLEMENTED")); // kloss : a faire : lancer l'ihm DATA +} + +void SUPERVGUI_CanvasNode::showPython() +{ + Trace("SUPERVGUI_CanvasNode::showPython"); + SUPERVGUI_Python cp(myMain->getStudy()->get_PyInterp(), !myMain->isEditable()); + cp.exec(); +} + +bool SUPERVGUI_CanvasNode::isWarning() +{ + Trace("SUPERVGUI_CanvasNode::isWarning"); + return(warning); +} + +bool SUPERVGUI_CanvasNode::isStep() +{ + Trace("SUPERVGUI_CanvasNode::isStep"); + return(step); +} + +bool SUPERVGUI_CanvasNode::isTrace() +{ + Trace("SUPERVGUI_CanvasNode::isTrace"); + return(trace); +} + +bool SUPERVGUI_CanvasNode::isVerbose() +{ + Trace("SUPERVGUI_CanvasNode::isVerbose"); + return(verbose); +} + +void SUPERVGUI_CanvasNode::setWarning(bool b) +{ + Trace("SUPERVGUI_CanvasNode::setWarning"); + warning = b; +} + +void SUPERVGUI_CanvasNode::setStep(bool b) +{ + Trace("SUPERVGUI_CanvasNode::setStep"); + step = b; +} + +void SUPERVGUI_CanvasNode::setTrace(bool b) +{ + Trace("SUPERVGUI_CanvasNode::setTrace"); + trace = b; +} + +void SUPERVGUI_CanvasNode::setVerbose(bool b) +{ + Trace("SUPERVGUI_CanvasNode::setVerbose"); + verbose = b; +} + + +void SUPERVGUI_CanvasNode::browse() +{ + if (!myBrowseDlg) { + myBrowseDlg = new SUPERVGUI_BrowseNodeDlg(this); + myBrowseDlg->installEventFilter(this); + } + if (!myBrowseDlg->isVisible()) + myBrowseDlg->show(); + else { + myBrowseDlg->raise(); + myBrowseDlg->setActiveWindow(); + myBrowseDlg->setFocus(); + } +} + +bool SUPERVGUI_CanvasNode::eventFilter( QObject* o, QEvent* e ) +{ + if (o == myBrowseDlg && e->type() == QEvent::Close) + myBrowseDlg = 0; + return QObject::eventFilter(o, e); +} + +SUPERV_Port SUPERVGUI_CanvasNode::createInPort() +{ + SUPERVGUI_PortParamsDlg* aDlg = new SUPERVGUI_PortParamsDlg(); + if (aDlg->exec()) { + if (aDlg->getName().isEmpty() || aDlg->getType().isEmpty()) { + QMessageBox::warning( QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_CANT_CREATE_PORT" ) ); + return NULL; + } + SUPERV_INode aNode = getInlineNode(); + if (SUPERV_isNull(aNode)) { + MESSAGE("SUPERVGUI_CanvasNode::createInPort: Node is wrong type"); + return NULL; + } + SUPERV_Ports aPorts = aNode->Ports(); + for (int i=0; ilength(); i++) { + if (aPorts[i]->IsInput() && 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_CanvasNode::createOutPort() +{ + SUPERVGUI_PortParamsDlg* aDlg = new SUPERVGUI_PortParamsDlg(); + if (aDlg->exec()) { + SUPERV_INode aNode = getInlineNode(); + if (SUPERV_isNull(aNode)) { + MESSAGE("SUPERVGUI_CanvasNode::createOutPort: Node is wrong type"); + return NULL; + } + SUPERV_Ports aPorts = aNode->Ports(); + for (int i=0; ilength(); i++) { + if (!aPorts[i]->IsInput() && 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_CanvasNode::addInputPort() { + SUPERV_Port aPort = createInPort(); + if (aPort == NULL) return; + + createPort(aPort.in()); +} + + +void SUPERVGUI_CanvasNode::addOutputPort() { + SUPERV_Port aPort = createOutPort(); + if (aPort == NULL) return; + + createPort(aPort.in()); +} + + +void SUPERVGUI_CanvasNode::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; + } +} diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasNode.h b/src/SUPERVGUI/SUPERVGUI_CanvasNode.h new file mode 100644 index 0000000..9cf391c --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_CanvasNode.h @@ -0,0 +1,121 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_CanvasNode.h +// Author : Natalia KOPNOVA +// Module : SUPERV + +#ifndef SUPERVGUI_CanvasNode_H +#define SUPERVGUI_CanvasNode_H + +using namespace std; +#include "SUPERVGUI_Def.h" +#include "SUPERVGUI_BrowseNodeDlg.h" + +class SUPERVGUI_Main; +class SUPERVGUI_CanvasNodePrs; + +class SUPERVGUI_CanvasNode : public QObject { + Q_OBJECT + + public: + SUPERVGUI_CanvasNode(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode); + virtual ~SUPERVGUI_CanvasNode(); + + // done to ignore port update when node is removed + bool isDestroyed() const { return myDestroyed; } + void setDestroyed(); + + virtual void merge(); + virtual void sync(); + virtual void syncOnEvent(SUPERV::GraphState theStateFromEvent); + + virtual void show(); + virtual void move(int x, int y); + + virtual void hideAll(); + virtual void showAll(); + virtual bool setNodeName(QString aName); + + SUPERV_CNode getEngine() const { return myNode; } + SUPERVGUI_Main* getMain() const { return myMain; } + SUPERVGUI_CanvasNodePrs* getPrs() const; + + bool isWarning(); + bool isStep(); + bool isTrace(); + bool isVerbose(); + + SUPERV::KindOfNode getNodeType() const { return myNode->Kind(); } + + SUPERV_CNode getComputingNode() const { return myNode; } + SUPERV_FNode getFactoryNode() const { return SUPERV::FNode::_narrow(myNode); } + SUPERV_INode getInlineNode() const { return SUPERV::INode::_narrow(myNode); } + SUPERV_GNode getGotoNode() const { return SUPERV::GNode::_narrow(myNode); } + SUPERV_LNode getLoopNode() const { return SUPERV::LNode::_narrow(myNode); } + SUPERV_ELNode getEndLoopNode() const { return SUPERV::ELNode::_narrow(myNode); } + SUPERV_SNode getSwitchNode() const { return SUPERV::SNode::_narrow(myNode); } + SUPERV_ESNode getEndSwitchNode() const { return SUPERV::ESNode::_narrow(myNode); } + SUPERV_Graph getMacroNode() const { return SUPERV::Graph::_narrow(myNode); } + + SUPERV_Port createInPort(); + SUPERV_Port createOutPort(); + + virtual QPopupMenu* getPopupMenu(QWidget* theParent); + + QString getLabelText() const { return myLabelText; } + + public slots: + void suspendResume(); + void kill(); + void stopRestart(); + void configure(); + void showPython(); + + virtual void rename(); + virtual void remove(); + void changeInformation(); + void browse(); + + void switchLabel(); + void switchPorts(); + + void setWarning(bool b); + void setStep(bool b); + void setTrace(bool b); + void setVerbose(bool b); + + virtual void addInputPort(); + virtual void addOutputPort(); + virtual void editFunction(); + + protected: + virtual SUPERVGUI_CanvasNodePrs* createPrs() const; + virtual void createPort(SUPERV::Port_ptr thePort) const; + virtual void createStreamPort(SUPERV::StreamPort_ptr thePort) const; + + virtual bool eventFilter(QObject* o, QEvent* e); + SUPERVGUI_BrowseNodeDlg* myBrowseDlg; + + bool isIgnore; + + protected slots: + virtual void onDestroyed(QObject*); + + private: + SUPERV_CNode myNode; + SUPERVGUI_Main* myMain; + + QString myLabelText; + SUPERVGUI_CanvasNodePrs* myPrs; + + bool myDestroyed; + + bool warning; + bool step; + bool trace; + bool verbose; +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx new file mode 100644 index 0000000..cda5aaf --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx @@ -0,0 +1,980 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_GanvasNodePrs.cxx +// Author : Natalia KOPNOVA +// Module : SUPERV + +using namespace std; +#include "SUPERVGUI_CanvasNodePrs.h" +#include "SUPERVGUI_CanvasNode.h" +#include "SUPERVGUI_CanvasPort.h" +#include "SUPERVGUI_Canvas.h" + +//#define CHECKTIME + +#ifdef CHECKTIME +#include +#endif + +#define PORT_MARGIN 2 +#undef PORT_HEIGHT // to avoid warning message +#define PORT_HEIGHT LABEL_HEIGHT +#define TEXT_MARGIN 5 + + +//===================================================================== +// Node presentation +//===================================================================== +SUPERVGUI_CanvasNodePrs::SUPERVGUI_CanvasNodePrs(QCanvas* theCanvas, + SUPERVGUI_CanvasNode* theNode): + QCanvasPolygonalItem(theCanvas), + myNode(theNode) +{ + Trace("SUPERVGUI_CanvasNodePrs::SUPERVGUI_CanvasNodePrs"); + myWidth = LABEL_WIDTH; + if (2*(PORT_WIDTH+PORT_MARGIN) > myWidth) + myWidth = 2*(PORT_WIDTH+PORT_MARGIN); + + myTitleHeight = LABEL_HEIGHT; + myLabelHeight = LABEL_HEIGHT; + myStatusHeight = LABEL_HEIGHT; + myPortHeight = 2*PORT_MARGIN; + myStreamHeight = 0; + myGateHeight = PORT_HEIGHT + 2*PORT_MARGIN; + + myLabelVisible = true; + myPortVisible = true; + + myColor = MAIN_BACK; + + // create in/out connection points prs + myPointIn = new SUPERVGUI_CanvasHookPrs(theCanvas, this, true); + myPointOut = new SUPERVGUI_CanvasHookPrs(theCanvas, this, false); + + setZ(0); + setState(myNode->getEngine()->State()); + updatePorts(); +} + + +SUPERVGUI_CanvasNodePrs::~SUPERVGUI_CanvasNodePrs() +{ + Trace("SUPERVGUI_CanvasNodePrs::~SUPERVGUI_CanvasNodePrs"); + if (myPointIn) delete myPointIn; + if (myPointOut) delete myPointOut; + hide(); +} + +int SUPERVGUI_CanvasNodePrs::rtti() const +{ + return SUPERVGUI_Canvas::Rtti_Node; +} + +int SUPERVGUI_CanvasNodePrs::width() const +{ + return myWidth; +} + +int SUPERVGUI_CanvasNodePrs::height() const +{ + return getTitleHeight() + getLabelHeight() + getStatusHeight() + + getBodyHeight() + getGateHeight(); +} + +int SUPERVGUI_CanvasNodePrs::getTitleHeight() const +{ + return myTitleHeight; +} + +int SUPERVGUI_CanvasNodePrs::getLabelHeight() const +{ + if (isLabelVisible()) + return myLabelHeight; + return 0; +} + +int SUPERVGUI_CanvasNodePrs::getStatusHeight() const +{ + return myStatusHeight; +} + +int SUPERVGUI_CanvasNodePrs::getBodyHeight() const +{ + if (isPortVisible()) + return myPortHeight + myStreamHeight; + return 0; +} + +int SUPERVGUI_CanvasNodePrs::getPortHeight() const +{ + if (isPortVisible()) + return myPortHeight; + return 0; +} + +int SUPERVGUI_CanvasNodePrs::getStreamHeight() const +{ + if (isPortVisible()) + return myStreamHeight; + return 0; +} + +int SUPERVGUI_CanvasNodePrs::getGateHeight() const +{ + if (isPortVisible()) + return myGateHeight; + return 0; +} + +QPointArray SUPERVGUI_CanvasNodePrs::areaPoints() const +{ + int w = width(); + int h = height()+1; + + QPointArray aPnts(4); + aPnts[0] = QPoint((int)x(), (int)y()); + aPnts[1] = aPnts[0] + QPoint(w, 0); + aPnts[2] = aPnts[1] + QPoint(0, h); + aPnts[3] = aPnts[0] + QPoint(0, h); + return aPnts; +} + +QObject* SUPERVGUI_CanvasNodePrs::getObject(const QPoint& thePos) const +{ + QObject* anObj = myNode; + + // check if it's a port + const QObjectList* list = myNode->children(); + if (list) { + QObjectListIt it(*list); + SUPERVGUI_CanvasPort* aPort; + while (QObject* obj = it.current()) { + ++it; + if (obj->inherits("SUPERVGUI_CanvasPort")) { + aPort = (SUPERVGUI_CanvasPort*) obj; + if (aPort->getPrs()->getPortRect().contains(thePos, true)) { + anObj = aPort; + break; + } + } + } + } + return anObj; +} + +void SUPERVGUI_CanvasNodePrs::moveBy(double dx, double dy) +{ + int aX = (int) (x()+dx); + int aY = (int) (y()+dy); + int xx = aX - (int)x(); + int yy = aY - (int)y(); + + int w = aX + width() + GRAPH_MARGIN; + int h = aY + height() + GRAPH_MARGIN; + if (canvas()->width() > w) w = canvas()->width(); + if (canvas()->height() > h) h = canvas()->height(); + if (canvas()->width() < w || canvas()->height() < h) + canvas()->resize(w, h); + + // save new coordinates only if node is really moving... + if (isMoving()) { + myNode->getEngine()->Coords(aX, aY); + } + + QCanvasPolygonalItem::moveBy(dx, dy); + + // update port's rectangle + const QObjectList* list = myNode->children(); + if (list) { + QObjectListIt it(*list); + SUPERVGUI_CanvasPort* aPort; + while (QObject* obj = it.current()) { + ++it; + if (obj->inherits("SUPERVGUI_CanvasPort")) { + aPort = (SUPERVGUI_CanvasPort*) obj; + aPort->moveBy(xx, yy); + } + } + } + + myPointIn->moveBy(dx, dy); + myPointOut->moveBy(dx, dy); +} + +void SUPERVGUI_CanvasNodePrs::setZ(double z) +{ + QCanvasItem::setZ(z); + + // update port's + const QObjectList* list = myNode->children(); + if (list) { + QObjectListIt it(*list); + SUPERVGUI_CanvasPort* aPort; + while (QObject* obj = it.current()) { + ++it; + if (obj->inherits("SUPERVGUI_CanvasPort")) { + aPort = (SUPERVGUI_CanvasPort*) obj; + aPort->getPrs()->setZ(z); + } + } + } +} + +void SUPERVGUI_CanvasNodePrs::hideAll() +{ + bool aDisp = isVisible(); + if (aDisp) hide(); + + setLabelVisible(false); + setPortVisible(false); + + if (aDisp) { + show(); + // canvas()->update(); + } +} + +void SUPERVGUI_CanvasNodePrs::showAll() +{ + bool aDisp = isVisible(); + if (aDisp) hide(); + + setLabelVisible(true); + setPortVisible(true); + + if (aDisp) { + show(); + // canvas()->update(); + } +} + +void SUPERVGUI_CanvasNodePrs::setLabelVisible(bool b) +{ + bool aDisp = isVisible(); + if (aDisp) hide(); + + myLabelVisible = b; + updatePorts(); + if (!isPortVisible()) updatePoints(); + + if (aDisp) { + show(); + canvas()->update(); + } +} + +void SUPERVGUI_CanvasNodePrs::setPortVisible(bool b) +{ + bool aDisp = isVisible(); + if (aDisp) hide(); + + myPortVisible = b; + if (b) { + myPointIn->hide(); + myPointOut->hide(); + + updateGates(); + } + else { + updatePoints(); + + myPointIn->show(); + myPointOut->show(); + } + + const QObjectList* list = myNode->children(); + if (list) { + QObjectListIt it(*list); + SUPERVGUI_CanvasPort* aPort; + while (QObject* obj = it.current()) { + ++it; + if (obj->inherits("SUPERVGUI_CanvasPort")) { + aPort = (SUPERVGUI_CanvasPort*) obj; + aPort->getPrs()->setVisible(b); + } + } + } + + if (aDisp) { + show(); + canvas()->update(); + } +} + +void SUPERVGUI_CanvasNodePrs::setNodeColor(const QColor& theColor) +{ + myColor = theColor; + canvas()->setChanged(getRect()); + canvas()->update(); +} + +void SUPERVGUI_CanvasNodePrs::updateInfo() +{ + canvas()->setChanged(getTitleRect()); + canvas()->setChanged(getLabelRect()); //node's comment is saved in engine (we can see it only + //with help of ChangeInformation dialog), + //node's label isn't change + canvas()->update(); +} + +void SUPERVGUI_CanvasNodePrs::updatePoints() +{ + QPoint in = getInConnectionPoint(); + myPointIn->setCoords(in.x(), in.y()); + + QPoint out = getOutConnectionPoint(); + myPointOut->setCoords(out.x(), out.y()); +} + +void SUPERVGUI_CanvasNodePrs::updatePorts() +{ + bool aDisp = isVisible(); + if (aDisp) hide(); + + QRect r = getBodyRect(); + int w = (int)(r.width()/2) - PORT_MARGIN; + if (w < PORT_WIDTH) w = PORT_WIDTH; + + int ix = r.x() + PORT_MARGIN; + int ih = r.y() + PORT_MARGIN; + int ox = ix + w; + int oh = r.y() + PORT_MARGIN; + + const QObjectList* list = myNode->children(); + if (list) { + QObjectListIt it(*list); + SUPERVGUI_CanvasPort* aPort; + while (QObject* obj = it.current()) { + ++it; + if (obj->inherits("SUPERVGUI_CanvasPort")) { + aPort = (SUPERVGUI_CanvasPort*) obj; + if (!aPort->getEngine()->IsGate() && !aPort->isStream()) { + if (aPort->getEngine()->IsInput()) { + aPort->getPrs()->setPortRect(QRect(ix, ih, w, PORT_HEIGHT)); + ih += PORT_HEIGHT; + } + else { + aPort->getPrs()->setPortRect(QRect(ox, oh, w, PORT_HEIGHT)); + oh += PORT_HEIGHT; + } + } + } + } + } + + myPortHeight = (ih>oh?ih:oh) - r.y() + PORT_MARGIN; + + // update stream ports + int sy = r.y() + myPortHeight; + ih = sy + PORT_MARGIN; + oh = sy + PORT_MARGIN; + + if (list) { + QObjectListIt it(*list); + SUPERVGUI_CanvasPort* aPort; + while (QObject* obj = it.current()) { + ++it; + if (obj->inherits("SUPERVGUI_CanvasPort")) { + aPort = (SUPERVGUI_CanvasPort*) obj; + if (!aPort->getEngine()->IsGate() && aPort->isStream()) { + if (aPort->getEngine()->IsInput()) { + aPort->getPrs()->setPortRect(QRect(ix, ih, w, PORT_HEIGHT)); + ih += PORT_HEIGHT; + } + else { + aPort->getPrs()->setPortRect(QRect(ox, oh, w, PORT_HEIGHT)); + oh += PORT_HEIGHT; + } + } + } + } + } + + myStreamHeight = (ih>oh?ih:oh) - sy + PORT_MARGIN; + if (myStreamHeight == 2*PORT_MARGIN) myStreamHeight = 0; + + // can update gates only after body height will be defined + updateGates(); + + if (aDisp) { + show(); + canvas()->update(); + } +} + +void SUPERVGUI_CanvasNodePrs::updateGates() +{ + bool aDisp = isVisible(); + if (aDisp) hide(); + + QRect r = getGateRect(); + int w = (int)(r.width()/2) - PORT_MARGIN; + if (w < PORT_WIDTH) w = PORT_WIDTH; + + int ix = r.x() + PORT_MARGIN; + int ih = r.y() + PORT_MARGIN; + int ox = ix + w; + int oh = r.y() + PORT_MARGIN; + + const QObjectList* list = myNode->children(); + if (list) { + QObjectListIt it(*list); + SUPERVGUI_CanvasPort* aPort; + while (QObject* obj = it.current()) { + ++it; + if (obj->inherits("SUPERVGUI_CanvasPort")) { + aPort = (SUPERVGUI_CanvasPort*) obj; + if (aPort->getEngine()->IsGate()) { + if (aPort->getEngine()->IsInput()) { + aPort->getPrs()->setPortRect(QRect(ix, ih, w, PORT_HEIGHT)); + ih += PORT_HEIGHT; + } + else { + aPort->getPrs()->setPortRect(QRect(ox, oh, w, PORT_HEIGHT)); + oh += PORT_HEIGHT; + } + } + } + } + } + + myGateHeight = (ih>oh?ih:oh) - r.y() + PORT_MARGIN; + + if (aDisp) show(); +} + +QRect SUPERVGUI_CanvasNodePrs::getRect() const +{ + return QRect((int)x(), (int)y(), width(), height()); +} + +QRect SUPERVGUI_CanvasNodePrs::getTitleRect() const +{ + return QRect((int)x(), (int)y(), width(), getTitleHeight()); +} + +QRect SUPERVGUI_CanvasNodePrs::getLabelRect() const +{ + return QRect((int)x(), ((int)y())+getTitleHeight(), width(), getLabelHeight()); +} + +QRect SUPERVGUI_CanvasNodePrs::getStatusRect() const +{ + return QRect((int)x(), ((int)y())+getTitleHeight()+getLabelHeight(), + width(), getStatusHeight()); +} + +QRect SUPERVGUI_CanvasNodePrs::getBodyRect() const +{ + return QRect((int)x(), ((int)y())+getTitleHeight()+getLabelHeight()+getStatusHeight(), + width(), getBodyHeight()); +} + +QRect SUPERVGUI_CanvasNodePrs::getGateRect() const +{ + return QRect((int)x(), ((int)y())+getTitleHeight()+getLabelHeight()+ + getStatusHeight()+getBodyHeight(), + width(), getGateHeight()); +} + +QPoint SUPERVGUI_CanvasNodePrs::getInConnectionPoint() const +{ + QRect r = getGateRect(); + int h; + if (isPortVisible()) { + h = (int)((r.top()+r.bottom())/2); + } + else { + h = (int)(y()+height()/2); + } + return QPoint(r.left()-POINT_SIZE, h); +} + +QPoint SUPERVGUI_CanvasNodePrs::getOutConnectionPoint() const +{ + QRect r = getGateRect(); + int h; + if (isPortVisible()) { + h = (int)((r.top()+r.bottom())/2); + } + else { + h = (int)y() + (int)(height()/2); + } + return QPoint(r.right()+POINT_SIZE, h); +} + +void drawText(QPainter& thePainter, const QString& theText, + const QRect& theRect, int theHAlign = Qt::AlignAuto) +{ + int flags = theHAlign | Qt::AlignVCenter; + QRect r(theRect.x() + TEXT_MARGIN, theRect.y(), + theRect.width() - 2*TEXT_MARGIN, theRect.height()); + thePainter.drawText(r, flags, theText); +} + +void SUPERVGUI_CanvasNodePrs::draw(QPainter& thePainter) +{ + thePainter.setPen(pen()); + thePainter.setBrush(nodeColor()); + drawShape(thePainter); +} + +void SUPERVGUI_CanvasNodePrs::drawShape(QPainter& thePainter) +{ + drawTitle(thePainter); + if (isLabelVisible()) { + drawLabel(thePainter); + } + if (isPortVisible()) { + drawPort(thePainter); + drawGate(thePainter); + } + drawStatus(thePainter); + drawFrame(thePainter); +} + +void SUPERVGUI_CanvasNodePrs::drawFrame(QPainter& thePainter) +{ + /* it was a good idea, but... + drawed polyline is out of item boundaries :-( + QPointArray pnts = areaPoints(); + int n = pnts.size(); + pnts.resize(n+1); + pnts[n] = pnts[0]; + thePainter.drawPolyline(pnts); + */ + + QBrush saved = thePainter.brush(); + thePainter.setBrush(NoBrush); + thePainter.drawRect(getRect()); + thePainter.setBrush(saved); +} + +void SUPERVGUI_CanvasNodePrs::drawTitle(QPainter& thePainter) +{ + QBrush saved = thePainter.brush(); + QBrush br(MAIN_TITLE); + thePainter.setBrush(br); + drawTitleShape(thePainter); + thePainter.setBrush(saved); + + drawText(thePainter, myNode->getEngine()->Name(), getTitleRect(), Qt::AlignHCenter); +} + +void SUPERVGUI_CanvasNodePrs::drawTitleShape(QPainter& thePainter) +{ + thePainter.drawRect(getTitleRect()); +} + +void SUPERVGUI_CanvasNodePrs::drawLabel(QPainter& thePainter) +{ + QRect r = getLabelRect(); + + QPen saved = thePainter.pen(); + thePainter.setPen(NoPen); + thePainter.drawRect(r); + thePainter.setPen(saved); + + // drawText(thePainter, myNode->getEngine()->Comment(), r); + drawText(thePainter, myNode->getLabelText(), r); +} + +void SUPERVGUI_CanvasNodePrs::drawStatus(QPainter& thePainter) +{ + QRect r = getStatusRect(); + if (isPortVisible()) + r.setHeight(r.height()+1); + + QBrush savedB = thePainter.brush(); + thePainter.setBrush(myStatusColor); + drawStatusShape(thePainter); + thePainter.setBrush(savedB); + + QRect r1(r.x(), r.y(), (int)r.width()/2, r.height()); + drawText(thePainter, myStatus, r1, Qt::AlignHCenter); + + QRect r2(r.x()+r.width()-r1.width(), r.y(), r1.width(), r.height()); + drawText(thePainter, myTime, r2, Qt::AlignHCenter); +} + +void SUPERVGUI_CanvasNodePrs::drawStatusShape(QPainter& thePainter) +{ + QRect r = getStatusRect(); + if (isPortVisible()) + r.setHeight(r.height()+1); + thePainter.drawRect(r); +} + +void SUPERVGUI_CanvasNodePrs::drawPort(QPainter& thePainter) +{ + QRect r = getBodyRect(); + r.setHeight(r.height()+1); + + thePainter.drawRect(r); + int x0 = (r.left() + r.right())/2; + thePainter.drawLine(x0, r.top(), x0, r.bottom()); + if (getStreamHeight() > 0) { + int y0 = r.top() + getPortHeight(); + thePainter.drawLine(r.left(), y0, r.right(), y0); + } + + const QObjectList* list = myNode->children(); + if (list) { + QObjectListIt it(*list); + SUPERVGUI_CanvasPort* aPort; + while (QObject* obj = it.current()) { + ++it; + if (obj->inherits("SUPERVGUI_CanvasPort")) { + aPort = (SUPERVGUI_CanvasPort*) obj; + if (!aPort->getEngine()->IsGate()) { + aPort->getPrs()->draw(thePainter); + } + } + } + } +} + +void SUPERVGUI_CanvasNodePrs::drawGate(QPainter& thePainter) +{ + QBrush saved = thePainter.brush(); + thePainter.setBrush(green.light(170)); + + QRect r = getGateRect(); + // r.setHeight(r.height()+1); + thePainter.drawRect(r); + int x0 = (r.left() + r.right())/2; + // thePainter.drawLine(x0, r.top(), x0, r.bottom()); + + const QObjectList* list = myNode->children(); + if (list) { + QObjectListIt it(*list); + SUPERVGUI_CanvasPort* aPort; + while (QObject* obj = it.current()) { + ++it; + if (obj->inherits("SUPERVGUI_CanvasPort")) { + aPort = (SUPERVGUI_CanvasPort*) obj; + if (aPort->getEngine()->IsGate()) { + aPort->getPrs()->draw(thePainter); + } + } + } + } + + thePainter.setBrush(saved); +} + +void SUPERVGUI_CanvasNodePrs::setState(SUPERV::GraphState theState) +{ + switch(theState) { + case SUPERV_Waiting: + myStatus = "Waiting"; + myStatusColor = QColor(35, 192, 255); + break; + + case SUPERV_Running: + case SUPERV::ReadyState: + myStatus = "Running"; + myStatusColor = QColor(32,210,32); + break; + + case SUPERV_Suspend: + case SUPERV::SuspendReadyState: + myStatus = "Suspended"; + myStatusColor = QColor(255,180, 0); + break; + + case SUPERV_Done: + myStatus = "Finished"; + myStatusColor = QColor(255, 158, 255); + break; + + case SUPERV_Error: + myStatus = "Aborted"; + myStatusColor = red; + break; + + case SUPERV_Kill: + myStatus = "Killed"; + myStatusColor = red; + break; + + default: + myStatus = "No Status"; + myStatusColor = MAIN_BACK; + break; + } + + long sec = myNode->getEngine()->CpuUsed(); + char hms[9]; + long 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 = QString(hms); + + canvas()->setChanged(getStatusRect()); + canvas()->update(); +} + + +//===================================================================== +// Port presentation +//===================================================================== +SUPERVGUI_CanvasPortPrs::SUPERVGUI_CanvasPortPrs(QCanvas* theCanvas, + SUPERVGUI_CanvasPort* thePort): + myCanvas(theCanvas), myPort(thePort) +{ + myText = getText(); + myVisible = true; + myPoint = new SUPERVGUI_CanvasHookPrs(theCanvas, this, myPort->getEngine()->IsInput()); +} + +SUPERVGUI_CanvasPortPrs::~SUPERVGUI_CanvasPortPrs() +{ + if (myPoint) delete myPoint; +} + +void SUPERVGUI_CanvasPortPrs::setVisible(bool b) +{ + if (myPoint) myPoint->setVisible(b); + myVisible = b; + myPort->updateLinks(); +} + +void SUPERVGUI_CanvasPortPrs::setPortRect(const QRect& theRect) +{ + myRect = theRect; + QPoint aPnt = getConnectionPoint(); +// int dx = 0; +// if (myPort->getEngine()->IsInput()) +// dx = POINT_SIZE; +// else +// dx = - POINT_SIZE; +// QPoint aPnt2(aPnt.x()+dx, aPnt.y()); + +// if (myLine) { +// myLine->move(0, 0); +// myLine->setPoints(aPnt2.x(), aPnt2.y(), aPnt.x(), aPnt.y()); +// if (myVisible) myLine->show(); +// } + if (myPoint) { + myPoint->setCoords(aPnt.x(), aPnt.y()); + // myPoint->move(aPnt.x(), aPnt.y()); + if (myVisible) myPoint->show(); + } + myPort->updateLinks(); +} + +void SUPERVGUI_CanvasPortPrs::moveBy(int dx, int dy) +{ + myRect.moveBy(dx, dy); + if (myPoint) myPoint->moveBy(dx, dy); + // if (myLine) myLine->moveBy(dx, dy); +} + +void SUPERVGUI_CanvasPortPrs::setZ(double z) +{ + if (myPoint) myPoint->setZ(z); + // if (myLine) myLine->setZ(z); +} + +void SUPERVGUI_CanvasPortPrs::update(bool theForce) +{ + QString aNewText = getText(); + if (theForce || myText.compare(aNewText) != 0) { + myText = aNewText; + myCanvas->setChanged(myRect); + } +} + +bool SUPERVGUI_CanvasPortPrs::isHilight() const +{ + SUPERV_Port aPort = myPort->getEngine(); + bool b = false; + if (!aPort->IsGate()) { + if (aPort->IsInput()) { + if (aPort->HasInput() && !aPort->IsLinked()) + b = true; + } + else if (myPort->inherits("SUPERVGUI_CanvasPortOut")) { + SUPERVGUI_CanvasPortOut* aPortOut = (SUPERVGUI_CanvasPortOut*) myPort; + if (aPortOut->isInStudy()) + b = true; + } + } + return b; +} + +bool SUPERVGUI_CanvasPortPrs::isAlert() const +{ + bool b = false; + SUPERV_Port aPort = myPort->getEngine(); + if (!aPort->IsGate()) { + if (aPort->IsInput() && !aPort->HasInput() && !aPort->IsLinked()) + b = true; + } + return b; +} + +QString SUPERVGUI_CanvasPortPrs::getText() const +{ + SUPERV_Port aPort = myPort->getEngine(); + QString aText = aPort->Name(); + if (aPort->IsParam() || aPort->IsInLine() || myPort->isStream()) + aText = aText + "=" + aPort->ToString(); + return aText; +} + +int SUPERVGUI_CanvasPortPrs::getAlignment() const +{ + int a = Qt::AlignAuto; + SUPERV_Port aPort = myPort->getEngine(); + /* Merge to Ecole_Ete + if (QString(aPort->Name()).compare(OUTVOID) == 0) + a = Qt::AlignRight; + */ + if (aPort->IsGate()) { + if (aPort->IsInput()) + a = Qt::AlignLeft; + else + a = Qt::AlignRight; + } + return a; +} + +QPoint SUPERVGUI_CanvasPortPrs::getConnectionPoint() const +{ + int x, y; + if (myPort->getEngine()->IsInput()) + x = myRect.left() - PORT_MARGIN - POINT_SIZE; + else + x = myRect.right() + PORT_MARGIN + POINT_SIZE; + y = (int)(myRect.top() + myRect.bottom())/2; + return QPoint(x, y); +} + +void SUPERVGUI_CanvasPortPrs::draw(QPainter& thePainter) +{ + /* + QPen savedP = thePainter.pen(); + QBrush savedB = thePainter.brush(); + + QPen aPen(savedP.color(), getLineWidth()); + thePainter.setPen(aPen); + thePainter.setBrush(Qt::NoBrush); + thePainter.drawRect(myRect); + thePainter.setPen(savedP); + thePainter.setBrush(savedB); + */ + QFont saved = thePainter.font(); + QFont f(saved); + f.setBold(isHilight()); + thePainter.setFont(f); + + QPen savedP = thePainter.pen(); + if (myPort->isStream()) + thePainter.setPen(QColor(128, 64, 0));// Qt::darkCyan); + else if (isHilight()) + thePainter.setPen(Qt::blue); + else if (isAlert()) + thePainter.setPen(Qt::red.dark(120)); + + drawText(thePainter, myText, myRect, getAlignment()); + + thePainter.setPen(savedP); + thePainter.setFont(saved); +} + + +//===================================================================== +// Node presentation +//===================================================================== +SUPERVGUI_CanvasHookPrs::SUPERVGUI_CanvasHookPrs(QCanvas* theCanvas, + SUPERVGUI_CanvasNodePrs* theNode, + const bool& theIn): + QCanvasEllipse(POINT_SIZE, POINT_SIZE, theCanvas), + myNodePrs(theNode), myPortPrs(0), myIn(theIn), myLine(0) +{ + init(theCanvas); +} + +SUPERVGUI_CanvasHookPrs::SUPERVGUI_CanvasHookPrs(QCanvas* theCanvas, + SUPERVGUI_CanvasPortPrs* thePort, + const bool& theIn): + QCanvasEllipse(POINT_SIZE, POINT_SIZE, theCanvas), + myNodePrs(0), myPortPrs(thePort), myIn(theIn), myLine(0) +{ + init(theCanvas); +} + +void SUPERVGUI_CanvasHookPrs::init(QCanvas* theCanvas) +{ + myLine = new QCanvasLine(theCanvas); + + setBrush(Qt::black); + myLine->setPen(QPen(Qt::black, 1)); + + setZ(0); +} + +SUPERVGUI_CanvasHookPrs::~SUPERVGUI_CanvasHookPrs() +{ + hide(); + if (myLine) { + delete myLine; + myLine = 0; + } +} + +QObject* SUPERVGUI_CanvasHookPrs::getObject() const +{ + QObject* anObj = 0; + if (myNodePrs) + anObj = myNodePrs->getNode(); + else if (myPortPrs) + anObj = myPortPrs->getPort(); + return anObj; +} + +void SUPERVGUI_CanvasHookPrs::setCoords(int x, int y) +{ + move(x, y); + if (myLine) { + myLine->move(0, 0); + myLine->setPoints(x+(myIn?POINT_SIZE:-POINT_SIZE), y, x, y); + } +} + +void SUPERVGUI_CanvasHookPrs::setVisible(bool b) +{ + QCanvasEllipse::setVisible(b); + if (myLine) myLine->setVisible(b); +} + +void SUPERVGUI_CanvasHookPrs::moveBy(double dx, double dy) +{ + QCanvasEllipse::moveBy(dx, dy); + if (myLine) myLine->moveBy(dx, dy); +} + +void SUPERVGUI_CanvasHookPrs::setZ(double z) +{ + QCanvasEllipse::setZ(z); + if (myLine) myLine->setZ(z); +} + +int SUPERVGUI_CanvasHookPrs::rtti() const +{ + return SUPERVGUI_Canvas::Rtti_Hook; +} diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.h b/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.h new file mode 100644 index 0000000..de23786 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.h @@ -0,0 +1,184 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_CanvasNodePrs.h +// Author : Natalia KOPNOVA +// Module : SUPERV + +#ifndef SUPERVGUI_CanvasNodePrs_H +#define SUPERVGUI_CanvasNodePrs_H + +using namespace std; +#include "SUPERVGUI_Def.h" + +#include + + +class SUPERVGUI_CanvasNodePrs; +class SUPERVGUI_CanvasPortPrs; +class SUPERVGUI_CanvasHookPrs : public QCanvasEllipse +{ + public: + SUPERVGUI_CanvasHookPrs(QCanvas* theCanvas, SUPERVGUI_CanvasNodePrs* theNode, const bool& theIn); + SUPERVGUI_CanvasHookPrs(QCanvas* theCanvas, SUPERVGUI_CanvasPortPrs* thePort, const bool& theIn); + ~SUPERVGUI_CanvasHookPrs(); + + QObject* getObject() const; + + void setCoords(int x, int y); + + void setVisible(bool b); + void moveBy(double dx, double dy); + void setZ(double z); + + virtual int rtti() const; + + private: + void init(QCanvas* theCanvas); + + SUPERVGUI_CanvasNodePrs* myNodePrs; + SUPERVGUI_CanvasPortPrs* myPortPrs; + + bool myIn; + + QCanvasLine* myLine; +}; + + +class SUPERVGUI_CanvasNode; +class SUPERVGUI_CanvasNodePrs: public QCanvasPolygonalItem { + + public: + SUPERVGUI_CanvasNodePrs(QCanvas* theCanvas, SUPERVGUI_CanvasNode* theNode); + virtual ~SUPERVGUI_CanvasNodePrs(); + + SUPERVGUI_CanvasNode* getNode() const { return myNode; } + QObject* getObject(const QPoint& thePos) const; + + virtual int width() const; + virtual int height() const; + + virtual int getTitleHeight() const; + virtual int getLabelHeight() const; + virtual int getStatusHeight() const; + virtual int getBodyHeight() const; + virtual int getPortHeight() const; + virtual int getStreamHeight() const; + virtual int getGateHeight() const; + + QPointArray areaPoints() const; + void moveBy(double dx, double dy); + void setZ(double z); + + void setMoving(bool b) { myMoving = b; } + bool isMoving() const { return myMoving; } + + virtual int rtti() const; + + virtual void hideAll(); + virtual void showAll(); + virtual void setLabelVisible(bool b); + virtual void setPortVisible(bool b); + bool isLabelVisible() const { return myLabelVisible; } + bool isPortVisible() const { return myPortVisible; } + + virtual void setNodeColor(const QColor& theColor); + virtual QColor nodeColor() const { return myColor; } + + virtual void setState(SUPERV::GraphState theState); + virtual void updateInfo(); + virtual void updatePorts(); + virtual void updateGates(); + virtual void updatePoints(); + + virtual QPoint getInConnectionPoint() const; + virtual QPoint getOutConnectionPoint() const; + + virtual QRect getRect() const; + virtual QRect getTitleRect() const; + virtual QRect getStatusRect() const; + virtual QRect getLabelRect() const; + virtual QRect getBodyRect() const; + virtual QRect getGateRect() const; + + protected: + void draw(QPainter& thePainter); + void drawShape(QPainter& thePainter); + + virtual void drawTitle(QPainter& thePainter); + virtual void drawLabel(QPainter& thePainter); + virtual void drawPort(QPainter& thePainter); + virtual void drawGate(QPainter& thePainter); + virtual void drawStatus(QPainter& thePainter); + + virtual void drawFrame(QPainter& thePainter); + virtual void drawTitleShape(QPainter& thePainter); + virtual void drawStatusShape(QPainter& thePainter); + + private: + SUPERVGUI_CanvasNode* myNode; + + int myWidth; + + int myTitleHeight; + int myLabelHeight; + int myStatusHeight; + int myPortHeight; + int myStreamHeight; + int myGateHeight; + + bool myLabelVisible; + bool myPortVisible; + bool myMoving; + + QString myStatus; + QString myTime; + + QColor myColor; + QColor myStatusColor; + + SUPERVGUI_CanvasHookPrs* myPointIn; + SUPERVGUI_CanvasHookPrs* myPointOut; +}; + + +class SUPERVGUI_CanvasPort; +class SUPERVGUI_CanvasPortPrs { + + public: + SUPERVGUI_CanvasPortPrs(QCanvas* theCanvas, SUPERVGUI_CanvasPort* thePort); + ~SUPERVGUI_CanvasPortPrs(); + + SUPERVGUI_CanvasPort* getPort() { return myPort; } + virtual void update(bool theForce = false); + + virtual bool isHilight() const; + virtual bool isAlert() const; + + virtual QString getText() const; + virtual int getAlignment() const; + + void setPortRect(const QRect& theRect); + QRect getPortRect() const { return myRect; } + + void setVisible(bool b); + bool isVisible() const { return myVisible; } + + void moveBy(int dx, int dy); + void setZ(double z); + + QPoint getConnectionPoint() const; + void draw(QPainter& thePainter); + + private: + SUPERVGUI_CanvasPort* myPort; + QCanvas* myCanvas; + QRect myRect; + QString myText; + + SUPERVGUI_CanvasHookPrs* myPoint; + bool myVisible; +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx new file mode 100644 index 0000000..db186c3 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx @@ -0,0 +1,324 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_CanvasPort.cxx +// Author : Natalia KOPNOVA +// Module : SUPERV + +using namespace std; +#include "SUPERVGUI_CanvasPort.h" +#include "SUPERVGUI_CanvasNode.h" +#include "SUPERVGUI_CanvasLink.h" +#include "SUPERVGUI_CanvasNodePrs.h" +#include "SUPERVGUI_Main.h" +#include "SUPERVGUI.h" +#include "SUPERVGUI_BrowseNodeDlg.h" + + +SUPERVGUI_CanvasPort::SUPERVGUI_CanvasPort(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::Port_ptr thePort): + QObject(theParent), + myMain(theMain), + myPrs(0), + isIgnore(false) +{ + Trace("SUPERVGUI_CanvasPort::SUPERVGUI_CanvasPort"); + myPort = SUPERV::Port::_duplicate(thePort); + + // setName(myPort->Name()); + setName(myMain->getCanvas()->getPortName(thePort)); +} + +SUPERVGUI_CanvasPort::~SUPERVGUI_CanvasPort() +{ + Trace("SUPERVGUI_CanvasPort::~SUPERVGUI_CanvasPort"); + if (myPrs) delete myPrs; + + isIgnore = true; + QValueList::Iterator it; + for (it = myLinks.begin(); it != myLinks.end(); ++it) { + delete *it; + } +} + +SUPERVGUI_CanvasPortPrs* SUPERVGUI_CanvasPort::getPrs() const +{ + if (myPrs == 0) ((SUPERVGUI_CanvasPort*)this)->myPrs = createPrs(); + return myPrs; +} + +SUPERVGUI_CanvasPortPrs* SUPERVGUI_CanvasPort::createPrs() const +{ + return new SUPERVGUI_CanvasPortPrs(myMain->getCanvas(), (SUPERVGUI_CanvasPort*)this); +} + +QPopupMenu* SUPERVGUI_CanvasPort::getPopupMenu(QWidget* theParent) +{ + QPopupMenu* popup = new QPopupMenu(theParent); + if (myMain->isEditable()) { + int anItem = popup->insertItem(tr("MSG_SKETCH_LINK"), this, SLOT(sketchLink())); + if (myMain->getDataflow()->IsExecuting()) + popup->setItemEnabled(anItem, false); + else + popup->setItemEnabled(anItem, !myPort->IsInput() || !myPort->IsLinked() + || myPort->Kind() == SUPERV::EndSwitchParameter); + popup->insertSeparator(); + } + if ((myPort->IsEndSwitch() && myPort->IsInput()) || + (myPort->IsInLine() && myPort->Node()->Kind() != SUPERV::EndLoopNode + && !(myPort->Node()->Kind() == SUPERV::LoopNode && !myPort->IsInput()))) { + popup->insertItem(tr("ITM_DEL_PORT"), this, SLOT(remove())); + } + + int anItem = popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse())); +// if (getEngine()->IsLinked()) +// popup->setItemEnabled(anItem, getEngine()->State() == SUPERV_Ready); +// else +// popup->setItemEnabled(anItem, getEngine()->HasInput()); + + return popup; +} + +QPoint SUPERVGUI_CanvasPort::getConnectionPoint() const +{ + QPoint p = getPrs()->getConnectionPoint(); + + if (!getPrs()->isVisible()) { + if (parent() && parent()->inherits("SUPERVGUI_CanvasNode")) { + SUPERVGUI_CanvasNodePrs* aNode = ((SUPERVGUI_CanvasNode*) parent())->getPrs(); + if (myPort->IsInput()) + p = aNode->getInConnectionPoint(); + else + p = aNode->getOutConnectionPoint(); + } + } + return p; +} + +void SUPERVGUI_CanvasPort::update() +{ + // ignore update if node itself is destroyed (critical for Start/End control nodes) + if (!((SUPERVGUI_CanvasNode*) parent())->isDestroyed()) + getPrs()->update(true); +} + +void SUPERVGUI_CanvasPort::sync() +{ + getPrs()->update(); +} + +void SUPERVGUI_CanvasPort::sketchLink() +{ + myMain->getCanvasView()->startSketch(this); +} + +void SUPERVGUI_CanvasPort::remove() { + Trace("SUPERVGUI_CanvasPort::remove"); + myPort->destroy(); + delete this; +} + +void SUPERVGUI_CanvasPort::moveBy(int dx, int dy) +{ + getPrs()->moveBy(dx, dy); + + QValueList::Iterator it; + for (it = myLinks.begin(); it != myLinks.end(); ++it) { + (*it)->moveByPort(this, dx, dy); + } +} + +void SUPERVGUI_CanvasPort::addLink(SUPERVGUI_CanvasLink* theLink) +{ + myLinks.append(theLink); + update(); +} + +void SUPERVGUI_CanvasPort::removeLink(SUPERVGUI_CanvasLink* theLink) +{ + if (!isIgnore) { + myLinks.remove(theLink); + update(); + } +} + +void SUPERVGUI_CanvasPort::updateLinks() +{ + QValueList::Iterator it; + for (it = myLinks.begin(); it != myLinks.end(); ++it) { + (*it)->moveByPort(this); + } +} + +void SUPERVGUI_CanvasPort::browse() +{ + QString aMes(getEngine()->IsInput()? tr("MSG_IPORT_VAL") : tr("MSG_OPORT_VAL")); + aMes += getEngine()->ToString(); + QMessageBox::information(QAD_Application::getDesktop(), tr("MSG_INFO"), aMes); +} + + +//*********************************************************** +// Input Port +//*********************************************************** +SUPERVGUI_CanvasPortIn::SUPERVGUI_CanvasPortIn(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::Port_ptr thePort): + SUPERVGUI_CanvasPort(theParent, theMain, thePort) +{ + Trace("SUPERVGUI_CanvasPortIn::SUPERVGUI_CanvasPortIn"); + myDlg = 0; +} + +SUPERVGUI_CanvasPortIn::~SUPERVGUI_CanvasPortIn() +{ + Trace("SUPERVGUI_CanvasPortIn::~SUPERVGUI_CanvasPortIn"); +} + +QPopupMenu* SUPERVGUI_CanvasPortIn::getPopupMenu(QWidget* theParent) +{ + QPopupMenu* popup = SUPERVGUI_CanvasPort::getPopupMenu(theParent); + bool editable = getEngine()->IsInput() && (!getEngine()->IsLinked()); + + if (!getEngine()->IsGate() && editable) + popup->insertItem(tr("MSG_SETVALUE"), this, SLOT(setInput())); + + return popup; +} + +void SUPERVGUI_CanvasPortIn::setValue(const char* theValue) +{ + if (getEngine()->Input(Supervision.getEngine()->StringValue(theValue))) + update(); // sync(); + else + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_SETVAL")); +} + +void SUPERVGUI_CanvasPortIn::setInput() +{ + if (!myDlg) { + myDlg = new SUPERVGUI_GetValueDlg(this); + myDlg->installEventFilter(this); + } + if (!myDlg->isVisible()) + myDlg->show(); + else { + myDlg->raise(); + myDlg->setActiveWindow(); + myDlg->setFocus(); + } + +} + +bool SUPERVGUI_CanvasPortIn::eventFilter(QObject* o, QEvent* e) +{ + if (o == myDlg && e->type() == QEvent::Close) + myDlg = 0; + return SUPERVGUI_CanvasPort::eventFilter(o, e); +} + + +//*********************************************************** +// Output Port +//*********************************************************** +SUPERVGUI_CanvasPortOut::SUPERVGUI_CanvasPortOut(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::Port_ptr thePort): + SUPERVGUI_CanvasPort(theParent, theMain, thePort) +{ + Trace("SUPERVGUI_CanvasPortOut::SUPERVGUI_CanvasPortOut"); + myInStudy = false; +} + +SUPERVGUI_CanvasPortOut::~SUPERVGUI_CanvasPortOut() +{ + Trace("SUPERVGUI_CanvasPortOut::~SUPERVGUI_CanvasPortOut"); +} + +QPopupMenu* SUPERVGUI_CanvasPortOut::getPopupMenu(QWidget* theParent) +{ + QPopupMenu* popup = SUPERVGUI_CanvasPort::getPopupMenu(theParent); + + if (!getEngine()->IsGate()) { + popup->insertItem(myInStudy?tr("MSG_NOT_INSTUDY"):tr("MSG_PUT_INSTUDY"), + this, SLOT(toStudy())); + } + + return popup; +} + +void SUPERVGUI_CanvasPortOut::sync() +{ + bool ok = getEngine()->State() == SUPERV_Ready; + if (ok && myInStudy) { + myInStudy = getMain()->putDataStudy(getEngine(), STUDY_PORT_OUT); + } + SUPERVGUI_CanvasPort::update(); +} + +void SUPERVGUI_CanvasPortOut::toStudy() +{ + Trace("SUPERVGUI_CanvasPortOut::toStudy"); + + if (getMain()->getStudy()->getStudyDocument()->GetProperties()->IsLocked()) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("WRN_WARNING"), + tr("WRN_STUDY_LOCKED")); + return; + } + + if (!getMain()->isFromStudy()) { + if (getMain()->addStudy()) + getMain()->setAsFromStudy(true); + } + myInStudy = !myInStudy; + sync(); + getMain()->getCanvas()->update(); +} + + + +//*********************************************************** +// Stream Input Port +//*********************************************************** +SUPERVGUI_CanvasStreamPortIn::SUPERVGUI_CanvasStreamPortIn(QObject* theParent, SUPERVGUI_Main* theMain, + SUPERV::StreamPort_ptr thePort): + SUPERVGUI_CanvasPortIn(theParent, theMain, thePort) +{ + myStreamPort = SUPERV::StreamPort::_duplicate(thePort); +} + +QPopupMenu* SUPERVGUI_CanvasStreamPortIn::getPopupMenu(QWidget* theParent) +{ + QPopupMenu* popup = SUPERVGUI_CanvasPortIn::getPopupMenu(theParent); + popup->insertItem(tr("MSG_STREAM_PARAM"),this, SLOT(setParams())); + return popup; +} + +void SUPERVGUI_CanvasStreamPortIn::setParams() +{ + SUPERVGUI_StreamInDlg* aDlg = new SUPERVGUI_StreamInDlg(this); + aDlg->exec(); + delete aDlg; +} + + +//*********************************************************** +// Stream Output Port +//*********************************************************** +SUPERVGUI_CanvasStreamPortOut::SUPERVGUI_CanvasStreamPortOut(QObject* theParent, SUPERVGUI_Main* theMain, + SUPERV::StreamPort_ptr thePort): + SUPERVGUI_CanvasPortOut(theParent, theMain, thePort) +{ + myStreamPort = SUPERV::StreamPort::_duplicate(thePort); +} + + +QPopupMenu* SUPERVGUI_CanvasStreamPortOut::getPopupMenu(QWidget* theParent) +{ + QPopupMenu* popup = SUPERVGUI_CanvasPortOut::getPopupMenu(theParent); + popup->insertItem(tr("MSG_STREAM_PARAM"),this, SLOT(setParams())); + return popup; +} + +void SUPERVGUI_CanvasStreamPortOut::setParams() +{ + SUPERVGUI_StreamOutDlg* aDlg = new SUPERVGUI_StreamOutDlg(this); + aDlg->exec(); + delete aDlg; +} diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasPort.h b/src/SUPERVGUI/SUPERVGUI_CanvasPort.h new file mode 100644 index 0000000..c7f81a4 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_CanvasPort.h @@ -0,0 +1,142 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_CanvasPort.h +// Author : Natalia KOPNOVA +// Module : SUPERV + +#ifndef SUPERVGUI_CanvasPort_H +#define SUPERVGUI_CanvasPort_H + +using namespace std; +#include "SUPERVGUI_Def.h" + + +class SUPERVGUI_Main; +class SUPERVGUI_CanvasLink; +class SUPERVGUI_CanvasPortPrs; + +class SUPERVGUI_CanvasPort : public QObject { + Q_OBJECT + + public: + SUPERVGUI_CanvasPort(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::Port_ptr thePort); + virtual ~SUPERVGUI_CanvasPort(); + + virtual void update(); + virtual void sync(); + + virtual bool isStream() const { return false; } + + SUPERV_Port getEngine() const { return myPort; } + SUPERVGUI_Main* getMain() const { return myMain; } + SUPERVGUI_CanvasPortPrs* getPrs() const; + + virtual QPopupMenu* getPopupMenu(QWidget* theParent); + + virtual QPoint getConnectionPoint() const; + + void moveBy(int dx, int dy); + void addLink(SUPERVGUI_CanvasLink* theLink); + void removeLink(SUPERVGUI_CanvasLink* theLink); + void updateLinks(); + + public slots: + void sketchLink(); + virtual void remove(); + void browse(); + + protected: + virtual SUPERVGUI_CanvasPortPrs* createPrs() const; + + private: + SUPERV_Port myPort; + SUPERVGUI_Main* myMain; + + SUPERVGUI_CanvasPortPrs* myPrs; + QValueList myLinks; + bool isIgnore; +}; + +class SUPERVGUI_GetValueDlg; +class SUPERVGUI_CanvasPortIn : public SUPERVGUI_CanvasPort { + Q_OBJECT + + public: + SUPERVGUI_CanvasPortIn(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::Port_ptr thePort); + virtual ~SUPERVGUI_CanvasPortIn(); + + void setValue(const char* theValue); + + virtual QPopupMenu* getPopupMenu(QWidget* theParent); + + public slots: + void setInput(); + + protected: + bool eventFilter(QObject* o, QEvent* e); + + private: + SUPERVGUI_GetValueDlg* myDlg; +}; + +class SUPERVGUI_CanvasPortOut : public SUPERVGUI_CanvasPort { + Q_OBJECT + + public: + SUPERVGUI_CanvasPortOut(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::Port_ptr thePort); + virtual ~SUPERVGUI_CanvasPortOut(); + + void sync(); + bool isInStudy() const { return myInStudy; } + void setStudyState(bool theInStudy) { myInStudy = theInStudy; } + + virtual QPopupMenu* getPopupMenu(QWidget* theParent); + + public slots: + void toStudy(); + + private: + bool myInStudy; +}; + +class SUPERVGUI_CanvasStreamPortIn : public SUPERVGUI_CanvasPortIn { + Q_OBJECT + + public: + SUPERVGUI_CanvasStreamPortIn(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::StreamPort_ptr thePort); + virtual ~SUPERVGUI_CanvasStreamPortIn() {} + + virtual bool isStream() const { return true; } + SUPERV_StreamPort getStreamEngine() const { return myStreamPort; } + + virtual QPopupMenu* getPopupMenu(QWidget* theParent); + + public slots: + void setParams(); + + private: + SUPERV_StreamPort myStreamPort; +}; + +class SUPERVGUI_CanvasStreamPortOut : public SUPERVGUI_CanvasPortOut { + Q_OBJECT + + public: + SUPERVGUI_CanvasStreamPortOut(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::StreamPort_ptr thePort); + virtual ~SUPERVGUI_CanvasStreamPortOut() {} + + virtual bool isStream() const { return true; } + SUPERV_StreamPort getStreamEngine() const { return myStreamPort; } + + virtual QPopupMenu* getPopupMenu(QWidget* theParent); + + public slots: + void setParams(); + + private: + SUPERV_StreamPort myStreamPort; +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx new file mode 100644 index 0000000..2f6f04e --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx @@ -0,0 +1,599 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : SUPERVGUI_CanvasView.cxx +// Author : Natalia KOPNOVA +// Module : SUPERV + +using namespace std; +#include "SUPERVGUI_CanvasView.h" +#include "SUPERVGUI_Main.h" +#include "SUPERVGUI_CanvasNode.h" +#include "SUPERVGUI_CanvasPort.h" +#include "SUPERVGUI_CanvasLink.h" +#include "SUPERVGUI_CanvasNodePrs.h" +#include "QAD_Config.h" + +#include +#include + +#define MARGIN 2 + + +/* XPM */ +const char* imageZoomCursor[] = { +"32 32 3 1", +". c None", +"a c #000000", +"# c #ffffff", +"................................", +"................................", +".#######........................", +"..aaaaaaa.......................", +"................................", +".............#####..............", +"...........##.aaaa##............", +"..........#.aa.....a#...........", +".........#.a.........#..........", +".........#a..........#a.........", +"........#.a...........#.........", +"........#a............#a........", +"........#a............#a........", +"........#a............#a........", +"........#a............#a........", +".........#...........#.a........", +".........#a..........#a.........", +".........##.........#.a.........", +"........#####.....##.a..........", +".......###aaa#####.aa...........", +"......###aa...aaaaa.......#.....", +".....###aa................#a....", +"....###aa.................#a....", +"...###aa...............#######..", +"....#aa.................aa#aaaa.", +".....a....................#a....", +"..........................#a....", +"...........................a....", +"................................", +"................................", +"................................", +"................................"}; + +QPixmap zoomPix(imageZoomCursor); +QCursor zoom2Cursor(zoomPix); + +#if QT_VERSION >= 0x030005 +QCursor pan2Cursor(Qt::SizeAllCursor); +#else +QCursor pan2Cursor(SizeAllCursor); +#endif + +SUPERVGUI_CanvasView::SUPERVGUI_CanvasView(SUPERVGUI_Canvas* theCanvas, SUPERVGUI_Main* theMain): + QCanvasView(theCanvas, theMain), + myMain(theMain), myCurrentItem(0), myHilighted(0), myLinkBuilder(0) +{ + setName("CanvasView"); + + myIsPanActivated = false; + myIsZoomActivated = false; + myIsLinkCreating = false; + + myAddStudyItem = 0; + myCursor = cursor(); + + myTimer = new QTimer(this); + connect(myTimer, SIGNAL(timeout()), this, SLOT(onTimeout())); + + myPopup = new QPopupMenu(viewport()); + + if (myMain->isEditable()) { + myPopup->insertItem(tr("MSG_ADD_NODE"), myMain, SLOT(addNode())); + myPopup->insertItem(tr("MSG_INS_FILE"), myMain, SLOT(insertFile())); + myPopup->insertSeparator(); + } + + QPopupMenu* aViewPopup = new QPopupMenu(viewport()); + // aViewPopup->insertItem(tr("POP_FULLVIEW"), myMain, SLOT(showFullGraph())); + aViewPopup->insertItem(tr("POP_FULLVIEW"), myMain, SLOT(showCanvas())); + aViewPopup->insertItem(tr("POP_CONTROLVIEW"), myMain, SLOT(showContolFlow())); + aViewPopup->insertItem(tr("POP_TABLEVIEW"), myMain, SLOT(showTable())); + // aViewPopup->insertItem("Previous Full View", myMain, SLOT(showFullGraph())); + // aViewPopup->insertItem(tr("POP_CANVASVIEW"), myMain, SLOT(showCanvas())); + + myPopup->insertItem(tr("POP_VIEW"), aViewPopup); + myPopup->insertSeparator(); + + QPopupMenu* aZoomPopup = new QPopupMenu(viewport()); + aZoomPopup->insertItem("200%", this, SLOT(zoomIn())); + aZoomPopup->insertItem("100%", this, SLOT(zoomReset())); + aZoomPopup->insertItem("50%", this, SLOT(zoomOut())); + aZoomPopup->insertSeparator(); + aZoomPopup->insertItem("Fit All", this, SLOT(fitAll())); + + myPopup->insertItem("Zoom", aZoomPopup); + myPopup->insertSeparator(); + + myAddStudyItem = myPopup->insertItem(tr("MSG_ADD_STUDY"), this, SLOT(addToStudy())); + myPopup->insertItem(tr("MSG_CHANGE_INFO"), myMain, SLOT(changeInformation())); + myPopup->insertSeparator(); + + myPopup->insertItem(tr("MSG_COPY_DATAFLOW"), myMain, SLOT(copy())); + myPopup->insertItem(tr("MSG_FILTER_NOTIFY"), myMain, SLOT(filterNotification())); + + myPopup->insertSeparator(); + myPopup->insertItem(tr("MSG_CHANGE_BACKGROUND"), this, SLOT(changeBackground())); + + viewport()->setMouseTracking(true); + + //create sketching popup menu + mySketchPopup = new QPopupMenu(viewport()); + mySketchPopup->setCheckable(true); + myDelPntItem = mySketchPopup->insertItem(tr("MSG_DEL_LAST_PNT"), this, SLOT(deletePoint())); + mySketchPopup->insertItem(tr("MSG_DEL_LINK"), this, SLOT(cancelSketch())); + myOrtoItem = mySketchPopup->insertItem(tr("MSG_ORTHO_LINE"), this, SLOT(setOrthoMode())); +} + + +SUPERVGUI_CanvasView::~SUPERVGUI_CanvasView() +{ +} + +void SUPERVGUI_CanvasView::contentsMousePressEvent(QMouseEvent* theEvent) +{ + // cout << "===> SUPERVGUI_CanvasView::contentsMousePressEvent(...) " << endl; + myPoint = inverseWorldMatrix().map(theEvent->pos()); + myGlobalPoint = theEvent->globalPos(); + myCurrentItem = 0; + + // compute collision rectangle + QRect aSel(myPoint.x()-MARGIN, myPoint.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN); + + if (((theEvent->button() == Qt::MidButton) && + (theEvent->state() == Qt::ControlButton)) || + myIsPanActivated) { + myIsPanActivated = true; + myCursor = cursor(); + setCursor(pan2Cursor); + return; + } + + if (((theEvent->button() == Qt::LeftButton) && + (theEvent->state() == Qt::ControlButton)) || + myIsZoomActivated) { + myIsZoomActivated = true; + myCursor = cursor(); + setCursor(zoom2Cursor); + return; + } + + if ( theEvent->button() == Qt::RightButton) { + if (myIsLinkCreating) { + myMain->showPopup(mySketchPopup, theEvent); + return; + } + + QCanvasItemList l = canvas()->collisions(aSel); + for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) { + if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) { + SUPERVGUI_CanvasNodePrs* aNodePrs = (SUPERVGUI_CanvasNodePrs*) (*it); + QObject* anObj = aNodePrs->getObject(myPoint); + if (anObj->inherits("SUPERVGUI_CanvasNode")) { + myMain->showPopup(((SUPERVGUI_CanvasNode*)anObj)->getPopupMenu(viewport()), + theEvent); + return; + } + else if (anObj->inherits("SUPERVGUI_CanvasPort")) { + myMain->showPopup(((SUPERVGUI_CanvasPort*)anObj)->getPopupMenu(viewport()), + theEvent); + return; + } + } + if (myMain->isEditable() && !myMain->getCanvas()->isControlView()) { + if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) { + SUPERVGUI_CanvasPointPrs* aPrs = (SUPERVGUI_CanvasPointPrs*) (*it); + aPrs->getLink()->setSelectedObject(aPrs, myPoint); + myMain->showPopup(aPrs->getLink()->getPopupMenu(viewport()), theEvent); + return; + } + if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge) { + SUPERVGUI_CanvasEdgePrs* aPrs = (SUPERVGUI_CanvasEdgePrs*) (*it); + aPrs->getLink()->setSelectedObject(aPrs, myPoint); + myMain->showPopup(aPrs->getLink()->getPopupMenu(viewport()), theEvent); + return; + } + } + } + + myPopup->setItemEnabled(myAddStudyItem, !myMain->isFromStudy()); + myMain->showPopup(myPopup, theEvent); + return; + } + + if (theEvent->button() == Qt::LeftButton) { + QCanvasItemList l = canvas()->collisions(myPoint); + if (myIsLinkCreating) { + for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) { + if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) { + SUPERVGUI_CanvasNodePrs* aNodePrs = (SUPERVGUI_CanvasNodePrs*) (*it); + QObject* anObj = aNodePrs->getObject(myPoint); + if (anObj->inherits("SUPERVGUI_CanvasPort")) { + endSketch((SUPERVGUI_CanvasPort*)anObj); + return; + } + else { + myCurrentItem = *it; + ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setZ(2); + ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setMoving(true); + return; + } + } + if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Hook) { + SUPERVGUI_CanvasHookPrs* aHookPrs = (SUPERVGUI_CanvasHookPrs*) (*it); + QObject* anObj = aHookPrs->getObject(); + if (anObj->inherits("SUPERVGUI_CanvasPort")) { + endSketch((SUPERVGUI_CanvasPort*)anObj); + return; + } + } + } + if (myLinkBuilder) { + myLinkBuilder->addNextPoint(myPoint, mySketchPopup->isItemChecked(myOrtoItem)); + canvas()->update(); + mySketchPopup->setItemEnabled(myDelPntItem, true); + return; + } + } + +// if (myMain->isEditable()) { // allow to move nodes and link point on imported graph + for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) { + if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) { + myCurrentItem = *it; + ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setZ(2); + ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setMoving(true); + return; + } + if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) { + SUPERVGUI_CanvasPointPrs* aPrs = (SUPERVGUI_CanvasPointPrs*) (*it); + if (aPrs->getIndex() > 0) { + myCurrentItem = *it; + aPrs->setMoving(true); + return; + } + } + } +// } + } +} + +bool busy = false; + +void SUPERVGUI_CanvasView::contentsMouseMoveEvent(QMouseEvent* theEvent) +{ + if (busy) return; + + busy = true; + QPoint p = inverseWorldMatrix().map(theEvent->pos()); + QPoint g = theEvent->globalPos(); + + if (myTimer->isActive()) myTimer->stop(); + + if (myIsLinkCreating && myLinkBuilder) { + myLinkBuilder->setFloatPoint(p); + canvas()->update(); + } + + if (myCurrentItem) { + // setHilighted(0); + double cx = myCurrentItem->x() - myPoint.x(); + double cy = myCurrentItem->y() - myPoint.y(); + if (p.x()+cx < 0) p.setX(-(int)cx); + if (p.y()+cy < 0) p.setY(-(int)cy); + myCurrentItem->moveBy(p.x() - myPoint.x(), + p.y() - myPoint.y()); + myPoint = p; + canvas()->update(); + + // scroll contents if mouse is outside + QRect r(contentsX(), contentsY(), visibleWidth(), visibleHeight()); + if (!r.contains(theEvent->pos())) { + int dx = 0, dy = 0; + if (theEvent->pos().x() < r.left()) dx = theEvent->pos().x() - r.left(); + if (theEvent->pos().x() > r.right()) dx = theEvent->pos().x() - r.right(); + if (theEvent->pos().y() < r.top()) dy = theEvent->pos().y() - r.top(); + if (theEvent->pos().y() > r.bottom()) dy = theEvent->pos().y() - r.bottom(); + scrollBy(dx, dy); + // start timer to scroll in silent mode + myDX = dx; myDY = dy; + myTimer->start(100); + } + busy = false; + return; + } + + if (myIsPanActivated) { + setHilighted(0); + scrollBy(myGlobalPoint.x() - g.x(), + myGlobalPoint.y() - g.y()); + myGlobalPoint = g; + busy = false; + return; + } + + if (myIsZoomActivated) { + setHilighted(0); + double dx = g.x() - myGlobalPoint.x(); + double s = 1. + fabs(dx)/10.; + if (dx < 0) s = 1./s; + + QWMatrix m = worldMatrix(); + m.scale(s, s); + setWorldMatrix(m); + + myGlobalPoint = g; + busy = false; + return; + } + + if (!myIsLinkCreating && myMain->isEditable() && + !myMain->getCanvas()->isControlView()) { + // compute collision rectangle + QRect aSel(p.x()-MARGIN, p.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN); + QCanvasItemList l = canvas()->collisions(aSel); + for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) { + if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) { + SUPERVGUI_CanvasPointPrs* aPrs = (SUPERVGUI_CanvasPointPrs*) (*it); + setHilighted(aPrs->getLink()); + busy = false; + return; + } + if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge) { + SUPERVGUI_CanvasEdgePrs* aPrs = (SUPERVGUI_CanvasEdgePrs*) (*it); + setHilighted(aPrs->getLink()); + busy = false; + return; + } + } + setHilighted(0); + } + + busy = false; +} + +void SUPERVGUI_CanvasView::contentsMouseReleaseEvent(QMouseEvent* theEvent) +{ + // cout << "===> SUPERVGUI_CanvasView::contentsMouseReleaseEvent(...) " << endl; + if (myTimer->isActive()) myTimer->stop(); + + if (myCurrentItem) { + if (myCurrentItem->rtti() == SUPERVGUI_Canvas::Rtti_Node) { + ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setZ(0); + ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setMoving(false); + canvas()->update(); + } + if (myCurrentItem->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) { + ((SUPERVGUI_CanvasPointPrs*)myCurrentItem)->setMoving(false); + } + } + myCurrentItem = 0; + + if (myIsPanActivated) { + myIsPanActivated = false; + setCursor(myCursor); + } + + if (myIsZoomActivated) { + myIsZoomActivated = false; + setCursor(myCursor); + } +} + +void SUPERVGUI_CanvasView::contentsMouseDoubleClickEvent(QMouseEvent* theEvent) +{ + // cout << "===> SUPERVGUI_CanvasView::contentsMouseDoubleClickEvent(...) " << endl; + QPoint p = inverseWorldMatrix().map(theEvent->pos()); + + // compute collision rectangle + QRect aSel(p.x()-MARGIN, p.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN); + + if (theEvent->button() == Qt::LeftButton) { + QCanvasItemList l = canvas()->collisions(p); + for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) { + if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) { + SUPERVGUI_CanvasNodePrs* aNodePrs = (SUPERVGUI_CanvasNodePrs*) (*it); + SUPERVGUI_CanvasNode* aNode = aNodePrs->getNode(); + if (aNode->getEngine()->IsMacro() && !myIsLinkCreating) { + myMain->openSubGraph(aNode->getEngine(), true); + return; + } + } + } + } +} + +void SUPERVGUI_CanvasView::onDestroyed(QObject* theObject) +{ + if (theObject == myHilighted) + myHilighted = 0; +} + +void SUPERVGUI_CanvasView::setHilighted(SUPERVGUI_CanvasLink* theLink) +{ + if (theLink == myHilighted) return; + if (myHilighted) { + disconnect(myHilighted, SIGNAL(destroyed(QObject*)), this, SLOT(onDestroyed(QObject*))); + myHilighted->setHilighted(false); + myHilighted = 0; + } + if (theLink) { + myHilighted = theLink; + myHilighted->setHilighted(true); + connect(myHilighted, SIGNAL(destroyed(QObject*)), this, SLOT(onDestroyed(QObject*))); + } +} + +void SUPERVGUI_CanvasView::onTimeout() +{ + if (myCurrentItem) { + scrollBy(myDX, myDY); + + double cx, cy; + inverseWorldMatrix().map((double)myDX, (double)myDY, &cx, &cy); + if (myCurrentItem->x()+cx < 0) cx = -myCurrentItem->x(); + if (myCurrentItem->y()+cy < 0) cy = -myCurrentItem->y(); + myCurrentItem->moveBy(cx, cy); + myPoint.setX(myPoint.x()+(int)cx); + myPoint.setY(myPoint.y()+(int)cy); + canvas()->update(); + } +} + +void SUPERVGUI_CanvasView::changeBackground() +{ + QColor aColor = QColorDialog::getColor(canvas()->backgroundColor(), this ); + if ( aColor.isValid() ) { + canvas()->setBackgroundColor(aColor); + setPaletteBackgroundColor(aColor.light(120)); + } +} + +void SUPERVGUI_CanvasView::ActivatePanning() +{ + myIsPanActivated = true; +} + +void SUPERVGUI_CanvasView::ResetView() +{ + setContentsPos(0,0); + QWMatrix m; + setWorldMatrix(m); +} + +void SUPERVGUI_CanvasView::startSketch(SUPERVGUI_CanvasPort* thePort) +{ + if (myIsLinkCreating) return; + + myIsLinkCreating = true; + myLinkBuilder = new SUPERVGUI_CanvasLinkBuilder(canvas(), myMain, thePort); + mySketchPopup->setItemEnabled(myDelPntItem, false); +} + +void SUPERVGUI_CanvasView::endSketch(SUPERVGUI_CanvasPort* thePort) +{ + // cout << "===> SUPERVGUI_CanvasView::endSketch(" << thePort->name() << ")" << endl; + if (!myIsLinkCreating) return; + + if (myLinkBuilder && myLinkBuilder->canCreateEngine(thePort)) { + bool input = thePort->getEngine()->IsInput(); + SUPERV_Link aLinkEngine; + if (thePort->getEngine()->Kind() == SUPERV::DataStreamParameter) { + SUPERVGUI_CanvasStreamPortIn* aInPort = (SUPERVGUI_CanvasStreamPortIn*) + (input ? thePort : myLinkBuilder->getStartPort()); + SUPERVGUI_CanvasStreamPortOut* aOutPort = (SUPERVGUI_CanvasStreamPortOut*) + (input ? myLinkBuilder->getStartPort() : thePort); +// aLinkEngine = myMain->getDataflow()->StreamLink(aOutPort->getStreamEngine(), +// aInPort->getStreamEngine()); + if (myMain->getDataflow()->IsStreamGraph()) { + SUPERV_StreamGraph aSGraph = myMain->getDataflow()->ToStreamGraph(); + if (!SUPERV_isNull(aSGraph)) + aLinkEngine = aSGraph->StreamLink(aOutPort->getStreamEngine(), + aInPort->getStreamEngine()); + } + } + else { + SUPERVGUI_CanvasPort* aInPort = (input ? thePort : myLinkBuilder->getStartPort()); + SUPERVGUI_CanvasPort* aOutPort = (input ? myLinkBuilder->getStartPort() : thePort); + aLinkEngine = myMain->getDataflow()->Link(aOutPort->getEngine(), aInPort->getEngine()); + } + if (SUPERV_isNull(aLinkEngine)) return; + + myLinkBuilder->setCoords(aLinkEngine.in()); + + delete myLinkBuilder; + myLinkBuilder = 0; + + SUPERVGUI_CanvasLink* aLink = new SUPERVGUI_CanvasLink(canvas(), myMain, aLinkEngine); + aLink->show(); + + canvas()->update(); + myIsLinkCreating = false; + } +} + +void SUPERVGUI_CanvasView::cancelSketch() +{ + if (myLinkBuilder) { + delete myLinkBuilder; + myLinkBuilder = 0; + canvas()->update(); + } + myIsLinkCreating = false; +} + +void SUPERVGUI_CanvasView::deletePoint() +{ + if (myIsLinkCreating && myLinkBuilder) { + myLinkBuilder->removeLastPoint(); + canvas()->update(); + mySketchPopup->setItemEnabled(myDelPntItem, myLinkBuilder->getPointCount()); + } +} + +void SUPERVGUI_CanvasView::setOrthoMode() +{ + bool aIsOrtho = !mySketchPopup->isItemChecked(myOrtoItem); + mySketchPopup->setItemChecked(myOrtoItem, aIsOrtho); +} + + +void SUPERVGUI_CanvasView::addToStudy() +{ + if (myMain->addStudy()) myMain->setAsFromStudy(true); +} + +void SUPERVGUI_CanvasView::zoomIn() +{ + QWMatrix m; + m.scale(2.0, 2.0); + setWorldMatrix(m); + canvas()->update(); +} + +void SUPERVGUI_CanvasView::zoomReset() +{ + QWMatrix m; + m.scale(1.0, 1.0); + setWorldMatrix(m); + canvas()->update(); +} + +void SUPERVGUI_CanvasView::zoomOut() +{ + QWMatrix m; + m.scale(0.5, 0.5); + setWorldMatrix(m); + canvas()->update(); +} + +void SUPERVGUI_CanvasView::fitAll() +{ + int w = 0, h = 0; + QCanvasItemList l = canvas()->allItems(); + for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) { + QRect r = (*it)->boundingRect(); + if (w < r.right()) w = r.right(); + if (h < r.bottom()) h = r.bottom(); + } + w += GRAPH_MARGIN; h += GRAPH_MARGIN; + double s = ((double)visibleWidth())/((double)w); + double s1 = ((double)visibleHeight())/((double)h); + if (s > s1) s = s1; + + setContentsPos(0,0); + QWMatrix m; + m.scale(s, s); + setWorldMatrix(m); + canvas()->update(); +} diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasView.h b/src/SUPERVGUI/SUPERVGUI_CanvasView.h new file mode 100644 index 0000000..7e19640 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_CanvasView.h @@ -0,0 +1,90 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_CanvasView.h +// Author : Natalia KOPNOVA +// Module : SUPERV + +#ifndef SUPERVGUI_CanvasView_H +#define SUPERVGUI_CanvasView_H + +#include "SUPERVGUI_Canvas.h" +#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_CanvasLink; +class SUPERVGUI_CanvasLinkBuilder; + +class SUPERVGUI_CanvasView: public QCanvasView { + Q_OBJECT + + public: + SUPERVGUI_CanvasView(SUPERVGUI_Canvas* theCanvas, SUPERVGUI_Main* theMain); + virtual ~SUPERVGUI_CanvasView(); + + SUPERVGUI_Main* getMain() const { return myMain; } + + void ActivatePanning(); + void ResetView(); + + bool isAnyLinkCreating() const { return myIsLinkCreating; } + void startSketch(SUPERVGUI_CanvasPort* thePort); + + public slots: + void addToStudy(); + void onTimeout(); + void zoomIn(); + void zoomOut(); + void zoomReset(); + void fitAll(); + void changeBackground(); + + protected: + void contentsMouseMoveEvent(QMouseEvent* theEvent); + void contentsMouseReleaseEvent(QMouseEvent* theEvent); + void contentsMousePressEvent(QMouseEvent* theEvent); + void contentsMouseDoubleClickEvent(QMouseEvent* theEvent); + + private slots: + void onDestroyed(QObject* theObject); + // new link creation + void cancelSketch(); + void deletePoint(); + void setOrthoMode(); + + private: + void setHilighted(SUPERVGUI_CanvasLink* theLink); + void endSketch(SUPERVGUI_CanvasPort* thePort); + + SUPERVGUI_Main* myMain; + QPopupMenu* myPopup; + int myAddStudyItem; + QPopupMenu* mySketchPopup; + int myDelPntItem; + int myOrtoItem; + + bool myIsPanActivated; + bool myIsZoomActivated; + bool myIsLinkCreating; + + QCanvasItem* myCurrentItem; + QPoint myPoint; + QCursor myCursor; + + QTimer* myTimer; + QPoint myGlobalPoint; + int myDX; + int myDY; + + SUPERVGUI_CanvasLink* myHilighted; + SUPERVGUI_CanvasLinkBuilder* myLinkBuilder; +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_Def.h b/src/SUPERVGUI/SUPERVGUI_Def.h index 8a8c906..dac075d 100644 --- a/src/SUPERVGUI/SUPERVGUI_Def.h +++ b/src/SUPERVGUI/SUPERVGUI_Def.h @@ -36,6 +36,8 @@ #define GRAPH_WIDTH 3500 #define GRAPH_HEIGHT 3500 +#define GRAPH_MARGIN 50 + #define GRAPH_MAX 245e5 // Taille du dataflow sous forme de tableau @@ -95,7 +97,7 @@ NODE_Editing "", NODE_RED, NODE_GREEN, NODE_BLUE, true, false, true // ---------------------------- #define LABEL_WIDTH 160 -#define LABEL_HEIGHT 15 +#define LABEL_HEIGHT 20 // Taille de la boite de filtre de notification // -------------------------------------------- @@ -174,7 +176,9 @@ NODE_Editing "", NODE_RED, NODE_GREEN, NODE_BLUE, true, false, true #define SUPERV_Engine SUPERV::SuperG_var -#define SUPERV_Graph SUPERV::StreamGraph_var +//#define SUPERV_Graph SUPERV::StreamGraph_var +#define SUPERV_Graph SUPERV::Graph_var +#define SUPERV_StreamGraph SUPERV::StreamGraph_var #define SUPERV_CNode SUPERV::CNode_var #define SUPERV_FNode SUPERV::FNode_var @@ -186,6 +190,7 @@ NODE_Editing "", NODE_RED, NODE_GREEN, NODE_BLUE, true, false, true #define SUPERV_ESNode SUPERV::ESNode_var #define SUPERV_Links SUPERV::ListOfLinks_var +#define SUPERV_StreamLinks SUPERV::ListOfStreamLinks_var #define SUPERV_Ports SUPERV::ListOfPorts_var #define SUPERV_StreamPorts SUPERV::ListOfStreamPorts_var #define SUPERV_Nodes SUPERV::ListOfNodes_var @@ -195,6 +200,7 @@ NODE_Editing "", NODE_RED, NODE_GREEN, NODE_BLUE, true, false, true #define SUPERV_Date SUPERV::SDate #define SUPERV_Port SUPERV::Port_var #define SUPERV_StreamPort SUPERV::StreamPort_var +#define SUPERV_StreamLink SUPERV::StreamLink_var #define SUPERV_Editing SUPERV::EditingState #define SUPERV_Running SUPERV::RunningState @@ -212,7 +218,7 @@ NODE_Editing "", NODE_RED, NODE_GREEN, NODE_BLUE, true, false, true #define SUPERV_isNull(oc) (CORBA::is_nil(oc)) -enum GraphViewType { GRAPH, CONTROLFLOW, TABLE }; +enum GraphViewType { GRAPH, CONTROLFLOW, TABLE, CANVAS }; //enum NodeType { COMPUTE, SWITCH, LOOP, GOTO, LABEL }; diff --git a/src/SUPERVGUI/SUPERVGUI_Graph.cxx b/src/SUPERVGUI/SUPERVGUI_Graph.cxx index d1feb17..afcddc3 100644 --- a/src/SUPERVGUI/SUPERVGUI_Graph.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Graph.cxx @@ -37,7 +37,6 @@ using namespace std; #include #include #include -#include //#define CHECKTIME @@ -234,7 +233,7 @@ void SUPERVGUI_Graph::draw() { struct timeb aTm2; ftime(&aTm2); ulong aTm = 1000*(aTm2.time-aTm1.time)+(aTm2.millitm-aTm1.millitm); - cout<<"### Time="<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 ); - - // DeltaTime - QLabel* DeltaTimeL = new QLabel( tr( "DELTATIME_LBL" ), TopGroup ); - TopGroupLayout->addWidget( DeltaTimeL, 0, 0 ); - - myDeltaTime = new QAD_SpinBoxDbl( TopGroup, 0.0, 1.0, 0.1); - myDeltaTime->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - TopGroupLayout->addWidget( myDeltaTime, 0, 1 ); - - // TimeOut - QLabel* TimeOutL = new QLabel( tr( "TIMEOUT_LBL" ), TopGroup); - TopGroupLayout->addWidget( TimeOutL, 1, 0 ); - - myTimeOut = new QLineEdit( TopGroup ); - myTimeOut->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myTimeOut->setValidator( new QIntValidator(this) ); - myTimeOut->setMinimumSize( 100, 0 ); - myTimeOut->setReadOnly( isReadOnly ); - TopGroupLayout->addWidget( myTimeOut, 1, 1 ); - - // DataStreamTrace - QLabel* DataStreamTraceL = new QLabel( tr( "DATASTREAMTRACE_LBL" ), TopGroup); - TopGroupLayout->addWidget( DataStreamTraceL, 2, 0 ); - - myDataStreamTrace = new QComboBox( TopGroup ); - myDataStreamTrace->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myDataStreamTrace->insertItem("WithoutTrace"); - myDataStreamTrace->insertItem("SummaryTrace"); - myDataStreamTrace->insertItem("DetailedTrace"); - TopGroupLayout->addWidget( myDataStreamTrace, 2, 1 ); - - 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( accept() ) ); - connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) ); - - setData(); -} - -/*! - Destructor -*/ -SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters() { - Trace("SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters"); -} - -/*! - Sets data function -*/ -void SUPERVGUI_DSGraphParameters::setData() { - double aDeltaTime; - long aTimeOut; - SUPERV::KindOfDataStreamTrace aDataStreamTrace; - - myGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime); - - myDeltaTime->setValue(aDeltaTime); - myTimeOut->setText(QString("%1").arg(aTimeOut)); - myDataStreamTrace->setCurrentItem((int)aDataStreamTrace); -} - -/*! - button slot -*/ -void SUPERVGUI_DSGraphParameters::accept() { - myGraph->SetStreamParams( myTimeOut->text().toLong(), - (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(), - myDeltaTime->value()); - QDialog::accept(); -} diff --git a/src/SUPERVGUI/SUPERVGUI_Graph.h b/src/SUPERVGUI/SUPERVGUI_Graph.h index a3e6dce..1efe20c 100644 --- a/src/SUPERVGUI/SUPERVGUI_Graph.h +++ b/src/SUPERVGUI/SUPERVGUI_Graph.h @@ -120,26 +120,4 @@ private slots: QMap myCtrlLinks; }; -//************************************************************** -class SUPERVGUI_DSGraphParameters: public QDialog { - Q_OBJECT - - public: - SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly); - virtual ~SUPERVGUI_DSGraphParameters(); - - private slots: - void accept(); - - private: - - void setData(); - - QAD_SpinBoxDbl* myDeltaTime; - QLineEdit* myTimeOut; - QComboBox* myDataStreamTrace; - - SUPERV_Graph myGraph; -}; - #endif diff --git a/src/SUPERVGUI/SUPERVGUI_Link.cxx b/src/SUPERVGUI/SUPERVGUI_Link.cxx index 80158db..adaa31d 100644 --- a/src/SUPERVGUI/SUPERVGUI_Link.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Link.cxx @@ -461,8 +461,10 @@ bool SUPERVGUI_Link::createEngine() { if (myStartPort->getPort()->Kind() == SUPERV::DataStreamParameter) { SUPERVGUI_StreamPortOut* aOut = dynamic_cast(myPortOut); SUPERVGUI_StreamPortIn* aIn = dynamic_cast(myPortIn); - myEngine = myGraph->getMain()->getDataflow()-> - StreamLink(aOut->getStreamPort(), aIn->getStreamPort()); + // myEngine = myGraph->getMain()->getDataflow()->StreamLink(aOut->getStreamPort(), aIn->getStreamPort()); + SUPERV_StreamGraph aSGraph = myGraph->getMain()->getDataflow()->ToStreamGraph(); + if (!SUPERV_isNull(aSGraph)) + myEngine = aSGraph->StreamLink(aOut->getStreamPort(), aIn->getStreamPort()); } else myEngine = myGraph->getMain()->getDataflow()-> Link(myPortOut->getPort(), myPortIn->getPort()); diff --git a/src/SUPERVGUI/SUPERVGUI_Link.h b/src/SUPERVGUI/SUPERVGUI_Link.h index cfa22dc..06d5ee2 100644 --- a/src/SUPERVGUI/SUPERVGUI_Link.h +++ b/src/SUPERVGUI/SUPERVGUI_Link.h @@ -15,7 +15,8 @@ using namespace std; #include "SUPERVGUI_Def.h" #include "SUPERVGUI_Port.h" -#include +//_CS_PhB BUG QT erreur de compilation #include +#include class SUPERVGUI_Graph; @@ -118,7 +119,9 @@ private: SUPERV_Link myEngine; QPoint myPrevPoint; // used for sketching only - QValueVector myTmpPoints; + //_CS_PhB BUG QT erreur de compilation QValueVector myTmpPoints; + vector myTmpPoints; + SUPERVGUI_Port* myStartPort; QPen myTmpPen; diff --git a/src/SUPERVGUI/SUPERVGUI_Main.cxx b/src/SUPERVGUI/SUPERVGUI_Main.cxx index 6dc5b61..ce4f2e2 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Main.cxx @@ -48,7 +48,8 @@ using namespace std; #include "SUPERVGUI_Notification.h" #include "SALOMEGUI_ImportOperation.h" #include "SUPERVGUI_Information.h" - +#include "SUPERVGUI_CanvasControlNode.h" +#include SUPERVGUI_Main::SUPERVGUI_Main(SUPERVGraph_ViewFrame* theParent, QAD_Desktop* theDesktop, bool fromIOR) : SUPERVGraph_View(theParent), @@ -162,8 +163,10 @@ void SUPERVGUI_Main::init(QAD_Desktop* theDesktop) { myIsKilled = false; //myIsRunned = false; - myCurrentView = GRAPH; + myCurrentView = CANVAS; + // myCurrentView = GRAPH; myIsFromStudy = false; + myLastGraph = 0; study = theDesktop->getActiveStudy(); SALOMEDS::Study_var studyDoc = study->getStudyDocument(); @@ -196,7 +199,11 @@ void SUPERVGUI_Main::init(QAD_Desktop* theDesktop) { graph = new SUPERVGUI_Graph(this); + graph->hide(); array = new SUPERVGUI_Array(this); + + myCanvas = new SUPERVGUI_Canvas(this); + myCanvasView = new SUPERVGUI_CanvasView(myCanvas, this); message = study->getActiveStudyFrame()->getRightFrame()->getMessage(); notification = new NOTIFICATION_Consumer(); @@ -206,7 +213,11 @@ void SUPERVGUI_Main::init(QAD_Desktop* theDesktop) { layout->setSpacing(0); layout->addWidget(graph); layout->addWidget(array); + layout->addWidget(myCanvasView); + if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) { + myCanvas->merge(); + } sync(); show(); if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) { @@ -219,12 +230,32 @@ void SUPERVGUI_Main::init(QAD_Desktop* theDesktop) { } SUPERVGUI_Main::~SUPERVGUI_Main() { +//cout << "===> SUPERVGUI_Main::~SUPERVGUI_Main() " << endl; Trace("SUPERVGUI_Main::~SUPERVGUI_Main"); + + // close all opened SubGraphs + QMap::iterator it; + for (it = mySubGraphs.begin(); it != mySubGraphs.end(); ++it) { + it.data()->removeEventFilter(this); + it.data()->close(); + } + mySubGraphs.clear(); + mySubGraphMap.clear(); + /* + QAD_StudyFrame* aSubGraph; + for (aSubGraph = mySubGraphs.first(); aSubGraph; aSubGraph = mySubGraphs.next()) { + aSubGraph->removeEventFilter(this); + aSubGraph->close(); + } + */ + 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 + delete myCanvas; + // delete notification; // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit + notification->_remove_ref(); // 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(), @@ -300,27 +331,31 @@ void SUPERVGUI_Main::syncAsync() { * Called by thread when dataflow is executing */ void SUPERVGUI_Main::execute(char * theNodeName, SUPERV::GraphState theNodeState) { - - SUPERVGUI_Node* aNodePrs; - SUPERVGUI_GraphNode* aGraphNodePrs; - if (myCurrentView == TABLE) { - aNodePrs = (SUPERVGUI_Node*) array->child(theNodeName, "SUPERVGUI_Node"); - aGraphNodePrs = (SUPERVGUI_GraphNode*) array->child(theNodeName, "SUPERVGUI_GraphNode"); - } else { - aNodePrs = (SUPERVGUI_Node*) graph->child(theNodeName, "SUPERVGUI_Node"); - aGraphNodePrs = (SUPERVGUI_GraphNode*) graph->child(theNodeName, "SUPERVGUI_GraphNode"); - } - if (aGraphNodePrs) { - aGraphNodePrs->sync(); + if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) { + SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*) myCanvas->child(theNodeName, "SUPERVGUI_CanvasNode"); + if (aNode) aNode->sync(); } - else if (aNodePrs) { - //aNodePrs->sync(); - aNodePrs->syncOnEvent(theNodeState); + else { + SUPERVGUI_Node* aNodePrs; + SUPERVGUI_GraphNode* aGraphNodePrs; + if (myCurrentView == TABLE) { + aNodePrs = (SUPERVGUI_Node*) array->child(theNodeName, "SUPERVGUI_Node"); + aGraphNodePrs = (SUPERVGUI_GraphNode*) array->child(theNodeName, "SUPERVGUI_GraphNode"); + } else { + aNodePrs = (SUPERVGUI_Node*) graph->child(theNodeName, "SUPERVGUI_Node"); + aGraphNodePrs = (SUPERVGUI_GraphNode*) graph->child(theNodeName, "SUPERVGUI_GraphNode"); + } + if (aGraphNodePrs) { + aGraphNodePrs->sync(); + } + else if (aNodePrs) { + //aNodePrs->sync(); + aNodePrs->syncOnEvent(theNodeState); + } } } - void SUPERVGUI_Main::sync() { Trace("SUPERVGUI_Main::sync") if ((SUPERV_isNull(dataflow))) return; @@ -331,9 +366,12 @@ void SUPERVGUI_Main::sync() { study->updateObjBrowser(); if (myCurrentView == TABLE) { - array->sync(); + array->sync(); + } else if (myCurrentView == GRAPH) { + graph->sync(); } else { - graph->sync(); + myCanvas->sync(); + myCanvas->update(); } } @@ -342,8 +380,11 @@ void SUPERVGUI_Main::showTable() { if (myCurrentView == TABLE) return; if (array->create()) { + if (myCurrentView == GRAPH) + graph->hide(); + else + myCanvasView->hide(); myCurrentView = TABLE; - graph->hide(); } sync(); } @@ -354,6 +395,10 @@ void SUPERVGUI_Main::showFullGraph() { array->destroy(); graph->show(); } + else if (myCurrentView != GRAPH) { // (myCurrentView == CANVAS) { + myCanvasView->hide(); + graph->show(); + } myCurrentView = GRAPH; graph->sync(); graph->setFullView(); @@ -361,13 +406,41 @@ void SUPERVGUI_Main::showFullGraph() { void SUPERVGUI_Main::showContolFlow() { + bool merge = false; if (myCurrentView == TABLE) { array->destroy(); - graph->show(); + merge = true; + } + else if (myCurrentView == GRAPH) { + graph->hide(); + merge = true; } myCurrentView = CONTROLFLOW; - graph->sync(); - graph->setControlView(); + myCanvas->setControlView(); + if (merge) { + myCanvas->merge(); + myCanvasView->show(); + } +} + +void SUPERVGUI_Main::showCanvas() { + if (myCurrentView == CANVAS) return; + + bool merge = false; + if (myCurrentView == TABLE) { + array->destroy(); + merge = true; + } + else if (myCurrentView == GRAPH) { + graph->hide(); + merge = true; + } + myCurrentView = CANVAS; + myCanvas->setFullView(); + if (merge) { + myCanvas->merge(); + myCanvasView->show(); + } } @@ -399,6 +472,9 @@ void SUPERVGUI_Main::insertFile() { array->destroy(); array->create(); } + else if (myCurrentView != GRAPH) { // (myCurrentView == CANVAS) { + myCanvas->merge(); + } sync(); } else { QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f)); @@ -416,7 +492,18 @@ void SUPERVGUI_Main::copy() { SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast (aStudyFrame->getRightFrame()->getViewFrame()); if(aViewFrame){ - SUPERV_Graph aNewGraph = dataflow->StreamCopy(); + SUPERV_Graph aNewGraph; // = dataflow->StreamCopy(); + if (dataflow->IsStreamGraph()) { + SUPERV_StreamGraph aSGraph = dataflow->ToStreamGraph(); + if (SUPERV_isNull(aSGraph)) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_CANT_COPY")); + return; + } + aNewGraph = aSGraph->StreamCopy(); + } + else { + aNewGraph = dataflow->Copy(); + } QString aNewName(tr("MSG_COPY_PREFIX").arg(++myCopyNum)); aNewName += dataflow->Name(); aNewGraph->SetName(aNewName); @@ -427,6 +514,108 @@ void SUPERVGUI_Main::copy() { } } +void SUPERVGUI_Main::openSubGraph(SUPERV_CNode theNode, bool correct) +{ + //cout << "===> SUPERVGUI_Main::openSubGraph(" << theNode->Name() << ")" << endl; + //cout << " macro node : " << theNode->IsMacro() << ", " << theNode->IsFlowMacro() << ", " << theNode->IsStreamMacro() << endl; + if (theNode->IsMacro()) { + // get SubGraph from MacroNode + SUPERV_Graph aMacro = SUPERV::Graph::_narrow(theNode); + SUPERV_Graph aGraph; + if (aMacro->IsStreamMacro()) + aGraph = aMacro->StreamObjRef(); + else + aGraph = aMacro->FlowObjRef(); + + // display SubGraph + if (SUPERV_isNull(aGraph)) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOACCESS")); + return; + } + else { + QString aGraphName = aGraph->Name(); + QAD_StudyFrame* aStudyFrame; + if (mySubGraphs.contains(aGraphName)) { + //cout << " activate already opened dataflow " << aGraphName << endl; + aStudyFrame = mySubGraphs[aGraphName]; + aStudyFrame->setActiveWindow(); + aStudyFrame->setFocus(); + } + else { + aStudyFrame = Supervision.createGraph(); + if (aStudyFrame) { + SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast + (aStudyFrame->getRightFrame()->getViewFrame()); + if(aViewFrame) { + SUPERVGUI_Main* m = new SUPERVGUI_Main(aViewFrame, + Supervision.getDesktop(), + aGraph); + // connect(aStudyFrame, SIGNAL(sfStudyFrameClosing(QAD_StudyFrame*)), + // this, SLOT(onSubGraphClosed(QAD_StudyFrame*))); + connect(aStudyFrame, SIGNAL(sfStudyFrameActivated(QAD_StudyFrame*)), + this, SLOT(onSubGraphActivated(QAD_StudyFrame*))); + aStudyFrame->installEventFilter(this); + + mySubGraphs.insert(aGraphName, aStudyFrame); + mySubGraphMap.insert(aGraphName, theNode->Name()); + + } + } + } + study->showFrame(aStudyFrame); + if (!correct) myLastGraph = aStudyFrame; + } + } +} + +bool SUPERVGUI_Main::eventFilter( QObject* o, QEvent* e) +{ + // workaround to get close event + if (o->inherits("QAD_StudyFrame") && e->type() == QEvent::Close) { + QAD_StudyFrame* aFrame = (QAD_StudyFrame*) o; + onSubGraphClosed(aFrame); + } + return SUPERVGraph_View::eventFilter(o, e); +} + +// workaround to fix PAL6255 -> opened SubGraph is not on top +void SUPERVGUI_Main::onSubGraphActivated(QAD_StudyFrame* theStudyFrame) +{ + if (myLastGraph) { + QAD_StudyFrame* aFrame = myLastGraph; + myLastGraph = 0; + aFrame->setActiveWindow(); + aFrame->setFocus(); + } +} + +void SUPERVGUI_Main::onSubGraphClosed(QAD_StudyFrame* theStudyFrame) +{ + QAD_ViewFrame* viewFrame = theStudyFrame->getRightFrame()->getViewFrame(); + if(SUPERVGraph_ViewFrame* supervFrame = dynamic_cast(viewFrame)){ + theStudyFrame->removeEventFilter(this); + disconnect(theStudyFrame, 0, this, 0); + + SUPERVGraph_View* view = supervFrame->getViewWidget(); + SUPERVGUI_Main* aGraph = dynamic_cast(view); + if (aGraph) { + QString aGraphName = aGraph->getDataflow()->Name(); + QMap::iterator it = mySubGraphMap.find(aGraphName); + if (it != mySubGraphMap.end()) { + QString aNodeName = it.data(); + SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*) + myCanvas->child(aNodeName, "SUPERVGUI_CanvasNode"); + if (aNode) { + aNode->merge(); + myCanvas->update(); + } + mySubGraphMap.remove(it); + } + mySubGraphs.remove(aGraphName); + } + } +} + void SUPERVGUI_Main::run() { Trace("SUPERVGUI_Main::run") if ((SUPERV_isNull(dataflow))) return; @@ -436,7 +625,7 @@ void SUPERVGUI_Main::run() { 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 if (graph->isAnyLinkCreating()) { + } else if (graph->isAnyLinkCreating() || myCanvasView->isAnyLinkCreating()) { QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE")); } else { myRunTime = QDateTime::currentDateTime(); @@ -479,7 +668,7 @@ void SUPERVGUI_Main::startExecute() { 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 if (graph->isAnyLinkCreating()) { + } else if (graph->isAnyLinkCreating() || myCanvasView->isAnyLinkCreating()) { QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE")); } else { myRunTime = QDateTime::currentDateTime(); @@ -580,8 +769,6 @@ void SUPERVGUI_Main::addNode() { Supervision.getBrowser()->choose(); } - - /** * Add Computation node */ @@ -596,19 +783,20 @@ void SUPERVGUI_Main::addComputeNode(SUPERV_CNode theNode) { 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; + case CANVAS: + case CONTROLFLOW: + { + SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasComputeNode(myCanvas, this, theNode); + aNode->move(theNode->X(), theNode->Y()); + if (myCurrentView == CONTROLFLOW) aNode->hideAll(); + aNode->show(); + myCanvas->update(); + } + break; } } @@ -625,19 +813,20 @@ void SUPERVGUI_Main::addGOTONode(SUPERV_CNode theNode) { 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; + case CANVAS: + case CONTROLFLOW: + { + SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasGotoNode(myCanvas, this, theNode); + aNode->move(theNode->X(), theNode->Y()); + if (myCurrentView == CONTROLFLOW) aNode->hideAll(); + aNode->show(); + myCanvas->update(); + } + break; } } @@ -666,38 +855,62 @@ void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theE graph->repaintContents(); } break; + case TABLE: + array->destroy(); + array->create(); + break; + case CANVAS: 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(); + SUPERVGUI_CanvasStartNode* aStartNode = new SUPERVGUI_CanvasStartNode(myCanvas, this, theStartNode); + aStartNode->move(theStartNode->X(), theStartNode->Y()); + if (myCurrentView == CONTROLFLOW) aStartNode->hideAll(); + + SUPERVGUI_CanvasEndNode* aEndNode = new SUPERVGUI_CanvasEndNode(myCanvas, this, theEndNode, aStartNode); + aEndNode->move(theEndNode->X(), theEndNode->Y()); + if (myCurrentView == CONTROLFLOW) aEndNode->hideAll(); + + aStartNode->show(); + aEndNode->show(); + myCanvas->update(); + } + break; + } +} + + +/** + * Add Macro node + */ +void SUPERVGUI_Main::addMacroNode(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 TABLE: array->destroy(); array->create(); break; + case CANVAS: + case CONTROLFLOW: + { + SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasMacroNode(myCanvas, this, theNode); + aNode->move(theNode->X(), theNode->Y()); + if (myCurrentView == CONTROLFLOW) aNode->hideAll(); + aNode->show(); + myCanvas->update(); + } + break; } } - SUPERVGUI_Graph* SUPERVGUI_Main::getGraph() { Trace("SUPERVGUI_Main::getGraph") return(graph); @@ -708,6 +921,16 @@ SUPERVGUI_Array* SUPERVGUI_Main::getArray() { return(array); } +SUPERVGUI_Canvas* SUPERVGUI_Main::getCanvas() { + Trace("SUPERVGUI_Main::getCanvas") + return(myCanvas); +} + +SUPERVGUI_CanvasView* SUPERVGUI_Main::getCanvasView() { + Trace("SUPERVGUI_Main::getCanvasView") + return(myCanvasView); +} + SUPERV_Graph SUPERVGUI_Main::getDataflow() { Trace("SUPERVGUI_Main::getDataflow") return(dataflow); @@ -1010,6 +1233,8 @@ void SUPERVGUI_Main::ActivatePanning() graph->ActivatePanning(); } else if (array->isVisible()) { array->ActivatePanning(); + } else if (myCanvasView->isVisible()) { + myCanvasView->ActivatePanning(); } } @@ -1020,6 +1245,8 @@ void SUPERVGUI_Main::ResetView() graph->ResetView(); } else if (array->isVisible()) { array->ResetView(); + } else if (myCanvasView->isVisible()) { + myCanvasView->ResetView(); } } @@ -1028,6 +1255,7 @@ void SUPERVGUI_Main::setAsFromStudy(bool theToStudy) { myIsFromStudy = theToStudy; graph->setAsFromStudy(theToStudy); array->setAsFromStudy(theToStudy); + myCanvas->setAsFromStudy(theToStudy); } void SUPERVGUI_Main::checkIsInStudy() { @@ -1111,6 +1339,8 @@ bool SUPERVGUI_Main::isFiltered(char* graph, char* node, char* type, char* me void SUPERVGUI_Main::setPaletteBackgroundColor(const QColor& color) { array->setPaletteBackgroundColor(color); graph->setPaletteBackgroundColor(color); + myCanvas->setBackgroundColor(color); + myCanvasView->setPaletteBackgroundColor(color.light()); SUPERVGraph_View::setPaletteBackgroundColor(color); } @@ -1327,3 +1557,126 @@ void SUPERVGUI_Thread::run() QThread::exit(); } +/******************************* SUPERVGUI_DSGraphParameters class ****************************************/ +/*! + Constructor +*/ +SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly) + : QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + Trace("SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters"); + setCaption( tr( "TLT_DSGRAPHPARAMS" ) ); + setSizeGripEnabled( true ); + myGraph = theGraph; + + 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 ); + + // DeltaTime + QLabel* DeltaTimeL = new QLabel( tr( "DELTATIME_LBL" ), TopGroup ); + TopGroupLayout->addWidget( DeltaTimeL, 0, 0 ); + + myDeltaTime = new QAD_SpinBoxDbl( TopGroup, 0.0, 1.0, 0.1); + myDeltaTime->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + TopGroupLayout->addWidget( myDeltaTime, 0, 1 ); + + // TimeOut + QLabel* TimeOutL = new QLabel( tr( "TIMEOUT_LBL" ), TopGroup); + TopGroupLayout->addWidget( TimeOutL, 1, 0 ); + + myTimeOut = new QLineEdit( TopGroup ); + myTimeOut->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myTimeOut->setValidator( new QIntValidator(this) ); + myTimeOut->setMinimumSize( 100, 0 ); + myTimeOut->setReadOnly( isReadOnly ); + TopGroupLayout->addWidget( myTimeOut, 1, 1 ); + + // DataStreamTrace + QLabel* DataStreamTraceL = new QLabel( tr( "DATASTREAMTRACE_LBL" ), TopGroup); + TopGroupLayout->addWidget( DataStreamTraceL, 2, 0 ); + + myDataStreamTrace = new QComboBox( TopGroup ); + myDataStreamTrace->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myDataStreamTrace->insertItem("WithoutTrace"); + myDataStreamTrace->insertItem("SummaryTrace"); + myDataStreamTrace->insertItem("DetailedTrace"); + TopGroupLayout->addWidget( myDataStreamTrace, 2, 1 ); + + 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( accept() ) ); + connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) ); + + setData(); +} + +/*! + Destructor +*/ +SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters() { + Trace("SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters"); +} + +/*! + Sets data function +*/ +void SUPERVGUI_DSGraphParameters::setData() { + double aDeltaTime; + long aTimeOut; + SUPERV::KindOfDataStreamTrace aDataStreamTrace; + +// myGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime); + if (myGraph->IsStreamGraph()) { + SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph(); + if (!SUPERV_isNull(aSGraph)) + aSGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime); + } + + myDeltaTime->setValue(aDeltaTime); + myTimeOut->setText(QString("%1").arg(aTimeOut)); + myDataStreamTrace->setCurrentItem((int)aDataStreamTrace); +} + +/*! + button slot +*/ +void SUPERVGUI_DSGraphParameters::accept() { +// myGraph->SetStreamParams( myTimeOut->text().toLong(), +// (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(), +// myDeltaTime->value()); + if (myGraph->IsStreamGraph()) { + SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph(); + if (!SUPERV_isNull(aSGraph)) + aSGraph->SetStreamParams( myTimeOut->text().toLong(), + (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(), + myDeltaTime->value()); + } + QDialog::accept(); +} diff --git a/src/SUPERVGUI/SUPERVGUI_Main.h b/src/SUPERVGUI/SUPERVGUI_Main.h index e1e51a5..b8140ec 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.h +++ b/src/SUPERVGUI/SUPERVGUI_Main.h @@ -34,6 +34,8 @@ #include "SUPERVGUI_Graph.h" #include "QAD_Desktop.h" #include "SUPERVGUI_Port.h" +#include "SUPERVGUI_Canvas.h" +#include "SUPERVGUI_CanvasView.h" #include #include @@ -60,12 +62,15 @@ class SUPERVGUI_Main: public SUPERVGraph_View { void suspendResume(); void stopRestart(); bool exportDataflow(QString theFile); + void openSubGraph(SUPERV_CNode theNode, bool correct = false); bool putDataStudy(SUPERV_Port port, const char* inout); void setData(SUPERVGUI_PortIn* p); SUPERVGUI_Graph* getGraph(); SUPERVGUI_Array* getArray(); + SUPERVGUI_Canvas* getCanvas(); + SUPERVGUI_CanvasView* getCanvasView(); SUPERV_Graph getDataflow(); QAD_Message* getMessage(); QAD_Study* getStudy(); @@ -93,6 +98,7 @@ class SUPERVGUI_Main: public SUPERVGraph_View { void addComputeNode(SUPERV_CNode theNode); void addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update); void addGOTONode(SUPERV_CNode theNode); + void addMacroNode(SUPERV_CNode theNode); void setPaletteBackgroundColor(const QColor& color); @@ -119,6 +125,8 @@ class SUPERVGUI_Main: public SUPERVGraph_View { void startTimer(); void executionFinished(); + bool eventFilter( QObject* o, QEvent* e); + signals: void KillMyThread(bool theValue); @@ -134,8 +142,11 @@ class SUPERVGUI_Main: public SUPERVGraph_View { void showTable(); void showFullGraph(); void showContolFlow(); + void showCanvas(); void filterNotification(); void changeDSGraphParameters(); + void onSubGraphClosed(QAD_StudyFrame* ); + void onSubGraphActivated(QAD_StudyFrame* ); private slots: void chooseData(QListViewItem* item); @@ -147,6 +158,11 @@ class SUPERVGUI_Main: public SUPERVGraph_View { bool isFiltered(char* graph, char* node, char* type, char* message, char* sender, long counter, char* date, long stamp); SUPERV_Graph dataflow; + + QMap mySubGraphs; + QMap mySubGraphMap; + QAD_StudyFrame* myLastGraph; + QAD_Study* study; QAD_ObjectBrowser* objectBrowser; QAD_Message* message; @@ -154,6 +170,8 @@ class SUPERVGUI_Main: public SUPERVGraph_View { GraphViewType myCurrentView; SUPERVGUI_Array* array; + SUPERVGUI_Canvas* myCanvas; + SUPERVGUI_CanvasView* myCanvasView; bool choosing; SUPERVGUI_PortIn* portIn; @@ -209,4 +227,26 @@ class SUPERVGUI_Thread : public QObject, public QThread { }; +//************************************************************** +class SUPERVGUI_DSGraphParameters: public QDialog { + Q_OBJECT + + public: + SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly); + virtual ~SUPERVGUI_DSGraphParameters(); + + private slots: + void accept(); + + private: + + void setData(); + + QAD_SpinBoxDbl* myDeltaTime; + QLineEdit* myTimeOut; + QComboBox* myDataStreamTrace; + + SUPERV_Graph myGraph; +}; + #endif diff --git a/src/SUPERVGUI/SUPERVGUI_Node.h b/src/SUPERVGUI/SUPERVGUI_Node.h index ec81d87..4acd05c 100644 --- a/src/SUPERVGUI/SUPERVGUI_Node.h +++ b/src/SUPERVGUI/SUPERVGUI_Node.h @@ -34,7 +34,7 @@ using namespace std; #include #include "SUPERVGUI_BrowseNodeDlg.h" #include - +#include "SUPERVGUI_Port.h" class SUPERVGUI_Main; diff --git a/src/SUPERVGUI/SUPERVGUI_Port.cxx b/src/SUPERVGUI/SUPERVGUI_Port.cxx index c773024..73a2422 100644 --- a/src/SUPERVGUI/SUPERVGUI_Port.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Port.cxx @@ -35,7 +35,6 @@ using namespace std; #include "QAD_LeftFrame.h" #include "QAD_ObjectBrowser.h" #include -#include #include "SUPERVGUI_GraphNode.h" @@ -420,8 +419,7 @@ void SUPERVGUI_PortOut::onDeleteLink(SUPERVGUI_Link* theLink) { void SUPERVGUI_PortOut::deleteLinks() { if (myLinksList.count() > 0) { - SUPERVGUI_Link* aLink; - while (aLink = myLinksList.last()) { + while (SUPERVGUI_Link* aLink = myLinksList.last()) { disconnect(aLink, 0, this, 0); myLinksList.remove(aLink); main->getGraph()->deleteLink(aLink); @@ -507,8 +505,7 @@ void SUPERVGUI_PortInESNode::setLinkPrs(SUPERVGUI_Link* theLink) { void SUPERVGUI_PortInESNode::deleteLinks() { if (myLinksList.count() > 0) { - SUPERVGUI_Link* aLink; - while (aLink = myLinksList.last()) { + while (SUPERVGUI_Link* aLink = myLinksList.last()) { disconnect(aLink, 0, this, 0); myLinksList.remove(aLink); main->getGraph()->deleteLink(aLink); @@ -564,102 +561,6 @@ void SUPERVGUI_PortInESNode::onDeleteLink(SUPERVGUI_Link* theLink) { // ---------------------------- // Stream Ports // ---------------------------- -SUPERVGUI_StreamInDlg::SUPERVGUI_StreamInDlg(SUPERVGUI_StreamPortIn* thePort) - :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) -{ - myPort = thePort; - setSizeGripEnabled( true ); - setCaption( tr( "MSG_STREAM_DLG_TIT" ) ); - - QVBoxLayout* TopLayout = new QVBoxLayout( this, 11, 6 ); - - QFrame* aCtrlPane = new QFrame(this); - QGridLayout* aCtrlLayout = new QGridLayout( aCtrlPane, 4, 10 ); - - // Schema - QLabel* aSchemaLbl = new QLabel(tr("MSG_STREAM_SCHEMA"),aCtrlPane); - aCtrlLayout->addWidget(aSchemaLbl, 0, 0); - - mySchemaCombo = new QComboBox(aCtrlPane, "SchemaBox" ); - mySchemaCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - mySchemaCombo->insertItem("SCHENULL"); - mySchemaCombo->insertItem("TI"); - mySchemaCombo->insertItem("TF"); - mySchemaCombo->insertItem("DELTA"); - aCtrlLayout->addWidget(mySchemaCombo, 0, 1); - - // Interpolation - QLabel* aInterLbl = new QLabel(tr("MSG_STREAM_INTER"),aCtrlPane); - aCtrlLayout->addWidget(aInterLbl, 1, 0); - - myInterCombo = new QComboBox(aCtrlPane, "InterBox" ); - myInterCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myInterCombo->insertItem("INTERNULL"); - myInterCombo->insertItem("L0"); - myInterCombo->insertItem("L1"); - aCtrlLayout->addWidget(myInterCombo, 1, 1); - - // Extrapolation - QLabel* aExtraLbl = new QLabel(tr("MSG_STREAM_EXTRA"),aCtrlPane); - aCtrlLayout->addWidget(aExtraLbl, 2, 0); - - myExterCombo = new QComboBox(aCtrlPane, "ExtraBox" ); - myExterCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myExterCombo->insertItem("EXTRANULL"); - myExterCombo->insertItem("E0"); - myExterCombo->insertItem("E1"); - aCtrlLayout->addWidget(myExterCombo, 2, 1); - - TopLayout->addWidget( aCtrlPane ); - - // Buttons - 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( 5 ); - GroupButtonsLayout->setMargin( 8 ); - - 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( GroupButtons ); - - connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) ); - connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) ); - setData(); -} - - -void SUPERVGUI_StreamInDlg::setData() { - SUPERV::KindOfSchema aSchema; - SUPERV::KindOfInterpolation aInterpolat; - SUPERV::KindOfExtrapolation aExtrapolat; - - myPort->getStreamPort()->Params(aSchema, aInterpolat, aExtrapolat); - - mySchemaCombo->setCurrentItem((int)aSchema); - myInterCombo->setCurrentItem((int)aInterpolat); - myExterCombo->setCurrentItem((int)aExtrapolat); -} - - - -void SUPERVGUI_StreamInDlg::accept() { - myPort->getStreamPort()->SetParams((SUPERV::KindOfSchema) mySchemaCombo->currentItem(), - (SUPERV::KindOfInterpolation) myInterCombo->currentItem(), - (SUPERV::KindOfExtrapolation) myExterCombo->currentItem()); - QDialog::accept(); -} - -//--------------------------------------------------------------------------------------- - SUPERVGUI_StreamPortIn::SUPERVGUI_StreamPortIn(QWidget* parent, SUPERVGUI_Main* m, SUPERV::StreamPort_ptr p): SUPERVGUI_PortIn(parent, m, p) @@ -687,62 +588,6 @@ void SUPERVGUI_StreamPortIn::sync() setText(myName + "=" + myPort->ToString()); } -//------------------------------------------------------------------------- - -SUPERVGUI_StreamOutDlg::SUPERVGUI_StreamOutDlg(SUPERVGUI_StreamPortOut* thePort) - :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) -{ - myPort = thePort; - setSizeGripEnabled( true ); - setCaption( tr( "MSG_STREAM_DLG_TIT" ) ); - - QVBoxLayout* TopLayout = new QVBoxLayout( this, 11, 6 ); - - QFrame* aCtrlPane = new QFrame(this); - QGridLayout* aCtrlLayout = new QGridLayout( aCtrlPane, 4, 10 ); - - QLabel* aLbl = new QLabel(tr("MSG_STREAM_LEVEL"),aCtrlPane); - aCtrlLayout->addWidget(aLbl, 0, 0); - - myValEdit = new QLineEdit( aCtrlPane, "ValEdit" ); - myValEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myValEdit->setValidator( new QIntValidator(this) ); - myValEdit->setText(QString("%1").arg(myPort->getStreamPort()->NumberOfValues())); - aCtrlLayout->addWidget(myValEdit, 0, 1); - TopLayout->addWidget( aCtrlPane ); - - // Buttons - 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( 5 ); - GroupButtonsLayout->setMargin( 8 ); - - 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( GroupButtons ); - - connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) ); - connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) ); -} - -void SUPERVGUI_StreamOutDlg::accept() { - int aRes = 0; - QString aStr = myValEdit->text(); - if (!aStr.isEmpty()) - aRes = aStr.toLong(); - myPort->getStreamPort()->SetNumberOfValues(aRes); - QDialog::accept(); -} - //------------------------------------------------------------------------------------------------ diff --git a/src/SUPERVGUI/SUPERVGUI_Port.h b/src/SUPERVGUI/SUPERVGUI_Port.h index 8137e35..e54ef63 100644 --- a/src/SUPERVGUI/SUPERVGUI_Port.h +++ b/src/SUPERVGUI/SUPERVGUI_Port.h @@ -197,30 +197,6 @@ class SUPERVGUI_PortInESNode: public SUPERVGUI_Port { - - - -//**************************************************************** -class SUPERVGUI_StreamPortIn; -class SUPERVGUI_StreamInDlg: public QDialog -{ - Q_OBJECT -public: - SUPERVGUI_StreamInDlg(SUPERVGUI_StreamPortIn* thePort); - virtual ~SUPERVGUI_StreamInDlg() {}; - -protected slots: - void accept(); - -private: - void setData(); - - SUPERVGUI_StreamPortIn* myPort; - QComboBox* mySchemaCombo; - QComboBox* myInterCombo; - QComboBox* myExterCombo; -}; - class SUPERVGUI_StreamPortIn: public SUPERVGUI_PortIn { Q_OBJECT @@ -241,23 +217,6 @@ private: }; -//************************************************************** -class SUPERVGUI_StreamPortOut; -class SUPERVGUI_StreamOutDlg: public QDialog -{ - Q_OBJECT -public: - SUPERVGUI_StreamOutDlg(SUPERVGUI_StreamPortOut* thePort); - virtual ~SUPERVGUI_StreamOutDlg() {}; - -protected slots: - void accept(); - -private: - SUPERVGUI_StreamPortOut* myPort; - QLineEdit* myValEdit; -}; - class SUPERVGUI_StreamPortOut: public SUPERVGUI_PortOut { Q_OBJECT diff --git a/src/SUPERVGUI/SUPERVGUI_Service.cxx b/src/SUPERVGUI/SUPERVGUI_Service.cxx index 749ed00..017ddeb 100644 --- a/src/SUPERVGUI/SUPERVGUI_Service.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Service.cxx @@ -94,7 +94,7 @@ static const char * InterfaceIcon[] = { SUPERVGUI_Service::SUPERVGUI_Service(SALOME_NamingService* ns): QDialog(QAD_Application::getDesktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), - naming(ns) + naming(ns), myMFile(0) { setSizeGripEnabled( true ); setCaption(tr("TIT_SERVICES")); @@ -194,6 +194,44 @@ SUPERVGUI_Service::SUPERVGUI_Service(SALOME_NamingService* ns): myTabPane->addTab(aPythonPane, tr("INLINE_PANE")); + // Create Tab for Macro node only if environmental variable ENABLE_MACRO_NODE is set + if ( getenv( "ENABLE_MACRO_NODE" ) != NULL ) + { + QWidget* aMacroPane = new QWidget(myTabPane); + QVBoxLayout* aMacroLayout = new QVBoxLayout(aMacroPane, 0, 4); + aMacroLayout->setMargin(5); + aMacroLayout->setSpacing(10); + + QHBoxLayout* aLoadLayout = new QHBoxLayout(aMacroPane); //!! + aLoadLayout->addStretch(); + + QPushButton* aLoadBtn = new QPushButton(tr("BUT_LOAD"), aMacroPane); + connect(aLoadBtn, SIGNAL(clicked()), this, SLOT(loadGraph())); + + aLoadLayout->addWidget(aLoadBtn); + + aMacroLayout->addLayout(aLoadLayout); + + myMacroPane = new QListView(aMacroPane); + myMacroPane->addColumn(tr("COL_COMPONENTS")); + myMacroPane->addColumn(tr("COL_PORTTYPE")); + myMacroPane->addColumn(tr("COL_PORTWAY")); + myMacroPane->setColumnAlignment(1, AlignLeft); + myMacroPane->setColumnAlignment(2, AlignLeft); + myMacroPane->setColumnAlignment(3, AlignLeft); + myMacroPane->setSelectionMode(QListView::Extended); + myMacroPane->setRootIsDecorated(true); + aMacroLayout->addWidget(myMacroPane); //!! + + QPushButton* aAddBtn = new QPushButton(tr("TIT_ADDFNODE"), aMacroPane); + connect(aAddBtn, SIGNAL(clicked()), this, SLOT(addMacroNode())); + aAddBtn->setDefault(true); + + aMacroLayout->addWidget(aAddBtn); + + myTabPane->addTab(aMacroPane, tr("MACRO_PANE")); + } + aMainLayout->addWidget(myTabPane); // Close button @@ -319,6 +357,7 @@ void SUPERVGUI_Service::initialise() { SUPERVGUI_Service::~SUPERVGUI_Service() { Trace("SUPERVGUI_Service::~SUPERVGUI_Service") + if (myMFile) delete myMFile; } void SUPERVGUI_Service::addComputeNode() { @@ -326,12 +365,14 @@ void SUPERVGUI_Service::addComputeNode() { SUPERVGUI_Main* aMain = Supervision.getMain(); if (aMain==0) { QMessageBox::warning(aDesktop, tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW")); + } else if (!aMain->isEditable()) { + QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); } 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")); + QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE")); } else { QListViewItem* item; bool b = false; @@ -351,7 +392,7 @@ void SUPERVGUI_Service::addComputeNode() { SUPERV_CNode node = aMain->getDataflow()->CNode(*myService); if (CORBA::is_nil(node)) { - QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); + QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); return; } node->Coords(myX, myY); @@ -373,12 +414,14 @@ void SUPERVGUI_Service::addFactoryNode() { SUPERVGUI_Main* aMain = Supervision.getMain(); if (aMain==0) { QMessageBox::warning(aDesktop, tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW")); + } else if (!aMain->isEditable()) { + QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); } 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")); + QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE")); } else { QListViewItem* item; bool b = false; @@ -401,7 +444,7 @@ void SUPERVGUI_Service::addFactoryNode() { if ( myService->TypeOfNode == 0 ) { // ComputeNode SUPERV_CNode node = aMain->getDataflow()->CNode(*myService); if (CORBA::is_nil(node)) { - QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); + QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); return; } node->Coords(myX, myY); @@ -411,7 +454,7 @@ void SUPERVGUI_Service::addFactoryNode() { } else { // Factory Node SUPERV_FNode node = aMain->getDataflow()->FNode(component, interface, *myService); if (CORBA::is_nil(node)) { - QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); + QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); return; } node->Coords(myX, myY); @@ -434,7 +477,7 @@ void SUPERVGUI_Service::addFactoryNode() { } } if (!b) { - QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NONODE_TOADD")); + QMessageBox::warning(aDesktop, tr("WARNING"), tr("MSG_NONODE_TOADD")); } } } @@ -445,6 +488,8 @@ 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 if (!aMain->isEditable()) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); } else { int aSel = myTypeCombo->currentItem(); switch (aSel) { @@ -522,7 +567,82 @@ void SUPERVGUI_Service::addInlineNode() { } } +void SUPERVGUI_Service::addMacroNode() { + SUPERVGUI_Main* aMain = Supervision.getMain(); + if (aMain==0) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW")); + } else if (!aMain->isEditable()) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); + } else { + if (myMFile) { + SUPERV_Graph aNode; + if (aMain->getDataflow()->IsStreamGraph()) { + SUPERV_StreamGraph aSGraph = aMain->getDataflow()->ToStreamGraph(); + if (!SUPERV_isNull(aSGraph)) + aNode = aSGraph->StreamMNode(myMFile->name().latin1()); + // TMP: while stream macro nodes doesn't impemented + if (CORBA::is_nil(aNode)) { + aNode = aSGraph->MNode(myMFile->name().latin1()); + } + } + else + aNode = aMain->getDataflow()->MNode(myMFile->name().latin1()); + 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->addMacroNode(SUPERV::CNode::_narrow(aNode)); + } + else { + QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NONODE_TOADD")); + } + } +} + +void SUPERVGUI_Service::loadGraph() { + if ( getenv( "ENABLE_MACRO_NODE" ) == NULL ) + // error! if ENABLE_MACRO_NODE is set - we should NOT get here by any means.. + { + //cout << "Error: ENABLE_MACRO_NODE is not set, but loadGraph() was called!" << endl; + return; + } + + QString aFileName = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), + "", + "*.xml", + tr("MSG_GRAPH_INSERT"), + true); + if (aFileName.isEmpty()) return; + + myMacroPane->clear(); + + myMFile = new QFile(aFileName); + if (!myMFile->open(IO_ReadOnly)) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), + tr("MSG_CANT_LOADSCRIPT")); + delete myMFile; myMFile = 0; + return; + } + + QTextStream* aStream = new QTextStream(myMFile); + if (aStream->atEnd()) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), + tr("MSG_EMTY_FILE")); + delete aStream; + myMFile->close(); + delete myMFile; myMFile = 0; + return; + } + // read graph info + // temporary display only file name + QFileInfo anInfo(*myMFile); + QListViewItem* anItem = new QListViewItem(myMacroPane, anInfo.baseName()); + anItem->setSelectable(true); +} void SUPERVGUI_Service::typeNodeSelected(int theRow) { if (theRow == 2) diff --git a/src/SUPERVGUI/SUPERVGUI_Service.h b/src/SUPERVGUI/SUPERVGUI_Service.h index c04a154..92c195d 100644 --- a/src/SUPERVGUI/SUPERVGUI_Service.h +++ b/src/SUPERVGUI/SUPERVGUI_Service.h @@ -94,7 +94,9 @@ class SUPERVGUI_Service: public QDialog { void addComputeNode(); void addFactoryNode(); void addInlineNode(); + void addMacroNode(); void typeNodeSelected(int theRow); + void loadGraph(); private: QListView* components; @@ -110,6 +112,9 @@ class SUPERVGUI_Service: public QDialog { SUPERVGUI_PythonEditPane* myMorePane; SUPERVGUI_PythonEditPane* myNextPane; + QListView* myMacroPane; + QFile* myMFile; + QTabWidget* myTabPane; bool myIsInline; diff --git a/src/SUPERVGUI/SUPERVGUI_View.cxx b/src/SUPERVGUI/SUPERVGUI_View.cxx index 30e5348..d47a98a 100644 --- a/src/SUPERVGUI/SUPERVGUI_View.cxx +++ b/src/SUPERVGUI/SUPERVGUI_View.cxx @@ -47,9 +47,12 @@ SUPERVGUI_View::SUPERVGUI_View(SUPERVGUI_Main* theMain): } myViewPopup = new QPopupMenu(viewport()); - myViewPopup->insertItem(tr("POP_FULLVIEW"), main, SLOT(showFullGraph())); + // myViewPopup->insertItem(tr("POP_FULLVIEW"), main, SLOT(showFullGraph())); + myViewPopup->insertItem(tr("POP_FULLVIEW"), main, SLOT(showCanvas())); myViewPopup->insertItem(tr("POP_CONTROLVIEW"), main, SLOT(showContolFlow())); myViewPopup->insertItem(tr("POP_TABLEVIEW"), main, SLOT(showTable())); + // myViewPopup->insertItem("Previous Full View", main, SLOT(showFullGraph())); + // myViewPopup->insertItem(tr("POP_CANVASVIEW"), main, SLOT(showCanvas())); myPopup->insertItem(tr("POP_VIEW"), myViewPopup); myPopup->insertSeparator(); diff --git a/src/SUPERVGUI/SUPERV_msg_en.po b/src/SUPERVGUI/SUPERV_msg_en.po index 5b94656..5832601 100644 --- a/src/SUPERVGUI/SUPERV_msg_en.po +++ b/src/SUPERVGUI/SUPERV_msg_en.po @@ -56,6 +56,9 @@ msgstr "Can't Access Dataflow: bad IOR" msgid "MSG_NOACCESS_BY_IOR" msgstr "Can't Access Dataflow by IOR" +msgid "MSG_NOACCESS" +msgstr "Can't Access Dataflow" + #:SUPERVGUI_Main.cxx:53 msgid "MSG_CANT_CREATE_DF" msgstr "Can't Create a New Dataflow" @@ -423,6 +426,9 @@ msgstr "No Supervision Window Selected to Kill a Dataflow" msgid "MSG_IMPORT" msgstr "Import Dataflow" +msgid "MSG_EXPORT" +msgstr "Export Dataflow" + msgid "MSG_NOTEDITABLE" msgstr "Current Dataflow is not editable" @@ -531,6 +537,9 @@ msgstr "Control" msgid "POP_TABLEVIEW" msgstr "Table" +msgid "POP_CANVASVIEW" +msgstr "Canvas" + msgid "POP_SHOW" msgstr "Show" @@ -615,6 +624,9 @@ msgstr "Factory" msgid "INLINE_PANE" msgstr "Inline" +msgid "MACRO_PANE" +msgstr "Macro" + msgid "ENDNODE_PREFIX" msgstr "EndOf" @@ -651,6 +663,9 @@ msgstr "Python function" msgid "COMMENT_CNODE" msgstr "Compute Node" +msgid "COMMENT_MNODE" +msgstr "Macro Node" + msgid "TIT_FUNC_PYTHON" msgstr "Edit function" -- 2.39.2