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

Place and connect two diagrams in merge composition. More...

#include <mergeSchema.h>

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

List of all members.

Public Member Functions

virtual void place (double ox, double oy, int orientation)
 Places the two subschema horizontaly, centered, with enough gap for the connections.
virtual void draw (device &dev)
 Draw the two sub schema and the connections between them.
virtual point inputPoint (unsigned int i) const
 The inputs of s1 :> s2 are the inputs of s1.
virtual point outputPoint (unsigned int i) const
 The outputs of s1 :> s2 are the outputs of s2.
virtual void collectTraits (collector &c)
 Draw the two sub schema and the connections between them.

Private Member Functions

 mergeSchema (schema *s1, schema *s2, double hgap)
 Constructor for a merge schema s1 :> s2 where the outputs of s1 are merged to the inputs of s2.

Private Attributes

schemafSchema1
schemafSchema2
double fHorzGap

Friends

schemamakeMergeSchema (schema *s1, schema *s2)
 Creates a new merge schema.

Detailed Description

Place and connect two diagrams in merge composition.

Definition at line 33 of file mergeSchema.h.


Constructor & Destructor Documentation

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

Constructor for a merge schema s1 :> s2 where the outputs of s1 are merged to the inputs of s2.

The constructor is private in order to enforce the usage of makeMergeSchema

Definition at line 50 of file mergeSchema.cpp.

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

Member Function Documentation

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

Draw the two sub schema and the connections between them.

Implements schema.

Definition at line 130 of file mergeSchema.cpp.

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

{
    assert(placed());

    // draw the two subdiagrams
    fSchema1->collectTraits(c);
    fSchema2->collectTraits(c);

    unsigned int r = fSchema2->inputs();
    assert(r>0);

    // draw the connections between them
    for (unsigned int i=0; i<fSchema1->outputs(); i++) {
        point p = fSchema1->outputPoint(i);
        point q = fSchema2->inputPoint(i%r);
        c.addTrait(trait(p,q));
    }
}

Here is the call graph for this function:

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

Draw the two sub schema and the connections between them.

Implements schema.

Definition at line 105 of file mergeSchema.cpp.

References schema::draw(), fSchema1, fSchema2, schema::inputPoint(), schema::inputs(), schema::outputPoint(), schema::outputs(), schema::placed(), device::trait(), point::x, and point::y.

{
    assert(placed());

    // draw the two subdiagrams
    fSchema1->draw(dev);
    fSchema2->draw(dev);

#if 0
    unsigned int r = fSchema2->inputs();
    assert(r>0);

    // draw the connections between them
    for (unsigned int i=0; i<fSchema1->outputs(); i++) {
        point p = fSchema1->outputPoint(i);
        point q = fSchema2->inputPoint(i%r);
        dev.trait(p.x, p.y, q.x, q.y);
    }
#endif
}

Here is the call graph for this function:

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

The inputs of s1 :> s2 are the inputs of s1.

Implements schema.

Definition at line 87 of file mergeSchema.cpp.

References fSchema1, and schema::inputPoint().

{
    return fSchema1->inputPoint(i);
}

Here is the call graph for this function:

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

The outputs of s1 :> s2 are the outputs of s2.

Implements schema.

Definition at line 96 of file mergeSchema.cpp.

References fSchema2, and schema::outputPoint().

{
    return fSchema2->outputPoint(i);
}

Here is the call graph for this function:

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

Places the two subschema horizontaly, centered, with enough gap for the connections.

Implements schema.

Definition at line 66 of file mergeSchema.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 dy1 = max(0.0, fSchema2->height()-fSchema1->height()) / 2.0;
    double dy2 = max(0.0, fSchema1->height()-fSchema2->height()) / 2.0;

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

Here is the call graph for this function:


Friends And Related Function Documentation

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

Creates a new merge schema.

Cables are enlarged to dWire. The horizontal gap between the two subschema is such that the connections are not too slopy.

Definition at line 35 of file mergeSchema.cpp.

{
    // avoid ugly diagram by ensuring at least dWire width
    schema * a = makeEnlargedSchema(s1, dWire);
    schema * b = makeEnlargedSchema(s2, dWire);
    double  hgap = (a->height()+b->height())/4;
    return new mergeSchema(a,b,hgap);
}

Member Data Documentation

double mergeSchema::fHorzGap [private]

Definition at line 37 of file mergeSchema.h.

Referenced by place().

Definition at line 35 of file mergeSchema.h.

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

Definition at line 36 of file mergeSchema.h.

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


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