From 16612039f09612edf803702b611365b14f081a08 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 29 May 2015 16:20:30 +0300 Subject: [PATCH] Visualize sketch nested created feature by mouse enters the view port Scenario: sketch, start line creation, click 1st, click 2nd, click 3rd(2nd line), click Distance in tool bar, select a point, select a point. Result - distance is not visualized until another click in the viewer. --- src/PartSet/PartSet_SketcherMgr.cpp | 42 ++++++++++++++++++++++++++--- src/PartSet/PartSet_SketcherMgr.h | 8 +++++- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index b128427a4..d4295f7ec 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -74,6 +74,7 @@ #include //#define DEBUG_DO_NOT_BY_ENTER +#define DEBUG_MOUSE_OVER_WINDOW_FLAGS /// Returns list of unique objects by sum of objects from List1 and List2 /*QList getSumList(const QList& theList1, @@ -168,12 +169,28 @@ void PartSet_SketcherMgr::onEnterViewPort() // redisplayed before this update, the feature presentation jumps from reset value to current. myIsMouseOverWindow = true; myIsPropertyPanelValueChanged = false; +#ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS + qDebug(QString("onEnterViewPort: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str()); +#endif #ifdef DEBUG_DO_NOT_BY_ENTER return; #endif - //if (!isNestedCreateOperation(getCurrentOperation())) - // return; + + if (!isNestedCreateOperation(getCurrentOperation())) + return; + // we need change displayed state of the current operation feature + // if the feature is presentable, e.g. distance construction. It has no results, so workshop does + // not accept a signal about the result created. Nothing is shown until mouse is moved out/in view + // port. If the isDisplayed flag is true, the presentable feature is displayed as soon as the + // presentation becomes valid and redisplay happens + ModuleBase_Operation* aOperation = getCurrentOperation(); + if (aOperation) { + FeaturePtr aFeature = aOperation->feature(); + if (aFeature.get() && aFeature->data()->isValid()) { + visualizeFeature(aOperation, canDisplayObject(aFeature), false); + } + } } void PartSet_SketcherMgr::onLeaveViewPort() @@ -181,6 +198,9 @@ void PartSet_SketcherMgr::onLeaveViewPort() myIsMouseOverViewProcessed = false; myIsMouseOverWindow = false; myIsPropertyPanelValueChanged = false; +#ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS + qDebug(QString("onLeaveViewPort: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str()); +#endif #ifdef DEBUG_DO_NOT_BY_ENTER return; @@ -716,6 +736,9 @@ void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation) { myIsMouseOverWindow = false; myIsConstraintsShown = true; +#ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS + qDebug(QString("stopSketch: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str()); +#endif // the objects activated in the sketch should be deactivated in order to do not have the specific // sketch selection mode activated on objects in neutral point of the application(no started operation) activateObjectsInSketchMode(false); @@ -878,6 +901,9 @@ bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const bool PartSet_SketcherMgr::canDisplayCurrentCreatedFeature() const { return myIsPropertyPanelValueChanged || myIsMouseOverWindow; +#ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS + qDebug(QString("canDisplayCurrentCreatedFeature: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str()); +#endif } bool PartSet_SketcherMgr::isObjectOfSketch(const ObjectPtr& theObject) const @@ -1061,7 +1087,8 @@ ModuleBase_Operation* PartSet_SketcherMgr::getCurrentOperation() const } void PartSet_SketcherMgr::visualizeFeature(ModuleBase_Operation* theOperation, - const bool isToDisplay) + const bool isToDisplay, + const bool isFlushRedisplay) { #ifdef DEBUG_DO_NOT_BY_ENTER return; @@ -1092,7 +1119,8 @@ void PartSet_SketcherMgr::visualizeFeature(ModuleBase_Operation* theOperation, (*aIt)->setDisplayed(false); } } - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); + if (isFlushRedisplay) + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); } void PartSet_SketcherMgr::activateObjectsInSketchMode(const bool isActive) @@ -1175,3 +1203,9 @@ void PartSet_SketcherMgr::onShowConstraintsToggle(bool theOn) } Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); } + +QString PartSet_SketcherMgr::mouseOverWindowFlagsInfo() const +{ + return QString("myIsPropertyPanelValueChanged = %1, myIsMouseOverWindow = %2") + .arg(myIsPropertyPanelValueChanged).arg(myIsMouseOverWindow); +} diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index 389fbf3b8..2300f5c7b 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -260,13 +260,19 @@ private: /// a current value is changed by property panel, the feature is displayed otherwise it is hidden /// \param theOperation an operation which feature is to be displayed, it is nested create operation /// \param isToDisplay a flag about the display or erase the feature - void visualizeFeature(ModuleBase_Operation* theOperation, const bool isToDisplay); + void visualizeFeature(ModuleBase_Operation* theOperation, const bool isToDisplay, + const bool isFlushRedisplay = true); /// Activates all visualized objects in the following selection modes: Dimension_Text/Line/Constraint, /// Shape Edge and Vertex. If the active flag is empty, it deactivates all modes /// \param isActive the flag whether the modes should be activated or deactivated void activateObjectsInSketchMode(const bool isActive); +private: + /// Gives a debug information about internal flags myIsMouseOverWindow and myIsPropertyPanelValueChanged + /// \return a string value + QString mouseOverWindowFlagsInfo() const; + private: PartSet_Module* myModule; -- 2.39.2