fillAttribute(theRadius, myradius);
fillAttribute(theAngle, myangle);
- bool isNeedPoint =
- feature()->integer(SketchPlugin_Circle::VERSION_ID())->value() > SketchPlugin_Circle::THE_VERSION_0;
- if (isNeedPoint)
- {
- fillAttribute(theAngle, angle());
+ fillAttribute(theAngle, angle());
- execute();
- createPoint();
- }
- else
- {
- execute();
- }
+ execute();
+ createPoint();
}
//==================================================================================================
{
fillAttribute(theCenter, mycenter);
fillAttribute(theRadius, myradius);
+ fillAttribute(theAngle, angle());
- bool isNeedPoint =
- feature()->integer(SketchPlugin_Circle::VERSION_ID())->value() > SketchPlugin_Circle::THE_VERSION_0;
-
- if (isNeedPoint)
- {
- fillAttribute(theAngle, angle());
-
- execute();
- createPoint();
- }
- else
- {
- execute();
- }
+ execute();
+ createPoint();
}
//==================================================================================================
const std::string& aSketchName = theDumper.parentName(aBase);
AttributeSelectionPtr anExternal = aBase->selection(SketchPlugin_SketchEntity::EXTERNAL_ID());
- std::string aComName = aBase->integer(SketchPlugin_Circle::VERSION_ID())->value() > SketchPlugin_Circle::THE_VERSION_0 ?
- "addCircleWithPoint" : "addCircle";
-
if (anExternal->context()) {
// circle is external
- theDumper << aBase << " = " << aSketchName << "." << aComName << "(" << anExternal << ")" << std::endl;
+ theDumper << aBase << " = " << aSketchName << ".addCircleWithPoint(" << anExternal << ")" << std::endl;
}
else {// circle given by center and radius
- theDumper << aBase << " = " << aSketchName << "." << aComName << "(" << center() << ", " << radius();
- if (aBase->integer(SketchPlugin_Circle::VERSION_ID())->value() > SketchPlugin_Circle::THE_VERSION_0)
- {
- theDumper << ", " << angle() << ")" << std::endl;
- std::shared_ptr<SketchAPI_SketchEntity> aPoint = createdPoint();
- if (aPoint)
- theDumper << aPoint->feature() << " = " << theDumper.name(aBase) << ".createdPoint()" << std::endl;
- }
- else
- {
- theDumper << ")" << std::endl;
- }
+ theDumper << aBase << " = " << aSketchName << ".addCircleWithPoint(" << center() << ", " << radius();
+ theDumper << ", " << angle() << ")" << std::endl;
+ std::shared_ptr<SketchAPI_SketchEntity> aPoint = createdPoint();
+ if (aPoint)
+ theDumper << aPoint->feature() << " = " << theDumper.name(aBase) << ".createdPoint()" << std::endl;
}
// dump "auxiliary" flag if necessary
SketchAPI_SketchEntity::dump(theDumper);
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_Circle::ID());
- fillAttribute(SketchPlugin_Circle::THE_VERSION_0, aFeature->integer(SketchPlugin_Circle::VERSION_ID()));
return CirclePtr(new SketchAPI_Circle(aFeature, theCenterX, theCenterY, theRadius, 0));
}
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_Circle::ID());
- fillAttribute(SketchPlugin_Circle::THE_VERSION_0, aFeature->integer(SketchPlugin_Circle::VERSION_ID()));
return CirclePtr(new SketchAPI_Circle(aFeature, theCenter, theRadius, 0));
}
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_MacroCircle::ID());
- fillAttribute(SketchPlugin_Circle::THE_VERSION_0, aFeature->integer(SketchPlugin_MacroCircle::VERSION_ID()));
return MacroCirclePtr(new SketchAPI_MacroCircle(aFeature, theCenterX, theCenterY,
thePassedX, thePassedY, 0));
}
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_MacroCircle::ID());
- fillAttribute(SketchPlugin_Circle::THE_VERSION_0, aFeature->integer(SketchPlugin_MacroCircle::VERSION_ID()));
return MacroCirclePtr(new SketchAPI_MacroCircle(aFeature, theCenterPoint, thePassedPoint, 0));
}
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_MacroCircle::ID());
- fillAttribute(SketchPlugin_Circle::THE_VERSION_0, aFeature->integer(SketchPlugin_MacroCircle::VERSION_ID()));
return MacroCirclePtr(new SketchAPI_MacroCircle(aFeature, theX1, theY1,
theX2, theY2,
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_MacroCircle::ID());
- fillAttribute(SketchPlugin_Circle::THE_VERSION_0, aFeature->integer(SketchPlugin_Circle::VERSION_ID()));
return MacroCirclePtr(new SketchAPI_MacroCircle(aFeature, thePoint1, thePoint2, thePoint3, 0));
}
data()->addAttribute(RADIUS_ID(), ModelAPI_AttributeDouble::typeId());
data()->addAttribute(ANGLE_ID(), ModelAPI_AttributeDouble::typeId());
- // While exist addCircle without creating point.
- AttributeIntegerPtr aVerAttr = std::dynamic_pointer_cast<ModelAPI_AttributeInteger>(
- data()->addAttribute(VERSION_ID(), ModelAPI_AttributeInteger::typeId()));
- aVerAttr->setIsArgument(false);
- ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), VERSION_ID());
- if (!aVerAttr->isInitialized()) {
- // this is a newly created feature (not read from file),
- // so, initialize the latest version
- aVerAttr->setValue(SketchPlugin_Circle::THE_VERSION_1);
- }
-
data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::typeId());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), ROTATE_ID());
aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
std::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(aNDir->x(), aNDir->y(), aNDir->z()));
- std::shared_ptr<GeomAPI_Edge> aCircleShape;
- if (integer(VERSION_ID())->value() > SketchPlugin_Circle::THE_VERSION_0)
- {
- double aValAn = anAngleAttr->value();
- aCircleShape = GeomAlgoAPI_EdgeBuilder::lineCircle(aCenter, aNormal, aRadius, aValAn / 180 * PI);
-
- // Update corrdinates for point on circle
- bool aWasBlocked = data()->blockSendAttributeUpdated(true);
- GeomPnt2dPtr aCircleSewPoint = aSketch->to2D(aCircleShape->firstPoint());
- std::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(ROTATE_ID()))
- ->setValue(aCircleSewPoint->x(), aCircleSewPoint->y());
- data()->blockSendAttributeUpdated(aWasBlocked, false);
- }
- else
- aCircleShape = GeomAlgoAPI_EdgeBuilder::lineCircle(aCenter, aNormal, aRadius);
+ double aValAn = anAngleAttr->value();
+ std::shared_ptr<GeomAPI_Edge> aCircleShape = GeomAlgoAPI_EdgeBuilder::lineCircle(aCenter, aNormal, aRadius, aValAn / 180 * PI);
+
+ // Update corrdinates for point on circle
+ bool aWasBlocked = data()->blockSendAttributeUpdated(true);
+ GeomPnt2dPtr aCircleSewPoint = aSketch->to2D(aCircleShape->firstPoint());
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(ROTATE_ID()))
+ ->setValue(aCircleSewPoint->x(), aCircleSewPoint->y());
+ data()->blockSendAttributeUpdated(aWasBlocked, false);
std::shared_ptr<ModelAPI_ResultConstruction> aResult = document()->createConstruction(data(), 1);
aResult->setShape(aCircleShape);
real(ANGLE_ID())->setValue(0);
}
}
- else if (integer(VERSION_ID())->value() > SketchPlugin_Circle::THE_VERSION_0 &&
- theID == ROTATE_ID())
+ else if (theID == ROTATE_ID())
{
// get cricle from results
std::shared_ptr<GeomAPI_Shape> aSelection;
return MY_KIND;
}
- static const int THE_VERSION_0 = 0;
- static const int THE_VERSION_1 = 20232206;
-
- /// Attribute name of the version of Circle feature
- inline static const std::string& VERSION_ID()
- {
- static const std::string MY_VERSION_ID("version");
- return MY_VERSION_ID;
- }
-
/// Returns true is sketch element is under the rigid constraint
SKETCHPLUGIN_EXPORT virtual bool isFixed();
data()->addAttribute(VERSION_ID(), ModelAPI_AttributeInteger::typeId()));
aVerAttr->setIsArgument(false);
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), VERSION_ID());
- if (!aVerAttr->isInitialized()) {
- // this is a newly created feature (not read from file),
- // so, initialize the latest version
- aVerAttr->setValue(SketchPlugin_Circle::THE_VERSION_1);
- }
string(EDIT_CIRCLE_TYPE())->setValue("");
}
this, PASSED_POINT_REF_ID(), AttributePtr(),
theCircleFeature->lastResult(), true);
- if (integer(VERSION_ID())->value() > SketchPlugin_Circle::THE_VERSION_0)
- SketchPlugin_Tools::createCoincidenceOrTangency(
- this, ROTATE_POINT_REF_ID(),
- AttributePtr(),
- theCircleFeature->lastResult(), false);
+ SketchPlugin_Tools::createCoincidenceOrTangency(
+ this, ROTATE_POINT_REF_ID(),
+ AttributePtr(),
+ theCircleFeature->lastResult(), false);
}
void SketchPlugin_MacroCircle::constraintsForCircleByThreePoints(FeaturePtr theCircleFeature)
this, aPointRef[i], AttributePtr(), aCircleResult, true);
}
- if (integer(VERSION_ID())->value() > SketchPlugin_Circle::THE_VERSION_0)
- SketchPlugin_Tools::createCoincidenceOrTangency(
- this, ROTATE_POINT_REF_ID(),
- AttributePtr(),
- aCircleResult, false);
+ SketchPlugin_Tools::createCoincidenceOrTangency(
+ this, ROTATE_POINT_REF_ID(),
+ AttributePtr(),
+ aCircleResult, false);
}
void SketchPlugin_MacroCircle::computeNewAngle(std::shared_ptr<GeomAPI_Circ2d>& theCircle)
{
- if (integer(VERSION_ID())->value() < SketchPlugin_Circle::THE_VERSION_1)
- return;
-
AttributePtr aRotateAtr = attribute(ROTATE_POINT_ID());
if (aRotateAtr->isInitialized())
{
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aCircleFeature->attribute(SketchPlugin_Circle::CENTER_ID()))->setValue(myCenter->x(),
myCenter->y());
- if (integer(VERSION_ID())->value() > SketchPlugin_Circle::THE_VERSION_0)
- {
- aCircleFeature->real(SketchPlugin_Circle::ANGLE_ID())->setValue(myAngle);
- }
+
+ aCircleFeature->real(SketchPlugin_Circle::ANGLE_ID())->setValue(myAngle);
aCircleFeature->real(SketchPlugin_Circle::RADIUS_ID())->setValue(myRadius);
- aCircleFeature->integer(SketchPlugin_Circle::VERSION_ID())->setValue(integer(VERSION_ID())->value());
aCircleFeature->boolean(SketchPlugin_Circle::AUXILIARY_ID())
->setValue(boolean(AUXILIARY_ID())->value());
aCircleFeature->execute();
- if (integer(VERSION_ID())->value() > SketchPlugin_Circle::THE_VERSION_0)
- {
- // Create point
- FeaturePtr aNPoint = CreatePoint(aCircleFeature, myRotPoint);
- }
+ // Create point
+ FeaturePtr aNPoint = CreatePoint(aCircleFeature, myRotPoint);
return aCircleFeature;
}
aShapes.push_back(aCircleShape);
aShapes.push_back(aCenterPointShape);
- // For addCircle command skip creating point
- if (integer(VERSION_ID())->value() > SketchPlugin_Circle::THE_VERSION_0)
- {
- std::shared_ptr<GeomAPI_Pnt> aRotPoint;
- if (myRotPoint.get())
- aRotPoint = std::shared_ptr<GeomAPI_Pnt>(aSketch->to3D(myRotPoint->x(), myRotPoint->y()));
- else
- aRotPoint = std::shared_ptr<GeomAPI_Pnt>(aSketch->to3D(myCenter->x() + myRadius, myCenter->y()));
- GeomShapePtr aNewPnt = GeomAlgoAPI_PointBuilder::vertex(aRotPoint);
- aShapes.push_back(aNewPnt);
- }
+ std::shared_ptr<GeomAPI_Pnt> aRotPoint;
+ if (myRotPoint.get())
+ aRotPoint = std::shared_ptr<GeomAPI_Pnt>(aSketch->to3D(myRotPoint->x(), myRotPoint->y()));
+ else
+ aRotPoint = std::shared_ptr<GeomAPI_Pnt>(aSketch->to3D(myCenter->x() + myRadius, myCenter->y()));
+ GeomShapePtr aNewPnt = GeomAlgoAPI_PointBuilder::vertex(aRotPoint);
+ aShapes.push_back(aNewPnt);
std::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
AISObjectPtr anAIS = thePrevious;
std::shared_ptr <GeomAPI_Circ2d> aCircle;
// If circle type switched reset all attributes.
if(theID == CIRCLE_TYPE()) {
- if (integer(VERSION_ID())->value() > SketchPlugin_Circle::THE_VERSION_0)
- {
- SketchPlugin_Tools::resetAttribute(this, ROTATE_POINT_ID());
- SketchPlugin_Tools::resetAttribute(this, ROTATE_POINT_REF_ID());
- }
-
+ SketchPlugin_Tools::resetAttribute(this, ROTATE_POINT_ID());
+ SketchPlugin_Tools::resetAttribute(this, ROTATE_POINT_REF_ID());
SketchPlugin_Tools::resetAttribute(this, CENTER_POINT_ID());
SketchPlugin_Tools::resetAttribute(this, CENTER_POINT_REF_ID());
SketchPlugin_Tools::resetAttribute(this, PASSED_POINT_ID());
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(CENTER_POINT_ID()))
->setValue(myCenter);
}
+ AttributeDoublePtr anAngleAttr = real(CIRCLE_ROTATE_ANGLE_ID());
- if (integer(VERSION_ID())->value() > SketchPlugin_Circle::THE_VERSION_0)
+ if (myRotPoint.get())
{
- AttributeDoublePtr anAngleAttr = real(CIRCLE_ROTATE_ANGLE_ID());
-
- if (myRotPoint.get())
- {
- AttributePoint2DPtr aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(ROTATE_POINT_ID()));
- aPointAttr->setValue(myRotPoint);
- }
-
- if (anAngleAttr->isInitialized())
- anAngleAttr->setValue(myAngle);
+ AttributePoint2DPtr aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(ROTATE_POINT_ID()));
+ aPointAttr->setValue(myRotPoint);
}
+ if (anAngleAttr->isInitialized())
+ anAngleAttr->setValue(myAngle);
+
aRadiusAttr->setValue(myRadius);
data()->blockSendAttributeUpdated(aWasBlocked, false);
aDistCL = model.distancePointLine(aCenter, theLine)
assert math.fabs(aDistCL - aRadius) < TOLERANCE, "Circle and line are not tangent"
-#=========================================================================
-# Set old version of Circle for avoid create point.
-#=========================================================================
-def setVersionOfCircle(theCircle, theVersion):
- aCircleVersion = theCircle.integer("version")
- assert (type(aCircleVersion) == ModelAPI_AttributeInteger)
- aCircleVersion.setValue(theVersion)
#=========================================================================
# Start of test
assert (not aCircleCenter.isInitialized())
aCircleRadius = aCircle.real("circle_radius")
assert (type(aCircleRadius) == ModelAPI_AttributeDouble)
-setVersionOfCircle(aCircle, 0)
# ModelAPI_AttributeDouble.typeId() is checked in ModelAPI_TestConstants
assert (aCircleRadius.attributeType() == ModelAPI_AttributeDouble.typeId())
aCircleCenter.setValue(-25., -25)
aCircleType = aCircle.string("circle_type")
assert (not aCircleType.isInitialized())
aCircleType.setValue("circle_type_by_center_and_passed_points")
-setVersionOfCircle(aCircle, 0)
aCircleCenter.setValue(-25., -25)
aCirclePassed.setValue(0., -25.)
aRadius = model.distancePointPoint(aCircleCenter, aCirclePassed)
assert (not aCircleType.isInitialized())
# initialize attributes
aCircleType.setValue("circle_type_by_center_and_passed_points")
-setVersionOfCircle(aCircle, 0)
aCenterRef.setObject(aPoint.lastResult())
aCenter.setValue(aPointCoord.pnt())
aPassedRef.setAttr(aPrevCenter)
aCircleType = aCircle.string("circle_type")
# initialize attributes
aCircleType.setValue("circle_type_by_center_and_passed_points")
-setVersionOfCircle(aCircle, 0)
aCenterRef.setObject(aLine.lastResult())
anExpectedCenter = [(aLineStart[0] + aLineEnd[0]) * 0.5, (aLineStart[1] + aLineEnd[1]) * 0.5]
aCenter.setValue(anExpectedCenter[0], anExpectedCenter[1])
aCircleType = aCircle.string("circle_type")
# initialize attributes
aCircleType.setValue("circle_type_by_center_and_passed_points")
-setVersionOfCircle(aCircle, 0)
anExpectedCenter = [(aLineStart[0] + aLineEnd[0]) * 0.5 + 10., (aLineStart[1] + aLineEnd[1]) * 0.5]
aCenter.setValue(anExpectedCenter[0], anExpectedCenter[1])
aPassedRef.setObject(aLine.lastResult())
aCircleType = aCircle.string("circle_type")
# initialize attributes
aCircleType.setValue("circle_type_by_center_and_passed_points")
-setVersionOfCircle(aCircle, 0)
aCenterRef.setObject(aLine.lastResult())
aCenter.setValue(anExpectedCenter[0], anExpectedCenter[1])
aPassedRef.setObject(aLine.lastResult())
aCircleAngle = aCircle.real("circle_angle")
# initialize attributes
aCircleType.setValue("circle_type_by_center_and_passed_points")
-setVersionOfCircle(aCircle, 20232206)
aCenter.setValue(35., -35)
anExpectedCenter = [35., -35]
aPassed.setValue(45., -35)
aDistCL = model.distancePointLine(aCenter, theLine)
assert math.fabs(aDistCL - aRadius) < TOLERANCE, "Circle and line are not tangent"
-#=========================================================================
-# Set old version of Circle for avoid create point.
-#=========================================================================
-def setOldVersionOfCircleFeature(theCircle):
- aCircleVersion = theCircle.integer("version")
- assert (type(aCircleVersion) == ModelAPI_AttributeInteger)
- aCircleVersion.setValue(0)
#=========================================================================
# Start of test
aCircleType = aCircle.string("circle_type")
assert (not aCircleType.isInitialized())
aCircleType.setValue("circle_type_by_three_points")
-setOldVersionOfCircleFeature(aCircle)
aCirclePnt1.setValue(expectedCenter[0] - expectedRadius, expectedCenter[1])
aCirclePnt2.setValue(expectedCenter[0] + expectedRadius, expectedCenter[1])
aCirclePnt3.setValue(expectedCenter[0], expectedCenter[1] + expectedRadius)
aCircleType = aCircle.string("circle_type")
# initialize attributes
aCircleType.setValue("circle_type_by_three_points")
-setOldVersionOfCircleFeature(aCircle)
aCirclePnt1Ref.setAttr(aPrevCenter)
aCirclePnt1.setValue(aPrevCenter.pnt())
aCirclePnt2Ref.setObject(aPoint.lastResult())
aCirclePnt2Ref = aCircle.refattr("second_point_ref")
aCirclePnt3Ref = aCircle.refattr("third_point_ref")
aCircleType = aCircle.string("circle_type")
-setOldVersionOfCircleFeature(aCircle)
# initialize attributes
aCircleType.setValue("circle_type_by_three_points")
aCirclePnt1Ref.setObject(aPrevCircle.lastResult())
aCircleType = aCircle.string("circle_type")
# initialize attributes
aCircleType.setValue("circle_type_by_three_points")
-setOldVersionOfCircleFeature(aCircle)
aCirclePnt1Ref.setAttr(aStartPnt)
aCirclePnt1.setValue(aStartPnt.pnt())
aCirclePnt2Ref.setAttr(aEndPnt)
aCircleType = aCircle.string("circle_type")
# initialize attributes
aCircleType.setValue("circle_type_by_three_points")
-setOldVersionOfCircleFeature(aCircle)
aCirclePnt1.setValue(aLineStart[0] + aDistanceFromLine, aLineStart[1])
aCirclePnt2.setValue(aLineStart[0] - aDistanceFromLine, aLineStart[1])
aCirclePnt3Ref.setObject(aLine.lastResult())
aCircleType = aCircle.string("circle_type")
# initialize attributes
aCircleType.setValue("circle_type_by_three_points")
-setOldVersionOfCircleFeature(aCircle)
aCirclePnt1.setValue(0, 0)
aCirclePnt2Ref.setObject(SketchLine_1.feature().lastResult())
aCirclePnt2.setValue(SketchLine_1.startPoint().x(), SketchLine_1.startPoint().y())
aCircleType = aCircle.string("circle_type")
# initialize attributes
aCircleType.setValue("circle_type_by_three_points")
-setOldVersionOfCircleFeature(aCircle)
aCirclePnt1.setValue(0, 0)
aCirclePnt2Ref.setObject(SketchCircle_3.feature().lastResult())
aCirclePnt2.setValue(40, 0)
aCircleType = aCircle.string("circle_type")
# initialize attributes
aCircleType.setValue("circle_type_by_three_points")
-setOldVersionOfCircleFeature(aCircle)
aCirclePnt1.setValue(0, 0)
aCirclePnt2Ref.setObject(SketchLine_3.feature().lastResult())
aCirclePnt2.setValue(30, 0)
aCircleType = aCircle.string("circle_type")
# initialize attributes
aCircleType.setValue("circle_type_by_three_points")
-setOldVersionOfCircleFeature(aCircle)
aCirclePnt1Ref.setObject(SketchLine_1.feature().lastResult())
aCirclePnt1.setValue(20, 0)
aCirclePnt2Ref.setObject(SketchLine_2.feature().lastResult())
aCircleType = aCircle.string("circle_type")
# initialize attributes
aCircleType.setValue("circle_type_by_three_points")
-setOldVersionOfCircleFeature(aCircle)
aCirclePnt1Ref.setObject(SketchLine_1.feature().lastResult())
aCirclePnt1.setValue(20, 0)
aCirclePnt2Ref.setObject(SketchLine_2.feature().lastResult())
aCircleType = aCircle.string("circle_type")
# initialize attributes
aCircleType.setValue("circle_type_by_three_points")
-setOldVersionOfCircleFeature(aCircle)
aCirclePnt1Ref.setObject(SketchCircle_1.feature().lastResult())
aCirclePnt1.setValue(10, 0)
aCirclePnt2Ref.setObject(SketchCircle_2.feature().lastResult())