From: erg Date: Mon, 19 Jul 2010 16:30:41 +0000 (+0000) Subject: Fix formatting; add copyright notice X-Git-Tag: LAST_LIBGRAPH~32^2~1260 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6e84024d0bd0a8ede79faae9125422f8547b958a;p=graphviz Fix formatting; add copyright notice --- diff --git a/cmd/smyrna/hotkeymap.c b/cmd/smyrna/hotkeymap.c index dd3b8a68f..1b1929634 100644 --- a/cmd/smyrna/hotkeymap.c +++ b/cmd/smyrna/hotkeymap.c @@ -1,83 +1,98 @@ +/* $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 "hotkeymap.h" -int static get_mouse_mode(const char* s) +int static get_mouse_mode(const char *s) { - if (strcmp(s,"MM_PAN")==0) + if (strcmp(s, "MM_PAN") == 0) return MM_PAN; - if (strcmp(s,"MM_ZOOM")==0) + if (strcmp(s, "MM_ZOOM") == 0) return MM_ZOOM; - if (strcmp(s,"MM_ROTATE")==0) + if (strcmp(s, "MM_ROTATE") == 0) return MM_ROTATE; - if (strcmp(s,"MM_SINGLE_SELECT")==0) + if (strcmp(s, "MM_SINGLE_SELECT") == 0) return MM_SINGLE_SELECT; - if (strcmp(s,"MM_RECTANGULAR_SELECT")==0) + if (strcmp(s, "MM_RECTANGULAR_SELECT") == 0) return MM_RECTANGULAR_SELECT; - if (strcmp(s,"MM_RECTANGULAR_X_SELECT")==0) + if (strcmp(s, "MM_RECTANGULAR_X_SELECT") == 0) return MM_RECTANGULAR_X_SELECT; - if (strcmp(s,"MM_POLYGON_SELECT")==0) + if (strcmp(s, "MM_POLYGON_SELECT") == 0) return MM_POLYGON_SELECT; - if (strcmp(s,"MM_MOVE")==0) + if (strcmp(s, "MM_MOVE") == 0) return MM_MOVE; - if (strcmp(s,"MM_MOVE")==0) + if (strcmp(s, "MM_MOVE") == 0) return MM_MOVE; - if (strcmp(s,"MM_MAGNIFIER")==0) + if (strcmp(s, "MM_MAGNIFIER") == 0) return MM_MAGNIFIER; - if (strcmp(s,"MM_FISHEYE_MAGNIFIER")==0) + if (strcmp(s, "MM_FISHEYE_MAGNIFIER") == 0) return MM_FISHEYE_MAGNIFIER; - if (strcmp(s,"MM_FISHEYE_PICK")==0) + if (strcmp(s, "MM_FISHEYE_PICK") == 0) return MM_FISHEYE_PICK; - + return -1; } -int static get_button(const char* s) +int static get_button(const char *s) { - if (strcmp(s,"B_LSHIFT")==0) + if (strcmp(s, "B_LSHIFT") == 0) return B_LSHIFT; - if (strcmp(s,"B_RSHIFT")==0) + if (strcmp(s, "B_RSHIFT") == 0) return B_RSHIFT; - if (strcmp(s,"B_LCTRL")==0) + if (strcmp(s, "B_LCTRL") == 0) return B_LCTRL; - if (strcmp(s,"B_RCTRL")==0) + if (strcmp(s, "B_RCTRL") == 0) return B_RCTRL; - if (strcmp(s,"0")==0) + if (strcmp(s, "0") == 0) return 0; return 0; } -int static get_view_mode(const char* s) +int static get_view_mode(const char *s) { - if (strcmp(s,"ALL")==0) + if (strcmp(s, "ALL") == 0) return smyrna_all; - if (strcmp(s,"2D")==0) + if (strcmp(s, "2D") == 0) return smyrna_2D; - if (strcmp(s,"3D")==0) + if (strcmp(s, "3D") == 0) return smyrna_3D; - if (strcmp(s,"FISHEYE")==0) + if (strcmp(s, "FISHEYE") == 0) return smyrna_fisheye; - if (strcmp(s,"NO_FISHEYE")==0) + if (strcmp(s, "NO_FISHEYE") == 0) return smyrna_all_but_fisheye; return -1; } -int static get_mouse_button(const char* s) +int static get_mouse_button(const char *s) { - if (strcmp(s,"LEFT")==0) + if (strcmp(s, "LEFT") == 0) return glMouseLeftButton; - if (strcmp(s,"RIGHT")==0) + if (strcmp(s, "RIGHT") == 0) return glMouseRightButton; - if (strcmp(s,"MIDDLE")==0) + if (strcmp(s, "MIDDLE") == 0) return glMouseMiddleButton; return -1; } -int static get_drag(const char* s) +int static get_drag(const char *s) { if (s[0] == '1') return 1; @@ -86,7 +101,7 @@ int static get_drag(const char* s) -void load_mouse_actions (char* modefile,ViewInfo* v) +void load_mouse_actions(char *modefile, ViewInfo * v) { /*#define MM_PAN 0 #define MM_ZOOM 1 @@ -97,54 +112,54 @@ void load_mouse_actions (char* modefile,ViewInfo* v) #define MM_MOVE 10 #define MM_MAGNIFIER 20 #define MM_FISHEYE_MAGNIFIER 21*/ - /*file parsing is temporarrily not available*/ - int i=0; - FILE* file; + /*file parsing is temporarrily not available */ + int i = 0; + FILE *file; char line[BUFSIZ]; - char* a; - char* action_file = smyrnaPath ("mouse_actions.txt"); + 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++; + 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; + } - fclose (file); + idx++; + } + ind++; } - free (action_file); + fclose(file); + } + free(action_file); /* @@ -213,20 +228,19 @@ void load_mouse_actions (char* modefile,ViewInfo* v) */ } -int get_key_action(ViewInfo* v,int key) +int get_key_action(ViewInfo * v, int key) { - int ind=0; - for (;ind < v->mouse_action_count ; ind ++) - { + int ind = 0; + for (; ind < v->mouse_action_count; ind++) { - if (v->mouse_actions[ind].hotkey==key) + if (v->mouse_actions[ind].hotkey == key) return v->mouse_actions[ind].action; } return -1; } -int get_mode(ViewInfo* v) +int get_mode(ViewInfo * v) { @@ -239,30 +253,28 @@ int get_mode(ViewInfo* v) #define MOUSE_BUTTON_2 RIGHT_MOUSE_BUTTON #define MOUSE_BUTTON_3 MIDDLE_MOUSE_BUTTON*/ //typedef enum {smyrna_2D,smyrna_3D,smyrna_fisheye} smyrna_view_mode; - int ind=0; - glMouseButtonType curMouseType=v->mouse.t; - int curDragging=((v->mouse.dragX != 0)||(v->mouse.dragY != 0)); + int ind = 0; + glMouseButtonType curMouseType = v->mouse.t; + int curDragging = ((v->mouse.dragX != 0) || (v->mouse.dragY != 0)); smyrna_view_mode view_mode; - view_mode=smyrna_2D; - if (v->active_camera >= 0 ) - view_mode=smyrna_3D; - if(v->Topview->fisheyeParams.active) - view_mode=smyrna_fisheye; - - - for (;ind < v->mouse_action_count ; ind ++) - { - - if ((v->mouse_actions[ind].hotkey==v->keymap.keyVal) - && - (v->mouse_actions[ind].type==curMouseType) - && - (v->mouse_actions[ind].drag==curDragging) - && - ((v->mouse_actions[ind].mode==view_mode)||( v->mouse_actions[ind].mode==smyrna_all)|| - ((v->mouse_actions[ind].mode==smyrna_all_but_fisheye)&&(view_mode !=smyrna_fisheye)) - )) - { + view_mode = smyrna_2D; + if (v->active_camera >= 0) + view_mode = smyrna_3D; + if (v->Topview->fisheyeParams.active) + view_mode = smyrna_fisheye; + + + for (; ind < v->mouse_action_count; ind++) { + + if ((v->mouse_actions[ind].hotkey == v->keymap.keyVal) + && (v->mouse_actions[ind].type == curMouseType) + && (v->mouse_actions[ind].drag == curDragging) + && + ((v->mouse_actions[ind].mode == view_mode) + || (v->mouse_actions[ind].mode == smyrna_all) + || ((v->mouse_actions[ind].mode == smyrna_all_but_fisheye) + && (view_mode != smyrna_fisheye)) + )) { return v->mouse_actions[ind].action; } diff --git a/cmd/smyrna/topviewfuncs.c b/cmd/smyrna/topviewfuncs.c index 86df003e8..6087e358f 100644 --- a/cmd/smyrna/topviewfuncs.c +++ b/cmd/smyrna/topviewfuncs.c @@ -392,7 +392,7 @@ static void renderNodes(Agraph_t * g) glVertex3f(pos.x,pos.y,pos.z); else if (defaultNodeShape == 1) drawCircle(pos.x,pos.y,nodeSize,pos.z); - ind++; + ind++; } if(defaultNodeShape==0) glEnd(); @@ -737,7 +737,6 @@ void renderSmGraph(Agraph_t * g,topview* t) if(view->zoom*-1 < t->fitin_zoom /(float)view->labelnumberofnodes*-1) glCallList(t->cache.nodelabel_id); } - } if(view->drawedges) @@ -751,7 +750,6 @@ void renderSmGraph(Agraph_t * g,topview* t) } } - } void freeSmGraph(Agraph_t * g,topview* t)