]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #514: use specific cursors for edition operations.
authormkr <mkr@opencascade.com>
Fri, 15 May 2015 14:52:37 +0000 (17:52 +0300)
committermkr <mkr@opencascade.com>
Fri, 15 May 2015 14:52:37 +0000 (17:52 +0300)
21 files changed:
src/HYDROGUI/HYDROGUI_ImportImageOp.cxx
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Module.h
src/HYDROGUI/HYDROGUI_Operation.cxx
src/HYDROGUI/HYDROGUI_Operation.h
src/HYDROGUI/HYDROGUI_PolylineOp.cxx
src/HYDROGUI/HYDROGUI_PrsImage.cxx
src/HYDROGUI/HYDROGUI_PrsImage.h
src/HYDROGUI/resources/icon_cursor_10.png
src/HYDROGUI/resources/icon_cursor_11.png
src/HYDROGUI/resources/icon_cursor_12.png
src/HYDROGUI/resources/icon_cursor_13.png
src/HYDROGUI/resources/icon_cursor_14.png
src/HYDROGUI/resources/icon_cursor_15.png
src/HYDROGUI/resources/icon_cursor_16.png
src/HYDROGUI/resources/icon_cursor_4.png
src/HYDROGUI/resources/icon_cursor_5.png
src/HYDROGUI/resources/icon_cursor_6.png
src/HYDROGUI/resources/icon_cursor_7.png
src/HYDROGUI/resources/icon_cursor_8.png
src/HYDROGUI/resources/icon_cursor_9.png

index 6a28b63737811f8a6b2001d00188982451c4f65c..12a71ec54cd32c8e6deae6235edf53ef984652fc 100644 (file)
@@ -622,6 +622,7 @@ void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage )
           }
           
           myPreviewPrs->setIsTransformationPointPreview( true );
+          myPreviewPrs->setTransformationPointCursorShape( module()->getPrefEditCursor().shape() );
         }
         connect( aViewer, SIGNAL( selectionChanged( GV_SelectionChangeStatus ) ),
                  this, SLOT( onPointSelected() ) );
@@ -774,6 +775,8 @@ void HYDROGUI_ImportImageOp::onRefImageActivated( const QString& theName )
 
     myRefPreviewPrs->setIsByTwoPoints( aPanel->isByTwoPoints() );
 
+    myRefPreviewPrs->setTransformationPointCursorShape( module()->getPrefEditCursor().shape() );
+
     // Add the new reference image presentation to the appropriate view
     aViewPort->addItem( myRefPreviewPrs );
 
index a9690cdb396f1195c7c6646afcf839c207c3f82a..c97dbd878b81fec238b41e5f9eea0de51288e696 100644 (file)
@@ -731,6 +731,15 @@ void HYDROGUI_Module::createPreferences()
   setPreferenceProperty( typeOfCursor, "icons",   aCursorTypeIconsList );
 }
 
+QCursor HYDROGUI_Module::getPrefEditCursor() const
+{
+  int aCursorType = SUIT_Session::session()->resourceMgr()->integerValue("preferences", "type_of_cursor", (int)CT_CrossCursor );
+  if ( aCursorType >= Qt::BlankCursor)
+    aCursorType++;
+  QCursor aCursor = QCursor( Qt::CursorShape(aCursorType) );
+  return aCursor;
+}
+
 void HYDROGUI_Module::update( const int flags )
 {
   if( !isUpdateEnabled() )
index 6aa6f6da2dd5692b097f792513705ce84286fe8e..6829fcbcc0b84c548b1464e4a97f35422d8d5a29 100644 (file)
@@ -62,12 +62,8 @@ class HYDROGUI_Module : public LightApp_Module
     CT_ArrowCursor = 0,
     CT_UpArrowCursor,
     CT_CrossCursor,
-    CT_IBeamCursor,
     CT_WaitCursor,
-    CT_BusyCursor,
-    CT_ForbiddenCursor,
-    CT_PointingHandCursor,
-    CT_WhatsThisCursor,
+    CT_IBeamCursor,
     CT_SizeVerCursor,
     CT_SizeHorCursor,
     CT_SizeBDiagCursor,
@@ -75,6 +71,10 @@ class HYDROGUI_Module : public LightApp_Module
     CT_SizeAllCursor,
     CT_SplitVCursor,
     CT_SplitHCursor,
+    CT_PointingHandCursor,
+    CT_ForbiddenCursor,
+    CT_WhatsThisCursor,
+    CT_BusyCursor,
     CT_OpenHandCursor,
     CT_ClosedHandCursor,
     CT_User
@@ -202,6 +202,12 @@ public:
   QStack<HYDROGUI_Operation*>&    getActiveOperations();
   HYDROGUI_Operation*             activeOperation();
 
+  /**
+   * Returns the cursor defined for edition operations in module preferences.
+   * \return specific cursor
+   */
+  QCursor                         getPrefEditCursor() const;
+
 protected:
   CAM_DataModel*                  createDataModel();
 
index 4762d58e416888fbc67bff3e8169fe33fdfff8c9..38281c81545b5abb08e2b6ac2a65c66c8e38ea47 100644 (file)
 #include <SUIT_MessageBox.h>
 #include <SUIT_Study.h>
 
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewWindow.h>
+#include <OCCViewer_ViewPort3d.h>
+
 #include <QApplication>
 
 HYDROGUI_Operation::HYDROGUI_Operation( HYDROGUI_Module* theModule )
@@ -154,6 +158,53 @@ void HYDROGUI_Operation::setPreviewManager( OCCViewer_ViewManager* theManager )
     setPreviewZLayer( module()->getOCCDisplayer()->AddPreviewZLayer( myPreviewManager ) );
 }
 
+void HYDROGUI_Operation::setCursor()
+{
+  if ( myPreviewManager )
+  {
+    QVector<SUIT_ViewWindow*> winList = myPreviewManager->getViews();
+    for ( QVector<SUIT_ViewWindow*>::iterator it = winList.begin(); it != winList.end(); ++it )
+    {
+      OCCViewer_ViewWindow* occWin = ::qobject_cast<OCCViewer_ViewWindow*>( *it );
+      if ( occWin )
+      {
+        OCCViewer_ViewPort3d* vp = occWin->getViewPort();
+        if ( vp )
+        {
+          // Save old cursor
+          myCursor = vp->cursor();
+          // Set specific cursor chosen in preferences
+          QCursor aCursor = module()->getPrefEditCursor();
+          vp->setDefaultCursor( aCursor.shape() );
+          vp->setCursor( *vp->getDefaultCursor() );
+        }
+      }
+    }
+  }
+}
+
+void HYDROGUI_Operation::restoreCursor()
+{
+  if ( myPreviewManager )
+  {
+    QVector<SUIT_ViewWindow*> winList = myPreviewManager->getViews();
+    for ( QVector<SUIT_ViewWindow*>::iterator it = winList.begin(); it != winList.end(); ++it )
+    {
+      OCCViewer_ViewWindow* occWin = ::qobject_cast<OCCViewer_ViewWindow*>( *it );
+      if ( occWin )
+      {
+        OCCViewer_ViewPort3d* vp = occWin->getViewPort();
+        if ( vp )
+        {
+          // Restore old cursor
+          vp->setDefaultCursor( myCursor.shape() );
+          vp->setCursor( myCursor );
+        }
+      }
+    }
+  }
+}
+
 void HYDROGUI_Operation::startOperation()
 {
   LightApp_Operation::startOperation();
index 74f9ca62c1f3321eb90ce8317a8e26cbf3bfc91b..89f6c9d2153300b8f25233d3e317a5b73ecec00e 100644 (file)
@@ -25,6 +25,8 @@
 
 #include <LightApp_Operation.h>
 
+#include <QCursor>
+
 class HYDROGUI_Module;
 class HYDROGUI_InputPanel;
 class HYDROGUI_Shape;
@@ -105,6 +107,15 @@ protected:
   OCCViewer_ViewManager*              getPreviewManager();
   void                                setPreviewManager( OCCViewer_ViewManager* theManager );
 
+  /**
+   * Set specific cursor chosen in preferences for edition operations.
+   */
+  virtual void setCursor();
+  /**
+   * Restore the default cursor.
+   */
+  virtual void restoreCursor();
+
 private:
 
   HYDROGUI_Module*                    myModule;
@@ -114,6 +125,8 @@ private:
   bool                                myIsPrintErrorMessage;
   bool                                myIsTransactionOpened;
   int                                 myPreviewZLayer;
+
+  QCursor                             myCursor;
 };
 
 #endif
index 61634ca78e968fbe2140b46b0d99458c5b9320b9..dff33ecf9dcfdad8c0ea818054bf5a75f66a2441 100755 (executable)
@@ -140,6 +140,8 @@ void HYDROGUI_PolylineOp::startOperation()
   aPanel->setOCCViewer( aViewManager ? aViewManager->getOCCViewer() : 0 );
   setPreviewManager( aViewManager );
 
+  setCursor();
+
   QString aPolylineName;
   if( !myEditedObject.IsNull() )
   {
@@ -186,6 +188,8 @@ void HYDROGUI_PolylineOp::startOperation()
 
 void HYDROGUI_PolylineOp::abortOperation()
 {
+  restoreCursor();
+
   HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel();
   if ( aPanel )
     aPanel->setOCCViewer( 0 );
@@ -196,6 +200,8 @@ void HYDROGUI_PolylineOp::abortOperation()
 
 void HYDROGUI_PolylineOp::commitOperation()
 {
+  restoreCursor();
+
   HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel();
   if ( aPanel )
     aPanel->setOCCViewer( 0 );
index bfe34090d6ea366a2d6b3abd6c042653b85c75d7..4ede95d70538a54e2b11e9d46470d9ff02c977a1 100644 (file)
@@ -161,6 +161,16 @@ void HYDROGUI_PrsImage::updateTransformationPoint( const int thePointType,
   }
 }
 
+//================================================================
+// Function : setTransformationPointCursorShape
+// Purpose  : 
+//================================================================
+void HYDROGUI_PrsImage::setTransformationPointCursorShape(Qt::CursorShape theCursorShape)
+{
+  if ( myTransformationPointCursor )
+    myTransformationPointCursor->setShape(theCursorShape);
+}
+
 //================================================================
 // Function : boundingRect
 // Purpose  : 
index 674c64d3203b07290e36cf799eb5eb92bfd4ff5f..6a7822b4ce45fbd3066c3d62daab39e3cb6898c1 100644 (file)
@@ -73,6 +73,12 @@ public:
                                                              const bool theIsY,
                                                              const int theValue );
 
+  /**
+   * Set shape of the transformation point cursor.
+   * @param theCursorShape a cursor shape to be set
+   */
+  void                            setTransformationPointCursorShape(Qt::CursorShape theCursorShape);
+
 public:
   // from QGraphicsItem
   virtual QRectF                  boundingRect() const;
index 1edbab27a5b05555aaf515931f69ad6bf7e417f0..69f13eb347a6c299e06844729a14f657b282fe8f 100644 (file)
Binary files a/src/HYDROGUI/resources/icon_cursor_10.png and b/src/HYDROGUI/resources/icon_cursor_10.png differ
index a9f40cbc3d77c566c11c32c0631b4f94f44dd441..1beda2570e4328382ea43512acfe23d386214f37 100644 (file)
Binary files a/src/HYDROGUI/resources/icon_cursor_11.png and b/src/HYDROGUI/resources/icon_cursor_11.png differ
index f37d7b91e8cde73243fa78df45c7808aba1c5fa0..a5667e3ffba185fd0138ddfca3d4d88049928812 100644 (file)
Binary files a/src/HYDROGUI/resources/icon_cursor_12.png and b/src/HYDROGUI/resources/icon_cursor_12.png differ
index 3b127a05d34b48a2f4f9b9cc77b681c6b43afcdd..d2004aefa7337edc3e15327992e1d69fda5b1831 100644 (file)
Binary files a/src/HYDROGUI/resources/icon_cursor_13.png and b/src/HYDROGUI/resources/icon_cursor_13.png differ
index 69f13eb347a6c299e06844729a14f657b282fe8f..2b08c4e2a3cafc992459a8f484e6c8e6c3e74857 100644 (file)
Binary files a/src/HYDROGUI/resources/icon_cursor_14.png and b/src/HYDROGUI/resources/icon_cursor_14.png differ
index 1beda2570e4328382ea43512acfe23d386214f37..b47601c3780eec780fdae43bab7481bbfebdddae 100644 (file)
Binary files a/src/HYDROGUI/resources/icon_cursor_15.png and b/src/HYDROGUI/resources/icon_cursor_15.png differ
index a5667e3ffba185fd0138ddfca3d4d88049928812..53717e49928a5d0e791baf971e95adc0bbe318d2 100644 (file)
Binary files a/src/HYDROGUI/resources/icon_cursor_16.png and b/src/HYDROGUI/resources/icon_cursor_16.png differ
index 097fc5fa7287da71ffd907b3a11adbda4516aca6..69056c479e9b2f009e366dfd71999a7c74f97620 100644 (file)
Binary files a/src/HYDROGUI/resources/icon_cursor_4.png and b/src/HYDROGUI/resources/icon_cursor_4.png differ
index 69056c479e9b2f009e366dfd71999a7c74f97620..097fc5fa7287da71ffd907b3a11adbda4516aca6 100644 (file)
Binary files a/src/HYDROGUI/resources/icon_cursor_5.png and b/src/HYDROGUI/resources/icon_cursor_5.png differ
index 53717e49928a5d0e791baf971e95adc0bbe318d2..1edbab27a5b05555aaf515931f69ad6bf7e417f0 100644 (file)
Binary files a/src/HYDROGUI/resources/icon_cursor_6.png and b/src/HYDROGUI/resources/icon_cursor_6.png differ
index 2b08c4e2a3cafc992459a8f484e6c8e6c3e74857..a9f40cbc3d77c566c11c32c0631b4f94f44dd441 100644 (file)
Binary files a/src/HYDROGUI/resources/icon_cursor_7.png and b/src/HYDROGUI/resources/icon_cursor_7.png differ
index d2004aefa7337edc3e15327992e1d69fda5b1831..f37d7b91e8cde73243fa78df45c7808aba1c5fa0 100644 (file)
Binary files a/src/HYDROGUI/resources/icon_cursor_8.png and b/src/HYDROGUI/resources/icon_cursor_8.png differ
index b47601c3780eec780fdae43bab7481bbfebdddae..3b127a05d34b48a2f4f9b9cc77b681c6b43afcdd 100644 (file)
Binary files a/src/HYDROGUI/resources/icon_cursor_9.png and b/src/HYDROGUI/resources/icon_cursor_9.png differ