#include "device.h"
#include <vector>
#include <string>
Go to the source code of this file.
Classes | |
struct | point |
class | schema |
An abstract block diagram schema. More... | |
Enumerations | |
enum | { kLeftRight = 1, kRightLeft = -1 } |
Functions | |
schema * | makeBlockSchema (unsigned int inputs, unsigned int outputs, const string &name, const string &color, const string &link) |
Build a simple colored blockSchema with a certain number of inputs and outputs, a text to be displayed, and an optional link. | |
schema * | makeCableSchema (unsigned int n=1) |
Build n cables in parallel. | |
schema * | makeCutSchema () |
Creates a new Cut schema. | |
schema * | makeEnlargedSchema (schema *s, double width) |
Returns an enlarged schema, but only if really needed that is if the requiered width is greater that the schema width. | |
schema * | makeParSchema (schema *s1, schema *s2) |
schema * | makeSeqSchema (schema *s1, schema *s2) |
Make a sequential schema. | |
schema * | makeMergeSchema (schema *s1, schema *s2) |
Creates a new merge schema. | |
schema * | makeSplitSchema (schema *s1, schema *s2) |
Creates a new split schema. | |
schema * | makeRecSchema (schema *s1, schema *s2) |
Creates a new recursive schema (s1 ~ s2). | |
schema * | makeTopSchema (schema *s1, double margin, const string &text, const string &link) |
Creates a new top schema. | |
schema * | makeDecorateSchema (schema *s1, double margin, const string &text) |
Creates a new decorated schema. | |
Variables | |
const double | dWire = 8 |
distance between two wires | |
const double | dLetter = 4.3 |
width of a letter | |
const double | dHorz = 4 |
marge horizontale | |
const double | dVert = 4 |
marge verticale |
anonymous enum |
Definition at line 50 of file schema.h.
00050 { kLeftRight=1, kRightLeft=-1 };
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 displayed, and an optional link.
Computes the size of the box according to the length of the text and the maximum number of ports.
Definition at line 40 of file blockSchema.cpp.
References dHorz, dVert, dWire, max(), and quantize().
Referenced by generateBargraphSchema(), generateDiagramSchema(), generateInputSlotSchema(), generateInsideSchema(), generateOutputSlotSchema(), and generateUserInterfaceSchema().
00045 { 00046 // determine the optimal size of the box 00047 double minimal = 3*dWire; 00048 double w = 2*dHorz + max( minimal, quantize(text.size()) ); 00049 double h = 2*dVert + max( minimal, max(inputs, outputs) * dWire ); 00050 00051 return new blockSchema(inputs, outputs, w, h, text, color, link); 00052 }
schema* makeCableSchema | ( | unsigned int | n = 1 |
) |
Build n cables in parallel.
Definition at line 32 of file cableSchema.cpp.
Referenced by generateInsideSchema(), and makeSeqSchema().
00033 { 00034 assert(n>0); 00035 return new cableSchema(n); 00036 }
schema* makeCutSchema | ( | ) |
Creates a new Cut schema.
Definition at line 33 of file cutSchema.cpp.
Referenced by generateInsideSchema().
00034 { 00035 return new cutSchema(); 00036 }
Creates a new decorated schema.
Definition at line 31 of file decorateSchema.cpp.
Referenced by generateDiagramSchema(), generateInsideSchema(), and makeTopSchema().
00032 { 00033 return new decorateSchema (s, margin, text); 00034 }
Returns an enlarged schema, but only if really needed that is if the requiered width is greater that the schema width.
Definition at line 32 of file enlargedSchema.cpp.
References schema::width().
Referenced by makeMergeSchema(), makeParSchema(), makeRecSchema(), and makeSplitSchema().
00033 { 00034 if (width > s->width()) { 00035 return new enlargedSchema(s, width); 00036 } else { 00037 return s; 00038 } 00039 }
Creates a new merge schema.
Cables are enlarged to dWire. The horizontal gap between the two subschema is such that the connections are not too slopy.
Definition at line 35 of file mergeSchema.cpp.
References dWire, schema::height(), and makeEnlargedSchema().
Referenced by generateInsideSchema().
00036 { 00037 // avoid ugly diagram by ensuring at least dWire width 00038 schema * a = makeEnlargedSchema(s1, dWire); 00039 schema * b = makeEnlargedSchema(s2, dWire); 00040 double hgap = (a->height()+b->height())/4; 00041 return new mergeSchema(a,b,hgap); 00042 }
Definition at line 28 of file parSchema.cpp.
References makeEnlargedSchema(), and schema::width().
Referenced by generateAbstractionSchema(), generateInsideSchema(), and makeSeqSchema().
00029 { 00030 // make sure s1 and s2 have same width 00031 return new parSchema( makeEnlargedSchema(s1, s2->width()), 00032 makeEnlargedSchema(s2, s1->width()) ); 00033 }
Creates a new recursive schema (s1 ~ s2).
The smallest component is enlarged to the width of the other. The left and right horizontal margins are computed according to the number of internal connections.
Definition at line 34 of file recSchema.cpp.
References dWire, makeEnlargedSchema(), max(), and schema::width().
Referenced by generateInsideSchema().
00035 { 00036 schema* a = makeEnlargedSchema(s1, s2->width()); 00037 schema* b = makeEnlargedSchema(s2, s1->width()); 00038 double m = dWire * max(b->inputs(), b->outputs()); 00039 double w = a->width() + 2*m; 00040 00041 return new recSchema(a,b,w); 00042 }
Make a sequential schema.
May add cables to ensure the internal connections are between the same number of outputs and inputs. Compute an horizontal gap based on the number of upward and downward connections.
Definition at line 43 of file seqSchema.cpp.
References computeHorzGap(), schema::inputs(), makeCableSchema(), makeParSchema(), and schema::outputs().
Referenced by generateAbstractionSchema(), and generateInsideSchema().
00044 { 00045 unsigned int o = s1->outputs(); 00046 unsigned int i = s2->inputs(); 00047 00048 schema* a = (o < i) ? makeParSchema(s1, makeCableSchema(i-o)) : s1; 00049 schema* b = (o > i) ? makeParSchema(s2, makeCableSchema(o-i)) : s2; 00050 00051 return new seqSchema(a, b, computeHorzGap(a,b)); 00052 }
Creates a new split schema.
Cables are enlarged to dWire. The horizontal gap between the two subschema is such that the connections are not too slopy.
Definition at line 34 of file splitSchema.cpp.
References dWire, schema::height(), and makeEnlargedSchema().
Referenced by generateInsideSchema().
00035 { 00036 // make sure a and b are at least dWire large 00037 schema * a = makeEnlargedSchema(s1, dWire); 00038 schema * b = makeEnlargedSchema(s2, dWire); 00039 00040 // horizontal gap to avaoid too slopy connections 00041 double hgap = (a->height()+b->height())/4; 00042 00043 return new splitSchema(a,b,hgap); 00044 }
Creates a new top schema.
Definition at line 33 of file topSchema.cpp.
References makeDecorateSchema().
Referenced by writeSchemaFile().
00034 { 00035 return new topSchema (makeDecorateSchema(s, margin/2, text), margin/2, "", link); 00036 }
const double dHorz = 4 |
marge horizontale
Definition at line 35 of file schema.h.
Referenced by blockSchema::drawInputWires(), blockSchema::drawOrientationMark(), blockSchema::drawOutputWires(), blockSchema::drawRectangle(), and makeBlockSchema().
const double dLetter = 4.3 |
width of a letter
Definition at line 34 of file schema.h.
Referenced by decorateSchema::draw(), and quantize().
const double dVert = 4 |
marge verticale
Definition at line 36 of file schema.h.
Referenced by blockSchema::drawOrientationMark(), blockSchema::drawRectangle(), and makeBlockSchema().
const double dWire = 8 |
distance between two wires
Definition at line 32 of file schema.h.
Referenced by computeHorzGap(), recSchema::draw(), cutSchema::draw(), recSchema::drawFeedback(), seqSchema::drawInternalWires(), makeBlockSchema(), makeMergeSchema(), makeRecSchema(), makeSplitSchema(), cableSchema::place(), blockSchema::placeInputPoints(), and blockSchema::placeOutputPoints().