From 3dcd3359db83b0472eeca02eaa422046846d28ab Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 4 Dec 2018 16:24:30 +0100 Subject: [PATCH] Fix behavior with offset --- Polyhedron/demo/Polyhedron/MainWindow.cpp | 13 +++++++++---- Polyhedron/demo/Polyhedron/MainWindow.h | 2 +- Polyhedron/demo/Polyhedron/Scene.cpp | 6 ++++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index ca9ac17873c..dc0023cf6ad 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -208,7 +208,7 @@ MainWindow::MainWindow(bool verbose, QWidget* parent) this, SLOT(removeManipulatedFrame(CGAL::Three::Scene_item*))); connect(scene, SIGNAL(updated_bbox(bool)), - this, SLOT(invalidate_bbox())); + this, SLOT(invalidate_bbox(bool))); connect(scene, SIGNAL(selectionChanged(int)), this, SLOT(selectSceneItem(int))); @@ -1105,6 +1105,7 @@ void MainWindow::open(QString filename) qobject_cast(scene_item); if(group) scene->redraw_model(); + updateViewerBBox(true); } bool MainWindow::open(QString filename, QString loader_name) { @@ -1776,7 +1777,6 @@ void MainWindow::on_actionLoad_triggered() scene->item(scene->numberOfEntries()-1)->setColor(colors_[++nb_item]); } } - updateViewerBBox(true); } void MainWindow::on_actionSaveAs_triggered() @@ -2228,7 +2228,9 @@ void MainWindow::setAddKeyFrameKeyboardModifiers(::Qt::KeyboardModifiers m) void MainWindow::on_actionRecenterScene_triggered() { - updateViewerBBox(); + //force the recomputaion of the bbox + bbox_need_update = true; + updateViewerBBox(true); viewer->camera()->showEntireScene(); } @@ -2582,7 +2584,10 @@ void MainWindow::setDefaultSaveDir() settings.setValue("default_saveas_dir", def_save_dir); } -void MainWindow::invalidate_bbox() +void MainWindow::invalidate_bbox(bool do_recenter) { bbox_need_update = true; + if(do_recenter) + updateViewerBBox(true); + } diff --git a/Polyhedron/demo/Polyhedron/MainWindow.h b/Polyhedron/demo/Polyhedron/MainWindow.h index 4c38c289b97..d0d1aad10ec 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.h +++ b/Polyhedron/demo/Polyhedron/MainWindow.h @@ -441,7 +441,7 @@ public: public Q_SLOTS: void toggleFullScreen(); void setDefaultSaveDir(); - void invalidate_bbox(); + void invalidate_bbox(bool do_recenter); private: QList visibleDockWidgets; QLineEdit operationSearchBar; diff --git a/Polyhedron/demo/Polyhedron/Scene.cpp b/Polyhedron/demo/Polyhedron/Scene.cpp index 13826d45f6d..890940606fe 100644 --- a/Polyhedron/demo/Polyhedron/Scene.cpp +++ b/Polyhedron/demo/Polyhedron/Scene.cpp @@ -1330,8 +1330,10 @@ void Scene::itemVisibilityChanged(CGAL::Three::Scene_item* item) && !item->isEmpty()) { //does not recenter - if(visibility_recentering_enabled) - Q_EMIT updated_bbox(false); + if(visibility_recentering_enabled){ + Q_EMIT updated_bbox(true); + + } } }