From: nds Date: Mon, 31 Aug 2015 08:48:00 +0000 (+0300) Subject: Issue #844 Infinite filter problem after activating GEOM module : deactivateSelection... X-Git-Tag: V_1.4.0_beta4~191 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8648407e479eeffbfbb0a952db8c47ddc8d058aa;p=modules%2Fshaper.git Issue #844 Infinite filter problem after activating GEOM module : deactivateSelectionFilters is realized in displayer. When the module is deactivated, myAndFilter of displayer is removed from context, but the displayer has an instance, which is not in the context. So, the filters do not work after: NewGeom, Geom, NewGeom activating. We nullify this fillter on deactivation and it will be created and set to the context by the first get of this filter. Issue #846 Color modification in preferences is applyed to the visualized objects after a model modification : correction to update the objects when "Default" state is clicked in the preferences dialog. --- diff --git a/src/ModuleBase/ModuleBase_ViewerPrs.h b/src/ModuleBase/ModuleBase_ViewerPrs.h index 419447edb..71f2cd627 100644 --- a/src/ModuleBase/ModuleBase_ViewerPrs.h +++ b/src/ModuleBase/ModuleBase_ViewerPrs.h @@ -20,80 +20,80 @@ * \ingroup GUI * \brief Presentation. Provides container to have feature, shape and/or selection owner. */ -class MODULEBASE_EXPORT ModuleBase_ViewerPrs +class ModuleBase_ViewerPrs { public: /// Constructor - ModuleBase_ViewerPrs(); + MODULEBASE_EXPORT ModuleBase_ViewerPrs(); /// Constructor /// \param theResult an object /// \param theShape a viewer shape /// \param theOwner a selection owner - ModuleBase_ViewerPrs(ObjectPtr theResult, const TopoDS_Shape& theShape, + MODULEBASE_EXPORT ModuleBase_ViewerPrs(ObjectPtr theResult, const TopoDS_Shape& theShape, Handle_SelectMgr_EntityOwner theOwner); /// Destructor - virtual ~ModuleBase_ViewerPrs(); + MODULEBASE_EXPORT virtual ~ModuleBase_ViewerPrs(); /// Sets the object. /// \param theResult an object instance - void setObject(ObjectPtr theResult) + MODULEBASE_EXPORT void setObject(ObjectPtr theResult) { myResult = theResult; } /// Returns the feature. /// \return a feature instance - ObjectPtr object() const + MODULEBASE_EXPORT ObjectPtr object() const { return myResult; } /// Set the presentation owner /// \param theOwner an owner to set - void setOwner(Handle_SelectMgr_EntityOwner theOwner) + MODULEBASE_EXPORT void setOwner(Handle_SelectMgr_EntityOwner theOwner) { myOwner = theOwner; } /// Returns the presentation owner /// \return an owner - Handle_SelectMgr_EntityOwner owner() const + MODULEBASE_EXPORT Handle_SelectMgr_EntityOwner owner() const { return myOwner; } /// Sets the shape /// \param theShape a shape instance - void setShape(const TopoDS_Shape& theShape) + MODULEBASE_EXPORT void setShape(const TopoDS_Shape& theShape) { myShape = theShape; } /// Returns the shape /// \return a shape instance - const TopoDS_Shape& shape() const + MODULEBASE_EXPORT const TopoDS_Shape& shape() const { return myShape; } /// Set interactive object /// \param theIO an interactive object - void setInteractive(const Handle(AIS_InteractiveObject)& theIO) + MODULEBASE_EXPORT void setInteractive(const Handle(AIS_InteractiveObject)& theIO) { myInteractive = theIO; } /// Returns interactive object if it is installed - Handle(AIS_InteractiveObject) interactive() const + MODULEBASE_EXPORT Handle(AIS_InteractiveObject) interactive() const { return myInteractive; } /// Returns true if all presentation fields are empty /// \return boolean value - bool isEmpty() const + MODULEBASE_EXPORT bool isEmpty() const { return myShape.IsNull() && myOwner.IsNull() && !myResult.get(); @@ -101,7 +101,7 @@ class MODULEBASE_EXPORT ModuleBase_ViewerPrs /// Returns True if the current object is equal to the given one /// \param thePrs an object to compare - bool operator==(const ModuleBase_ViewerPrs& thePrs) + MODULEBASE_EXPORT bool operator==(const ModuleBase_ViewerPrs& thePrs) { bool aResult = (myResult.get() == thePrs.object().get()); bool aOwner = (myOwner.Access() == thePrs.owner().Access()); diff --git a/src/NewGeom/NewGeom_Module.cpp b/src/NewGeom/NewGeom_Module.cpp index 50ff8bc2c..71bde789c 100644 --- a/src/NewGeom/NewGeom_Module.cpp +++ b/src/NewGeom/NewGeom_Module.cpp @@ -272,6 +272,7 @@ void NewGeom_Module::onViewManagerAdded(SUIT_ViewManager* theMgr) { if (!mySelector) { mySelector = createSelector(theMgr); + myWorkshop->module()->activateSelectionFilters(); } } @@ -314,6 +315,8 @@ void NewGeom_Module::onDefaultPreferences() LightApp_Preferences* pref = preferences(); if (pref) pref->retrieve(); + + myWorkshop->displayer()->redisplayObjects(); } //****************************************************** @@ -608,16 +611,7 @@ void NewGeom_Module::preferencesChanged(const QString& theSection, const QString } aProp->setValue(aValue); - // redisplay objects visualized in the viewer - static Events_ID EVENT_DISP = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY); - static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get(); - QObjectPtrList aDisplayed = myWorkshop->displayer()->displayedObjects(); - QObjectPtrList::const_iterator anIt = aDisplayed.begin(), aLast = aDisplayed.end(); - for (; anIt != aLast; anIt++) { - aECreator->sendUpdated(*anIt, EVENT_DISP); - } - Events_Loop::loop()->flush(EVENT_DISP); - + myWorkshop->displayer()->redisplayObjects(); } void NewGeom_Module::inspectSalomeModules() diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index f436aa208..dbbe99bb0 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -800,7 +800,7 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation) aConnector->activateModuleSelectionModes(); } -void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation*/* theOperation*/) +void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* /* theOperation*/) { myIsMouseOverWindow = false; myIsConstraintsShown = true; diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index ecbc29b4e..c79aeafac 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -46,6 +46,9 @@ #include #include +#include +#include + #include const int MOUSE_SENSITIVITY_IN_PIXEL = 10; ///< defines the local context mouse selection sensitivity @@ -301,6 +304,19 @@ void XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer) } } +void XGUI_Displayer::redisplayObjects() +{ + // redisplay objects visualized in the viewer + static Events_ID EVENT_DISP = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY); + static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get(); + QObjectPtrList aDisplayed = myWorkshop->displayer()->displayedObjects(); + QObjectPtrList::const_iterator anIt = aDisplayed.begin(), aLast = aDisplayed.end(); + for (; anIt != aLast; anIt++) { + aECreator->sendUpdated(*anIt, EVENT_DISP); + } + Events_Loop::loop()->flush(EVENT_DISP); +} + void XGUI_Displayer::deactivate(ObjectPtr theObject, const bool theUpdateViewer) { #ifdef DEBUG_DEACTIVATE @@ -326,6 +342,17 @@ void XGUI_Displayer::deactivate(ObjectPtr theObject, const bool theUpdateViewer) } } +void XGUI_Displayer::deactivateObjects(const QObjectPtrList& theObjList, + const bool theUpdateViewer) +{ + QObjectPtrList::const_iterator anIt = theObjList.begin(), aLast = theObjList.end(); + for (; anIt != aLast; anIt++) { + deactivate(*anIt, false); + } + if (theUpdateViewer) + updateViewer(); +} + void XGUI_Displayer::getModesOfActivation(ObjectPtr theObject, QIntList& theModes) { if (!isVisible(theObject)) @@ -783,6 +810,24 @@ XGUI_Displayer::DisplayMode XGUI_Displayer::displayMode(ObjectPtr theObject) con return (XGUI_Displayer::DisplayMode) aAISIO->DisplayMode(); } +void XGUI_Displayer::deactivateSelectionFilters() +{ + Handle(AIS_InteractiveContext) aContext = AISContext(); + if (!myAndFilter.IsNull() && !aContext.IsNull()) { + bool aFound = false; + const SelectMgr_ListOfFilter& aFilters = aContext->Filters(); + SelectMgr_ListIteratorOfListOfFilter anIt(aFilters); + for (; anIt.More() && !aFound; anIt.Next()) { + Handle(SelectMgr_Filter) aFilter = anIt.Value(); + aFound = aFilter == myAndFilter; + } + if (aFound) { + aContext->RemoveFilter(myAndFilter); + myAndFilter.Nullify(); + } + } +} + void XGUI_Displayer::addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) { Handle(AIS_InteractiveContext) aContext = AISContext(); diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index beefc2f48..dfaffc9bb 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -83,6 +83,11 @@ class XGUI_EXPORT XGUI_Displayer: public QObject */ void redisplay(ObjectPtr theObject, bool theUpdateViewer = true); + /** + * Sends and flushes a signal to redisplay all visualized objects. + */ + void redisplayObjects(); + /** * Add presentations to current selection. It unhighlight and deselect the current selection. * The shape and result components are processed in the values. If the presentation shape is not @@ -114,6 +119,9 @@ class XGUI_EXPORT XGUI_Displayer: public QObject /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly void closeLocalContexts(const bool theUpdateViewer = true); + // Remove default selection filters of the module from the current viewer + void deactivateSelectionFilters(); + /// \brief Add selection filter /// \param theFilter a filter instance void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter); @@ -163,9 +171,11 @@ class XGUI_EXPORT XGUI_Displayer: public QObject /// \return corresponded object or NULL if it not found ObjectPtr getObject(const Handle(AIS_InteractiveObject)& theIO) const; - /// Deactivates the given object (not allow selection) - /// \param theObject object to deactivate - void deactivate(ObjectPtr theObject, const bool theUpdateViewer); + /// Deactivates the given objects (not allow selection) + /// \param theObjList - list of objects which has to be deactivated. + /// \param theUpdateViewer update viewer flag + void deactivateObjects(const QObjectPtrList& theObjList, + const bool theUpdateViewer = true); /// Activates the given object (it can be selected) /// \param theObject object to activate @@ -258,6 +268,10 @@ private: void activate(const Handle(AIS_InteractiveObject)& theIO, const QIntList& theModes, const bool theUpdateViewer) const; + /// Deactivates the given object (not allow selection) + /// \param theObject object to deactivate + void deactivate(ObjectPtr theObject, const bool theUpdateViewer); + /// Find a trihedron in a list of displayed presentations and deactivate it. void deactivateTrihedron() const; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 804648de6..c8058f38d 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -223,16 +223,29 @@ void XGUI_Workshop::activateModule() myActionsMgr->update(); + // activate visualized objects in the viewer + XGUI_Displayer* aDisplayer = displayer(); + QObjectPtrList aDisplayed = aDisplayer->displayedObjects(); + QIntList aModes; + module()->activeSelectionModes(aModes); + aDisplayer->activateObjects(aModes, aDisplayed); } void XGUI_Workshop::deactivateModule() { myModule->deactivateSelectionFilters(); + // remove internal displayer filter + displayer()->deactivateSelectionFilters(); + disconnect(myDisplayer, SIGNAL(objectDisplayed(ObjectPtr, AISObjectPtr)), myModule, SLOT(onObjectDisplayed(ObjectPtr, AISObjectPtr))); disconnect(myDisplayer, SIGNAL(beforeObjectErase(ObjectPtr, AISObjectPtr)), myModule, SLOT(onBeforeObjectErase(ObjectPtr, AISObjectPtr))); + + XGUI_Displayer* aDisplayer = displayer(); + QObjectPtrList aDisplayed = aDisplayer->displayedObjects(); + aDisplayer->deactivateObjects(aDisplayed, true); } //****************************************************** @@ -368,8 +381,11 @@ void XGUI_Workshop::onStartWaiting() void XGUI_Workshop::deactivateActiveObject(const ObjectPtr& theObject, const bool theUpdateViewer) { if (!myModule->canActivateSelection(theObject)) { - if (myDisplayer->isActive(theObject)) - myDisplayer->deactivate(theObject, theUpdateViewer); + if (myDisplayer->isActive(theObject)) { + QObjectPtrList anObjects; + anObjects.append(theObject); + myDisplayer->deactivateObjects(anObjects, theUpdateViewer); + } } } @@ -755,15 +771,7 @@ void XGUI_Workshop::onPreferences() myMainWindow->menuObject()->updateFromResources(); } } - // redisplay objects visualized in the viewer - static Events_ID EVENT_DISP = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY); - static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get(); - QObjectPtrList aDisplayed = displayer()->displayedObjects(); - QObjectPtrList::const_iterator anIt = aDisplayed.begin(), aLast = aDisplayed.end(); - for (; anIt != aLast; anIt++) { - aECreator->sendUpdated(*anIt, EVENT_DISP); - } - Events_Loop::loop()->flush(EVENT_DISP); + displayer()->redisplayObjects(); } }