Salome HOME
Fix for stable processing of mirror constraint (eliminating SolveSpace problems)
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_SymbolPrs.cpp
index 144664122a2f66c548dff867b47b31c527912322..b953501fa8b509abe938eb6182df85e9aa36e199 100644 (file)
 
 #include <Graphic3d_ArrayOfSegments.hxx>
 
+#include <SelectMgr_Selection.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <Select3D_SensitivePoint.hxx>
+
 
 #ifdef WIN32
 # define FSEP "\\"
@@ -32,6 +36,7 @@ SketcherPrs_SymbolPrs::SketcherPrs_SymbolPrs(SketchPlugin_Constraint* theConstra
   SetAutoHilight(Standard_False);
 }
 
+
 Handle(Image_AlienPixMap) SketcherPrs_SymbolPrs::icon()
 {
   if (myIconsMap.count(iconName()) == 1) {
@@ -65,15 +70,59 @@ void SketcherPrs_SymbolPrs::prepareAspect()
 
 void SketcherPrs_SymbolPrs::addLine(const Handle(Graphic3d_Group)& theGroup, std::string theAttrName) const
 {
-  std::shared_ptr<GeomAPI_Edge> aLine = SketcherPrs_Tools::getLine(myConstraint, theAttrName);
+  ObjectPtr aObj = SketcherPrs_Tools::getResult(myConstraint, theAttrName);
+  std::shared_ptr<GeomAPI_Shape> aLine = SketcherPrs_Tools::getShape(aObj);
   if (aLine.get() == NULL)
     return;
+  std::shared_ptr<GeomAPI_Edge> aEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aLine));
 
-  std::shared_ptr<GeomAPI_Pnt> aPnt1 = aLine->firstPoint();
-  std::shared_ptr<GeomAPI_Pnt> aPnt2 = aLine->lastPoint();
+  std::shared_ptr<GeomAPI_Pnt> aPnt1 = aEdge->firstPoint();
+  std::shared_ptr<GeomAPI_Pnt> aPnt2 = aEdge->lastPoint();
 
   Handle(Graphic3d_ArrayOfSegments) aLines = new Graphic3d_ArrayOfSegments(2, 1);
   aLines->AddVertex(aPnt1->impl<gp_Pnt>());
   aLines->AddVertex(aPnt2->impl<gp_Pnt>());
   theGroup->AddPrimitiveArray(aLines);
 }
+
+void SketcherPrs_SymbolPrs::HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM, 
+                                           const SelectMgr_SequenceOfOwner& theOwners)
+{
+
+  Handle( Prs3d_Presentation ) aSelectionPrs = GetSelectPresentation( thePM );
+  aSelectionPrs->Clear();
+  drawLines(aSelectionPrs, Quantity_NOC_WHITE);
+
+  aSelectionPrs->SetDisplayPriority(9);
+  aSelectionPrs->Display();
+  thePM->Highlight(this);
+}
+
+void SketcherPrs_SymbolPrs::HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager3d)& thePM, 
+                                                 const Quantity_NameOfColor theColor, const Handle(SelectMgr_EntityOwner)& theOwner)
+{
+  thePM->Color(this, theColor);
+
+  Handle( Prs3d_Presentation ) aHilightPrs = GetHilightPresentation( thePM );
+  aHilightPrs->Clear();
+  drawLines(aHilightPrs, theColor);
+
+  if (thePM->IsImmediateModeOn())
+    thePM->AddToImmediateList(aHilightPrs);
+}
+
+
+
+void SketcherPrs_SymbolPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+                                            const Standard_Integer aMode)
+{
+  ClearSelected();
+
+  if (!myPntArray.IsNull()) {
+    Handle(SelectMgr_EntityOwner) aOwn = new SelectMgr_EntityOwner(this);
+    for (int i = 1; i <= myPntArray->VertexNumber(); i++) {
+      Handle(Select3D_SensitivePoint) aSP = new Select3D_SensitivePoint(aOwn, myPntArray->Vertice(i));
+      aSelection->Add(aSP);
+    }
+  }
+}