Skip to content

Commit

Permalink
update draw
Browse files Browse the repository at this point in the history
  • Loading branch information
gdamiand committed Nov 20, 2023
1 parent 2214e3d commit 8dbd394
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ void draw(const CGAL_P2T2_TYPE& ap2t2,
typename CGAL_P2T2_TYPE::Periodic_triangle_iterator> gs_options;

add_to_graphics_scene(ap2t2, buffer, gs_options);
QApplication_and_basic_viewer app(buffer, title);
CGAL::Qt::QApplication_and_basic_viewer app(buffer, title);
if(app)
{
// Here we define the std::function to capture key pressed.
app.basic_viewer().on_key_pressed=
[&ap2t2, &gs_options] (QKeyEvent* e, CGAL::Qt::Basic_viewer* basic_viewer) -> bool
[&ap2t2, &buffer, &gs_options] (QKeyEvent* e, CGAL::Qt::Basic_viewer* basic_viewer) -> bool
{
const ::Qt::KeyboardModifiers modifiers = e->modifiers();
if ((e->key() == ::Qt::Key_D) && (modifiers == ::Qt::NoButton))
Expand All @@ -258,10 +258,8 @@ void draw(const CGAL_P2T2_TYPE& ap2t2,
(gs_options.current_display_type()==1?"Unique":
(gs_options.current_display_type()==2?"Stored cover":
"Unique cover"))));
basic_viewer->clear();
draw_function_for_P2T2::compute_elements(ap2t2,
basic_viewer->get_graphics_scene(),
gs_options);
buffer.clear();
draw_function_for_P2T2::compute_elements(ap2t2, buffer, gs_options);
basic_viewer->redraw();
}
else
Expand Down
18 changes: 7 additions & 11 deletions Voronoi_diagram_2/include/CGAL/draw_voronoi_diagram_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,19 +384,19 @@ void draw(const CGAL_VORONOI_TYPE& av2,

add_to_graphics_scene(av2, buffer, gs_options);

QApplication_and_basic_viewer app(buffer, title);
CGAL::Qt::QApplication_and_basic_viewer app(buffer, title);
if(app)
{
// Here we define the std::function to capture key pressed.
app.basic_viewer().on_key_pressed=
[&av2, &gs_options] (QKeyEvent* e, CGAL::Qt::Basic_viewer* basic_viewer) -> bool
[&av2, &buffer, &gs_options] (QKeyEvent* e, CGAL::Qt::Basic_viewer* basic_viewer) -> bool
{
const ::Qt::KeyboardModifiers modifiers = e->modifiers();
if ((e->key() == ::Qt::Key_R) && (modifiers == ::Qt::NoButton))
{
basic_viewer->toggle_draw_rays();
basic_viewer->displayMessage
(QString("Draw rays=%1.").arg(basic_viewer->get_draw_rays()?"true":"false"));
(QString("Draw rays=%1.").arg(basic_viewer->draw_rays()?"true":"false"));

basic_viewer->redraw();
}
Expand All @@ -410,10 +410,8 @@ void draw(const CGAL_VORONOI_TYPE& av2,
(QString("Voronoi vertices=%1.").
arg(gs_options.are_voronoi_vertices_enabled()?"true":"false"));

basic_viewer->clear();
draw_function_for_v2::compute_elements(av2,
basic_viewer->get_graphics_scene(),
gs_options);
buffer.clear();
draw_function_for_v2::compute_elements(av2, buffer, gs_options);
basic_viewer->redraw();
}
else if ((e->key() == ::Qt::Key_D) && (modifiers == ::Qt::NoButton))
Expand All @@ -425,10 +423,8 @@ void draw(const CGAL_VORONOI_TYPE& av2,
basic_viewer->displayMessage(QString("Dual vertices=%1.").
arg(gs_options.are_dual_vertices_enabled()?"true":"false"));

basic_viewer->clear();
draw_function_for_v2::compute_elements(av2,
basic_viewer->get_graphics_scene(),
gs_options);
buffer.clear();
draw_function_for_v2::compute_elements(av2, buffer, gs_options);
basic_viewer->redraw();
}
else
Expand Down

0 comments on commit 8dbd394

Please sign in to comment.