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.
* \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();
/// 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());
{
if (!mySelector) {
mySelector = createSelector(theMgr);
+ myWorkshop->module()->activateSelectionFilters();
}
}
LightApp_Preferences* pref = preferences();
if (pref)
pref->retrieve();
+
+ myWorkshop->displayer()->redisplayObjects();
}
//******************************************************
}
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()
aConnector->activateModuleSelectionModes();
}
-void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation*/* theOperation*/)
+void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* /* theOperation*/)
{
myIsMouseOverWindow = false;
myIsConstraintsShown = true;
#include <TColStd_MapOfTransient.hxx>
#include <TColStd_MapIteratorOfMapOfTransient.hxx>
+#include <Events_Loop.h>
+#include <ModelAPI_Events.h>
+
#include <set>
const int MOUSE_SENSITIVITY_IN_PIXEL = 10; ///< defines the local context mouse selection sensitivity
}
}
+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
}
}
+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))
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();
*/
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
/// \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);
/// \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
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;
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);
}
//******************************************************
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);
+ }
}
}
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();
}
}