It creates a new custom filter to ignore the global selected construction results with an exception of the sketch feature(a composite feature).
icon=":icons/point.png"
tooltip="Select a first point"
shape_types="vertex">
+ <selection_filter id="NoConstructionSubShapesFilter"/>
</shape_selector>
<shape_selector id="secondPoint"
label="Second point"
icon=":icons/point.png"
tooltip="Select a second point"
shape_types="vertex">
+ <selection_filter id="NoConstructionSubShapesFilter"/>
</shape_selector>
</source>
SET(PROJECT_HEADERS
ModuleBase.h
ModuleBase_Filter.h
+ ModuleBase_FilterCustom.h
ModuleBase_FilterFace.h
ModuleBase_FilterFactory.h
ModuleBase_FilterLinearEdge.h
- ModuleBase_FilterMulti.h
- ModuleBase_FilterShapeType.h
+ ModuleBase_FilterMulti.h
+ ModuleBase_FilterNoConsructionSubShapes.h
+ ModuleBase_FilterShapeType.h
ModuleBase_Tools.h
ModuleBase_IModule.h
ModuleBase_Operation.h
SET(PROJECT_SOURCES
ModuleBase_Filter.cpp
+ ModuleBase_FilterCustom.cpp
ModuleBase_FilterFace.cpp
ModuleBase_FilterFactory.cpp
ModuleBase_FilterLinearEdge.cpp
- ModuleBase_FilterMulti.cpp
- ModuleBase_FilterShapeType.cpp
+ ModuleBase_FilterMulti.cpp
+ ModuleBase_FilterNoConsructionSubShapes.cpp
+ ModuleBase_FilterShapeType.cpp
ModuleBase_Tools.cpp
ModuleBase_IModule.cpp
ModuleBase_IWorkshop.cpp
)
SET(PROJECT_LIBRARIES
- Config
- ModelAPI
+ Config
+ ModelAPI
GeomAPI
GeomAlgoAPI
- ${QT_LIBRARIES}
+ ${QT_LIBRARIES}
${CAS_VIEWER}
${CAS_KERNEL}
${CAS_SHAPE}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_FilterCustom.cpp
+// Created: 10 Dec 2014
+// Author: Natalia ERMOLAEVA
+
+
+#include "ModuleBase_FilterCustom.h"
+
+#include <StdSelect_EdgeFilter.hxx>
+#include <StdSelect_TypeOfEdge.hxx>
+
+#include <Events_Error.h>
+
+#include <QString>
+#include <QMap>
+
+ModuleBase_FilterCustom::ModuleBase_FilterCustom(Handle(SelectMgr_Filter) theFilter)
+: ModuleBase_Filter()
+{
+ myFilter = theFilter;
+}
+
+void ModuleBase_FilterCustom::createFilter()
+{
+}
+
+void ModuleBase_FilterCustom::setArguments(const std::list<std::string>& theArguments)
+{
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_FilterCustom.h
+// Created: 10 Dec 2014
+// Author: Natalia ERMOLAEVA
+
+#ifndef ModuleBase_FilterCustom_H
+#define ModuleBase_FilterCustom_H
+
+#include "ModuleBase.h"
+
+#include "ModuleBase_Filter.h"
+
+/**
+* This is a child of ModuleBase_Filter to be used in the factory of filters. Despite of other
+* child it does not create the internal filter itself, it get it from the constructor argument.
+* This is useful for custom filters, which are not the standard OCC filters. It is not necessary
+* to redefine the ModuleBase_Filter. The filter is realized and put here as the class parameter.
+*/
+
+class ModuleBase_FilterCustom: public ModuleBase_Filter
+{
+public:
+ /**
+ * Constructor
+ * \param theFilter an OCC filter to be used in the parent base filter
+ */
+ MODULEBASE_EXPORT ModuleBase_FilterCustom(Handle(SelectMgr_Filter) theFilter);
+
+ /**
+ * Sets the arguments to the filter. Currently it is not used in this filter.
+ * \param theArguments a list of arguments
+ */
+ MODULEBASE_EXPORT virtual void setArguments(const std::list<std::string>& theArguments);
+
+protected:
+ /**
+ * It creates an OCC filter. The realization is empty because the filter is set through the constructor
+ */
+ virtual void createFilter();
+
+};
+
+#endif //ModuleBase_FilterCustom
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_ViewerFilters.cpp
+// Created: 07 Okt 2014
+// Author: Vitaly SMETANNIKOV
+
+
+#include "ModuleBase_FilterNoConsructionSubShapes.h"
+#include "ModuleBase_IWorkshop.h"
+
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_ResultConstruction.h>
+
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_Shape.hxx>
+
+#include <StdSelect_BRepOwner.hxx>
+
+#include <BRep_Tool.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <Geom_Curve.hxx>
+
+#include <ModelAPI_CompositeFeature.h>
+#include <GeomAPI_ICustomPrs.h>
+
+
+IMPLEMENT_STANDARD_HANDLE(ModuleBase_FilterNoConsructionSubShapes, SelectMgr_Filter);
+IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_FilterNoConsructionSubShapes, SelectMgr_Filter);
+
+Standard_Boolean ModuleBase_FilterNoConsructionSubShapes::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
+{
+ // global selection should be ignored, the filter processes only selected sub-shapes
+ Handle(StdSelect_BRepOwner) aShapeOwner = Handle(StdSelect_BRepOwner)::DownCast(theOwner);
+ if (!aShapeOwner.IsNull()) {
+ if (!aShapeOwner->ComesFromDecomposition())
+ return Standard_True;
+ }
+
+ if (theOwner->HasSelectable()) {
+ Handle(AIS_InteractiveObject) aAisObj =
+ Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
+ if (!aAisObj.IsNull()) {
+ std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+ aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj));
+ ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj);
+
+ ResultConstructionPtr aConstr =
+ std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aObj);
+ if (aConstr != NULL) {
+ // it provides selection only on compositie features, construction without composite
+ // feature is not selectable
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aConstr);
+ CompositeFeaturePtr aComposite =
+ std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeature);
+ return aComposite && aComposite->numberOfSubs() > 0;
+ }
+ }
+ }
+ return Standard_False;
+}
+
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_ViewerFilters.h
+// Created: 07 Okt 2014
+// Author: Vitaly SMETANNIKOV
+
+
+#ifndef ModuleBase_FilterNoConsructionSubShapes_H
+#define ModuleBase_FilterNoConsructionSubShapes_H
+
+#include <QStringList>
+
+#include <SelectMgr_Filter.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+
+class ModuleBase_IWorkshop;
+
+/**
+* A filter which provides filtering of selection in 3d viewer.
+* Installing of this filter lets to select objects which belong to
+* currently active document or to global document
+*/
+DEFINE_STANDARD_HANDLE(ModuleBase_FilterNoConsructionSubShapes, SelectMgr_Filter);
+class ModuleBase_FilterNoConsructionSubShapes: public SelectMgr_Filter
+{
+public:
+ Standard_EXPORT ModuleBase_FilterNoConsructionSubShapes(ModuleBase_IWorkshop* theWorkshop):
+ SelectMgr_Filter(), myWorkshop(theWorkshop) {}
+
+ /**
+ * Returns true if the owner is computed from decomposition(it is global selection, not the sub-shapes)
+ * of if the selected result is a construction and the result feature is composite and has sub-elements.
+ * \param theOwner the result of selection
+ * \return whether the owner is selectable in the viewer
+ */
+ Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const;
+
+ DEFINE_STANDARD_RTTI(ModuleBase_FilterNoConsructionSubShapes)
+
+protected:
+ ModuleBase_IWorkshop* myWorkshop;
+};
+
+#endif
\ No newline at end of file
void ModuleBase_WidgetShapeSelector::updateSelectionName()
{
DataPtr aData = myFeature->data();
- AttributeSelectionPtr aSelect = aData->selection(attributeID());
- if (aSelect) {
- myTextLine->setText(QString::fromStdString(aSelect->namingName()));
+ bool isNameUpdated = false;
+ if (aData.get() != NULL) {
+ AttributeSelectionPtr aSelect = aData->selection(attributeID());
+ if (aSelect) {
+ myTextLine->setText(QString::fromStdString(aSelect->namingName()));
+ isNameUpdated = true;
+ }
}
- else {
+ if (!isNameUpdated) {
if (mySelectedObject) {
std::string aName = mySelectedObject->data()->name();
myTextLine->setText(QString::fromStdString(aName));
#include <ModuleBase_FilterLinearEdge.h>
#include <ModuleBase_FilterFace.h>
#include <ModuleBase_FilterMulti.h>
-
+#include <ModuleBase_FilterCustom.h>
+#include <ModuleBase_FilterNoConsructionSubShapes.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_Events.h>
aFactory->registerFilter("EdgeFilter", new ModuleBase_FilterLinearEdge);
aFactory->registerFilter("FaceFilter", new ModuleBase_FilterFace);
aFactory->registerFilter("MultiFilter", new ModuleBase_FilterMulti);
+ Handle(SelectMgr_Filter) aSelectFilter = new ModuleBase_FilterNoConsructionSubShapes(workshop());
+ aFactory->registerFilter("NoConstructionSubShapesFilter",
+ new ModuleBase_FilterCustom(aSelectFilter));
}
void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation)