From: nds Date: Wed, 4 Oct 2017 06:01:43 +0000 (+0300) Subject: #2205 Ability to customize the arrows and texts of dimensions: Default arrow/text... X-Git-Tag: V_2.9.0~22 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=456499432be32573f88db84184d9a1b9319a32cd;p=modules%2Fshaper.git #2205 Ability to customize the arrows and texts of dimensions: Default arrow/text size of dimensions. --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 282f82889..4cdd4e928 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -986,14 +986,14 @@ void PartSet_Module::onViewTransformed(int theTrsfType) } if (aView.IsNull()) return; - double aLen = aView->Convert(SketcherPrs_Tools::getDefaultArrowSize()); + double aLen = aView->Convert(SketcherPrs_Tools::getConfigArrowSize()); double aPrevLen = SketcherPrs_Tools::getArrowSize(); SketcherPrs_Tools::setArrowSize(aLen); - const double aPrevScale = aViewer->Scale(aViewer->activeView()); const double aCurScale = aViewer->activeView()->Camera()->Scale(); aViewer->SetScale(aViewer->activeView(), aCurScale); - SketcherPrs_Tools::setTextHeight (aCurScale / aPrevScale * SketcherPrs_Tools::getTextHeight()); + double aTextHeight = SketcherPrs_Tools::getConfigTextHeight(); + SketcherPrs_Tools::setTextHeight (aTextHeight); bool isModified = false; QList aPrsList = aDisplayer->displayedPresentations(); foreach (AISObjectPtr aAIS, aPrsList) { @@ -1002,6 +1002,7 @@ void PartSet_Module::onViewTransformed(int theTrsfType) Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(aAisObj); if (!aDim.IsNull()) { aDim->DimensionAspect()->ArrowAspect()->SetLength(aLen); + aDim->DimensionAspect()->TextAspect()->SetHeight(aTextHeight); aContext->Redisplay(aDim, false); isModified = true; } diff --git a/src/SketcherPrs/SketcherPrs_Angle.cpp b/src/SketcherPrs/SketcherPrs_Angle.cpp index 400f07099..5deea42e4 100644 --- a/src/SketcherPrs/SketcherPrs_Angle.cpp +++ b/src/SketcherPrs/SketcherPrs_Angle.cpp @@ -66,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); diff --git a/src/SketcherPrs/SketcherPrs_LengthDimension.cpp b/src/SketcherPrs/SketcherPrs_LengthDimension.cpp index 9de74eb32..c0c79a10a 100644 --- a/src/SketcherPrs/SketcherPrs_LengthDimension.cpp +++ b/src/SketcherPrs/SketcherPrs_LengthDimension.cpp @@ -54,7 +54,7 @@ Handle(Prs3d_DimensionAspect) createDimensionAspect() anAspect->MakeText3d(false); anAspect->MakeTextShaded(false); anAspect->MakeUnitsDisplayed(false); - anAspect->TextAspect()->SetHeight(SketcherPrs_Tools::getDefaultTextHeight()); + anAspect->TextAspect()->SetHeight(SketcherPrs_Tools::getConfigTextHeight()); anAspect->ArrowAspect()->SetLength(SketcherPrs_Tools::getArrowSize()); return anAspect; @@ -70,7 +70,7 @@ void updateArrows(Handle(Prs3d_DimensionAspect) theDimAspect, if (theLocationType == SketcherPrs_Tools::LOCATION_AUTOMATIC) { double anArrowLength = theDimAspect->ArrowAspect()->Length(); // This is not realy correct way to get viewer scale. - double aViewerScale = (double) SketcherPrs_Tools::getDefaultArrowSize() / anArrowLength; + double aViewerScale = (double) SketcherPrs_Tools::getConfigArrowSize() / anArrowLength; if(theTextSize > ((theDimValue - 3 * SketcherPrs_Tools::getArrowSize()) * aViewerScale)) { theDimAspect->SetTextHorizontalPosition(Prs3d_DTHP_Left); @@ -90,7 +90,7 @@ void updateArrows(Handle(Prs3d_DimensionAspect) theDimAspect, double anArrowLength = theDimAspect->ArrowAspect()->Length(); // This is not realy correct way to get viewer scale. - double aViewerScale = (double) SketcherPrs_Tools::getDefaultArrowSize() / anArrowLength; + double aViewerScale = (double) SketcherPrs_Tools::getConfigArrowSize() / anArrowLength; theDimAspect->SetExtensionSize( (theTextSize / aViewerScale + SketcherPrs_Tools::getArrowSize()) / 2.0); } diff --git a/src/SketcherPrs/SketcherPrs_Tools.cpp b/src/SketcherPrs/SketcherPrs_Tools.cpp index 5bf2840ba..97aa2d015 100644 --- a/src/SketcherPrs/SketcherPrs_Tools.cpp +++ b/src/SketcherPrs/SketcherPrs_Tools.cpp @@ -240,6 +240,11 @@ int getDefaultArrowSize() return 20; } +int getConfigArrowSize() +{ + return Config_PropManager::integer(SKETCH_TAB_NAME, "dimension_arrow_size"); +} + static double MyTextHeight = 16; double getTextHeight() { @@ -256,6 +261,11 @@ double getDefaultTextHeight() return 16; } +double getConfigTextHeight() +{ + return Config_PropManager::integer(SKETCH_TAB_NAME, "dimension_value_size"); +} + double getFlyoutDistance(const ModelAPI_Feature* theConstraint) { std::shared_ptr aFlyoutPoint = diff --git a/src/SketcherPrs/SketcherPrs_Tools.h b/src/SketcherPrs/SketcherPrs_Tools.h index bdb0c5737..f119a3027 100644 --- a/src/SketcherPrs/SketcherPrs_Tools.h +++ b/src/SketcherPrs/SketcherPrs_Tools.h @@ -165,6 +165,9 @@ namespace SketcherPrs_Tools { /// Returns default value of dimension arrows size SKETCHERPRS_EXPORT int getDefaultArrowSize(); + /// Returns value of dimension arrows size set in preferences + SKETCHERPRS_EXPORT int getConfigArrowSize(); + /// Set value of dimension text height /// \param theHeight a height value SKETCHERPRS_EXPORT void setTextHeight(double theHeight); @@ -175,6 +178,9 @@ namespace SketcherPrs_Tools { /// Returns default value of dimension text height SKETCHERPRS_EXPORT double getDefaultTextHeight(); + /// Returns value of dimension text height set in preferences + SKETCHERPRS_EXPORT double getConfigTextHeight(); + /// Get flayout distance of the dimension constraint /// \param theConstraint a dimension constraint object SKETCHERPRS_EXPORT double getFlyoutDistance(const ModelAPI_Feature* theConstraint);