Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_CanvasControlNode.cxx
index 5d9c498d3513f3fac2fde17fa4063d040f2f9565..4bfd92425dc7645ed594e33e1ef03f09816289c0 100644 (file)
@@ -26,6 +26,7 @@
 #include "SUPERVGUI_CanvasControlNode.h"
 #include "SUPERVGUI_CanvasControlNodePrs.h"
 #include "SUPERVGUI_CanvasCellNodePrs.h"
+#include "SUPERVGUI_CanvasLink.h"
 #include "SUPERVGUI_Clipboard.h"
 #include "SUPERVGUI_Main.h"
 #include "SUPERVGUI.h"
 //=====================================================================
 // Compute node
 //=====================================================================
-SUPERVGUI_CanvasComputeNode::SUPERVGUI_CanvasComputeNode( SUIT_ResourceMgr* mgr, QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode):
-  SUPERVGUI_CanvasNode( mgr, theParent, theMain, theNode)
+SUPERVGUI_CanvasComputeNode::SUPERVGUI_CanvasComputeNode (SUIT_ResourceMgr* mgr, QObject* theParent,
+                                                          SUPERVGUI_Main* theMain, SUPERV_CNode theNode):
+  SUPERVGUI_CanvasNode(mgr, theParent, theMain, theNode)
 {
   Trace("SUPERVGUI_CanvasComputeNode::SUPERVGUI_CanvasComputeNode");
 }
 
