Exemplo n.º 1
0
/*
	initialize the gl , run only once!!
	params:gtk opgn gl canvas and optional data pointer
	return value:none
*/
static void realize(GtkWidget * widget, gpointer data)
{

    GdkGLContext *glcontext = gtk_widget_get_gl_context(widget);
    GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget);

    /*smyrna does not use any ligthting affects but can be turned on for more effects in the future */
    GLfloat ambient[] = { 0.0, 0.0, 0.0, 1.0 };
    GLfloat diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
    GLfloat position[] = { 0.0, 3.0, 3.0, 0.0 };

    GLfloat lmodel_ambient[] = { 0.2f, 0.2f, 0.2f, 1.0f };
    GLfloat local_view[] = { 0.0 };

    static char *smyrna_font;

#ifdef WIN32
    smyrna_font = "c:/arial.tga";
#else
    smyrna_font = smyrnaPath("arial.tga");
#endif
    g_print("loading font....%i\n", fontLoad(smyrna_font));

  /*** OpenGL BEGIN ***/
    if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext))
	return;

    glClearColor(view->bgColor.R, view->bgColor.G, view->bgColor.B, view->bgColor.A);	//background color
    glClearDepth(1.0);

    glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
    glLightfv(GL_LIGHT0, GL_POSITION, position);
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
    glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view);

    glFrontFace(GL_CW);
