FAUST compiler  0.9.9.6b8
Public Member Functions | Protected Member Functions | Protected Attributes | Friends
blockSchema Class Reference

A simple rectangular box with a text and inputs and outputs. More...

#include <blockSchema.h>

Inheritance diagram for blockSchema:
Inheritance graph
[legend]
Collaboration diagram for blockSchema:
Collaboration graph
[legend]

List of all members.

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< pointfInputPoint
 input connection points
vector< pointfOutputPoint
 output connection points

Friends

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

Detailed Description

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.


Constructor & Destructor Documentation

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));
}

Here is the call graph for this function:


Member Function Documentation

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));
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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));
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

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);
}

Here is the call graph for this function:

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());
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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() );
}

Here is the call graph for this function:

Here is the caller graph for this function:

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);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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()
            );
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

{
    dev.text(   x() + width()/2,
                y() + height()/2,
                fText.c_str(),
                fLink.c_str()
            );
}

Here is the call graph for this function:

Here is the caller graph for this function:

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];
}

Here is the call graph for this function:

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];
}

Here is the call graph for this function:

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

Here is the call graph for this function:

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);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

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.

{
    // determine the optimal size of the box
    double minimal = 3*dWire;
    double w = 2*dHorz + max( minimal, quantize(text.size()) );
    double h = 2*dVert + max( minimal, max(inputs, outputs) * dWire );

    return new blockSchema(inputs, outputs, w, h, text, color, link);
}

Member Data Documentation

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]

Text to be displayed.

Definition at line 38 of file blockSchema.h.

Referenced by drawText().


The documentation for this class was generated from the following files: