Prohibit the selection of a feature when constructing point on edge.
TestPlane_ErrorMsg.py
TestPlane_FaceValidator.py
Test19207.py
+ Test19471.py
)
new ConstructionPlugin_ValidatorAxisTwoNotParallelPlanes());
aFactory->registerValidator("ConstructionPlugin_ValidatorPointThreeNonParallelPlanes",
new ConstructionPlugin_ValidatorPointThreeNonParallelPlanes());
+ aFactory->registerValidator("ConstructionPlugin_ValidatorNotFeature",
+ new ConstructionPlugin_ValidatorNotFeature());
Config_PropManager::registerProp(SKETCH_TAB_NAME, "planes_size", "Size", Config_Prop::DblSpin,
PLANE_SIZE, "0", "1000");
return true;
}
+//==================================================================================================
+bool ConstructionPlugin_ValidatorNotFeature::isValid(
+ const AttributePtr& theAttribute,
+ const std::list<std::string>& /*theArguments*/,
+ Events_InfoMessage& theError) const
+{
+ AttributeSelectionPtr aSelAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
+ if (!aSelAttr) {
+ theError = "Wrong attribute";
+ return false;
+ }
+
+ FeaturePtr aContextFeature = aSelAttr->contextFeature();
+ if (aContextFeature) {
+ theError = "Feature should not be selected";
+ return false;
+ }
+ return true;
+}
+
+//==================================================================================================
+
std::shared_ptr<GeomAPI_Edge> getEdge(const GeomShapePtr theShape)
{
GeomEdgePtr anEdge;
Events_InfoMessage& theError) const;
};
+/// \class ConstructionPlugin_ValidatorNotFeature
+/// \ingroup Validators
+/// \brief A validator for selection of a result but not a feature.
+class ConstructionPlugin_ValidatorNotFeature : public ModelAPI_AttributeValidator
+{
+public:
+ //! \return True if the attribute is valid.
+ //! \param[in] theAttribute the checked attribute.
+ //! \param[in] theArguments arguments of the attribute.
+ //! \param[out] theError error message.
+ virtual bool isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ Events_InfoMessage& theError) const;
+};
+
#endif
\ No newline at end of file
<translation>Select an edge.</translation>
</message>
</context>
+ <context>
+ <name>Point:edge:ConstructionPlugin_ValidatorNotFeature</name>
+ <message>
+ <source>Wrong attribute</source>
+ <translation>Wrong attribute.</translation>
+ </message>
+ <message>
+ <source>Feature should not be selected</source>
+ <translation>Feature should not be selected.</translation>
+ </message>
+ </context>
<context>
<name>Point:edge_for_point_projection</name>
<message>
<translation>Sélectionnez l'arête de référence.</translation>
</message>
</context>
+ <context>
+ <name>Point:edge:ConstructionPlugin_ValidatorNotFeature</name>
+ <message>
+ <source>Wrong attribute</source>
+ <translation>Attribut incorrect.</translation>
+ </message>
+ <message>
+ <source>Feature should not be selected</source>
+ <translation>La fonction ne doit pas être sélectionnée.</translation>
+ </message>
+ </context>
<context>
<name>Point:edge_for_point_projection</name>
<message>
--- /dev/null
+# Copyright (C) 2020 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Point_2 = model.addPoint(Part_1_doc, 5, 0, 0)
+Point_3 = model.addPoint(Part_1_doc, 20, 0, 0)
+Edge_1 = model.addEdge(Part_1_doc, model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_2"))
+Point_4 = model.addPoint(Part_1_doc, model.selection("EDGE", "all-in-Edge_1"), 10, False, False)
+model.end()
+
+assert(Point_4.feature().error() != "")
icon="icons/Construction/edge.png"
shape_types="edge">
<validator id="GeomValidators_Finite"/>
+ <validator id="ConstructionPlugin_ValidatorNotFeature"/>
</shape_selector>
<radiobox id="offset_type">
<radio id="offset_type_by_distance"