mirror of https://github.com/CGAL/cgal
Selection_items keep displaying their polyhedron_items ids and zoomToId doesn't override the sceneCenterPoint anymore.
This commit is contained in:
parent
3c08937edb
commit
ee93ab34dd
|
|
@ -1174,7 +1174,7 @@ void Scene::printVertexIds(CGAL::Three::Viewer_interface* viewer)
|
||||||
Scene_item *it = item(mainSelectionIndex());
|
Scene_item *it = item(mainSelectionIndex());
|
||||||
if(it)
|
if(it)
|
||||||
{
|
{
|
||||||
Scene_print_item_interface* item= dynamic_cast<Scene_print_item_interface*>(it);
|
Scene_print_item_interface* item= qobject_cast<Scene_print_item_interface*>(it);
|
||||||
if(item)
|
if(item)
|
||||||
item->printVertexIds(viewer);
|
item->printVertexIds(viewer);
|
||||||
}
|
}
|
||||||
|
|
@ -1186,7 +1186,7 @@ void Scene::printEdgeIds(CGAL::Three::Viewer_interface* viewer)
|
||||||
if(it)
|
if(it)
|
||||||
{
|
{
|
||||||
//Only call printEdgeIds if the item is a Scene_print_item_interface
|
//Only call printEdgeIds if the item is a Scene_print_item_interface
|
||||||
Scene_print_item_interface* item= dynamic_cast<Scene_print_item_interface*>(it);
|
Scene_print_item_interface* item= qobject_cast<Scene_print_item_interface*>(it);
|
||||||
if(item)
|
if(item)
|
||||||
item->printEdgeIds(viewer);
|
item->printEdgeIds(viewer);
|
||||||
}
|
}
|
||||||
|
|
@ -1198,7 +1198,7 @@ void Scene::printFaceIds(CGAL::Three::Viewer_interface* viewer)
|
||||||
if(it)
|
if(it)
|
||||||
{
|
{
|
||||||
//Only call printFaceIds if the item is a Scene_print_item_interface
|
//Only call printFaceIds if the item is a Scene_print_item_interface
|
||||||
Scene_print_item_interface* item= dynamic_cast<Scene_print_item_interface*>(it);
|
Scene_print_item_interface* item= qobject_cast<Scene_print_item_interface*>(it);
|
||||||
if(item)
|
if(item)
|
||||||
item->printFaceIds(viewer);
|
item->printFaceIds(viewer);
|
||||||
}
|
}
|
||||||
|
|
@ -1210,7 +1210,7 @@ void Scene::printAllIds(CGAL::Three::Viewer_interface* viewer)
|
||||||
if(it)
|
if(it)
|
||||||
{
|
{
|
||||||
//Only call printFaceIds if the item is a Scene_print_item_interface
|
//Only call printFaceIds if the item is a Scene_print_item_interface
|
||||||
Scene_print_item_interface* item= dynamic_cast<Scene_print_item_interface*>(it);
|
Scene_print_item_interface* item= qobject_cast<Scene_print_item_interface*>(it);
|
||||||
if(item)
|
if(item)
|
||||||
item->printAllIds(viewer);
|
item->printAllIds(viewer);
|
||||||
}
|
}
|
||||||
|
|
@ -1219,7 +1219,7 @@ void Scene::updatePrimitiveIds(CGAL::Three::Viewer_interface* viewer, CGAL::Thre
|
||||||
{
|
{
|
||||||
if(it)
|
if(it)
|
||||||
{
|
{
|
||||||
Scene_print_item_interface* item= dynamic_cast<Scene_print_item_interface*>(it);
|
Scene_print_item_interface* item= qobject_cast<Scene_print_item_interface*>(it);
|
||||||
if(item)
|
if(item)
|
||||||
{
|
{
|
||||||
//As this function works as a toggle, the first call hides the ids and the second one shows them again,
|
//As this function works as a toggle, the first call hides the ids and the second one shows them again,
|
||||||
|
|
|
||||||
|
|
@ -2421,9 +2421,15 @@ void Scene_polyhedron_item::zoomToId()
|
||||||
viewer->camera()->position().z - viewer->camera()->sceneCenter().z)
|
viewer->camera()->position().z - viewer->camera()->sceneCenter().z)
|
||||||
.norm() * normal ;
|
.norm() * normal ;
|
||||||
|
|
||||||
viewer->camera()->setSceneCenter(qglviewer::Vec(p.x(),
|
#if QGLVIEWER_VERSION >= 0x020502
|
||||||
p.y(),
|
viewer->camera()->setPivotPoint(qglviewer::Vec(p.x(),
|
||||||
|
p.y(),
|
||||||
p.z()));
|
p.z()));
|
||||||
|
#else
|
||||||
|
viewer->camera()->setRevolveAroundPoint(qglviewer::Vec(p.x(),
|
||||||
|
p.y(),
|
||||||
|
p.z()));
|
||||||
|
#endif
|
||||||
|
|
||||||
viewer->moveCameraToCoordinates(QString("%1 %2 %3 %4 %5 %6 %7").arg(new_pos.x())
|
viewer->moveCameraToCoordinates(QString("%1 %2 %3 %4 %5 %6 %7").arg(new_pos.x())
|
||||||
.arg(new_pos.y())
|
.arg(new_pos.y())
|
||||||
|
|
@ -2435,3 +2441,7 @@ void Scene_polyhedron_item::zoomToId()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bool Scene_polyhedron_item::shouldDisplayIds(CGAL::Three::Scene_item *current_item) const
|
||||||
|
{
|
||||||
|
return this == current_item;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,7 @@ public:
|
||||||
bool printEdgeIds(CGAL::Three::Viewer_interface*)const Q_DECL_OVERRIDE;
|
bool printEdgeIds(CGAL::Three::Viewer_interface*)const Q_DECL_OVERRIDE;
|
||||||
bool printFaceIds(CGAL::Three::Viewer_interface*)const Q_DECL_OVERRIDE;
|
bool printFaceIds(CGAL::Three::Viewer_interface*)const Q_DECL_OVERRIDE;
|
||||||
void printAllIds(CGAL::Three::Viewer_interface*) Q_DECL_OVERRIDE;
|
void printAllIds(CGAL::Three::Viewer_interface*) 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 Q_DECL_OVERRIDE;
|
bool testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface*)const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2207,3 +2207,52 @@ void Scene_polyhedron_selection_item::selection_changed(bool b)
|
||||||
viewer->setNoBinding();
|
viewer->setNoBinding();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Scene_polyhedron_selection_item::printPrimitiveId(QPoint p, CGAL::Three::Viewer_interface* viewer)
|
||||||
|
{
|
||||||
|
#ifndef USE_SURFACE_MESH
|
||||||
|
d->item->polyhedron_item()->printPrimitiveId(p, viewer);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
bool Scene_polyhedron_selection_item::printVertexIds(CGAL::Three::Viewer_interface* viewer) const
|
||||||
|
{
|
||||||
|
#ifndef USE_SURFACE_MESH
|
||||||
|
return d->item->polyhedron_item()->printVertexIds(viewer);
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool Scene_polyhedron_selection_item::printEdgeIds(CGAL::Three::Viewer_interface* viewer) const
|
||||||
|
{
|
||||||
|
#ifndef USE_SURFACE_MESH
|
||||||
|
d->item->polyhedron_item()->printEdgeIds(viewer);
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool Scene_polyhedron_selection_item::printFaceIds(CGAL::Three::Viewer_interface* viewer) const
|
||||||
|
{
|
||||||
|
#ifndef USE_SURFACE_MESH
|
||||||
|
return d->item->polyhedron_item()->printFaceIds(viewer);
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
void Scene_polyhedron_selection_item::printAllIds(CGAL::Three::Viewer_interface* viewer)
|
||||||
|
{
|
||||||
|
#ifndef USE_SURFACE_MESH
|
||||||
|
d->item->polyhedron_item()->printAllIds(viewer);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
bool Scene_polyhedron_selection_item::testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface* viewer)const
|
||||||
|
{
|
||||||
|
#ifndef USE_SURFACE_MESH
|
||||||
|
return d->item->polyhedron_item()->testDisplayId(x, y, z, viewer);
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Scene_polyhedron_selection_item::shouldDisplayIds(CGAL::Three::Scene_item *current_item) const
|
||||||
|
{
|
||||||
|
#ifndef USE_SURFACE_MESH
|
||||||
|
return d->item->polyhedron_item() == current_item;
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@
|
||||||
#include <CGAL/Polygon_mesh_processing/orient_polygon_soup.h>
|
#include <CGAL/Polygon_mesh_processing/orient_polygon_soup.h>
|
||||||
#include <CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h>
|
#include <CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h>
|
||||||
#include <CGAL/Polygon_mesh_processing/connected_components.h>
|
#include <CGAL/Polygon_mesh_processing/connected_components.h>
|
||||||
|
#include <CGAL/Three/Scene_print_item_interface.h>
|
||||||
|
|
||||||
#include "Polyhedron_demo_detect_sharp_edges.h"
|
#include "Polyhedron_demo_detect_sharp_edges.h"
|
||||||
|
|
||||||
// Laurent Rineau, 2016/04/07: that header should not be included here, but
|
// Laurent Rineau, 2016/04/07: that header should not be included here, but
|
||||||
|
|
@ -201,9 +203,12 @@ struct Selection_traits<typename SelectionItem::fg_edge_descriptor, SelectionIte
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
struct Scene_polyhedron_selection_item_priv;
|
struct Scene_polyhedron_selection_item_priv;
|
||||||
class SCENE_POLYHEDRON_SELECTION_ITEM_EXPORT Scene_polyhedron_selection_item
|
class SCENE_POLYHEDRON_SELECTION_ITEM_EXPORT Scene_polyhedron_selection_item
|
||||||
: public Scene_polyhedron_item_decorator
|
: public Scene_polyhedron_item_decorator,
|
||||||
|
public CGAL::Three::Scene_print_item_interface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_INTERFACES(CGAL::Three::Scene_print_item_interface)
|
||||||
|
Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PrintInterface/1.0")
|
||||||
|
|
||||||
friend class Polyhedron_demo_selection_plugin;
|
friend class Polyhedron_demo_selection_plugin;
|
||||||
|
|
||||||
|
|
@ -220,6 +225,14 @@ public:
|
||||||
~Scene_polyhedron_selection_item();
|
~Scene_polyhedron_selection_item();
|
||||||
void inverse_selection();
|
void inverse_selection();
|
||||||
void setPathSelection(bool b);
|
void setPathSelection(bool b);
|
||||||
|
//For ID printing
|
||||||
|
void printPrimitiveId(QPoint, CGAL::Three::Viewer_interface*);
|
||||||
|
bool printVertexIds(CGAL::Three::Viewer_interface*) const;
|
||||||
|
bool printEdgeIds(CGAL::Three::Viewer_interface*) const;
|
||||||
|
bool printFaceIds(CGAL::Three::Viewer_interface*) const;
|
||||||
|
void printAllIds(CGAL::Three::Viewer_interface*);
|
||||||
|
bool testDisplayId(double, double, double, CGAL::Three::Viewer_interface*)const;
|
||||||
|
bool shouldDisplayIds(CGAL::Three::Scene_item *current_item) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void init(Scene_face_graph_item* poly_item, QMainWindow* mw);
|
void init(Scene_face_graph_item* poly_item, QMainWindow* mw);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
#include <CGAL/Three/TextRenderer.h>
|
#include <CGAL/Three/TextRenderer.h>
|
||||||
#include <CGAL/Three/Scene_item.h>
|
#include <CGAL/Three/Scene_item.h>
|
||||||
|
#include <CGAL/Three/Scene_print_item_interface.h>
|
||||||
|
#include "Scene_polyhedron_selection_item.h"
|
||||||
void TextRenderer::draw(CGAL::Three::Viewer_interface *viewer)
|
void TextRenderer::draw(CGAL::Three::Viewer_interface *viewer)
|
||||||
{
|
{
|
||||||
QPainter *painter = viewer->getPainter();
|
QPainter *painter = viewer->getPainter();
|
||||||
|
|
@ -9,7 +11,12 @@ void TextRenderer::draw(CGAL::Three::Viewer_interface *viewer)
|
||||||
qglviewer::Camera* camera = viewer->camera();
|
qglviewer::Camera* camera = viewer->camera();
|
||||||
//Display the items textItems
|
//Display the items textItems
|
||||||
Q_FOREACH(TextListItem* list, textItems)
|
Q_FOREACH(TextListItem* list, textItems)
|
||||||
if(list->item() == scene->item(scene->mainSelectionIndex()))
|
{
|
||||||
|
CGAL::Three::Scene_print_item_interface* item =
|
||||||
|
qobject_cast<CGAL::Three::Scene_print_item_interface*>(scene->item(scene->mainSelectionIndex()));
|
||||||
|
if( item &&
|
||||||
|
item->shouldDisplayIds(list->item())
|
||||||
|
)
|
||||||
Q_FOREACH(TextItem* item, list->textList())
|
Q_FOREACH(TextItem* item, list->textList())
|
||||||
{
|
{
|
||||||
qglviewer::Vec src(item->position().x(), item->position().y(),item->position().z());
|
qglviewer::Vec src(item->position().x(), item->position().y(),item->position().z());
|
||||||
|
|
@ -31,6 +38,7 @@ void TextRenderer::draw(CGAL::Three::Viewer_interface *viewer)
|
||||||
painter->drawText(rect, item->text());
|
painter->drawText(rect, item->text());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Display the local TextItems
|
//Display the local TextItems
|
||||||
Q_FOREACH(TextItem* item, local_textItems)
|
Q_FOREACH(TextItem* item, local_textItems)
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ namespace CGAL
|
||||||
{
|
{
|
||||||
namespace Three {
|
namespace Three {
|
||||||
class Viewer_interface;
|
class Viewer_interface;
|
||||||
|
class Scene_item;
|
||||||
|
|
||||||
|
|
||||||
//! An item that wants to print its primitive IDs must derive from this interface.
|
//! An item that wants to print its primitive IDs must derive from this interface.
|
||||||
|
|
@ -56,6 +57,14 @@ public:
|
||||||
//! \returns true if the Id should be displayed
|
//! \returns true if the Id should be displayed
|
||||||
//! \returns false if the Id should not be displayed (if it is hidden for example)
|
//! \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 = 0;
|
virtual bool testDisplayId(double, double, double, CGAL::Three::Viewer_interface*)const = 0;
|
||||||
|
|
||||||
|
//! \brief Tests if this item should display its ids.
|
||||||
|
//!
|
||||||
|
//! The default behavior is to only display ids of the currently selected item (\see mainSelectionIndex()).
|
||||||
|
//! This function allows to override this behavior.
|
||||||
|
//! @param tets_item the currently tested TextListItem.
|
||||||
|
//! \return true if this item should display its ids when `test_item` is tested.
|
||||||
|
virtual bool shouldDisplayIds(CGAL::Three::Scene_item* test_item)const = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue