From: vsv Date: Mon, 16 Mar 2015 15:32:36 +0000 (+0300) Subject: Horisontal and vertical constraints added X-Git-Tag: V_1.1.0~129 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=747b8fc4fc7746b3abe2f0b4aa5a583ae38aedcb;p=modules%2Fshaper.git Horisontal and vertical constraints added --- 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 000000000..a7621499f Binary files /dev/null and b/src/PartSet/icons/horisontal.png differ diff --git a/src/PartSet/icons/vertical.png b/src/PartSet/icons/vertical.png new file mode 100644 index 000000000..a09de0407 Binary files /dev/null and b/src/PartSet/icons/vertical.png differ 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 000000000..ad67bb2d6 Binary files /dev/null and b/src/SketcherPrs/icons/horisontal.png differ diff --git a/src/SketcherPrs/icons/vertical.png b/src/SketcherPrs/icons/vertical.png new file mode 100644 index 000000000..68f803392 Binary files /dev/null and b/src/SketcherPrs/icons/vertical.png differ