]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Perpendicular constraint presentation created
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 12 Mar 2015 16:22:10 +0000 (19:22 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 12 Mar 2015 16:22:10 +0000 (19:22 +0300)
13 files changed:
src/SketchPlugin/SketchPlugin_ConstraintParallel.h
src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp
src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h
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 [new file with mode: 0644]
src/SketcherPrs/SketcherPrs_Perpendicular.h [new file with mode: 0644]
src/SketcherPrs/SketcherPrs_SymbolPrs.cpp [new file with mode: 0644]
src/SketcherPrs/SketcherPrs_SymbolPrs.h [new file with mode: 0644]
src/SketcherPrs/icons/perpendicular.png [new file with mode: 0644]

index afaae6c005bca6baaaabe05adf1d4b787c7e19a5..5e9cc9fe9ec88ab343105b7992e6598769e259be 100644 (file)
@@ -43,11 +43,6 @@ class SketchPlugin_ConstraintParallel : public SketchPlugin_ConstraintBase
   /// Returns the AIS preview
   SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
 
-  /// Moves the feature
-  /// \param theDeltaX the delta for X coordinate is moved
-  /// \param theDeltaY the delta for Y coordinate is moved
-  //SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
-
   /// \brief Use plugin manager for features creation
   SketchPlugin_ConstraintParallel();
 };
index ca791d55f5e20c04c643bdcb5589dc71a08a7fd4..152fabe222534208c3096a2a9e6db326f05468cb 100644 (file)
@@ -14,6 +14,8 @@
 #include <SketchPlugin_Line.h>
 #include <SketchPlugin_Sketch.h>
 
+#include <SketcherPrs_Factory.h>
+
 #include <GeomDataAPI_Point2D.h>
 #include <GeomAPI_Pnt2d.h>
 #include <GeomAPI_Pnt.h>
@@ -39,55 +41,10 @@ AISObjectPtr SketchPlugin_ConstraintPerpendicular::getAISObject(AISObjectPtr the
   if (!sketch())
     return thePrevious;
 
-  std::shared_ptr<ModelAPI_Data> aData = data();
-  std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr1 = std::dynamic_pointer_cast<
-      ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
-  std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr2 = std::dynamic_pointer_cast<
-      ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_B()));
-  if (!anAttr1 || !anAttr1->isObject() || !anAttr2 || !anAttr2->isObject())
-    return thePrevious;
-
-  FeaturePtr aFeature = ModelAPI_Feature::feature(anAttr1->object());
-  if (!aFeature)
-    return thePrevious;
-  std::shared_ptr<SketchPlugin_Line> aLine1Feature =
-      std::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
-
-  aFeature = ModelAPI_Feature::feature(anAttr2->object());
-  if (!aFeature)
-    return thePrevious;
-  std::shared_ptr<SketchPlugin_Line> aLine2Feature =
-      std::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
-
-  if (!aLine1Feature || !aLine2Feature)
-    return thePrevious;
-
-  std::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
-  std::shared_ptr<GeomAPI_Shape> aLine1, aLine2;
-  std::shared_ptr<ModelAPI_ResultConstruction> aConst1 = std::dynamic_pointer_cast<
-      ModelAPI_ResultConstruction>(anAttr1->object());
-  if (aConst1)
-    aLine1 = aConst1->shape();
-  std::shared_ptr<ModelAPI_ResultConstruction> aConst2 = std::dynamic_pointer_cast<
-      ModelAPI_ResultConstruction>(anAttr2->object());
-  if (aConst2)
-    aLine2 = aConst2->shape();
-
   AISObjectPtr anAIS = thePrevious;
-  if (!anAIS)
-    anAIS = AISObjectPtr(new GeomAPI_AISObject);
-  anAIS->createPerpendicular(aLine1, aLine2, 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::perpendicularConstraint(this, sketch()->coordinatePlane());
+  }
   return anAIS;
 }
 
-void SketchPlugin_ConstraintPerpendicular::move(double theDeltaX, double theDeltaY)
-{
-  //Flyout point of the constraint follows it's features
-  return;
-}
-
index fa5eaacecc9d716a5d3430177939de7ef497def5..3dc6f589b8339c8e00e6c45cd253024b52ae796c 100644 (file)
@@ -43,11 +43,6 @@ class SketchPlugin_ConstraintPerpendicular : public SketchPlugin_ConstraintBase
   /// Returns the AIS preview
   SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
 
