From 97c6d9faa9466aadd9c3c43489d5f68c888a7be2 Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 7 Apr 2015 15:35:54 +0300 Subject: [PATCH] Create mirror symbols --- src/PartSet/PartSet_Module.cpp | 16 ++- src/PartSet/PartSet_Validators.cpp | 66 +++++++++-- src/PartSet/PartSet_Validators.h | 46 ++++++-- src/PartSet/PartSet_icons.qrc | 1 + src/PartSet/icons/mirror.png | Bin 0 -> 422 bytes .../SketchPlugin_ConstraintMirror.cpp | 4 +- src/SketchPlugin/plugin-Sketch.xml | 18 +-- src/SketcherPrs/CMakeLists.txt | 3 + src/SketcherPrs/SketcherPrs_Equal.cpp | 13 ++- src/SketcherPrs/SketcherPrs_Factory.cpp | 2 + src/SketcherPrs/SketcherPrs_Factory.h | 5 + src/SketcherPrs/SketcherPrs_Mirror.cpp | 109 ++++++++++++++++++ src/SketcherPrs/SketcherPrs_Mirror.h | 39 +++++++ src/SketcherPrs/SketcherPrs_Rigid.cpp | 26 +---- src/SketcherPrs/SketcherPrs_SymbolPrs.cpp | 28 +++++ src/SketcherPrs/SketcherPrs_SymbolPrs.h | 4 + src/SketcherPrs/SketcherPrs_Tangent.cpp | 20 +--- src/SketcherPrs/SketcherPrs_Tools.cpp | 4 +- src/SketcherPrs/icons/mirror.png | Bin 0 -> 299 bytes 19 files changed, 329 insertions(+), 75 deletions(-) create mode 100644 src/PartSet/icons/mirror.png create mode 100644 src/SketcherPrs/SketcherPrs_Mirror.cpp create mode 100644 src/SketcherPrs/SketcherPrs_Mirror.h create mode 100644 src/SketcherPrs/icons/mirror.png diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 3d22b28a7..b33326687 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -130,12 +130,16 @@ void PartSet_Module::registerValidators() //Registering of validators SessionPtr aMgr = ModelAPI_Session::get(); ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); - aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator); - aFactory->registerValidator("PartSet_LengthValidator", new PartSet_LengthValidator); - aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator); - aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator); - aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator); - aFactory->registerValidator("PartSet_RigidValidator", new PartSet_RigidValidator); + aFactory->registerValidator("PartSet_DistanceSelection", new PartSet_DistanceSelection); + aFactory->registerValidator("PartSet_LengthSelection", new PartSet_LengthSelection); + aFactory->registerValidator("PartSet_PerpendicularSelection", new PartSet_PerpendicularSelection); + aFactory->registerValidator("PartSet_ParallelSelection", new PartSet_ParallelSelection); + aFactory->registerValidator("PartSet_RadiusSelection", new PartSet_RadiusSelection); + aFactory->registerValidator("PartSet_RigidSelection", new PartSet_RigidSelection); + aFactory->registerValidator("PartSet_CoincidentSelection", new PartSet_CoincidentSelection); + aFactory->registerValidator("PartSet_HVDirSelection", new PartSet_HVDirSelection); + aFactory->registerValidator("PartSet_TangentSelection", new PartSet_TangentSelection); + aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator); aFactory->registerValidator("PartSet_DifferentShapes", new ModelAPI_ShapeValidator); diff --git a/src/PartSet/PartSet_Validators.cpp b/src/PartSet/PartSet_Validators.cpp index 04bcb3663..2837ba7bf 100644 --- a/src/PartSet/PartSet_Validators.cpp +++ b/src/PartSet/PartSet_Validators.cpp @@ -63,31 +63,31 @@ int shapesNbLines(const ModuleBase_ISelection* theSelection) return aCount; } -bool PartSet_DistanceValidator::isValid(const ModuleBase_ISelection* theSelection) const +bool PartSet_DistanceSelection::isValid(const ModuleBase_ISelection* theSelection) const { int aCount = shapesNbPoints(theSelection) + shapesNbLines(theSelection); return (aCount > 0) && (aCount < 3); } -bool PartSet_LengthValidator::isValid(const ModuleBase_ISelection* theSelection) const +bool PartSet_LengthSelection::isValid(const ModuleBase_ISelection* theSelection) const { int aCount = shapesNbLines(theSelection); - return (aCount > 0) && (aCount < 2); + return (aCount == 1); } -bool PartSet_PerpendicularValidator::isValid(const ModuleBase_ISelection* theSelection) const +bool PartSet_PerpendicularSelection::isValid(const ModuleBase_ISelection* theSelection) const { int aCount = shapesNbLines(theSelection); return (aCount > 0) && (aCount < 3); } -bool PartSet_ParallelValidator::isValid(const ModuleBase_ISelection* theSelection) const +bool PartSet_ParallelSelection::isValid(const ModuleBase_ISelection* theSelection) const { int aCount = shapesNbLines(theSelection); return (aCount > 0) && (aCount < 3); } -bool PartSet_RadiusValidator::isValid(const ModuleBase_ISelection* theSelection) const +bool PartSet_RadiusSelection::isValid(const ModuleBase_ISelection* theSelection) const { QList aList = theSelection->getSelected(); ModuleBase_ViewerPrs aPrs; @@ -105,15 +105,63 @@ bool PartSet_RadiusValidator::isValid(const ModuleBase_ISelection* theSelection) } } } - return (aCount > 0) && (aCount < 2); + return (aCount == 1); } -bool PartSet_RigidValidator::isValid(const ModuleBase_ISelection* theSelection) const +bool PartSet_RigidSelection::isValid(const ModuleBase_ISelection* theSelection) const +{ + QList aList = theSelection->getSelected(); + return (aList.count() == 1); +} + + +bool PartSet_CoincidentSelection::isValid(const ModuleBase_ISelection* theSelection) const +{ + int aCount = shapesNbPoints(theSelection); + return (aCount > 0) && (aCount < 3); +} + +bool PartSet_HVDirSelection::isValid(const ModuleBase_ISelection* theSelection) const { int aCount = shapesNbLines(theSelection); - return (aCount > 0) && (aCount < 2); + return (aCount == 1); } +bool PartSet_TangentSelection::isValid(const ModuleBase_ISelection* theSelection) const +{ + QList aList = theSelection->getSelected(); + ModuleBase_ViewerPrs aPrs; + if (aList.size() != 2) + return false; + + ModuleBase_ViewerPrs aPrs1 = aList.first(); + ModuleBase_ViewerPrs aPrs2 = aList.last(); + + const TopoDS_Shape& aShape1 = aPrs1.shape(); + const TopoDS_Shape& aShape2 = aPrs2.shape(); + if (aShape1.IsNull() || aShape2.IsNull()) + return false; + + if ((aShape1.ShapeType() != TopAbs_EDGE) || (aShape2.ShapeType() != TopAbs_EDGE)) + return false; + + TopoDS_Edge aEdge1 = TopoDS::Edge(aShape1); + TopoDS_Edge aEdge2 = TopoDS::Edge(aShape2); + + Standard_Real aStart, aEnd; + Handle(Geom_Curve) aCurve1 = BRep_Tool::Curve(aEdge1, aStart, aEnd); + Handle(Geom_Curve) aCurve2 = BRep_Tool::Curve(aEdge2, aStart, aEnd); + + GeomAdaptor_Curve aAdaptor1(aCurve1); + GeomAdaptor_Curve aAdaptor2(aCurve2); + if (aAdaptor1.GetType() == GeomAbs_Circle) + return aAdaptor2.GetType() == GeomAbs_Line; + else if (aAdaptor2.GetType() == GeomAbs_Circle) + return aAdaptor1.GetType() == GeomAbs_Line; + return false; +} + + bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute, const std::list& theArguments) const { diff --git a/src/PartSet/PartSet_Validators.h b/src/PartSet/PartSet_Validators.h index 7a7f2333c..101bba5f9 100644 --- a/src/PartSet/PartSet_Validators.h +++ b/src/PartSet/PartSet_Validators.h @@ -19,7 +19,7 @@ //! \ingroup Validators //! A class to validate a selection for Distance constraint operation -class PartSet_DistanceValidator : public ModuleBase_SelectionValidator +class PartSet_DistanceSelection : public ModuleBase_SelectionValidator { public: PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const; @@ -27,7 +27,7 @@ class PartSet_DistanceValidator : public ModuleBase_SelectionValidator //! \ingroup Validators //! A class to validate a selection for Length constraint operation -class PartSet_LengthValidator : public ModuleBase_SelectionValidator +class PartSet_LengthSelection : public ModuleBase_SelectionValidator { public: PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const; @@ -35,36 +35,64 @@ class PartSet_LengthValidator : public ModuleBase_SelectionValidator //! \ingroup Validators //! A class to validate a selection for Perpendicular constraint operation -class PartSet_PerpendicularValidator : public ModuleBase_SelectionValidator +class PartSet_PerpendicularSelection : public ModuleBase_SelectionValidator { public: PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const; }; //! \ingroup Validators -//! A class to validate a selection for Perpendicular constraint operation -class PartSet_ParallelValidator : public ModuleBase_SelectionValidator +//! A class to validate a selection for Parallel constraint operation +class PartSet_ParallelSelection : public ModuleBase_SelectionValidator { public: PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const; }; //! \ingroup Validators -//! A class to validate a selection for Perpendicular constraint operation -class PartSet_RadiusValidator : public ModuleBase_SelectionValidator +//! A class to validate a selection for Radius constraint operation +class PartSet_RadiusSelection : public ModuleBase_SelectionValidator { public: PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const; }; //! \ingroup Validators -//! A class to validate a selection for Perpendicular constraint operation -class PartSet_RigidValidator : public ModuleBase_SelectionValidator +//! A class to validate a selection for Rigid constraint operation +class PartSet_RigidSelection : public ModuleBase_SelectionValidator +{ + public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const; +}; + + +//! \ingroup Validators +//! A class to validate a selection for coincedence constraint operation +class PartSet_CoincidentSelection : public ModuleBase_SelectionValidator +{ + public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const; +}; + +//! \ingroup Validators +//! A class to validate a selection for Horizontal and Vertical constraints operation +class PartSet_HVDirSelection : public ModuleBase_SelectionValidator +{ + public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const; +}; + +//! \ingroup Validators +//! A class to validate a selection for Tangential constraints operation +class PartSet_TangentSelection : public ModuleBase_SelectionValidator { public: PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const; }; +////////////// Attribute validators //////////////// + + /** * \ingroup Validators * A validator which checks that objects selected for feature attributes are different (not the same) diff --git a/src/PartSet/PartSet_icons.qrc b/src/PartSet/PartSet_icons.qrc index 62cefad48..b37f9e71a 100644 --- a/src/PartSet/PartSet_icons.qrc +++ b/src/PartSet/PartSet_icons.qrc @@ -36,5 +36,6 @@ icons/tangent.png icons/fillet.png icons/coincedence.png + icons/mirror.png diff --git a/src/PartSet/icons/mirror.png b/src/PartSet/icons/mirror.png new file mode 100644 index 0000000000000000000000000000000000000000..1c12a711557f2f3a5f414dcce27d60df9b6793e6 GIT binary patch literal 422 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL5ULAh?3y^w370~qEv>0#LT=By}Z;C1rt33 zJ=4@yqg0@w;+`&!Ar}6vlXmAGb`WsMJk2Cw5csTNX6xz$tOg;HU98g{=*2W}7YOP( zEaWOUaA2c$#Mw7zWh+&D^*@ySKHMOclbXi8DnWlZd;ipfJ=Z5qTynYQE)h;l0ZLv#_Kdk3JE55Y+oPuvM>+68Q O$l&Sf=d#Wzp$PyNl&G}; literal 0 HcmV?d00001 diff --git a/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp b/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp index fd765dec9..f28a09516 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp @@ -187,7 +187,9 @@ AISObjectPtr SketchPlugin_ConstraintMirror::getAISObject(AISObjectPtr thePreviou return thePrevious; AISObjectPtr anAIS = thePrevious; - /// TODO: Equal constraint presentation should be put here + if (!anAIS) { + anAIS = SketcherPrs_Factory::mirrorConstraint(this, sketch()->coordinatePlane()); + } return anAIS; } diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index f2bce5f32..b7ccc6f99 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -71,7 +71,7 @@ - + @@ -85,7 +85,7 @@ - + @@ -97,7 +97,7 @@ - + @@ -114,7 +114,7 @@ - + @@ -135,7 +135,7 @@ - + @@ -144,6 +144,7 @@ + @@ -153,7 +154,7 @@ - + @@ -162,6 +163,7 @@ label="Line" tooltip="Select a line" shape_types="edge"> + @@ -170,6 +172,7 @@ label="Line" tooltip="Select a line" shape_types="edge"> + @@ -197,12 +200,13 @@ label="Last object" tooltip="Select line or arc" shape_types="edge"> + diff --git a/src/SketcherPrs/CMakeLists.txt b/src/SketcherPrs/CMakeLists.txt index be597690d..963c7e542 100644 --- a/src/SketcherPrs/CMakeLists.txt +++ b/src/SketcherPrs/CMakeLists.txt @@ -16,6 +16,7 @@ SET(PROJECT_HEADERS SketcherPrs_SensitivePoint.h SketcherPrs_Radius.h SketcherPrs_LengthDimension.h + SketcherPrs_Mirror.h ) SET(PROJECT_SOURCES @@ -33,6 +34,7 @@ SET(PROJECT_SOURCES SketcherPrs_SensitivePoint.cpp SketcherPrs_Radius.cpp SketcherPrs_LengthDimension.cpp + SketcherPrs_Mirror.cpp ) SET(PROJECT_LIBRARIES @@ -62,6 +64,7 @@ SET(PROJECT_PICTURES icons/vertical.png icons/equal.png icons/tangent.png + icons/mirror.png ) ADD_DEFINITIONS(-DSKETCHERPRS_EXPORTS ${CAS_DEFINITIONS}) diff --git a/src/SketcherPrs/SketcherPrs_Equal.cpp b/src/SketcherPrs/SketcherPrs_Equal.cpp index f26682c3c..90f705fd8 100644 --- a/src/SketcherPrs/SketcherPrs_Equal.cpp +++ b/src/SketcherPrs/SketcherPrs_Equal.cpp @@ -52,7 +52,16 @@ void SketcherPrs_Equal::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quan 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()); + ObjectPtr aObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A()); + std::shared_ptr aLine = SketcherPrs_Tools::getShape(aObj); + if (aLine.get() == NULL) + return; + drawShape(aLine, thePrs); + + aObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B()); + aLine = SketcherPrs_Tools::getShape(aObj); + if (aLine.get() == NULL) + return; + drawShape(aLine, thePrs); } diff --git a/src/SketcherPrs/SketcherPrs_Factory.cpp b/src/SketcherPrs/SketcherPrs_Factory.cpp index 7ef236862..39ce4d6e0 100644 --- a/src/SketcherPrs/SketcherPrs_Factory.cpp +++ b/src/SketcherPrs/SketcherPrs_Factory.cpp @@ -15,6 +15,7 @@ #include "SketcherPrs_Tangent.h" #include "SketcherPrs_Radius.h" #include "SketcherPrs_LengthDimension.h" +#include "SketcherPrs_Mirror.h" #define CONSTRAINT_PRS_IMPL(NAME, CLASS) \ AISObjectPtr SketcherPrs_Factory::NAME(ModelAPI_Feature* theConstraint, \ @@ -34,6 +35,7 @@ CONSTRAINT_PRS_IMPL(equalConstraint, SketcherPrs_Equal); CONSTRAINT_PRS_IMPL(tangentConstraint, SketcherPrs_Tangent); CONSTRAINT_PRS_IMPL(radiusConstraint, SketcherPrs_Radius); CONSTRAINT_PRS_IMPL(lengthDimensionConstraint, SketcherPrs_LengthDimension); +CONSTRAINT_PRS_IMPL(mirrorConstraint, SketcherPrs_Mirror); AISObjectPtr SketcherPrs_Factory::horisontalConstraint(ModelAPI_Feature* theConstraint, diff --git a/src/SketcherPrs/SketcherPrs_Factory.h b/src/SketcherPrs/SketcherPrs_Factory.h index c43fb948f..9b627b940 100644 --- a/src/SketcherPrs/SketcherPrs_Factory.h +++ b/src/SketcherPrs/SketcherPrs_Factory.h @@ -74,6 +74,11 @@ public: /// \param theConstraint the constraint /// \param thePlane the current sketch plane GET_CONSTRAINT_PRS(lengthDimensionConstraint) + + /// Creates coincedent perpendicular presentation + /// \param theConstraint the constraint + /// \param thePlane the current sketch plane + GET_CONSTRAINT_PRS(mirrorConstraint) }; #endif diff --git a/src/SketcherPrs/SketcherPrs_Mirror.cpp b/src/SketcherPrs/SketcherPrs_Mirror.cpp new file mode 100644 index 000000000..2c05d225f --- /dev/null +++ b/src/SketcherPrs/SketcherPrs_Mirror.cpp @@ -0,0 +1,109 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: SketcherPrs_Mirror.cpp +// Created: 6 April 2015 +// Author: Vitaly SMETANNIKOV + +#include "SketcherPrs_Mirror.h" +#include "SketcherPrs_Tools.h" +#include "SketcherPrs_PositionMgr.h" + +#include + +#include + +#include +#include + + + +IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Mirror, SketcherPrs_SymbolPrs); +IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Mirror, SketcherPrs_SymbolPrs); + +static Handle(Image_AlienPixMap) MyPixMap; + +SketcherPrs_Mirror::SketcherPrs_Mirror(ModelAPI_Feature* theConstraint, + const std::shared_ptr& thePlane) + : SketcherPrs_SymbolPrs(theConstraint, thePlane) +{ +} + + +bool SketcherPrs_Mirror::updatePoints(double theStep) const +{ + ObjectPtr aAxisObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A()); + if (SketcherPrs_Tools::getShape(aAxisObj).get() == NULL) + return false; + + std::shared_ptr aData = myConstraint->data(); + std::shared_ptr anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B()); + if (anAttrB.get() == NULL) + return false; + std::shared_ptr anAttrC = aData->reflist(SketchPlugin_Constraint::ENTITY_C()); + if (anAttrC.get() == NULL) + return false; + + SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get(); + int aNb = anAttrB->size(); + if (aNb != anAttrC->size()) + return false; + + myPntArray = new Graphic3d_ArrayOfPoints(2 * aNb); + int i; + ObjectPtr aObj; + gp_Pnt aP1; + for (i = 0; i < aNb; i++) { + aObj = anAttrB->object(i); + aP1 = aMgr->getPosition(aObj, this, theStep); + myPntArray->SetVertice(i + 1, aP1); + } + for (i = 0; i < aNb; i++) { + aObj = anAttrC->object(i); + aP1 = aMgr->getPosition(aObj, this, theStep); + myPntArray->SetVertice(aNb + i + 1, aP1); + } + return true; +} + + +void SketcherPrs_Mirror::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const +{ + std::shared_ptr aData = myConstraint->data(); + std::shared_ptr anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B()); + if (anAttrB.get() == NULL) + return; + std::shared_ptr anAttrC = aData->reflist(SketchPlugin_Constraint::ENTITY_C()); + if (anAttrC.get() == NULL) + return; + + SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get(); + int aNb = anAttrB->size(); + if (aNb != anAttrC->size()) + return; + + Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs); + + Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2); + aGroup->SetPrimitivesAspect(aLineAspect); + + // Draw axis line + addLine(aGroup, SketchPlugin_Constraint::ENTITY_A()); + + // Draw source objects + int i; + ObjectPtr aObj; + for (i = 0; i < aNb; i++) { + aObj = anAttrB->object(i); + std::shared_ptr aShape = SketcherPrs_Tools::getShape(aObj); + if (aShape.get() != NULL) + drawShape(aShape, thePrs); + } + // draw mirrored objects + for (i = 0; i < aNb; i++) { + aObj = anAttrC->object(i); + std::shared_ptr aShape = SketcherPrs_Tools::getShape(aObj); + if (aShape.get() != NULL) + drawShape(aShape, thePrs); + } +} + diff --git a/src/SketcherPrs/SketcherPrs_Mirror.h b/src/SketcherPrs/SketcherPrs_Mirror.h new file mode 100644 index 000000000..69e9494d9 --- /dev/null +++ b/src/SketcherPrs/SketcherPrs_Mirror.h @@ -0,0 +1,39 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: SketcherPrs_Mirror.h +// Created: 6 April 2015 +// Author: Vitaly SMETANNIKOV + +#ifndef SketcherPrs_Mirror_H +#define SketcherPrs_Mirror_H + +#include "SketcherPrs_SymbolPrs.h" + + +DEFINE_STANDARD_HANDLE(SketcherPrs_Mirror, SketcherPrs_SymbolPrs) + +/** +* \ingroup GUI +* A redefinition of standard AIS Interactive Object in order to provide +* presentation of mirror constraint +*/ +class SketcherPrs_Mirror: public SketcherPrs_SymbolPrs +{ +public: + /// Constructor + /// \param theConstraint a constraint feature + /// \param thePlane a coordinate plane of current sketch + Standard_EXPORT SketcherPrs_Mirror(ModelAPI_Feature* theConstraint, + const std::shared_ptr& thePlane); + DEFINE_STANDARD_RTTI(SketcherPrs_Mirror) +protected: + virtual const char* iconName() const { return "mirror.png"; } + + virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const; + + /// Update myPntArray according to presentation positions + /// \return true in case of success + virtual bool updatePoints(double theStep) const; +}; + +#endif \ No newline at end of file diff --git a/src/SketcherPrs/SketcherPrs_Rigid.cpp b/src/SketcherPrs/SketcherPrs_Rigid.cpp index 2a7245e1d..73963b7fe 100644 --- a/src/SketcherPrs/SketcherPrs_Rigid.cpp +++ b/src/SketcherPrs/SketcherPrs_Rigid.cpp @@ -66,25 +66,11 @@ void SketcherPrs_Rigid::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quan return; Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs); - if (aShape->isEdge()) { - Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2); - aGroup->SetPrimitivesAspect(aLineAspect); - std::shared_ptr aCurve = std::shared_ptr(new GeomAPI_Curve(aShape)); - if (aCurve->isLine()) { - addLine(aGroup, SketchPlugin_Constraint::ENTITY_A()); - } else { - GeomAdaptor_Curve aAdaptor(aCurve->impl(), aCurve->startParam(), aCurve->endParam()); - StdPrs_DeflectionCurve::Add(thePrs,aAdaptor,myDrawer); - } - } else { - // This is a point - Handle(Prs3d_PointAspect) aPntAspect = new Prs3d_PointAspect(Aspect_TOM_PLUS, theColor, 1); - myDrawer->SetPointAspect(aPntAspect); - - std::shared_ptr aVertex = std::shared_ptr(new GeomAPI_Vertex(aShape)); - std::shared_ptr aPnt = aVertex->point(); - Handle(Geom_CartesianPoint) aPoint = new Geom_CartesianPoint(aPnt->impl()); - StdPrs_Point::Add(thePrs, aPoint, myDrawer); - } + Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2); + aGroup->SetPrimitivesAspect(aLineAspect); + + Handle(Prs3d_PointAspect) aPntAspect = new Prs3d_PointAspect(Aspect_TOM_PLUS, theColor, 1); + myDrawer->SetPointAspect(aPntAspect); + drawShape(aShape, thePrs); } diff --git a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp index 20fc780a7..b4e646709 100644 --- a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp +++ b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp @@ -9,6 +9,8 @@ #include "SketcherPrs_PositionMgr.h" #include +#include +#include #include #include @@ -20,6 +22,11 @@ #include #include #include +#include +#include +#include +#include +#include #include #include @@ -437,3 +444,24 @@ void SketcherPrs_SymbolPrs::Release (OpenGl_Context* theContext) } } +void SketcherPrs_SymbolPrs::drawShape(const std::shared_ptr& theShape, + const Handle(Prs3d_Presentation)& thePrs) const +{ + if (theShape->isEdge()) { + std::shared_ptr aCurve = + std::shared_ptr(new GeomAPI_Curve(theShape)); + if (aCurve->isLine()) { + GeomAdaptor_Curve aCurv(aCurve->impl(), aCurve->startParam(), aCurve->endParam()); + StdPrs_Curve::Add(thePrs, aCurv, myDrawer); + } else { + GeomAdaptor_Curve aAdaptor(aCurve->impl(), aCurve->startParam(), aCurve->endParam()); + StdPrs_DeflectionCurve::Add(thePrs,aAdaptor,myDrawer); + } + } else if (theShape->isVertex()) { + std::shared_ptr aVertex = + std::shared_ptr(new GeomAPI_Vertex(theShape)); + std::shared_ptr aPnt = aVertex->point(); + Handle(Geom_CartesianPoint) aPoint = new Geom_CartesianPoint(aPnt->impl()); + StdPrs_Point::Add(thePrs, aPoint, myDrawer); + } +} diff --git a/src/SketcherPrs/SketcherPrs_SymbolPrs.h b/src/SketcherPrs/SketcherPrs_SymbolPrs.h index 446cedabc..91b2323ac 100644 --- a/src/SketcherPrs/SketcherPrs_SymbolPrs.h +++ b/src/SketcherPrs/SketcherPrs_SymbolPrs.h @@ -103,6 +103,10 @@ protected: /// \return true in case of success virtual bool updatePoints(double theStep) const { return true; } + void drawShape(const std::shared_ptr& theShape, + const Handle(Prs3d_Presentation)& thePrs) const; + + protected: /// Constraint feature ModelAPI_Feature* myConstraint; diff --git a/src/SketcherPrs/SketcherPrs_Tangent.cpp b/src/SketcherPrs/SketcherPrs_Tangent.cpp index 45f320494..199eb782f 100644 --- a/src/SketcherPrs/SketcherPrs_Tangent.cpp +++ b/src/SketcherPrs/SketcherPrs_Tangent.cpp @@ -64,23 +64,7 @@ void SketcherPrs_Tangent::drawLines(const Handle(Prs3d_Presentation)& thePrs, Qu if ((aShape1.get() == NULL) || (aShape2.get() == NULL)) return; - - std::shared_ptr aCurve1 = std::shared_ptr(new GeomAPI_Curve(aShape1)); - std::shared_ptr aCurve2 = std::shared_ptr(new GeomAPI_Curve(aShape2)); - if (aCurve1->isCircle() && aCurve2->isLine()) { - addLine(aGroup, SketchPlugin_Constraint::ENTITY_B()); - GeomAdaptor_Curve aAdaptor(aCurve1->impl(), aCurve1->startParam(), aCurve1->endParam()); - StdPrs_DeflectionCurve::Add(thePrs,aAdaptor,myDrawer); - } else if (aCurve1->isLine() && aCurve2->isCircle()) { - addLine(aGroup, SketchPlugin_Constraint::ENTITY_A()); - GeomAdaptor_Curve aAdaptor(aCurve2->impl(), aCurve2->startParam(), aCurve2->endParam()); - StdPrs_DeflectionCurve::Add(thePrs,aAdaptor,myDrawer); - } else { - // Both curves are arcs - GeomAdaptor_Curve aAdaptor1(aCurve1->impl(), aCurve1->startParam(), aCurve1->endParam()); - StdPrs_DeflectionCurve::Add(thePrs, aAdaptor1, myDrawer); - GeomAdaptor_Curve aAdaptor2(aCurve2->impl(), aCurve2->startParam(), aCurve2->endParam()); - StdPrs_DeflectionCurve::Add(thePrs, aAdaptor2, myDrawer); - } + drawShape(aShape1, thePrs); + drawShape(aShape2, thePrs); } diff --git a/src/SketcherPrs/SketcherPrs_Tools.cpp b/src/SketcherPrs/SketcherPrs_Tools.cpp index 47468899e..8c28de0b0 100644 --- a/src/SketcherPrs/SketcherPrs_Tools.cpp +++ b/src/SketcherPrs/SketcherPrs_Tools.cpp @@ -23,9 +23,7 @@ namespace SketcherPrs_Tools { ObjectPtr getResult(ModelAPI_Feature* theFeature, const std::string& theAttrName) { std::shared_ptr aData = theFeature->data(); - std::shared_ptr anAttr = - std::dynamic_pointer_cast(aData->attribute(theAttrName)); - + std::shared_ptr anAttr = aData->refattr(theAttrName); return anAttr->object(); } diff --git a/src/SketcherPrs/icons/mirror.png b/src/SketcherPrs/icons/mirror.png new file mode 100644 index 0000000000000000000000000000000000000000..3197cf36e9e466ed90e4c28b68885b7df7e64ab4 GIT binary patch literal 299 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&kmUKs7M+SzC{oH>NS%G}c0*}aI z1_r)^Ak4U9V)k30phSslL`iUdT1k0gQ7S`0VrE{6US4X6f{C7io@r{UQ7TZ)N>3NZ z5RKs4AVa=G4m__fOlE>+L{}lHRY>r zv7YHkU8FMqcHGstW;VO^8<>+7U-7KFvbJGbO@JSpT*5aelV5HN*u^(|agy12heLpU z!atwIi8}u|1k?le&gQm#?%(jw@1S|u_Lk)ZF$Y#1f4|?A