CGAL 6.1 - CGAL Basic Viewer

Loading...
Searching...
No Matches
List of all members | Public Attributes
CGAL::Qt::Basic_viewer Class Reference
Reference Manual » Classes

`#include <CGAL/Qt/Basic_viewer.h>`

## Inherits from

CGAL::QGLViewer.

## Definition

The class `Basic_viewer` is a Qt widget based on `QGLViewer` that allows to visualize 3D elements: points, segments, triangles, rays and lines.

This class stores a reference to a `Graphics_scene`. Elements are added through the scene. This class requires `CGAL_Qt6`, and is only available if the macro `CGAL_USE_BASIC_VIEWER` is defined. Linking with the cmake target `CGAL::CGAL_Basic_viewer` will link with `CGAL_Qt6` and add the definition `CGAL_USE_BASIC_VIEWER`.

CGAL::QGLViewer is our internal fork of QGLViewer class which is A versatile 3D OpenGL viewer based on QOpenGLWidget.

Examples
  Basic_viewer/draw_several_windows.cpp, and Basic_viewer/draw_surface_mesh_small_faces.cpp.

## Public Attributes
std::function< bool(QKeyEvent *, CGAL::Qt::Basic_viewer *)> | on_key_pressed
| Function called when a key is pressed.

## Constructors
| Basic_viewer (QWidget *parent, const Graphics_scene &scene, const char *title="")
| Constructor given a pointer on a `QWidget` (can be a `nullptr`) and a `Graphics_scene`.

## Setters
void | size_vertices (float s)
| Set size of vertices.
void | size_edges (float s)
| Set size of edges.
void | size_rays (float s)
| Set size of rays.
void | size_lines (float s)
| Set size of lines.
void | draw_vertices (bool b)
| Enables or disables the drawing of vertices.
void | draw_edges (bool b)
| Enables or disables the drawing of edges.
void | draw_rays (bool b)
| Enables or disables the drawing of rays.
void | draw_lines (bool b)
| Enables or disables the drawing of lines.
void | draw_faces (bool b)
| enables or disables the drawing of faces.
void | draw_text (bool b)
| enables or disables the drawing of texts.
void | draw_mesh_triangles (bool b)
| Enables or disables the drawing of mesh triangles.
void | use_default_color (bool b)
| Enables or disables the use of only one color or the use of multiple colors.
void | use_default_color_normals (bool b)
| Enables or disables the use of a single color for all normals.
void | flat_shading (bool b)
| enables or disables the use of flat shading or the use of smooth shading.
void | reverse_normal (bool b)
| Enables or disables the reversal of normals.
void | default_color_normals (const CGAL::IO::Color &c)
| Sets the default color of the normals.
void | normal_height_factor (float h)
| Sets the height factor value of the normals.
void | toggle_draw_vertices ()
| Toggles the drawing of vertices.
void | toggle_draw_edges ()
| Toggles the drawing of edges.
void | toggle_draw_rays ()
| Toggles the drawing of rays.
void | toggle_draw_lines ()
| Toggles the drawing of lines.
void | toggle_draw_faces ()
| Toggles the drawing of faces.
void | toggle_use_default_color ()
| Toggles the use of mono color mode.
void | toggle_use_default_color_normal ()
| Toggles the use of the default color mode for normals.
void | toggle_flat_shading ()
| Toggles the use of flat shading.
void | toggle_draw_text ()
| Toggles the drawing of text.
void | reverse_all_normals ()
| Reverses all normals of vertices and faces.

## Getters
bool | draw_vertices () const
| Checks if vertices are drawn.
bool | draw_edges () const
| Checks if edges are drawn.
bool | draw_rays () const
| Checks if rays are drawn.
bool | draw_lines () const
| Checks if lines are drawn.
bool | draw_faces () const
| Checks if faces are drawn.
bool | draw_text () const
| Checks if text is drawn.
bool | use_default_color () const
| Checks if the default color mode is used.
bool | use_default_color_normal () const
| Checks if the default color mode for normals is used.
bool | reverse_normal () const
| Checks if normals are reversed.
bool | clipping_plane_enabled () const
| Checks if the clipping plane is enabled.
bool | is_two_dimensional () const
| Checks if m_no_2D_mode is false and the graphics scene is two-dimensional.
CGAL::Exact_predicates_inexact_constructions_kernel::Plane_3 | clipping_plane () const
| Gets the clipping plane when enabled.
const Graphics_scene & | graphics_scene () const
| Gets the graphics scene of the viewer.