-  /// Moves the feature
-  /// \param theDeltaX the delta for X coordinate is moved
-  /// \param theDeltaY the delta for Y coordinate is moved
-  SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
-
   /// \brief Use plugin manager for features creation
   SketchPlugin_ConstraintPerpendicular();
 };
index fcb8889ad201dde1bb8cf5819da4228710c5a11f..833e0de69ac39e8d0b3fdd701692f6eda95aa2ef 100644 (file)
@@ -4,15 +4,17 @@ SET(PROJECT_HEADERS
     SketcherPrs.h
     SketcherPrs_Coincident.h
     SketcherPrs_Factory.h
-       SketcherPrs_Parallel.h
-       SketcherPrs_Tools.h
+    SketcherPrs_Parallel.h
+    SketcherPrs_Tools.h
+    SketcherPrs_Perpendicular.h
 )
 
 SET(PROJECT_SOURCES
     SketcherPrs_Coincident.cpp
     SketcherPrs_Factory.cpp
-       SketcherPrs_Parallel.cpp
-       SketcherPrs_Tools.cpp
+    SketcherPrs_Parallel.cpp
+    SketcherPrs_Tools.cpp
+    SketcherPrs_Perpendicular.cpp
 )
 
 SET(PROJECT_LIBRARIES
@@ -28,6 +30,7 @@ SET(PROJECT_LIBRARIES
 
 SET(PROJECT_PICTURES
     icons/parallel.png
+    icons/perpendicular.png
 )
 
 ADD_DEFINITIONS(-DCONSTRAINTS_EXPORTS ${CAS_DEFINITIONS})
index 829052feef312ba4781f1973f12924ac3a5216aa..1e3e7c67bc2929dd39fdb3d569e21b92f3f7ccfd 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <SketcherPrs_Coincident.h>
 #include <SketcherPrs_Parallel.h>
+#include <SketcherPrs_Perpendicular.h>
 
 
 AISObjectPtr SketcherPrs_Factory::coincidentConstraint(SketchPlugin_Constraint* theConstraint, 
@@ -27,4 +28,13 @@ AISObjectPtr SketcherPrs_Factory::parallelConstraint(SketchPlugin_Constraint* th
   Handle(SketcherPrs_Parallel) aPrs = new SketcherPrs_Parallel(theConstraint, thePlane);
   aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs));
   return aAISObj;
-}
\ No newline at end of file
+}
+
+AISObjectPtr SketcherPrs_Factory::perpendicularConstraint(SketchPlugin_Constraint* theConstraint, 
+                                                     const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+{
+  std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+  Handle(SketcherPrs_Perpendicular) aPrs = new SketcherPrs_Perpendicular(theConstraint, thePlane);
+  aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs));
+  return aAISObj;
+}
index 75a496f80f5306e400faa57904287d67cb6a4710..fb287c05e7dc5500512fc272efa7d2fb358b09cd 100644 (file)
@@ -31,6 +31,12 @@ public:
   /// \param thePlane the current sketch plane
   static AISObjectPtr parallelConstraint(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 perpendicularConstraint(SketchPlugin_Constraint* theConstraint, 
+                                         const std::shared_ptr<GeomAPI_Ax3>& thePlane);
 };
 
 #endif
index ed23fc51922f32a97c2606023c3ec33244e517b7..9cb425b46643b37465ffd5985f1c990c9d0061f9 100644 (file)
@@ -13,7 +13,6 @@
 
 #include <AIS_Drawer.hxx>
 #include <gp_Pnt2d.hxx>
-#include <Image_AlienPixMap.hxx>
 
 #include <Prs3d_PointAspect.hxx>
 #include <Prs3d_Root.hxx>
 extern std::shared_ptr<GeomAPI_Pnt2d> getFeaturePoint(DataPtr theData,
                                                       const std::string& theAttribute);
 
-#ifdef WIN32
-# define FSEP "\\"
-#else
-# define FSEP "/"
-#endif
 
