FAUST compiler  0.9.9.6b8
drawschema.cpp
Go to the documentation of this file.
1 /************************************************************************
2  ************************************************************************
3  FAUST compiler
4  Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale
5  ---------------------------------------------------------------------
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  ************************************************************************
20  ************************************************************************/
21 
30 #include <stdio.h>
31 #include <ctype.h>
32 #include <sys/stat.h>
33 #include <sys/types.h>
34 #include <errno.h>
35 #include <string.h>
36 
37 #include <ostream>
38 #include <sstream>
39 #include <set>
40 #include <utility>
41 #include <map>
42 #include <stack>
43 #include <string>
44 
45 #include "boxes.hh"
46 #include "ppbox.hh"
47 #include "prim2.hh"
48 
49 #include <vector>
50 #include "devLib.h"
51 #include "ppbox.hh"
52 #include "xtended.hh"
53 #include "occurrences.hh"
54 #include "boxcomplexity.h"
55 
56 #include "schema.h"
57 #include "drawschema.hh"
58 #include "compatibility.hh"
59 #include "names.hh"
60 #include "description.hh"
61 #include "property.hh"
62 #include "files.hh"
63 
64 #if 0
65 #define linkcolor "#b3d1dc"
66 #define normalcolor "#ffeaa2"
67 #define uicolor "#F1CFA1"
68 #define slotcolor "#ffffd7"
69 #define numcolor "#ffffff"
70 #endif
71 
72 #if 0
73 #define linkcolor "#F57900"
74 #define normalcolor "#4B71A1"
75 #define uicolor "#47945E"
76 #define slotcolor "#EDD400"
77 #define numcolor "#4B71A1"
78 #endif
79 
80 #if 0
81 #define linkcolor "#47945E"
82 #define normalcolor "#4B71A1"
83 #define uicolor "#f44800"
84 #define slotcolor "#EDD400"
85 #define numcolor "#f44800"
86 #endif
87 
88 #if 0
89 #define linkcolor "#47945E"
90 #define normalcolor "#4B71A1"
91 #define uicolor "#816647"
92 #define slotcolor "#EDD400"
93 #define numcolor "#f44800"
94 #endif
95 
96 #if 0
97 #define linkcolor "#003366"
98 #define normalcolor "#4B71A1"
99 #define uicolor "#816647"
100 #define slotcolor "#EDD400"
101 #define numcolor "#f44800"
102 #endif
103 
104 #if 0
105 #define linkcolor "#003366"
106 #define normalcolor "#4B71A1"
107 #define uicolor "#477881"
108 #define slotcolor "#816647"
109 #define numcolor "#f44800"
110 #endif
111 
112 
113 #if 1
114 #define linkcolor "#003366"
115 #define normalcolor "#4B71A1"
116 #define uicolor "#477881"
117 #define slotcolor "#47945E"
118 #define numcolor "#f44800"
119 #define invcolor "#ffffff"
120 #endif
121 
122 using namespace std;
123 
124 // external parameters
125 extern int gFoldThreshold; // max diagram complexity before folding
126 
127 
128 // internal state during drawing
130 static bool sFoldingFlag; // true with complex block-diagrams
131 static stack<Tree> gPendingExp; // Expressions that need to be drawn
132 static set<Tree> gDrawnExp; // Expressions drawn or scheduled so far
133 static const char* gDevSuffix; // .svg or .ps used to choose output device
134 static string gSchemaFileName; // name of schema file beeing generated
135 static map<Tree,string> gBackLink; // link to enclosing file for sub schema
136 
137 // prototypes of internal functions
138 static void writeSchemaFile(Tree bd);
139 static schema* generateDiagramSchema (Tree bd);
140 static schema* generateInsideSchema(Tree t);
141 static void scheduleDrawing(Tree t);
142 static bool pendingDrawing(Tree& t);
148 static char* legalFileName(Tree t, int n, char* dst);
149 
150 static schema* addSchemaInputs(int ins, schema* x);
151 static schema* addSchemaOutputs(int outs, schema* x);
152 
153 
154 
155 
161 void drawSchema(Tree bd, const char* projname, const char* dev)
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 }
176 
177 
178 /************************************************************************
179  ************************************************************************
180  IMPLEMENTATION
181  ************************************************************************
182  ************************************************************************/
183 
184 
185 //------------------- to schedule and retreive drawing ------------------
186 
190 static void scheduleDrawing(Tree t)
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 }
198 
202 static bool pendingDrawing(Tree& t)
203 {
204  if (gPendingExp.empty()) return false;
205  t = gPendingExp.top();
206  gPendingExp.pop();
207  return true;
208 }
209 
210 
211 
212 //------------------------ dealing with files -------------------------
213 
219 static void writeSchemaFile(Tree bd)
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 }
263 
264 
271 static char* legalFileName(Tree t, int n, char* dst)
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 }
288 
289 
290 //------------------------ generating the schema -------------------------
291 
292 
298 
299 static bool isInverter(Tree t)
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 }
317 
318 
325 
326 static bool isPureRouting(Tree t)
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 }
350 
351 
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 }
391 
392 
393 
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 }
476 
480 static void UserInterfaceDescription(Tree box, string& d)
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 }
538 
539 
544 {
545  string s; UserInterfaceDescription(t,s);
546  return makeBlockSchema(0, 1, s, uicolor, "");
547 }
548 
549 
554 {
555  string s; UserInterfaceDescription(t,s);
556  return makeBlockSchema(1, 1, s, uicolor, "");
557 }
558 
559 
560 
565 {
566  Tree id; assert(getDefNameProperty(a, id));
567  stringstream s; s << tree2str(id);
568  return makeBlockSchema(1, 0, s.str(), slotcolor, "");
569 }
570 
571 
572 
577 {
578  Tree id; assert(getDefNameProperty(a, id));
579  stringstream s; s << tree2str(id);
580  return makeBlockSchema(0, 1, s.str(), slotcolor, "");
581 }
582 
583 
584 
590 {
591  Tree a,b;
592 
593  while (isBoxSymbolic(t,a,b)) {
595  t = b;
596  }
597  return makeSeqSchema(x, generateDiagramSchema(t));
598 }
599 
600 static schema* addSchemaInputs(int ins, schema* x)
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 }
617 
618 
619 static schema* addSchemaOutputs(int outs, schema* x)
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 }
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
Definition: PSDev.h:31
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
static bool pendingDrawing(Tree &t)
Retrieve next block diagram that must be drawn.
Definition: drawschema.cpp:202
Symbol * unique(const char *str)
Returns a new unique symbol of name strxxx.
Definition: symbol.hh:97
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
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
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
const char * prim2name(CTree *(*ptr)(CTree *, CTree *))
Definition: ppbox.cpp:47
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 "
Definition: drawschema.cpp:161
schema * makeCutSchema()
Creates a new Cut schema.
Definition: cutSchema.cpp:33
bool isBoxSplit(Tree t, Tree &x, Tree &y)
Definition: boxes.cpp:148
virtual void draw(device &dev)=0
Tree(* prim4)(Tree w, Tree x, Tree y, Tree z)
Definition: boxes.hh:212
void draw(device &dev)
Definition: collector.cpp:59
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
int gFoldThreshold
Definition: main.cpp:126
bool isBoxCut(Tree t)
Definition: boxes.cpp:105
#define slotcolor
Definition: drawschema.cpp:117
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
static bool sFoldingFlag
Definition: drawschema.cpp:130
bool isBoxPrim0(Tree s)
Definition: boxes.cpp:310
static schema * addSchemaInputs(int ins, schema *x)
Definition: drawschema.cpp:600
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
virtual void collectTraits(collector &c)=0
#define normalcolor
Definition: drawschema.cpp:115
Count subtree occurences Count the number of occurences of each subtree of a root tree...
Definition: occurrences.hh:32
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
schema * makeConnectorSchema()
Connectors are used to ensure unused inputs and outputs are drawn.
Tree boxInt(int n)
Definition: boxes.cpp:75
double max(double x, double y)
Definition: interval.hh:60
Tree(* prim3)(Tree x, Tree y, Tree z)
Definition: boxes.hh:211
Tree boxWire()
Definition: boxes.cpp:108
Tree(* prim5)(Tree v, Tree w, Tree x, Tree y, Tree z)
Definition: boxes.hh:213
static set< Tree > gDrawnExp
Definition: drawschema.cpp:132
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
Tree sigSub(Tree x, Tree y)
Definition: signals.hh:153
static schema * addSchemaOutputs(int outs, schema *x)
Definition: drawschema.cpp:619
double width() const
Definition: schema.h: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
int boxComplexity(Tree box)
Return the complexity propety of a box expression tree.
static string gSchemaFileName
Definition: drawschema.cpp:134
static schema * generateDiagramSchema(Tree bd)
Generate an appropriate schema according to the type of block diagram.
Definition: drawschema.cpp:358
static Occurrences * gOccurrences
Definition: drawschema.cpp:129
bool isBoxPar(Tree t, Tree &x, Tree &y)
Definition: boxes.cpp:140
bool isBoxHSlider(Tree s)
Definition: boxes.cpp:379
schema * makeTopSchema(schema *s1, double margin, const string &text, const string &link)
Creates a new top schema.
Definition: topSchema.cpp:33
static bool isInverter(Tree t)
Definition: drawschema.cpp:299
bool isBoxVBargraph(Tree s)
Definition: boxes.cpp:461
static stack< Tree > gPendingExp
Definition: drawschema.cpp:131
Tree gInverter[6]
isInverter(t) returns true if t == '*(-1)'.
Definition: drawschema.cpp:297
static void scheduleDrawing(Tree t)
Schedule a makeBlockSchema diagram to be drawn.
Definition: drawschema.cpp:190
bool isBoxWaveform(Tree s)
Definition: boxes.cpp:97
#define invcolor
Definition: drawschema.cpp:119
bool isBoxCheckbox(Tree s)
Definition: boxes.cpp:372
Tree boxReal(double n)
Definition: boxes.cpp:76
static bool isPureRouting(Tree t)
Definition: drawschema.cpp:326
Tree boxPrim2(prim2 foo)
Definition: boxes.cpp:319
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
property< bool > gPureRoutingProperty
Compute the Pure Routing property, that is expressions only made of cut, wires and slots...
Definition: drawschema.cpp:324
static const char * gDevSuffix
Definition: drawschema.cpp:133
virtual void place(double x, double y, int orientation)=0
bool isBoxVGroup(Tree s)
Definition: boxes.cpp:443
virtual unsigned int arity()=0
string extractName(Tree fulllabel)
Tree boxSeq(Tree x, Tree y)
Definition: boxes.cpp:135
bool isBoxFVar(Tree s)
Definition: boxes.cpp:356
Definition: SVGDev.h:31
const char * name(Symbol *sym)
Returns the name of a symbol.
Definition: symbol.hh:98
An abstract block diagram schema.
Definition: schema.h:97
static void UserInterfaceDescription(Tree box, string &d)
Convert User interface element into a textual representation.
Definition: drawschema.cpp:480
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
bool isBoxVSlider(Tree s)
Definition: boxes.cpp:399
Definition: ppbox.hh:58
bool isBoxNumEntry(Tree s)
Definition: boxes.cpp:418
bool isBoxSlot(Tree t)
Definition: boxes.cpp:119
Tree boxPar(Tree x, Tree y)
Definition: boxes.cpp:139
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
Tree sigMul(Tree x, Tree y)
Definition: signals.hh:154
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
Interface for names management.
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
static schema * generateInsideSchema(Tree t)
Generate the inside schema of a block diagram according to its type.
Definition: drawschema.cpp:398
static void writeSchemaFile(Tree bd)
Write a top level diagram.
Definition: drawschema.cpp:219
schema * makeSeqSchema(schema *s1, schema *s2)
Make a sequential schema.
Definition: seqSchema.cpp:43
double min(double x, double y)
Definition: interval.hh:59
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
#define uicolor
Definition: drawschema.cpp:116
#define linkcolor
Definition: drawschema.cpp:114
const char * prim4name(CTree *(*ptr)(CTree *, CTree *, CTree *, CTree *))
Definition: ppbox.cpp:83
Tree(* prim0)()
Definition: boxes.hh:208
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
void print(Tree t, FILE *out)
Definition: list.cpp:154