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>
|
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||||
// Contributor(s): Kumar Snehasish <kumar.snehasish@gmail.com>
|
// Contributor(s): Kumar Snehasish <kumar.snehasish@gmail.com>
|
||||||
|
// Mostafa Ashraf <mostaphaashraf1996@gmail.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "Viewer.h"
|
#include "Viewer.h"
|
||||||
#include <CGAL/Qt/vec.h>
|
#include <CGAL/Qt/vec.h>
|
||||||
|
|
||||||
Viewer::Viewer(QWidget* parent) :
|
Viewer::Viewer(QWidget *parent)
|
||||||
Base(parent, nullptr, ""),
|
// TODO: add a new constructor that does not take graphic buffer.
|
||||||
m_previous_scene_empty(true)
|
: 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_;
|
scene = scene_;
|
||||||
set_lcc(scene->lcc, doredraw);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Viewer::sceneChanged()
|
if (scene->lcc != nullptr) {
|
||||||
{
|
compute_elements(gBuffer, scene->lcc, m_drawing_functor, m_nofaces,
|
||||||
Base::compute_elements();
|
m_random_face_color);
|
||||||
this->camera()->
|
}
|
||||||
setSceneBoundingBox(CGAL::qglviewer::Vec(m_bounding_box.xmin(),
|
|
||||||
m_bounding_box.ymin(),
|
if (doredraw) {
|
||||||
m_bounding_box.zmin()),
|
|
||||||
CGAL::qglviewer::Vec(m_bounding_box.xmax(),
|
|
||||||
m_bounding_box.ymax(),
|
|
||||||
m_bounding_box.zmax()));
|
|
||||||
Base::redraw();
|
Base::redraw();
|
||||||
if (m_previous_scene_empty)
|
}
|
||||||
{ this->showEntireScene(); }
|
|
||||||
|
|
||||||
m_previous_scene_empty = scene->lcc->is_empty(); // for the next call to sceneChanged
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Viewer::keyPressEvent(QKeyEvent *e)
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_previous_scene_empty =
|
||||||
|
scene->lcc->is_empty(); // for the next call to sceneChanged
|
||||||
|
}
|
||||||
|
|
||||||
|
void Viewer::keyPressEvent(QKeyEvent *e) {
|
||||||
// const Qt::KeyboardModifiers modifiers = e->modifiers();
|
// const Qt::KeyboardModifiers modifiers = e->modifiers();
|
||||||
Base::keyPressEvent(e);
|
Base::keyPressEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Viewer::helpString() const
|
QString Viewer::helpString() const { return Base::helpString("LCC Demo"); }
|
||||||
{ return Base::helpString("LCC Demo"); }
|
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,15 @@
|
||||||
//
|
//
|
||||||
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||||
// Kumar Snehasish <kumar.snehasish@gmail.com>
|
// Kumar Snehasish <kumar.snehasish@gmail.com>
|
||||||
|
// Mostafa Ashraf <mostaphaashraf1996@gmail.com>
|
||||||
//
|
//
|
||||||
#ifndef VIEWER_H
|
#ifndef VIEWER_H
|
||||||
#define VIEWER_H
|
#define VIEWER_H
|
||||||
|
|
||||||
#include "typedefs.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.
|
// Functor used by SimpleLCCViewerQt to colorize of not elements.
|
||||||
struct MyDrawingFunctorLCC
|
struct MyDrawingFunctorLCC
|
||||||
|
|
@ -104,11 +107,11 @@ struct MyDrawingFunctorLCC
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Viewer : public CGAL::SimpleLCCViewerQt<LCC, MyDrawingFunctorLCC>
|
class Viewer : public Basic_viewer_qt
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
typedef CGAL::SimpleLCCViewerQt<LCC, MyDrawingFunctorLCC> Base;
|
typedef CGAL::Basic_viewer_qt Base;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Viewer(QWidget* parent);
|
Viewer(QWidget* parent);
|
||||||
|
|
@ -120,6 +123,8 @@ public Q_SLOTS:
|
||||||
void sceneChanged();
|
void sceneChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
const DrawingFunctorLCC &m_drawing_functor;
|
||||||
|
bool m_nofaces, m_random_face_color;
|
||||||
Scene* scene;
|
Scene* scene;
|
||||||
bool m_previous_scene_empty;
|
bool m_previous_scene_empty;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue