From 747b8fc4fc7746b3abe2f0b4aa5a583ae38aedcb Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 16 Mar 2015 18:32:36 +0300 Subject: [PATCH] Horisontal and vertical constraints added --- src/PartSet/PartSet_Module.cpp | 4 +- src/PartSet/PartSet_SketcherMgr.cpp | 6 ++ src/PartSet/PartSet_icons.qrc | 2 + src/PartSet/icons/horisontal.png | Bin 0 -> 218 bytes src/PartSet/icons/vertical.png | Bin 0 -> 219 bytes .../SketchPlugin_ConstraintHorizontal.cpp | 4 +- .../SketchPlugin_ConstraintVertical.cpp | 4 +- src/SketchPlugin/plugin-Sketch.xml | 4 +- src/SketcherPrs/CMakeLists.txt | 4 + src/SketcherPrs/SketcherPrs_Factory.cpp | 20 +++++ src/SketcherPrs/SketcherPrs_Factory.h | 10 +++ src/SketcherPrs/SketcherPrs_HVDirection.cpp | 82 ++++++++++++++++++ src/SketcherPrs/SketcherPrs_HVDirection.h | 50 +++++++++++ src/SketcherPrs/icons/horisontal.png | Bin 0 -> 217 bytes src/SketcherPrs/icons/vertical.png | Bin 0 -> 231 bytes 15 files changed, 184 insertions(+), 6 deletions(-) create mode 100644 src/PartSet/icons/horisontal.png create mode 100644 src/PartSet/icons/vertical.png create mode 100644 src/SketcherPrs/SketcherPrs_HVDirection.cpp create mode 100644 src/SketcherPrs/SketcherPrs_HVDirection.h create mode 100644 src/SketcherPrs/icons/horisontal.png create mode 100644 src/SketcherPrs/icons/vertical.png diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index ebc5db732..cb62b8797 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -419,8 +419,8 @@ void PartSet_Module::onOperationActivatedByPreselection() 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(); diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index b55c62ad1..9567abc7c 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -48,6 +48,9 @@ #include #include #include +#include +#include +#include #include #include @@ -578,6 +581,9 @@ QStringList PartSet_SketcherMgr::sketchOperationIdList() 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; } diff --git a/src/PartSet/PartSet_icons.qrc b/src/PartSet/PartSet_icons.qrc index d580c0de6..1b30b61e3 100644 --- a/src/PartSet/PartSet_icons.qrc +++ b/src/PartSet/PartSet_icons.qrc @@ -30,5 +30,7 @@ icons/fixed.png icons/placement.png icons/geom_export.png + icons/horisontal.png + icons/vertical.png diff --git a/src/PartSet/icons/horisontal.png b/src/PartSet/icons/horisontal.png new file mode 100644 index 0000000000000000000000000000000000000000..a7621499fc324a91295ef9df52f54e019f2702a0 GIT binary patch literal 218 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?8Z%-G;5DWjMeH%F$6nG9)^&bEEKThCI+l zx5K~B*-Zcbe!;7?PalUT1bqFS(Qpw6H~Jl8+E#n@n7i+?WT3GOp00i_>zopr0FNO_ Aq5uE@ literal 0 HcmV?d00001 diff --git a/src/PartSet/icons/vertical.png b/src/PartSet/icons/vertical.png new file mode 100644 index 0000000000000000000000000000000000000000..a09de04075b391413f9ee8972d4bdfbc3604ac1f GIT binary patch literal 219 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?8A5Ry@5DWje{Rep&6gZe?9(#D_e|%<73tP;A9~QmhYpyYDx$)sBr}@s8 zJerRL7=I=SE4BChdGN_9Q*|Q4C+(d7+EXMic_}eIxyrSH_3@dj$5IX%8w1T{@O1Ta JS?83{1OWMiNPhqT literal 0 HcmV?d00001 diff --git a/src/SketchPlugin/SketchPlugin_ConstraintHorizontal.cpp b/src/SketchPlugin/SketchPlugin_ConstraintHorizontal.cpp index 722ea659a..175715d28 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintHorizontal.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintHorizontal.cpp @@ -36,7 +36,9 @@ AISObjectPtr SketchPlugin_ConstraintHorizontal::getAISObject(AISObjectPtr thePre return thePrevious; AISObjectPtr anAIS = thePrevious; - /// TODO: Horizontal constraint presentation should be put here + if (!anAIS) { + anAIS = SketcherPrs_Factory::horisontalConstraint(this, sketch()->coordinatePlane()); + } return anAIS; } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintVertical.cpp b/src/SketchPlugin/SketchPlugin_ConstraintVertical.cpp index ecfc91776..bb824715a 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintVertical.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintVertical.cpp @@ -36,7 +36,9 @@ AISObjectPtr SketchPlugin_ConstraintVertical::getAISObject(AISObjectPtr thePrevi return thePrevious; AISObjectPtr anAIS = thePrevious; - /// TODO: Horizontal constraint presentation should be put here + if (!anAIS) { + anAIS = SketcherPrs_Factory::verticalConstraint(this, sketch()->coordinatePlane()); + } return anAIS; } diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 06167aa91..b33c14891 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -150,14 +150,14 @@ - + - + diff --git a/src/SketcherPrs/CMakeLists.txt b/src/SketcherPrs/CMakeLists.txt index c2ed12fda..b2061ca13 100644 --- a/src/SketcherPrs/CMakeLists.txt +++ b/src/SketcherPrs/CMakeLists.txt @@ -10,6 +10,7 @@ SET(PROJECT_HEADERS SketcherPrs_SymbolPrs.h SketcherPrs_PositionMgr.h SketcherPrs_Rigid.h + SketcherPrs_HVDirection.h ) SET(PROJECT_SOURCES @@ -21,6 +22,7 @@ SET(PROJECT_SOURCES SketcherPrs_SymbolPrs.cpp SketcherPrs_PositionMgr.cpp SketcherPrs_Rigid.cpp + SketcherPrs_HVDirection.cpp ) SET(PROJECT_LIBRARIES @@ -38,6 +40,8 @@ SET(PROJECT_PICTURES icons/parallel.png icons/perpendicular.png icons/anchor.png + icons/horisontal.png + icons/vertical.png ) ADD_DEFINITIONS(-DCONSTRAINTS_EXPORTS ${CAS_DEFINITIONS}) diff --git a/src/SketcherPrs/SketcherPrs_Factory.cpp b/src/SketcherPrs/SketcherPrs_Factory.cpp index 8898569c3..95c79fc44 100644 --- a/src/SketcherPrs/SketcherPrs_Factory.cpp +++ b/src/SketcherPrs/SketcherPrs_Factory.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #define CONSTRAINT_PRS_IMPL(NAME, CLASS) \ AISObjectPtr SketcherPrs_Factory::NAME(SketchPlugin_Constraint* theConstraint, \ @@ -25,3 +26,22 @@ CONSTRAINT_PRS_IMPL(coincidentConstraint, SketcherPrs_Coincident); 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& thePlane) +{ + std::shared_ptr 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& thePlane) +{ + std::shared_ptr aAISObj = AISObjectPtr(new GeomAPI_AISObject()); + Handle(SketcherPrs_HVDirection) aPrs = new SketcherPrs_HVDirection(theConstraint, thePlane, false); + aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); + return aAISObj; +} diff --git a/src/SketcherPrs/SketcherPrs_Factory.h b/src/SketcherPrs/SketcherPrs_Factory.h index a76b5a285..14a8f5e2a 100644 --- a/src/SketcherPrs/SketcherPrs_Factory.h +++ b/src/SketcherPrs/SketcherPrs_Factory.h @@ -44,6 +44,16 @@ public: /// \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 diff --git a/src/SketcherPrs/SketcherPrs_HVDirection.cpp b/src/SketcherPrs/SketcherPrs_HVDirection.cpp new file mode 100644 index 000000000..0ad7c1f15 --- /dev/null +++ b/src/SketcherPrs/SketcherPrs_HVDirection.cpp @@ -0,0 +1,82 @@ +// 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 + +#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_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& 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 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()); +} + diff --git a/src/SketcherPrs/SketcherPrs_HVDirection.h b/src/SketcherPrs/SketcherPrs_HVDirection.h new file mode 100644 index 000000000..84e993b05 --- /dev/null +++ b/src/SketcherPrs/SketcherPrs_HVDirection.h @@ -0,0 +1,50 @@ +// 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& 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 diff --git a/src/SketcherPrs/icons/horisontal.png b/src/SketcherPrs/icons/horisontal.png new file mode 100644 index 0000000000000000000000000000000000000000..ad67bb2d69f1ac335bc919769ea570a2eb271b93 GIT binary patch literal 217 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?8FHaZ85DWk0AOHW`yGpE9(3EJseBlCv2%}MbHp9*pT#gd6Z5&xoRCGu( zBqbkqk#yh?e$Fa0qk?(Dk;EAp`aLPkCk{rib{_vP$>6zlo4PZbLM6~t22WQ%mvv4F FO#lE@Kg0k4 literal 0 HcmV?d00001 diff --git a/src/SketcherPrs/icons/vertical.png b/src/SketcherPrs/icons/vertical.png new file mode 100644 index 0000000000000000000000000000000000000000..68f803392dad74bf4e96f4e6c2794b4be5dacf18 GIT binary patch literal 231 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@p2u~Ns5DWjKeU^L-3LGrCf6VROw_T`E$k5PGYb>1^F~hP&>Yo9d(j?ww z(Q}X9-qkIMVcaoQ=jWy;+y~;e^&J!h(lsfv%%(it4d1`^Ni}VFAZl9E?#*1a;rPRS TdRd2nb})Fl`njxgN@xNAC(22= literal 0 HcmV?d00001 -- 2.30.2