\( \newcommand{\E}{\mathrm{E}} \) \( \newcommand{\A}{\mathrm{A}} \) \( \newcommand{\R}{\mathrm{R}} \) \( \newcommand{\N}{\mathrm{N}} \) \( \newcommand{\Q}{\mathrm{Q}} \) \( \newcommand{\Z}{\mathrm{Z}} \) \( \def\ccSum #1#2#3{ \sum_{#1}^{#2}{#3} } \def\ccProd #1#2#3{ \sum_{#1}^{#2}{#3} }\)
CGAL 5.0.2 - Three
CGAL::Three::Scene_item Class Referenceabstract

#include <CGAL/Three/Scene_item.h>

Inherits from

QObject.

Inherited by CGAL::Three::Scene_item_rendering_helper.

Definition

This class represents an object in the OpenGL scene.

It contains all the functions called by the Scene. It acts like a mix between an interface and a helper.

Examples:
Three/Example_plugin/Basic_item_plugin.cpp, and Three/Example_plugin/Example_plugin.cpp.

Classes

struct  Header_data
 Contains the header for the table in the statistics dialog. More...
 

Public Types

enum  OpenGL_program_IDs { ,
  PROGRAM_WITHOUT_LIGHT, PROGRAM_NO_SELECTION, PROGRAM_WITH_TEXTURE, PROGRAM_PLANE_TWO_FACES,
  PROGRAM_WITH_TEXTURED_EDGES, PROGRAM_INSTANCED, PROGRAM_INSTANCED_WIRE, PROGRAM_C3T3,
  PROGRAM_C3T3_EDGES, PROGRAM_CUTPLANE_SPHERES, PROGRAM_SPHERES, PROGRAM_DARK_SPHERES,
  PROGRAM_FLAT, PROGRAM_OLD_FLAT, PROGRAM_SOLID_WIREFRAME, PROGRAM_NO_INTERPOLATION,
  PROGRAM_HEAT_INTENSITY, NB_OF_PROGRAMS
}
 The OpenGL_program_IDs enum. More...
 

Public Slots

virtual void invalidateOpenGLBuffers ()
 Notifies the program that the internal data or the properties of an item has changed, and that it must be computed again. More...
 
virtual void setColor (QColor c)
 Setter for the color of the item.
 
void setRgbColor (int r, int g, int b)
 Setter for the RGB color of the item. More...
 
virtual void setName (QString n)
 Sets the name of the item.
 
virtual void setVisible (bool b)
 Sets the visibility of the item.
 
virtual void moveToGroup (Scene_group_item *group)
 Set the parent group. More...
 
virtual void setRenderingMode (RenderingMode m)
 Sets the rendering mode of the item. More...
 
void setPointsMode ()
 Sets the RenderingMode to Points.
 
void setShadedPointsMode ()
 Sets the RenderingMode to Points.
 
void setWireframeMode ()
 Sets the RenderingMode to Wireframe.
 
void setFlatMode ()
 Sets the RenderingMode to Flat.
 
void setFlatPlusEdgesMode ()
 Set the RenderingMode to FlatPlusEdges.
 
void setGouraudMode ()
 Sets the RenderingMode to Gouraud.
 
void setPointsPlusNormalsMode ()
 Sets the RenderingMode to PointsPlusNormals.
 
void setGouraudPlusEdgesMode ()
 Sets the RenderingMode to GouraudPlusEdges.
 
virtual void itemAboutToBeDestroyed (Scene_item *)
 Emits an aboutToBeDestroyed() signal. More...
 
virtual float alpha () const
 Returns the alpha value for the item. More...
 
virtual void setAlpha (int alpha)
 Sets the value of the aplha Slider for this item. More...
 
virtual void select (double orig_x, double orig_y, double orig_z, double dir_x, double dir_y, double dir_z)
 Selects a point through raycasting.
 

Signals

void itemChanged ()
 Is emitted to notify a change in the item's data.
 
void itemVisibilityChanged ()
 Is emitted when the item is shown to notify a change in the item's visibility. More...
 
void aboutToBeDestroyed ()
 Is emitted to notify that the item is about to be deleted.
 
void redraw ()
 Is emitted to require a new display.
 

Public Member Functions

 Scene_item (int buffers_size=20, int vaos_size=10)
 The Constructor. More...
 
void setNbIsolatedvertices (std::size_t nb)
 Sets the number of isolated vertices. More...
 
std::size_t getNbIsolatedvertices () const
 Getter for the number of isolated vertices. More...
 
virtual Scene_itemclone () const =0
 Duplicates the item. More...
 
virtual bool supportsRenderingMode (RenderingMode m) const =0
 Indicates if m is supported. More...
 
virtual void draw () const
 Deprecated. Does nothing.
 
virtual void draw (CGAL::Three::Viewer_interface *) const
 The drawing function for faces. More...
 
virtual void drawEdges () const
 Deprecated. Does nothing.
 
virtual void drawEdges (CGAL::Three::Viewer_interface *viewer) const
 The drawing function for the edges. More...
 
virtual void drawPoints () const
 Deprecated. Does nothing.
 
virtual void drawPoints (CGAL::Three::Viewer_interface *) const
 The drawing function for the points. More...
 
virtual void selection_changed (bool b)
 Called by the scene. If b is true, then this item is currently selected.
 
virtual QString toolTip () const =0
 Contains meta-data about the item. More...
 
virtual QPixmap graphicalToolTip () const
 Contains graphical meta-data about the item. More...
 
virtual QFont font () const
 Contains the font used for the data of the item. More...
 
virtual bool isFinite () const
 Determines if the item is finite or not. More...
 
virtual bool isEmpty () const
 Specifies if the item is empty or null. More...
 
virtual Bbox bbox () const
 The item's bounding box. More...
 
virtual double diagonalBbox () const
 the item's bounding box's diagonal length. More...
 
virtual bool manipulatable () const
 Returns true if the item has a ManipulatedFrame. More...
 
virtual ManipulatedFrame * manipulatedFrame ()
 The manipulatedFrame of the item. More...
 
virtual QColor color () const
 Getter for the item's color. More...
 
virtual QString name () const
 Getter for the item's name. More...
 
virtual bool visible () const
 If the item is not visible, it is not drawn and its Bbox is ignored in the computation of the scene's. More...
 
virtual RenderingMode renderingMode () const
 Getter for the item's rendering mode. More...
 
virtual QString renderingModeName () const
 The renderingMode's name. More...
 
virtual QMenu * contextMenu ()
 Context menu. More...
 
void setId (int id)
 setId informs the item of its current index in the scene entries.
 
int getId () const
 getId returns the current index of this item in the scene entries.
 
void resetMenu ()
 invalidates the context menu. More...
 
virtual bool keyPressEvent (QKeyEvent *)
 Handles key press events.
 
Scene_group_itemparentGroup () const
 The group containing the item. More...
 
virtual Header_data header () const
 Returns a Header_data struct containing the header information.
 
virtual bool has_stats () const
 Returns true if the item has statistics.
 
virtual QString computeStats (int i)
 Returns a QString containing the requested value for the the table in the statistics dialog. More...
 
virtual void newViewer (CGAL::Three::Viewer_interface *viewer)=0
 newViewer adds Vaos for viewer. More...
 
virtual void removeViewer (CGAL::Three::Viewer_interface *viewer)=0
 removeViewer removes the Vaos fo viewer. More...
 
virtual QString defaultSaveName () const
 defaultSaveName returns the name to be used as default when saving this item. More...
 

Public Attributes

int has_group
 Contains the number of group and subgroups containing this item.
 

Static Public Attributes

static const QColor defaultColor
 The default color of a scene_item. More...
 

Protected Member Functions

void addVaos (int i)
 Adds a VAO to the Map.
 
void initializeBuffers ()
 Fills the VBOs with data.
 
void attribBuffers (CGAL::Three::Viewer_interface *, int program_name) const
 Passes all the uniform data to the shaders. More...
 
virtual QOpenGLShaderProgram * getShaderProgram (int name, CGAL::Three::Viewer_interface *viewer=0) const
 Compatibility function. More...
 

Protected Attributes

Bbox _bbox
 Holds the BBox of the item.
 
QString name_
 The name of the item.
 
QColor color_
 The color of the item.
 
bool visible_
 The visibility of the item.
 
Scene_group_itemparent_group
 The parent group, or 0 if the item is not in a group.
 
bool is_selected
 Specifies if the item is currently selected.
 
std::size_t nb_isolated_vertices
 Holds the number of vertices that are not linked to the polyhedron from the OFF file. More...
 
bool are_buffers_filled
 Decides if the draw function must call initializeBuffers() or not. More...
 
RenderingMode rendering_mode
 The rendering mode of the item. More...
 
QMenu * defaultContextMenu
 The default context menu.
 
RenderingMode prev_shading
 Contains the previous RenderingMode. More...
 
RenderingMode cur_shading
 Contains the current RenderingMode. More...
 
int buffersSize
 Contains the size of the vector of VBOs.
 
int vaosSize
 Contains the size of the map of VAOs.
 
std::vector< QOpenGLBuffer > buffers
 Contains the VBOs.
 
std::vector< QOpenGLVertexArrayObject * > vaos
 Contains the VAOs.
 

Member Enumeration Documentation

◆ OpenGL_program_IDs

The OpenGL_program_IDs enum.

This enum holds the OpenGL programs IDs that are given to getShaderProgram() and attribBuffers().

See also
getShaderProgram
attribBuffers
Enumerator
PROGRAM_WITHOUT_LIGHT 

Used to render a surface or an edge affected by the light. It uses a per fragment lighting model, and renders the selected item brighter.

PROGRAM_NO_SELECTION 

Used to render a polyhedron edge or points. It renders in a uniform color and is not affected by light.

Attention
It renders the selected item in black.
PROGRAM_WITH_TEXTURE 

Used to render a polyline or a surface that is not affected by light, like a cutting plane. It renders in a uniform color that does not change with selection.

PROGRAM_PLANE_TWO_FACES 

Used to render a textured polyhedron. Affected by light.

PROGRAM_WITH_TEXTURED_EDGES 

Used to render a two-faced plane. The two faces have a different color. Not affected by light.

PROGRAM_INSTANCED 

Used to render the edges of a textured polyhedron. Not affected by light.

PROGRAM_INSTANCED_WIRE 

Used to display instanced rendered spheres.Affected by light.

PROGRAM_C3T3 

Used to display instanced rendered wired spheres. Not affected by light.

PROGRAM_C3T3_EDGES 

Used to render a c3t3_item. It discards any fragment on a side of a plane, meaning that nothing is displayed on this side of the plane. Affected by light.

PROGRAM_CUTPLANE_SPHERES 

Used to render the edges of a c3t3_item. It discards any fragment on a side of a plane, meaning that nothing is displayed on this side of the plane. Not affected by light.

PROGRAM_SPHERES 

Used to render the spheres of an item with a cut plane.

PROGRAM_DARK_SPHERES 

Used to render one or several spheres.

PROGRAM_FLAT 

Used to render one or several spheres without light (for picking for example).

PROGRAM_OLD_FLAT 

Used to render flat shading without pre computing normals.

PROGRAM_SOLID_WIREFRAME 

Used to render flat shading without pre computing normals without geometry shader.

PROGRAM_NO_INTERPOLATION 

Used to render edges with width superior to 1.

PROGRAM_HEAT_INTENSITY 

Used to render faces without interpolating their color.

NB_OF_PROGRAMS 

Used to render special item in Display_property_plugin.

Holds the number of different programs in this enum.

Constructor & Destructor Documentation

◆ Scene_item()

CGAL::Three::Scene_item::Scene_item ( int  buffers_size = 20,
int  vaos_size = 10 
)

The Constructor.

This is where the vectors of VBOs and VAOs are initialized.

Member Function Documentation

◆ alpha

virtual float CGAL::Three::Scene_item::alpha ( ) const
virtualslot

Returns the alpha value for the item.

Must be called within a valid openGl context.

Reimplemented in CGAL::Three::Scene_item_rendering_helper.

◆ attribBuffers()

void CGAL::Three::Scene_item::attribBuffers ( CGAL::Three::Viewer_interface ,
int  program_name 
) const
protected

Passes all the uniform data to the shaders.

According to program_name, this data may change.

Examples:
Three/Example_plugin/Example_plugin.cpp.

◆ bbox()

virtual Bbox CGAL::Three::Scene_item::bbox ( ) const
virtual

The item's bounding box.

If the Bbox has never been computed, computes it and saves the result for further calls.

Returns
the item's bounding box.

Reimplemented in CGAL::Three::Scene_group_item, and CGAL::Three::Scene_item_rendering_helper.

◆ clone()

virtual Scene_item* CGAL::Three::Scene_item::clone ( ) const
pure virtual

Duplicates the item.

Creates a new item as a copy of this one.

Implemented in CGAL::Three::Scene_group_item.

Examples:
Three/Example_plugin/Example_plugin.cpp.

◆ color()

virtual QColor CGAL::Three::Scene_item::color ( ) const
virtual

Getter for the item's color.

Returns
the current color of the item.
Examples:
Three/Example_plugin/Example_plugin.cpp.

◆ computeStats()

virtual QString CGAL::Three::Scene_item::computeStats ( int  i)
virtual

Returns a QString containing the requested value for the the table in the statistics dialog.

* Example :
*  ____________________________
* |             |Name   |Cube |
* |             |_______|_____|
* |General Info | #Edges|12   |
* |_____________|_______|_____|
* ComputeStats(0) should return "Cube" and computeStats(1) should return QString::number(12);
* The numbers must be coherent with the order of declaration of the titles in the header.
* 

◆ contextMenu()

virtual QMenu* CGAL::Three::Scene_item::contextMenu ( )
virtual

Context menu.

Contains the list of the supported rendering modes, the Operations menu, actions to save or clone the item if it is supported and any contextual action for the item.

◆ defaultSaveName()

virtual QString CGAL::Three::Scene_item::defaultSaveName ( ) const
virtual

defaultSaveName returns the name to be used as default when saving this item.

Default is name().

Returns
A new name for the default value in the "save as" dialog.

◆ diagonalBbox()

virtual double CGAL::Three::Scene_item::diagonalBbox ( ) const
virtual

the item's bounding box's diagonal length.

If the diagonal's length has never been computed, computes it and saves the result for further calls.

Returns
the item's bounding box's diagonal length.

Reimplemented in CGAL::Three::Scene_item_rendering_helper.

◆ draw()

virtual void CGAL::Three::Scene_item::draw ( CGAL::Three::Viewer_interface ) const
virtual

The drawing function for faces.

Draws the faces of the item in the viewer. The data for the drawing is gathered in computeElements(), and is sent to buffers in initializeBuffers().

See also
computeElements()
initializeBuffers()

Reimplemented in CGAL::Three::Scene_group_item.

◆ drawEdges()

virtual void CGAL::Three::Scene_item::drawEdges ( CGAL::Three::Viewer_interface viewer) const
virtual

The drawing function for the edges.

Draws the edges and lines of the item in the viewer. The data for the drawing is gathered in computeElements(), and is sent to buffers in initializeBuffers().

See also
computeElements()
initializeBuffers()

Reimplemented in CGAL::Three::Scene_group_item.

◆ drawPoints()

virtual void CGAL::Three::Scene_item::drawPoints ( CGAL::Three::Viewer_interface ) const
virtual

The drawing function for the points.

Draws the points of the item in the viewer. The data for the drawing is gathered in computeElements(), and is sent to buffers in initializeBuffers().

See also
computeElements()
initializeBuffers()

Reimplemented in CGAL::Three::Scene_group_item.

◆ font()

virtual QFont CGAL::Three::Scene_item::font ( ) const
virtual

Contains the font used for the data of the item.

Returns
a QFont containing the font used for the data of the item.

◆ getNbIsolatedvertices()

std::size_t CGAL::Three::Scene_item::getNbIsolatedvertices ( ) const

Getter for the number of isolated vertices.

See also
setNbIsolatedvertices

◆ getShaderProgram()

virtual QOpenGLShaderProgram* CGAL::Three::Scene_item::getShaderProgram ( int  name,
CGAL::Three::Viewer_interface viewer = 0 
) const
protectedvirtual

Compatibility function.

Calls viewer->getShaderProgram().

Examples:
Three/Example_plugin/Example_plugin.cpp.

◆ graphicalToolTip()

virtual QPixmap CGAL::Three::Scene_item::graphicalToolTip ( ) const
virtual

Contains graphical meta-data about the item.

Returns
a QPixmap containing graphical meta-data about the item.

◆ invalidateOpenGLBuffers

virtual void CGAL::Three::Scene_item::invalidateOpenGLBuffers ( )
virtualslot

Notifies the program that the internal data or the properties of an item has changed, and that it must be computed again.

It is important to call this function whenever the internal data is changed, or the displayed item will not be updated.

Examples:
Three/Example_plugin/Example_plugin.cpp.

◆ isEmpty()

virtual bool CGAL::Three::Scene_item::isEmpty ( ) const
virtual

Specifies if the item is empty or null.

If true, the BBox is not computed.

Reimplemented in CGAL::Three::Scene_group_item.

◆ isFinite()

virtual bool CGAL::Three::Scene_item::isFinite ( ) const
virtual

Determines if the item is finite or not.

For example, a plane is not finite. If false, the BBox is not computed.

Reimplemented in CGAL::Three::Scene_group_item.

◆ itemAboutToBeDestroyed

virtual void CGAL::Three::Scene_item::itemAboutToBeDestroyed ( Scene_item )
virtualslot

Emits an aboutToBeDestroyed() signal.

Override this function to delete what needs to be deleted on destruction. This might be needed as items are not always deleted right away by Qt and this behaviour may cause a simily memory leak, for example when multiple items are created at the same time.

◆ itemVisibilityChanged

void CGAL::Three::Scene_item::itemVisibilityChanged ( )
signal

Is emitted when the item is shown to notify a change in the item's visibility.

Typically used to update the scene's bbox;

◆ manipulatable()

virtual bool CGAL::Three::Scene_item::manipulatable ( ) const
virtual

Returns true if the item has a ManipulatedFrame.

See also
manipulatedFrame()

◆ manipulatedFrame()

virtual ManipulatedFrame* CGAL::Three::Scene_item::manipulatedFrame ( )
virtual

The manipulatedFrame of the item.

A manipulated frame is an independent system that can be translated or rotated using the Ctrl key and the mouse.

Returns
the manipulatedFrame of the item.

◆ moveToGroup

virtual void CGAL::Three::Scene_item::moveToGroup ( Scene_group_item group)
virtualslot

Set the parent group.

If group==0, then the item has no parent. This function is called by Scene::changeGroup and should not be called manually.

◆ name()

virtual QString CGAL::Three::Scene_item::name ( ) const
virtual

Getter for the item's name.

Returns
the current name of the item.

◆ newViewer()

virtual void CGAL::Three::Scene_item::newViewer ( CGAL::Three::Viewer_interface viewer)
pure virtual

newViewer adds Vaos for viewer.

Must be overriden;

Implemented in CGAL::Three::Scene_item_rendering_helper.

◆ parentGroup()

Scene_group_item* CGAL::Three::Scene_item::parentGroup ( ) const

The group containing the item.

Returns
the parent group if the item is in a group
0 if the item is not in a group.

◆ removeViewer()

virtual void CGAL::Three::Scene_item::removeViewer ( CGAL::Three::Viewer_interface viewer)
pure virtual

removeViewer removes the Vaos fo viewer.

Must be overriden;

Implemented in CGAL::Three::Scene_item_rendering_helper.

◆ renderingMode()

virtual RenderingMode CGAL::Three::Scene_item::renderingMode ( ) const
virtual

Getter for the item's rendering mode.

Returns
the current rendering mode of the item.
See also
RenderingMode

◆ renderingModeName()

virtual QString CGAL::Three::Scene_item::renderingModeName ( ) const
virtual

The renderingMode's name.

Returns
the current rendering mode of the item as a human readable string.

◆ resetMenu()

void CGAL::Three::Scene_item::resetMenu ( )

invalidates the context menu.

Call it when supportsRenderingMode() changes, for example.

◆ setAlpha

virtual void CGAL::Three::Scene_item::setAlpha ( int  alpha)
virtualslot

Sets the value of the aplha Slider for this item.

Must be overriden;

Parameters
alphamust be between 0 and 255

Reimplemented in CGAL::Three::Scene_group_item, and CGAL::Three::Scene_item_rendering_helper.

◆ setNbIsolatedvertices()

void CGAL::Three::Scene_item::setNbIsolatedvertices ( std::size_t  nb)

Sets the number of isolated vertices.

This number will be displayed in a warning box at loading.

See also
getNbIsolatedvertices

◆ setRenderingMode

virtual void CGAL::Three::Scene_item::setRenderingMode ( RenderingMode  m)
virtualslot

Sets the rendering mode of the item.

See also
RenderingMode

Reimplemented in CGAL::Three::Scene_group_item.

◆ setRgbColor

void CGAL::Three::Scene_item::setRgbColor ( int  r,
int  g,
int  b 
)
slot

Setter for the RGB color of the item.

Calls setColor(QColor).

See also
setColor(QColor c)

◆ supportsRenderingMode()

virtual bool CGAL::Three::Scene_item::supportsRenderingMode ( RenderingMode  m) const
pure virtual

Indicates if m is supported.

If it is, it will be displayed in the context menu of the item.

Implemented in CGAL::Three::Scene_group_item.

Examples:
Three/Example_plugin/Example_plugin.cpp.

◆ toolTip()

virtual QString CGAL::Three::Scene_item::toolTip ( ) const
pure virtual

Contains meta-data about the item.

Returns
a QString containing meta-data about the item.

Implemented in CGAL::Three::Scene_group_item.

Examples:
Three/Example_plugin/Example_plugin.cpp.

◆ visible()

virtual bool CGAL::Three::Scene_item::visible ( ) const
virtual

If the item is not visible, it is not drawn and its Bbox is ignored in the computation of the scene's.

Returns
the current visibility of the item.

Member Data Documentation

◆ are_buffers_filled

bool CGAL::Three::Scene_item::are_buffers_filled
mutableprotected

Decides if the draw function must call initializeBuffers() or not.

It is set to true in the end of initializeBuffers() and to false in invalidateOpenGLBuffers(). The need of this boolean comes from the need of a context from the OpenGLFunctions used in initializeBuffers().

See also
initializeBuffers()
invalidateOpenGLBuffers()

◆ cur_shading

RenderingMode CGAL::Three::Scene_item::cur_shading
protected

Contains the current RenderingMode.

This is used to determine if invalidateOpenGLBuffers should be called or not in certain cases.

See also
invalidateOpenGLBuffers()

◆ defaultColor

const QColor CGAL::Three::Scene_item::defaultColor
static

The default color of a scene_item.

This color is the one that will be displayed if none is specified after its creation.

◆ nb_isolated_vertices

std::size_t CGAL::Three::Scene_item::nb_isolated_vertices
protected

Holds the number of vertices that are not linked to the polyhedron from the OFF file.

◆ prev_shading

RenderingMode CGAL::Three::Scene_item::prev_shading
protected

Contains the previous RenderingMode.

This is used to determine if invalidateOpenGLBuffers should be called or not in certain cases.

See also
invalidateOpenGLBuffers()

◆ rendering_mode

RenderingMode CGAL::Three::Scene_item::rendering_mode
protected

The rendering mode of the item.

See also
RenderingMode