]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Define rigid constraint symbol
authorvsv <vitaly.smetannikov@opencascade.com>
Mon, 16 Mar 2015 09:56:51 +0000 (12:56 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Mon, 16 Mar 2015 09:56:51 +0000 (12:56 +0300)
13 files changed:
src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp
src/SketcherPrs/CMakeLists.txt
src/SketcherPrs/SketcherPrs_Factory.cpp
src/SketcherPrs/SketcherPrs_Factory.h
src/SketcherPrs/SketcherPrs_Parallel.cpp
src/SketcherPrs/SketcherPrs_Parallel.h
src/SketcherPrs/SketcherPrs_Perpendicular.cpp
src/SketcherPrs/SketcherPrs_Perpendicular.h
src/SketcherPrs/SketcherPrs_Rigid.cpp [new file with mode: 0644]
src/SketcherPrs/SketcherPrs_Rigid.h [new file with mode: 0644]
src/SketcherPrs/SketcherPrs_SymbolPrs.cpp
src/SketcherPrs/SketcherPrs_SymbolPrs.h
src/SketcherPrs/icons/anchor.png [new file with mode: 0644]

index 51f4b3a01eb49249bd9e9745f3975365977c48e2..6695a8813dd8f0b0b7b1be6929734e6e05d8be75 100644 (file)
@@ -7,6 +7,8 @@
 #include "SketchPlugin_ConstraintRigid.h"
 #include "SketchPlugin_ConstraintParallel.h"
 
+#include <SketcherPrs_Factory.h>
+
 #include <ModelAPI_ResultConstruction.h>
 #include <Config_PropManager.h>
 
@@ -31,50 +33,10 @@ AISObjectPtr SketchPlugin_ConstraintRigid::getAISObject(AISObjectPtr thePrevious
   if (!sketch())
     return thePrevious;
 
-  std::shared_ptr<ModelAPI_Data> aData = data();
-  std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = std::dynamic_pointer_cast<
-      ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
-  if (!anAttr /*|| !anAttr->isObject()*/)
-    return thePrevious;
-
-  std::shared_ptr<GeomAPI_Shape> aShape;
-
-  if (anAttr->isObject()) {
-    std::shared_ptr<ModelAPI_ResultConstruction> aConst;
-    aConst = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(anAttr->object());
-
-    if (!aConst) 
-      return thePrevious;
-
-    std::shared_ptr<SketchPlugin_Feature> aSketchFea = 
-      std::dynamic_pointer_cast<SketchPlugin_Feature>(ModelAPI_Feature::feature(aConst));
-    if (aSketchFea.get() != NULL) {
-      if (aSketchFea->isExternal())
-        return thePrevious;
-    }
-    aShape = aConst->shape();
-  }
-  else {
-    std::shared_ptr<GeomDataAPI_Point2D> aPointAttr =
-                             std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr->attr());
-    if (!aPointAttr)
-      return thePrevious;
-    std::shared_ptr<GeomAPI_Pnt> aPoint(sketch()->to3D(aPointAttr->x(), aPointAttr->y()));
-    aShape = GeomAlgoAPI_PointBuilder::point(aPoint);
-  }
-
   AISObjectPtr anAIS = thePrevious;
-  if (!anAIS)
-    anAIS = AISObjectPtr(new GeomAPI_AISObject);
-
-  std::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
-  anAIS->createFixed(aShape, aPlane);
-
-  // Set color from preferences
-  std::vector<int> aRGB = Config_PropManager::color("Visualization", "sketch_constraint_color",
-                                                    SKETCH_CONSTRAINT_COLOR);
-
-  anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
+  if (!anAIS) {
+    anAIS = SketcherPrs_Factory::rigidConstraint(this, sketch()->coordinatePlane());
+  }
 
   return anAIS;
 }
\ No newline at end of file
index 37ec076c998cbe65ced1588045c750e75ac4d363..c2ed12fda0a75d63971b6d86c8595a0c6b1010c6 100644 (file)
@@ -9,6 +9,7 @@ SET(PROJECT_HEADERS
     SketcherPrs_Perpendicular.h
     SketcherPrs_SymbolPrs.h
        SketcherPrs_PositionMgr.h
+       SketcherPrs_Rigid.h
 )
 
 SET(PROJECT_SOURCES
@@ -19,6 +20,7 @@ SET(PROJECT_SOURCES
     SketcherPrs_Perpendicular.cpp
     SketcherPrs_SymbolPrs.cpp
        SketcherPrs_PositionMgr.cpp
+       SketcherPrs_Rigid.cpp
 )
 
 SET(PROJECT_LIBRARIES
@@ -35,6 +37,7 @@ SET(PROJECT_LIBRARIES
 SET(PROJECT_PICTURES
     icons/parallel.png
     icons/perpendicular.png
+       icons/anchor.png
 )
 
 ADD_DEFINITIONS(-DCONSTRAINTS_EXPORTS ${CAS_DEFINITIONS})
index 1e3e7c67bc2929dd39fdb3d569e21b92f3f7ccfd..187b94dce89024a05296b8cb6a556935db012c02 100644 (file)
@@ -9,6 +9,7 @@
 #include <SketcherPrs_Coincident.h>
 #include <SketcherPrs_Parallel.h>
 #include <SketcherPrs_Perpendicular.h>
+#include <SketcherPrs_Rigid.h>
 
 
 AISObjectPtr SketcherPrs_Factory::coincidentConstraint(SketchPlugin_Constraint* theConstraint, 
@@ -38,3 +39,12 @@ AISObjectPtr SketcherPrs_Factory::perpendicularConstraint(SketchPlugin_Constrain
   aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs));
   return aAISObj;
 }
+
+AISObjectPtr SketcherPrs_Factory::rigidConstraint(SketchPlugin_Constraint* theConstraint, 
+                                                     const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+{
+  std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+  Handle(SketcherPrs_Rigid) aPrs = new SketcherPrs_Rigid(theConstraint, thePlane);
+  aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs));
+  return aAISObj;
+}
index fb287c05e7dc5500512fc272efa7d2fb358b09cd..6e61853e93a30171cd83449902d387853e2d6697 100644 (file)
@@ -37,6 +37,12 @@ public:
   /// \param thePlane the current sketch plane
   static AISObjectPtr perpendicularConstraint(SketchPlugin_Constraint* theConstraint, 
                                          const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+
+  /// Creates coincedent perpendicular presentation
+  /// \param theConstraint the constraint
+  /// \param thePlane the current sketch plane
+  static AISObjectPtr rigidConstraint(SketchPlugin_Constraint* theConstraint, 
+                                      const std::shared_ptr<GeomAPI_Ax3>& thePlane);
 };
 
 #endif
index e34dfb49696b8a70f4d73c91c260b0e7f71b8311..380c15f9ca12cd94b89729c0f0d63fd47d2cf480 100644 (file)
@@ -75,45 +75,6 @@ void SketcherPrs_Parallel::Compute(const Handle(PrsMgr_PresentationManager3d)& t
   aGroup->AddPrimitiveArray(myPntArray);
 }
 
-void SketcherPrs_Parallel::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
-                                            const Standard_Integer aMode)
-{
-  ClearSelected();
-
-  Handle(SelectMgr_EntityOwner) aOwn = new SelectMgr_EntityOwner(this);
-  Handle(Select3D_SensitivePoint) aSP1 = new Select3D_SensitivePoint(aOwn, myPntArray->Vertice(1));
-  Handle(Select3D_SensitivePoint) aSP2 = new Select3D_SensitivePoint(aOwn, myPntArray->Vertice(2));
-  aSelection->Add(aSP1);
-  aSelection->Add(aSP2);
-}
-
-void SketcherPrs_Parallel::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_Parallel::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_Parallel::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const
 {
   Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
index 9ea829874867c91b0a3017525490300091d27cbd..63aa6afc3efb87649cf038240badac9d5d4b1665 100644 (file)
@@ -28,33 +28,15 @@ public:
   /// \param thePlane a coordinate plane of current sketch
   Standard_EXPORT SketcherPrs_Parallel(SketchPlugin_Constraint* theConstraint, 
                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane);
-
-  //! Method which draws selected owners ( for fast presentation draw )
-  Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM, 
-                                               const SelectMgr_SequenceOfOwner& theOwners);
-  
-  //! Method which hilight an owner belonging to
-  //! this selectable object  ( for fast presentation draw )
-  Standard_EXPORT virtual void HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager3d)& thePM, 
-                                                     const Quantity_NameOfColor theColor, const Handle(SelectMgr_EntityOwner)& theOwner);
-
   DEFINE_STANDARD_RTTI(SketcherPrs_Parallel)
 protected:
   /// Redefinition of virtual function
   Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
     const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
 
-  /// Redefinition of virtual function
-  Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
-    const Standard_Integer aMode) ;
-
   virtual const char* iconName() const { return "parallel.png"; }
 
-private:
-
-  void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const;
-
-  Handle(Graphic3d_ArrayOfPoints) myPntArray;
+  virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const;
 };
 
 #endif
\ No newline at end of file
index 05c7506b251198b26d8cabcf13dfb0510160a9bb..0c9e45da273a071f60fa41c1ec420809a31dc720 100644 (file)
 #include <Graphic3d_AspectLine3d.hxx>
 #include <Graphic3d_ArrayOfSegments.hxx>
 
-#include <Select3D_SensitivePoint.hxx>
-#include <Select3D_SensitiveSegment.hxx>
-
-#include <SelectMgr_SequenceOfOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-
 
 // Function which is defined in SketchPlugin_ConstraintDistance.cpp
 extern std::shared_ptr<GeomAPI_Pnt2d> getFeaturePoint(DataPtr theData,
@@ -69,29 +62,6 @@ void SketcherPrs_Perpendicular::Compute(const Handle(PrsMgr_PresentationManager3
   SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
   gp_Pnt aP1 = aMgr->getPosition(aLine1, this);
   gp_Pnt aP2 = aMgr->getPosition(aLine2, this);
-  //std::shared_ptr<GeomAPI_Pnt> aPnt1 = aLine1->firstPoint();
-  //std::shared_ptr<GeomAPI_Pnt> aPnt2 = aLine1->lastPoint();
-  //gp_Pnt aP1((aPnt1->x() + aPnt2->x())/2.,
-  //           (aPnt1->y() + aPnt2->y())/2.,
-  //           (aPnt1->z() + aPnt2->z())/2.);
-
-  //gp_Vec aVec1(aPnt1->impl<gp_Pnt>(), aPnt2->impl<gp_Pnt>());
-  //gp_Vec aShift = aVec1.Crossed(myPlane->norm()->impl<gp_Dir>());
-  //aShift.Normalize();
-  //aShift.Multiply(20);
-  //aP1.Translate(aShift);
-
-  //aPnt1 = aLine2->firstPoint();
-  //aPnt2 = aLine2->lastPoint();
-  //gp_Pnt aP2((aPnt1->x() + aPnt2->x())/2.,
-  //           (aPnt1->y() + aPnt2->y())/2.,
-  //           (aPnt1->z() + aPnt2->z())/2.);
-
-  //gp_Vec aVec2(aPnt1->impl<gp_Pnt>(), aPnt2->impl<gp_Pnt>());
-  //aShift = aVec2.Crossed(myPlane->norm()->impl<gp_Dir>());
-  //aShift.Normalize();
-  //aShift.Multiply(20);
-  //aP2.Translate(aShift);
 
   Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
   aGroup->SetPrimitivesAspect(myAspect);
@@ -100,45 +70,6 @@ void SketcherPrs_Perpendicular::Compute(const Handle(PrsMgr_PresentationManager3
   aGroup->AddPrimitiveArray(myPntArray);
 }
 
-void SketcherPrs_Perpendicular::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
-                                            const Standard_Integer aMode)
-{
-  ClearSelected();
-
-  Handle(SelectMgr_EntityOwner) aOwn = new SelectMgr_EntityOwner(this);
-  Handle(Select3D_SensitivePoint) aSP1 = new Select3D_SensitivePoint(aOwn, myPntArray->Vertice(1));
-  Handle(Select3D_SensitivePoint) aSP2 = new Select3D_SensitivePoint(aOwn, myPntArray->Vertice(2));
-  aSelection->Add(aSP1);
-  aSelection->Add(aSP2);
-}
-
-void SketcherPrs_Perpendicular::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_Perpendicular::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_Perpendicular::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const
 {
   Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
index a41350b4eb859b10d5320241932e244c3a58318c..87a620ab13d06e4ebfd4499cd1d1ec9acd916ca5 100644 (file)
@@ -28,33 +28,18 @@ public:
   Standard_EXPORT SketcherPrs_Perpendicular(SketchPlugin_Constraint* theConstraint, 
                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane);
 
-  //! Method which draws selected owners ( for fast presentation draw )
-  Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM, 
-                                               const SelectMgr_SequenceOfOwner& theOwners);
-  
-  //! Method which hilight an owner belonging to
-  //! this selectable object  ( for fast presentation draw )
-  Standard_EXPORT virtual void HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager3d)& thePM, 
-                                                     const Quantity_NameOfColor theColor, const Handle(SelectMgr_EntityOwner)& theOwner);
-
-
   DEFINE_STANDARD_RTTI(SketcherPrs_Perpendicular)
 protected:
   /// Redefinition of virtual function
   Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
     const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
 
-  /// Redefinition of virtual function
-  Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
-    const Standard_Integer aMode) ;
-
   virtual const char* iconName() const { return "perpendicular.png"; }
 
