mirror of https://github.com/CGAL/cgal
Initial commit for modifying demo.
This commit is contained in:
parent
8e3b1bef75
commit
ebc4b65607
|
|
@ -9,44 +9,54 @@
|
|||
//
|
||||
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||
// Contributor(s): Kumar Snehasish <kumar.snehasish@gmail.com>
|
||||
// Mostafa Ashraf <mostaphaashraf1996@gmail.com>
|
||||
//
|
||||
|
||||
#include "Viewer.h"
|
||||
#include <CGAL/Qt/vec.h>
|
||||
|
||||
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"); }
|
||||
|
|
|
|||
|
|
@ -9,12 +9,15 @@
|
|||
//
|
||||
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||
// Kumar Snehasish <kumar.snehasish@gmail.com>
|
||||
// Mostafa Ashraf <mostaphaashraf1996@gmail.com>
|
||||
//
|
||||
#ifndef VIEWER_H
|
||||
#define VIEWER_H
|
||||
|
||||
#include "typedefs.h"
|
||||
#include <CGAL/draw_linear_cell_complex.h>
|
||||
|
||||
#include <CGAL/draw_linear_cell_complex_function.h>
|
||||
#include <CGAL/Qt/Basic_viewer_qt.h>
|
||||
|
||||
// Functor used by SimpleLCCViewerQt to colorize of not elements.
|
||||
struct MyDrawingFunctorLCC
|
||||
|
|
@ -104,11 +107,11 @@ struct MyDrawingFunctorLCC
|
|||
};
|
||||
|
||||
|
||||
class Viewer : public CGAL::SimpleLCCViewerQt<LCC, MyDrawingFunctorLCC>
|
||||
class Viewer : public Basic_viewer_qt
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
typedef CGAL::SimpleLCCViewerQt<LCC, MyDrawingFunctorLCC> 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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue