for now keep them at the bottom
*/
#include "draw.h"
-/* #include "topview.h" */
#include <common/colorprocs.h>
#include "smyrna_utils.h"
#include <glcomp/glutils.h>
}
-#if 0
-static void relocate_spline(sdot_op * sop, int param)
-{
- Agedge_t *e;
- Agnode_t *tn; //tail node
- Agnode_t *hn; //head node
- int i = 0;
- xdot_op *op = &sop->op;
- if (AGTYPE(sop->obj) == AGEDGE)
- {
- e = sop->obj;
- tn = agtail(e);
- hn = aghead(e);
- if ((OD_Selected(hn) == 1) && (OD_Selected(tn) == 0))
- {
- set_options(sop, 1);
- for (i = 1; i < op->u.bezier.cnt - 1; i = i + 1)
- {
- if ((dx != 0) || (dy != 0))
- {
- op->u.bezier.pts[i].x =
- op->u.bezier.pts[i].x -
- (int) (dx * (float) i /
- (float) (op->u.bezier.cnt));
- op->u.bezier.pts[i].y =
- op->u.bezier.pts[i].y -
- (int) (dy * (float) i /
- (float) (op->u.bezier.cnt));
- }
- }
- if ((dx != 0) || (dy != 0))
- {
- op->u.bezier.pts[op->u.bezier.cnt - 1].x =
- op->u.bezier.pts[op->u.bezier.cnt - 1].x - (int) dx;
- op->u.bezier.pts[op->u.bezier.cnt - 1].y =
- op->u.bezier.pts[op->u.bezier.cnt - 1].y - (int) dy;
- }
- }
- else if ((OD_Selected(hn) == 0) && (OD_Selected(tn) == 1))
- {
- set_options(sop, 1);
- for (i = op->u.bezier.cnt - 1; i > 0; i = i - 1)
- {
- if ((dx != 0) || (dy != 0))
- {
- op->u.bezier.pts[i].x =
- op->u.bezier.pts[i].x -
- (int) (dx * (float) (op->u.bezier.cnt - i) /
- (float) (op->u.bezier.cnt));
- op->u.bezier.pts[i].y =
- op->u.bezier.pts[i].y -
- (int) (dy * (float) (op->u.bezier.cnt - i) /
- (float) (op->u.bezier.cnt));
- }
- }
- if ((dx != 0) || (dy != 0))
- {
- op->u.bezier.pts[0].x = op->u.bezier.pts[0].x - (int) dx;
- op->u.bezier.pts[0].y = op->u.bezier.pts[0].y - (int) dy;
- }
- }
- else if ((OD_Selected(hn) == 1) && (OD_Selected(tn) == 1))
- {
- set_options(sop, 1);
- for (i = 0; i < op->u.bezier.cnt; i = i + 1)
- {
- if ((dx != 0) || (dy != 0))
- {
- op->u.bezier.pts[i].x =
- op->u.bezier.pts[i].x - (int) dx;
- op->u.bezier.pts[i].y =
- op->u.bezier.pts[i].y - (int) dy;
- }
- }
- }
- }
-}
-#endif
-
static void DrawBeziers(sdot_op* o, int param)
{
- /* GLfloat tempX[4]; */
- /* GLfloat tempY[4]; */
- /* GLfloat tempZ[4]; */
- /* int temp = 0; */
int filled;
int i = 0;
xdot_op * op=&o->op;
xdot_point* ps = op->u.bezier.pts;
view->Topview->global_z = view->Topview->global_z + o->layer*LAYER_DIFF;
- /* SelectBeziers((sdot_op *) op); */
- /* relocate_spline((sdot_op *) op, param); */
if (op->kind == xd_filled_bezier)
filled = 1;
else
y = op->u.ellipse.y - dy;
xradius = (GLfloat) op->u.ellipse.w;
yradius = (GLfloat) op->u.ellipse.h;
-// SelectEllipse((sdot_op *) op);
if (op->kind == xd_filled_ellipse) {
if (param == 0)
glColor4f(view->fillColor.R, view->fillColor.G,
}
static void DrawPolygon(sdot_op * o, int param)
-//void DrawPolygon(xdot_point* xpoint,int count, int filled)
{
int filled;
xdot_op * op=&o->op;
view->Topview->global_z=view->Topview->global_z+o->layer*LAYER_DIFF;
- //SelectPolygon((sdot_op *) op);
set_options((sdot_op *) op, param);
if (op->kind == xd_filled_polygon) {
}
glLineWidth(view->LineWidth);
drawTessPolygon(o);
-/*
- if (!filled)
- glBegin(GL_LINE_STRIP);
- else
- glBegin(GL_POLYGON);
- for (i = 0; i < op->u.polygon.cnt; i = i + 1) {
- glVertex3f((GLfloat) op->u.polygon.pts[i].x - dx,
- (GLfloat) op->u.polygon.pts[i].y - dy,
- (GLfloat) op->u.polygon.pts[i].z + view->Topview->global_z);
- }
- glVertex3f((GLfloat) op->u.polygon.pts[0].x - dx, (GLfloat) op->u.polygon.pts[0].y - dy, (GLfloat) op->u.polygon.pts[0].z + view->Topview->global_z); //close the polygon
- glEnd();*/
}
-#if 0
-static void DrawPolygon2(sdot_op * o, int param)
-{
- drawTessPolygon(o);
-}
-#endif
-
static void DrawPolyline(sdot_op* o, int param)
{
int i = 0;
if (param == 1) //selected
glColor4f(view->selectedNodeColor.R, view->selectedNodeColor.G,
view->selectedNodeColor.B, view->selectedNodeColor.A);
- //SelectPolyline((sdot_op *) op);
set_options((sdot_op *) op, param);
glLineWidth(view->LineWidth);
glBegin(GL_LINE_STRIP);
static void SetStyle(sdot_op* o, int param)
{
- /* xdot_op * op=&o->op; */
}
static sdot_op * font_op;
&view->penColor,
pangotext,
font_op->op.u.font.name,font_op->op.u.font.size,0);
- //glNewFont(glCompSet * s, char *text, glCompColor * c, glCompFontType type, char *fontdesc, int fs)*/
}
glCompDrawText3D(o->font,x,y,view->Topview->global_z,o->op.u.text.width,font_op->op.u.font.size);
}
-#if 0
-void draw_selection_box(ViewInfo * view)
-{
-/* if (((view->mouse.mouse_mode == 4) || (view->mouse.mouse_mode == 5))
- && view->mouse.down) {
- glColor4f(view->Selection.SelectionColor.R,
- view->Selection.SelectionColor.G,
- view->Selection.SelectionColor.B,
- view->Selection.SelectionColor.A);
- if (view->mouse.mouse_mode == 5) {
- glEnable(GL_LINE_STIPPLE);
- glLineStipple(1, 15);
- }
- glBegin(GL_LINE_STRIP);
- glVertex3f((GLfloat) view->mouse.GLinitPos.x, (GLfloat) view->mouse.GLinitPos.y,
- (GLfloat) 0.001 + view->Topview->global_z);
- glVertex3f((GLfloat) view->mouse.GLinitPos.x, (GLfloat) view->mouse.GLfinalPos.y,
- (GLfloat) 0.001 + view->Topview->global_z);
- glVertex3f((GLfloat) view->mouse.GLfinalPos.x, (GLfloat) view->mouse.GLfinalPos.y,
- (GLfloat) 0.001 + view->Topview->global_z);
- glVertex3f((GLfloat) view->mouse.GLfinalPos.x, (GLfloat) view->mouse.GLinitPos.y,
- (GLfloat) 0.001 + view->Topview->global_z);
- glVertex3f((GLfloat) view->mouse.GLinitPos.x, (GLfloat) view->mouse.GLinitPos.y,
- (GLfloat) 0.001 + view->Topview->global_z);
- glEnd();
- if (view->mouse.mouse_mode == 5)
- glDisable(GL_LINE_STIPPLE);
-
- }*/
-}
-#endif
-
-#if 0
-void draw_magnifier(ViewInfo * view)
-{
-
- if ((get_mode(view) == MM_MAGNIFIER)
- && (view->mouse.down)) {
-
- GLfloat mg_x, mg_y, mg_z;
- //converting screen pixel distaances to GL distances
- view->mg.GLwidth = GetOGLDistance(view->mg.width) / (float) 2.0;
- view->mg.GLheight = GetOGLDistance(view->mg.height) / (float) 2.0;
- GetOGLPosRef((int) view->mouse.pos.x, (int) view->mouse.pos.y, &mg_x, &mg_y, &mg_z); //retrieving mouse coords as GL coordinates
- view->mg.x = mg_x;
- view->mg.y = mg_y;
- glLineWidth(4);
-// local_zoom(view->Topview);
- //drawing the magnifier borders
- glBegin(GL_LINE_STRIP);
- glColor4f((GLfloat) 0.3, (GLfloat) 0.1, (GLfloat) 0.8,
- (GLfloat) 1);
- glVertex3f(view->mg.x - view->mg.GLwidth,
- view->mg.y - view->mg.GLheight, Z_MIDDLE_PLANE);
- glVertex3f(view->mg.x + view->mg.GLwidth,
- view->mg.y - view->mg.GLheight, Z_MIDDLE_PLANE);
- glVertex3f(view->mg.x + view->mg.GLwidth,
- view->mg.y + view->mg.GLheight, Z_MIDDLE_PLANE);
- glVertex3f(view->mg.x - view->mg.GLwidth,
- view->mg.y + view->mg.GLheight, Z_MIDDLE_PLANE);
- glVertex3f(view->mg.x - view->mg.GLwidth,
- view->mg.y - view->mg.GLheight, Z_MIDDLE_PLANE);
- glEnd();
- glBegin(GL_TRIANGLE_FAN);
- glColor4f(1, 1, 1, 1);
- glVertex3f(view->mg.x - view->mg.GLwidth + 1,
- view->mg.y - view->mg.GLheight + 1, Z_MIDDLE_PLANE);
- glVertex3f(view->mg.x + view->mg.GLwidth - 1,
- view->mg.y - view->mg.GLheight + 1, Z_MIDDLE_PLANE);
- glVertex3f(view->mg.x + view->mg.GLwidth - 1,
- view->mg.y + view->mg.GLheight - 1, Z_MIDDLE_PLANE);
- glVertex3f(view->mg.x - view->mg.GLwidth + 1,
- view->mg.y + view->mg.GLheight - 1, Z_MIDDLE_PLANE);
- glVertex3f(view->mg.x - view->mg.GLwidth + 1,
- view->mg.y - view->mg.GLheight + 1, Z_MIDDLE_PLANE);
- glEnd();
- glLineWidth(1);
- }
-
-}
-
-static void draw_circle(float originX, float originY, float radius)
-{
-/* draw a circle from a bunch of short lines */
- float vectorX1, vectorY1, vectorX, vectorY, angle;
- vectorY1 = originY + radius;
- vectorX1 = originX;
- glLineWidth(4);
- glBegin(GL_LINE_STRIP);
- for (angle = (float) 0.0; angle <= (float) (2.1 * 3.14159);
- angle += (float) 0.1) {
- vectorX = originX + radius * (float) sin(angle);
- vectorY = originY + radius * (float) cos(angle);
- glVertex3d(vectorX1, vectorY1, view->Topview->global_z);
- vectorY1 = vectorY;
- vectorX1 = vectorX;
- }
- glEnd();
- glLineWidth(1);
-
-}
-
-GLUquadric *fisheyesphere;
-void draw_fisheye_magnifier(ViewInfo * view)
-{
- if (get_mode(view)==MM_FISHEYE_MAGNIFIER) {
- float a;
- GLfloat mg_x, mg_y, mg_z;
- a = GetOGLDistance((int) view->fmg.constantR);
- view->fmg.R = (int) a;
- GetOGLPosRef((int) view->mouse.pos.x, (int) view->mouse.pos.y,
- &mg_x, &mg_y, &mg_z);
- glColor4f((GLfloat) 0.3, (GLfloat) 0.1, (GLfloat) 0.8,
- (GLfloat) 1);
- if ((view->fmg.x != mg_x) || (view->fmg.y != mg_y)) {
- if (view->active_camera == -1) {
- /* fisheye_polar(mg_x, mg_y, view->Topview); */
- draw_circle(mg_x, mg_y, a);
- }
- else {
- /* fisheye_spherical(mg_x, mg_y, 0.00, view->Topview); */
- if (!fisheyesphere)
- fisheyesphere = gluNewQuadric();
- gluQuadricDrawStyle(fisheyesphere, GLU_LINE);
- glColor4f((GLfloat) 0.3, (GLfloat) 0.1, (GLfloat) 0.8, (GLfloat) 0.05);
- glTranslatef(mg_x, mg_y, 0);
- gluSphere(fisheyesphere, a, 30, 30);
- glTranslatef(-mg_x, -mg_y, 0);
- }
- view->fmg.x = mg_x;
- view->fmg.y = mg_y;
- }
- }
-}
-#endif
-
void drawBorders(ViewInfo * view)
{
if (view->bdVisible) {
}
}
-/*static void drawXdot(xdot * xDot, int param, void *p)
-{
- int id;
- sdot_op *ops = (sdot_op *) (xDot->ops);
- sdot_op *op;
- //to avoid the overlapping , z is slightly increased for each xdot of a particular object
- if (AGTYPE(p)==AGEDGE)
- view->Topview->global_z=1;
- else
- view->Topview->global_z=0;
-
- for (id = 0; id < xDot->cnt; id++)
- {
- view->Topview->global_z += (float)GLOBAL_Z_OFFSET;
- op = ops + id;
- op->obj = p;
- op->op.drawfunc(&(op->op), param);
- }
- if (OD_Preselected(p) == 1)
- select_object(view->g[view->activeGraph], p);
- OD_Preselected(p) = 0;
-}*/
-
-
-#ifdef UNUSED
-static void drawXdotwithattr(void *p, char *attr, int param)
-{
-/* xdot *xDot;
- if ((xDot = parseXDotF(agget(p, attr), OpFns, sizeof(sdot_op))))
- {
- drawXdot(xDot, param, p);
- freeXDot(xDot);
- }*/
-}
-
-static void drawXdotwithattrs(void *e, int param)
-{
- /* drawXdotwithattr(e, "_draw_", param);
- drawXdotwithattr(e, "_ldraw_", param);
- drawXdotwithattr(e, "_hdraw_", param);
- drawXdotwithattr(e, "_tdraw_", param);
- drawXdotwithattr(e, "_hldraw_", param);
- drawXdotwithattr(e, "_tldraw_", param); */
-}
-#endif
-
-
-#if 0
-void drawGraph(Agraph_t * g)
-{
- Agnode_t *v;
- Agedge_t *e;
- Agraph_t *s;
- int param = 0;
- for (s = agfstsubg(g); s; s = agnxtsubg(s))
- {
- OD_SelFlag(s) = 0;
- if (OD_Selected(s) == 1)
- param = 1;
- else
- param = 0;
- drawXdotwithattrs(s, param);
- }
-
- for (v = agfstnode(g); v; v = agnxtnode(g, v))
- {
- if (OD_Selected(v) == 1)
- param = 1;
- else
- param = 0;
- OD_SelFlag(v) = 0;
- drawXdotwithattr(v, "_draw_", param); //draw primitives
- drawXdotwithattr(v, "_ldraw_", param);//label drawing
- for (e = agfstout(g, v); e; e = agnxtout(g, e))
- {
- OD_SelFlag(e) = 0;
- if (OD_Selected(e) == 1)
- param = 1;
- else
- param = 0;
- drawXdotwithattrs(e, param);
- }
- }
- if ((view->Selection.Active > 0) && (!view->SignalBlock))
- {
- view->Selection.Active = 0;
- drawGraph(g);
- view->SignalBlock = 1;
- glexpose();
- view->SignalBlock = 0;
- }
-
-}
-#endif
-
-#if 0
-
-/*
- this function is used to cache fonts in view->fontset
-*/
-
-static void scanXdot(xdot * xDot, void *p)
-{
- int id;
- sdot_op *ops = (sdot_op *) (xDot->ops);
- sdot_op *op;
-
- for (id = 0; id < xDot->cnt; id++) {
- op = ops + id;
- op->obj = p;
-/* if (op->op->kind == xd_font) {
-// add_font(view->widgets->fontset,op->op.u.font.name,op->op.u.font.size);//load or set active font
- }*/
- }
-
-}
-
-static void scanXdotwithattr(void *p, char *attr)
-{
- xdot *xDot;
- if ((xDot = parseXDotF(agget(p, attr), OpFns, sizeof(sdot_op)))) {
- scanXdot(xDot, p);
- freeXDot(xDot);
- }
-}
-
-static void scanXdotwithattrs(void *e)
-{
- scanXdotwithattr(e, "_draw_");
- scanXdotwithattr(e, "_ldraw_");
- scanXdotwithattr(e, "_hdraw_");
- scanXdotwithattr(e, "_tdraw_");
- scanXdotwithattr(e, "_hldraw_");
- scanXdotwithattr(e, "_tldraw_");
-}
-
-
-
-/*
- iterate in nodes and edges to cache fonts, run this once or whenever a new font is added to the graph
-*/
-
-static void scanGraph(Agraph_t * g)
-{
- Agnode_t *v;
- Agedge_t *e;
- for (v = agfstnode(g); v; v = agnxtnode(g, v)) {
- scanXdotwithattr(v, "_draw_");
- scanXdotwithattr(v, "_ldraw_");
- for (e = agfstout(g, v); e; e = agnxtout(g, e)) {
- scanXdotwithattrs(e);
- }
- }
-
-}
-int randomize_color(glCompColor * c, int brightness)
-{
- float R, B, G;
- float add;
- R = (float) (rand() % 255) / (float) 255.0;
- G = (float) (rand() % 255) / (float) 255.0;
- B = (float) (rand() % 255) / (float) 255.0;
- add = (brightness - (R + G + B)) / 3;
- R = R;
- G = G;
- B = B;
- c->R = R;
- c->G = G;
- c->B = B;
- return 1;
-}
-#endif
-
-
void drawCircle(float x, float y, float radius, float zdepth)
{
int i;
glEnd();
}
-#if 0
-int draw_node_hintbox_gl_polygon(GLfloat x, GLfloat y, GLfloat z,
- GLfloat fs, char *text)
-{
-
-
- GLfloat X, Y, Z, pad;
- pad = fs / (GLfloat) 5.0;
- X = x;
- Y = y;
- Z = z + (GLfloat) 0.0005;
- glBegin(GL_POLYGON);
- glVertex3f(X, Y, Z);
- Y = Y + fs;
- glVertex3f(X, Y, Z);
- X = X + fs;
- glVertex3f(X, Y, Z);
- X = x;
- y = y;
- glVertex3f(X, Y, Z);
- glEnd();
-
- X = x;
- Y = y + fs;
- glBegin(GL_POLYGON);
- glVertex3f(X, Y, Z);
- X = x;
- Y = Y + fs + 2 * pad;
- glVertex3f(X, Y, Z);
- X = x + strlen(text) * fs / (GLfloat) 2.0 + (GLfloat) 2.0 *pad;
- glVertex3f(X, Y, Z);
- Y = y + fs;
- glVertex3f(X, Y, Z);
- X = x;
- glVertex3f(X, Y, Z);
- glEnd();
-
-
- return 1;
-
-}
-int draw_node_hintbox_gl_line(GLfloat x, GLfloat y, GLfloat z, GLfloat fs,
- char *text)
-{
-
-
- GLfloat X, Y, Z, pad;
- pad = fs / (GLfloat) 5.0;
- X = x;
- Y = y;
- Z = z + (GLfloat) 0.001;
- glBegin(GL_LINE_STRIP);
- glVertex3f(X, Y, Z);
- Y = Y + 2 * fs + 2 * pad;
- glVertex3f(X, Y, Z);
- X = X + 2 * pad + strlen(text) * fs / (GLfloat) 2.0;
- glVertex3f(X, Y, Z);
- Y = y + fs;
- glVertex3f(X, Y, Z);
- X = x + fs;
- glVertex3f(X, Y, Z);
- X = x;
- Y = y;
- glVertex3f(X, Y, Z);
- glEnd();
-
-
-
- return 1;
-
-}
-
-
-int draw_node_hintbox(GLfloat x, GLfloat y, GLfloat z, GLfloat fs,
- char *text)
-{
-
-
- glColor3f(1, 1, 0);
- draw_node_hintbox_gl_polygon(x, y, z, fs, text);
- glColor3f(0, 0, 1);
- draw_node_hintbox_gl_line(x, y, z, fs, text);
- return 1;
-
-}
-#endif
-
-#if 0
-static GLUquadric *sphere;
-void draw_sphere(float x, float y, float z, float r)
-{
- if (!sphere)
- fisheyesphere = gluNewQuadric();
- gluQuadricDrawStyle(fisheyesphere, GLU_FILL);
- glTranslatef(x, y, z);
- gluSphere(fisheyesphere, r, SPHERE_SLICE_COUNT, SPHERE_SLICE_COUNT);
- glTranslatef(-x, -y, -z);
-}
-#endif
-
void draw_selpoly(glCompPoly* selPoly)
{
int i;
-/* glColor4f(view->gridColor.R, view->gridColor.G, view->gridColor.B,
- view->gridColor.A);*/
glColor4f(1,0,0,1);
glBegin(GL_LINE_STRIP);
for (i = 0;i < selPoly->cnt ; i++)
glEnd();
}
}
-
-#ifdef UNUSED
-void draw_xdot_set(xdot_set * s)
-{
- int ind = 0;
- int ind2 = 0;
- for (ind = 0; ind < s->cnt; ind++) {
- for (ind2 = 0; ind2 < s->xdots[ind]->cnt; ind2++) {
- xdot_op *op;
- op = &s->xdots[ind]->ops[ind2];
- if (op->drawfunc)
- op->drawfunc(op, 0);
- }
- }
-}
-#endif
* topview drawings are not here
*/
extern drawfunc_t OpFns[];
-extern void drawGraph(Agraph_t * g);
-#if 0
-extern void scanGraph(Agraph_t * g);
-extern int randomize_color(glCompColor * c, int brightness);
-extern void draw_sphere(float x, float y, float z, float r);
-extern int draw_node_hintbox(GLfloat x, GLfloat y, GLfloat z, GLfloat fs, char *text);
-extern glCompColor GetglCompColor(char *color);
-extern void draw_magnifier(ViewInfo * view);
-extern void draw_fisheye_magnifier(ViewInfo * view);
-#endif
-extern void draw_selection_box(ViewInfo * view);
extern void drawCircle(float x, float y, float radius, float zdepth);
extern void drawBorders(ViewInfo * view);
extern void drawEllipse(float xradius, float yradius, int angle1, int angle2);
extern void draw_selpoly(glCompPoly* selPoly);
-#if 0
- /*xdot drawing functions*/
-extern void DrawBeziers(sdot_op* o, int param);
-extern void DrawEllipse(sdot_op * op, int param);
-extern void DrawPolygon(sdot_op * op, int param);
-extern void DrawPolyline(sdot_op * op, int param);
-extern void SetFillColor(sdot_op* o, int param);
-extern void SetPenColor(sdot_op* o, int param);
-extern void SetStyle(sdot_op* o, int param);
-extern void SetFont(sdot_op * o, int param);
-extern void InsertImage(sdot_op * o, int param);
-extern void EmbedText(sdot_op * o, int param);
-#endif
-
typedef struct {
glCompColor color;
float width;
Status=1; // Set The Status To TRUE
}
-
-#if UNUSED
-void draw_cube_tex()
-{
-
-
- glRotatef(45,1,1,1);
- glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
- glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
- if(!Status)
- LoadGLTextures();
- if(!Status)
- return;
- glBindTexture(GL_TEXTURE_2D,texture[1]);
- glBegin(GL_QUADS);
- // Front Face
- glColor4f(1, 1, 1,1); // Color Blue
-
- glNormal3f( 0.0f, 0.0f, 1.0f);
- glTexCoord2f(0.0f, 0.0f); glVertex3f(-100.0f, -100.0f, 100.0f);
- glTexCoord2f(1.0f, 0.0f); glVertex3f( 100.0f, -100.0f, 100.0f);
- glTexCoord2f(1.0f, 1.0f); glVertex3f( 100.0f, 100.0f, 100.0f);
- glTexCoord2f(0.0f, 1.0f); glVertex3f(-100.0f, 100.0f, 100.0f);
- // Back Face
- glNormal3f( 0.0f, 0.0f,-1.0f);
- glTexCoord2f(1.0f, 0.0f); glVertex3f(-100.0f, -100.0f, -100.0f);
- glTexCoord2f(1.0f, 1.0f); glVertex3f(-100.0f, 100.0f, -100.0f);
- glTexCoord2f(0.0f, 1.0f); glVertex3f( 100.0f, 100.0f, -100.0f);
- glTexCoord2f(0.0f, 0.0f); glVertex3f( 100.0f, -100.0f, -100.0f);
- // Top Face
- glNormal3f( 0.0f, 1.0f, 0.0f);
- glTexCoord2f(0.0f, 1.0f); glVertex3f(-100.0f, 100.0f, -100.0f);
- glTexCoord2f(0.0f, 0.0f); glVertex3f(-100.0f, 100.0f, 100.0f);
- glTexCoord2f(1.0f, 0.0f); glVertex3f( 100.0f, 100.0f, 100.0f);
- glTexCoord2f(1.0f, 1.0f); glVertex3f( 100.0f, 100.0f, -100.0f);
- // Bottom Face
- glNormal3f( 0.0f,-1.0f, 0.0f);
- glTexCoord2f(1.0f, 1.0f); glVertex3f(-100.0f, -100.0f, -100.0f);
- glTexCoord2f(0.0f, 1.0f); glVertex3f( 100.0f, -100.0f, -100.0f);
- glTexCoord2f(0.0f, 0.0f); glVertex3f( 100.0f, -100.0f, 100.0f);
- glTexCoord2f(1.0f, 0.0f); glVertex3f(-100.0f, -100.0f, 100.0f);
- // Right face
- glNormal3f( 1.0f, 0.0f, 0.0f);
- glTexCoord2f(1.0f, 0.0f); glVertex3f( 100.0f, -100.0f, -100.0f);
- glTexCoord2f(1.0f, 1.0f); glVertex3f( 100.0f, 100.0f, -100.0f);
- glTexCoord2f(0.0f, 1.0f); glVertex3f( 100.0f, 100.0f, 100.0f);
- glTexCoord2f(0.0f, 0.0f); glVertex3f( 100.0f, -100.0f, 100.0f);
- // Left Face
- glNormal3f(-1.0f, 0.0f, 0.0f);
- glTexCoord2f(0.0f, 0.0f); glVertex3f(-100.0f, -100.0f, -100.0f);
- glTexCoord2f(1.0f, 0.0f); glVertex3f(-100.0f, -100.0f, 100.0f);
- glTexCoord2f(1.0f, 1.0f); glVertex3f(-100.0f, 100.0f, 100.0f);
- glTexCoord2f(0.0f, 1.0f); glVertex3f(-100.0f, 100.0f, -100.0f);
- glEnd();
- glDisable(GL_TEXTURE_2D); // Enable Texture Mapping
-
-
-
-}
-static void draw_cube()
-{
- glRotatef(30,1,1,1);
- glBegin(GL_QUADS); // Draw The Cube Using quads
- glColor4f(0.0f, 100.0f, 0.0f,0.5); // Color Blue
- glVertex3f(100.0f, 100.0f, -100.0f); // Top Right Of The Quad (Top)
- glVertex3f(-100.0f, 100.0f, -100.0f); // Top Left Of The Quad (Top)
- glVertex3f(-100.0f, 100.0f, 100.0f); // Bottom Left Of The Quad (Top)
- glVertex3f(100.0f, 100.0f, 100.0f); // Bottom Right Of The Quad (Top)
- glColor4f(100.0f, 0.5f, 0.0f,0.5); // Color Orange
- glVertex3f(100.0f, -100.0f, 100.0f); // Top Right Of The Quad (Bottom)
- glVertex3f(-100.0f, -100.0f, 100.0f); // Top Left Of The Quad (Bottom)
- glVertex3f(-100.0f, -100.0f, -100.0f); // Bottom Left Of The Quad (Bottom)
- glVertex3f(100.0f, -100.0f, -100.0f); // Bottom Right Of The Quad (Bottom)
- glColor4f(100.0f, 0.0f, 0.0f,0.5); // Color Red
- glVertex3f(100.0f, 100.0f, 100.0f); // Top Right Of The Quad (Front)
- glVertex3f(-100.0f, 100.0f, 100.0f); // Top Left Of The Quad (Front)
- glVertex3f(-100.0f, -100.0f, 100.0f); // Bottom Left Of The Quad (Front)
- glVertex3f(100.0f, -100.0f, 100.0f); // Bottom Right Of The Quad (Front)
- glColor3f(100.0f, 100.0f, 0.0f); // Color Yellow
- glVertex3f(100.0f, -100.0f, -100.0f); // Top Right Of The Quad (Back)
- glVertex3f(-100.0f, -100.0f, -100.0f); // Top Left Of The Quad (Back)
- glVertex3f(-100.0f, 100.0f, -100.0f); // Bottom Left Of The Quad (Back)
- glVertex3f(100.0f, 100.0f, -100.0f); // Bottom Right Of The Quad (Back)
- glColor3f(0.0f, 0.0f, 100.0f); // Color Blue
- glVertex3f(-100.0f, 100.0f, 100.0f); // Top Right Of The Quad (Left)
- glVertex3f(-100.0f, 100.0f, -100.0f); // Top Left Of The Quad (Left)
- glVertex3f(-100.0f, -100.0f, -100.0f); // Bottom Left Of The Quad (Left)
- glVertex3f(-100.0f, -100.0f, 100.0f); // Bottom Right Of The Quad (Left)
- glColor3f(100.0f, 0.0f, 100.0f); // Color Violet
- glVertex3f(100.0f, 100.0f, -100.0f); // Top Right Of The Quad (Right)
- glVertex3f(100.0f, 100.0f, 100.0f); // Top Left Of The Quad (Right)
- glVertex3f(100.0f, -100.0f, 100.0f); // Bottom Left Of The Quad (Right)
- glVertex3f(100.0f, -100.0f, -100.0f); // Bottom Right Of The Quad (Right)
- glEnd();
-}
-#endif
-
static void drawRotatingAxis(void)
{
static GLUquadricObj *quadratic;
if (!quadratic) {
quadratic = gluNewQuadric(); // Create A Pointer To The Quadric Object
gluQuadricNormals(quadratic, GLU_SMOOTH); // Create Smooth Normals
-// gluQuadricTexture(quadratic, GL_TRUE); // Create Texture Coords
gluQuadricDrawStyle(quadratic, GLU_LINE);
return 1;
}
-#if 0
-static void drawtestpoly(void)
-{
- glEnable(GL_TEXTURE_2D);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-// glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE , GL_DECAL);
-// glBindTexture(GL_TEXTURE_2D,view->widgets->fontset->fonts[view->widgets->fontset->activefont]->texId);
- glBindTexture(GL_TEXTURE_2D, 1);
- glColor4f(1, 1, 1, 1);
- glBegin(GL_QUADS);
- glTexCoord2f(0.0, 0.0);
- glVertex3f(0.0, 0.0, 0.0);
- glTexCoord2f(0.0, 1.0);
- glVertex3f(0.0, 256.0, 0.0);
- glTexCoord2f(1.0, 1.0);
- glVertex3f(256.0, 256.0, 0.0);
- glTexCoord2f(1.0, 0.0);
- glVertex3f(256.0, 0.0, 0.0);
- glTexCoord2f(0.0, 0.0);
- glVertex3f(0.0, 0.0, 0.0);
- glEnd();
- glDisable(GL_TEXTURE_2D);
-
-}
-#endif
-
/*
draws grid (little dots , with no use)
params:ViewInfo , global view variable defined in viewport.c
{
if (view->activeGraph > -1) {
-// if (GD_TopView(view->g[view->activeGraph]))
-// {
if (!view->Topview->fisheyeParams.active)
-// drawTopViewGraph(view->g[view->activeGraph]); //view->Topview style dots and straight lines
renderSmGraph(view->g[view->activeGraph],view->Topview);
else {
drawtopologicalfisheye(view->Topview);
}
-// }
-// else
-// drawGraph(view->g[view->activeGraph]); //xdot based drawing functions
return 1;
}
return 0;
}
-#if 0
-static void test_color_pallete(void)
-{
- int ind = 0;
- float xGAP = 5;
- float yGAP = 80;
- float x = 50;
- float y = 50;
- glCompColor c;
- for (ind = 0; ind < 350; ind++) {
- getcolorfromschema(view->colschms, ind, 350, &c);
- x = ind * xGAP;
- glBegin(GL_POLYGON);
- glColor3f(c.R, c.G, c.B);
- glVertex3f(x, y, 0.0);
- glVertex3f(x + xGAP, y, 0.0);
- glVertex3f(x + xGAP, y + yGAP, 0.0);
- glVertex3f(x, y + yGAP, 0.0);
- glEnd();
- }
-}
-#endif
/*
main gl expose ,any time sreen needs to be redrawn, this function is called by gltemplate
,all drawings are initialized in this function
if (!glupdatecamera(view))
return 0;
-// glEnable(GL_DEPTH_TEST);
-// draw_cube();
-// draw_cube_tex();
-
-
if (view->activeGraph >= 0) {
if (!doonce) {
doonce = 1;
glexpose_grid(view);
-#if UNUSED
- draw_fisheye_magnifier(view);
- draw_magnifier(view);
-#endif
drawBorders(view);
glexpose_drawgraph(view);
drawRotatingAxis();
draw_selpoly(&view->Topview->sel.selPoly);
glCompSetDraw(view->widgets);
-// draw_stuff();
-// test_color_pallete();
-// drawtestpoly();
- /*DEBUG*/
-/* if (view->mouse.mouse_mode == MM_PAN)
- {
- glBegin(GL_LINE_STRIP);
- glColor4f((GLfloat) 1, (GLfloat) 0.0, (GLfloat) 0.0,
- (GLfloat) 1);
- glVertex3f((GLfloat) view->GLx, (GLfloat) view->GLy,
- (GLfloat) 0.001);
- glVertex3f((GLfloat) view->GLx2, (GLfloat) view->GLy2,
- (GLfloat) 0.001);
-
-
- glEnd();
- }*/
/*DEBUG*/ return 1;
}
-
-/*
-void drawRotatingTools(void)
-{
- float x, y;
- float x1, y1, z1;
- float x2, y2, z2;
- float R1, R2;
- if ((view->mouse.mouse_mode == MM_ROTATE)
- && (view->active_camera >= 0)) {
- R1 = 25;
- R2 = 200;
- glCompDrawBegin();
- GetOGLPosRef(1, view->h - 5, &x1, &y1, &z1);
- GetOGLPosRef(view->w - 1, 1, &x2, &y2, &z2);
- x = (x2 - x1) / (float) 2.0;
- y = (y2 - y1) / (float) 2.0;
- glTranslatef(x, y, 0);
- if ((view->mouse.rotate_axis == MOUSE_ROTATE_X)
- || (view->mouse.rotate_axis == MOUSE_ROTATE_XY)) {
- glLineWidth(2);
- glColor4f(0, 1, 0, 0.5);
- } else {
- glLineWidth(1);
- glColor4f(1, 0, 0, 0.5);
- }
- drawEllipse(R1, R2, 90, 270);
- if ((view->mouse.rotate_axis == MOUSE_ROTATE_Y)
- || (view->mouse.rotate_axis == MOUSE_ROTATE_XY)) {
- glLineWidth(2);
- glColor4f(0, 1, 0, 0.5);
- } else {
- glLineWidth(1);
- glColor4f(1, 0, 0, 0.5);
- }
- drawEllipse(R2, R1, 0, 180);
- if (view->mouse.rotate_axis == MOUSE_ROTATE_Z) {
- glLineWidth(2);
- glColor4f(0, 1, 0, 0.5);
- } else {
- glLineWidth(1);
- glColor4f(1, 0, 0, 0.5);
- }
-
- drawEllipse(R2, R2, 0, 360);
- glCompDrawEnd();
- }
-
-}
-*/
}
void cb_display(void )
{
-// glClearColor(view->bgColor.R, view->bgColor.G, view->bgColor.B, view->bgColor.A);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glexpose_main(view); //draw all stuff
-// draw_cube_tex();
glutSwapBuffers();
if (view->initFile) {
view->initFile = 0;
}
void cb_mouseover(int x,int y)/*no mouse click only mouse pointer moving on context*/
{
-
-
-
-
-
-
-
-
}
void cb_drag(int X,int Y)/*mouse moving witha button clicked (dragging)*/
{
glutInit(argcp,argv); //this is required by some OS.
-// glutInitDisplayMode( GLUT_ALPHA | GLUT_DOUBLE | GLUT_RGBA);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
// The Type Of Depth Testing To Do
-/* glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glShadeModel(GL_SMOOTH);*/
glDisable(GL_DEPTH);
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
return 0; //we should never reach here
}
-
-
*p = '\0';
return buf;
}
-#if 0
-static int late_int(void *obj,Agsym_t* attr, int def, int low)
-{
- char *p;
- int rv;
- if (attr == NULL)
- return def;
- p = agxget(obj, attr);
- if (!p || p[0] == '\0')
- return def;
- if ((rv = atoi(p)) < low)
- rv = low;
- return rv;
-}
-
-static double late_double(void *obj, Agsym_t* attr, double def, double low)
-{
- char *p;
- double rv;
-
- if (!attr || !obj)
- return def;
- p = agxget(obj, attr);
- if (!p || p[0] == '\0')
- return def;
- if ((rv = atof(p)) < low)
- rv = low;
- return rv;
-}
-
-static char *late_nnstring(void *obj, Agsym_t * attr, char *def)
-{
- char *rv = late_string(obj, attr, def);
- if (!rv || (rv[0] == '\0'))
- rv = def;
- return rv;
-}
-
-#endif
static char* late_string(void *obj, Agsym_t * attr, char *def)
{
return p;
}
-
-#if 0
-static float interpol(float minv, float maxv, float minc, float maxc, float x)
-{
- return ((x - minv) * (maxc - minc) / (maxv - minv) + minc);
-}
-
-
-void
-getcolorfromschema(colorschemaset * sc, float l, float maxl,glCompColor * c)
-{
- int ind;
- float percl = l / maxl * 100.00;
- for (ind = 0; ind < sc->schemacount; ind++) {
- if (percl < sc->s[ind].perc)
- break;
- }
-
- if (sc->s[ind].smooth) {
- c->R =
- interpol(sc->s[ind - 1].perc, sc->s[ind].perc,
- sc->s[ind - 1].c.R, sc->s[ind].c.R, percl);
- c->G =
- interpol(sc->s[ind - 1].perc, sc->s[ind].perc,
- sc->s[ind - 1].c.G, sc->s[ind].c.G, percl);
- c->B =
- interpol(sc->s[ind - 1].perc, sc->s[ind].perc,
- sc->s[ind - 1].c.B, sc->s[ind].c.B, percl);
- c->A = 1;
- } else {
- c->R = sc->s[ind].c.R;
- c->G = sc->s[ind].c.G;
- c->B = sc->s[ind].c.B;
- c->A = 1;
- }
-}
-#endif
-
int point_within_ellips_with_coords(float ex, float ey, float ea, float eb,
float px, float py)
{
return 1;
return 0;
}
-#if 0
-float distance_to_line(float ax, float ay, float bx, float by, float cx,
- float cy)
-{
- //this function returns the distance between a line(a-b) segment and a point(c) in 2D plane
- return (float)
- sqrt(pow(((by - ay) * (cx - ax) + (bx - ax) * (cy - ay)), 2)
- / (pow((bx - ax), 2) + pow((by - ay), 2))
- );
-}
-
-int _point_in_polygon(int npol, float *xp, float *yp, float x, float y)
-{
- int i, j, c = 0;
- for (i = 0, j = npol-1; i < npol; j = i++) {
- if ((((yp[i] <= y) && (y < yp[j])) ||
- ((yp[j] <= y) && (y < yp[i]))) &&
- (x < (xp[j] - xp[i]) * (y - yp[i]) / (yp[j] - yp[i]) + xp[i]))
- c = !c;
- }
- return c;
-}
-#endif
-
int point_in_polygon(glCompPoly* selPoly,glCompPoint p)
{
}
return c;
}
-
-
extern void setColor(glCompColor* c,GLfloat R,GLfloat G,GLfloat B,GLfloat A);
extern void getcolorfromschema(colorschemaset * sc, float l, float maxl,glCompColor * c);
extern glCompPoint getPointFromStr(char* str);
-#if 0
-extern float distance_to_line(float ax, float ay, float bx, float by, float cx,float cy);
-#endif
extern int point_in_polygon(glCompPoly* selPoly,glCompPoint p);
extern int point_within_ellips_with_coords(float ex, float ey,
float ea, float eb,