blockSchema Class Reference

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

#include <blockSchema.h>

Inherits schema.

Collaboration diagram for blockSchema:
[legend]

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) const
 Returns an input point.
virtual point outputPoint (unsigned int i) const
 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< pointfInputPoint
 input connection points
vector< pointfOutputPoint
 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(), drawText(), and schema::placed().

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

Here is the call graph for this function:

void blockSchema::drawInputWires ( device dev  )  [private]

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

Definition at line 234 of file blockSchema.cpp.

References dHorz, fInputPoint, device::fleche(), schema::inputs(), kLeftRight, schema::orientation(), device::trait(), point::x, and point::y.

Referenced by draw().

00235 {
00236     double dx = (orientation() == kLeftRight) ? dHorz : -dHorz;
00237 
00238     for (unsigned int i=0; i<inputs(); i++) {
00239         point p = fInputPoint[i];
00240         dev.trait(p.x, p.y, p.x+dx, p.y);
00241         dev.fleche(p.x+dx, p.y, 0, orientation());
00242     }
00243 }

Here is the call graph for this function:

Here is the caller graph for this function:

void blockSchema::drawOrientationMark ( device dev  )  [private]

Draw the orientation mark, a small point that indicates the first input (like integrated circuits).

Definition at line 215 of file blockSchema.cpp.

References dHorz, dVert, schema::height(), kLeftRight, device::markSens(), schema::orientation(), schema::width(), schema::x(), and schema::y().

Referenced by draw().

00216 {
00217     double px, py;
00218 
00219     if (orientation() == kLeftRight) {
00220         px = x() + dHorz;
00221         py = y() + dVert;
00222     } else {
00223         px = x() + width() - dHorz;
00224         py = y() + height() - dVert;
00225     }
00226 
00227     dev.markSens( px, py, orientation() );
00228 }

Here is the call graph for this function:

Here is the caller graph for this function:

void blockSchema::drawOutputWires ( device dev  )  [private]

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

Definition at line 249 of file blockSchema.cpp.

References dHorz, fOutputPoint, kLeftRight, schema::orientation(), schema::outputs(), device::trait(), point::x, and point::y.

Referenced by draw().

00250 {
00251     double dx = (orientation() == kLeftRight) ? dHorz : -dHorz;
00252 
00253     for (unsigned int i=0; i<outputs(); i++) {
00254         point p = fOutputPoint[i];
00255         dev.trait(p.x, p.y, p.x-dx, p.y);
00256     }
00257 }

Here is the call graph for this function:

Here is the caller graph for this function:

void blockSchema::drawRectangle ( device dev  )  [private]

Draw the colored rectangle with the optional link.

Definition at line 188 of file blockSchema.cpp.

References dHorz, dVert, fColor, fLink, schema::height(), device::rect(), schema::width(), schema::x(), and schema::y().

Referenced by draw().

00189 {
00190     dev.rect(   x() + dHorz,
00191                 y() + dVert,
00192                 width() - 2*dHorz,
00193                 height() - 2*dVert,
00194                 fColor.c_str(),
00195                 fLink.c_str()
00196             );
00197 }

Here is the call graph for this function:

Here is the caller graph for this function:

void blockSchema::drawText ( device dev  )  [private]

Draw the text centered on the box.

Definition at line 203 of file blockSchema.cpp.

References fText, schema::height(), device::text(), schema::width(), schema::x(), and schema::y().

Referenced by draw().

00204 {
00205     dev.text(   x() + width()/2,
00206                 y() + height()/2,
00207                 fText.c_str()
00208             );
00209 }

Here is the call graph for this function:

Here is the caller graph for this function:

point blockSchema::inputPoint ( unsigned int  i  )  const [virtual]

Returns an input point.

Implements schema.

Definition at line 95 of file blockSchema.cpp.

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

00096 {
00097     assert (placed());
00098     assert (i < inputs());
00099     return fInputPoint[i];
00100 }

Here is the call graph for this function:

point blockSchema::outputPoint ( unsigned int  i  )  const [virtual]

Returns an output point.

Implements schema.

Definition at line 105 of file blockSchema.cpp.

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

00106 {
00107     assert (placed());
00108     assert (i < outputs());
00109     return fOutputPoint[i];
00110 }

Here is the call graph for this function:

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 schema::beginPlace(), schema::endPlace(), placeInputPoints(), and placeOutputPoints().

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

Here is the call graph for this function:

void blockSchema::placeInputPoints (  )  [private]

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

Definition at line 116 of file blockSchema.cpp.

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

Referenced by place().

00117 {
00118     int     N = inputs();
00119 
00120     if (orientation() == kLeftRight) {
00121 
00122         double  px = x();
00123         double  py = y() + (height() - dWire*(N-1))/2;
00124 
00125         for (int i=0; i<N; i++) {
00126             fInputPoint[i] = point(px, py+i*dWire);
00127         }
00128 
00129     } else {
00130 
00131         double px = x() + width();
00132         double py = y() + height() - (height() - dWire*(N-1))/2;
00133 
00134         for (int i=0; i<N; i++) {
00135             fInputPoint[i] = point(px, py-i*dWire);
00136         }
00137     }
00138 }

Here is the call graph for this function:

Here is the caller graph for this function:

void blockSchema::placeOutputPoints (  )  [private]

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

Definition at line 145 of file blockSchema.cpp.

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

Referenced by place().

00146 {
00147     int N = outputs();
00148 
00149     if (orientation() == kLeftRight) {
00150 
00151         double px = x() + width();
00152         double py = y() + (height() - dWire*(N-1))/2;
00153 
00154         for (int i=0; i<N; i++) {
00155             fOutputPoint[i] = point(px, py + i*dWire);
00156         }
00157 
00158     } else {
00159 
00160         double px = x();
00161         double py = y() + height() - (height() - dWire*(N-1))/2;
00162 
00163         for (int i=0; i<N; i++) {
00164             fOutputPoint[i] = point(px, py - i*dWire);
00165         }
00166     }
00167 }

Here is the call graph for this function:

Here is the caller graph for this function:


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 }


Member Data Documentation

const string blockSchema::fColor [private]

color of the box

Definition at line 39 of file blockSchema.h.

Referenced by drawRectangle().

vector<point> blockSchema::fInputPoint [private]

input connection points

Definition at line 43 of file blockSchema.h.

Referenced by blockSchema(), drawInputWires(), inputPoint(), and placeInputPoints().

const string blockSchema::fLink [private]

option URL link

Definition at line 40 of file blockSchema.h.

Referenced by drawRectangle().

vector<point> blockSchema::fOutputPoint [private]

output connection points

Definition at line 44 of file blockSchema.h.

Referenced by blockSchema(), drawOutputWires(), outputPoint(), and placeOutputPoints().

const string blockSchema::fText [private]

Text to be displayed.

Definition at line 38 of file blockSchema.h.

Referenced by drawText().


The documentation for this class was generated from the following files:
Generated on Thu Jul 15 16:15:54 2010 for FAUST compiler by  doxygen 1.6.3