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

A simple rectangular box with a text and inputs and outputs. More...

#include <connectorSchema.h>

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

Public Member Functions

virtual void place (double x, double y, int orientation)
 Define the graphic position of the connectorSchema. More...
 
virtual void draw (device &dev)
 Draw the connectorSchema on the device. More...
 
virtual point inputPoint (unsigned int i) const
 Returns an input point. More...
 
virtual point outputPoint (unsigned int i) const
 Returns an output point. More...
 
virtual void collectTraits (collector &c)
 Draw horizontal arrows from the input points to the connectorSchema rectangle. 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
 

Protected Member Functions

 connectorSchema ()
 A connector is an invisible square fo dWire size with 1 input and 1 output. More...
 
void placeInputPoints ()
 Computes the input points according to the position and the orientation of the connectorSchema. More...
 
void placeOutputPoints ()
 Computes the output points according to the position and the orientation of the connectorSchema. More...
 
void collectInputWires (collector &c)
 Draw horizontal arrows from the input points to the connectorSchema rectangle. More...
 
void collectOutputWires (collector &c)
 Draw horizontal line from the connectorSchema rectangle to the output points. More...
 

Protected Attributes

vector< pointfInputPoint
 input connection points More...
 
vector< pointfOutputPoint
 output connection points More...
 

Friends

schemamakeConnectorSchema ()
 Connectors are used to ensure unused inputs and outputs are drawn. More...
 

Detailed Description

A simple rectangular box with a text and inputs and outputs.

The constructor is private in order to make sure makeconnectorSchema is used instead

Definition at line 35 of file connectorSchema.h.

Constructor & Destructor Documentation

connectorSchema::connectorSchema ( )
protected

A connector is an invisible square fo dWire size with 1 input and 1 output.

Definition at line 42 of file connectorSchema.cpp.

References fInputPoint, and fOutputPoint.

42  : schema(1, 1, dWire, dWire)
43 {
44  fInputPoint.push_back(point(0,0));
45  fOutputPoint.push_back(point(0,0));
46 }
const double dWire
distance between two wires
Definition: schema.h:33
vector< point > fOutputPoint
output connection points
vector< point > fInputPoint
input connection points
schema(unsigned int inputs, unsigned int outputs, double width, double height)
Definition: schema.h:113
Definition: schema.h:40

Member Function Documentation

void connectorSchema::collectInputWires ( collector c)
protected

Draw horizontal arrows from the input points to the connectorSchema rectangle.

Definition at line 166 of file connectorSchema.cpp.

References collector::addInput(), collector::addTrait(), dHorz, fInputPoint, schema::inputs(), kLeftRight, schema::orientation(), point::x, and point::y.

Referenced by collectTraits().

167 {
168  double dx = (orientation() == kLeftRight) ? dHorz : -dHorz;
169 
170  for (unsigned int i=0; i<inputs(); i++) {
171  point p = fInputPoint[i];
172  c.addTrait(trait(point(p.x, p.y), point(p.x+dx, p.y))); // in->out direction
173  c.addInput(point(p.x+dx, p.y));
174  }
175 }
void addTrait(const trait &t)
Definition: schema.h:84
Definition: schema.h:56
unsigned int inputs() const
Definition: schema.h:128
double y
Definition: schema.h:43
vector< point > fInputPoint
input connection points
int orientation() const
Definition: schema.h:140
double x
Definition: schema.h:42
Definition: schema.h:40
const double dHorz
marge horizontale
Definition: schema.h:36
void addInput(const point &p)
Definition: schema.h:83

Here is the call graph for this function:

Here is the caller graph for this function:

void connectorSchema::collectOutputWires ( collector c)
protected

Draw horizontal line from the connectorSchema rectangle to the output points.

Definition at line 182 of file connectorSchema.cpp.

References collector::addOutput(), collector::addTrait(), dHorz, fOutputPoint, kLeftRight, schema::orientation(), schema::outputs(), point::x, and point::y.

Referenced by collectTraits().

183 {
184  double dx = (orientation() == kLeftRight) ? dHorz : -dHorz;
185 
186  for (unsigned int i=0; i<outputs(); i++) {
187  point p = fOutputPoint[i];
188  c.addTrait(trait(point(p.x-dx, p.y), point(p.x, p.y))); // in->out direction
189  c.addOutput(point(p.x-dx, p.y));
190  }
191 }
void addOutput(const point &p)
Definition: schema.h:82
void addTrait(const trait &t)
Definition: schema.h:84
Definition: schema.h:56
unsigned int outputs() const
Definition: schema.h:129
vector< point > fOutputPoint
output connection points
double y
Definition: schema.h:43
int orientation() const
Definition: schema.h:140
double x
Definition: schema.h:42
Definition: schema.h:40
const double dHorz
marge horizontale
Definition: schema.h:36

Here is the call graph for this function:

Here is the caller graph for this function:

void connectorSchema::collectTraits ( collector c)
virtual

Draw horizontal arrows from the input points to the connectorSchema rectangle.

Implements schema.

Definition at line 155 of file connectorSchema.cpp.

References collectInputWires(), and collectOutputWires().

156 {
159 }
void collectOutputWires(collector &c)
Draw horizontal line from the connectorSchema rectangle to the output points.
void collectInputWires(collector &c)
Draw horizontal arrows from the input points to the connectorSchema rectangle.

Here is the call graph for this function:

void connectorSchema::draw ( device dev)
virtual

Draw the connectorSchema on the device.

This methos can only be called after the connectorSchema have been placed

Implements schema.

Definition at line 145 of file connectorSchema.cpp.

References schema::placed().

146 {
147  assert(placed());
148  // nothing to do
149 }
bool placed() const
Definition: schema.h:137

Here is the call graph for this function:

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

Returns an input point.

Implements schema.

Definition at line 66 of file connectorSchema.cpp.

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

67 {
68  assert (placed());
69  assert (i < inputs());
70  return fInputPoint[i];
71 }
unsigned int inputs() const
Definition: schema.h:128
bool placed() const
Definition: schema.h:137
vector< point > fInputPoint
input connection points

Here is the call graph for this function:

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

Returns an output point.

Implements schema.

Definition at line 76 of file connectorSchema.cpp.

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

77 {
78  assert (placed());
79  assert (i < outputs());
80  return fOutputPoint[i];
81 }
unsigned int outputs() const
Definition: schema.h:129
vector< point > fOutputPoint
output connection points
bool placed() const
Definition: schema.h:137

Here is the call graph for this function:

void connectorSchema::place ( double  x,
double  y,
int  orientation 
)
virtual

Define the graphic position of the connectorSchema.

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 53 of file connectorSchema.cpp.

References schema::beginPlace(), schema::endPlace(), placeInputPoints(), and placeOutputPoints().

54 {
56 
59 
60  endPlace();
61 }
void endPlace()
Definition: schema.h:134
void beginPlace(double x, double y, int orientation)
Definition: schema.h:132
void placeOutputPoints()
Computes the output points according to the position and the orientation of the connectorSchema.
void placeInputPoints()
Computes the input points according to the position and the orientation of the connectorSchema.
double y() const
Definition: schema.h:139
double x() const
Definition: schema.h:138
int orientation() const
Definition: schema.h:140

Here is the call graph for this function:

void connectorSchema::placeInputPoints ( )
protected

Computes the input points according to the position and the orientation of the connectorSchema.

Definition at line 87 of file connectorSchema.cpp.

References dWire, fInputPoint, schema::height(), schema::inputs(), kLeftRight, schema::orientation(), schema::width(), schema::x(), and schema::y().

Referenced by place().

88 {
89  int N = inputs();
90 
91  if (orientation() == kLeftRight) {
92 
93  double px = x();
94  double py = y() + (height() - dWire*(N-1))/2;
95 
96  for (int i=0; i<N; i++) {
97  fInputPoint[i] = point(px, py+i*dWire);
98  }
99 
100  } else {
101 
102  double px = x() + width();
103  double py = y() + height() - (height() - dWire*(N-1))/2;
104 
105  for (int i=0; i<N; i++) {
106  fInputPoint[i] = point(px, py-i*dWire);
107  }
108  }
109 }
const double dWire
distance between two wires
Definition: schema.h:33
unsigned int inputs() const
Definition: schema.h:128
double y() const
Definition: schema.h:139
double width() const
Definition: schema.h:126
vector< point > fInputPoint
input connection points
double x() const
Definition: schema.h:138
int orientation() const
Definition: schema.h:140
Definition: schema.h:40
double height() const
Definition: schema.h:127

Here is the call graph for this function:

Here is the caller graph for this function:

void connectorSchema::placeOutputPoints ( )
protected

Computes the output points according to the position and the orientation of the connectorSchema.

Definition at line 116 of file connectorSchema.cpp.

References dWire, fOutputPoint, schema::height(), kLeftRight, schema::orientation(), schema::outputs(), schema::width(), schema::x(), and schema::y().

Referenced by place().

117 {
118  int N = outputs();
119 
120  if (orientation() == kLeftRight) {
121 
122  double px = x() + width();
123  double py = y() + (height() - dWire*(N-1))/2;
124 
125  for (int i=0; i<N; i++) {
126  fOutputPoint[i] = point(px, py + i*dWire);
127  }
128 
129  } else {
130 
131  double px = x();
132  double py = y() + height() - (height() - dWire*(N-1))/2;
133 
134  for (int i=0; i<N; i++) {
135  fOutputPoint[i] = point(px, py - i*dWire);
136  }
137  }
138 }
unsigned int outputs() const
Definition: schema.h:129
const double dWire
distance between two wires
Definition: schema.h:33
vector< point > fOutputPoint
output connection points
double y() const
Definition: schema.h:139
double width() const
Definition: schema.h:126
double x() const
Definition: schema.h:138
int orientation() const
Definition: schema.h:140
Definition: schema.h:40
double height() const
Definition: schema.h:127

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

schema* makeConnectorSchema ( )
friend

Connectors are used to ensure unused inputs and outputs are drawn.

Definition at line 33 of file connectorSchema.cpp.

34 {
35  return new connectorSchema();
36 }
connectorSchema()
A connector is an invisible square fo dWire size with 1 input and 1 output.

Member Data Documentation

vector<point> connectorSchema::fInputPoint
protected

input connection points

Definition at line 39 of file connectorSchema.h.

Referenced by collectInputWires(), connectorSchema(), inputPoint(), and placeInputPoints().

vector<point> connectorSchema::fOutputPoint
protected

output connection points

Definition at line 40 of file connectorSchema.h.

Referenced by collectOutputWires(), connectorSchema(), outputPoint(), and placeOutputPoints().


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