From 5709da577274e3e7ff0e572c05166337d7851e15 Mon Sep 17 00:00:00 2001 From: nds Date: Mon, 12 Jan 2015 11:29:43 +0300 Subject: [PATCH] It should not be possible to use the circle/arc line in the distance operation. --- src/ModuleBase/CMakeLists.txt | 4 ++ src/ModuleBase/ModuleBase_FilterMulti.cpp | 64 +++++++++++++++++++ src/ModuleBase/ModuleBase_FilterMulti.h | 46 +++++++++++++ src/ModuleBase/ModuleBase_FilterShapeType.cpp | 48 ++++++++++++++ src/ModuleBase/ModuleBase_FilterShapeType.h | 39 +++++++++++ src/PartSet/PartSet_Module.cpp | 2 + src/PartSet/PartSet_SketcherMgr.cpp | 5 +- src/SketchPlugin/plugin-Sketch.xml | 15 +++-- 8 files changed, 215 insertions(+), 8 deletions(-) create mode 100644 src/ModuleBase/ModuleBase_FilterMulti.cpp create mode 100644 src/ModuleBase/ModuleBase_FilterMulti.h create mode 100644 src/ModuleBase/ModuleBase_FilterShapeType.cpp create mode 100644 src/ModuleBase/ModuleBase_FilterShapeType.h diff --git a/src/ModuleBase/CMakeLists.txt b/src/ModuleBase/CMakeLists.txt index a7d3cc500..149ae4797 100644 --- a/src/ModuleBase/CMakeLists.txt +++ b/src/ModuleBase/CMakeLists.txt @@ -9,6 +9,8 @@ SET(PROJECT_HEADERS ModuleBase_FilterFace.h ModuleBase_FilterFactory.h ModuleBase_FilterLinearEdge.h + ModuleBase_FilterMulti.h + ModuleBase_FilterShapeType.h ModuleBase_Tools.h ModuleBase_IModule.h ModuleBase_Operation.h @@ -45,6 +47,8 @@ SET(PROJECT_SOURCES ModuleBase_FilterFace.cpp ModuleBase_FilterFactory.cpp ModuleBase_FilterLinearEdge.cpp + ModuleBase_FilterMulti.cpp + ModuleBase_FilterShapeType.cpp ModuleBase_Tools.cpp ModuleBase_IModule.cpp ModuleBase_IWorkshop.cpp diff --git a/src/ModuleBase/ModuleBase_FilterMulti.cpp b/src/ModuleBase/ModuleBase_FilterMulti.cpp new file mode 100644 index 000000000..6fcab0a7b --- /dev/null +++ b/src/ModuleBase/ModuleBase_FilterMulti.cpp @@ -0,0 +1,64 @@ +// 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 + +#include + +#include +#include + +ModuleBase_Filter* ModuleBase_FilterMulti::findFilter(const std::string& theType) +{ + ModuleBase_Filter* aFilter = 0; + + if (theType == "line") { + aFilter = new ModuleBase_FilterLinearEdge(); + std::list anArguments; + anArguments.push_back(theType); + aFilter->setArguments(anArguments); + } + if (theType == "vertex") { + aFilter = new ModuleBase_FilterShapeType(); + std::list 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::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& theArguments) +{ + myArguments.clear(); + myArguments = theArguments; +} diff --git a/src/ModuleBase/ModuleBase_FilterMulti.h b/src/ModuleBase/ModuleBase_FilterMulti.h new file mode 100644 index 000000000..e7ba0f175 --- /dev/null +++ b/src/ModuleBase/ModuleBase_FilterMulti.h @@ -0,0 +1,46 @@ +// 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 + +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& theArguments); + +protected: + /** + * It creates an OCC face filter + */ + virtual void createFilter(); + +protected: + std::list myArguments; /// the filter arguments +}; + +#endif //ModuleBase_FilterMulti diff --git a/src/ModuleBase/ModuleBase_FilterShapeType.cpp b/src/ModuleBase/ModuleBase_FilterShapeType.cpp new file mode 100644 index 000000000..2b981f785 --- /dev/null +++ b/src/ModuleBase/ModuleBase_FilterShapeType.cpp @@ -0,0 +1,48 @@ +// 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 +#include + +#include + +#include +#include + +typedef QMap 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& theArguments) +{ + if (theArguments.size()!= 1) + return; + myShapeType = shapeType(theArguments.front()); +} diff --git a/src/ModuleBase/ModuleBase_FilterShapeType.h b/src/ModuleBase/ModuleBase_FilterShapeType.h new file mode 100644 index 000000000..2b20a2965 --- /dev/null +++ b/src/ModuleBase/ModuleBase_FilterShapeType.h @@ -0,0 +1,39 @@ +// 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 + +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& theArguments); + +protected: + /** + * It creates an OCC face filter + */ + virtual void createFilter(); + +private: + TopAbs_ShapeEnum myShapeType; /// the shape type of the filter +}; + +#endif //ModuleBase_FilterShapeType diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 9714f41a5..d5f96e489 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -124,6 +125,7 @@ void PartSet_Module::registerFilters() 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) diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index e8dce9b05..7937a60c3 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -530,6 +530,9 @@ void PartSet_SketcherMgr::getCurrentSelection(const FeaturePtr& theFeature, 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(); @@ -552,8 +555,6 @@ void PartSet_SketcherMgr::getCurrentSelection(const FeaturePtr& theFeature, void PartSet_SketcherMgr::getSelectionOwners(const FeaturePtr& theFeature, const FeaturePtr& theSketch, ModuleBase_IWorkshop* theWorkshop, - //const std::set& theSelectedAttributes, - //const std::set& theSelectedResults, const FeatureToSelectionMap& theSelection, SelectMgr_IndexedMapOfOwner& anOwnersToSelect) { diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index e249eb240..712efa282 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -45,18 +45,21 @@ tooltip="Set fixed distance from a point to an object" icon=":icons/distance.png">