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

Sequential composition. More...

#include <seqSchema.h>

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

List of all members.

Public Member Functions

virtual void place (double ox, double oy, int orientation)
 Place the two components horizontally with enough space for the connections.
virtual void draw (device &dev)
 Draw the two components as well as the internal wires.
virtual point inputPoint (unsigned int i) const
 The input points are the input points of the first component.
virtual point outputPoint (unsigned int i) const
 The output points are the output points of the second component.
virtual void collectTraits (collector &c)
 Draw the two components as well as the internal wires.

Private Member Functions

 seqSchema (schema *s1, schema *s2, double hgap)
 Constructor for a sequential schema (s1:s2).
void drawInternalWires (device &dev)
 Draw the internal wires aligning the vertical segments in a symetric way when possible.
void collectInternalWires (collector &c)
 Draw the internal wires aligning the vertical segments in a symetric way when possible.

Private Attributes

schemafSchema1
schemafSchema2
double fHorzGap

Friends

schemamakeSeqSchema (schema *s1, schema *s2)
 Make a sequential schema.

Detailed Description

Sequential composition.

Place and connect two diagrams in sequence. The constructor is private because one should use the makeSeqSchema function instead.

Definition at line 36 of file seqSchema.h.


Constructor & Destructor Documentation

seqSchema::seqSchema ( schema s1,
schema s2,
double  hgap 
) [private]

Constructor for a sequential schema (s1:s2).

The components s1 and s2 are supposed to be "compatible" (s1 : n->m and s2 : m->q)

Definition at line 62 of file seqSchema.cpp.

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

    :   schema( s1->inputs(),
                s2->outputs(),
                s1->width() + hgap + s2->width(),
                max(s1->height(), s2->height()) ),
        fSchema1(s1),
        fSchema2(s2),
        fHorzGap(hgap)
{
    assert(s1->outputs() == s2->inputs());
}

Here is the call graph for this function:


Member Function Documentation

void seqSchema::collectInternalWires ( collector c) [private]

Draw the internal wires aligning the vertical segments in a symetric way when possible.

Definition at line 233 of file seqSchema.cpp.

References collector::addTrait(), direction(), dWire, fHorzGap, fSchema1, fSchema2, schema::inputPoint(), schema::inputs(), kDownDir, kLeftRight, kUpDir, schema::orientation(), schema::outputPoint(), schema::outputs(), point::x, and point::y.

Referenced by collectTraits().

