Salome HOME
Point 2.12 from "SUPERVISOR: Current status - bugs/improvements"
authormkr <mkr@opencascade.com>
Tue, 21 Dec 2004 08:30:40 +0000 (08:30 +0000)
committermkr <mkr@opencascade.com>
Tue, 21 Dec 2004 08:30:40 +0000 (08:30 +0000)
document : Move segment of link.

src/SUPERVGUI/SUPERVGUI_CanvasLink.cxx
src/SUPERVGUI/SUPERVGUI_CanvasLink.h
src/SUPERVGUI/SUPERVGUI_CanvasView.cxx

index 5a15d84290d040994e507b7cc2b23da5e69a7d8b..08ad4a67e86377cee53260d75d4b6622a32bd9e1 100644 (file)
@@ -510,20 +510,20 @@ 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;
@@ -556,17 +556,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);
+  }
+}
+
index cb54d0c2534a5a96cc9bfd5c5f1707d27816c497..3865950d8cf953d8cf54e37b7dd40f3588334239 100644 (file)
@@ -151,16 +151,24 @@ class SUPERVGUI_CanvasEdgePrs : public QCanvasLine
 
     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 setMoving(bool b) { myMoving = b; }
+    bool isMoving() const { return myMoving; }
+
     virtual int rtti() const;
 
   private:
+    bool myMoving;
     SUPERVGUI_CanvasLink* myLink;
+
+    //mkr: for moving segment of link
+    SUPERVGUI_CanvasPointPrs* myStartPoint;
+    SUPERVGUI_CanvasPointPrs* myEndPoint;
 };
 
 #endif
index 5b5b7b01e8f081e79a7790cef9fa5425953b15f7..ea908fc6e25ab16971c417f9e2cd44e657838808 100644 (file)
@@ -265,6 +265,22 @@ void SUPERVGUI_CanvasView::contentsMousePressEvent(QMouseEvent* theEvent)
            return;
          }
        }
+       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;
+       }
       }
 //  }
   }
@@ -289,10 +305,13 @@ void SUPERVGUI_CanvasView::contentsMouseMoveEvent(QMouseEvent* theEvent)
       
   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;