Graphviz
13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
glmotion.c
Go to the documentation of this file.
1
/*************************************************************************
2
* Copyright (c) 2011 AT&T Intellectual Property
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* https://www.eclipse.org/legal/epl-v10.html
7
*
8
* Contributors: Details at https://graphviz.org
9
*************************************************************************/
10
11
#include "
glmotion.h
"
12
#include <gtk/gtk.h>
13
#include <gdk/gdkkeysyms.h>
14
#include <gtk/gtkgl.h>
15
#include <gdk/gdkcursor.h>
16
#include "
draw.h
"
17
#include <
glcomp/glutils.h
>
18
#include "
hotkeymap.h
"
19
#include <stdint.h>
20
21
/*real zoom in out is done here, all other functions send this one what they desire, it is not guranteed,*/
22
static
void
graph_zoom
(
float
real_zoom)
23
{
24
float
old_zoom;
25
26
if
(
view
->
active_camera
==
SIZE_MAX
)
27
old_zoom =
view
->
zoom
;
28
else
29
old_zoom =
view
->
cameras
[
view
->
active_camera
]->
r
;
30
31
if
(real_zoom < view->Topview->fitin_zoom *
MAX_ZOOM
)
32
real_zoom =
view
->
Topview
->
fitin_zoom
*
MAX_ZOOM
;
33
if
(real_zoom >
view
->
Topview
->
fitin_zoom
*
MIN_ZOOM
)
34
real_zoom =
view
->
Topview
->
fitin_zoom
*
MIN_ZOOM
;
35
if
(
view
->
active_camera
==
SIZE_MAX
)
36
view
->
zoom
= real_zoom;
37
else
38
view
->
cameras
[
view
->
active_camera
]->
r
= real_zoom * -1;
39
/*adjust pan values */
40
view
->
panx
= old_zoom *
view
->
panx
/ real_zoom;
41
view
->
pany
= old_zoom *
view
->
pany
/ real_zoom;
42
}
43
44
void
glmotion_zoom_inc
(
int
zoomin)
45
{
46
if
(zoomin)
/*zooming in , zoom value should be decreased */
47
graph_zoom
(
view
->
zoom
-
view
->
zoom
* 0.25f);
48
else
49
graph_zoom
(
view
->
zoom
+
view
->
zoom
* 0.25f);
/*zoom out */
50
glexpose
();
51
52
}
53
54
void
glmotion_zoom
(
void
)
55
{
56
float
real_zoom;
57
if
(
view
->
active_camera
==
SIZE_MAX
) {
58
real_zoom =
59
view
->
zoom
+
view
->
mouse
.
dragX
/ 10 * (
view
->
zoom
* -1 / 20);
60
}
else
{
61
real_zoom =
62
(
view
->
cameras
[
view
->
active_camera
]->
r
+
63
view
->
mouse
.
dragX
/ 10 * (
view
->
cameras
[
view
->
active_camera
]->
r
/
64
20)) * -1;
65
}
66
graph_zoom
(real_zoom);
67
68
}
69
70
void
glmotion_pan
(
ViewInfo
* v)
71
{
72
float
gldx, gldy;
73
if
(v->
active_camera
==
SIZE_MAX
) {
74
gldx =
GetOGLDistance
(v->
mouse
.
dragX
) / v->
zoom
* -1;
75
gldy =
GetOGLDistance
(v->
mouse
.
dragY
) / v->
zoom
* -1;
76
v->
panx
= v->
panx
- gldx;
77
v->
pany
= v->
pany
+ gldy;
78
}
else
{
79
gldx =
GetOGLDistance
(v->
mouse
.
dragX
) / v->
cameras
[v->
active_camera
]->
r
;
80
gldy =
GetOGLDistance
(v->
mouse
.
dragY
) / v->
cameras
[v->
active_camera
]->
r
;
81
v->
cameras
[v->
active_camera
]->
x
-= gldx;
82
v->
cameras
[v->
active_camera
]->
y
-= gldy;
83
v->
cameras
[v->
active_camera
]->
targetx
-= gldx;
84
v->
cameras
[v->
active_camera
]->
targety
+= gldy;
85
}
86
}
draw.h
glmotion_pan
void glmotion_pan(ViewInfo *v)
Definition
glmotion.c:70
glmotion_zoom
void glmotion_zoom(void)
Definition
glmotion.c:54
glmotion_zoom_inc
void glmotion_zoom_inc(int zoomin)
Definition
glmotion.c:44
graph_zoom
static void graph_zoom(float real_zoom)
Definition
glmotion.c:22
glmotion.h
GetOGLDistance
float GetOGLDistance(float l)
Definition
glutils.c:53
glutils.h
SIZE_MAX
#define SIZE_MAX
Definition
gmlscan.c:347
hotkeymap.h
view
ViewInfo * view
Definition
viewport.c:37
MAX_ZOOM
#define MAX_ZOOM
Definition
smyrnadefs.h:53
MIN_ZOOM
#define MIN_ZOOM
Definition
smyrnadefs.h:54
glexpose
void glexpose(void)
Definition
viewport.c:540
_ViewInfo
Definition
smyrnadefs.h:252
_ViewInfo::Topview
topview * Topview
Definition
smyrnadefs.h:313
_ViewInfo::pany
float pany
Definition
smyrnadefs.h:256
_ViewInfo::panx
float panx
Definition
smyrnadefs.h:255
_ViewInfo::cameras
viewport_camera ** cameras
Definition
smyrnadefs.h:305
_ViewInfo::zoom
float zoom
Definition
smyrnadefs.h:258
_ViewInfo::mouse
glCompMouse mouse
Definition
smyrnadefs.h:303
_ViewInfo::active_camera
size_t active_camera
<number of cameras
Definition
smyrnadefs.h:307
_viewport_camera::targetx
float targetx
Definition
smyrnadefs.h:137
_viewport_camera::targety
float targety
Definition
smyrnadefs.h:138
_viewport_camera::y
float y
Definition
smyrnadefs.h:134
_viewport_camera::x
float x
Definition
smyrnadefs.h:133
_viewport_camera::r
float r
Definition
smyrnadefs.h:141
glCompMouse::dragY
float dragY
Definition
glcompdefs.h:245
glCompMouse::dragX
float dragX
Definition
glcompdefs.h:245
topview::fitin_zoom
float fitin_zoom
Definition
smyrnadefs.h:236
cmd
smyrna
glmotion.c
Generated by
1.9.8