]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
#1371 Using auxilliary Sketch elements in any Feature: code improvement to separate...
authornds <nds@opencascade.com>
Mon, 28 Mar 2016 09:43:21 +0000 (12:43 +0300)
committerdbv <dbv@opencascade.com>
Wed, 6 Apr 2016 10:25:14 +0000 (13:25 +0300)
src/PartSet/PartSet_ResultSketchPrs.cpp
src/PartSet/PartSet_ResultSketchPrs.h

index ec87b9dc4aa25a307b2d6e29692d5327976896ea..64ba7b087ad8d27f8c9976c907fdeaaa77100388 100755 (executable)
@@ -83,38 +83,7 @@ void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d)
     return;
   }
 
-  {
-    std::vector<int> aColor;
-    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();
-
-    Handle(Prs3d_Drawer) aDrawer = Attributes();
-    setColor(aDrawer, Quantity_Color(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255., Quantity_TOC_RGB));
-
-    //thePresentation->Clear();
-    setWidth(aDrawer, anAuxiliaryWidth);
-    // set line style
-    Handle(Prs3d_LineAspect) aLineAspect;
-
-    Aspect_TypeOfLine aType = (Aspect_TypeOfLine)anAuxiliaryLineStyle;
-    if (aDrawer->HasOwnLineAspect()) {
-      aLineAspect = aDrawer->LineAspect();
-    }
-    if (aDrawer->HasOwnWireAspect()) {
-      aLineAspect = aDrawer->WireAspect();
-    }
-    Quantity_Color aCurrentColor;
-    Aspect_TypeOfLine aPrevLineType;
-    Standard_Real aCurrentWidth;
-    aLineAspect->Aspect()->Values(aCurrentColor, aPrevLineType, aCurrentWidth);
-    bool isChangedLineType = aType != aPrevLineType;
-    if (isChangedLineType) {
-      aLineAspect->SetTypeOfLine(aType);
-    }
-    // end of set line style
-  }
+  setAuxiliaryPresentationStyle(false);
 
   myFacesList.clear();
   ResultConstructionPtr aConstruction = 
@@ -125,7 +94,6 @@ void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d)
       myFacesList.push_back(aConstruction->face(aFaceIndex));
     }
   }
-
   myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
   if (!myOriginalShape.IsNull()) {
     Set(myOriginalShape);
@@ -137,8 +105,7 @@ void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d)
   else
     Events_Error::throwException("An empty AIS presentation: PartSet_ResultSketchPrs");
 
-
-  // create auxiliary shapes
+  // visualize auxiliary shapes and sketch construction elements(point, center of a circle)
   FeaturePtr aResultFeature = ModelAPI_Feature::feature(myResult);
   CompositeFeaturePtr aSketchFeature = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>
                                                                           (aResultFeature);
@@ -175,45 +142,11 @@ void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d)
   }
 
   if (anAuxiliaryResults.size() > 0) {
-    Quantity_Color aPrevColor;
-    Color(aPrevColor);
-    Standard_Real aPrevWidth = Width();
-
-    std::vector<int> aColor;
-    aColor = Config_PropManager::color("Visualization", "sketch_auxiliary_color",
-                                         SKETCH_AUXILIARY_COLOR);
-    Standard_Real anAuxiliaryWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH_AUXILIARY();
-    Standard_Integer anAuxiliaryLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE_AUXILIARY();
-
-    Handle(Prs3d_Drawer) aDrawer = Attributes();
-    setColor(aDrawer, Quantity_Color(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255., Quantity_TOC_RGB));
-
-    //thePresentation->Clear();
-    setWidth(aDrawer, anAuxiliaryWidth);
-    // set line style
-    Handle(Prs3d_LineAspect) aLineAspect;
-
-    Aspect_TypeOfLine aType = (Aspect_TypeOfLine)anAuxiliaryLineStyle;
-    if (aDrawer->HasOwnLineAspect()) {
-      aLineAspect = aDrawer->LineAspect();
-    }
-    if (aDrawer->HasOwnWireAspect()) {
-      aLineAspect = aDrawer->WireAspect();
-    }
-    Quantity_Color aCurrentColor;
-    Aspect_TypeOfLine aPrevLineType;
-    Standard_Real aCurrentWidth;
-    aLineAspect->Aspect()->Values(aCurrentColor, aPrevLineType, aCurrentWidth);
-    bool isChangedLineType = aType != aPrevLineType;
-    if (isChangedLineType) {
-      aLineAspect->SetTypeOfLine(aType);
-    }
-    // end of set line style
+    setAuxiliaryPresentationStyle(true);
 
     BRep_Builder aBuilder;
     TopoDS_Compound aComp;
     aBuilder.MakeCompound(aComp);
-
     std::list<ResultPtr>::const_iterator anIt = anAuxiliaryResults.begin(),
                                          aLast = anAuxiliaryResults.end();
     for (; anIt != aLast; anIt++) {
@@ -228,14 +161,8 @@ void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d)
       }
     }
     myAuxiliaryCompound = aComp;
