X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FSketchPlugin_ConstraintRadius.cpp;h=906802732176716dfe7d9d7def0879547d2078f4;hb=77ce6d35ac8d2f0fdaecb4f23e0870bf74e36103;hp=c2f363b731b7a36139765491aaf71cf368eaec76;hpb=97917d3698f5a2f7fc9596e7c755ff8f6751e373;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp b/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp index c2f363b73..906802732 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// Copyright (C) 2014-2024 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -75,27 +76,6 @@ void SketchPlugin_ConstraintRadius::execute() ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object()); if (aFeature) { - double aRadius = 0; - std::shared_ptr aData = aFeature->data(); - if (aFeature->getKind() == SketchPlugin_Circle::ID()) { - AttributeDoublePtr anAttribute = std::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Circle::RADIUS_ID())); - if (anAttribute) - aRadius = anAttribute->value(); - } else if (aFeature->getKind() == SketchPlugin_Arc::ID()) { - std::shared_ptr aCenterAttr = std::dynamic_pointer_cast< - GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::CENTER_ID())); - std::shared_ptr aStartAttr = std::dynamic_pointer_cast< - GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID())); - if (aCenterAttr && aStartAttr) - aRadius = aCenterAttr->pnt()->distance(aStartAttr->pnt()); - } - //std::shared_ptr aValueAttr = std::dynamic_pointer_cast< - // ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE())); - //if(!aValueAttr->isInitialized()) { - // aValueAttr->setValue(aRadius); - //} - // the value should to be computed here, // not in the getAISObject in order to change the model value // inside the object transaction. This is important for creating a constraint by preselection. @@ -175,8 +155,10 @@ AISObjectPtr SketchPlugin_ConstraintRadius::getAISObject(AISObjectPtr thePreviou if (!sketch()) return thePrevious; - AISObjectPtr anAIS = SketcherPrs_Factory::radiusConstraint(this, sketch()->coordinatePlane(), + AISObjectPtr anAIS = SketcherPrs_Factory::radiusConstraint(this, sketch(), thePrevious); + if (anAIS.get() && !thePrevious.get()) + SketchPlugin_Tools::setDimensionColor(anAIS); return anAIS; }