Graphviz 13.0.0~dev.20250121.0651
Loading...
Searching...
No Matches
glexpose.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#include "glexpose.h"
11#include "draw.h"
12#include "topviewfuncs.h"
13#include <glcomp/glutils.h>
14#include "topfisheyeview.h"
16#include "arcball.h"
17#include "hotkeymap.h"
18#include "polytess.h"
19#include <stdbool.h>
20#include <stdint.h>
21
22static void drawRotatingAxis(void)
23{
24 static GLUquadricObj *quadratic;
25 float AL = 45;
26
27 if (get_mode(view) != MM_ROTATE)
28 return;
29
30 if (!quadratic) {
31 quadratic = gluNewQuadric(); // Create A Pointer To The Quadric Object
32 gluQuadricNormals(quadratic, GLU_SMOOTH); // Create Smooth Normals
33 gluQuadricDrawStyle(quadratic, GLU_LINE);
34
35
36 }
37
38 glPushMatrix();
39 glLoadIdentity();
40 glMultMatrixf(view->arcball->Transform.M); /*arcball transformations , experimental */
41 glLineWidth(3);
42 glBegin(GL_LINES);
43 glColor3f(1, 1, 0);
44
45 glVertex3f(0, 0, 0);
46 glVertex3f(0, AL, 0);
47
48 glVertex3f(0, 0, 0);
49 glVertex3f(AL, 0, 0);
50
51 glVertex3f(0, 0, 0);
52 glVertex3f(0, 0, AL);
53
54 glEnd();
55 glColor4f(0, 1, 0, 0.3f);
56 gluSphere(quadratic, AL, 20, 20);
57 glLineWidth(1);
58 glPopMatrix();
59
60
61}
62
63
64
65/*
66 refreshes camera settings using view parameters such as pan zoom etc
67 if a camera is selected viewport is switched to 3D
68 params:ViewInfo , global view variable defined in viewport.c
69 return value:always 1
70*/
71static int glupdatecamera(ViewInfo * vi)
72{
73 if (vi->active_camera == SIZE_MAX)
74 glTranslatef(-vi->panx, -vi->pany, 0);
75
76
77 /*toggle to active camera */
78 else {
79 glMultMatrixf(vi->arcball->Transform.M); /*arcball transformations , experimental */
80 glTranslatef(-vi->cameras[vi->active_camera]->targetx,
81 -vi->cameras[vi->active_camera]->targety, 0);
82 }
83 vi->clipX1=0;
84 vi->clipX2=0;
85 vi->clipY1=0;
86 vi->clipY2=0;
87 GetOGLPosRef(1, vi->h - 5, &(vi->clipX1), &(vi->clipY1));
88 GetOGLPosRef(vi->w - 1, 1, &(vi->clipX2), &(vi->clipY2));
89
90 if (vi->active_camera == SIZE_MAX) {
91 glScalef(1 / vi->zoom * -1, 1 / vi->zoom * -1,
92 1 / vi->zoom * -1);
93 } else {
94 glScalef(1 / vi->cameras[vi->active_camera]->r,
95 1 / vi->cameras[vi->active_camera]->r,
96 1 / vi->cameras[vi->active_camera]->r);
97 }
98
99
100 return 1;
101}
102
103/*
104 draws grid (little dots , with no use)
105 params:ViewInfo , global view variable defined in viewport.c
106 return value:none
107*/
108static void glexpose_grid(ViewInfo * vi)
109{
110 //drawing grids
111 float x, y;
112 if (vi->gridVisible) {
113 glPointSize(1);
114 glBegin(GL_POINTS);
115 glColor4f(vi->gridColor.R, vi->gridColor.G, vi->gridColor.B,
116 vi->gridColor.A);
117 for (x = vi->bdxLeft; x <= vi->bdxRight;
118 x = x + vi->gridSize) {
119 for (y = vi->bdyBottom; y <= vi->bdyTop;
120 y = y + vi->gridSize) {
121 glVertex3f(x, y, 0);
122 }
123 }
124 glEnd();
125 }
126}
127
128/*
129 draws active graph depending on graph type
130 params:ViewInfo , global view variable defined in viewport.c
131 return value:1 if there is a graph to draw else 0
132*/
134{
135
136 if (vi->activeGraph > -1) {
137 if (!vi->Topview->fisheyeParams.active)
139 else {
141 }
142
143 return 1;
144 }
145 return 0;
146}
147
149{
150 static bool doonce;
151 if (!glupdatecamera(vi))
152 return 0;
153
154 if (vi->activeGraph >= 0) {
155 if (!doonce) {
156 doonce = true;
159 }
160 }
161 else
162 return 0;
163
164
165
166 glexpose_grid(vi);
167 drawBorders(vi);
172
173 /*DEBUG*/ return 1;
174}
void draw_selpoly(glCompPoly_t *selPoly)
Definition draw.c:413
void drawBorders(ViewInfo *vi)
Definition draw.c:367
void glCompSetDraw(glCompSet *s)
Definition glcompset.c:239
static int glupdatecamera(ViewInfo *vi)
Definition glexpose.c:71
static void drawRotatingAxis(void)
Definition glexpose.c:22
static void glexpose_grid(ViewInfo *vi)
Definition glexpose.c:108
static int glexpose_drawgraph(ViewInfo *vi)
Definition glexpose.c:133
int glexpose_main(ViewInfo *vi)
Definition glexpose.c:148
int GetOGLPosRef(int x, int y, float *X, float *Y)
Definition glutils.c:19
#define SIZE_MAX
Definition gmlscan.c:347
node NULL
Definition grammar.y:163
int get_mode(ViewInfo *v)
Definition hotkeymap.c:166
ViewInfo * view
Definition viewport.c:37
#define MM_ROTATE
Definition smyrnadefs.h:43
Matrix4fT Transform
Definition arcball.h:548
float bdxLeft
Definition smyrnadefs.h:287
ArcBall_t * arcball
Definition smyrnadefs.h:340
topview * Topview
Definition smyrnadefs.h:310
float pany
Definition smyrnadefs.h:254
float clipX2
Definition smyrnadefs.h:258
float bdyTop
Definition smyrnadefs.h:287
glCompSet * widgets
Definition smyrnadefs.h:333
float gridSize
Definition smyrnadefs.h:281
float panx
Definition smyrnadefs.h:253
int activeGraph
Definition smyrnadefs.h:297
viewport_camera ** cameras
Definition smyrnadefs.h:302
float bdxRight
Definition smyrnadefs.h:288
float bdyBottom
Definition smyrnadefs.h:288
int gridVisible
Definition smyrnadefs.h:279
float zoom
Definition smyrnadefs.h:255
float clipY1
Definition smyrnadefs.h:258
float clipX1
Definition smyrnadefs.h:258
glCompColor gridColor
Definition smyrnadefs.h:267
float clipY2
Definition smyrnadefs.h:258
size_t active_camera
<number of cameras
Definition smyrnadefs.h:304
glCompPoly_t selPoly
Definition smyrnadefs.h:212
int active
Definition smyrnadefs.h:220
struct topview::@55 fisheyeParams
selection sel
Definition smyrnadefs.h:240
void btnToolZoomFit_clicked(GtkWidget *widget, void *user_data)
void drawtopologicalfisheye(topview *t)
void renderSmGraph(topview *t)
float M[16]
Definition arcball.h:122