Hide menu
Loading...
Searching...
No Matches
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.
 
 ModelPrs_SceneNode (initialized)
 Constructor.
 
ModelPrs_SceneNode Parent () const
 Returns a parent of this.
 
bool Detach ()
 Detachs from parent and returns a result.
 
bool AddChildNode (ModelPrs_SceneNode &theNode)
 Adds theNode to children. Returns false if the node already has a parent, otherwise returns true.
 
bool RemoveChildNode (ModelPrs_SceneNode &theNode)
 Removes theNode from children.
 
void RemoveChildrenNodes ()
 Removes all children.
 
ModelPrs_Geometry Geometry () const
 Returns a geometry attribute.
 
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.
 
void SetDisplayMode (ModelPrs_DisplayMode theMode)
 Sets theMode as display mode.
 
ModelPrs_SelectionMode SelectionMode () const
 Returns selection mode.
 
void SetSelectionMode (ModelPrs_SelectionMode theMode)
 Sets theMode as selection mode.
 
ModelPrs_VisibilityMode VisibilityMode () const
 Returns visibility mode.
 
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
void Nullify ()
 Resets reference to implementation object.
 
bool IsNull () const
 Returns true if the object is nullified.
 
 operator bool () const
 Casts the object to the bool type.
 
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.

Warning
This class is a part of Visualization Toolkit add-on, which is licensed separately from the base CAD Exchanger SDK.

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);
Defines a visitor of the scene nodes.
Definition: ModelPrs_SceneNodeVisitor.hxx:30
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
MTKConverter/Program.cs, visualization/offscreen/Program.cs, visualization/qtquick_qml/baseviewer/main.cxx, visualization/qtquick_qml/manipulator/main.cxx, visualization/qtquick_qml/measurements/main.cxx, visualization/qtquick_qml/pmiviewer/main.cxx, visualization/qtquick_qml/selectionhandling/main.cxx, visualization/winforms/baseviewer/Program.cs, visualization/wpf/baseviewer/App.xaml.cs, visualization/wpf/pmiviewer/App.xaml.cs, and visualization/wpf/selectionhandling/App.xaml.cs.

Constructor & Destructor Documentation

◆ ModelPrs_SceneNode() [1/2]

cadex::ModelPrs_SceneNode::ModelPrs_SceneNode ( )

Constructor.

Creates a null object (see IsNull()).

◆ ModelPrs_SceneNode() [2/2]

cadex::ModelPrs_SceneNode::ModelPrs_SceneNode ( initialized  )

Constructor.

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

Member Function Documentation

◆ AddChildNode()

bool cadex::ModelPrs_SceneNode::AddChildNode ( ModelPrs_SceneNode theNode)

Adds theNode to children. Returns false if the node already has a parent, otherwise returns true.

See also
RemoveChildNode, RemoveChildrenNodes
Examples
visualization/qtquick_qml/measurements/main.cxx, visualization/qtquick_qml/pmiviewer/main.cxx, and visualization/wpf/pmiviewer/App.xaml.cs.

◆ Detach()

bool cadex::ModelPrs_SceneNode::Detach ( )

Detachs from parent and returns a result.

Returns true if parent exists and false otherwise.

◆ DisplayMode()

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

◆ Geometry()

ModelPrs_Geometry cadex::ModelPrs_SceneNode::Geometry ( ) const

Returns a geometry attribute.

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

◆ Parent()

ModelPrs_SceneNode cadex::ModelPrs_SceneNode::Parent ( ) const

◆ RemoveChildNode()

bool cadex::ModelPrs_SceneNode::RemoveChildNode ( ModelPrs_SceneNode theNode)

Removes theNode from children.

Warning
A call to this function resulting in true value invalidates the instance of ModelPrs_SceneNodeVisitor over scene node's children, making further behavior of these objects undefined.

◆ SelectionMode()

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

◆ SetAppearance()

void cadex::ModelPrs_SceneNode::SetAppearance ( const ModelData_Appearance theAppearance)

◆ SetTransformation()

void cadex::ModelPrs_SceneNode::SetTransformation ( const ModelData_Transformation theTransformation)

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

◆ VisibilityMode()

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