-// Copyright (C) 2014-2017 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
//
// 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
+// 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>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "SketchAPI_Sketch.h"
execute();
}
+void SketchAPI_Sketch::setPlane(const ModelHighAPI_Selection & thePlane,
+ bool theRemoveExternalDependency)
+{
+ FeaturePtr aSketch = feature();
+
+ DocumentPtr aDoc = aSketch->document();
+ bool useVisible = false;
+ FeaturePtr aCurFeatureBefore = aDoc->currentFeature(useVisible);
+ aDoc->setCurrentFeature(aSketch, useVisible);
+
+ if (theRemoveExternalDependency)
+ aSketch->customAction(SketchPlugin_Sketch::ACTION_REMOVE_EXTERNAL());
+
+ setExternal(thePlane);
+
+ aDoc->setCurrentFeature(aCurFeatureBefore, useVisible);
+}
+
+//--------------------------------------------------------------------------------------
void SketchAPI_Sketch::setExternal(const ModelHighAPI_Selection & theExternal)
{
fillAttribute(theExternal, myexternal);
}
+//--------------------------------------------------------------------------------------
+std::list< std::shared_ptr<SketchAPI_Point> > SketchAPI_Sketch::getFreePoints()
+{
+ std::list< std::shared_ptr<SketchAPI_Point> > aFreePoints;
+ std::list<ResultPtr> aPoints = SketcherPrs_Tools::getFreePoints(compositeFeature());
+ for (std::list<ResultPtr>::iterator anIt = aPoints.begin(); anIt != aPoints.end(); ++anIt) {
+ FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
+ PointPtr aPoint(new SketchAPI_Point(aFeature));
+ aFreePoints.push_back(aPoint);
+ }
+ return aFreePoints;
+}
+
//--------------------------------------------------------------------------------------
std::shared_ptr<SketchAPI_Point> SketchAPI_Sketch::addPoint(
double theX, double theY)
//--------------------------------------------------------------------------------------
std::shared_ptr<SketchAPI_IntersectionPoint> SketchAPI_Sketch::addIntersectionPoint(
- const ModelHighAPI_Selection & theExternal)
+ const ModelHighAPI_Selection & theExternal,
+ bool theKeepResult)
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_IntersectionPoint::ID());
- return IntersectionPointPtr(new SketchAPI_IntersectionPoint(aFeature, theExternal));
+ IntersectionPointPtr anIntersection(new SketchAPI_IntersectionPoint(aFeature, theExternal));
+ anIntersection->setIncludeToResult(theKeepResult);
+ return anIntersection;
}
std::shared_ptr<SketchAPI_IntersectionPoint> SketchAPI_Sketch::addIntersectionPoint(
- const std::string & theExternalName)
+ const std::string & theExternalName,
+ bool theKeepResult)
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_IntersectionPoint::ID());
- return IntersectionPointPtr(new SketchAPI_IntersectionPoint(aFeature, theExternalName));
+ IntersectionPointPtr anIntersection(new SketchAPI_IntersectionPoint(aFeature, theExternalName));
+ anIntersection->setIncludeToResult(theKeepResult);
+ return anIntersection;
}
//--------------------------------------------------------------------------------------
fillAttribute(SketcherPrs_Tools::ANGLE_DIRECT,
aFeature->integer(SketchPlugin_ConstraintAngle::TYPE_ID()));
// fill the value before llines to avoid calculation of angle value by the Angle feature
- fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()));
fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
+ fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()));
aFeature->execute();
return InterfacePtr(new ModelHighAPI_Interface(aFeature));
}
compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::ID());
fillAttribute(SketcherPrs_Tools::ANGLE_COMPLEMENTARY,
aFeature->integer(SketchPlugin_ConstraintAngle::TYPE_ID()));
- fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()));
fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
-// fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
+ fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()));
aFeature->execute();
return InterfacePtr(new ModelHighAPI_Interface(aFeature));
}
compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::ID());
fillAttribute(SketcherPrs_Tools::ANGLE_BACKWARD,
aFeature->integer(SketchPlugin_ConstraintAngle::TYPE_ID()));
- fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()));
fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
-// fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
+ fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()));
aFeature->execute();
return InterfacePtr(new ModelHighAPI_Interface(aFeature));
}
static std::shared_ptr<GeomAPI_Pnt2d> pointCoordinates(const AttributePtr& thePoint)
{
AttributePoint2DPtr aPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(thePoint);
- if (aPnt)
- return aPnt->pnt();
- return std::shared_ptr<GeomAPI_Pnt2d>();
+ return aPnt ? aPnt->pnt() : std::shared_ptr<GeomAPI_Pnt2d>();
}
static std::shared_ptr<GeomAPI_Pnt2d> middlePointOnLine(const FeaturePtr& theFeature)
static std::shared_ptr<GeomAPI_Pnt2d> middlePoint(const ObjectPtr& theObject)
{
+ std::shared_ptr<GeomAPI_Pnt2d> aMiddlePoint;
FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
if (aFeature) {
+ // move only features of the following types
const std::string& aFeatureKind = aFeature->getKind();
if (aFeatureKind == SketchPlugin_Point::ID())
- return pointCoordinates(aFeature->attribute(SketchPlugin_Point::COORD_ID()));
+ aMiddlePoint = pointCoordinates(aFeature->attribute(SketchPlugin_Point::COORD_ID()));
else if (aFeatureKind == SketchPlugin_Line::ID())
- return middlePointOnLine(aFeature);
+ aMiddlePoint = middlePointOnLine(aFeature);
else if (aFeatureKind == SketchPlugin_Circle::ID())
- return pointOnCircle(aFeature);
+ aMiddlePoint = pointOnCircle(aFeature);
else if (aFeatureKind == SketchPlugin_Arc::ID())
- return middlePointOnArc(aFeature);
+ aMiddlePoint = middlePointOnArc(aFeature);
}
- // do not move other types of features
- return std::shared_ptr<GeomAPI_Pnt2d>();
+ return aMiddlePoint;
}
void SketchAPI_Sketch::move(const ModelHighAPI_RefAttr& theMovedEntity,