FAUST compiler  0.9.9.6b8
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
splitSchema Class Reference

place and connect two diagrams in split composition More...

#include <splitSchema.h>

Inheritance diagram for splitSchema:
Inheritance graph
[legend]
Collaboration diagram for splitSchema:
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

 splitSchema (schema *s1, schema *s2, double hgap)
 Constructor for a split schema s1 <: s2 where the outputs of s1 are distributed to the inputs of s2. More...
 

Private Attributes

schemafSchema1
 
schemafSchema2
 
double fHorzGap
 

Friends

schemamakeSplitSchema (schema *s1, schema *s2)
 Creates a new split schema. More...
 

Detailed Description

place and connect two diagrams in split composition

Definition at line 33 of file splitSchema.h.

Constructor & Destructor Documentation

splitSchema::splitSchema ( schema s1,
schema s2,
double  hgap 
)
private

Constructor for a split schema s1 <: s2 where the outputs of s1 are distributed to the inputs of s2.

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

Definition at line 52 of file splitSchema.cpp.

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

Member Function Documentation

void splitSchema::collectTraits ( collector c)
virtual

Draw the two sub schema and the connections between them.

Implements schema.

Definition at line 133 of file splitSchema.cpp.

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

134 {
135  assert(placed());
136 
137  // draw the two subdiagrams
140 
141  unsigned int r = fSchema1->outputs();
142  assert(r>0);
143 
144  // draw the connections between them
145  for (unsigned int i=0; i<fSchema2->inputs(); i++) {
146  point p = fSchema1->outputPoint(i%r);
147  point q = fSchema2->inputPoint(i);
148  c.addTrait(trait(point(p.x, p.y), point(q.x, q.y)));
149  }
150 }
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
double y
Definition: schema.h:43
bool placed() const
Definition: schema.h:137
schema * fSchema1
Definition: splitSchema.h:35
schema * fSchema2
Definition: splitSchema.h:36
double x
Definition: schema.h:42
Definition: schema.h:40
virtual point outputPoint(unsigned int i) const =0

Here is the call graph for this function:

void splitSchema::draw ( device dev)
virtual

Draw the two sub schema and the connections between them.

Implements schema.

Definition at line 107 of file splitSchema.cpp.

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

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

Here is the call graph for this function:

point splitSchema::inputPoint ( unsigned int  i) const
virtual

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

Implements schema.

Definition at line 89 of file splitSchema.cpp.

References fSchema1, and schema::inputPoint().

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

Here is the call graph for this function:

point splitSchema::outputPoint ( unsigned int  i) const
virtual

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

Implements schema.

Definition at line 98 of file splitSchema.cpp.

References fSchema2, and schema::outputPoint().

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

Here is the call graph for this function:

void splitSchema::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 68 of file splitSchema.cpp.

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

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

Here is the call graph for this function:

Friends And Related Function Documentation

schema* makeSplitSchema ( schema s1,
schema s2 
)
friend

Creates a new split 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 34 of file splitSchema.cpp.

35 {
36  // make sure a and b are at least dWire large
37  schema * a = makeEnlargedSchema(s1, dWire);
38  schema * b = makeEnlargedSchema(s2, dWire);
39 
40  // horizontal gap to avaoid too slopy connections
41  double hgap = (a->height()+b->height())/4;
42 
43  return new splitSchema(a,b,hgap);
44 }
const double dWire
distance between two wires
Definition: schema.h:33
splitSchema(schema *s1, schema *s2, double hgap)
Constructor for a split schema s1 <: s2 where the outputs of s1 are distributed to the inputs of s2...
Definition: splitSchema.cpp:52
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 splitSchema::fHorzGap
private

Definition at line 37 of file splitSchema.h.

Referenced by place().

schema* splitSchema::fSchema1
private

Definition at line 35 of file splitSchema.h.

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

schema* splitSchema::fSchema2
private

Definition at line 36 of file splitSchema.h.

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


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