Graphviz 13.0.2~dev.20250618.0117
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 attrList(glCompObj *obj, float x, float y, glMouseButtonType t) {
158 (void)obj;
159 (void)x;
160 (void)y;
161 (void)t;
162
164}
165
166static void glCompMouseMove(glCompObj *obj, float x, float y) {
167 (void)x;
168 (void)y;
169
170 glCompMouse *m = &((glCompSet *) obj)->mouse;
171
172 sel->base.common.visible = 1;
173
174 if (m->down && m->t == glMouseRightButton) {
175 sel->base.common.pos.x = m->x - m->dragX;
176 sel->base.common.pos.y = m->y - m->dragY;
177 sel->base.common.width = m->dragX;
178 sel->base.common.height = m->dragY;
179 glexpose();
180 }
181}
182
183static void selectedges(glCompObj *obj, float x, float y, glMouseButtonType t) {
184 (void)obj;
185 (void)x;
186 (void)y;
187 (void)t;
188
190}
191
192static void selectnodes(glCompObj *obj, float x, float y, glMouseButtonType t) {
193 (void)obj;
194 (void)x;
195 (void)y;
196 (void)t;
197
199}
200
202{
203 float y = 5;
204 float off = 43;
206 glCompPanel *p = NULL;
207 glCompButton *b = NULL;
208 glCompImage *i = NULL;
209
210 p = glCompPanelNew(s, 25, 25, 45, 47);
212 p->base.common.data = 0;
213
214 /*pan */
215 b = glCompButtonNew(p, 1, y, 42, 42, "");
216 {
217 char *pan = smyrnaPath("pan.png");
219 free(pan);
220 }
222 panBtn = b;
223
224 y = y + off;
225
226 /*switch to fisheye */
227 b = glCompButtonNew(p, 1, y, 42, 42, "");
228 {
229 char *fisheye = smyrnaPath("fisheye.png");
230 glCompButtonAddPngGlyph(b, fisheye);
231 free(fisheye);
232 }
234 toFisheye = b;
235
236
237 /*switch to normal mode */
238 b = glCompButtonNew(p, 1, y, 42, 42, "");
239 {
240 char *fisheye = smyrnaPath("no_fisheye.png");
241 glCompButtonAddPngGlyph(b, fisheye);
242 free(fisheye);
243 }
245 b->base.common.visible = 0;
246 toNormal = b;
247
248 y=y+off;
249 b = glCompButtonNew(p, 1, y, 42, 42, "");
250 {
251 char *threed = smyrnaPath("3D.png");
252 glCompButtonAddPngGlyph(b, threed);
253 free(threed);
254 }
256 to3DBtn = b;
257
258 b = glCompButtonNew(p, 1, y, 42, 42, "");
259 {
260 char *twod = smyrnaPath("2D.png");
262 free(twod);
263 }
266 to2DBtn = b;
267
268 y=y+off;
269 b = glCompButtonNew(p, 1, y, 42, 42, "N");
271 b->groupid=-1;
272 b->status = true;
273
274 y=y+off;
275 b = glCompButtonNew(p, 1, y, 42, 42, "E");
277 b->groupid=-1;
278
279 p = glCompPanelNew(p, 1, 325, 45, 180);
281 p->base.common.data = 0;
282 p->base.common.borderWidth = 1;
283 p->shadowwidth = 0;
284
285 const glCompColor c = {.R = 0.80f, .G = 0.6f, .B = 0.6f, .A = 1.6f};
286
287 y = 1;
288
289 b = glCompButtonNew(p, 1, y, 42, 42, "");
290 {
291 char *details = smyrnaPath("details.png");
292 glCompButtonAddPngGlyph(b, details);
293 free(details);
294 }
296 b->base.common.color = c;
297
298 y = y + off;
299
300 b = glCompButtonNew(p, 1, y, 42, 42, "");
301 {
302 char *zoomin = smyrnaPath("zoomin.png");
303 glCompButtonAddPngGlyph(b, zoomin);
304 free(zoomin);
305 }
306 b->groupid = 0;
308 b->base.common.color = c;
309 y = y + off;
310
311 b = glCompButtonNew(p, 1, y, 42, 42, "");
312 {
313 char *zoomout = smyrnaPath("zoomout.png");
314 glCompButtonAddPngGlyph(b, zoomout);
315 free(zoomout);
316 }
318 b->base.common.color = c;
319
320 y = y + off;
321
322 b = glCompButtonNew(p, 1, y, 42, 42, "");
323 {
324 char *center = smyrnaPath("center.png");
326 free(center);
327 }
329 b->base.common.color = c;
330
331 p = glCompPanelNew(s, -250, 550, 150, 175);
332 p->base.common.borderWidth = 0;
333 p->shadowwidth = 0;
334 p->base.common.color.R = 0;
335 p->base.common.color.G = 0;
336 p->base.common.color.B = 1;
337 p->base.common.color.A = 0.2f;
338 p->base.common.visible = 0;
339 sel = p;
340 s->base.common.callbacks.mouseover = glCompMouseMove;
341 s->base.common.callbacks.mouseup = CBglCompMouseUp;
342
343 p = glCompPanelNew(s, 25, 25, 52, 47);
345 p->base.common.data = 0;
346 p->base.common.color.A = 0;
347
348 p = glCompPanelNew(p, 25, 0, 52, 110);
350 p->base.common.data = 0;
351 p->base.common.color.A = 0;
352 p->shadowwidth = 0;
353
354 i = glCompImageNew(p, 0, 0);
355 {
356 char *fisheye = smyrnaPath("mod_fisheye.png");
357 glCompImageLoadPng(i, fisheye);
358 free(fisheye);
359 }
360 imgFisheye = i;
361 i->base.common.visible = 0;
362
363 i = glCompImageNew(p, 0, 52);
364 {
365 char *threed = smyrnaPath("mod_3D.png");
366 glCompImageLoadPng(i, threed);
367 free(threed);
368 }
369 img3D = i;
370 i->base.common.visible = 0;
371
372 return s;
373
374
375
376}
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: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:50
glCompSet * glCompSetNew(int w, int h)
Definition glcompset.c:170
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:201
static void glCompMouseMove(glCompObj *obj, float x, float y)
Definition glcompui.c:166
static void attrList(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompui.c:157
static void selectedges(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompui.c:183
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:192
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
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 free(void *)
#define SIZE_MAX
Definition gmlscan.c:347
node NULL
Definition grammar.y:181
char * smyrnaPath(char *suffix)
Definition main.c:50
void deselect_all(Agraph_t *g)
ViewInfo * view
Definition viewport.c:37
void glexpose(void)
Definition viewport.c:538
topview * Topview
Definition smyrnadefs.h:312
Agraph_t ** g
Definition smyrnadefs.h:295
GTimer * timer
Definition smyrnadefs.h:314
size_t camera_count
Definition smyrnadefs.h:305
int activeGraph
Definition smyrnadefs.h:299
viewport_camera ** cameras
Definition smyrnadefs.h:304
size_t active_camera
<number of cameras
Definition smyrnadefs.h:306
bool selectEdges
Definition smyrnadefs.h:215
bool selectNodes
Definition smyrnadefs.h:214
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::@56 fisheyeParams
Hierarchy * h
Definition smyrnadefs.h:227
int active
Definition smyrnadefs.h:221
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:89
void menu_click_add_camera(void)