Graphviz 12.0.1~dev.20240716.0800
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 "frmobjectui.h"
26
35
36
37void menu_click_pan(glCompObj *obj, float x, float y, glMouseButtonType t) {
38 (void)obj;
39 (void)x;
40 (void)y;
41 (void)t;
42
44}
45
46void menu_click_zoom_minus(glCompObj *obj, float x, float y,
48{
49 (void)obj;
50 (void)x;
51 (void)y;
52 (void)t;
53
55}
56
57void menu_click_zoom_plus(glCompObj *obj, float x, float y, glMouseButtonType t)
58{
59 (void)obj;
60 (void)x;
61 (void)y;
62 (void)t;
63
65}
66
67static void menu_switch_to_fisheye(glCompObj *obj, float x, float y,
69{
70 (void)obj;
71 (void)x;
72 (void)y;
73 (void)t;
74
76 {
77 if (!view->Topview->fisheyeParams.h) {
79 g_timer_start(view->timer);
80 }
85
86
87 } else {
89 g_timer_stop(view->timer);
93
94
95 }
96}
97
98void menu_click_center(glCompObj *obj, float x, float y, glMouseButtonType t) {
99 (void)obj;
100 (void)x;
101 (void)y;
102 (void)t;
103
104 if (view->active_camera == SIZE_MAX) { // 2D mode
106 } else { /*there is active camera , adjust it to look at the center */
107
111
112 }
113}
114
115void switch2D3D(glCompObj *obj, float x, float y, glMouseButtonType t) {
116 (void)obj;
117 (void)x;
118 (void)y;
119
120 if (t == glMouseLeftButton) {
121
122 if (view->active_camera == SIZE_MAX) {
123
124 if (view->camera_count == 0) {
126 } else {
127 view->active_camera = 0; /*set to camera */
128 }
131 img3D->common.visible = 1;
132 } else { /*switch to 2d */
133
134 view->active_camera = SIZE_MAX; // set to camera
139 img3D->common.visible = 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->common.visible = 0;
154 sel->common.pos.x = -5000;
155
156}
157
158static void CBglCompMouseRightClick(glCompObj *obj, float x, float y,
160{
161 (void)obj;
162
163 if (t == glMouseRightButton)
164 {
165 float X, Y, Z = 0;
166 to3D((int) x, (int) y, &X, &Y, &Z);
167 }
168}
169
170static void attrList(glCompObj *obj, float x, float y, glMouseButtonType t) {
171 (void)obj;
172 (void)x;
173 (void)y;
174 (void)t;
175
177}
178
179static void glCompMouseMove(glCompObj *obj, float x, float y) {
180 (void)x;
181 (void)y;
182
183 glCompMouse *m = &((glCompSet *) obj)->mouse;
184
185 sel->common.visible = 1;
186
187
188 if ((m->down) && (m->t == glMouseRightButton))
189 {
190 sel->common.pos.x = m->pos.x - m->dragX;
191 sel->common.pos.y = m->pos.y - m->dragY;
192 sel->common.width = m->dragX;
193 sel->common.height = m->dragY;
194 glexpose();
195 }
196}
197
198static void selectedges(glCompObj *obj, float x, float y, glMouseButtonType t) {
199 (void)obj;
200 (void)x;
201 (void)y;
202 (void)t;
203
205}
206
207static void selectnodes(glCompObj *obj, float x, float y, glMouseButtonType t) {
208 (void)obj;
209 (void)x;
210 (void)y;
211 (void)t;
212
214}
215
217{
218 float y = 5;
219 float off = 43;
221 glCompPanel *p = NULL;
222 glCompButton *b = NULL;
223 glCompImage *i = NULL;
224 glCompColor c;
225 s->common.callbacks.click = CBglCompMouseRightClick;
226
227 p = glCompPanelNew(s, 25, 25, 45, 47);
229 p->common.data = 0;
230
231 /*pan */
232 b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
233 glCompButtonAddPngGlyph(b, smyrnaPath("pan.png"));
235 panBtn = b;
236
237 y = y + off;
238
239 /*switch to fisheye */
240 b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
241 glCompButtonAddPngGlyph(b, smyrnaPath("fisheye.png"));
243 toFisheye = b;
244
245
246 /*switch to normal mode */
247 b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
248 glCompButtonAddPngGlyph(b, smyrnaPath("no_fisheye.png"));
250 b->common.visible = 0;
251 toNormal = b;
252
253 y=y+off;
254 b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
257 to3DBtn = b;
258
259
260 b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
264 to2DBtn = b;
265
266 y=y+off;
267 b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "N");
269 b->groupid=-1;
270 b->status = true;
271
272 y=y+off;
273 b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "E");
275 b->groupid=-1;
276
277 p = glCompPanelNew(p, 1, 325, 45, 180);
279 p->common.data = 0;
280 p->common.borderWidth = 1;
281 p->shadowwidth = 0;
282
283 c.R = 0.80f;
284 c.G = 0.6f;
285 c.B = 0.6f;
286 c.A = 1.6f;
287
288 y = 1;
289
290 b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
291 glCompButtonAddPngGlyph(b, smyrnaPath("details.png"));
293 b->common.color = c;
294
295 y = y + off;
296
297 b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
298 glCompButtonAddPngGlyph(b, smyrnaPath("zoomin.png"));
299 b->groupid = 0;
301 b->common.color = c;
302 y = y + off;
303
304
305 b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
306 glCompButtonAddPngGlyph(b, smyrnaPath("zoomout.png"));
308 b->common.color = c;
309
310 y = y + off;
311
312
313 b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
314 glCompButtonAddPngGlyph(b, smyrnaPath("center.png"));
316 b->common.color = c;
317
318 p = glCompPanelNew(s, -250, 550, 150, 175);
319 p->common.borderWidth = 0;
320 p->shadowwidth = 0;
321 p->common.color.R = 0;
322 p->common.color.G = 0;
323 p->common.color.B = 1;
324 p->common.color.A = 0.2f;
325 p->common.visible = 0;
326 sel = p;
327 s->common.callbacks.mouseover = glCompMouseMove;
328 s->common.callbacks.mouseup = CBglCompMouseUp;
329
330 p = glCompPanelNew(s, 25, 25, 52, 47);
332 p->common.data = 0;
333 p->common.color.A = 0;
334
335 p = glCompPanelNew(p, 25, 0, 52, 110);
337 p->common.data = 0;
338 p->common.color.A = 0;
339 p->shadowwidth = 0;
340
341 i = glCompImageNew((glCompObj *) p, 0, 0);
342 glCompImageLoadPng(i, smyrnaPath("mod_fisheye.png"));
343 imgFisheye = i;
344 i->common.visible = 0;
345
346 i = glCompImageNew((glCompObj *) p, 0, 52);
347 glCompImageLoadPng(i, smyrnaPath("mod_3D.png"));
348 img3D = i;
349 i->common.visible = 0;
350
351
352 return s;
353
354
355
356}
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, char *fileName)
glCompButton * glCompButtonNew(glCompObj *par, float x, float y, float w, float h, char *caption)
void glCompButtonShow(glCompButton *p)
void glCompButtonHide(glCompButton *p)
glMouseButtonType
Definition glcompdefs.h:89
@ glMouseRightButton
Definition glcompdefs.h:89
@ glMouseLeftButton
Definition glcompdefs.h:89
@ glAlignTop
Definition glcompdefs.h:80
@ glAlignLeft
Definition glcompdefs.h:80
@ glAlignRight
Definition glcompdefs.h:81
int glCompImageLoadPng(glCompImage *i, char *pngFile)
Definition glcompimage.c:75
glCompImage * glCompImageNew(glCompObj *par, float x, float y)
Definition glcompimage.c:19
glCompPanel * glCompPanelNew(void *parentObj, float x, float y, float w, float h)
Definition glcomppanel.c:53
glCompSet * glCompSetNew(int w, int h)
Definition glcompset.c:188
static void CBglCompMouseUp(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompui.c:146
static glCompButton * to3DBtn
Definition glcompui.c:28
void switch2D3D(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompui.c:115
static glCompButton * toNormal
Definition glcompui.c:31
glCompSet * glcreate_gl_topview_menu(void)
Definition glcompui.c:216
static void glCompMouseMove(glCompObj *obj, float x, float y)
Definition glcompui.c:179
static void attrList(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompui.c:170
static void selectedges(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompui.c:198
void menu_click_zoom_minus(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompui.c:46
void menu_click_center(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompui.c:98
static void menu_switch_to_fisheye(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompui.c:67
static glCompButton * toFisheye
Definition glcompui.c:30
static void selectnodes(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompui.c:207
static glCompImage * imgFisheye
Definition glcompui.c:32
void menu_click_pan(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompui.c:37
static glCompPanel * sel
Definition glcompui.c:27
static glCompButton * to2DBtn
Definition glcompui.c:29
static glCompButton * panBtn
Definition glcompui.c:34
static glCompImage * img3D
Definition glcompui.c:33
static void CBglCompMouseRightClick(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompui.c:158
void menu_click_zoom_plus(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompui.c:57
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
#define SIZE_MAX
Definition gmlscan.c:347
node NULL
Definition grammar.y:149
char * smyrnaPath(char *suffix)
Definition main.c:68
void deselect_all(Agraph_t *g)
ViewInfo * view
Definition viewport.c:38
void glexpose(void)
Definition viewport.c:543
topview * Topview
Definition smyrnadefs.h:334
Agraph_t ** g
Definition smyrnadefs.h:313
GTimer * timer
Definition smyrnadefs.h:336
size_t camera_count
Definition smyrnadefs.h:327
int activeGraph
Definition smyrnadefs.h:317
viewport_camera ** cameras
Definition smyrnadefs.h:326
size_t active_camera
<number of cameras
Definition smyrnadefs.h:328
glCompCommon common
Definition glcompdefs.h:258
bool status
false not pressed, true pressed
Definition glcompdefs.h:261
bool selectEdges
Definition smyrnadefs.h:233
bool selectNodes
Definition smyrnadefs.h:232
glcompclickfunc_t click
Definition glcompdefs.h:191
glCompColor color
Definition glcompdefs.h:212
glCompCallBacks callbacks
Definition glcompdefs.h:222
glCompPoint pos
Definition glcompdefs.h:208
glCompAlignment align
Definition glcompdefs.h:219
float borderWidth
Definition glcompdefs.h:211
glCompCommon common
Definition glcompdefs.h:230
glMouseButtonType t
Definition glcompdefs.h:278
glCompPoint pos
Definition glcompdefs.h:279
float shadowwidth
Definition glcompdefs.h:241
glCompCommon common
Definition glcompdefs.h:240
Hierarchy * h
Definition smyrnadefs.h:243
int active
Definition smyrnadefs.h:239
struct topview::@55 fisheyeParams
selection sel
Definition smyrnadefs.h:259
void btnToolZoomFit_clicked(GtkWidget *widget, gpointer user_data)
void prepare_topological_fisheye(Agraph_t *g, topview *t)
Definition grammar.c:93
void menu_click_add_camera(void)