FAUST compiler  0.9.9.6b8
Macros | Functions | Variables
drawschema.cpp File Reference

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 "occurrences.hh"
#include "boxcomplexity.h"
#include "schema.h"
#include "drawschema.hh"
#include "compatibility.hh"
#include "names.hh"
#include "description.hh"
#include "property.hh"
#include "files.hh"
Include dependency graph for drawschema.cpp:

Go to the source code of this file.

Macros

#define linkcolor   "#003366"
 
#define normalcolor   "#4B71A1"
 
#define uicolor   "#477881"
 
#define slotcolor   "#47945E"
 
#define numcolor   "#f44800"
 
#define invcolor   "#ffffff"
 

Functions

static void writeSchemaFile (Tree bd)
 Write a top level diagram. More...
 
static schemagenerateDiagramSchema (Tree t)
 Generate an appropriate schema according to the type of block diagram. More...
 
static schemagenerateInsideSchema (Tree t)
 Generate the inside schema of a block diagram according to its type. More...
 
static void scheduleDrawing (Tree t)
 Schedule a makeBlockSchema diagram to be drawn. More...
 
static bool pendingDrawing (Tree &t)
 Retrieve next block diagram that must be drawn. More...
 
static schemagenerateAbstractionSchema (schema *x, Tree t)
 Generate an abstraction schema by placing in sequence the input slots and the body. More...
 
static schemagenerateOutputSlotSchema (Tree a)
 Generate a 0->1 block schema for an output slot. More...
 
static schemagenerateInputSlotSchema (Tree a)
 Generate a 1->0 block schema for an input slot. More...
 
static schemagenerateBargraphSchema (Tree t)
 Generate a 1->1 block schema for a user interface bargraph. More...
 
static schemagenerateUserInterfaceSchema (Tree t)
 Generate a 0->1 block schema for a user interface element. More...
 
static char * legalFileName (Tree t, int n, char *dst)
 Transform the definition name property of tree <t> into a legal file name. More...
 
static schemaaddSchemaInputs (int ins, schema *x)
 
static schemaaddSchemaOutputs (int outs, schema *x)
 
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>. More...
 
static bool isInverter (Tree t)
 
static bool isPureRouting (Tree t)
 
static void UserInterfaceDescription (Tree box, string &d)
 Convert User interface element into a textual representation. More...
 

Variables

int gFoldThreshold
 
static OccurrencesgOccurrences
 
static bool sFoldingFlag
 
static stack< TreegPendingExp
 
static set< TreegDrawnExp
 
static const char * gDevSuffix
 
static string gSchemaFileName
 
static map< Tree, string > gBackLink
 
Tree gInverter [6]
 isInverter(t) returns true if t == '*(-1)'. More...
 
property< bool > gPureRoutingProperty
 Compute the Pure Routing property, that is expressions only made of cut, wires and slots. More...
 

Detailed Description

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.

Macro Definition Documentation

#define invcolor   "#ffffff"

Definition at line 119 of file drawschema.cpp.

Referenced by generateInsideSchema().

#define linkcolor   "#003366"

Definition at line 114 of file drawschema.cpp.

Referenced by generateDiagramSchema().

#define normalcolor   "#4B71A1"

Definition at line 115 of file drawschema.cpp.

Referenced by generateInsideSchema().

#define numcolor   "#f44800"

Definition at line 118 of file drawschema.cpp.

Referenced by generateInsideSchema().

#define slotcolor   "#47945E"

Definition at line 117 of file drawschema.cpp.

Referenced by generateInputSlotSchema(), and generateOutputSlotSchema().

#define uicolor   "#477881"

Definition at line 116 of file drawschema.cpp.

Referenced by generateBargraphSchema(), and generateUserInterfaceSchema().

Function Documentation

static schema * addSchemaInputs ( int  ins,
schema x 
)
static

Definition at line 600 of file drawschema.cpp.

References makeConnectorSchema(), makeParSchema(), and makeSeqSchema().

Referenced by writeSchemaFile().

601 {
602  if (ins==0) {
603  return x;
604  } else {
605  schema* y = 0;
606  do {
608  if (y != 0) {
609  y = makeParSchema(y,z);
610  } else {
611  y = z;
612  }
613  } while (--ins);
614  return makeSeqSchema(y,x);
615  }
616 }
schema * makeParSchema(schema *s1, schema *s2)
Definition: parSchema.cpp:28
schema * makeConnectorSchema()
Connectors are used to ensure unused inputs and outputs are drawn.
An abstract block diagram schema.
Definition: schema.h:97
schema * makeSeqSchema(schema *s1, schema *s2)
Make a sequential schema.
Definition: seqSchema.cpp:43

Here is the call graph for this function:

Here is the caller graph for this function:

static schema * addSchemaOutputs ( int  outs,
schema x 
)
static

Definition at line 619 of file drawschema.cpp.

References makeConnectorSchema(), makeParSchema(), and makeSeqSchema().

Referenced by writeSchemaFile().

620 {
621  if (outs==0) {
622  return x;
623  } else {
624  schema* y = 0;
625  do {
627  if (y != 0) {
628  y = makeParSchema(y,z);
629  } else {
630  y = z;
631  }
632  } while (--outs);
633  return makeSeqSchema(x,y);
634  }
635 }
schema * makeParSchema(schema *s1, schema *s2)
Definition: parSchema.cpp:28
schema * makeConnectorSchema()
Connectors are used to ensure unused inputs and outputs are drawn.
An abstract block diagram schema.
Definition: schema.h:97
schema * makeSeqSchema(schema *s1, schema *s2)
Make a sequential schema.
Definition: seqSchema.cpp:43

Here is the call graph for this function:

Here is the caller graph for this function:

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>.

Definition at line 161 of file drawschema.cpp.

References boxComplexity(), cholddir(), gDevSuffix, gFoldThreshold, mkchdir(), pendingDrawing(), scheduleDrawing(), sFoldingFlag, and writeSchemaFile().

Referenced by main(), and printDocDgm().

162 {
163  gDevSuffix = dev;
165 
166  mkchdir(projname); // create a directory to store files
167 
168  scheduleDrawing(bd); // schedule the initial drawing
169 
170  Tree t; while (pendingDrawing(t)) {
171  writeSchemaFile(t); // generate all the pending drawing
172  }
173 
174  cholddir(); // return to current directory
175 }
static bool pendingDrawing(Tree &t)
Retrieve next block diagram that must be drawn.
Definition: drawschema.cpp:202
static int cholddir()
Switch back to the previously stored current directory.
Definition: doc_lang.cpp:242
int mkchdir(string dirname)
Create a new directory in the current one to store the diagrams.
Definition: files.cpp:55
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
int gFoldThreshold
Definition: main.cpp:126
static bool sFoldingFlag
Definition: drawschema.cpp:130
int boxComplexity(Tree box)
Return the complexity propety of a box expression tree.
static void scheduleDrawing(Tree t)
Schedule a makeBlockSchema diagram to be drawn.
Definition: drawschema.cpp:190
static const char * gDevSuffix
Definition: drawschema.cpp:133
static void writeSchemaFile(Tree bd)
Write a top level diagram.
Definition: drawschema.cpp:219

Here is the call graph for this function:

Here is the caller graph for this function:

static schema * generateAbstractionSchema ( schema x,
Tree  t 
)
static

Generate an abstraction schema by placing in sequence the input slots and the body.

Definition at line 589 of file drawschema.cpp.

References generateDiagramSchema(), generateInputSlotSchema(), isBoxSymbolic(), makeParSchema(), and makeSeqSchema().

Referenced by generateInsideSchema().

590 {
591  Tree a,b;
592 
593  while (isBoxSymbolic(t,a,b)) {
595  t = b;
596  }
597  return makeSeqSchema(x, generateDiagramSchema(t));
598 }
static schema * generateInputSlotSchema(Tree a)
Generate a 1->0 block schema for an input slot.
Definition: drawschema.cpp:564
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
schema * makeParSchema(schema *s1, schema *s2)
Definition: parSchema.cpp:28
bool isBoxSymbolic(Tree t)
Definition: boxes.cpp:126
static schema * generateDiagramSchema(Tree bd)
Generate an appropriate schema according to the type of block diagram.
Definition: drawschema.cpp:358
schema * makeSeqSchema(schema *s1, schema *s2)
Make a sequential schema.
Definition: seqSchema.cpp:43

Here is the call graph for this function:

Here is the caller graph for this function:

static schema * generateBargraphSchema ( Tree  t)
static

Generate a 1->1 block schema for a user interface bargraph.

Definition at line 553 of file drawschema.cpp.

References makeBlockSchema(), uicolor, and UserInterfaceDescription().

Referenced by generateInsideSchema().

554 {
555  string s; UserInterfaceDescription(t,s);
556  return makeBlockSchema(1, 1, s, uicolor, "");
557 }
static void UserInterfaceDescription(Tree box, string &d)
Convert User interface element into a textual representation.
Definition: drawschema.cpp:480
schema * makeBlockSchema(unsigned int inputs, unsigned int outputs, const string &text, const string &color, const string &link)
Build a simple colored blockSchema with a certain number of inputs and outputs, a text to be displaye...
Definition: blockSchema.cpp:41
#define uicolor
Definition: drawschema.cpp:116

Here is the call graph for this function:

Here is the caller graph for this function:

static schema * generateDiagramSchema ( Tree  t)
static

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 358 of file drawschema.cpp.

References boxComplexity(), gDevSuffix, generateInsideSchema(), getBoxType(), getDefNameProperty(), isPureRouting(), legalFileName(), linkcolor, makeBlockSchema(), makeDecorateSchema(), scheduleDrawing(), sFoldingFlag, and tree2str().

Referenced by generateAbstractionSchema(), and generateInsideSchema().

359 {
360  Tree id;
361  int ins, outs;
362 
363  //cerr << t << " generateDiagramSchema " << boxpp(t)<< endl;
364 
365  if (getDefNameProperty(t, id)) {
366  stringstream s; s << tree2str(id);
367  //cerr << t << "\tNAMED : " << s.str() << endl;
368  }
369 
370  if ( sFoldingFlag && /*(gOccurrences->getCount(t) > 0) &&*/
371  (boxComplexity(t) > 2) && getDefNameProperty(t, id)) {
372  char temp[1024];
373  getBoxType(t, &ins, &outs);
374  stringstream s, l;
375  s << tree2str(id);
376  l << legalFileName(t,1024,temp) << "." << gDevSuffix;
377  scheduleDrawing(t);
378  return makeBlockSchema(ins, outs, s.str(), linkcolor, l.str());
379 
380  } else if (getDefNameProperty(t, id) && ! isPureRouting(t)) {
381  // named case : not a slot, with a name
382  // draw a line around the object with its name
383  stringstream s; s << tree2str(id);
384  return makeDecorateSchema(generateInsideSchema(t), 10, s.str());
385 
386  } else {
387  // normal case
388  return generateInsideSchema(t);
389  }
390 }
bool getDefNameProperty(Tree t, Tree &id)
Indicates the identifier (if any) the expression was a definition of.
Definition: names.cpp:85
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
static bool sFoldingFlag
Definition: drawschema.cpp:130
schema * makeDecorateSchema(schema *s, double margin, const string &text)
Creates a new decorated schema.
int boxComplexity(Tree box)
Return the complexity propety of a box expression tree.
static void scheduleDrawing(Tree t)
Schedule a makeBlockSchema diagram to be drawn.
Definition: drawschema.cpp:190
static bool isPureRouting(Tree t)
Definition: drawschema.cpp:326
static char * legalFileName(Tree t, int n, char *dst)
Transform the definition name property of tree into a legal file name.
Definition: drawschema.cpp:271
static const char * gDevSuffix
Definition: drawschema.cpp:133
schema * makeBlockSchema(unsigned int inputs, unsigned int outputs, const string &text, const string &color, const string &link)
Build a simple colored blockSchema with a certain number of inputs and outputs, a text to be displaye...
Definition: blockSchema.cpp:41
static schema * generateInsideSchema(Tree t)
Generate the inside schema of a block diagram according to its type.
Definition: drawschema.cpp:398
const char * tree2str(Tree t)
if t has a node of type symbol, return its name otherwise error
Definition: tree.cpp:278
#define linkcolor
Definition: drawschema.cpp:114
bool getBoxType(Tree box, int *inum, int *onum)
Return the type (number of inputs and outputs) of a box or false if undefined.
Definition: boxtype.cpp:63

Here is the call graph for this function:

Here is the caller graph for this function:

static schema * generateInputSlotSchema ( Tree  a)
static

Generate a 1->0 block schema for an input slot.

Definition at line 564 of file drawschema.cpp.

References getDefNameProperty(), makeBlockSchema(), slotcolor, and tree2str().

Referenced by generateAbstractionSchema(), and generateInsideSchema().

565 {
566  Tree id; assert(getDefNameProperty(a, id));
567  stringstream s; s << tree2str(id);
568  return makeBlockSchema(1, 0, s.str(), slotcolor, "");
569 }
bool getDefNameProperty(Tree t, Tree &id)
Indicates the identifier (if any) the expression was a definition of.
Definition: names.cpp:85
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
#define slotcolor
Definition: drawschema.cpp:117
schema * makeBlockSchema(unsigned int inputs, unsigned int outputs, const string &text, const string &color, const string &link)
Build a simple colored blockSchema with a certain number of inputs and outputs, a text to be displaye...
Definition: blockSchema.cpp:41
const char * tree2str(Tree t)
if t has a node of type symbol, return its name otherwise error
Definition: tree.cpp:278

Here is the call graph for this function:

Here is the caller graph for this function:

static schema * generateInsideSchema ( Tree  t)
static

Generate the inside schema of a block diagram according to its type.

Definition at line 398 of file drawschema.cpp.

References xtended::arity(), extractName(), ffarity(), ffname(), generateAbstractionSchema(), generateBargraphSchema(), generateDiagramSchema(), generateInputSlotSchema(), generateOutputSlotSchema(), generateUserInterfaceSchema(), getDefNameProperty(), getUserData(), invcolor, isBoxButton(), isBoxCheckbox(), isBoxCut(), isBoxFConst(), isBoxFFun(), isBoxFVar(), isBoxHBargraph(), isBoxHGroup(), isBoxHSlider(), isBoxInt(), isBoxMerge(), isBoxNumEntry(), isBoxPar(), isBoxPrim0(), isBoxPrim1(), isBoxPrim2(), isBoxPrim3(), isBoxPrim4(), isBoxPrim5(), isBoxReal(), isBoxRec(), isBoxSeq(), isBoxSlot(), isBoxSplit(), isBoxSymbolic(), isBoxTGroup(), isBoxVBargraph(), isBoxVGroup(), isBoxVSlider(), isBoxWaveform(), isBoxWire(), isInverter(), makeBlockSchema(), makeCableSchema(), makeCutSchema(), makeDecorateSchema(), makeInverterSchema(), makeMergeSchema(), makeParSchema(), makeRecSchema(), makeSeqSchema(), makeSplitSchema(), xtended::name(), name(), normalcolor, numcolor, prim0name(), prim1name(), prim2name(), prim3name(), prim4name(), prim5name(), print(), and tree2str().

Referenced by generateDiagramSchema(), and writeSchemaFile().

