/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #ifndef __TNW_VARIANT_H__ #define __TNW_VARIANT_H__ #include "RxVariant.h" #include "NwExport.h" class OdNwVariant; class OdNwColor; class OdGeMatrix3d; class OdGePoint3d; class OdGePoint2d; /** \details A class that implements an extension of the OdVariant class that can be used as universal storage of typified data. Corresponding C++ library: Od_Nw */ class NWDBEXPORT OdNwVariant : public OdVariant { public: /** \details Creates a factory (if it was not created previously) for variant objects of a specified data type. \param type [in] A data type of objects that are created by the factory. \returns A raw pointer to a factory object. */ static const OdVariant::TypeFactory* typeFactory(int type); /** \details Defines data types for OdNwVariant objects. */ typedef enum { /** A color data type. */ kColor = OdVariant::kNextType, /** A matrix3d data type. */ kMatrix3d, /** A date/time data type. */ kTime, /** A 3D point data type. */ kPoint3d, /** A 2D point data type. */ kPoint2d, /** An angular double type. */ kAngle, /** A length double type. */ kLength, /** An area double type. */ kArea, /** A volume double type. */ kVolume, /** A system data type (for internal use only). */ kNextType } Type; /** \details Creates an empty OdNwVariant object. */ OdNwVariant(); /** \details Creates a new OdNwVariant object that is a copy of another variant object represented with the OdVariant class instance. \param value [in] An OdVariant object that is copied to a created OdNwVariant object. */ OdNwVariant(const OdVariant& value); /** \details Creates a new OdNwVariant object that is a copy of another Tf variant object (copy constructor). \param value [in] An OdNwVariant object that is copied to a created OdNwVariant object. */ OdNwVariant(const OdNwVariant& value); /** \details Creates a new OdNwVariant object with a specified OdNwColor. \param value [in] An OdNwColor value. */ OdNwVariant(const OdNwColor& value); /** \details Creates a new OdNwVariant object with a specified OdGeMatrix3d. \param value [in] An OdGeMatrix3d value. */ OdNwVariant(const OdGeMatrix3d& value); /** \details Creates a new OdNwVariant object with a specified time value. \param value [in] A time value. */ OdNwVariant(const tm& value); /** \details Creates a new OdNwVariant object with a specified 3d point value. \param value [in] A OdGePoint3d value. */ OdNwVariant(const OdGePoint3d& value); /** \details Creates a new OdNwVariant object with a specified 2d point value. \param value [in] A OdGePoint2d value. */ OdNwVariant(const OdGePoint2d& value); /** \details Creates a new OdNwVariant object with a specified measured double value. \param value [in] A double value. \param type [in] A measured type for value. \remarks Type must be one of the following or OdNwVariant will be created with kDouble type: Name Value Description Type::kAngle 0x0F An angular double type. Type::kLength 0x10 A length double type. Type::kArea 0x11 An area double type. Type::kVolume 0x12 A volume double type.
*/ OdNwVariant(double value, Type type); /** \details The assignment operator for two OdNwVariant objects. \param value [in] A right operand of the assignment operation. \returns This variant object after the assignment operation. */ OdNwVariant& operator =(const OdNwVariant& value); /** \details Destroys the variant object. */ virtual ~OdNwVariant(); /** \details Retrieves the current color of the variant object. \returns The current color of the variant object. */ const OdNwColor& getColor() const; /** \details Retrieves the current matrix3d of the variant object. \returns The current matrix3d of the variant object. */ const OdGeMatrix3d& getMatrix3d() const; /** \details Retrieves the current time of the variant object. \returns The current time of the variant object as tm. */ const tm& getTime() const; /** \details Receives a reference to the value of this variant object. \returns An OdArray object as a reference to the value of this variant object. \remarks No check is made to determine whether this variant object is of the specified type. */ const OdArray& getColorArray() const; /** \details Retrieves the 3D point of the variant object. \returns The current 3D point of the variant object as an OdGePoint3d. */ const OdGePoint3d& getPoint3d() const; /** \details Retrieves the 2D point of the variant object. \returns The current 2D point of the variant object as an OdGePoint2d. */ const OdGePoint2d& getPoint2d() const; /** \details Retrieves the measured double value of the variant object. \returns The current measured value of the variant object as double. */ double getMeasuredDouble() const; /** \details Sets a new color for the variant object. \param value [in] A new color value to set. \returns The reference to the modified variant object. */ OdNwVariant& setColor(const OdNwColor& value); /** \details Sets a new matrix 3D for the variant object. \param value [in] A new matrix 3D value. \returns The reference to the modified variant object. */ OdNwVariant& setMatrix3d(const OdGeMatrix3d& value); /** \details Sets a new time for the variant object. \param value [in] A new time value to set. \returns The reference to the modified variant object. */ OdNwVariant& setTime(const tm& value); /** \details Sets the given color array for this variant object. \param val [in] A new array of colors to set. \returns The reference to this variant object. */ OdVariant& setColorArray(const OdArray& array); /** \details Sets a new 3D point for the variant object. \param value [in] A new 3D point value as an OdGePoint3d to set. \returns The reference to the modified variant object. */ OdNwVariant& setPoint3d(const OdGePoint3d& value); /** \details Sets a new 2D point for the variant object. \param value [in] A new 2D point value as an OdGePoint2d to set. \returns The reference to the modified variant object. */ OdNwVariant& setPoint2d(const OdGePoint2d& value); /** \details Sets a new measured double value for the variant object. \param value [in] A new measured value as double to set. \param type [in] A measured type for value. \returns The reference to the modified variant object. \remarks The type must be one of the following or OdNwVariant will be set with kDouble type: Name Value Description Type::kAngle 0x0F An angular double type. Type::kLength 0x10 A length double type. Type::kArea 0x11 An area double type. Type::kVolume 0x12 A volume double type.
*/ OdNwVariant& setMeasuredDouble(double value, Type type); protected: /** \details Sets a new type for the variant object. \param newType [in] New variant type to set. \param type [in] Old variant type. \param data [in] Pointer to data. */ void setVarType(int newType, int& type, void* data); }; /** \details The comparison operator for two Nw variant data types. \param lhs [in] A left-hand operand for the comparison operation. \param rhs [in] A right-hand operand for the comparison operation. \returns The true value if the specified data types can be cast to each other, or false otherwise. */ inline bool operator==(OdNwVariant::Type lhs, OdVariant::Type rhs) { return lhs == static_cast(rhs); } /** \details The non-equality operator for two Nw variant data types. \param lhs [in] A left-hand operand. \param rhs [in] A right-hand operand. \returns The true value if the specified data types are not equal, or false otherwise. */ inline bool operator!=(OdNwVariant::Type lhs, OdVariant::Type rhs) { return !(lhs == rhs); } /** \details The comparison operator for two OdVariant data types. \param lhs [in] A left-hand operand for the comparison operation. \param rhs [in] A right-hand operand for the comparison operation. \returns The true value if the specified data types are equal, or false otherwise. */ inline bool operator==(OdVariant::Type lhs, OdNwVariant::Type rhs) { return rhs == lhs; } /** \details The non-equality operator for two OdVariant data types. \param lhs [in] A left-hand operand. \param rhs [in] A right-hand operand. \returns The true value if the specified data types are not equal, or false otherwise. */ inline bool operator!=(OdVariant::Type lhs, OdNwVariant::Type rhs) { return rhs != lhs; } #endif //__TNW_VARIANT_H__