FAUST compiler  0.9.9.6b8
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
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]

Public Member Functions

virtual void place (double ox, double oy, int orientation)
 Places the two subschema horizontaly, centered, with enough gap for the connections. More...
 
virtual void draw (device &dev)
 Draw the two sub schema and the connections between them. More...
 
virtual point inputPoint (unsigned int i) const
 The inputs of s1 :> s2 are the inputs of s1. More...
 
virtual point outputPoint (unsigned int i) const
 The outputs of s1 :> s2 are the outputs of s2. More...
 
virtual void collectTraits (collector &c)
 Draw the two sub schema and the connections between them. More...
 
- Public Member Functions inherited from schema
 schema (unsigned int inputs, unsigned int outputs, double width, double height)
 
virtual ~schema ()
 
double width () const
 
double height () const
 
unsigned int inputs () const
 
unsigned int outputs () const
 
void beginPlace (double x, double y, int orientation)
 
void endPlace ()
 
bool placed () const
 
double x () const
 
double y () const
 
int orientation () const
 

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. More...
 

Private Attributes

schemafSchema1
 
schemafSchema2
 
double fHorzGap
 

Friends

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

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.

51  : schema( s1->inputs(),
52  s2->outputs(),
53  s1->width() + s2->width() + hgap,
54  max(s1->height(), s2->height()) ),
55  fSchema1(s1),
56  fSchema2(s2),
57  fHorzGap(hgap)
58 {
59 }
unsigned int outputs() const
Definition: schema.h:129
double fHorzGap
Definition: mergeSchema.h:37
unsigned int inputs() const
Definition: schema.h:128
double max(double x, double y)
Definition: interval.hh:60
schema * fSchema1
Definition: mergeSchema.h:35
double width() const
Definition: schema.h:126
schema(unsigned int inputs, unsigned int outputs, double width, double height)
Definition: schema.h:113
double height() const
Definition: schema.h:127
schema * fSchema2
Definition: mergeSchema.h:36

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

131 {
132  assert(placed());
133 
134  // draw the two subdiagrams
137 
138  unsigned int r = fSchema2->inputs();
139  assert(r>0);
140 
141  // draw the connections between them
142  for (unsigned int i=0; i<fSchema1->outputs(); i++) {
143  point p = fSchema1->outputPoint(i);
144  point q = fSchema2->inputPoint(i%r);
145  c.addTrait(trait(p,q));
146  }
147 }
void addTrait(const trait &t)
Definition: schema.h:84
Definition: schema.h:56
unsigned int outputs() const
Definition: schema.h:129
virtual point inputPoint(unsigned int i) const =0
virtual void collectTraits(collector &c)=0
unsigned int inputs() const
Definition: schema.h:128
schema * fSchema1
Definition: mergeSchema.h:35
bool placed() const
Definition: schema.h:137
Definition: schema.h:40
virtual point outputPoint(unsigned int i) const =0
schema * fSchema2
Definition: mergeSchema.h:36

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.

106 {
107  assert(placed());
108 
109  // draw the two subdiagrams
110  fSchema1->draw(dev);
111  fSchema2->draw(dev);
112 
113 #if 0
114  unsigned int r = fSchema2->inputs();
115  assert(r>0);
116 
117  // draw the connections between them
118  for (unsigned int i=0; i<fSchema1->outputs(); i++) {
119  point p = fSchema1->outputPoint(i);
120  point q = fSchema2->inputPoint(i%r);
121  dev.trait(p.x, p.y, q.x, q.y);
122  }
123 #endif
124 }
unsigned int outputs() const
Definition: schema.h:129
virtual point inputPoint(unsigned int i) const =0
virtual void draw(device &dev)=0
unsigned int inputs() const
Definition: schema.h:128
schema * fSchema1
Definition: mergeSchema.h:35
double y
Definition: schema.h:43
bool placed() const
Definition: schema.h:137
double x
Definition: schema.h:42
Definition: schema.h:40
virtual point outputPoint(unsigned int i) const =0
schema * fSchema2
Definition: mergeSchema.h:36
virtual void trait(double x1, double y1, double x2, double y2)=0

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

88 {
89  return fSchema1->inputPoint(i);
90 }
virtual point inputPoint(unsigned int i) const =0
schema * fSchema1
Definition: mergeSchema.h:35

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

97 {
98  return fSchema2->outputPoint(i);
99 }
virtual point outputPoint(unsigned int i) const =0
schema * fSchema2
Definition: mergeSchema.h:36

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

67 {
68  beginPlace(ox, oy, orientation);
69 
70  double dy1 = max(0.0, fSchema2->height()-fSchema1->height()) / 2.0;
71  double dy2 = max(0.0, fSchema1->height()-fSchema2->height()) / 2.0;
72 
73  if (orientation == kLeftRight) {
74  fSchema1->place(ox, oy+dy1, orientation);
76  } else {
77  fSchema2->place(ox, oy+dy2, orientation);
79  }
80  endPlace();
81 }
void endPlace()
Definition: schema.h:134
void beginPlace(double x, double y, int orientation)
Definition: schema.h:132
double fHorzGap
Definition: mergeSchema.h:37
double max(double x, double y)
Definition: interval.hh:60
schema * fSchema1
Definition: mergeSchema.h:35
double width() const
Definition: schema.h:126
int orientation() const
Definition: schema.h:140
virtual void place(double x, double y, int orientation)=0
double height() const
Definition: schema.h:127
schema * fSchema2
Definition: mergeSchema.h:36

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.

36 {
37  // avoid ugly diagram by ensuring at least dWire width
38  schema * a = makeEnlargedSchema(s1, dWire);
39  schema * b = makeEnlargedSchema(s2, dWire);
40  double hgap = (a->height()+b->height())/4;
41  return new mergeSchema(a,b,hgap);
42 }
const double dWire
distance between two wires
Definition: schema.h:33
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...
Definition: mergeSchema.cpp:50
An abstract block diagram schema.
Definition: schema.h:97
double height() const
Definition: schema.h:127
schema * makeEnlargedSchema(schema *s, double width)
Returns an enlarged schema, but only if really needed that is if the requiered width is greater that ...

Member Data Documentation

double mergeSchema::fHorzGap
private

Definition at line 37 of file mergeSchema.h.

Referenced by place().

schema* mergeSchema::fSchema1
private

Definition at line 35 of file mergeSchema.h.

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

schema* mergeSchema::fSchema2
private

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: