label="Main objects"
icon=":icons/cut_shape.png"
tooltip="Select a solid objects"
- type_choice="Solids"
+ type_choice="Compounds Solids"
+ use_choice="false"
concealment="true">
+ <validator id="GeomValidators_PartSet"/>
</multi_selector>
<shape_selector id="axis_object"
icon=":icons/axis.png"
GeomValidators_BooleanArguments.h
GeomValidators_ConstructionComposite.h
GeomValidators_Face.h
+ GeomValidators_PartSet.h
GeomValidators_Positive.h
GeomValidators_ShapeType.h
GeomValidators_Tools.h
GeomValidators_BooleanArguments.cpp
GeomValidators_ConstructionComposite.cpp
GeomValidators_Face.cpp
+ GeomValidators_PartSet.cpp
GeomValidators_Positive.cpp
GeomValidators_ShapeType.cpp
GeomValidators_Tools.cpp
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomValidators_PartSet.cpp
+// Created: 27 Aug 2015
+// Author: Natalia ERMOLAEVA
+
+#include <GeomValidators_PartSet.h>
+#include <GeomValidators_Tools.h>
+
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_Session.h>
+
+#include <TopAbs_ShapeEnum.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Iterator.hxx>
+
+bool GeomValidators_PartSet::isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ std::string& theError) const
+{
+ bool aValid = false;
+ SessionPtr aMgr = ModelAPI_Session::get();
+ bool isPartSetDocument = aMgr->activeDocument() == aMgr->moduleDocument();
+
+ if (theAttribute->attributeType() == ModelAPI_AttributeSelectionList::typeId()) {
+ AttributeSelectionListPtr aSelectionListAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+ // all context objects should be sketch entities
+ for (int i = 0, aSize = aSelectionListAttr->size(); i < aSize; i++) {
+ AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(i);
+
+ GeomShapePtr aShape = aSelectAttr->value();
+ if (!aShape.get()) {
+ ResultPtr aResult = aSelectAttr->context();
+ if (aResult.get())
+ aShape = aResult->shape();
+ }
+ TopoDS_Shape aTopoShape = aShape->impl<TopoDS_Shape>();
+ TopAbs_ShapeEnum aShapeType = aTopoShape.ShapeType();
+
+ if (isPartSetDocument)
+ aValid = aShapeType == TopAbs_COMPOUND;
+ else {
+ TopoDS_Shape aTopoShape = aShape->impl<TopoDS_Shape>();
+ aShapeType = GeomValidators_Tools::getCompoundSubType(aTopoShape);
+
+ aValid = aShapeType == TopAbs_SOLID;
+ }
+ }
+ }
+
+ return aValid;
+}
+
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomValidators_Face.h
+// Created: 27 Aug 2015
+// Author: Natalia ERMOLAEVA
+
+#ifndef GeomValidators_PartSet_H
+#define GeomValidators_PartSet_H
+
+#include <GeomValidators.h>
+#include <ModelAPI_AttributeValidator.h>
+
+/**
+* \ingroup Validators
+* A validator for partset objects.
+*/
+class GeomValidators_PartSet : public ModelAPI_AttributeValidator
+{
+public:
+ //! returns true if attribute is valid
+ //! \param theAttribute the checked attribute
+ //! \param theArguments arguments of the attribute
+ GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ std::string& theError) const;
+};
+
+#endif
#include "ModelAPI_AttributeSelection.h"
#include "ModelAPI_AttributeReference.h"
+#include <TopoDS_Iterator.hxx>
+
namespace GeomValidators_Tools {
ObjectPtr getObject(const AttributePtr& theAttribute)
}
return anObject;
}
+
+ TopAbs_ShapeEnum getCompoundSubType(const TopoDS_Shape& theShape)
+ {
+ TopAbs_ShapeEnum aShapeType = theShape.ShapeType();
+
+ // for compounds check sub-shapes: it may be compound of needed type:
+ // Booleans may produce compounds of Solids
+ if (aShapeType == TopAbs_COMPOUND) {
+ for(TopoDS_Iterator aSubs(theShape); aSubs.More(); aSubs.Next()) {
+ if (!aSubs.Value().IsNull()) {
+ TopAbs_ShapeEnum aSubType = aSubs.Value().ShapeType();
+ if (aSubType == TopAbs_COMPOUND) { // compound of compound(s)
+ aShapeType = TopAbs_COMPOUND;
+ break;
+ }
+ if (aShapeType == TopAbs_COMPOUND) {
+ aShapeType = aSubType;
+ } else if (aShapeType != aSubType) { // compound of shapes of different types
+ aShapeType = TopAbs_COMPOUND;
+ break;
+ }
+ }
+ }
+ }
+ return aShapeType;
+ }
+
}
#include "ModelAPI_Object.h"
#include "ModelAPI_Attribute.h"
+#include "TopAbs_ShapeEnum.hxx"
+#include "TopoDS_Shape.hxx"
namespace GeomValidators_Tools
{
/// \param theObj an object
GEOMVALIDATORS_EXPORT ObjectPtr getObject(const AttributePtr& theAttribute);
+ // Returns the object from the attribute
+ /// \param theObj an object
+ GEOMVALIDATORS_EXPORT TopAbs_ShapeEnum getCompoundSubType(const TopoDS_Shape& theShape);
+
};
#endif
MyShapeTypes["shell"] = TopAbs_SHELL;
MyShapeTypes["solid"] = TopAbs_SOLID;
MyShapeTypes["solids"] = TopAbs_SOLID;
+ MyShapeTypes["compounds"] = TopAbs_COMPOUND;
}
QString aType = theType.toLower();
if (MyShapeTypes.contains(aType))
#include <ModuleBase_Tools.h>
#include <ModuleBase_Definitions.h>
-#include <GeomValidators_ShapeType.h>
-
#include <ModelAPI_Data.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_ResultConstruction.h>
+#include <GeomValidators_Tools.h>
+
#include <TopoDS_Iterator.hxx>
ModuleBase_WidgetSelector::ModuleBase_WidgetSelector(QWidget* theParent,
if (theResult.get())
aShape = theResult->shape();
}
+ QIntList aShapeTypes = getShapeTypes();
+
TopAbs_ShapeEnum aShapeType = TopAbs_SHAPE;
if (aShape.get()) {
// Check that the selection corresponds to selection type
// for compounds check sub-shapes: it may be compound of needed type:
// Booleans may produce compounds of Solids
if (aShapeType == TopAbs_COMPOUND) {
- for(TopoDS_Iterator aSubs(aTopoShape); aSubs.More(); aSubs.Next()) {
- if (!aSubs.Value().IsNull()) {
- TopAbs_ShapeEnum aSubType = aSubs.Value().ShapeType();
- if (aSubType == TopAbs_COMPOUND) { // compound of compound(s)
- aShapeType = TopAbs_COMPOUND;
- break;
- }
- if (aShapeType == TopAbs_COMPOUND) {
- aShapeType = aSubType;
- } else if (aShapeType != aSubType) { // compound of shapes of different types
- aShapeType = TopAbs_COMPOUND;
- break;
- }
- }
- }
+ if (aShapeTypes.contains(aShapeType))
+ return true;
+
+ aShapeType = GeomValidators_Tools::getCompoundSubType(aTopoShape);
}
}
- QIntList aShapeTypes = getShapeTypes();
QIntList::const_iterator anIt = aShapeTypes.begin(), aLast = aShapeTypes.end();
for (; anIt != aLast; anIt++) {
if (aShapeType == *anIt)
#include <ModuleBase_FilterFactory.h>
#include <ModuleBase_Filter.h>
-#include <GeomValidators_ShapeType.h>
-
#include <Config_WidgetAPI.h>
#include <Events_Loop.h>
#include <Events_Message.h>
#include "ModuleBase_IModule.h"
#include <ModelAPI_Feature.h>
+#include <ModelAPI_ResultPart.h>
+#include <ModelAPI_Session.h>
#include <FeaturesPlugin_Group.h>
#include <AIS_InteractiveObject.hxx>
}
ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj);
if (aObj) {
- FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
- if (aFeature) {
- aValid = aFeature->getKind() != FeaturesPlugin_Group::ID();
- } else
- aValid = Standard_True;
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+ // result of parts belongs to PartSet document and can be selected only when PartSet is active
+ // in order to do not select the result of the active part.
+ if (aResult.get() && aResult->groupName() == ModelAPI_ResultPart::group()) {
+ SessionPtr aMgr = ModelAPI_Session::get();
+ aValid = aMgr->activeDocument() == aMgr->moduleDocument();
+ }
+ else {
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
+ if (aFeature) {
+ aValid = aFeature->getKind() != FeaturesPlugin_Group::ID();
+ } else
+ aValid = Standard_True;
+ }
} else
// This is not object controlled by the filter
aValid = Standard_True;
#include <ModuleBase_OperationFeature.h>
#include <GeomValidators_ShapeType.h>
+#include <GeomValidators_PartSet.h>
#include <GeomValidators_Face.h>
#include <GeomValidators_ConstructionComposite.h>
#include <GeomValidators_ZeroOffset.h>
aFactory->registerValidator("GeomValidators_ShapeType", new GeomValidators_ShapeType);
aFactory->registerValidator("GeomValidators_Face", new GeomValidators_Face);
+ aFactory->registerValidator("GeomValidators_PartSet", new GeomValidators_PartSet);
+
aFactory->registerValidator("GeomValidators_ConstructionComposite",
new GeomValidators_ConstructionComposite);