theRadiusAttr->setValue(theCircle->radius());
}
-static inline void calculatePassedPoint(
+static inline bool calculatePassedPoint(
const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
const std::shared_ptr<GeomAPI_Pnt2d>& theStartPoint,
const std::shared_ptr<GeomAPI_Pnt2d>& theEndPoint,
{
if (theCenter->distance(theStartPoint) < tolerance ||
theCenter->distance(theEndPoint) < tolerance)
- return;
+ return false;
std::shared_ptr<GeomAPI_Dir2d> aStartDir(new GeomAPI_Dir2d(
theStartPoint->xy()->decreased(theCenter->xy())));
double aRadius = theCenter->distance(theStartPoint);
std::shared_ptr<GeomAPI_XY> aPassedPnt = theCenter->xy()->added( aMidDir->xy()->multiplied(aRadius) );
thePassedPoint->setValue(aPassedPnt->x(), aPassedPnt->y());
+ return true;
}
void SketchPlugin_Arc::updateDependentAttributes()
data()->blockSendAttributeUpdated(true);
- calculatePassedPoint(aCenterAttr->pnt(), aStartAttr->pnt(), anEndAttr->pnt(),
+ bool isOk = calculatePassedPoint(aCenterAttr->pnt(), aStartAttr->pnt(), anEndAttr->pnt(),
isReversed(), aPassedPoint);
- if (aRadiusAttr && anAngleAttr) {
+ if (isOk && aRadiusAttr && anAngleAttr) {
std::shared_ptr<GeomAPI_Circ2d> aCircle(
new GeomAPI_Circ2d(aStartAttr->pnt(), anEndAttr->pnt(), aPassedPoint->pnt()));
if (aCircle->implPtr<void*>())
void SketchPlugin_Line::attributeChanged(const std::string& theID) {
// the second condition for unability to move external segments anywhere
- if (theID == EXTERNAL_ID() || isFixed()) {
+ // isCopy() is checked temporary for case when copied lines stored external id state
+ // to be removed after debug
+ if ((theID == EXTERNAL_ID() || isFixed()) && !isCopy()) {
std::shared_ptr<GeomAPI_Shape> aSelection = data()->selection(EXTERNAL_ID())->value();
// update arguments due to the selection value
if (aSelection && !aSelection->isNull() && aSelection->isEdge()) {
std::string aUniqueFeatureName = aNewFeature->data()->name();
// all attribute values are copied\pasted to the new feature, name is not an exception
theFeature->data()->copyTo(aNewFeature->data());
- // as a name for the feature, the generated unique name is set
+ // external state should not be copied as a new object is an object of the current sketch
+ if (theFeature->selection(SketchPlugin_SketchEntity::EXTERNAL_ID()).get())
+ theFeature->selection(SketchPlugin_SketchEntity::EXTERNAL_ID())->setValue(NULL, NULL);
aNewFeature->data()->setName(aUniqueFeatureName);
// text expressions could block setValue of some attributes
SketchPlugin_Tools::clearExpressions(aNewFeature);