Salome HOME
Update copyrights
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintAngle.cpp
index 7a6a4ac0f3efc3d059b2862a147de0abaa3b7dc3..d51be3f9d98adedaf48f54120292bd74c4b568fb 100644 (file)
@@ -1,33 +1,40 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019  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
+//
 
 #include <SketchSolver_ConstraintAngle.h>
-#include <SketchSolver_Manager.h>
 
-#include <GeomAPI_Dir2d.h>
-#include <GeomAPI_Lin2d.h>
-#include <GeomAPI_Pnt2d.h>
-#include <GeomAPI_XY.h>
-
-#include <cmath>
+#include <ModelAPI_AttributeInteger.h>
+#include <SketchPlugin_ConstraintAngle.h>
 
 void SketchSolver_ConstraintAngle::getAttributes(
-    double& theValue, std::vector<EntityWrapperPtr>& theAttributes)
+    EntityWrapperPtr& theValue, std::vector<EntityWrapperPtr>& theAttributes)
 {
   SketchSolver_Constraint::getAttributes(theValue, theAttributes);
-
-  myAngle = theValue;
+  myType = myBaseConstraint->integer(SketchPlugin_ConstraintAngle::TYPE_ID())->value();
 }
 
 
 void SketchSolver_ConstraintAngle::adjustConstraint()
 {
-  static const double aTol = 1000. * tolerance;
-  BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder();
-
-  ConstraintWrapperPtr aConstraint = myStorage->constraint(myBaseConstraint).front();
-  //if (fabs(myAngle - aConstraint->value()) < aTol)
-  //  return;
-  myAngle = aConstraint->value();
-  aBuilder->adjustConstraint(aConstraint);
-  myStorage->addConstraint(myBaseConstraint, aConstraint);
+  int aType = myBaseConstraint->integer(SketchPlugin_ConstraintAngle::TYPE_ID())->value();
+  if (aType != myType) {
+    myType = aType;
+    myStorage->setNeedToResolve(true);
+  }
 }