From: vsv Date: Fri, 16 Dec 2016 14:20:19 +0000 (+0300) Subject: Porting of dimensions X-Git-Tag: V_2.7.0~351^2~55^2~13 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d001905c7f8188c0c4bcbf1ac5a649f69d1fdfda;p=modules%2Fshaper.git Porting of dimensions --- diff --git a/src/SketcherPrs/SketcherPrs_Angle.cpp b/src/SketcherPrs/SketcherPrs_Angle.cpp index 03b495a84..03a74c4fb 100644 --- a/src/SketcherPrs/SketcherPrs_Angle.cpp +++ b/src/SketcherPrs/SketcherPrs_Angle.cpp @@ -5,8 +5,8 @@ // Author: Vitaly SMETANNIKOV #include "SketcherPrs_Angle.h" -#include "SketcherPrs_Tools.h" #include "SketcherPrs_DimensionStyleListener.h" +#include "SketcherPrs_Tools.h" #include #include @@ -180,8 +180,7 @@ void SketcherPrs_Angle::Compute(const Handle(PrsMgr_PresentationManager3d)& theP SetMeasuredGeometry(myFirstPoint, myCenterPoint, mySecondPoint); #ifndef COMPILATION_CORRECTION bool isReversedPlanes = isAnglePlaneReversedToSketchPlane(); - SetType(!isReversedPlanes ? AIS_TypeOfAngle::AIS_TOA_Exterior - : AIS_TypeOfAngle::AIS_TOA_Interior); + SetType(!isReversedPlanes ? AIS_TOA_Exterior : AIS_TOA_Interior); #endif } break; @@ -192,19 +191,18 @@ void SketcherPrs_Angle::Compute(const Handle(PrsMgr_PresentationManager3d)& theP gp_Vec(myCenterPoint, myFirstPoint).Normalized() * (-anEdge1Length)); SetMeasuredGeometry(aFirstPoint, myCenterPoint, mySecondPoint); #ifndef COMPILATION_CORRECTION - SetType(AIS_TypeOfAngle::AIS_TOA_Interior); + SetType(AIS_TOA_Interior); #endif } break; case SketcherPrs_Tools::ANGLE_BACKWARD: { #ifndef COMPILATION_CORRECTION - SetArrowsVisibility(AIS_TypeOfAngleArrowVisibility::AIS_TOAV_Second); + SetArrowsVisibility(AIS_TOAV_Second); #endif SetMeasuredGeometry(myFirstPoint, myCenterPoint, mySecondPoint); bool isReversedPlanes = isAnglePlaneReversedToSketchPlane(); #ifndef COMPILATION_CORRECTION - SetType(isReversedPlanes ? AIS_TypeOfAngle::AIS_TOA_Exterior - : AIS_TypeOfAngle::AIS_TOA_Interior); + SetType(isReversedPlanes ? AIS_TOA_Exterior : AIS_TOA_Interior); #endif } break; diff --git a/src/SketcherPrs/SketcherPrs_LengthDimension.cpp b/src/SketcherPrs/SketcherPrs_LengthDimension.cpp index a315082f2..300d30c7f 100644 --- a/src/SketcherPrs/SketcherPrs_LengthDimension.cpp +++ b/src/SketcherPrs/SketcherPrs_LengthDimension.cpp @@ -27,6 +27,47 @@ #include +/// Creates an aspect to be shown in length/radius dimension presentations +/// \return an instance of aspect +Handle(Prs3d_DimensionAspect) createDimensionAspect() +{ + Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect(); + anAspect->MakeArrows3d(false); + anAspect->MakeText3d(false); + anAspect->MakeTextShaded(false); + anAspect->MakeUnitsDisplayed(false); + anAspect->TextAspect()->SetHeight(SketcherPrs_Tools::getDefaultTextHeight()); + anAspect->ArrowAspect()->SetLength(SketcherPrs_Tools::getArrowSize()); + + return anAspect; +} + +/// 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 +void updateArrows(Handle(Prs3d_DimensionAspect) theDimAspect, + double theDimValue, double theTextSize) +{ + double anArrowLength = theDimAspect->ArrowAspect()->Length(); + // This is not realy correct way to get viewer scale. + double aViewerScale = (double) SketcherPrs_Tools::getDefaultArrowSize() / anArrowLength; + + if(theTextSize > ((theDimValue - 3 * SketcherPrs_Tools::getArrowSize()) * aViewerScale)) { + theDimAspect->SetTextHorizontalPosition(Prs3d_DTHP_Left); + theDimAspect->SetArrowOrientation(Prs3d_DAO_External); + theDimAspect->SetExtensionSize( + (theTextSize / aViewerScale + SketcherPrs_Tools::getArrowSize()) / 2.0); + } else { + theDimAspect->SetTextHorizontalPosition(Prs3d_DTHP_Center); + theDimAspect->SetArrowOrientation(Prs3d_DAO_Internal); + } + theDimAspect->SetArrowTailSize(theDimAspect->ArrowAspect()->Length()); + // The value of vertical aligment is sometimes changed + theDimAspect->TextAspect()->SetVerticalJustification(Graphic3d_VTA_CENTER); +} + + static const gp_Pnt MyDefStart(0,0,0); static const gp_Pnt MyDefEnd(1,0,0); static const gp_Pln MyDefPln(gp_Pnt(0,0,0), gp_Dir(0,0,1)); @@ -44,8 +85,7 @@ SketcherPrs_LengthDimension::SketcherPrs_LengthDimension(ModelAPI_Feature* theCo myDistance(1), myValue(0., false, "") { - // PORTING_TO_SALOME_8 - // SetDimensionAspect(SketcherPrs_Tools::createDimensionAspect()); + SetDimensionAspect(createDimensionAspect()); myStyleListener = new SketcherPrs_DimensionStyleListener(); } @@ -88,8 +128,7 @@ void SketcherPrs_LengthDimension::Compute( double aTextSize = 0.0; GetValueString(aTextSize); - // PORTING_TO_SALOME_8 - //SketcherPrs_Tools::updateArrows(DimensionAspect(), GetValue(), aTextSize); + updateArrows(DimensionAspect(), GetValue(), aTextSize); // Update text visualization: parameter value or parameter text myStyleListener->updateDimensions(this, myValue); diff --git a/src/SketcherPrs/SketcherPrs_Radius.cpp b/src/SketcherPrs/SketcherPrs_Radius.cpp index 985f6babc..d4e3dc9d5 100644 --- a/src/SketcherPrs/SketcherPrs_Radius.cpp +++ b/src/SketcherPrs/SketcherPrs_Radius.cpp @@ -21,6 +21,18 @@ #include +/// Creates an aspect to be shown in length/radius dimension presentations +/// \return an instance of aspect +extern Handle(Prs3d_DimensionAspect) createDimensionAspect(); + +/// 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); + + static const gp_Circ MyDefCirc(gp_Ax2(gp_Pnt(0,0,0), gp_Dir(0,0,1)), 1); IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Radius, AIS_RadiusDimension); @@ -32,8 +44,7 @@ SketcherPrs_Radius::SketcherPrs_Radius(ModelAPI_Feature* theConstraint, myAnchorPoint(gp_Pnt(0, 0, 2)), myValue(1, false, "") { - // PORTING_TO_SALOME_8 - // SetDimensionAspect(SketcherPrs_Tools::createDimensionAspect()); + SetDimensionAspect(createDimensionAspect()); myStyleListener = new SketcherPrs_DimensionStyleListener(); } @@ -138,8 +149,7 @@ void SketcherPrs_Radius::Compute( // Update variable aspect parameters (depending on viewer scale) double aTextSize = 0.0; GetValueString(aTextSize); - // PORTING_TO_SALOME_8 - //SketcherPrs_Tools::updateArrows(DimensionAspect(), GetValue(), aTextSize); + updateArrows(DimensionAspect(), GetValue(), aTextSize); AIS_RadiusDimension::Compute(thePresentationManager, thePresentation, theMode); diff --git a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp index ba5424ea6..24a31bc88 100644 --- a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp +++ b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp @@ -231,8 +231,8 @@ private: //************************************************************** // PORTING_TO_SALOME_8 -/*//! Definition of call back -OpenGl_Element* SymbolPrsCallBack(const CALL_DEF_USERDRAW * theUserDraw) +//! Definition of call back +/*OpenGl_Element* SymbolPrsCallBack(const CALL_DEF_USERDRAW * theUserDraw) { Handle(SketcherPrs_SymbolPrs) anIObj = (SketcherPrs_SymbolPrs*)theUserDraw->Data; if (anIObj.IsNull()) { diff --git a/src/SketcherPrs/SketcherPrs_Tools.cpp b/src/SketcherPrs/SketcherPrs_Tools.cpp index edd56ad30..50adc14bc 100644 --- a/src/SketcherPrs/SketcherPrs_Tools.cpp +++ b/src/SketcherPrs/SketcherPrs_Tools.cpp @@ -28,7 +28,7 @@ #include #include -//#include +#include #include #include @@ -297,40 +297,6 @@ void sendExpressionShownEvent(const bool& theState) Events_Loop::loop()->flush(anId); } -/*Handle(Prs3d_DimensionAspect) createDimensionAspect() -{ - Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect(); - anAspect->MakeArrows3d(false); - anAspect->MakeText3d(false); - anAspect->MakeTextShaded(false); - anAspect->MakeUnitsDisplayed(false); - anAspect->TextAspect()->SetHeight(SketcherPrs_Tools::getDefaultTextHeight()); - anAspect->ArrowAspect()->SetLength(SketcherPrs_Tools::getArrowSize()); - - return anAspect; -} - -void updateArrows(Handle(Prs3d_DimensionAspect) theDimAspect, - double theDimValue, double theTextSize) -{ - double anArrowLength = theDimAspect->ArrowAspect()->Length(); - // This is not realy correct way to get viewer scale. - double aViewerScale = (double) SketcherPrs_Tools::getDefaultArrowSize() / anArrowLength; - - if(theTextSize > ((theDimValue - 3 * SketcherPrs_Tools::getArrowSize()) * aViewerScale)) { - theDimAspect->SetTextHorizontalPosition(Prs3d_DTHP_Left); - theDimAspect->SetArrowOrientation(Prs3d_DAO_External); - theDimAspect->SetExtensionSize( - (theTextSize / aViewerScale + SketcherPrs_Tools::getArrowSize()) / 2.0); - } else { - theDimAspect->SetTextHorizontalPosition(Prs3d_DTHP_Center); - theDimAspect->SetArrowOrientation(Prs3d_DAO_Internal); - } - theDimAspect->SetArrowTailSize(theDimAspect->ArrowAspect()->Length()); - // The value of vertical aligment is sometimes changed - theDimAspect->TextAspect()->SetVerticalJustification(Graphic3d_VTA_CENTER); -}*/ - void sendEmptyPresentationError(ModelAPI_Feature* theFeature, const std::string theError) { Events_InfoMessage("SketcherPrs_Tools", diff --git a/src/SketcherPrs/SketcherPrs_Tools.h b/src/SketcherPrs/SketcherPrs_Tools.h index 365961fcb..aad79acc0 100644 --- a/src/SketcherPrs/SketcherPrs_Tools.h +++ b/src/SketcherPrs/SketcherPrs_Tools.h @@ -19,9 +19,6 @@ #include #include -// PORTING_TO_SALOME_8 -//class Handle_Prs3d_DimensionAspect; - class GeomDataAPI_Point2D; class AIS_Dimension; @@ -171,17 +168,6 @@ namespace SketcherPrs_Tools { /// \param theState a new state SKETCHERPRS_EXPORT void sendExpressionShownEvent(const bool& theState); - /// Creates an aspect to be shown in length/radius dimension presentations - /// \return an instance of aspect - //SKETCHERPRS_EXPORT Handle_Prs3d_DimensionAspect createDimensionAspect(); - - /// 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 - //SKETCHERPRS_EXPORT void updateArrows(Handle_Prs3d_DimensionAspect theDimAspect, - // double theDimValue, double theTextSize); - /// Throws an exception(in debug mode) and sends a signal about necessity to hide the object /// \param theFeature a feature where AIS presentation is empty /// \param theError a debug error information