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)
GeomAPI_DataMapOfShapeShape.h
GeomAPI_ICustomPrs.h
GeomAPI_Vertex.h
+ GeomAPI_Ax3.h
)
SET(PROJECT_SOURCES
GeomAPI_DataMapOfShapeShape.cpp
GeomAPI_Vertex.cpp
GeomAPI_ICustomPrs.cpp
+ GeomAPI_Ax3.cpp
)
SET(PROJECT_LIBRARIES
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);
--- /dev/null
+// 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
--- /dev/null
+// 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
}
bool GeomAPI_PlanarEdges::hasPlane() const {
- return myOrigin && myNorm && myDirX && myDirY;
+ return myPlane.get() != NULL;
}
bool GeomAPI_PlanarEdges::isVertex() 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
#include "GeomAPI_Edge.h"
#include "GeomAPI_Pnt.h"
#include "GeomAPI_Dir.h"
+#include "GeomAPI_Ax3.h"
#include <memory>
/// 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
GeomAPI
GeomAlgoAPI
ModelAPI
+ SketcherPrs
${CAS_KERNEL}
${CAS_SHAPE}
)
../GeomAPI
../GeomAlgoAPI
../GeomDataAPI
+ ../SketcherPrs
)
INSTALL(TARGETS SketchPlugin DESTINATION plugins)
#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()
{
{
}
+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
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();
// 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>
{
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()
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);
-}
/// 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();
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);
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<
#include <GeomAPI_Pnt.h>
#include <GeomAPI_Pln.h>
#include <GeomAPI_IPresentable.h>
+#include <GeomAPI_Ax3.h>
#include <list>
#define YZ_PLANE_COLOR "#ff0000"
SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY)
{
}
- ;
/// Return the distance between the feature and the point
/// \param thePoint the point
{
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);
/// 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
<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 -->
--- /dev/null
+## 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)
--- /dev/null
+// 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
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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
--- /dev/null
+// 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
--- /dev/null
+// 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
--- /dev/null
+// 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);
+}
+
--- /dev/null
+// 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
--- /dev/null
+// 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
--- /dev/null
+// 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