399 {
400  Tree a, b, ff, l, type,name,file;
401  int i;
402  double r;
403  prim0 p0;
404  prim1 p1;
405  prim2 p2;
406  prim3 p3;
407  prim4 p4;
408  prim5 p5;
409 
410 
411  xtended* xt = (xtended*)getUserData(t);
412 
413  if (xt) { return makeBlockSchema(xt->arity(), 1, xt->name(), normalcolor, ""); }
414 
415  else if (isInverter(t)) { return makeInverterSchema(invcolor); }
416 
417  else if (isBoxInt(t, &i)) { stringstream s; s << i; return makeBlockSchema(0, 1, s.str(), numcolor, "" ); }
418  else if (isBoxReal(t, &r)) { stringstream s; s << r; return makeBlockSchema(0, 1, s.str(), numcolor, "" ); }
419  else if (isBoxWaveform(t)) { return makeBlockSchema(0, 2, "waveform{...}", normalcolor, ""); }
420  else if (isBoxWire(t)) { return makeCableSchema(); }
421  else if (isBoxCut(t)) { return makeCutSchema(); }
422 
423  else if (isBoxPrim0(t, &p0)) { return makeBlockSchema(0, 1, prim0name(p0), normalcolor, ""); }
424  else if (isBoxPrim1(t, &p1)) { return makeBlockSchema(1, 1, prim1name(p1), normalcolor, ""); }
425  else if (isBoxPrim2(t, &p2)) { return makeBlockSchema(2, 1, prim2name(p2), normalcolor, ""); }
426  else if (isBoxPrim3(t, &p3)) { return makeBlockSchema(3, 1, prim3name(p3), normalcolor, ""); }
427  else if (isBoxPrim4(t, &p4)) { return makeBlockSchema(4, 1, prim4name(p4), normalcolor, ""); }
428  else if (isBoxPrim5(t, &p5)) { return makeBlockSchema(5, 1, prim5name(p5), normalcolor, ""); }
429 
430  else if (isBoxFFun(t, ff)) { return makeBlockSchema(ffarity(ff), 1, ffname(ff), normalcolor, ""); }
431  else if (isBoxFConst(t, type,name,file)) { return makeBlockSchema(0, 1, tree2str(name), normalcolor, ""); }
432  else if (isBoxFVar (t, type, name,file)) { return makeBlockSchema(0, 1, tree2str(name), normalcolor, ""); }
433 
434  else if (isBoxButton(t)) { return generateUserInterfaceSchema(t); }
435  else if (isBoxCheckbox(t)) { return generateUserInterfaceSchema(t); }
436  else if (isBoxVSlider(t)) { return generateUserInterfaceSchema(t); }
437  else if (isBoxHSlider(t)) { return generateUserInterfaceSchema(t); }
438  else if (isBoxNumEntry(t)) { return generateUserInterfaceSchema(t); }
439  else if (isBoxVBargraph(t)) { return generateBargraphSchema(t); }
440  else if (isBoxHBargraph(t)) { return generateBargraphSchema(t); }
441 
442  // don't draw group rectangle when labels are empty (ie "")
443  else if (isBoxVGroup(t,l,a)) { stringstream s; s << "vgroup(" << extractName(l) << ")";
445  return makeDecorateSchema(r, 10, s.str()); }
446  else if (isBoxHGroup(t,l,a)) { stringstream s; s << "hgroup(" << extractName(l) << ")";
448  return makeDecorateSchema(r, 10, s.str()); }
449  else if (isBoxTGroup(t,l,a)) { stringstream s; s << "tgroup(" << extractName(l) << ")";
451  return makeDecorateSchema(r, 10, s.str()); }
452 
453  else if (isBoxSeq(t, a, b)) { return makeSeqSchema(generateDiagramSchema(a), generateDiagramSchema(b)); }
454  else if (isBoxPar(t, a, b)) { return makeParSchema(generateDiagramSchema(a), generateDiagramSchema(b)); }
455  else if (isBoxSplit(t, a, b)) { return makeSplitSchema(generateDiagramSchema(a), generateDiagramSchema(b)); }
456  else if (isBoxMerge(t, a, b)) { return makeMergeSchema(generateDiagramSchema(a), generateDiagramSchema(b)); }
457  else if (isBoxRec(t, a, b)) { return makeRecSchema(generateDiagramSchema(a), generateDiagramSchema(b)); }
458 
459  else if (isBoxSlot(t, &i)) { return generateOutputSlotSchema(t); }
460  else if (isBoxSymbolic(t,a,b)) {
461  Tree id;
462  if (getDefNameProperty(t, id)) {
464  } else {
465  return makeDecorateSchema(generateAbstractionSchema(generateInputSlotSchema(a), b), 10, "Abstraction");
466  }
467  }
468 
469  else {
470 
471  fprintf(stderr, "Internal Error, box expression not recognized : "); print(t, stderr); fprintf(stderr, "\n");
472  exit(1);
473 
474  }
475 }
bool isBoxPrim1(Tree s)
Definition: boxes.cpp:315
bool isBoxPrim5(Tree s)
Definition: boxes.cpp:335
bool getDefNameProperty(Tree t, Tree &id)
Indicates the identifier (if any) the expression was a definition of.
Definition: names.cpp:85
static schema * generateBargraphSchema(Tree t)
Generate a 1->1 block schema for a user interface bargraph.
Definition: drawschema.cpp:553
Tree(* prim2)(Tree x, Tree y)
Definition: boxes.hh:210
schema * makeMergeSchema(schema *s1, schema *s2)
Creates a new merge schema.
Definition: mergeSchema.cpp:35
bool isBoxWire(Tree t)
Definition: boxes.cpp:109
static schema * generateInputSlotSchema(Tree a)
Generate a 1->0 block schema for an input slot.
Definition: drawschema.cpp:564
const char * prim3name(CTree *(*ptr)(CTree *, CTree *, CTree *))
Definition: ppbox.cpp:76
bool isBoxSeq(Tree t, Tree &x, Tree &y)
Definition: boxes.cpp:136
bool isBoxInt(Tree t)
Definition: boxes.cpp:78
const char * prim2name(CTree *(*ptr)(CTree *, CTree *))
Definition: ppbox.cpp:47
schema * makeCutSchema()
Creates a new Cut schema.
Definition: cutSchema.cpp:33
bool isBoxSplit(Tree t, Tree &x, Tree &y)
Definition: boxes.cpp:148
Tree(* prim4)(Tree w, Tree x, Tree y, Tree z)
Definition: boxes.hh:212
bool isBoxFFun(Tree s)
Definition: boxes.cpp:344
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
bool isBoxCut(Tree t)
Definition: boxes.cpp:105
const char * ffname(Tree t)
Definition: prim2.cpp:60
#define numcolor
Definition: drawschema.cpp:118
int ffarity(Tree t)
Definition: prim2.cpp:67
static schema * generateUserInterfaceSchema(Tree t)
Generate a 0->1 block schema for a user interface element.
Definition: drawschema.cpp:543
schema * makeParSchema(schema *s1, schema *s2)
Definition: parSchema.cpp:28
bool isBoxPrim0(Tree s)
Definition: boxes.cpp:310
const char * name()
Definition: xtended.hh:25
bool isBoxPrim4(Tree s)
Definition: boxes.cpp:330
bool isBoxHGroup(Tree s)
Definition: boxes.cpp:437
bool isBoxHBargraph(Tree s)
Definition: boxes.cpp:455
#define normalcolor
Definition: drawschema.cpp:115
bool isBoxRec(Tree t, Tree &x, Tree &y)
Definition: boxes.cpp:144
static schema * generateOutputSlotSchema(Tree a)
Generate a 0->1 block schema for an output slot.
Definition: drawschema.cpp:576
Tree(* prim3)(Tree x, Tree y, Tree z)
Definition: boxes.hh:211
Tree(* prim5)(Tree v, Tree w, Tree x, Tree y, Tree z)
Definition: boxes.hh:213
schema * makeRecSchema(schema *s1, schema *s2)
Creates a new recursive schema (s1 ~ s2).
Definition: recSchema.cpp:34
bool isBoxSymbolic(Tree t)
Definition: boxes.cpp:126
bool isBoxTGroup(Tree s)
Definition: boxes.cpp:449
schema * makeInverterSchema(const string &color)
Build n cables in parallel.
bool isBoxButton(Tree s)
Definition: boxes.cpp:366
bool isBoxReal(Tree t)
Definition: boxes.cpp:79
schema * makeSplitSchema(schema *s1, schema *s2)
Creates a new split schema.
Definition: splitSchema.cpp:34
schema * makeDecorateSchema(schema *s, double margin, const string &text)
Creates a new decorated schema.
Tree(* prim1)(Tree x)
Definition: boxes.hh:209
static schema * generateDiagramSchema(Tree bd)
Generate an appropriate schema according to the type of block diagram.
Definition: drawschema.cpp:358
bool isBoxPar(Tree t, Tree &x, Tree &y)
Definition: boxes.cpp:140
bool isBoxHSlider(Tree s)
Definition: boxes.cpp:379
static bool isInverter(Tree t)
Definition: drawschema.cpp:299
bool isBoxVBargraph(Tree s)
Definition: boxes.cpp:461
bool isBoxWaveform(Tree s)
Definition: boxes.cpp:97
#define invcolor
Definition: drawschema.cpp:119
bool isBoxCheckbox(Tree s)
Definition: boxes.cpp:372
bool isBoxVGroup(Tree s)
Definition: boxes.cpp:443
virtual unsigned int arity()=0
string extractName(Tree fulllabel)
bool isBoxFVar(Tree s)
Definition: boxes.cpp:356
const char * name(Symbol *sym)
Returns the name of a symbol.
Definition: symbol.hh:98
An abstract block diagram schema.
Definition: schema.h:97
bool isBoxVSlider(Tree s)
Definition: boxes.cpp:399
bool isBoxNumEntry(Tree s)
Definition: boxes.cpp:418
bool isBoxSlot(Tree t)
Definition: boxes.cpp:119
static schema * generateAbstractionSchema(schema *x, Tree t)
Generate an abstraction schema by placing in sequence the input slots and the body.
Definition: drawschema.cpp:589
void * getUserData(Symbol *sym)
Returns user data.
Definition: symbol.hh:100
bool isBoxPrim3(Tree s)
Definition: boxes.cpp:325
schema * makeCableSchema(unsigned int n)
Build n cables in parallel.
Definition: cableSchema.cpp:32
const char * prim5name(CTree *(*ptr)(CTree *, CTree *, CTree *, CTree *, CTree *))
Definition: ppbox.cpp:89
schema * makeBlockSchema(unsigned int inputs, unsigned int outputs, const string &text, const string &color, const string &link)
Build a simple colored blockSchema with a certain number of inputs and outputs, a text to be displaye...
Definition: blockSchema.cpp:41
const char * prim1name(CTree *(*ptr)(CTree *))
Definition: ppbox.cpp:39
bool isBoxMerge(Tree t, Tree &x, Tree &y)
Definition: boxes.cpp:152
bool isBoxFConst(Tree s)
Definition: boxes.cpp:350
schema * makeSeqSchema(schema *s1, schema *s2)
Make a sequential schema.
Definition: seqSchema.cpp:43
bool isBoxPrim2(Tree s)
Definition: boxes.cpp:320
const char * prim0name(CTree *(*ptr)())
Definition: ppbox.cpp:34
const char * tree2str(Tree t)
if t has a node of type symbol, return its name otherwise error
Definition: tree.cpp:278
const char * prim4name(CTree *(*ptr)(CTree *, CTree *, CTree *, CTree *))
Definition: ppbox.cpp:83
Tree(* prim0)()
Definition: boxes.hh:208
void print(Tree t, FILE *out)
Definition: list.cpp:154

Here is the caller graph for this function:

static schema * generateOutputSlotSchema ( Tree  a)
static

Generate a 0->1 block schema for an output slot.

Definition at line 576 of file drawschema.cpp.

References getDefNameProperty(), makeBlockSchema(), slotcolor, and tree2str().

Referenced by generateInsideSchema().

577 {
578  Tree id; assert(getDefNameProperty(a, id));
579  stringstream s; s << tree2str(id);
580  return makeBlockSchema(0, 1, s.str(), slotcolor, "");
581 }
bool getDefNameProperty(Tree t, Tree &id)
Indicates the identifier (if any) the expression was a definition of.
Definition: names.cpp:85
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
#define slotcolor
Definition: drawschema.cpp:117
schema * makeBlockSchema(unsigned int inputs, unsigned int outputs, const string &text, const string &color, const string &link)
Build a simple colored blockSchema with a certain number of inputs and outputs, a text to be displaye...
Definition: blockSchema.cpp:41
const char * tree2str(Tree t)
if t has a node of type symbol, return its name otherwise error
Definition: tree.cpp:278

Here is the call graph for this function:

Here is the caller graph for this function:

static schema * generateUserInterfaceSchema ( Tree  t)
static

Generate a 0->1 block schema for a user interface element.

Definition at line 543 of file drawschema.cpp.

References makeBlockSchema(), uicolor, and UserInterfaceDescription().

Referenced by generateInsideSchema().

544 {
545  string s; UserInterfaceDescription(t,s);
546  return makeBlockSchema(0, 1, s, uicolor, "");
547 }
static void UserInterfaceDescription(Tree box, string &d)
Convert User interface element into a textual representation.
Definition: drawschema.cpp:480
schema * makeBlockSchema(unsigned int inputs, unsigned int outputs, const string &text, const string &color, const string &link)
Build a simple colored blockSchema with a certain number of inputs and outputs, a text to be displaye...
Definition: blockSchema.cpp:41
#define uicolor
Definition: drawschema.cpp:116

Here is the call graph for this function:

Here is the caller graph for this function:

static bool isInverter ( Tree  t)
static

Definition at line 299 of file drawschema.cpp.

References boxInt(), boxPar(), boxPrim2(), boxReal(), boxSeq(), boxWire(), gInverter, sigMul(), and sigSub().

Referenced by generateInsideSchema(), and isPureRouting().

300 {
301  // init gInverted table. For some reason doesn't work if done outside
302  if (gInverter[0] == 0) {
309  };
310 
311  //cerr << "isInverter " << t << '$' << boxpp(t) << endl;
312  for (int i=0; i<6; i++) {
313  if (t == gInverter[i]) return true;
314  }
315  return false;
316 }
Tree boxInt(int n)
Definition: boxes.cpp:75
Tree boxWire()
Definition: boxes.cpp:108
Tree sigSub(Tree x, Tree y)
Definition: signals.hh:153
Tree gInverter[6]
isInverter(t) returns true if t == '*(-1)'.
Definition: drawschema.cpp:297
Tree boxReal(double n)
Definition: boxes.cpp:76
Tree boxPrim2(prim2 foo)
Definition: boxes.cpp:319
Tree boxSeq(Tree x, Tree y)
Definition: boxes.cpp:135
Tree boxPar(Tree x, Tree y)
Definition: boxes.cpp:139
Tree sigMul(Tree x, Tree y)
Definition: signals.hh:154

Here is the call graph for this function:

Here is the caller graph for this function:

static bool isPureRouting ( Tree  t)
static

Definition at line 326 of file drawschema.cpp.

References gPureRoutingProperty, isBoxCut(), isBoxMerge(), isBoxPar(), isBoxSeq(), isBoxSlot(), isBoxSplit(), isBoxWire(), and isInverter().

Referenced by generateDiagramSchema().

327 {
328  bool r;
329  int ID;
330  Tree x,y;
331 
332  if (gPureRoutingProperty.get(t,r)) {
333  return r;
334  } else if ( isBoxCut(t)
335  || isBoxWire(t)
336  || isInverter(t)
337  || isBoxSlot(t, &ID)
338  || (isBoxPar(t,x,y) && isPureRouting(x) && isPureRouting(y))
339  || (isBoxSeq(t,x,y) && isPureRouting(x) && isPureRouting(y))
340  || (isBoxSplit(t,x,y) && isPureRouting(x) && isPureRouting(y))
341  || (isBoxMerge(t,x,y) && isPureRouting(x) && isPureRouting(y))
342  ) {
343  gPureRoutingProperty.set(t,true);
344  return true;
345  } else {
346  gPureRoutingProperty.set(t,false);
347  return false;
348  }
349 }
bool isBoxWire(Tree t)
Definition: boxes.cpp:109
bool isBoxSeq(Tree t, Tree &x, Tree &y)
Definition: boxes.cpp:136
bool isBoxSplit(Tree t, Tree &x, Tree &y)
Definition: boxes.cpp:148
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
bool isBoxCut(Tree t)
Definition: boxes.cpp:105
bool isBoxPar(Tree t, Tree &x, Tree &y)
Definition: boxes.cpp:140
static bool isInverter(Tree t)
Definition: drawschema.cpp:299
static bool isPureRouting(Tree t)
Definition: drawschema.cpp:326
property< bool > gPureRoutingProperty
Compute the Pure Routing property, that is expressions only made of cut, wires and slots...
Definition: drawschema.cpp:324
bool isBoxSlot(Tree t)
Definition: boxes.cpp:119
bool isBoxMerge(Tree t, Tree &x, Tree &y)
Definition: boxes.cpp:152

Here is the call graph for this function:

Here is the caller graph for this function:

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 271 of file drawschema.cpp.

References getDefNameProperty(), and tree2str().

Referenced by generateDiagramSchema(), and writeSchemaFile().

272 {
273  Tree id;
274  int i=0;
275  if (getDefNameProperty(t, id)) {
276  const char* src = tree2str(id);
277  for (i=0; isalnum(src[i]) && i<16; i++) {
278  dst[i] = src[i];
279  }
280  }
281  dst[i] = 0;
282  if (strcmp(dst, "process") != 0) {
283  // if it is not process add the hex address to make the name unique
284  snprintf(&dst[i], n-i, "-%p", t);
285  }
286  return dst;
287 }
bool getDefNameProperty(Tree t, Tree &id)
Indicates the identifier (if any) the expression was a definition of.
Definition: names.cpp:85
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
const char * tree2str(Tree t)
if t has a node of type symbol, return its name otherwise error
Definition: tree.cpp:278

Here is the call graph for this function:

Here is the caller graph for this function:

static bool pendingDrawing ( Tree t)
static

Retrieve next block diagram that must be drawn.

Definition at line 202 of file drawschema.cpp.

References gPendingExp.

Referenced by drawSchema().

203 {
204  if (gPendingExp.empty()) return false;
205  t = gPendingExp.top();
206  gPendingExp.pop();
207  return true;
208 }
static stack< Tree > gPendingExp
Definition: drawschema.cpp:131

Here is the caller graph for this function:

static void scheduleDrawing ( Tree  t)
static

Schedule a makeBlockSchema diagram to be drawn.

Definition at line 190 of file drawschema.cpp.

References gBackLink, gDrawnExp, gPendingExp, and gSchemaFileName.

Referenced by drawSchema(), and generateDiagramSchema().

191 {
192  if (gDrawnExp.find(t) == gDrawnExp.end()) {
193  gDrawnExp.insert(t);
194  gBackLink.insert(make_pair(t,gSchemaFileName)); // remember the enclosing filename
195  gPendingExp.push(t);
196  }
197 }
static set< Tree > gDrawnExp
Definition: drawschema.cpp:132
static string gSchemaFileName
Definition: drawschema.cpp:134
static stack< Tree > gPendingExp
Definition: drawschema.cpp:131
static map< Tree, string > gBackLink
Definition: drawschema.cpp:135

Here is the caller graph for this function:

static void UserInterfaceDescription ( Tree  box,
string &  d 
)
static

Convert User interface element into a textual representation.

Definition at line 480 of file drawschema.cpp.

References extractName(), isBoxButton(), isBoxCheckbox(), isBoxHBargraph(), isBoxHGroup(), isBoxHSlider(), isBoxNumEntry(), isBoxTGroup(), isBoxVBargraph(), isBoxVGroup(), isBoxVSlider(), max(), and min().

Referenced by generateBargraphSchema(), and generateUserInterfaceSchema().

481 {
482  Tree t1, label, cur, min, max, step;
483  stringstream fout;
484  // user interface
485  if (isBoxButton(box, label)) fout << "button(" << extractName(label) << ')';
486  else if (isBoxCheckbox(box, label)) fout << "checkbox(" << extractName(label) << ')';
487  else if (isBoxVSlider(box, label, cur, min, max, step)) {
488  fout << "vslider("
489  << extractName(label) << ", "
490  << boxpp(cur) << ", "
491  << boxpp(min) << ", "
492  << boxpp(max) << ", "
493  << boxpp(step)<< ')';
494  }
495  else if (isBoxHSlider(box, label, cur, min, max, step)) {
496  fout << "hslider("
497  << extractName(label) << ", "
498  << boxpp(cur) << ", "
499  << boxpp(min) << ", "
500  << boxpp(max) << ", "
501  << boxpp(step)<< ')';
502  }
503  else if (isBoxVGroup(box, label, t1)) {
504  fout << "vgroup(" << extractName(label) << ", " << boxpp(t1, 0) << ')';
505  }
506  else if (isBoxHGroup(box, label, t1)) {
507  fout << "hgroup(" << extractName(label) << ", " << boxpp(t1, 0) << ')';
508  }
509  else if (isBoxTGroup(box, label, t1)) {
510  fout << "tgroup(" << extractName(label) << ", " << boxpp(t1, 0) << ')';
511  }
512  else if (isBoxHBargraph(box, label, min, max)) {
513  fout << "hbargraph("
514  << extractName(label) << ", "
515  << boxpp(min) << ", "
516  << boxpp(max) << ')';
517  }
518  else if (isBoxVBargraph(box, label, min, max)) {
519  fout << "vbargraph("
520  << extractName(label) << ", "
521  << boxpp(min) << ", "
522  << boxpp(max) << ')';
523  }
524  else if (isBoxNumEntry(box, label, cur, min, max, step)) {
525  fout << "nentry("
526  << extractName(label) << ", "
527  << boxpp(cur) << ", "
528  << boxpp(min) << ", "
529  << boxpp(max) << ", "
530  << boxpp(step)<< ')';
531  }
532  else {
533  cerr << "INTERNAL ERROR : unknow user interface element " << endl;
534  exit(0);
535  }
536  d = fout.str();
537 }
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
bool isBoxHGroup(Tree s)
Definition: boxes.cpp:437
bool isBoxHBargraph(Tree s)
Definition: boxes.cpp:455
double max(double x, double y)
Definition: interval.hh:60
bool isBoxTGroup(Tree s)
Definition: boxes.cpp:449
bool isBoxButton(Tree s)
Definition: boxes.cpp:366
bool isBoxHSlider(Tree s)
Definition: boxes.cpp:379
bool isBoxVBargraph(Tree s)
Definition: boxes.cpp:461
bool isBoxCheckbox(Tree s)
Definition: boxes.cpp:372
bool isBoxVGroup(Tree s)
Definition: boxes.cpp:443
string extractName(Tree fulllabel)
bool isBoxVSlider(Tree s)
Definition: boxes.cpp:399
Definition: ppbox.hh:58
bool isBoxNumEntry(Tree s)
Definition: boxes.cpp:418
double min(double x, double y)
Definition: interval.hh:59

Here is the call graph for this function:

Here is the caller graph for this function:

static void writeSchemaFile ( Tree  bd)
static

Write a top level diagram.

A top level diagram is decorated with its definition name property and is drawn in an individual file

