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<ClickBindingPrivate, qglviewer::ClickAction> clickBinding_;
|
||||
::Qt::Key currentlyPressedKey_;
|
||||
|
||||
// S t a t e F i l e
|
||||
QString stateFileName_;
|
||||
|
||||
|
|
@ -1212,6 +1211,9 @@ protected:
|
|||
bool is_sharing;
|
||||
bool is_linked;
|
||||
QOpenGLContext* shared_context;
|
||||
// Zoom
|
||||
bool _first_tick;
|
||||
|
||||
public:
|
||||
//! Is used to know if the openGL context is 4.3 or ES 2.0.
|
||||
//! @returns `true` if the context is 4.3.
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ void CGAL::QGLViewer::defaultConstructor() {
|
|||
|
||||
CGAL::QGLViewer::QGLViewerPool().append(this);
|
||||
camera_ = new qglviewer::Camera(this);
|
||||
setCamera(camera());
|
||||
setCamera(camera_);
|
||||
|
||||
setDefaultShortcuts();
|
||||
setDefaultMouseBindings();
|
||||
|
|
@ -155,6 +155,7 @@ void CGAL::QGLViewer::defaultConstructor() {
|
|||
is_sharing = false;
|
||||
is_linked = false;
|
||||
shared_context = nullptr;
|
||||
_first_tick = true;
|
||||
}
|
||||
|
||||
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...) */
|
||||
CGAL_INLINE_FUNCTION
|
||||
void CGAL::QGLViewer::paintGL() {
|
||||
makeCurrent();
|
||||
// Clears screen, set model view matrix...
|
||||
preDraw();
|
||||
// Used defined method. Default calls draw()
|
||||
|
|
@ -529,6 +531,7 @@ void CGAL::QGLViewer::paintGL() {
|
|||
draw();
|
||||
// Add visual hints: axis, camera, grid...
|
||||
postDraw();
|
||||
doneCurrent();
|
||||
Q_EMIT drawFinished(true);
|
||||
}
|
||||
|
||||
|
|
@ -624,7 +627,7 @@ void CGAL::QGLViewer::postDraw() {
|
|||
painter.end();
|
||||
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# mouseString() concatenates bindings description in inverse
|
||||
// order.
|
||||
makeCurrent();
|
||||
ClickBindingPrivate cbp(e->modifiers(), e->button(), false,
|
||||
(::Qt::MouseButtons)(e->buttons() & ~(e->button())),
|
||||
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()). */
|
||||
CGAL_INLINE_FUNCTION
|
||||
void CGAL::QGLViewer::wheelEvent(QWheelEvent *e) {
|
||||
makeCurrent();
|
||||
if (mouseGrabber()) {
|
||||
if (mouseGrabberIsAManipulatedFrame_) {
|
||||
for (QMap<WheelBindingPrivate, MouseActionPrivate>::ConstIterator
|
||||
|
|
@ -1536,6 +1541,17 @@ void CGAL::QGLViewer::wheelEvent(QWheelEvent *e) {
|
|||
MouseActionPrivate map = wheelBinding_[wbp];
|
||||
switch (map.handler) {
|
||||
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()->wheelEvent(e, camera());
|
||||
break;
|
||||
|
|
@ -2255,8 +2271,11 @@ void CGAL::QGLViewer::keyPressEvent(QKeyEvent *e) {
|
|||
|
||||
const ::Qt::Key key = ::Qt::Key(e->key());
|
||||
|
||||
if(key == ::Qt::Key_Z && ! e->isAutoRepeat())
|
||||
{
|
||||
_first_tick = true;
|
||||
}
|
||||
const ::Qt::KeyboardModifiers modifiers = e->modifiers();
|
||||
|
||||
QMap<qglviewer::KeyboardAction, unsigned int>::ConstIterator it = keyboardBinding_
|
||||
.begin(),
|
||||
end =
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ void draw(const CGAL_POLY_TYPE& apoly,
|
|||
|
||||
if (!cgal_test_suite)
|
||||
{
|
||||
int argc=1;
|
||||
const char* argv[2]={"polyhedron_viewer","\0"};
|
||||
int argc=2;
|
||||
const char* argv[2]={"polyhedron_viewer","--old"};
|
||||
QApplication app(argc,const_cast<char**>(argv));
|
||||
SimpleFaceGraphViewerQt
|
||||
mainwindow(app.activeWindow(), apoly, title, nofill);
|
||||
|
|
|
|||
Loading…
Reference in New Issue