fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_CENTER_AND_PASSED_POINTS(), mycircleType);
fillAttribute(centerPoint(), theCenterX, theCenterY);
fillAttribute(passedPoint(), thePassedX, thePassedY);
-
- bool isNeedPoint =
- feature()->integer(SketchPlugin_MacroCircle::VERSION_ID())->value() > 0;
-
- if (isNeedPoint)
- fillAttribute(theAngle, angle());
+ fillAttribute(theAngle, angle());
execute();
}
fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_CENTER_AND_PASSED_POINTS(), mycircleType);
fillAttribute(theCenterPoint, mycenterPoint);
fillAttribute(thePassedPoint, mypassedPoint);
-
- bool isNeedPoint =
- feature()->integer(SketchPlugin_MacroCircle::VERSION_ID())->value() > 0;
-
- if (isNeedPoint)
- fillAttribute(theAngle, angle());
+ fillAttribute(theAngle, angle());
execute();
}
fillAttribute(firstPoint(), theX1, theY1);
fillAttribute(secondPoint(), theX2, theY2);
fillAttribute(thirdPoint(), theX3, theY3);
-
- bool isNeedPoint =
- feature()->integer(SketchPlugin_MacroCircle::VERSION_ID())->value() > 0;
-
- if (isNeedPoint)
- fillAttribute(theAngle, angle());
+ fillAttribute(theAngle, angle());
execute();
}
fillAttribute(thePoint1, myfirstPoint);
fillAttribute(thePoint2, mysecondPoint);
fillAttribute(thePoint3, mythirdPoint);
-
- bool isNeedPoint =
- feature()->integer(SketchPlugin_MacroCircle::VERSION_ID())->value() > 0;
-
- if (isNeedPoint)
- fillAttribute(theAngle, angle());
+ fillAttribute(theAngle, angle());
execute();
}
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), ANGLE_ID());
}
+/*static FeaturePtr CreatePoint(FeaturePtr theCircleFeature, SketchPlugin_Sketch* theSketch,
+ GeomPnt2dPtr thePoint)
+{
+ // create point at sewing point of circle
+ FeaturePtr aPointFeature = theSketch->addFeature(SketchPlugin_Point::ID());
+ aPointFeature->reference(SketchPlugin_Point::PARENT_ID())->setValue(theCircleFeature);
+
+ AttributePoint2DPtr aCoord = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aPointFeature->attribute(SketchPlugin_Point::COORD_ID()));
+ aCoord->setValue(thePoint);
+ aPointFeature->execute();
+ return aPointFeature;
+}*/
+
void SketchPlugin_Circle::execute()
{
SketchPlugin_Sketch* aSketch = sketch();
- if(!aSketch) {
+ if (!aSketch) {
return;
}
// Compute a circle in 3D view.
std::shared_ptr<GeomDataAPI_Point2D> aCenterAttr =
- std::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(CENTER_ID()));
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(CENTER_ID()));
AttributeDoublePtr aRadiusAttr = real(RADIUS_ID());
AttributeDoublePtr anAngleAttr = real(ANGLE_ID());
- if(!aCenterAttr->isInitialized() || !aRadiusAttr->isInitialized()) {
+ if (!aCenterAttr->isInitialized() || !aRadiusAttr->isInitialized()) {
return;
}
double aRadius = aRadiusAttr->value();
- if(aRadius < tolerance) {
+ if (aRadius < tolerance) {
return;
}
// Make a visible circle.
std::shared_ptr<GeomAPI_Pnt> aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y()));
std::shared_ptr<GeomDataAPI_Dir> aNDir = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
- aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
+ aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
std::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(aNDir->x(), aNDir->y(), aNDir->z()));
double aValAn = anAngleAttr->value();
aResult->setShape(aCircleShape);
aResult->setIsInHistory(false);
setResult(aResult, 1);
+
+ /*if (!reference(ROTATE_REF_ID())->value())
+ {
+ aWasBlocked = data()->blockSendAttributeUpdated(true);
+ auto aCurCircle = this->document()->currentFeature(true);
+ auto aCrPoint = CreatePoint(aCurCircle, sketch(), std::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(ROTATE_ID()))->pnt());
+ SketchPlugin_Tools::createConstraintAttrAttr(sketch(), SketchPlugin_ConstraintCoincidenceInternal::ID(),
+ attribute(SketchPlugin_Circle::ROTATE_ID()), std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aCrPoint->attribute(SketchPlugin_Point::COORD_ID())));
+ aCrPoint->boolean(AUXILIARY_ID())->setValue(boolean(AUXILIARY_ID())->value());
+ reference(SketchPlugin_Circle::ROTATE_REF_ID())->setValue(aCrPoint);
+ data()->blockSendAttributeUpdated(aWasBlocked, false);
+ }*/
}
bool SketchPlugin_Circle::isFixed() {
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), THIRD_POINT_REF_ID());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EDIT_CIRCLE_TYPE());
- // 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());
-
string(EDIT_CIRCLE_TYPE())->setValue("");
}
SketchPlugin_Tools::resetAttribute(this, THIRD_POINT_ID());
SketchPlugin_Tools::resetAttribute(this, THIRD_POINT_REF_ID());
} else if(theID == CENTER_POINT_ID() || theID == PASSED_POINT_ID() ||
- theID == CENTER_POINT_REF_ID() || theID == PASSED_POINT_REF_ID() ||
- isRotPoint(theID, string(CIRCLE_TYPE())->value(), CIRCLE_TYPE_BY_CENTER_AND_PASSED_POINTS()))
+ theID == CENTER_POINT_REF_ID() || theID == PASSED_POINT_REF_ID())
fillByCenterAndPassed();
else if(theID == FIRST_POINT_ID() || theID == FIRST_POINT_REF_ID() ||
theID == SECOND_POINT_ID() || theID == SECOND_POINT_REF_ID() ||
- theID == THIRD_POINT_ID() || theID == THIRD_POINT_REF_ID() ||
- isRotPoint(theID, string(CIRCLE_TYPE())->value(), CIRCLE_TYPE_BY_THREE_POINTS())) {
+ theID == THIRD_POINT_ID() || theID == THIRD_POINT_REF_ID())
+ {
std::shared_ptr<GeomAPI_Pnt2d> aPoints[3];
int aNbInitialized = 0;
for(int i = 1; i <= 3; ++i) {
AttributePoint2DPtr aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(ROTATE_POINT_ID()));
aPointAttr->setValue(myRotPoint);
}
+ else if (aCircle)
+ {
+ computeNewAngle(aCircle);
+ }
if (anAngleAttr->isInitialized())
anAngleAttr->setValue(myAngle);
return ID;
}
- /// Attribute name of the version of Circle feature
- /// Need for compability with old way of creating circle
- inline static const std::string& VERSION_ID()
- {
- static const std::string MY_VERSION_ID("version");
- return MY_VERSION_ID;
- }
-
/// Returns the kind of a feature
SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
{
tooltip="Center coordinates"
accept_expressions="0"
enable_value="enable_by_preferences"/>
- <sketch-2dpoint_selector id="circle_rotate"
- title="Rotate"
- tooltip="Rotate coordinates"
- accept_expressions="0"
- enable_value="enable_by_preferences"/>
<labelvalue id="circle_radius"
icon="icons/Sketch/radius.png"
label="Radius"
enable_value="enable_by_preferences">
<validator id="SketchPlugin_CirclePassedPointValidator"/>
</sketch-2dpoint_selector>
- <sketch-2dpoint_selector id="rotate_point"
- reference_attribute="rotate_point_ref"
- title="Rotate point"
- tooltip="Rotate point coordinates"
- accept_expressions="0"
- enable_value="enable_by_preferences"/>
<validator id="GeomValidators_Different" parameters="center_point_ref,passed_point_ref"/>
- <validator id="GeomValidators_Different" parameters="center_point_ref,rotate_point_ref"/>
</box>
<box id="circle_type_by_three_points"
icon="icons/Sketch/circle_3pt_32x32.png"
<validator id="SketchPlugin_DifferentReference" parameters="first_point_ref,second_point_ref,third_point_ref"/>
<validator id="SketchPlugin_ThirdPointValidator" parameters="third_point_ref"/>
</sketch-2dpoint_selector>
- <sketch-2dpoint_selector id="rotate_point"
- reference_attribute="rotate_point_ref"
- title="Rotate point"
- tooltip="Rotate point coordinates"
- accept_expressions="0"
- enable_value="enable_by_preferences"/>
- <validator id="GeomValidators_Different" parameters="first_point_ref,second_point_ref,third_point_ref"/>
</box>
</toolbox>
<labelvalue id="circle_radius"