document : Move segment of link.
void SUPERVGUI_CanvasPointPrs::setInEdge(SUPERVGUI_CanvasEdgePrs* theEdge)
{
myInEdge = theEdge;
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;
}
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);
}
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;
//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;
}
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::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);
+ }
+}
+
SUPERVGUI_CanvasLink* getLink() const { return myLink; }
SUPERVGUI_CanvasLink* getLink() const { return myLink; }
- void setFromPoint(int x, int y);
- void setToPoint(int x, int y);
+ void setFromPoint(SUPERVGUI_CanvasPointPrs* thePoint);
+ void setToPoint(SUPERVGUI_CanvasPointPrs* thePoint);
- void moveBy(double dx, double dy) {}
+ void moveBy(double dx, double dy);
void setColor(const QColor& theColor);
void setColor(const QColor& theColor);
+ void setMoving(bool b) { myMoving = b; }
+ bool isMoving() const { return myMoving; }
+
virtual int rtti() const;
private:
virtual int rtti() const;
private:
SUPERVGUI_CanvasLink* myLink;
SUPERVGUI_CanvasLink* myLink;
+
+ //mkr: for moving segment of link
+ SUPERVGUI_CanvasPointPrs* myStartPoint;
+ SUPERVGUI_CanvasPointPrs* myEndPoint;
+ if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge) {
+ //mkr: for moving segment of link
+ SUPERVGUI_CanvasEdgePrs* aPrs = (SUPERVGUI_CanvasEdgePrs*) (*it);
+ if (aPrs->getLink()->getInputPort()->getConnectionPoint() == aPrs->startPoint()
+ ||
+ aPrs->getLink()->getInputPort()->getConnectionPoint() == aPrs->endPoint()
+ ||
+ aPrs->getLink()->getOutputPort()->getConnectionPoint() == aPrs->startPoint()
+ ||
+ aPrs->getLink()->getOutputPort()->getConnectionPoint() == aPrs->endPoint()) {
+ return;
+ }
+ myCurrentItem = *it;
+ aPrs->setMoving(true);
+ return;
+ }
if (myCurrentItem) {
// setHilighted(0);
if (myCurrentItem) {
// setHilighted(0);
- double cx = myCurrentItem->x() - myPoint.x();
- double cy = myCurrentItem->y() - myPoint.y();
- if (p.x()+cx < 0) p.setX(-(int)cx);
- if (p.y()+cy < 0) p.setY(-(int)cy);
+ if (myCurrentItem->x() && myCurrentItem->y()) {
+ double cx = myCurrentItem->x() - myPoint.x();
+ double cy = myCurrentItem->y() - myPoint.y();
+
+ if (p.x()+cx < 0) p.setX(-(int)cx);
+ if (p.y()+cy < 0) p.setY(-(int)cy);
+ }
myCurrentItem->moveBy(p.x() - myPoint.x(),
p.y() - myPoint.y());
myPoint = p;
myCurrentItem->moveBy(p.x() - myPoint.x(),
p.y() - myPoint.y());
myPoint = p;