]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Define user preferences for sketch operation cursor
authorvsv <vsv@opencascade.com>
Fri, 24 Jan 2020 09:30:06 +0000 (12:30 +0300)
committervsv <vsv@opencascade.com>
Mon, 27 Jan 2020 11:05:55 +0000 (14:05 +0300)
Signed-off-by: vsv <vsv@opencascade.com>
12 files changed:
src/Config/Config_Prop.h
src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp
src/ModuleBase/ModuleBase_Preferences.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_Tools.h
src/XGUI/XGUI_pictures.qrc
src/XGUI/pictures/ArrowCursor.png [new file with mode: 0644]
src/XGUI/pictures/CrossCursor.png [new file with mode: 0644]
src/XGUI/pictures/HandCursor.png [new file with mode: 0644]

index fe97e96756c9990d7c3e6ff6e529b9dd2140492f..050b5d6a6fb45c426bc8c41f95123bc843daa2c4 100644 (file)
@@ -60,7 +60,15 @@ class Config_Prop
     ShortcutTree,
     BiColor,
     Background,
-    Directory
+    Directory,
+    Cursor
+  };
+
+  enum CursorType
+  {
+    ArrowCursor,
+    CrossCursor,
+    HandCursor
   };
 
   /** 
index 637e37b4e8de2f9edff675305ab4198034e474f2..855ce055a46a7eab21f9288174b5cabc3fc68bde 100644 (file)
@@ -62,6 +62,8 @@ ConstructionPlugin_Plugin::ConstructionPlugin_Plugin()
     Config_Prop::DblSpin, "0.04");
   Config_PropManager::registerProp(SKETCH_TAB_NAME, "rotate_to_plane",
     "Rotate to plane when selected", Config_Prop::Boolean, "false");
+  Config_PropManager::registerProp(SKETCH_TAB_NAME, "operation_cursor",
+    "Cursor for Sketch operation", Config_Prop::Cursor, "0");
 
   // register this plugin
   ModelAPI_Session::get()->registerPlugin(this);
index 68e275d213504e78b2adf87a9fdbfe3bdc53328f..4d5f2a1c50d0f84b5912425809543a06540c30e5 100644 (file)
@@ -176,18 +176,26 @@ void ModuleBase_Preferences::createCustomPage(ModuleBase_IPrefMgr* thePref, int
       // Add item
       if (aProp->type() != Config_Prop::Disabled) {
         SUIT_PreferenceMgr::PrefItemType aPrefType = SUIT_PreferenceMgr::Auto;
-        if (aProp->type() == Config_Prop::Directory) {
+        switch (aProp->type()) {
+        case Config_Prop::Directory:
           aPrefType = SUIT_PreferenceMgr::File;
-        } else {
+          break;
+        case Config_Prop::Cursor:
+          aPrefType = SUIT_PreferenceMgr::Selector;
+          break;
+        default:
           aPrefType = (SUIT_PreferenceMgr::PrefItemType) aProp->type();
         }
+
         int anId = thePref->addPreference(QObject::tr(aProp->title().c_str()), aTab, aPrefType,
                                           QString::fromStdString(aProp->section()),
                                           QString::fromStdString(aProp->name()));
-        if(aProp->type() == Config_Prop::Directory) {
+
+        switch (aProp->type()) {
+        case Config_Prop::Directory:
           thePref->setItemProperty("path_type", Qtx::PT_Directory, anId);
-        }
-        if (aPrefType == SUIT_PreferenceMgr::DblSpin) {
+          break;
+        case SUIT_PreferenceMgr::DblSpin:
           if (aProp->min() != "") {
             double aMin = QString(aProp->min().c_str()).toDouble();
             thePref->setItemProperty("min", aMin, anId);
@@ -196,8 +204,8 @@ void ModuleBase_Preferences::createCustomPage(ModuleBase_IPrefMgr* thePref, int
             double aMax = QString(aProp->max().c_str()).toDouble();
             thePref->setItemProperty("max", aMax, anId);
           }
-        }
-        if (aPrefType == SUIT_PreferenceMgr::IntSpin) {
+          break;
+        case SUIT_PreferenceMgr::IntSpin:
           if (aProp->min() != "") {
             int aMin = QString(aProp->min().c_str()).toInt();
             thePref->setItemProperty("min", aMin, anId);
@@ -206,6 +214,20 @@ void ModuleBase_Preferences::createCustomPage(ModuleBase_IPrefMgr* thePref, int
             int aMax = QString(aProp->max().c_str()).toInt();
             thePref->setItemProperty("max", aMax, anId);
           }
+          break;
+        case Config_Prop::Cursor:
+          {
+            QList<QVariant> aIndicesList;
+            QList<QVariant> aIconsList;
+            aIndicesList << 0 << 1 << 2;
+            aIconsList << QPixmap(":pictures/ArrowCursor.png") <<
+              QPixmap(":pictures/CrossCursor.png") <<
+              QPixmap(":pictures/HandCursor.png");
+
+            thePref->setItemProperty("indexes", aIndicesList, anId);
+            thePref->setItemProperty("icons", aIconsList, anId);
+          }
+          break;
         }
       }
     }
index 5b50689714efd32cde8bd4584cae4d8411858834..feeda8b7185350a10e14402a6d8e818779ea7187 100644 (file)
@@ -459,9 +459,9 @@ void PartSet_Module::updateSketcherOnStart(ModuleBase_Operation* theOperation)
   }
   // It is switched off because of
   // Task #3067: 5.2.2 Drawing in the sketcher: change the mouse cursor arrow
-  //else if (sketchMgr()->isNestedSketchOperation(theOperation)) {
-  //  mySketchMgr->startNestedSketch(theOperation);
-  //}
+  else if (sketchMgr()->isNestedSketchOperation(theOperation)) {
+    mySketchMgr->startNestedSketch(theOperation);
+  }
 }
 
 //******************************************************
index b230b6dd6a1cbd427aff033d37238ced312ad460..cb916284bcbbc890b272f8d09ec8650aafc9fe16 100644 (file)
@@ -226,15 +226,15 @@ void PartSet_SketcherMgr::onEnterViewPort()
 
   // It is switched off because of
   // Task #3067: 5.2.2 Drawing in the sketcher: change the mouse cursor arrow
-  //  if (canChangeCursor(getCurrentOperation())) {
-  //    QCursor* aCurrentCursor = QApplication::overrideCursor();
-  //    if (!aCurrentCursor || aCurrentCursor->shape() != Qt::CrossCursor) {
-  //      QApplication::setOverrideCursor(QCursor(Qt::CrossCursor));
+    if (canChangeCursor(getCurrentOperation())) {
+      QCursor* aCurrentCursor = QApplication::overrideCursor();
+      if (!aCurrentCursor || aCurrentCursor->shape() != Qt::CrossCursor) {
+        QApplication::setOverrideCursor(PartSet_Tools::getOperationCursor());
   //#ifdef DEBUG_CURSOR
   //      qDebug("onEnterViewPort() : Qt::CrossCursor");
   //#endif
-  //    }
-  //  }
+      }
+    }
 
   if (!isNestedCreateOperation(getCurrentOperation(), activeSketch()))
     return;
@@ -266,12 +266,12 @@ void PartSet_SketcherMgr::onLeaveViewPort()
   return;
   #endif
 
-//  if (canChangeCursor(getCurrentOperation())) {
-//    QApplication::restoreOverrideCursor();
+  if (canChangeCursor(getCurrentOperation())) {
+    QApplication::restoreOverrideCursor();
 //#ifdef DEBUG_CURSOR
 //    qDebug("onLeaveViewPort() : None");
 //#endif
-//  }
+  }
 
   if (!isNestedCreateOperation(getCurrentOperation(), activeSketch()))
     return;
@@ -1217,30 +1217,30 @@ void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
   workshop()->viewer()->set2dMode(false);
 }
 
-//void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* theOperation)
-//{
-//  if (canChangeCursor(theOperation) && myIsMouseOverWindow) {
-//    QCursor* aCurrentCursor = QApplication::overrideCursor();
-//    if (!aCurrentCursor || aCurrentCursor->shape() != Qt::CrossCursor) {
-//      QApplication::setOverrideCursor(QCursor(Qt::CrossCursor));
+void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* theOperation)
+{
+  if (canChangeCursor(theOperation) && myIsMouseOverWindow) {
+    QCursor* aCurrentCursor = QApplication::overrideCursor();
+    if (!aCurrentCursor || aCurrentCursor->shape() != Qt::CrossCursor) {
+      QApplication::setOverrideCursor(PartSet_Tools::getOperationCursor());
 //#ifdef DEBUG_CURSOR
 //      qDebug("startNestedSketch() : Qt::CrossCursor");
 //#endif
-//    }
-//  }
-//}
+    }
+  }
+}
 
 void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* theOperation)
 {
   myIsMouseOverViewProcessed = true;
   operationMgr()->onValidateOperation();
   // when sketch nested operation is stopped the cursor should be restored unconditionally
-  //if (canChangeCursor(theOperation)) {
-    //QApplication::restoreOverrideCursor();
+  if (canChangeCursor(theOperation)) {
+    QApplication::restoreOverrideCursor();
 #ifdef DEBUG_CURSOR
     qDebug("stopNestedSketch() : None");
 #endif
-  //}
+  }
   /// improvement to deselect automatically all eventual selected objects, when
   // returning to the neutral point of the Sketcher
   bool isClearSelectionPossible = true;
index 20ee6e6594dee9e42b0466dc1960b8c49021bc92..67640b0184c9fa779fa1103ac6f72c1228e7ddf8 100644 (file)
@@ -219,7 +219,7 @@ public:
 
   /// Starts sketch operation, connects to the opeation property panel
   /// \param theOperation a committed operation
-  //void startNestedSketch(ModuleBase_Operation* theOperation);
+  void startNestedSketch(ModuleBase_Operation* theOperation);
 
   /// Stop sketch operation, disconnects from the opeation property panel
   /// \param theOperation a stopped operation
index fbb50228faf57290a384d347d72b2e8b0b0dffec..83476b096d03d4bd9c0f64e99b4b8c6e00367bd8 100644 (file)
@@ -851,3 +851,17 @@ double PartSet_Tools::getDefaultTransparency()
 {
   return Config_PropManager::integer("Visualization", "shaper_default_transparency") / 100.;
 }
+
+QCursor PartSet_Tools::getOperationCursor()
+{
+  int aId = Config_PropManager::integer(SKETCH_TAB_NAME, "operation_cursor");
+  switch (aId) {
+  case 0:
+    return QCursor(Qt::ArrowCursor);
+  case 1:
+    return QCursor(Qt::CrossCursor);
+  case 2:
+    return QCursor(Qt::PointingHandCursor);
+  }
+  return QCursor();
+}
index 7f1c236abb474dc25a51394062dce820cc262cfe..250e82a19119653cb83bf5b71f2b0768026f4f68 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <QPoint>
 #include <QList>
+#include <QCursor>
 
 #include <ModelAPI_CompositeFeature.h>
 #include <ModelAPI_Object.h>
@@ -317,6 +318,11 @@ public:
   * Returns default transparency value
   */
   static double getDefaultTransparency();
