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