From: mkr Date: Wed, 20 May 2015 12:30:44 +0000 (+0300) Subject: [HYDRO 514] Use specific cursors for edition operations. X-Git-Tag: V7_7_0a1~42^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=720b79f28e41eaee78ad3c1a4d4b12e1e7005eea;p=modules%2Fgui.git [HYDRO 514] Use specific cursors for edition operations. --- diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.cxx b/src/OCCViewer/OCCViewer_ViewPort3d.cxx index 06029fb30..e7ae97c5f 100755 --- a/src/OCCViewer/OCCViewer_ViewPort3d.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort3d.cxx @@ -89,6 +89,8 @@ OCCViewer_ViewPort3d::OCCViewer_ViewPort3d( QWidget* parent, const Handle( V3d_V #endif setBackground( Qtx::BackgroundData( Qt::black ) ); // set default background + + myCursor = NULL; } /*! @@ -96,6 +98,12 @@ OCCViewer_ViewPort3d::OCCViewer_ViewPort3d( QWidget* parent, const Handle( V3d_V */ OCCViewer_ViewPort3d::~OCCViewer_ViewPort3d() { + if ( myCursor ) + { + delete myCursor; + myCursor = NULL; + } + emit vpClosed(this); Handle(V3d_View) aView = activeView(); if (!aView.IsNull()) @@ -764,3 +772,22 @@ void OCCViewer_ViewPort3d::showStaticTrihedron( bool on ) } aView->Update(); } + +/* + * Create default cursor with a specific shape + */ +void OCCViewer_ViewPort3d::setDefaultCursor( Qt::CursorShape theCursorShape ) +{ + if ( !myCursor ) + myCursor = new QCursor(); + + myCursor->setShape( theCursorShape ); +} + +/* + * Get default cursor with a specific shape + */ +QCursor* OCCViewer_ViewPort3d::getDefaultCursor() const +{ + return myCursor; +} diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.h b/src/OCCViewer/OCCViewer_ViewPort3d.h index 9f591a3c6..5ac793fb3 100755 --- a/src/OCCViewer/OCCViewer_ViewPort3d.h +++ b/src/OCCViewer/OCCViewer_ViewPort3d.h @@ -94,6 +94,9 @@ public: void showStaticTrihedron( bool ); + void setDefaultCursor( Qt::CursorShape theCursorShape ); + QCursor* getDefaultCursor() const; + signals: void vpChangeBackground( const Qtx::BackgroundData& ); void vpClosed(OCCViewer_ViewPort3d*); @@ -130,6 +133,7 @@ private: Qtx::BackgroundData myBackground; int myBgImgHeight; int myBgImgWidth; + QCursor* myCursor; }; #ifdef WIN32 diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 57a571e47..7d357e192 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -248,6 +248,7 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop* theDesktop, myPreselectionEnabled = true; mySelectionEnabled = true; + myCursorIsHand = false; clearViewAspects(); @@ -570,7 +571,7 @@ void OCCViewer_ViewWindow::vpMousePressEvent( QMouseEvent* theEvent ) void OCCViewer_ViewWindow::activateZoom() { if ( !transformRequested() && !myCursorIsHand ) - myCursor = cursor(); /* save old cursor */ + saveCursor(); /* save old cursor */ if ( myOperation != ZOOMVIEW ) { QPixmap zoomPixmap (imageZoomCursor); @@ -589,7 +590,7 @@ void OCCViewer_ViewWindow::activateZoom() void OCCViewer_ViewWindow::activatePanning() { if ( !transformRequested() && !myCursorIsHand ) - myCursor = cursor(); // save old cursor + saveCursor(); // save old cursor if ( myOperation != PANVIEW ) { QCursor panCursor (Qt::SizeAllCursor); @@ -606,7 +607,7 @@ void OCCViewer_ViewWindow::activatePanning() void OCCViewer_ViewWindow::activateRotation() { if ( !transformRequested() && !myCursorIsHand ) - myCursor = cursor(); // save old cursor + saveCursor(); // save old cursor if ( myOperation != ROTATE ) { QPixmap rotatePixmap (imageRotateCursor); @@ -816,7 +817,7 @@ void OCCViewer_ViewWindow::activateStartPointSelection( TopAbs_ShapeEnum theShap { QCursor handCursor (Qt::PointingHandCursor); myCursorIsHand = true; - myCursor = cursor(); + saveCursor(); myViewPort->setCursor( handCursor ); } myRotationPointSelection = true; @@ -835,7 +836,7 @@ void OCCViewer_ViewWindow::activateGlobalPanning() QCursor glPanCursor (globalPanPixmap); myCurScale = aView3d->Scale(); aView3d->FitAll(0.01, false); - myCursor = cursor(); // save old cursor + saveCursor(); // save old cursor myViewPort->fitAll(); // fits view before selecting a new scene center if( setTransformRequested( PANGLOBAL ) ) myViewPort->setCursor( glPanCursor ); @@ -850,7 +851,7 @@ void OCCViewer_ViewWindow::activateGlobalPanning() void OCCViewer_ViewWindow::activateWindowFit() { if ( !transformRequested() && !myCursorIsHand ) - myCursor = cursor(); /* save old cursor */ + saveCursor(); /* save old cursor */ if ( myOperation != WINDOWFIT ) { QCursor handCursor (Qt::PointingHandCursor); @@ -945,7 +946,7 @@ void OCCViewer_ViewWindow::vpMouseMoveEvent( QMouseEvent* theEvent ) if ( !myCursorIsHand ) { // we are going to sketch a rectangle QCursor handCursor (Qt::PointingHandCursor); myCursorIsHand = true; - myCursor = cursor(); + saveCursor(); myViewPort->setCursor( handCursor ); } } @@ -2488,6 +2489,18 @@ void OCCViewer_ViewWindow::hideEvent( QHideEvent* theEvent ) } +/*! + Save old cursor. [ protected ] +*/ +void OCCViewer_ViewWindow::saveCursor() +{ + QCursor* aCursor = NULL; + if ( myViewPort ) + aCursor = myViewPort->getDefaultCursor(); + myCursor = ( aCursor ? *aCursor : cursor() ); +} + + /*! Creates default sketcher. [ virtual protected ] */ diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index 9e46e3a90..088249714 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -329,6 +329,8 @@ protected: virtual OCCViewer_ViewSketcher* createSketcher( int ); + void saveCursor(); + OCCViewer_ViewSketcher* mypSketcher; QList mySketchers;