From: vsv Date: Fri, 24 Jan 2020 09:30:06 +0000 (+0300) Subject: Define user preferences for sketch operation cursor X-Git-Tag: V9_5_0a1~64 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5cd9804b0680fcf9c89c4265964679e36c015773;p=modules%2Fshaper.git Define user preferences for sketch operation cursor Signed-off-by: vsv --- diff --git a/src/Config/Config_Prop.h b/src/Config/Config_Prop.h index fe97e9675..050b5d6a6 100644 --- a/src/Config/Config_Prop.h +++ b/src/Config/Config_Prop.h @@ -60,7 +60,15 @@ class Config_Prop ShortcutTree, BiColor, Background, - Directory + Directory, + Cursor + }; + + enum CursorType + { + ArrowCursor, + CrossCursor, + HandCursor }; /** diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp b/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp index 637e37b4e..855ce055a 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp @@ -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); diff --git a/src/ModuleBase/ModuleBase_Preferences.cpp b/src/ModuleBase/ModuleBase_Preferences.cpp index 68e275d21..4d5f2a1c5 100644 --- a/src/ModuleBase/ModuleBase_Preferences.cpp +++ b/src/ModuleBase/ModuleBase_Preferences.cpp @@ -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 aIndicesList; + QList 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; } } } diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 5b5068971..feeda8b71 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -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); + } } //****************************************************** diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index b230b6dd6..cb916284b 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -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; diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index 20ee6e659..67640b018 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -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 diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index fbb50228f..83476b096 100644 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -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(); +} diff --git a/src/PartSet/PartSet_Tools.h b/src/PartSet/PartSet_Tools.h index 7f1c236ab..250e82a19 100644 --- a/src/PartSet/PartSet_Tools.h +++ b/src/PartSet/PartSet_Tools.h @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -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 diff --git a/src/XGUI/XGUI_pictures.qrc b/src/XGUI/XGUI_pictures.qrc index 9b958d9e7..2178d9dda 100644 --- a/src/XGUI/XGUI_pictures.qrc +++ b/src/XGUI/XGUI_pictures.qrc @@ -92,5 +92,8 @@ pictures/normal-view.png pictures/move_to_end.png pictures/move_to_end_split.png + pictures/ArrowCursor.png + pictures/CrossCursor.png + pictures/HandCursor.png diff --git a/src/XGUI/pictures/ArrowCursor.png b/src/XGUI/pictures/ArrowCursor.png new file mode 100644 index 000000000..de53b1069 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 index 000000000..230d586be 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 index 000000000..0d664358d Binary files /dev/null and b/src/XGUI/pictures/HandCursor.png differ