From: vsv Date: Tue, 17 Mar 2015 14:36:59 +0000 (+0300) Subject: Create tangent constraint presentation X-Git-Tag: V_1.1.0~119 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4ec2f8898777f6c71fcf6818b4e0fc340d057bde;p=modules%2Fshaper.git Create tangent constraint presentation --- 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 000000000..9cc2c73ea Binary files /dev/null and b/src/PartSet/icons/tangent.png differ 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 000000000..d4d8cd79f Binary files /dev/null and b/src/SketcherPrs/icons/tangent.png differ