ModuleBase_FilterFace.h
ModuleBase_FilterFactory.h
ModuleBase_FilterLinearEdge.h
+ ModuleBase_FilterMulti.h
+ ModuleBase_FilterShapeType.h
ModuleBase_Tools.h
ModuleBase_IModule.h
ModuleBase_Operation.h
ModuleBase_FilterFace.cpp
ModuleBase_FilterFactory.cpp
ModuleBase_FilterLinearEdge.cpp
+ ModuleBase_FilterMulti.cpp
+ ModuleBase_FilterShapeType.cpp
ModuleBase_Tools.cpp
ModuleBase_IModule.cpp
ModuleBase_IWorkshop.cpp
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_FilterMulti.cpp
+// Created: 12 Jan 2015
+// Author: Natalia ERMOLAEVA
+
+
+#include "ModuleBase_FilterMulti.h"
+
+#include "ModuleBase_FilterLinearEdge.h"
+#include "ModuleBase_FilterShapeType.h"
+
+#include <SelectMgr_OrFilter.hxx>
+
+#include <Events_Error.h>
+
+#include <QString>
+#include <QMap>
+
+ModuleBase_Filter* ModuleBase_FilterMulti::findFilter(const std::string& theType)
+{
+ ModuleBase_Filter* aFilter = 0;
+
+ if (theType == "line") {
+ aFilter = new ModuleBase_FilterLinearEdge();
+ std::list<std::string> anArguments;
+ anArguments.push_back(theType);
+ aFilter->setArguments(anArguments);
+ }
+ if (theType == "vertex") {
+ aFilter = new ModuleBase_FilterShapeType();
+ std::list<std::string> anArguments;
+ anArguments.push_back(theType);
+ aFilter->setArguments(anArguments);
+ }
+
+ return aFilter;
+}
+
+void ModuleBase_FilterMulti::createFilter()
+{
+ myFilter = new SelectMgr_OrFilter();
+
+ // set filter arguments
+ Handle(SelectMgr_OrFilter) anOrFilter = Handle(SelectMgr_OrFilter)::DownCast(myFilter);
+ if (anOrFilter.IsNull())
+ return;
+
+ std::list<std::string>::const_iterator anIt = myArguments.begin(),
+ aLast = myArguments.end();
+ for (; anIt != aLast; ++anIt) {
+ std::string aType = *anIt;
+ ModuleBase_Filter* aFilter = findFilter(aType);
+ if (aFilter) {
+ anOrFilter->Add(aFilter->getFilter());
+ }
+ }
+}
+
+void ModuleBase_FilterMulti::setArguments(const std::list<std::string>& theArguments)
+{
+ myArguments.clear();
+ myArguments = theArguments;
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_FilterMulti.h
+// Created: 12 Jan 2015
+// Author: Natalia ERMOLAEVA
+
+#ifndef ModuleBase_FilterMulti_H
+#define ModuleBase_FilterMulti_H
+
+#include "ModuleBase.h"
+
+#include "ModuleBase_Filter.h"
+
+#include <StdSelect_TypeOfFace.hxx>
+
+class ModuleBase_FilterMulti: public ModuleBase_Filter
+{
+ /**
+ * Creates a new filter according to the given type
+ * It is only for internal use.
+ * This class creates the sub-filters now. It is possible to use the filter factory for this.
+ * \param theType a type of the created filter
+ */
+ ModuleBase_Filter* findFilter(const std::string& theType);
+
+public:
+ MODULEBASE_EXPORT ModuleBase_FilterMulti():
+ ModuleBase_Filter() {}
+
+ /**
+ * Sets the arguments to the filter.
+ * \param theArguments a list of arguments
+ */
+ MODULEBASE_EXPORT virtual void setArguments(const std::list<std::string>& theArguments);
+
+protected:
+ /**
+ * It creates an OCC face filter
+ */
+ virtual void createFilter();
+
+protected:
+ std::list<std::string> myArguments; /// the filter arguments
+};
+
+#endif //ModuleBase_FilterMulti
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_FilterShapeType.cpp
+// Created: 12 Jan 2015
+// Author: Natalia ERMOLAEVA
+
+
+#include "ModuleBase_FilterShapeType.h"
+
+#include <StdSelect_ShapeTypeFilter.hxx>
+#include <TopAbs_ShapeEnum.hxx>
+
+#include <Events_Error.h>
+
+#include <QString>
+#include <QMap>
+
+typedef QMap<QString, TopAbs_ShapeEnum> FaceTypes;
+static FaceTypes MyShapeTypes;
+
+TopAbs_ShapeEnum ModuleBase_FilterShapeType::shapeType(const std::string& theType)
+{
+ if (MyShapeTypes.count() == 0) {
+ MyShapeTypes["vertex"] = TopAbs_VERTEX;
+ }
+ QString aType = QString(theType.c_str()).toLower();
+ if (MyShapeTypes.contains(aType))
+ return MyShapeTypes[aType];
+ Events_Error::send("Shape type defined in XML is not implemented!");
+ return TopAbs_SHAPE;
+}
+
+ModuleBase_FilterShapeType::ModuleBase_FilterShapeType()
+: ModuleBase_Filter(), myShapeType(TopAbs_SHAPE)
+{
+}
+
+void ModuleBase_FilterShapeType::createFilter()
+{
+ myFilter = new StdSelect_ShapeTypeFilter(myShapeType);
+}
+
+void ModuleBase_FilterShapeType::setArguments(const std::list<std::string>& theArguments)
+{
+ if (theArguments.size()!= 1)
+ return;
+ myShapeType = shapeType(theArguments.front());
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_FilterShapeType.h
+// Created: 12 Jan 2015
+// Author: Natalia ERMOLAEVA
+
+#ifndef ModuleBase_FilterShapeType_H
+#define ModuleBase_FilterShapeType_H
+
+#include "ModuleBase.h"
+
+#include "ModuleBase_Filter.h"
+
+#include <StdSelect_TypeOfFace.hxx>
+
+class ModuleBase_FilterShapeType: public ModuleBase_Filter
+{
+public:
+ static MODULEBASE_EXPORT TopAbs_ShapeEnum shapeType(const std::string& theType);
+
+ MODULEBASE_EXPORT ModuleBase_FilterShapeType();
+
+ /**
+ * Sets the arguments to the filter.
+ * \param theArguments a list of arguments
+ */
+ MODULEBASE_EXPORT virtual void setArguments(const std::list<std::string>& theArguments);
+
+protected:
+ /**
+ * It creates an OCC face filter
+ */
+ virtual void createFilter();
+
+private:
+ TopAbs_ShapeEnum myShapeType; /// the shape type of the filter
+};
+
+#endif //ModuleBase_FilterShapeType
#include <ModuleBase_FilterFactory.h>
#include <ModuleBase_FilterLinearEdge.h>
#include <ModuleBase_FilterFace.h>
+#include <ModuleBase_FilterMulti.h>
#include <ModelAPI_Object.h>
aFactory->registerFilter("EdgeFilter", new ModuleBase_FilterLinearEdge);
aFactory->registerFilter("FaceFilter", new ModuleBase_FilterFace);
+ aFactory->registerFilter("MultiFilter", new ModuleBase_FilterMulti);
}
void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation)
continue;
Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(
aBRepOwner->Selectable());
+ if (anIO != anAISIO)
+ continue;
+
if (aBRepOwner->HasShape()) {
const TopoDS_Shape& aShape = aBRepOwner->Shape();
TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
void PartSet_SketcherMgr::getSelectionOwners(const FeaturePtr& theFeature,
const FeaturePtr& theSketch,
ModuleBase_IWorkshop* theWorkshop,
- //const std::set<AttributePtr>& theSelectedAttributes,
- //const std::set<ResultPtr>& theSelectedResults,
const FeatureToSelectionMap& theSelection,
SelectMgr_IndexedMapOfOwner& anOwnersToSelect)
{
tooltip="Set fixed distance from a point to an object"
icon=":icons/distance.png">
<label title="Select objects for distance definition. Following objects can be accepted: point, line or arc end point, center of circle or arc."/>
- <sketch_shape_selector
- id="ConstraintEntityA"
- label="First object"
- tooltip="Select point, line end point, line, center of circle or arc."
- shape_types="edge vertex"/>
+ <sketch_shape_selector
+ id="ConstraintEntityA"
+ label="First object"
+ tooltip="Select point, line end point, line, center of circle or arc."
+ shape_types="edge vertex">
+ <selection_filter id="MultiFilter" parameters="line,vertex"/>
+ </sketch_shape_selector>/>
<sketch_shape_selector
id="ConstraintEntityB"
label="Last object"
tooltip="Select point, line end point, line, center of circle or arc."
shape_types="edge vertex">
<validator id="SketchPlugin_DifferentObjects"/>
- </sketch_shape_selector>
+ <selection_filter id="MultiFilter" parameters="line,vertex"/>
+ </sketch_shape_selector>
<sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" internal="1" obligatory="0"/>