From: vsv Date: Thu, 12 Dec 2019 15:48:49 +0000 (+0300) Subject: Issue #3108: Take into account current parameters style for new dimensions. X-Git-Tag: V9_5_0a1~94 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f96597c41d8ae0949c8bb72d54e2d9c2e7f49914;p=modules%2Fshaper.git Issue #3108: Take into account current parameters style for new dimensions. --- diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index e82577145..a0e1b7efa 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -2019,8 +2019,9 @@ void PartSet_SketcherMgr::updateBySketchParameters( if (aPrevState != theState) { /// call all sketch features redisplay, the expression state will be corrected in customize /// of distance presentation - SketcherPrs_Tools:: - sendExpressionShownEvent(myIsConstraintsShown[PartSet_Tools::Expressions]); + SketcherPrs_Tools::ParameterStyle aStyle = myIsConstraintsShown[PartSet_Tools::Expressions] ? + SketcherPrs_Tools::ParameterText : SketcherPrs_Tools::ParameterValue; + SketcherPrs_Tools::setParameterStyle(aStyle); Events_ID anEventId = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY); PartSet_Tools::sendSubFeaturesEvent(myCurrentSketch, anEventId); } diff --git a/src/SketcherPrs/CMakeLists.txt b/src/SketcherPrs/CMakeLists.txt index f84bb4322..51a7b9f8b 100644 --- a/src/SketcherPrs/CMakeLists.txt +++ b/src/SketcherPrs/CMakeLists.txt @@ -26,7 +26,7 @@ SET(PROJECT_HEADERS SketcherPrs.h SketcherPrs_Coincident.h SketcherPrs_Collinear.h - SketcherPrs_DimensionStyleListener.h + SketcherPrs_DimensionStyle.h SketcherPrs_Factory.h SketcherPrs_Parallel.h SketcherPrs_Tools.h @@ -49,7 +49,7 @@ SET(PROJECT_HEADERS SET(PROJECT_SOURCES SketcherPrs_Coincident.cpp SketcherPrs_Collinear.cpp - SketcherPrs_DimensionStyleListener.cpp + SketcherPrs_DimensionStyle.cpp SketcherPrs_Factory.cpp SketcherPrs_Parallel.cpp SketcherPrs_Tools.cpp diff --git a/src/SketcherPrs/SketcherPrs_Angle.cpp b/src/SketcherPrs/SketcherPrs_Angle.cpp index 9edc95a76..f09c4a933 100644 --- a/src/SketcherPrs/SketcherPrs_Angle.cpp +++ b/src/SketcherPrs/SketcherPrs_Angle.cpp @@ -18,7 +18,7 @@ // #include "SketcherPrs_Angle.h" -#include "SketcherPrs_DimensionStyleListener.h" +#include "SketcherPrs_DimensionStyle.h" #include "SketcherPrs_Tools.h" #include @@ -70,7 +70,7 @@ SketcherPrs_Angle::SketcherPrs_Angle(ModelAPI_Feature* theConstraint, SetDimensionAspect(myAspect); - myStyleListener = new SketcherPrs_DimensionStyleListener(); + myStyleListener = new SketcherPrs_DimensionStyle(); } SketcherPrs_Angle::~SketcherPrs_Angle() diff --git a/src/SketcherPrs/SketcherPrs_Angle.h b/src/SketcherPrs/SketcherPrs_Angle.h index 75d0c37d8..009a482a8 100644 --- a/src/SketcherPrs/SketcherPrs_Angle.h +++ b/src/SketcherPrs/SketcherPrs_Angle.h @@ -27,7 +27,7 @@ #include #include -#include +#include DEFINE_STANDARD_HANDLE(SketcherPrs_Angle, AIS_AngleDimension) @@ -99,7 +99,7 @@ private: Handle(Prs3d_DimensionAspect) myAspect; /// Listener to update dimension visualization style - SketcherPrs_DimensionStyleListener* myStyleListener; + SketcherPrs_DimensionStyle* myStyleListener; /// container of values obtained from the constraint, which are necessary to fill the presentation gp_Pnt myFirstPoint; ///< the dimension first point for measured geometry @@ -107,7 +107,7 @@ private: gp_Pnt myCenterPoint; ///< the dimension center point for measured geometry gp_Pnt myFlyOutPoint; ///< the dimension fly out point for measured geometry - SketcherPrs_DimensionStyleListener::DimensionValue myValue; /// the structure filled by constraint + SketcherPrs_DimensionStyle::DimensionValue myValue; /// the structure filled by constraint }; diff --git a/src/SketcherPrs/SketcherPrs_DimensionStyle.cpp b/src/SketcherPrs/SketcherPrs_DimensionStyle.cpp new file mode 100644 index 000000000..fb82eb40b --- /dev/null +++ b/src/SketcherPrs/SketcherPrs_DimensionStyle.cpp @@ -0,0 +1,117 @@ +// Copyright (C) 2014-2019 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_DimensionStyle.h" +#include +#include "SketcherPrs_Tools.h" + +#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_DimensionStyle::DimensionValue::DimensionValue(double theDoubleValue, + bool theHasParameters, const std::string& theTextValue) +: myDoubleValue(theDoubleValue), + myHasParameters(theHasParameters), + myTextValue(theTextValue) +{ +} + +void SketcherPrs_DimensionStyle::DimensionValue::init( + const AttributeDoublePtr& theAttributeValue) +{ + myDoubleValue = theAttributeValue->value(); + myHasParameters = theAttributeValue->usedParameters().size() > 0; + myTextValue = theAttributeValue->text(); +} + +SketcherPrs_DimensionStyle::SketcherPrs_DimensionStyle() +{ +} + +SketcherPrs_DimensionStyle::~SketcherPrs_DimensionStyle() +{ +} + +void SketcherPrs_DimensionStyle::updateDimensions(AIS_Dimension* theDimension, + const SketcherPrs_DimensionStyle::DimensionValue& theDimensionValue) +{ + if (!theDimension) + return; + updateDimensions(theDimension, theDimensionValue.myHasParameters, + theDimensionValue.myTextValue, theDimensionValue.myDoubleValue); +} + +void SketcherPrs_DimensionStyle::updateDimensions(AIS_Dimension* theDimension, + const bool theHasParameters, + 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 isParameterTextStyle = myStyle == SketcherPrs_ParameterStyleMessage::ParameterText; + bool isParameterTextStyle = + SketcherPrs_Tools::parameterStyle() == SketcherPrs_Tools::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 { + // 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 +} diff --git a/src/SketcherPrs/SketcherPrs_DimensionStyle.h b/src/SketcherPrs/SketcherPrs_DimensionStyle.h new file mode 100644 index 000000000..47be050d3 --- /dev/null +++ b/src/SketcherPrs/SketcherPrs_DimensionStyle.h @@ -0,0 +1,80 @@ +// Copyright (C) 2014-2019 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 +// + +#ifndef SketcherPrs_DimensionStyleListener_H +#define SketcherPrs_DimensionStyleListener_H + +//#include + +#include + +#include "SketcherPrs_Tools.h" + +#include + +#include + +/** +* \class SketcherPrs_DimensionStyleListener +* \ingroup GUI +* A class for representation of linear dimension constraint. +* It supports SketchPlugin_ConstraintLength and SketchPlugin_ConstraintDistance features. +*/ +class SketcherPrs_DimensionStyle +{ +public: + class DimensionValue { + public: + DimensionValue(double theDoubleValue, bool theHasParameters, const std::string& theTextValue); + /// Fills internal fields by the given attribute + /// \param theAttributeValue a model attribute + void init(const AttributeDoublePtr& theAttributeValue); + + public: + double myDoubleValue; ///< the angle value to be shown as custom value of presentation + bool myHasParameters; ///< true if the atrribute value has used parameters + std::string myTextValue; ///< the angle value depending on angle type + }; + +public: + /// Constructor + Standard_EXPORT SketcherPrs_DimensionStyle(); + + /// Destructor + Standard_EXPORT ~SketcherPrs_DimensionStyle(); + + /// Visualizes the dimension text or dimension value depending on the has parameters state + /// \param theDimension a modified dimension + /// \param theDimensionValue container filled by the model double attribute + Standard_EXPORT void updateDimensions(AIS_Dimension* theDimension, + const DimensionValue& theDimensionValue); + +private: + /// Visualizes the dimension text or dimension value depending on the has parameters state + /// \param theDimension a modified dimension + /// \param theHasParameters if true, the text is shown, else digit + /// \param theTextValue a dimension text value + /// \param theDoubleValue a dimension digit value + void updateDimensions(AIS_Dimension* theDimension, + const bool theHasParameters, + const std::string& theTextValue, + const double theDoubleValue); +}; + +#endif \ No newline at end of file diff --git a/src/SketcherPrs/SketcherPrs_DimensionStyleListener.cpp b/src/SketcherPrs/SketcherPrs_DimensionStyleListener.cpp deleted file mode 100644 index e00f81acb..000000000 --- a/src/SketcherPrs/SketcherPrs_DimensionStyleListener.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (C) 2014-2019 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_DimensionStyleListener.h" -#include -#include "SketcherPrs_Tools.h" - -#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(); - const Events_ID kDocCreatedEvent = - SketcherPrs_ParameterStyleMessage::eventId(); - aLoop->registerListener(this, kDocCreatedEvent, NULL, false); -} - -SketcherPrs_DimensionStyleListener::~SketcherPrs_DimensionStyleListener() -{ - Events_Loop* aLoop = Events_Loop::loop(); - aLoop->removeListener(this); -} - -void SketcherPrs_DimensionStyleListener::processEvent( - const std::shared_ptr& theMessage) -{ - const Events_ID kParameterStyleEvent = SketcherPrs_ParameterStyleMessage::eventId(); - if (theMessage->eventID() == kParameterStyleEvent) { - std::shared_ptr aMessage = std::dynamic_pointer_cast< - SketcherPrs_ParameterStyleMessage>(theMessage); - myStyle = aMessage->style(); - } -} - -void SketcherPrs_DimensionStyleListener::updateDimensions(AIS_Dimension* theDimension, - const SketcherPrs_DimensionStyleListener::DimensionValue& theDimensionValue) -{ - if (!theDimension) - return; - updateDimensions(theDimension, theDimensionValue.myHasParameters, - theDimensionValue.myTextValue, theDimensionValue.myDoubleValue); -} - -void SketcherPrs_DimensionStyleListener::updateDimensions(AIS_Dimension* theDimension, - const bool theHasParameters, - 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 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 { - // 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 -} - diff --git a/src/SketcherPrs/SketcherPrs_DimensionStyleListener.h b/src/SketcherPrs/SketcherPrs_DimensionStyleListener.h deleted file mode 100644 index 5e6239943..000000000 --- a/src/SketcherPrs/SketcherPrs_DimensionStyleListener.h +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (C) 2014-2019 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 -// - -#ifndef SketcherPrs_DimensionStyleListener_H -#define SketcherPrs_DimensionStyleListener_H - -#include - -#include - -#include "SketcherPrs_Tools.h" - -#include - -#include - -/** -* \class SketcherPrs_DimensionStyleListener -* \ingroup GUI -* A class for representation of linear dimension constraint. -* It supports SketchPlugin_ConstraintLength and SketchPlugin_ConstraintDistance features. -*/ -class SketcherPrs_DimensionStyleListener : public Events_Listener -{ -public: - class DimensionValue { - public: - DimensionValue(double theDoubleValue, bool theHasParameters, const std::string& theTextValue); - /// Fills internal fields by the given attribute - /// \param theAttributeValue a model attribute - void init(const AttributeDoublePtr& theAttributeValue); - - public: - double myDoubleValue; ///< the angle value to be shown as custom value of presentation - bool myHasParameters; ///< true if the atrribute value has used parameters - std::string myTextValue; ///< the angle value depending on angle type - }; - -public: - /// Constructor - Standard_EXPORT SketcherPrs_DimensionStyleListener(); - - /// Destructor - Standard_EXPORT ~SketcherPrs_DimensionStyleListener(); - - /// Process the ModelAPI_DocumentCreatedMessage to fulfill a document - /// from the message with origin and planes - virtual void processEvent(const std::shared_ptr& theMessage); - - /// Visualizes the dimension text or dimension value depending on the has parameters state - /// \param theDimension a modified dimension - /// \param theDimensionValue container filled by the model double attribute - Standard_EXPORT void updateDimensions(AIS_Dimension* theDimension, - const DimensionValue& theDimensionValue); - -private: - /// Visualizes the dimension text or dimension value depending on the has parameters state - /// \param theDimension a modified dimension - /// \param theHasParameters if true, the text is shown, else digit - /// \param theTextValue a dimension text value - /// \param theDoubleValue a dimension digit value - void updateDimensions(AIS_Dimension* theDimension, - const bool theHasParameters, - const std::string& theTextValue, - const double theDoubleValue); -private: - /// Style how the parameter of dimension should be visualized - SketcherPrs_ParameterStyleMessage::ParameterStyle myStyle; -}; - -#endif \ No newline at end of file diff --git a/src/SketcherPrs/SketcherPrs_LengthDimension.cpp b/src/SketcherPrs/SketcherPrs_LengthDimension.cpp index b15f0d05f..de9d7e752 100644 --- a/src/SketcherPrs/SketcherPrs_LengthDimension.cpp +++ b/src/SketcherPrs/SketcherPrs_LengthDimension.cpp @@ -19,7 +19,7 @@ #include "SketcherPrs_LengthDimension.h" #include "SketcherPrs_Tools.h" -#include "SketcherPrs_DimensionStyleListener.h" +#include "SketcherPrs_DimensionStyle.h" #include #include @@ -120,7 +120,7 @@ SketcherPrs_LengthDimension::SketcherPrs_LengthDimension(ModelAPI_Feature* theCo myValue(0., false, "") { SetDimensionAspect(createDimensionAspect()); - myStyleListener = new SketcherPrs_DimensionStyleListener(); + myStyleListener = new SketcherPrs_DimensionStyle(); setDirection(theConstraint, plane()); } diff --git a/src/SketcherPrs/SketcherPrs_LengthDimension.h b/src/SketcherPrs/SketcherPrs_LengthDimension.h index 43a27c717..b737488fa 100644 --- a/src/SketcherPrs/SketcherPrs_LengthDimension.h +++ b/src/SketcherPrs/SketcherPrs_LengthDimension.h @@ -30,7 +30,7 @@ #include #include -#include +#include DEFINE_STANDARD_HANDLE(SketcherPrs_LengthDimension, AIS_LengthDimension) @@ -96,7 +96,7 @@ private: //Handle(Prs3d_DimensionAspect) myAspect; /// Listener to update dimension visualization style - SketcherPrs_DimensionStyleListener* myStyleListener; + SketcherPrs_DimensionStyle* myStyleListener; /// container of values obtained from the constraint, which are necessary /// to fill the presentation @@ -106,7 +106,7 @@ private: double myDistance; ///< the flyout distance /// the structure filled by constraint - SketcherPrs_DimensionStyleListener::DimensionValue myValue; + SketcherPrs_DimensionStyle::DimensionValue myValue; }; #endif \ No newline at end of file diff --git a/src/SketcherPrs/SketcherPrs_Radius.cpp b/src/SketcherPrs/SketcherPrs_Radius.cpp index bd10874fc..5b94a63de 100644 --- a/src/SketcherPrs/SketcherPrs_Radius.cpp +++ b/src/SketcherPrs/SketcherPrs_Radius.cpp @@ -19,7 +19,7 @@ #include "SketcherPrs_Radius.h" #include "SketcherPrs_Tools.h" -#include "SketcherPrs_DimensionStyleListener.h" +#include "SketcherPrs_DimensionStyle.h" #include #include @@ -59,7 +59,7 @@ SketcherPrs_Radius::SketcherPrs_Radius(ModelAPI_Feature* theConstraint, myValue(1, false, "") { SetDimensionAspect(createDimensionAspect()); - myStyleListener = new SketcherPrs_DimensionStyleListener(); + myStyleListener = new SketcherPrs_DimensionStyle(); } SketcherPrs_Radius::~SketcherPrs_Radius() diff --git a/src/SketcherPrs/SketcherPrs_Radius.h b/src/SketcherPrs/SketcherPrs_Radius.h index a6fbe75e9..e675e24e0 100644 --- a/src/SketcherPrs/SketcherPrs_Radius.h +++ b/src/SketcherPrs/SketcherPrs_Radius.h @@ -27,7 +27,7 @@ #include #include -#include +#include DEFINE_STANDARD_HANDLE(SketcherPrs_Radius, AIS_RadiusDimension) @@ -91,13 +91,13 @@ private: SketchPlugin_Sketch* mySketcher; /// Listener to update dimension visualization style - SketcherPrs_DimensionStyleListener* myStyleListener; + SketcherPrs_DimensionStyle* myStyleListener; /// container of values obtained from the constraint, which are necessary to fill the presentation gp_Circ myCircle; ///< the radius circle gp_Pnt myAnchorPoint; ///< an ancor for the radius value visualization - SketcherPrs_DimensionStyleListener::DimensionValue myValue; /// the structure filled by constraint + SketcherPrs_DimensionStyle::DimensionValue myValue; /// the structure filled by constraint }; #endif \ No newline at end of file diff --git a/src/SketcherPrs/SketcherPrs_Tools.cpp b/src/SketcherPrs/SketcherPrs_Tools.cpp index 8b32e6944..2de9b6c82 100644 --- a/src/SketcherPrs/SketcherPrs_Tools.cpp +++ b/src/SketcherPrs/SketcherPrs_Tools.cpp @@ -51,6 +51,18 @@ namespace SketcherPrs_Tools { +static ParameterStyle MyStyle = ParameterValue; + +void setParameterStyle(ParameterStyle theStyle) +{ + MyStyle = theStyle; +} + +ParameterStyle parameterStyle() +{ + return MyStyle; +} + AttributePtr getAttribute(ModelAPI_Feature* theFeature, const std::string& theAttrName) { AttributePtr anAttribute; @@ -369,17 +381,6 @@ std::shared_ptr getAnchorPoint(const ModelAPI_Feature* theConstrain return thePlane->to3D(aFlyoutPnt->x(), aFlyoutPnt->y()); } -void sendExpressionShownEvent(const bool& theState) -{ - static Events_ID anId = SketcherPrs_ParameterStyleMessage::eventId(); - std::shared_ptr aMessage = std::shared_ptr - (new SketcherPrs_ParameterStyleMessage(anId, 0)); - aMessage->setStyle(theState ? SketcherPrs_ParameterStyleMessage::ParameterText - : SketcherPrs_ParameterStyleMessage::ParameterValue); - Events_Loop::loop()->send(aMessage); - Events_Loop::loop()->flush(anId); -} - 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 5a719646c..0b075f581 100644 --- a/src/SketcherPrs/SketcherPrs_Tools.h +++ b/src/SketcherPrs/SketcherPrs_Tools.h @@ -37,41 +37,20 @@ class GeomDataAPI_Point2D; class AIS_Dimension; -//#define MyTextHeight 20 +namespace SketcherPrs_Tools { -/// Message that style of visualization of parameter is changed. -/// It will be shown as expression or value -class SketcherPrs_ParameterStyleMessage : public Events_Message -{ -public: /// \enum ParameterStyle lists styles of parameter enum ParameterStyle { ParameterValue, ///< using symbol with the parameter value ParameterText ///< using parameter text }; -public: - /// Creates an empty message - SKETCHERPRS_EXPORT SketcherPrs_ParameterStyleMessage(const Events_ID theID, - const void* theSender = 0) - : Events_Message(theID, theSender) {} - /// The virtual destructor - SKETCHERPRS_EXPORT virtual ~SketcherPrs_ParameterStyleMessage() {} - /// Static. Returns EventID of the message. - SKETCHERPRS_EXPORT static Events_ID eventId() - { - static const char * MY_EVENT_PARAMETER_STYLE_ID("ParameterStyle"); - return Events_Loop::eventByName(MY_EVENT_PARAMETER_STYLE_ID); - } - /// Returns a document stored in the message - SKETCHERPRS_EXPORT ParameterStyle style() const { return myStyle; } - /// Sets a document to the message - SKETCHERPRS_EXPORT void setStyle(ParameterStyle theStyle) { myStyle = theStyle; } -private: - ParameterStyle myStyle; /// style of the parameter visualization -}; + /// Set dimensions parameters style + /// \param theStyle new style + SKETCHERPRS_EXPORT void setParameterStyle(ParameterStyle theStyle); -namespace SketcherPrs_Tools { + /// Return dimensions parameters style + SKETCHERPRS_EXPORT ParameterStyle parameterStyle(); /// Enumeration with modes for activation of selection custom presentations enum SelectionModes { @@ -196,11 +175,6 @@ namespace SketcherPrs_Tools { const ModelAPI_Feature* theConstraint, const std::shared_ptr& thePlane); - /// Sends event about expression visualization type is changed for dimension presentations - /// Sends event to redisplay all sub-features of composite feature - /// \param theState a new state - SKETCHERPRS_EXPORT void sendExpressionShownEvent(const bool& theState); - /// 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