From: vsv Date: Mon, 17 Jun 2019 15:11:27 +0000 (+0300) Subject: Issue #2929: Make possible enable/disable additional highlighting on mouse moving X-Git-Tag: VEDF2019Lot4~111 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3c521abdcd7ca02cf3a2575dea7ee8f6ce97130e;p=modules%2Fshaper.git Issue #2929: Make possible enable/disable additional highlighting on mouse moving --- diff --git a/src/ModuleBase/ModuleBase_IViewer.cpp b/src/ModuleBase/ModuleBase_IViewer.cpp index 57d5ad0f0..ef7b0b7c3 100644 --- a/src/ModuleBase/ModuleBase_IViewer.cpp +++ b/src/ModuleBase/ModuleBase_IViewer.cpp @@ -21,7 +21,8 @@ Handle(Prs3d_Drawer) ModuleBase_IViewer::DefaultHighlightDrawer; -ModuleBase_IViewer::ModuleBase_IViewer(QObject* theParent) : QObject(theParent) +ModuleBase_IViewer::ModuleBase_IViewer(QObject* theParent) + : QObject(theParent), myIs2dMode(false) { } diff --git a/src/ModuleBase/ModuleBase_IViewer.h b/src/ModuleBase/ModuleBase_IViewer.h index 05104257d..f079bd4d9 100644 --- a/src/ModuleBase/ModuleBase_IViewer.h +++ b/src/ModuleBase/ModuleBase_IViewer.h @@ -131,6 +131,17 @@ Q_OBJECT /// Show highlight for pre-highlighted sub-shape virtual void updateHighlight() {} + /// Set flag which indicates that viewer is used for 2d operations + /// \param is2d a new 2d mode state + void set2dMode(bool is2d) { + myIs2dMode = is2d; + } + + /// Returns current state of 2d mode flag + bool is2dMode() const { + return myIs2dMode; + } + static Handle(Prs3d_Drawer) DefaultHighlightDrawer; signals: @@ -184,6 +195,7 @@ signals: /// A map for storing a scale factors dependent on view object QMap myWindowScale; + bool myIs2dMode; }; #endif diff --git a/src/ModuleBase/ModuleBase_Preferences.cpp b/src/ModuleBase/ModuleBase_Preferences.cpp index a07060302..c616449e3 100644 --- a/src/ModuleBase/ModuleBase_Preferences.cpp +++ b/src/ModuleBase/ModuleBase_Preferences.cpp @@ -263,7 +263,7 @@ ModuleBase_PreferencesDlg::ModuleBase_PreferencesDlg(SUIT_ResourceMgr* theResurc createEditors(); myPreferences->retrieve(); - setMinimumSize(800, 240); + setMinimumSize(800, 300); } ModuleBase_PreferencesDlg::~ModuleBase_PreferencesDlg() @@ -333,6 +333,13 @@ void ModuleBase_PreferencesDlg::createViewerPage(int thePageId) ModuleBase_Preferences::VIEWER_SECTION, "point-selection-sensitivity"); myPreferences->addItem(tr("Edge"), sensitivityGroup, SUIT_PreferenceMgr::DblSpin, ModuleBase_Preferences::VIEWER_SECTION, "edge-selection-sensitivity"); + + int highlightGroup = myPreferences->addItem(tr("Additional highlighting"), viewTab); + myPreferences->setItemProperty("columns", 2, highlightGroup); + myPreferences->addItem(tr("In 3d mode"), highlightGroup, + SUIT_PreferenceMgr::Bool, ModuleBase_Preferences::VIEWER_SECTION, "highlighting-3d"); + myPreferences->addItem(tr("In 2d mode"), highlightGroup, + SUIT_PreferenceMgr::Bool, ModuleBase_Preferences::VIEWER_SECTION, "highlighting-2d"); } void ModuleBase_PreferencesDlg::createMenuPage(int thePageId) diff --git a/src/ModuleBase/ModuleBase_WidgetChoice.cpp b/src/ModuleBase/ModuleBase_WidgetChoice.cpp index ce893667e..f06efdc19 100644 --- a/src/ModuleBase/ModuleBase_WidgetChoice.cpp +++ b/src/ModuleBase/ModuleBase_WidgetChoice.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 7864827ba..cca6529d8 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -1050,6 +1050,8 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation) Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); myExternalPointsMgr = new PartSet_ExternalPointsMgr(myModule->workshop(), myCurrentSketch); + + workshop()->viewer()->set2dMode(true); } void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation) @@ -1119,6 +1121,7 @@ void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation) } workshop()->selectionActivate()->updateSelectionFilters(); workshop()->selectionActivate()->updateSelectionModes(); + workshop()->viewer()->set2dMode(false); } void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* theOperation) diff --git a/src/XGUI/SHAPER.xml b/src/XGUI/SHAPER.xml index 954153eed..525736c32 100644 --- a/src/XGUI/SHAPER.xml +++ b/src/XGUI/SHAPER.xml @@ -12,6 +12,8 @@ + +
diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index e00490f8e..6a1639032 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -684,7 +684,7 @@ bool XGUI_OperationMgr::onKeyReleased(QObject *theObject, QKeyEvent* theEvent) aContext->HilightNextDetected(aView); else if ((theEvent->key() == Qt::Key_P)) aContext->HilightPreviousDetected(aView); - aViewer->updateHighlight(); + //aViewer->updateHighlight(); isAccepted = true; } } diff --git a/src/XGUI/XGUI_ViewerProxy.cpp b/src/XGUI/XGUI_ViewerProxy.cpp index 6105a6fb6..10abc5754 100644 --- a/src/XGUI/XGUI_ViewerProxy.cpp +++ b/src/XGUI/XGUI_ViewerProxy.cpp @@ -30,22 +30,25 @@ #endif #include +#include #include #include #include +#include #include #include #include +#include #define HIGHLIGHT_COLOR Quantity_NOC_YELLOW XGUI_ViewerProxy::XGUI_ViewerProxy(XGUI_Workshop* theParent) : ModuleBase_IViewer(theParent), - myWorkshop(theParent) + myWorkshop(theParent), myShowHighlight(false) { } @@ -293,17 +296,36 @@ void XGUI_ViewerProxy::onMouseDoubleClick(AppElements_ViewWindow* theWnd, QMouse void XGUI_ViewerProxy::onMouseMove(AppElements_ViewWindow* theWnd, QMouseEvent* theEvent) { - updateHighlight(); + if (myIs2dMode) { + bool aHighlight2d = + ModuleBase_Preferences::resourceMgr()->booleanValue("Viewer", "highlighting-2d", true); + if (aHighlight2d || myShowHighlight) + updateHighlight(); + else + eraseHighlight(); + } + else { + bool aHighlight3d = + ModuleBase_Preferences::resourceMgr()->booleanValue("Viewer", "highlighting-3d", false); + if (aHighlight3d || myShowHighlight) + updateHighlight(); + else + eraseHighlight(); + } emit mouseMove(theWnd, theEvent); } void XGUI_ViewerProxy::onKeyPress(AppElements_ViewWindow* theWnd, QKeyEvent* theEvent) { + myShowHighlight = theEvent->key() == Qt::Key_H; emit keyPress(theWnd, theEvent); } void XGUI_ViewerProxy::onKeyRelease(AppElements_ViewWindow* theWnd, QKeyEvent* theEvent) { + if (theEvent->key() == Qt::Key_H) { + myShowHighlight = false; + } emit keyRelease(theWnd, theEvent); } diff --git a/src/XGUI/XGUI_ViewerProxy.h b/src/XGUI/XGUI_ViewerProxy.h index 3e78f0c9a..e250d0356 100644 --- a/src/XGUI/XGUI_ViewerProxy.h +++ b/src/XGUI/XGUI_ViewerProxy.h @@ -164,6 +164,8 @@ private slots: XGUI_Workshop* myWorkshop; ResultPtr myResult; AIS_ListOfInteractive myHighlights; + + bool myShowHighlight; }; #endif