Hide menu
cadex::ModelPrs_SceneNode Class Reference

Represents a node in the visual scene graph. More...

Inheritance diagram for cadex::ModelPrs_SceneNode:
cadex::Base_PublicObject

Public Types

typedef cadex::internal::ModelPrs_SceneNodeImpl ImplType
 

Public Member Functions

 ModelPrs_SceneNode ()
 Constructor. More...
 
 ModelPrs_SceneNode (initialized)
 Constructor. More...
 
ModelPrs_SceneNode Parent () const
 Returns a parent of this. More...
 
bool Detach ()
 Detachs from parent and returns a result. More...
 
void AddChildNode (ModelPrs_SceneNode &theNode)
 Adds theNode to children. More...
 
void RemoveChildNode (ModelPrs_SceneNode &theNode)
 Removes theNode from children.
 
void RemoveChildrenNodes ()
 Removes all children.
 
ModelPrs_Geometry Geometry () const
 Returns a geometry attribute. More...
 
void SetGeometry (const ModelPrs_Geometry &theGeometry)
 Sets geometry attribute or nullify it if ModelPrs_Geometry::IsNull() returns true for theGeometry.
 
ModelData_Appearance Appearance () const
 Returns appearance.
 
void SetAppearance (const ModelData_Appearance &theAppearance)
 
ModelData_Transformation Transformation () const
 Returns transformation.
 
void SetTransformation (const ModelData_Transformation &theTransformation)
 
ModelPrs_DisplayMode DisplayMode () const
 Returns display mode. More...
 
void SetDisplayMode (ModelPrs_DisplayMode theMode)
 Sets theMode as display mode.
 
ModelPrs_SelectionMode SelectionMode () const
 Returns selection mode. More...
 
void SetSelectionMode (ModelPrs_SelectionMode theMode)
 Sets theMode as selection mode.
 
ModelPrs_VisibilityMode VisibilityMode () const
 Returns visibility mode. More...
 
void SetVisibilityMode (ModelPrs_VisibilityMode theMode)
 Sets theMode as visibility mode.
 
std::shared_ptr< Data > UserData () const
 Returns pointer to user data if exist or nullptr otherwise.
 
void SetUserData (const std::shared_ptr< Data > &theUserData)
 Sets user data or nullify it if theUserData is nullptr.
 
void Accept (ModelPrs_SceneNodeVisitor &theVisitor) const
 Accepts a visitor.
 
void Invalidate ()
 Marks scene node to update.
 
 ModelPrs_SceneNode (ImplType *theImpl)
 Constructor (reserved for internal use).
 
- Public Member Functions inherited from cadex::Base_PublicObject
 Base_PublicObject ()
 Constructor. More...
 
void Nullify ()
 Resets reference to implementation object.
 
bool IsNull () const
 Returns true if the object is nullified. More...
 
 operator bool () const
 Casts the object to the bool type. More...
 
internal::Base_HandledObject * Impl () const
 Return a handle to backend (reserved for internal use).
 

Additional Inherited Members

- Protected Member Functions inherited from cadex::Base_PublicObject
 Base_PublicObject (const internal::Base_HandledObject *theObject)
 Constructor (reserved for internal use).
 
template<typename T >
T * GetOrCreateImpl ()
 Reserved for internal use.
 

Detailed Description

Represents a node in the visual scene graph.

Scene nodes constitute hierarchy of the logical objects on the 3D scene. A node has a single parent node and may have zero, one or multiple child nodes.

The scene node is not typed: ModelPrs_SceneNode may not have subclasses. Semantics is determined by the application.

Each node can carry various data items that define how the object or a sub-tree is displayed. These include:

  • Geometrical definition: B-Rep or meshes (triangles, polylines, points);
  • Visual appearance (colors, materials, textures, line styles, etc);
  • Transformations (e.g. 3x4 or 4x4 matrices);
  • Display styles (shading or wireframe, semi-transparent or full hiding, etc);
  • Selection modes (entire object, or individual sub-shapes, etc).

Implementation has been optimized to allocate memory only for those data items that have been explicitly created (e.g. transformation matrix or a material). When data items are not explicitly defined then no extra memory footprint is incurred.

Scene nodes may not be shared among parents, sharing of heavy-weight data (e.g. geometry) is provided via shareable data attributes. For instance, two instances of the same part in an assembly will be mapped to two scene nodes referring to the same geometry and distinct transformations.

Creation

Refer Creating a scene graph and ModelPrs_SceneGraphFactory.

See also
Scene Graph, Adding and removing scene nodes

Traversal

Traversal of the sub-tree starting with the given scene node can be done with the help of visitors. Each scene node accepts a visitor which must be a subclass of an abstract class ModelPrs_SceneNodeVisitor with overridden methods. If the redefined VisitEnter() method returns false then the respective subgraph will not be visited.

class NodeVisitor : public ModelPrs_SceneNodeVisitor
{
};
NodeVisitor aVisitor;
aNode.Accept (aVisitor);
See also
ModelPrs_SceneNodeVisitor

A scene node contains a shared pointer to its internal implementation, so simple copying an object will just copy a shared pointer. Therefore any modification of the copied object will propagate to original object.

See also
Using pimpl pattern
Examples:
visualization/qtquick_qml/baseviewer/main.cxx, visualization/qtquick_qml/manipulator/main.cxx, visualization/qtquick_qml/measurements/main.cxx, visualization/qtquick_qml/pmiviewer/main.cxx, and visualization/qtquick_qml/selectionhandling/main.cxx.

Constructor & Destructor Documentation

cadex::ModelPrs_SceneNode::ModelPrs_SceneNode ( )

Constructor.

Creates a null object (see IsNull()).

cadex::ModelPrs_SceneNode::ModelPrs_SceneNode ( initialized  )

Constructor.

Creates an object with implementation (IsNull() is false).

Member Function Documentation

bool cadex::ModelPrs_SceneNode::Detach ( )

Detachs from parent and returns a result.

Returns true if parent exists and false otherwise.

ModelPrs_DisplayMode cadex::ModelPrs_SceneNode::DisplayMode ( ) const

Returns display mode.

ModelPrs_DM_Undefined display mode means that it inherits from parent.

See also
Node attributes inheritance
ModelPrs_Geometry cadex::ModelPrs_SceneNode::Geometry ( ) const

Returns a geometry attribute.

Will return an empty object (see IsNull()) if geometry is not exist.

ModelPrs_SceneNode cadex::ModelPrs_SceneNode::Parent ( ) const

Returns a parent of this.

Will return null object (see IsNull()) if parent is not exist.

Examples:
visualization/qtquick_qml/measurements/main.cxx, and visualization/qtquick_qml/selectionhandling/main.cxx.
ModelPrs_SelectionMode cadex::ModelPrs_SceneNode::SelectionMode ( ) const

Returns selection mode.

ModelPrs_SM_Undefined selection mode means that it inherits from parent.

See also
Node attributes inheritance
void cadex::ModelPrs_SceneNode::SetAppearance ( const ModelData_Appearance theAppearance)
void cadex::ModelPrs_SceneNode::SetTransformation ( const ModelData_Transformation theTransformation)

Sets theTransformation as transformation or nullify it if ModelData_Transformation::IsIdentity() for theTransformation returns true;

Examples:
visualization/qtquick_qml/pmiviewer/main.cxx, and visualization/qtquick_qml/selectionhandling/main.cxx.
ModelPrs_VisibilityMode cadex::ModelPrs_SceneNode::VisibilityMode ( ) const

Returns visibility mode.

ModelPrs_VM_Undefined visibility mode means that it inherits from parent.

See also
Node attributes inheritance