-
-IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Parallel, AIS_InteractiveObject);
-IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Parallel, AIS_InteractiveObject);
+IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Parallel, SketcherPrs_SymbolPrs);
+IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Parallel, SketcherPrs_SymbolPrs);
 
 static Handle(Image_AlienPixMap) MyPixMap;
 
 SketcherPrs_Parallel::SketcherPrs_Parallel(SketchPlugin_Constraint* theConstraint, 
                                            const std::shared_ptr<GeomAPI_Ax3>& thePlane) 
- : AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane)
+ : SketcherPrs_SymbolPrs(theConstraint, thePlane)
 {
-  if (MyPixMap.IsNull()) {
-    TCollection_AsciiString aFile(getenv("NewGeomResources"));
-    aFile += FSEP;
-    aFile += "parallel.png";
-    MyPixMap = new Image_AlienPixMap();
-    if (!MyPixMap->Load(aFile))
-      MyPixMap.Nullify();
-  }
-  if (!MyPixMap.IsNull()) {
-    myAspect = new Graphic3d_AspectMarker3d(MyPixMap);
-    myPntArray = new Graphic3d_ArrayOfPoints(2);
-    myPntArray->AddVertex(0., 0., 0.);
-    myPntArray->AddVertex(0. ,0., 0.);
-  }
-  SetAutoHilight(Standard_False);
+  myPntArray = new Graphic3d_ArrayOfPoints(2);
+  myPntArray->AddVertex(0., 0., 0.);
+  myPntArray->AddVertex(0. ,0., 0.);
 }  
 
 void SketcherPrs_Parallel::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
                                    const Handle(Prs3d_Presentation)& thePresentation, 
                                    const Standard_Integer theMode)
 {
-  if (myAspect.IsNull())
-    return;
+  prepareAspect();
 
   std::shared_ptr<GeomAPI_Edge> aLine1 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_A());
   if (aLine1.get() == NULL)
@@ -102,7 +82,7 @@ void SketcherPrs_Parallel::Compute(const Handle(PrsMgr_PresentationManager3d)& t
              (aPnt1->z() + aPnt2->z())/2.);
 
   gp_Vec aVec2(aPnt1->impl<gp_Pnt>(), aPnt2->impl<gp_Pnt>());
-  aShift = aVec1.Crossed(myPlane->norm()->impl<gp_Dir>());
+  aShift = aVec2.Crossed(myPlane->norm()->impl<gp_Dir>());
   aShift.Normalize();
   aShift.Multiply(20);
   aP2.Translate(aShift);
@@ -118,13 +98,6 @@ void SketcherPrs_Parallel::ComputeSelection(const Handle(SelectMgr_Selection)& a
                                             const Standard_Integer aMode)
 {
   ClearSelected();
-  std::shared_ptr<GeomAPI_Edge> aLine1 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_A());
-  if (aLine1.get() == NULL)
-    return;
-
-  std::shared_ptr<GeomAPI_Edge> aLine2 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_B());
-  if (aLine2.get() == NULL)
-    return;
 
   Handle(SelectMgr_EntityOwner) aOwn = new SelectMgr_EntityOwner(this);
   Handle(Select3D_SensitivePoint) aSP1 = new Select3D_SensitivePoint(aOwn, myPntArray->Vertice(1));
@@ -162,38 +135,12 @@ void SketcherPrs_Parallel::HilightOwnerWithColor(const Handle(PrsMgr_Presentatio
 
 void SketcherPrs_Parallel::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const
 {
-  std::shared_ptr<GeomAPI_Edge> aLine1 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_A());
-  if (aLine1.get() == NULL)
-    return;
-
-  std::shared_ptr<GeomAPI_Edge> aLine2 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_B());
-  if (aLine2.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);
 
-  std::shared_ptr<GeomAPI_Pnt> aPnt1 = aLine1->firstPoint();
-  std::shared_ptr<GeomAPI_Pnt> aPnt2 = aLine1->lastPoint();
-  Handle(Graphic3d_ArrayOfSegments) aLines = new Graphic3d_ArrayOfSegments(2, 1);
-  aLines->AddVertex(aPnt1->impl<gp_Pnt>());
-  aLines->AddVertex(aPnt2->impl<gp_Pnt>());
-  aGroup->AddPrimitiveArray(aLines);
-
-  aPnt1 = aLine2->firstPoint();
-  aPnt2 = aLine2->lastPoint();
-  aLines = new Graphic3d_ArrayOfSegments(2, 1);
-  aLines->AddVertex(aPnt1->impl<gp_Pnt>());
-  aLines->AddVertex(aPnt2->impl<gp_Pnt>());
-  aGroup->AddPrimitiveArray(aLines);
+  addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
+  addLine(aGroup, SketchPlugin_Constraint::ENTITY_B());
 }
 
