diff --git a/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp b/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp index dafcccb1695..6187787bc19 100644 --- a/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp +++ b/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp @@ -9,44 +9,54 @@ // // Author(s) : Guillaume Damiand // Contributor(s): Kumar Snehasish +// Mostafa Ashraf // #include "Viewer.h" #include -Viewer::Viewer(QWidget* parent) : - Base(parent, nullptr, ""), - m_previous_scene_empty(true) -{} +Viewer::Viewer(QWidget *parent) + // TODO: add a new constructor that does not take graphic buffer. + : Base(parent, ""), m_drawing_functor(MyDrawingFunctorLCC()), + m_nofaces(false), m_random_face_color(false), + m_previous_scene_empty(true) {} -void Viewer::setScene(Scene* scene_, bool doredraw) -{ +void Viewer::setScene(Scene *scene_, bool doredraw) { scene = scene_; - set_lcc(scene->lcc, doredraw); + + if (scene->lcc != nullptr) { + compute_elements(gBuffer, scene->lcc, m_drawing_functor, m_nofaces, + m_random_face_color); + } + + if (doredraw) { + Base::redraw(); + } } -void Viewer::sceneChanged() -{ - Base::compute_elements(); - this->camera()-> - setSceneBoundingBox(CGAL::qglviewer::Vec(m_bounding_box.xmin(), - m_bounding_box.ymin(), - m_bounding_box.zmin()), - CGAL::qglviewer::Vec(m_bounding_box.xmax(), - m_bounding_box.ymax(), - m_bounding_box.zmax())); +void Viewer::sceneChanged() { + compute_elements(gBuffer, scene->lcc, m_drawing_functor, m_nofaces, + m_random_face_color); + + this->camera()->setSceneBoundingBox( + CGAL::qglviewer::Vec(gBuffer.get_bounding_box().xmin(), + gBuffer.get_bounding_box().ymin(), + gBuffer.get_bounding_box().zmin()), + CGAL::qglviewer::Vec(gBuffer.get_bounding_box().xmax(), + gBuffer.get_bounding_box().ymax(), + gBuffer.get_bounding_box().zmax())); Base::redraw(); - if (m_previous_scene_empty) - { this->showEntireScene(); } + if (m_previous_scene_empty) { + this->showEntireScene(); + } - m_previous_scene_empty = scene->lcc->is_empty(); // for the next call to sceneChanged + m_previous_scene_empty = + scene->lcc->is_empty(); // for the next call to sceneChanged } -void Viewer::keyPressEvent(QKeyEvent *e) -{ +void Viewer::keyPressEvent(QKeyEvent *e) { // const Qt::KeyboardModifiers modifiers = e->modifiers(); Base::keyPressEvent(e); } -QString Viewer::helpString() const -{ return Base::helpString("LCC Demo"); } +QString Viewer::helpString() const { return Base::helpString("LCC Demo"); } diff --git a/Linear_cell_complex/demo/Linear_cell_complex/Viewer.h b/Linear_cell_complex/demo/Linear_cell_complex/Viewer.h index 18e66603ef4..f25f73de78a 100644 --- a/Linear_cell_complex/demo/Linear_cell_complex/Viewer.h +++ b/Linear_cell_complex/demo/Linear_cell_complex/Viewer.h @@ -9,12 +9,15 @@ // // Author(s) : Guillaume Damiand // Kumar Snehasish +// Mostafa Ashraf // #ifndef VIEWER_H #define VIEWER_H #include "typedefs.h" -#include + +#include +#include // Functor used by SimpleLCCViewerQt to colorize of not elements. struct MyDrawingFunctorLCC @@ -104,11 +107,11 @@ struct MyDrawingFunctorLCC }; -class Viewer : public CGAL::SimpleLCCViewerQt +class Viewer : public Basic_viewer_qt { Q_OBJECT - typedef CGAL::SimpleLCCViewerQt Base; + typedef CGAL::Basic_viewer_qt Base; public: Viewer(QWidget* parent); @@ -120,6 +123,8 @@ public Q_SLOTS: void sceneChanged(); private: + const DrawingFunctorLCC &m_drawing_functor; + bool m_nofaces, m_random_face_color; Scene* scene; bool m_previous_scene_empty; };