|
FAUST compiler
0.9.9.6b8
|
A simple rectangular box with a text and inputs and outputs. More...
#include <blockSchema.h>


Public Member Functions | |
| virtual void | place (double x, double y, int orientation) |
| Define the graphic position of the blockSchema. | |
| virtual void | draw (device &dev) |
| Draw the blockSchema on the device. | |
| virtual point | inputPoint (unsigned int i) const |
| Returns an input point. | |
| virtual point | outputPoint (unsigned int i) const |
| Returns an output point. | |
Protected Member Functions | |
| blockSchema (unsigned int inputs, unsigned int outputs, double width, double height, 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. | |
| void | placeInputPoints () |
| Computes the input points according to the position and the orientation of the blockSchema. | |
| void | placeOutputPoints () |
| Computes the output points according to the position and the orientation of the blockSchema. | |
| void | drawRectangle (device &dev) |
| Draw the colored rectangle with the optional link. | |
| void | drawText (device &dev) |
| Draw the text centered on the box. | |
| void | drawOrientationMark (device &dev) |
| Draw the orientation mark, a small point that indicates the first input (like integrated circuits) | |
| void | drawInputWires (device &dev) |
| Draw horizontal arrows from the input points to the blockSchema rectangle. | |
| void | drawOutputWires (device &dev) |
| Draw horizontal line from the blockSchema rectangle to the output points. | |
| void | collectTraits (collector &c) |
| Draw horizontal arrows from the input points to the blockSchema rectangle. | |
| void | collectInputWires (collector &c) |
| Draw horizontal arrows from the input points to the blockSchema rectangle. | |
| void | collectOutputWires (collector &c) |
| Draw horizontal line from the blockSchema rectangle to the output points. | |
Protected Attributes | |
| const string | fText |
| Text to be displayed. | |
| const string | fColor |
| color of the box | |
| const string | fLink |
| option URL link | |
| vector< point > | fInputPoint |
| input connection points | |
| vector< point > | fOutputPoint |
| output connection points | |
Friends | |
| 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. | |
A simple rectangular box with a text and inputs and outputs.
The constructor is private in order to make sure makeBlockSchema is used instead
Definition at line 35 of file blockSchema.h.
| blockSchema::blockSchema | ( | unsigned int | inputs, |
| unsigned int | outputs, | ||
| double | width, | ||
| double | height, | ||
| const string & | text, | ||
| const string & | color, | ||
| const string & | link | ||
| ) | [protected] |
Build a simple colored blockSchema with a certain number of inputs and outputs, a text to be displayed, and an optional link.
The length of the text as well as th number of inputs and outputs are used to compute the size of the blockSchema
Definition at line 60 of file blockSchema.cpp.
References fInputPoint, fOutputPoint, schema::inputs(), and schema::outputs().
: schema( inputs, outputs, width, height ), fText(text), fColor(color), fLink(link) { 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 blockSchema::collectInputWires | ( | collector & | c | ) | [protected] |
Draw horizontal arrows from the input points to the blockSchema rectangle.
Definition at line 276 of file blockSchema.cpp.
References collector::addInput(), collector::addTrait(), dHorz, fInputPoint, schema::inputs(), kLeftRight, schema::orientation(), point::x, and point::y.
Referenced by collectTraits().
{
double dx = (orientation() == kLeftRight) ? dHorz : -dHorz;
for (unsigned int i=0; i<inputs(); i++) {
point p = fInputPoint[i];
c.addTrait(trait(point(p.x, p.y), point(p.x+dx, p.y))); // in->out direction
c.addInput(point(p.x+dx, p.y));
}
}


| void blockSchema::collectOutputWires | ( | collector & | c | ) | [protected] |
Draw horizontal line from the blockSchema rectangle to the output points.
Definition at line 291 of file blockSchema.cpp.
References collector::addOutput(), collector::addTrait(), dHorz, fOutputPoint, kLeftRight, schema::orientation(), schema::outputs(), point::x, and point::y.
Referenced by collectTraits().
{
double dx = (orientation() == kLeftRight) ? dHorz : -dHorz;
for (unsigned int i=0; i<outputs(); i++) {
point p = fOutputPoint[i];
c.addTrait(trait(point(p.x-dx, p.y), point(p.x, p.y))); // in->out direction
c.addOutput(point(p.x-dx, p.y));
}
}


| void blockSchema::collectTraits | ( | collector & | c | ) | [protected, virtual] |
Draw horizontal arrows from the input points to the blockSchema rectangle.
Implements schema.
Definition at line 266 of file blockSchema.cpp.
References collectInputWires(), and collectOutputWires().
{
collectInputWires(c);
collectOutputWires(c);
}

| void blockSchema::draw | ( | device & | dev | ) | [virtual] |
Draw the blockSchema on the device.
This methos can only be called after the blockSchema have been placed
Implements schema.
Reimplemented in inverterSchema.
Definition at line 174 of file blockSchema.cpp.
References drawInputWires(), drawOrientationMark(), drawOutputWires(), drawRectangle(), drawText(), and schema::placed().
{
assert(placed());
drawRectangle(dev);
drawText(dev);
drawOrientationMark(dev);
drawInputWires(dev);
drawOutputWires(dev);
}

| void blockSchema::drawInputWires | ( | device & | dev | ) | [protected] |
Draw horizontal arrows from the input points to the blockSchema rectangle.
Definition at line 236 of file blockSchema.cpp.
References dHorz, fInputPoint, device::fleche(), schema::inputs(), kLeftRight, schema::orientation(), point::x, and point::y.
Referenced by draw().
{
double dx = (orientation() == kLeftRight) ? dHorz : -dHorz;
for (unsigned int i=0; i<inputs(); i++) {
point p = fInputPoint[i];
//dev.trait(p.x, p.y, p.x+dx, p.y);
dev.fleche(p.x+dx, p.y, 0, orientation());
}
}


| void blockSchema::drawOrientationMark | ( | device & | dev | ) | [protected] |
Draw the orientation mark, a small point that indicates the first input (like integrated circuits)
Definition at line 217 of file blockSchema.cpp.
References dHorz, dVert, schema::height(), kLeftRight, device::markSens(), schema::orientation(), schema::width(), schema::x(), and schema::y().
Referenced by draw().
{
double px, py;
if (orientation() == kLeftRight) {
px = x() + dHorz;
py = y() + dVert;
} else {
px = x() + width() - dHorz;
py = y() + height() - dVert;
}
dev.markSens( px, py, orientation() );
}


| void blockSchema::drawOutputWires | ( | device & | dev | ) | [protected] |
Draw horizontal line from the blockSchema rectangle to the output points.
Definition at line 251 of file blockSchema.cpp.
References fOutputPoint, and schema::outputs().
Referenced by draw().
{
//double dx = (orientation() == kLeftRight) ? dHorz : -dHorz;
for (unsigned int i=0; i<outputs(); i++) {
point p = fOutputPoint[i];
//dev.trait(p.x, p.y, p.x-dx, p.y);
}
}


| void blockSchema::drawRectangle | ( | device & | dev | ) | [protected] |
Draw the colored rectangle with the optional link.
Definition at line 188 of file blockSchema.cpp.
References dHorz, dVert, fColor, fLink, schema::height(), device::rect(), schema::width(), schema::x(), and schema::y().
Referenced by draw().
{
dev.rect( x() + dHorz,
y() + dVert,
width() - 2*dHorz,
height() - 2*dVert,
fColor.c_str(),
fLink.c_str()
);
}


| void blockSchema::drawText | ( | device & | dev | ) | [protected] |
Draw the text centered on the box.
Definition at line 203 of file blockSchema.cpp.
References fLink, fText, schema::height(), device::text(), schema::width(), schema::x(), and schema::y().
Referenced by draw().


| point blockSchema::inputPoint | ( | unsigned int | i | ) | const [virtual] |
Returns an input point.
Implements schema.
Definition at line 95 of file blockSchema.cpp.
References fInputPoint, schema::inputs(), and schema::placed().
{
assert (placed());
assert (i < inputs());
return fInputPoint[i];
}

| point blockSchema::outputPoint | ( | unsigned int | i | ) | const [virtual] |
Returns an output point.
Implements schema.
Definition at line 105 of file blockSchema.cpp.
References fOutputPoint, schema::outputs(), and schema::placed().
{
assert (placed());
assert (i < outputs());
return fOutputPoint[i];
}

| void blockSchema::place | ( | double | x, |
| double | y, | ||
| int | orientation | ||
| ) | [virtual] |
Define the graphic position of the blockSchema.
Computes the graphic position of all the elements, in particular the inputs and outputs. This method must be called before draw(), otherwise draw is not allowed
Implements schema.
Definition at line 82 of file blockSchema.cpp.
References schema::beginPlace(), schema::endPlace(), placeInputPoints(), and placeOutputPoints().
{
beginPlace(x, y, orientation);
placeInputPoints();
placeOutputPoints();
endPlace();
}

| void blockSchema::placeInputPoints | ( | ) | [protected] |
Computes the input points according to the position and the orientation of the blockSchema.
Definition at line 116 of file blockSchema.cpp.
References dWire, fInputPoint, schema::height(), schema::inputs(), kLeftRight, schema::orientation(), schema::width(), schema::x(), and schema::y().
Referenced by place().
{
int N = inputs();
if (orientation() == kLeftRight) {
double px = x();
double py = y() + (height() - dWire*(N-1))/2;
for (int i=0; i<N; i++) {
fInputPoint[i] = point(px, py+i*dWire);
}
} else {
double px = x() + width();
double py = y() + height() - (height() - dWire*(N-1))/2;
for (int i=0; i<N; i++) {
fInputPoint[i] = point(px, py-i*dWire);
}
}
}


| void blockSchema::placeOutputPoints | ( | ) | [protected] |
Computes the output points according to the position and the orientation of the blockSchema.
Definition at line 145 of file blockSchema.cpp.
References dWire, fOutputPoint, schema::height(), kLeftRight, schema::orientation(), schema::outputs(), schema::width(), schema::x(), and schema::y().
Referenced by place().
{
int N = outputs();
if (orientation() == kLeftRight) {
double px = x() + width();
double py = y() + (height() - dWire*(N-1))/2;
for (int i=0; i<N; i++) {
fOutputPoint[i] = point(px, py + i*dWire);
}
} else {
double px = x();
double py = y() + height() - (height() - dWire*(N-1))/2;
for (int i=0; i<N; i++) {
fOutputPoint[i] = point(px, py - i*dWire);
}
}
}


| schema* makeBlockSchema | ( | unsigned int | inputs, |
| unsigned int | outputs, | ||
| const string & | name, | ||
| const string & | color, | ||
| const string & | link | ||
| ) | [friend] |
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.
const string blockSchema::fColor [protected] |
color of the box
Definition at line 39 of file blockSchema.h.
Referenced by inverterSchema::draw(), and drawRectangle().
vector<point> blockSchema::fInputPoint [protected] |
input connection points
Definition at line 43 of file blockSchema.h.
Referenced by blockSchema(), collectInputWires(), drawInputWires(), inputPoint(), and placeInputPoints().
const string blockSchema::fLink [protected] |
option URL link
Definition at line 40 of file blockSchema.h.
Referenced by inverterSchema::draw(), drawRectangle(), and drawText().
vector<point> blockSchema::fOutputPoint [protected] |
output connection points
Definition at line 44 of file blockSchema.h.
Referenced by blockSchema(), collectOutputWires(), drawOutputWires(), outputPoint(), and placeOutputPoints().
const string blockSchema::fText [protected] |
1.8.0