-void SketcherPrs_Parallel::ClearSelected()
-{
-  Handle( Prs3d_Presentation ) aSelectionPrs = GetSelectPresentation( NULL );  
-  if( !aSelectionPrs.IsNull() ) {
-    aSelectionPrs->Clear(); 
-  }
-}
index 5ead01c60da6370ac619bdbef813a6f62b04a7a6..9ea829874867c91b0a3017525490300091d27cbd 100644 (file)
@@ -7,30 +7,25 @@
 #ifndef SketcherPrs_Parallel_H
 #define SketcherPrs_Parallel_H
 
-#include <GeomAPI_Ax3.h>
-#include <GeomAPI_Edge.h>
-
-#include <AIS_InteractiveObject.hxx>
-#include <Graphic3d_ArrayOfPoints.hxx>
-#include <Graphic3d_AspectMarker3d.hxx>
-#include <Standard_DefineHandle.hxx>
+#include "SketcherPrs_SymbolPrs.h"
 
 class SketchPlugin_Constraint;
 class SketchPlugin_Sketch;
 
 
-DEFINE_STANDARD_HANDLE(SketcherPrs_Parallel, AIS_InteractiveObject)
+DEFINE_STANDARD_HANDLE(SketcherPrs_Parallel, SketcherPrs_SymbolPrs)
 
 /**
 * \ingroup GUI
 * A redefinition of standard AIS Interactive Object in order to provide  
-* presentation of coincident constraint
+* presentation of parallel constraint
 */
-class SketcherPrs_Parallel: public AIS_InteractiveObject
+class SketcherPrs_Parallel: public SketcherPrs_SymbolPrs
 {
 public:
   /// Constructor
-  /// \param theResult a result object
+  /// \param theConstraint a constraint feature
+  /// \param thePlane a coordinate plane of current sketch
   Standard_EXPORT SketcherPrs_Parallel(SketchPlugin_Constraint* theConstraint, 
                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane);
 
@@ -43,10 +38,6 @@ public:
   Standard_EXPORT virtual void HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager3d)& thePM, 
                                                      const Quantity_NameOfColor theColor, const Handle(SelectMgr_EntityOwner)& theOwner);
 
-  //! Method which clear all selected owners belonging
-  //! to this selectable object ( for fast presentation draw )
-  Standard_EXPORT virtual void ClearSelected();
-
   DEFINE_STANDARD_RTTI(SketcherPrs_Parallel)
 protected:
   /// Redefinition of virtual function
@@ -57,13 +48,12 @@ protected:
   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;
 
-  SketchPlugin_Constraint* myConstraint;
-  std::shared_ptr<GeomAPI_Ax3> myPlane;
-  Handle(Graphic3d_AspectMarker3d) myAspect;
   Handle(Graphic3d_ArrayOfPoints) myPntArray;
 };
 
diff --git a/src/SketcherPrs/SketcherPrs_Perpendicular.cpp b/src/SketcherPrs/SketcherPrs_Perpendicular.cpp
new file mode 100644 (file)
index 0000000..1d20021
--- /dev/null
@@ -0,0 +1,148 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Perpendicular.cpp
+// Created:     12 March 2015
+// Author:      Vitaly SMETANNIKOV
+
+#include "SketcherPrs_Perpendicular.h"
+#include "SketcherPrs_Tools.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>
+
+
+// Function which is defined in SketchPlugin_ConstraintDistance.cpp
+extern std::shared_ptr<GeomAPI_Pnt2d> getFeaturePoint(DataPtr theData,
+                                                      const std::string& theAttribute);
+
+
+
+IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Perpendicular, SketcherPrs_SymbolPrs);
+IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Perpendicular, SketcherPrs_SymbolPrs);
+
+static Handle(Image_AlienPixMap) MyPixMap;
+
+SketcherPrs_Perpendicular::SketcherPrs_Perpendicular(SketchPlugin_Constraint* theConstraint, 
+                                                     const std::shared_ptr<GeomAPI_Ax3>& thePlane) 
+ : SketcherPrs_SymbolPrs(theConstraint, thePlane)
+{
+  myPntArray = new Graphic3d_ArrayOfPoints(2);
+  myPntArray->AddVertex(0., 0., 0.);
+  myPntArray->AddVertex(0. ,0., 0.);
+}  
+
+void SketcherPrs_Perpendicular::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+                                   const Handle(Prs3d_Presentation)& thePresentation, 
+                                   const Standard_Integer theMode)
+{
+  prepareAspect();
+
+  std::shared_ptr<GeomAPI_Edge> aLine1 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_A());
+  if (aLine1.get() == NULL)
+    return;
+
+  std::shared_ptr<GeomAPI_Edge> aLine2 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_B());
+  if (aLine2.get() == NULL)
+    return;
+
+  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);
+  myPntArray->SetVertice(1, aP1);
+  myPntArray->SetVertice(2, aP2);
+  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);
+
+  Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
+  aGroup->SetPrimitivesAspect(aLineAspect);
+
+  addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
+  addLine(aGroup, SketchPlugin_Constraint::ENTITY_B());
+}
+
diff --git a/src/SketcherPrs/SketcherPrs_Perpendicular.h b/src/SketcherPrs/SketcherPrs_Perpendicular.h
new file mode 100644 (file)
index 0000000..a41350b
--- /dev/null
@@ -0,0 +1,60 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Perpendicular.h
+// Created:     12 March 2015
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef SketcherPrs_Perpendicular_H
+#define SketcherPrs_Perpendicular_H
+
+#include "SketcherPrs_SymbolPrs.h"
+
+class SketchPlugin_Sketch;
+
+
+DEFINE_STANDARD_HANDLE(SketcherPrs_Perpendicular, SketcherPrs_SymbolPrs)
+
+/**
+* \ingroup GUI
+* A redefinition of standard AIS Interactive Object in order to provide  
+* presentation of perpendicular constraint
+*/
+class SketcherPrs_Perpendicular: public SketcherPrs_SymbolPrs
+{
+public:
+  /// Constructor
+  /// \param theConstraint a constraint feature
+  /// \param thePlane a coordinate plane of current sketch
+  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;
+};
+
+#endif
\ No newline at end of file
diff --git a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp
new file mode 100644 (file)
index 0000000..1446641
--- /dev/null
@@ -0,0 +1,79 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_SymbolPrs.cpp
+// Created:     12 March 2015
+// Author:      Vitaly SMETANNIKOV
+
+#include "SketcherPrs_SymbolPrs.h"
+#include "SketcherPrs_Tools.h"
+
+#include <GeomAPI_Edge.h>
+
+#include <Graphic3d_ArrayOfSegments.hxx>
+
+
+#ifdef WIN32
+# define FSEP "\\"
+#else
+# define FSEP "/"
+#endif
+
+IMPLEMENT_STANDARD_HANDLE(SketcherPrs_SymbolPrs, AIS_InteractiveObject);
+IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_SymbolPrs, AIS_InteractiveObject);
+
+
+std::map<const char*, Handle(Image_AlienPixMap)> SketcherPrs_SymbolPrs::myIconsMap;
+
+
+SketcherPrs_SymbolPrs::SketcherPrs_SymbolPrs(SketchPlugin_Constraint* theConstraint, 
+                                             const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+ : AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane)
+{
+  SetAutoHilight(Standard_False);
+}
+
+Handle(Image_AlienPixMap) SketcherPrs_SymbolPrs::icon()
+{
+  if (myIconsMap.count(iconName()) == 1) {
+    return myIconsMap[iconName()];
+  }
+  TCollection_AsciiString aFile(getenv("NewGeomResources"));
+  aFile += FSEP;
+  aFile += iconName();
+  Handle(Image_AlienPixMap) aPixMap = new Image_AlienPixMap();
+  if (aPixMap->Load(aFile)) {
+    myIconsMap[iconName()] = aPixMap;
+    return aPixMap;
+  }
+  return Handle(Image_AlienPixMap)();
+}
+
+void SketcherPrs_SymbolPrs::ClearSelected()
+{
+  Handle( Prs3d_Presentation ) aSelectionPrs = GetSelectPresentation( NULL );  
+  if( !aSelectionPrs.IsNull() ) {
+    aSelectionPrs->Clear(); 
+  }
+}
+
+void SketcherPrs_SymbolPrs::prepareAspect()
+{
+  if (myAspect.IsNull()) {
+    myAspect = new Graphic3d_AspectMarker3d(icon());
+  }
+}
+
+void SketcherPrs_SymbolPrs::addLine(const Handle(Graphic3d_Group)& theGroup, std::string theAttrName) const
+{
+  std::shared_ptr<GeomAPI_Edge> aLine = SketcherPrs_Tools::getLine(myConstraint, theAttrName);
+  if (aLine.get() == NULL)
+    return;
+
+  std::shared_ptr<GeomAPI_Pnt> aPnt1 = aLine->firstPoint();
+  std::shared_ptr<GeomAPI_Pnt> aPnt2 = aLine->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);
+}
diff --git a/src/SketcherPrs/SketcherPrs_SymbolPrs.h b/src/SketcherPrs/SketcherPrs_SymbolPrs.h
new file mode 100644 (file)
index 0000000..792fde0
--- /dev/null
@@ -0,0 +1,74 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_SymbolPrs.h
+// Created:     12 March 2015
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef SketcherPrs_SymbolPrs_H
+#define SketcherPrs_SymbolPrs_H
+
+#include <AIS_InteractiveObject.hxx>
+#include <GeomAPI_Ax3.h>
+#include <Graphic3d_ArrayOfPoints.hxx>
+#include <Graphic3d_AspectMarker3d.hxx>
+#include <Image_AlienPixMap.hxx>
+
+#include <Standard_DefineHandle.hxx>
+#include <map>
+
+class SketchPlugin_Constraint;
+
+
+DEFINE_STANDARD_HANDLE(SketcherPrs_SymbolPrs, AIS_InteractiveObject)
+
+/**
+* \ingroup GUI
+* A base class of constraint presentation which is represented by an icon
+*/
+class SketcherPrs_SymbolPrs: public AIS_InteractiveObject
+{
+public:
+  /// Constructor
+  /// \param theConstraint a constraint feature
+  /// \param thePlane a coordinate plane of current sketch
+  SketcherPrs_SymbolPrs(SketchPlugin_Constraint* theConstraint, 
+                        const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+
+  //! Method which clear all selected owners belonging
+  //! to this selectable object ( for fast presentation draw )
+  Standard_EXPORT virtual void ClearSelected();
+
+  DEFINE_STANDARD_RTTI(SketcherPrs_SymbolPrs)
+
+protected:
+  /// Returns an icon file name. Has to be redefined in successors
+  virtual const char* iconName() const = 0;
+
+  /// Check and creates if it is necessary myAspect member.
+  /// It has to be called before the object computation
+  virtual void prepareAspect();
+
+  /// Returns icon corresponded to the current constraint type
+  Handle(Image_AlienPixMap) icon();
+
+  /// Add a line into the given group
+  /// \param theGroup a group for drawing
+  /// \param theAttrName an attribute name which corresponds to referenced line
+  void addLine(const Handle(Graphic3d_Group)& theGroup, std::string theAttrName) const;
+
+protected:
+  /// Constraint feature
+  SketchPlugin_Constraint* myConstraint;
+
+  /// Plane of the current sketcher
+  std::shared_ptr<GeomAPI_Ax3> myPlane;
+
+  /// Aspect for entities drawing
+  Handle(Graphic3d_AspectMarker3d) myAspect;
+
+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/perpendicular.png b/src/SketcherPrs/icons/perpendicular.png
new file mode 100644 (file)
index 0000000..8f64a9f
Binary files /dev/null and b/src/SketcherPrs/icons/perpendicular.png differ