From: mkr Date: Fri, 20 Apr 2007 07:53:52 +0000 (+0000) Subject: Improve resize of Bloc nodes in expanded mode (take into account zoom factor). X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b78743dae9d24bcdcf427750f5ef6cc8c5b0fa10;p=modules%2Fgui.git Improve resize of Bloc nodes in expanded mode (take into account zoom factor). --- diff --git a/src/QxGraph/QxGraph_ActiveItem.h b/src/QxGraph/QxGraph_ActiveItem.h index 728be6a12..4f84089ca 100644 --- a/src/QxGraph/QxGraph_ActiveItem.h +++ b/src/QxGraph/QxGraph_ActiveItem.h @@ -22,6 +22,7 @@ #include "QxGraph.h" #include +#include class QXGRAPH_EXPORT QxGraph_ActiveItem { @@ -44,6 +45,12 @@ class QXGRAPH_EXPORT QxGraph_ActiveItem virtual void showPopup() = 0; virtual QString getToolTipText(const QPoint& theMousePos, QRect& theRect) const = 0; + + void setTMatrix(QWMatrix theMatrix) { myTMatrix = theMatrix; } + QWMatrix getTMatrix() const { return myTMatrix; } + + private: + QWMatrix myTMatrix; // canvas view's current transformation matrix }; #endif diff --git a/src/QxGraph/QxGraph_CanvasView.cxx b/src/QxGraph/QxGraph_CanvasView.cxx index b09654846..fdc5c6b5b 100644 --- a/src/QxGraph/QxGraph_CanvasView.cxx +++ b/src/QxGraph/QxGraph_CanvasView.cxx @@ -242,7 +242,14 @@ void QxGraph_CanvasView::contentsMouseMoveEvent(QMouseEvent* theEvent) QWMatrix m = worldMatrix(); m.scale(s, s); setWorldMatrix(m); - + + // remember the canvas view's current transformation matrix in all canvas items + QCanvasItemList aList = canvas()->allItems(); + for (QCanvasItemList::Iterator it = aList.begin(); it != aList.end(); ++it) { + QxGraph_ActiveItem* anActItem = dynamic_cast( *it ); + if ( anActItem ) anActItem->setTMatrix(m); + } + myGlobalPoint = aGlobalPoint; return; } @@ -416,6 +423,14 @@ void QxGraph_CanvasView::contentsMouseReleaseEvent(QMouseEvent* theEvent) QWMatrix m; m.scale(aXzoom, aXzoom); setWorldMatrix(m); + + // remember the canvas view's current transformation matrix in all canvas items + QCanvasItemList aList = canvas()->allItems(); + for (QCanvasItemList::Iterator it = aList.begin(); it != aList.end(); ++it) { + QxGraph_ActiveItem* anActItem = dynamic_cast( *it ); + if ( anActItem ) anActItem->setTMatrix(m); + } + setContentsPos((int)(aLX*aXzoom), (int)(aTY*aYzoom)); canvas()->update(); @@ -528,6 +543,14 @@ void QxGraph_CanvasView::activateFitAll() QWMatrix m; m.scale(s, s); setWorldMatrix(m); + + // remember the canvas view's current transformation matrix in all canvas items + QCanvasItemList aList = canvas()->allItems(); + for (QCanvasItemList::Iterator it = aList.begin(); it != aList.end(); ++it) { + QxGraph_ActiveItem* anActItem = dynamic_cast( *it ); + if ( anActItem ) anActItem->setTMatrix(m); + } + canvas()->update(); //myOperation = NOTHING; } @@ -575,6 +598,14 @@ void QxGraph_CanvasView::activateReset() setContentsPos(0,0); QWMatrix m; setWorldMatrix(m); + + // remember the canvas view's current transformation matrix in all canvas items + QCanvasItemList aList = canvas()->allItems(); + for (QCanvasItemList::Iterator it = aList.begin(); it != aList.end(); ++it) { + QxGraph_ActiveItem* anActItem = dynamic_cast( *it ); + if ( anActItem ) anActItem->setTMatrix(m); + } + //myOperation = NOTHING; }