X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketcherPrs%2FSketcherPrs_Angle.cpp;h=c8f79b464d7f1b696f4b4a56cf0b1e8fc69688cc;hb=db25cb9e9be0ce3e2332141f7f2f47f088956bea;hp=4376f773ff39720b91e527883dd3d49ebf360fcb;hpb=423c10234142d14d0d5de89383f2f96a4ec5930f;p=modules%2Fshaper.git diff --git a/src/SketcherPrs/SketcherPrs_Angle.cpp b/src/SketcherPrs/SketcherPrs_Angle.cpp index 4376f773f..c8f79b464 100644 --- a/src/SketcherPrs/SketcherPrs_Angle.cpp +++ b/src/SketcherPrs/SketcherPrs_Angle.cpp @@ -1,12 +1,26 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: SketcherPrs_Angle.cpp -// Created: 20 August 2015 -// Author: Vitaly SMETANNIKOV +// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or +// email : webmaster.salome@opencascade.com +// #include "SketcherPrs_Angle.h" -#include "SketcherPrs_Tools.h" #include "SketcherPrs_DimensionStyleListener.h" +#include "SketcherPrs_Tools.h" #include #include @@ -25,13 +39,19 @@ #include #include +/// Update variable aspect parameters (depending on viewer scale) +/// \param theDimAspect an aspect to be changed +/// \param theDimValue an arrow value +/// \param theTextSize an arrow value +extern void updateArrows(Handle_Prs3d_DimensionAspect theDimAspect, + double theDimValue, double theTextSize, SketcherPrs_Tools::LocationType theLocationType); + #define PI 3.1415926535897932 //#ifndef WNT // #define COMPILATION_CORRECTION //#endif -IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Angle, AIS_AngleDimension); IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Angle, AIS_AngleDimension); SketcherPrs_Angle::SketcherPrs_Angle(ModelAPI_Feature* theConstraint, @@ -46,7 +66,7 @@ SketcherPrs_Angle::SketcherPrs_Angle(ModelAPI_Feature* theConstraint, myAspect->MakeText3d(false); myAspect->MakeTextShaded(false); myAspect->MakeUnitsDisplayed(false); - myAspect->TextAspect()->SetHeight(SketcherPrs_Tools::getDefaultTextHeight()); + myAspect->TextAspect()->SetHeight(SketcherPrs_Tools::getConfigTextHeight()); myAspect->ArrowAspect()->SetLength(SketcherPrs_Tools::getArrowSize()); SetDimensionAspect(myAspect); @@ -176,12 +196,12 @@ void SketcherPrs_Angle::Compute(const Handle(PrsMgr_PresentationManager3d)& theP switch (anAngleType) { case SketcherPrs_Tools::ANGLE_DIRECT: { #ifndef COMPILATION_CORRECTION - SetArrowVisible(Standard_False/*first*/, Standard_True/*second*/); + SetArrowsVisibility(AIS_TOAV_Second); #endif SetMeasuredGeometry(myFirstPoint, myCenterPoint, mySecondPoint); #ifndef COMPILATION_CORRECTION bool isReversedPlanes = isAnglePlaneReversedToSketchPlane(); - SetAngleReversed(!isReversedPlanes); + SetType(!isReversedPlanes ? AIS_TOA_Exterior : AIS_TOA_Interior); #endif } break; @@ -192,18 +212,18 @@ void SketcherPrs_Angle::Compute(const Handle(PrsMgr_PresentationManager3d)& theP gp_Vec(myCenterPoint, myFirstPoint).Normalized() * (-anEdge1Length)); SetMeasuredGeometry(aFirstPoint, myCenterPoint, mySecondPoint); #ifndef COMPILATION_CORRECTION - SetAngleReversed(false); + SetType(AIS_TOA_Interior); #endif } break; case SketcherPrs_Tools::ANGLE_BACKWARD: { #ifndef COMPILATION_CORRECTION - SetArrowVisible(Standard_False/*first*/, Standard_True/*second*/); + SetArrowsVisibility(AIS_TOAV_Second); #endif SetMeasuredGeometry(myFirstPoint, myCenterPoint, mySecondPoint); bool isReversedPlanes = isAnglePlaneReversedToSketchPlane(); #ifndef COMPILATION_CORRECTION - SetAngleReversed(isReversedPlanes); + SetType(isReversedPlanes ? AIS_TOA_Exterior : AIS_TOA_Interior); #endif } break; @@ -217,8 +237,19 @@ void SketcherPrs_Angle::Compute(const Handle(PrsMgr_PresentationManager3d)& theP // Update text visualization: parameter value or parameter text myStyleListener->updateDimensions(this, myValue); - myAspect->SetExtensionSize(myAspect->ArrowAspect()->Length()); - myAspect->SetArrowTailSize(myAspect->ArrowAspect()->Length()); + double aTextSize = 0.0; + GetValueString(aTextSize); + AttributeIntegerPtr aLocAttr = std::dynamic_pointer_cast + (myConstraint->data()->attribute(SketchPlugin_ConstraintAngle::LOCATION_TYPE_ID())); + SketcherPrs_Tools::LocationType aLocationType = aLocAttr->isInitialized() ? + (SketcherPrs_Tools::LocationType)(aLocAttr->value()) : SketcherPrs_Tools::LOCATION_AUTOMATIC; + + double aRadius = myCenterPoint.Translated( + gp_Vec(myCenterPoint, myFirstPoint).Normalized()*aDist).Distance(myCenterPoint); + double anAngleValue = myValue.myDoubleValue; + double anAngleCircleLength = aRadius * anAngleValue * PI / 180.; + + updateArrows(myAspect, anAngleCircleLength, aTextSize, aLocationType); AIS_AngleDimension::Compute(thePresentationManager, thePresentation, theMode); @@ -250,7 +281,7 @@ void SketcherPrs_Angle::ComputeSelection(const Handle(SelectMgr_Selection)& aSel return; } } - SetSelToleranceForText2d(SketcherPrs_Tools::getTextHeight()); + SetSelToleranceForText2d(SketcherPrs_Tools::getArrowSize()/5.); AIS_AngleDimension::ComputeSelection(aSelection, aMode); }