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