void PartSet_Module::onNoMoreWidgets()
{
ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
- if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) {
- if (anOperation) {
+ if (anOperation) {
+ if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) {
if (myRestartingMode != RM_Forbided)
myRestartingMode = RM_LastFeatureUsed;
anOperation->commit();
#include <SketchPlugin_ConstraintPerpendicular.h>
#include <SketchPlugin_ConstraintRadius.h>
#include <SketchPlugin_ConstraintRigid.h>
+#include <SketchPlugin_ConstraintHorizontal.h>
+#include <SketchPlugin_ConstraintVertical.h>
+#include <SketchPlugin_ConstraintEqual.h>
#include <SelectMgr_IndexedMapOfOwner.hxx>
#include <StdSelect_BRepOwner.hxx>
aIds << SketchPlugin_ConstraintRadius::ID().c_str();
aIds << SketchPlugin_ConstraintPerpendicular::ID().c_str();
aIds << SketchPlugin_ConstraintParallel::ID().c_str();
+ aIds << SketchPlugin_ConstraintHorizontal::ID().c_str();
+ aIds << SketchPlugin_ConstraintVertical::ID().c_str();
+ aIds << SketchPlugin_ConstraintEqual::ID().c_str();
}
return aIds;
}
<file>icons/fixed.png</file>
<file>icons/placement.png</file>
<file>icons/geom_export.png</file>
+ <file>icons/horisontal.png</file>
+ <file>icons/vertical.png</file>
</qresource>
</RCC>
return thePrevious;
AISObjectPtr anAIS = thePrevious;
- /// TODO: Horizontal constraint presentation should be put here
+ if (!anAIS) {
+ anAIS = SketcherPrs_Factory::horisontalConstraint(this, sketch()->coordinatePlane());
+ }
return anAIS;
}
return thePrevious;
AISObjectPtr anAIS = thePrevious;
- /// TODO: Horizontal constraint presentation should be put here
+ if (!anAIS) {
+ anAIS = SketcherPrs_Factory::verticalConstraint(this, sketch()->coordinatePlane());
+ }
return anAIS;
}
<validator id="PartSet_RigidValidator"/>
</feature>
<!-- SketchConstraintHorizontal -->
- <feature id="SketchConstraintHorizontal" title="Horizontal" tooltip="Create constraint defining horizontal line">
+ <feature id="SketchConstraintHorizontal" title="Horizontal" tooltip="Create constraint defining horizontal line" icon=":icons/horisontal.png">
<sketch_constraint_shape_selector id="ConstraintEntityA"
label="Line" tooltip="Select a line" shape_types="edge">
<selection_filter id="EdgeFilter" parameters="line"/>
</sketch_constraint_shape_selector>
</feature>
<!-- SketchConstraintVertical -->
- <feature id="SketchConstraintVertical" title="Vertical" tooltip="Create constraint defining vertical line">
+ <feature id="SketchConstraintVertical" title="Vertical" tooltip="Create constraint defining vertical line" icon=":icons/vertical.png">
<sketch_constraint_shape_selector id="ConstraintEntityA"
label="Line" tooltip="Select a line" shape_types="edge">
<selection_filter id="EdgeFilter" parameters="line"/>
SketcherPrs_SymbolPrs.h
SketcherPrs_PositionMgr.h
SketcherPrs_Rigid.h
+ SketcherPrs_HVDirection.h
)
SET(PROJECT_SOURCES
SketcherPrs_SymbolPrs.cpp
SketcherPrs_PositionMgr.cpp
SketcherPrs_Rigid.cpp
+ SketcherPrs_HVDirection.cpp
)
SET(PROJECT_LIBRARIES
icons/parallel.png
icons/perpendicular.png
icons/anchor.png
+ icons/horisontal.png
+ icons/vertical.png
)
ADD_DEFINITIONS(-DCONSTRAINTS_EXPORTS ${CAS_DEFINITIONS})
#include <SketcherPrs_Parallel.h>
#include <SketcherPrs_Perpendicular.h>
#include <SketcherPrs_Rigid.h>
+#include <SketcherPrs_HVDirection.h>
#define CONSTRAINT_PRS_IMPL(NAME, CLASS) \
AISObjectPtr SketcherPrs_Factory::NAME(SketchPlugin_Constraint* theConstraint, \
CONSTRAINT_PRS_IMPL(parallelConstraint, SketcherPrs_Parallel);
CONSTRAINT_PRS_IMPL(perpendicularConstraint, SketcherPrs_Perpendicular);
CONSTRAINT_PRS_IMPL(rigidConstraint, SketcherPrs_Rigid)
+
+
+AISObjectPtr SketcherPrs_Factory::horisontalConstraint(SketchPlugin_Constraint* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+{
+ std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+ Handle(SketcherPrs_HVDirection) aPrs = new SketcherPrs_HVDirection(theConstraint, thePlane, true);
+ aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs));
+ return aAISObj;
+}
+
+AISObjectPtr SketcherPrs_Factory::verticalConstraint(SketchPlugin_Constraint* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+{
+ std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+ Handle(SketcherPrs_HVDirection) aPrs = new SketcherPrs_HVDirection(theConstraint, thePlane, false);
+ aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs));
+ return aAISObj;
+}
/// \param theConstraint the constraint
/// \param thePlane the current sketch plane
GET_CONSTRAINT_PRS(rigidConstraint)
+
+ /// Creates coincedent perpendicular presentation
+ /// \param theConstraint the constraint
+ /// \param thePlane the current sketch plane
+ GET_CONSTRAINT_PRS(horisontalConstraint)
+
+ /// Creates coincedent perpendicular presentation
+ /// \param theConstraint the constraint
+ /// \param thePlane the current sketch plane
+ GET_CONSTRAINT_PRS(verticalConstraint)
};
#endif
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: SketcherPrs_HVDirection.cpp
+// Created: 16 February 2015
+// Author: Vitaly SMETANNIKOV
+
+#include "SketcherPrs_HVDirection.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_HVDirection, SketcherPrs_SymbolPrs);
+IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_HVDirection, SketcherPrs_SymbolPrs);
+
+static Handle(Image_AlienPixMap) MyPixMap;
+
+SketcherPrs_HVDirection::SketcherPrs_HVDirection(SketchPlugin_Constraint* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane,
+ bool isHorisontal)
+ : SketcherPrs_SymbolPrs(theConstraint, thePlane), myIsHorisontal(isHorisontal)
+{
+ myPntArray = new Graphic3d_ArrayOfPoints(1);
+ myPntArray->AddVertex(0., 0., 0.);
+}
+
+void SketcherPrs_HVDirection::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());
+ std::shared_ptr<GeomAPI_Shape> aLine1 = SketcherPrs_Tools::getLine(aObj1);
+ if (aLine1.get() == NULL)
+ return;
+
+ SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
+ gp_Pnt aP1 = aMgr->getPosition(aObj1, this);
+
+ Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
+ aGroup->SetPrimitivesAspect(myAspect);
+ myPntArray->SetVertice(1, aP1);
+ aGroup->AddPrimitiveArray(myPntArray);
+}
+
+void SketcherPrs_HVDirection::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());
+}
+
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: SketcherPrs_HVDirection.h
+// Created: 16 February 2015
+// Author: Vitaly SMETANNIKOV
+
+#ifndef SketcherPrs_HVDirection_H
+#define SketcherPrs_HVDirection_H
+
+#include "SketcherPrs_SymbolPrs.h"
+
+class SketchPlugin_Constraint;
+class SketchPlugin_Sketch;
+
+
+DEFINE_STANDARD_HANDLE(SketcherPrs_HVDirection, SketcherPrs_SymbolPrs)
+
+/**
+* \ingroup GUI
+* A redefinition of standard AIS Interactive Object in order to provide
+* presentation of parallel constraint
+*/
+class SketcherPrs_HVDirection: public SketcherPrs_SymbolPrs
+{
+public:
+ /// Constructor
+ /// \param theConstraint a constraint feature
+ /// \param thePlane a coordinate plane of current sketch
+ Standard_EXPORT SketcherPrs_HVDirection(SketchPlugin_Constraint* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane,
+ bool isHorisontal);
+
+ DEFINE_STANDARD_RTTI(SketcherPrs_HVDirection)
+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 myIsHorisontal? "horisontal.png" : "vertical.png"; }
+
+ /// Redefine this function in order to add additiona lines of constraint base
+ /// \param thePrs a presentation
+ /// \param theColor a color of additiona lines
+ virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const;
+
+private:
+ bool myIsHorisontal;
+};
+
+#endif
\ No newline at end of file