return true;
}
+void SketchAPI_Constraint::setEntityA(const ModelHighAPI_RefAttr& theEntity)
+{
+ fillAttribute(theEntity, feature()->refattr(SketchPlugin_Constraint::ENTITY_A()));
+}
+
+void SketchAPI_Constraint::setEntityB(const ModelHighAPI_RefAttr& theEntity)
+{
+ fillAttribute(theEntity, feature()->refattr(SketchPlugin_Constraint::ENTITY_B()));
+}
+
+void SketchAPI_Constraint::setEntityC(const ModelHighAPI_RefAttr& theEntity)
+{
+ fillAttribute(theEntity, feature()->refattr(SketchPlugin_Constraint::ENTITY_C()));
+}
+
+void SketchAPI_Constraint::setEntityD(const ModelHighAPI_RefAttr& theEntity)
+{
+ fillAttribute(theEntity, feature()->refattr(SketchPlugin_Constraint::ENTITY_D()));
+}
+
+void SketchAPI_Constraint::setValue(const ModelHighAPI_Double& theValue)
+{
+ fillAttribute(theValue, feature()->real(SketchPlugin_Constraint::VALUE()));
+}
+
static const std::string& constraintTypeToSetter(const std::string& theType)
{
if (theType == SketchPlugin_ConstraintCoincidence::ID()) {
#include <SketchPlugin_Constraint.h>
+class ModelHighAPI_Double;
+
/**\class SketchAPI_Constraint
* \ingroup CPPHighAPI
* \brief Interface for Constraint feature
SKETCHAPI_EXPORT
bool initialize();
+ SKETCHAPI_EXPORT void setEntityA(const ModelHighAPI_RefAttr& theEntity);
+ SKETCHAPI_EXPORT void setEntityB(const ModelHighAPI_RefAttr& theEntity);
+ SKETCHAPI_EXPORT void setEntityC(const ModelHighAPI_RefAttr& theEntity);
+ SKETCHAPI_EXPORT void setEntityD(const ModelHighAPI_RefAttr& theEntity);
+
+ SKETCHAPI_EXPORT void setValue(const ModelHighAPI_Double& theValue);
+
/// Dump wrapped feature
SKETCHAPI_EXPORT
virtual void dump(ModelHighAPI_Dumper& theDumper) const;
--- /dev/null
+## Copyright (C) 2018-20xx 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<mailto:webmaster.salome@opencascade.com>
+##
+
+"""
+ Test2741.py
+ Test case for issue #2741 "Undo of distance argument change produces crash"
+"""
+
+from salome.shaper import model
+from SketchAPI import *
+
+model.begin()
+partSet = model.moduleDocument()
+Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(-34.48932587013569, -5.994823429605995, -23.03828378136105, 27.99739301876914)
+SketchLine_2 = Sketch_1.addLine(-23.03828378136105, 27.99739301876914, -14.34307552407934, -3.849202930145424)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_1.startPoint(), SketchLine_2.result(), 20, True)
+model.do()
+
+# Change point-line distance constraint to point-point distance
+SketchAPI_Constraint(SketchConstraintDistance_1).setEntityB(SketchLine_2.endPoint())
+model.do()
+model.end()
+
+# Check no crash on undo distance changing
+model.undo()
aParams.insert(myOddPoint->y);
aStorage->removeParameters(aParams);
- aGCSConstraints.pop_back();
- aGCSConstraints.pop_back();
+ // remove constraints keeping sign of point-line distance,
+ // not more than 2 additional constraints is possible
+ if (!aGCSConstraints.empty())
+ aGCSConstraints.pop_back();
+ if (!aGCSConstraints.empty())
+ aGCSConstraints.pop_back();
aConstraint->setConstraints(aGCSConstraints);
aStorage->addConstraint(myBaseConstraint, aConstraint);