Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sauvage
CGoGN
Commits
dc1e629f
Commit
dc1e629f
authored
May 03, 2011
by
Pierre Kraemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QTgl -> ajout evenement mouseClick
parent
eeaa15ab
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
47 deletions
+69
-47
include/Utils/qtSimple.h
include/Utils/qtSimple.h
+6
-1
include/Utils/qtgl.h
include/Utils/qtgl.h
+10
-6
src/Utils/qtgl.cpp
src/Utils/qtgl.cpp
+53
-40
No files found.
include/Utils/qtSimple.h
View file @
dc1e629f
...
...
@@ -272,10 +272,15 @@ public:
*/
virtual
void
cb_mouseRelease
(
int
button
,
int
x
,
int
y
)
{}
/**
* Mouse button has been clicked
*/
virtual
void
cb_mouseClick
(
int
button
,
int
x
,
int
y
)
{}
/**
* the mouse has been move (with button still pressed)
*/
virtual
void
cb_mouseMove
(
int
x
,
int
y
)
{}
virtual
void
cb_mouseMove
(
int
button
,
int
x
,
int
y
)
{}
/**
* key press CB (context is ok)
...
...
include/Utils/qtgl.h
View file @
dc1e629f
...
...
@@ -69,6 +69,7 @@ protected:
std
::
stack
<
glm
::
mat4
>
m_stack_mv
;
int
m_current_button
;
QPoint
clickPoint
;
int
beginx
;
int
beginy
;
int
newModel
;
...
...
@@ -100,17 +101,20 @@ public:
void
resizeGL
(
int
width
,
int
height
);
void
mousePressEvent
(
QMouseEvent
*
event
);
public:
void
mousePressEvent
(
QMouseEvent
*
event
);
void
mouseReleaseEvent
(
QMouseEvent
*
event
);
void
mouse
ReleaseEvent
(
QMouseEvent
*
event
);
void
mouse
ClickEvent
(
QMouseEvent
*
event
);
void
mouseMoveEvent
(
QMouseEvent
*
event
);
void
mouseMoveEvent
(
QMouseEvent
*
event
);
void
keyPressEvent
(
QKeyEvent
*
event
);
void
keyPressEvent
(
QKeyEvent
*
event
);
void
keyReleaseEvent
(
QKeyEvent
*
event
);
void
keyReleaseEvent
(
QKeyEvent
*
event
);
void
wheelEvent
(
QWheelEvent
*
event
);
void
wheelEvent
(
QWheelEvent
*
event
);
bool
Shift
()
{
return
m_state_modifier
&
Qt
::
ShiftModifier
;
}
...
...
src/Utils/qtgl.cpp
View file @
dc1e629f
...
...
@@ -148,63 +148,76 @@ void GLWidget::mousePressEvent(QMouseEvent* event)
{
beginx
=
event
->
x
();
beginy
=
event
->
y
();
clickPoint
=
event
->
pos
();
m_current_button
=
event
->
button
();
if
(
m_cbs
)
m_cbs
->
cb_mousePress
(
event
->
button
(),
event
->
x
(),
event
->
y
());
m_cbs
->
cb_mousePress
(
event
->
button
(),
event
->
x
(),
getHeight
()
-
event
->
y
());
}
void
GLWidget
::
mouseReleaseEvent
(
QMouseEvent
*
event
)
{
if
(
m_cbs
)
m_cbs
->
cb_mouseRelease
(
event
->
button
(),
event
->
x
(),
event
->
y
());
m_cbs
->
cb_mouseRelease
(
event
->
button
(),
event
->
x
(),
getHeight
()
-
event
->
y
());
if
(
event
->
pos
()
==
clickPoint
)
mouseClickEvent
(
event
)
;
}
void
GLWidget
::
mouse
Move
Event
(
QMouseEvent
*
event
)
void
GLWidget
::
mouse
Click
Event
(
QMouseEvent
*
event
)
{
int
x
=
event
->
x
();
int
y
=
event
->
y
();
if
(
m_cbs
)
m_cbs
->
cb_mouseClick
(
event
->
button
(),
event
->
x
(),
getHeight
()
-
event
->
y
());
}
switch
(
m_current_button
)
void
GLWidget
::
mouseMoveEvent
(
QMouseEvent
*
event
)
{
if
(
m_state_modifier
==
Qt
::
NoModifier
)
{
case
Qt
::
RightButton
:
{
float
wl
;
if
(
m_cbs
->
trans_z
()
>
-
20.0
f
)
wl
=
20.0
f
/
foc
;
else
wl
=
-
2.0
f
*
m_cbs
->
trans_z
()
/
foc
;
m_cbs
->
trans_x
()
+=
wl
/
W
*
(
x
-
beginx
);
m_cbs
->
trans_y
()
+=
wl
/
H
*
(
beginy
-
y
);
}
break
;
case
Qt
::
MidButton
:
{
float
wl
=
-
0.5
f
*
FAR_PLANE
/
foc
;
m_cbs
->
trans_z
()
-=
wl
/
W
*
(
x
-
beginx
);
m_cbs
->
trans_z
()
-=
wl
/
H
*
(
y
-
beginy
);
}
break
;
case
Qt
::
LeftButton
:
int
x
=
event
->
x
();
int
y
=
event
->
y
();
switch
(
m_current_button
)
{
trackball
(
m_cbs
->
lastquat
(),
(
2.0
f
*
beginx
-
W
)
/
W
,
(
H
-
2.0
f
*
beginy
)
/
H
,
(
2.0
f
*
x
-
W
)
/
W
,(
H
-
2.0
f
*
y
)
/
H
);
add_quats
(
m_cbs
->
lastquat
(),
m_cbs
->
curquat
(),
m_cbs
->
curquat
());
case
Qt
::
RightButton
:
{
float
wl
;
if
(
m_cbs
->
trans_z
()
>
-
20.0
f
)
wl
=
20.0
f
/
foc
;
else
wl
=
-
2.0
f
*
m_cbs
->
trans_z
()
/
foc
;
m_cbs
->
trans_x
()
+=
wl
/
W
*
(
x
-
beginx
);
m_cbs
->
trans_y
()
+=
wl
/
H
*
(
beginy
-
y
);
}
break
;
case
Qt
::
MidButton
:
{
float
wl
=
-
0.5
f
*
FAR_PLANE
/
foc
;
m_cbs
->
trans_z
()
-=
wl
/
W
*
(
x
-
beginx
);
m_cbs
->
trans_z
()
-=
wl
/
H
*
(
y
-
beginy
);
}
break
;
case
Qt
::
LeftButton
:
{
trackball
(
m_cbs
->
lastquat
(),
(
2.0
f
*
beginx
-
W
)
/
W
,
(
H
-
2.0
f
*
beginy
)
/
H
,
(
2.0
f
*
x
-
W
)
/
W
,(
H
-
2.0
f
*
y
)
/
H
);
add_quats
(
m_cbs
->
lastquat
(),
m_cbs
->
curquat
(),
m_cbs
->
curquat
());
}
break
;
}
break
;
}
beginx
=
x
;
beginy
=
y
;
newModel
=
1
;
updateGL
();
beginx
=
x
;
beginy
=
y
;
newModel
=
1
;
updateGL
();
}
if
(
m_cbs
)
m_cbs
->
cb_mouseMove
(
event
->
x
(),
event
->
y
());
m_cbs
->
cb_mouseMove
(
event
->
button
(),
event
->
x
(),
getHeight
()
-
event
->
y
());
}
void
GLWidget
::
wheelEvent
(
QWheelEvent
*
event
)
...
...
@@ -245,7 +258,7 @@ void GLWidget::keyReleaseEvent(QKeyEvent *event)
int
k
=
event
->
key
();
if
(
(
k
>=
65
)
&&
(
k
<=
91
)
&&
(
event
->
modifiers
()
!=
Qt
::
ShiftModifier
)
)
k
+=
32
;
k
+=
32
;
if
(
m_cbs
)
m_cbs
->
cb_keyRelease
(
k
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment