Implement block-diagram schema generation in svg or postscript format. More...
#include <stdio.h>
#include <ctype.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <string.h>
#include <ostream>
#include <sstream>
#include <set>
#include <utility>
#include <map>
#include <stack>
#include <string>
#include "boxes.hh"
#include "ppbox.hh"
#include "prim2.hh"
#include <vector>
#include "devLib.h"
#include "xtended.hh"
#include "eval.hh"
#include "occurrences.hh"
#include "boxcomplexity.h"
#include "schema.h"
#include "drawschema.hh"
#include "compatibility.hh"
Go to the source code of this file.
Functions | |
static void | writeSchemaFile (Tree bd) |
Write a top level diagram. | |
static schema * | generateDiagramSchema (Tree t) |
Generate an appropriate schema according to the type of block diagram. | |
static schema * | generateInsideSchema (Tree t) |
Generate the inside schema of a block diagram according to its type. | |
static void | scheduleDrawing (Tree t) |
Schedule a makeBlockSchema diagram to be drawn. | |
static bool | pendingDrawing (Tree &t) |
Retrieve next block diagram that must be drawn. | |
static schema * | generateAbstractionSchema (schema *x, Tree t) |
Generate an abstraction schema by placing in sequence the input slots and the body. | |
static schema * | generateOutputSlotSchema (Tree a) |
Generate a 0->1 block schema for an output slot. | |
static schema * | generateInputSlotSchema (Tree a) |
Generate a 1->0 block schema for an input slot. | |
static schema * | generateBargraphSchema (Tree t) |
Generate a 1->1 block schema for a user interface bargraph. | |
static schema * | generateUserInterfaceSchema (Tree t) |
Generate a 0->1 block schema for a user interface element. | |
static char * | legalFileName (Tree t, int n, char *dst) |
Transform the definition name property of tree <t> into a legal file name. | |
static int | cholddir () |
Switch back to the previously stored current directory. | |
static int | mkchdir (const char *dirname) |
Create a new directory in the current one to store the diagrams. | |
void | drawSchema (Tree bd, const char *projname, const char *dev) |
The entry point to generate from a block diagram as a set of svg files stored in the directory "<projname>-svg/" or "<projname>-ps/" depending of <dev>. |
Implement block-diagram schema generation in svg or postscript format.
The result is a folder containing one or more schema files in svg or ps format. Complex block-diagrams are automatically splitted.
Definition in file drawschema.cpp.
Generate an appropriate schema according to the type of block diagram.
When folding is requiered, instead of going down block-diagrams with a name, schedule them for an individual file.
Definition at line 317 of file drawschema.cpp.
References boxComplexity(), generateInsideSchema(), getBoxType(), getDefNameProperty(), legalFileName(), and scheduleDrawing().
Referenced by generateAbstractionSchema(), and generateInsideSchema().
00318 { 00319 Tree id; 00320 int ins, outs; 00321 00322 //cerr << t << " generateDiagramSchema " << boxpp(t)<< endl; 00323 00324 if (getDefNameProperty(t, id)) { 00325 stringstream s; s << tree2str(id); 00326 //cerr << t << "\tNAMED : " << s.str() << endl; 00327 } 00328 00329 if ( sFoldingFlag && /*(gOccurrences->getCount(t) > 0) &&*/ 00330 (boxComplexity(t) > 2) && getDefNameProperty(t, id)) { 00331 char temp[1024]; 00332 getBoxType(t, &ins, &outs); 00333 stringstream s, l; 00334 s << tree2str(id); 00335 l << legalFileName(t,1024,temp) << "." << gDevSuffix; 00336 scheduleDrawing(t); 00337 return makeBlockSchema(ins, outs, s.str(), linkcolor, l.str()); 00338 00339 } else if (getDefNameProperty(t, id) && ! isBoxSlot(t)) { 00340 // named case : not a slot, with a name 00341 // draw a line around the object with its name 00342 stringstream s; s << tree2str(id); 00343 return makeDecorateSchema(generateInsideSchema(t), 10, s.str()); 00344 00345 } else { 00346 // normal case 00347 return generateInsideSchema(t); 00348 } 00349 }
static char * legalFileName | ( | Tree | t, | |
int | n, | |||
char * | dst | |||
) | [static] |
Transform the definition name property of tree <t> into a legal file name.
The resulting file name is stored in <dst> a table of at least <n> chars. Returns the <dst> pointer for convenience.
Definition at line 289 of file drawschema.cpp.
References getDefNameProperty().
Referenced by generateDiagramSchema(), and writeSchemaFile().
00290 { 00291 Tree id; 00292 int i=0; 00293 if (getDefNameProperty(t, id)) { 00294 const char* src = tree2str(id); 00295 for (i=0; isalnum(src[i]) && i<16; i++) { 00296 dst[i] = src[i]; 00297 } 00298 } 00299 dst[i] = 0; 00300 if (strcmp(dst, "process") != 0) { 00301 // if it is not process add the hex address to make the name unique 00302 snprintf(&dst[i], n-i, "-%p", t); 00303 } 00304 return dst; 00305 }
static int mkchdir | ( | const char * | dirname | ) | [static] |
Create a new directory in the current one to store the diagrams.
The current directory is saved to be later restaured.
Definition at line 252 of file drawschema.cpp.
Referenced by drawSchema().
00253 { 00254 //cerr << "mkchdir of " << dirname << endl; 00255 if (getcwd(gCurrentDir, 512) != 0) { 00256 int status = mkdir(dirname, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); 00257 if (status == 0 || errno == EEXIST) { 00258 if (chdir(dirname) == 0) { 00259 return 0; 00260 } 00261 } 00262 } 00263 perror("mkchdir"); 00264 exit(errno); 00265 //return errno; 00266 }
static void writeSchemaFile | ( | Tree | bd | ) | [static] |
Write a top level diagram.
A top level diagram is decorated with is definition name property and is drawn in an individual file
Definition at line 215 of file drawschema.cpp.
References generateInsideSchema(), getDefNameProperty(), and legalFileName().
Referenced by drawSchema().
00216 { 00217 Tree id; 00218 schema* ts; 00219 00220 char temp[1024]; 00221 00222 gOccurrences = new Occurrences(bd); 00223 00224 bool hasname = getDefNameProperty(bd, id); assert(hasname); 00225 00226 // generate legal file name for the schema 00227 stringstream s1; s1 << legalFileName(bd, 1024, temp) << "." << gDevSuffix; 00228 gSchemaFileName = s1.str(); 00229 00230 // generate the label of the schema 00231 stringstream s2; s2 << tree2str(id); 00232 string link = gBackLink[bd]; 00233 ts = makeTopSchema(generateInsideSchema(bd), 20, s2.str(), link); 00234 // draw to the device defined by gDevSuffix 00235 if (strcmp(gDevSuffix, "svg") == 0) { 00236 SVGDev dev(s1.str().c_str(), ts->width(), ts->height()); 00237 ts->place(0,0, kLeftRight); 00238 ts->draw(dev); 00239 } else { 00240 PSDev dev(s1.str().c_str(), ts->width(), ts->height()); 00241 ts->place(0,0, kLeftRight); 00242 ts->draw(dev); 00243 } 00244 }