diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/draw_periodic_2_triangulation_2.h b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/draw_periodic_2_triangulation_2.h index c0d06a67e33..fafd9a4f5f1 100644 --- a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/draw_periodic_2_triangulation_2.h +++ b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/draw_periodic_2_triangulation_2.h @@ -20,12 +20,7 @@ template struct Graphics_scene_options_periodic_2_triangulation_2: public CGAL::Graphics_scene_options -{ -public: - typedef VertexDescriptor vertex_descriptor; - typedef EdgeDescriptor edge_descriptor; - typedef FaceDescriptor face_descriptor; -}; +{}; /*! \ingroup PkgDrawPeriodic2Triangulation2 diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/GraphicsSceneOptionsPeriodic2Triangulation2.h b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/GraphicsSceneOptionsPeriodic2Triangulation2.h index 565d8e1b913..54b84e2d75a 100644 --- a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/GraphicsSceneOptionsPeriodic2Triangulation2.h +++ b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/GraphicsSceneOptionsPeriodic2Triangulation2.h @@ -13,7 +13,7 @@ The concept `GraphicsSceneOptionsPeriodic2Triangulation2` defines data and metho class GraphicsSceneOptionsPeriodic2Triangulation2 { public: - /// returns `true` if the domain of the Periodic_2_triangulation_2 must be ignored, `false` otherwise. + /// returns `true` if the domain of the Periodic_2_triangulation_2 must be drawn, `false` otherwise. /// Returns `false` by default. bool draw_domain() const; diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/PackageDescription.txt b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/PackageDescription.txt index 00c17ceec12..3c527f6fdd2 100644 --- a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/PackageDescription.txt +++ b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/PackageDescription.txt @@ -110,7 +110,9 @@ of the concept `Periodic_2Offset_2`. - `CGAL::Periodic_2_triangulation_2::Locate_type` \cgalCRPSection{Draw 2D Periodic Triangulation} - - \link PkgDrawPeriodic2Triangulation2 CGAL::draw() \endlink +- \link PkgDrawPeriodic2Triangulation2 CGAL::draw() \endlink +- `GraphicsSceneOptionsPeriodic2Triangulation2` +- `CGAL::Graphics_scene_options_periodic_2_triangulation_2` */ diff --git a/Voronoi_diagram_2/doc/Voronoi_diagram_2/CGAL/draw_voronoi_diagram_2.h b/Voronoi_diagram_2/doc/Voronoi_diagram_2/CGAL/draw_voronoi_diagram_2.h index 530bcaf5dda..8298b7b1a52 100644 --- a/Voronoi_diagram_2/doc/Voronoi_diagram_2/CGAL/draw_voronoi_diagram_2.h +++ b/Voronoi_diagram_2/doc/Voronoi_diagram_2/CGAL/draw_voronoi_diagram_2.h @@ -3,16 +3,94 @@ namespace CGAL { /*! \ingroup PkgDrawVoronoiDiagram2 -opens a new window and draws `av2`, the `Voronoi_diagram_2` constructed from a Delaunay Graph which is a model of `DelaunayGraph_2` concept. -The class `Voronoi_diagram_2` provides an adaptor to view a triangulated Delaunay graph as their dual subdivision, the -Voronoi diagram. A call to this function is blocking, that is the program continues as soon as the user closes the window. -This function 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`. -\tparam V2 a model of the `AdaptationTraits_2` concept. -\param av2 the voronoi diagram to draw. +The class `Graphics_scene_options_voronoi_diagram_2` defines data and methods used to tune the way that the cells of a `Voronoi_diagram_2` are considered for drawing or to be added into a graphics scene. +This class is a model of `GraphicsSceneOptionsVoronoiDiagram2`. + +\tparam DS a `CGAL::Voronoi_diagram_2`. +\tparam VertexDescriptor a descriptor of vertices of `DS`. +\tparam EdgeDescriptor a descriptor of edges of `DS`. +\tparam FaceDescriptor a descriptor of faces of `DS`. + +\cgalModels{GraphicsSceneOptionsVoronoiDiagram2} */ -template -void draw(const V2& av2); + +template +struct Graphics_scene_options_voronoi_diagram_2: public CGAL::Graphics_scene_options +{}; + +/*! +\ingroup PkgDrawVoronoiDiagram2 + +opens a new window and draws a 2D voronoi diagram. Parameters of the drawing are taken from the optional graphics scene options parameter. + +A call to this function blocks the execution of the program until the drawing window is closed. This function 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`. + +\tparam VD2 which must be an instanciation of a `CGAL::Voronoi_diagram_2<...>`. +\tparam GSOptions a model of `GraphicsSceneOptionsVoronoiDiagram2` concept. + +\param vd2 the voronoi diagram to draw. +\param gso the graphics scene options parameter. + +\cgalAdvancedBegin +The real declaration of this function template is: + + + template + + void CGAL::draw(const CGAL::Voronoi_diagram_2& vd2, const GSOptions& gso); + +\cgalAdvancedEnd +*/ +template +void draw(const VD2& vd2, const GSOptions& gso); + +/*! +\ingroup PkgDrawVoronoiDiagram2 + +A shortcut to `CGAL::draw(vd2, Graphics_scene_options_voronoi_diagram_2{})`. +*/ +template +void draw(const VD2& vd2); + +/*! +\ingroup PkgDrawVoronoiDiagram2 + +adds the vertices, edges and faces of `vd2` into the given graphic scene `gs`. Parameters of the cells are taken from the optional graphics scene options parameter `gso`. Note that `gs` is not cleared before being filled (to enable to draw several data structures in the same basic viewer). + +\tparam VD2 which must be an instanciation of a `CGAL::Voronoi_diagram_2<...>`. +\tparam GSOptions a model of `GraphicsSceneOptionsVoronoiDiagram2` concept. + +\param vd2 the voronoi diagram to draw. +\param gs the graphic scene to fill. +\param gso the graphics scene options parameter. + +\cgalAdvancedBegin +The real declaration of this function template is: + + + template + + void CGAL::add_to_graphics_scene(const CGAL::Voronoi_diagram_2& vd2, CGAL::Graphics_scene& gs, const GSOptions& gso); + +\cgalAdvancedEnd +*/ +template +void add_to_graphics_scene(const VD2& vd2, + CGAL::Graphics_scene& gs, + const GSOptions& gso); + +/*! +\ingroup PkgDrawVoronoiDiagram2 + +A shortcut to `CGAL::add_to_graphics_scene(vd2, gs, Graphics_scene_options_voronoi_diagram_2{})`. +*/ +template +void add_to_graphics_scene(const VD2& vd2, + CGAL::Graphics_scene& gs); } /* namespace CGAL */ diff --git a/Voronoi_diagram_2/doc/Voronoi_diagram_2/Concepts/GraphicsSceneOptionsVoronoiDiagram2.h b/Voronoi_diagram_2/doc/Voronoi_diagram_2/Concepts/GraphicsSceneOptionsVoronoiDiagram2.h new file mode 100644 index 00000000000..42c8baee972 --- /dev/null +++ b/Voronoi_diagram_2/doc/Voronoi_diagram_2/Concepts/GraphicsSceneOptionsVoronoiDiagram2.h @@ -0,0 +1,46 @@ +/*! +\ingroup PkgVoronoiDiagram2Concepts + +The concept `GraphicsSceneOptionsVoronoiDiagram2` defines data and methods used to tune the way that the cells of a `Voronoi_diagram_2` are considered for drawing or to be added into a graphics scene. + +\cgalRefines{GraphicsSceneOptions} + +\cgalHasModelsBegin +\cgalHasModelsBare{\link CGAL::Graphics_scene_options_voronoi_diagram_2 `CGAL::Graphics_scene_options_voronoi_diagram_2`\endlink} +\cgalHasModelsEnd + +*/ +class GraphicsSceneOptionsVoronoiDiagram2 +{ +public: + /// returns the color of the dual vertices. + const CGAL::IO::Color& dual_vertex_color() const; + /// sets the color of dual vertices to `c`. + void dual_vertex_color(const CGAL::IO::Color& c); + + /// returns the color of rays. + const CGAL::IO::Color& ray_color() const; + /// sets the color of rays to `c`. + void ray_color(const CGAL::IO::Color& c); + + /// returns the color of the bisectors. + const CGAL::IO::Color& bisector_color() const; + /// sets the color of bisectors to `c`. + void bisector_color(const CGAL::IO::Color& c); + + /// returns `true` if the voronoi vertices must be drawn, `false` otherwise. + /// Returns `false` by default. + bool draw_voronoi_vertices() const; + /// sets the draw of voronoi vertices to `b`. + void draw_voronoi_vertices(bool b); + /// toggles the draw voronoi vertices value. + void toggle_draw_voronoi_vertices(); + + /// returns `true` if the dual vertices must be drawn, `false` otherwise. + /// Returns `false` by default. + bool draw_dual_vertices() const; + /// sets the draw of dual vertices to `b`. + void draw_dual_vertices(); + /// toggles the draw dual vertices value. + void toggle_draw_dual_vertices(); +}; diff --git a/Voronoi_diagram_2/doc/Voronoi_diagram_2/PackageDescription.txt b/Voronoi_diagram_2/doc/Voronoi_diagram_2/PackageDescription.txt index b109a0213d9..58edde2ec5a 100644 --- a/Voronoi_diagram_2/doc/Voronoi_diagram_2/PackageDescription.txt +++ b/Voronoi_diagram_2/doc/Voronoi_diagram_2/PackageDescription.txt @@ -90,6 +90,7 @@ performing this adaptation. \cgalCRPSection{Draw Voronoi Diagram} - \link PkgDrawVoronoiDiagram2 CGAL::draw() \endlink - +- `GraphicsSceneOptionsVoronoiDiagram2` +- `CGAL::Graphics_scene_options_voronoi_2` */ diff --git a/Voronoi_diagram_2/include/CGAL/draw_voronoi_diagram_2.h b/Voronoi_diagram_2/include/CGAL/draw_voronoi_diagram_2.h index afe34cd5855..534d5aa47c3 100644 --- a/Voronoi_diagram_2/include/CGAL/draw_voronoi_diagram_2.h +++ b/Voronoi_diagram_2/include/CGAL/draw_voronoi_diagram_2.h @@ -57,14 +57,12 @@ struct Graphics_scene_options_voronoi_2 : void bisector_color(const CGAL::IO::Color& c) { m_bisector_color=c; } - void disable_voronoi_vertices() { m_draw_voronoi_vertices=false; } - void enable_voronoi_vertices() { m_draw_voronoi_vertices=true; } - bool are_voronoi_vertices_enabled() const { return m_draw_voronoi_vertices; } + void draw_voronoi_vertices(bool b) { m_draw_voronoi_vertices=b; } + bool draw_voronoi_vertices() const { return m_draw_voronoi_vertices; } void toggle_draw_voronoi_vertices() { m_draw_voronoi_vertices=!m_draw_voronoi_vertices; } - void disable_dual_vertices() { m_draw_dual_vertices=false; } - void enable_dual_vertices() { m_draw_dual_vertices=true; } - bool are_dual_vertices_enabled() const { return m_draw_dual_vertices; } + void draw_dual_vertices(bool b) { m_draw_dual_vertices=b; } + bool draw_dual_vertices() const { return m_draw_dual_vertices; } void toggle_draw_dual_vertices() { m_draw_dual_vertices=!m_draw_dual_vertices; } protected: @@ -310,7 +308,7 @@ void compute_elements(const V2& v2, if(gs_options.are_vertices_enabled()) { // Draw the voronoi vertices - if (gs_options.are_voronoi_vertices_enabled()) + if (gs_options.draw_voronoi_vertices()) { for (typename V2::Vertex_iterator it=v2.vertices_begin(); it!=v2.vertices_end(); ++it) @@ -318,7 +316,7 @@ void compute_elements(const V2& v2, } // Draw the dual vertices - if (gs_options.are_dual_vertices_enabled()) + if (gs_options.draw_dual_vertices()) { for (typename V2::Delaunay_graph::Finite_vertices_iterator it=v2.dual().finite_vertices_begin(); @@ -402,13 +400,10 @@ void draw(const CGAL_VORONOI_TYPE& av2, } else if ((e->key() == ::Qt::Key_V) && (modifiers == ::Qt::ShiftModifier)) { - if(gs_options.are_voronoi_vertices_enabled()) - { gs_options.disable_voronoi_vertices(); } - else { gs_options.enable_voronoi_vertices(); } - + gs_options.toggle_draw_voronoi_vertices(); basic_viewer->displayMessage (QString("Voronoi vertices=%1."). - arg(gs_options.are_voronoi_vertices_enabled()?"true":"false")); + arg(gs_options.draw_voronoi_vertices()?"true":"false")); buffer.clear(); draw_function_for_v2::compute_elements(av2, buffer, gs_options); @@ -416,12 +411,9 @@ void draw(const CGAL_VORONOI_TYPE& av2, } else if ((e->key() == ::Qt::Key_D) && (modifiers == ::Qt::NoButton)) { - if(gs_options.are_dual_vertices_enabled()) - { gs_options.disable_dual_vertices(); } - else { gs_options.enable_dual_vertices(); } - + gs_options.toggle_draw_dual_vertices(); basic_viewer->displayMessage(QString("Dual vertices=%1."). - arg(gs_options.are_dual_vertices_enabled()?"true":"false")); + arg(gs_options.draw_dual_vertices()?"true":"false")); buffer.clear(); draw_function_for_v2::compute_elements(av2, buffer, gs_options);