]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix colors of highlighting of symbol constraints
authorvsv <vsv@opencascade.com>
Thu, 27 Apr 2017 15:31:42 +0000 (18:31 +0300)
committervsv <vsv@opencascade.com>
Thu, 27 Apr 2017 15:32:15 +0000 (18:32 +0300)
12 files changed:
src/SketcherPrs/SketcherPrs_Collinear.cpp
src/SketcherPrs/SketcherPrs_Equal.cpp
src/SketcherPrs/SketcherPrs_HVDirection.cpp
src/SketcherPrs/SketcherPrs_Middle.cpp
src/SketcherPrs/SketcherPrs_Mirror.cpp
src/SketcherPrs/SketcherPrs_Parallel.cpp
src/SketcherPrs/SketcherPrs_Perpendicular.cpp
src/SketcherPrs/SketcherPrs_Rigid.cpp
src/SketcherPrs/SketcherPrs_SymbolPrs.cpp
src/SketcherPrs/SketcherPrs_SymbolPrs.h
src/SketcherPrs/SketcherPrs_Tangent.cpp
src/SketcherPrs/SketcherPrs_Transformation.cpp

index ac28d6436ef90ef1ecd9648a0b786972775466d5..336ece32127e4c74ac0be80c2d20801201f54d04 100755 (executable)
@@ -63,7 +63,7 @@ bool SketcherPrs_Collinear::updateIfReadyToDisplay(double theStep, bool withColo
 void SketcherPrs_Collinear::drawLines(const Handle(Prs3d_Presentation)& thePrs,
                                       Quantity_Color theColor) const
 {
-  Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
+  Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePrs);
 
   Handle(Graphic3d_AspectLine3d) aLineAspect =
     new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
index fde1496877a21b9e4cdde21ec53dedb28510e3e0..9141b161f809e77327fffe28fb7d374b6be26b7c 100644 (file)
@@ -64,24 +64,18 @@ bool SketcherPrs_Equal::updateIfReadyToDisplay(double theStep, bool withColor) c
 void SketcherPrs_Equal::drawLines(const Handle(Prs3d_Presentation)& thePrs,
                                   Quantity_Color theColor) const
 {
-  Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
-
-  Handle(Graphic3d_AspectLine3d) aLineAspect =
-    new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
-  aGroup->SetPrimitivesAspect(aLineAspect);
-
   // Draw first line
   ObjectPtr aObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
   std::shared_ptr<GeomAPI_Shape> aLine = SketcherPrs_Tools::getShape(aObj);
   if (aLine.get() == NULL)
     return;
-  drawShape(aLine, thePrs);
+  drawShape(aLine, thePrs, theColor);
 
   // Draw second line
   aObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B());
   aLine = SketcherPrs_Tools::getShape(aObj);
   if (aLine.get() == NULL)
     return;
-  drawShape(aLine, thePrs);
+  drawShape(aLine, thePrs, theColor);
 }
 
index 552da1a6c63bc7c1d20af471218b5df4033ebbd8..6c2ea1e4934cb3f8c7312d98d65600e906ad1d24 100644 (file)
@@ -53,7 +53,7 @@ bool SketcherPrs_HVDirection::updateIfReadyToDisplay(double theStep, bool withCo
 void SketcherPrs_HVDirection::drawLines(const Handle(Prs3d_Presentation)& thePrs,
                                         Quantity_Color theColor) const
 {
-  Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
+  Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePrs);
 
   // Draw constrained object
   Handle(Graphic3d_AspectLine3d) aLineAspect =
index df7590a1c37e377752ab42cedbdca0f1cce5ebf5..c072e1f8231e0b5a06fd7bcadf6bc072289f95e2 100755 (executable)
@@ -80,7 +80,7 @@ bool SketcherPrs_Middle::updateIfReadyToDisplay(double theStep, bool withColor)
 void SketcherPrs_Middle::drawLines(const Handle(Prs3d_Presentation)& thePrs,
                                    Quantity_Color theColor) const
 {
-  Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
+  Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePrs);
 
   Handle(Graphic3d_AspectLine3d) aLineAspect =
     new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
@@ -105,13 +105,13 @@ void SketcherPrs_Middle::drawLine(const Handle(Prs3d_Presentation)& thePrs,
       ResultPtr aResult = aResults.front();
       std::shared_ptr<GeomAPI_Shape> aLine = SketcherPrs_Tools::getShape(aResult);
       if (aLine.get() != NULL)
-        drawShape(aLine, thePrs);
+        drawShape(aLine, thePrs, theColor);
     }
   }
   else {
     std::shared_ptr<GeomAPI_Shape> aLine = SketcherPrs_Tools::getShape(theObject);
     if (aLine.get() != NULL)
-      drawShape(aLine, thePrs);
+      drawShape(aLine, thePrs, theColor);
   }
 }
 
