// Clear selection mode and define sketching mode
XGUI_Displayer* aDisp = myWorkshop->displayer();
- aDisp->removeSelectionFilter(myPlaneFilter);
+ aDisp->removeSelectionFilter(myFaceFilter);
aDisp->closeLocalContexts();
emit planeSelected(plane());
setSketchingMode();
XGUI_Displayer* aDisp = myWorkshop->displayer();
aDisp->openLocalContext();
- aDisp->activateObjectsOutOfContext(QIntList());
- if (myPlaneFilter.IsNull())
- myPlaneFilter = new StdSelect_FaceFilter(StdSelect_Plane);
- aDisp->addSelectionFilter(myPlaneFilter);
+ aDisp->activateObjects(QIntList());
+ if (myFaceFilter.IsNull())
+ myFaceFilter = new StdSelect_FaceFilter(StdSelect_Plane);
+ aDisp->addSelectionFilter(myFaceFilter);
QIntList aModes;
aModes << TopAbs_FACE;
- aDisp->setSelectionModes(aModes);
+ aDisp->activateObjects(aModes);
myLabel->setText(myText);
myLabel->setToolTip(myTooltip);
{
XGUI_Displayer* aDisp = myWorkshop->displayer();
- aDisp->removeSelectionFilter(myPlaneFilter);
+ aDisp->removeSelectionFilter(myFaceFilter);
//aDisp->removeSelectionFilter(mySketchFilter);
aDisp->closeLocalContexts();
erasePreviewPlanes();
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);
}
void XGUI_Displayer::eraseAll(const bool isUpdateViewer)
{
- Handle(AIS_InteractiveContext) ic = AISContext();
- if (ic.IsNull())
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
return;
foreach (AISObjectPtr aAISObj, myResult2AISObjectMap) {
// erase an object
Handle(AIS_InteractiveObject) anIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
if (!anIO.IsNull())
- ic->Remove(anIO, false);
+ aContext->Remove(anIO, false);
}
myResult2AISObjectMap.clear();
if (isUpdateViewer)
//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());
+ // it is important to remove the filters in the global context, because there is a code
+ // in the closeLocalContex, which restore the global context filters
+ aContext->RemoveFilters();
- aContext->ClearCurrents();
+ //aContext->ClearCurrents();
aContext->OpenLocalContext();
aContext->NotUseDisplayedObjects();
void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer)
{
- Handle(AIS_InteractiveContext) ic = AISContext();
- if ( (!ic.IsNull()) && (ic->HasOpenedContext()) ) {
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if ( (!aContext.IsNull()) && (aContext->HasOpenedContext()) ) {
// Preserve selected objects
//AIS_ListOfInteractive aAisList;
- //for (ic->InitSelected(); ic->MoreSelected(); ic->NextSelected())
- // aAisList.Append(ic->SelectedInteractive());
+ //for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
+ // aAisList.Append(aContext->SelectedInteractive());
+
+ // 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(aContext->Filters());
- ic->ClearSelected();
- ic->CloseAllContexts(false);
+ //aContext->ClearSelected();
+ aContext->CloseAllContexts(false);
// Redisplay all object if they were displayed in localContext
Handle(AIS_InteractiveObject) aAISIO;
foreach (AISObjectPtr aAIS, myResult2AISObjectMap) {
aAISIO = aAIS->impl<Handle(AIS_InteractiveObject)>();
- if (ic->DisplayStatus(aAISIO) != AIS_DS_Displayed) {
- ic->Display(aAISIO, false);
- ic->SetDisplayMode(aAISIO, Shading, false);
+ if (aContext->DisplayStatus(aAISIO) != AIS_DS_Displayed) {
+ aContext->Display(aAISIO, false);
+ aContext->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();
+ aContext->AddFilter(aFilter);
+ }
+
if (isUpdateViewer)
updateViewer();
myUseExternalObjects = false;
// Restore selection
//AIS_ListIteratorOfListOfInteractive aIt(aAisList);
//for(; aIt.More(); aIt.Next()) {
- // if (ic->IsDisplayed(aIt.Value()))
- // ic->SetCurrentObject(aIt.Value(), false);
+ // if (aContext->IsDisplayed(aIt.Value()))
+ // aContext->SetCurrentObject(aIt.Value(), false);
//}
}
}
void XGUI_Displayer::updateViewer()
{
- Handle(AIS_InteractiveContext) ic = AISContext();
- if (!ic.IsNull())
- ic->UpdateCurrentViewer();
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (!aContext.IsNull())
+ aContext->UpdateCurrentViewer();
}
Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const
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);
+ GetFilter()->Add(theFilter);
}
void XGUI_Displayer::removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
Handle(AIS_InteractiveContext) aContext = AISContext();
if (aContext.IsNull())
return;
- aContext->RemoveFilter(theFilter);
+ GetFilter()->Remove(theFilter);
}
void XGUI_Displayer::removeFilters()
Handle(AIS_InteractiveContext) aContext = AISContext();
if (aContext.IsNull())
return;
- 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;