40 #if defined(__WXMSW__)
45 #elif defined(__WXGTK__)
50 #elif defined(__WXMAC__)
54 #include <OpenGL/glu.h>
63 #define GL_ENUM_TYPE GLenum
64 #define GL_INT_TYPE GLint
65 #define GL_DOUBLE_TYPE GLdouble
85 #define USE_MY_GLU_QUADS 1
90 #define MAC_GL_OPTIMIZE 1
91 #define MAC_GL_SETCOLOR SetColor(eUseCachedValues);
92 #ifndef USE_MY_GLU_QUADS
93 #define USE_MY_GLU_QUADS 1
98 #define MAC_GL_SETCOLOR
102 #ifndef USE_MY_GLU_QUADS
104 static GLUquadricObj *qobj =
NULL;
107 static const double PI = acos(-1.0);
123 static const GLfloat
Color_Off[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
126 static const GLfloat
Color_On[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
141 g[0]=m.
m[0];
g[4]=m.
m[1];
g[8]=m.
m[2];
g[12]=m.
m[3];
142 g[1]=m.
m[4];
g[5]=m.
m[5];
g[9]=m.
m[6];
g[13]=m.
m[7];
143 g[2]=m.
m[8];
g[6]=m.
m[9];
g[10]=m.
m[10];
g[14]=m.
m[11];
144 g[3]=m.
m[12];
g[7]=m.
m[13];
g[11]=m.
m[14];
g[15]=m.
m[15];
150 m->
m[0]=
g[0]; m->
m[1]=
g[4]; m->
m[2]=
g[8]; m->
m[3]=
g[12];
151 m->
m[4]=
g[1]; m->
m[5]=
g[5]; m->
m[6]=
g[9]; m->
m[7]=
g[13];
152 m->
m[8]=
g[2]; m->
m[9]=
g[6]; m->
m[10]=
g[10]; m->
m[11]=
g[14];
153 m->
m[12]=
g[3]; m->
m[13]=
g[7]; m->
m[14]=
g[11]; m->
m[15]=
g[15];
159 static const GLdouble
origin[] = { 0.0, 0.0, 0.0 },
unitZ[] = { 0.0, 0.0, 1.0 };
161 #define GLU_DISK(q, i, o, s, l) MyGluDisk((i), (o), (s), (l))
165 if (slices < 3 || loops < 1 || innerRadius < 0.0 || innerRadius >= outerRadius) {
166 ERRORMSG(
"MyGluDisk() - bad parameters");
171 vector < GLdouble > x(slices), y(slices);
174 for (s=0; s<slices; ++s) {
175 a =
PI * 2 * s / slices;
181 if (innerRadius == 0.0) {
182 f = innerRadius + (outerRadius - innerRadius) / loops;
183 glBegin(GL_TRIANGLE_FAN);
187 for (s=0; s<=slices; ++s) {
188 i = (s == slices) ? 0 : s;
190 glVertex3d(x[
i] *
f, y[
i] *
f, 0.0);
197 for (;
l<loops; ++
l) {
198 f = innerRadius + (outerRadius - innerRadius) *
l / loops;
199 f2 = innerRadius + (outerRadius - innerRadius) * (
l + 1) / loops;
200 glBegin(GL_QUAD_STRIP);
202 for (s=0; s<=slices; ++s) {
203 i = (s == slices) ? 0 : s;
205 glVertex3d(x[
i] *
f, y[
i] *
f, 0.0);
207 glVertex3d(x[
i] * f2, y[
i] * f2, 0.0);
213 #define GLU_CYLINDER(q, b, t, h, l, k) MyGluCylinder((b), (t), (h), (l), (k))
217 if (slices < 3 || stacks < 1 || height <= 0.0 || baseRadius < 0.0 || topRadius < 0.0 ||
218 (baseRadius == 0.0 && topRadius == 0.0)) {
219 ERRORMSG(
"MyGluCylinder() - bad parameters");
224 vector < GLdouble > x(slices), y(slices);
225 vector < Vector >
N(slices);
229 for (s=0; s<slices; ++s) {
230 a =
PI * 2 * s / slices;
235 N[s].Set(x[s], y[s], 0.0);
240 for (k=0; k<stacks; ++k) {
241 f = baseRadius + (topRadius - baseRadius) * k / stacks;
242 f2 = baseRadius + (topRadius - baseRadius) * (k + 1) / stacks;
243 glBegin(GL_QUAD_STRIP);
244 for (s=0; s<=slices; ++s) {
245 i = (s == slices) ? 0 : s;
247 glNormal3d(
N[
i].x,
N[
i].y,
N[
i].z);
248 glVertex3d(x[
i] * f2, y[
i] * f2, height * (k + 1) / stacks);
250 glVertex3d(x[
i] *
f, y[
i] *
f, height * k / stacks);
256 #define GLU_SPHERE(q, r, l, k) MyGluSphere((r), (l), (k))
260 if (slices < 3 || stacks < 2 || radius <= 0.0) {
261 ERRORMSG(
"MyGluSphere() - bad parameters");
266 vector < vector < Vector > >
N(stacks - 1);
269 for (k=0; k<stacks-1; ++k) {
271 a =
PI * (-0.5 + (1.0 + k) / stacks);
274 for (s=0; s<slices; ++s) {
275 a =
PI * 2 * s / slices;
276 N[k][s].Set(cos(
a) *
r, sin(
a) *
r, z);
281 glBegin(GL_TRIANGLE_FAN);
283 glNormal3d(0.0, 0.0, -1.0);
284 glVertex3d(0.0, 0.0, -radius);
285 for (s=slices; s>=0; --s) {
286 i = (s == slices) ? 0 : s;
289 glNormal3d(
n.x,
n.y,
n.z);
290 glVertex3d(
n.x * radius,
n.y * radius,
n.z * radius);
295 for (k=0; k<stacks-2; ++k) {
296 glBegin(GL_QUAD_STRIP);
297 for (s=slices; s>=0; --s) {
298 i = (s == slices) ? 0 : s;
301 glNormal3d(n1.
x, n1.
y, n1.
z);
302 glVertex3d(n1.
x * radius, n1.
y * radius, n1.
z * radius);
305 glNormal3d(n2.
x, n2.
y, n2.
z);
306 glVertex3d(n2.
x * radius, n2.
y * radius, n2.
z * radius);
312 glBegin(GL_TRIANGLE_FAN);
315 glVertex3d(0.0, 0.0, radius);
316 for (s=0; s<=slices; ++s) {
317 i = (s == slices) ? 0 : s;
320 glNormal3d(
n.x,
n.y,
n.z);
321 glVertex3d(
n.x * radius,
n.y * radius,
n.z * radius);
328 #define GLU_DISK gluDisk
329 #define GLU_CYLINDER gluCylinder
330 #define GLU_SPHERE gluSphere
337 structureSet(
NULL), glCanvas(parentGLCanvas),
338 cameraAngleRad(0.0), rotateSpeed(0.5), selectMode(
false), currentDisplayList(NO_LIST),
342 if (
sizeof(GLuint) <
sizeof(
unsigned int))
343 FATALMSG(
"Cn3D requires that sizeof(GLuint) >= sizeof(unsigned int)");
348 glMatrixMode(GL_MODELVIEW);
353 GLfloat LightPosition[4] = { 0.0f, 0.0f, 1.0f, 0.0f };
354 glLightfv(GL_LIGHT0, GL_POSITION, LightPosition);
355 glLightfv(GL_LIGHT0, GL_AMBIENT,
Color_Off);
357 glLightfv(GL_LIGHT0, GL_SPECULAR,
Color_On);
358 glLightModelfv(GL_LIGHT_MODEL_AMBIENT,
Color_On);
359 glEnable(GL_LIGHTING);
363 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION,
Color_Off);
364 glMateriali(GL_FRONT_AND_BACK, GL_SHININESS,
Shininess);
366 glDisable(GL_COLOR_MATERIAL);
368 glEnable(GL_COLOR_MATERIAL);
372 glEnable(GL_CULL_FACE);
377 glShadeModel(GL_SMOOTH);
378 glEnable(GL_DEPTH_TEST);
379 glDisable(GL_NORMALIZE);
380 glDisable(GL_SCISSOR_TEST);
401 glGetIntegerv(GL_VIEWPORT, Viewport);
403 glMatrixMode(GL_PROJECTION);
407 gluPickMatrix(
static_cast<GLdouble
>(
selectX),
408 static_cast<GLdouble
>(Viewport[3] -
selectY),
412 GLdouble aspect = (
static_cast<GLdouble
>(Viewport[2])) / Viewport[3];
423 right = top * aspect;
434 if (
stereoOn && eyeTranslateToAngleDegrees != 0.0) {
436 Vector translate = vector_cross(view,
Vector(0.0, 1.0, 0.0));
439 cameraLoc += translate;
446 gluLookAt(cameraLoc.
x, cameraLoc.
y, cameraLoc.
z,
450 glMatrixMode(GL_MODELVIEW);
460 glClearColor(background[0], background[1], background[2], 1.0);
462 glClearColor(0.0, 0.0, 0.0, 1.0);
463 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
470 GLint viewport[4] = {0, 0, 0, 0};
471 double eyeSeparationDegrees = 0.0;
474 glGetIntegerv(GL_VIEWPORT, viewport);
478 ERRORMSG(
"OpenGLRenderer::Display() - error getting stereo settings from registry");
482 eyeSeparationDegrees = -eyeSeparationDegrees;
494 glViewport(0, viewport[1], viewport[2] / 2, viewport[3]);
495 NewView(eyeSeparationDegrees / 2);
498 glViewport(viewport[2] / 2, viewport[1], viewport[2] - viewport[2] / 2, viewport[3]);
499 NewView(-eyeSeparationDegrees / 2);
512 StructureSet::DisplayLists::const_iterator
538 glViewport(0, viewport[1], viewport[2], viewport[3]);
543 TRACEMSG(
"turning " << (enableStereo ?
"on" :
"off" ) <<
" stereo");
560 glGetIntegerv(GL_VIEWPORT, Viewport);
561 double angle =
cameraAngleRad, aspect = (
static_cast<double>(Viewport[2])) / Viewport[3];
562 if (aspect < 1.0) angle *= aspect;
579 glGetDoublev(GL_MODELVIEW_MATRIX,
viewMatrix);
585 bool doTranslation =
false;
597 doTranslation =
true;
603 if (doTranslation) glTranslated(rotCenter.
x, rotCenter.
y, rotCenter.
z);
605 #define MIN_CAMERA_ANGLE 0.001
606 #define MAX_CAMERA_ANGLE (0.999 * PI)
619 glGetIntegerv(GL_VIEWPORT, viewport);
654 if (doTranslation) glTranslated(-rotCenter.
x, -rotCenter.
y, -rotCenter.
z);
657 glGetDoublev(GL_MODELVIEW_MATRIX,
viewMatrix);
668 Vector direction = centerWRTcamera - cameraLocation;
670 double cosAngleZ = -direction.
z;
671 Vector lookAt = centerWRTcamera + direction * (centerWRTcamera.
z / cosAngleZ);
675 cameraAngleRad = 2.0 * atan(radius / (cameraLocation - centerWRTcamera).length());
709 ERRORMSG(
"OpenGLRenderer::StartDisplayList() - too many display lists;\n"
710 <<
"increase OpenGLRenderer::FONT_BASE");
716 glNewList(list, GL_COMPILE);
804 glRenderMode(GL_SELECT);
810 GLint hits = glRenderMode(GL_RENDER);
815 int i, j, p=0,
n, top=0;
818 for (
i=0;
i<hits; ++
i) {
827 for (j=0; j<
n; ++j) {
830 if (top) *name =
static_cast<unsigned int>(
selectBuf[p]);
833 WARNINGMSG(
"GL select: Got more than 1 name!");
860 #ifndef USE_MY_GLU_QUADS
862 gluDeleteQuadric(qobj);
863 if (!(qobj = gluNewQuadric())) {
864 ERRORMSG(
"unable to create a new GLUQuadricObj");
867 gluQuadricDrawStyle(qobj, (GLenum) GLU_FILL);
868 gluQuadricNormals(qobj, (GLenum) GLU_SMOOTH);
869 gluQuadricOrientation(qobj, (GLenum) GLU_OUTSIDE);
870 gluQuadricTexture(qobj, GL_FALSE);
876 glMatrixMode(GL_MODELVIEW);
890 ERRORMSG(
"OpenGLRenderer::Construct() - error getting quality setting from registry");
904 GLenum
type, GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha)
906 static GLdouble cr, cg, cb, ca;
907 static GLenum cachedType = GL_NONE, lastType = GL_NONE;
910 cachedType = lastType = GL_NONE;
918 if (cachedType == GL_NONE) {
919 ERRORMSG(
"can't do SetColor(eUseCachedValues) w/o previously doing eSetCacheValues or eSetColorIfDifferent");
923 cachedType = (GLenum)
type;
932 if (cachedType != lastType) {
933 if (cachedType == GL_DIFFUSE) {
934 #ifndef MAC_GL_OPTIMIZE
935 glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
939 }
else if (cachedType == GL_AMBIENT) {
940 #ifndef MAC_GL_OPTIMIZE
941 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT);
943 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE,
Color_Off);
944 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR,
Color_Off);
946 ERRORMSG(
"don't know how to handle material type " << cachedType);
948 lastType = cachedType;
951 GLfloat rgba[4] = { (GLfloat) cr, (GLfloat) cg, (GLfloat) cb, (GLfloat) ca };
953 glMaterialfv(GL_FRONT_AND_BACK, cachedType, rgba);
961 static const GLfloat logoColor[3] = { 100.0f/255, 240.0f/255, 150.0f/255 };
962 static const int LOGO_SIDES = 36, segments = 180;
964 GLdouble bigRad = 12.0, height = 24.0,
965 minRad = 0.1, maxRad = 2.0,
966 ringPts[LOGO_SIDES * 3], *pRingPts = ringPts,
967 prevRing[LOGO_SIDES * 3], *pPrevRing = prevRing, *
tmp,
968 ringNorm[LOGO_SIDES * 3], *pRingNorm = ringNorm,
969 prevNorm[LOGO_SIDES * 3], *pPrevNorm = prevNorm,
970 length, startRad, midRad, phase, currentRad,
CR[3],
H[3], V[3];
978 for (
n = 0;
n < 2; ++
n) {
988 for (
g = 0;
g <= segments; ++
g) {
991 currentRad = startRad + (midRad - startRad) *
992 (0.5 - 0.5 * cos(
PI *
g / (segments/2)));
994 currentRad = midRad + (startRad - midRad) *
995 (0.5 - 0.5 * cos(
PI * (
g - segments/2) / (segments/2)));
997 CR[1] = height *
g / segments - height/2;
998 if (
g > 0) phase +=
PI * 2 / segments;
999 CR[2] = bigRad * cos(phase);
1000 CR[0] = bigRad * sin(phase);
1003 for (s = 0; s < LOGO_SIDES; ++s) {
1007 length = sqrt(V[0]*V[0] + V[1]*V[1] + V[2]*V[2]);
1008 for (
i = 0;
i < 3; ++
i) V[
i] /= length;
1011 for (
i = 0;
i < 3; ++
i) {
1012 pRingNorm[3*s +
i] = V[
i] * cos(
PI * 2 * s / LOGO_SIDES) +
1013 H[
i] * sin(
PI * 2 * s / LOGO_SIDES);
1014 pRingPts[3*s +
i] =
CR[
i] + pRingNorm[3*s +
i] * currentRad;
1018 glBegin(GL_TRIANGLE_STRIP);
1019 for (s = 0; s < LOGO_SIDES; ++s) {
1020 glNormal3d(pPrevNorm[3*s], pPrevNorm[3*s + 1], pPrevNorm[3*s + 2]);
1021 glVertex3d(pPrevRing[3*s], pPrevRing[3*s + 1], pPrevRing[3*s + 2]);
1022 glNormal3d(pRingNorm[3*s], pRingNorm[3*s + 1], pRingNorm[3*s + 2]);
1023 glVertex3d(pRingPts[3*s], pRingPts[3*s + 1], pRingPts[3*s + 2]);
1025 glNormal3d(pPrevNorm[0], pPrevNorm[1], pPrevNorm[2]);
1026 glVertex3d(pPrevRing[0], pPrevRing[1], pPrevRing[2]);
1027 glNormal3d(pRingNorm[0], pRingNorm[1], pRingNorm[2]);
1028 glVertex3d(pRingPts[0], pRingPts[1], pRingPts[2]);
1033 glBegin(GL_POLYGON);
1034 if ((
g == 0 &&
n == 0) || (
g == segments &&
n == 1))
1035 glNormal3d(-1, 0, 0);
1037 glNormal3d(1, 0, 0);
1039 for (s = 0; s < LOGO_SIDES; ++s)
1040 glVertex3d(pRingPts[3*s], pRingPts[3*s + 1], pRingPts[3*s + 2]);
1041 }
else if (
g == segments) {
1042 for (s = LOGO_SIDES - 1; s >= 0; --s)
1043 glVertex3d(pRingPts[3*s], pRingPts[3*s + 1], pRingPts[3*s + 2]);
1049 pPrevRing = pRingPts;
1052 pPrevNorm = pRingNorm;
1063 const Vector&
site,
double radius,
double alpha)
1066 WARNINGMSG(
"OpenGLRenderer::AddTransparentSphere() - not called during display list creation");
1071 spheres.resize(spheres.size() + 1);
1076 info.radius = radius;
1094 SphereList::const_iterator
i, ie=sphereList.end();
1095 const Matrix *dependentTransform;
1096 for (
i=sphereList.begin();
i!=ie; ++
i, ++sph) {
1097 sph->siteGL =
i->site;
1099 if (dependentTransform)
1116 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1123 glLoadName(
static_cast<GLuint
>(
i->ptr->name));
1125 glTranslated(
i->siteGL.x,
i->siteGL.y,
i->siteGL.z);
1128 srand(
static_cast<unsigned int>(
fabs(
i->ptr->site.x * 1000)));
1129 glRotated(360.0*rand()/RAND_MAX,
1130 1.0*rand()/RAND_MAX - 0.5, 1.0*rand()/RAND_MAX - 0.5, 1.0*rand()/RAND_MAX - 0.5);
1142 glDisable(GL_BLEND);
1159 glLoadName(
static_cast<GLuint
>(atomStyle.
name));
1180 double radius,
bool cap1,
bool cap2,
1184 Vector R1, R2, Qt, p, dQt,
H, V;
1185 double len, MG[4][3],
T[4],
t, prevlen=0.0, cosj, sinj;
1190 ERRORMSG(
"DrawHalfWorm: got NULL 0th and/or 3rd coords for worm");
1197 static double Mh[4][4] = {
1213 WARNINGMSG(
"worm sides must be an even number");
1216 GLdouble *fblock =
NULL;
1221 R1 = 0.5 * (1 -
a) * (1 +
b) * (1 + c) * (p1 - *p0) + 0.5 * (1 -
a) * (1 -
b) * (1 - c) * ( p2 - p1);
1222 R2 = 0.5 * (1 -
a) * (1 +
b) * (1 - c) * (p2 - p1) + 0.5 * (1 -
a) * (1 -
b) * (1 + c) * (*p3 - p2);
1228 for (
i = 0;
i < 4; ++
i) {
1229 MG[
i][0] = Mh[
i][0] * p1.
x + Mh[
i][1] * p2.
x + Mh[
i][2] * R1.
x + Mh[
i][3] * R2.
x;
1230 MG[
i][1] = Mh[
i][0] * p1.
y + Mh[
i][1] * p2.
y + Mh[
i][2] * R1.
y + Mh[
i][3] * R2.
y;
1231 MG[
i][2] = Mh[
i][0] * p1.
z + Mh[
i][1] * p2.
z + Mh[
i][2] * R1.
z + Mh[
i][3] * R2.
z;
1246 Qt.
x =
T[0] * MG[0][0] +
T[1] * MG[1][0] +
T[2] * MG[2][0] + MG[3][0] ;
1247 Qt.
y =
T[0] * MG[0][1] +
T[1] * MG[1][1] +
T[2] * MG[2][1] + MG[3][1] ;
1248 Qt.
z =
T[0] * MG[0][2] +
T[1] * MG[1][2] +
T[2] * MG[2][2] + MG[3][2] ;
1250 if (radius == 0.0) {
1254 glVertex3d(p.
x, p.
y, p.
z);
1256 glVertex3d(Qt.
x, Qt.
y, Qt.
z);
1292 dQt.
x =
T[0] * MG[0][0] +
T[1] * MG[1][0] + MG[2][0] ;
1293 dQt.
y =
T[0] * MG[0][1] +
T[1] * MG[1][1] + MG[2][1] ;
1294 dQt.
z =
T[0] * MG[0][2] +
T[1] * MG[1][2] + MG[2][2] ;
1297 H.Set(0.0, -dQt.
z, dQt.
y);
1298 if (
H.length() < 0.000001)
1299 H.Set(0.1 * dQt.
z, -dQt.
z, dQt.
y - 0.1 * dQt.
x);
1303 V = vector_cross(dQt,
H);
1311 Nx[j] =
H.x * cosj + V.
x * sinj;
1312 Ny[j] =
H.y * cosj + V.
y * sinj;
1313 Nz[j] =
H.z * cosj + V.
z * sinj;
1314 Cx[j] = Qt.
x + Nx[j] * radius;
1315 Cy[j] = Qt.
y + Ny[j] * radius;
1316 Cz[j] = Qt.
z + Nz[j] * radius;
1328 len += (Cx[k] - pCx[j]) * (Cx[k] - pCx[j]) +
1329 (Cy[k] - pCy[j]) * (Cy[k] - pCy[j]) +
1330 (Cz[k] - pCz[j]) * (Cz[k] - pCz[j]);
1332 if (m == 0 ||
len < prevlen) {
1341 glBegin(GL_TRIANGLE_STRIP);
1346 glNormal3d(Nx[k], Ny[k], Nz[k]);
1347 glVertex3d(Cx[k], Cy[k], Cz[k]);
1349 glNormal3d(pNx[j], pNy[j], pNz[j]);
1350 glVertex3d(pCx[j], pCy[j], pCz[j]);
1356 glNormal3d(pNx[0], pNy[0], pNz[0]);
1357 glVertex3d(pCx[0], pCy[0], pCz[0]);
1362 if (cap1 &&
i == 0) {
1364 glBegin(GL_POLYGON);
1365 glNormal3d(-dQt.
x, -dQt.
y, -dQt.
z);
1368 glVertex3d(Cx[j], Cy[j], Cz[j]);
1374 glBegin(GL_POLYGON);
1375 glNormal3d(dQt.
x, dQt.
y, dQt.
z);
1380 glVertex3d(Cx[k], Cy[k], Cz[k]);
1387 #define SWAPPTR(p1,p2) tmp=(p1); (p1)=(p2); (p2)=tmp
1397 if (fblock)
delete[] fblock;
1403 glTranslated(
a.x,
a.y,
a.z);
1407 if (
fabs(
a.y -
b.y) < 0.000001 &&
fabs(
a.x -
b.x) < 0.000001) {
1408 if (
b.z -
a.z < 0.0) glRotated(180.0, 1.0, 0.0, 0.0);
1411 a.y -
b.y,
b.x -
a.x, 0.0);
1417 bool cap1,
bool cap2)
1423 glVertex3d(site1.
x, site1.
y, site1.
z);
1425 glVertex3d(midpoint.
x, midpoint.
y, midpoint.
z);
1431 double length = (site1 - midpoint).length();
1432 if (length <= 0.000001 ||
bondSides <= 1)
return;
1438 glRotated(180.0, 0.0, 1.0, 0.0);
1444 glTranslated(0.0, 0.0, length);
1456 Vector midpoint = (site1 + site2) / 2;
1463 ? GL_AMBIENT : GL_DIFFUSE;
1469 glLoadName(
static_cast<GLuint
>(style.
end1.
name));
1488 ? GL_AMBIENT : GL_DIFFUSE;
1494 glLoadName(
static_cast<GLuint
>(style.
end2.
name));
1516 glLoadName(
static_cast<GLuint
>(
NO_NAME));
1518 double wholeLength = (Nterm - Cterm).length();
1519 if (wholeLength <= 0.000001)
return;
1526 double shaftLength =
1533 glRotated(180.0, 0.0, 1.0, 0.0);
1542 glTranslated(0.0, 0.0, shaftLength);
1543 glRotated(180.0, 0.0, 1.0, 0.0);
1549 glTranslated(0.0, 0.0, shaftLength);
1556 glTranslated(0.0, 0.0, wholeLength);
1565 glTranslated(0.0, 0.0, wholeLength);
1577 GLdouble c000[3], c001[3], c010[3], c011[3],
1578 c100[3], c101[3], c110[3], c111[3],
n[3];
1587 glLoadName(
static_cast<GLuint
>(
NO_NAME));
1595 h = vector_cross(unitNormal,
a);
1601 for (
i=0;
i<3; ++
i) {
1614 for (
i=0;
i<3; ++
i)
n[
i] = unitNormal[
i];
1625 for (
i=0;
i<3; ++
i)
n[
i] = -unitNormal[
i];
1636 for (
i=0;
i<3; ++
i)
n[
i] = h[
i];
1647 for (
i=0;
i<3; ++
i)
n[
i] = -h[
i];
1658 for (
i=0;
i<3; ++
i)
n[
i] = -
a[
i];
1670 for (
i=0;
i<3; ++
i)
n[
i] =
a[
i];
1682 GLdouble
FT[3],
LT[3],
RT[3],
FB[3], LB[3], RB[3];
1684 for (
i=0;
i<3; ++
i) {
1700 for (
i=0;
i<3; ++
i)
n[
i] = -
a[
i];
1722 Vector nL = vector_cross(unitNormal, h);
1724 for (
i=0;
i<3; ++
i)
n[
i] = nL[
i];
1737 Vector nR = vector_cross(h, unitNormal);
1739 for (
i=0;
i<3; ++
i)
n[
i] = nR[
i];
1756 glBegin(GL_TRIANGLE_FAN);
1757 for (
i=0;
i<3; ++
i)
n[
i] = unitNormal[
i];
1771 glBegin(GL_TRIANGLE_FAN);
1772 for (
i=0;
i<3; ++
i)
n[
i] = -unitNormal[
i];
1787 glBegin(GL_TRIANGLES);
1790 for (
i=0;
i<3; ++
i)
n[
i] = unitNormal[
i];
1796 for (
i=0;
i<3; ++
i)
n[
i] = -unitNormal[
i];
1811 int width, height, textCenterX = 0, textCenterY = 0;
1816 WARNINGMSG(
"MeasureText() failed, text may not be properly centered");
1820 glRasterPos3d(center.
x, center.
y, center.
z);
1821 glBitmap(0, 0, 0.0, 0.0, -textCenterX, -textCenterY,
NULL);
1822 glCallLists(
text.size(), GL_UNSIGNED_BYTE,
text.data());
1867 if (!annotations.IsSetView())
return true;
1868 TRACEMSG(
"Using view from incoming data...");
1916 static const wxFont emptyFont;
1918 ERRORMSG(
"Can't call GetGLFont w/ NULL glCanvas");
1928 #if defined(__WXMSW__)
1929 HDC hdc = wglGetCurrentDC();
1930 HGDIOBJ currentFont = SelectObject(hdc,
reinterpret_cast<HGDIOBJ
>(
GetGLFont().GetHFONT()));
1931 if (!wglUseFontBitmaps(hdc, firstChar, nChars, fontBase)) {
1932 ERRORMSG(
"OpenGLRenderer::SetGLFont() - wglUseFontBitmaps() failed");
1935 SelectObject(hdc, currentFont);
1937 #elif defined(__WXGTK__)
1947 #elif defined(__WXMAC__)
1952 int fontFamily =
GetGLFont().GetFamily() - wxFONTFAMILY_DEFAULT;
1953 int fontSize =
GetGLFont().GetPointSize();
1954 int fontStyle =
GetGLFont().GetStyle() - wxFONTSTYLE_NORMAL;
1958 if (aglUseFont(aglGetCurrentContext(),
1960 fontStyle, (GLint) fontSize,
1961 firstChar, nChars, fontBase) != GL_TRUE) {
User-defined methods of the data storage class.
User-defined methods of the data storage class.
StyleManager::eDisplayStyle style
const wxFont & GetGLFont(void) const
bool MeasureText(const std::string &text, int *width, int *height, int *centerX, int *centerY)
double arrowTipWidthProportion
void UnPostStructureRedraws(void)
double arrowBaseWidthProportion
StyleManager::eDisplayStyle style
void MyGluSphere(double radius, int slices, int stacks)
bool GetSelected(int x, int y, unsigned int *name)
std::vector< bool > displayListEmpty
void ShowPreviousFrame(void)
void DrawHalfBond(const Vector &site1, const Vector &midpoint, StyleManager::eDisplayStyle style, double radius, bool cap1, bool cap2)
void CenterView(const Vector &viewCenter, double radius)
void DrawAtom(const Vector &site, const AtomStyle &atomStyle)
SpherePtrList transparentSpheresToRender
void RecreateQuadric(void) const
void AddTransparentSphere(const Vector &color, unsigned int name, const Vector &site, double radius, double alpha)
void AddTransparentSpheresForList(unsigned int list)
void SetColor(EColorAction action, int=0, double red=0.0, double green=0.0, double blue=0.0, double alpha=1.0)
void StartDisplayList(unsigned int list)
const wxFont & GetGLFont(void) const
void MyGluDisk(double innerRadius, double outerRadius, int slices, int loops)
SphereMap transparentSphereMap
void AttachStructureSet(StructureSet *targetStructureSet)
void EndDisplayList(void)
void MyGluCylinder(double baseRadius, double topRadius, double height, int slices, int stacks)
void ShowFirstFrame(void)
void DrawBond(const Vector &site1, const Vector &site2, const BondStyle &style, const Vector *site0, const Vector *site3)
void DrawHalfWorm(const Vector *p0, const Vector &p1, const Vector &p2, const Vector *p3, double radius, bool cap1, bool cap2, double tension)
ncbi::CRef< ncbi::objects::CCn3d_view_settings > initialViewFromASN
void ChangeView(eViewAdjust control, int dX=0, int dY=0, int X2=0, int Y2=0)
bool LoadFromASNViewSettings(const ncbi::objects::CCn3d_user_annotations &annotations)
void PushMatrix(const Matrix *xform)
bool SetGLFont(int firstChar, int nChars, int fontBase)
void RestoreSavedView(void)
void ShowFrameNumber(int frame)
void EnableStereo(bool enableStereo)
void DrawHelix(const Vector &Nterm, const Vector &Cterm, const HelixStyle &helixStyle)
void ClearTransparentSpheresForList(unsigned int list)
bool IsFrameEmpty(unsigned int frame) const
void RenderTransparentSpheres(void)
void NewView(double eyeTranslateToAngleDegrees=0.0) const
static const unsigned int NO_NAME
void ComputeBestView(void)
bool SaveToASNViewSettings(ncbi::objects::CCn3d_user_annotations *annotations)
StructureSet * structureSet
static const unsigned int FIRST_LIST
unsigned int currentFrame
std::list< SphereInfo > SphereList
void DrawStrand(const Vector &Nterm, const Vector &Cterm, const Vector &unitNormal, const StrandStyle &strandStyle)
void DrawLabel(const std::string &text, const Vector ¢er, const Vector &color)
static const unsigned int NO_LIST
unsigned int currentDisplayList
static const unsigned int FONT_BASE
OpenGLRenderer(Cn3DGLCanvas *parentGLCanvas)
virtual bool DrawAll(const AtomSet *atomSet=NULL) const
unsigned int lastDisplayList
TransformMap transformMap
void CenterViewOnStructure(void)
bool IsMultiStructure(void) const
bool CenterViewOnAlignedResidues(void)
StyleManager * styleManager
const Vector & GetBackgroundColor(void) const
double length(void) const
void Set(double xs, double ys, double zs)
bool IsWindowedMode(void)
const Colors * GlobalColors(void)
Include a standard set of the NCBI C++ Toolkit most basic headers.
static const unsigned long CR
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
static DLIST_TYPE *DLIST_NAME() last(DLIST_LIST_TYPE *list)
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_SCOPE(ns)
Define a new scope.
static void text(MDB_val *v)
Messenger * GlobalMessenger(void)
const TYPE & Get(const CNamedParameterList *param)
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
Defines: CTimeFormat - storage class for time format.
bool le(T x_, T y_, T round_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
static const GLfloat Color_MostlyOff[4]
static const GLdouble origin[]
static const GLdouble unitZ[]
static const GLfloat Color_Specular[4]
static const GLfloat Color_On[4]
static double DegreesToRad(double deg)
static void GL2Matrix(GLdouble *g, Matrix *m)
static const unsigned int ALL_FRAMES
#define GLU_DISK(q, i, o, s, l)
static const int pickBufSize
static void DoCylinderPlacementTransform(const Vector &a, const Vector &b, double length)
static void Matrix2GL(const Matrix &m, GLdouble *g)
#define GLU_CYLINDER(q, b, t, h, l, k)
static string projectionType
static const GLfloat Color_Off[4]
static const GLint Shininess
static const GLfloat Color_MostlyOn[4]
static double RadToDegrees(double rad)
static GLuint selectBuf[pickBufSize]
#define GLU_SPHERE(q, r, l, k)
static SLJIT_INLINE sljit_ins l(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
StyleManager::eDisplayStyle style
int g(Seg_Gsm *spe, Seq_Mtf *psm, Thd_Gsm *tdg)
void SetRotationMatrix(Matrix *m, const Vector &v, double rad, int n)
void ApplyTransformation(Vector *v, const Matrix &m)