if (!sketch())
return thePrevious;
- AISObjectPtr anAIS = SketcherPrs_Factory::angleConstraint(this, sketch()->coordinatePlane(),
+ AISObjectPtr anAIS = SketcherPrs_Factory::angleConstraint(this, sketch(),
thePrevious);
return anAIS;
}
return thePrevious;
AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this,
- sketch()->coordinatePlane(),
+ sketch(),
thePrevious);
return anAIS;
}
return thePrevious;
AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this,
- sketch()->coordinatePlane(),
+ sketch(),
thePrevious);
return anAIS;
}
return thePrevious;
AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this,
- sketch()->coordinatePlane(), thePrevious);
+ sketch(), thePrevious);
return anAIS;
}
if (!sketch())
return thePrevious;
- AISObjectPtr anAIS = SketcherPrs_Factory::radiusConstraint(this, sketch()->coordinatePlane(),
+ AISObjectPtr anAIS = SketcherPrs_Factory::radiusConstraint(this, sketch(),
thePrevious);
return anAIS;
}
IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Angle, AIS_AngleDimension);
SketcherPrs_Angle::SketcherPrs_Angle(ModelAPI_Feature* theConstraint,
- const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+ SketchPlugin_Sketch* theSketcher)
: AIS_AngleDimension(gp_Pnt(0,0,0), gp_Pnt(1,0,0), gp_Pnt(0,1,0)), myConstraint(theConstraint),
- mySketcherPlane(thePlane),
+ mySketcher(theSketcher),
myFirstPoint(gp_Pnt(0,0,0)), myCenterPoint(gp_Pnt(1,0,0)), mySecondPoint(gp_Pnt(0,1,0)),
myValue(90., false, ""), myFlyOutPoint(0, 0.5, 0)
{
const Standard_Integer theMode)
{
gp_Pnt aFirstPoint, aSecondPoint, aCenterPoint;
- bool aReadyToDisplay = readyToDisplay(myConstraint, mySketcherPlane,
+ bool aReadyToDisplay = readyToDisplay(myConstraint, plane(),
aFirstPoint, aSecondPoint, aCenterPoint);
if (aReadyToDisplay) {
myFirstPoint = aFirstPoint;
std::dynamic_pointer_cast<GeomDataAPI_Point2D>
(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
std::shared_ptr<GeomAPI_Pnt> aFlyoutPnt =
- mySketcherPlane->to3D(aFlyoutAttr->x(), aFlyoutAttr->y());
+ plane()->to3D(aFlyoutAttr->x(), aFlyoutAttr->y());
myFlyOutPoint = aFlyoutPnt->impl<gp_Pnt>();
}
bool SketcherPrs_Angle::isAnglePlaneReversedToSketchPlane()
{
bool aReversed = false;
- if (!mySketcherPlane.get())
+ if (!plane().get())
return aReversed;
gp_Pln aPlane = GetPlane();
gp_Dir aDir = aPlane.Axis().Direction();
- double aDot = mySketcherPlane->normal()->dot(
+ double aDot = plane()->normal()->dot(
std::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z())));
return aDot < 0;
}
#include <GeomAPI_Ax3.h>
#include <ModelAPI_Feature.h>
+#include <SketchPlugin_Sketch.h>
#include <AIS_AngleDimension.hxx>
#include <Standard_DefineHandle.hxx>
/// \param theConstraint a constraint feature
/// \param thePlane a coordinate plane of current sketch
Standard_EXPORT SketcherPrs_Angle(ModelAPI_Feature* theConstraint,
- const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+ SketchPlugin_Sketch* theSketcher);
/// Destructor
Standard_EXPORT ~SketcherPrs_Angle();
/// \return boolean result value
static bool IsReadyToDisplay(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+
+ /// Returns sketcher plane
+ Standard_EXPORT std::shared_ptr<GeomAPI_Ax3> plane() const
+ {
+ return mySketcher->coordinatePlane();
+ }
+
protected:
/// Redefinition of virtual function
Standard_EXPORT virtual void Compute(
/// Constraint feature
ModelAPI_Feature* myConstraint;
- /// Plane of the current sketcher
- std::shared_ptr<GeomAPI_Ax3> mySketcherPlane;
+ /// A current sketcher
+ SketchPlugin_Sketch* mySketcher;
Handle(Prs3d_DimensionAspect) myAspect;
CONSTRAINT_PRS_IMPL(middleConstraint, SketcherPrs_Middle);
CONSTRAINT_PRS_IMPL(mirrorConstraint, SketcherPrs_Mirror);
CONSTRAINT_PRS_IMPL(coincidentConstraint, SketcherPrs_Coincident);
-
-
-
-#define CONSTRAINT2_PRS_IMPL(NAME, CLASS) \
-AISObjectPtr SketcherPrs_Factory::NAME(ModelAPI_Feature* theConstraint, \
- const std::shared_ptr<GeomAPI_Ax3>& thePlane, \
- AISObjectPtr thePrevious) \
-{ \
- std::shared_ptr<GeomAPI_AISObject> anAISObj; \
- if (CLASS::IsReadyToDisplay(theConstraint, thePlane)) { \
- if (thePrevious.get()) \
- anAISObj = thePrevious; \
- else { \
- anAISObj = AISObjectPtr(new GeomAPI_AISObject()); \
- Handle(CLASS) aPrs = new CLASS(theConstraint, thePlane); \
- anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); \
- } \
- } \
- return anAISObj; \
-}
-
-
-CONSTRAINT2_PRS_IMPL(angleConstraint, SketcherPrs_Angle);
-CONSTRAINT2_PRS_IMPL(radiusConstraint, SketcherPrs_Radius);
-CONSTRAINT2_PRS_IMPL(lengthDimensionConstraint, SketcherPrs_LengthDimension);
+CONSTRAINT_PRS_IMPL(lengthDimensionConstraint, SketcherPrs_LengthDimension);
+CONSTRAINT_PRS_IMPL(angleConstraint, SketcherPrs_Angle);
+CONSTRAINT_PRS_IMPL(radiusConstraint, SketcherPrs_Radius);
// Non-standard constraints definition
AISObjectPtr SketcherPrs_Factory::horisontalConstraint(ModelAPI_Feature* theConstraint,
/// \param thePrevious the previous presentation
GET_CONSTRAINT_PRS(coincidentConstraint)
-#define GET_CONSTRAINT2_PRS(NAME) \
- static AISObjectPtr NAME(ModelAPI_Feature* theConstraint, \
- const std::shared_ptr<GeomAPI_Ax3>& thePlane, \
- AISObjectPtr thePrevious);
-
- /// Creates angle constraint presentation
+ /// Creates length dimension presentation
/// \param theConstraint the constraint
/// \param thePlane the current sketch plane
/// \param thePrevious the previous presentation
- GET_CONSTRAINT2_PRS(angleConstraint)
+ GET_CONSTRAINT_PRS(lengthDimensionConstraint)
- /// Creates length dimension presentation
+ /// Creates angle constraint presentation
/// \param theConstraint the constraint
/// \param thePlane the current sketch plane
/// \param thePrevious the previous presentation
- GET_CONSTRAINT2_PRS(lengthDimensionConstraint)
+ GET_CONSTRAINT_PRS(angleConstraint)
/// Creates radius dimension presentation
/// \param theConstraint the constraint
/// \param thePlane the current sketch plane
/// \param thePrevious the previous presentation
- GET_CONSTRAINT2_PRS(radiusConstraint)
+ GET_CONSTRAINT_PRS(radiusConstraint)
};
#endif
IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_LengthDimension, AIS_LengthDimension);
SketcherPrs_LengthDimension::SketcherPrs_LengthDimension(ModelAPI_Feature* theConstraint,
- const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+ SketchPlugin_Sketch* theSketcher)
: AIS_LengthDimension(MyDefStart, MyDefEnd, MyDefPln),
myConstraint(theConstraint),
- mySketcherPlane(thePlane),
+ mySketcher(theSketcher),
myFirstPoint(MyDefStart),
mySecondPoint(MyDefEnd),
myPlane(MyDefPln),
#ifdef OCCT_28850_FIXED
if (theConstraint->getKind() == SketchPlugin_ConstraintDistanceHorizontal::ID())
- SetDirection(mySketcherPlane->dirX()->impl<gp_Dir>(), true);
+ SetDirection(plane()->dirX()->impl<gp_Dir>(), true);
else if (theConstraint->getKind() == SketchPlugin_ConstraintDistanceVertical::ID())
- SetDirection(mySketcherPlane->dirY()->impl<gp_Dir>(), true);
+ SetDirection(plane()->dirY()->impl<gp_Dir>(), true);
#endif
}
const Standard_Integer theMode)
{
gp_Pnt aPnt1, aPnt2;
- bool aReadyToDisplay = readyToDisplay(myConstraint, mySketcherPlane, aPnt1, aPnt2);
+ bool aReadyToDisplay = readyToDisplay(myConstraint, plane(), aPnt1, aPnt2);
if (aReadyToDisplay) {
myFirstPoint = aPnt1;
mySecondPoint = aPnt2;
myDistance = SketcherPrs_Tools::getFlyoutDistance(myConstraint);
- myPlane = gp_Pln(mySketcherPlane->impl<gp_Ax3>());
+ myPlane = gp_Pln(plane()->impl<gp_Ax3>());
DataPtr aData = myConstraint->data();
AttributeDoublePtr anAttributeValue;
#include <ModelAPI_Feature.h>
#include <AIS_LengthDimension.hxx>
#include <Standard_DefineHandle.hxx>
+#include <SketchPlugin_Sketch.h>
#include <gp_Pnt.hxx>
#include <gp_Pln.hxx>
/// \param theConstraint a constraint feature
/// \param thePlane a coordinate plane of current sketch
Standard_EXPORT SketcherPrs_LengthDimension(ModelAPI_Feature* theConstraint,
- const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+ SketchPlugin_Sketch* theSketcher);
/// Destructor
Standard_EXPORT ~SketcherPrs_LengthDimension();
/// \return boolean result value
static bool IsReadyToDisplay(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+
+ /// Returns sketcher plane
+ Standard_EXPORT std::shared_ptr<GeomAPI_Ax3> plane() const
+ {
+ return mySketcher->coordinatePlane();
+ }
+
protected:
/// Redefinition of virtual function
Standard_EXPORT virtual void Compute(
/// Constraint feature
ModelAPI_Feature* myConstraint;
- /// Plane of the current sketcher
- std::shared_ptr<GeomAPI_Ax3> mySketcherPlane;
+ /// A current sketcher
+ SketchPlugin_Sketch* mySketcher;
//Handle(Prs3d_DimensionAspect) myAspect;
IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Radius, AIS_RadiusDimension);
SketcherPrs_Radius::SketcherPrs_Radius(ModelAPI_Feature* theConstraint,
- const std::shared_ptr<GeomAPI_Ax3>& thePlane)
-: AIS_RadiusDimension(MyDefCirc), myConstraint(theConstraint), mySketcherPlane(thePlane),
+ SketchPlugin_Sketch* theSketcher)
+: AIS_RadiusDimension(MyDefCirc), myConstraint(theConstraint), mySketcher(theSketcher),
myCircle(MyDefCirc),
myAnchorPoint(gp_Pnt(0, 0, 2)),
myValue(1, false, "")
{
gp_Circ aCircle;
gp_Pnt anAnchorPoint;
- bool aReadyToDisplay = readyToDisplay(myConstraint, mySketcherPlane, aCircle, anAnchorPoint);
+ bool aReadyToDisplay = readyToDisplay(myConstraint, plane(), aCircle, anAnchorPoint);
if (aReadyToDisplay) {
myCircle = aCircle;
myAnchorPoint = anAnchorPoint;
#include <GeomAPI_Ax3.h>
#include <ModelAPI_Feature.h>
+#include <SketchPlugin_Sketch.h>
#include <AIS_RadiusDimension.hxx>
#include <Standard_DefineHandle.hxx>
/// \param theConstraint a constraint feature
/// \param thePlane a coordinate plane of current sketch
Standard_EXPORT SketcherPrs_Radius(ModelAPI_Feature* theConstraint,
- const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+ SketchPlugin_Sketch* theSketcher);
/// Destructor
Standard_EXPORT ~SketcherPrs_Radius();
/// \return boolean result value
static bool IsReadyToDisplay(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+
+ /// Returns sketcher plane
+ Standard_EXPORT std::shared_ptr<GeomAPI_Ax3> plane() const
+ {
+ return mySketcher->coordinatePlane();
+ }
+
private:
/// Fills the constraint parameters by constraint and plane
/// \param theConstraint a constraint feature
/// Constraint feature
ModelAPI_Feature* myConstraint;
- /// Plane of the current sketcher
- std::shared_ptr<GeomAPI_Ax3> mySketcherPlane;
+ /// A current sketcher
+ SketchPlugin_Sketch* mySketcher;
/// Listener to update dimension visualization style
SketcherPrs_DimensionStyleListener* myStyleListener;
const Handle(SelectMgr_EntityOwner)& theOwner);
/// Returns sketcher plane
- Standard_EXPORT std::shared_ptr<GeomAPI_Ax3> plane() const { return mySketcher->coordinatePlane(); }
+ Standard_EXPORT std::shared_ptr<GeomAPI_Ax3> plane() const
+ {
+ return mySketcher->coordinatePlane();
+ }
/// Returns feature object
Standard_EXPORT ModelAPI_Feature* feature() const { return myConstraint; }