X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSUPERVGUI%2FSUPERVGUI_CanvasLink.cxx;h=4855b18adae231260f802b0680c3b23c39977385;hb=ea7f29f75031ca13b9454f5e9ac73730f1f584eb;hp=4ed27d15d741bcbf2d62166426ce14cf7768a114;hpb=b7b531f894fd0a967071ce2b05e0ced7b4743f3b;p=modules%2Fsuperv.git diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasLink.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasLink.cxx index 4ed27d1..4855b18 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasLink.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasLink.cxx @@ -214,6 +214,8 @@ void SUPERVGUI_CanvasLink::setColor(const QColor& theColor) } void SUPERVGUI_CanvasLink::remove() { + myMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag + QString aValue; SUPERVGUI_CanvasPortIn* aPort = 0; SUPERVGUI_Canvas* aCanvas = myMain->getCanvas(); @@ -324,7 +326,6 @@ SUPERVGUI_CanvasLinkBuilder::~SUPERVGUI_CanvasLinkBuilder() bool SUPERVGUI_CanvasLinkBuilder::canCreateEngine(SUPERVGUI_CanvasPort* thePort) { - bool result = false; if (thePort && myPort) { SUPERVGUI_CanvasPort* aInPort; SUPERVGUI_CanvasPort* aOutPort; @@ -343,17 +344,10 @@ bool SUPERVGUI_CanvasLinkBuilder::canCreateEngine(SUPERVGUI_CanvasPort* thePort) aInPort = thePort; } - // control if node is different + // control if nodes are different, not the same node 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) + if (aInNode.compare(aOutNode) == 0) // linking outport and inport of the same node return false; // control types of ports @@ -365,23 +359,30 @@ bool SUPERVGUI_CanvasLinkBuilder::canCreateEngine(SUPERVGUI_CanvasPort* thePort) (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; - } + // asv : 15.12.04 : NOT allow to connect Gate-to-InLine --> it does not make sence! + // Out Gate port can be connected only to In Gate port + if ( aOutKind == SUPERV::GateParameter && aInKind != SUPERV::GateParameter ) + 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()) + // In Gate can be connected to (receive links from) Gate port and InLine ports (important for Switch nodes) + if ( aInKind == SUPERV::GateParameter && aOutKind != SUPERV::GateParameter && aOutKind != SUPERV::InLineParameter ) return false; - } - result = true; + + // asv : 15.12.04 : PAL7374, p.2.2 "Bugs and Improvements": multiple links into Gate port + // for InGate it's OK to accept more than 1 link + // THESE NEEDS REVISION, ALSO DON'T ALLOW MANY LINKS TO "DEFAULT" PORT OF EndSwitch + //if ( aInPort->getEngine()->IsLinked() && aInKind != SUPERV::GateParameter ) + + // control if port is already linked except for input inline ports of end switch node (check for EndSwitchParameter) + // and "Default" port of Switch node (check for aNode->isEndSwitch()). "Default" port is linked by default, but we + // let it to be "re-linked" to another port. + const bool isEndSwitch = ( aInKind == SUPERV::EndSwitchParameter || aInPort->getEngine()->Node()->IsEndSwitch() ); + if ( !isEndSwitch && aInPort->getEngine()->IsLinked() ) + return false; + + return true; } - return result; + return false; } void SUPERVGUI_CanvasLinkBuilder::setCoords(SUPERV::Link_ptr theLink) @@ -508,20 +509,26 @@ int SUPERVGUI_CanvasPointPrs::rtti() const void SUPERVGUI_CanvasPointPrs::setInEdge(SUPERVGUI_CanvasEdgePrs* theEdge) { myInEdge = theEdge; - theEdge->setFromPoint((int)x(), (int)y()); + theEdge->setFromPoint(this); } void SUPERVGUI_CanvasPointPrs::setOutEdge(SUPERVGUI_CanvasEdgePrs* theEdge) { myOutEdge = theEdge; - theEdge->setToPoint((int)x(), (int)y()); + theEdge->setToPoint(this); } 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 (myInEdge) myInEdge->setFromPoint(this); + if (myOutEdge) myOutEdge->setToPoint(this); + //resize canvas view if mouse is outside + int w = (int)(x()+dx) + width() + GRAPH_MARGIN; + int h = (int)(y()+dy) + 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); if (myIndex > 0 && isMoving()) { myLink->getEngine()->ChangeCoord(myIndex, (int)x(), (int)y()); } @@ -548,17 +555,32 @@ int SUPERVGUI_CanvasEdgePrs::rtti() const return SUPERVGUI_Canvas::Rtti_LinkEdge; } -void SUPERVGUI_CanvasEdgePrs::setFromPoint(int x, int y) +void SUPERVGUI_CanvasEdgePrs::setFromPoint(SUPERVGUI_CanvasPointPrs* thePoint) { - setPoints(x, y, endPoint().x(), endPoint().y()); + myStartPoint = thePoint; + setPoints((int)(thePoint->x()), (int)(thePoint->y()), endPoint().x(), endPoint().y()); } -void SUPERVGUI_CanvasEdgePrs::setToPoint(int x, int y) +void SUPERVGUI_CanvasEdgePrs::setToPoint(SUPERVGUI_CanvasPointPrs* thePoint) { - setPoints(startPoint().x(), startPoint().y(), x, y); + myEndPoint = thePoint; + setPoints(startPoint().x(), startPoint().y(), (int)(thePoint->x()), (int)(thePoint->y())); } void SUPERVGUI_CanvasEdgePrs::setColor(const QColor& theColor) { setPen(QPen(theColor, LINE_WIDTH)); } + +void SUPERVGUI_CanvasEdgePrs::moveBy(double dx, double dy) +{ + //mkr: for moving segment of link + if (myStartPoint && myEndPoint) { + myStartPoint->setMoving(true); + myStartPoint->moveBy(dx, dy); + + myEndPoint->setMoving(true); + myEndPoint->moveBy(dx,dy); + } +} +