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,*/
22static void graph_zoom(float real_zoom)
23{
24 float old_zoom;
25
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;
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
44void 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
54void 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 =
64 20)) * -1;
65 }
66 graph_zoom(real_zoom);
67
68}
69
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}
void glmotion_pan(ViewInfo *v)
Definition glmotion.c:70
void glmotion_zoom(void)
Definition glmotion.c:54
void glmotion_zoom_inc(int zoomin)
Definition glmotion.c:44
static void graph_zoom(float real_zoom)
Definition glmotion.c:22
float GetOGLDistance(float l)
Definition glutils.c:53
#define SIZE_MAX
Definition gmlscan.c:347
ViewInfo * view
Definition viewport.c:37
#define MAX_ZOOM
Definition smyrnadefs.h:53
#define MIN_ZOOM
Definition smyrnadefs.h:54
void glexpose(void)
Definition viewport.c:540
topview * Topview
Definition smyrnadefs.h:313
float pany
Definition smyrnadefs.h:256
float panx
Definition smyrnadefs.h:255
viewport_camera ** cameras
Definition smyrnadefs.h:305
float zoom
Definition smyrnadefs.h:258
glCompMouse mouse
Definition smyrnadefs.h:303
size_t active_camera
<number of cameras
Definition smyrnadefs.h:307
float fitin_zoom
Definition smyrnadefs.h:236