From: arif Date: Wed, 4 Aug 2010 15:02:36 +0000 (+0000) Subject: glutrender files X-Git-Tag: LAST_LIBGRAPH~32^2~1233 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b988a5dacb04fbe54008da32252ce44f27e64db7;p=graphviz glutrender files --- diff --git a/cmd/smyrna/Makefile.am b/cmd/smyrna/Makefile.am index 2c3a5f9a0..a803ee9e3 100644 --- a/cmd/smyrna/Makefile.am +++ b/cmd/smyrna/Makefile.am @@ -43,7 +43,7 @@ noinst_HEADERS = arcball.h draw.h glexpose.h \ viewport.h viewportcamera.h support.h \ gui/datalistcallbacks.h gui/frmobjectui.h \ gui/glcompui.h gui/gui.h gui/menucallbacks.h \ - gui/toolboxcallbacks.h gui/topviewsettings.h gvprpipe.h hier.h + gui/toolboxcallbacks.h gui/topviewsettings.h gvprpipe.h hier.h glutrender.h smyrna_SOURCES = arcball.c draw.c glexpose.c \ glmotion.c gltemplate.c gui/appmouse.c gui/callbacks.c \ @@ -53,7 +53,7 @@ smyrna_SOURCES = arcball.c draw.c glexpose.c \ viewport.c viewportcamera.c \ gui/datalistcallbacks.c gui/frmobjectui.c \ gui/glcompui.c gui/gui.c gui/menucallbacks.c \ - gui/toolboxcallbacks.c gui/topviewsettings.c + gui/toolboxcallbacks.c gui/topviewsettings.c glutrender.c smyrna_LDADD = $(top_builddir)/lib/cgraph/libcgraph_C.la \ $(top_builddir)/lib/cdt/libcdt_C.la \ diff --git a/cmd/smyrna/glutrender.c b/cmd/smyrna/glutrender.c new file mode 100644 index 000000000..9b41bc042 --- /dev/null +++ b/cmd/smyrna/glutrender.c @@ -0,0 +1,223 @@ +/* $Id$ $Revision$ */ +/* vim:set shiftwidth=4 ts=8: */ + +/********************************************************** +* This software is part of the graphviz package * +* http://www.graphviz.org/ * +* * +* Copyright (c) 1994-2004 AT&T Corp. * +* and is licensed under the * +* Common Public License, Version 1.0 * +* by AT&T Corp. * +* * +* Information and Software Systems Research * +* AT&T Research, Florham Park NJ * +**********************************************************/ + +#include "glutrender.h" +#include "viewport.h" +#include "arcball.h" +#include "appmouse.h" +#include "glexpose.h" + + + /*call backs */ + +static float begin_x = 0.0; +static float begin_y = 0.0; +static float dx = 0.0; +static float dy = 0.0; + +/*mouse mode mapping funvtion from glut to glcomp*/ +static glMouseButtonType getGlCompMouseType(int n) +{ + switch (n) { + case GLUT_LEFT_BUTTON: + return glMouseLeftButton; + case GLUT_RIGHT_BUTTON: + return glMouseMiddleButton; + case GLUT_MIDDLE_BUTTON: + return glMouseRightButton; + + default: + return glMouseLeftButton; + } +} + + +void cb_glutreshape(int width, int height) +{ + /* static int doonce=0; */ + int vPort[4]; + float aspect; + view->w = width; + view->h = height; + if (view->widgets) + glcompsetUpdateBorder(view->widgets, view->w, view->h); + glViewport(0, 0, view->w, view->h); + /* get current viewport */ + glGetIntegerv(GL_VIEWPORT, vPort); + /* setup various opengl things that we need */ + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + init_arcBall(view->arcball, (GLfloat) view->w, (GLfloat) view->h); + if (view->w > view->h) { + aspect = (float) view->w / (float) view->h; + glOrtho(-aspect * GL_VIEWPORT_FACTOR, aspect * GL_VIEWPORT_FACTOR, + GL_VIEWPORT_FACTOR * -1, GL_VIEWPORT_FACTOR, -1500, 1500); + } else { + aspect = (float) view->h / (float) view->w; + glOrtho(GL_VIEWPORT_FACTOR * -1, GL_VIEWPORT_FACTOR, + -aspect * GL_VIEWPORT_FACTOR, aspect * GL_VIEWPORT_FACTOR, + -1500, 1500); + } + + glMatrixMode(GL_MODELVIEW); + /*** OpenGL END ***/ + +} +void cb_glutdisplay() +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glClearColor(view->bgColor.R, view->bgColor.G, view->bgColor.B, view->bgColor.A); + glLoadIdentity(); + glexpose_main(view); //draw all stuff + glutSwapBuffers(); + if (view->initFile) { + view->initFile = 0; + if (view->activeGraph == 0) + close_graph(view, 0); + add_graph_to_viewport_from_file(view->initFileName); + } + +} +void cb_mouseclick(int button, int state,int x, int y) +{ + Agraph_t* g; + + if (view->g == 0) return; + g=view->g[view->activeGraph]; + begin_x = (float) x; + begin_y = (float) y; + if(state==GLUT_DOWN) + { + view->widgets->common.functions.mousedown((glCompObj*)view->widgets,(GLfloat) x,(GLfloat)y,getGlCompMouseType(button)); + if (button == GLUT_LEFT_BUTTON) + appmouse_left_click_down(view,x,y); + if (button == GLUT_RIGHT_BUTTON) + appmouse_right_click_down(view,x,y); + if (button == GLUT_MIDDLE_BUTTON) + appmouse_middle_click_down(view,x,y); + } + else + { + view->FontSizeConst = GetOGLDistance(14); + view->arcball->isDragging = 0; + view->widgets->common.functions.mouseup((glCompObj*)view->widgets,(GLfloat) x,(GLfloat) y,getGlCompMouseType(button)); + + if (button == GLUT_LEFT_BUTTON) + appmouse_left_click_up(view,x,y); + if (button == GLUT_LEFT_BUTTON) + appmouse_right_click_up(view,x,y); + if (button == GLUT_MIDDLE_BUTTON) + appmouse_middle_click_up(view,x,y); + dx = 0.0; + dy = 0.0; + } + cb_glutdisplay(); + +} +void cb_mouseover(int x,int y)/*no mouse click only mouse pointer moving on context*/ +{ + + + + + + + + +} +void cb_mouseover2(int X,int Y)/*mouse moving witha button clicked (dragging)*/ +{ + + float x = (float) X; + float y = (float) Y; + + if (view->widgets) + view->widgets->common.functions.mouseover((glCompObj*)view->widgets, (GLfloat) x,(GLfloat) y); + + dx = x - begin_x; + dy = y - begin_y; + view->mouse.dragX = dx; + view->mouse.dragY = dy; + appmouse_move(view,x,y); + + if((view->mouse.t==glMouseLeftButton) && (view->mouse.down) ) + appmouse_left_drag(view,x,y); + if((view->mouse.t==glMouseRightButton) && (view->mouse.down)) + appmouse_right_drag(view,x,y); + if((view->mouse.t==glMouseMiddleButton) && (view->mouse.down)) + appmouse_middle_drag(view,x,y); + begin_x = x; + begin_y = y; + cb_glutdisplay(); + +} + + +void sm_glutinit(int w,int h,int full) +{ + glutInitWindowSize(512,512); + glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH|GLUT_RGBA|GLUT_ALPHA|GLUT_STENCIL); + + +// glutInitDisplayMode ( GLUT_RGBA | GLUT_DOUBLE); + glutCreateWindow("The glut hello world program"); + glutDisplayFunc(cb_glutdisplay); + glutReshapeFunc(cb_glutreshape); + glutMouseFunc(cb_mouseclick); + glutMotionFunc(cb_mouseover2); + glutFullScreen(); + + glClearColor(view->bgColor.R, view->bgColor.G, view->bgColor.B, view->bgColor.A); //background color + glClearDepth(1.0); + glClear(GL_COLOR_BUFFER_BIT); + + + glFrontFace(GL_CW); +// glEnable (GL_LIGHTING); +// glEnable (GL_LIGHT0); +// glEnable (GL_AUTO_NORMAL); +// glEnable (GL_NORMALIZE); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDepthFunc(GL_LESS); + glDisable(GL_DEPTH); +// glEnable(GL_LINE_SMOOTH); + + + +/* * 7.1 glutDisplayFunc + * 7.2 glutOverlayDisplayFunc + * 7.3 glutReshapeFunc + * 7.4 glutKeyboardFunc + * 7.5 glutMouseFunc + * 7.6 glutMotionFunc, glutPassiveMotionFunc + * 7.7 glutVisibilityFunc + * 7.8 glutEntryFunc + * 7.9 glutSpecialFunc + * 7.10 glutSpaceballMotionFunc + * 7.11 glutSpaceballRotateFunc + * 7.12 glutSpaceballButtonFunc + * 7.13 glutButtonBoxFunc + * 7.14 glutDialsFunc + * 7.15 glutTabletMotionFunc + * 7.16 glutTabletButtonFunc + * 7.17 glutMenuStatusFunc + * 7.18 glutIdleFunc + * 7.19 glutTimerFunc + */ + glutMainLoop(); // Infinite event loop +} + diff --git a/cmd/smyrna/glutrender.h b/cmd/smyrna/glutrender.h new file mode 100644 index 000000000..7fce19745 --- /dev/null +++ b/cmd/smyrna/glutrender.h @@ -0,0 +1,14 @@ +#ifndef GLUTRENDER_H +#define GLUTRENDER_H + + +#ifdef __cplusplus +extern "C" { +#endif + + void sm_glutinit(int w,int h,int full); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif +#endif diff --git a/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user b/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user index f2fba747f..f97efcafa 100644 --- a/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user +++ b/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user @@ -11,7 +11,7 @@