<file>icons/geom_export.png</file>
<file>icons/horisontal.png</file>
<file>icons/vertical.png</file>
+ <file>icons/equal.png</file>
</qresource>
</RCC>
return thePrevious;
AISObjectPtr anAIS = thePrevious;
- /// TODO: Equal constraint presentation should be put here
+ if (!anAIS) {
+ anAIS = SketcherPrs_Factory::equalConstraint(this, sketch()->coordinatePlane());
+ }
return anAIS;
}
</sketch_constraint_shape_selector>
</feature>
<!-- SketchConstraintEqual -->
- <feature id="SketchConstraintEqual" title="Equal" tooltip="Create constraint defining equality of two objects">
+ <feature id="SketchConstraintEqual" title="Equal" tooltip="Create constraint defining equality of two objects" icon=":icons/equal.png">
<sketch_constraint_shape_selector id="ConstraintEntityA"
label="First object" tooltip="Select line, circle or arc" shape_types="edge">
</sketch_constraint_shape_selector>
SketcherPrs_PositionMgr.h
SketcherPrs_Rigid.h
SketcherPrs_HVDirection.h
+ SketcherPrs_Equal.h
)
SET(PROJECT_SOURCES
SketcherPrs_PositionMgr.cpp
SketcherPrs_Rigid.cpp
SketcherPrs_HVDirection.cpp
+ SketcherPrs_Equal.cpp
)
SET(PROJECT_LIBRARIES
icons/anchor.png
icons/horisontal.png
icons/vertical.png
+ icons/equal.png
)
ADD_DEFINITIONS(-DCONSTRAINTS_EXPORTS ${CAS_DEFINITIONS})
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: SketcherPrs_Equal.cpp
+// Created: 16 February 2015
+// Author: Vitaly SMETANNIKOV
+
+#include "SketcherPrs_Equal.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>
+
+
+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);
+
+static Handle(Image_AlienPixMap) MyPixMap;
+
+SketcherPrs_Equal::SketcherPrs_Equal(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_Equal::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_Equal::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_Equal.h
+// Created: 16 February 2015
+// Author: Vitaly SMETANNIKOV
+
+#ifndef SketcherPrs_Equal_H
+#define SketcherPrs_Equal_H
+
+#include "SketcherPrs_SymbolPrs.h"
+
+class SketchPlugin_Constraint;
+class SketchPlugin_Sketch;
+
+
+DEFINE_STANDARD_HANDLE(SketcherPrs_Equal, SketcherPrs_SymbolPrs)
+
+/**
+* \ingroup GUI
+* A redefinition of standard AIS Interactive Object in order to provide
+* presentation of Equal constraint
+*/
+class SketcherPrs_Equal: public SketcherPrs_SymbolPrs
+{
+public:
+ /// Constructor
+ /// \param theConstraint a constraint feature
+ /// \param thePlane a coordinate plane of current sketch
+ Standard_EXPORT SketcherPrs_Equal(SketchPlugin_Constraint* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+ DEFINE_STANDARD_RTTI(SketcherPrs_Equal)
+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 "equal.png"; }
+
+ virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const;
+};
+
+#endif
\ No newline at end of file
#include "SketcherPrs_Factory.h"
-#include <SketcherPrs_Coincident.h>
-#include <SketcherPrs_Parallel.h>
-#include <SketcherPrs_Perpendicular.h>
-#include <SketcherPrs_Rigid.h>
-#include <SketcherPrs_HVDirection.h>
+#include "SketcherPrs_Coincident.h"
+#include "SketcherPrs_Parallel.h"
+#include "SketcherPrs_Perpendicular.h"
+#include "SketcherPrs_Rigid.h"
+#include "SketcherPrs_HVDirection.h"
+#include "SketcherPrs_Equal.h"
#define CONSTRAINT_PRS_IMPL(NAME, CLASS) \
AISObjectPtr SketcherPrs_Factory::NAME(SketchPlugin_Constraint* theConstraint, \
CONSTRAINT_PRS_IMPL(coincidentConstraint, SketcherPrs_Coincident);
CONSTRAINT_PRS_IMPL(parallelConstraint, SketcherPrs_Parallel);
CONSTRAINT_PRS_IMPL(perpendicularConstraint, SketcherPrs_Perpendicular);
-CONSTRAINT_PRS_IMPL(rigidConstraint, SketcherPrs_Rigid)
+CONSTRAINT_PRS_IMPL(rigidConstraint, SketcherPrs_Rigid);
+CONSTRAINT_PRS_IMPL(equalConstraint, SketcherPrs_Equal);
AISObjectPtr SketcherPrs_Factory::horisontalConstraint(SketchPlugin_Constraint* theConstraint,
/// \param theConstraint the constraint
/// \param thePlane the current sketch plane
GET_CONSTRAINT_PRS(verticalConstraint)
+
+ /// Creates coincedent perpendicular presentation
+ /// \param theConstraint the constraint
+ /// \param thePlane the current sketch plane
+ GET_CONSTRAINT_PRS(equalConstraint)
};
#endif