+    Handle(Prs3d_Drawer) aDrawer = Attributes();
     StdPrs_WFDeflectionShape::Add(thePresentation, aComp, aDrawer);
-
-    // restore presentation properties
-    //SetColor(aPrevColor);
-    //setWidth(aDrawer, aPrevWidth);
-    //if (isChangedLineType) {
-    //  aLineAspect->SetTypeOfLine(aPrevLineType);
-    //}
   }
 }
 
@@ -320,3 +247,47 @@ void PartSet_ResultSketchPrs::appendShapeSelection(const Handle(SelectMgr_Select
   } catch ( Standard_Failure ) {
   }
 }
+
+void PartSet_ResultSketchPrs::setAuxiliaryPresentationStyle(const bool isAuxiliary)
+{
+  std::vector<int> aColor;
+  Standard_Real aWidth;
+  Standard_Integer aLineStyle;
+  if (!isAuxiliary) {
+    aColor = Config_PropManager::color("Visualization", "result_construction_color",
+                                        ModelAPI_ResultConstruction::DEFAULT_COLOR());
+    aWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH();
+    aLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE();
+  }
+  else {
+    aColor = Config_PropManager::color("Visualization", "sketch_auxiliary_color",
+                                         SKETCH_AUXILIARY_COLOR);
+    aWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH_AUXILIARY();
+    aLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE_AUXILIARY();
+  }
+
+  Handle(Prs3d_Drawer) aDrawer = Attributes();
+  setColor(aDrawer, Quantity_Color(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255.,
+           Quantity_TOC_RGB));
+
+  setWidth(aDrawer, aWidth);
+  // set line style
+  Handle(Prs3d_LineAspect) aLineAspect;
+
+  Aspect_TypeOfLine aType = (Aspect_TypeOfLine)aLineStyle;
+  if (aDrawer->HasOwnLineAspect()) {
+    aLineAspect = aDrawer->LineAspect();
+  }
+  if (aDrawer->HasOwnWireAspect()) {
+    aLineAspect = aDrawer->WireAspect();
+  }
+  Quantity_Color aCurrentColor;
+  Aspect_TypeOfLine aPrevLineType;
+  Standard_Real aCurrentWidth;
+  aLineAspect->Aspect()->Values(aCurrentColor, aPrevLineType, aCurrentWidth);
+  bool isChangedLineType = aType != aPrevLineType;
+  if (isChangedLineType) {
+    aLineAspect->SetTypeOfLine(aType);
+  }
+}
index dc79c7c26b9f77441859e1048801ba026903fcd8..d2861823d8156a9b0e0a33d14c0a6f46ba371be4 100755 (executable)
@@ -53,6 +53,10 @@ private:
   void appendShapeSelection(const Handle(SelectMgr_Selection)& theSelection,
                             const TopoDS_Shape& theShape, const TopAbs_ShapeEnum& theTypeOfSelection);
 
+  /// Sets color/line style/width of the presentation depending on the parameter state
+  /// \param isAuxiliary a boolean value if the properties are for auxiliary objects
+  void setAuxiliaryPresentationStyle(const bool isAuxiliary);
+
   /// Reference to result object
   ResultPtr myResult;