## Draw
virtual void | draw ()
| draws the viewer without recomputing all internal buffers.
virtual void | redraw ()
| redraws the viewer, i.e., recompute all internal buffers and update the window.

## Constructor & Destructor Documentation

## ◆ Basic_viewer()

CGAL::Qt::Basic_viewer::Basic_viewer | ( | QWidget * | parent,
|  | const Graphics_scene & | scene,
|  | const char * | title = `""`
| ) |  |

Constructor given a pointer on a `QWidget` (can be a `nullptr`) and a `Graphics_scene`.

`title` will be the title of the window.

## Member Function Documentation

## ◆ clipping_plane()

CGAL::Exact_predicates_inexact_constructions_kernel::Plane_3 CGAL::Qt::Basic_viewer::clipping_plane | ( |  | ) | const

Gets the clipping plane when enabled.

Returns
  The clipping plane as a `CGAL::Exact_predicates_inexact_constructions_kernel::Plane_3` object.

## ◆ clipping_plane_enabled()

bool CGAL::Qt::Basic_viewer::clipping_plane_enabled | ( |  | ) | const

Checks if the clipping plane is enabled.

Returns
  `true` if the clipping plane is enabled, `false` otherwise.

## ◆ default_color_normals()

void CGAL::Qt::Basic_viewer::default_color_normals | ( | const CGAL::IO::Color & | c | ) |

Sets the default color of the normals.

Parameters

  c | The default color of the normals.

## ◆ draw_edges() [1/2]

bool CGAL::Qt::Basic_viewer::draw_edges | ( |  | ) | const

Checks if edges are drawn.

Returns
  `true` if edges are drawn, `false` otherwise.

## ◆ draw_edges() [2/2]

void CGAL::Qt::Basic_viewer::draw_edges | ( | bool | b | ) |

Enables or disables the drawing of edges.

Parameters

  b | Set to `true` to enable, `false` to disable.

## ◆ draw_faces() [1/2]

bool CGAL::Qt::Basic_viewer::draw_faces | ( |  | ) | const

Checks if faces are drawn.

Returns
  `true` if faces are drawn, `false` otherwise.

## ◆ draw_faces() [2/2]

void CGAL::Qt::Basic_viewer::draw_faces | ( | bool | b | ) |

enables or disables the drawing of faces.

Parameters

  b | Set to `true` to enable, `false` to disable.

## ◆ draw_lines() [1/2]

bool CGAL::Qt::Basic_viewer::draw_lines | ( |  | ) | const

Checks if lines are drawn.

Returns
  `true` if lines are drawn, `false` otherwise.

## ◆ draw_lines() [2/2]

void CGAL::Qt::Basic_viewer::draw_lines | ( | bool | b | ) |

Enables or disables the drawing of lines.

Parameters

  b | Set to `true` to enable, `false` to disable.

## ◆ draw_mesh_triangles()

void CGAL::Qt::Basic_viewer::draw_mesh_triangles | ( | bool | b | ) |

Enables or disables the drawing of mesh triangles.

Parameters

  b | Set to `true` to enable, `false` to disable.

## ◆ draw_rays() [1/2]

bool CGAL::Qt::Basic_viewer::draw_rays | ( |  | ) | const

Checks if rays are drawn.

Returns
  `true` if rays are drawn, `false` otherwise.

## ◆ draw_rays() [2/2]

void CGAL::Qt::Basic_viewer::draw_rays | ( | bool | b | ) |

Enables or disables the drawing of rays.

Parameters

  b | Set to `true` to enable, `false` to disable.

## ◆ draw_text() [1/2]

bool CGAL::Qt::Basic_viewer::draw_text | ( |  | ) | const

Checks if text is drawn.

Returns
  `true` if text is drawn, `false` otherwise.

## ◆ draw_text() [2/2]

void CGAL::Qt::Basic_viewer::draw_text | ( | bool | b | ) |

enables or disables the drawing of texts.

enables or disables the drawing of texts.

Parameters

  b | Set to `true` to enable, `false` to disable.

## ◆ draw_vertices() [1/2]

bool CGAL::Qt::Basic_viewer::draw_vertices | ( |  | ) | const

Checks if vertices are drawn.

Returns
  `true` if vertices are drawn, `false` otherwise.

## ◆ draw_vertices() [2/2]

void CGAL::Qt::Basic_viewer::draw_vertices | ( | bool | b | ) |

Enables or disables the drawing of vertices.

Parameters

  b | Set to `true` to enable, `false` to disable.

Examples
  Basic_viewer/draw_several_windows.cpp.

## ◆ flat_shading()

void CGAL::Qt::Basic_viewer::flat_shading | ( | bool | b | ) |

enables or disables the use of flat shading or the use of smooth shading.

Parameters

  b | Set to `true` for flat shading, `false` for smooth shading.

## ◆ graphics_scene()

const Graphics_scene & CGAL::Qt::Basic_viewer::graphics_scene | ( |  | ) | const

Gets the graphics scene of the viewer.

Returns
  A reference to the `Graphics_scene` object.

## ◆ is_two_dimensional()

bool CGAL::Qt::Basic_viewer::is_two_dimensional | ( |  | ) | const

Checks if m_no_2D_mode is false and the graphics scene is two-dimensional.

Returns
  `true` if m_no_2D_mode is false and the scene is 2D, `false` otherwise.

## ◆ normal_height_factor()

void CGAL::Qt::Basic_viewer::normal_height_factor | ( | float | h | ) |

Sets the height factor value of the normals.

Parameters

  h | The height factor value of the normals.

## ◆ reverse_normal() [1/2]

bool CGAL::Qt::Basic_viewer::reverse_normal | ( |  | ) | const

Checks if normals are reversed.

Returns
  `true` if normals are reversed, `false` otherwise.

## ◆ reverse_normal() [2/2]

void CGAL::Qt::Basic_viewer::reverse_normal | ( | bool | b | ) |

Enables or disables the reversal of normals.

Parameters

  b | Set to `true` to reverse normals, `false` to keep normals as is.

## ◆ size_edges()

void CGAL::Qt::Basic_viewer::size_edges | ( | float | s | ) |

Set size of edges.

Parameters

  s | The size of edges.

## ◆ size_lines()

void CGAL::Qt::Basic_viewer::size_lines | ( | float | s | ) |

Set size of lines.

Parameters

  s | The size of lines.

## ◆ size_rays()

void CGAL::Qt::Basic_viewer::size_rays | ( | float | s | ) |

Set size of rays.

Parameters

  s | The size of rays.

## ◆ size_vertices()

void CGAL::Qt::Basic_viewer::size_vertices | ( | float | s | ) |

Set size of vertices.

Parameters

  s | The size of vertices.

## ◆ use_default_color() [1/2]

bool CGAL::Qt::Basic_viewer::use_default_color | ( |  | ) | const

Checks if the default color mode is used.

Returns
  `true` if mono color mode is used, `false` otherwise.

## ◆ use_default_color() [2/2]

void CGAL::Qt::Basic_viewer::use_default_color | ( | bool | b | ) |

Enables or disables the use of only one color or the use of multiple colors.

Parameters

  b | Set to `true` to use only one color, `false` to use multiple colors.

## ◆ use_default_color_normal()

bool CGAL::Qt::Basic_viewer::use_default_color_normal | ( |  | ) | const

Checks if the default color mode for normals is used.

Returns
  `true` if default color mode for normals is used, `false` otherwise.

## ◆ use_default_color_normals()

void CGAL::Qt::Basic_viewer::use_default_color_normals | ( | bool | b | ) |

Enables or disables the use of a single color for all normals.

Parameters

  b | Set to `true` to enable, `false` to disable.

## Member Data Documentation

## ◆ on_key_pressed

std::function<bool(QKeyEvent *, CGAL::Qt::Basic_viewer *)> CGAL::Qt::Basic_viewer::on_key_pressed

Function called when a key is pressed.

Users can define their own function in order to add specific behavior.