XGUI_Displayer* aDisp = myWorkshop->displayer();
aDisp->openLocalContext();
- aDisp->activateObjectsOutOfContext(QIntList());
+ aDisp->activateObjects(QIntList());
if (myPlaneFilter.IsNull())
myPlaneFilter = new StdSelect_FaceFilter(StdSelect_Plane);
aDisp->addSelectionFilter(myPlaneFilter);
QIntList aModes;
aModes << TopAbs_FACE;
- aDisp->setSelectionModes(aModes);
+ aDisp->activateObjects(aModes);
myLabel->setText(myText);
myLabel->setToolTip(myTooltip);
XGUI_Displayer* aDisp = myWorkshop->displayer();
QIntList aModes;
// Clear standard selection modes if they are defined
- aDisp->setSelectionModes(aModes);
+ aDisp->activateObjects(aModes);
aDisp->openLocalContext();
// Set filter
aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
- aDisp->activateObjectsOutOfContext(aModes);
+ aDisp->activateObjects(aModes);
}
//for (aContext->InitCurrent(); aContext->MoreCurrent(); aContext->NextCurrent())
// aAisList.Append(aContext->Current());
+ // get the filters from the global context and append them to the local context
+ // a list of filters in the global context is not cleared and should be cleared here
SelectMgr_ListOfFilter aFilters;
aFilters.Assign(aContext->Filters());
- aContext->ClearCurrents();
+ //aContext->ClearCurrents();
aContext->OpenLocalContext();
aContext->NotUseDisplayedObjects();
SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
for (;aIt.More(); aIt.Next()) {
aContext->AddFilter(aIt.Value());
+ //GetFilter()->Add(aIt.Value());
}
// Restore selection
//AIS_ListIteratorOfListOfInteractive aIt(aAisList);
//for (ic->InitSelected(); ic->MoreSelected(); ic->NextSelected())
// aAisList.Append(ic->SelectedInteractive());
- ic->ClearSelected();
+ // get the filters from the local context and append them to the global context
+ // a list of filters in the local context is cleared
+ SelectMgr_ListOfFilter aFilters;
+ aFilters.Assign(ic->Filters());
+
+ //ic->ClearSelected();
ic->CloseAllContexts(false);
// Redisplay all object if they were displayed in localContext
ic->SetDisplayMode(aAISIO, Shading, false);
}
}
+
+ // Append the filters from the local selection in the global selection context
+ SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
+ for (;aIt.More(); aIt.Next()) {
+ Handle(SelectMgr_Filter) aFilter = aIt.Value();
+ ic->AddFilter(aFilter);
+ //GetFilter()->Add(aIt.Value());
+ }
+
if (isUpdateViewer)
updateViewer();
myUseExternalObjects = false;
return myWorkshop->viewer()->AISContext();
}
+Handle(SelectMgr_AndFilter) XGUI_Displayer::GetFilter()
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (myAndFilter.IsNull() && !aContext.IsNull()) {
+ myAndFilter = new SelectMgr_AndFilter();
+ aContext->AddFilter(myAndFilter);
+ }
+ return myAndFilter;
+}
+
void XGUI_Displayer::displayAIS(AISObjectPtr theAIS, bool isUpdate)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
}
}
-void XGUI_Displayer::activateObjectsOutOfContext(const QIntList& theModes)
+void XGUI_Displayer::activateObjects(const QIntList& theModes)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
// Open local context if there is no one
}
}
+ //Activate all displayed objects with the module modes
+ //AIS_ListOfInteractive aPrsList;
+ //aContext->DisplayedObjects(aPrsList, true);
+
+ //AIS_ListIteratorOfListOfInteractive aLIt(aPrsList);
Handle(AIS_InteractiveObject) anAISIO;
- foreach (AISObjectPtr aAIS, myResult2AISObjectMap) {
- anAISIO = aAIS->impl<Handle(AIS_InteractiveObject)>();
+ for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
+ anAISIO = aLIt.Value();
+ aTrihedron = Handle(AIS_Trihedron)::DownCast(anAISIO);
+ if (!aTrihedron.IsNull())
+ continue;
+
aContext->Load(anAISIO, -1, true);
if (theModes.size() == 0)
aContext->Activate(anAISIO);
}
-void XGUI_Displayer::deactivateObjectsOutOfContext()
+void XGUI_Displayer::deactivateObjects()
{
Handle(AIS_InteractiveContext) aContext = AISContext();
// Open local context if there is no one
aContext->SetDisplayMode(aAISIO, theMode, toUpdate);
}
-void XGUI_Displayer::setSelectionModes(const QIntList& theModes)
-{
- Handle(AIS_InteractiveContext) aContext = AISContext();
- if (aContext.IsNull())
- return;
- if (!aContext->HasOpenedContext())
- return;
- // Clear previous mode
- const TColStd_ListOfInteger& aModes = aContext->ActivatedStandardModes();
- if (!aModes.IsEmpty()) {
- TColStd_ListOfInteger aMModes;
- aMModes.Assign(aModes);
- TColStd_ListIteratorOfListOfInteger it(aMModes);
- for(; it.More(); it.Next()) {
- aContext->DeactivateStandardMode((TopAbs_ShapeEnum)it.Value());
- }
- }
- foreach(int aMode, theModes) {
- aContext->ActivateStandardMode((TopAbs_ShapeEnum)aMode);
- }
-}
-
XGUI_Displayer::DisplayMode XGUI_Displayer::displayMode(ObjectPtr theObject) const
{
Handle(AIS_InteractiveContext) aContext = AISContext();
if (theFilter.Access() == aIt.Value().Access())
return;
}
- aContext->AddFilter(theFilter);
+ //aContext->AddFilter(theFilter);
+ GetFilter()->Add(theFilter);
}
void XGUI_Displayer::removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
Handle(AIS_InteractiveContext) aContext = AISContext();
if (aContext.IsNull())
return;
- aContext->RemoveFilter(theFilter);
+ //aContext->RemoveFilter(theFilter);
+ GetFilter()->Remove(theFilter);
}
void XGUI_Displayer::removeFilters()
Handle(AIS_InteractiveContext) aContext = AISContext();
if (aContext.IsNull())
return;
- aContext->RemoveFilters();
+ //aContext->RemoveFilters();
+ GetFilter()->Clear();
}
#include <ModuleBase_Definitions.h>
#include <ModuleBase_ViewerPrs.h>
+#include <SelectMgr_AndFilter.hxx>
+
#include <QString>
#include <QMap>
/// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
void closeLocalContexts(const bool isUpdateViewer = true);
- /*
- * Set modes of selections. Selection mode has to be defined by TopAbs_ShapeEnum.
- * It doesn't manages a local context
- * \param theModes - list of selection modes. If the list is empty then all selectoin modes will be cleared.
- */
- void setSelectionModes(const QIntList& theModes);
-
void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
/// Activates in local context displayed outside of the context.
/// \param theModes - modes on which it has to be activated (can be empty)
- void activateObjectsOutOfContext(const QIntList& theModes);
+ void activateObjects(const QIntList& theModes);
/// Activates in local context displayed outside of the context.
- void deactivateObjectsOutOfContext();
+ void deactivateObjects();
/// Sets display mode for the given object if this object is displayed
void setDisplayMode(ObjectPtr theObject, DisplayMode theMode, bool toUpdate = true);
/// Returns currently installed AIS_InteractiveContext
Handle(AIS_InteractiveContext) AISContext() const;
+ /// Returns the viewer context top filter. If there is no a filter, it is created and set into
+ /// The context should have only this filter inside. Other filters should be add to the filter
+ Handle(SelectMgr_AndFilter) GetFilter();
+
/// Display the feature and a shape. This shape would be associated to the given feature
/// \param theFeature a feature instance
/// \param theAIS AIS presentation
protected:
XGUI_Workshop* myWorkshop;
+ Handle(SelectMgr_AndFilter) myAndFilter;
+
typedef QMap<ObjectPtr, AISObjectPtr> ResultToAISMap;
ResultToAISMap myResult2AISObjectMap;