return aResult;
}
+void GeomData_Point::setText(const std::string& theX,
+ const std::string& theY,
+ const std::string& theZ)
+{
+ TCollection_ExtendedString aX(theX.c_str());
+ TCollection_ExtendedString aY(theY.c_str());
+ TCollection_ExtendedString aZ(theZ.c_str());
+
+ if (!myIsInitialized ||
+ myTextArray->Value(0) != aX ||
+ myTextArray->Value(1) != aY ||
+ myTextArray->Value(2) != aZ) {
+ myTextArray->SetValue(0, aX);
+ myTextArray->SetValue(1, aY);
+ myTextArray->SetValue(2, aZ);
+ owner()->data()->sendAttributeUpdated(this);
+ }
+}
+
+std::string GeomData_Point::textX()
+{
+ return TCollection_AsciiString(myTextArray->Value(0)).ToCString();;
+}
+std::string GeomData_Point::textY()
+{
+ return TCollection_AsciiString(myTextArray->Value(1)).ToCString();;
+}
+std::string GeomData_Point::textZ()
+{
+ return TCollection_AsciiString(myTextArray->Value(2)).ToCString();;
+}
+
+void GeomData_Point::setExpressionInvalid(int theComponent, bool theFlag)
+{
+ if (!myIsInitialized || myExpressionInvalidArray->Value(theComponent) != theFlag) {
+ myExpressionInvalidArray->SetValue(theComponent, theFlag);
+ }
+}
+
+bool GeomData_Point::expressionInvalid(int theComponent)
+{
+ return myExpressionInvalidArray->Value(theComponent);
+}
+
GeomData_Point::GeomData_Point(TDF_Label& theLabel)
{
- myIsInitialized = theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords) == Standard_True;
- if (!myIsInitialized) {
+ myIsInitialized = true;
+
+ if (theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords) != Standard_True) {
// create attribute: not initialized by value yet, just zero
myCoords = TDataStd_RealArray::Set(theLabel, 0, 2);
+ myIsInitialized = false;
+ }
+ if (theLabel.FindAttribute(TDataStd_ExtStringArray::GetID(), myTextArray) != Standard_True) {
+ // create attribute: not initialized by value yet, just zero
+ myTextArray = TDataStd_ExtStringArray::Set(theLabel, 0, 2);
+ myIsInitialized = false;
+ }
+ if (theLabel.FindAttribute(TDataStd_BooleanArray::GetID(), myExpressionInvalidArray) != Standard_True) {
+ // create attribute: not initialized by value yet, just zero
+ myExpressionInvalidArray = TDataStd_BooleanArray::Set(theLabel, 0, 2);
+ myIsInitialized = false;
}
}
#include "GeomData.h"
#include "GeomDataAPI_Point.h"
#include <TDataStd_RealArray.hxx>
+#include <TDataStd_ExtStringArray.hxx>
+#include <TDataStd_BooleanArray.hxx>
#include <TDF_Label.hxx>
/**\class GeomData_Point
class GeomData_Point : public GeomDataAPI_Point
{
Handle_TDataStd_RealArray myCoords; ///< X, Y and Z doubles as real array attribute [0; 2]
+ Handle_TDataStd_ExtStringArray myTextArray; ///< Text representation of the X, Y and Z attributes [0; 2]
+ Handle_TDataStd_BooleanArray myExpressionInvalidArray; ///< Flag of invalid expression of the X, Y and Z attributes [0; 2]
public:
/// Defines the double value
GEOMDATA_EXPORT virtual void setValue(const double theX, const double theY, const double theZ);
/// Returns the 3D point
GEOMDATA_EXPORT virtual std::shared_ptr<GeomAPI_Pnt> pnt();
+ /// Defines the text values
+ GEOMDATA_EXPORT virtual void setText(const std::string& theX,
+ const std::string& theY,
+ const std::string& theZ);
+
+ /// Returns the X text value
+ GEOMDATA_EXPORT virtual std::string textX();
+ /// Returns the Y text value
+ GEOMDATA_EXPORT virtual std::string textY();
+ /// Returns the Z text value
+ GEOMDATA_EXPORT virtual std::string textZ();
+
+ /// Allows to set expression (text) as invalid (by the parameters listener)
+ GEOMDATA_EXPORT virtual void setExpressionInvalid(int, bool theFlag);
+
+ /// Returns true if text is invalid
+ GEOMDATA_EXPORT virtual bool expressionInvalid(int);
+
protected:
/// Initializes attributes
GEOMDATA_EXPORT GeomData_Point(TDF_Label& theLabel);
return aResult;
}
+void GeomData_Point2D::setText(const std::string& theX,
+ const std::string& theY)
+{
+ TCollection_ExtendedString aX(theX.c_str());
+ TCollection_ExtendedString aY(theY.c_str());
+
+ if (!myIsInitialized ||
+ myTextArray->Value(0) != aX ||
+ myTextArray->Value(1) != aY) {
+ myTextArray->SetValue(0, aX);
+ myTextArray->SetValue(1, aY);
+ owner()->data()->sendAttributeUpdated(this);
+ }
+}
+
+std::string GeomData_Point2D::textX()
+{
+ return TCollection_AsciiString(myTextArray->Value(0)).ToCString();;
+}
+std::string GeomData_Point2D::textY()
+{
+ return TCollection_AsciiString(myTextArray->Value(1)).ToCString();;
+}
+
+void GeomData_Point2D::setExpressionInvalid(int theComponent, bool theFlag)
+{
+ if (!myIsInitialized || myExpressionInvalidArray->Value(theComponent) != theFlag) {
+ myExpressionInvalidArray->SetValue(theComponent, theFlag);
+ }
+}
+
+bool GeomData_Point2D::expressionInvalid(int theComponent)
+{
+ return myExpressionInvalidArray->Value(theComponent);
+}
+
GeomData_Point2D::GeomData_Point2D(TDF_Label& theLabel)
{
- myIsInitialized = theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords) == Standard_True;
- if (!myIsInitialized) {
+ myIsInitialized = true;
+
+ if (theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords) != Standard_True) {
// create attribute: not initialized by value yet, just zero
myCoords = TDataStd_RealArray::Set(theLabel, 0, 1);
+ myIsInitialized = false;
+ }
+ if (theLabel.FindAttribute(TDataStd_ExtStringArray::GetID(), myTextArray) != Standard_True) {
+ // create attribute: not initialized by value yet, just zero
+ myTextArray = TDataStd_ExtStringArray::Set(theLabel, 0, 1);
+ myIsInitialized = false;
+ }
+ if (theLabel.FindAttribute(TDataStd_BooleanArray::GetID(), myExpressionInvalidArray) != Standard_True) {
+ // create attribute: not initialized by value yet, just zero
+ myExpressionInvalidArray = TDataStd_BooleanArray::Set(theLabel, 0, 1);
+ myIsInitialized = false;
}
}
#include "GeomData.h"
#include "GeomDataAPI_Point2D.h"
#include <TDataStd_RealArray.hxx>
+#include <TDataStd_ExtStringArray.hxx>
+#include <TDataStd_BooleanArray.hxx>
#include <TDF_Label.hxx>
/**\class GeomData_Point2D
class GeomData_Point2D : public GeomDataAPI_Point2D
{
Handle_TDataStd_RealArray myCoords; ///< X and Y doubles as real array attribute [0; 1]
+ Handle_TDataStd_ExtStringArray myTextArray; ///< Text representation of the X, Y and Z attributes [0; 2]
+ Handle_TDataStd_BooleanArray myExpressionInvalidArray; ///< Flag of invalid expression of the X, Y and Z attributes [0; 2]
public:
/// Defines the double value
GEOMDATA_EXPORT virtual void setValue(const double theX, const double theY);
/// Returns the 2D point
GEOMDATA_EXPORT virtual std::shared_ptr<GeomAPI_Pnt2d> pnt();
+ /// Defines the double values
+ GEOMDATA_EXPORT virtual void setText(const std::string& theX,
+ const std::string& theY);
+
+ /// Returns the double values
+ GEOMDATA_EXPORT virtual std::string textX();
+ GEOMDATA_EXPORT virtual std::string textY();
+
+ /// Allows to set expression (text) as invalid (by the parameters listener)
+ GEOMDATA_EXPORT virtual void setExpressionInvalid(int, const bool theFlag);
+
+ /// Returns true if text is invalid
+ GEOMDATA_EXPORT virtual bool expressionInvalid(int);
+
protected:
/// Initializes attributes
GEOMDATA_EXPORT GeomData_Point2D(TDF_Label& theLabel);
/// Returns the 3D point
virtual std::shared_ptr<GeomAPI_Pnt> pnt() = 0;
+ /// Defines the double values
+ virtual void setText(const std::string& theX,
+ const std::string& theY,
+ const std::string& theZ) = 0;
+
+ /// Returns the double values
+ virtual std::string textX() = 0;
+ virtual std::string textY() = 0;
+ virtual std::string textZ() = 0;
+
+ enum PointComponent { C_X = 0,
+ C_Y = 1,
+ C_Z = 2,
+ };
+
+ /// Allows to set expression (text) as invalid (by the parameters listener)
+ virtual void setExpressionInvalid(int theComponent, const bool theFlag) = 0;
+
+ /// Returns true if text is invalid
+ virtual bool expressionInvalid(int theComponent) = 0;
+
/// Returns the type of this class of attributes
static std::string typeId()
{
/// Returns the 2D point
virtual std::shared_ptr<GeomAPI_Pnt2d> pnt() = 0;
+ /// Defines the double values
+ virtual void setText(const std::string& theX,
+ const std::string& theY) = 0;
+
+ /// Returns the double values
+ virtual std::string textX() = 0;
+ virtual std::string textY() = 0;
+
+ enum PointComponent { C_X = 0,
+ C_Y = 1,
+ };
+
+ /// Allows to set expression (text) as invalid (by the parameters listener)
+ virtual void setExpressionInvalid(int theComponent, const bool theFlag) = 0;
+
+ /// Returns true if text is invalid
+ virtual bool expressionInvalid(int theComponent) = 0;
+
/// Appends the delta values to point
GEOMDATAAPI_EXPORT void move(const double theDeltaX, const double theDeltaY);