Events_Loop* aLoop = Events_Loop::loop();
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED));
- mySelectionFilters.Append(new PartSet_GlobalFilter(myWorkshop));
- mySelectionFilters.Append(new PartSet_FilterInfinite(myWorkshop));
+ registerSelectionFilter(SF_GlobalFilter, new PartSet_GlobalFilter(myWorkshop));
+ registerSelectionFilter(SF_FilterInfinite, new PartSet_FilterInfinite(myWorkshop));
+ Handle(PartSet_ResultGroupNameFilter) aCRFilter = new PartSet_ResultGroupNameFilter(myWorkshop);
+ std::set<std::string> aCRGroupNames;
+ aCRGroupNames.insert(ModelAPI_ResultConstruction::group());
+ aCRFilter->setGroupNames(aCRGroupNames);
+ registerSelectionFilter(SF_ResultGroupNameFilter, aCRFilter);
setDefaultConstraintShown();
//******************************************************
PartSet_Module::~PartSet_Module()
{
- SelectMgr_ListIteratorOfListOfFilter aIt(mySelectionFilters);
- for (; aIt.More(); aIt.Next()) {
- Handle(SelectMgr_Filter) aFilter = aIt.Value();
+ std::map<XGUI_SelectionFilterType, Handle(SelectMgr_Filter)>::const_iterator aFiltersIt =
+ mySelectionFilters.begin();
+ for (; aFiltersIt != mySelectionFilters.end(); aFiltersIt++) {
+ Handle(SelectMgr_Filter) aFilter = aFiltersIt->second;
if (!aFilter.IsNull())
aFilter.Nullify();
}
return aCanActivate;
}
-//******************************************************
-void PartSet_Module::selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters) const
-{
- for (SelectMgr_ListOfFilter::Iterator aFiltersIt(mySelectionFilters); aFiltersIt.More();
- aFiltersIt.Next())
- theSelectionFilters.Append(aFiltersIt.Value());
-
- if (mySketchMgr->activeSketch())
- mySketchMgr->selectionFilters(theSelectionFilters);
-}
-
//******************************************************
bool PartSet_Module::addViewerMenu(const QMap<QString, QAction*>& theStdActions,
QWidget* theParent,
theModes = XGUI_Tools::workshop(myWorkshop)->viewerSelectionModes();
}
+//******************************************************
+void PartSet_Module::moduleSelectionModes(int theModesType, QIntList& theModes)
+{
+ customSubShapesSelectionModes(theModes);
+ //theModes.append(XGUI_Tools::workshop(myWorkshop)->viewerSelectionModes());
+ //myWorkshop->module()->activeSelectionModes(theModes);
+}
+
+//******************************************************
+void PartSet_Module::moduleSelectionFilters(const QIntList& theFilterTypes,
+ SelectMgr_ListOfFilter& theSelectionFilters)
+{
+ bool isSketchActive = mySketchMgr->activeSketch().get();
+
+ std::map<XGUI_SelectionFilterType, Handle(SelectMgr_Filter)>::const_iterator aFiltersIt =
+ mySelectionFilters.begin();
+ for (; aFiltersIt != mySelectionFilters.end(); aFiltersIt++) {
+ int aFilterType = aFiltersIt->first;
+ // do not add not participating filters in given parameters
+ if (!theFilterTypes.contains(aFilterType))
+ continue;
+
+ // using sketch filters only if sketch operation is active
+ if (!isSketchActive &&
+ mySketchMgr->sketchSelectionFilter((XGUI_SelectionFilterType)aFilterType))
+ continue;
+
+ // using filtering of construction results only from faces panel
+ if (aFilterType == SF_ResultGroupNameFilter)
+ continue;
+
+ theSelectionFilters.Append(aFiltersIt->second);
+ }
+}
+
+//******************************************************
+QIntList PartSet_Module::selectionFilters()
+{
+ QIntList aTypes;
+
+ std::map<XGUI_SelectionFilterType, Handle(SelectMgr_Filter)>::const_iterator aFiltersIt =
+ mySelectionFilters.begin();
+ for (; aFiltersIt != mySelectionFilters.end(); aFiltersIt++)
+ aTypes.append(aFiltersIt->first);
+
+ return aTypes;
+}
+
+//******************************************************
+void PartSet_Module::registerSelectionFilter(const XGUI_SelectionFilterType theFilterType,
+ const Handle(SelectMgr_Filter)& theFilter)
+{
+ mySelectionFilters[theFilterType] = theFilter;
+}
+
+//******************************************************
+Handle(SelectMgr_Filter) PartSet_Module::selectionFilter(const int theType)
+{
+ XGUI_SelectionFilterType aType = (XGUI_SelectionFilterType)theType;
+
+ if (mySelectionFilters.find(aType) != mySelectionFilters.end())
+ return mySelectionFilters[aType];
+ else
+ return Handle(SelectMgr_Filter)();
+}
+
//******************************************************
void PartSet_Module::customSubShapesSelectionModes(QIntList& theModes)
{
SessionPtr aMgr = ModelAPI_Session::get();
DocumentPtr aActiveDoc = aMgr->activeDocument();
- if (myActivePartIndex.isValid())
- aTreeView->setExpanded(myActivePartIndex, false);
+ // workaround for #2431 (SISGSEGV when launching some unit tests from GUI)
+ //if (myActivePartIndex.isValid())
+ // aTreeView->setExpanded(myActivePartIndex, false);
XGUI_DataModel* aDataModel = aWorkshop->objectBrowser()->dataModel();
myActivePartIndex = aDataModel->documentRootIndex(aActiveDoc, 0);