blockSchema Class Reference

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

#include <blockSchema.h>

Inheritance diagram for blockSchema:

schema

List of all members.

Public Member Functions

virtual void place (double x, double y, int orientation)
 Define the graphic position of the blockSchema.
virtual void draw (device &dev)
 Draw the blockSchema on the device.
virtual point inputPoint (unsigned int i)
 Returns an input point.
virtual point outputPoint (unsigned int i)
 Returns an output point.

Private Member Functions

 blockSchema (unsigned int inputs, unsigned int outputs, double width, double height, const string &name, const string &color, const string &link)
 Build a simple colored blockSchema with a certain number of inputs and outputs, a text to be displayed, and an optional link.
void placeInputPoints ()
 Computes the input points according to the position and the orientation of the blockSchema.
void placeOutputPoints ()
 Computes the output points according to the position and the orientation of the blockSchema.
void drawRectangle (device &dev)
 Draw the colored rectangle with the optional link.
void drawText (device &dev)
 Draw the text centered on the box.
void drawOrientationMark (device &dev)
 Draw the orientation mark, a small point that indicates the first input (like integrated circuits).
void drawInputWires (device &dev)
 Draw horizontal arrows from the input points to the blockSchema rectangle.
void drawOutputWires (device &dev)
 Draw horizontal line from the blockSchema rectangle to the output points.

Private Attributes

const string fText
 Text to be displayed.
const string fColor
 color of the box
const string fLink
 option URL link
vector< point > fInputPoint
 input connection points
vector< point > fOutputPoint
 output connection points

Friends

schemamakeBlockSchema (unsigned int inputs, unsigned int outputs, const string &name, const string &color, const string &link)
 Build a simple colored blockSchema with a certain number of inputs and outputs, a text to be displayed, and an optional link.


Detailed Description

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

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

Definition at line 35 of file blockSchema.h.


Constructor & Destructor Documentation

blockSchema::blockSchema ( unsigned int  inputs,
unsigned int  outputs,
double  width,
double  height,
const string &  text,
const string &  color,
const string &  link 
) [private]

Build a simple colored blockSchema with a certain number of inputs and outputs, a text to be displayed, and an optional link.

The length of the text as well as th number of inputs and outputs are used to compute the size of the blockSchema

Definition at line 60 of file blockSchema.cpp.

References fInputPoint, and fOutputPoint.

00068     :   schema( inputs, outputs, width, height ),
00069         fText(text),
00070         fColor(color),
00071         fLink(link)
00072 {
00073     for (unsigned int i=0; i<inputs; i++)   fInputPoint.push_back(point(0));
00074     for (unsigned int i=0; i<outputs; i++)  fOutputPoint.push_back(point(0));
00075 }


Member Function Documentation

void blockSchema::draw ( device &  dev  )  [virtual]

Draw the blockSchema on the device.

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

Implements schema.

Definition at line 174 of file blockSchema.cpp.

References drawInputWires(), drawOrientationMark(), drawOutputWires(), drawRectangle(), and drawText().

00175 {
00176     assert(placed());
00177 
00178     drawRectangle(dev);
00179     drawText(dev);
00180     drawOrientationMark(dev);
00181     drawInputWires(dev);
00182     drawOutputWires(dev);
00183 }

void blockSchema::place ( double  x,
double  y,
int  orientation 
) [virtual]

Define the graphic position of the blockSchema.

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 82 of file blockSchema.cpp.

References placeInputPoints(), and placeOutputPoints().

00083 {
00084     beginPlace(x, y, orientation);
00085 
00086     placeInputPoints();
00087     placeOutputPoints();
00088 
00089     endPlace();
00090 }


Friends And Related Function Documentation

schema* makeBlockSchema ( unsigned int  inputs,
unsigned int  outputs,
const string &  name,
const string &  color,
const string &  link 
) [friend]

Build a simple colored blockSchema with a certain number of inputs and outputs, a text to be displayed, and an optional link.

Computes the size of the box according to the length of the text and the maximum number of ports.

Definition at line 40 of file blockSchema.cpp.

00045 {
00046     // determine the optimal size of the box
00047     double minimal = 3*dWire;
00048     double w = 2*dHorz + max( minimal, quantize(text.size()) );
00049     double h = 2*dVert + max( minimal, max(inputs, outputs) * dWire );
00050 
00051     return new blockSchema(inputs, outputs, w, h, text, color, link);
00052 }


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

Generated on Sat Jul 25 13:26:42 2009 for FAUST compiler by  doxygen 1.5.9