/////////////////////////////////////////////////////////////////////////////// // 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_MODELITEM_H__ #define __TNW_MODELITEM_H__ #include "NwObject.h" #include "NwExport.h" #include "NwModelItemIcon.h" #include "NwHyperlinkOverrideType.h" #include "Ge/GePoint3dArray.h" #include "NwTextureSpaceMapping.h" class OdGeExtent3d; class OdNwFullSubentPath; class OdNwAttribute; class OdNwMaterialAttribute; class OdNwGraphicMaterialAttribute; class OdNwPropertyAttribute; class OdNwColor; /** \details This template class is a specialization of the OdSmartPtr class for OdNwAttribute object pointers. */ typedef OdSmartPtr OdNwAttributePtr; /** \details This template class is a specialization of the OdSmartPtr class for OdNwMaterialAttribute object pointers. */ typedef OdSmartPtr OdNwMaterialAttributePtr; /** \details This template class is a specialization of the OdSmartPtr class for OdNwGraphicMaterialAttribute object pointers. */ typedef OdSmartPtr OdNwGraphicMaterialAttributePtr; /** \details This template class is a specialization of the OdSmartPtr class for OdNwPropertyAttribute object pointers. */ typedef OdSmartPtr OdNwPropertyAttributePtr; /** \details This class represents an instance node within the model hierarchy. */ class NWDBEXPORT OdNwModelItem : public OdNwObject { //DOM-IGNORE-BEGIN ODRX_DECLARE_MEMBERS(OdNwModelItem); //DOM-IGNORE-END public: /** \details Default constructor. Creates a new object of the OdNwModelItem class. */ OdNwModelItem(); /** \details Constructor for objects of the OdNwModelItem class. Creates a new OdNwModelItem object for the specified item. \param pImpl [in] Item to create an OdNwModelItem object for. */ explicit OdNwModelItem(OdNwObjectImpl* pImpl); public: /** \details Virtual destructor. Frees allocated resources. */ virtual ~OdNwModelItem(); public: /** \details Calculates and returns the bounding box of an item and its children. \returns OdGeExtents3d object with the bounding box of this model item. */ OdGeExtents3d getBoundingBox() const; /** \details Gets all ancestors within the model hierarchy of this item. \param aAncestors [out] OdArray with object IDs of ancestors of the model item. \returns The eOk value if successful, or an appropriate error code if not. */ OdResult getAncestors(OdNwObjectIdArray& aAncestors) const; /** \details Gets all ancestors within the model hierarchy of this item and the item itself. \param aAncestors [out] OdArray with the object IDs of ancestors of the model item and the item itself. \returns The eOk value if successful, or an appropriate error code if not. */ OdResult getAncestorsAndSelf(OdNwObjectIdArray& aAncestors) const; /** \details Gets the children within the model hierarchy of this item. \param aChildren [out] OdArray with the object IDs of the children of this item. \returns The eOk value if successful, or an appropriate error code if not. */ OdResult getChildren(OdNwObjectIdArray& aChildren) const; /** \details Gets the display name for the type of the item. \returns Display name for the type of the item. \remarks Display name is derived from the type in the original design application. */ OdString getClassDisplayName() const; /** \details Gets the name of the type of the item. \returns Name of the type of the item. \remarks Name is derived from the type in the original design application. */ OdString getClassName() const; /** \details Gets all descendants within the model hierarchy of this item. \param aDescendants [out] OdArray with the object IDs to descendants of this model item. \returns The eOk value if successful, or an appropriate error code if not. */ OdResult getDescendants(OdNwObjectIdArray& aDescendants) const; /** \details Gets all descendants within the model hierarchy of this item and the item itself. \param aDescendants [out] OdArray with the object IDs of descendants of this model item and the item itself. \returns The eOk value if successful, or an appropriate error code if not. */ OdResult getDescendantsAndSelf(OdNwObjectIdArray& aDescendants) const; /** \details Gets all items in the model hierarchy that share instance data with this item. \param aInstances [out] OdArray with the object IDs of instances of this model item and the item itself. \returns The eOk value if successful, or an appropriate error code if not. */ OdResult getInstances(OdNwObjectIdArray& aInstances) const; /** \details Receives the end-user supplied name for the item. \returns End-user supplied name for the item. \remarks DisplayName can be empty. */ OdString getDisplayName() const; /** \details Indicates whether there is geometry in the model item. \returns The true value if the model item has geometry, or false otherwise. */ bool hasGeometry() const; /** \details Receives the object ID of the geometry component for this item. \returns Object ID of the OdNwComponent object with the geometry component for this item. If the item does not have geometry, the returned object ID is empty. */ OdNwObjectId getGeometryComponentId() const; /** \details Receives the GUID for the instance data referred to by this item. \returns OdGUID object with the GUID for the instance data referred to by this item. */ OdGUID getInstanceGuid() const; /** \details Receives the object ID of the parent model item within the model hierarchy. \returns Object ID of the OdNwModelItem object with the parent model item. If the item is the root of the hierarchy, the returned object ID is empty. */ OdNwObjectId getParentId() const; /** \details Gets the properties of this item divided into multiple categories as objects of classes which are derived from OdNwAttribute. \param aAttributes [out] OdArray with smart pointers to attributes. \param categoryTypes [in] OdUInt32 value with bitfields such as an attribute's type for selective getting. \returns The eOk value if the operation is successful, or an appropriate error code otherwise. \remarks Bitfield values with an attribute's type for selective getting can be returned from the NwCategoryConversionType::Enum enumeration. If categoryTypes is NULL, the method gets all attributes. */ OdResult getAttributes(OdArray& aAttributes, OdUInt32 categoryTypes = 0) const; /** \details Receives the icon type of the model item. \returns One of the enumerated items from the NwModelItemIcon::Enum enumerated type. \remarks The returned type can be one of the following: Name Value Description NwModelItemIcon::NONE 0x0 Model item doesn't have a type NwModelItemIcon::FILE 0x1 Model item type is file NwModelItemIcon::LAYER 0x2 Model item type is layer NwModelItemIcon::COLLECTION 0x3 Model item type is collection NwModelItemIcon::GROUP 0x4 Model item type is group NwModelItemIcon::INSERT_GROUP 0x5 Model item type is insert group NwModelItemIcon::COMPOSITE_OBJECT 0x6 Model item type is composite object NwModelItemIcon::INSERT_GEOMETRY 0x7 Model item type is insert geometry NwModelItemIcon::GEOMETRY 0x8 Model item type is geometry
*/ NwModelItemIcon::Enum getIcon() const; /** \details Indicates whether the model item node is hidden. \returns The true value if the model item is hidden, or false if not. \remarks The method returns a value corresponding to the current viewpoint. */ bool isHidden() const; /** \details Indicates whether the model item node is required. \returns The true value if the model item is required, or false if not. \remarks The method returns a value corresponding to the current viewpoint. */ bool isRequired() const; /** \details Gets the material mapping of the model item. \returns The NwTextureSpaceMapping::Enum value with the material mapping for this model item, which is explictly set or contains common mapping from children. \remarks The returned type can be one of the following: Name Value Description NwTextureSpaceMapping::kBox 0x00 Box space mapping. NwTextureSpaceMapping::kPlane 0x01 Plane space mapping. NwTextureSpaceMapping::kCylinder 0x02 Cylinder space mapping. NwTextureSpaceMapping::kSphere 0x03 Sphere space mapping. NwTextureSpaceMapping::kExplicit 0x04 Explicit space mapping. NwTextureSpaceMapping::kMaterialMapping 0x05 Mixed or unspecified material mapping.
*/ NwTextureSpaceMapping::Enum getMaterialMapping() const; /** \details Adds a new model item node to the model item. \param sClassName [in] Class name of the source tree node. \param sClassDisplayName [in] Class user name of the source tree node. \param icon [in] Type of the new child model item. \param sDisplayName [in] Name of the source tree node. \param pResCode [out] Pointer to the OdResult object with an error code if the operation is not successful, or eOk if successful. \returns Object ID of the new OdNwModelItem object. \remarks The icon can be one of the following: Name Value Description NwModelItemIcon::NONE 0x0 Model item doesn't have a type NwModelItemIcon::FILE 0x1 Model item type is file NwModelItemIcon::LAYER 0x2 Model item type is layer NwModelItemIcon::COLLECTION 0x3 Model item type is collection NwModelItemIcon::GROUP 0x4 Model item type is group NwModelItemIcon::INSERT_GROUP 0x5 Model item type is insert group NwModelItemIcon::COMPOSITE_OBJECT 0x6 Model item type is composite object NwModelItemIcon::INSERT_GEOMETRY 0x7 Model item type is insert geometry NwModelItemIcon::GEOMETRY 0x8 Model item type is geometry
Adding is succesfull only for types: NwModelItemIcon::FILE, if addition is in the root node only with FILE nodes as child. NwModelItemIcon::LAYER, if addition is in the FILE node without FILE nodes as child. NwModelItemIcon::INSERT_GROUP, NwModelItemIcon::COMPOSITE_OBJECT, NwModelItemIcon::INSERT_GEOMETRY if addition is not in the insert node. NwModelItemIcon::GROUP if addition is not in the insert node, or if insert node has not children and has type NwModelItemIcon::INSERT_GROUP NwModelItemIcon::GEOMETRY if addition is not in the insert node, or if insert node has not children and has type NwModelItemIcon::INSERT_GEOMETRY in other cases this method returns an empty OdNwObjectId with eNotApplicable as the resulting code. */ OdNwObjectId addModelItem(const OdString& sClassName, const OdString& sClassDisplayName, NwModelItemIcon::Enum icon, const OdString& sDisplayName = OD_T(""), OdResult* pResCode = NULL); /** \details Adds a reused model item node to the model item. \param nwModelItemId [in] Object ID of the reused OdNwModelItem object. \param pResCode [out] Pointer to the OdResult object with an error code if the operation is not successful, or eOk if successful. \returns Object ID of the new OdNwModelItem object. \remarks Adding is succesfull only if: current node has type NwModelItemIcon::INSERT_GROUP, has not children and OdNwModelItem from nwModelItemId has NwModelItemIcon::GROUP or current node has type NwModelItemIcon::INSERT_GEOMETRY, has not children and OdNwModelItem from nwModelItemId has NwModelItemIcon::GEOMETRY in other cases this method returns an empty OdNwObjectId with eNotApplicable as the resulting code. */ OdNwObjectId addReusedModelItem(const OdNwObjectId& nwModelItemId, OdResult* pResCode = NULL); /** \details Sets the node's hidden value. \param value [in] Hidden value for the node. \returns The eOk value if the far hidden status is set to the node, or an appropriate error code otherwise. \remarks The method sets a value corresponding to the current viewpoint. */ OdResult setIsHidden(bool value); /** \details Sets the node's override color value. \param clr [in] OdNwColor value for the node. \returns The eOk value if the override color is set to the node, or an appropriate error code otherwise. \remarks The method sets a value corresponding to the current viewpoint. The method changes materials from the OdNwComponent object for nested geometry nodes. To get up-to-date materials, use the getMaterial/getOriginalMaterial methods once again. */ OdResult setOverrideColor(OdNwColor&& clr); /** \details Sets the node's override transparency value. \param fTrcy [in] float value for the node. \returns The eOk value if the override transparency is set to the node, or an appropriate error code otherwise. \remarks The transparency value must be in the [0.,1.] range. The method sets a value corresponding to the current viewpoint. The method changes materials from the OdNwComponent object for nested geometry nodes. To get up-to-date materials, use the getMaterial/getOriginalMaterial methods once again. */ OdResult setOverrideTransparency(float fTrcy); /** \details Resets the node's override color/transparency values. \returns The eOk value if the override data are reset, or an appropriate error code otherwise. \remarks The method sets a value corresponding to the current viewpoint. The method changes materials from the OdNwComponent object for nested geometry nodes. To get up-to-date materials, use the getMaterial/getOriginalMaterial methods once again. */ OdResult resetOverrideAppearance(); /** \details Adds a new simple material to the model item. \param pMaterial [in] Pointer to the OdNwMaterialAttribute class object with simple material. \returns The eOk value if the material adding to node, or an appropriate error code otherwise. \remarks If model item already has material attribute - then it will be changed by new material. */ OdResult addMaterial(OdNwMaterialAttributePtr pMaterial); /** \details Adds a transformation to the model item. \param pTransform [in] Pointer to the OdNwAttribute class object with transformation. \returns The eOk value if the transformation is adding to node, or an appropriate error code otherwise. \remarks If model item already has transformation attribute - then it will be changed by new transform. pTransform can be object with type - OdNwTransAttribute/OdNwTransRotationAttribute/OdNwTransformAttribute. */ OdResult addTransform(OdNwAttributePtr pTransform); /** \details Adds a texture material to the model item. \param pGraphMaterial [in] Pointer to the OdNwGraphicMaterialAttribute class object with texture material. \returns The eOk value if the graphic material adding to node, or an appropriate error code otherwise. \remarks If model item already has graphic material attribute - then it will be changed by new material. */ OdResult addGraphicMaterial(OdNwGraphicMaterialAttributePtr pGraphMaterial); /** \details Adds a not render attribute to the model item. \param pAttribute [in] Pointer to the OdNwAttribute derrived class object with attribute. \returns The eOk value if the attribute is added to node, or an appropriate error code otherwise. \remarks For now it's possible to append atributes with types: OdNwUInt64Attribute OdNwPropertyAttribute. */ OdResult addAttribute(OdNwAttributePtr pAttribute); /** \details Adds a hyperlink override to the model item. \param nType [in] Hyperlink override type. \param sName [in] Hyperlink override name. \param sURL [in] Hyperlink override URL. \param sCategory [in] Category name for user-defined hyperlink type. \param aAttachmentPoints [in] Array of attachment points. It must be inside of model item's extents or can be empty. \returns The eOk value if the hyperlink override is added to the model item, otherwise an appropriate error code. \remarks The type can be one of the following: Name Value Description NwHyperlinkOverrideType::HYPERLINK 0x0 Hyperlink override is a hyperlink. NwHyperlinkOverrideType::LABEL 0x1 Hyperlink override is a label. NwHyperlinkOverrideType::USER_DEFINED 0x2 Hyperlink override is user-defined.
*/ OdResult addHyperlinkOverride(const NwHyperlinkOverrideType::Enum nType, const OdString& sName, const OdString& sURL, const OdString& sCategory, const OdGePoint3dArray& aAttachmentPoints); /** \details Adds a property override attribute to the model item. \param attribute [in] Property attribute object to be added as an override. \returns The eOk value if the property override was added to the model item, or an appropriate error code otherwise. \remarks The type of property variant in the attribute can be one of the following: Type Description OdString Property variant is a string value OdInt32 Property variant is a 32-bit integer value double Property variant is a double precision value bool Property variant is a boolean value
Otherwise the method will return eWrongObjectType result. */ OdResult addPropertyOverride(const OdNwPropertyAttributePtr& attribute); /** \details Highlights the specified entity in underlying model objects. \param bDoIt [in] Flag that indicates whether highlighting is enabled (true value) or disabled (false value). \param pSubId [in] Path to the entity for highlighting. \param highlightAll [in] Flag to highlight all. */ void highlight(const bool bDoIt = true, const OdNwFullSubentPath* pSubId = 0, const bool highlightAll = false) const; /** \details Highlights an element. \param bDoIt [in] Flag that indicates whether highlighting is enabled (true value) or disabled (false value). \param pSubId [in] Path to the entity for highlighting. \param highlightAll [in] Flag to highlight all. */ void subHighlight(const bool bDoIt, const OdNwFullSubentPath* pPath, const bool highlightAll = false) const; }; /** \details This template class is a specialization of the OdSmartPtr class for OdNwModelItem object pointers. */ typedef OdSmartPtr OdNwModelItemPtr; #endif //__TNW_MODELITEM_H__