#include "xcddraw.h" //#include #include #include #include #include #include #include #define CONVERT_X(x) ((x)) #define CONVERT_Y(y) (draw_area_height - (y)) extern "C" { extern double sin(double); extern double cos(double); extern double sqrt(double); } void printText(FILE *fp,char *c) { if (c != NULL && strlen(c) ) { fprintf(fp,"%% "); while (*c != '\0') { fprintf(fp,"%c",*c); if (*c == '\n' && ((*(c+1)) != '\0')) fprintf(fp,"%% "); c++; } if (*(c-1) != '\n') fprintf(fp,"\n"); } } void printHeader(FILE *fp,int rows, int cols,double scale) { fprintf(fp,"%%!PS-Adobe-2.0\n"); fprintf(fp,"%%%%Creator: xcddraw\n"); fprintf(fp,"%%%%DocumentFonts: Times-Bold Courier\n"); fprintf(fp,"%%%%Pages: %d\n",rows*cols); fprintf(fp,"%%%%BoundingBox: ? ? ? ?\n"); fprintf(fp,"%%%%EndComments\n"); fprintf(fp,"\n"); fprintf(fp,"/inch {72 mul} def\n"); fprintf(fp,"/leftmargin .5 inch def\n"); fprintf(fp,"/botmargin .25 inch def\n"); fprintf(fp,"/pagewidth 7.5 inch def\n"); fprintf(fp,"/pageheight 10 inch def\n"); fprintf(fp,"\n"); fprintf(fp,"/vertex-name-font\n"); fprintf(fp,"{ /Times-Bold findfont 14 scalefont setfont } def\n"); fprintf(fp,"\n"); fprintf(fp,"/edge-label-font\n"); fprintf(fp,"{ /Courier findfont 12 scalefont setfont } def\n"); fprintf(fp,"\n"); fprintf(fp,"/cvbox\n"); fprintf(fp,"{ gsave newpath moveto\n"); fprintf(fp," 60 0 rlineto\n"); fprintf(fp," 0 -40 rlineto\n"); fprintf(fp," -60 0 rlineto\n"); fprintf(fp," 0 40 rlineto\n"); fprintf(fp," closepath\n"); fprintf(fp," stroke grestore } def\n"); fprintf(fp,"\n"); fprintf(fp,"/avbox\n"); fprintf(fp,"{ gsave newpath moveto\n"); fprintf(fp," 15 0 rmoveto\n"); fprintf(fp," 30 0 rlineto\n"); fprintf(fp," 15 -20 rlineto\n"); fprintf(fp," -15 -20 rlineto\n"); fprintf(fp," -30 0 rlineto\n"); fprintf(fp," -15 20 rlineto\n"); fprintf(fp," 15 20 rlineto\n"); fprintf(fp," closepath\n"); fprintf(fp," stroke grestore } def\n"); fprintf(fp,"\n"); fprintf(fp,"/rvbox\n"); fprintf(fp,"{ gsave newpath moveto\n"); fprintf(fp," 15 0 rmoveto\n"); fprintf(fp," 30 0 rlineto\n"); fprintf(fp," 15 -20 rlineto\n"); fprintf(fp," -15 -20 rlineto\n"); fprintf(fp," -30 0 rlineto\n"); fprintf(fp," -15 20 rlineto\n"); fprintf(fp," 15 20 rlineto\n"); fprintf(fp," 0 -40 rlineto\n"); fprintf(fp," 30 0 rlineto\n"); fprintf(fp," 0 40 rlineto\n"); fprintf(fp," -30 0 rlineto\n"); fprintf(fp," closepath \n"); fprintf(fp," stroke grestore } def\n"); fprintf(fp,"\n"); fprintf(fp,"/tvbox\n"); fprintf(fp,"{ gsave newpath moveto\n"); fprintf(fp," 60 0 rlineto\n"); fprintf(fp," 0 -40 rlineto\n"); fprintf(fp," -60 0 rlineto\n"); fprintf(fp," 0 40 rlineto\n"); fprintf(fp," closepath\n"); fprintf(fp," stroke grestore } def\n"); fprintf(fp,"\n"); fprintf(fp,"/tvmark\n"); fprintf(fp,"{ gsave moveto\n"); fprintf(fp," 25 -25 rmoveto\n"); fprintf(fp," vertex-name-font (T) show\n"); fprintf(fp," grestore } def\n"); fprintf(fp,"\n"); fprintf(fp,"/evbox\n"); fprintf(fp,"{ gsave newpath moveto\n"); fprintf(fp," 60 0 rlineto\n"); fprintf(fp," 0 -40 rlineto\n"); fprintf(fp," -60 0 rlineto\n"); fprintf(fp," 0 40 rlineto\n"); fprintf(fp," closepath\n"); fprintf(fp," stroke grestore } def\n"); fprintf(fp,"\n"); fprintf(fp,"/evmark\n"); fprintf(fp,"{ gsave\n"); fprintf(fp," moveto\n"); fprintf(fp," 25 -25 rmoveto\n"); fprintf(fp," vertex-name-font (?) show\n"); fprintf(fp," grestore } def\n"); fprintf(fp,"\n"); fprintf(fp,"/pmark\n"); fprintf(fp,"{ gsave\n"); fprintf(fp," moveto\n"); fprintf(fp," 25 -13 rmoveto\n"); fprintf(fp," vertex-name-font (*) show\n"); fprintf(fp," grestore } def\n"); fprintf(fp,"\n"); fprintf(fp,"/pvbox\n"); fprintf(fp,"{ gsave newpath 20 0 360 arc stroke grestore } def\n"); fprintf(fp,"\n"); fprintf(fp,"/arrow\n"); fprintf(fp,"{ gsave newpath\n"); fprintf(fp," moveto\n"); fprintf(fp," lineto\n"); fprintf(fp," lineto\n"); fprintf(fp," lineto\n"); fprintf(fp," lineto\n"); fprintf(fp," closepath\n"); fprintf(fp," 0 setgray fill\n"); fprintf(fp," 1 setlinejoin\n"); fprintf(fp," stroke grestore } def\n"); fprintf(fp,"\n"); fprintf(fp,"/re-pattern\n"); fprintf(fp,"{ 1 setlinecap\n"); fprintf(fp," 1 setlinejoin\n"); fprintf(fp," 0 setgray\n"); fprintf(fp," 3 setlinewidth\n"); fprintf(fp," [] 0 setdash } def\n"); fprintf(fp,"\n"); fprintf(fp,"/oe-pattern\n"); fprintf(fp,"{ 1 setlinecap\n"); fprintf(fp," 1 setlinejoin\n"); fprintf(fp," 0 setgray\n"); fprintf(fp," 3 setlinewidth\n"); fprintf(fp," [4 5] 0 setdash } def\n"); fprintf(fp,"\n"); fprintf(fp,"/aebg-pattern\n"); fprintf(fp,"{ 1 setlinecap\n"); fprintf(fp," 1 setlinejoin\n"); fprintf(fp," 0 setgray\n"); fprintf(fp," 5 setlinewidth\n"); fprintf(fp," [] 0 setdash } def\n"); fprintf(fp,"\n"); fprintf(fp,"/aefg-pattern\n"); fprintf(fp,"{ 1 setlinecap\n"); fprintf(fp," 1 setlinejoin\n"); fprintf(fp," 1 setgray\n"); fprintf(fp," 3 setlinewidth\n"); fprintf(fp," [] 0 setdash } def\n"); fprintf(fp,"\n"); fprintf(fp,"/iebg-pattern\n"); fprintf(fp,"{ 1 setlinecap\n"); fprintf(fp," 1 setlinejoin\n"); fprintf(fp," 0 setgray\n"); fprintf(fp," 5 setlinewidth\n"); fprintf(fp," [4 5] 0 setdash } def\n"); fprintf(fp,"\n"); fprintf(fp,"/iefg-pattern\n"); fprintf(fp,"{ 1 setlinecap\n"); fprintf(fp," 1 setlinejoin\n"); fprintf(fp," 1 setgray\n"); fprintf(fp," 3 setlinewidth\n"); fprintf(fp," [] 0 setdash } def\n"); fprintf(fp,"\n"); fprintf(fp,"/pie-pattern\n"); fprintf(fp,"{ 1 setlinecap\n"); fprintf(fp," 1 setlinejoin\n"); fprintf(fp," 0 setgray\n"); fprintf(fp," 5 setlinewidth\n"); fprintf(fp," [] 0 setdash } def\n"); fprintf(fp,"\n"); fprintf(fp,"/pe-pattern\n"); fprintf(fp,"{ 1 setlinecap\n"); fprintf(fp," 1 setlinejoin\n"); fprintf(fp," 0 setgray\n"); fprintf(fp," 1 setlinewidth\n"); fprintf(fp," [] 0 setdash } def\n"); fprintf(fp,"\n"); fprintf(fp,"\n"); fprintf(fp,"/psb-pattern\n"); fprintf(fp,"{ 1 setlinecap\n"); fprintf(fp," 1 setlinejoin\n"); fprintf(fp," 0 setgray\n"); fprintf(fp," 1 setlinewidth\n"); fprintf(fp," [4 5] 0 setdash } def\n"); fprintf(fp,"\n"); fprintf(fp,"/normal-primary-construction-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," re-pattern\n"); fprintf(fp," cvbox\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/normal-primary-of-construction-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," dup 3 2 roll dup 4 1 roll exch\n"); fprintf(fp," re-pattern\n"); fprintf(fp," cvbox pmark\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/parameterized-primary-construction-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," oe-pattern\n"); fprintf(fp," cvbox\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/parameterized-primary-of-construction-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," dup 3 2 roll dup 4 1 roll exch\n"); fprintf(fp," oe-pattern\n"); fprintf(fp," cvbox pmark\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/normal-secondary-construction-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," pe-pattern\n"); fprintf(fp," cvbox\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"\n"); fprintf(fp,"/parameterized-secondary-construction-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," psb-pattern\n"); fprintf(fp," cvbox\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"\n"); fprintf(fp,"/normal-primary-alternation-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," re-pattern\n"); fprintf(fp," avbox\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/normal-primary-of-alternation-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," dup 3 2 roll dup 4 1 roll exch\n"); fprintf(fp," re-pattern\n"); fprintf(fp," avbox pmark\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/parameterized-primary-alternation-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," oe-pattern\n"); fprintf(fp," avbox\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/parameterized-primary-of-alternation-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," dup 3 2 roll dup 4 1 roll exch\n"); fprintf(fp," oe-pattern\n"); fprintf(fp," avbox pmark\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/normal-secondary-alternation-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," pe-pattern\n"); fprintf(fp," avbox\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"\n"); fprintf(fp,"/parameterized-secondary-alternation-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," psb-pattern\n"); fprintf(fp," avbox\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"\n"); fprintf(fp,"/normal-primary-repetition-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," re-pattern\n"); fprintf(fp," rvbox\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/normal-primary-of-repetition-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," dup 3 2 roll dup 4 1 roll exch\n"); fprintf(fp," re-pattern\n"); fprintf(fp," rvbox pmark\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/parameterized-primary-repetition-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," oe-pattern\n"); fprintf(fp," rvbox\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/parameterized-primary-of-repetition-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," dup 3 2 roll dup 4 1 roll exch\n"); fprintf(fp," oe-pattern\n"); fprintf(fp," rvbox pmark\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/normal-secondary-repetition-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," pe-pattern\n"); fprintf(fp," rvbox\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"\n"); fprintf(fp,"/parameterized-secondary-repetition-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," psb-pattern\n"); fprintf(fp," rvbox\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"\n"); fprintf(fp,"/terminal-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," dup 3 2 roll dup 4 1 roll exch\n"); fprintf(fp," re-pattern\n"); fprintf(fp," tvbox tvmark\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"\n"); fprintf(fp,"/normal-primary-external-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," dup 3 2 roll dup 4 1 roll exch\n"); fprintf(fp," re-pattern\n"); fprintf(fp," evbox evmark\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/normal-primary-of-external-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," dup 3 2 roll dup 4 1 roll exch\n"); fprintf(fp," dup 3 2 roll dup 4 1 roll exch\n"); fprintf(fp," re-pattern\n"); fprintf(fp," evbox evmark pmark\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/parameterized-primary-external-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," dup 3 2 roll dup 4 1 roll exch\n"); fprintf(fp," oe-pattern\n"); fprintf(fp," evbox evmark\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/parameterized-primary-of-external-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," dup 3 2 roll dup 4 1 roll exch\n"); fprintf(fp," dup 3 2 roll dup 4 1 roll exch\n"); fprintf(fp," oe-pattern\n"); fprintf(fp," evbox evmark pmark\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/normal-secondary-external-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," dup 3 2 roll dup 4 1 roll exch\n"); fprintf(fp," pe-pattern\n"); fprintf(fp," evbox evmark\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/parameterized-secondary-external-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," dup 3 2 roll dup 4 1 roll exch\n"); fprintf(fp," psb-pattern\n"); fprintf(fp," evbox evmark\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"\n"); fprintf(fp,"/parameter-vertex\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," re-pattern\n"); fprintf(fp," pvbox\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/edge-label{\n"); fprintf(fp," gsave\n"); fprintf(fp," moveto\n"); fprintf(fp," edge-label-font\n"); fprintf(fp," show\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/vertex-name\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," moveto\n"); fprintf(fp," vertex-name-font\n"); fprintf(fp," show\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/Line\n"); fprintf(fp,"{\n"); fprintf(fp," /points exch def\n"); fprintf(fp," points 0 get\n"); fprintf(fp," /segs exch def\n"); fprintf(fp," newpath\n"); fprintf(fp," points 1 get\n"); fprintf(fp," points 2 get\n"); fprintf(fp," moveto\n"); fprintf(fp," 1 1 segs\n"); fprintf(fp," {\n"); fprintf(fp," /segcount exch def\n"); fprintf(fp," points segcount 1 add 2 mul 1 sub get\n"); fprintf(fp," points segcount 1 add 2 mul get\n"); fprintf(fp," lineto\n"); fprintf(fp," } for\n"); fprintf(fp," stroke\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/required-construction-edge\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," re-pattern Line\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/optional-construction-edge\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," oe-pattern Line\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/required-repetition-edge\n"); fprintf(fp,"{\n"); fprintf(fp," required-construction-edge\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/optional-repetition-edge\n"); fprintf(fp,"{\n"); fprintf(fp," optional-construction-edge\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/alternation-edge\n"); fprintf(fp,"{\n"); fprintf(fp," gsave dup\n"); fprintf(fp," aebg-pattern Line\n"); fprintf(fp," aefg-pattern Line\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"\n"); fprintf(fp,"/inheritance-edge\n"); fprintf(fp,"{\n"); fprintf(fp," gsave dup\n"); fprintf(fp," iebg-pattern Line\n"); fprintf(fp," iefg-pattern Line\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/parameter-edge\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," pe-pattern Line\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n"); fprintf(fp,"\n"); fprintf(fp,"/instantiation-edge\n"); fprintf(fp,"{\n"); fprintf(fp," gsave\n"); fprintf(fp," pie-pattern Line\n"); fprintf(fp," grestore\n"); fprintf(fp,"} def\n\n"); fprintf(fp,"/EXEC { /exec load } bind def\n\n"); fprintf(fp,"\n/cdgproc [ \n"); fprintf(fp,"{ gsave } EXEC\n"); } void printTail(FILE *fp,int rows, int cols,double scale) { fprintf(fp,"\n"); fprintf(fp,"{ grestore} EXEC\n"); fprintf(fp,"] cvx bind def\n"); fprintf(fp,"\n"); fprintf(fp,"/rows %d def\n",rows); fprintf(fp,"/columns %d def\n",cols); fprintf(fp,"\n"); fprintf(fp,"newpath\n"); fprintf(fp," leftmargin botmargin moveto\n"); fprintf(fp," 0 pageheight rlineto\n"); fprintf(fp," pagewidth 0 rlineto\n"); fprintf(fp," 0 pageheight neg rlineto\n"); fprintf(fp,"closepath clip\n\n"); fprintf(fp,"0 1 rows 1 sub\n"); fprintf(fp," { /rowcount exch def\n"); fprintf(fp," 0 1 columns 1 sub\n"); fprintf(fp," { /colcount exch def\n\n"); fprintf(fp," gsave\n"); fprintf(fp," newpath\n"); fprintf(fp," leftmargin botmargin moveto\n"); fprintf(fp," 0 pageheight rlineto\n"); fprintf(fp," pagewidth 0 rlineto\n"); fprintf(fp," 0 pageheight neg rlineto\n"); fprintf(fp," closepath stroke\n"); fprintf(fp,"\n"); // fprintf(fp," 90 rotate\n"); // fprintf(fp," %d 0 translate\n", (int)draw_area_height*scale); fprintf(fp," pagewidth colcount mul neg leftmargin add\n"); fprintf(fp," %d pageheight rowcount 1 add mul botmargin add sub neg \n", (int)(draw_area_height*scale)); fprintf(fp," translate\n"); fprintf(fp,"\n"); fprintf(fp," %.4f %.4f scale\n",scale,scale); fprintf(fp,"\n"); fprintf(fp," cdgproc\n"); fprintf(fp," showpage\n"); fprintf(fp," grestore\n"); fprintf(fp," } for\n"); fprintf(fp," } for\n"); fprintf(fp,"\n"); fprintf(fp,"\n"); } void save(char *fname,double scale) { int rows = (int)((((double)draw_area_height)*scale)/720); int cols = (int)((((double)draw_area_width)*scale)/540); if (rows == 0) rows = 1; else if (rows * 720 < draw_area_height) rows++; if (cols == 0) cols = 1; else if (cols * 540 < draw_area_width) cols++; FILE *fp = fopen(fname,"w"); if (fp==NULL) { sprintf(message, "Print Cd: unable to open %s.\n",fname); xm_print_message(message); XBell(XtDisplay(draw_area),0); return; } printHeader(fp,rows,cols,scale); /* print out vertices */ vertex_store->printVertices(fp); /* print edges */ vertex_store->printCPEdges(fp); repedge_store->printAIRIEdges(fp); altedge_store->printAIRIEdges(fp); inhedge_store->printAIRIEdges(fp); parinstedge_store->printAIRIEdges(fp); paredge_store->printAIRIEdges(fp); fprintf(fp,"\n%%END\n"); /* print out vertices */ vertex_store->printVertices(fp); printTail(fp,rows,cols,scale); fclose(fp); if ((fp = fopen(fname,"r")) == NULL) { sprintf(message, "Print Cd: unable to open %s.\n",fname); xm_print_message(message); XBell(XtDisplay(draw_area),0); fclose ( fp ); return; } fclose ( fp ); } void printCDCB(Widget w,int *doit,XtPointer call_data) { dialog_done = 1; *doit = 1; } void cancelPrintCDCB(Widget w,XtPointer unused,XtPointer call_data) { dialog_done = 1; } typedef struct { Widget pages; Widget scaleb; double scalev; } scale_struct; void new_print_scale_value( Widget w, scale_struct *sv, XmScaleCallbackStruct *cbs) { sv->scalev = ((double)cbs->value) / 1000; int rows = (int)((((double)draw_area_height)*sv->scalev)/720); int cols = (int)((((double)draw_area_width)*sv->scalev)/540); if (rows == 0) rows = 1; else if (rows * 720 < draw_area_height) rows++; if (cols == 0) cols = 1; else if (cols * 540 < draw_area_width) cols++; char buf[60]; sprintf(buf,"Pages: %d x %d",rows,cols); XmString xmstr = XmStringCreateSimple(buf); XtVaSetValues(sv->pages, XmNalignment , XmALIGNMENT_BEGINNING, XmNlabelString,xmstr,NULL); XmStringFree(xmstr); } void cdPrintCallback(Widget w,XtPointer unused,XtPointer call_data) { char fname[256]; Widget dialog; int n; static scale_struct ss; XmString xmstr = XmStringCreateSimple("Printer:"); n = 0; XtSetArg(wargs[n], XmNselectionLabelString, xmstr); n++; XtSetArg(wargs[n], XmNautoUnmanage, False); n++; XtSetArg(wargs[n], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL); n++; dialog = XmCreatePromptDialog(draw_area, "Prompt", wargs, n); XmStringFree(xmstr); Widget form = XtCreateManagedWidget("Form",xmFormWidgetClass,dialog,NULL,0); Widget scale = XtVaCreateManagedWidget("Scale", xmScaleWidgetClass, form, XtVaTypedArg, XmNtitleString, XmRString, "Scale", 5, XmNmaximum, 5000, XmNminimum, 1, XmNvalue, 500, XmNdecimalPoints, 3, XmNshowValue, True, XmNorientation, XmHORIZONTAL, NULL); n = 0; XtSetArg(wargs[0],XmNwidth , 1024); n++; XtSetArg(wargs[1],XmNalignment , XmALIGNMENT_BEGINNING); n++; Widget pages = XtCreateManagedWidget( "Pages",xmLabelGadgetClass,form,wargs,n); ss.scalev = 0.500; ss.pages = pages; XtAddCallback(scale, XmNvalueChangedCallback, (XtCallbackProc)new_print_scale_value, (XtPointer)&ss); XtVaSetValues (scale,XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_NONE, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); XtVaSetValues (pages, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, scale, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); int rows = (int)((((double)draw_area_width)*ss.scalev)/720); int cols = (int)((((double)draw_area_height)*ss.scalev)/540); if (rows == 0) rows = 1; else if (rows * 720 < draw_area_height) rows++; if (cols == 0) cols = 1; else if (cols * 540 < draw_area_width) cols++; char buf[30]; sprintf(buf,"Pages: %d x %d",rows,cols); xmstr = XmStringCreateSimple(buf); XtVaSetValues(pages,XmNlabelString,xmstr,NULL); XmStringFree(xmstr); char *printer = getenv("PRINTER"); if (printer) XmTextSetString( XmSelectionBoxGetChild(dialog,XmDIALOG_VALUE_TEXT), printer); free(printer); xmstr = XmStringCreateSimple("Print"); XtVaSetValues(dialog, XmNokLabelString, xmstr, NULL); XmStringFree(xmstr); xmstr = XmStringCreateSimple("Cancel"); XtVaSetValues(dialog, XmNcancelLabelString,xmstr, NULL); XmStringFree(xmstr); xmstr = XmStringCreateSimple("Help"); XtVaSetValues(dialog, XmNhelpLabelString, xmstr, NULL); XmStringFree(xmstr); dialog_done = 0; int doit = 0; XtAddCallback(dialog, XmNokCallback, (XtCallbackProc)printCDCB,(XtPointer)&doit); XtAddCallback(dialog, XmNcancelCallback, (XtCallbackProc)cancelPrintCDCB,(XtPointer)NULL); XtManageChild(dialog); XtPopup(XtParent(dialog), XtGrabExclusive); dialog_done = 0; while ( dialog_done == 0 || XtAppPending(app)) XtAppProcessEvent(app, XtIMAll); char cmd[1024]; if (doit) { tmpnam(fname); save(fname,ss.scalev); printer = XmTextGetString(XmSelectionBoxGetChild(dialog,XmDIALOG_VALUE_TEXT)); if (strlen(printer)) sprintf(cmd,"lpr -P%s %s;rm %s\n",printer,fname,fname); else sprintf(cmd,"lpr %s;rm %s\n",fname,fname); system(cmd); free(printer); } XtDestroyWidget(dialog); } void GraphicsObject::printPrimaryVertex(FILE *fp) { } void VertexObject::printPrimaryVertex(FILE *fp) { } void ConstructionVertex::printPrimaryVertex(FILE *fp) { char pname[1024]; pname[0] = '\0'; if (this->get_is_template()) { this->get_name()->get_parameterized_name(this->get_parassignstore(),pname); if (this->no_parameters()) pname[strlen(pname)-2] = '\0'; } else if (this->get_template_name()) /* template instance */ this->get_template_name()->get_parameterized_name(this->get_parassignstore(),pname); fprintf(fp,"\n%%CV %d (%s) %d %d %d %d\n", (char*)(GraphicsObject*)this,this->get_name()->get_vertex_name(), this->get_name_x(),this->get_name_y(), this->get_box()->get_x1(),this->get_box()->get_y1()); if (this->get_subhome()->get_comments()->get_comments()) fprintf(fp,"%%C %d\n",strlen(this->get_subhome()->get_comments()->get_comments())); else fprintf(fp,"%%C 0\n"); printText(fp,this->get_subhome()->get_comments()->get_comments()); fprintf(fp,"%%C\n"); /* before after*/ if (this->get_subhome()->get_before()) fprintf(fp,"%%B %d\n",strlen(this->get_subhome()->get_before())); else fprintf(fp,"%%B 0\n"); printText(fp,this->get_subhome()->get_before()); fprintf(fp,"%%B\n"); if (this->get_subhome()->get_after()) fprintf(fp,"%%A %d\n",strlen(this->get_subhome()->get_after())); else fprintf(fp,"%%A 0\n"); printText(fp,this->get_subhome()->get_after()); fprintf(fp,"%%A\n"); fprintf(fp,"{ (%s) %d %d vertex-name} EXEC\n", pname, CONVERT_X(this->get_name_x()), CONVERT_Y(this->get_name_y())); if (this->get_primary_flag() == PRIMARY) { if (this->no_formal_parameters()) fprintf(fp,"{ %d %d normal-primary-construction-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()), CONVERT_Y(this->get_box()->get_y1()+20)); else fprintf(fp,"{ %d %d parameterized-primary-construction-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()), CONVERT_Y(this->get_box()->get_y1()+20)); } else { if (this->no_formal_parameters()) fprintf(fp,"{ %d %d normal-primary-of-construction-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()), CONVERT_Y(this->get_box()->get_y1()+20)); else fprintf(fp,"{ %d %d parameterized-primary-of-construction-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()), CONVERT_Y(this->get_box()->get_y1()+20)); } } void AlternationVertex::printPrimaryVertex(FILE *fp) { char pname[1024]; pname[0] = '\0'; if (this->get_is_template()) { this->get_name()->get_parameterized_name(this->get_parassignstore(),pname); if (this->no_parameters()) pname[strlen(pname)-2] = '\0'; } else if (this->get_template_name()) /* template instance */ this->get_template_name()->get_parameterized_name(this->get_parassignstore(),pname); fprintf(fp,"\n%%AV %d (%s) %d %d %d %d\n", (char*)(GraphicsObject*)this,this->get_name()->get_vertex_name(), this->get_name_x(),this->get_name_y(), this->get_box()->get_x1(),this->get_box()->get_y1()); if (this->get_subhome()->get_comments()->get_comments()) fprintf(fp,"%%C %d\n",strlen(this->get_subhome()->get_comments()->get_comments())); else fprintf(fp,"%%C 0\n"); printText(fp,this->get_subhome()->get_comments()->get_comments()); fprintf(fp,"%%C\n"); /* before after*/ if (this->get_subhome()->get_before()) fprintf(fp,"%%B %d\n",strlen(this->get_subhome()->get_before())); else fprintf(fp,"%%B 0\n"); printText(fp,this->get_subhome()->get_before()); fprintf(fp,"%%B\n"); if (this->get_subhome()->get_after()) fprintf(fp,"%%A %d\n",strlen(this->get_subhome()->get_after())); else fprintf(fp,"%%A 0\n"); printText(fp,this->get_subhome()->get_after()); fprintf(fp,"%%A\n"); fprintf(fp,"{ (%s) %d %d vertex-name} EXEC\n", pname, CONVERT_X(this->get_name_x()), CONVERT_Y(this->get_name_y())); if (this->get_primary_flag() == PRIMARY) { if (this->no_formal_parameters()) fprintf(fp,"{ %d %d normal-primary-alternation-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()),CONVERT_Y(this->get_box()->get_y1()+20)); else fprintf(fp,"{ %d %d parameterized-primary-alternation-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()),CONVERT_Y(this->get_box()->get_y1()+20)); } else { if (this->no_formal_parameters()) fprintf(fp,"{ %d %d normal-primary-of-alternation-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()),CONVERT_Y(this->get_box()->get_y1()+20)); else fprintf(fp,"{ %d %d parameterized-primary-of-alternation-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()),CONVERT_Y(this->get_box()->get_y1()+20)); } } void RepetitionVertex::printPrimaryVertex(FILE *fp) { char pname[1024]; pname[0] = '\0'; if (this->get_is_template()) { this->get_name()->get_parameterized_name(this->get_parassignstore(),pname); if (this->no_parameters()) pname[strlen(pname)-2] = '\0'; } else if (this->get_template_name()) /* template instance */ this->get_template_name()->get_parameterized_name(this->get_parassignstore(),pname); fprintf(fp,"\n%%RV %d (%s) %d %d %d %d\n", (char*)(GraphicsObject*)this,this->get_name()->get_vertex_name(), this->get_name_x(),this->get_name_y(), this->get_box()->get_x1(),this->get_box()->get_y1()); if (this->get_subhome()->get_comments()->get_comments()) fprintf(fp,"%%C %d\n",strlen(this->get_subhome()->get_comments()->get_comments())); else fprintf(fp,"%%C 0\n"); printText(fp,this->get_subhome()->get_comments()->get_comments()); fprintf(fp,"%%C\n"); /* before after*/ if (this->get_subhome()->get_before()) fprintf(fp,"%%B %d\n",strlen(this->get_subhome()->get_before())); else fprintf(fp,"%%B 0\n"); printText(fp,this->get_subhome()->get_before()); fprintf(fp,"%%B\n"); if (this->get_subhome()->get_after()) fprintf(fp,"%%A %d\n",strlen(this->get_subhome()->get_after())); else fprintf(fp,"%%A 0\n"); printText(fp,this->get_subhome()->get_after()); fprintf(fp,"%%A\n"); fprintf(fp,"{ (%s) %d %d vertex-name} EXEC\n", pname, CONVERT_X(this->get_name_x()), CONVERT_Y(this->get_name_y())); if (this->get_primary_flag() == PRIMARY) { if (this->no_formal_parameters()) fprintf(fp,"{ %d %d normal-primary-repetition-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()),CONVERT_Y(this->get_box()->get_y1()+20)); else fprintf(fp,"{ %d %d parameterized-primary-repetition-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()),CONVERT_Y(this->get_box()->get_y1()+20)); } else { if (this->no_formal_parameters()) fprintf(fp,"{ %d %d normal-primary-of-repetition-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()),CONVERT_Y(this->get_box()->get_y1()+20)); else fprintf(fp,"{ %d %d parameterized-primary-of-repetition-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()),CONVERT_Y(this->get_box()->get_y1()+20)); } } void ExternalVertex::printPrimaryVertex(FILE *fp) { char pname[1024]; pname[0] = '\0'; if (this->get_is_template()) { this->get_name()->get_parameterized_name(this->get_parassignstore(),pname); if (this->no_parameters()) pname[strlen(pname)-2] = '\0'; } else if (this->get_template_name()) /* template instance */ this->get_template_name()->get_parameterized_name(this->get_parassignstore(),pname); fprintf(fp,"\n%%EV %d (%s) %d %d %d %d\n", (char*)(GraphicsObject*)this,this->get_name()->get_vertex_name(), this->get_name_x(),this->get_name_y(), this->get_box()->get_x1(),this->get_box()->get_y1()); if (this->get_subhome()->get_comments()->get_comments()) fprintf(fp,"%%C %d\n",strlen(this->get_subhome()->get_comments()->get_comments())); else fprintf(fp,"%%C 0\n"); printText(fp,this->get_subhome()->get_comments()->get_comments()); fprintf(fp,"%%C\n"); fprintf(fp,"{ (%s) %d %d vertex-name} EXEC\n", pname, CONVERT_X(this->get_name_x()), CONVERT_Y(this->get_name_y())); if (this->get_primary_flag() == PRIMARY) { if (this->no_formal_parameters()) fprintf(fp,"{ %d %d normal-primary-external-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()),CONVERT_Y(this->get_box()->get_y1()+20)); else fprintf(fp,"{ %d %d parameterized-primary-external-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()),CONVERT_Y(this->get_box()->get_y1()+20)); } else { if (this->no_formal_parameters()) fprintf(fp,"{ %d %d normal-primary-of-external-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()),CONVERT_Y(this->get_box()->get_y1()+20)); else fprintf(fp,"{ %d %d parameterized-primary-of-external-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()),CONVERT_Y(this->get_box()->get_y1()+20)); } } void NameSensitiveVertex::printVertices(FILE *fp) { primary->printPrimaryVertex(fp); vertices->printSVertices(fp); /* secondary */ tempinststore->printIVertices(fp); /* inst */ } void NameInsensitiveVertexStore::printVertices(FILE *fp) { vertices->printNameInsenVertices(fp); } void NameInsensitiveVertexStore::printNameInsenVertices(FILE *fp) { vertices->printNameInsenVertices(fp); } void NameSensitiveVertexList::printVertices(FILE *fp) { elm->printVertices(fp); if (next) next->printVertices(fp); } void NameSensitiveVertexStore::printVertices(FILE *fp) { if (vertices) vertices->printVertices(fp); } void GraphicsObjectList::printNameInsenVertices(FILE *fp) { elm->printNameInsenVertices(fp); if (next) next->printNameInsenVertices(fp); } void ObjectStore::printNameInsenVertices(FILE *fp) { if (objects) objects->printNameInsenVertices(fp); } void GraphicsObjectList::printSVertices(FILE *fp) { elm->printSVertex(fp); if (next) next->printSVertices(fp); } void ObjectStore::printSVertices(FILE *fp) { if (objects) objects->printSVertices(fp); } void GraphicsObjectList::printIVertices(FILE *fp) { elm->printIVertex(fp); if (next) next->printIVertices(fp); } void ObjectStore::printIVertices(FILE *fp) { if (objects) objects->printIVertices(fp); } void TemplateInstStore::printIVertices(FILE *fp) { instances->printIVertices(fp); } void ExternalVertexStore::printVertices(FILE *fp) { tempstore->printVertices(fp); /* print primary, sencondary and inst */ } void VertexStore::printVertices(FILE *fp) { localvertices->printVertices(fp); /* print primary, sencondary and inst */ termvstore->printVertices(fp); paravstore->printVertices(fp); extvstore->printVertices(fp); /* print primary, sencondary and inst */ ubvstore->printVertices(fp); } void TerminalVertexStore::printVertices(FILE *fp) { vstore->printNameInsenVertices(fp); } void ParameterVertexStore::printVertices(FILE *fp) { vstore->printNameInsenVertices(fp); } void UnboundVertexStore::printVertices(FILE *fp) { vstore->printNameInsenVertices(fp); } void GraphicsObject::printNameInsenVertices(FILE *fp) { } void TerminalVertex::printNameInsenVertices(FILE *fp) { fprintf(fp,"\n%%TV %d (%s) %d %d %d %d\n", (char*)(GraphicsObject*)this,this->get_name()->get_vertex_name(), this->get_name_x(),this->get_name_y(), this->get_box()->get_x1(),this->get_box()->get_y1()); if (this->get_comments()->get_comments()) fprintf(fp,"%%C %d\n",strlen(this->get_comments()->get_comments())); else fprintf(fp,"%%C 0\n"); printText(fp,this->get_comments()->get_comments()); fprintf(fp,"%%C\n"); fprintf(fp,"{ (%s) %d %d vertex-name} EXEC\n", this->get_name()->get_vertex_name(), CONVERT_X(this->get_name_x()), CONVERT_Y(this->get_name_y())); fprintf(fp,"{ %d %d terminal-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()),CONVERT_Y(this->get_box()->get_y1()+20)); } void ConstructionVertex::printNameInsenVertices(FILE *fp) { fprintf(fp,"\n%%PUC %d %d %d\n", (char*)(GraphicsObject*)this, this->get_box()->get_x1(),this->get_box()->get_y1()); fprintf(fp,"{ %d %d normal-primary-construction-vertex} EXEC\n", CONVERT_X((this->get_box()->get_x1()+this->get_box()->get_x2())/2), CONVERT_Y((this->get_box()->get_y1()+20 + this->get_box()->get_y2())/2)); } void AlternationVertex::printNameInsenVertices(FILE *fp) { fprintf(fp,"\n%%PUA %d %d %d\n", (char*)(GraphicsObject*)this, this->get_box()->get_x1(),this->get_box()->get_y1()); fprintf(fp,"{ %d %d normal-primary-alternation-vertex} EXEC\n", CONVERT_X((this->get_box()->get_x1()+this->get_box()->get_x2())/2), CONVERT_Y((this->get_box()->get_y1()+20 + this->get_box()->get_y2())/2)); } void RepetitionVertex::printNameInsenVertices(FILE *fp) { fprintf(fp,"\n%%PUR %d %d %d\n", (char*)(GraphicsObject*)this, this->get_box()->get_x1(),this->get_box()->get_y1()); fprintf(fp,"{ %d %d normal-primary-of-repetition-vertex} EXEC\n", CONVERT_X((this->get_box()->get_x1()+this->get_box()->get_x2())/2), CONVERT_Y((this->get_box()->get_y1()+20 + this->get_box()->get_y2())/2)); } void ExternalVertex::printNameInsenVertices(FILE *fp) { fprintf(fp,"\n%%PUE %d %d %d\n", (char*)(GraphicsObject*)this, this->get_box()->get_x1(),this->get_box()->get_y1()); fprintf(fp,"{ %d %d normal-primary-external-vertex} EXEC\n", CONVERT_X((this->get_box()->get_x1()+this->get_box()->get_x2())/2), CONVERT_Y((this->get_box()->get_y1()+20 + this->get_box()->get_y2())/2)); } void ParameterVertex::printNameInsenVertices(FILE *fp) { fprintf(fp,"\n%%PV %d (%s) %d %d %d %d\n", (char*)(GraphicsObject*)this,this->get_name()->get_vertex_name(), this->get_name_x(),this->get_name_y(), this->get_box()->get_x1(),this->get_box()->get_y1()); if (this->get_comments()->get_comments()) fprintf(fp,"%%C %d\n",strlen(this->get_comments()->get_comments())); else fprintf(fp,"%%C 0\n"); printText(fp,this->get_comments()->get_comments()); fprintf(fp,"%%C\n"); fprintf(fp,"{ (%s) %d %d vertex-name} EXEC\n", this->get_name()->get_vertex_name(), CONVERT_X(this->get_name_x()), CONVERT_Y(this->get_name_y())); fprintf(fp,"{ %d %d parameter-vertex} EXEC\n", CONVERT_X((this->get_box()->get_x1()+this->get_box()->get_x2())/2), CONVERT_Y((this->get_box()->get_y1()+20 + this->get_box()->get_y2())/2)); } void GraphicsObject::printSVertex(FILE *fp) { /* print secondary */ } void GraphicsObject::printIVertex(FILE *fp) { /* print instance */ } void ExternalVertex::printSVertex(FILE *fp) { /* print secondary */ if ((this->get_primary_flag() != PRIMARY) && (this->get_primary_flag() != PRIMARY_OF)) { char pname[1024]; pname[0] = '\0'; if (this->get_is_template()) { this->get_name()->get_parameterized_name(this->get_parassignstore(),pname); if (this->no_parameters()) pname[strlen(pname)-2] = '\0'; } else if (this->get_template_name()) /* template instance */ this->get_template_name()->get_parameterized_name(this->get_parassignstore(),pname); fprintf(fp,"\n%%S %d %d %d %d %d\n", (char*)(GraphicsObject*)this,this->get_name_x(),this->get_name_y(), this->get_box()->get_x1(),this->get_box()->get_y1()); fprintf(fp,"{ (%s) %d %d vertex-name} EXEC\n", pname, CONVERT_X(this->get_name_x()), CONVERT_Y(this->get_name_y())); if (this->no_formal_parameters()) fprintf(fp,"{ %d %d normal-secondary-external-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()), CONVERT_Y(this->get_box()->get_y1()+20)); else fprintf(fp,"{ %d %d parameterized-secondary-external-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()), CONVERT_Y(this->get_box()->get_y1()+20)); } } void RepetitionVertex::printSVertex(FILE *fp) { /* print secondary */ if ((this->get_primary_flag() != PRIMARY) && (this->get_primary_flag() != PRIMARY_OF)) { char pname[1024]; pname[0] = '\0'; if (this->get_is_template()) { this->get_name()->get_parameterized_name(this->get_parassignstore(),pname); if (this->no_parameters()) pname[strlen(pname)-2] = '\0'; } else if (this->get_template_name()) /* template instance */ this->get_template_name()->get_parameterized_name(this->get_parassignstore(),pname); fprintf(fp,"\n%%S %d %d %d %d %d\n", (char*)(GraphicsObject*)this,this->get_name_x(),this->get_name_y(), this->get_box()->get_x1(),this->get_box()->get_y1()); fprintf(fp,"{ (%s) %d %d vertex-name} EXEC\n", pname, CONVERT_X(this->get_name_x()), CONVERT_Y(this->get_name_y())); if (this->no_formal_parameters()) fprintf(fp,"{ %d %d normal-secondary-repetition-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()), CONVERT_Y(this->get_box()->get_y1()+20)); else fprintf(fp,"{ %d %d parameterized-secondary-repetition-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()), CONVERT_Y(this->get_box()->get_y1()+20)); } } void AlternationVertex::printSVertex(FILE *fp) { /* print secondary */ if ((this->get_primary_flag() != PRIMARY) && (this->get_primary_flag() != PRIMARY_OF)) { char pname[1024]; pname[0] = '\0'; if (this->get_is_template()) { this->get_name()->get_parameterized_name(this->get_parassignstore(),pname); if (this->no_parameters()) pname[strlen(pname)-2] = '\0'; } else if (this->get_template_name()) /* template instance */ this->get_template_name()->get_parameterized_name(this->get_parassignstore(),pname); fprintf(fp,"\n%%S %d %d %d %d %d\n", (char*)(GraphicsObject*)this,this->get_name_x(),this->get_name_y(), this->get_box()->get_x1(),this->get_box()->get_y1()); fprintf(fp,"{ (%s) %d %d vertex-name} EXEC\n", pname, CONVERT_X(this->get_name_x()), CONVERT_Y(this->get_name_y())); if (this->no_formal_parameters()) fprintf(fp,"{ %d %d normal-secondary-alternation-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()), CONVERT_Y(this->get_box()->get_y1()+20)); else fprintf(fp,"{ %d %d parameterized-secondary-alternation-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()), CONVERT_Y(this->get_box()->get_y1()+20)); } } void ConstructionVertex::printSVertex(FILE *fp) { if ((this->get_primary_flag() != PRIMARY) && (this->get_primary_flag() != PRIMARY_OF)) { char pname[1024]; pname[0] = '\0'; if (this->get_is_template()) { this->get_name()->get_parameterized_name(this->get_parassignstore(),pname); if (this->no_parameters()) pname[strlen(pname)-2] = '\0'; } else if (this->get_template_name()) /* template instance */ this->get_template_name()->get_parameterized_name(this->get_parassignstore(),pname); fprintf(fp,"\n%%S %d %d %d %d %d\n", (char*)(GraphicsObject*)this,this->get_name_x(),this->get_name_y(), this->get_box()->get_x1(),this->get_box()->get_y1()); fprintf(fp,"{ (%s) %d %d vertex-name} EXEC\n", pname, CONVERT_X(this->get_name_x()), CONVERT_Y(this->get_name_y())); if (this->no_formal_parameters()) fprintf(fp,"{ %d %d normal-secondary-construction-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()), CONVERT_Y(this->get_box()->get_y1()+20)); else fprintf(fp,"{ %d %d parameterized-secondary-construction-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()), CONVERT_Y(this->get_box()->get_y1()+20)); } } void ExternalVertex::printIVertex(FILE *fp) { char pname[1024]; pname[0] = '\0'; if (this->get_is_template()) { this->get_name()->get_parameterized_name(this->get_parassignstore(),pname); if (this->no_parameters()) pname[strlen(pname)-2] = '\0'; } else if (this->get_template_name()) /* template instance */ this->get_template_name()->get_parameterized_name(this->get_parassignstore(),pname); fprintf(fp,"\n%%I %d %d %d %d %d\n", (char*)(GraphicsObject*)this, this->get_name_x(),this->get_name_y(), this->get_box()->get_x1(),this->get_box()->get_y1()); this->get_parassignstore()->printAssignmentPS(fp); fprintf(fp,"{ (%s) %d %d vertex-name} EXEC\n", pname, CONVERT_X(this->get_name_x()), CONVERT_Y(this->get_name_y())); if (this->no_formal_parameters()) fprintf(fp,"{ %d %d normal-primary-external-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()), CONVERT_Y(this->get_box()->get_y1()+20)); else fprintf(fp,"{ %d %d parameterized-primary-external-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()), CONVERT_Y(this->get_box()->get_y1()+20)); } void RepetitionVertex::printIVertex(FILE *fp) { char pname[1024]; pname[0] = '\0'; if (this->get_is_template()) { this->get_name()->get_parameterized_name(this->get_parassignstore(),pname); if (this->no_parameters()) pname[strlen(pname)-2] = '\0'; } else if (this->get_template_name()) /* template instance */ this->get_template_name()->get_parameterized_name(this->get_parassignstore(),pname); fprintf(fp,"\n%%I %d %d %d %d %d\n", (char*)(GraphicsObject*)this,this->get_name_x(),this->get_name_y(), this->get_box()->get_x1(),this->get_box()->get_y1()); this->get_parassignstore()->printAssignmentPS(fp); fprintf(fp,"{ (%s) %d %d vertex-name} EXEC\n", pname, CONVERT_X(this->get_name_x()), CONVERT_Y(this->get_name_y())); if (this->no_formal_parameters()) fprintf(fp,"{ %d %d normal-primary-repetition-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()), CONVERT_Y(this->get_box()->get_y1()+20)); else fprintf(fp,"{ %d %d parameterized-primary-repetition-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()), CONVERT_Y(this->get_box()->get_y1()+20)); } void AlternationVertex::printIVertex(FILE *fp) { char pname[1024]; pname[0] = '\0'; if (this->get_is_template()) { this->get_name()->get_parameterized_name(this->get_parassignstore(),pname); if (this->no_parameters()) pname[strlen(pname)-2] = '\0'; } else if (this->get_template_name()) /* template instance */ this->get_template_name()->get_parameterized_name(this->get_parassignstore(),pname); fprintf(fp,"\n%%I %d %d %d %d %d\n", (char*)(GraphicsObject*)this,this->get_name_x(),this->get_name_y(), this->get_box()->get_x1(),this->get_box()->get_y1()); this->get_parassignstore()->printAssignmentPS(fp); fprintf(fp,"{ (%s) %d %d vertex-name} EXEC\n", pname, CONVERT_X(this->get_name_x()), CONVERT_Y(this->get_name_y())); if (this->no_formal_parameters()) fprintf(fp,"{ %d %d normal-primary-alternation-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()), CONVERT_Y(this->get_box()->get_y1()+20)); else fprintf(fp,"{ %d %d parameterized-primary-alternation-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()), CONVERT_Y(this->get_box()->get_y1()+20)); } void ConstructionVertex::printIVertex(FILE *fp) { char pname[1024]; pname[0] = '\0'; if (this->get_is_template()) { this->get_name()->get_parameterized_name(this->get_parassignstore(),pname); if (this->no_parameters()) pname[strlen(pname)-2] = '\0'; } else if (this->get_template_name()) /* template instance */ this->get_template_name()->get_parameterized_name(this->get_parassignstore(),pname); fprintf(fp,"\n%%I %d %d %d %d %d\n", (char*)(GraphicsObject*)this,this->get_name_x(),this->get_name_y(), this->get_box()->get_x1(),this->get_box()->get_y1()); this->get_parassignstore()->printAssignmentPS(fp); fprintf(fp,"{ (%s) %d %d vertex-name} EXEC\n", pname, CONVERT_X(this->get_name_x()), CONVERT_Y(this->get_name_y())); if (this->no_formal_parameters()) fprintf(fp,"{ %d %d normal-primary-construction-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()), CONVERT_Y(this->get_box()->get_y1()+20)); else fprintf(fp,"{ %d %d parameterized-primary-construction-vertex} EXEC\n", CONVERT_X(this->get_box()->get_x1()), CONVERT_Y(this->get_box()->get_y1()+20)); } /*********************************************************/ /* store edge: */ /* */ /* first print construction edge in order */ /* print parameter edge in order */ /* */ /* print alternation edge */ /* inheritance edge */ /* repetition edge */ /* instance edge */ /*********************************************************/ void VertexStore::printCPEdges(FILE *fp) { /* print construction and parameter edge */ localvertices->printCPEdges(fp); extvstore->printCPEdges(fp); } void ExternalVertexStore::printCPEdges(FILE*fp) { tempstore->printCPEdges(fp); } void NameSensitiveVertexStore::printCPEdges(FILE*fp) { if (vertices) vertices->printCPEdges(fp); } void NameSensitiveVertexList::printCPEdges(FILE*fp) { elm->printCPEdges(fp); if (next) next->printCPEdges(fp); } void NameSensitiveVertex::printCPEdges(FILE*fp) { outgoing_consedge_store->printConsEdges(fp); primary->printParEdges(fp); } void ObjectStore::printConsEdges(FILE*fp) { if (objects) objects->printConsEdges(fp); } void GraphicsObjectList::printConsEdges(FILE*fp) { elm->printConsEdges(fp); if (next) next->printConsEdges(fp); } void GraphicsObject::printConsEdges(FILE*fp) { } void VertexObject::printParEdges(FILE *fp) { this->get_parassignstore()->printParEdges(fp); } void ParameterAssignmentStore::printParEdges(FILE *fp) { if (assignments) assignments->printParEdges(fp); } void ParameterAssignmentList::printParEdges(FILE *fp) { elm->printParEdges(fp); if (next) next->printParEdges(fp); } void ParameterAssignment::printParEdges(FILE *fp) { formaledge->printParEdges(fp); } void ObjectStore::printAIRIEdges(FILE *fp) { /* print alternation, inheritance, repetition and instantiantion edge */ if (objects) objects->printAIRIEdges(fp); } void GraphicsObjectList::printAIRIEdges(FILE *fp) { /* print alternation, inheritance, repetition and instantiantion edge */ elm->printAIRIEdges(fp); if (next) next->printAIRIEdges(fp); } void GraphicsObject::printAIRIEdges(FILE *fp) { } void PointObjectList::genPSArray(FILE *fp) { fprintf(fp,"%d %d ",CONVERT_X(elm->get_x()),CONVERT_Y(elm->get_y())); if (next) next->genPSArray(fp); } void PointObjectList::genCDArray(FILE *fp) { fprintf(fp,"%d %d ",elm->get_x(),elm->get_y()); if (next) next->genCDArray(fp); } static double theta = 3.14159265358979323846/7; static double sin_theta = sin(theta); static double cos_theta = cos(theta); void PointObjectList::genArrow(FILE *fp,draw_kind kind) { if (next->next != NULL) next->genArrow(fp,kind); else { int x1 = this->get_elm()->get_x() - pix_hoffset; int y1 = this->get_elm()->get_y() - pix_voffset; int x2 = this->get_next()->get_elm()->get_x() - pix_hoffset; int y2 = this->get_next()->get_elm()->get_y() - pix_voffset; /* draw arrow */ double arrow_slope_length; if (kind == INH_EDGE || kind == ALT_EDGE || kind == PAR_INST_EDGE) arrow_slope_length = 20; else if (kind == PAR_EDGE) arrow_slope_length = 10; else arrow_slope_length = 15; if (y1 == y2) { int xd1,yd1,xd2,yd2,xd3,yd3,xd4,yd4; xd1 = x2; yd1 = y2; yd2 = yd1 + (int) (arrow_slope_length * sin_theta); yd3 = yd1; yd4 = yd1 - (int) (arrow_slope_length * sin_theta); if (x1 > x2) { xd2 = xd4 = x2 + (int) (arrow_slope_length * cos_theta); xd3 = x2 + (int)(arrow_slope_length/2); } else { xd2 = xd4 = x2 - (int) (arrow_slope_length * cos_theta); xd3 = x2 - (int)(arrow_slope_length/2); } fprintf(fp,"%d %d %d %d %d %d %d %d %d %d", CONVERT_X(xd1 + pix_hoffset), CONVERT_Y(yd1 + pix_voffset), CONVERT_X(xd2 + pix_hoffset), CONVERT_Y(yd2 + pix_voffset), CONVERT_X(xd3 + pix_hoffset), CONVERT_Y(yd3 + pix_voffset), CONVERT_X(xd4 + pix_hoffset), CONVERT_Y(yd4 + pix_voffset), CONVERT_X(xd1 + pix_hoffset), CONVERT_Y(yd1 + pix_voffset)); return; } else if (x1 == x2) { int xd1,yd1,xd2,yd2,xd3,yd3,xd4,yd4; xd1 = x2; yd1 = y2; xd2 = xd1 + (int) (arrow_slope_length * sin_theta); xd3 = xd1; xd4 = xd1 - (int) (arrow_slope_length * sin_theta); if (y1 > y2) { yd2 = yd4 = y2 + (int) (arrow_slope_length * cos_theta); yd3 = y2 + (int)(arrow_slope_length/2); } else { yd2 = yd4 = y2 - (int) (arrow_slope_length * cos_theta); yd3 = y2 - (int)(arrow_slope_length/2); } fprintf(fp,"%d %d %d %d %d %d %d %d %d %d ", CONVERT_X(xd1 + pix_hoffset), CONVERT_Y(yd1 + pix_voffset), CONVERT_X(xd2 + pix_hoffset), CONVERT_Y(yd2 + pix_voffset), CONVERT_X(xd3 + pix_hoffset), CONVERT_Y(yd3 + pix_voffset), CONVERT_X(xd4 + pix_hoffset), CONVERT_Y(yd4 + pix_voffset), CONVERT_X(xd1 + pix_hoffset), CONVERT_Y(yd1 + pix_voffset)); return; } else { double xd1,yd1; xd1 = x2; yd1 = y2; double d = sqrt(((double)x1-(double)x2) * ((double)x1-(double)x2) + ((double)y1-(double)y2) * ((double)y1-(double)y2)); double xd2 = cos_theta; double yd2 = sin_theta; double xd3 = 0.6; double yd3 = 0; double xd4 = xd2; double yd4 = -yd2; /* rotate */ double sin_gamma = ((double)y1-(double)y2)/d; double cos_gamma = ((double)x1-(double)x2)/d; double tx = xd2*cos_gamma - yd2*sin_gamma; double ty = xd2*sin_gamma + yd2*cos_gamma; xd2 = tx; yd2 = ty; tx = xd3*cos_gamma - yd3*sin_gamma; ty = xd3*sin_gamma + yd3*cos_gamma; xd3 = tx; yd3 = ty; tx = xd4*cos_gamma - yd4*sin_gamma; ty = xd4*sin_gamma + yd4*cos_gamma; xd4 = tx; yd4 = ty; d = sqrt(tx*tx + ty*ty); xd2 = xd2/d*arrow_slope_length + x2; xd3 = xd3/d*arrow_slope_length + x2; xd4 = xd4/d*arrow_slope_length + x2; yd2 = yd2/d*arrow_slope_length + y2; yd3 = yd3/d*arrow_slope_length + y2; yd4 = yd4/d*arrow_slope_length + y2; fprintf(fp,"%d %d %d %d %d %d %d %d %d %d ", CONVERT_X(((int)xd1) + pix_hoffset), CONVERT_Y(((int)yd1) + pix_voffset), CONVERT_X(((int)xd2) + pix_hoffset), CONVERT_Y(((int)yd2) + pix_voffset), CONVERT_X(((int)xd3) + pix_hoffset), CONVERT_Y(((int)yd3) + pix_voffset), CONVERT_X(((int)xd4) + pix_hoffset), CONVERT_Y(((int)yd4) + pix_voffset), CONVERT_X(((int)xd1) + pix_hoffset), CONVERT_Y(((int)yd1) + pix_voffset)); return; } } } /******************/ void gen_fvvertex(FILE *fp,VertexObject*fv, VertexObject*tv) { switch(fv->get_kind()) { case CONS_VERTEX: if (fv->isTemplateInst()) fprintf(fp,"CVI "); else fprintf(fp,"CV "); break; case ALT_VERTEX: if (fv->isTemplateInst()) fprintf(fp,"AVI "); else fprintf(fp,"AV "); break; case REP_VERTEX: if (fv->isTemplateInst()) fprintf(fp,"RVI "); else fprintf(fp,"RV "); break; case TERM_VERTEX: fprintf(fp,"TV "); break; case EXT_VERTEX: if (fv->isTemplateInst()) fprintf(fp,"EVI "); else fprintf(fp,"EV "); break; case PARAM_VERTEX: fprintf(fp,"PV "); break; default: break; } fprintf(fp,"%d ", (char*)((GraphicsObject*)fv)); switch(tv->get_kind()) { case CONS_VERTEX: if (tv->isTemplateInst()) fprintf(fp,"CVI "); else fprintf(fp,"CV "); break; case ALT_VERTEX: if (tv->isTemplateInst()) fprintf(fp,"AVI "); else fprintf(fp,"AV "); break; case REP_VERTEX: if (tv->isTemplateInst()) fprintf(fp,"RVI "); else fprintf(fp,"RV "); break; case TERM_VERTEX: fprintf(fp,"TV "); break; case EXT_VERTEX: if (tv->isTemplateInst()) fprintf(fp,"EVI "); else fprintf(fp,"EV "); break; case PARAM_VERTEX: fprintf(fp,"PV "); break; default: break; } fprintf(fp,"%d ", (char*)((GraphicsObject*)tv)); } void AlternationEdge::printAIRIEdges(FILE *fp) { fprintf(fp,"%%AE "); gen_fvvertex(fp,this->get_from_vertex(),this->get_to_vertex()); fprintf(fp,"[ %d ",this->get_points()->length()-1); this->get_points()->genCDArray(fp); fprintf(fp,"] \n"); if (this->get_comments()->get_comments()) fprintf(fp,"%%C %d\n",strlen(this->get_comments()->get_comments())); else fprintf(fp,"%%C 0\n"); printText(fp,this->get_comments()->get_comments()); fprintf(fp,"%%C\n"); fprintf(fp,"{ [ %d ",this->get_points()->length()-1); this->get_points()->genPSArray(fp); fprintf(fp,"] alternation-edge} EXEC\n{"); this->get_points()->genArrow(fp,this->get_kind()); fprintf(fp," arrow} EXEC\n"); } void InheritanceEdge::printAIRIEdges(FILE *fp) { fprintf(fp,"%%IE "); gen_fvvertex(fp,this->get_from_vertex(),this->get_to_vertex()); fprintf(fp,"[ %d ",this->get_points()->length()-1); this->get_points()->genCDArray(fp); fprintf(fp,"] \n"); if (this->get_comments()->get_comments()) fprintf(fp,"%%C %d\n",strlen(this->get_comments()->get_comments())); else fprintf(fp,"%%C 0\n"); printText(fp,this->get_comments()->get_comments()); fprintf(fp,"%%C\n"); fprintf(fp,"{ [ %d ",this->get_points()->length()-1); this->get_points()->genPSArray(fp); fprintf(fp,"] inheritance-edge} EXEC\n{"); this->get_points()->genArrow(fp,this->get_kind()); fprintf(fp," arrow} EXEC\n\n"); } void ReqRepetitionEdge::printAIRIEdges(FILE *fp) { fprintf(fp,"%%RRE "); gen_fvvertex(fp,this->get_from_vertex(),this->get_to_vertex()); fprintf(fp,"[ %d ",this->get_points()->length()-1); this->get_points()->genCDArray(fp); fprintf(fp,"] \n"); if (this->get_comments()->get_comments()) fprintf(fp,"%%C %d\n",strlen(this->get_comments()->get_comments())); else fprintf(fp,"%%C 0\n"); printText(fp,this->get_comments()->get_comments()); fprintf(fp,"%%C\n"); /* before after outbefore */ if (this->get_before()) fprintf(fp,"%%B %d\n",strlen(this->get_before())); else fprintf(fp,"%%B 0\n"); printText(fp,this->get_before()); fprintf(fp,"%%B\n"); if (this->get_after()) fprintf(fp,"%%A %d\n",strlen(this->get_after())); else fprintf(fp,"%%A 0\n"); printText(fp,this->get_after()); fprintf(fp,"%%A\n"); if (this->get_before()) fprintf(fp,"%%OB %d\n",strlen(this->get_before())); else fprintf(fp,"%%OB 0\n"); printText(fp,this->get_before()); fprintf(fp,"%%OB\n"); fprintf(fp,"{ [ %d ",this->get_points()->length()-1); this->get_points()->genPSArray(fp); fprintf(fp,"] required-repetition-edge} EXEC\n{"); this->get_points()->genArrow(fp,this->get_kind()); fprintf(fp," arrow} EXEC\n\n"); } void OptRepetitionEdge::printAIRIEdges(FILE *fp) { fprintf(fp,"%%ORE "); gen_fvvertex(fp,this->get_from_vertex(),this->get_to_vertex()); fprintf(fp,"[ %d ",this->get_points()->length()-1); this->get_points()->genCDArray(fp); fprintf(fp,"] \n"); if (this->get_comments()->get_comments()) fprintf(fp,"%%C %d\n",strlen(this->get_comments()->get_comments())); else fprintf(fp,"%%C 0\n"); printText(fp,this->get_comments()->get_comments()); fprintf(fp,"%%C\n"); /* before after*/ if (this->get_before()) fprintf(fp,"%%B %d\n",strlen(this->get_before())); else fprintf(fp,"%%B 0\n"); printText(fp,this->get_before()); fprintf(fp,"%%B\n"); if (this->get_after()) fprintf(fp,"%%A %d\n",strlen(this->get_after())); else fprintf(fp,"%%A 0\n"); printText(fp,this->get_after()); fprintf(fp,"%%A\n"); fprintf(fp,"{ [ %d ",this->get_points()->length()-1); this->get_points()->genPSArray(fp); fprintf(fp,"] optional-repetition-edge} EXEC\n{"); this->get_points()->genArrow(fp,this->get_kind()); fprintf(fp," arrow} EXEC\n\n"); } void ParameterInstEdge::printAIRIEdges(FILE *fp) { fprintf(fp,"%%PIE "); gen_fvvertex(fp,this->get_from_vertex(),this->get_to_vertex()); fprintf(fp,"[ %d ",this->get_points()->length()-1); this->get_points()->genCDArray(fp); fprintf(fp,"] \n"); if (this->get_comments()->get_comments()) fprintf(fp,"%%C %d\n",strlen(this->get_comments()->get_comments())); else fprintf(fp,"%%C 0\n"); printText(fp,this->get_comments()->get_comments()); fprintf(fp,"%%C\n"); fprintf(fp,"{ [ %d ",this->get_points()->length()-1); this->get_points()->genPSArray(fp); fprintf(fp,"] instantiation-edge} EXEC\n{ "); this->get_points()->genArrow(fp,this->get_kind()); fprintf(fp," arrow} EXEC\n"); } void ParameterEdge::printParEdges(FILE *fp) { fprintf(fp,"%%PE "); gen_fvvertex(fp,this->get_from_vertex(),this->get_to_vertex()); fprintf(fp,"[ %d ",this->get_points()->length()-1); this->get_points()->genCDArray(fp); fprintf(fp,"] \n"); if (this->get_comments()->get_comments()) fprintf(fp,"%%C %d\n",strlen(this->get_comments()->get_comments())); else fprintf(fp,"%%C 0\n"); printText(fp,this->get_comments()->get_comments()); fprintf(fp,"%%C\n"); fprintf(fp,"{ [ %d ",this->get_points()->length()-1); this->get_points()->genPSArray(fp); fprintf(fp,"] parameter-edge} EXEC\n{ "); this->get_points()->genArrow(fp,this->get_kind()); fprintf(fp," arrow} EXEC\n\n"); } void OptConstructionEdge::printConsEdges(FILE*fp) { fprintf(fp,"%%OCE "); gen_fvvertex(fp,this->get_from_vertex(),this->get_to_vertex()); fprintf(fp,"[ %d ",this->get_points()->length()-1); this->get_points()->genCDArray(fp); fprintf(fp,"] \n"); fprintf(fp,"%%EL (%s) %d %d\n",this->get_edge_label()->get_val(), this->get_edge_label()->get_x(), this->get_edge_label()->get_y()); if (this->get_comments()->get_comments()) fprintf(fp,"%%C %d\n",strlen(this->get_comments()->get_comments())); else fprintf(fp,"%%C 0\n"); printText(fp,this->get_comments()->get_comments()); fprintf(fp,"%%C\n"); /*before after inafter inbefore */ if (this->get_before()) fprintf(fp,"%%B %d\n",strlen(this->get_before())); else fprintf(fp,"%%B 0\n"); printText(fp,this->get_before()); fprintf(fp,"%%B\n"); if (this->get_after()) fprintf(fp,"%%A %d\n",strlen(this->get_after())); else fprintf(fp,"%%A 0\n"); printText(fp,this->get_after()); fprintf(fp,"%%A\n"); if (this->get_inbefore()) fprintf(fp,"%%IB %d\n",strlen(this->get_inbefore())); else fprintf(fp,"%%IB 0\n"); printText(fp,this->get_inbefore()); fprintf(fp,"%%IB\n"); if (this->get_inafter()) fprintf(fp,"%%IA %d\n",strlen(this->get_inafter())); else fprintf(fp,"%%IA 0\n"); printText(fp,this->get_inafter()); fprintf(fp,"%%IA\n"); fprintf(fp,"{ [ %d ",this->get_points()->length()-1); this->get_points()->genPSArray(fp); fprintf(fp,"] optional-construction-edge} EXEC\n"); fprintf(fp,"{ (%s) %d %d edge-label} EXEC\n", this->get_edge_label()->get_val(), CONVERT_X(this->get_edge_label()->get_x()), CONVERT_Y(this->get_edge_label()->get_y())); fprintf(fp,"{ "); this->get_points()->genArrow(fp,this->get_kind()); fprintf(fp," arrow} EXEC\n\n"); } void ReqConstructionEdge::printConsEdges(FILE*fp) { fprintf(fp,"%%RCE "); gen_fvvertex(fp,this->get_from_vertex(),this->get_to_vertex()); fprintf(fp,"[ %d ",this->get_points()->length()-1); this->get_points()->genCDArray(fp); fprintf(fp,"] \n"); fprintf(fp,"%%EL (%s) %d %d\n",this->get_edge_label()->get_val(), this->get_edge_label()->get_x(), this->get_edge_label()->get_y()); if (this->get_comments()->get_comments()) fprintf(fp,"%%C %d\n",strlen(this->get_comments()->get_comments())); else fprintf(fp,"%%C 0\n"); printText(fp,this->get_comments()->get_comments()); fprintf(fp,"%%C\n"); /* before after*/ if (this->get_before()) fprintf(fp,"%%B %d\n",strlen(this->get_before())); else fprintf(fp,"%%B 0\n"); printText(fp,this->get_before()); fprintf(fp,"%%B\n"); if (this->get_after()) fprintf(fp,"%%A %d\n",strlen(this->get_after())); else fprintf(fp,"%%A 0\n"); printText(fp,this->get_after()); fprintf(fp,"%%A\n"); fprintf(fp,"{ [ %d ",this->get_points()->length()-1); this->get_points()->genPSArray(fp); fprintf(fp,"] required-construction-edge} EXEC\n"); fprintf(fp,"{ (%s) %d %d edge-label} EXEC\n", this->get_edge_label()->get_val(), CONVERT_X(this->get_edge_label()->get_x()), CONVERT_Y(this->get_edge_label()->get_y())); fprintf(fp,"{ "); this->get_points()->genArrow(fp,this->get_kind()); fprintf(fp," arrow} EXEC\n\n"); } void ParameterAssignmentStore::printAssignmentPS(FILE *fp) { if (assignments) assignments->printAssignmentPS(fp); fprintf(fp,"%%EAS\n"); } void ParameterAssignmentList::printAssignmentPS(FILE *fp) { elm->printAssignmentPS(fp); if (next) next->printAssignmentPS(fp); } void ParameterAssignment::printAssignmentPS(FILE *fp) { if (this->get_actual_val() && strlen(this->get_actual_val())) { if (this->get_flag() == READONLY) fprintf(fp,"%%AS (%s) RO\n",this->get_actual_val()); else fprintf(fp,"%%AS (%s) RW\n",this->get_actual_val()); } else { if (this->get_flag() == READONLY) fprintf(fp,"%%AS () RO\n"); else fprintf(fp,"%%AS () RW\n"); } }