Graphviz 14.1.3~dev.20260201.2050
Loading...
Searching...
No Matches
glcompui.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 "config.h"
12
13#include "glcompui.h"
14#include <glcomp/glcompbutton.h>
15#include <glcomp/glcomppanel.h>
16#include <glcomp/glcomplabel.h>
17#include <glcomp/glcompimage.h>
18#include "gltemplate.h"
19#include <glcomp/glutils.h>
20#include "glmotion.h"
21#include "topfisheyeview.h"
22#include "toolboxcallbacks.h"
23#include "viewportcamera.h"
24#include "selectionfuncs.h"
25#include <stdbool.h>
26#include <stdint.h>
27#include <stdlib.h>
28#include "frmobjectui.h"
29
38
39
40void menu_click_pan(glCompObj *obj, float x, float y, glMouseButtonType t) {
41 (void)obj;
42 (void)x;
43 (void)y;
44 (void)t;
45
47}
48
49void menu_click_zoom_minus(glCompObj *obj, float x, float y,
51{
52 (void)obj;
53 (void)x;
54 (void)y;
55 (void)t;
56
58}
59
60void menu_click_zoom_plus(glCompObj *obj, float x, float y, glMouseButtonType t)
61{
62 (void)obj;
63 (void)x;
64 (void)y;
65 (void)t;
66
68}
69
70static void menu_switch_to_fisheye(glCompObj *obj, float x, float y,
72{
73 (void)obj;
74 (void)x;
75 (void)y;
76 (void)t;
77
79 {
80 if (!view->Topview->fisheyeParams.h) {
82 g_timer_start(view->timer);
83 }
88
89
90 } else {
92 g_timer_stop(view->timer);
96
97
98 }
99}
100
101void menu_click_center(glCompObj *obj, float x, float y, glMouseButtonType t) {
102 (void)obj;
103 (void)x;
104 (void)y;
105 (void)t;
106
107 if (view->active_camera == SIZE_MAX) { // 2D mode
109 } else { /*there is active camera , adjust it to look at the center */
110
114
115 }
116}
117
118void switch2D3D(glCompObj *obj, float x, float y, glMouseButtonType t) {
119 (void)obj;
120 (void)x;
121 (void)y;
122
123 if (t == glMouseLeftButton) {
124
125 if (view->active_camera == SIZE_MAX) {
126
127 if (view->camera_count == 0) {
129 } else {
130 view->active_camera = 0; /*set to camera */
131 }
135 } else { /*switch to 2d */
136
137 view->active_camera = SIZE_MAX; // set to camera
140 panBtn->base.common.callbacks.click(&panBtn->base, 0.0f, 0.0f, 0);
142
143
144 }
145 }
146}
147
148static void CBglCompMouseUp(glCompObj *obj, float x, float y, glMouseButtonType t)
149{
150 (void)obj;
151 (void)x;
152 (void)y;
153 (void)t;
154
155 sel->base.common.visible = 0;
156 sel->base.common.pos.x = -5000;
157}
158
159static void attrList(glCompObj *obj, float x, float y, glMouseButtonType t) {
160 (void)obj;
161 (void)x;
162 (void)y;
163 (void)t;
164
166}
167
168static void glCompMouseMove(glCompObj *obj, float x, float y) {
169 (void)x;
170 (void)y;
171
172 glCompMouse *m = &((glCompSet *) obj)->mouse;
173
174 sel->base.common.visible = 1;
175
176 if (m->down && m->t == glMouseRightButton) {
177 sel->base.common.pos.x = m->x - m->dragX;
178 sel->base.common.pos.y = m->y - m->dragY;
179 sel->base.common.width = m->dragX;
180 sel->base.common.height = m->dragY;
181 glexpose();
182 }
183}
184
185static void selectedges(glCompObj *obj, float x, float y, glMouseButtonType t) {
186 (void)obj;
187 (void)x;
188 (void)y;
189 (void)t;
190
192}
193
194static void selectnodes(glCompObj *obj, float x, float y, glMouseButtonType t) {
195 (void)obj;
196 (void)x;
197 (void)y;
198 (void)t;
199
201}
202
204{
205 float y = 5;
206 float off = 43;
208 glCompPanel *p = NULL;
209 glCompButton *b = NULL;
210 glCompImage *i = NULL;
211
212 p = glCompPanelNew(s, 25, 25, 45, 47);
214 p->base.common.data = 0;
215
216 /*pan */
217 b = glCompButtonNew(p, 1, y, 42, 42, "");
218 {
219 char *pan = smyrnaPath("pan.png");
221 free(pan);
222 }
224 panBtn = b;
225
226 y = y + off;
227
228 /*switch to fisheye */
229 b = glCompButtonNew(p, 1, y, 42, 42, "");
230 {
231 char *fisheye = smyrnaPath("fisheye.png");
232 glCompButtonAddPngGlyph(b, fisheye);
233 free(fisheye);
234 }
236 toFisheye = b;
237
238
239 /*switch to normal mode */
240 b = glCompButtonNew(p, 1, y, 42, 42, "");
241 {
242 char *fisheye = smyrnaPath("no_fisheye.png");
243 glCompButtonAddPngGlyph(b, fisheye);
244 free(fisheye);
245 }
247 b->base.common.visible = 0;
248 toNormal = b;
249
250 y=y+off;
251 b = glCompButtonNew(p, 1, y, 42, 42, "");
252 {
253 char *threed = smyrnaPath("3D.png");
254 glCompButtonAddPngGlyph(b, threed);
255 free(threed);
256 }
258 to3DBtn = b;
259
260 b = glCompButtonNew(p, 1, y, 42, 42, "");
261 {
262 char *twod = smyrnaPath("2D.png");
264 free(twod);
265 }
268 to2DBtn = b;
269
270 y=y+off;
271 b = glCompButtonNew(p, 1, y, 42, 42, "N");
273 b->groupid=-1;
274 b->status = true;
275
276 y=y+off;
277 b = glCompButtonNew(p, 1, y, 42, 42, "E");
279 b->groupid=-1;
280
281 p = glCompPanelNew(p, 1, 325, 45, 180);
283 p->base.common.data = 0;
284 p->base.common.borderWidth = 1;
285 p->shadowwidth = 0;
286
287 const glCompColor c = {.R = 0.8, .G = 0.6, .B = 0.6, .A = 1.6};
288
289 y = 1;
290
291 b = glCompButtonNew(p, 1, y, 42, 42, "");
292 {
293 char *details = smyrnaPath("details.png");
294 glCompButtonAddPngGlyph(b, details);
295 free(details);
296 }
298 b->base.common.color = c;
299
300 y = y + off;
301
302 b = glCompButtonNew(p, 1, y, 42, 42, "");
303 {
304 char *zoomin = smyrnaPath("zoomin.png");
305 glCompButtonAddPngGlyph(b, zoomin);
306 free(zoomin);
307 }
308 b->groupid = 0;
310 b->base.common.color = c;
311 y = y + off;
312
313 b = glCompButtonNew(p, 1, y, 42, 42, "");
314 {
315 char *zoomout = smyrnaPath("zoomout.png");
316 glCompButtonAddPngGlyph(b, zoomout);
317 free(zoomout);
318 }
320 b->base.common.color = c;
321
322 y = y + off;
323
324 b = glCompButtonNew(p, 1, y, 42, 42, "");
325 {
326 char *center = smyrnaPath("center.png");
328 free(center);
329 }
331 b->base.common.color = c;
332
333 p = glCompPanelNew(s, -250, 550, 150, 175);
334 p->base.common.borderWidth = 0;
335 p->shadowwidth = 0;
336 p->base.common.color.R = 0;
337 p->base.common.color.G = 0;
338 p->base.common.color.B = 1;
339 p->base.common.color.A = 0.2f;
340 p->base.common.visible = 0;
341 sel = p;
342 s->base.common.callbacks.mouseover = glCompMouseMove;
343 s->base.common.callbacks.mouseup = CBglCompMouseUp;
344
345 p = glCompPanelNew(s, 25, 25, 52, 47);
347 p->base.common.data = 0;
348 p->base.common.color.A = 0;
349
350 p = glCompPanelNew(p, 25, 0, 52, 110);
352 p->base.common.data = 0;
353 p->base.common.color.A = 0;
354 p->shadowwidth = 0;
355
356 i = glCompImageNew(p, 0, 0);
357 {
358 char *fisheye = smyrnaPath("mod_fisheye.png");
359 glCompImageLoadPng(i, fisheye);
360 free(fisheye);
361 }
362 imgFisheye = i;
363 i->base.common.visible = 0;
364
365 i = glCompImageNew(p, 0, 52);
366 {
367 char *threed = smyrnaPath("mod_3D.png");
368 glCompImageLoadPng(i, threed);
369 free(threed);
370 }
371 img3D = i;
372 i->base.common.visible = 0;
373
374 return s;
375
376
377
378}
void showAttrsWidget(void)
int glCompButtonAddPngGlyph(glCompButton *b, const char *fileName)
glCompButton * glCompButtonNew(void *par, float x, float y, float w, float h, char *caption)
void glCompButtonShow(glCompButton *p)
void glCompButtonHide(glCompButton *p)
glMouseButtonType
Definition glcompdefs.h:67
@ glMouseRightButton
Definition glcompdefs.h:67
@ glMouseLeftButton
Definition glcompdefs.h:67
@ glAlignTop
Definition glcompdefs.h:60
@ glAlignLeft
Definition glcompdefs.h:60
@ glAlignRight
Definition glcompdefs.h:61
int glCompImageLoadPng(glCompImage *i, const char *pngFile)
Definition glcompimage.c:77
glCompImage * glCompImageNew(void *par, float x, float y)
Definition glcompimage.c:22
glCompPanel * glCompPanelNew(void *parentObj, float x, float y, float w, float h)
Definition glcomppanel.c:52
glCompSet * glCompSetNew(int w, int h)
Definition glcompset.c:173
static void CBglCompMouseUp(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompui.c:148
static glCompButton * to3DBtn
Definition glcompui.c:31
void switch2D3D(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompui.c:118
static glCompButton * toNormal
Definition glcompui.c:34
glCompSet * glcreate_gl_topview_menu(void)
Definition glcompui.c:203
static void glCompMouseMove(glCompObj *obj, float x, float y)
Definition glcompui.c:168
static void attrList(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompui.c:159
static void selectedges(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompui.c:185
void menu_click_zoom_minus(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompui.c:49
void menu_click_center(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompui.c:101
static void menu_switch_to_fisheye(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompui.c:70
static glCompButton * toFisheye
Definition glcompui.c:33
static void selectnodes(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompui.c:194
static glCompImage * imgFisheye
Definition glcompui.c:35
void menu_click_pan(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompui.c:40
static glCompPanel * sel
Definition glcompui.c:30
static glCompButton * to2DBtn
Definition glcompui.c:32
static glCompButton * panBtn
Definition glcompui.c:37
static glCompImage * img3D
Definition glcompui.c:36
void menu_click_zoom_plus(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompui.c:60
void glmotion_zoom_inc(int zoomin)
Definition glmotion.c:45
void free(void *)
#define SIZE_MAX
Definition gmlscan.c:347
node NULL
Definition grammar.y:181
char * smyrnaPath(char *suffix)
Definition main.c:51
void deselect_all(Agraph_t *g)
ViewInfo * view
Definition viewport.c:40
void glexpose(void)
Definition viewport.c:523
topview * Topview
Definition smyrnadefs.h:305
Agraph_t ** g
Definition smyrnadefs.h:288
GTimer * timer
Definition smyrnadefs.h:307
size_t camera_count
Definition smyrnadefs.h:298
int activeGraph
Definition smyrnadefs.h:292
viewport_camera ** cameras
Definition smyrnadefs.h:297
size_t active_camera
<number of cameras
Definition smyrnadefs.h:299
bool selectEdges
Definition smyrnadefs.h:208
bool selectNodes
Definition smyrnadefs.h:207
glCompObj base
Definition glcompdefs.h:210
bool status
false not pressed, true pressed
Definition glcompdefs.h:213
glcompclickfunc_t click
Definition glcompdefs.h:151
glCompColor color
Definition glcompdefs.h:168
glCompCallBacks callbacks
Definition glcompdefs.h:178
glCompPoint pos
Definition glcompdefs.h:164
glCompAlignment align
Definition glcompdefs.h:175
float borderWidth
Definition glcompdefs.h:167
glCompObj base
Definition glcompdefs.h:190
glMouseButtonType t
Definition glcompdefs.h:223
float y
current mouse pos
Definition glcompdefs.h:224
object prototype
Definition glcompdefs.h:184
glCompCommon common
Definition glcompdefs.h:185
float shadowwidth
Definition glcompdefs.h:198
glCompObj base
Definition glcompdefs.h:197
struct topview::@22 fisheyeParams
Hierarchy * h
Definition smyrnadefs.h:220
int active
Definition smyrnadefs.h:214
selection sel
Definition smyrnadefs.h:235
static point center(point vertex[], size_t n)
void btnToolZoomFit_clicked(GtkWidget *widget, void *user_data)
void prepare_topological_fisheye(Agraph_t *g, topview *t)
Definition grammar.c:90
void menu_click_add_camera(void)