+
+  /**
+  * Returns cursor according to (SKETCH_TAB_NAME, "operation_cursor") property value
+  */
+  static QCursor getOperationCursor();
 };
 
 #endif
index 9b958d9e758cde5347d49338cc273f11ccf7af60..2178d9dda21d4ebf86037792b770e8fcd2f5c9c2 100644 (file)
@@ -92,5 +92,8 @@
      <file>pictures/normal-view.png</file>
      <file>pictures/move_to_end.png</file>
      <file>pictures/move_to_end_split.png</file>
+     <file>pictures/ArrowCursor.png</file>
+     <file>pictures/CrossCursor.png</file>
+     <file>pictures/HandCursor.png</file>
  </qresource>
  </RCC>
diff --git a/src/XGUI/pictures/ArrowCursor.png b/src/XGUI/pictures/ArrowCursor.png
new file mode 100644 (file)
index 0000000..de53b10
Binary files /dev/null and b/src/XGUI/pictures/ArrowCursor.png differ
diff --git a/src/XGUI/pictures/CrossCursor.png b/src/XGUI/pictures/CrossCursor.png
new file mode 100644 (file)
index 0000000..230d586
Binary files /dev/null and b/src/XGUI/pictures/CrossCursor.png differ
diff --git a/src/XGUI/pictures/HandCursor.png b/src/XGUI/pictures/HandCursor.png
new file mode 100644 (file)
index 0000000..0d66435
Binary files /dev/null and b/src/XGUI/pictures/HandCursor.png differ