X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketcherPrs%2FSketcherPrs_DimensionStyleListener.cpp;h=5c9e3fbe6c81cc9102c1ad36d5a402aa25ee6935;hb=471cc7b52168016a3b6fff7e64cdd800cd7d8f91;hp=e8b950f383b72facb28039ec2b96c0164b3da744;hpb=a49ed1bc5c4745f07d1aabbaf465f25f00ff1040;p=modules%2Fshaper.git diff --git a/src/SketcherPrs/SketcherPrs_DimensionStyleListener.cpp b/src/SketcherPrs/SketcherPrs_DimensionStyleListener.cpp index e8b950f38..5c9e3fbe6 100755 --- a/src/SketcherPrs/SketcherPrs_DimensionStyleListener.cpp +++ b/src/SketcherPrs/SketcherPrs_DimensionStyleListener.cpp @@ -7,9 +7,36 @@ #include "SketcherPrs_DimensionStyleListener.h" #include "SketcherPrs_Tools.h" -#include #include +#include +#include + +//#ifndef WNT +// #define COMPILATION_CORRECTION +//#endif + +// it is not possible to use 0x2211 as summ symbol because it is not supported by +// debian Linux platform +static const Standard_ExtCharacter MyEmptySymbol(' '); +static const Standard_ExtCharacter MySigmaSymbol('=');//0x03A3); // using equal instead of sigma + +SketcherPrs_DimensionStyleListener::DimensionValue::DimensionValue(double theDoubleValue, + bool theHasParameters, const std::string& theTextValue) +: myDoubleValue(theDoubleValue), + myHasParameters(theHasParameters), + myTextValue(theTextValue) +{ +} + +void SketcherPrs_DimensionStyleListener::DimensionValue::init( + const AttributeDoublePtr& theAttributeValue) +{ + myDoubleValue = theAttributeValue->value(); + myHasParameters = theAttributeValue->usedParameters().size() > 0; + myTextValue = theAttributeValue->text(); +} + SketcherPrs_DimensionStyleListener::SketcherPrs_DimensionStyleListener() { Events_Loop* aLoop = Events_Loop::loop(); @@ -35,29 +62,53 @@ void SketcherPrs_DimensionStyleListener::processEvent(const std::shared_ptrusedParameters().size() > 0, - theAttributeValue->text()); + updateDimensions(theDimension, theDimensionValue.myHasParameters, + theDimensionValue.myTextValue, theDimensionValue.myDoubleValue); } void SketcherPrs_DimensionStyleListener::updateDimensions(AIS_Dimension* theDimension, const bool theHasParameters, - const std::string& theValue) + const std::string& theTextValue, + const double theDoubleValue) { if (!theDimension) return; + /// do not show special symbols of dimension: previous implementation did not allow to unite them + theDimension->SetSpecialSymbol(MyEmptySymbol); + theDimension->SetDisplaySpecialSymbol(AIS_DSS_No); + + TCollection_ExtendedString aCustomValue; if (theHasParameters) { - bool isParameterValueStyle = myStyle == SketcherPrs_ParameterStyleMessage::ParameterValue; - SketcherPrs_Tools::setDisplaySpecialSymbol(theDimension, isParameterValueStyle); - SketcherPrs_Tools::setDisplayParameter(theDimension, theValue, !isParameterValueStyle); + bool isParameterTextStyle = myStyle == SketcherPrs_ParameterStyleMessage::ParameterText; + + if (isParameterTextStyle) + aCustomValue = theTextValue.c_str(); + else { + // format value string using "sprintf" + TCollection_AsciiString aFormatStr = theDimension->Attributes()->DimensionAspect()->ValueStringFormat(); + char aFmtBuffer[256]; + sprintf (aFmtBuffer, aFormatStr.ToCString(), theDoubleValue); + aCustomValue = TCollection_ExtendedString (aFmtBuffer); + + aCustomValue.Insert (1, MySigmaSymbol); + } } else { - SketcherPrs_Tools::setDisplaySpecialSymbol(theDimension, false); - SketcherPrs_Tools::setDisplayParameter(theDimension, theValue, false); + // format value string using "sprintf" + TCollection_AsciiString aFormatStr = theDimension->Attributes()->DimensionAspect()->ValueStringFormat(); + char aFmtBuffer[256]; + sprintf (aFmtBuffer, aFormatStr.ToCString(), theDoubleValue); + aCustomValue = TCollection_ExtendedString (aFmtBuffer); } +#ifdef COMPILATION_CORRECTION + theDimension->SetCustomValue(theDoubleValue); +#else + theDimension->SetCustomValue(aCustomValue); +#endif }