]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2027 Sketcher Trim Feature: clear PreviewObject reference as it is not necessa...
authornds <nds@opencascade.com>
Wed, 29 Mar 2017 08:28:56 +0000 (11:28 +0300)
committernds <nds@opencascade.com>
Wed, 29 Mar 2017 08:29:14 +0000 (11:29 +0300)
src/SketchPlugin/SketchPlugin_Trim.cpp
src/SketcherPrs/SketcherPrs_SymbolPrs.cpp
src/SketcherPrs/SketcherPrs_SymbolPrs.h

index eb8f27c901cdcf5408be6b3abcfc331e05f9a54f..46b01dee111b80214a810185788aa4d61d2be937 100644 (file)
@@ -194,6 +194,13 @@ void SketchPlugin_Trim::execute()
     return;
   FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value());
 
+  /// Remove reference of this feature to feature used in preview, it is not necessary anymore
+  /// as trim will be removed after execute
+  AttributeReferencePtr aPreviewObjectAttr =
+                     std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
+                     data()->attribute(SketchPlugin_Trim::PREVIEW_OBJECT()));
+  aPreviewObjectAttr->setValue(ResultPtr());
+
   /// points of trim
   std::shared_ptr<GeomAPI_Pnt> aStartShapePoint, aLastShapePoint;
 #ifdef DEBUG_TRIM
@@ -272,12 +279,6 @@ void SketchPlugin_Trim::execute()
     // otherwise Trim feature will be removed with the circle before
     // this operation is finished
     aBaseObjectAttr->setObject(ResultPtr());
-
-    AttributeReferencePtr aPreviewObjectAttr =
-                     std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
-                     data()->attribute(SketchPlugin_Trim::PREVIEW_OBJECT()));
-    aPreviewObjectAttr->setObject(ResultPtr());
-
   }
   else if (aKind == SketchPlugin_Line::ID()) {
     trimLine(aStartShapePoint2d, aLastShapePoint2d, aBaseRefAttributes,
@@ -378,6 +379,17 @@ void SketchPlugin_Trim::execute()
     Events_Loop::loop()->setFlushed(anUpdateEvent, false);
 
   // delete constraints
+#ifdef DEBUG_TRIM
+  if (aFeaturesToDelete.size() > 0) {
+    std::cout << "after SPlit: removeFeaturesAndReferences: " << std::endl;
+    std::string aValue;
+    for (std::set<FeaturePtr>::const_iterator anIt = aFeaturesToDelete.begin();
+         anIt != aFeaturesToDelete.end(); anIt++) {
+      FeaturePtr aFeature = *anIt;
+      std::cout << aFeature->data()->name() << std::endl;
+    }
+  }
+#endif
   ModelAPI_Tools::removeFeaturesAndReferences(aFeaturesToDelete);
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
 
@@ -716,7 +728,18 @@ void SketchPlugin_Trim::removeReferencesToAttribute(const AttributePtr& theAttri
     }
   }
 
+#ifdef DEBUG_TRIM
   // delete constraints
+  if (aFeaturesToDelete.size() > 0) {
+    std::cout << "removeReferencesToAttribute: " << std::endl;
+    std::string aValue;
+    for (std::set<FeaturePtr>::const_iterator anIt = aFeaturesToDelete.begin();
+         anIt != aFeaturesToDelete.end(); anIt++) {
+      FeaturePtr aFeature = *anIt;
+      std::cout << aFeature->data()->name() << std::endl;
+    }
+  }
+#endif
   ModelAPI_Tools::removeFeaturesAndReferences(aFeaturesToDelete);
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
 }
index 1e7d5f6a8e5f89ab21668bdad43e081391283b85..48a0256e2195d07d4520ad277c0f5849407c711e 100644 (file)
@@ -165,6 +165,8 @@ void SketcherPrs_SymbolPrs::prepareAspect()
       myAspect = new Graphic3d_AspectMarker3d();
     else
       myAspect = new Graphic3d_AspectMarker3d(aIcon);
+
+    myAspect->SetColor(myColor);
   }
 }
 
@@ -297,16 +299,19 @@ void SketcherPrs_SymbolPrs::SetConflictingConstraint(const bool& theConflicting,
 {
   if (theConflicting)
   {
-    if (!myAspect.IsNull())
-      myAspect->SetColor (Quantity_Color (theColor[0] / 255., theColor[1] / 255.,
-                          theColor[2] / 255., Quantity_TOC_RGB));
-    myIsConflicting = true;
+    myColor = Quantity_Color (theColor[0] / 255., theColor[1] / 255.,
+                              theColor[2] / 255., Quantity_TOC_RGB);
+    //if (!myAspect.IsNull())
+    //  myAspect->SetColor (Quantity_Color (theColor[0] / 255., theColor[1] / 255.,
+    //                      theColor[2] / 255., Quantity_TOC_RGB));
+    //myIsConflicting = true;
   }
   else
   {
-    if (!myAspect.IsNull())
-      myAspect->SetColor (Quantity_Color (1.0, 1.0, 0.0, Quantity_TOC_RGB));
-    myIsConflicting = false;
+    myColor = Quantity_Color (1.0, 1.0, 0.0, Quantity_TOC_RGB);
+    //if (!myAspect.IsNull())
+    //  myAspect->SetColor (Quantity_Color (1.0, 1.0, 0.0, Quantity_TOC_RGB));
+    //myIsConflicting = false;
   }
 }
 
index affd9d07409356c4e9d7ede33b96d7675ca13878..4c852d5a4ec94816806f81fba34dcb81fe041efc 100644 (file)
@@ -149,6 +149,7 @@ private:
 
   Select3D_EntitySequence mySPoints;
 
+  Quantity_Color myColor;
   bool myIsConflicting; /// state if the presentation is visualized in error state
   Handle(Image_AlienPixMap) myErrorIcon;
   Handle(Graphic3d_MarkerImage) myErrorImage;