From 4ec2f8898777f6c71fcf6818b4e0fc340d057bde Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 17 Mar 2015 17:36:59 +0300 Subject: [PATCH] Create tangent constraint presentation --- src/PartSet/PartSet_SketcherMgr.cpp | 2 + src/PartSet/PartSet_icons.qrc | 1 + src/PartSet/icons/tangent.png | Bin 0 -> 430 bytes .../SketchPlugin_ConstraintTangent.cpp | 4 +- src/SketchPlugin/plugin-Sketch.xml | 2 +- src/SketcherPrs/CMakeLists.txt | 3 + src/SketcherPrs/SketcherPrs_Equal.cpp | 3 - src/SketcherPrs/SketcherPrs_Factory.cpp | 2 + src/SketcherPrs/SketcherPrs_Factory.h | 5 + src/SketcherPrs/SketcherPrs_HVDirection.cpp | 3 - src/SketcherPrs/SketcherPrs_Parallel.cpp | 3 - src/SketcherPrs/SketcherPrs_Perpendicular.cpp | 5 - src/SketcherPrs/SketcherPrs_Rigid.cpp | 3 - src/SketcherPrs/SketcherPrs_Tangent.cpp | 88 ++++++++++++++++++ src/SketcherPrs/SketcherPrs_Tangent.h | 42 +++++++++ src/SketcherPrs/icons/tangent.png | Bin 0 -> 366 bytes 16 files changed, 147 insertions(+), 19 deletions(-) create mode 100644 src/PartSet/icons/tangent.png create mode 100644 src/SketcherPrs/SketcherPrs_Tangent.cpp create mode 100644 src/SketcherPrs/SketcherPrs_Tangent.h create mode 100644 src/SketcherPrs/icons/tangent.png diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 9567abc7c..64b07a1ee 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -584,6 +585,7 @@ QStringList PartSet_SketcherMgr::sketchOperationIdList() aIds << SketchPlugin_ConstraintHorizontal::ID().c_str(); aIds << SketchPlugin_ConstraintVertical::ID().c_str(); aIds << SketchPlugin_ConstraintEqual::ID().c_str(); + aIds << SketchPlugin_ConstraintTangent::ID().c_str(); } return aIds; } diff --git a/src/PartSet/PartSet_icons.qrc b/src/PartSet/PartSet_icons.qrc index f54b2c80c..90415fe29 100644 --- a/src/PartSet/PartSet_icons.qrc +++ b/src/PartSet/PartSet_icons.qrc @@ -33,5 +33,6 @@ icons/horisontal.png icons/vertical.png icons/equal.png + icons/tangent.png diff --git a/src/PartSet/icons/tangent.png b/src/PartSet/icons/tangent.png new file mode 100644 index 0000000000000000000000000000000000000000..9cc2c73ea6190a14e1828bfd5efdff01fbce7791 GIT binary patch literal 430 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@}4e^Ar}6%lN8Gi1qiq*3y5;4Fa;j$T=haI!hw~kF@;f(qwK=c62=ZL zmPJaX9AW{HjVl=Vj2?ZC`}NGgN9c&{|1*2cC)@v=ymX4(q^B=g|1@w{cK-@*Aw^Rf;0t}Z-U zcW?4JJv&F+pxb-c=eloTQLar`GNbZU`~vrb=TFa1^*vT*&Hwq*%V>jx*~W&9stXMA zwar$X4mYY`F7v(DOE6ea=&W6B`+;u;KNvcM66vsdHX5N-ArN^ WV;xsXIi3LqCxfS}pUXO@geCx){G~Ji literal 0 HcmV?d00001 diff --git a/src/SketchPlugin/SketchPlugin_ConstraintTangent.cpp b/src/SketchPlugin/SketchPlugin_ConstraintTangent.cpp index f2cf4a307..c979d8939 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintTangent.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintTangent.cpp @@ -37,7 +37,9 @@ AISObjectPtr SketchPlugin_ConstraintTangent::getAISObject(AISObjectPtr thePrevio return thePrevious; AISObjectPtr anAIS = thePrevious; - /// TODO: Tangency constraint presentation should be put here + if (!anAIS) { + anAIS = SketcherPrs_Factory::tangentConstraint(this, sketch()->coordinatePlane()); + } return anAIS; } diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 55afbd01e..3bbfbfead 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -174,7 +174,7 @@ - + diff --git a/src/SketcherPrs/CMakeLists.txt b/src/SketcherPrs/CMakeLists.txt index 5c7f7b34c..5fe8b8437 100644 --- a/src/SketcherPrs/CMakeLists.txt +++ b/src/SketcherPrs/CMakeLists.txt @@ -12,6 +12,7 @@ SET(PROJECT_HEADERS SketcherPrs_Rigid.h SketcherPrs_HVDirection.h SketcherPrs_Equal.h + SketcherPrs_Tangent.h ) SET(PROJECT_SOURCES @@ -25,6 +26,7 @@ SET(PROJECT_SOURCES SketcherPrs_Rigid.cpp SketcherPrs_HVDirection.cpp SketcherPrs_Equal.cpp + SketcherPrs_Tangent.cpp ) SET(PROJECT_LIBRARIES @@ -45,6 +47,7 @@ SET(PROJECT_PICTURES icons/horisontal.png icons/vertical.png icons/equal.png + icons/tangent.png ) ADD_DEFINITIONS(-DCONSTRAINTS_EXPORTS ${CAS_DEFINITIONS}) diff --git a/src/SketcherPrs/SketcherPrs_Equal.cpp b/src/SketcherPrs/SketcherPrs_Equal.cpp index 9dd35cfe5..e14da56f3 100644 --- a/src/SketcherPrs/SketcherPrs_Equal.cpp +++ b/src/SketcherPrs/SketcherPrs_Equal.cpp @@ -32,9 +32,6 @@ #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); diff --git a/src/SketcherPrs/SketcherPrs_Factory.cpp b/src/SketcherPrs/SketcherPrs_Factory.cpp index 639a557f5..b46070694 100644 --- a/src/SketcherPrs/SketcherPrs_Factory.cpp +++ b/src/SketcherPrs/SketcherPrs_Factory.cpp @@ -12,6 +12,7 @@ #include "SketcherPrs_Rigid.h" #include "SketcherPrs_HVDirection.h" #include "SketcherPrs_Equal.h" +#include "SketcherPrs_Tangent.h" #define CONSTRAINT_PRS_IMPL(NAME, CLASS) \ AISObjectPtr SketcherPrs_Factory::NAME(SketchPlugin_Constraint* theConstraint, \ @@ -28,6 +29,7 @@ CONSTRAINT_PRS_IMPL(parallelConstraint, SketcherPrs_Parallel); CONSTRAINT_PRS_IMPL(perpendicularConstraint, SketcherPrs_Perpendicular); CONSTRAINT_PRS_IMPL(rigidConstraint, SketcherPrs_Rigid); CONSTRAINT_PRS_IMPL(equalConstraint, SketcherPrs_Equal); +CONSTRAINT_PRS_IMPL(tangentConstraint, SketcherPrs_Tangent); AISObjectPtr SketcherPrs_Factory::horisontalConstraint(SketchPlugin_Constraint* theConstraint, diff --git a/src/SketcherPrs/SketcherPrs_Factory.h b/src/SketcherPrs/SketcherPrs_Factory.h index 9de1038a8..1d3f7335d 100644 --- a/src/SketcherPrs/SketcherPrs_Factory.h +++ b/src/SketcherPrs/SketcherPrs_Factory.h @@ -59,6 +59,11 @@ public: /// \param theConstraint the constraint /// \param thePlane the current sketch plane GET_CONSTRAINT_PRS(equalConstraint) + + /// Creates coincedent perpendicular presentation + /// \param theConstraint the constraint + /// \param thePlane the current sketch plane + GET_CONSTRAINT_PRS(tangentConstraint) }; #endif diff --git a/src/SketcherPrs/SketcherPrs_HVDirection.cpp b/src/SketcherPrs/SketcherPrs_HVDirection.cpp index 13b3def6e..fe0831211 100644 --- a/src/SketcherPrs/SketcherPrs_HVDirection.cpp +++ b/src/SketcherPrs/SketcherPrs_HVDirection.cpp @@ -32,9 +32,6 @@ #include -extern std::shared_ptr getFeaturePoint(DataPtr theData, - const std::string& theAttribute); - IMPLEMENT_STANDARD_HANDLE(SketcherPrs_HVDirection, SketcherPrs_SymbolPrs); IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_HVDirection, SketcherPrs_SymbolPrs); diff --git a/src/SketcherPrs/SketcherPrs_Parallel.cpp b/src/SketcherPrs/SketcherPrs_Parallel.cpp index b3bd0ffa9..2736ee169 100644 --- a/src/SketcherPrs/SketcherPrs_Parallel.cpp +++ b/src/SketcherPrs/SketcherPrs_Parallel.cpp @@ -32,9 +32,6 @@ #include -extern std::shared_ptr getFeaturePoint(DataPtr theData, - const std::string& theAttribute); - IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Parallel, SketcherPrs_SymbolPrs); IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Parallel, SketcherPrs_SymbolPrs); diff --git a/src/SketcherPrs/SketcherPrs_Perpendicular.cpp b/src/SketcherPrs/SketcherPrs_Perpendicular.cpp index 303daffeb..5158b932d 100644 --- a/src/SketcherPrs/SketcherPrs_Perpendicular.cpp +++ b/src/SketcherPrs/SketcherPrs_Perpendicular.cpp @@ -25,11 +25,6 @@ #include -// Function which is defined in SketchPlugin_ConstraintDistance.cpp -extern std::shared_ptr getFeaturePoint(DataPtr theData, - const std::string& theAttribute); - - IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Perpendicular, SketcherPrs_SymbolPrs); IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Perpendicular, SketcherPrs_SymbolPrs); diff --git a/src/SketcherPrs/SketcherPrs_Rigid.cpp b/src/SketcherPrs/SketcherPrs_Rigid.cpp index c436e586a..34c028751 100644 --- a/src/SketcherPrs/SketcherPrs_Rigid.cpp +++ b/src/SketcherPrs/SketcherPrs_Rigid.cpp @@ -41,9 +41,6 @@ #include -extern std::shared_ptr getFeaturePoint(DataPtr theData, - const std::string& theAttribute); - IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Rigid, SketcherPrs_SymbolPrs); IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Rigid, SketcherPrs_SymbolPrs); diff --git a/src/SketcherPrs/SketcherPrs_Tangent.cpp b/src/SketcherPrs/SketcherPrs_Tangent.cpp new file mode 100644 index 000000000..4d13a6535 --- /dev/null +++ b/src/SketcherPrs/SketcherPrs_Tangent.cpp @@ -0,0 +1,88 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: SketcherPrs_Tangent.cpp +// Created: 16 February 2015 +// Author: Vitaly SMETANNIKOV + +#include "SketcherPrs_Tangent.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 + + + +IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Tangent, SketcherPrs_SymbolPrs); +IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Tangent, SketcherPrs_SymbolPrs); + +static Handle(Image_AlienPixMap) MyPixMap; + +SketcherPrs_Tangent::SketcherPrs_Tangent(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_Tangent::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_Tangent::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_Tangent.h b/src/SketcherPrs/SketcherPrs_Tangent.h new file mode 100644 index 000000000..e1faefe21 --- /dev/null +++ b/src/SketcherPrs/SketcherPrs_Tangent.h @@ -0,0 +1,42 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: SketcherPrs_Tangent.h +// Created: 16 February 2015 +// Author: Vitaly SMETANNIKOV + +#ifndef SketcherPrs_Tangent_H +#define SketcherPrs_Tangent_H + +#include "SketcherPrs_SymbolPrs.h" + +class SketchPlugin_Constraint; +class SketchPlugin_Sketch; + + +DEFINE_STANDARD_HANDLE(SketcherPrs_Tangent, SketcherPrs_SymbolPrs) + +/** +* \ingroup GUI +* A redefinition of standard AIS Interactive Object in order to provide +* presentation of tangent constraint +*/ +class SketcherPrs_Tangent: public SketcherPrs_SymbolPrs +{ +public: + /// Constructor + /// \param theConstraint a constraint feature + /// \param thePlane a coordinate plane of current sketch + Standard_EXPORT SketcherPrs_Tangent(SketchPlugin_Constraint* theConstraint, + const std::shared_ptr& thePlane); + DEFINE_STANDARD_RTTI(SketcherPrs_Tangent) +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 "tangent.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/icons/tangent.png b/src/SketcherPrs/icons/tangent.png new file mode 100644 index 0000000000000000000000000000000000000000..d4d8cd79fc09da184b0478d40965f61b0bc64cc2 GIT binary patch literal 366 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@p`<^b2Ar}5iC-3DwtRT=jQ@gmLMMO@CHHb@GPJy+xdy1y5)3L&dj6oB= z_Z|Mj5?$2vC9>fAJ4W@KHCzA5^RU_Pe|%p(e(^ck9U8L9x@$k$Eo^13Xq1c*JtrxB zL}T^J?)eWc-s&`P_syF$r)MXldQxw#ppVQ}LpAxkwKsM9SSG8^b83=EH;^@$5pj4c zi=ocR_uE?Mg?)+f7Ff*wu7UCQg<@Hut9!o%G;fVpocL~Qbyv>!t?`}$K0o;0iEK;g zn-viwr7~GCXYUb1eYK^G3l$_j#!tvAmV3N)Uxdu@+5E=0e5S9}lXC`omBG{1&t;uc GLK6TrNrh+t literal 0 HcmV?d00001 -- 2.39.2