{
    assert (fSchema1->outputs() == fSchema2->inputs());

    const int   N   = fSchema1->outputs();
    double      dx  = 0;
    double      mx  = 0;
    int         dir =-1;

    if (orientation() == kLeftRight) {
        // draw left right cables
        for (int i=0; i<N; i++) {
            point src = fSchema1->outputPoint(i);
            point dst = fSchema2->inputPoint(i);

            int d = direction(src,dst);
            if (d != dir) {
                // compute attributes of new direction
                switch (d) {
                    case kUpDir     : mx = 0; dx = dWire; break;
                    case kDownDir   : mx = fHorzGap; dx = -dWire; break;
                    default         : mx = 0; dx = 0; break;
                }
                dir = d;
            } else {
                // move in same direction
                mx = mx +dx;
            }
            if (src.y == dst.y) {
                // draw straight cable
                c.addTrait(trait(point(src.x, src.y), point(dst.x, dst.y)));
            } else {
                // draw zizag cable
                c.addTrait(trait(point(src.x, src.y), point(src.x+mx, src.y)));
                c.addTrait(trait(point(src.x+mx, src.y), point(src.x+mx, dst.y)));
                c.addTrait(trait(point(src.x+mx, dst.y), point(dst.x, dst.y)));
            }

        }
    } else {
        // draw right left cables
        for (int i=0; i<N; i++) {
            point src = fSchema1->outputPoint(i);
            point dst = fSchema2->inputPoint(i);

            int d = direction(src,dst);
            if (d != dir) {
                // compute attributes of new direction
                switch (d) {
                    case kUpDir     : mx = -fHorzGap; dx = dWire; break;
                    case kDownDir   : mx = 0; dx = -dWire; break;
                    default         : mx = 0; dx = 0; break;
                }
                dir = d;
            } else {
                // move in same direction
                mx = mx +dx;
            }
            if (src.y == dst.y) {
                // draw straight cable
                c.addTrait(trait(point(src.x, src.y), point(dst.x, dst.y)));
            } else {
                // draw zizag cable
                c.addTrait(trait(point(src.x, src.y), point(src.x+mx, src.y)));
                c.addTrait(trait(point(src.x+mx, src.y), point(src.x+mx, dst.y)));
                c.addTrait(trait(point(src.x+mx, dst.y), point(dst.x, dst.y)));
            }

        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void seqSchema::collectTraits ( collector c) [virtual]

Draw the two components as well as the internal wires.

Implements schema.

Definition at line 138 of file seqSchema.cpp.

References collectInternalWires(), schema::collectTraits(), fSchema1, fSchema2, schema::inputs(), schema::outputs(), and schema::placed().

Here is the call graph for this function:

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

Draw the two components as well as the internal wires.

Implements schema.

Definition at line 125 of file seqSchema.cpp.

References schema::draw(), fSchema1, fSchema2, schema::inputs(), schema::outputs(), and schema::placed().

{
    assert(placed());
    assert(fSchema1->outputs() == fSchema2->inputs());

    fSchema1->draw(dev);
    fSchema2->draw(dev);
    //drawInternalWires(dev);
}

Here is the call graph for this function:

void seqSchema::drawInternalWires ( device dev) [private]

Draw the internal wires aligning the vertical segments in a symetric way when possible.

Definition at line 154 of file seqSchema.cpp.

References direction(), dWire, fHorzGap, fSchema1, fSchema2, schema::inputPoint(), schema::inputs(), kDownDir, kLeftRight, kUpDir, schema::orientation(), schema::outputPoint(), schema::outputs(), device::trait(), point::x, and point::y.

{
    assert (fSchema1->outputs() == fSchema2->inputs());

    const int   N   = fSchema1->outputs();
    double      dx  = 0;
    double      mx  = 0;
    int         dir =-1;

    if (orientation() == kLeftRight) {
        // draw left right cables
        for (int i=0; i<N; i++) {
            point src = fSchema1->outputPoint(i);
            point dst = fSchema2->inputPoint(i);

            int d = direction(src,dst);
            if (d != dir) {
                // compute attributes of new direction
                switch (d) {
                    case kUpDir     : mx = 0; dx = dWire; break;
                    case kDownDir   : mx = fHorzGap; dx = -dWire; break;
                    default         : mx = 0; dx = 0; break;
                }
                dir = d;
            } else {
                // move in same direction
                mx = mx +dx;
            }
            if (src.y == dst.y) {
                // draw straight cable
                dev.trait(src.x, src.y, dst.x, dst.y);
            } else {
                // draw zizag cable
                dev.trait(src.x, src.y, src.x+mx, src.y);
                dev.trait(src.x+mx, src.y, src.x+mx, dst.y);
                dev.trait(src.x+mx, dst.y, dst.x, dst.y);
            }

        }
    } else {
        // draw right left cables
        for (int i=0; i<N; i++) {
            point src = fSchema1->outputPoint(i);
            point dst = fSchema2->inputPoint(i);

            int d = direction(src,dst);
            if (d != dir) {
                // compute attributes of new direction
                switch (d) {
                    case kUpDir     : mx = -fHorzGap; dx = dWire; break;
                    case kDownDir   : mx = 0; dx = -dWire; break;
                    default         : mx = 0; dx = 0; break;
                }
                dir = d;
            } else {
                // move in same direction
                mx = mx +dx;
            }
            if (src.y == dst.y) {
                // draw straight cable
                dev.trait(src.x, src.y, dst.x, dst.y);
            } else {
                // draw zizag cable
                dev.trait(src.x, src.y, src.x+mx, src.y);
                dev.trait(src.x+mx, src.y, src.x+mx, dst.y);
                dev.trait(src.x+mx, dst.y, dst.x, dst.y);
            }

        }
    }
}

Here is the call graph for this function:

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

The input points are the input points of the first component.

Implements schema.

Definition at line 103 of file seqSchema.cpp.

References fSchema1, and schema::inputPoint().

{
    return fSchema1->inputPoint(i);
}

Here is the call graph for this function:

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

The output points are the output points of the second component.

Implements schema.

Definition at line 112 of file seqSchema.cpp.

References fSchema2, and schema::outputPoint().

{
    return fSchema2->outputPoint(i);
}

Here is the call graph for this function:

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

Place the two components horizontally with enough space for the connections.

Implements schema.

Definition at line 82 of file seqSchema.cpp.

References schema::beginPlace(), schema::endPlace(), fHorzGap, fSchema1, fSchema2, schema::height(), kLeftRight, max(), schema::orientation(), schema::place(), and schema::width().

{
    beginPlace(ox, oy, orientation);

    double y1 = max(0.0, 0.5*(fSchema2->height() - fSchema1->height()));
    double y2 = max(0.0, 0.5*(fSchema1->height() - fSchema2->height()));

    if (orientation == kLeftRight) {
        fSchema1->place(ox, oy+y1, orientation);
        fSchema2->place(ox+fSchema1->width()+fHorzGap, oy+y2, orientation);
    } else {
        fSchema2->place(ox, oy+y2, orientation);
        fSchema1->place(ox+fSchema2->width()+fHorzGap, oy+y1, orientation);
    }
    endPlace();
}

Here is the call graph for this function:


Friends And Related Function Documentation

schema* makeSeqSchema ( schema s1,
schema s2 
) [friend]

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.

{
    unsigned int o = s1->outputs();
    unsigned int i = s2->inputs();

    schema* a = (o < i) ? makeParSchema(s1, makeCableSchema(i-o)) : s1;
    schema* b = (o > i) ? makeParSchema(s2, makeCableSchema(o-i)) : s2;

    return new seqSchema(a, b, computeHorzGap(a,b));
}

Member Data Documentation

double seqSchema::fHorzGap [private]

Definition at line 40 of file seqSchema.h.

Referenced by collectInternalWires(), drawInternalWires(), and place().


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