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

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

#include <topSchema.h>

Inheritance diagram for topSchema:
Inheritance graph
[legend]
Collaboration diagram for topSchema:
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
 Top schema has no input. More...
 
virtual point outputPoint (unsigned int i) const
 Top schema has no output. 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

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

Private Attributes

schemafSchema
 
double fMargin
 
string fText
 
string fLink
 
vector< pointfInputPoint
 
vector< pointfOutputPoint
 

Friends

schemamakeTopSchema (schema *s1, double margin, const string &text, const string &link)
 Creates a new top schema. More...
 

Detailed Description

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

The rectangle is placed at half the margin parameter. Arrows are added to all the outputs

Definition at line 34 of file topSchema.h.

Constructor & Destructor Documentation

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

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

The rectangle is placed at half the margin parameter. Arrows are added to the outputs. The constructor is made private to enforce the usage of makeTopSchema.

Definition at line 45 of file topSchema.cpp.

46  : schema(0, 0, s->width()+2*margin, s->height()+2*margin),
47  fSchema(s),
48  fMargin(margin),
49  fText(text),
50  fLink(link)
51 {
52 }
double fMargin
Definition: topSchema.h:37
string fLink
Definition: topSchema.h:39
double width() const
Definition: schema.h:126
string fText
Definition: topSchema.h:38
schema(unsigned int inputs, unsigned int outputs, double width, double height)
Definition: schema.h:113
schema * fSchema
Definition: topSchema.h:36
double height() const
Definition: schema.h:127

Member Function Documentation

void topSchema::collectTraits ( collector c)
virtual

Draw the enlarged schema.

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

Implements schema.

Definition at line 115 of file topSchema.cpp.

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

116 {
117  assert(placed());
119 
120  // draw arrows at output points of schema
121  for (unsigned int i=0; i<fSchema->inputs(); i++) {
122  point p = fSchema->inputPoint(i);
123  c.addOutput(p);;
124  }
125 
126  // draw arrows at output points of schema
127  for (unsigned int i=0; i<fSchema->outputs(); i++) {
128  point p = fSchema->outputPoint(i);
129  c.addInput(p);;
130  }
131 
132 
133 }
void addOutput(const point &p)
Definition: schema.h:82
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
bool placed() const
Definition: schema.h:137
Definition: schema.h:40
virtual point outputPoint(unsigned int i) const =0
schema * fSchema
Definition: topSchema.h:36
void addInput(const point &p)
Definition: schema.h:83

Here is the call graph for this function:

void topSchema::draw ( device dev)
virtual

Draw the enlarged schema.

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

Implements schema.

Definition at line 92 of file topSchema.cpp.

References schema::draw(), device::fleche(), fLink, fMargin, fSchema, fText, schema::height(), device::label(), schema::orientation(), schema::outputPoint(), schema::outputs(), schema::placed(), device::rect(), schema::width(), point::x, schema::x(), point::y, and schema::y().

93 {
94  assert(placed());
95 
96  // draw a background white rectangle
97  dev.rect(x(), y(), width()-1, height()-1, "#ffffff", fLink.c_str());
98 
99  // draw the label
100  dev.label(x()+fMargin, y()+fMargin/2, fText.c_str());
101 
102  fSchema->draw(dev);
103 
104  // draw arrows at output points of schema
105  for (unsigned int i=0; i<fSchema->outputs(); i++) {
106  point p = fSchema->outputPoint(i);
107  dev.fleche(p.x, p.y, 0, orientation());
108  }
109 }
unsigned int outputs() const
Definition: schema.h:129
double fMargin
Definition: topSchema.h:37
virtual void draw(device &dev)=0
string fLink
Definition: topSchema.h:39
virtual void label(double x, double y, const char *name)=0
double y() const
Definition: schema.h:139
double width() const
Definition: schema.h:126
double y
Definition: schema.h:43
virtual void rect(double x, double y, double l, double h, const char *color, const char *link)=0
bool placed() const
Definition: schema.h:137
double x() const
Definition: schema.h:138
int orientation() const
Definition: schema.h:140
string fText
Definition: topSchema.h:38
double x
Definition: schema.h:42
Definition: schema.h:40
virtual point outputPoint(unsigned int i) const =0
schema * fSchema
Definition: topSchema.h:36
double height() const
Definition: schema.h:127
virtual void fleche(double x, double y, double rotation, int sens)=0

Here is the call graph for this function:

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

Top schema has no input.

Implements schema.

Definition at line 71 of file topSchema.cpp.

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

72 {
73  assert (placed());
74  assert (i < inputs());
75  exit(1);
76 }
unsigned int inputs() const
Definition: schema.h:128
bool placed() const
Definition: schema.h:137

Here is the call graph for this function:

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

Top schema has no output.

Implements schema.

Definition at line 81 of file topSchema.cpp.

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

82 {
83  assert (placed());
84  assert (i < outputs());
85  exit(1);
86 }
unsigned int outputs() const
Definition: schema.h:129
bool placed() const
Definition: schema.h:137

Here is the call graph for this function:

void topSchema::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 60 of file topSchema.cpp.

References schema::beginPlace(), schema::endPlace(), fMargin, fSchema, and schema::place().

61 {
62  beginPlace(ox, oy, orientation);
63 
65  endPlace();
66 }
void endPlace()
Definition: schema.h:134
double fMargin
Definition: topSchema.h:37
void beginPlace(double x, double y, int orientation)
Definition: schema.h:132
int orientation() const
Definition: schema.h:140
virtual void place(double x, double y, int orientation)=0
schema * fSchema
Definition: topSchema.h:36

Here is the call graph for this function:

Friends And Related Function Documentation

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

Creates a new top schema.

Definition at line 33 of file topSchema.cpp.

34 {
35  return new topSchema (makeDecorateSchema(s, margin/2, text), margin/2, "", link);
36 }
topSchema(schema *s1, double margin, const string &text, const string &link)
A topSchema is a schema surrounded by a dashed rectangle with a label on the top left.
Definition: topSchema.cpp:45
schema * makeDecorateSchema(schema *s, double margin, const string &text)
Creates a new decorated schema.

Member Data Documentation

vector<point> topSchema::fInputPoint
private

Definition at line 40 of file topSchema.h.

string topSchema::fLink
private

Definition at line 39 of file topSchema.h.

Referenced by draw().

double topSchema::fMargin
private

Definition at line 37 of file topSchema.h.

Referenced by draw(), and place().

vector<point> topSchema::fOutputPoint
private

Definition at line 41 of file topSchema.h.

schema* topSchema::fSchema
private

Definition at line 36 of file topSchema.h.

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

string topSchema::fText
private

Definition at line 38 of file topSchema.h.

Referenced by draw().


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