Graphviz 13.0.0~dev.20241220.2304
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 <stdint.h>
20
21static void drawRotatingAxis(void)
22{
23 static GLUquadricObj *quadratic;
24 float AL = 45;
25
26 if (get_mode(view) != MM_ROTATE)
27 return;
28
29 if (!quadratic) {
30 quadratic = gluNewQuadric(); // Create A Pointer To The Quadric Object
31 gluQuadricNormals(quadratic, GLU_SMOOTH); // Create Smooth Normals
32 gluQuadricDrawStyle(quadratic, GLU_LINE);
33
34
35 }
36
37 glPushMatrix();
38 glLoadIdentity();
39 glMultMatrixf(view->arcball->Transform.M); /*arcball transformations , experimental */
40 glLineWidth(3);
41 glBegin(GL_LINES);
42 glColor3f(1, 1, 0);
43
44 glVertex3f(0, 0, 0);
45 glVertex3f(0, AL, 0);
46
47 glVertex3f(0, 0, 0);
48 glVertex3f(AL, 0, 0);
49
50 glVertex3f(0, 0, 0);
51 glVertex3f(0, 0, AL);
52
53 glEnd();
54 glColor4f(0, 1, 0, 0.3f);
55 gluSphere(quadratic, AL, 20, 20);
56 glLineWidth(1);
57 glPopMatrix();
58
59
60}
61
62
63
64/*
65 refreshes camera settings using view parameters such as pan zoom etc
66 if a camera is selected viewport is switched to 3D
67 params:ViewInfo , global view variable defined in viewport.c
68 return value:always 1
69*/
70static int glupdatecamera(ViewInfo * vi)
71{
72 if (vi->active_camera == SIZE_MAX)
73 glTranslatef(-vi->panx, -vi->pany, vi->panz);
74
75
76 /*toggle to active camera */
77 else {
78 glMultMatrixf(vi->arcball->Transform.M); /*arcball transformations , experimental */
79 glTranslatef(-vi->cameras[vi->active_camera]->targetx,
80 -vi->cameras[vi->active_camera]->targety, 0);
81 }
82 vi->clipX1=0;
83 vi->clipX2=0;
84 vi->clipY1=0;
85 vi->clipY2=0;
86 GetOGLPosRef(1, vi->h - 5, &(vi->clipX1), &(vi->clipY1));
87 GetOGLPosRef(vi->w - 1, 1, &(vi->clipX2), &(vi->clipY2));
88
89 if (vi->active_camera == SIZE_MAX) {
90 glScalef(1 / vi->zoom * -1, 1 / vi->zoom * -1,
91 1 / vi->zoom * -1);
92 } else {
93 glScalef(1 / vi->cameras[vi->active_camera]->r,
94 1 / vi->cameras[vi->active_camera]->r,
95 1 / vi->cameras[vi->active_camera]->r);
96 }
97
98
99 return 1;
100}
101
102/*
103 draws grid (little dots , with no use)
104 params:ViewInfo , global view variable defined in viewport.c
105 return value:none
106*/
107static void glexpose_grid(ViewInfo * vi)
108{
109 //drawing grids
110 float x, y;
111 if (vi->gridVisible) {
112 glPointSize(1);
113 glBegin(GL_POINTS);
114 glColor4f(vi->gridColor.R, vi->gridColor.G, vi->gridColor.B,
115 vi->gridColor.A);
116 for (x = vi->bdxLeft; x <= vi->bdxRight;
117 x = x + vi->gridSize) {
118 for (y = vi->bdyBottom; y <= vi->bdyTop;
119 y = y + vi->gridSize) {
120 glVertex3f(x, y, 0);
121 }
122 }
123 glEnd();
124 }
125}
126
127/*
128 draws active graph depending on graph type
129 params:ViewInfo , global view variable defined in viewport.c
130 return value:1 if there is a graph to draw else 0
131*/
133{
134
135 if (vi->activeGraph > -1) {
136 if (!vi->Topview->fisheyeParams.active)
138 else {
140 }
141
142 return 1;
143 }
144 return 0;
145}
146
147/*
148 main gl expose ,any time sreen needs to be redrawn, this function is called by gltemplate
149 ,all drawings are initialized in this function
150 params:ViewInfo , global view variable defined in viewport.c
151 return value:0 if something goes wrong with GL 1 , otherwise
152*/
154{
155 static int doonce = 0;
156 if (!glupdatecamera(vi))
157 return 0;
158
159 if (vi->activeGraph >= 0) {
160 if (!doonce) {
161 doonce = 1;
164 }
165 }
166 else
167 return 0;
168
169
170
171 glexpose_grid(vi);
172 drawBorders(vi);
177
178 /*DEBUG*/ return 1;
179}
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:70
static void drawRotatingAxis(void)
Definition glexpose.c:21
static void glexpose_grid(ViewInfo *vi)
Definition glexpose.c:107
static int glexpose_drawgraph(ViewInfo *vi)
Definition glexpose.c:132
int glexpose_main(ViewInfo *vi)
Definition glexpose.c:153
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:290
ArcBall_t * arcball
Definition smyrnadefs.h:343
topview * Topview
Definition smyrnadefs.h:313
float pany
Definition smyrnadefs.h:256
float clipX2
Definition smyrnadefs.h:261
float bdyTop
Definition smyrnadefs.h:290
glCompSet * widgets
Definition smyrnadefs.h:336
float gridSize
Definition smyrnadefs.h:284
float panx
Definition smyrnadefs.h:255
int activeGraph
Definition smyrnadefs.h:300
viewport_camera ** cameras
Definition smyrnadefs.h:305
float bdxRight
Definition smyrnadefs.h:291
float bdyBottom
Definition smyrnadefs.h:291
int gridVisible
Definition smyrnadefs.h:282
float zoom
Definition smyrnadefs.h:258
float panz
Definition smyrnadefs.h:257
float clipY1
Definition smyrnadefs.h:261
float clipX1
Definition smyrnadefs.h:261
glCompColor gridColor
Definition smyrnadefs.h:270
float clipY2
Definition smyrnadefs.h:261
size_t active_camera
<number of cameras
Definition smyrnadefs.h:307
glCompPoly_t selPoly
Definition smyrnadefs.h:214
int active
Definition smyrnadefs.h:222
struct topview::@55 fisheyeParams
selection sel
Definition smyrnadefs.h:242
void btnToolZoomFit_clicked(GtkWidget *widget, void *user_data)
void drawtopologicalfisheye(topview *t)
void renderSmGraph(topview *t)
float M[16]
Definition arcball.h:122