From b21d854d78f5e595afad0c17373f18e2160366a5 Mon Sep 17 00:00:00 2001 From: mkr Date: Tue, 29 May 2007 10:34:13 +0000 Subject: [PATCH] Porting to Qt4. --- src/OCCViewer/OCCViewer_ViewWindow.cxx | 33 ++++++++++++++++++++------ src/OCCViewer/OCCViewer_ViewWindow.h | 8 +++++-- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 935d4dc78..4fe1ad855 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -189,6 +189,15 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_V updateEnabledDrawMode(); myClippingDlg = 0; mySetRotationPointDlg = 0; + myRectBand = 0; +} + +/*! + \brief Destructor. +*/ +OCCViewer_ViewWindow::~OCCViewer_ViewWindow() +{ + endDrawRect(); } /*! @@ -754,6 +763,7 @@ void OCCViewer_ViewWindow::vpMouseReleaseEvent(QMouseEvent* theEvent) if ( theEvent->button() == Qt::LeftButton && myDrawRect ) { myDrawRect = false; drawRect(); + endDrawRect(); resetState(); myViewPort->update(); } @@ -796,17 +806,26 @@ void OCCViewer_ViewWindow::resetState() */ void OCCViewer_ViewWindow::drawRect() { - QRubberBand* aRB = new QRubberBand( QRubberBand::Rectangle, myViewPort ); + if ( !myRectBand ) + myRectBand = new QRubberBand( QRubberBand::Rectangle, myViewPort ); + QRect aRect = SUIT_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY); if ( !myRect.isEmpty() ) { - aRB->setGeometry( myRect ); - aRB->setVisible( myRect.isValid() ); + myRectBand->setGeometry( myRect ); + myRectBand->setVisible( myRect.isValid() ); } - aRB->setGeometry( aRect ); - aRB->setVisible( aRect.isValid() ); + myRectBand->setGeometry( aRect ); + myRectBand->setVisible( aRect.isValid() ); myRect = aRect; - - delete aRB; +} + +/*! + \brief Delete rubber band on the end on the dragging operation. +*/ +void OCCViewer_ViewWindow::endDrawRect() +{ + delete myRectBand; + myRectBand = 0; } /*! diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index 2d3d2aa37..86f4c7c42 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -27,6 +27,8 @@ #include +class QRubberBand; + class SUIT_Desktop; class OCCViewer_ViewPort3d; @@ -49,7 +51,7 @@ public: enum RotationPointType{ GRAVITY, SELECTED }; OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel); - virtual ~OCCViewer_ViewWindow() {}; + virtual ~OCCViewer_ViewWindow(); OCCViewer_ViewPort3d* getViewPort() { return myViewPort; } @@ -134,6 +136,7 @@ protected: void resetState(); void drawRect(); + void endDrawRect(); void createActions(); void createToolBar(); @@ -180,7 +183,8 @@ private: OCCViewer_SetRotationPointDlg* mySetRotationPointDlg; QtxAction* mySetRotationPointAction; - + + QRubberBand* myRectBand; //!< selection rectangle rubber band }; #ifdef WIN32 -- 2.39.2