From 303a8f8c0a451e65f1ad390f8b73d3408bf28425 Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 24 Apr 2015 13:44:40 +0300 Subject: [PATCH] Symbols for translation/rotation are created --- .../SketchPlugin_MultiRotation.cpp | 5 +- .../SketchPlugin_MultiTranslation.cpp | 5 +- src/SketcherPrs/CMakeLists.txt | 4 + src/SketcherPrs/SketcherPrs_Factory.cpp | 19 +++++ src/SketcherPrs/SketcherPrs_Factory.h | 28 ++++--- src/SketcherPrs/SketcherPrs_Mirror.cpp | 20 +---- src/SketcherPrs/SketcherPrs_SymbolPrs.cpp | 27 ++++++- src/SketcherPrs/SketcherPrs_SymbolPrs.h | 6 ++ .../SketcherPrs_Transformation.cpp | 71 ++++++++++++++++++ src/SketcherPrs/SketcherPrs_Transformation.h | 48 ++++++++++++ src/SketcherPrs/icons/rotate.png | Bin 0 -> 288 bytes src/SketcherPrs/icons/translate.png | Bin 0 -> 243 bytes src/XGUI/XGUI_pictures.qrc | 1 + src/XGUI/pictures/arrow.png | Bin 0 -> 748 bytes 14 files changed, 200 insertions(+), 34 deletions(-) create mode 100644 src/SketcherPrs/SketcherPrs_Transformation.cpp create mode 100644 src/SketcherPrs/SketcherPrs_Transformation.h create mode 100644 src/SketcherPrs/icons/rotate.png create mode 100644 src/SketcherPrs/icons/translate.png create mode 100644 src/XGUI/pictures/arrow.png diff --git a/src/SketchPlugin/SketchPlugin_MultiRotation.cpp b/src/SketchPlugin/SketchPlugin_MultiRotation.cpp index 86f6943fa..2f5ad3a49 100644 --- a/src/SketchPlugin/SketchPlugin_MultiRotation.cpp +++ b/src/SketchPlugin/SketchPlugin_MultiRotation.cpp @@ -20,6 +20,8 @@ #include #include +#include + #define PI 3.1415926535897932 SketchPlugin_MultiRotation::SketchPlugin_MultiRotation() @@ -190,8 +192,7 @@ AISObjectPtr SketchPlugin_MultiRotation::getAISObject(AISObjectPtr thePrevious) AISObjectPtr anAIS = thePrevious; if (!anAIS) { -// TODO: -// anAIS = SketcherPrs_Factory::mirrorConstraint(this, sketch()->coordinatePlane()); + anAIS = SketcherPrs_Factory::rotateConstraint(this, sketch()->coordinatePlane()); } return anAIS; } diff --git a/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp b/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp index e7b850ec2..06cbd55d7 100644 --- a/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp +++ b/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp @@ -18,6 +18,8 @@ #include #include +#include + SketchPlugin_MultiTranslation::SketchPlugin_MultiTranslation() { } @@ -174,8 +176,7 @@ AISObjectPtr SketchPlugin_MultiTranslation::getAISObject(AISObjectPtr thePreviou AISObjectPtr anAIS = thePrevious; if (!anAIS) { -// TODO: -// anAIS = SketcherPrs_Factory::mirrorConstraint(this, sketch()->coordinatePlane()); + anAIS = SketcherPrs_Factory::translateConstraint(this, sketch()->coordinatePlane()); } return anAIS; } diff --git a/src/SketcherPrs/CMakeLists.txt b/src/SketcherPrs/CMakeLists.txt index 963c7e542..833d9b62b 100644 --- a/src/SketcherPrs/CMakeLists.txt +++ b/src/SketcherPrs/CMakeLists.txt @@ -17,6 +17,7 @@ SET(PROJECT_HEADERS SketcherPrs_Radius.h SketcherPrs_LengthDimension.h SketcherPrs_Mirror.h + SketcherPrs_Transformation.h ) SET(PROJECT_SOURCES @@ -35,6 +36,7 @@ SET(PROJECT_SOURCES SketcherPrs_Radius.cpp SketcherPrs_LengthDimension.cpp SketcherPrs_Mirror.cpp + SketcherPrs_Transformation.cpp ) SET(PROJECT_LIBRARIES @@ -65,6 +67,8 @@ SET(PROJECT_PICTURES icons/equal.png icons/tangent.png icons/mirror.png + icons/rotate.png + icons/translate.png ) ADD_DEFINITIONS(-DSKETCHERPRS_EXPORTS ${CAS_DEFINITIONS}) diff --git a/src/SketcherPrs/SketcherPrs_Factory.cpp b/src/SketcherPrs/SketcherPrs_Factory.cpp index 39ce4d6e0..b855929ab 100644 --- a/src/SketcherPrs/SketcherPrs_Factory.cpp +++ b/src/SketcherPrs/SketcherPrs_Factory.cpp @@ -16,6 +16,7 @@ #include "SketcherPrs_Radius.h" #include "SketcherPrs_LengthDimension.h" #include "SketcherPrs_Mirror.h" +#include "SketcherPrs_Transformation.h" #define CONSTRAINT_PRS_IMPL(NAME, CLASS) \ AISObjectPtr SketcherPrs_Factory::NAME(ModelAPI_Feature* theConstraint, \ @@ -55,3 +56,21 @@ AISObjectPtr SketcherPrs_Factory::verticalConstraint(ModelAPI_Feature* theConstr aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); return aAISObj; } + +AISObjectPtr SketcherPrs_Factory::translateConstraint(ModelAPI_Feature* theConstraint, + const std::shared_ptr& thePlane) +{ + std::shared_ptr aAISObj = AISObjectPtr(new GeomAPI_AISObject()); + Handle(SketcherPrs_Transformation) aPrs = new SketcherPrs_Transformation(theConstraint, thePlane, true); + aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); + return aAISObj; +} + +AISObjectPtr SketcherPrs_Factory::rotateConstraint(ModelAPI_Feature* theConstraint, + const std::shared_ptr& thePlane) +{ + std::shared_ptr aAISObj = AISObjectPtr(new GeomAPI_AISObject()); + Handle(SketcherPrs_Transformation) aPrs = new SketcherPrs_Transformation(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 9b627b940..291484d3b 100644 --- a/src/SketcherPrs/SketcherPrs_Factory.h +++ b/src/SketcherPrs/SketcherPrs_Factory.h @@ -30,7 +30,7 @@ public: /// \param thePlane the current sketch plane GET_CONSTRAINT_PRS(coincidentConstraint) - /// Creates coincedent parallel presentation + /// Creates parallel constraint presentation /// \param theConstraint the constraint /// \param thePlane the current sketch plane GET_CONSTRAINT_PRS(parallelConstraint) @@ -40,45 +40,55 @@ public: /// \param thePlane the current sketch plane GET_CONSTRAINT_PRS(perpendicularConstraint) - /// Creates coincedent perpendicular presentation + /// Creates rigid constraint presentation /// \param theConstraint the constraint /// \param thePlane the current sketch plane GET_CONSTRAINT_PRS(rigidConstraint) - /// Creates coincedent perpendicular presentation + /// Creates horizontal constraint presentation /// \param theConstraint the constraint /// \param thePlane the current sketch plane GET_CONSTRAINT_PRS(horisontalConstraint) - /// Creates coincedent perpendicular presentation + /// Creates vertical constraint presentation /// \param theConstraint the constraint /// \param thePlane the current sketch plane GET_CONSTRAINT_PRS(verticalConstraint) - /// Creates coincedent perpendicular presentation + /// Creates equal constraint presentation /// \param theConstraint the constraint /// \param thePlane the current sketch plane GET_CONSTRAINT_PRS(equalConstraint) - /// Creates coincedent perpendicular presentation + /// Creates tangent constraiont presentation /// \param theConstraint the constraint /// \param thePlane the current sketch plane GET_CONSTRAINT_PRS(tangentConstraint) - /// Creates coincedent perpendicular presentation + /// Creates radius dimension presentation /// \param theConstraint the constraint /// \param thePlane the current sketch plane GET_CONSTRAINT_PRS(radiusConstraint) - /// Creates coincedent perpendicular presentation + /// Creates length dimension presentation /// \param theConstraint the constraint /// \param thePlane the current sketch plane GET_CONSTRAINT_PRS(lengthDimensionConstraint) - /// Creates coincedent perpendicular presentation + /// Creates mirror constraint presentation /// \param theConstraint the constraint /// \param thePlane the current sketch plane GET_CONSTRAINT_PRS(mirrorConstraint) + + /// Creates translate constraint presentation + /// \param theConstraint the constraint + /// \param thePlane the current sketch plane + GET_CONSTRAINT_PRS(translateConstraint) + + /// Creates rotate constraint presentation + /// \param theConstraint the constraint + /// \param thePlane the current sketch plane + GET_CONSTRAINT_PRS(rotateConstraint) }; #endif diff --git a/src/SketcherPrs/SketcherPrs_Mirror.cpp b/src/SketcherPrs/SketcherPrs_Mirror.cpp index 2c05d225f..2c680a64a 100644 --- a/src/SketcherPrs/SketcherPrs_Mirror.cpp +++ b/src/SketcherPrs/SketcherPrs_Mirror.cpp @@ -10,8 +10,6 @@ #include -#include - #include #include @@ -76,7 +74,6 @@ void SketcherPrs_Mirror::drawLines(const Handle(Prs3d_Presentation)& thePrs, Qua if (anAttrC.get() == NULL) return; - SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get(); int aNb = anAttrB->size(); if (aNb != anAttrC->size()) return; @@ -90,20 +87,9 @@ void SketcherPrs_Mirror::drawLines(const Handle(Prs3d_Presentation)& thePrs, Qua addLine(aGroup, SketchPlugin_Constraint::ENTITY_A()); // Draw source objects - int i; - ObjectPtr aObj; - for (i = 0; i < aNb; i++) { - aObj = anAttrB->object(i); - std::shared_ptr aShape = SketcherPrs_Tools::getShape(aObj); - if (aShape.get() != NULL) - drawShape(aShape, thePrs); - } + drawListOfShapes(anAttrB, thePrs); + // draw mirrored objects - for (i = 0; i < aNb; i++) { - aObj = anAttrC->object(i); - std::shared_ptr aShape = SketcherPrs_Tools::getShape(aObj); - if (aShape.get() != NULL) - drawShape(aShape, thePrs); - } + drawListOfShapes(anAttrC, thePrs); } diff --git a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp index b4e646709..9a7e9a431 100644 --- a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp +++ b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp @@ -335,10 +335,12 @@ void SketcherPrs_SymbolPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& int aNbVertex = myPntArray->VertexNumber(); if (myOwner.IsNull()) { myOwner = new SelectMgr_EntityOwner(this); - for (int i = 1; i <= aNbVertex; i++) { - Handle(SketcherPrs_SensitivePoint) aSP = new SketcherPrs_SensitivePoint(myOwner, myPntArray, i); - mySPoints.Append(aSP); - } + } + + mySPoints.Clear(); + for (int i = 1; i <= aNbVertex; i++) { + Handle(SketcherPrs_SensitivePoint) aSP = new SketcherPrs_SensitivePoint(myOwner, myPntArray, i); + mySPoints.Append(aSP); } Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePresentation); @@ -465,3 +467,20 @@ void SketcherPrs_SymbolPrs::drawShape(const std::shared_ptr& theS StdPrs_Point::Add(thePrs, aPoint, myDrawer); } } + +void SketcherPrs_SymbolPrs::drawListOfShapes(const std::shared_ptr& theListAttr, + const Handle(Prs3d_Presentation)& thePrs) const +{ + int aNb = theListAttr->size(); + if (aNb == 0) + return; + int i; + ObjectPtr aObj; + for (i = 0; i < aNb; i++) { + aObj = theListAttr->object(i); + std::shared_ptr aShape = SketcherPrs_Tools::getShape(aObj); + if (aShape.get() != NULL) + drawShape(aShape, thePrs); + } +} + diff --git a/src/SketcherPrs/SketcherPrs_SymbolPrs.h b/src/SketcherPrs/SketcherPrs_SymbolPrs.h index b6c0cf66a..d2202bacf 100644 --- a/src/SketcherPrs/SketcherPrs_SymbolPrs.h +++ b/src/SketcherPrs/SketcherPrs_SymbolPrs.h @@ -9,6 +9,7 @@ #include "SketcherPrs_SensitivePoint.h" #include +#include #include #include @@ -115,6 +116,11 @@ protected: void drawShape(const std::shared_ptr& theShape, const Handle(Prs3d_Presentation)& thePrs) const; + /// Draw a list of shapes stored in a RefListAttribute + /// \param theListAttr the attribute of reference3s list + /// \param thePrs the presentation scene + void drawListOfShapes(const std::shared_ptr& theListAttr, + const Handle(Prs3d_Presentation)& thePrs) const; protected: /// Constraint feature diff --git a/src/SketcherPrs/SketcherPrs_Transformation.cpp b/src/SketcherPrs/SketcherPrs_Transformation.cpp new file mode 100644 index 000000000..dcbe96667 --- /dev/null +++ b/src/SketcherPrs/SketcherPrs_Transformation.cpp @@ -0,0 +1,71 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: SketcherPrs_Transformation.cpp +// Created: 16 February 2015 +// Author: Vitaly SMETANNIKOV + +#include "SketcherPrs_Transformation.h" +#include "SketcherPrs_Tools.h" +#include "SketcherPrs_PositionMgr.h" + +#include +#include + +#include +#include + + + +IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Transformation, SketcherPrs_SymbolPrs); +IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Transformation, SketcherPrs_SymbolPrs); + +static Handle(Image_AlienPixMap) MyPixMap; + +SketcherPrs_Transformation::SketcherPrs_Transformation(ModelAPI_Feature* theConstraint, + const std::shared_ptr& thePlane, + bool isTranslation) + : SketcherPrs_SymbolPrs(theConstraint, thePlane), myIsTranslation(isTranslation) +{ +} + +bool SketcherPrs_Transformation::updatePoints(double theStep) const +{ + std::shared_ptr aData = myConstraint->data(); + std::shared_ptr anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B()); + if (anAttrB.get() == NULL) + return false; + + int aNbB = anAttrB->size(); + if (aNbB == 0) + return false; + + SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get(); + myPntArray = new Graphic3d_ArrayOfPoints(aNbB); + + int i; + ObjectPtr aObj; + gp_Pnt aP1; + for (i = 0; i < aNbB; i++) { + aObj = anAttrB->object(i); + aP1 = aMgr->getPosition(aObj, this, theStep); + myPntArray->SetVertice(i + 1, aP1); + } + + return true; +} + +void SketcherPrs_Transformation::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const +{ + std::shared_ptr aData = myConstraint->data(); + std::shared_ptr anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B()); + if (anAttrB.get() == NULL) + return; + + Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs); + + Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2); + aGroup->SetPrimitivesAspect(aLineAspect); + + drawListOfShapes(anAttrB, thePrs); +} + diff --git a/src/SketcherPrs/SketcherPrs_Transformation.h b/src/SketcherPrs/SketcherPrs_Transformation.h new file mode 100644 index 000000000..6ba9bc8e4 --- /dev/null +++ b/src/SketcherPrs/SketcherPrs_Transformation.h @@ -0,0 +1,48 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: SketcherPrs_Transformation.h +// Created: 16 February 2015 +// Author: Vitaly SMETANNIKOV + +#ifndef SketcherPrs_Transformation_H +#define SketcherPrs_Transformation_H + +#include "SketcherPrs_SymbolPrs.h" +#include + + +DEFINE_STANDARD_HANDLE(SketcherPrs_Transformation, SketcherPrs_SymbolPrs) + +/** +* \ingroup GUI +* A redefinition of standard AIS Interactive Object in order to provide +* presentation of parallel constraint +*/ +class SketcherPrs_Transformation: public SketcherPrs_SymbolPrs +{ +public: + /// Constructor + /// \param theConstraint a constraint feature + /// \param thePlane a coordinate plane of current sketch + Standard_EXPORT SketcherPrs_Transformation(ModelAPI_Feature* theConstraint, + const std::shared_ptr& thePlane, + bool isTranslation); + + DEFINE_STANDARD_RTTI(SketcherPrs_Transformation) +protected: + virtual const char* iconName() const { return myIsTranslation? "translate.png" : "rotate.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; + + /// Update myPntArray according to presentation positions + /// \return true in case of success + virtual bool updatePoints(double theStep) const; + +private: + bool myIsTranslation; +}; + +#endif \ No newline at end of file diff --git a/src/SketcherPrs/icons/rotate.png b/src/SketcherPrs/icons/rotate.png new file mode 100644 index 0000000000000000000000000000000000000000..300121ca0dd9b25621fdd7f5608668146488f71d GIT binary patch literal 288 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&k#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!phSslL`iUdT1k0gQ7S`0VrE{6US4X6f{C7i zo@r{UQ7TZ)L{AsT5RKs0i5mqQ6nI=E4;(twbcj)=;}D~cOmnQR>_Mex&K-;&pS<%t z^WR?F-`$04zUi@!M+`yvQ{8*wj_56_mdKI;Vst0DJml<^TWy literal 0 HcmV?d00001 diff --git a/src/SketcherPrs/icons/translate.png b/src/SketcherPrs/icons/translate.png new file mode 100644 index 0000000000000000000000000000000000000000..54be370f477db4ef4ab1df82d16ccd063406fa56 GIT binary patch literal 243 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&k#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!phSslL`iUdT1k0gQ7S`0VrE{6US4X6f{C7i zo@r{UQ7TYPil>WXh(_?#2^V=A3^-gQ4=~CcG`xA!-`?+>NRVgr#3!xZ6SUaWzP9*+vhLtwuyUYyiw)9 hy;{Q8BBwH*;0>uvoFSp;WCyg5!PC{xWt~$(69CIkO~U{H literal 0 HcmV?d00001 diff --git a/src/XGUI/XGUI_pictures.qrc b/src/XGUI/XGUI_pictures.qrc index 085837a92..de9da1ce1 100644 --- a/src/XGUI/XGUI_pictures.qrc +++ b/src/XGUI/XGUI_pictures.qrc @@ -46,5 +46,6 @@ pictures/shading.png pictures/wireframe.png pictures/expression.png + pictures/arrow.png diff --git a/src/XGUI/pictures/arrow.png b/src/XGUI/pictures/arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..47cc73d9b02a2e0f9949f9a7380a84ff743aa818 GIT binary patch literal 748 zcmVPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02p*dSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E;VI^GGzb&0$oW&K~y+Tm6B~pQ(+XxE!}R#@q^_v{;npqBYy5ZH<;unVP9fiiqgNQqgL*8IcfCLM%22R(%NeqRhRKL4E5} zANm^fE&F%w)y;|u_JheXpxqJ}6J0}JBy7EP-q$Y7deKepJE zHz~GaKDDTSolJ*HH4&`+4Y{m{Xvd18D1>VMmW~%N^k7wEQ^|+$-mhHJlcY* zU>M`RQ%>q2XLcqz^vnuyzZ1}v5a5b1w7wxi4EC1{r$Q?9zOID(l@_}O*k|%cGY|*W zbTrCIrt?Vw-7^9@rvg>qAfLr1Ix zeQ|mmSL5m?WF?bVB+?{gZtY1rCS3Dr!Z=1*)CuJCzHefW-gnLOd zys1`&>}gGp!bb1@xxS)!gI9*pm>rD|x$Gk4ExvxF2zA3nVu4>*IWO_rONC+q eaYz26f`Xr{E%2kOx9hP00000