Salome HOME
Take into account context of selection for sketch features if the selected shape...
authorazv <azv@opencascade.com>
Tue, 23 Aug 2016 08:12:36 +0000 (11:12 +0300)
committerazv <azv@opencascade.com>
Tue, 23 Aug 2016 08:13:05 +0000 (11:13 +0300)
src/SketchAPI/SketchAPI_Arc.cpp
src/SketchAPI/SketchAPI_Circle.cpp
src/SketchAPI/SketchAPI_Line.cpp
src/SketchAPI/SketchAPI_Point.cpp
src/SketchPlugin/SketchPlugin_Arc.cpp
src/SketchPlugin/SketchPlugin_Circle.cpp
src/SketchPlugin/SketchPlugin_Line.cpp
src/SketchPlugin/SketchPlugin_Point.cpp
src/SketchPlugin/SketchPlugin_Sketch.cpp

index ba8e4cb8b10cb473f447f5a9ee77e560612d2579..628e43238efb0e887ea83ca98c464b6e22934870 100644 (file)
@@ -244,7 +244,7 @@ void SketchAPI_Arc::dump(ModelHighAPI_Dumper& theDumper) const
   const std::string& aSketchName = theDumper.parentName(aBase);
 
   AttributeSelectionPtr anExternal = aBase->selection(SketchPlugin_SketchEntity::EXTERNAL_ID());
-  if (anExternal->value()) {
+  if (anExternal->context()) {
     // arc is external
     theDumper << aBase << " = " << aSketchName << ".addArc(" << anExternal << ")" << std::endl;
   } else {
index 8403b5896bce6a5dcf8ca51dc17dc6c36ffd2a0a..9cac0bd31cbf58bee789d7d87dd9fe9d78f92ba7 100644 (file)
@@ -247,7 +247,7 @@ void SketchAPI_Circle::dump(ModelHighAPI_Dumper& theDumper) const
   const std::string& aSketchName = theDumper.parentName(aBase);
 
   AttributeSelectionPtr anExternal = aBase->selection(SketchPlugin_SketchEntity::EXTERNAL_ID());
-  if (anExternal->value()) {
+  if (anExternal->context()) {
     // circle is external
     theDumper << aBase << " = " << aSketchName << ".addCircle(" << anExternal << ")" << std::endl;
   } else {
index e06448ecdc1daa5a61c7bdce2119e03f05a44af1..1e5a2da04fc01a250631b6940ea62338ae6df9c1 100644 (file)
@@ -137,7 +137,7 @@ void SketchAPI_Line::dump(ModelHighAPI_Dumper& theDumper) const
   const std::string& aSketchName = theDumper.parentName(aBase);
 
   AttributeSelectionPtr anExternal = aBase->selection(SketchPlugin_SketchEntity::EXTERNAL_ID());
-  if (anExternal->value()) {
+  if (anExternal->context()) {
     // line is external
     theDumper << aBase << " = " << aSketchName << ".addLine(" << anExternal << ")" << std::endl;
   } else {
index 4e44f259c2a70200cba00f40efaa09eb34b1ce11..346ae4442983e89735d5f97afc67f2aa128e8232 100644 (file)
@@ -107,7 +107,7 @@ void SketchAPI_Point::dump(ModelHighAPI_Dumper& theDumper) const
   const std::string& aSketchName = theDumper.parentName(aBase);
 
   AttributeSelectionPtr anExternal = aBase->selection(SketchPlugin_SketchEntity::EXTERNAL_ID());
-  if (anExternal->value()) {
+  if (anExternal->context()) {
     // point is external
     theDumper << aBase << " = " << aSketchName << ".addPoint(" << anExternal << ")" << std::endl;
   } else {
index 9873f01afcdf4bffb1a6f3126886a80a0f0536d8..ab27bbbe8e6e7dd98f50a45f761603efefc98a6b 100644 (file)
@@ -338,6 +338,12 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID)
   // the second condition for unability to move external segments anywhere
   if (theID == EXTERNAL_ID() || isFixed()) {
     std::shared_ptr<GeomAPI_Shape> aSelection = data()->selection(EXTERNAL_ID())->value();
+    if (!aSelection) {
+      // empty shape in selection shows that the shape is equal to context
+      ResultPtr anExtRes = selection(EXTERNAL_ID())->context();
+      if (anExtRes)
+        aSelection = anExtRes->shape();
+    }
     // update arguments due to the selection value
     if (aSelection && !aSelection->isNull() && aSelection->isEdge()) {
       std::shared_ptr<GeomAPI_Edge> anEdge( new GeomAPI_Edge(aSelection));
index ccb1a6efe0ba58991c853535229a022c4d67b408..babdd6f14e01dcff3da73c1b76c1f4f01ac1a09f 100644 (file)
@@ -189,6 +189,12 @@ void SketchPlugin_Circle::attributeChanged(const std::string& theID) {
   // the second condition for unability to move external segments anywhere
   if (theID == EXTERNAL_ID() || isFixed()) {
     std::shared_ptr<GeomAPI_Shape> aSelection = data()->selection(EXTERNAL_ID())->value();
+    if (!aSelection) {
+      // empty shape in selection shows that the shape is equal to context
+      ResultPtr anExtRes = selection(EXTERNAL_ID())->context();
+      if (anExtRes)
+        aSelection = anExtRes->shape();
+    }
     // update arguments due to the selection value
     if (aSelection && !aSelection->isNull() && aSelection->isEdge()) {
       std::shared_ptr<GeomAPI_Edge> anEdge( new GeomAPI_Edge(aSelection));
index 2d2c6bc4a9880955de3c1f030c2b2d6cf231ed38..782f99a2472346eed9e2e785846da018e28853ca 100644 (file)
@@ -123,7 +123,13 @@ void SketchPlugin_Line::attributeChanged(const std::string& theID) {
   // 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) {
+      // empty shape in selection shows that the shape is equal to context
+      ResultPtr anExtRes = selection(EXTERNAL_ID())->context();
+      if (anExtRes)
+        aSelection = anExtRes->shape();
+    }
+    // update arguments due to the selection value
     if (aSelection && !aSelection->isNull() && aSelection->isEdge()) {
       std::shared_ptr<GeomAPI_Edge> anEdge( new GeomAPI_Edge(aSelection));
       std::shared_ptr<GeomDataAPI_Point2D> aStartAttr = 
index afa84bf135efa5993c0762f1e1e3662640abf25c..4ee1f89845f46d680a5af1af57728b6f6d549557 100644 (file)
@@ -69,7 +69,13 @@ void SketchPlugin_Point::attributeChanged(const std::string& theID) {
   // the second condition for unability to move external point anywhere
   if (theID == EXTERNAL_ID() || isFixed()) {
     std::shared_ptr<GeomAPI_Shape> aSelection = data()->selection(EXTERNAL_ID())->value();
-     // update arguments due to the selection value
+    if (!aSelection) {
+      // empty shape in selection shows that the shape is equal to context
+      ResultPtr anExtRes = selection(EXTERNAL_ID())->context();
+      if (anExtRes)
+        aSelection = anExtRes->shape();
+    }
+    // update arguments due to the selection value
     if (aSelection && !aSelection->isNull() && aSelection->isVertex()) {
       std::shared_ptr<GeomAPI_Vertex> aVertex(new GeomAPI_Vertex(aSelection));
       std::shared_ptr<GeomDataAPI_Point2D> aCoordAttr = 
index ef2ef9c691327934c4f4cf171008ffb5fd1b3842..189c0c3dff15b92249a14394bd8df98d1a36496f 100755 (executable)
@@ -91,7 +91,7 @@ void SketchPlugin_Sketch::execute()
         aFeature->setSketch(this);
       // do not include the external edges into the result
       if (aFeature->data()->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())) {
-        if (aFeature->data()->selection(SketchPlugin_SketchEntity::EXTERNAL_ID())->value())
+        if (aFeature->data()->selection(SketchPlugin_SketchEntity::EXTERNAL_ID())->context())
           continue;
       }
       // do not include the construction entities in the result