+SUPERVGUI_CanvasComputeNode* SUPERVGUI_CanvasComputeNode::Create
+                             (SUIT_ResourceMgr* mgr, QObject* theParent,
+                              SUPERVGUI_Main* theMain, SUPERV_CNode theNode)
+{
+  SUPERVGUI_CanvasComputeNode* aRet = new SUPERVGUI_CanvasComputeNode (mgr, theParent, theMain, theNode);
+  emit aRet->objectCreatedDeleted();
+  return aRet;
+}
+
 QPopupMenu* SUPERVGUI_CanvasComputeNode::getPopupMenu(QWidget* theParent) 
 {
   QPopupMenu* popup = SUPERVGUI_CanvasNode::getPopupMenu(theParent);
@@ -67,16 +78,25 @@ QPopupMenu* SUPERVGUI_CanvasComputeNode::getPopupMenu(QWidget* theParent)
 //=====================================================================
 // Start control node
 //=====================================================================
-SUPERVGUI_CanvasStartNode::SUPERVGUI_CanvasStartNode(SUIT_ResourceMgr* mgr, QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode):
+SUPERVGUI_CanvasStartNode::SUPERVGUI_CanvasStartNode (SUIT_ResourceMgr* mgr, QObject* theParent,
+                                                      SUPERVGUI_Main* theMain, SUPERV_CNode theNode):
   SUPERVGUI_CanvasNode( mgr, theParent, theMain, theNode), 
   myCoupled(0)
 {
   Trace("SUPERVGUI_CanvasStartNode::SUPERVGUI_CanvasStartNode");
 }
 
+SUPERVGUI_CanvasStartNode* SUPERVGUI_CanvasStartNode::Create (SUIT_ResourceMgr* mgr, QObject* theParent,
+                                                              SUPERVGUI_Main* theMain, SUPERV_CNode theNode)
+{
+  SUPERVGUI_CanvasStartNode* aRet = new SUPERVGUI_CanvasStartNode (mgr, theParent, theMain, theNode);
+  emit aRet->objectCreatedDeleted();
+  return aRet;
+}
+
 SUPERVGUI_CanvasNodePrs* SUPERVGUI_CanvasStartNode::createPrs() const
 {
-  return new SUPERVGUI_CanvasStartNodePrsresMgr(), getMain()->getCanvas(), 
+  return new SUPERVGUI_CanvasStartNodePrs (resMgr(), getMain()->getCanvas(), 
                                           (SUPERVGUI_CanvasStartNode*)this);
 }
 
@@ -135,6 +155,8 @@ void SUPERVGUI_CanvasStartNode::remove()
   if (myCoupled) 
     delete myCoupled;
 
+  emit objectCreatedDeleted(); // jfa : NPAL15529
+
   delete this;
 
   aCanvas->update();
@@ -176,8 +198,9 @@ void SUPERVGUI_CanvasStartNode::pastePort()
 //=====================================================================
 // End control node
 //=====================================================================
-SUPERVGUI_CanvasEndNode::SUPERVGUI_CanvasEndNode(SUIT_ResourceMgr* mgr, QObject* theParent, SUPERVGUI_Main* theMain,
-                                                SUPERV_CNode theNode, SUPERVGUI_CanvasStartNode* theStart):
+SUPERVGUI_CanvasEndNode::SUPERVGUI_CanvasEndNode (SUIT_ResourceMgr* mgr, QObject* theParent,
+                                                  SUPERVGUI_Main* theMain, SUPERV_CNode theNode,
+                                                  SUPERVGUI_CanvasStartNode* theStart):
   SUPERVGUI_CanvasNode(mgr, theParent, theMain, theNode), 
   myCoupled(theStart)
 {
@@ -185,6 +208,15 @@ SUPERVGUI_CanvasEndNode::SUPERVGUI_CanvasEndNode(SUIT_ResourceMgr* mgr, QObject*
   myCoupled->setCoupled(this);
 }
 
+SUPERVGUI_CanvasEndNode* SUPERVGUI_CanvasEndNode::Create (SUIT_ResourceMgr* mgr, QObject* theParent,
+                                                          SUPERVGUI_Main* theMain, SUPERV_CNode theNode,
+                                                          SUPERVGUI_CanvasStartNode* theStart)
+{
+  SUPERVGUI_CanvasEndNode* aRet = new SUPERVGUI_CanvasEndNode (mgr, theParent, theMain, theNode, theStart);
+  emit aRet->objectCreatedDeleted();
+  return aRet;
+}
+
 SUPERVGUI_CanvasNodePrs* SUPERVGUI_CanvasEndNode::createPrs() const
 {
   return new SUPERVGUI_CanvasEndNodePrs( resMgr(), getMain()->getCanvas(), 
@@ -213,12 +245,21 @@ QPopupMenu* SUPERVGUI_CanvasEndNode::getPopupMenu(QWidget* theParent)
 //=====================================================================
 // Goto control node
 //=====================================================================
-SUPERVGUI_CanvasGotoNode::SUPERVGUI_CanvasGotoNode(SUIT_ResourceMgr* mgr, QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode):
+SUPERVGUI_CanvasGotoNode::SUPERVGUI_CanvasGotoNode (SUIT_ResourceMgr* mgr, QObject* theParent,
+                                                    SUPERVGUI_Main* theMain, SUPERV_CNode theNode):
   SUPERVGUI_CanvasNode(mgr, theParent, theMain, theNode)
 {
   Trace("SUPERVGUI_CanvasGotoNode::SUPERVGUI_CanvasGotoNode");
 }
 
+SUPERVGUI_CanvasGotoNode* SUPERVGUI_CanvasGotoNode::Create (SUIT_ResourceMgr* mgr, QObject* theParent,
+                                                            SUPERVGUI_Main* theMain, SUPERV_CNode theNode)
+{
+  SUPERVGUI_CanvasGotoNode* aRet = new SUPERVGUI_CanvasGotoNode (mgr, theParent, theMain, theNode);
+  emit aRet->objectCreatedDeleted();
+  return aRet;
+}
+
 SUPERVGUI_CanvasNodePrs* SUPERVGUI_CanvasGotoNode::createPrs() const
 {
   return new SUPERVGUI_CanvasGotoNodePrs( resMgr(), getMain()->getCanvas(), 
@@ -244,7 +285,43 @@ void SUPERVGUI_CanvasGotoNode::linkToNode() {
   if (aDlg->exec()) {
     QString aNodeName = aDlg->getName();
     if (!aNodeName.isEmpty()) { //implement additional check from GUI side for bug PAL7007
+      // mkr : here we should re/create (if it is not yet exists) a presentation for new
+      //       Goto(OutGate)->CoupledNode(InGate) link, which will be created in SetCoupled method
+
+      // check if GoTo node have coupled node
+      SUPERV_INode aCoupledNode = getGotoNode()->Coupled();
+      if ( !SUPERV_isNull(aCoupledNode) )
+      { // we got old coupled node
+       SUPERV_Port anInGatePort = aCoupledNode->GetInPort("InGate");
+       SUPERV_Link anOldLinkEngine = anInGatePort->Link();
+       if ( !SUPERV_isNull(anOldLinkEngine) )
+       { // we got old link engine
+         SUPERVGUI_CanvasLink* anOldLinkPrs = getMain()->getCanvas()->getLink(anOldLinkEngine);
+         if ( anOldLinkPrs )
+         { // delete old link presentation
+           delete anOldLinkPrs;
+           anOldLinkPrs = 0;
+         }
+       }
+      }
+
       getGotoNode()->SetCoupled(aNodeName.latin1());
+
+      aCoupledNode = SUPERV::INode::_narrow(getMain()->getDataflow()->Node(aNodeName.latin1()));
+      if ( !SUPERV_isNull(aCoupledNode) )
+      { // we got new coupled node
+       SUPERV_Port anInGatePort = aCoupledNode->GetInPort("InGate");
+       SUPERV_Link aLinkEngine = anInGatePort->Link();
+       if ( !SUPERV_isNull(aLinkEngine) )
+       { // we got new link engine
+         if ( !getMain()->getCanvas()->getLink(aLinkEngine) )
+         { // there is no presentation for such link engine => create it
+           SUPERVGUI_CanvasLink* aLink = new SUPERVGUI_CanvasLink(getMain()->getCanvas(), getMain(), aLinkEngine);
+           aLink->show();
+         }
+       }
+      }
+
       getMain()->getCanvas()->sync();
     }
   }
@@ -254,12 +331,21 @@ void SUPERVGUI_CanvasGotoNode::linkToNode() {
 //=====================================================================
 // Macro node
 //=====================================================================
-SUPERVGUI_CanvasMacroNode::SUPERVGUI_CanvasMacroNode(SUIT_ResourceMgr* mgr, QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode):
+SUPERVGUI_CanvasMacroNode::SUPERVGUI_CanvasMacroNode (SUIT_ResourceMgr* mgr, QObject* theParent,
+                                                      SUPERVGUI_Main* theMain, SUPERV_CNode theNode):
   SUPERVGUI_CanvasComputeNode(mgr, theParent, theMain, theNode)
 {
   Trace("SUPERVGUI_CanvasMacroNode::SUPERVGUI_CanvasMacroNode");
 }
 
+SUPERVGUI_CanvasMacroNode* SUPERVGUI_CanvasMacroNode::Create (SUIT_ResourceMgr* mgr, QObject* theParent,
+                                                              SUPERVGUI_Main* theMain, SUPERV_CNode theNode)
+{
+  SUPERVGUI_CanvasMacroNode* aRet = new SUPERVGUI_CanvasMacroNode (mgr, theParent, theMain, theNode);
+  emit aRet->objectCreatedDeleted();
+  return aRet;
+}
+
 SUPERVGUI_CanvasNodePrs* SUPERVGUI_CanvasMacroNode::createPrs() const
 {
   return new SUPERVGUI_CanvasMacroNodePrs( resMgr(), getMain()->getCanvas(), 
@@ -344,9 +430,8 @@ void SUPERVGUI_CanvasMacroNode::remove()
 //=====================================================================
 // Cell node: node for table view
 //=====================================================================
-SUPERVGUI_CanvasCellNode::SUPERVGUI_CanvasCellNode(SUIT_ResourceMgr* mgr, QObject* theParent, 
-                                                  SUPERVGUI_Main* theMain, 
-                                                  SUPERV_CNode theNode):
+SUPERVGUI_CanvasCellNode::SUPERVGUI_CanvasCellNode (SUIT_ResourceMgr* mgr, QObject* theParent, 
+                                                    SUPERVGUI_Main* theMain, SUPERV_CNode theNode):
   SUPERVGUI_CanvasNode(mgr, theParent, theMain, theNode, true)
 {
   Trace("SUPERVGUI_CanvasCellNode::SUPERVGUI_CanvasCellNode");
@@ -363,6 +448,14 @@ SUPERVGUI_CanvasCellNode::SUPERVGUI_CanvasCellNode(SUIT_ResourceMgr* mgr, QObjec
     myIsControl = true;
 }
 
+SUPERVGUI_CanvasCellNode* SUPERVGUI_CanvasCellNode::Create (SUIT_ResourceMgr* mgr, QObject* theParent, 
+                                                            SUPERVGUI_Main* theMain, SUPERV_CNode theNode)
+{
+  SUPERVGUI_CanvasCellNode* aRet = new SUPERVGUI_CanvasCellNode (mgr, theParent, theMain, theNode);
+  emit aRet->objectCreatedDeleted();
+  return aRet;
+}
+
 SUPERVGUI_CanvasCellNode::~SUPERVGUI_CanvasCellNode()
 {
 }
@@ -428,9 +521,8 @@ SUPERVGUI_CanvasNodePrs* SUPERVGUI_CanvasCellNode::createPrs() const
   return aPrs;
 }
 
-SUPERVGUI_CanvasCellEndNode::SUPERVGUI_CanvasCellEndNode( SUIT_ResourceMgr* mgr, QObject* theParent, 
-                                                         SUPERVGUI_Main* theMain, 
-                                                         SUPERV_CNode theNode, 
+SUPERVGUI_CanvasCellEndNode::SUPERVGUI_CanvasCellEndNode (SUIT_ResourceMgr* mgr, QObject* theParent, 
+                                                         SUPERVGUI_Main* theMain, SUPERV_CNode theNode, 
                                                          SUPERVGUI_CanvasCellNode* theStart):
   SUPERVGUI_CanvasCellNode(mgr, theParent, theMain, theNode)
 {
@@ -439,12 +531,25 @@ SUPERVGUI_CanvasCellEndNode::SUPERVGUI_CanvasCellEndNode( SUIT_ResourceMgr* mgr,
   //set end cell for start cell as pair
   myPairCell->setPairCell(dynamic_cast<SUPERVGUI_CanvasCellNode*>(this));
 }
+
+SUPERVGUI_CanvasCellEndNode* SUPERVGUI_CanvasCellEndNode::Create (SUIT_ResourceMgr* mgr, QObject* theParent, 
+                                                                  SUPERVGUI_Main* theMain,
+                                                                  SUPERV_CNode theNode, 
+                                                                  SUPERVGUI_CanvasCellNode* theStart)
+{
+  SUPERVGUI_CanvasCellEndNode* aRet =
+    new SUPERVGUI_CanvasCellEndNode (mgr, theParent, theMain, theNode, theStart);
+  emit aRet->objectCreatedDeleted();
+  return aRet;
+}
+
 /*
 bool SUPERVGUI_CanvasCellEndNode::setNodeName(QString theName)
 {
   return SUPERVGUI_CanvasNode::setNodeName(theName);
 }
 */
+
 //-----------------------------------------------------------
 //*************** Select Inline node dialog******************
 // Taken from SUPERVGUI_ControlNode.cxx without change