Visual Computing Library
Loading...
Searching...
No Matches
vcl::MeshRenderSettings Class Reference

The MeshRenderSettings class allows an easy management of render settings of a Mesh. This class stores the rendering status of a Mesh, the rendering capability of a Mesh and a series of other data like user colors used for the mesh primitives. More...

#include <vclib/render/drawable/mesh/mesh_render_settings.h>

Public Member Functions

 MeshRenderSettings ()=default
 Construct a new MeshRenderSettings object with capabilities set to false.
 
template<MeshConcept MeshType>
 MeshRenderSettings (const MeshType &m)
 Construct a new MeshRenderSettings object from a Mesh.
 
MeshRenderInfo drawMode () const
 Returns the current draw mode as a MeshRenderInfo object.
 
bool operator== (const MeshRenderSettings &) const =default
 
bool operator!= (const MeshRenderSettings &) const =default
 
bool canBeVisible () const
 Returns whether the mesh can be visible.
 
template<MeshRenderInfo::Primitive PRIMITIVE, typename Enum >
bool can (Enum val) const
 Returns the capability of a given option for the given primitive.
 
bool canPoints (MeshRenderInfo::Points p) const
 Returns the capability of a given option for the points primitive.
 
bool canSurface (MeshRenderInfo::Surface s) const
 Returns the capability of a given option for the surface primitive.
 
bool canWireframe (MeshRenderInfo::Wireframe w) const
 Returns the capability of a given option for the wireframe primitive.
 
bool canEdges (MeshRenderInfo::Edges e) const
 Returns the capability of a given option for the edges primitive.
 
bool isVisible () const
 Returns whether the mesh is visible.
 
template<MeshRenderInfo::Primitive PRIMITIVE, typename Enum >
bool is (Enum val) const
 Returns whether the given option for the given primitive is set.
 
bool isPoints (MeshRenderInfo::Points p) const
 Returns whether the given points option is set.
 
float pointWidth () const
 
vcl::Color pointUserColor () const
 
const floatpointUserColorData () const
 
bool isSurface (MeshRenderInfo::Surface s) const
 Returns whether the given surface option is set.
 
vcl::Color surfaceUserColor () const
 
const uintsurfaceUserColorData () const
 
bool isWireframe (MeshRenderInfo::Wireframe w) const
 Returns whether the given wireframe option is set.
 
int wireframeWidth () const
 
vcl::Color wireframeUserColor () const
 
const floatwireframeUserColorData () const
 
bool isEdges (MeshRenderInfo::Edges e) const
 Returns whether the given edges option is set.
 
int edgesWidth () const
 
vcl::Color edgesUserColor () const
 
const uintedgesUserColorData () const
 
bool setVisibility (bool b)
 Sets the visibility of the mesh.
 
template<MeshRenderInfo::Primitive PRIMITIVE, typename Enum >
bool set (Enum val, bool b=true)
 Sets given the shading option of the given primitive.
 
bool setPoints (MeshRenderInfo::Points p, bool b=true)
 Sets the given shading option of the points.
 
bool setPointsWidth (float width)
 
bool setPointsUserColor (float r, float g, float b, float a=1)
 
bool setPointsUserColor (const vcl::Color &c)
 
bool setSurface (MeshRenderInfo::Surface s, bool b=true)
 Sets the given shading option of the surface.
 
bool setSurfaceUserColor (float r, float g, float b, float a=1)
 
bool setSurfaceUserColor (const vcl::Color &c)
 
bool setWireframe (MeshRenderInfo::Wireframe w, bool b=true)
 Sets the given shading option of the wireframe.
 
bool setWireframeUserColor (float r, float g, float b, float a=1)
 
bool setWireframeUserColor (const vcl::Color &c)
 
bool setWireframeWidth (int width)
 
bool setEdges (MeshRenderInfo::Edges e, bool b=true)
 Sets the given shading option of the edges.
 
bool setEdgesUserColor (float r, float g, float b, float a=1)
 
bool setEdgesUserColor (const vcl::Color &c)
 
bool setEdgesWidth (int width)
 
template<MeshConcept MeshType>
void setRenderCapabilityFrom (const MeshType &m)
 
void setDefaultSettingsFromCapability ()
 

Private Types

using MRI = MeshRenderInfo
 

Private Member Functions

template<MeshRenderInfo::Primitive PRIMITIVE, typename Enum >
void setCapability (Enum val, bool b=true)
 
void setPointsCapability (MeshRenderInfo::Points p, bool b=true)
 
void setSurfaceCapability (MeshRenderInfo::Surface s, bool b=true)
 
void setWireframeCapability (MeshRenderInfo::Wireframe w, bool b=true)
 
void setEdgesCapability (MeshRenderInfo::Edges e, bool b=true)
 
void setDefaultPointSettingsFromCapability ()
 
void setDefaultSurfaceSettingsFromCapability ()
 
void setDefaultWireframeSettingsFromCapability ()
 
void setDefaultEdgeSettingsFromCapability ()
 

Private Attributes

MeshRenderInfo mCapability
 
