From 59120096cc22136bcc3ebc9c24dd1d1ced35955d Mon Sep 17 00:00:00 2001 From: mkr Date: Thu, 16 Dec 2004 12:33:43 +0000 Subject: [PATCH] Point 2.8 of "SUPERVISOR: Current status - bugs/improvements": Adding node to graph window with taking into account zoom factor. --- src/SUPERVGUI/SUPERVGUI_Service.cxx | 78 +++++++++++++++++++---------- 1 file changed, 52 insertions(+), 26 deletions(-) diff --git a/src/SUPERVGUI/SUPERVGUI_Service.cxx b/src/SUPERVGUI/SUPERVGUI_Service.cxx index fe0c91f..78bed9c 100644 --- a/src/SUPERVGUI/SUPERVGUI_Service.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Service.cxx @@ -397,10 +397,15 @@ void SUPERVGUI_Service::addComputeNode() { } //to appear a new node in the top-left corner of the current viewport int cx, cy; + //2.8 point of improvements: Adding node to graph window with taking into account zoom factor + QWMatrix aWM = aMain->getCanvasView()->worldMatrix(); aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy); + //2.8 point of improvements: + cx = (int)((double)cx/aWM.m11()); + cy = (int)((double)cy/aWM.m22()); node->Coords(cx, cy); - myX += NODE_DX; - myY += NODE_DY; + myX += (int)(NODE_DX*aWM.m11()); + myY += (int)(NODE_DY*aWM.m22()); aMain->addComputeNode(SUPERV::CNode::_narrow(node)); } } @@ -445,6 +450,10 @@ void SUPERVGUI_Service::addFactoryNode() { MESSAGE ( " myService->TypeOfNode == " << myService->TypeOfNode ) int cx, cy; + + //2.8 point of improvements: Adding node to graph window with taking into account zoom factor + QWMatrix aWM = aMain->getCanvasView()->worldMatrix(); + if ( myService->TypeOfNode == 0 ) { // ComputeNode SUPERV_CNode node = aMain->getDataflow()->CNode(*myService); if (CORBA::is_nil(node)) { @@ -453,9 +462,12 @@ void SUPERVGUI_Service::addFactoryNode() { } //to appear a new node in the top-left corner of the current viewport aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy); + //2.8 point of improvements: + cx = (int)((double)cx/aWM.m11()); + cy = (int)((double)cy/aWM.m22()); node->Coords(cx, cy); - myX += NODE_DX; - myY += NODE_DY; + myX += (int)(NODE_DX*aWM.m11()); + myY += (int)(NODE_DY*aWM.m22()); aMain->addComputeNode(SUPERV::CNode::_narrow(node)); } else { // Factory Node SUPERV_FNode node = aMain->getDataflow()->FNode(component, interface, *myService); @@ -465,22 +477,15 @@ void SUPERVGUI_Service::addFactoryNode() { } //to appear a new node in the top-left corner of the current viewport aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy); + //2.8 point of improvements: + cx = (int)((double)cx/aWM.m11()); + cy = (int)((double)cy/aWM.m22()); node->Coords(cx, cy); - myX += NODE_DX; - myY += NODE_DY; + myX += (int)(NODE_DX*aWM.m11()); + myY += (int)(NODE_DY*aWM.m22()); aMain->addComputeNode(SUPERV::CNode::_narrow(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")); -// return; -// } -// node->Coords(myX, myY); -// myX += NODE_DX; -// myY += NODE_DY; -// aMain->addComputeNode(SUPERV::CNode::_narrow(node)); } } } @@ -501,6 +506,10 @@ void SUPERVGUI_Service::addInlineNode() { } else { int aSel = myTypeCombo->currentItem(); int cx, cy; + + //2.8 point of improvements: Adding node to graph window with taking into account zoom factor + QWMatrix aWM = aMain->getCanvasView()->worldMatrix(); + switch (aSel) { case 0: // Computation { @@ -512,9 +521,12 @@ void SUPERVGUI_Service::addInlineNode() { } //to appear a new node in the top-left corner of the current viewport aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy); + //2.8 point of improvements: + cx = (int)((double)cx/aWM.m11()); + cy = (int)((double)cy/aWM.m22()); aNode->Coords(cx, cy); - myX += NODE_DX; - myY += NODE_DY; + myX += (int)(NODE_DX*aWM.m11()); + myY += (int)(NODE_DY*aWM.m22()); aMain->addComputeNode(SUPERV::CNode::_narrow(aNode)); } break; @@ -531,10 +543,13 @@ void SUPERVGUI_Service::addInlineNode() { } //to appear a new node in the top-left corner of the current viewport aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy); + //2.8 point of improvements: + cx = (int)((double)cx/aWM.m11()); + cy = (int)((double)cy/aWM.m22()); aStartNode->Coords(cx, cy); aEndNode->Coords(cx + LABEL_WIDTH*2, cy); - myX += NODE_DX; - myY += NODE_DY; + myX += (int)(NODE_DX*aWM.m11()); + myY += (int)(NODE_DY*aWM.m22()); aMain->addControlNode(SUPERV::CNode::_narrow(aStartNode), SUPERV::CNode::_narrow(aEndNode), true); } break; @@ -552,10 +567,13 @@ void SUPERVGUI_Service::addInlineNode() { } //to appear a new node in the top-left corner of the current viewport aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy); + //2.8 point of improvements: + cx = (int)((double)cx/aWM.m11()); + cy = (int)((double)cy/aWM.m22()); aStartNode->Coords(cx, cy); aEndNode->Coords(cx + LABEL_WIDTH*2, cy); - myX += NODE_DX; - myY += NODE_DY; + myX += (int)(NODE_DX*aWM.m11()); + myY += (int)(NODE_DY*aWM.m22()); aMain->addControlNode(SUPERV::CNode::_narrow(aStartNode), SUPERV::CNode::_narrow(aEndNode), true); } break; @@ -574,9 +592,12 @@ void SUPERVGUI_Service::addInlineNode() { } //to appear a new node in the top-left corner of the current viewport aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy); + //2.8 point of improvements: + cx = (int)((double)cx/aWM.m11()); + cy = (int)((double)cy/aWM.m22()); aGotoNode->Coords(cx, cy); - myX += NODE_DX; - myY += NODE_DY; + myX += (int)(NODE_DX*aWM.m11()); + myY += (int)(NODE_DY*aWM.m22()); aMain->addGOTONode(SUPERV::GNode::_narrow(aGotoNode)); } break; @@ -610,10 +631,15 @@ void SUPERVGUI_Service::addMacroNode() { } //to appear a new node in the top-left corner of the current viewport int cx, cy; + //2.8 point of improvements: Adding node to graph window with taking into account zoom factor + QWMatrix aWM = aMain->getCanvasView()->worldMatrix(); aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy); + //2.8 point of improvements: + cx = (int)((double)cx/aWM.m11()); + cy = (int)((double)cy/aWM.m22()); aNode->Coords(cx, cy); - myX += NODE_DX; - myY += NODE_DY; + myX += (int)(NODE_DX*aWM.m11()); + myY += (int)(NODE_DY*aWM.m22()); aMain->addMacroNode(SUPERV::CNode::_narrow(aNode)); } else { -- 2.39.2