From Kristofer Tingdahl, "I and my team have gone over the code again, and we feel that we are comfortable in our current proposal for change. It goes deeper than it did before, and I explain why:
There was code in the osgViewer/Viewer.cpp and osgViewer/CompositeViewer.cpp that transformed the Y-coordinates of an event. The code in the composite viewer did however miss the touch-data of the event. I thought that it should really be the GUIEventAdapter that should know about this, and hence I added the GUIEventAdapter::setMouseYOrientationAndUpdateCoords which is re-computing the coordinates. First I simply added a boolean to the setMouseYOrientation function: setMouseYOrientation( MouseYOrientation, bool updatecooreds=false ); but then the serializer complained. This function is called from both the Viewer and the CompositeViewer. We have not tested from the viewer, but I cannot see it would not work from visual inspection. The other change is in MultiTouchTrackballManipulator::handleMultiTouchDrag. I have removed the normalisation. The reason for that is that it normalised into screen coordinates from 0,0 to 1,1. The problem with that is that if you have a pinch event and you keep the distance say 300 pixels between your fingers, these 300 pixels represent 0.20 of the screen in the horizontal domain, but 0.3 of the screen in the vertical domain. A rotation of the pinch-fingers will hence result in a zoom in, as the normalised distance is changing between them. A consequence of this is that I have changed the pan-code to use the same algorithm as the middle-mouse-pan. The rest of it is very similar from previous revision, and there has been some fine-tuning here and there. "
This commit is contained in:
@@ -602,6 +602,9 @@ public:
|
||||
/// get mouse-Y orientation (mouse-Y increases upwards or downwards).
|
||||
MouseYOrientation getMouseYOrientation() const { return _mouseYOrientation; }
|
||||
|
||||
/// set mouse-Y orientation (mouse-Y increases upwards or downwards) and recompute variables
|
||||
void setMouseYOrientationAndUpdateCoords(MouseYOrientation myo);
|
||||
|
||||
/// set current mouse button state.
|
||||
void setButtonMask(int mask) { _buttonMask = mask; }
|
||||
|
||||
|
||||
@@ -23,8 +23,10 @@
|
||||
#include <QEvent>
|
||||
#include <QQueue>
|
||||
#include <QSet>
|
||||
#include <QGLWidget>
|
||||
|
||||
class QInputEvent;
|
||||
class QGestureEvent;
|
||||
|
||||
namespace osgViewer {
|
||||
class ViewerBase;
|
||||
@@ -66,6 +68,9 @@ public:
|
||||
|
||||
inline bool getForwardKeyEvents() const { return _forwardKeyEvents; }
|
||||
virtual void setForwardKeyEvents( bool f ) { _forwardKeyEvents = f; }
|
||||
|
||||
inline bool getTouchEventsEnabled() const { return _touchEventsEnabled; }
|
||||
void setTouchEventsEnabled( bool e );
|
||||
|
||||
void setKeyboardModifiers( QInputEvent* event );
|
||||
|
||||
@@ -76,6 +81,7 @@ public:
|
||||
virtual void mouseDoubleClickEvent( QMouseEvent* event );
|
||||
virtual void mouseMoveEvent( QMouseEvent* event );
|
||||
virtual void wheelEvent( QWheelEvent* event );
|
||||
virtual bool gestureEvent( QGestureEvent* event );
|
||||
|
||||
protected:
|
||||
|
||||
@@ -109,6 +115,8 @@ protected:
|
||||
QQueue<QEvent::Type> _deferredEventQueue;
|
||||
QSet<QEvent::Type> _eventCompressor;
|
||||
|
||||
bool _touchEventsEnabled;
|
||||
|
||||
bool _forwardKeyEvents;
|
||||
qreal _devicePixelRatio;
|
||||
|
||||
@@ -157,6 +165,9 @@ public:
|
||||
virtual std::string getWindowName();
|
||||
virtual void useCursor( bool cursorOn );
|
||||
virtual void setCursor( MouseCursor cursor );
|
||||
inline bool getTouchEventsEnabled() const { return _widget->getTouchEventsEnabled(); }
|
||||
virtual void setTouchEventsEnabled( bool e ) { _widget->setTouchEventsEnabled(e); }
|
||||
|
||||
|
||||
virtual bool valid() const;
|
||||
virtual bool realizeImplementation();
|
||||
|
||||
Reference in New Issue
Block a user