Salome HOME
Issue #2200: Fix for highlighting of points
authorvsv <vsv@opencascade.com>
Fri, 27 Oct 2017 09:30:17 +0000 (12:30 +0300)
committervsv <vsv@opencascade.com>
Fri, 27 Oct 2017 09:30:17 +0000 (12:30 +0300)
src/PartSet/PartSet_CenterPrs.cpp
src/PartSet/PartSet_CenterPrs.h

index 065c7971cae650daa565e2e0bfa78f772cec1d26..cc2ad4b0f090eead63aa3bc8e3837ef7f4bb804c 100644 (file)
 
 #include "PartSet_CenterPrs.h"
 
+#include <ModuleBase_Tools.h>
 #include <Geom_CartesianPoint.hxx>
+#include <Prs3d_PointAspect.hxx>
+#include <Graphic3d_AspectMarker3d.hxx>
+#include <Prs3d_Root.hxx>
+#include <Graphic3d_ArrayOfPoints.hxx>
+#include <AIS_InteractiveContext.hxx>
 
 
 IMPLEMENT_STANDARD_RTTIEXT(PartSet_CenterPrs, AIS_Point)
 
+
 PartSet_CenterPrs::PartSet_CenterPrs(const ObjectPtr& theObject,
                                      const GeomEdgePtr& theEdge,
                                      const gp_Pnt& theCenter,
@@ -38,4 +45,61 @@ PartSet_CenterPrs::PartSet_CenterPrs(const ObjectPtr& theObject,
   myEdge(theEdge),
   myCenterType(theType)
 {
-}
\ No newline at end of file
+  SetAutoHilight(Standard_False);
+}
+
+void PartSet_CenterPrs::drawPoint(const Handle(Prs3d_Presentation)& thePrs,
+                                  Quantity_Color theColor)
+{
+  Handle(Prs3d_Drawer) aDrawer = HilightAttributes();
+
+  Handle(Prs3d_PointAspect) aPntAspect = aDrawer->PointAspect();
+
+  Handle(Graphic3d_AspectMarker3d) PtA = aPntAspect->Aspect();
+  PtA->SetType(Aspect_TOM_RING1);
+  PtA->SetColor(theColor);
+
+  Handle(Geom_Point) aPnt = Component();
+  Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(thePrs);
+  TheGroup->SetPrimitivesAspect(PtA);
+
+  Handle(Graphic3d_ArrayOfPoints) aPoint = new Graphic3d_ArrayOfPoints (1);
+  aPoint->AddVertex(aPnt->X(),aPnt->Y(),aPnt->Z());
+  TheGroup->AddPrimitiveArray(aPoint);
+
+  PtA = new Graphic3d_AspectMarker3d();
+  PtA->SetType(Aspect_TOM_POINT);
+  PtA->SetScale(5.);
+  PtA->SetColor(theColor);
+  TheGroup->SetPrimitivesAspect(PtA);
+  TheGroup->AddPrimitiveArray (aPoint);
+}
+
+void PartSet_CenterPrs::HilightSelected(const Handle(PrsMgr_PresentationManager3d)& PM,
+                                        const SelectMgr_SequenceOfOwner& Seq)
+{
+  Handle( Prs3d_Presentation ) aSelectionPrs = GetSelectPresentation( PM );
+  aSelectionPrs->Clear();
+
+  drawPoint(aSelectionPrs, GetContext()->SelectionStyle()->Color());
+
+  aSelectionPrs->SetDisplayPriority(9);
+  aSelectionPrs->Display();
+  PM->Color(this, GetContext()->SelectionStyle());
+}
+
+void PartSet_CenterPrs::HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager3d)& thePM,
+                                              const Handle(Graphic3d_HighlightStyle)& theStyle,
+                                              const Handle(SelectMgr_EntityOwner)& theOwner)
+{
+  Handle( Prs3d_Presentation ) aHilightPrs = GetHilightPresentation( thePM );
+  aHilightPrs->Clear();
+
+  thePM->Color(this, theStyle);
+  drawPoint(aHilightPrs, theStyle->Color());
+
+  aHilightPrs->SetZLayer(Graphic3d_ZLayerId_Topmost);
+
+  if (thePM->IsImmediateModeOn())
+    thePM->AddToImmediateList(aHilightPrs);
+}
index 86e54b24f345f62e11fd06baa0f12a7c41760d06..91a5387cd5a57d3a66f50e613b7809a7664fbf20 100644 (file)
@@ -32,6 +32,7 @@
 #include <AIS_Point.hxx>
 #include <Standard_DefineHandle.hxx>
 #include <gp_Pnt.hxx>
+#include <Geom_Point.hxx>
 
 DEFINE_STANDARD_HANDLE(PartSet_CenterPrs, AIS_Point)
 
@@ -61,9 +62,16 @@ public:
   /// Returns type of the center
   ModelAPI_AttributeSelection::CenterType centerType() const { return myCenterType; }
 
+  virtual void HilightSelected(const Handle(PrsMgr_PresentationManager3d)& PM, const SelectMgr_SequenceOfOwner& Seq);
+  virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)&,
+                                      const Handle(Graphic3d_HighlightStyle)&,
+                                      const Handle(SelectMgr_EntityOwner)&);
+
   DEFINE_STANDARD_RTTIEXT(PartSet_CenterPrs, AIS_Point)
 
 private:
+  void drawPoint(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor);
+
   ObjectPtr myObject;
   GeomEdgePtr myEdge;
   ModelAPI_AttributeSelection::CenterType myCenterType;