MeshRenderInfo mDrawMode
 
float mPointWidth = 3
 
float mPointUserColor [4] = {1, 1, 0, 1}
 
uint mSurfUserColor = 0xFF808080
 
int mWrfWidth = 1
 
float mWrfUserColor [4] = {0, 0, 0, 1}
 
int mEdgesWidth = 1
 
uint mEdgesUserColor = 0xFF000000
 

Detailed Description

The MeshRenderSettings class allows an easy management of render settings of a Mesh. This class stores the rendering status of a Mesh, the rendering capability of a Mesh and a series of other data like user colors used for the mesh primitives.

Render capabilities store what can be actually rendered of a vcl::Mesh (e.g. it will be possible to render the surface of the mesh if the Mesh has Faces, or it will be possible to render per Face colors only if the Mesh has enabled per face colors).

The render status of this class is guaranteed to be consistent to the render capabilities.

An instance of this class must be initialized with a vcl::Mesh at first, in order to initialize the render capabilites. Render settings won't be possible to set if this class is not first initialized using a vcl::Mesh, trough the constructor or the setRenderCapabilityFrom() member function.

Render capabilities can be get by calling the member functions can*() for each primitive, and providing the according enum value for the option to query.

The memeber functions is*() allow to get the current render status for each primitive, providing the according enum value for the option to query.

The render status can be modified using the set*() member functions for each primitive. They return a boolean indicating if the operation has been performed (if the capabilities allows it, the operation will be always performed).

The set*() functions are guaranteed to keep the state of the draw mode consistent. This means that if the user sets an option that belongs to a range (e.g. SHADING_*), the other options of the range will be automatically set to false.

Constructor & Destructor Documentation

◆ MeshRenderSettings() [1/2]

vcl::MeshRenderSettings::MeshRenderSettings ( )
default

Construct a new MeshRenderSettings object with capabilities set to false.

An object created with this constructor will not be able to set any rendering option until the setRenderCapabilityFrom() member function is called.

◆ MeshRenderSettings() [2/2]

template<MeshConcept MeshType>
vcl::MeshRenderSettings::MeshRenderSettings ( const MeshType &  m)
inline

Construct a new MeshRenderSettings object from a Mesh.

This constructor initializes the render capabilities from the given Mesh object. The render settings are then set to the default values.

Template Parameters
MeshTypethe type of the Mesh object.
Parameters
mthe Mesh object to initialize the render capabilities.

Member Function Documentation

◆ can()

template<MeshRenderInfo::Primitive PRIMITIVE, typename Enum >
bool vcl::MeshRenderSettings::can ( Enum  val) const
inline

Returns the capability of a given option for the given primitive.

The primitive is a template parameter that specifies the primitive to query. The Enum parameter specifies the option to query.

Template Parameters
PRIMTIVEthe primitive for which to get the capability.
Parameters
[in]valthe option to query.
Returns
true if the option can be set, false otherwise.

◆ canBeVisible()

bool vcl::MeshRenderSettings::canBeVisible ( ) const
inline

Returns whether the mesh can be visible.

Returns
true if the mesh can be visible, false otherwise.

◆ canEdges()

bool vcl::MeshRenderSettings::canEdges ( MeshRenderInfo::Edges  e) const
inline

Returns the capability of a given option for the edges primitive.

Parameters
[in]ethe edges option to query.
Returns
true if the option can be set, false otherwise.

◆ canPoints()

bool vcl::MeshRenderSettings::canPoints ( MeshRenderInfo::Points  p) const
inline

Returns the capability of a given option for the points primitive.

Parameters
[in]pthe points option to query.
Returns
true if the option can be set, false otherwise.

◆ canSurface()

bool vcl::MeshRenderSettings::canSurface ( MeshRenderInfo::Surface  s) const
inline

Returns the capability of a given option for the surface primitive.

Parameters
[in]sthe surface option to query.
Returns
true if the option can be set, false otherwise.

◆ canWireframe()

bool vcl::MeshRenderSettings::canWireframe ( MeshRenderInfo::Wireframe  w) const
inline

Returns the capability of a given option for the wireframe primitive.

Parameters
[in]wthe wireframe option to query.
Returns
true if the option can be set, false otherwise.

◆ drawMode()

MeshRenderInfo vcl::MeshRenderSettings::drawMode ( ) const
inline

Returns the current draw mode as a MeshRenderInfo object.

Returns
the current draw mode as a MeshRenderInfo object.

◆ is()

template<MeshRenderInfo::Primitive PRIMITIVE, typename Enum >
bool vcl::MeshRenderSettings::is ( Enum  val) const
inline

Returns whether the given option for the given primitive is set.

The primitive is a template parameter that specifies the primitive to query. The Enum parameter specifies the option to query.

Template Parameters
PRIMTIVEthe primitive for which to get the option.
Parameters
[in]valthe option to query.
Returns
true if the option is set, false otherwise.

◆ isEdges()

bool vcl::MeshRenderSettings::isEdges ( MeshRenderInfo::Edges  e) const
inline

Returns whether the given edges option is set.

Parameters
[in]ethe edges option to query.
Returns
true if the option is set, false otherwise.

◆ isPoints()

bool vcl::MeshRenderSettings::isPoints ( MeshRenderInfo::Points  p) const
inline

Returns whether the given points option is set.

Parameters
[in]pthe points option to query.
Returns
true if the option is set, false otherwise.

◆ isSurface()

bool vcl::MeshRenderSettings::isSurface ( MeshRenderInfo::Surface  s) const
inline

Returns whether the given surface option is set.

Parameters
[in]sthe surface option to query.
Returns
true if the option is set, false otherwise.

◆ isVisible()

bool vcl::MeshRenderSettings::isVisible ( ) const
inline

Returns whether the mesh is visible.

Returns
true if the mesh is visible, false otherwise.

◆ isWireframe()

bool vcl::MeshRenderSettings::isWireframe ( MeshRenderInfo::Wireframe  w) const
inline

Returns whether the given wireframe option is set.

Parameters
[in]wthe wireframe option to query.
Returns
true if the option is set, false otherwise.

◆ set()

template<MeshRenderInfo::Primitive PRIMITIVE, typename Enum >
bool vcl::MeshRenderSettings::set ( Enum  val,
bool  b = true 
)
inline

Sets given the shading option of the given primitive.

The primitive is a template parameter that specifies the primitive to query. The Enum parameter specifies the option to query.

If the capability does not allow to set the given option, the function does nothing and it returns false. Otherwise, it returns true.

If the option does not have a range (e.g. VISIBLE), the

Parameters
bparameter will be used to set the option to the primitive.

If the option has a range (e.g. the range SHADING_*), the

Parameters
bis not considered. The given option is set to true, and all the other options of the range are automatically set to false.
Template Parameters
PRIMTIVEthe primitive for which to set the option.
Parameters
[in]valthe primitive option to set
[in]bboolean value to set to the option (if it is not a range).
Returns
true if the option has been set, false otherwise.

◆ setEdges()

bool vcl::MeshRenderSettings::setEdges ( MeshRenderInfo::Edges  e,
bool  b = true 
)
inline

Sets the given shading option of the edges.

If the capability does not allow to set the given option, the function does nothing and it returns false. Otherwise, it returns true.

If the option does not have a range (e.g. VISIBLE), the

Parameters
bparameter will be used to set the option to the edges.

If the option has a range (e.g. the range SHADING_*), the

Parameters
bis not considered. The given option is set to true, and all the other options of the range are automatically set to false.
[in]ethe edges option to set
[in]bboolean value to set to the option (if it is not a range).
Returns
true if the option has been set, false otherwise.

◆ setPoints()

bool vcl::MeshRenderSettings::setPoints ( MeshRenderInfo::Points  p,
bool  b = true 
)
inline

Sets the given shading option of the points.

If the capability does not allow to set the given option, the function does nothing and it returns false. Otherwise, it returns true.

If the option does not have a range (e.g. VISIBLE), the

Parameters
bparameter will be used to set the option to the points.

If the option has a range (e.g. the range SHADING_*), the

Parameters
bis not considered. The given option is set to true, and all the other options of the range are automatically set to false.
[in]pthe points option to set
[in]bboolean value to set to the option (if it is not a range).
Returns
true if the option has been set, false otherwise.

◆ setSurface()

bool vcl::MeshRenderSettings::setSurface ( MeshRenderInfo::Surface  s,
bool  b = true 
)
inline

Sets the given shading option of the surface.

If the capability does not allow to set the given option, the function does nothing and it returns false. Otherwise, it returns true.

If the option does not have a range (e.g. VISIBLE), the

Parameters
bparameter will be used to set the option to the surface.

If the option has a range (e.g. the range SHADING_*), the

Parameters
bis not considered. The given option is set to true, and all the other options of the range are automatically set to false.
[in]sthe surface option to set
[in]bboolean value to set to the option (if it is not a range).
Returns
true if the option has been set, false otherwise.

◆ setVisibility()

bool vcl::MeshRenderSettings::setVisibility ( bool  b)
inline

Sets the visibility of the mesh.

The visibility status can be set only if the capability allows it.

Parameters
[in]bthe visibility status to set.
Returns
true if the visibility status has been set, false otherwise.

◆ setWireframe()

bool vcl::MeshRenderSettings::setWireframe ( MeshRenderInfo::Wireframe  w,
bool  b = true 
)
inline

Sets the given shading option of the wireframe.

If the capability does not allow to set the given option, the function does nothing and it returns false. Otherwise, it returns true.

If the option does not have a range (e.g. VISIBLE), the

Parameters
bparameter will be used to set the option to the wireframe.

If the option has a range (e.g. the range SHADING_*), the

Parameters
bis not considered. The given option is set to true, and all the other options of the range are automatically set to false.
[in]wthe wireframe option to set
[in]bboolean value to set to the option (if it is not a range).
Returns
true if the option has been set, false otherwise.

The documentation for this class was generated from the following file: