mirror of https://github.com/CGAL/cgal
doc: draw p2t2 and voronoi2
This commit is contained in:
parent
769f615366
commit
489317b6f2
|
|
@ -20,12 +20,7 @@ template <typename DS,
|
|||
typename EdgeDescriptor,
|
||||
typename FaceDescriptor>
|
||||
struct Graphics_scene_options_periodic_2_triangulation_2: public CGAL::Graphics_scene_options<DS, VertexDescriptor, EdgeDescriptor, FaceDescriptor>
|
||||
{
|
||||
public:
|
||||
typedef VertexDescriptor vertex_descriptor;
|
||||
typedef EdgeDescriptor edge_descriptor;
|
||||
typedef FaceDescriptor face_descriptor;
|
||||
};
|
||||
{};
|
||||
|
||||
/*!
|
||||
\ingroup PkgDrawPeriodic2Triangulation2
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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<P2T2>() \endlink
|
||||
- \link PkgDrawPeriodic2Triangulation2 CGAL::draw<P2T2>() \endlink
|
||||
- `GraphicsSceneOptionsPeriodic2Triangulation2`
|
||||
- `CGAL::Graphics_scene_options_periodic_2_triangulation_2`
|
||||
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -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<class V2>
|
||||
void draw(const V2& av2);
|
||||
|
||||
template <typename DS,
|
||||
typename VertexDescriptor,
|
||||
typename EdgeDescriptor,
|
||||
typename FaceDescriptor>
|
||||
struct Graphics_scene_options_voronoi_diagram_2: public CGAL::Graphics_scene_options<DS, VertexDescriptor, EdgeDescriptor, FaceDescriptor>
|
||||
{};
|
||||
|
||||
/*!
|
||||
\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:
|
||||
|
||||
<code>
|
||||
template<class DG, class AT, class AP, class GSOptions>
|
||||
|
||||
void CGAL::draw(const CGAL::Voronoi_diagram_2<DG, AT, AP>& vd2, const GSOptions& gso);
|
||||
</code>
|
||||
\cgalAdvancedEnd
|
||||
*/
|
||||
template<class VD2, class GSOptions>
|
||||
void draw(const VD2& vd2, const GSOptions& gso);
|
||||
|
||||
/*!
|
||||
\ingroup PkgDrawVoronoiDiagram2
|
||||
|
||||
A shortcut to `CGAL::draw(vd2, Graphics_scene_options_voronoi_diagram_2{})`.
|
||||
*/
|
||||
template<class VD2>
|
||||
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:
|
||||
|
||||
<code>
|
||||
template<class DG, class AT, class AP, class GSOptions>
|
||||
|
||||
void CGAL::add_to_graphics_scene(const CGAL::Voronoi_diagram_2<DG, AT, AP>& vd2, CGAL::Graphics_scene& gs, const GSOptions& gso);
|
||||
</code>
|
||||
\cgalAdvancedEnd
|
||||
*/
|
||||
template<class VD2, class GSOptions>
|
||||
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<class VD2>
|
||||
void add_to_graphics_scene(const VD2& vd2,
|
||||
CGAL::Graphics_scene& gs);
|
||||
|
||||
} /* namespace CGAL */
|
||||
|
|
|
|||
|
|
@ -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<DS, VertexDescriptor, EdgeDescriptor, FaceDescriptor>`\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();
|
||||
};
|
||||
|
|
@ -90,6 +90,7 @@ performing this adaptation.
|
|||
\cgalCRPSection{Draw Voronoi Diagram}
|
||||
|
||||
- \link PkgDrawVoronoiDiagram2 CGAL::draw<VD>() \endlink
|
||||
|
||||
- `GraphicsSceneOptionsVoronoiDiagram2`
|
||||
- `CGAL::Graphics_scene_options_voronoi_2`
|
||||
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue