Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
6214141e
Commit
6214141e
authored
14 years ago
by
Marco Biasini
Browse files
Options
Downloads
Patches
Plain Diff
added support for scene rotation by pinching
parent
f7d0f0d8
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/gui/src/gl_canvas.cc
+66
-1
66 additions, 1 deletion
modules/gui/src/gl_canvas.cc
modules/gui/src/gl_canvas.hh
+8
-1
8 additions, 1 deletion
modules/gui/src/gl_canvas.hh
with
74 additions
and
2 deletions
modules/gui/src/gl_canvas.cc
+
66
−
1
View file @
6214141e
...
...
@@ -39,6 +39,10 @@
#include
<QApplication>
#include
<QClipboard>
#include
<QMenu>
#if QT_VERSION >= 0x040600
# include <QGesture>
#endif
#include
"tools/tool_manager.hh"
namespace
ost
{
namespace
gui
{
...
...
@@ -54,7 +58,8 @@ GLCanvas::GLCanvas(GLWin* gl_win, QWidget* parent, const QGLFormat& f):
bench_flag_
(
false
),
last_pos_
(),
scene_menu_
(
NULL
),
show_beacon_
(
false
)
show_beacon_
(
false
),
angular_speed_
(
0.0
)
{
if
(
!
isValid
())
return
;
master_timer_
.
start
(
10
,
this
);
...
...
@@ -64,8 +69,52 @@ GLCanvas::GLCanvas(GLWin* gl_win, QWidget* parent, const QGLFormat& f):
this
->
setContextMenuPolicy
(
Qt
::
CustomContextMenu
);
connect
(
this
,
SIGNAL
(
customContextMenuRequested
(
const
QPoint
&
)),
this
,
SLOT
(
RequestContextMenu
(
const
QPoint
&
)));
#if QT_VERSION >= 0x040600
this
->
grabGesture
(
Qt
::
PinchGesture
);
#endif
}
bool
GLCanvas
::
event
(
QEvent
*
event
)
{
#if QT_VERSION >= 0x040600
if
(
event
->
type
()
==
QEvent
::
Gesture
)
{
return
this
->
GestureEvent
(
static_cast
<
QGestureEvent
*>
(
event
));
}
#endif
return
QGLWidget
::
event
(
event
);
}
#if QT_VERSION >= 0x040600
bool
GLCanvas
::
GestureEvent
(
QGestureEvent
*
event
)
{
if
(
QGesture
*
pinch
=
event
->
gesture
(
Qt
::
PinchGesture
))
{
QPinchGesture
*
pinch_gesture
=
static_cast
<
QPinchGesture
*>
(
pinch
);
QPinchGesture
::
ChangeFlags
changeFlags
=
pinch_gesture
->
changeFlags
();
if
(
changeFlags
&
QPinchGesture
::
RotationAngleChanged
)
{
qreal
value
=
pinch_gesture
->
rotationAngle
();
qreal
lastValue
=
pinch_gesture
->
lastRotationAngle
();
this
->
OnTransform
(
gfx
::
INPUT_COMMAND_ROTZ
,
0
,
gfx
::
TRANSFORM_VIEW
,
static_cast
<
Real
>
(
value
-
lastValue
));
this
->
update
();
event
->
accept
();
if
(
pinch_gesture
->
state
()
==
Qt
::
GestureFinished
)
{
angular_speed_
=
value
-
lastValue
;
if
(
!
gesture_timer_
.
isActive
())
gesture_timer_
.
start
(
10
,
this
);
}
return
true
;
}
}
return
false
;
}
#endif
void
GLCanvas
::
MakeActive
()
{
makeCurrent
();
...
...
@@ -425,6 +474,22 @@ Real delta_time(const timeval& t1, const timeval& t2)
void
GLCanvas
::
timerEvent
(
QTimerEvent
*
event
)
{
#if QT_VERSION>= 0x040600
// gesture support
if
(
gesture_timer_
.
timerId
()
==
event
->
timerId
())
{
if
(
angular_speed_
!=
0.0
)
{
angular_speed_
*=
0.95
;
this
->
OnTransform
(
gfx
::
INPUT_COMMAND_ROTZ
,
0
,
gfx
::
TRANSFORM_VIEW
,
static_cast
<
Real
>
(
angular_speed_
));
if
(
std
::
abs
(
angular_speed_
)
<
0.001
)
{
angular_speed_
=
0.0
;
gesture_timer_
.
stop
();
}
this
->
update
();
}
return
;
}
#endif
#ifndef _MSC_VER
static
struct
timeval
time0
,
time1
;
static
int
count
=
0
;
...
...
This diff is collapsed.
Click to expand it.
modules/gui/src/gl_canvas.hh
+
8
−
1
View file @
6214141e
...
...
@@ -83,11 +83,14 @@ protected:
virtual
void
keyReleaseEvent
(
QKeyEvent
*
event
);
virtual
void
timerEvent
(
QTimerEvent
*
event
);
virtual
void
wheelEvent
(
QWheelEvent
*
event
);
virtual
bool
event
(
QEvent
*
event
);
private
slots
:
virtual
void
RequestContextMenu
(
const
QPoint
&
pos
);
private
:
#if QT_VERSION >= 0x040600
bool
GestureEvent
(
QGestureEvent
*
event
);
#endif
bool
IsToolEvent
(
QInputEvent
*
event
)
const
;
MouseEvent
::
Buttons
TranslateButtons
(
Qt
::
MouseButtons
buttons
)
const
;
void
HandleMousePressEvent
(
QMouseEvent
*
event
);
...
...
@@ -103,6 +106,10 @@ private:
QPoint
last_pos_
;
SceneMenu
*
scene_menu_
;
bool
show_beacon_
;
float
angular_speed_
;
#if QT_VERSION>=0x04600
QBasicTimer
gesture_timer_
;
#endif
};
}}
// ns
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment