Add special KeyPressEvent for rays. Format typedefs. Set cgal_test_suit = qEnvironmentVariableIsSet("CGAL_TEST_SUITE")

Adding these changes after learning from the viewers generated by GDamiand.
This commit is contained in:
Jasmeet Singh 2019-06-19 14:24:40 -07:00
parent 955a982a5f
commit 43015b0059
2 changed files with 38 additions and 41 deletions

View File

@ -858,7 +858,6 @@ protected:
// Add custom key description (see keyPressEvent).
setKeyDescription(::Qt::Key_E, "Toggles edges display");
setKeyDescription(::Qt::Key_R, "Toggles rays display");
setKeyDescription(::Qt::Key_F, "Toggles faces display");
setKeyDescription(::Qt::Key_G, "Switch between flat/Gouraud shading display");
setKeyDescription(::Qt::Key_M, "Toggles mono color");
@ -920,13 +919,7 @@ protected:
m_draw_edges=!m_draw_edges;
displayMessage(QString("Draw edges=%1.").arg(m_draw_edges?"true":"false"));
update();
}else if((e->key()==::Qt::Key_R) && (modifiers==::Qt::NoButton))
{
m_draw_rays=!m_draw_rays;
displayMessage(QString("Draw rays=%1.").arg(m_draw_rays?"true":"false"));
update();
}
else if ((e->key()==::Qt::Key_F) && (modifiers==::Qt::NoButton))
}else if ((e->key()==::Qt::Key_F) && (modifiers==::Qt::NoButton))
{
m_draw_faces=!m_draw_faces;
displayMessage(QString("Draw faces=%1.").arg(m_draw_faces?"true":"false"));

View File

@ -69,8 +69,7 @@ public:
/// @param av2 the voronoi diagram to view
/// @param title the title of the window
/// @param anofaces if true, do not draw faces (faces are not computed; this
/// can be
/// useful for very big object where this time could be long)
/// can be useful for very big object where this time could be long)
SimpleVoronoiDiagram2ViewerQt(QWidget *parent, const V2 &av2,
const char *title = "Basic Voronoi Viewer",
bool anofaces = false,
@ -78,7 +77,11 @@ public:
: // First draw: vertices; half-edges; faces; multi-color; no inverse
// normal
Base(parent, title, true, true, true, false, false), v2(av2),
m_nofaces(anofaces), m_fcolor(fcolor) {
m_nofaces(anofaces), m_fcolor(fcolor)
{
// Add custom key description (see keyPressEvent)
setKeyDescription(::Qt::Key_R, "Toggles rays display");
compute_elements();
}
@ -230,21 +233,22 @@ protected:
// { compute_vertex(it);}
}
virtual void keyPressEvent(QKeyEvent *e) {
// Test key pressed:
// const ::Qt::KeyboardModifiers modifiers = e->modifiers();
// if ((e->key()==Qt::Key_PageUp) && (modifiers==Qt::NoButton)) { ... }
// Call: * compute_elements() if the model changed, followed by
// * redraw() if some viewing parameters changed that implies some
// modifications of the buffers
// (eg. type of normal, color/mono)
// * update() just to update the drawing
virtual void keyPressEvent(QKeyEvent *e)
{
/// [Keypress]
const ::Qt::KeyboardModifiers modifiers = e->modifiers();
if((e->key()==::Qt::Key_R) && (modifiers==::Qt::NoButton))
{
m_draw_rays=!m_draw_rays;
displayMessage(QString("Draw rays=%1.").arg(m_draw_rays?"true":"false"));
update();
}
else {
// Call the base method to process others/classicals key
Base::keyPressEvent(e);
}
/// [Keypress]
}
protected:
const V2 &v2;
bool m_nofaces;
@ -257,7 +261,7 @@ void draw(const V2 &av2, const char *title, bool nofill,
#if defined(CGAL_TEST_SUITE)
bool cgal_test_suite = true;
#else
bool cgal_test_suite = false;
bool cgal_test_suite = qEnvironmentVariableIsSet("CGAL_TEST_SUITE");
#endif
if (!cgal_test_suite) {