Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
toolboxcallbacks.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 "toolboxcallbacks.h"
12#include "viewport.h"
13
14#include "gltemplate.h"
15#include <glcomp/glutils.h>
16#include "glmotion.h"
17#include <stdint.h>
18
19void btnToolZoomOut_clicked(GtkWidget *widget, void *user_data) {
20 (void)widget;
21 (void)user_data;
22
24}
25
26void btnToolZoomFit_clicked(GtkWidget *widget, void *user_data) {
27 (void)widget;
28 (void)user_data;
29
30 float z = view->active_camera != SIZE_MAX
32 : -view->zoom;
33
34 float GDX = view->bdxRight / z - view->bdxLeft / z;
35 float SDX = view->clipX2 - view->clipX1;
36 float GDY = view->bdyTop / z - view->bdyBottom / z;
37 float SDY = view->clipY2 - view->clipY1;
38
39 if (SDX / GDX <= SDY / GDY) {
40 if (view->active_camera != SIZE_MAX) {
41 view->cameras[view->active_camera]->r /= SDX / GDX;
42 } else {
43 view->zoom /= SDX / GDX;
44 }
45 } else {
46 if (view->active_camera != SIZE_MAX) {
47 view->cameras[view->active_camera]->r /= SDY / GDY;
48 } else {
49 view->zoom /= SDY / GDY;
50 }
51
52 }
54}
55
56void btnToolFit_clicked(GtkWidget *widget, void *user_data) {
57 (void)widget;
58 (void)user_data;
59
60 float scx, scy, gcx, gcy, z;
61
63 ? (z = view->cameras[view->active_camera]->r) : (z =
64 view->zoom * -1);
65
66 gcx = view->bdxLeft / z + (view->bdxRight / z - view->bdxLeft / z) / 2.0f;
67 scx = view->clipX1 + (view->clipX2 - view->clipX1) / 2.0f;
68 gcy = view->bdyBottom / z + (view->bdyTop / z - view->bdyBottom / z) / 2.0f;
69 scy = view->clipY1 + (view->clipY2 - view->clipY1) / 2.0f;
70
71 if (view->active_camera != SIZE_MAX) {
72 view->cameras[view->active_camera]->targetx += (gcx - scx);
73 view->cameras[view->active_camera]->targety += (gcx - scy);
74 } else {
75 view->panx += gcx - scx;
76 view->pany += gcy - scy;
77 }
79
80 glexpose();
81}
82
83void on_btnActivateGraph_clicked(GtkWidget *widget, void *user_data) {
84 (void)widget;
85 (void)user_data;
86
87 int graphId;
88 graphId = gtk_combo_box_get_active(view->graphComboBox);
89 /* fprintf (stderr, "switch to graph %d\n",graphId); */
90 switch_graph(graphId);
91}
void glmotion_zoom_inc(int zoomin)
Definition glmotion.c:44
#define SIZE_MAX
Definition gmlscan.c:347
node NULL
Definition grammar.y:163
static int z
ViewInfo * view
Definition viewport.c:37
void glexpose(void)
Definition viewport.c:540
float bdxLeft
Definition smyrnadefs.h:290
topview * Topview
Definition smyrnadefs.h:313
float pany
Definition smyrnadefs.h:256
float clipX2
Definition smyrnadefs.h:261
float bdyTop
Definition smyrnadefs.h:290
GtkComboBox * graphComboBox
Definition smyrnadefs.h:342
float panx
Definition smyrnadefs.h:255
viewport_camera ** cameras
Definition smyrnadefs.h:305
float bdxRight
Definition smyrnadefs.h:291
float bdyBottom
Definition smyrnadefs.h:291
float zoom
Definition smyrnadefs.h:258
float clipY1
Definition smyrnadefs.h:261
float clipX1
Definition smyrnadefs.h:261
float clipY2
Definition smyrnadefs.h:261
size_t active_camera
<number of cameras
Definition smyrnadefs.h:307
float fitin_zoom
Definition smyrnadefs.h:236
void btnToolZoomOut_clicked(GtkWidget *widget, void *user_data)
void btnToolFit_clicked(GtkWidget *widget, void *user_data)
void btnToolZoomFit_clicked(GtkWidget *widget, void *user_data)
void on_btnActivateGraph_clicked(GtkWidget *widget, void *user_data)
void switch_graph(int graphId)
Definition viewport.c:449