]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
#1371 Using auxilliary Sketch elements in any Feature: we need to use setColor instea...
authornds <nds@opencascade.com>
Mon, 28 Mar 2016 09:32:08 +0000 (12:32 +0300)
committernds <nds@opencascade.com>
Mon, 28 Mar 2016 09:32:08 +0000 (12:32 +0300)
src/PartSet/PartSet_ResultSketchPrs.cpp
src/SketchPlugin/SketchPlugin_SketchEntity.h

index f0db6da461c1ce429b9462e372b856a8bc7d799b..ec87b9dc4aa25a307b2d6e29692d5327976896ea 100755 (executable)
@@ -71,7 +71,6 @@ bool PartSet_ResultSketchPrs::isValidShapeType(const TopAbs_ShapeEnum& theBaseTy
   return aValid;
 }
 
-
 void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
                                    const Handle(Prs3d_Presentation)& thePresentation, 
                                    const Standard_Integer theMode)
@@ -86,15 +85,15 @@ void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d)
 
   {
     std::vector<int> aColor;
-    aColor = Config_PropManager::color("Visualization", "result_body_color",
-                                       ("200,200,230"));
-    Standard_Real anAuxiliaryWidth = 3.;
-    Standard_Integer anAuxiliaryLineStyle = 0;
+    aColor = Config_PropManager::color("Visualization", "result_construction_color",
+                                       ModelAPI_ResultConstruction::DEFAULT_COLOR());
+    Standard_Real anAuxiliaryWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH();
+    Standard_Integer anAuxiliaryLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE();
 
-    SetColor(Quantity_Color(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255., Quantity_TOC_RGB));
+    Handle(Prs3d_Drawer) aDrawer = Attributes();
+    setColor(aDrawer, Quantity_Color(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255., Quantity_TOC_RGB));
 
     //thePresentation->Clear();
-    Handle(Prs3d_Drawer) aDrawer = Attributes();
     setWidth(aDrawer, anAuxiliaryWidth);
     // set line style
     Handle(Prs3d_LineAspect) aLineAspect;
@@ -144,6 +143,7 @@ void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d)
   CompositeFeaturePtr aSketchFeature = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>
                                                                           (aResultFeature);
   std::list<ResultPtr> anAuxiliaryResults;
+  /// append auxiliary shapes
   for (int i = 0; i < aSketchFeature->numberOfSubs(); i++) {
     FeaturePtr aFeature = aSketchFeature->subFeature(i);
     if (PartSet_Tools::isAuxiliarySketchEntity(aFeature)) {
@@ -155,7 +155,25 @@ void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d)
           anAuxiliaryResults.push_back(aResult);
       }
     }
+    else {
+    /// append not-edges shapes, e.g. center of a circle, an arc, a point feature
+      const std::list<std::shared_ptr<ModelAPI_Result> >& aRes = aFeature->results();
+      std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aResIter = aRes.cbegin();
+      for (; aResIter != aRes.cend(); aResIter++) {
+        std::shared_ptr<ModelAPI_ResultConstruction> aConstr = std::dynamic_pointer_cast<
+            ModelAPI_ResultConstruction>(*aResIter);
+        if (aConstr) {
+          std::shared_ptr<GeomAPI_Shape> aGeomShape = aConstr->shape();
+          if (aGeomShape.get()) {
+            const TopoDS_Shape& aShape = aGeomShape->impl<TopoDS_Shape>();
+            if (aShape.ShapeType() != TopAbs_EDGE)
+              anAuxiliaryResults.push_back(aConstr);
+          }
+        }
+      }
+    }
   }
+
   if (anAuxiliaryResults.size() > 0) {
     Quantity_Color aPrevColor;
     Color(aPrevColor);
@@ -164,13 +182,13 @@ void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d)
     std::vector<int> aColor;
     aColor = Config_PropManager::color("Visualization", "sketch_auxiliary_color",
                                          SKETCH_AUXILIARY_COLOR);
-    Standard_Real anAuxiliaryWidth = 1.;
-    Standard_Integer anAuxiliaryLineStyle = 3;
+    Standard_Real anAuxiliaryWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH_AUXILIARY();
+    Standard_Integer anAuxiliaryLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE_AUXILIARY();
 
-    SetColor(Quantity_Color(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255., Quantity_TOC_RGB));
+    Handle(Prs3d_Drawer) aDrawer = Attributes();
+    setColor(aDrawer, Quantity_Color(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255., Quantity_TOC_RGB));
 
     //thePresentation->Clear();
-    Handle(Prs3d_Drawer) aDrawer = Attributes();
     setWidth(aDrawer, anAuxiliaryWidth);
     // set line style
     Handle(Prs3d_LineAspect) aLineAspect;
index 20f1e46f732205e98545e914308135dc613ef898..864b25b41efe6b8bc812b28bb737f420fea215ac 100644 (file)
@@ -54,6 +54,30 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC
     return MY_COPY_ID;
   }
 
+  /// Width of the auxiliary line
+  inline static const double SKETCH_LINE_WIDTH_AUXILIARY()
+  {
+    return 1;
+  }
+
+  /// Width of the line
+  inline static const double SKETCH_LINE_WIDTH()
+  {
+    return 3;
+  }
+
+  /// Style of the auxiliary line
+  inline static const int SKETCH_LINE_STYLE_AUXILIARY()
+  {
+    return  3;
+  }
+
+  /// Style of the line
+  inline static const int SKETCH_LINE_STYLE()
+  {
+    return  0;
+  }
+
   /// Request for initialization of data model of the feature: adding all attributes
   virtual void initAttributes();
 
@@ -108,12 +132,12 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC
 
     if (aShapeType == 6 || aShapeType == 0) { // if this is an edge or a compound
       if (isConstruction) {
-        isCustomized = thePrs->setWidth(1) || isCustomized;
-        isCustomized = thePrs->setLineStyle(3) || isCustomized;
+        isCustomized = thePrs->setWidth(SKETCH_LINE_WIDTH_AUXILIARY()) || isCustomized;
+        isCustomized = thePrs->setLineStyle(SKETCH_LINE_STYLE_AUXILIARY()) || isCustomized;
       }
       else {
-        isCustomized = thePrs->setWidth(3) || isCustomized;
-        isCustomized = thePrs->setLineStyle(0) || isCustomized;
+        isCustomized = thePrs->setWidth(SKETCH_LINE_WIDTH()) || isCustomized;
+        isCustomized = thePrs->setLineStyle(SKETCH_LINE_STYLE()) || isCustomized;
       }
     }
     else if (aShapeType == 7) { // otherwise this is a vertex