// glEnable (GL_LIGHTING);
//  glEnable (GL_LIGHT0);
//  glEnable (GL_AUTO_NORMAL);
//  glEnable (GL_NORMALIZE);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glDepthFunc(GL_LESS);
//  glEnable(GL_LINE_SMOOTH);

    gdk_gl_drawable_gl_end(gldrawable);
  /*** OpenGL END ***/
    return;
}
Exemplo n.º 2
0
glCompSet *glcreate_gl_topview_menu(void)
{
    /* static char* icondir[512]; */
    /* int ind=0; */
    GLfloat y = 5;
    GLfloat off = 43;
    glCompSet *s = glCompSetNew(view->w, view->h);
    glCompPanel *p = NULL;
    glCompButton *b = NULL;
    /* glCompLabel *l=NULL; */
    glCompImage *i = NULL;
    /* glCompLabel* l; */
    glCompColor c;
    s->common.callbacks.click = CBglCompMouseRightClick;

    p = glCompPanelNew((glCompObj *) s, 25, 25, 45, 47);
    p->common.align = glAlignLeft;
    p->common.data = 0;

    /*pan */
    b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
    glCompButtonAddPngGlyph(b, smyrnaPath("pan.png"));
    b->common.callbacks.click = menu_click_pan;
    panBtn = b;

    y = y + off;

    /*switch to fisheye */
    b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
    glCompButtonAddPngGlyph(b, smyrnaPath("fisheye.png"));
    b->common.callbacks.click = menu_switch_to_fisheye;
    toFisheye = b;


    /*switch to normal mode */
    b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
    glCompButtonAddPngGlyph(b, smyrnaPath("no_fisheye.png"));
    b->common.callbacks.click = menu_switch_to_fisheye;
    b->common.visible = 0;
    toNormal = b;

    y=y+off;
    b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
    glCompButtonAddPngGlyph(b, smyrnaPath("3D.png"));
    b->common.callbacks.click = switch2D3D;
    to3DBtn = b;


    b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
    glCompButtonAddPngGlyph(b, smyrnaPath("2D.png"));
    b->common.callbacks.click = switch2D3D;
    glCompButtonHide(b);
    to2DBtn = b;

    y=y+off;
    b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "N");
    b->common.callbacks.click = (glcompclickfunc_t)selectnodes;
    b->groupid=-1;
    b->status=1;

    y=y+off;
    b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "E");
    b->common.callbacks.click = (glcompclickfunc_t)selectedges;
    b->groupid=-1;

    p = glCompPanelNew((glCompObj *) p, 1, 325, 45, 180);
    p->common.align = glAlignTop;
    p->common.data = 0;
    p->common.borderWidth = 1;
    p->shadowwidth = 0;

    c.R = 0.80;
    c.G = 0.6;
    c.B = 0.6;
    c.A = 1.6;

    y = 1;

    b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
    glCompButtonAddPngGlyph(b, smyrnaPath("details.png"));
    b->common.callbacks.click = attrList;
    copy_glcomp_color(&c, &b->common.color);

	
    y = y + off;
	
	b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
    glCompButtonAddPngGlyph(b, smyrnaPath("zoomin.png"));
    b->groupid = 0;
    b->common.callbacks.click = menu_click_zoom_plus;
    copy_glcomp_color(&c, &b->common.color);
    y = y + off;


    b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
    glCompButtonAddPngGlyph(b, smyrnaPath("zoomout.png"));
    b->common.callbacks.click = menu_click_zoom_minus;
    copy_glcomp_color(&c, &b->common.color);

    y = y + off;


    b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
    glCompButtonAddPngGlyph(b, smyrnaPath("center.png"));
    b->common.callbacks.click = menu_click_center;
    copy_glcomp_color(&c, &b->common.color);



	
	







    p = glCompPanelNew((glCompObj *) s, -250, 550, 150, 175);
    p->common.borderWidth = 0;
    p->shadowwidth = 0;
    p->common.color.R = 0;
    p->common.color.G = 0;
    p->common.color.B = 1;
    p->common.color.A = 0.2;
    p->common.visible = 0;
    sel = p;
    s->common.callbacks.mouseover = glCompMouseMove;
    s->common.callbacks.mouseup = CBglCompMouseUp;


    p = glCompPanelNew((glCompObj *) s, 25, 25, 52, 47);
    p->common.align = glAlignRight;
    p->common.data = 0;
    p->common.color.A = 0;




	
    p = glCompPanelNew((glCompObj *) p, 25, 0, 52, 110);
    p->common.align = glAlignTop;
    p->common.data = 0;
    p->common.color.A = 0;
    p->shadowwidth = 0;

    i = glCompImageNew((glCompObj *) p, 0, 0);
    glCompImageLoadPng(i, smyrnaPath("mod_fisheye.png"),1);
    imgFisheye = i;
    i->common.visible = 0;

    i = glCompImageNew((glCompObj *) p, 0, 52);
    glCompImageLoadPng(i, smyrnaPath("mod_3D.png"),1);
    img3D = i;
    i->common.visible = 0;
    

    return s;



}
Exemplo n.º 3
0
void load_attributes(void)
{
    FILE *file;
    char line[BUFSIZ];
    char *ss;
    char *pch;
    int ind = 0;
    int attrcount = 0;
    static char *smyrna_attrs;

    if (!smyrna_attrs) {
	smyrna_attrs = smyrnaPath("attrs.txt");
    }
    //loads attributes from a text file
    file = fopen(smyrna_attrs, "r");
    if (file != NULL) {
	while (fgets(line, sizeof line, file) != NULL) {
	    pch = strtok(line, ",");
	    ind = 0;
	    while (pch != NULL) {
		ss = strdup(pch);
		//                              ABRemove(&ss,'\"');
		//                              ABRemove(&ss,' ');
		pch = strtok(NULL, ",");
		switch (ind) {
		case 0:
		    attr[attrcount].Type = ss[0];
		    break;
		case 1:
		    attr[attrcount].Name = strdup(ss);
		    break;
		case 2:
		    attr[attrcount].Default = strdup(ss);
		    break;
		case 3:
		    if (strstr(ss, "ANY_ELEMENT")) {
			attr[attrcount].ApplyTo[GVE_GRAPH] = 1;
			attr[attrcount].ApplyTo[GVE_CLUSTER] = 1;
			attr[attrcount].ApplyTo[GVE_NODE] = 1;
			attr[attrcount].ApplyTo[GVE_EDGE] = 1;
		    } else {
			attr[attrcount].ApplyTo[GVE_GRAPH] =
			    strstr(ss, "GRAPH") ? 1 : 0;
			attr[attrcount].ApplyTo[GVE_CLUSTER] =
			    strstr(ss, "CLUSTER") ? 1 : 0;
			attr[attrcount].ApplyTo[GVE_NODE] =
			    strstr(ss, "NODE") ? 1 : 0;
			attr[attrcount].ApplyTo[GVE_EDGE] =
			    strstr(ss, "EDGE") ? 1 : 0;
		    }
		    break;
		case 4:
		    if (strstr(ss, "ALL_ENGINES")) {
			attr[attrcount].Engine[GVK_DOT] = 1;
			attr[attrcount].Engine[GVK_NEATO] = 1;
			attr[attrcount].Engine[GVK_TWOPI] = 1;
			attr[attrcount].Engine[GVK_CIRCO] = 1;
			attr[attrcount].Engine[GVK_FDP] = 1;
		    } else {
			attr[attrcount].Engine[GVK_DOT] =
			    strstr(ss, "DOT") ? 1 : 0;
			attr[attrcount].Engine[GVK_NEATO] =
			    strstr(ss, "NEATO") ? 1 : 0;
			attr[attrcount].Engine[GVK_TWOPI] =
			    strstr(ss, "TWOPI") ? 1 : 0;
			attr[attrcount].Engine[GVK_CIRCO] =
			    strstr(ss, "CIRCO") ? 1 : 0;
			attr[attrcount].Engine[GVK_FDP] =
			    strstr(ss, "FDP") ? 1 : 0;
		    }
		    break;
		default:
		    attr[attrcount].ComboValues =
			RALLOC(attr[attrcount].ComboValuesCount,
			       attr[attrcount].ComboValues, char *);
		    attr[attrcount].ComboValues[attr[attrcount].
						ComboValuesCount] =
			strdup(ss);
		    attr[attrcount].ComboValuesCount++;
		    break;
		}
		ind++;
	    }
	    attrcount++;
	}
	fclose (file);
    }
}
Exemplo n.º 4
0
void load_mouse_actions(char *modefile, ViewInfo * v)
{
/*#define MM_PAN					0
#define MM_ZOOM					1
#define MM_ROTATE				2
#define MM_SINGLE_SELECT		3
#define MM_RECTANGULAR_SELECT	4
#define MM_RECTANGULAR_X_SELECT	5
#define MM_MOVE					10
#define MM_MAGNIFIER			20
#define MM_FISHEYE_MAGNIFIER	21*/
    /*file parsing is temporarrily not available */
    int i = 0;
    FILE *file;
    char line[BUFSIZ];
    char *a;
    char *action_file = smyrnaPath("mouse_actions.txt");
    file = fopen(action_file, "r");
    if (file != NULL) {
	int ind = 0;
	while (fgets(line, BUFSIZ, file) != NULL) {
	    int idx = 0;
	    a = strtok(line, ",");

	    if ((line[0] == '#') || (line[0] == ' ')
		|| (strlen(line) == 0))
		continue;

	    v->mouse_action_count++;
	    v->mouse_actions =
		realloc(v->mouse_actions,
			v->mouse_action_count * sizeof(mouse_action_t));
	    v->mouse_actions[ind].action = get_mouse_mode(a);
	    v->mouse_actions[ind].index = i;

	    while ((a = strtok(NULL, ","))) {
		//#Action(0),hotkey(1),view_mode(2),mouse_button(3),drag(4)
		switch (idx) {
		case 0:
		    v->mouse_actions[ind].hotkey = get_button(a);
		    break;
		case 1:
		    v->mouse_actions[ind].mode = get_view_mode(a);
		    break;
		case 2:
		    v->mouse_actions[ind].type = get_mouse_button(a);
		    break;
		case 3:
		    v->mouse_actions[ind].drag = get_drag(a);
		    break;

		}
		idx++;
	    }
	    ind++;
	}
	fclose(file);
    }
    free(action_file);


/*
    v->mouse_action_count=7;
    v->mouse_actions=realloc(v->mouse_actions,v->mouse_action_count * sizeof(mouse_action_t));
    v->mouse_actions[ind].action=MM_PAN;
    v->mouse_actions[ind].drag=1;
    v->mouse_actions[ind].hotkey=0;
    v->mouse_actions[ind].index=ind;
    v->mouse_actions[ind].mode=smyrna_all;
    v->mouse_actions[ind].type=glMouseLeftButton;

    ind++;

    v->mouse_actions[ind].action=MM_ROTATE;
    v->mouse_actions[ind].drag=1;
    v->mouse_actions[ind].hotkey=B_LSHIFT;
    v->mouse_actions[ind].index=ind;
    v->mouse_actions[ind].mode=smyrna_3D;
    v->mouse_actions[ind].type=glMouseLeftButton;

    ind++;

    v->mouse_actions[ind].action=MM_SINGLE_SELECT;
    v->mouse_actions[ind].drag=0;
    v->mouse_actions[ind].hotkey=0;
    v->mouse_actions[ind].index=ind;
    v->mouse_actions[ind].mode=smyrna_all_but_fisheye;
    v->mouse_actions[ind].type=glMouseLeftButton;

    ind++;

    v->mouse_actions[ind].action=MM_RECTANGULAR_SELECT;
    v->mouse_actions[ind].drag=1;
    v->mouse_actions[ind].hotkey=0;
    v->mouse_actions[ind].index=ind;
    v->mouse_actions[ind].mode=smyrna_all;
    v->mouse_actions[ind].type=glMouseRightButton;

    ind++;

    v->mouse_actions[ind].action=MM_MOVE;
    v->mouse_actions[ind].drag=1;
    v->mouse_actions[ind].hotkey=B_LCTRL;
    v->mouse_actions[ind].index=ind;
    v->mouse_actions[ind].mode=smyrna_2D;
    v->mouse_actions[ind].type=glMouseLeftButton;

    ind++;

    v->mouse_actions[ind].action=MM_FISHEYE_MAGNIFIER;
    v->mouse_actions[ind].drag=1;
    v->mouse_actions[ind].hotkey=B_LSHIFT;
    v->mouse_actions[ind].index=ind;
    v->mouse_actions[ind].mode=smyrna_2D;
    v->mouse_actions[ind].type=glMouseLeftButton;

    ind++;

    v->mouse_actions[ind].action=MM_FISHEYE_PICK;
    v->mouse_actions[ind].drag=0;
    v->mouse_actions[ind].hotkey=0;
    v->mouse_actions[ind].index=ind;
    v->mouse_actions[ind].mode=smyrna_fisheye;
    v->mouse_actions[ind].type=glMouseRightButton;
*/
}