+
+/**
+ * Do the following actions for newly created Engine's CNode:
+ * 1. Create a presentation for it (CanvasNode)
+ * 2. Place the CanvasNode to the current top-left corner or the current viewport
+ * 3. Increment the coordinates of the next CanvasNode (new nodes are "cascaded" when several of them are created at once)
+ * PS theEndNode is passed only for Loop and Switch nodes (EndLoop and EndSwitch)
+ */
+void SUPERVGUI_Service::addNode( SUPERV::CNode_var theNode, SUPERV::INode_var theEndNode, int& theX, int& theY ) {
+ SUPERVGUI_Main* aMain = Supervision.getMain();
+
+ if ( !CORBA::is_nil( theNode ) && aMain ) {
+
+ aMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag, why here? -> PAL7960
+
+ int cx, cy; //to appear a new node in the top-left corner of the current viewport
+
+ //2.8 point of improvements: Adding node to graph window with taking into account zoom factor
+ QWMatrix aWM = aMain->getCanvasView()->worldMatrix();
+ aMain->getCanvasView()->viewportToContents(theX, theY, cx, cy);
+
+ //2.8 point of improvements:
+ cx = (int)((double)cx/aWM.m11());
+ cy = (int)((double)cy/aWM.m22());
+ theNode->Coords(cx, cy);
+ if ( !CORBA::is_nil( theEndNode ) )
+ theEndNode->Coords(cx + LABEL_WIDTH*2, cy);
+ theX += (int)(NODE_DX*aWM.m11());
+ theY += (int)(NODE_DY*aWM.m22());
+
+ if ( theNode->IsGOTO() )
+ aMain->addGOTONode( theNode );
+ else if ( theNode->IsMacro() )
+ aMain->addMacroNode( theNode );
+ else if ( theNode->IsLoop() || theNode->IsSwitch() )
+ aMain->addControlNode( theNode, SUPERV::CNode::_narrow( theEndNode ), true );
+ else
+ aMain->addComputeNode( theNode );
+ }
+}
+