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

A decorateSchema is a schema surrounded by a dashed rectangle with a label on the top left. More...

#include <decorateSchema.h>

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

Public Member Functions

virtual void place (double ox, double oy, int orientation)
 Define the graphic position of the schema. More...
 
virtual void draw (device &dev)
 Draw the enlarged schema. 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 the enlarged schema. 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

 decorateSchema (schema *s1, double margin, const string &text)
 A decorateSchema is a schema surrounded by a dashed rectangle with a label on the top left. More...
 

Private Attributes

schemafSchema
 
double fMargin
 
string fText
 
vector< pointfInputPoint
 
vector< pointfOutputPoint
 

Friends

schemamakeDecorateSchema (schema *s1, double margin, const string &text)
 Creates a new decorated schema. More...
 

Detailed Description

A decorateSchema is a schema surrounded by a dashed rectangle with a label on the top left.

The rectangle is placed at half the margin parameter

Definition at line 34 of file decorateSchema.h.

Constructor & Destructor Documentation

decorateSchema::decorateSchema ( schema s,
double  margin,
const string &  text 
)
private

A decorateSchema is a schema surrounded by a dashed rectangle with a label on the top left.

The rectangle is placed at half the margin parameter. The constructor is made private to enforce the usage of makeDecorateSchema

Definition at line 43 of file decorateSchema.cpp.

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

44  : schema(s->inputs(), s->outputs(), s->width()+2*margin, s->height()+2*margin),
45  fSchema(s),
46  fMargin(margin),
47  fText(text)
48 {
49  for (unsigned int i=0; i<inputs(); i++) fInputPoint.push_back(point(0,0));
50  for (unsigned int i=0; i<outputs(); i++) fOutputPoint.push_back(point(0,0));
51 }
unsigned int outputs() const
Definition: schema.h:129
unsigned int inputs() const
Definition: schema.h:128
double width() const
Definition: schema.h:126
schema * fSchema
schema(unsigned int inputs, unsigned int outputs, double width, double height)
Definition: schema.h:113
vector< point > fInputPoint
Definition: schema.h:40
double height() const
Definition: schema.h:127
vector< point > fOutputPoint

Here is the call graph for this function:

Member Function Documentation

void decorateSchema::collectTraits ( collector c)
virtual

Draw the enlarged schema.

This methods can only be called after the block have been placed

Implements schema.

Definition at line 152 of file decorateSchema.cpp.

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

153 {
154  assert(placed());
155 
157 
158  // draw enlarge input wires
159  for (unsigned int i=0; i<inputs(); i++) {
160  point p = inputPoint(i);
161  point q = fSchema->inputPoint(i);
162  c.addTrait(trait(p,q)); // in->out direction
163  }
164 
165  // draw enlarge output wires
166  for (unsigned int i=0; i<outputs(); i++) {
167  point p = fSchema->outputPoint(i);
168  point q = outputPoint(i);
169  c.addTrait(trait(p,q)); // in->out direction
170  }
171 }
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 point inputPoint(unsigned int i) const
Returns an input point.
virtual void collectTraits(collector &c)=0
unsigned int inputs() const
Definition: schema.h:128
schema * fSchema
bool placed() const
Definition: schema.h:137
Definition: schema.h:40
virtual point outputPoint(unsigned int i) const =0
virtual point outputPoint(unsigned int i) const
Returns an output point.

Here is the call graph for this function:

void decorateSchema::draw ( device dev)
virtual

Draw the enlarged schema.

This methods can only be called after the block have been placed

Implements schema.

Definition at line 107 of file decorateSchema.cpp.

References device::dasharray(), dLetter, schema::draw(), fMargin, fSchema, fText, schema::height(), inputPoint(), schema::inputPoint(), schema::inputs(), device::label(), min(), outputPoint(), schema::outputPoint(), schema::outputs(), schema::placed(), tl(), device::trait(), schema::width(), point::x, schema::x(), point::y, and schema::y().

