From 08069d25db8d7d1ac6012a316e68edecf0fb9fb3 Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 17 Mar 2015 15:58:11 +0300 Subject: [PATCH] Equal constraint presentation --- src/PartSet/PartSet_icons.qrc | 1 + src/PartSet/icons/equal.png | Bin 0 -> 205 bytes .../SketchPlugin_ConstraintEqual.cpp | 4 +- src/SketchPlugin/plugin-Sketch.xml | 2 +- src/SketcherPrs/CMakeLists.txt | 3 + src/SketcherPrs/SketcherPrs_Equal.cpp | 91 ++++++++++++++++++ src/SketcherPrs/SketcherPrs_Equal.h | 42 ++++++++ src/SketcherPrs/SketcherPrs_Factory.cpp | 14 +-- src/SketcherPrs/SketcherPrs_Factory.h | 5 + src/SketcherPrs/icons/equal.png | Bin 0 -> 237 bytes 10 files changed, 154 insertions(+), 8 deletions(-) create mode 100644 src/PartSet/icons/equal.png create mode 100644 src/SketcherPrs/SketcherPrs_Equal.cpp create mode 100644 src/SketcherPrs/SketcherPrs_Equal.h create mode 100644 src/SketcherPrs/icons/equal.png diff --git a/src/PartSet/PartSet_icons.qrc b/src/PartSet/PartSet_icons.qrc index 1b30b61e3..f54b2c80c 100644 --- a/src/PartSet/PartSet_icons.qrc +++ b/src/PartSet/PartSet_icons.qrc @@ -32,5 +32,6 @@ icons/geom_export.png icons/horisontal.png icons/vertical.png + icons/equal.png diff --git a/src/PartSet/icons/equal.png b/src/PartSet/icons/equal.png new file mode 100644 index 0000000000000000000000000000000000000000..0b446f6934f4a9fb1653aacd9bc65fa747d4af42 GIT binary patch literal 205 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?8J5LwK5DWk0gn-}wQ2M-YXMm1UC(tAYPgg&ebxsLQ0QeOk literal 0 HcmV?d00001 diff --git a/src/SketchPlugin/SketchPlugin_ConstraintEqual.cpp b/src/SketchPlugin/SketchPlugin_ConstraintEqual.cpp index 00531acde..efd034fea 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintEqual.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintEqual.cpp @@ -37,7 +37,9 @@ AISObjectPtr SketchPlugin_ConstraintEqual::getAISObject(AISObjectPtr thePrevious return thePrevious; AISObjectPtr anAIS = thePrevious; - /// TODO: Equal constraint presentation should be put here + if (!anAIS) { + anAIS = SketcherPrs_Factory::equalConstraint(this, sketch()->coordinatePlane()); + } return anAIS; } diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 8e8803758..55afbd01e 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -164,7 +164,7 @@ - + diff --git a/src/SketcherPrs/CMakeLists.txt b/src/SketcherPrs/CMakeLists.txt index b2061ca13..5c7f7b34c 100644 --- a/src/SketcherPrs/CMakeLists.txt +++ b/src/SketcherPrs/CMakeLists.txt @@ -11,6 +11,7 @@ SET(PROJECT_HEADERS SketcherPrs_PositionMgr.h SketcherPrs_Rigid.h SketcherPrs_HVDirection.h + SketcherPrs_Equal.h ) SET(PROJECT_SOURCES @@ -23,6 +24,7 @@ SET(PROJECT_SOURCES SketcherPrs_PositionMgr.cpp SketcherPrs_Rigid.cpp SketcherPrs_HVDirection.cpp + SketcherPrs_Equal.cpp ) SET(PROJECT_LIBRARIES @@ -42,6 +44,7 @@ SET(PROJECT_PICTURES icons/anchor.png icons/horisontal.png icons/vertical.png + icons/equal.png ) ADD_DEFINITIONS(-DCONSTRAINTS_EXPORTS ${CAS_DEFINITIONS}) diff --git a/src/SketcherPrs/SketcherPrs_Equal.cpp b/src/SketcherPrs/SketcherPrs_Equal.cpp new file mode 100644 index 000000000..9dd35cfe5 --- /dev/null +++ b/src/SketcherPrs/SketcherPrs_Equal.cpp @@ -0,0 +1,91 @@ +// 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 + +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + + +extern std::shared_ptr 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& 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 aLine1 = SketcherPrs_Tools::getShape(aObj1); + if (aLine1.get() == NULL) + return; + + std::shared_ptr 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()); +} + diff --git a/src/SketcherPrs/SketcherPrs_Equal.h b/src/SketcherPrs/SketcherPrs_Equal.h new file mode 100644 index 000000000..90beb8c04 --- /dev/null +++ b/src/SketcherPrs/SketcherPrs_Equal.h @@ -0,0 +1,42 @@ +// 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& 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 diff --git a/src/SketcherPrs/SketcherPrs_Factory.cpp b/src/SketcherPrs/SketcherPrs_Factory.cpp index 95c79fc44..639a557f5 100644 --- a/src/SketcherPrs/SketcherPrs_Factory.cpp +++ b/src/SketcherPrs/SketcherPrs_Factory.cpp @@ -6,11 +6,12 @@ #include "SketcherPrs_Factory.h" -#include -#include -#include -#include -#include +#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, \ @@ -25,7 +26,8 @@ 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, diff --git a/src/SketcherPrs/SketcherPrs_Factory.h b/src/SketcherPrs/SketcherPrs_Factory.h index 14a8f5e2a..9de1038a8 100644 --- a/src/SketcherPrs/SketcherPrs_Factory.h +++ b/src/SketcherPrs/SketcherPrs_Factory.h @@ -54,6 +54,11 @@ public: /// \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 diff --git a/src/SketcherPrs/icons/equal.png b/src/SketcherPrs/icons/equal.png new file mode 100644 index 0000000000000000000000000000000000000000..e3af2c6e25b1ca67515c5f56754a68eaa0ead62d GIT binary patch literal 237 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@pI8PVH5DWjM=MDJ|DDXH3_FYbXc272@g(av*Inip5Vtm{shCfP+o!#1d z_#|bG+*q{s_#W@F4d15Q{;)P+QLa_qi4}G8D`xkJR