X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketcherPrs%2FSketcherPrs_PositionMgr.cpp;h=ec7938b89abfd58c7fdf66432b34ca550ae76a9d;hb=8ebc9a7d5f87057b61b174e7568e01e44571549d;hp=e7648db53b4df56d42d9c6c313920fb8b1053e37;hpb=706361414a00e683cf7ecb6ca3e3a7e941833200;p=modules%2Fshaper.git diff --git a/src/SketcherPrs/SketcherPrs_PositionMgr.cpp b/src/SketcherPrs/SketcherPrs_PositionMgr.cpp index e7648db53..ec7938b89 100644 --- a/src/SketcherPrs/SketcherPrs_PositionMgr.cpp +++ b/src/SketcherPrs/SketcherPrs_PositionMgr.cpp @@ -28,27 +28,27 @@ SketcherPrs_PositionMgr::SketcherPrs_PositionMgr() int SketcherPrs_PositionMgr::getPositionIndex(ObjectPtr theLine, - Handle(SketcherPrs_SymbolPrs) thePrs) + const SketcherPrs_SymbolPrs* thePrs) { if (myShapes.count(theLine) == 1) { PositionsMap& aPosMap = myShapes[theLine]; - if (aPosMap.count(thePrs.Access()) == 1) { - return aPosMap[thePrs.Access()]; + if (aPosMap.count(thePrs) == 1) { + return aPosMap[thePrs]; } else { int aInd = aPosMap.size(); - aPosMap[thePrs.Access()] = aInd; + aPosMap[thePrs] = aInd; return aInd; } } else { PositionsMap aPosMap; - aPosMap[thePrs.Access()] = 0; + aPosMap[thePrs] = 0; myShapes[theLine] = aPosMap; return 0; } } gp_Pnt SketcherPrs_PositionMgr::getPosition(ObjectPtr theShape, - Handle(SketcherPrs_SymbolPrs) thePrs, + const SketcherPrs_SymbolPrs* thePrs, double theStep) { std::shared_ptr aShape = SketcherPrs_Tools::getShape(theShape); @@ -107,7 +107,7 @@ gp_Pnt SketcherPrs_PositionMgr::getPosition(ObjectPtr theShape, // Odd position aP.Translate(-aShift); if (aPos > 1) { - if (aPos % 4 == 0) + if ((aPos - 1) % 4 == 0) aM = (aPos - 1) / 4; else aM = -(aPos + 1) / 4; @@ -122,18 +122,20 @@ gp_Pnt SketcherPrs_PositionMgr::getPosition(ObjectPtr theShape, return aP; } -void SketcherPrs_PositionMgr::deleteConstraint(Handle(SketcherPrs_SymbolPrs) thePrs) +void SketcherPrs_PositionMgr::deleteConstraint(const SketcherPrs_SymbolPrs* thePrs) { std::map::iterator aIt; + std::list aToDel; for (aIt = myShapes.begin(); aIt != myShapes.end(); ++aIt) { PositionsMap& aPosMap = aIt->second; - if (aPosMap.count(thePrs.Access()) > 0) - aPosMap.erase(aPosMap.find(thePrs.Access())); - } - for (aIt = myShapes.begin(); aIt != myShapes.end(); ++aIt) { - if (aIt->second.size() == 0) { - myShapes.erase(aIt); - aIt = myShapes.begin(); + if (aPosMap.count(thePrs) > 0) { + aPosMap.erase(aPosMap.find(thePrs)); + if (aPosMap.size() == 0) + aToDel.push_back(aIt->first); } } + std::list::const_iterator aListIt; + for (aListIt = aToDel.cbegin(); aListIt != aToDel.cend(); ++aListIt) { + myShapes.erase(*aListIt); + } }