108 {
109  assert(placed());
110 
111  fSchema->draw(dev);
112 #if 0
113  // draw enlarge input wires
114  for (unsigned int i=0; i<inputs(); i++) {
115  point p = inputPoint(i);
116  point q = fSchema->inputPoint(i);
117  dev.trait(p.x, p.y, q.x, q.y);
118  }
119 
120  // draw enlarge output wires
121  for (unsigned int i=0; i<outputs(); i++) {
122  point p = outputPoint(i);
123  point q = fSchema->outputPoint(i);
124  dev.trait(p.x, p.y, q.x, q.y);
125  }
126 #endif
127  // define the coordinates of the frame
128  double tw = (2+fText.size())*dLetter*0.75;
129  double x0 = x() + fMargin/2; // left
130  double y0 = y() + fMargin/2; // top
131  double x1 = x() + width() - fMargin/2; // right
132  double y1 = y() + height() - fMargin/2; // bottom
133  //double tl = x0 + 2*dWire; // left of text zone
134  double tl = x() + fMargin; // left of text zone
135  double tr = min(tl+tw, x1); // right of text zone
136 
137  // draw the surronding frame
138  dev.dasharray(x0, y0, x0, y1); // left line
139  dev.dasharray(x0, y1, x1, y1); // bottom line
140  dev.dasharray(x1, y1, x1, y0); // right line
141  dev.dasharray(x0, y0, tl, y0); // top segment before text
142  dev.dasharray(tr, y0, x1, y0); // top segment after text
143 
144  // draw the label
145  dev.label(tl, y0, fText.c_str()); //
146 }
unsigned int outputs() const
Definition: schema.h:129
virtual point inputPoint(unsigned int i) const =0
virtual void draw(device &dev)=0
virtual point inputPoint(unsigned int i) const
Returns an input point.
virtual void label(double x, double y, const char *name)=0
unsigned int inputs() const
Definition: schema.h:128
double y() const
Definition: schema.h:139
double width() const
Definition: schema.h:126
double y
Definition: schema.h:43
schema * fSchema
bool placed() const
Definition: schema.h:137
double x() const
Definition: schema.h:138
double x
Definition: schema.h:42
Definition: schema.h:40
virtual point outputPoint(unsigned int i) const =0
double height() const
Definition: schema.h:127
virtual point outputPoint(unsigned int i) const
Returns an output point.
const double dLetter
width of a letter
Definition: schema.h:35
double min(double x, double y)
Definition: interval.hh:59
Tree tl(Tree l)
Definition: list.hh:134
virtual void dasharray(double x1, double y1, double x2, double y2)=0
virtual void trait(double x1, double y1, double x2, double y2)=0

Here is the call graph for this function:

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

Returns an input point.

Implements schema.

Definition at line 86 of file decorateSchema.cpp.

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

Referenced by collectTraits(), and draw().

87 {
88  assert (placed());
89  assert (i < inputs());
90  return fInputPoint[i];
91 }
unsigned int inputs() const
Definition: schema.h:128
bool placed() const
Definition: schema.h:137
vector< point > fInputPoint

Here is the call graph for this function:

Here is the caller graph for this function:

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

Returns an output point.

Implements schema.

Definition at line 96 of file decorateSchema.cpp.

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

Referenced by collectTraits(), and draw().

97 {
98  assert (placed());
99  assert (i < outputs());
100  return fOutputPoint[i];
101 }
unsigned int outputs() const
Definition: schema.h:129
bool placed() const
Definition: schema.h:137
vector< point > fOutputPoint

Here is the call graph for this function:

Here is the caller graph for this function:

void decorateSchema::place ( double  ox,
double  oy,
int  orientation 
)
virtual

Define the graphic position of the schema.

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 59 of file decorateSchema.cpp.

References schema::beginPlace(), schema::endPlace(), fInputPoint, fMargin, fOutputPoint, fSchema, schema::inputPoint(), schema::inputs(), kRightLeft, schema::outputPoint(), schema::outputs(), schema::place(), point::x, and point::y.

60 {
61  beginPlace(ox, oy, orientation);
62 
64 
65  double m = fMargin;
66  if (orientation == kRightLeft) {
67  m = -m;
68  }
69 
70  for (unsigned int i=0; i < inputs(); i++) {
71  point p = fSchema->inputPoint(i);
72  fInputPoint[i] = point(p.x-m, p.y); //, p.z);
73  }
74 
75  for (unsigned int i=0; i < outputs(); i++) {
76  point p = fSchema->outputPoint(i);
77  fOutputPoint[i] = point(p.x+m, p.y); //, p.z);
78  }
79 
80  endPlace();
81 }
void endPlace()
Definition: schema.h:134
unsigned int outputs() const
Definition: schema.h:129
virtual point inputPoint(unsigned int i) const =0
void beginPlace(double x, double y, int orientation)
Definition: schema.h:132
unsigned int inputs() const
Definition: schema.h:128
double y
Definition: schema.h:43
schema * fSchema
int orientation() const
Definition: schema.h:140
virtual void place(double x, double y, int orientation)=0
vector< point > fInputPoint
double x
Definition: schema.h:42
Definition: schema.h:40
virtual point outputPoint(unsigned int i) const =0
vector< point > fOutputPoint

Here is the call graph for this function:

Friends And Related Function Documentation

schema* makeDecorateSchema ( schema s1,
double  margin,
const string &  text 
)
friend

Creates a new decorated schema.

Definition at line 31 of file decorateSchema.cpp.

32 {
33  return new decorateSchema (s, margin, text);
34 }
decorateSchema(schema *s1, double margin, const string &text)
A decorateSchema is a schema surrounded by a dashed rectangle with a label on the top left...

Member Data Documentation

vector<point> decorateSchema::fInputPoint
private

Definition at line 39 of file decorateSchema.h.

Referenced by decorateSchema(), inputPoint(), and place().

double decorateSchema::fMargin
private

Definition at line 37 of file decorateSchema.h.

Referenced by draw(), and place().

vector<point> decorateSchema::fOutputPoint
private

Definition at line 40 of file decorateSchema.h.

Referenced by decorateSchema(), outputPoint(), and place().

schema* decorateSchema::fSchema
private

Definition at line 36 of file decorateSchema.h.

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

string decorateSchema::fText
private

Definition at line 38 of file decorateSchema.h.

Referenced by draw().


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