mirror of https://github.com/CGAL/cgal
Merge pull request #4949 from maxGimeno/Demo-Fixes-maxGimeno
Polyhedron demo: Fixes
This commit is contained in:
commit
6aefea87b9
|
|
@ -1323,6 +1323,8 @@ void MainWindow::selectSceneItem(int i)
|
|||
else {
|
||||
QItemSelection s =
|
||||
proxyModel->mapSelectionFromSource(scene->createSelection(i));
|
||||
if(s.empty())
|
||||
return;
|
||||
QModelIndex mi = proxyModel->mapFromSource(scene->getModelIndexFromId(i).first());
|
||||
sceneView->setCurrentIndex(mi);
|
||||
sceneView->selectionModel()->select(s,
|
||||
|
|
@ -1347,7 +1349,8 @@ void MainWindow::selectSceneItems(QList<int> is)
|
|||
sceneView->setCurrentIndex(i);
|
||||
sceneView->selectionModel()->select(s,
|
||||
QItemSelectionModel::ClearAndSelect);
|
||||
sceneView->scrollTo(s.indexes().first());
|
||||
if(!s.empty())
|
||||
sceneView->scrollTo(s.indexes().first());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1392,10 +1395,7 @@ void MainWindow::removeSceneItemFromSelection(int i)
|
|||
|
||||
void MainWindow::selectAll()
|
||||
{
|
||||
QItemSelection s =
|
||||
proxyModel->mapSelectionFromSource(scene->createSelectionAll());
|
||||
sceneView->selectionModel()->select(s,
|
||||
QItemSelectionModel::ClearAndSelect);
|
||||
sceneView->selectAll();
|
||||
}
|
||||
|
||||
int MainWindow::getSelectedSceneItemIndex() const
|
||||
|
|
@ -1789,12 +1789,12 @@ void MainWindow::updateInfo() {
|
|||
CGAL::Bbox_3 bbox = item->bbox();
|
||||
if(bbox !=CGAL::Bbox_3())
|
||||
item_text += QString("<div>Bounding box: min (%1,%2,%3), max (%4,%5,%6)</div>")
|
||||
.arg(bbox.xmin())
|
||||
.arg(bbox.ymin())
|
||||
.arg(bbox.zmin())
|
||||
.arg(bbox.xmax())
|
||||
.arg(bbox.ymax())
|
||||
.arg(bbox.zmax());
|
||||
.arg(bbox.xmin(),0, 'g', 17)
|
||||
.arg(bbox.ymin(),0, 'g', 17)
|
||||
.arg(bbox.zmin(),0, 'g', 17)
|
||||
.arg(bbox.xmax(),0, 'g', 17)
|
||||
.arg(bbox.ymax(),0, 'g', 17)
|
||||
.arg(bbox.zmax(),0, 'g', 17);
|
||||
if(!item_filename.isEmpty()) {
|
||||
item_text += QString("<div>File:<i> %1</div>").arg(item_filename);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -450,7 +450,7 @@ void Polyhedron_demo_affine_transform_plugin::grid()
|
|||
Kernel::Aff_transformation_3 trans(CGAL::TRANSLATION, Kernel::Vector_3(i*x_t,j*y_t,k*z_t));
|
||||
CGAL::Polygon_mesh_processing::transform(trans, e);
|
||||
Facegraph_item* t_item = new Facegraph_item(e);
|
||||
t_item->setName(tr("%1 %2%3%4")
|
||||
t_item->setName(tr("%1 %2,%3,%4")
|
||||
.arg(item->name())
|
||||
.arg(i)
|
||||
.arg(j)
|
||||
|
|
|
|||
|
|
@ -704,7 +704,22 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer)
|
|||
Q_FOREACH(Item_id id, children)
|
||||
{
|
||||
Scene_item* item = m_entries[id];
|
||||
if(item->alpha() == 1.0f)
|
||||
Scene_group_item* group = qobject_cast<Scene_group_item*>(item);
|
||||
bool is_transparent=false;
|
||||
if(item->alpha() != 1.0f)
|
||||
is_transparent = true;
|
||||
else if(group)
|
||||
{
|
||||
for(const auto& child : group->getChildren())
|
||||
{
|
||||
if(group->getChild(child)->alpha() < 1.0f)
|
||||
{
|
||||
is_transparent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!is_transparent)
|
||||
opaque_items.push_back(id);
|
||||
else
|
||||
transparent_items.push_back(id);
|
||||
|
|
@ -1200,6 +1215,8 @@ bool Scene::sort_lists(QVector<QList<int> >&sorted_lists, bool up)
|
|||
}
|
||||
void Scene::moveRowUp()
|
||||
{
|
||||
if(selectionIndices().isEmpty())
|
||||
return;
|
||||
QVector<QList<int> >sorted_lists(1);
|
||||
QList<int> to_select;
|
||||
//sort lists according to the indices of each item in its container (scene or group)
|
||||
|
|
@ -1251,6 +1268,8 @@ void Scene::moveRowUp()
|
|||
}
|
||||
void Scene::moveRowDown()
|
||||
{
|
||||
if(selectionIndices().isEmpty())
|
||||
return;
|
||||
QVector<QList<int> >sorted_lists(1);
|
||||
QList<int> to_select;
|
||||
//sort lists according to the indices of each item in its container (scene or group)
|
||||
|
|
@ -1300,7 +1319,9 @@ void Scene::moveRowDown()
|
|||
}
|
||||
}
|
||||
}
|
||||
selectionChanged(to_select);
|
||||
if(!to_select.isEmpty()){
|
||||
selectionChanged(to_select);
|
||||
}
|
||||
}
|
||||
Scene::Item_id Scene::mainSelectionIndex() const {
|
||||
return (selectionIndices().size() == 1) ? selected_item : -1;
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ public :
|
|||
alphaSlider->setMaximum(255);
|
||||
alphaSlider->setValue(255);
|
||||
}
|
||||
viewer->makeCurrent();
|
||||
//viewer->makeCurrent();
|
||||
const EPICK::Plane_3& plane = qobject_cast<Scene_c3t3_item*>(this->parent())->plane();
|
||||
float shrink_factor = qobject_cast<Scene_c3t3_item*>(this->parent())->getShrinkFactor();
|
||||
QVector4D cp = cgal_plane_to_vector4d(plane);
|
||||
|
|
|
|||
|
|
@ -546,12 +546,14 @@ Scene_polygon_soup_item::draw(CGAL::Three::Viewer_interface* viewer) const {
|
|||
|
||||
if(d->soup->fcolors.empty())
|
||||
getTriangleContainer(Priv::Flat_facets)->setColor(this->color());
|
||||
getTriangleContainer(Priv::Flat_facets)->setAlpha(alpha());
|
||||
getTriangleContainer(Priv::Flat_facets)->draw(viewer, d->soup->fcolors.empty());
|
||||
}
|
||||
else if(renderingMode() == Gouraud)
|
||||
{
|
||||
if(d->soup->vcolors.empty())
|
||||
getTriangleContainer(Priv::Smooth_facets)->setColor(this->color());
|
||||
getTriangleContainer(Priv::Smooth_facets)->setAlpha(alpha());
|
||||
getTriangleContainer(Priv::Smooth_facets)->draw(viewer, d->soup->vcolors.empty());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2610,3 +2610,17 @@ CGAL::Three::Scene_item::Header_data Scene_polyhedron_selection_item::header() c
|
|||
data.titles.append(QString("Average"));
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
void Scene_polyhedron_selection_item::updateDisplayedIds(QEvent* e)
|
||||
{
|
||||
if(e->type() == QEvent::MouseButtonRelease )
|
||||
{
|
||||
QMouseEvent* mouse_event = static_cast<QMouseEvent*>(e);
|
||||
if((mouse_event->button() == Qt::RightButton || mouse_event->button() == Qt::MiddleButton)
|
||||
&& temp_selected_vertices.size() == 1) {
|
||||
fg_vertex_descriptor vh = *temp_selected_vertices.begin();
|
||||
poly_item->updateIds(vh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -799,6 +799,7 @@ public:
|
|||
}
|
||||
|
||||
void selection_changed(bool);
|
||||
void updateDisplayedIds(QEvent *e);
|
||||
|
||||
Q_SIGNALS:
|
||||
void updateInstructions(QString);
|
||||
|
|
@ -875,6 +876,8 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
updateDisplayedIds(gen_event);
|
||||
|
||||
if(!visible() || !k_ring_selector.state.shift_pressing) { return false; }
|
||||
if(gen_event->type() == QEvent::Wheel)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -136,6 +136,7 @@ struct Scene_surface_mesh_item_priv{
|
|||
<< GouraudPlusEdges
|
||||
<< Points;
|
||||
item->setProperty("classname", QString("surface_mesh"));
|
||||
ids_need_update = false;
|
||||
}
|
||||
|
||||
Scene_surface_mesh_item_priv(SMesh* sm, Scene_surface_mesh_item *parent):
|
||||
|
|
@ -168,7 +169,8 @@ struct Scene_surface_mesh_item_priv{
|
|||
<< Gouraud
|
||||
<< GouraudPlusEdges
|
||||
<< Points;
|
||||
item->setProperty("classname", QString("surface_mesh"));
|
||||
item->setProperty("classname", QString("surface_mesh"));\
|
||||
ids_need_update = false;
|
||||
}
|
||||
|
||||
~Scene_surface_mesh_item_priv()
|
||||
|
|
@ -224,7 +226,6 @@ struct Scene_surface_mesh_item_priv{
|
|||
mutable bool edges_displayed;
|
||||
mutable bool faces_displayed;
|
||||
mutable bool all_displayed;
|
||||
mutable QList<double> text_ids;
|
||||
mutable std::vector<TextItem*> targeted_id;
|
||||
|
||||
std::string comments;
|
||||
|
|
@ -239,7 +240,6 @@ struct Scene_surface_mesh_item_priv{
|
|||
mutable bool isinit;
|
||||
mutable std::vector<unsigned int> idx_data_;
|
||||
mutable std::size_t idx_data_size;
|
||||
mutable std::map<unsigned int, unsigned int> current_indices; //map im values to ghosts-free values
|
||||
mutable std::vector<unsigned int> idx_edge_data_;
|
||||
mutable std::size_t idx_edge_data_size;
|
||||
mutable std::vector<unsigned int> idx_feature_edge_data_;
|
||||
|
|
@ -267,6 +267,7 @@ struct Scene_surface_mesh_item_priv{
|
|||
bool has_nm_vertices;
|
||||
int genus;
|
||||
bool self_intersect;
|
||||
bool ids_need_update;
|
||||
mutable QSlider* alphaSlider;
|
||||
QList<RenderingMode> supported_rendering_modes;
|
||||
};
|
||||
|
|
@ -2017,6 +2018,7 @@ void Scene_surface_mesh_item_priv::fillTargetedIds(const face_descriptor &select
|
|||
CGAL::Three::Viewer_interface *viewer,
|
||||
const CGAL::qglviewer::Vec& offset)
|
||||
{
|
||||
all_displayed = false;
|
||||
compute_displayed_ids(*smesh_,
|
||||
viewer,
|
||||
selected_fh,
|
||||
|
|
@ -2368,9 +2370,31 @@ void Scene_surface_mesh_item::updateVertex(vertex_descriptor vh)
|
|||
getTriangleContainer(0)->getVbo(Tri::Smooth_normals),
|
||||
new_point,id);
|
||||
}
|
||||
d->ids_need_update = true;
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
|
||||
void Scene_surface_mesh_item::updateIds(vertex_descriptor vh)
|
||||
{
|
||||
if(d->ids_need_update &&
|
||||
(d->faces_displayed || d->vertices_displayed || d->edges_displayed))
|
||||
{
|
||||
invalidate_aabb_tree();
|
||||
|
||||
if(d->all_displayed)
|
||||
{
|
||||
d->killIds();
|
||||
d->all_displayed = true;
|
||||
::printVertexIds(*d->smesh_, d->textVItems);
|
||||
}
|
||||
else
|
||||
{
|
||||
d->fillTargetedIds(face(halfedge(vh, *d->smesh_), *d->smesh_),
|
||||
face_graph()->point(vh), CGAL::Three::Three::mainViewer(), CGAL::Three::Three::mainViewer()->offset());
|
||||
}
|
||||
d->ids_need_update = false;
|
||||
}
|
||||
invalidate_aabb_tree();
|
||||
redraw();
|
||||
}
|
||||
|
||||
void Scene_surface_mesh_item::switchToGouraudPlusEdge(bool b)
|
||||
|
|
|
|||
|
|
@ -156,6 +156,7 @@ public:
|
|||
void computeElements() const Q_DECL_OVERRIDE;
|
||||
void initializeBuffers(CGAL::Three::Viewer_interface*)const Q_DECL_OVERRIDE;
|
||||
void updateVertex(vertex_descriptor vh);
|
||||
void updateIds(vertex_descriptor vh);
|
||||
void switchToGouraudPlusEdge(bool b); //replace flatPlusEdge by gouraudPlusEdge and ban Flat.
|
||||
Q_SIGNALS:
|
||||
void item_is_about_to_be_changed();
|
||||
|
|
|
|||
|
|
@ -408,6 +408,7 @@ Viewer::~Viewer()
|
|||
.arg(d->back_color.greenF())
|
||||
.arg(d->back_color.blueF()));
|
||||
|
||||
d->vao.destroy();
|
||||
if(d->_recentFunctions)
|
||||
delete d->_recentFunctions;
|
||||
if(d->painter)
|
||||
|
|
@ -1559,12 +1560,18 @@ void Viewer_impl::showDistance(QPoint pixel)
|
|||
TextItem *ACoord = new TextItem(float(APoint.x),
|
||||
float(APoint.y),
|
||||
float(APoint.z),
|
||||
QString("A(%1,%2,%3)").arg(APoint.x-viewer->offset().x).arg(APoint.y-viewer->offset().y).arg(APoint.z-viewer->offset().z), true, font, Qt::red, true);
|
||||
QString("A(%1,%2,%3)")
|
||||
.arg(APoint.x-viewer->offset().x, 0, 'g', 10)
|
||||
.arg(APoint.y-viewer->offset().y, 0, 'g', 10)
|
||||
.arg(APoint.z-viewer->offset().z, 0, 'g', 10), true, font, Qt::red, true);
|
||||
distance_text.append(ACoord);
|
||||
TextItem *BCoord = new TextItem(float(BPoint.x),
|
||||
float(BPoint.y),
|
||||
float(BPoint.z),
|
||||
QString("B(%1,%2,%3)").arg(BPoint.x-viewer->offset().x).arg(BPoint.y-viewer->offset().y).arg(BPoint.z-viewer->offset().z), true, font, Qt::red, true);
|
||||
QString("B(%1,%2,%3)")
|
||||
.arg(BPoint.x-viewer->offset().x, 0, 'g', 10)
|
||||
.arg(BPoint.y-viewer->offset().y, 0, 'g', 10)
|
||||
.arg(BPoint.z-viewer->offset().z, 0, 'g', 10), true, font, Qt::red, true);
|
||||
distance_text.append(BCoord);
|
||||
CGAL::qglviewer::Vec centerPoint = 0.5*(BPoint+APoint);
|
||||
TextItem *centerCoord = new TextItem(float(centerPoint.x),
|
||||
|
|
@ -1582,7 +1589,7 @@ void Viewer_impl::showDistance(QPoint pixel)
|
|||
.arg(BPoint.x-viewer->offset().x)
|
||||
.arg(BPoint.y-viewer->offset().y)
|
||||
.arg(BPoint.z-viewer->offset().z)
|
||||
.arg(dist)));
|
||||
.arg(dist, 0, 'g', 10)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
#include <CGAL/license/Three.h>
|
||||
|
||||
#include <QPoint>
|
||||
#include <QVector3D>
|
||||
class QKeyEvent;
|
||||
class QPoint;
|
||||
namespace CGAL
|
||||
|
|
|
|||
Loading…
Reference in New Issue