#include <SketchPlugin_ConstraintHorizontal.h>
#include <SketchPlugin_ConstraintVertical.h>
#include <SketchPlugin_ConstraintEqual.h>
+#include <SketchPlugin_ConstraintTangent.h>
#include <SelectMgr_IndexedMapOfOwner.hxx>
#include <StdSelect_BRepOwner.hxx>
aIds << SketchPlugin_ConstraintHorizontal::ID().c_str();
aIds << SketchPlugin_ConstraintVertical::ID().c_str();
aIds << SketchPlugin_ConstraintEqual::ID().c_str();
+ aIds << SketchPlugin_ConstraintTangent::ID().c_str();
}
return aIds;
}
<file>icons/horisontal.png</file>
<file>icons/vertical.png</file>
<file>icons/equal.png</file>
+ <file>icons/tangent.png</file>
</qresource>
</RCC>
return thePrevious;
AISObjectPtr anAIS = thePrevious;
- /// TODO: Tangency constraint presentation should be put here
+ if (!anAIS) {
+ anAIS = SketcherPrs_Factory::tangentConstraint(this, sketch()->coordinatePlane());
+ }
return anAIS;
}
</sketch_constraint_shape_selector>
</feature>
<!-- SketchConstraintTangent -->
- <feature id="SketchConstraintTangent" title="Tangent" tooltip="Create constraint defining tangency of two objects">
+ <feature id="SketchConstraintTangent" title="Tangent" tooltip="Create constraint defining tangency of two objects" icon=":icons/tangent.png">
<sketch_constraint_shape_selector id="ConstraintEntityA"
label="First object" tooltip="Select line or arc" shape_types="edge">
</sketch_constraint_shape_selector>
SketcherPrs_Rigid.h
SketcherPrs_HVDirection.h
SketcherPrs_Equal.h
+ SketcherPrs_Tangent.h
)
SET(PROJECT_SOURCES
SketcherPrs_Rigid.cpp
SketcherPrs_HVDirection.cpp
SketcherPrs_Equal.cpp
+ SketcherPrs_Tangent.cpp
)
SET(PROJECT_LIBRARIES
icons/horisontal.png
icons/vertical.png
icons/equal.png
+ icons/tangent.png
)
ADD_DEFINITIONS(-DCONSTRAINTS_EXPORTS ${CAS_DEFINITIONS})
#include <SelectMgr_EntityOwner.hxx>
-extern std::shared_ptr<GeomAPI_Pnt2d> getFeaturePoint(DataPtr theData,
- const std::string& theAttribute);
-
IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Equal, SketcherPrs_SymbolPrs);
IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Equal, SketcherPrs_SymbolPrs);
#include "SketcherPrs_Rigid.h"
#include "SketcherPrs_HVDirection.h"
#include "SketcherPrs_Equal.h"
+#include "SketcherPrs_Tangent.h"
#define CONSTRAINT_PRS_IMPL(NAME, CLASS) \
AISObjectPtr SketcherPrs_Factory::NAME(SketchPlugin_Constraint* theConstraint, \
CONSTRAINT_PRS_IMPL(perpendicularConstraint, SketcherPrs_Perpendicular);
CONSTRAINT_PRS_IMPL(rigidConstraint, SketcherPrs_Rigid);
CONSTRAINT_PRS_IMPL(equalConstraint, SketcherPrs_Equal);
+CONSTRAINT_PRS_IMPL(tangentConstraint, SketcherPrs_Tangent);
AISObjectPtr SketcherPrs_Factory::horisontalConstraint(SketchPlugin_Constraint* theConstraint,
/// \param theConstraint the constraint
/// \param thePlane the current sketch plane
GET_CONSTRAINT_PRS(equalConstraint)
+
+ /// Creates coincedent perpendicular presentation
+ /// \param theConstraint the constraint
+ /// \param thePlane the current sketch plane
+ GET_CONSTRAINT_PRS(tangentConstraint)
};
#endif
#include <SelectMgr_EntityOwner.hxx>
-extern std::shared_ptr<GeomAPI_Pnt2d> getFeaturePoint(DataPtr theData,
- const std::string& theAttribute);
-
IMPLEMENT_STANDARD_HANDLE(SketcherPrs_HVDirection, SketcherPrs_SymbolPrs);
IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_HVDirection, SketcherPrs_SymbolPrs);
#include <SelectMgr_EntityOwner.hxx>
-extern std::shared_ptr<GeomAPI_Pnt2d> getFeaturePoint(DataPtr theData,
- const std::string& theAttribute);
-
IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Parallel, SketcherPrs_SymbolPrs);
IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Parallel, SketcherPrs_SymbolPrs);
#include <Graphic3d_ArrayOfSegments.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);
#include <Geom_CartesianPoint.hxx>
-extern std::shared_ptr<GeomAPI_Pnt2d> getFeaturePoint(DataPtr theData,
- const std::string& theAttribute);
-
IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Rigid, SketcherPrs_SymbolPrs);
IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Rigid, SketcherPrs_SymbolPrs);
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: SketcherPrs_Tangent.cpp
+// Created: 16 February 2015
+// Author: Vitaly SMETANNIKOV
+
+#include "SketcherPrs_Tangent.h"
+#include "SketcherPrs_Tools.h"
+#include "SketcherPrs_PositionMgr.h"
+
+#include <GeomAPI_Pnt.h>
+
+#include <SketchPlugin_Constraint.h>
+
+#include <AIS_Drawer.hxx>
+#include <gp_Pnt2d.hxx>
+
+#include <Prs3d_PointAspect.hxx>
+#include <Prs3d_Root.hxx>
+#include <Prs3d_LineAspect.hxx>
+
+#include <Graphic3d_MarkerImage.hxx>
+#include <Graphic3d_AspectMarker3d.hxx>
+#include <Graphic3d_AspectLine3d.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
+
+#include <Select3D_SensitivePoint.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+
+#include <SelectMgr_SequenceOfOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+
+
+
+IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Tangent, SketcherPrs_SymbolPrs);
+IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Tangent, SketcherPrs_SymbolPrs);
+
+static Handle(Image_AlienPixMap) MyPixMap;
+
+SketcherPrs_Tangent::SketcherPrs_Tangent(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_Tangent::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+ const Handle(Prs3d_Presentation)& thePresentation,
+ const Standard_Integer theMode)
+{
+ prepareAspect();
+
+ ObjectPtr aObj1 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
+ ObjectPtr aObj2 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B());
+
+ std::shared_ptr<GeomAPI_Shape> aLine1 = SketcherPrs_Tools::getShape(aObj1);
+ if (aLine1.get() == NULL)
+ return;
+
+ std::shared_ptr<GeomAPI_Shape> aLine2 = SketcherPrs_Tools::getShape(aObj2);
+ if (aLine2.get() == NULL)
+ return;
+
+ SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
+ gp_Pnt aP1 = aMgr->getPosition(aObj1, this);
+ gp_Pnt aP2 = aMgr->getPosition(aObj2, this);
+
+ Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
+ aGroup->SetPrimitivesAspect(myAspect);
+ myPntArray->SetVertice(1, aP1);
+ myPntArray->SetVertice(2, aP2);
+ aGroup->AddPrimitiveArray(myPntArray);
+}
+
+void SketcherPrs_Tangent::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());
+}
+
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: SketcherPrs_Tangent.h
+// Created: 16 February 2015
+// Author: Vitaly SMETANNIKOV
+
+#ifndef SketcherPrs_Tangent_H
+#define SketcherPrs_Tangent_H
+
+#include "SketcherPrs_SymbolPrs.h"
+
+class SketchPlugin_Constraint;
+class SketchPlugin_Sketch;
+
+
+DEFINE_STANDARD_HANDLE(SketcherPrs_Tangent, SketcherPrs_SymbolPrs)
+
+/**
+* \ingroup GUI
+* A redefinition of standard AIS Interactive Object in order to provide
+* presentation of tangent constraint
+*/
+class SketcherPrs_Tangent: public SketcherPrs_SymbolPrs
+{
+public:
+ /// Constructor
+ /// \param theConstraint a constraint feature
+ /// \param thePlane a coordinate plane of current sketch
+ Standard_EXPORT SketcherPrs_Tangent(SketchPlugin_Constraint* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+ DEFINE_STANDARD_RTTI(SketcherPrs_Tangent)
+protected:
+ /// Redefinition of virtual function
+ Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+ const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
+
+ virtual const char* iconName() const { return "tangent.png"; }
+
+ virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const;
+};
+
+#endif
\ No newline at end of file