// SUPERV SUPERVGUI : GUI for Supervisor component
//
-// Copyright (C) 2003 OPEN CASCADE
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : SUPERVGUI_GanvasNodePrs.cxx
// Author : Natalia KOPNOVA
// Module : SUPERV
-using namespace std;
#include "SUPERVGUI_CanvasLink.h"
#include "SUPERVGUI_Canvas.h"
#include "SUPERVGUI_CanvasPort.h"
else
myColor = DRAW_COLOR;
}
+
+ // mkr : PAL8237
+ connect(this, SIGNAL(objectCreatedDeleted()), myMain, SLOT(onObjectCreatedDeleted()));
}
SUPERVGUI_CanvasLink::~SUPERVGUI_CanvasLink()
addPoint(myInputPort->getConnectionPoint());
}
if (!myMain->getCanvas()->isControlView()) {
- long x, y;
- for (int i = 0; i < myLink->CoordsSize(); i++) {
+ CORBA::Long x, y;
+ for (CORBA::Long i = 0; i < myLink->CoordsSize(); i++) {
myLink->Coords(i+1, x, y);
addPoint(QPoint(x, y), i+1);
}
}
void SUPERVGUI_CanvasLink::remove() {
+ // IPAL9369 : check the dataflow readiness to modify
+ if ( !myMain->ReadyToModify() ) // null dataflow or executing, ..
+ return;
+
+ myMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag
+
QString aValue;
SUPERVGUI_CanvasPortIn* aPort = 0;
SUPERVGUI_Canvas* aCanvas = myMain->getCanvas();
}
}
myLink->destroy();
+
+ emit objectCreatedDeleted(); // mkr : PAL8237
}
+
delete this;
if (aPort && !aValue.isEmpty() && myMain->getDataflow()->GraphLevel() == 0) {
aPort->setValue(aValue);
anIndex = aPoint->getIndex()+1;
if (anIndex < 1) anIndex = 1;
}
- if (myLink && !SUPERV_isNull(myLink))
+ if (myLink && !SUPERV_isNull(myLink)) {
myLink->AddCoord(anIndex, mySelectedPoint.x(), mySelectedPoint.y());
+ emit objectCreatedDeleted(); // mkr : PAL8237
+ }
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))
+ if (myLink && !SUPERV_isNull(myLink)) {
myLink->RemoveCoord(aPoint->getIndex());
+ emit objectCreatedDeleted(); // mkr : PAL8237
+ }
merge();
myMain->getCanvas()->update();
}
}
+QString SUPERVGUI_CanvasLink::getToolTipText() const {
+ QString aTTT;
+ if (myInputPort && myOutputPort)
+ aTTT = myOutputPort->getEngine()->Node()->Name() + QString(" : ") +
+ myOutputPort->getEngine()->Name() + QString(" => ") +
+ myInputPort->getEngine()->Node()->Name() + QString(" : ") +
+ myInputPort->getEngine()->Name();
+ return aTTT;
+}
+
/*
//===============================================================================
// SUPERVGUI_CanvasStreamLink: new link to be created
bool SUPERVGUI_CanvasLinkBuilder::canCreateEngine(SUPERVGUI_CanvasPort* thePort)
{
- bool result = false;
if (thePort && myPort) {
SUPERVGUI_CanvasPort* aInPort;
SUPERVGUI_CanvasPort* aOutPort;
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
(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
+ // mkr : NPAL14823 : Out Gate port can be connected to Inline port too
+ if ( aOutKind == SUPERV::GateParameter && aInKind != SUPERV::GateParameter && aInKind != 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())
+ // 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)
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;
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);
+ }
+}
+