]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Modifications to edit links presentations : add and delete links points,
authormkr <mkr@opencascade.com>
Wed, 25 Apr 2007 14:32:37 +0000 (14:32 +0000)
committermkr <mkr@opencascade.com>
Wed, 25 Apr 2007 14:32:37 +0000 (14:32 +0000)
move links points and links edges.

src/QxGraph/QxGraph_ActiveItem.h
src/QxGraph/QxGraph_CanvasView.cxx
src/QxGraph/QxGraph_CanvasView.h

index 4f84089caded0016900841fb25e6aa7543a68620..fc9f008e7b9dd299759f5c732849a59b35a562f5 100644 (file)
@@ -22,7 +22,8 @@
 #include "QxGraph.h"
 
 #include <qpoint.h>
-#include <qwmatrix.h> 
+#include <qwmatrix.h>
+#include <qevent.h>
 
 class QXGRAPH_EXPORT QxGraph_ActiveItem
 {
@@ -42,10 +43,12 @@ class QXGRAPH_EXPORT QxGraph_ActiveItem
 
   virtual void hilight(const QPoint& theMousePos, const bool toHilight = true) = 0;
   virtual void select(const QPoint& theMousePos, const bool toSelect = true) = 0;
-  virtual void showPopup() = 0;
+  virtual void showPopup(QWidget* theParent, QMouseEvent* theEvent, const QPoint& theMousePos = QPoint()) = 0;
 
   virtual QString getToolTipText(const QPoint& theMousePos, QRect& theRect) const = 0;
 
+  virtual bool arePartsOfOtherItem(QxGraph_ActiveItem* theSecondItem) { return false; }
+
   void setTMatrix(QWMatrix theMatrix) { myTMatrix = theMatrix; }
   QWMatrix getTMatrix() const { return myTMatrix; }
 
index 7cfc82d6d2963efb904a9ad131440db98158f7c6..a563bc5c2f5ed4696e65abb915bcf974871d40ad 100644 (file)
@@ -459,9 +459,15 @@ void QxGraph_CanvasView::contentsMouseReleaseEvent(QMouseEvent* theEvent)
        anActItem->select(aPoint);
        if (anActItem != mySelectedItem) 
        {
-         if (mySelectedItem)
-           mySelectedItem->select(aPoint, false);
+         if (mySelectedItem && isSelectedItemInCanvas() &&
+             !mySelectedItem->arePartsOfOtherItem(anActItem)) mySelectedItem->select(aPoint, false);
          mySelectedItem = anActItem;
+
+         // unhilight hilighted item if selection was performed
+         if (myHilightedItem) {
+           myHilightedItem->hilight(aPoint, false);
+           myHilightedItem = 0;
+         }
        }
        isSelectionPerformed = true;
       }
@@ -471,8 +477,8 @@ void QxGraph_CanvasView::contentsMouseReleaseEvent(QMouseEvent* theEvent)
     { 
       if ( mySelectedItem )
       {
-      mySelectedItem->select(aPoint, false);
-      mySelectedItem = 0;
+       if ( isSelectedItemInCanvas() ) mySelectedItem->select(aPoint, false);
+       mySelectedItem = 0;
       }
       
       // Background popup
@@ -485,7 +491,7 @@ void QxGraph_CanvasView::contentsMouseReleaseEvent(QMouseEvent* theEvent)
     }
     else
     { // show context popup for the selected item
-      
+      mySelectedItem->showPopup(viewport(), theEvent, aPoint);
     }
   }
 
@@ -496,7 +502,7 @@ void QxGraph_CanvasView::contentsMouseReleaseEvent(QMouseEvent* theEvent)
 
     if ( aList.empty() && mySelectedItem )
     {
-      mySelectedItem->select(aPoint, false);
+      if ( isSelectedItemInCanvas() ) mySelectedItem->select(aPoint, false);
       mySelectedItem = 0;
     }
     else
@@ -508,8 +514,8 @@ void QxGraph_CanvasView::contentsMouseReleaseEvent(QMouseEvent* theEvent)
          anActItem->select(aPoint);
          if (anActItem != mySelectedItem) 
          {
-           if (mySelectedItem)
-             mySelectedItem->select(aPoint, false);
+           if (mySelectedItem && isSelectedItemInCanvas() &&
+               !mySelectedItem->arePartsOfOtherItem(anActItem)) mySelectedItem->select(aPoint, false);
            mySelectedItem = anActItem;
          }
          break;
@@ -521,7 +527,24 @@ void QxGraph_CanvasView::contentsMouseReleaseEvent(QMouseEvent* theEvent)
 
 void QxGraph_CanvasView::contentsMouseDoubleClickEvent(QMouseEvent* theEvent)
 {
+  
+}
 
+bool QxGraph_CanvasView::isSelectedItemInCanvas()
+{
+  // check if mySelectedItem is included into the canvas:
+  // if yes => unselect it
+  // if no => do nothing
+  bool anIsInCanvas = false;
+  QCanvasItemList aListC = canvas()->allItems();
+  for (QCanvasItemList::Iterator itC = aListC.begin(); itC != aListC.end(); ++itC) {
+    QxGraph_ActiveItem* anActItemC = dynamic_cast<QxGraph_ActiveItem*>( *itC );
+    if ( anActItemC && anActItemC == mySelectedItem ) {
+      anIsInCanvas = true;
+      break;
+    }
+  }
+  return anIsInCanvas;
 }
 
 void QxGraph_CanvasView::activateFitAll()
index 484f7f97841f4c8f9d97e29e19488a65d0fe9f23..5bd14f7404f1dc120c4c24e56df9b07323da1da2 100644 (file)
@@ -63,6 +63,8 @@ class QXGRAPH_EXPORT QxGraph_CanvasView : public QCanvasView {
   void contentsMouseReleaseEvent(QMouseEvent* theEvent); 
   void contentsMouseDoubleClickEvent(QMouseEvent* theEvent);
 
+  bool isSelectedItemInCanvas();
+
  private:
   // for moving items
   QCanvasItem*      myCurrentItem;