FAUST compiler  0.9.9.6b8
Public Member Functions | Private Member Functions | Private Attributes | Friends
decorateSchema Class Reference

A decorateSchema is a schema surrounded by a dashed rectangle with a label on the top left. More...

#include <decorateSchema.h>

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

List of all members.

Public Member Functions

virtual void place (double ox, double oy, int orientation)
 Define the graphic position of the schema.
virtual void draw (device &dev)
 Draw the enlarged schema.
virtual void collectTraits (collector &c)
 Draw the enlarged schema.
virtual point inputPoint (unsigned int i) const
 Returns an input point.
virtual point outputPoint (unsigned int i) const
 Returns an output point.

Private Member Functions

 decorateSchema (schema *s1, double margin, const string &text)
 A decorateSchema is a schema surrounded by a dashed rectangle with a label on the top left.

Private Attributes

schemafSchema
double fMargin
string fText
vector< pointfInputPoint
vector< pointfOutputPoint

Friends

schemamakeDecorateSchema (schema *s1, double margin, const string &text)
 Creates a new decorated schema.

Detailed Description

A decorateSchema is a schema surrounded by a dashed rectangle with a label on the top left.

The rectangle is placed at half the margin parameter

Definition at line 34 of file decorateSchema.h.


Constructor & Destructor Documentation

decorateSchema::decorateSchema ( schema s,
double  margin,
const string &  text 
) [private]

A decorateSchema is a schema surrounded by a dashed rectangle with a label on the top left.

The rectangle is placed at half the margin parameter. The constructor is made private to enforce the usage of makeDecorateSchema

Definition at line 43 of file decorateSchema.cpp.

References fInputPoint, fOutputPoint, schema::inputs(), and schema::outputs().

    :   schema(s->inputs(), s->outputs(), s->width()+2*margin, s->height()+2*margin),
        fSchema(s),
        fMargin(margin),
        fText(text)
{
    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 decorateSchema::collectTraits ( collector c) [virtual]

Draw the enlarged schema.

This methods can only be called after the block have been placed

Implements schema.

Definition at line 152 of file decorateSchema.cpp.

References collector::addTrait(), schema::collectTraits(), fSchema, inputPoint(), schema::inputPoint(), schema::inputs(), outputPoint(), schema::outputPoint(), schema::outputs(), and schema::placed().

{
    assert(placed());

    fSchema->collectTraits(c);

    // draw enlarge input wires
    for (unsigned int i=0; i<inputs(); i++) {
        point p = inputPoint(i);
        point q = fSchema->inputPoint(i);
        c.addTrait(trait(p,q));     // in->out direction
    }

    // draw enlarge output wires
    for (unsigned int i=0; i<outputs(); i++) {
        point p = fSchema->outputPoint(i);
        point q = outputPoint(i);
        c.addTrait(trait(p,q));     // in->out direction
    }
}

Here is the call graph for this function:

void decorateSchema::draw ( device dev) [virtual]

Draw the enlarged schema.

This methods can only be called after the block have been placed

Implements schema.

Definition at line 107 of file decorateSchema.cpp.

References device::dasharray(), dLetter, schema::draw(), fMargin, fSchema, fText, schema::height(), inputPoint(), schema::inputPoint(), schema::inputs(), device::label(), min(), outputPoint(), schema::outputPoint(), schema::outputs(), schema::placed(), tl(), device::trait(), schema::width(), point::x, schema::x(), point::y, and schema::y().

{
    assert(placed());

    fSchema->draw(dev);
#if 0
    // draw enlarge input wires
    for (unsigned int i=0; i<inputs(); i++) {
        point p = inputPoint(i);
        point q = fSchema->inputPoint(i);
        dev.trait(p.x, p.y, q.x, q.y);
    }

    // draw enlarge output wires
    for (unsigned int i=0; i<outputs(); i++) {
        point p = outputPoint(i);
        point q = fSchema->outputPoint(i);
        dev.trait(p.x, p.y, q.x, q.y);
    }
#endif
    // define the coordinates of the frame
    double tw = (2+fText.size())*dLetter*0.75;
    double x0 = x() + fMargin/2;                // left
    double y0 = y() + fMargin/2;                // top
    double x1 = x() + width() - fMargin/2;      // right
    double y1 = y() + height() - fMargin/2;     // bottom
    //double tl = x0 + 2*dWire;                 // left of text zone
    double tl = x() + fMargin;                  // left of text zone
    double tr = min(tl+tw, x1);                 // right of text zone

    // draw the surronding frame
    dev.dasharray(x0, y0, x0, y1);              // left line
    dev.dasharray(x0, y1, x1, y1);              // bottom line
    dev.dasharray(x1, y1, x1, y0);              // right line
    dev.dasharray(x0, y0, tl, y0);              // top segment before text
    dev.dasharray(tr, y0, x1, y0);              // top segment after text

    // draw the label
    dev.label(tl, y0, fText.c_str());   //
}

Here is the call graph for this function:

point decorateSchema::inputPoint ( unsigned int  i) const [virtual]

Returns an input point.

Implements schema.

Definition at line 86 of file decorateSchema.cpp.

References fInputPoint, schema::inputs(), and schema::placed().

Referenced by collectTraits(), and draw().

{
    assert (placed());
    assert (i < inputs());
    return fInputPoint[i];
}

Here is the call graph for this function:

Here is the caller graph for this function:

point decorateSchema::outputPoint ( unsigned int  i) const [virtual]

Returns an output point.

Implements schema.

Definition at line 96 of file decorateSchema.cpp.

References fOutputPoint, schema::outputs(), and schema::placed().

Referenced by collectTraits(), and draw().

{
    assert (placed());
    assert (i < outputs());
    return fOutputPoint[i];
}

Here is the call graph for this function:

Here is the caller graph for this function:

void decorateSchema::place ( double  ox,
double  oy,
int  orientation 
) [virtual]

Define the graphic position of the schema.

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 59 of file decorateSchema.cpp.

References schema::beginPlace(), schema::endPlace(), fInputPoint, fMargin, fOutputPoint, fSchema, schema::inputPoint(), schema::inputs(), kRightLeft, schema::outputPoint(), schema::outputs(), schema::place(), point::x, and point::y.

{
    beginPlace(ox, oy, orientation);

    fSchema->place(ox+fMargin, oy+fMargin, orientation);

    double m = fMargin;
    if (orientation == kRightLeft) {
        m = -m;
    }

    for (unsigned int i=0; i < inputs(); i++) {
        point p = fSchema->inputPoint(i);
        fInputPoint[i] = point(p.x-m, p.y); //, p.z);
    }

    for (unsigned int i=0; i < outputs(); i++) {
        point p = fSchema->outputPoint(i);
        fOutputPoint[i] = point(p.x+m, p.y); //, p.z);
    }

    endPlace();
}

Here is the call graph for this function:


Friends And Related Function Documentation

schema* makeDecorateSchema ( schema s1,
double  margin,
const string &  text 
) [friend]

Creates a new decorated schema.

Definition at line 31 of file decorateSchema.cpp.

{
    return new decorateSchema (s, margin, text);
}

Member Data Documentation

Definition at line 39 of file decorateSchema.h.

Referenced by decorateSchema(), inputPoint(), and place().

double decorateSchema::fMargin [private]

Definition at line 37 of file decorateSchema.h.

Referenced by draw(), and place().

Definition at line 40 of file decorateSchema.h.

Referenced by decorateSchema(), outputPoint(), and place().

Definition at line 36 of file decorateSchema.h.

Referenced by collectTraits(), draw(), and place().

string decorateSchema::fText [private]

Definition at line 38 of file decorateSchema.h.

Referenced by draw().


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