diff --git a/Basic_viewer/doc/Basic_viewer/CGAL/Qt/Basic_viewer.h b/Basic_viewer/doc/Basic_viewer/CGAL/Qt/Basic_viewer.h index adcdbbc266a..5ef340bd40d 100644 --- a/Basic_viewer/doc/Basic_viewer/CGAL/Qt/Basic_viewer.h +++ b/Basic_viewer/doc/Basic_viewer/CGAL/Qt/Basic_viewer.h @@ -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 on_key_pressed; + std::function on_key_pressed; }; @@ -157,6 +158,8 @@ public: Basic_viewer& basic_viewer(); }; +} // End namespace Qt + //------------------------------------------------------------------------------ /*! \ingroup PkgBasicViewerClasses diff --git a/Basic_viewer/include/CGAL/Qt/Basic_viewer.h b/Basic_viewer/include/CGAL/Qt/Basic_viewer.h index acd9d8b66dd..60b16ff2b20 100644 --- a/Basic_viewer/include/CGAL/Qt/Basic_viewer.h +++ b/Basic_viewer/include/CGAL/Qt/Basic_viewer.h @@ -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 on_key_pressed; + std::function 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(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(argv)); + Basic_viewer basic_viewer(app.activeWindow(), graphics_scene, title); + + basic_viewer.show(); + app.exec(); + } +} + } // End namespace CGAL #else // CGAL_USE_BASIC_VIEWER