From: dbv Date: Fri, 12 Feb 2016 11:21:34 +0000 (+0300) Subject: Bug #1279: Bad display of distance constraint in the sktech X-Git-Tag: V_2.2.0~128 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=551524964a46d4af95f0c27fb093545a3b1d4730;p=modules%2Fshaper.git Bug #1279: Bad display of distance constraint in the sktech --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index aef61e704..df2a560b7 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -776,7 +776,7 @@ void PartSet_Module::onViewTransformed(int theTrsfType) } if (aView.IsNull()) return; - double aLen = aView->Convert(20); + double aLen = aView->Convert(SketcherPrs_Tools::getDefaultArrowSize()); double aPrevLen = SketcherPrs_Tools::getArrowSize(); SketcherPrs_Tools::setArrowSize(aLen); diff --git a/src/SketcherPrs/SketcherPrs_LengthDimension.cpp b/src/SketcherPrs/SketcherPrs_LengthDimension.cpp index f70de41f5..34cae3a54 100644 --- a/src/SketcherPrs/SketcherPrs_LengthDimension.cpp +++ b/src/SketcherPrs/SketcherPrs_LengthDimension.cpp @@ -37,12 +37,13 @@ static const Standard_ExtCharacter MySummSymbol(0x03A3); IMPLEMENT_STANDARD_HANDLE(SketcherPrs_LengthDimension, AIS_LengthDimension); IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_LengthDimension, AIS_LengthDimension); -SketcherPrs_LengthDimension::SketcherPrs_LengthDimension(ModelAPI_Feature* theConstraint, - const std::shared_ptr& thePlane) -: AIS_LengthDimension(MyDefStart, MyDefEnd, MyDefPln), -myConstraint(theConstraint), myPlane(thePlane) +SketcherPrs_LengthDimension::SketcherPrs_LengthDimension(ModelAPI_Feature* theConstraint, + const std::shared_ptr& thePlane) +: AIS_LengthDimension(MyDefStart, MyDefEnd, MyDefPln), + myConstraint(theConstraint), + myPlane(thePlane), + myAspect(new Prs3d_DimensionAspect()) { - myAspect = new Prs3d_DimensionAspect(); myAspect->MakeArrows3d(false); myAspect->MakeText3d(false); myAspect->MakeTextShaded(false); @@ -54,7 +55,6 @@ myConstraint(theConstraint), myPlane(thePlane) SetDimensionAspect(myAspect); } - void SketcherPrs_LengthDimension::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode) @@ -64,13 +64,27 @@ void SketcherPrs_LengthDimension::Compute(const Handle(PrsMgr_PresentationManage return; // compute flyout distance - double aD = SketcherPrs_Tools::getFlyoutDistance(myConstraint); SetFlyout(SketcherPrs_Tools::getFlyoutDistance(myConstraint)); SetMeasuredGeometry(aPnt1, aPnt2, myPlane->impl()); // Update variable aspect parameters (depending on viewer scale) - myAspect->SetExtensionSize(myAspect->ArrowAspect()->Length()); + double anArrowLength = myAspect->ArrowAspect()->Length(); + // This is not realy correct way to get viewer scale. + double aViewerScale = (double) SketcherPrs_Tools::getDefaultArrowSize() / anArrowLength; + double aDimensionValue = GetValue(); + double aTextSize = 0.0; + GetValueString(aTextSize); + + if(aTextSize > ((aDimensionValue - 3 * SketcherPrs_Tools::getArrowSize()) * aViewerScale)) { + myAspect->SetTextHorizontalPosition(Prs3d_DTHP_Left); + myAspect->SetArrowOrientation(Prs3d_DAO_External); + myAspect->SetExtensionSize(aTextSize / aViewerScale - SketcherPrs_Tools::getArrowSize() / 2.0); + } else { + myAspect->SetTextHorizontalPosition(Prs3d_DTHP_Center); + myAspect->SetArrowOrientation(Prs3d_DAO_Internal); + } myAspect->SetArrowTailSize(myAspect->ArrowAspect()->Length()); + // The value of vertical aligment is sometimes changed myAspect->TextAspect()->SetVerticalJustification(Graphic3d_VTA_CENTER); diff --git a/src/SketcherPrs/SketcherPrs_Radius.cpp b/src/SketcherPrs/SketcherPrs_Radius.cpp index 458bf517b..56f9d7f0e 100644 --- a/src/SketcherPrs/SketcherPrs_Radius.cpp +++ b/src/SketcherPrs/SketcherPrs_Radius.cpp @@ -102,8 +102,24 @@ void SketcherPrs_Radius::Compute(const Handle(PrsMgr_PresentationManager3d)& the SetMeasuredGeometry(aCirc, anAncorPnt); SetCustomValue(aRadius); - myAspect->SetExtensionSize(myAspect->ArrowAspect()->Length()); + // Update variable aspect parameters (depending on viewer scale) + double anArrowLength = myAspect->ArrowAspect()->Length(); + // This is not realy correct way to get viewer scale. + double aViewerScale = (double) SketcherPrs_Tools::getDefaultArrowSize() / anArrowLength; + double aDimensionValue = GetValue(); + double aTextSize = 0.0; + GetValueString(aTextSize); + + if(aTextSize > ((aDimensionValue - 2 * SketcherPrs_Tools::getArrowSize()) * aViewerScale)) { + myAspect->SetTextHorizontalPosition(Prs3d_DTHP_Left); + myAspect->SetArrowOrientation(Prs3d_DAO_External); + myAspect->SetExtensionSize(aTextSize / aViewerScale - SketcherPrs_Tools::getArrowSize() / 2.0); + } else { + myAspect->SetTextHorizontalPosition(Prs3d_DTHP_Center); + myAspect->SetArrowOrientation(Prs3d_DAO_Internal); + } myAspect->SetArrowTailSize(myAspect->ArrowAspect()->Length()); + // The value of vertical aligment is sometimes changed myAspect->TextAspect()->SetVerticalJustification(Graphic3d_VTA_CENTER); diff --git a/src/SketcherPrs/SketcherPrs_Tools.cpp b/src/SketcherPrs/SketcherPrs_Tools.cpp index 847509a1b..be093bc69 100644 --- a/src/SketcherPrs/SketcherPrs_Tools.cpp +++ b/src/SketcherPrs/SketcherPrs_Tools.cpp @@ -194,7 +194,7 @@ std::shared_ptr getProjectionPoint(const FeaturePtr theLine, } -static double MyArrowSize = 24.; +static double MyArrowSize = 20; double getArrowSize() { return MyArrowSize; @@ -205,6 +205,11 @@ void setArrowSize(double theSize) MyArrowSize = theSize; } +int getDefaultArrowSize() +{ + return 20; +} + static double MyTextHeight = 16; double getTextHeight() { diff --git a/src/SketcherPrs/SketcherPrs_Tools.h b/src/SketcherPrs/SketcherPrs_Tools.h index a7c0925b5..0daf04723 100644 --- a/src/SketcherPrs/SketcherPrs_Tools.h +++ b/src/SketcherPrs/SketcherPrs_Tools.h @@ -82,6 +82,9 @@ namespace SketcherPrs_Tools { /// \param theSize a size value SKETCHERPRS_EXPORT void setArrowSize(double theSize); + /// Returns default value of dimension arrows size + SKETCHERPRS_EXPORT int getDefaultArrowSize(); + /// Set value of dimension text height /// \param theHeight a height value SKETCHERPRS_EXPORT void setTextHeight(double theHeight);