Remove visibleBbox from scene. Working subviewer.

This commit is contained in:
Maxime Gimeno 2018-09-04 10:29:54 +02:00
parent 06ce5dddca
commit e5aaab93d5
8 changed files with 230 additions and 318 deletions

2
GraphicsView/include/CGAL/Qt/qglviewer_impl.h Normal file → Executable file
View File

@ -3183,9 +3183,7 @@ void CGAL::QGLViewer::drawVisualHints() {
int size = 100;
glViewport(width()*devicePixelRatio()-size, height()*devicePixelRatio()-size, size, size);
glScissor (width()*devicePixelRatio()-size, height()*devicePixelRatio()-size, size, size);
glDisable(GL_DEPTH_TEST);
glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(axis_size / 9));
glEnable(GL_DEPTH_TEST);
// The viewport and the scissor are restored.
glScissor(scissor[0],scissor[1],scissor[2],scissor[3]);
glViewport(viewport[0],viewport[1],viewport[2],viewport[3]);

57
Polyhedron/demo/Polyhedron/MainWindow.cpp Normal file → Executable file
View File

@ -148,14 +148,9 @@ MainWindow::MainWindow(bool verbose, QWidget* parent)
// Save some pointers from ui, for latter use.
sceneView = ui->sceneView;
viewer = ui->viewer;
viewer->setObjectName("viewer");
// do not save the state of the viewer (anoying)
viewer->setStateFileName(QString::null);
// setup scene
scene = new Scene(this);
viewer->textRenderer()->setScene(scene);
viewer->setScene(scene);
CGAL::Three::Three::s_scene = scene;
CGAL::Three::Three::s_connectable_scene = scene;
{
@ -169,12 +164,6 @@ MainWindow::MainWindow(bool verbose, QWidget* parent)
connect(shortcut, SIGNAL(activated()),
this, SLOT(toggleFullScreen()));
}
setupViewer(viewer, 0);
viewer->setKeyDescription(Qt::Key_R + Qt::CTRL,
tr("Recenters the viewer under the cursor. "
"If the cursor is not over any viewer, "
"then all viewers are recentered."));
proxyModel = new QSortFilterProxyModel(this);
proxyModel->setSourceModel(scene);
@ -198,11 +187,6 @@ MainWindow::MainWindow(bool verbose, QWidget* parent)
connect(scene, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex & )),
this, SLOT(updateDisplayInfo()));
connect(scene, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex & )),
viewer, SLOT(update()));
connect(scene, SIGNAL(updated()),
viewer, SLOT(update()));
connect(viewer, &Viewer::needNewContext,
[this](){create();});
@ -251,31 +235,7 @@ MainWindow::MainWindow(bool verbose, QWidget* parent)
connect(scene, SIGNAL(restoreCollapsedState()),
this, SLOT(restoreCollapseState()));
connect(viewer, SIGNAL(selected(int)),
this, SLOT(selectSceneItem(int)));
connect(viewer, SIGNAL(selectedPoint(double, double, double)),
this, SLOT(showSelectedPoint(double, double, double)));
connect(viewer, SIGNAL(selectionRay(double, double, double,
double, double, double)),
scene, SIGNAL(selectionRay(double, double, double,
double, double, double)));
connect(viewer, SIGNAL(requestContextMenu(QPoint)),
this, SLOT(contextMenuRequested(QPoint)));
connect(viewer, SIGNAL(sendMessage(QString)),
this, SLOT(information(QString)));
// The contextMenuPolicy of infoLabel is now the default one, so that one
// can easily copy-paste its text.
// connect(ui->infoLabel, SIGNAL(customContextMenuRequested(const QPoint & )),
// this, SLOT(showSceneContextMenu(const QPoint &)));
connect(ui->actionRecenterScene, SIGNAL(triggered()),
viewer, SLOT(update()));
connect(ui->actionDrawTwoSides, SIGNAL(toggled(bool)),
viewer, SLOT(setTwoSides(bool)));
connect(ui->actionSwitchProjection, SIGNAL(toggled(bool)),
viewer, SLOT(SetOrthoProjection(bool)));
setupViewer(viewer, nullptr);
// add the "About CGAL..." and "About demo..." entries
this->addAboutCGAL();
@ -883,8 +843,7 @@ void MainWindow::updateViewersBboxes(bool recenter)
void MainWindow::computeViewerBBox(CGAL::qglviewer::Vec& min, CGAL::qglviewer::Vec& max)
{
const Scene::Bbox bbox = scene->visibleBbox();
const Scene::Bbox all_bbox = scene->bbox();
const Scene::Bbox bbox = scene->bbox();
const double xmin = bbox.xmin();
const double ymin = bbox.ymin();
const double zmin = bbox.zmin();
@ -892,20 +851,12 @@ void MainWindow::computeViewerBBox(CGAL::qglviewer::Vec& min, CGAL::qglviewer::V
const double ymax = bbox.ymax();
const double zmax = bbox.zmax();
const double axmin = all_bbox.xmin();
const double aymin = all_bbox.ymin();
const double azmin = all_bbox.zmin();
const double axmax = all_bbox.xmax();
const double aymax = all_bbox.ymax();
const double azmax = all_bbox.zmax();
min = CGAL::qglviewer::Vec(xmin, ymin, zmin);
max= CGAL::qglviewer::Vec(xmax, ymax, zmax);
CGAL::qglviewer::Vec abbox_center((axmin+axmax)/2, (aymin+aymax)/2, (azmin+azmax)/2),
bbox_center((xmin+xmax)/2, (ymin+ymax)/2, (zmin+zmax)/2);
CGAL::qglviewer::Vec bbox_center((xmin+xmax)/2, (ymin+ymax)/2, (zmin+zmax)/2);
CGAL::qglviewer::Vec offset(0,0,0);
@ -2103,7 +2054,6 @@ void MainWindow::setAddKeyFrameKeyboardModifiers(::Qt::KeyboardModifiers m)
void MainWindow::on_actionRecenterScene_triggered()
{
scene->computeBbox();
scene->computeVisibleBbox();
CGAL::qglviewer::Vec min, max;
computeViewerBBox(min, max);
Q_FOREACH(CGAL::QGLViewer* v, CGAL::QGLViewer::QGLViewerPool())
@ -2583,7 +2533,6 @@ void MainWindow::on_actionAdd_Viewer_triggered()
void MainWindow::recenterViewer()
{
scene->computeBbox();
scene->computeVisibleBbox();
CGAL::qglviewer::Vec min, max;
computeViewerBBox(min, max);
Viewer* target = qobject_cast<Viewer*>(childAt(cursor().pos()));

2
Polyhedron/demo/Polyhedron/Polyhedron_3.qrc Normal file → Executable file
View File

@ -31,6 +31,8 @@
<file>resources/pss_inter.png</file>
<file>resources/pss_diff.png</file>
<file>resources/help_button.png</file>
<file>resources/exit.png</file>
<file>resources/menu.png</file>
</qresource>
<qresource prefix="/cgal/Polyhedron_3">
<file alias="about.html">resources/about.html</file>

34
Polyhedron/demo/Polyhedron/Scene.cpp Normal file → Executable file
View File

@ -1201,7 +1201,6 @@ void Scene::itemVisibilityChanged(CGAL::Three::Scene_item* item)
&& !item->isEmpty())
{
//does not recenter
computeVisibleBbox();
Q_EMIT updated_bbox(false);
}
}
@ -1664,34 +1663,6 @@ void Scene::adjustIds(Item_id removed_id)
}
}
void Scene::computeVisibleBbox()
{
if(m_entries.empty())
{
last_visible_bbox = Bbox(0,0,0,0,0,0);
return;
}
bool bbox_initialized = false;
Bbox bbox = Bbox(0,0,0,0,0,0);
Q_FOREACH(CGAL::Three::Scene_item* item, m_entries)
{
if(item->isFinite() && !item->isEmpty() && item->visible()) {
if(bbox_initialized) {
bbox = bbox + item->bbox();
}
else {
bbox = item->bbox();
bbox_initialized = true;
}
}
}
last_visible_bbox = bbox;
}
void Scene::computeBbox()
{
if(m_entries.empty())
@ -1740,11 +1711,6 @@ void Scene::removeViewer(Viewer_interface *viewer)
}
}
Scene::Bbox Scene::visibleBbox() const
{
return last_visible_bbox;
}
void Scene::initGL(Viewer_interface *viewer)
{
viewer->makeCurrent();

3
Polyhedron/demo/Polyhedron/Scene.h Normal file → Executable file
View File

@ -94,9 +94,7 @@ public:
void updatePrimitiveIds(Viewer_interface *, Scene_item *item) Q_DECL_OVERRIDE;
bool testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface* viewer) Q_DECL_OVERRIDE;
Bbox bbox() const Q_DECL_OVERRIDE;
Bbox visibleBbox() const ;
void computeBbox();
void computeVisibleBbox();
double len_diagonal() const Q_DECL_OVERRIDE
{
Bbox box = bbox();
@ -286,7 +284,6 @@ private:
QMap<CGAL::Three::Viewer_interface*, QOpenGLVertexArrayObject*> vaos;
mutable QOpenGLBuffer vbo[2];
Bbox last_bbox;
Bbox last_visible_bbox;
}; // end class Scene
class QAbstractProxyModel;

6
Polyhedron/demo/Polyhedron/SubViewer.ui Normal file → Executable file
View File

@ -37,8 +37,8 @@
<string/>
</property>
<property name="icon">
<iconset resource="Polyhedron_3.qrc">
<normaloff>:/cgal/icons/menu</normaloff>:/cgal/icons/menu</iconset>
<iconset>
<normaloff>resources/menu.png</normaloff>resources/menu.png</iconset>
</property>
<property name="iconSize">
<size>
@ -61,7 +61,7 @@
</property>
<property name="icon">
<iconset resource="Polyhedron_3.qrc">
<normaloff>:/cgal/icons/exit</normaloff>:/cgal/icons/exit</iconset>
<normaloff>:/cgal/icons/resources/exit.png</normaloff>:/cgal/icons/resources/exit.png</iconset>
</property>
<property name="iconSize">
<size>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 742 B