X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FSketchPlugin%2FSketchPlugin_MacroBSpline.cpp;h=9781c8e22dd2fae4b650d1e2a0eb7eee391d32d6;hb=86f4ec4eb5ff5f119914f3d44cf945b49845d8c2;hp=100e011e66d33cafc01038c3bd2fb92a1f68f393;hpb=c0c5763cf0cc9462b9bca9d1d272f862d921f130;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_MacroBSpline.cpp b/src/SketchPlugin/SketchPlugin_MacroBSpline.cpp index 100e011e6..9781c8e22 100644 --- a/src/SketchPlugin/SketchPlugin_MacroBSpline.cpp +++ b/src/SketchPlugin/SketchPlugin_MacroBSpline.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2020 CEA/DEN, EDF R&D +// Copyright (C) 2019-2023 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -27,13 +27,15 @@ #include #include +#include + #include #include #include #include -#include #include #include +#include #include @@ -85,60 +87,10 @@ void SketchPlugin_MacroBSpline::execute() if (boolean(CONTROL_POLYGON_ID())->value()) { std::list aControlPoles; - createControlPolygon(aBSpline, aControlPoles); + createControlPolygon(aBSpline, myIsPeriodic, aControlPoles); constraintsForPoles(aControlPoles); - - // message to init reentrant operation - static Events_ID anId = ModelAPI_EventReentrantMessage::eventId(); - ReentrantMessagePtr aMessage(new ModelAPI_EventReentrantMessage(anId, this)); - // set here the last pole to make coincidence with the start point of the next B-spline curve - aMessage->setCreatedFeature(aControlPoles.back()); - Events_Loop::loop()->send(aMessage); - } -} - -// LCOV_EXCL_START -std::string SketchPlugin_MacroBSpline::processEvent( - const std::shared_ptr& theMessage) -{ - ReentrantMessagePtr aReentrantMessage = - std::dynamic_pointer_cast(theMessage); - if (aReentrantMessage) { - FeaturePtr aCreatedFeature = aReentrantMessage->createdFeature(); - ObjectPtr anObject = aReentrantMessage->selectedObject(); - AttributePtr anAttribute = aReentrantMessage->selectedAttribute(); - std::shared_ptr aClickedPoint = aReentrantMessage->clickedPoint(); - - if (aClickedPoint) { - // fill points list (it consists of 2 points to make editable the second one) - AttributePoint2DArrayPtr aPointArrayAttr = - std::dynamic_pointer_cast(attribute(POLES_ID())); - aPointArrayAttr->setSize(2); - aPointArrayAttr->setPnt(0, aClickedPoint); - aPointArrayAttr->setPnt(1, aClickedPoint); - - // fill weights - AttributeDoubleArrayPtr aWeightsArrayAttr = data()->realArray(WEIGHTS_ID()); - aWeightsArrayAttr->setSize(2); - aWeightsArrayAttr->setValue(0, 1.0); - aWeightsArrayAttr->setValue(1, 1.0); - - // fill reference attribute - AttributeRefAttrListPtr aRefAttrList = - std::dynamic_pointer_cast(attribute(REF_POLES_ID())); - if (anAttribute) { - if (!anAttribute->owner() || !anAttribute->owner()->data()->isValid()) { - if (aCreatedFeature && anAttribute->id() == SketchPlugin_Point::COORD_ID()) - anAttribute = aCreatedFeature->attribute(SketchPlugin_Point::COORD_ID()); - } - aRefAttrList->append(anAttribute); - } - } - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); } - return std::string(); } -// LCOV_EXCL_STOP FeaturePtr SketchPlugin_MacroBSpline::createBSplineFeature() { @@ -198,6 +150,7 @@ FeaturePtr SketchPlugin_MacroBSpline::createBSplineFeature() } void SketchPlugin_MacroBSpline::createControlPolygon(FeaturePtr theBSpline, + bool thePeriodic, std::list& thePoles) { AttributePoint2DArrayPtr aPoles = std::dynamic_pointer_cast( @@ -209,7 +162,7 @@ void SketchPlugin_MacroBSpline::createControlPolygon(FeaturePtr theBSpline, // segments for (int index = 1; index < aSize; ++index) createAuxiliarySegment(aPoles, index - 1, index); - if (myIsPeriodic) { + if (thePeriodic) { // additional segment to close the control polygon createAuxiliarySegment(aPoles, aSize - 1, 0); } @@ -316,10 +269,10 @@ void SketchPlugin_MacroBSpline::assignDefaultNameForAux(FeaturePtr theAuxFeature { FeaturePtr aBSpline = ModelAPI_Feature::feature(theBSplinePoles->owner()); - std::ostringstream aName; + std::wostringstream aName; aName << aBSpline->name(); if (theAuxFeature->getKind() == SketchPlugin_Point::ID()) - aName << "_" << theBSplinePoles->id() << "_" << thePoleIndex1; + aName << "_" << Locale::Convert::toWString(theBSplinePoles->id()) << "_" << thePoleIndex1; else aName << "_segment_" << thePoleIndex1 << "_" << thePoleIndex2;