Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
authornds <natalia.donis@opencascade.com>
Wed, 11 Mar 2015 14:42:38 +0000 (17:42 +0300)
committernds <natalia.donis@opencascade.com>
Wed, 11 Mar 2015 14:42:38 +0000 (17:42 +0300)
26 files changed:
CMakeLists.txt
src/GeomAPI/CMakeLists.txt
src/GeomAPI/GeomAPI_AISObject.cpp
src/GeomAPI/GeomAPI_Ax3.cpp [new file with mode: 0644]
src/GeomAPI/GeomAPI_Ax3.h [new file with mode: 0644]
src/GeomAPI/GeomAPI_PlanarEdges.cpp
src/GeomAPI/GeomAPI_PlanarEdges.h
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp
src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h
src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp
src/SketchPlugin/SketchPlugin_ConstraintParallel.h
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h
src/SketchPlugin/plugin-Sketch.xml
src/SketcherPrs/CMakeLists.txt [new file with mode: 0644]
src/SketcherPrs/SketcherPrs.h [new file with mode: 0644]
src/SketcherPrs/SketcherPrs_Coincident.cpp [new file with mode: 0644]
src/SketcherPrs/SketcherPrs_Coincident.h [new file with mode: 0644]
src/SketcherPrs/SketcherPrs_Factory.cpp [new file with mode: 0644]
src/SketcherPrs/SketcherPrs_Factory.h [new file with mode: 0644]
src/SketcherPrs/SketcherPrs_Parallel.cpp [new file with mode: 0644]
src/SketcherPrs/SketcherPrs_Parallel.h [new file with mode: 0644]
src/SketcherPrs/SketcherPrs_Tools.cpp [new file with mode: 0644]
src/SketcherPrs/SketcherPrs_Tools.h [new file with mode: 0644]
src/SketcherPrs/icons/parallel.png [new file with mode: 0644]

index 895c8e8ed9e47cf473dae443216b49ee69493319..8406c7645f9741309ac3644da6618d2156c0fdc4 100644 (file)
@@ -54,6 +54,7 @@ ADD_SUBDIRECTORY (src/GeomDataAPI)
 ADD_SUBDIRECTORY (src/PartSetPlugin)
 ADD_SUBDIRECTORY (src/ConstructionPlugin)
 ADD_SUBDIRECTORY (src/FeaturesPlugin)
+ADD_SUBDIRECTORY (src/SketcherPrs)
 ADD_SUBDIRECTORY (src/SketchPlugin)
 ADD_SUBDIRECTORY (src/SketchSolver)
 ADD_SUBDIRECTORY (src/ModuleBase)
index ef0f5b1a97f453f5828c6242dce9486e1416f858..e1726ca506616a4d427fcf096c58dc212fc1c1db 100644 (file)
@@ -29,6 +29,7 @@ SET(PROJECT_HEADERS
     GeomAPI_DataMapOfShapeShape.h
     GeomAPI_ICustomPrs.h
     GeomAPI_Vertex.h
+       GeomAPI_Ax3.h
 )
 
 SET(PROJECT_SOURCES
@@ -53,6 +54,7 @@ SET(PROJECT_SOURCES
     GeomAPI_DataMapOfShapeShape.cpp
     GeomAPI_Vertex.cpp
     GeomAPI_ICustomPrs.cpp
+       GeomAPI_Ax3.cpp
 )
 
 SET(PROJECT_LIBRARIES
index fb90ceccb6d06672058670f36bc40dc4b5d9a287..f4ae420490bada6d8d4b177459ba93c67198fb94 100644 (file)
@@ -98,9 +98,9 @@ void GeomAPI_AISObject::createDistance(std::shared_ptr<GeomAPI_Pnt> theStartPoin
 
     Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
     anAspect->MakeArrows3d(Standard_False);
-    anAspect->MakeText3d(false);
+    anAspect->MakeText3d(Standard_False);
     anAspect->TextAspect()->SetHeight(CONSTRAINT_TEXT_HEIGHT);
-    anAspect->MakeTextShaded(false);
+    anAspect->MakeTextShaded(Standard_True);
     anAspect->ArrowAspect()->SetLength(theDistance / 10.);
     aDimAIS->DimensionAspect()->MakeUnitsDisplayed(false);
     aDimAIS->SetDimensionAspect(anAspect);
diff --git a/src/GeomAPI/GeomAPI_Ax3.cpp b/src/GeomAPI/GeomAPI_Ax3.cpp
new file mode 100644 (file)
index 0000000..d7950b5
--- /dev/null
@@ -0,0 +1,107 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomAPI_Ax3.cpp
+// Created:     16 February 2015
+// Author:      Vitaly SMETANNIKOV
+
+
+#include "GeomAPI_Ax3.h"
+#include "GeomAPI_XYZ.h"
+#include "GeomAPI_Pnt2d.h"
+
+#include <gp_Dir.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Ax3.hxx>
+#include <Precision.hxx>
+
+
+#define MY_AX3 static_cast<gp_Ax3*>(myImpl)
+
+
+GeomAPI_Ax3::GeomAPI_Ax3()
+: GeomAPI_Interface(new gp_Ax3())
+{
+}
+
+GeomAPI_Ax3::GeomAPI_Ax3(std::shared_ptr<GeomAPI_Pnt> theOrigin,
+                         std::shared_ptr<GeomAPI_Dir> theDirX,
+                         std::shared_ptr<GeomAPI_Dir> theDirY,
+                         std::shared_ptr<GeomAPI_Dir> theNorm)
+: GeomAPI_Interface(new gp_Ax3(theOrigin->impl<gp_Pnt>(), 
+                               theNorm->impl<gp_Dir>(), 
+                               theDirX->impl<gp_Dir>()))
+ {
+   MY_AX3->SetYDirection(theDirY->impl<gp_Dir>());
+ }
+
+void GeomAPI_Ax3::setOrigin(const std::shared_ptr<GeomAPI_Pnt>& theOrigin)
+{
+  gp_Ax1 aAx1 = MY_AX3->Axis();
+  aAx1.SetLocation(theOrigin->impl<gp_Pnt>());
+  MY_AX3->SetAxis(aAx1);
+}
+
+std::shared_ptr<GeomAPI_Pnt> GeomAPI_Ax3::origin() const
+{
+  gp_Pnt aPnt = MY_AX3->Axis().Location();
+  return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aPnt.X(),aPnt.Y(),aPnt.Z()));
+}
+
+void GeomAPI_Ax3::setDirX(const std::shared_ptr<GeomAPI_Dir>& theDirX)
+{
+  MY_AX3->SetXDirection(theDirX->impl<gp_Dir>());
+}
+
+std::shared_ptr<GeomAPI_Dir> GeomAPI_Ax3::dirX() const
+{
+  gp_Dir aDir = MY_AX3->XDirection();
+  return std::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
+}
+
+void GeomAPI_Ax3::setDirY(const std::shared_ptr<GeomAPI_Dir>& theDirY)
+{
+  MY_AX3->SetYDirection(theDirY->impl<gp_Dir>());
+}
+
+std::shared_ptr<GeomAPI_Dir> GeomAPI_Ax3::dirY() const
+{
+  gp_Dir aDir = MY_AX3->YDirection();
+  return std::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
+}
+
+void GeomAPI_Ax3::setNorm(const std::shared_ptr<GeomAPI_Dir>& theNorm)
+{
+  gp_Ax1 aAx1 = MY_AX3->Axis();
+  aAx1.SetDirection(theNorm->impl<gp_Dir>());
+  MY_AX3->SetAxis(aAx1);
+}
+
+std::shared_ptr<GeomAPI_Dir> GeomAPI_Ax3::norm() const
+{
+  gp_Dir aDir = MY_AX3->Axis().Direction();
+  return std::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(aDir.X(),aDir.Y(),aDir.Z()));
+}
+
+
+std::shared_ptr<GeomAPI_Pnt> GeomAPI_Ax3::to3D(double theX, double theY) const
+{
+  gp_Pnt aPnt = MY_AX3->Axis().Location();
+  gp_Dir aXDir = MY_AX3->XDirection();
+  gp_Dir aYDir = MY_AX3->YDirection();
+  gp_XYZ aSum = aPnt.XYZ().Added(aXDir.XYZ().Multiplied(theX)).Added(aYDir.XYZ().Multiplied(theY));
+
+  return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aSum.X(), aSum.Y(), aSum.Z()));
+}
+
+std::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Ax3::to2D(double theX, double theY, double theZ) const
+{
+  gp_Pnt anOriginPnt = MY_AX3->Axis().Location();
+  gp_Vec aVec(anOriginPnt, gp_Pnt(0, 0, 0));
+
+  gp_Dir aXDir = MY_AX3->XDirection();
+  gp_Dir aYDir = MY_AX3->YDirection();
+
+  double aX = aVec.X() * aXDir.X() + aVec.Y() * aXDir.Y() + aVec.Z() * aXDir.Z();
+  double aY = aVec.X() * aYDir.X() + aVec.Y() * aYDir.Y() + aVec.Z() * aYDir.Y();
+  return std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, aY));
+}
\ No newline at end of file
diff --git a/src/GeomAPI/GeomAPI_Ax3.h b/src/GeomAPI/GeomAPI_Ax3.h
new file mode 100644 (file)
index 0000000..67bde43
--- /dev/null
@@ -0,0 +1,73 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomAPI_Ax3.hxx
+// Created:     16 February 2015
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef GEOMAPI_AX3_H_
+#define GEOMAPI_AX3_H_
+
+#include "GeomAPI.h"
+#include "GeomAPI_Pnt.h"
+#include "GeomAPI_Dir.h"
+
+/**
+ * \ingroup DataModel
+ * \brief The class represents a coordinate plane which is 2d plane with X and Y directions
+ * and origin
+ */ 
+class GEOMAPI_EXPORT GeomAPI_Ax3 : public GeomAPI_Interface
+{
+public:
+  /// Default constructor
+  GeomAPI_Ax3();
+
+  /// Ñonstructor
+  /// \param theOrigin point of origin
+  /// \param theDirX direction of X axis
+  /// \param theDirY direction of Y axis
+  /// \param theNorm direction of normal vector
+  GeomAPI_Ax3(std::shared_ptr<GeomAPI_Pnt> theOrigin,
+              std::shared_ptr<GeomAPI_Dir> theDirX,
+              std::shared_ptr<GeomAPI_Dir> theDirY,
+              std::shared_ptr<GeomAPI_Dir> theNorm);
+
+  /// Sets origin point
+  void setOrigin(const std::shared_ptr<GeomAPI_Pnt>& theOrigin);
+
+  /// Returns the plane origin point
+  std::shared_ptr<GeomAPI_Pnt> origin() const;
+
+  /// Sets X direction vector
+  void setDirX(const std::shared_ptr<GeomAPI_Dir>& theDirX);
+
+  /// Returns X direction vector
+  std::shared_ptr<GeomAPI_Dir> dirX() const;
+
+  /// Sets Y direction vector
+  void setDirY(const std::shared_ptr<GeomAPI_Dir>& theDirY);
+
+  /// Returns Y direction vector
+  std::shared_ptr<GeomAPI_Dir> dirY() const;
+
+  /// Sets Z direction vector
+  void setNorm(const std::shared_ptr<GeomAPI_Dir>& theNorm);
+
+  /// Returns Z direction vector
+  std::shared_ptr<GeomAPI_Dir> norm() const;
+
+  /// Converts 2d coordinates from the plane to 3d space point
+  /// \param theX X coordinate
+  /// \param theY Y coordinate
+  std::shared_ptr<GeomAPI_Pnt> to3D(double theX, double theY) const;
+
+  /// Converts 3d  to 2d coordinates of the plane
+  /// \param theX X coordinate
+  /// \param theY Y coordinate
+  /// \param theZ Z coordinate
+  std::shared_ptr<GeomAPI_Pnt2d> to2D(double theX, double theY, double theZ) const;
+
+};
+
+
+#endif
\ No newline at end of file
index 53470fb5e55d09aa3c21ee1fc2baa012a0f3b625..f7757cf7e94b7b32a3ad5f0a23067ece92cd4381 100644 (file)
@@ -52,7 +52,7 @@ std::list<std::shared_ptr<GeomAPI_Shape> > GeomAPI_PlanarEdges::getEdges()
 }
 
 bool GeomAPI_PlanarEdges::hasPlane() const {
-  return myOrigin && myNorm && myDirX && myDirY;
+  return myPlane.get() != NULL;
 }
 
 bool GeomAPI_PlanarEdges::isVertex() const {
@@ -63,28 +63,38 @@ bool GeomAPI_PlanarEdges::isEdge() const {
   return false;
 }
 
-void GeomAPI_PlanarEdges::setOrigin(const std::shared_ptr<GeomAPI_Pnt>& theOrigin)
+std::shared_ptr<GeomAPI_Pnt> GeomAPI_PlanarEdges::origin() const 
 {
-  myOrigin = theOrigin;
+  if (hasPlane())
+    return myPlane->origin();
+  return std::shared_ptr<GeomAPI_Pnt>();
 }
-std::shared_ptr<GeomAPI_Pnt> GeomAPI_PlanarEdges::origin() const {
-  return myOrigin;
-}
-void GeomAPI_PlanarEdges::setDirX(const std::shared_ptr<GeomAPI_Dir>& theDirX) {
-  myDirX = theDirX;
-}
-std::shared_ptr<GeomAPI_Dir> GeomAPI_PlanarEdges::dirX() const {
-  return myDirX;
-}
-void GeomAPI_PlanarEdges::setDirY(const std::shared_ptr<GeomAPI_Dir>& theDirY) {
-  myDirY = theDirY;
-}
-std::shared_ptr<GeomAPI_Dir> GeomAPI_PlanarEdges::dirY() const {
-  return myDirY;
+
+std::shared_ptr<GeomAPI_Dir> GeomAPI_PlanarEdges::dirX() const 
+{
+  if (hasPlane())
+    return myPlane->dirX();
+  return std::shared_ptr<GeomAPI_Dir>();
 }
-void GeomAPI_PlanarEdges::setNorm(const std::shared_ptr<GeomAPI_Dir>& theNorm) {
-  myNorm = theNorm;
+
+std::shared_ptr<GeomAPI_Dir> GeomAPI_PlanarEdges::dirY() const 
+{
+  if (hasPlane())
+    return myPlane->dirY();
+  return std::shared_ptr<GeomAPI_Dir>();
 }
-std::shared_ptr<GeomAPI_Dir> GeomAPI_PlanarEdges::norm() const {
-  return myNorm;
+
+std::shared_ptr<GeomAPI_Dir> GeomAPI_PlanarEdges::norm() const 
+{
+  if (hasPlane())
+    return myPlane->norm();
+  return std::shared_ptr<GeomAPI_Dir>();
 }
+
+void GeomAPI_PlanarEdges::setPlane(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
+                                   const std::shared_ptr<GeomAPI_Dir>& theDirX,
+                                   const std::shared_ptr<GeomAPI_Dir>& theDirY,
+                                   const std::shared_ptr<GeomAPI_Dir>& theNorm)
+{
+  myPlane = std::shared_ptr<GeomAPI_Ax3>(new GeomAPI_Ax3(theOrigin, theDirX, theDirY, theNorm));
+}
\ No newline at end of file
index 627bc5d719cfded780ee8c181ba13a29d18103c2..1eddd16c899ca9bb59c39d39eb34a33eafe47820 100644 (file)
@@ -11,6 +11,7 @@
 #include "GeomAPI_Edge.h"
 #include "GeomAPI_Pnt.h"
 #include "GeomAPI_Dir.h"
+#include "GeomAPI_Ax3.h"
 
 #include <memory>
 
@@ -41,36 +42,31 @@ class GeomAPI_PlanarEdges : public GeomAPI_Shape
   /// Returns True if the wire is defined in a plane
   GEOMAPI_EXPORT bool hasPlane() const;
 
-  /// Sets origin point
-  GEOMAPI_EXPORT void setOrigin(const std::shared_ptr<GeomAPI_Pnt>& theOrigin);
-
   /// Returns the plane origin point
   GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Pnt> origin() const;
 
-  /// Sets X direction vector
-  GEOMAPI_EXPORT void setDirX(const std::shared_ptr<GeomAPI_Dir>& theDirX);
   /// Returns X direction vector
   GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Dir> dirX() const;
 
-  /// Sets Y direction vector
-  GEOMAPI_EXPORT void setDirY(const std::shared_ptr<GeomAPI_Dir>& theDirY);
   /// Returns Y direction vector
   GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Dir> dirY() const;
 
-  /// Sets Z direction vector
-  GEOMAPI_EXPORT void setNorm(const std::shared_ptr<GeomAPI_Dir>& theNorm);
   /// Returns Z direction vector
   GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Dir> norm() const;
 
+  /// Set working plane
+  /// \param theOrigin origin of the plane axis
+  /// \param theDirX X direction of the plane axis
+  /// \param theDirY Y direction of the plane axis
+  /// \param theNorm normal direction of the plane axis
+  GEOMAPI_EXPORT void setPlane(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
+                               const std::shared_ptr<GeomAPI_Dir>& theDirX,
+                               const std::shared_ptr<GeomAPI_Dir>& theDirY,
+                               const std::shared_ptr<GeomAPI_Dir>& theNorm);
+
 private:
-  /// Origin point of the plane
-  std::shared_ptr<GeomAPI_Pnt> myOrigin;
-  /// The X direction inside of the plane
-  std::shared_ptr<GeomAPI_Dir> myDirX;
-  /// The Y direction inside of the plane
-  std::shared_ptr<GeomAPI_Dir> myDirY;
-  /// The normal direction to the plane
-  std::shared_ptr<GeomAPI_Dir> myNorm;
+
+  std::shared_ptr<GeomAPI_Ax3> myPlane;
 };
 
 #endif
index d4efeee6c8c472a835e077d5d809ca171bf5c333..01c640568d5617ede4b48ae4725b6f6af098850f 100644 (file)
@@ -54,6 +54,7 @@ SET(PROJECT_LIBRARIES
     GeomAPI
     GeomAlgoAPI
     ModelAPI
+    SketcherPrs
     ${CAS_KERNEL}
     ${CAS_SHAPE}
 )
@@ -73,6 +74,7 @@ INCLUDE_DIRECTORIES(
   ../GeomAPI
   ../GeomAlgoAPI
   ../GeomDataAPI
+  ../SketcherPrs
 )
 
 INSTALL(TARGETS SketchPlugin DESTINATION plugins)
index 15f6d1cccfc0844d7e55f573fa3994e588d47781..358158325fc9b4da8f49f9a60ca6efae1e14a66c 100644 (file)
@@ -6,9 +6,13 @@
 
 #include "SketchPlugin_ConstraintCoincidence.h"
 
+#include <SketcherPrs_Factory.h>
+
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_Data.h>
 #include <SketchPlugin_Point.h>
+#include <GeomDataAPI_Dir.h>
+#include <GeomDataAPI_Point.h>
 
 SketchPlugin_ConstraintCoincidence::SketchPlugin_ConstraintCoincidence()
 {
@@ -24,3 +28,15 @@ void SketchPlugin_ConstraintCoincidence::execute()
 {
 }
 
+AISObjectPtr SketchPlugin_ConstraintCoincidence::getAISObject(AISObjectPtr thePrevious)
+{
+  if (!sketch())
+    return thePrevious;
+
+  AISObjectPtr anAIS = thePrevious;
+  if (!anAIS) {
+    anAIS = SketcherPrs_Factory::coincidentConstraint(this, sketch()->coordinatePlane());
+    anAIS->setColor(0, 0, 255);
+  }
+  return anAIS;
+}
\ No newline at end of file
index ce1939f7689a024ccc08847117c7e22486c0a737..c3f359d73bcc52b51177bcdaf8637b77f7490fe3 100644 (file)
@@ -35,6 +35,9 @@ class SketchPlugin_ConstraintCoincidence : public SketchPlugin_ConstraintBase
     return MY_KIND;
   }
 
+  /// Returns the AIS preview
+  SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
+
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
 
index ae26fc1c2d41218454c5c7432032e4be0a8b0947..29a7f0a25c1c6da37e19c10a514b0ad0ee9687ff 100644 (file)
@@ -5,7 +5,6 @@
 // Author:  Artem ZHIDKOV
 
 #include "SketchPlugin_ConstraintParallel.h"
-#include "SketchPlugin_ConstraintPerpendicular.h"
 
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_Data.h>
 #include <SketchPlugin_Line.h>
 #include <SketchPlugin_Sketch.h>
 
+#include <SketcherPrs_Factory.h>
+
 #include <GeomDataAPI_Point2D.h>
 #include <GeomAPI_Pnt2d.h>
 #include <GeomAPI_Pnt.h>
+#include <GeomDataAPI_Dir.h>
+#include <GeomDataAPI_Point.h>
 
 #include <Config_PropManager.h>
 
@@ -28,7 +31,7 @@ void SketchPlugin_ConstraintParallel::initAttributes()
 {
   data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
   data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
-  data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
+  //data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
 }
 
 void SketchPlugin_ConstraintParallel::execute()
@@ -40,67 +43,11 @@ AISObjectPtr SketchPlugin_ConstraintParallel::getAISObject(AISObjectPtr thePrevi
   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();
-
-  std::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr = std::dynamic_pointer_cast<
-      GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
-  std::shared_ptr<GeomAPI_Pnt> aFlyoutPnt = std::shared_ptr<GeomAPI_Pnt>();;
-  if(aFlyoutAttr->isInitialized()) {
-    aFlyoutPnt = sketch()->to3D(aFlyoutAttr->x(), aFlyoutAttr->y());
-  }
-
   AISObjectPtr anAIS = thePrevious;
-  if (!anAIS)
-    anAIS = AISObjectPtr(new GeomAPI_AISObject);
-  anAIS->createParallel(aLine1, aLine2, aFlyoutPnt, aPlane);
-
-  // Set color from preferences
-  std::vector<int> aRGB = Config_PropManager::color("Visualization", "sketch_parallel_color",
-                                                    SKETCH_CONSTRAINT_COLOR);
-  anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
+  if (!anAIS) {
+    anAIS = SketcherPrs_Factory::parallelConstraint(this, sketch()->coordinatePlane());
+  }
   return anAIS;
 }
 
-void SketchPlugin_ConstraintParallel::move(double theDeltaX, double theDeltaY)
-{
-  std::shared_ptr<ModelAPI_Data> aData = data();
-  if (!aData->isValid())
-    return;
-
-  std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-      aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
-  aPoint->move(theDeltaX, theDeltaY);
-}
 
index 87f69fe70ee76b2506e25abe546325ef607856b4..afaae6c005bca6baaaabe05adf1d4b787c7e19a5 100644 (file)
@@ -46,7 +46,7 @@ class SketchPlugin_ConstraintParallel : public SketchPlugin_ConstraintBase
   /// 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);
+  //SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
 
   /// \brief Use plugin manager for features creation
   SketchPlugin_ConstraintParallel();
index c19e27114b2bb001425f78ae9f8b383f6031c5aa..58ab7cb98af9708399f88d172a257094dd8a7839 100644 (file)
@@ -117,10 +117,7 @@ void SketchPlugin_Sketch::execute()
   for (; aShapeIt != aFeaturesPreview.end(); ++aShapeIt) {
     aBigWire->addEdge(*aShapeIt);
   }
-  aBigWire->setOrigin(anOrigin->pnt());
-  aBigWire->setDirX(aDirX->dir());
-  aBigWire->setDirY(aDirY->dir());
-  aBigWire->setNorm(aNorm->dir());
+  aBigWire->setPlane(anOrigin->pnt(), aDirX->dir(), aDirY->dir(), aNorm->dir());
 
 //  GeomAlgoAPI_SketchBuilder::createFaces(anOrigin->pnt(), aDirX->dir(), aDirY->dir(), aNorm->dir(),
 //                                         aFeaturesPreview, aLoops, aWires);
@@ -246,6 +243,21 @@ std::shared_ptr<GeomAPI_Pln> SketchPlugin_Sketch::plane()
   return std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(anOrigin->pnt(), aNorm->dir()));
 }
 
+std::shared_ptr<GeomAPI_Ax3> SketchPlugin_Sketch::coordinatePlane() const
+{
+  DataPtr aData = data();
+  std::shared_ptr<GeomDataAPI_Point> aC = std::dynamic_pointer_cast<GeomDataAPI_Point>(
+    aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+  std::shared_ptr<GeomDataAPI_Dir> aX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+    aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
+  std::shared_ptr<GeomDataAPI_Dir> aY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+    aData->attribute(SketchPlugin_Sketch::DIRY_ID()));
+  std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+    aData->attribute(SketchPlugin_Sketch::NORM_ID()));
+
+  return std::shared_ptr<GeomAPI_Ax3>(new GeomAPI_Ax3(aC->pnt(), aX->dir(), aY->dir(), aNorm->dir()));
+}
+
 void SketchPlugin_Sketch::erase()
 {
   std::shared_ptr<ModelAPI_AttributeRefList> aRefList = std::dynamic_pointer_cast<
index c4721f547bfb114dbd7d50a0f6d9c948d3d4b966..43a6e370792dc38e1d020ee6808fe739d6b5e04f 100644 (file)
@@ -12,6 +12,7 @@
 #include <GeomAPI_Pnt.h>
 #include <GeomAPI_Pln.h>
 #include <GeomAPI_IPresentable.h>
+#include <GeomAPI_Ax3.h>
 #include <list>
 
 #define YZ_PLANE_COLOR "#ff0000"
@@ -81,7 +82,6 @@ class SketchPlugin_Sketch : public ModelAPI_CompositeFeature//, public GeomAPI_I
   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY)
   {
   }
