|
|
1.1 ! root 1: /******************************************************************* ! 2: * * ! 3: * File: CIFPLOT/layers.c * ! 4: * Written by Dan Fitzpatrick * ! 5: * copyright 1980 -- Regents of the University of California * ! 6: * * ! 7: ********************************************************************/ ! 8: ! 9: #include <stdio.h> ! 10: #include "defs.h" ! 11: #include "globals.h" ! 12: #include "parser_defs.h" ! 13: #include "structs.h" ! 14: #include "pats.h" ! 15: #include "alloc.h" ! 16: ! 17: IMPORT alloc(); ! 18: IMPORT palloc(); ! 19: ! 20: struct LCell *Layers; /* Points to the list of layers */ ! 21: int UsedLayers = 0; /* Count of how many layers have been used */ ! 22: ! 23: extern struct LCell *FindLayer(); /* Forward Reference FindLayer */ ! 24: ! 25: InitLayers() ! 26: { ! 27: int i; ! 28: ! 29: MaxLayers = NUM_LAYERS; ! 30: Pats = (int **) alloc(MaxLayers*sizeof(int *)); ! 31: Layers = NIL; ! 32: for(i=0; i<NLAYERS; i++) ! 33: CreatLayer(pats[i].IName,&(pats[i].IPat[0])); ! 34: FindLayer(pats[0].IName); ! 35: } ! 36: ! 37: CreatLayer(s,p) ! 38: char *s; ! 39: int *p; ! 40: /* Add a layer to the 'Layers' list. 's' is the layer's name and ! 41: * p is a pointer to the patterns */ ! 42: { ! 43: struct LCell *t; ! 44: ! 45: t = (struct LCell *) palloc(sizeof(struct LCell)); ! 46: t->LName = s; ! 47: t->pat = p; ! 48: t->LNum = -1; ! 49: /* Add t to list of layers */ ! 50: t->Link = Layers; ! 51: t->BackLink = NIL; ! 52: t->visible = 1; ! 53: if(Layers != NIL) ! 54: Layers->BackLink = t; ! 55: Layers = t; ! 56: return; ! 57: } ! 58: ! 59: struct LCell * ! 60: FindLayer(s) ! 61: char *s; ! 62: /* Return a pointer to list element of layer 's'. Return NIL if ! 63: * 's' is not a layer */ ! 64: { ! 65: struct LCell *p; ! 66: ! 67: for(p=Layers;p!=NIL;p=p->Link) ! 68: if(strcmp(p->LName,s) == 0) { ! 69: if(p->LNum == -1) { ! 70: /* If this layer has never been used before give it ! 71: * a number */ ! 72: if(UsedLayers >= MaxLayers) { ! 73: MaxLayers = MaxLayers*2; ! 74: Pats = (int **) expand(Pats,MaxLayers*sizeof(int *)); ! 75: } ! 76: Pats[UsedLayers] = p->pat; ! 77: p->LNum = UsedLayers++; ! 78: } ! 79: return(p); ! 80: } ! 81: return((struct LCell *) NIL); ! 82: } ! 83: ! 84: struct LCell * ! 85: GetLayer(n) ! 86: int n; ! 87: { ! 88: struct LCell *p; ! 89: ! 90: for(p=Layers;p!=NIL;p=p->Link) ! 91: if(p->LNum == n) ! 92: return(p); ! 93: return(NIL); ! 94: } ! 95: ! 96: Command * ! 97: MakeLayer(l) ! 98: char *l; ! 99: /* Create a Command of type LAYER which has the value of ! 100: * the layer in it's level field */ ! 101: { ! 102: Command *command; ! 103: struct LCell *p; ! 104: ! 105: command = GetCommand(); ! 106: command->type = LAYER; ! 107: command->CLink = NIL; ! 108: command->Ctype.Layer = l; ! 109: p = FindLayer(l); ! 110: if(p == NIL) { ! 111: Error("Unknown Layer",FATAL); ! 112: CreatLayer(l,FindLayer("null")->pat); ! 113: p = FindLayer(l); ! 114: } ! 115: command->level = p->LNum; ! 116: return(command); ! 117: } ! 118: ! 119: Invisible(str) ! 120: char *str; ! 121: /* str is a string of layer names seperated by commas or spaces ! 122: * that are to be made invisible */ ! 123: { ! 124: char *name,ch; ! 125: struct LCell *l; ! 126: do { ! 127: name = str; ! 128: while(*str != '\0' && *str != ',' && *str != ' ' && *str != '\t') str++; ! 129: ch = *str; ! 130: *str = '\0'; ! 131: if(strcmp(name,"bbox") == 0) symbox = 0; ! 132: else if(strcmp(name,"text") == 0) text = 0; ! 133: else if(strcmp(name,"symbolName") == 0) printSymbolName = 0; ! 134: else { ! 135: l = FindLayer(name); ! 136: if(l != NIL) l->visible = 0; ! 137: else fprintf(stderr,"%s: No Such Layer\n",name); ! 138: } ! 139: str++; ! 140: } while(ch != '\0'); ! 141: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.