| 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 "config.h" |
| 12 |
|
| 13 |
#include "glexpose.h" |
| 14 |
#include "draw.h" |
| 15 |
#include "topviewfuncs.h" |
| 16 |
#include <glcomp/glutils.h> |
| 17 |
#include "topfisheyeview.h" |
| 18 |
#include "gui/toolboxcallbacks.h" |
| 19 |
#include "arcball.h" |
| 20 |
#include "hotkeymap.h" |
| 21 |
#include "polytess.h" |
| 22 |
#include <stdbool.h> |
| 23 |
#include <stdint.h> |
| 24 |
|
| 25 |
static void drawRotatingAxis(void) |
| 26 |
{ |
| 27 |
static GLUquadricObj *quadratic; |
| 28 |
float AL = 45; |
| 29 |
|
| 30 |
if (get_mode(view) != MM_ROTATE) |
| 31 |
return; |
| 32 |
|
| 33 |
if (!quadratic) { |
| 34 |
quadratic = gluNewQuadric(); // Create A Pointer To The Quadric Object |
| 35 |
gluQuadricNormals(quadratic, GLU_SMOOTH); // Create Smooth Normals |
| 36 |
gluQuadricDrawStyle(quadratic, GLU_LINE); |
| 37 |
|
| 38 |
|
| 39 |
} |
| 40 |
|
| 41 |
glPushMatrix(); |
| 42 |
glLoadIdentity(); |
| 43 |
glMultMatrixf(view->arcball->Transform.M); /*arcball transformations , experimental */ |
| 44 |
glLineWidth(3); |
| 45 |
glBegin(GL_LINES); |
| 46 |
glColor3f(1, 1, 0); |
| 47 |
|
| 48 |
glVertex3f(0, 0, 0); |
| 49 |
glVertex3f(0, AL, 0); |
| 50 |
|
| 51 |
glVertex3f(0, 0, 0); |
| 52 |
glVertex3f(AL, 0, 0); |
| 53 |
|
| 54 |
glVertex3f(0, 0, 0); |
| 55 |
glVertex3f(0, 0, AL); |
| 56 |
|
| 57 |
glEnd(); |
| 58 |
glColor4f(0, 1, 0, 0.3f); |
| 59 |
gluSphere(quadratic, AL, 20, 20); |
| 60 |
glLineWidth(1); |
| 61 |
glPopMatrix(); |
| 62 |
|
| 63 |
|
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
/* |
| 69 |
refreshes camera settings using view parameters such as pan zoom etc |
| 70 |
if a camera is selected viewport is switched to 3D |
| 71 |
params:ViewInfo , global view variable defined in viewport.c |
| 72 |
return value:always 1 |
| 73 |
*/ |
| 74 |
static int glupdatecamera(ViewInfo * vi) |
| 75 |
{ |
| 76 |
if (vi->active_camera == SIZE_MAX) |
| 77 |
glTranslated(-vi->panx, -vi->pany, 0); |
| 78 |
|
| 79 |
|
| 80 |
/*toggle to active camera */ |
| 81 |
else { |
| 82 |
glMultMatrixf(vi->arcball->Transform.M); /*arcball transformations , experimental */ |
| 83 |
glTranslated(-vi->cameras[vi->active_camera]->targetx, |
| 84 |
-vi->cameras[vi->active_camera]->targety, 0); |
| 85 |
} |
| 86 |
vi->clipX1=0; |
| 87 |
vi->clipX2=0; |
| 88 |
vi->clipY1=0; |
| 89 |
vi->clipY2=0; |
| 90 |
GetOGLPosRef(1, vi->h - 5, &vi->clipX1, &vi->clipY1); |
| 91 |
GetOGLPosRef(vi->w - 1, 1, &vi->clipX2, &vi->clipY2); |
| 92 |
|
| 93 |
if (vi->active_camera == SIZE_MAX) { |
| 94 |
glScaled(1 / vi->zoom * -1, 1 / vi->zoom * -1, 1 / vi->zoom * -1); |
| 95 |
} else { |
| 96 |
glScaled(1 / vi->cameras[vi->active_camera]->r, |
| 97 |
1 / vi->cameras[vi->active_camera]->r, |
| 98 |
1 / vi->cameras[vi->active_camera]->r); |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
return 1; |
| 103 |
} |
| 104 |
|
| 105 |
/* |
| 106 |
draws grid (little dots , with no use) |
| 107 |
params:ViewInfo , global view variable defined in viewport.c |
| 108 |
return value:none |
| 109 |
*/ |
| 110 |
static void glexpose_grid(ViewInfo * vi) |
| 111 |
{ |
| 112 |
//drawing grids |
| 113 |
if (vi->gridVisible) { |
| 114 |
glPointSize(1); |
| 115 |
glBegin(GL_POINTS); |
| 116 |
glColor4d(vi->gridColor.R, vi->gridColor.G, vi->gridColor.B, |
| 117 |
vi->gridColor.A); |
| 118 |
for (double x = vi->bdxLeft; x <= vi->bdxRight; x += vi->gridSize) { |
| 119 |
for (double y = vi->bdyBottom; y <= vi->bdyTop; y += vi->gridSize) { |
| 120 |
glVertex3d(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 |
*/ |
| 132 |
static int glexpose_drawgraph(ViewInfo * vi) |
| 133 |
{ |
| 134 |
|
| 135 |
if (vi->activeGraph > -1) { |
| 136 |
if (!vi->Topview->fisheyeParams.active) |
| 137 |
renderSmGraph(vi->Topview); |
| 138 |
else { |
| 139 |
drawtopologicalfisheye(vi->Topview); |
| 140 |
} |
| 141 |
|
| 142 |
return 1; |
| 143 |
} |
| 144 |
return 0; |
| 145 |
} |
| 146 |
|
| 147 |
int glexpose_main(ViewInfo * vi) |
| 148 |
{ |
| 149 |
static bool doonce; |
| 150 |
if (!glupdatecamera(vi)) |
| 151 |
return 0; |
| 152 |
|
| 153 |
if (vi->activeGraph >= 0) { |
| 154 |
if (!doonce) { |
| 155 |
doonce = true; |
| 156 |
btnToolZoomFit_clicked(NULL, NULL); |
| 157 |
btnToolZoomFit_clicked(NULL, NULL); |
| 158 |
} |
| 159 |
} |
| 160 |
else |
| 161 |
return 0; |
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
glexpose_grid(vi); |
| 166 |
drawBorders(vi); |
| 167 |
glexpose_drawgraph(vi); |
| 168 |
drawRotatingAxis(); |
| 169 |
draw_selpoly(&vi->Topview->sel.selPoly); |
| 170 |
glCompSetDraw(vi->widgets); |
| 171 |
|
| 172 |
/*DEBUG*/ return 1; |
| 173 |
} |