Remove the scaler form the scene API

This commit is contained in:
Maxime Gimeno 2020-10-16 14:32:12 +02:00
parent 812d082883
commit af7e1a8829
11 changed files with 19 additions and 14 deletions

View File

@ -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<Scene_print_item_interface*>(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

View File

@ -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

View File

@ -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;
}

View File

@ -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::Three::Viewer_interface*>(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);

View File

@ -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();

View File

@ -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"

View File

@ -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*);

View File

@ -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

View File

@ -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.
//!

View File

@ -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)

View File

@ -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
}
}