mirror of https://github.com/CGAL/cgal
Move class in CGAL namespace
This commit is contained in:
parent
49de2dee13
commit
f1e9fc7ed8
|
|
@ -37,9 +37,8 @@
|
||||||
#include <CGAL/Qt/CreateOpenGLContext.h>
|
#include <CGAL/Qt/CreateOpenGLContext.h>
|
||||||
#include <CGAL/Random.h>
|
#include <CGAL/Random.h>
|
||||||
|
|
||||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Local_kernel;
|
namespace CGAL
|
||||||
typedef Local_kernel::Point_3 Local_point;
|
{
|
||||||
typedef Local_kernel::Vector_3 Local_vector;
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
const char vertex_source_color[] =
|
const char vertex_source_color[] =
|
||||||
|
|
@ -132,7 +131,11 @@ inline CGAL::Color get_random_color(CGAL::Random& random)
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
class Basic_viewer_qt : public QGLViewer, public QOpenGLFunctions_2_1
|
class Basic_viewer_qt : public QGLViewer, public QOpenGLFunctions_2_1
|
||||||
{
|
{
|
||||||
|
typedef CGAL::Exact_predicates_inexact_constructions_kernel Local_kernel;
|
||||||
|
typedef Local_kernel::Point_3 Local_point;
|
||||||
|
typedef Local_kernel::Vector_3 Local_vector;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor/Destructor
|
// Constructor/Destructor
|
||||||
Basic_viewer_qt(const char* title="") :
|
Basic_viewer_qt(const char* title="") :
|
||||||
|
|
@ -145,9 +148,9 @@ public:
|
||||||
m_inverse_normal(false),
|
m_inverse_normal(false),
|
||||||
m_size_points(7.),
|
m_size_points(7.),
|
||||||
m_size_edges(3.1),
|
m_size_edges(3.1),
|
||||||
m_vertices_mono_color(51, 51, 178),
|
m_vertices_mono_color(200, 60, 60),
|
||||||
m_edges_mono_color(51, 51, 148),
|
m_edges_mono_color(0, 0, 0),
|
||||||
m_faces_mono_color(180, 125, 200),
|
m_faces_mono_color(60, 60, 200),
|
||||||
m_ambient_color(0.6f, 0.5f, 0.5f, 0.5f),
|
m_ambient_color(0.6f, 0.5f, 0.5f, 0.5f),
|
||||||
m_are_buffers_initialized(false),
|
m_are_buffers_initialized(false),
|
||||||
m_buffer_for_mono_points(&arrays[POS_MONO_POINTS],
|
m_buffer_for_mono_points(&arrays[POS_MONO_POINTS],
|
||||||
|
|
@ -218,7 +221,7 @@ public:
|
||||||
|
|
||||||
const CGAL::Bbox_3& bounding_box() const
|
const CGAL::Bbox_3& bounding_box() const
|
||||||
{ return m_bounding_box; }
|
{ return m_bounding_box; }
|
||||||
|
|
||||||
template<typename KPoint>
|
template<typename KPoint>
|
||||||
void add_point(const KPoint& p)
|
void add_point(const KPoint& p)
|
||||||
{ m_buffer_for_mono_points.add_point(p); }
|
{ m_buffer_for_mono_points.add_point(p); }
|
||||||
|
|
@ -707,21 +710,21 @@ protected:
|
||||||
initializeOpenGLFunctions();
|
initializeOpenGLFunctions();
|
||||||
|
|
||||||
// Define 'Control+Q' as the new exit shortcut (default was 'Escape')
|
// Define 'Control+Q' as the new exit shortcut (default was 'Escape')
|
||||||
setShortcut(EXIT_VIEWER, Qt::CTRL+Qt::Key_Q);
|
setShortcut(EXIT_VIEWER, ::Qt::CTRL+::Qt::Key_Q);
|
||||||
|
|
||||||
// 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_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 for all faces");
|
setKeyDescription(::Qt::Key_M, "Toggles mono color for all faces");
|
||||||
setKeyDescription(Qt::Key_N, "Inverse direction of normals");
|
setKeyDescription(::Qt::Key_N, "Inverse direction of normals");
|
||||||
setKeyDescription(Qt::Key_V, "Toggles vertices display");
|
setKeyDescription(::Qt::Key_V, "Toggles vertices display");
|
||||||
setKeyDescription(Qt::Key_Plus, "Increase size of edges");
|
setKeyDescription(::Qt::Key_Plus, "Increase size of edges");
|
||||||
setKeyDescription(Qt::Key_Minus, "Decrease size of edges");
|
setKeyDescription(::Qt::Key_Minus, "Decrease size of edges");
|
||||||
setKeyDescription(Qt::Key_Plus+Qt::ControlModifier, "Increase size of vertices");
|
setKeyDescription(::Qt::Key_Plus+::Qt::ControlModifier, "Increase size of vertices");
|
||||||
setKeyDescription(Qt::Key_Minus+Qt::ControlModifier, "Decrease size of vertices");
|
setKeyDescription(::Qt::Key_Minus+::Qt::ControlModifier, "Decrease size of vertices");
|
||||||
setKeyDescription(Qt::Key_PageDown, "Increase light (all colors, use shift/alt/ctrl for one rgb component)");
|
setKeyDescription(::Qt::Key_PageDown, "Increase light (all colors, use shift/alt/ctrl for one rgb component)");
|
||||||
setKeyDescription(Qt::Key_PageUp, "Decrease light (all colors, use shift/alt/ctrl for one rgb component)");
|
setKeyDescription(::Qt::Key_PageUp, "Decrease light (all colors, use shift/alt/ctrl for one rgb component)");
|
||||||
|
|
||||||
// Light default parameters
|
// Light default parameters
|
||||||
::glLineWidth(m_size_edges);
|
::glLineWidth(m_size_edges);
|
||||||
|
|
@ -770,21 +773,21 @@ protected:
|
||||||
|
|
||||||
virtual void keyPressEvent(QKeyEvent *e)
|
virtual void keyPressEvent(QKeyEvent *e)
|
||||||
{
|
{
|
||||||
const Qt::KeyboardModifiers modifiers = e->modifiers();
|
const ::Qt::KeyboardModifiers modifiers = e->modifiers();
|
||||||
|
|
||||||
if ((e->key()==Qt::Key_E) && (modifiers==Qt::NoButton))
|
if ((e->key()==::Qt::Key_E) && (modifiers==::Qt::NoButton))
|
||||||
{
|
{
|
||||||
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_F) && (modifiers==Qt::NoButton))
|
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"));
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
else if ((e->key()==Qt::Key_G) && (modifiers==Qt::NoButton))
|
else if ((e->key()==::Qt::Key_G) && (modifiers==::Qt::NoButton))
|
||||||
{
|
{
|
||||||
m_flatShading=!m_flatShading;
|
m_flatShading=!m_flatShading;
|
||||||
if (m_flatShading)
|
if (m_flatShading)
|
||||||
|
|
@ -794,13 +797,13 @@ protected:
|
||||||
initialize_buffers();
|
initialize_buffers();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
else if ((e->key()==Qt::Key_M) && (modifiers==Qt::NoButton))
|
else if ((e->key()==::Qt::Key_M) && (modifiers==::Qt::NoButton))
|
||||||
{
|
{
|
||||||
m_use_mono_color=!m_use_mono_color;
|
m_use_mono_color=!m_use_mono_color;
|
||||||
displayMessage(QString("Mono color=%1.").arg(m_use_mono_color?"true":"false"));
|
displayMessage(QString("Mono color=%1.").arg(m_use_mono_color?"true":"false"));
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
else if ((e->key()==Qt::Key_N) && (modifiers==Qt::NoButton))
|
else if ((e->key()==::Qt::Key_N) && (modifiers==::Qt::NoButton))
|
||||||
{
|
{
|
||||||
m_inverse_normal=!m_inverse_normal;
|
m_inverse_normal=!m_inverse_normal;
|
||||||
displayMessage(QString("Inverse normal=%1.").arg(m_inverse_normal?"true":"false"));
|
displayMessage(QString("Inverse normal=%1.").arg(m_inverse_normal?"true":"false"));
|
||||||
|
|
@ -808,37 +811,37 @@ protected:
|
||||||
initialize_buffers();
|
initialize_buffers();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
else if ((e->key()==Qt::Key_V) && (modifiers==Qt::NoButton))
|
else if ((e->key()==::Qt::Key_V) && (modifiers==::Qt::NoButton))
|
||||||
{
|
{
|
||||||
m_draw_vertices=!m_draw_vertices;
|
m_draw_vertices=!m_draw_vertices;
|
||||||
displayMessage(QString("Draw vertices=%1.").arg(m_draw_vertices?"true":"false"));
|
displayMessage(QString("Draw vertices=%1.").arg(m_draw_vertices?"true":"false"));
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
else if ((e->key()==Qt::Key_Plus) && (!modifiers.testFlag(Qt::ControlModifier))) // No ctrl
|
else if ((e->key()==::Qt::Key_Plus) && (!modifiers.testFlag(::Qt::ControlModifier))) // No ctrl
|
||||||
{
|
{
|
||||||
m_size_edges+=.5;
|
m_size_edges+=.5;
|
||||||
displayMessage(QString("Size of edges=%1.").arg(m_size_edges));
|
displayMessage(QString("Size of edges=%1.").arg(m_size_edges));
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
else if ((e->key()==Qt::Key_Minus) && (!modifiers.testFlag(Qt::ControlModifier))) // No ctrl
|
else if ((e->key()==::Qt::Key_Minus) && (!modifiers.testFlag(::Qt::ControlModifier))) // No ctrl
|
||||||
{
|
{
|
||||||
if (m_size_edges>.5) m_size_edges-=.5;
|
if (m_size_edges>.5) m_size_edges-=.5;
|
||||||
displayMessage(QString("Size of edges=%1.").arg(m_size_edges));
|
displayMessage(QString("Size of edges=%1.").arg(m_size_edges));
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
else if ((e->key()==Qt::Key_Plus) && (modifiers.testFlag(Qt::ControlModifier)))
|
else if ((e->key()==::Qt::Key_Plus) && (modifiers.testFlag(::Qt::ControlModifier)))
|
||||||
{
|
{
|
||||||
m_size_points+=.5;
|
m_size_points+=.5;
|
||||||
displayMessage(QString("Size of points=%1.").arg(m_size_points));
|
displayMessage(QString("Size of points=%1.").arg(m_size_points));
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
else if ((e->key()==Qt::Key_Minus) && (modifiers.testFlag(Qt::ControlModifier)))
|
else if ((e->key()==::Qt::Key_Minus) && (modifiers.testFlag(::Qt::ControlModifier)))
|
||||||
{
|
{
|
||||||
if (m_size_points>.5) m_size_points-=.5;
|
if (m_size_points>.5) m_size_points-=.5;
|
||||||
displayMessage(QString("Size of points=%1.").arg(m_size_points));
|
displayMessage(QString("Size of points=%1.").arg(m_size_points));
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
else if ((e->key()==Qt::Key_PageUp) && (modifiers==Qt::NoButton))
|
else if ((e->key()==::Qt::Key_PageUp) && (modifiers==::Qt::NoButton))
|
||||||
{
|
{
|
||||||
m_ambient_color.setX(m_ambient_color.x()+.1);
|
m_ambient_color.setX(m_ambient_color.x()+.1);
|
||||||
if (m_ambient_color.x()>1.) m_ambient_color.setX(1.);
|
if (m_ambient_color.x()>1.) m_ambient_color.setX(1.);
|
||||||
|
|
@ -850,7 +853,7 @@ protected:
|
||||||
arg(m_ambient_color.x()).arg(m_ambient_color.y()).arg(m_ambient_color.z()));
|
arg(m_ambient_color.x()).arg(m_ambient_color.y()).arg(m_ambient_color.z()));
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
else if ((e->key()==Qt::Key_PageDown) && (modifiers==Qt::NoButton))
|
else if ((e->key()==::Qt::Key_PageDown) && (modifiers==::Qt::NoButton))
|
||||||
{
|
{
|
||||||
m_ambient_color.setX(m_ambient_color.x()-.1);
|
m_ambient_color.setX(m_ambient_color.x()-.1);
|
||||||
if (m_ambient_color.x()<0.) m_ambient_color.setX(0.);
|
if (m_ambient_color.x()<0.) m_ambient_color.setX(0.);
|
||||||
|
|
@ -862,7 +865,7 @@ protected:
|
||||||
arg(m_ambient_color.x()).arg(m_ambient_color.y()).arg(m_ambient_color.z()));
|
arg(m_ambient_color.x()).arg(m_ambient_color.y()).arg(m_ambient_color.z()));
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
else if ((e->key()==Qt::Key_PageUp) && (modifiers==Qt::ShiftModifier))
|
else if ((e->key()==::Qt::Key_PageUp) && (modifiers==::Qt::ShiftModifier))
|
||||||
{
|
{
|
||||||
m_ambient_color.setX(m_ambient_color.x()+.1);
|
m_ambient_color.setX(m_ambient_color.x()+.1);
|
||||||
if (m_ambient_color.x()>1.) m_ambient_color.setX(1.);
|
if (m_ambient_color.x()>1.) m_ambient_color.setX(1.);
|
||||||
|
|
@ -870,7 +873,7 @@ protected:
|
||||||
arg(m_ambient_color.x()).arg(m_ambient_color.y()).arg(m_ambient_color.z()));
|
arg(m_ambient_color.x()).arg(m_ambient_color.y()).arg(m_ambient_color.z()));
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
else if ((e->key()==Qt::Key_PageUp) && (modifiers==Qt::AltModifier))
|
else if ((e->key()==::Qt::Key_PageUp) && (modifiers==::Qt::AltModifier))
|
||||||
{
|
{
|
||||||
m_ambient_color.setY(m_ambient_color.y()+.1);
|
m_ambient_color.setY(m_ambient_color.y()+.1);
|
||||||
if (m_ambient_color.y()>1.) m_ambient_color.setY(1.);
|
if (m_ambient_color.y()>1.) m_ambient_color.setY(1.);
|
||||||
|
|
@ -878,7 +881,7 @@ protected:
|
||||||
arg(m_ambient_color.x()).arg(m_ambient_color.y()).arg(m_ambient_color.z()));
|
arg(m_ambient_color.x()).arg(m_ambient_color.y()).arg(m_ambient_color.z()));
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
else if ((e->key()==Qt::Key_PageUp) && (modifiers==Qt::ControlModifier))
|
else if ((e->key()==::Qt::Key_PageUp) && (modifiers==::Qt::ControlModifier))
|
||||||
{
|
{
|
||||||
m_ambient_color.setZ(m_ambient_color.z()+.1);
|
m_ambient_color.setZ(m_ambient_color.z()+.1);
|
||||||
if (m_ambient_color.z()>1.) m_ambient_color.setZ(1.);
|
if (m_ambient_color.z()>1.) m_ambient_color.setZ(1.);
|
||||||
|
|
@ -886,7 +889,7 @@ protected:
|
||||||
arg(m_ambient_color.x()).arg(m_ambient_color.y()).arg(m_ambient_color.z()));
|
arg(m_ambient_color.x()).arg(m_ambient_color.y()).arg(m_ambient_color.z()));
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
else if ((e->key()==Qt::Key_PageDown) && (modifiers==Qt::ShiftModifier))
|
else if ((e->key()==::Qt::Key_PageDown) && (modifiers==::Qt::ShiftModifier))
|
||||||
{
|
{
|
||||||
m_ambient_color.setX(m_ambient_color.x()-.1);
|
m_ambient_color.setX(m_ambient_color.x()-.1);
|
||||||
if (m_ambient_color.x()<0.) m_ambient_color.setX(0.);
|
if (m_ambient_color.x()<0.) m_ambient_color.setX(0.);
|
||||||
|
|
@ -894,7 +897,7 @@ protected:
|
||||||
arg(m_ambient_color.x()).arg(m_ambient_color.y()).arg(m_ambient_color.z()));
|
arg(m_ambient_color.x()).arg(m_ambient_color.y()).arg(m_ambient_color.z()));
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
else if ((e->key()==Qt::Key_PageDown) && (modifiers==Qt::AltModifier))
|
else if ((e->key()==::Qt::Key_PageDown) && (modifiers==::Qt::AltModifier))
|
||||||
{
|
{
|
||||||
m_ambient_color.setY(m_ambient_color.y()-.1);
|
m_ambient_color.setY(m_ambient_color.y()-.1);
|
||||||
if (m_ambient_color.y()<0.) m_ambient_color.setY(0.);
|
if (m_ambient_color.y()<0.) m_ambient_color.setY(0.);
|
||||||
|
|
@ -902,7 +905,7 @@ protected:
|
||||||
arg(m_ambient_color.x()).arg(m_ambient_color.y()).arg(m_ambient_color.z()));
|
arg(m_ambient_color.x()).arg(m_ambient_color.y()).arg(m_ambient_color.z()));
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
else if ((e->key()==Qt::Key_PageDown) && (modifiers==Qt::ControlModifier))
|
else if ((e->key()==::Qt::Key_PageDown) && (modifiers==::Qt::ControlModifier))
|
||||||
{
|
{
|
||||||
m_ambient_color.setZ(m_ambient_color.z()-.1);
|
m_ambient_color.setZ(m_ambient_color.z()-.1);
|
||||||
if (m_ambient_color.z()<0.) m_ambient_color.setZ(0.);
|
if (m_ambient_color.z()<0.) m_ambient_color.setZ(0.);
|
||||||
|
|
@ -1020,4 +1023,6 @@ private:
|
||||||
QOpenGLShaderProgram rendering_program_p_l;
|
QOpenGLShaderProgram rendering_program_p_l;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // End namespace CGAL
|
||||||
|
|
||||||
#endif // CGAL_BASIC_VIEWER_QT_H
|
#endif // CGAL_BASIC_VIEWER_QT_H
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue