mirror of https://github.com/CGAL/cgal
Merge pull request #560 from maxGimeno/Polyhedron_demo-scroll_sceneview-GF
Scrolls the sceneView when a picking is performed.
This commit is contained in:
commit
b4315f4232
|
|
@ -194,6 +194,9 @@ MainWindow::MainWindow(QWidget* parent)
|
||||||
connect(scene, SIGNAL(selectionChanged(int)),
|
connect(scene, SIGNAL(selectionChanged(int)),
|
||||||
this, SLOT(selectSceneItem(int)));
|
this, SLOT(selectSceneItem(int)));
|
||||||
|
|
||||||
|
connect(scene, SIGNAL(itemPicked(const QModelIndex &)),
|
||||||
|
this, SLOT(recenterSceneView(const QModelIndex &)));
|
||||||
|
|
||||||
connect(sceneView->selectionModel(),
|
connect(sceneView->selectionModel(),
|
||||||
SIGNAL(selectionChanged ( const QItemSelection & , const QItemSelection & ) ),
|
SIGNAL(selectionChanged ( const QItemSelection & , const QItemSelection & ) ),
|
||||||
this, SLOT(updateInfo()));
|
this, SLOT(updateInfo()));
|
||||||
|
|
@ -1736,3 +1739,14 @@ void MainWindow::on_downButton_pressed()
|
||||||
{
|
{
|
||||||
scene->moveRowDown();
|
scene->moveRowDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::recenterSceneView(const QModelIndex &id)
|
||||||
|
{
|
||||||
|
if(id.isValid())
|
||||||
|
{
|
||||||
|
// mapFromSource is necessary to convert the QModelIndex received
|
||||||
|
// from the Scene into a valid QModelIndex in the view, beacuse of
|
||||||
|
// the proxymodel
|
||||||
|
sceneView->scrollTo(proxyModel->mapFromSource(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
class Scene;
|
class Scene;
|
||||||
class Viewer;
|
class Viewer;
|
||||||
class QTreeView;
|
class QTreeView;
|
||||||
|
|
@ -212,6 +211,9 @@ protected Q_SLOTS:
|
||||||
* frame of the viewer to the new selected item's and calls updateGL().
|
* frame of the viewer to the new selected item's and calls updateGL().
|
||||||
*/
|
*/
|
||||||
void selectionChanged();
|
void selectionChanged();
|
||||||
|
//! Scrolls to the new selected item.
|
||||||
|
void recenterSceneView(const QModelIndex &id);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Invoques a context menu for the currently selected item at the requested
|
* Invoques a context menu for the currently selected item at the requested
|
||||||
* position.
|
* position.
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ Scene::Scene(QObject* parent)
|
||||||
if(ms_splatting==0)
|
if(ms_splatting==0)
|
||||||
ms_splatting = new GlSplat::SplatRenderer();
|
ms_splatting = new GlSplat::SplatRenderer();
|
||||||
ms_splattingCounter++;
|
ms_splattingCounter++;
|
||||||
|
picked = false;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -480,6 +481,15 @@ glDepthFunc(GL_LEQUAL);
|
||||||
ms_splatting->finalize();
|
ms_splatting->finalize();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//scrolls the sceneView to the selected item's line.
|
||||||
|
if(picked)
|
||||||
|
Q_EMIT(itemPicked(index_map.key(mainSelectionIndex())));
|
||||||
|
if(with_names)
|
||||||
|
picked = true;
|
||||||
|
else
|
||||||
|
picked = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// workaround for Qt-4.2 (see above)
|
// workaround for Qt-4.2 (see above)
|
||||||
|
|
|
||||||
|
|
@ -235,6 +235,7 @@ public Q_SLOTS:
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
//generated automatically by moc
|
//generated automatically by moc
|
||||||
|
void itemPicked(const QModelIndex &);
|
||||||
void newItem(int);
|
void newItem(int);
|
||||||
void updated_bbox();
|
void updated_bbox();
|
||||||
void updated();
|
void updated();
|
||||||
|
|
@ -272,6 +273,7 @@ private:
|
||||||
int item_A;
|
int item_A;
|
||||||
//!Index of the item_B.
|
//!Index of the item_B.
|
||||||
int item_B;
|
int item_B;
|
||||||
|
bool picked;
|
||||||
static GlSplat::SplatRenderer* ms_splatting;
|
static GlSplat::SplatRenderer* ms_splatting;
|
||||||
static int ms_splattingCounter;
|
static int ms_splattingCounter;
|
||||||
QMap<QModelIndex, int> index_map;
|
QMap<QModelIndex, int> index_map;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue