mirror of https://github.com/CGAL/cgal
Merge pull request #5107 from maxGimeno/Demo-Optical_zoom_to_pointer-maxGimeno
GraphicsView: Zoom enhancement
This commit is contained in:
commit
9db83004d5
|
|
@ -1167,7 +1167,6 @@ protected:
|
||||||
QMap<WheelBindingPrivate, MouseActionPrivate> wheelBinding_;
|
QMap<WheelBindingPrivate, MouseActionPrivate> wheelBinding_;
|
||||||
QMap<ClickBindingPrivate, qglviewer::ClickAction> clickBinding_;
|
QMap<ClickBindingPrivate, qglviewer::ClickAction> clickBinding_;
|
||||||
::Qt::Key currentlyPressedKey_;
|
::Qt::Key currentlyPressedKey_;
|
||||||
|
|
||||||
// S t a t e F i l e
|
// S t a t e F i l e
|
||||||
QString stateFileName_;
|
QString stateFileName_;
|
||||||
|
|
||||||
|
|
@ -1212,6 +1211,9 @@ protected:
|
||||||
bool is_sharing;
|
bool is_sharing;
|
||||||
bool is_linked;
|
bool is_linked;
|
||||||
QOpenGLContext* shared_context;
|
QOpenGLContext* shared_context;
|
||||||
|
// Zoom
|
||||||
|
bool _first_tick;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Is used to know if the openGL context is 4.3 or ES 2.0.
|
//! Is used to know if the openGL context is 4.3 or ES 2.0.
|
||||||
//! @returns `true` if the context is 4.3.
|
//! @returns `true` if the context is 4.3.
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ void CGAL::QGLViewer::defaultConstructor() {
|
||||||
|
|
||||||
CGAL::QGLViewer::QGLViewerPool().append(this);
|
CGAL::QGLViewer::QGLViewerPool().append(this);
|
||||||
camera_ = new qglviewer::Camera(this);
|
camera_ = new qglviewer::Camera(this);
|
||||||
setCamera(camera());
|
setCamera(camera_);
|
||||||
|
|
||||||
setDefaultShortcuts();
|
setDefaultShortcuts();
|
||||||
setDefaultMouseBindings();
|
setDefaultMouseBindings();
|
||||||
|
|
@ -155,6 +155,7 @@ void CGAL::QGLViewer::defaultConstructor() {
|
||||||
is_sharing = false;
|
is_sharing = false;
|
||||||
is_linked = false;
|
is_linked = false;
|
||||||
shared_context = nullptr;
|
shared_context = nullptr;
|
||||||
|
_first_tick = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGAL_INLINE_FUNCTION
|
CGAL_INLINE_FUNCTION
|
||||||
|
|
@ -520,6 +521,7 @@ camera is manipulated) : main drawing method. Should be overloaded. \arg
|
||||||
postDraw() : display of visual hints (world axis, FPS...) */
|
postDraw() : display of visual hints (world axis, FPS...) */
|
||||||
CGAL_INLINE_FUNCTION
|
CGAL_INLINE_FUNCTION
|
||||||
void CGAL::QGLViewer::paintGL() {
|
void CGAL::QGLViewer::paintGL() {
|
||||||
|
makeCurrent();
|
||||||
// Clears screen, set model view matrix...
|
// Clears screen, set model view matrix...
|
||||||
preDraw();
|
preDraw();
|
||||||
// Used defined method. Default calls draw()
|
// Used defined method. Default calls draw()
|
||||||
|
|
@ -529,6 +531,7 @@ void CGAL::QGLViewer::paintGL() {
|
||||||
draw();
|
draw();
|
||||||
// Add visual hints: axis, camera, grid...
|
// Add visual hints: axis, camera, grid...
|
||||||
postDraw();
|
postDraw();
|
||||||
|
doneCurrent();
|
||||||
Q_EMIT drawFinished(true);
|
Q_EMIT drawFinished(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -624,7 +627,7 @@ void CGAL::QGLViewer::postDraw() {
|
||||||
painter.end();
|
painter.end();
|
||||||
camera()->frame()->action_= qglviewer::NO_MOUSE_ACTION;
|
camera()->frame()->action_= qglviewer::NO_MOUSE_ACTION;
|
||||||
}
|
}
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1323,6 +1326,7 @@ void CGAL::QGLViewer::mousePressEvent(QMouseEvent *e) {
|
||||||
//#CONNECTION# mouseDoubleClickEvent has the same structure
|
//#CONNECTION# mouseDoubleClickEvent has the same structure
|
||||||
//#CONNECTION# mouseString() concatenates bindings description in inverse
|
//#CONNECTION# mouseString() concatenates bindings description in inverse
|
||||||
// order.
|
// order.
|
||||||
|
makeCurrent();
|
||||||
ClickBindingPrivate cbp(e->modifiers(), e->button(), false,
|
ClickBindingPrivate cbp(e->modifiers(), e->button(), false,
|
||||||
(::Qt::MouseButtons)(e->buttons() & ~(e->button())),
|
(::Qt::MouseButtons)(e->buttons() & ~(e->button())),
|
||||||
currentlyPressedKey_);
|
currentlyPressedKey_);
|
||||||
|
|
@ -1506,6 +1510,7 @@ If defined, the wheel event is sent to the mouseGrabber(). It is otherwise sent
|
||||||
according to wheel bindings (see setWheelBinding()). */
|
according to wheel bindings (see setWheelBinding()). */
|
||||||
CGAL_INLINE_FUNCTION
|
CGAL_INLINE_FUNCTION
|
||||||
void CGAL::QGLViewer::wheelEvent(QWheelEvent *e) {
|
void CGAL::QGLViewer::wheelEvent(QWheelEvent *e) {
|
||||||
|
makeCurrent();
|
||||||
if (mouseGrabber()) {
|
if (mouseGrabber()) {
|
||||||
if (mouseGrabberIsAManipulatedFrame_) {
|
if (mouseGrabberIsAManipulatedFrame_) {
|
||||||
for (QMap<WheelBindingPrivate, MouseActionPrivate>::ConstIterator
|
for (QMap<WheelBindingPrivate, MouseActionPrivate>::ConstIterator
|
||||||
|
|
@ -1536,6 +1541,17 @@ void CGAL::QGLViewer::wheelEvent(QWheelEvent *e) {
|
||||||
MouseActionPrivate map = wheelBinding_[wbp];
|
MouseActionPrivate map = wheelBinding_[wbp];
|
||||||
switch (map.handler) {
|
switch (map.handler) {
|
||||||
case qglviewer::CAMERA:
|
case qglviewer::CAMERA:
|
||||||
|
if(currentlyPressedKey_ == ::Qt::Key_Z && _first_tick)
|
||||||
|
{
|
||||||
|
_first_tick = false;
|
||||||
|
makeCurrent();
|
||||||
|
//orient camera to the cursor.
|
||||||
|
bool found = false;
|
||||||
|
qglviewer::Vec point;
|
||||||
|
point = camera()->pointUnderPixel(mapFromGlobal(QCursor::pos()), found);
|
||||||
|
if(found)
|
||||||
|
camera()->lookAt(point);
|
||||||
|
}
|
||||||
camera()->frame()->startAction(map.action, map.withConstraint);
|
camera()->frame()->startAction(map.action, map.withConstraint);
|
||||||
camera()->frame()->wheelEvent(e, camera());
|
camera()->frame()->wheelEvent(e, camera());
|
||||||
break;
|
break;
|
||||||
|
|
@ -2255,8 +2271,11 @@ void CGAL::QGLViewer::keyPressEvent(QKeyEvent *e) {
|
||||||
|
|
||||||
const ::Qt::Key key = ::Qt::Key(e->key());
|
const ::Qt::Key key = ::Qt::Key(e->key());
|
||||||
|
|
||||||
|
if(key == ::Qt::Key_Z && ! e->isAutoRepeat())
|
||||||
|
{
|
||||||
|
_first_tick = true;
|
||||||
|
}
|
||||||
const ::Qt::KeyboardModifiers modifiers = e->modifiers();
|
const ::Qt::KeyboardModifiers modifiers = e->modifiers();
|
||||||
|
|
||||||
QMap<qglviewer::KeyboardAction, unsigned int>::ConstIterator it = keyboardBinding_
|
QMap<qglviewer::KeyboardAction, unsigned int>::ConstIterator it = keyboardBinding_
|
||||||
.begin(),
|
.begin(),
|
||||||
end =
|
end =
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,8 @@ void draw(const CGAL_POLY_TYPE& apoly,
|
||||||
|
|
||||||
if (!cgal_test_suite)
|
if (!cgal_test_suite)
|
||||||
{
|
{
|
||||||
int argc=1;
|
int argc=2;
|
||||||
const char* argv[2]={"polyhedron_viewer","\0"};
|
const char* argv[2]={"polyhedron_viewer","--old"};
|
||||||
QApplication app(argc,const_cast<char**>(argv));
|
QApplication app(argc,const_cast<char**>(argv));
|
||||||
SimpleFaceGraphViewerQt
|
SimpleFaceGraphViewerQt
|
||||||
mainwindow(app.activeWindow(), apoly, title, nofill);
|
mainwindow(app.activeWindow(), apoly, title, nofill);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue