mirror of https://github.com/CGAL/cgal
Basic viewer is now in namespace Qt
This commit is contained in:
parent
126b9360c9
commit
2b69e29fe5
|
|
@ -1,10 +1,11 @@
|
|||
namespace CGAL {
|
||||
namespace Qt {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/*!
|
||||
\ingroup PkgBasicViewerClasses
|
||||
|
||||
The class `Basic_viewer` is a Qt widget based on `QGLViewer` that allows to visualize 3D elements: points, segments, triangles, rays and lines. This class stores a reference to a `Graphics_scene`. Elements can either be added directly in the viewer or through the scene. This class requires `CGAL_Qt5`, 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_Qt5` and add the definition `CGAL_USE_BASIC_VIEWER`.
|
||||
The class `Basic_viewer` is a Qt widget based on `QGLViewer` that allows to visualize 3D elements: points, segments, triangles, rays and lines. This class stores a reference to a `Graphics_scene`. Elements are added through the scene. This class requires `CGAL_Qt5`, 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_Qt5` and add the definition `CGAL_USE_BASIC_VIEWER`.
|
||||
|
||||
*/
|
||||
class Basic_viewer : public CGAL::QGLViewer
|
||||
|
|
@ -132,7 +133,7 @@ public:
|
|||
|
||||
/// Function called when a key is pressed. Users can define their own function in order
|
||||
/// to add specific behavior.
|
||||
std::function<bool(QKeyEvent *, CGAL::Basic_viewer *)> on_key_pressed;
|
||||
std::function<bool(QKeyEvent *, CGAL::Qt::Basic_viewer *)> on_key_pressed;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -157,6 +158,8 @@ public:
|
|||
Basic_viewer& basic_viewer();
|
||||
};
|
||||
|
||||
} // End namespace Qt
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/*!
|
||||
\ingroup PkgBasicViewerClasses
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@
|
|||
#define CGAL_BASIC_VIEWER_INIT_SIZE_Y 450
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
namespace Qt {
|
||||
//------------------------------------------------------------------------------
|
||||
class Basic_viewer : public CGAL::QGLViewer
|
||||
{
|
||||
|
|
@ -1457,7 +1457,7 @@ protected:
|
|||
return text;
|
||||
}
|
||||
public:
|
||||
std::function<bool(QKeyEvent *, CGAL::Basic_viewer *)> on_key_pressed;
|
||||
std::function<bool(QKeyEvent *, CGAL::Qt::Basic_viewer *)> on_key_pressed;
|
||||
|
||||
protected:
|
||||
const Graphics_scene& gBuffer;
|
||||
|
|
@ -1537,30 +1537,6 @@ protected:
|
|||
|
||||
};
|
||||
|
||||
inline
|
||||
void draw_graphics_scene(const Graphics_scene& graphics_scene,
|
||||
const char *title="CGAL Basic Viewer")
|
||||
{
|
||||
#if defined(CGAL_TEST_SUITE)
|
||||
bool cgal_test_suite = true;
|
||||
#else
|
||||
bool cgal_test_suite = qEnvironmentVariableIsSet("CGAL_TEST_SUITE");
|
||||
#endif
|
||||
|
||||
if (!cgal_test_suite)
|
||||
{
|
||||
Qt::init_ogl_context(4, 3);
|
||||
|
||||
int argc = 1;
|
||||
const char *argv[2] = {title, nullptr};
|
||||
QApplication app(argc, const_cast<char **>(argv));
|
||||
Basic_viewer basic_viewer(app.activeWindow(), graphics_scene, title);
|
||||
|
||||
basic_viewer.show();
|
||||
app.exec();
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
class QApplication_and_basic_viewer
|
||||
{
|
||||
|
|
@ -1622,6 +1598,36 @@ protected:
|
|||
int m_argc;
|
||||
};
|
||||
|
||||
} // End namespace Qt
|
||||
|
||||
// A shortcut to use directly CGAL::Basic_viewer instead of CGAL::Qt::Basic_viewer.
|
||||
// Can be changed later if we have several viewers.
|
||||
using Qt::Basic_viewer;
|
||||
|
||||
inline
|
||||
void draw_graphics_scene(const Graphics_scene& graphics_scene,
|
||||
const char *title="CGAL Basic Viewer")
|
||||
{
|
||||
#if defined(CGAL_TEST_SUITE)
|
||||
bool cgal_test_suite = true;
|
||||
#else
|
||||
bool cgal_test_suite = qEnvironmentVariableIsSet("CGAL_TEST_SUITE");
|
||||
#endif
|
||||
|
||||
if (!cgal_test_suite)
|
||||
{
|
||||
Qt::init_ogl_context(4, 3);
|
||||
|
||||
int argc = 1;
|
||||
const char *argv[2] = {title, nullptr};
|
||||
QApplication app(argc, const_cast<char **>(argv));
|
||||
Basic_viewer basic_viewer(app.activeWindow(), graphics_scene, title);
|
||||
|
||||
basic_viewer.show();
|
||||
app.exec();
|
||||
}
|
||||
}
|
||||
|
||||
} // End namespace CGAL
|
||||
|
||||
#else // CGAL_USE_BASIC_VIEWER
|
||||
|
|
|
|||
Loading…
Reference in New Issue