]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1448 problem with saved study and visualization of distance: activate of the...
authornds <nds@opencascade.com>
Tue, 26 Apr 2016 15:16:54 +0000 (18:16 +0300)
committernds <nds@opencascade.com>
Tue, 26 Apr 2016 15:17:45 +0000 (18:17 +0300)
src/SketchPlugin/SketchPlugin_Arc.cpp
src/SketchPlugin/SketchPlugin_Line.cpp
src/SketchPlugin/SketchPlugin_Sketch.cpp

index d8803e90a278db8d2beed4363b52964a2537b9be..18380c7ec0c5975a7ab859427132475a529a7742 100644 (file)
@@ -353,7 +353,7 @@ static inline void calculateArcAngleRadius(
   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,
@@ -362,7 +362,7 @@ static inline void calculatePassedPoint(
 {
   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())));
@@ -381,6 +381,7 @@ static inline void calculatePassedPoint(
   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()
@@ -403,9 +404,9 @@ 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*>())
index 33d087d2c6d5aff70cd11cd44c739062cd2ecff3..c69b6019b66178402ed5428caee05798617e002a 100644 (file)
@@ -110,7 +110,9 @@ bool SketchPlugin_Line::isFixed() {
 
 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()) {
index 053957cc5e9a3fb5245c95e7f51c47a2154e7b5d..ac94b5dd1f174e2bf436f2a1a7793b3c0ec70979 100755 (executable)
@@ -290,7 +290,9 @@ FeaturePtr SketchPlugin_Sketch::addUniqueNamedCopiedFeature(FeaturePtr theFeatur
   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);