|
FAUST compiler
0.9.9.6b8
|
place and connect two diagrams in recursive composition More...
#include <recSchema.h>


Public Member Functions | |
| virtual void | place (double ox, double oy, int orientation) |
| The two subschema are placed centered vertically, s2 on top of s1. | |
| virtual void | draw (device &dev) |
| Draw the two subschema s1 and s2 as well as the feedback connections between s1 and s2, and the feedfrom connections beetween s2 and s1. | |
| virtual point | inputPoint (unsigned int i) const |
| The input points s1 ~ s2. | |
| virtual point | outputPoint (unsigned int i) const |
| The output points s1 ~ s2. | |
| virtual void | collectTraits (collector &c) |
| Draw the two subschema s1 and s2 as well as the feedback connections between s1 and s2, and the feedfrom connections beetween s2 and s1. | |
Private Member Functions | |
| recSchema (schema *s1, schema *s2, double width) | |
| Constructor of a recursive schema (s1 ~ s2). | |
| void | drawDelaySign (device &dev, double x, double y, double size) |
| Draw the delay sign of a feedback connection. | |
| void | drawFeedback (device &dev, const point &src, const point &dst, double dx) |
| Draw a feedback connection between two points with an horizontal displacement dx. | |
| void | drawFeedfront (device &dev, const point &src, const point &dst, double dx) |
| Draw a feedfrom connection between two points with an horizontal displacement dx. | |
| void | collectFeedback (collector &c, const point &src, const point &dst, double dx, const point &out) |
| Draw a feedback connection between two points with an horizontal displacement dx. | |
| void | collectFeedfront (collector &c, const point &src, const point &dst, double dx) |
| Draw a feedfrom connection between two points with an horizontal displacement dx. | |
Private Attributes | |
| schema * | fSchema1 |
| schema * | fSchema2 |
| vector< point > | fInputPoint |
| vector< point > | fOutputPoint |
Friends | |
| schema * | makeRecSchema (schema *s1, schema *s2) |
| Creates a new recursive schema (s1 ~ s2). | |
place and connect two diagrams in recursive composition
Definition at line 33 of file recSchema.h.
| recSchema::recSchema | ( | schema * | s1, |
| schema * | s2, | ||
| double | width | ||
| ) | [private] |
Constructor of a recursive schema (s1 ~ s2).
The two components are supposed to have the same width.
Definition at line 48 of file recSchema.cpp.
References fInputPoint, fOutputPoint, schema::inputs(), schema::outputs(), and schema::width().
: schema( s1->inputs() - s2->outputs(), s1->outputs(), width, s1->height() + s2->height() ), fSchema1(s1), fSchema2(s2) { // this version only accepts legal expressions of same width assert(s1->inputs() >= s2->outputs()); assert(s1->outputs() >= s2->inputs()); assert(s1->width() >= s2->width()); // create the input and output points for (unsigned int i=0; i<inputs(); i++) fInputPoint.push_back(point(0,0)); for (unsigned int i=0; i<outputs(); i++) fOutputPoint.push_back(point(0,0)); }

| void recSchema::collectFeedback | ( | collector & | c, |
| const point & | src, | ||
| const point & | dst, | ||
| double | dx, | ||
| const point & | out | ||
| ) | [private] |
Draw a feedback connection between two points with an horizontal displacement dx.
Definition at line 237 of file recSchema.cpp.
References collector::addInput(), collector::addOutput(), collector::addTrait(), dWire, kLeftRight, schema::orientation(), point::x, and point::y.
Referenced by collectTraits().
{
double ox = src.x + ((orientation()==kLeftRight) ? dx : -dx);
double ct = (orientation()==kLeftRight) ? dWire/2 : -dWire/2;
point up(ox, src.y-ct);
point br(ox+ct/2.0, src.y);
c.addOutput(up);
c.addOutput(br);
c.addInput(br);
c.addTrait(trait(up, point(ox, dst.y)));
c.addTrait(trait(point(ox, dst.y), point(dst.x, dst.y)));
c.addTrait(trait(src,br));
c.addTrait(trait(br,out));
}


| void recSchema::collectFeedfront | ( | collector & | c, |
| const point & | src, | ||
| const point & | dst, | ||
| double | dx | ||
| ) | [private] |
Draw a feedfrom connection between two points with an horizontal displacement dx.
Definition at line 275 of file recSchema.cpp.
References collector::addTrait(), kLeftRight, schema::orientation(), point::x, and point::y.
Referenced by collectTraits().
{
double ox = src.x + ((orientation()==kLeftRight) ? -dx : dx);
c.addTrait(trait(point(src.x, src.y), point(ox, src.y)));
c.addTrait(trait(point(ox, src.y), point(ox, dst.y)));
c.addTrait(trait(point(ox, dst.y), point(dst.x, dst.y)));
}


| void recSchema::collectTraits | ( | collector & | c | ) | [virtual] |
Draw the two subschema s1 and s2 as well as the feedback connections between s1 and s2, and the feedfrom connections beetween s2 and s1.
Implements schema.
Definition at line 181 of file recSchema.cpp.
References collector::addTrait(), collectFeedback(), collectFeedfront(), schema::collectTraits(), dWire, fSchema1, fSchema2, inputPoint(), schema::inputPoint(), schema::inputs(), outputPoint(), schema::outputPoint(), schema::outputs(), and schema::placed().
{
assert(placed());
// draw the two subdiagrams
fSchema1->collectTraits(c);
fSchema2->collectTraits(c);
// draw the feedback connections to each fSchema2 input
for (unsigned int i=0; i<fSchema2->inputs(); i++) {
collectFeedback(c, fSchema1->outputPoint(i), fSchema2->inputPoint(i), i*dWire, outputPoint(i));
}
// draw the non recursive output lines
for (unsigned int i=fSchema2->inputs(); i<outputs(); i++) {
point p = fSchema1->outputPoint(i);
point q = outputPoint(i);
c.addTrait(trait(p,q)); // in->out order
}
// draw the input lines
unsigned int skip = fSchema2->outputs();
for (unsigned int i=0; i<inputs(); i++) {
point p = inputPoint(i);
point q = fSchema1->inputPoint(i+skip);
c.addTrait(trait(p,q)); // in->out order
}
// draw the feedfront connections from each fSchema2 output
for (unsigned int i=0; i<fSchema2->outputs(); i++) {
collectFeedfront(c, fSchema2->outputPoint(i), fSchema1->inputPoint(i), i*dWire);
}
}

| void recSchema::draw | ( | device & | dev | ) | [virtual] |
Draw the two subschema s1 and s2 as well as the feedback connections between s1 and s2, and the feedfrom connections beetween s2 and s1.
Implements schema.
Definition at line 130 of file recSchema.cpp.
References schema::draw(), drawFeedback(), drawFeedfront(), dWire, fSchema1, fSchema2, inputPoint(), schema::inputPoint(), schema::inputs(), outputPoint(), schema::outputPoint(), schema::outputs(), and schema::placed().
{
assert(placed());
// draw the two subdiagrams
fSchema1->draw(dev);
fSchema2->draw(dev);
// draw the output lines
for (unsigned int i=0; i<outputs(); i++) {
point p = fSchema1->outputPoint(i);
point q = outputPoint(i);
//dev.trait(p.x, p.y, q.x, q.y);
}
// draw the input lines
unsigned int skip = fSchema2->outputs();
for (unsigned int i=0; i<inputs(); i++) {
point p = fSchema1->inputPoint(i+skip);
point q = inputPoint(i);
//dev.trait(p.x, p.y, q.x, q.y);
}
// draw the feedback connections to each fSchema2 input
for (unsigned int i=0; i<fSchema2->inputs(); i++) {
drawFeedback(dev, fSchema1->outputPoint(i), fSchema2->inputPoint(i), i*dWire);
}
// draw the feedfront connections from each fSchema2 output
for (unsigned int i=0; i<fSchema2->outputs(); i++) {
drawFeedfront(dev, fSchema2->outputPoint(i), fSchema1->inputPoint(i), i*dWire);
}
}

| void recSchema::drawDelaySign | ( | device & | dev, |
| double | x, | ||
| double | y, | ||
| double | size | ||
| ) | [private] |
Draw the delay sign of a feedback connection.
Definition at line 168 of file recSchema.cpp.
References device::trait().
Referenced by drawFeedback().
{
dev.trait(x-size/2, y, x-size/2, y-size);
dev.trait(x-size/2, y-size, x+size/2, y-size);
dev.trait(x+size/2, y-size, x+size/2, y);
}


| void recSchema::drawFeedback | ( | device & | dev, |
| const point & | src, | ||
| const point & | dst, | ||
| double | dx | ||
| ) | [private] |
Draw a feedback connection between two points with an horizontal displacement dx.
Definition at line 221 of file recSchema.cpp.
References drawDelaySign(), dWire, kLeftRight, schema::orientation(), point::x, and point::y.
Referenced by draw().
{
double ox = src.x + ((orientation()==kLeftRight) ? dx : -dx);
double ct = (orientation()==kLeftRight) ? dWire/2 : -dWire/2;
drawDelaySign(dev, ox, src.y, ct);
//dev.trait(ox, src.y-ct, ox, dst.y);
//dev.trait(ox, dst.y, dst.x, dst.y);
}


| void recSchema::drawFeedfront | ( | device & | dev, |
| const point & | src, | ||
| const point & | dst, | ||
| double | dx | ||
| ) | [private] |
Draw a feedfrom connection between two points with an horizontal displacement dx.
Definition at line 261 of file recSchema.cpp.
Referenced by draw().
{
// double ox = src.x + ((orientation()==kLeftRight) ? -dx : dx);
// dev.trait(ox, src.y, src.x, src.y);
// dev.trait(ox, src.y, ox, dst.y);
// dev.trait(ox, dst.y, dst.x, dst.y);
}

| point recSchema::inputPoint | ( | unsigned int | i | ) | const [virtual] |
The input points s1 ~ s2.
Implements schema.
Definition at line 110 of file recSchema.cpp.
References fInputPoint.
Referenced by collectTraits(), and draw().
{
return fInputPoint[i];
}

| point recSchema::outputPoint | ( | unsigned int | i | ) | const [virtual] |
The output points s1 ~ s2.
Implements schema.
Definition at line 119 of file recSchema.cpp.
References fOutputPoint.
Referenced by collectTraits(), and draw().
{
return fOutputPoint[i];
}

| void recSchema::place | ( | double | ox, |
| double | oy, | ||
| int | orientation | ||
| ) | [virtual] |
The two subschema are placed centered vertically, s2 on top of s1.
The input and output points are computed.
Implements schema.
Definition at line 71 of file recSchema.cpp.
References schema::beginPlace(), schema::endPlace(), fInputPoint, fOutputPoint, fSchema1, fSchema2, schema::height(), schema::inputPoint(), schema::inputs(), kLeftRight, kRightLeft, schema::outputPoint(), schema::outputs(), schema::place(), schema::width(), point::x, and point::y.
{
beginPlace(ox, oy, orientation);
double dx1 = (width() - fSchema1->width())/2;
double dx2 = (width() - fSchema2->width())/2;
// place the two sub diagrams
if (orientation == kLeftRight) {
fSchema2->place(ox+dx2, oy, kRightLeft);
fSchema1->place(ox+dx1, oy+fSchema2->height(), kLeftRight);
} else {
fSchema1->place(ox+dx1, oy, kRightLeft);
fSchema2->place(ox+dx2, oy+fSchema1->height(), kLeftRight);
}
// adjust delta space to orientation
if (orientation == kRightLeft) { dx1 = -dx1; }
// place input points
for (unsigned int i=0; i<inputs(); i++) {
point p = fSchema1->inputPoint(i+fSchema2->outputs());
fInputPoint[i] = point(p.x-dx1, p.y);
}
// place output points
for (unsigned int i=0; i<outputs(); i++) {
point p = fSchema1->outputPoint(i);
fOutputPoint[i] = point(p.x+dx1, p.y);
}
endPlace();
}

| schema* makeRecSchema | ( | schema * | s1, |
| schema * | s2 | ||
| ) | [friend] |
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.
{
schema* a = makeEnlargedSchema(s1, s2->width());
schema* b = makeEnlargedSchema(s2, s1->width());
double m = dWire * max(b->inputs(), b->outputs());
double w = a->width() + 2*m;
return new recSchema(a,b,w);
}
vector<point> recSchema::fInputPoint [private] |
Definition at line 37 of file recSchema.h.
Referenced by inputPoint(), place(), and recSchema().
vector<point> recSchema::fOutputPoint [private] |
Definition at line 38 of file recSchema.h.
Referenced by outputPoint(), place(), and recSchema().
schema* recSchema::fSchema1 [private] |
Definition at line 35 of file recSchema.h.
Referenced by collectTraits(), draw(), and place().
schema* recSchema::fSchema2 [private] |
Definition at line 36 of file recSchema.h.
Referenced by collectTraits(), draw(), and place().
1.8.0