\( \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 4.12.2 - Three
CGAL::Three::Scene_item Class Referenceabstract

#include <CGAL/Three/Scene_item.h>

Inherits from

QObject.

Inherited by CGAL::Three::Scene_group_item.

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_FLAT,
  PROGRAM_OLD_FLAT, 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 setRbgColor (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.
 
virtual void itemAboutToBeDestroyed (Scene_item *)
 Emits an aboutToBeDestroyed() signal. 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...
 
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...
 

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. More...
 
void computeElements ()
 Collects all the data for the shaders. More...
 
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 edge affected by the light.

It uses a per fragment lighting model, and renders brighter the selected item.

PROGRAM_NO_SELECTION 

Used to render a polygon edge or points.

It renders in a uniform color and is not affected by light. 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 polyhedorn.

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_FLAT 

Used to render one or several spheres.

PROGRAM_OLD_FLAT 

Used to render flat shading without pre computing normals.

NB_OF_PROGRAMS 

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

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

◆ 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.

◆ 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.

◆ computeElements()

void CGAL::Three::Scene_item::computeElements ( )
protected

Collects all the data for the shaders.

Must be called in invalidateOpenGLBuffers().

See also
invalidateOpenGLBuffers().
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   |
* |_____________|_______|_____|
* compute stats(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.

◆ 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.

◆ 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.

◆ initializeBuffers()

void CGAL::Three::Scene_item::initializeBuffers ( )
protected

Fills the VBOs with data.

Must be called after each call to computeElements().

See also
compute_elements()
Examples:
Three/Example_plugin/Example_plugin.cpp.

◆ 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 independant 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.

◆ 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.

◆ 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.

◆ 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

◆ setRbgColor

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

Setter for the RGB color of the item.

Calls setColor(QColor).

See also
setColor(QColor c)

◆ 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.

◆ 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