From e3f1f11a6fa18935c70877e804bae039d375094b Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 20 Mar 2015 10:34:55 +0300 Subject: [PATCH] Union of validator and filter functionalities. EdgeFilter and MultiFilter use is replaced by validator. --- src/ModuleBase/CMakeLists.txt | 4 + src/ModuleBase/ModuleBase_ISelection.h | 8 ++ src/ModuleBase/ModuleBase_PageWidget.cpp | 2 + .../ModuleBase_ValidatorLinearEdge.cpp | 65 +++++++++++++++ .../ModuleBase_ValidatorLinearEdge.h | 43 ++++++++++ ...ModuleBase_ValidatorLinearEdgeOrVertex.cpp | 61 ++++++++++++++ .../ModuleBase_ValidatorLinearEdgeOrVertex.h | 30 +++++++ .../ModuleBase_WidgetMultiSelector.cpp | 4 +- .../ModuleBase_WidgetMultiSelector.h | 8 +- .../ModuleBase_WidgetShapeSelector.cpp | 79 ++++++++++--------- .../ModuleBase_WidgetShapeSelector.h | 13 +-- src/ModuleBase/ModuleBase_WidgetValidated.cpp | 21 ++++- src/ModuleBase/ModuleBase_WidgetValidated.h | 7 +- src/PartSet/PartSet_Module.cpp | 7 ++ src/PartSet/PartSet_WidgetShapeSelector.cpp | 21 ++++- src/SketchPlugin/plugin-Sketch.xml | 28 +++---- src/XGUI/XGUI_Selection.h | 3 +- 17 files changed, 331 insertions(+), 73 deletions(-) create mode 100644 src/ModuleBase/ModuleBase_ValidatorLinearEdge.cpp create mode 100644 src/ModuleBase/ModuleBase_ValidatorLinearEdge.h create mode 100644 src/ModuleBase/ModuleBase_ValidatorLinearEdgeOrVertex.cpp create mode 100644 src/ModuleBase/ModuleBase_ValidatorLinearEdgeOrVertex.h diff --git a/src/ModuleBase/CMakeLists.txt b/src/ModuleBase/CMakeLists.txt index a7ad900d1..4508cf3c4 100644 --- a/src/ModuleBase/CMakeLists.txt +++ b/src/ModuleBase/CMakeLists.txt @@ -37,6 +37,8 @@ SET(PROJECT_HEADERS ModuleBase_IViewer.h ModuleBase_WidgetLineEdit.h ModuleBase_WidgetMultiSelector.h + ModuleBase_ValidatorLinearEdge.h + ModuleBase_ValidatorLinearEdgeOrVertex.h ModuleBase_ViewerFilters.h ModuleBase_ResultPrs.h ModuleBase_IViewWindow.h @@ -80,6 +82,8 @@ SET(PROJECT_SOURCES ModuleBase_DoubleSpinBox.cpp ModuleBase_WidgetLineEdit.cpp ModuleBase_WidgetMultiSelector.cpp + ModuleBase_ValidatorLinearEdge.cpp + ModuleBase_ValidatorLinearEdgeOrVertex.cpp ModuleBase_ViewerFilters.cpp ModuleBase_ResultPrs.cpp ModuleBase_WidgetLabel.cpp diff --git a/src/ModuleBase/ModuleBase_ISelection.h b/src/ModuleBase/ModuleBase_ISelection.h index 29829a39e..a444e5867 100644 --- a/src/ModuleBase/ModuleBase_ISelection.h +++ b/src/ModuleBase/ModuleBase_ISelection.h @@ -18,6 +18,8 @@ #include +class Handle_SelectMgr_EntityOwner; + /** * \ingroup GUI * A class which provides access to selection. @@ -35,6 +37,12 @@ class ModuleBase_ISelection /// \return list of presentations virtual QList getHighlighted() const = 0; + /// Fills the viewer presentation parameters by the parameters from the owner + /// \param thePrs a container for selection + /// \param theOwner a selection owner + virtual void fillPresentation(ModuleBase_ViewerPrs& thePrs, + const Handle_SelectMgr_EntityOwner& theOwner) const = 0; + /** * Returns list of features currently selected in object browser */ diff --git a/src/ModuleBase/ModuleBase_PageWidget.cpp b/src/ModuleBase/ModuleBase_PageWidget.cpp index d3039cac5..9d32e79e7 100644 --- a/src/ModuleBase/ModuleBase_PageWidget.cpp +++ b/src/ModuleBase/ModuleBase_PageWidget.cpp @@ -11,6 +11,8 @@ #include +#include + ModuleBase_PageWidget::ModuleBase_PageWidget(QWidget* theParent) : QFrame(theParent) { diff --git a/src/ModuleBase/ModuleBase_ValidatorLinearEdge.cpp b/src/ModuleBase/ModuleBase_ValidatorLinearEdge.cpp new file mode 100644 index 000000000..cf2d28082 --- /dev/null +++ b/src/ModuleBase/ModuleBase_ValidatorLinearEdge.cpp @@ -0,0 +1,65 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + + +#include "ModuleBase_ValidatorLinearEdge.h" +#include "ModuleBase_WidgetShapeSelector.h" + +#include + +#include + +#include + +#include +#include + + +typedef QMap EdgeTypes; +static EdgeTypes MyEdgeTypes; + +ModuleBase_ValidatorLinearEdge::TypeOfEdge ModuleBase_ValidatorLinearEdge::edgeType(const std::string& theType) +{ + if (MyEdgeTypes.count() == 0) { + MyEdgeTypes["line"] = Line; + MyEdgeTypes["circle"] = Circle; + } + QString aType = QString(theType.c_str()).toLower(); + if (MyEdgeTypes.contains(aType)) + return MyEdgeTypes[aType]; + + Events_Error::send("Edge type defined in XML is not implemented!"); + return AnyEdge; +} + +bool ModuleBase_ValidatorLinearEdge::isValid(const AttributePtr& theAttribute, + const std::list& theArguments) const +{ + bool aValid = false; + + TypeOfEdge anEdgeType = AnyEdge; + if (theArguments.size() == 1) { + std::string anArgument = theArguments.front(); + anEdgeType = edgeType(anArgument); + } + + ObjectPtr anObject = ModuleBase_WidgetShapeSelector::getObject(theAttribute); + if (anObject.get() != NULL) { + FeaturePtr aFeature = ModelAPI_Feature::feature(anObject); + ResultPtr aResult = std::dynamic_pointer_cast(anObject); + if (aResult.get() != NULL) { + GeomShapePtr aShape = aResult->shape(); + if (aShape.get() != NULL && aShape->isEdge()) { + aValid = anEdgeType == AnyEdge; + if (!aValid) { + bool isCircle = GeomAPI_Curve(aShape).isCircle(); + aValid = (isCircle && anEdgeType == Circle) || + (!isCircle && anEdgeType == Line); + } + } + } + } + else { + //AttributeRefAttrPtr anAttr = std::dynamic_pointer_cast(theAttribute); + } + return aValid; +} diff --git a/src/ModuleBase/ModuleBase_ValidatorLinearEdge.h b/src/ModuleBase/ModuleBase_ValidatorLinearEdge.h new file mode 100644 index 000000000..f88527abf --- /dev/null +++ b/src/ModuleBase/ModuleBase_ValidatorLinearEdge.h @@ -0,0 +1,43 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: ModuleBase_ValidatorLinearEdge.h +// Created: 19 Mar 2015 +// Author: Natalia ERMOLAEVA + +#ifndef ModuleBase_ValidatorLinearEdge_H +#define ModuleBase_ValidatorLinearEdge_H + +#include "ModuleBase.h" +#include "ModelAPI_AttributeValidator.h" + +#include + +/** +* \ingroup Validators +* A validator of selection +*/ +class ModuleBase_ValidatorLinearEdge : public ModelAPI_AttributeValidator +{ + public: + // the edge type + enum TypeOfEdge + { + AnyEdge, + Line, + Circle + }; + + public: + MODULEBASE_EXPORT ModuleBase_ValidatorLinearEdge() {} + //! returns true if attribute is valid + //! \param theAttribute the checked attribute + //! \param theArguments arguments of the attribute + MODULEBASE_EXPORT virtual bool isValid(const AttributePtr& theAttribute, + const std::list& theArguments) const; +protected: + /// Convert string to StdSelect_TypeOfFace value + /// \param theType a string value + static TypeOfEdge edgeType(const std::string& theType); +}; + +#endif diff --git a/src/ModuleBase/ModuleBase_ValidatorLinearEdgeOrVertex.cpp b/src/ModuleBase/ModuleBase_ValidatorLinearEdgeOrVertex.cpp new file mode 100644 index 000000000..b9c8ce1eb --- /dev/null +++ b/src/ModuleBase/ModuleBase_ValidatorLinearEdgeOrVertex.cpp @@ -0,0 +1,61 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + + +#include "ModuleBase_ValidatorLinearEdgeOrVertex.h" +#include "ModuleBase_WidgetShapeSelector.h" +#include "ModuleBase_ValidatorLinearEdge.h" + +#include "ModelAPI_AttributeRefAttr.h" + +#include + +#include +#include + +#include + +#include + +#include +#include + + +bool ModuleBase_ValidatorLinearEdgeOrVertex::isValid(const AttributePtr& theAttribute, + const std::list& theArguments) const +{ + bool aValid = false; + + // 1. check whether the attribute is a linear edge + // there is a check whether the feature contains a point and a linear edge or two point values + SessionPtr aMgr = ModelAPI_Session::get(); + ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); + + const ModuleBase_ValidatorLinearEdge* aLinearEdgeValidator = + dynamic_cast(aFactory->validator("ModuleBase_ValidatorLinearEdge")); + + std::list anArguments; + anArguments.push_back("line"); + aValid = aLinearEdgeValidator->isValid(theAttribute, anArguments); + if (!aValid) { + //2. check whether the attribute is a vertex + ObjectPtr anObject = ModuleBase_WidgetShapeSelector::getObject(theAttribute); + if (anObject.get() != NULL) { + FeaturePtr aFeature = ModelAPI_Feature::feature(anObject); + ResultPtr aResult = std::dynamic_pointer_cast(anObject); + if (aResult.get() != NULL) { + GeomShapePtr aShape = aResult->shape(); + if (aShape.get() != NULL) { + aValid = aShape->isVertex(); + } + } + } + else { + AttributeRefAttrPtr anAttr = std::dynamic_pointer_cast(theAttribute); + if (anAttr.get() != NULL) { + AttributePtr aRefAttr = anAttr->attr(); + aValid = aRefAttr.get() != NULL && aRefAttr->attributeType() == GeomDataAPI_Point2D::type(); + } + } + } + return aValid; +} diff --git a/src/ModuleBase/ModuleBase_ValidatorLinearEdgeOrVertex.h b/src/ModuleBase/ModuleBase_ValidatorLinearEdgeOrVertex.h new file mode 100644 index 000000000..0df6c882f --- /dev/null +++ b/src/ModuleBase/ModuleBase_ValidatorLinearEdgeOrVertex.h @@ -0,0 +1,30 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: ModuleBase_ValidatorLinearEdgeOrVertex.h +// Created: 19 Mar 2015 +// Author: Natalia ERMOLAEVA + +#ifndef ModuleBase_ValidatorLinearEdgeOrVertex_H +#define ModuleBase_ValidatorLinearEdgeOrVertex_H + +#include "ModuleBase.h" +#include "ModelAPI_AttributeValidator.h" + +#include + +/** +* \ingroup Validators +* A validator of selection +*/ +class ModuleBase_ValidatorLinearEdgeOrVertex : public ModelAPI_AttributeValidator +{ + public: + MODULEBASE_EXPORT ModuleBase_ValidatorLinearEdgeOrVertex() {} + //! returns true if attribute is valid + //! \param theAttribute the checked attribute + //! \param theArguments arguments of the attribute + MODULEBASE_EXPORT virtual bool isValid(const AttributePtr& theAttribute, + const std::list& theArguments) const; +}; + +#endif diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index c3bf95327..bba656f87 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -178,9 +178,9 @@ void ModuleBase_WidgetMultiSelector::backupAttributeValue(const bool isBackup) } //******************************************************************** -void ModuleBase_WidgetMultiSelector::setSelection(const Handle_SelectMgr_EntityOwner& theOwner) +bool ModuleBase_WidgetMultiSelector::setSelection(const Handle_SelectMgr_EntityOwner& theOwner) { - + return false; } //******************************************************************** diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h index e0b257ca4..385eabf3f 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h @@ -73,6 +73,10 @@ class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_Widge /// The methiod called when widget is deactivated virtual void deactivate(); + /// Fills the attribute with the value of the selected owner + /// \param theOwner a selected owner + virtual bool setSelection(const Handle_SelectMgr_EntityOwner& theOwner); + public slots: /// Slot is called on selection type changed void onSelectionTypeChanged(); @@ -102,10 +106,6 @@ protected slots: /// to backup, otherwise set the backed up values to the attribute virtual void backupAttributeValue(const bool isBackup); - /// Fills the attribute with the value of the selected owner - /// \param theOwner a selected owner - virtual void setSelection(const Handle_SelectMgr_EntityOwner& theOwner); - /// Set current shape type for selection void setCurrentShapeType(const TopAbs_ShapeEnum theShapeType); diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index ec7defe22..e60c8cb30 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -215,13 +215,16 @@ void ModuleBase_WidgetShapeSelector::onSelectionChanged() //QObjectPtrList aObjects = myWorkshop->selection()->selectedPresentations(); QList aSelected = myWorkshop->selection()->getSelected(); if (aSelected.size() > 0) { - if (setSelection(aSelected.first())) + Handle(SelectMgr_EntityOwner) anOwner = aSelected.first().owner(); + if (isValid(anOwner)) { + setSelection(anOwner); emit focusOutWidget(this); + } } } //******************************************************************** -bool ModuleBase_WidgetShapeSelector::setSelection(ModuleBase_ViewerPrs theValue) +bool ModuleBase_WidgetShapeSelector::setSelectionPrs(ModuleBase_ViewerPrs theValue) { ObjectPtr aObject = theValue.object(); ObjectPtr aCurrentObject = getObject(myFeature->attribute(attributeID())); @@ -258,43 +261,26 @@ bool ModuleBase_WidgetShapeSelector::setSelection(ModuleBase_ViewerPrs theValue) aShape = std::shared_ptr(new GeomAPI_Shape()); aShape->setImpl(new TopoDS_Shape(theValue.shape())); } - // Check that the selection corresponds to selection type if (!acceptSubShape(aShape)) return false; -// if (!acceptObjectShape(aObject)) -// return false; - - // Check whether the value is valid for the viewer selection filters - Handle(SelectMgr_EntityOwner) anOwner = theValue.owner(); - if (!anOwner.IsNull()) { - SelectMgr_ListOfFilter aFilters; - selectionFilters(myWorkshop, aFilters); - SelectMgr_ListIteratorOfListOfFilter aIt(aFilters); - for (; aIt.More(); aIt.Next()) { - const Handle(SelectMgr_Filter)& aFilter = aIt.Value(); - if (!aFilter->IsOk(anOwner)) - return false; - } - } - if (isValid(aObject, aShape)) { - setObject(aObject, aShape); - return true; - } - return false; + + setObject(aObject, aShape); + return true; } //******************************************************************** void ModuleBase_WidgetShapeSelector::setObject(ObjectPtr theObj, std::shared_ptr theShape) { - if (storeAttributeValues(theObj, theShape)) - updateObject(myFeature); - - if (theObj) { - raisePanel(); - } - updateSelectionName(); - emit valuesChanged(); + //if ( + storeAttributeValues(theObj, theShape);//) + // updateObject(myFeature); + + //if (theObj) { + // raisePanel(); + //} + //updateSelectionName(); + //emit valuesChanged(); } //******************************************************************** @@ -395,7 +381,17 @@ void ModuleBase_WidgetShapeSelector::updateSelectionName() std::string aName = anObject->data()->name(); myTextLine->setText(QString::fromStdString(aName)); } else { - if (myIsActive) { + AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID()); + if (aRefAttr && aRefAttr->attr().get() != NULL) { + //myIsObject = aRefAttr->isObject(); + AttributePtr anAttr = aRefAttr->attr(); + if (anAttr.get() != NULL) { + std::stringstream aName; + aName <owner()->data()->name()<<"/"<id(); + myTextLine->setText(QString::fromStdString(aName.str())); + } + } + else if (myIsActive) { myTextLine->setText(""); } } @@ -469,18 +465,23 @@ void ModuleBase_WidgetShapeSelector::backupAttributeValue(const bool isBackup) storeAttributeValues(myObject, myShape); AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID()); if (aRefAttr) { - if (myIsObject) - aRefAttr->setObject(myObject); - else + if (!myIsObject) aRefAttr->setAttr(myRefAttribute); } } } //******************************************************************** -void ModuleBase_WidgetShapeSelector::setSelection(const Handle_SelectMgr_EntityOwner& theOwner) +bool ModuleBase_WidgetShapeSelector::setSelection(const Handle_SelectMgr_EntityOwner& theOwner) { - + bool isDone = false; + //QList aSelected = myWorkshop->selection()->getSelected(); + //if (aSelected.size() > 0) { + ModuleBase_ViewerPrs aPrs; + myWorkshop->selection()->fillPresentation(aPrs, theOwner); + isDone = setSelectionPrs(aPrs); + //} + return isDone; } //******************************************************************** @@ -491,7 +492,7 @@ void ModuleBase_WidgetShapeSelector::deactivate() } //******************************************************************** -bool ModuleBase_WidgetShapeSelector::isValid(ObjectPtr theObj, std::shared_ptr theShape) +/*bool ModuleBase_WidgetShapeSelector::isValid(ObjectPtr theObj, std::shared_ptr theShape) { bool isValid = ModuleBase_WidgetValidated::isValid(theObj, theShape); if (!isValid) @@ -529,4 +530,4 @@ bool ModuleBase_WidgetShapeSelector::isValid(ObjectPtr theObj, std::shared_ptrblockSendAttributeUpdated(false); return aValid; -} +}*/ diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.h b/src/ModuleBase/ModuleBase_WidgetShapeSelector.h index ca735d532..c430fc170 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.h @@ -10,6 +10,7 @@ #include "ModuleBase.h" #include "ModuleBase_WidgetValidated.h" #include "ModuleBase_ViewerFilters.h" +#include #include #include @@ -84,7 +85,11 @@ Q_OBJECT /// Set the given wrapped value to the current widget /// This value should be processed in the widget according to the needs /// \param theValue the wrapped widget value - virtual bool setSelection(ModuleBase_ViewerPrs theValue); + virtual bool setSelectionPrs(ModuleBase_ViewerPrs theValue); + + /// Fills the attribute with the value of the selected owner + /// \param theOwner a selected owner + virtual bool setSelection(const Handle_SelectMgr_EntityOwner& theOwner); /// The methiod called when widget is deactivated virtual void deactivate(); @@ -117,10 +122,6 @@ Q_OBJECT /// to backup, otherwise set the backed up values to the attribute virtual void backupAttributeValue(const bool isBackup); - /// Fills the attribute with the value of the selected owner - /// \param theOwner a selected owner - virtual void setSelection(const Handle_SelectMgr_EntityOwner& theOwner); - /// Computes and updates name of selected object in the widget void updateSelectionName(); @@ -143,7 +144,7 @@ Q_OBJECT /// Check the selected with validators if installed /// \param theObj the object for checking /// \param theShape the shape for checking - virtual bool isValid(ObjectPtr theObj, std::shared_ptr theShape); + //virtual bool isValid(ObjectPtr theObj, std::shared_ptr theShape); /// Clear attribute void clearAttribute(); diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index d81ec7970..d17cd98e8 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -25,6 +25,21 @@ ModuleBase_WidgetValidated::~ModuleBase_WidgetValidated() { } +bool ModuleBase_WidgetValidated::setSelection(ModuleBase_ViewerPrs theValue) +{ + bool isDone = false; + + Handle(SelectMgr_EntityOwner) anOwner = theValue.owner(); + if (isValid(anOwner)) { + //storeAttributeValue(anOwner); + setSelection(anOwner); + updateObject(myFeature); + //isDone = setSelection(anOwner); + emit valuesChanged(); + } + return isDone; +} + bool ModuleBase_WidgetValidated::isValid(const Handle_SelectMgr_EntityOwner& theOwner) { backupAttributeValue(true); @@ -97,13 +112,13 @@ void ModuleBase_WidgetValidated::activateFilters(ModuleBase_IWorkshop* theWorksh const bool toActivate) const { ModuleBase_IViewer* aViewer = theWorkshop->viewer(); -/* + Handle(SelectMgr_Filter) aSelFilter = theWorkshop->validatorFilter(); if (toActivate) aViewer->addSelectionFilter(aSelFilter); else aViewer->removeSelectionFilter(aSelFilter); -*/ +/* // apply filters loaded from the XML definition of the widget ModuleBase_FilterFactory* aFactory = theWorkshop->selectionFilters(); SelectMgr_ListOfFilter aFactoryFilters; @@ -117,7 +132,7 @@ void ModuleBase_WidgetValidated::activateFilters(ModuleBase_IWorkshop* theWorksh aViewer->addSelectionFilter(aSelFilter); else aViewer->removeSelectionFilter(aSelFilter); - } + }*/ } void ModuleBase_WidgetValidated::selectionFilters(ModuleBase_IWorkshop* theWorkshop, diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.h b/src/ModuleBase/ModuleBase_WidgetValidated.h index 90a83677e..fdb094112 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.h +++ b/src/ModuleBase/ModuleBase_WidgetValidated.h @@ -43,6 +43,11 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidg /// \return a boolean value bool isValid(const Handle_SelectMgr_EntityOwner& theOwner); + /// Set the given wrapped value to the current widget + /// This value should be processed in the widget according to the needs + /// \param theValue the wrapped widget value + virtual bool setSelection(ModuleBase_ViewerPrs theValue); + protected: /// Creates a backup of the current values of the attribute /// It should be realized in the specific widget because of different @@ -53,7 +58,7 @@ protected: /// Fills the attribute with the value of the selected owner /// \param theOwner a selected owner - virtual void setSelection(const Handle_SelectMgr_EntityOwner& theOwner) = 0; + virtual bool setSelection(const Handle_SelectMgr_EntityOwner& theOwner) = 0; /// Checks the current attibute in all attribute validators // \return true if all validators return that the attribute is valid diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 83f59bfe6..a04ce1ee1 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -21,6 +21,9 @@ #include #include #include +#include +#include + #include #include @@ -126,6 +129,10 @@ void PartSet_Module::registerValidators() aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator); aFactory->registerValidator("PartSet_DifferentShapes", new ModelAPI_ShapeValidator); aFactory->registerValidator("PartSet_SketchValidator", new PartSet_SketchValidator); + + aFactory->registerValidator("ModuleBase_ValidatorLinearEdge", new ModuleBase_ValidatorLinearEdge); + aFactory->registerValidator("ModuleBase_ValidatorLinearEdgeOrVertex", + new ModuleBase_ValidatorLinearEdgeOrVertex); } void PartSet_Module::registerFilters() diff --git a/src/PartSet/PartSet_WidgetShapeSelector.cpp b/src/PartSet/PartSet_WidgetShapeSelector.cpp index 93aac5e0c..726f8c160 100644 --- a/src/PartSet/PartSet_WidgetShapeSelector.cpp +++ b/src/PartSet/PartSet_WidgetShapeSelector.cpp @@ -25,7 +25,7 @@ bool PartSet_WidgetShapeSelector::storeAttributeValues(ObjectPtr theSelectedObje return false; std::shared_ptr aSPFeature = std::dynamic_pointer_cast(aSelectedFeature); - if (aSPFeature.get() != NULL && aShape.get() != NULL && !aShape->isNull()) { + if (aSPFeature.get() == NULL && aShape.get() != NULL && !aShape->isNull()) { // Processing of external (non-sketch) object ObjectPtr aObj = PartSet_Tools::createFixedObjectByExternal(aShape->impl(), aSelectedObject, mySketch); @@ -42,9 +42,24 @@ bool PartSet_WidgetShapeSelector::storeAttributeValues(ObjectPtr theSelectedObje AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast(aAttr); if (aRefAttr) { - TopoDS_Shape aTDSShape = aShape->impl(); - AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(aSelectedObject, aTDSShape, mySketch); + // it is possible that the point feature is selected. It should be used itself + // instead of searching an attribute for the shape + bool aShapeIsResult = false; + /*ResultPtr aResult = std::dynamic_pointer_cast(theSelectedObject); + if (aResult.get() != NULL) { + GeomShapePtr aShapePtr = aResult->shape(); + // it is important to call isEqual of the shape of result. + // It is a GeomAPI_Vertex shape for the point. The shape of the parameter is + // GeomAPI_Shape. It is important to use the realization of the isEqual method from + // GeomAPI_Vertex class + aShapeIsResult = aShapePtr.get() != NULL && aShapePtr->isEqual(theShape); + }*/ + AttributePtr aPntAttr; + if (!aShapeIsResult) { + TopoDS_Shape aTDSShape = aShape->impl(); + aPntAttr = PartSet_Tools::findAttributeBy2dPoint(aSelectedObject, aTDSShape, mySketch); + } // this is an alternative, whether the attribute should be set or object in the attribute // the first check is the attribute because the object already exist // the object is set only if there is no selected attribute diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index b4a7ab35b..ed75e1bd9 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -56,7 +56,7 @@ tooltip="Select point, line end point, line, center of circle or arc." shape_types="edge vertex"> - + /> - - + + @@ -83,7 +83,7 @@ - + @@ -98,7 +98,7 @@ - + @@ -108,13 +108,13 @@ - - + + - + @@ -127,16 +127,16 @@ label="First line" tooltip="Select an line" shape_types="edge"> - - + + - - + + @@ -153,14 +153,14 @@ - + - + diff --git a/src/XGUI/XGUI_Selection.h b/src/XGUI/XGUI_Selection.h index 9d6848ccd..a782444c8 100644 --- a/src/XGUI/XGUI_Selection.h +++ b/src/XGUI/XGUI_Selection.h @@ -41,7 +41,8 @@ class XGUI_EXPORT XGUI_Selection : public ModuleBase_ISelection /// Fills the viewer presentation parameters by the parameters from the owner /// \param thePrs a container for selection /// \param theOwner a selection owner - void fillPresentation(ModuleBase_ViewerPrs& thePrs, const Handle_SelectMgr_EntityOwner& theOwner) const; + virtual void fillPresentation(ModuleBase_ViewerPrs& thePrs, + const Handle_SelectMgr_EntityOwner& theOwner) const; /// Returns a list of viewer highlited presentations /// \return list of presentations -- 2.39.2