Definition at line 219 of file drawschema.cpp.

References addSchemaInputs(), addSchemaOutputs(), schema::collectTraits(), collector::draw(), schema::draw(), gBackLink, gDevSuffix, generateInsideSchema(), getBoxType(), getDefNameProperty(), gOccurrences, gSchemaFileName, schema::height(), kLeftRight, legalFileName(), makeTopSchema(), schema::place(), tree(), tree2str(), unique(), and schema::width().

Referenced by drawSchema().

220 {
221  Tree id;
222  schema* ts;
223  int ins, outs;
224 
225  char temp[1024];
226 
227  gOccurrences = new Occurrences(bd);
228  getBoxType (bd, &ins, &outs);
229 
230  bool hasname = getDefNameProperty(bd, id);
231 
232  //assert(hasname);
233  if (!hasname) {
234  // create an arbitrary name
235  id = tree(Node(unique("diagram_")));
236  }
237 
238  // generate legal file name for the schema
239  stringstream s1; s1 << legalFileName(bd, 1024, temp) << "." << gDevSuffix;
240  gSchemaFileName = s1.str();
241 
242  // generate the label of the schema
243  stringstream s2; s2 << tree2str(id);
244  string link = gBackLink[bd];
245  ts = makeTopSchema(addSchemaOutputs(outs, addSchemaInputs(ins, generateInsideSchema(bd))), 20, s2.str(), link);
246  // draw to the device defined by gDevSuffix
247  if (strcmp(gDevSuffix, "svg") == 0) {
248  SVGDev dev(s1.str().c_str(), ts->width(), ts->height());
249  ts->place(0,0, kLeftRight);
250  ts->draw(dev);
251  { collector c; ts->collectTraits(c); c.draw(dev); }
252  } else {
253  PSDev dev(s1.str().c_str(), ts->width(), ts->height());
254  ts->place(0,0, kLeftRight);
255  ts->draw(dev);
256  {
257  collector c;
258  ts->collectTraits(c);
259  c.draw(dev);
260  }
261  }
262 }
bool getDefNameProperty(Tree t, Tree &id)
Indicates the identifier (if any) the expression was a definition of.
Definition: names.cpp:85
Definition: PSDev.h:31
Symbol * unique(const char *str)
Returns a new unique symbol of name strxxx.
Definition: symbol.hh:97
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
virtual void draw(device &dev)=0
void draw(device &dev)
Definition: collector.cpp:59
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
static schema * addSchemaInputs(int ins, schema *x)
Definition: drawschema.cpp:600
virtual void collectTraits(collector &c)=0
Count subtree occurences Count the number of occurences of each subtree of a root tree...
Definition: occurrences.hh:32
static schema * addSchemaOutputs(int outs, schema *x)
Definition: drawschema.cpp:619
double width() const
Definition: schema.h:126
static string gSchemaFileName
Definition: drawschema.cpp:134
static Occurrences * gOccurrences
Definition: drawschema.cpp:129
schema * makeTopSchema(schema *s1, double margin, const string &text, const string &link)
Creates a new top schema.
Definition: topSchema.cpp:33
static char * legalFileName(Tree t, int n, char *dst)
Transform the definition name property of tree into a legal file name.
Definition: drawschema.cpp:271
static const char * gDevSuffix
Definition: drawschema.cpp:133
virtual void place(double x, double y, int orientation)=0
Definition: SVGDev.h:31
An abstract block diagram schema.
Definition: schema.h:97
Tree tree(const Node &n)
Definition: tree.hh:186
double height() const
Definition: schema.h:127
static map< Tree, string > gBackLink
Definition: drawschema.cpp:135
static schema * generateInsideSchema(Tree t)
Generate the inside schema of a block diagram according to its type.
Definition: drawschema.cpp:398
const char * tree2str(Tree t)
if t has a node of type symbol, return its name otherwise error
Definition: tree.cpp:278
bool getBoxType(Tree box, int *inum, int *onum)
Return the type (number of inputs and outputs) of a box or false if undefined.
Definition: boxtype.cpp:63

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

map<Tree,string> gBackLink
static

Definition at line 135 of file drawschema.cpp.

Referenced by scheduleDrawing(), and writeSchemaFile().

const char* gDevSuffix
static

Definition at line 133 of file drawschema.cpp.

Referenced by drawSchema(), generateDiagramSchema(), and writeSchemaFile().

set<Tree> gDrawnExp
static

Definition at line 132 of file drawschema.cpp.

Referenced by scheduleDrawing().

int gFoldThreshold

Definition at line 126 of file main.cpp.

Referenced by drawSchema(), and process_cmdline().

Tree gInverter[6]

isInverter(t) returns true if t == '*(-1)'.

This test is used to simplify diagram by using a special symbol for inverters.

Definition at line 297 of file drawschema.cpp.

Referenced by isInverter().

Occurrences* gOccurrences
static

Definition at line 129 of file drawschema.cpp.

Referenced by writeSchemaFile().

stack<Tree> gPendingExp
static

Definition at line 131 of file drawschema.cpp.

Referenced by pendingDrawing(), and scheduleDrawing().

property<bool> gPureRoutingProperty

Compute the Pure Routing property, that is expressions only made of cut, wires and slots.

No labels will be dispayed for pure routing expressions.

Definition at line 324 of file drawschema.cpp.

Referenced by isPureRouting().

string gSchemaFileName
static

Definition at line 134 of file drawschema.cpp.

Referenced by scheduleDrawing(), and writeSchemaFile().

bool sFoldingFlag
static

Definition at line 130 of file drawschema.cpp.

Referenced by drawSchema(), and generateDiagramSchema().