-private:
-
-  void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const;
-
-  Handle(Graphic3d_ArrayOfPoints) myPntArray;
+  /// Redefine this function in order to add additiona lines of constraint base
+  /// \param thePrs a presentation
+  /// \param theColor a color of additiona lines
+  virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const;
 };
 
 #endif
\ No newline at end of file
diff --git a/src/SketcherPrs/SketcherPrs_Rigid.cpp b/src/SketcherPrs/SketcherPrs_Rigid.cpp
new file mode 100644 (file)
index 0000000..e171bf8
--- /dev/null
@@ -0,0 +1,80 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Rigid.cpp
+// Created:     16 February 2015
+// Author:      Vitaly SMETANNIKOV
+
+#include "SketcherPrs_Rigid.h"
+#include "SketcherPrs_Tools.h"
+#include "SketcherPrs_PositionMgr.h"
+
+#include <GeomAPI_Pnt.h>
+
+#include <SketchPlugin_Constraint.h>
+
+#include <AIS_Drawer.hxx>
+#include <gp_Pnt2d.hxx>
+
+#include <Prs3d_PointAspect.hxx>
+#include <Prs3d_Root.hxx>
+#include <Prs3d_LineAspect.hxx>
+
+#include <Graphic3d_MarkerImage.hxx>
+#include <Graphic3d_AspectMarker3d.hxx>
+#include <Graphic3d_AspectLine3d.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
+
+#include <Select3D_SensitivePoint.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+
+#include <SelectMgr_SequenceOfOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+
+
+extern std::shared_ptr<GeomAPI_Pnt2d> getFeaturePoint(DataPtr theData,
+                                                      const std::string& theAttribute);
+
+
+IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Rigid, SketcherPrs_SymbolPrs);
+IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Rigid, SketcherPrs_SymbolPrs);
+
+static Handle(Image_AlienPixMap) MyPixMap;
+
+SketcherPrs_Rigid::SketcherPrs_Rigid(SketchPlugin_Constraint* theConstraint, 
+                                           const std::shared_ptr<GeomAPI_Ax3>& thePlane) 
+ : SketcherPrs_SymbolPrs(theConstraint, thePlane)
+{
+  myPntArray = new Graphic3d_ArrayOfPoints(1);
+  myPntArray->AddVertex(0., 0., 0.);
+}  
+
+void SketcherPrs_Rigid::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+                                   const Handle(Prs3d_Presentation)& thePresentation, 
+                                   const Standard_Integer theMode)
+{
+  prepareAspect();
+
+  std::shared_ptr<GeomAPI_Shape> aLine1 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_A());
+  if (aLine1.get() == NULL)
+    return;
+
+  SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
+  gp_Pnt aP1 = aMgr->getPosition(aLine1, this);
+
+  Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
+  aGroup->SetPrimitivesAspect(myAspect);
+  myPntArray->SetVertice(1, aP1);
+  aGroup->AddPrimitiveArray(myPntArray);
+}
+
+void SketcherPrs_Rigid::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);
+
+  addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
+}
+
diff --git a/src/SketcherPrs/SketcherPrs_Rigid.h b/src/SketcherPrs/SketcherPrs_Rigid.h
new file mode 100644 (file)
index 0000000..29ed454
--- /dev/null
@@ -0,0 +1,46 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Rigid.h
+// Created:     16 February 2015
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef SketcherPrs_Rigid_H
+#define SketcherPrs_Rigid_H
+
+#include "SketcherPrs_SymbolPrs.h"
+
+class SketchPlugin_Constraint;
+class SketchPlugin_Sketch;
+
+
+DEFINE_STANDARD_HANDLE(SketcherPrs_Rigid, SketcherPrs_SymbolPrs)
+
+/**
+* \ingroup GUI
+* A redefinition of standard AIS Interactive Object in order to provide  
+* presentation of parallel constraint
+*/
+class SketcherPrs_Rigid: public SketcherPrs_SymbolPrs
+{
+public:
+  /// Constructor
+  /// \param theConstraint a constraint feature
+  /// \param thePlane a coordinate plane of current sketch
+  Standard_EXPORT SketcherPrs_Rigid(SketchPlugin_Constraint* theConstraint, 
+                                       const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+
+  DEFINE_STANDARD_RTTI(SketcherPrs_Rigid)
+protected:
+  /// Redefinition of virtual function
+  Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+    const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
+
+  virtual const char* iconName() const { return "anchor.png"; }
+
+  /// Redefine this function in order to add additiona lines of constraint base
+  /// \param thePrs a presentation
+  /// \param theColor a color of additiona lines
+  virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const;
+};
+
+#endif
\ No newline at end of file
index 4637f910c08de6a27b2efe79b863997c73aff634..fe06620a3703c8bf4a97c0aa18c8025fc4bc1141 100644 (file)
 
 #include <Graphic3d_ArrayOfSegments.hxx>
 
+#include <SelectMgr_Selection.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <Select3D_SensitivePoint.hxx>
+
 
 #ifdef WIN32
 # define FSEP "\\"
@@ -79,3 +83,45 @@ void SketcherPrs_SymbolPrs::addLine(const Handle(Graphic3d_Group)& theGroup, std
   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);
+    }
+  }
+}
index 6cce9503e6e7bdc97b27fc3ca0913ed4142fa7f6..3fe2086996917b60e2e590adf4e4c99d8e7e7b7b 100644 (file)
@@ -38,6 +38,16 @@ public:
   //! to this selectable object ( for fast presentation draw )
   Standard_EXPORT virtual void ClearSelected();
 
+
+  //! Method which draws selected owners ( for fast presentation draw )
+  Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM, 
+                                               const SelectMgr_SequenceOfOwner& theOwners);
+  
+  //! Method which hilight an owner belonging to
+  //! this selectable object  ( for fast presentation draw )
+  Standard_EXPORT virtual void HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager3d)& thePM, 
+                                                     const Quantity_NameOfColor theColor, const Handle(SelectMgr_EntityOwner)& theOwner);
+
   Standard_EXPORT std::shared_ptr<GeomAPI_Ax3> plane() const { return myPlane; }
 
   Standard_EXPORT SketchPlugin_Constraint* feature() const { return myConstraint; }
@@ -45,6 +55,11 @@ public:
   DEFINE_STANDARD_RTTI(SketcherPrs_SymbolPrs)
 
 protected:
+
+  /// Redefinition of virtual function
+  Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+    const Standard_Integer aMode);
+
   /// Returns an icon file name. Has to be redefined in successors
   virtual const char* iconName() const = 0;
 
@@ -60,6 +75,11 @@ protected:
   /// \param theAttrName an attribute name which corresponds to referenced line
   void addLine(const Handle(Graphic3d_Group)& theGroup, std::string theAttrName) const;
 
+  /// Redefine this function in order to add additiona lines of constraint base
+  /// \param thePrs a presentation
+  /// \param theColor a color of additiona lines
+  virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const {}
+
 protected:
   /// Constraint feature
   SketchPlugin_Constraint* myConstraint;
@@ -70,9 +90,13 @@ protected:
   /// Aspect for entities drawing
   Handle(Graphic3d_AspectMarker3d) myAspect;
 
+  /// Array of symbols positions
+  Handle(Graphic3d_ArrayOfPoints) myPntArray;
+
 private: 
   /// Static map to collect constraints icons {IconName : IconPixMap}
   static std::map<const char*, Handle(Image_AlienPixMap)> myIconsMap;
+
 };
 
 #endif
\ No newline at end of file
diff --git a/src/SketcherPrs/icons/anchor.png b/src/SketcherPrs/icons/anchor.png
new file mode 100644 (file)
index 0000000..5dc7b58
Binary files /dev/null and b/src/SketcherPrs/icons/anchor.png differ