index e78dc668e7762624396a25f19ce83f943bf4f1a8..55215e5aba03e288d3aef828d20644e4249ddc87 100644 (file)
@@ -120,7 +120,7 @@ void SketcherPrs_Mirror::drawLines(const Handle(Prs3d_Presentation)& thePrs,
   if (aNb != anAttrC->size())
     return;
 
-  Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
+  Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePrs);
 
   // drawListOfShapes uses myDrawer for attributes definition
   Handle(Prs3d_LineAspect) aLnAspect = new Prs3d_LineAspect(theColor, Aspect_TOL_SOLID, 1);
@@ -130,9 +130,9 @@ void SketcherPrs_Mirror::drawLines(const Handle(Prs3d_Presentation)& thePrs,
   addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
 
   // Draw source objects
-  drawListOfShapes(anAttrB, thePrs);
+  drawListOfShapes(anAttrB, thePrs, theColor);
 
   // draw mirrored objects
-  drawListOfShapes(anAttrC, thePrs);
+  drawListOfShapes(anAttrC, thePrs, theColor);
 }
 
index 770df4e2a7f54d8422dee9c893594995c2ac2625..76879ab3c0acc136f905fb58c4de3fd05bee378e 100644 (file)
@@ -64,7 +64,7 @@ bool SketcherPrs_Parallel::updateIfReadyToDisplay(double theStep, bool withColor
 void SketcherPrs_Parallel::drawLines(const Handle(Prs3d_Presentation)& thePrs,
   Quantity_Color theColor) const
 {
-  Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
+  Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePrs);
 
   Handle(Graphic3d_AspectLine3d) aLineAspect =
     new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
index 54d263498796490e505be32fc3da848f28c60c83..8903ce1c7409594090ea73ab129a333fc0c20fdf 100644 (file)
@@ -64,7 +64,7 @@ bool SketcherPrs_Perpendicular::updateIfReadyToDisplay(double theStep, bool with
 void SketcherPrs_Perpendicular::drawLines(const Handle(Prs3d_Presentation)& thePrs,
                                           Quantity_Color theColor) const
 {
-  Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
+  Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePrs);
 
   Handle(Graphic3d_AspectLine3d) aLineAspect =
     new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
index 8b0ccb425fa0ed3ceab85c80a590278be7c55e97..ba4e53f191968afcad069a867180d8c5c17716d0 100644 (file)
@@ -116,13 +116,8 @@ void SketcherPrs_Rigid::drawLines(const Handle(Prs3d_Presentation)& thePrs,
   if (aShape.get() == NULL)
     return;
 
-  Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
-  Handle(Graphic3d_AspectLine3d) aLineAspect =
-    new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
-  aGroup->SetPrimitivesAspect(aLineAspect);
-
   Handle(Prs3d_PointAspect) aPntAspect = new Prs3d_PointAspect(Aspect_TOM_PLUS, theColor, 1);
   myDrawer->SetPointAspect(aPntAspect);
-  drawShape(aShape, thePrs);
+  drawShape(aShape, thePrs, theColor);
 }
 
index 2dfcc68f31301bfdc554c0ffa75ec82388715767..195547813051ee8d14c72f79378c289924f763fa 100644 (file)
@@ -28,6 +28,7 @@
 #include <StdPrs_DeflectionCurve.hxx>
 #include <StdPrs_Point.hxx>
 #include <StdPrs_Curve.hxx>
+#include <Prs3d_LineAspect.hxx>
 
 #include <OpenGl_Element.hxx>
 #include <OpenGl_GraphicDriver.hxx>
@@ -194,7 +195,6 @@ void SketcherPrs_SymbolPrs::addLine(const Handle(Graphic3d_Group)& theGroup,
 void SketcherPrs_SymbolPrs::HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM,
                                             const SelectMgr_SequenceOfOwner& theOwners)
 {
-
   Handle( Prs3d_Presentation ) aSelectionPrs = GetSelectPresentation( thePM );
   aSelectionPrs->Clear();
   drawLines(aSelectionPrs, GetContext()->SelectionStyle()->Color());
@@ -310,8 +310,17 @@ void SketcherPrs_SymbolPrs::SetCustomColor(const std::vector<int>& theColor)
 
 //*********************************************************************************
 void SketcherPrs_SymbolPrs::drawShape(const std::shared_ptr<GeomAPI_Shape>& theShape,
-                                      const Handle(Prs3d_Presentation)& thePrs) const
+                                      const Handle(Prs3d_Presentation)& thePrs,
+                                      Quantity_Color theColor) const
 {
+  Handle(Graphic3d_AspectLine3d) aLineAspect =
+    new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
+
+  Handle(Prs3d_LineAspect) aLinesStyle = myDrawer->LineAspect();
+  Handle(Graphic3d_AspectLine3d) aOldStyle = aLinesStyle->Aspect();
+  aLinesStyle->SetAspect(aLineAspect);
+  myDrawer->SetLineAspect(aLinesStyle);
+
   if (theShape->isEdge()) {
     // The shape is edge
     std::shared_ptr<GeomAPI_Curve> aCurve =
@@ -335,12 +344,15 @@ void SketcherPrs_SymbolPrs::drawShape(const std::shared_ptr<GeomAPI_Shape>& theS
     Handle(Geom_CartesianPoint) aPoint = new Geom_CartesianPoint(aPnt->impl<gp_Pnt>());
     StdPrs_Point::Add(thePrs, aPoint, myDrawer);
   }
+
+  aLinesStyle->SetAspect(aOldStyle);
+  myDrawer->SetLineAspect(aLinesStyle);
 }
 
 //*********************************************************************************
 void SketcherPrs_SymbolPrs::drawListOfShapes(
                       const std::shared_ptr<ModelAPI_AttributeRefList>& theListAttr,
-                      const Handle(Prs3d_Presentation)& thePrs) const
+                      const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const
 {
   int aNb = theListAttr->size();
   if (aNb == 0)
@@ -351,7 +363,7 @@ void SketcherPrs_SymbolPrs::drawListOfShapes(
     aObj = theListAttr->object(i);
     std::shared_ptr<GeomAPI_Shape> aShape = SketcherPrs_Tools::getShape(aObj);
     if (aShape.get() != NULL)
-      drawShape(aShape, thePrs);
+      drawShape(aShape, thePrs, theColor);
   }
 }
 
index c672b4ea7a3e3a67a7484f3d5badb3aefface604..83eba27eadd17421656a71c8873c4b6cbd7b50ed 100644 (file)
@@ -117,13 +117,13 @@ protected:
   /// \param theShape the shape to draw
   /// \param thePrs the presentation scene
   void drawShape(const std::shared_ptr<GeomAPI_Shape>& theShape,
-    const Handle(Prs3d_Presentation)& thePrs) const;
+    const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const;
 
   /// Draw a list of shapes stored in a RefListAttribute
   /// \param theListAttr the attribute of reference3s list
   /// \param thePrs the presentation scene
   void drawListOfShapes(const std::shared_ptr<ModelAPI_AttributeRefList>& theListAttr,
-                        const Handle(Prs3d_Presentation)& thePrs) const;
+                        const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const;
 
 protected:
   /// Constraint feature
index 7704d95cffa51766b87b7326797ded96457b92a4..403fffee029f08b24eb2affb0a8c3af081b36ebb 100644 (file)
@@ -67,12 +67,6 @@ bool SketcherPrs_Tangent::updateIfReadyToDisplay(double theStep, bool withColor)
 void SketcherPrs_Tangent::drawLines(const Handle(Prs3d_Presentation)& thePrs,
                                     Quantity_Color theColor) const
 {
-  Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
-
-  Handle(Graphic3d_AspectLine3d) aLineAspect =
-    new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
-  aGroup->SetPrimitivesAspect(aLineAspect);
-
   ObjectPtr aObj1 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
   ObjectPtr aObj2 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B());
 
@@ -81,7 +75,7 @@ void SketcherPrs_Tangent::drawLines(const Handle(Prs3d_Presentation)& thePrs,
 
   if ((aShape1.get() == NULL) || (aShape2.get() == NULL))
     return;
-  drawShape(aShape1, thePrs);
-  drawShape(aShape2, thePrs);
+  drawShape(aShape1, thePrs, theColor);
+  drawShape(aShape2, thePrs, theColor);
 }
 
index 9d6061e2618716ae575a26353fe8597cd4945736..3ea06f9fa36ed377720c5c596a0f838ec954bc73 100644 (file)
@@ -117,13 +117,11 @@ void SketcherPrs_Transformation::drawLines(const Handle(Prs3d_Presentation)& the
   if (anAttrB.get() == NULL)
     return;
 
-  Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
-
   // drawListOfShapes uses myDrawer for attributes definition
-  Handle(Prs3d_LineAspect) aLnAspect = new Prs3d_LineAspect(theColor, Aspect_TOL_SOLID, 1);
-  myDrawer->SetLineAspect(aLnAspect);
+  //Handle(Prs3d_LineAspect) aLnAspect = new Prs3d_LineAspect(theColor, Aspect_TOL_SOLID, 1);
+  //myDrawer->SetLineAspect(aLnAspect);
 
-  drawListOfShapes(anAttrB, thePrs);
+  drawListOfShapes(anAttrB, thePrs, theColor);
   if (myConstraint->getKind() == SketchPlugin_MultiTranslation::ID()) {
     // If it is translation
     AttributePoint2DPtr aStart = GeomDataAPI_Point2D::getPoint2D(aData,