From: nds Date: Sat, 27 Dec 2014 07:59:51 +0000 (+0300) Subject: The local selection restore for a feature vertex (it is checked on the line feature) X-Git-Tag: V_0.7.0_rc1~34^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=393405dc9972b1a8488efa2b44a6cb0c16e87774;p=modules%2Fshaper.git The local selection restore for a feature vertex (it is checked on the line feature) It blocks updateViewer() during move feature. The block, selection save, move, selection restore, unblock, updateViewer. Also it corrects the XGUI_Workshop to do not deactivate current object if the current operation is edit. --- diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index a2303017c..b4a44f8b3 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -240,6 +240,7 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve return; // No edit operation activated static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED); + Handle(V3d_View) aView = theWnd->v3dView(); gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView); double aX, aY; @@ -266,52 +267,51 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve } } } else { + ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); + XGUI_ModuleConnector* aConnector = dynamic_cast(aWorkshop); + XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); + bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false); + foreach(FeaturePtr aFeature, myEditingFeatures) { std::shared_ptr aSketchFeature = std::dynamic_pointer_cast(aFeature); if (aSketchFeature) { // save the previous selection - /*ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); - XGUI_ModuleConnector* aConnector = dynamic_cast(aWorkshop); - XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); QIntList anActivatedModes; - ResultPtr aResult = aSketchFeature->firstResult(); aDisplayer->getModesOfActivation(aResult, anActivatedModes); - + std::list aSelectedAttributes; - getCurrentSelection(aSketchFeature, myCurrentSketch, aWorkshop, aSelectedAttributes);*/ + getCurrentSelection(aSketchFeature, myCurrentSketch, aWorkshop, aSelectedAttributes); // save the previous selection: end - aSketchFeature->move(dX, dY); - ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, anEvent); - /* + // TODO: the selection restore should be after the AIS presentation is rebuilt Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_MOVED)); Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); - // restore the previous selection - aResult = aSketchFeature->firstResult(); - aDisplayer->activate(aResult, anActivatedModes); + //aResult = aSketchFeature->firstResult(); + // aDisplayer->activate(aResult, anActivatedModes); SelectMgr_IndexedMapOfOwner anOwnersToSelect; getSelectionOwners(aSketchFeature, myCurrentSketch, aWorkshop, aSelectedAttributes, anOwnersToSelect); - ModuleBase_IViewer* aViewer = aWorkshop->viewer(); - Handle(AIS_InteractiveContext) aContext = aViewer->AISContext(); - for (Standard_Integer i = 1, n = anOwnersToSelect.Extent(); i <= n; i++) - aContext->AddOrRemoveSelected(anOwnersToSelect(i), false); // SetSelected() - - aContext->UpdateCurrentViewer(); - // restore the previous selection*/ + aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false); + // restore the previous selection } + ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, anEvent, true); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); } // TODO: set here - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_MOVED)); - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); + //Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_MOVED)); + //Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); + + //Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); + aDisplayer->enableUpdateViewer(isEnableUpdateViewer); + aDisplayer->updateViewer(); } myDragDone = true; myCurX = aX; diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index bf5a05165..56b16f907 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -68,6 +68,7 @@ void displayedObjects(const Handle(AIS_InteractiveContext)& theAIS, AIS_ListOfIn XGUI_Displayer::XGUI_Displayer(XGUI_Workshop* theWorkshop) : myWorkshop(theWorkshop) { + enableUpdateViewer(true); } XGUI_Displayer::~XGUI_Displayer() @@ -152,7 +153,7 @@ void XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS, if (aCanBeShaded) { openLocalContext(); activateObjects(myActiveSelectionModes); - myWorkshop->selector()->setSelectedOwners(aSelectedOwners); + myWorkshop->selector()->setSelectedOwners(aSelectedOwners, false); } } if (isUpdateViewer) @@ -206,7 +207,7 @@ void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer) aContext->Redisplay(aAISIO, false); // Restore selection state after redisplay if (aToSelect) - aContext->SetSelected(aAISIO); + aContext->SetSelected(aAISIO, false); if (isUpdateViewer) updateViewer(); } @@ -541,10 +542,19 @@ ObjectPtr XGUI_Displayer::getObject(const Handle(AIS_InteractiveObject)& theIO) return aFeature; } +bool XGUI_Displayer::enableUpdateViewer(const bool isEnabled) +{ + bool aWasEnabled = myEnableUpdateViewer; + + myEnableUpdateViewer = isEnabled; + + return aWasEnabled; +} + void XGUI_Displayer::updateViewer() { Handle(AIS_InteractiveContext) aContext = AISContext(); - if (!aContext.IsNull()) + if (!aContext.IsNull() && myEnableUpdateViewer) aContext->UpdateCurrentViewer(); } diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index 176f52bc4..154e4b020 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -89,6 +89,13 @@ class XGUI_EXPORT XGUI_Displayer void removeFilters(); + /** + * Sets a flag to the displayer whether the internal viewer can be updated by + * the updateViewer method call. If it is not enabled, this method do nothing + * \param isEnabled a boolean value + */ + bool enableUpdateViewer(const bool isEnabled); + /// Updates the viewer void updateViewer(); @@ -188,6 +195,8 @@ class XGUI_EXPORT XGUI_Displayer //bool myUseExternalObjects; // Selection modes installed for external objects in local context QIntList myActiveSelectionModes; + + bool myEnableUpdateViewer; /// the enable update viewer flag }; #endif diff --git a/src/XGUI/XGUI_SelectionMgr.cpp b/src/XGUI/XGUI_SelectionMgr.cpp index 0cdaecf9b..94c846267 100644 --- a/src/XGUI/XGUI_SelectionMgr.cpp +++ b/src/XGUI/XGUI_SelectionMgr.cpp @@ -41,11 +41,12 @@ void XGUI_SelectionMgr::connectViewers() } //************************************************************** -void XGUI_SelectionMgr::setSelectedOwners(const SelectMgr_IndexedMapOfOwner& theSelectedOwners) +void XGUI_SelectionMgr::setSelectedOwners(const SelectMgr_IndexedMapOfOwner& theSelectedOwners, + bool isUpdateViewer) { Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); for (Standard_Integer i = 1, n = theSelectedOwners.Extent(); i <= n; i++) { - aContext->AddOrRemoveSelected(theSelectedOwners(i), false); + aContext->AddOrRemoveSelected(theSelectedOwners(i), isUpdateViewer); } } diff --git a/src/XGUI/XGUI_SelectionMgr.h b/src/XGUI/XGUI_SelectionMgr.h index 8d74e0990..f1665a746 100644 --- a/src/XGUI/XGUI_SelectionMgr.h +++ b/src/XGUI/XGUI_SelectionMgr.h @@ -39,7 +39,9 @@ Q_OBJECT //! Selects the owners in the context. //! \param theSelectedOwners a container of owners - void setSelectedOwners(const SelectMgr_IndexedMapOfOwner& theSelectedOwners); + /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly + void setSelectedOwners(const SelectMgr_IndexedMapOfOwner& theSelectedOwners, + bool isUpdateViewer); signals: //! Emited when selection in a one of viewers was changed diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index d892ccf70..87d424125 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -502,7 +502,8 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const std::shared_ptrhasOperation()) { ModuleBase_Operation* aOperation = myOperationMgr->currentOperation(); - if (aOperation->hasObject(aObj) && myDisplayer->isActive(aObj)) + if (!aOperation->isEditOperation() && + aOperation->hasObject(aObj) && myDisplayer->isActive(aObj)) myDisplayer->deactivate(aObj); } } else {