Graphviz 13.1.3~dev.20250813.2319
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 glTranslated(-vi->panx, -vi->pany, 0);
75
76
77 /*toggle to active camera */
78 else {
79 glMultMatrixf(vi->arcball->Transform.M); /*arcball transformations , experimental */
80 glTranslated(-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 glScaled(1 / vi->zoom * -1, 1 / vi->zoom * -1, 1 / vi->zoom * -1);
92 } else {
93 glScaled(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 if (vi->gridVisible) {
111 glPointSize(1);
112 glBegin(GL_POINTS);
113 glColor4d(vi->gridColor.R, vi->gridColor.G, vi->gridColor.B,
114 vi->gridColor.A);
115 for (double x = vi->bdxLeft; x <= vi->bdxRight; x += vi->gridSize) {
116 for (double y = vi->bdyBottom; y <= vi->bdyTop; y += vi->gridSize) {
117 glVertex3d(x, y, 0);
118 }
119 }
120 glEnd();
121 }
122}
123
124/*
125 draws active graph depending on graph type
126 params:ViewInfo , global view variable defined in viewport.c
127 return value:1 if there is a graph to draw else 0
128*/
130{
131
132 if (vi->activeGraph > -1) {
133 if (!vi->Topview->fisheyeParams.active)
135 else {
137 }
138
139 return 1;
140 }
141 return 0;
142}
143
145{
146 static bool doonce;
147 if (!glupdatecamera(vi))
148 return 0;
149
150 if (vi->activeGraph >= 0) {
151 if (!doonce) {
152 doonce = true;
155 }
156 }
157 else
158 return 0;
159
160
161
162 glexpose_grid(vi);
163 drawBorders(vi);
168
169 /*DEBUG*/ return 1;
170}
void draw_selpoly(glCompPoly_t *selPoly)
Definition draw.c:389
void drawBorders(ViewInfo *vi)
Definition draw.c:344
void glCompSetDraw(glCompSet *s)
Definition glcompset.c:228
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:107
static int glexpose_drawgraph(ViewInfo *vi)
Definition glexpose.c:129
int glexpose_main(ViewInfo *vi)
Definition glexpose.c:144
void 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:181
int get_mode(ViewInfo *v)
Definition hotkeymap.c:166
ViewInfo * view
Definition viewport.c:37
#define MM_ROTATE
Definition smyrnadefs.h:41
Matrix4fT Transform
Definition arcball.h:547
ArcBall_t * arcball
Definition smyrnadefs.h:333
topview * Topview
Definition smyrnadefs.h:307
double bdxRight
Definition smyrnadefs.h:285
float clipX2
Definition smyrnadefs.h:255
double bdyBottom
Definition smyrnadefs.h:285
double zoom
Definition smyrnadefs.h:252
double bdyTop
Definition smyrnadefs.h:284
glCompSet * widgets
Definition smyrnadefs.h:326
float gridSize
Definition smyrnadefs.h:278
int activeGraph
Definition smyrnadefs.h:294
viewport_camera ** cameras
Definition smyrnadefs.h:299
double bdxLeft
Definition smyrnadefs.h:284
int gridVisible
Definition smyrnadefs.h:276
double panx
Definition smyrnadefs.h:250
double pany
Definition smyrnadefs.h:251
float clipY1
Definition smyrnadefs.h:255
float clipX1
Definition smyrnadefs.h:255
glCompColor gridColor
Definition smyrnadefs.h:264
float clipY2
Definition smyrnadefs.h:255
size_t active_camera
<number of cameras
Definition smyrnadefs.h:301
glCompPoly_t selPoly
Definition smyrnadefs.h:208
struct topview::@56 fisheyeParams
int active
Definition smyrnadefs.h:216
selection sel
Definition smyrnadefs.h:237
void btnToolZoomFit_clicked(GtkWidget *widget, void *user_data)
void drawtopologicalfisheye(topview *t)
void renderSmGraph(topview *t)
float M[16]
Definition arcball.h:122