Salome HOME
[HYDRO 514] Use specific cursors for edition operations.
authormkr <mkr@opencascade.com>
Wed, 20 May 2015 12:30:44 +0000 (15:30 +0300)
committermkr <mkr@opencascade.com>
Wed, 20 May 2015 12:30:44 +0000 (15:30 +0300)
src/OCCViewer/OCCViewer_ViewPort3d.cxx
src/OCCViewer/OCCViewer_ViewPort3d.h
src/OCCViewer/OCCViewer_ViewWindow.cxx
src/OCCViewer/OCCViewer_ViewWindow.h

index 06029fb30c09cf042bc534d694c289be73e27bb0..e7ae97c5f52ae20b91885853b1b87ea024671e3f 100755 (executable)
@@ -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;
+}
index 9f591a3c63aa44196fc5620ed6efb4eb8f5c6289..5ac793fb399b4d0b65b2bb1a189268f0d0a1a3e3 100755 (executable)
@@ -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
index 57a571e477afef89a44c5afd359796c6d3b7c7eb..7d357e1927336db0bbba59fc5ca8ce5f87dc91e4 100755 (executable)
@@ -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 ]
 */
index 9e46e3a907ceb3f9f20c42e32cab479637812bb7..088249714aaa3d344fc6d20120fd50ff800ef7f9 100755 (executable)
@@ -329,6 +329,8 @@ protected:
 
   virtual OCCViewer_ViewSketcher*       createSketcher( int );
 
+  void                                  saveCursor();
+
   OCCViewer_ViewSketcher*               mypSketcher;
   QList<OCCViewer_ViewSketcher*>        mySketchers;