-// Copyright (C) 2014-2021 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2022 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include <ModelAPI_Events.h>
#include <ModelAPI_FiltersFactory.h>
#include <ModelAPI_ResultBody.h>
+
#include <GeomAPI_ShapeExplorer.h>
+#include <GeomAPI_Edge.h>
#include <Events_Loop.h>
#include <Config_ValidatorReader.h>
#include <QCheckBox>
#include <QDir>
+#ifdef WIN32
+#pragma warning(disable : 4456) // for nested foreach
+#endif
+
FeaturePtr ModuleBase_WidgetSelectionFilter::SelectorFeature;
std::string ModuleBase_WidgetSelectionFilter::AttributeId;
connect(aWidget, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)),
theParent, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)));
connect(aWidget, SIGNAL(objectUpdated()), theParent, SLOT(onObjectUpdated()));
+ aWidget->enableFocusProcessing();
}
aLayout->addWidget(aParamsWgt);
}
clearCurrentSelection();
+ FiltersFeaturePtr aFiltersFeature =
+ std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(myFeature);
+ static SessionPtr aSession = ModelAPI_Session::get();
+ std::list< std::pair<ResultPtr, GeomShapePtr> > aResList =
+ aSession->filters()->select(aFiltersFeature, (GeomAPI_Shape::ShapeType)mySelectionType);
+
BRep_Builder aBuilder;
TopoDS_Compound aComp;
aBuilder.MakeCompound(aComp);
- DocumentPtr aDoc = myFeature->document();
- int aNb = aDoc->size(ModelAPI_ResultBody::group());
- ObjectPtr aObj;
- ResultBodyPtr aBody;
- for (int i = 0; i < aNb; i++) {
- aObj = aDoc->object(ModelAPI_ResultBody::group(), i);
- aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aObj);
- GeomShapePtr aShape = aBody->shape();
- std::list<GeomShapePtr> aSubShapes =
- aShape->subShapes((GeomAPI_Shape::ShapeType)mySelectionType);
- TopTools_MapOfShape alreadyThere;
- std::list<GeomShapePtr>::const_iterator aShapesIt;
- for (aShapesIt = aSubShapes.cbegin(); aShapesIt != aSubShapes.cend(); aShapesIt++) {
- GeomShapePtr aSubShape = (*aShapesIt);
- TopoDS_Shape aTShape = aSubShape->impl<TopoDS_Shape>();
- if (!alreadyThere.Add(aTShape))
- continue;
- static SessionPtr aSession = ModelAPI_Session::get();
- bool isValid = aSession->filters()->isValid(myFeature, aBody, aSubShape);
- if (isValid) {
- aBuilder.Add(aComp, aTShape);
- // bos #24043: Naming on a compsolid works wrong.
- // Find a simple sub-result for the ViewerPrs context:
- ResultBodyPtr aContext = aBody;
- bool isComposite = aContext->numberOfSubs() > 0;
- while (isComposite) {
- isComposite = false;
- int nbSubs = aContext->numberOfSubs();
- for (int aSubIndex = 0; aSubIndex < nbSubs; aSubIndex++) {
- ResultBodyPtr aSubResult = aContext->subResult(aSubIndex);
- GeomShapePtr aSubResultShape = aSubResult->shape();
- if (aSubResultShape->isSubShape(aSubShape)) {
- aContext = aSubResult;
- isComposite = aContext->numberOfSubs() > 0;
- break;
- }
- }
- }
- ModuleBase_ViewerPrsPtr aValue(new ModuleBase_ViewerPrs(aContext, aSubShape));
- //ModuleBase_ViewerPrsPtr aValue(new ModuleBase_ViewerPrs(aObj, aSubShape));
- myValues.append(aValue);
- }
- }
+ std::list< std::pair<ResultPtr, GeomShapePtr> >::const_iterator itSelected = aResList.cbegin();
+ for (; itSelected != aResList.cend(); itSelected++) {
+ ResultPtr aCurRes = (*itSelected).first;
+ GeomShapePtr aSubShape = (*itSelected).second;
+ TopoDS_Shape aTShape = aSubShape->impl<TopoDS_Shape>();
+ aBuilder.Add(aComp, aTShape);
+ ModuleBase_ViewerPrsPtr aValue (new ModuleBase_ViewerPrs(aCurRes, aSubShape));
+ myValues.append(aValue);
}
if (myValues.size() > 0)