From af7e1a8829c07fa0ddb5cb163079f7f36abca92d Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 16 Oct 2020 14:32:12 +0200 Subject: [PATCH] Remove the scaler form the scene API --- Polyhedron/demo/Polyhedron/Scene.cpp | 4 ++-- Polyhedron/demo/Polyhedron/Scene.h | 2 +- .../demo/Polyhedron/Scene_polyhedron_selection_item.cpp | 4 ++-- Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp | 3 ++- Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.h | 2 +- Polyhedron/demo/Polyhedron/Viewer.cpp | 4 +++- Polyhedron/demo/Polyhedron/Viewer.h | 1 + Three/include/CGAL/Three/Scene_draw_interface.h | 6 ++---- Three/include/CGAL/Three/Scene_print_item_interface.h | 2 +- Three/include/CGAL/Three/TextRenderer.h | 2 +- Three/include/CGAL/Three/Viewer_interface.h | 3 +++ 11 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Scene.cpp b/Polyhedron/demo/Polyhedron/Scene.cpp index 6ddc13cc074..88c60c0b06f 100644 --- a/Polyhedron/demo/Polyhedron/Scene.cpp +++ b/Polyhedron/demo/Polyhedron/Scene.cpp @@ -1738,7 +1738,7 @@ void Scene::updatePrimitiveIds(CGAL::Three::Scene_item* it) } } } -bool Scene::testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface* viewer, const QVector3D& scaler) +bool Scene::testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface* viewer) { CGAL::Three::Scene_item *i = item(mainSelectionIndex()); if(!i) @@ -1746,7 +1746,7 @@ bool Scene::testDisplayId(double x, double y, double z, CGAL::Three::Viewer_inte Scene_print_item_interface* spit= qobject_cast(i); if(spit && i->visible()) { - bool res = spit->testDisplayId(x,y,z, viewer, scaler); + bool res = spit->testDisplayId(x,y,z, viewer); return res; } else diff --git a/Polyhedron/demo/Polyhedron/Scene.h b/Polyhedron/demo/Polyhedron/Scene.h index 1159739e3e7..61010a23513 100644 --- a/Polyhedron/demo/Polyhedron/Scene.h +++ b/Polyhedron/demo/Polyhedron/Scene.h @@ -95,7 +95,7 @@ public: void printAllIds() Q_DECL_OVERRIDE; //!Re-computes the primitiveIds for `item` void updatePrimitiveIds(Scene_item *item) Q_DECL_OVERRIDE; - bool testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface* viewer, const QVector3D& scaler) 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; void computeBbox(); double len_diagonal() const Q_DECL_OVERRIDE diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp index 69de06f2d58..2473c474f3c 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp @@ -2254,9 +2254,9 @@ void Scene_polyhedron_selection_item::printAllIds() { d->item->polyhedron_item()->printAllIds(); } -bool Scene_polyhedron_selection_item::testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface* viewer, const QVector3D& scaler)const +bool Scene_polyhedron_selection_item::testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface* viewer)const { - return d->item->polyhedron_item()->testDisplayId(x, y, z, viewer, scaler); + return d->item->polyhedron_item()->testDisplayId(x, y, z, viewer); return false; } diff --git a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp index 5c5f39e8788..ca0f35f9359 100644 --- a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp @@ -2130,7 +2130,7 @@ void Scene_surface_mesh_item::printAllIds() d->killIds(); } -bool Scene_surface_mesh_item::testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface* viewer, const QVector3D& scaler)const +bool Scene_surface_mesh_item::testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface* viewer)const { const CGAL::qglviewer::Vec offset = static_cast(CGAL::QGLViewer::QGLViewerPool().first())->offset(); EPICK::Point_3 src(x - offset.x, @@ -2138,6 +2138,7 @@ bool Scene_surface_mesh_item::testDisplayId(double x, double y, double z, CGAL:: z - offset.z); CGAL::qglviewer::Camera* cam = viewer->camera(); + const QVector3D& scaler = viewer->scaler(); EPICK::Point_3 dest( cam->position().x/scaler.x() - offset.x, cam->position().y/scaler.y() - offset.y, cam->position().z/scaler.z() - offset.z); diff --git a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.h b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.h index fba5cb89635..d04f771899b 100644 --- a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.h @@ -149,7 +149,7 @@ public: bool printFaceIds()const Q_DECL_OVERRIDE; void printAllIds() Q_DECL_OVERRIDE; bool shouldDisplayIds(CGAL::Three::Scene_item *current_item) const Q_DECL_OVERRIDE; - bool testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface*, const QVector3D &scaler)const Q_DECL_OVERRIDE; + bool testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface*)const Q_DECL_OVERRIDE; float alpha() const Q_DECL_OVERRIDE; void setAlpha(int alpha) Q_DECL_OVERRIDE; QSlider* alphaSlider(); diff --git a/Polyhedron/demo/Polyhedron/Viewer.cpp b/Polyhedron/demo/Polyhedron/Viewer.cpp index b215784e429..9cda012df08 100644 --- a/Polyhedron/demo/Polyhedron/Viewer.cpp +++ b/Polyhedron/demo/Polyhedron/Viewer.cpp @@ -1483,7 +1483,7 @@ void Viewer::wheelEvent(QWheelEvent* e) bool Viewer::testDisplayId(double x, double y, double z) { - return d->scene->testDisplayId(x,y,z,this, d->scaler); + return d->scene->testDisplayId(x,y,z,this); } QPainter* Viewer::getPainter(){return d->painter;} @@ -2116,4 +2116,6 @@ void Viewer::onTextMessageSocketReceived(QString message) update(); } #endif + +const QVector3D& Viewer::scaler()const { return d->scaler; } #include "Viewer.moc" diff --git a/Polyhedron/demo/Polyhedron/Viewer.h b/Polyhedron/demo/Polyhedron/Viewer.h index 7fceedbb0e7..00381648013 100644 --- a/Polyhedron/demo/Polyhedron/Viewer.h +++ b/Polyhedron/demo/Polyhedron/Viewer.h @@ -92,6 +92,7 @@ public: //!Set total number of depth peeling passes. void setTotalPass(int); void resetFov(); + const QVector3D& scaler() const; Q_SIGNALS: void sendMessage(QString); void doneInitGL(CGAL::Three::Viewer_interface*); diff --git a/Three/include/CGAL/Three/Scene_draw_interface.h b/Three/include/CGAL/Three/Scene_draw_interface.h index 4fc582fa111..d91fb6df0ec 100644 --- a/Three/include/CGAL/Three/Scene_draw_interface.h +++ b/Three/include/CGAL/Three/Scene_draw_interface.h @@ -60,10 +60,8 @@ public: * \param y the Y coordinate of theTextItem's position. * \param z the Z coordinate of theTextItem's position. * \param viewer the viewer used to display the Scene. - * \param scaler a vector indicating the scaling factors to apply to the scene when displaying it. - * It can be useful when a scene is very large along one of it's coordinates, making it hard to visualize it. * \return true if the TextItem is visible. */ - virtual bool testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface* viewer, const QVector3D& scaler) = 0; + virtual bool testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface* viewer) = 0; ///\brief displays all the vertices ids if there are less than max_textItems. virtual void printVertexIds() = 0; @@ -74,7 +72,7 @@ public: ///\brief displays all the primitive ids if there are less than max_textItems. virtual void printAllIds() = 0; - //!\brief moves the camera orthogonally to the picked sface. + //!\brief moves the camera orthogonally to the picked face. //! //! \param point the picked point //! \param viewer the active viewer diff --git a/Three/include/CGAL/Three/Scene_print_item_interface.h b/Three/include/CGAL/Three/Scene_print_item_interface.h index f6ff32c2374..3ad79996463 100644 --- a/Three/include/CGAL/Three/Scene_print_item_interface.h +++ b/Three/include/CGAL/Three/Scene_print_item_interface.h @@ -48,7 +48,7 @@ public: //! //! \returns true if the Id should be displayed //! \returns false if the Id should not be displayed (if it is hidden for example) - virtual bool testDisplayId(double, double, double, CGAL::Three::Viewer_interface*, const QVector3D& scaler)const = 0; + virtual bool testDisplayId(double, double, double, CGAL::Three::Viewer_interface*)const = 0; //! \brief Tests if this item should display its ids. //! diff --git a/Three/include/CGAL/Three/TextRenderer.h b/Three/include/CGAL/Three/TextRenderer.h index 2d2f8e3a4c0..67dae47abae 100644 --- a/Three/include/CGAL/Three/TextRenderer.h +++ b/Three/include/CGAL/Three/TextRenderer.h @@ -139,7 +139,7 @@ public: { } //!Draws all the `TextItem`s - void draw(CGAL::Three::Viewer_interface* viewer, const QVector3D& scaler); + void draw(CGAL::Three::Viewer_interface* viewer, const QVector3D &scaler); //!\brief Adds a single TextItem to TextRenderer::local_textItems //! //! @see addText(float p_x, float p_y, float p_z, QString p_text, bool p_3D = true, QFont font = QFont(), QColor p_color = Qt::black) diff --git a/Three/include/CGAL/Three/Viewer_interface.h b/Three/include/CGAL/Three/Viewer_interface.h index 8498ccb2fef..17a5e9e2fb0 100644 --- a/Three/include/CGAL/Three/Viewer_interface.h +++ b/Three/include/CGAL/Three/Viewer_interface.h @@ -284,6 +284,9 @@ public: virtual void makeCurrent() = 0; virtual QVector4D* clipBox() const =0; virtual bool isClipping() const = 0; + //! A vector indicating the scaling factors to apply to the scene when displaying it. + //! It can be useful when a scene is very large along one of it's coordinates, making it hard to visualize it. + virtual const QVector3D& scaler() const = 0; }; // end class Viewer_interface } }