-  ;
 
   /// Return the distance between the feature and the point
   /// \param thePoint the point
@@ -89,7 +89,6 @@ class SketchPlugin_Sketch : public ModelAPI_CompositeFeature//, public GeomAPI_I
   {
     return 0;
   }
-  ;
 
   /// Converts a 2D sketch space point into point in 3D space
   SKETCHPLUGIN_EXPORT std::shared_ptr<GeomAPI_Pnt> to3D(const double theX, const double theY);
@@ -106,6 +105,8 @@ class SketchPlugin_Sketch : public ModelAPI_CompositeFeature//, public GeomAPI_I
   /// Returns the basis plane for the sketch
   std::shared_ptr<GeomAPI_Pln> plane();
 
+  SKETCHPLUGIN_EXPORT std::shared_ptr<GeomAPI_Ax3> coordinatePlane() const;
+
   //virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
 
   /// removes also all sub-sketch elements
index 7ca945676eb3f8c45354faa4d3f9545264a49612..3875aa213b0b802f92030f0f09dc56edcacb113e 100644 (file)
             <validator id="SketchPlugin_ShapeValidator" parameters="ConstraintEntityA"/>
         </sketch_constraint_shape_selector>
         
-        <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" internal="1" obligatory="0"/>
         <validator id="PartSet_ParallelValidator"/>
       </feature>
     <!--  SketchConstraintPerpendicular  -->
diff --git a/src/SketcherPrs/CMakeLists.txt b/src/SketcherPrs/CMakeLists.txt
new file mode 100644 (file)
index 0000000..fcb8889
--- /dev/null
@@ -0,0 +1,48 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+SET(PROJECT_HEADERS
+    SketcherPrs.h
+    SketcherPrs_Coincident.h
+    SketcherPrs_Factory.h
+       SketcherPrs_Parallel.h
+       SketcherPrs_Tools.h
+)
+
+SET(PROJECT_SOURCES
+    SketcherPrs_Coincident.cpp
+    SketcherPrs_Factory.cpp
+       SketcherPrs_Parallel.cpp
+       SketcherPrs_Tools.cpp
+)
+
+SET(PROJECT_LIBRARIES
+    Config
+    ModelAPI
+    GeomAPI
+    ${CAS_KERNEL} 
+    ${CAS_MODELER} 
+    ${CAS_VIEWER}
+    ${CAS_SHAPE}
+    ${CAS_TKTopAlgo}
+)
+
+SET(PROJECT_PICTURES
+    icons/parallel.png
+)
+
+ADD_DEFINITIONS(-DCONSTRAINTS_EXPORTS ${CAS_DEFINITIONS})
+ADD_LIBRARY(SketcherPrs SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+
+INCLUDE_DIRECTORIES(
+  ${PROJECT_SOURCE_DIR}/src/Config
+  ${PROJECT_SOURCE_DIR}/src/ModelAPI
+  ${PROJECT_SOURCE_DIR}/src/GeomAPI
+  ${PROJECT_SOURCE_DIR}/src/GeomDataAPI
+  ${PROJECT_SOURCE_DIR}/src/SketchPlugin
+  ${CAS_INCLUDE_DIRS}
+)
+
+TARGET_LINK_LIBRARIES(SketcherPrs ${PROJECT_LIBRARIES})
+
+INSTALL(TARGETS SketcherPrs DESTINATION bin)
+INSTALL(FILES ${PROJECT_PICTURES} DESTINATION resources)
diff --git a/src/SketcherPrs/SketcherPrs.h b/src/SketcherPrs/SketcherPrs.h
new file mode 100644 (file)
index 0000000..978f8c2
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#ifndef SKETCHERPRS_H
+#define SKETCHERPRS_H
+
+#if defined SKETCHERPRS_EXPORTS
+#if defined WIN32
+#define SKETCHERPRS_EXPORT   __declspec( dllexport )
+#else
+#define SKETCHERPRS_EXPORT
+#endif
+#else
+#if defined WIN32
+#define SKETCHERPRS_EXPORT   __declspec( dllimport )
+#else
+#define SKETCHERPRS_EXPORT
+#endif
+#endif
+
+#endif
diff --git a/src/SketcherPrs/SketcherPrs_Coincident.cpp b/src/SketcherPrs/SketcherPrs_Coincident.cpp
new file mode 100644 (file)
index 0000000..60c2e45
--- /dev/null
@@ -0,0 +1,78 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Coincident.cpp
+// Created:     12 February 2015
+// Author:      Vitaly SMETANNIKOV
+
+#include "SketcherPrs_Coincident.h"
+#include "SketcherPrs_Tools.h"
+
+#include <ModelAPI_AttributeRefAttr.h>
+#include <GeomDataAPI_Point2D.h>
+#include <GeomDataAPI_Dir.h>
+#include <GeomDataAPI_Point.h>
+
+#include <GeomAPI_XYZ.h>
+#include <GeomAPI_Dir.h>
+#include <GeomAPI_Pnt2d.h>
+
+#include <SketchPlugin_Point.h>
+#include <SketchPlugin_Circle.h>
+#include <SketchPlugin_Constraint.h>
+
+#include <AIS_Drawer.hxx>
+#include <Graphic3d_AspectMarker3d.hxx>
+#include <Graphic3d_ArrayOfPoints.hxx>
+#include <Prs3d_PointAspect.hxx>
+#include <Prs3d_Root.hxx>
+
+
+IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Coincident, AIS_InteractiveObject);
+IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Coincident, AIS_InteractiveObject);
+
+SketcherPrs_Coincident::SketcherPrs_Coincident(SketchPlugin_Constraint* theConstraint, 
+                                               const std::shared_ptr<GeomAPI_Ax3>& thePlane) 
+ : AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane)
+{
+}  
+
+
+
+void SketcherPrs_Coincident::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+                                   const Handle(Prs3d_Presentation)& thePresentation, 
+                                   const Standard_Integer theMode)
+{
+  std::shared_ptr<GeomAPI_Pnt2d> aPnt = SketcherPrs_Tools::getPoint(myConstraint, 
+                                                                    SketchPlugin_Constraint::ENTITY_A());
+  if (aPnt.get() == NULL)
+    return;
+
+  std::shared_ptr<GeomAPI_Pnt> aPoint = myPlane->to3D(aPnt->x(), aPnt->y());
+
+  static Handle(Graphic3d_AspectMarker3d) aPtA = new Graphic3d_AspectMarker3d ();
+  aPtA->SetType(Aspect_TOM_RING1);
+  aPtA->SetScale(2.);
+  aPtA->SetColor(myOwnColor);
+  Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
+  aGroup->SetPrimitivesAspect(aPtA);
+  Handle(Graphic3d_ArrayOfPoints) aPntArray = new Graphic3d_ArrayOfPoints(1);
+  aPntArray->AddVertex (aPoint->x(), aPoint->y(), aPoint->z());
+  aGroup->AddPrimitiveArray (aPntArray);
+}
+
+
+void SketcherPrs_Coincident::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+                                            const Standard_Integer aMode)
+{
+}
+
+void SketcherPrs_Coincident::SetColor(const Quantity_NameOfColor aCol)
+{
+  SetColor(Quantity_Color(aCol));
+}
+
+void SketcherPrs_Coincident::SetColor(const Quantity_Color &aCol)
+{
+  hasOwnColor=Standard_True;
+  myOwnColor=aCol;
+}
diff --git a/src/SketcherPrs/SketcherPrs_Coincident.h b/src/SketcherPrs/SketcherPrs_Coincident.h
new file mode 100644 (file)
index 0000000..9b9c4cd
--- /dev/null
@@ -0,0 +1,53 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Coincident.h
+// Created:     12 February 2015
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef SketcherPrs_Coincident_H
+#define SketcherPrs_Coincident_H
+
+#include <GeomAPI_Ax3.h>
+
+#include <AIS_InteractiveObject.hxx>
+#include <Standard_DefineHandle.hxx>
+
+class SketchPlugin_Constraint;
+
+
+DEFINE_STANDARD_HANDLE(SketcherPrs_Coincident, AIS_InteractiveObject)
+
+/**
+* \ingroup GUI
+* A redefinition of standard AIS Interactive Object in order to provide  
+* presentation of coincident constraint
+*/
+class SketcherPrs_Coincident: public AIS_InteractiveObject
+{
+public:
+  /// Constructor
+  /// \param theResult a result object
+  Standard_EXPORT SketcherPrs_Coincident(SketchPlugin_Constraint* theConstraint, 
+                                         const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+
+  Standard_EXPORT virtual void SetColor(const Quantity_Color& aColor);
+  
+  Standard_EXPORT virtual void SetColor(const Quantity_NameOfColor aColor);
+   
+  DEFINE_STANDARD_RTTI(SketcherPrs_Coincident)
+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) ;
+
+private:
+  SketchPlugin_Constraint* myConstraint;
+  std::shared_ptr<GeomAPI_Ax3> myPlane;
+};
+
+
+#endif
\ No newline at end of file
diff --git a/src/SketcherPrs/SketcherPrs_Factory.cpp b/src/SketcherPrs/SketcherPrs_Factory.cpp
new file mode 100644 (file)
index 0000000..829052f
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Factory.cpp
+// Created:     13 February 2015
+// Author:      Vitaly SMETANNIKOV
+
+#include "SketcherPrs_Factory.h"
+
+#include <SketcherPrs_Coincident.h>
+#include <SketcherPrs_Parallel.h>
+
+
+AISObjectPtr SketcherPrs_Factory::coincidentConstraint(SketchPlugin_Constraint* theConstraint, 
+                                                       const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+{
+  std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+  Handle(SketcherPrs_Coincident) aPrs = new SketcherPrs_Coincident(theConstraint, thePlane);
+  aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs));
+  return aAISObj;
+}
+
+
+AISObjectPtr SketcherPrs_Factory::parallelConstraint(SketchPlugin_Constraint* theConstraint, 
+                                                     const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+{
+  std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+  Handle(SketcherPrs_Parallel) aPrs = new SketcherPrs_Parallel(theConstraint, thePlane);
+  aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs));
+  return aAISObj;
+}
\ No newline at end of file
diff --git a/src/SketcherPrs/SketcherPrs_Factory.h b/src/SketcherPrs/SketcherPrs_Factory.h
new file mode 100644 (file)
index 0000000..75a496f
--- /dev/null
@@ -0,0 +1,36 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Factory.h
+// Created:     13 February 2015
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef SketcherPrs_Factory_H_
+#define SketcherPrs_Factory_H_
+
+#include "SketcherPrs.h"
+
+#include <GeomAPI_Ax3.h>
+#include <GeomAPI_AISObject.h>
+
+class SketchPlugin_Constraint;
+
+/**
+* Class which creates constraints presentations
+*/
+class SKETCHERPRS_EXPORT SketcherPrs_Factory
+{
+public:
+  /// Creates coincedent constraint presentation
+  /// \param theConstraint the constraint
+  /// \param thePlane the current sketch plane
+  static AISObjectPtr coincidentConstraint(SketchPlugin_Constraint* theConstraint, 
+                                           const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+
+  /// Creates coincedent parallel presentation
+  /// \param theConstraint the constraint
+  /// \param thePlane the current sketch plane
+  static AISObjectPtr parallelConstraint(SketchPlugin_Constraint* theConstraint, 
+                                         const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+};
+
+#endif
diff --git a/src/SketcherPrs/SketcherPrs_Parallel.cpp b/src/SketcherPrs/SketcherPrs_Parallel.cpp
new file mode 100644 (file)
index 0000000..74e9772
--- /dev/null
@@ -0,0 +1,124 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Parallel.cpp
+// Created:     16 February 2015
+// Author:      Vitaly SMETANNIKOV
+
+#include "SketcherPrs_Parallel.h"
+#include "SketcherPrs_Tools.h"
+
+#include <GeomAPI_Pnt.h>
+
+#include <SketchPlugin_Constraint.h>
+
+#include <AIS_Drawer.hxx>
+#include <Graphic3d_AspectMarker3d.hxx>
+#include <Prs3d_PointAspect.hxx>
+#include <Prs3d_Root.hxx>
+#include <gp_Pnt2d.hxx>
+#include <Image_AlienPixMap.hxx>
+#include <Graphic3d_MarkerImage.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <Select3D_SensitivePoint.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Select3D_SensitiveSegment.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);
+
+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)
+{
+  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.);
+  }
+}  
+
+void SketcherPrs_Parallel::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+                                   const Handle(Prs3d_Presentation)& thePresentation, 
+                                   const Standard_Integer theMode)
+{
+  if (myAspect.IsNull())
+    return;
+
+  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 = aVec1.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_Parallel::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+                                            const Standard_Integer aMode)
+{
+  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) eown = new SelectMgr_EntityOwner(this);
+  Handle(Select3D_SensitivePoint) aSP1 = new Select3D_SensitivePoint(eown, myPntArray->Vertice(1));
+  Handle(Select3D_SensitivePoint) aSP2 = new Select3D_SensitivePoint(eown, myPntArray->Vertice(2));
+  aSelection->Add(aSP1);
+  aSelection->Add(aSP2);
+}
+
diff --git a/src/SketcherPrs/SketcherPrs_Parallel.h b/src/SketcherPrs/SketcherPrs_Parallel.h
new file mode 100644 (file)
index 0000000..5e39abb
--- /dev/null
@@ -0,0 +1,56 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Parallel.h
+// Created:     16 February 2015
+// Author:      Vitaly SMETANNIKOV
+
+#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>
+
+class SketchPlugin_Constraint;
+class SketchPlugin_Sketch;
+
+
+DEFINE_STANDARD_HANDLE(SketcherPrs_Parallel, AIS_InteractiveObject)
+
+/**
+* \ingroup GUI
+* A redefinition of standard AIS Interactive Object in order to provide  
+* presentation of coincident constraint
+*/
+class SketcherPrs_Parallel: public AIS_InteractiveObject
+{
+public:
+  /// Constructor
+  /// \param theResult a result object
+  Standard_EXPORT SketcherPrs_Parallel(SketchPlugin_Constraint* theConstraint, 
+                                       const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+
+
+  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) ;
+
+private:
+
+  SketchPlugin_Constraint* myConstraint;
+  std::shared_ptr<GeomAPI_Ax3> myPlane;
+  Handle(Graphic3d_AspectMarker3d) myAspect;
+  Handle(Graphic3d_ArrayOfPoints) myPntArray;
+};
+
+#endif
\ No newline at end of file
diff --git a/src/SketcherPrs/SketcherPrs_Tools.cpp b/src/SketcherPrs/SketcherPrs_Tools.cpp
new file mode 100644 (file)
index 0000000..2f356e1
--- /dev/null
@@ -0,0 +1,69 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Tools.cpp
+// Created:     10 March 2015
+// Author:      Vitaly SMETANNIKOV
+
+#include "SketcherPrs_Tools.h"
+
+#include <SketchPlugin_Constraint.h>
+#include <SketchPlugin_Point.h>
+#include <SketchPlugin_Circle.h>
+#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_AttributeRefAttr.h>
+
+#include <GeomDataAPI_Point2D.h>
+
+
+namespace SketcherPrs_Tools {
+
+
+std::shared_ptr<GeomAPI_Edge> getLine(SketchPlugin_Constraint* theFeature,
+                                      const std::string& theAttrName)
+{
+  std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
+    std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(theAttrName));
+
+  ObjectPtr aObject = anAttr->object();
+  ResultConstructionPtr aRes = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aObject);
+  if (aRes.get() != NULL) {
+    std::shared_ptr<GeomAPI_Shape> aShape = aRes->shape();
+    if (aShape.get() != NULL) {   
+      return std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aShape));
+    }
+  }
+  return std::shared_ptr<GeomAPI_Edge>();
+}
+
+
+std::shared_ptr<GeomAPI_Pnt2d> getPoint(SketchPlugin_Constraint* theFeature,
+                                               const std::string& theAttribute)
+{
+  std::shared_ptr<GeomDataAPI_Point2D> aPointAttr;
+
+  if (!theFeature->data())
+    return std::shared_ptr<GeomAPI_Pnt2d>();
+
+  FeaturePtr aFeature;
+  std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = std::dynamic_pointer_cast<
+      ModelAPI_AttributeRefAttr>(theFeature->data()->attribute(theAttribute));
+  if (anAttr)
+    aFeature = ModelAPI_Feature::feature(anAttr->object());
+
+  if (aFeature && aFeature->getKind() == SketchPlugin_Point::ID())
+    aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+        aFeature->data()->attribute(SketchPlugin_Point::COORD_ID()));
+
+  else if (aFeature && aFeature->getKind() == SketchPlugin_Circle::ID())
+    aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+        aFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID()));
+
+  else if (anAttr->attr()) {
+    aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr->attr());
+  }
+  return aPointAttr->pnt();
+}
+
+
+};
\ No newline at end of file
diff --git a/src/SketcherPrs/SketcherPrs_Tools.h b/src/SketcherPrs/SketcherPrs_Tools.h
new file mode 100644 (file)
index 0000000..5a93295
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Tools.h
+// Created:     10 March 2015
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef SketcherPrs_Tools_H
+#define SketcherPrs_Tools_H
+
+#include "SketcherPrs.h"
+#include <GeomAPI_Edge.h>
+#include <GeomAPI_Pnt2d.h>
+#include <string>
+
+class SketchPlugin_Constraint;
+
+namespace SketcherPrs_Tools {
+
+  std::shared_ptr<GeomAPI_Edge> getLine(SketchPlugin_Constraint* theFeature,
+                                        const std::string& theAttrName);
+
+  std::shared_ptr<GeomAPI_Pnt2d> getPoint(SketchPlugin_Constraint* theFeature,
+                                          const std::string& theAttrName);
+
+};
+
+#endif
\ No newline at end of file
diff --git a/src/SketcherPrs/icons/parallel.png b/src/SketcherPrs/icons/parallel.png
new file mode 100644 (file)
index 0000000..4918612
Binary files /dev/null and b/src/SketcherPrs/icons/parallel.png differ