A decorateSchema is a schema surrounded by a dashed rectangle with a label on the top left. More...
#include <decorateSchema.h>
Inherits schema.
Public Member Functions | |
virtual void | place (double ox, double oy, int orientation) |
Define the graphic position of the schema. | |
virtual void | draw (device &dev) |
Draw the enlarged schema. | |
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 | |
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. | |
Private Attributes | |
schema * | fSchema |
double | fMargin |
string | fText |
vector< point > | fInputPoint |
vector< point > | fOutputPoint |
Friends | |
schema * | makeDecorateSchema (schema *s1, double margin, const string &text) |
Creates a new decorated schema. |
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.
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().
00044 : schema(s->inputs(), s->outputs(), s->width()+2*margin, s->height()+2*margin), 00045 fSchema(s), 00046 fMargin(margin), 00047 fText(text) 00048 { 00049 for (unsigned int i=0; i<inputs(); i++) fInputPoint.push_back(point(0)); 00050 for (unsigned int i=0; i<outputs(); i++) fOutputPoint.push_back(point(0)); 00051 }
void decorateSchema::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 107 of file decorateSchema.cpp.
References device::dasharray(), dLetter, schema::draw(), fMargin, fSchema, fText, schema::height(), schema::inputPoint(), inputPoint(), schema::inputs(), device::label(), min(), schema::outputPoint(), outputPoint(), schema::outputs(), schema::placed(), tl(), device::trait(), schema::width(), schema::x(), point::x, schema::y(), and point::y.
00108 { 00109 assert(placed()); 00110 00111 fSchema->draw(dev); 00112 00113 // draw enlarge input wires 00114 for (unsigned int i=0; i<inputs(); i++) { 00115 point p = inputPoint(i); 00116 point q = fSchema->inputPoint(i); 00117 dev.trait(p.x, p.y, q.x, q.y); 00118 } 00119 00120 // draw enlarge output wires 00121 for (unsigned int i=0; i<outputs(); i++) { 00122 point p = outputPoint(i); 00123 point q = fSchema->outputPoint(i); 00124 dev.trait(p.x, p.y, q.x, q.y); 00125 } 00126 00127 // define the coordinates of the frame 00128 double tw = (2+fText.size())*dLetter*0.75; 00129 double x0 = x() + fMargin/2; // left 00130 double y0 = y() + fMargin/2; // top 00131 double x1 = x() + width() - fMargin/2; // right 00132 double y1 = y() + height() - fMargin/2; // bottom 00133 //double tl = x0 + 2*dWire; // left of text zone 00134 double tl = x() + fMargin; // left of text zone 00135 double tr = min(tl+tw, x1); // right of text zone 00136 00137 // draw the surronding frame 00138 dev.dasharray(x0, y0, x0, y1); // left line 00139 dev.dasharray(x0, y1, x1, y1); // bottom line 00140 dev.dasharray(x1, y1, x1, y0); // right line 00141 dev.dasharray(x0, y0, tl, y0); // top segment before text 00142 dev.dasharray(tr, y0, x1, y0); // top segment after text 00143 00144 // draw the label 00145 dev.label(tl, y0, fText.c_str()); // 00146 }
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 draw().
00087 { 00088 assert (placed()); 00089 assert (i < inputs()); 00090 return fInputPoint[i]; 00091 }
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 draw().
00097 { 00098 assert (placed()); 00099 assert (i < outputs()); 00100 return fOutputPoint[i]; 00101 }
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.
00060 { 00061 beginPlace(ox, oy, orientation); 00062 00063 fSchema->place(ox+fMargin, oy+fMargin, orientation); 00064 00065 double m = fMargin; 00066 if (orientation == kRightLeft) { 00067 m = -m; 00068 } 00069 00070 for (unsigned int i=0; i < inputs(); i++) { 00071 point p = fSchema->inputPoint(i); 00072 fInputPoint[i] = point(p.x-m, p.y); 00073 } 00074 00075 for (unsigned int i=0; i < outputs(); i++) { 00076 point p = fSchema->outputPoint(i); 00077 fOutputPoint[i] = point(p.x+m, p.y); 00078 } 00079 00080 endPlace(); 00081 }
Creates a new decorated schema.
Definition at line 31 of file decorateSchema.cpp.
00032 { 00033 return new decorateSchema (s, margin, text); 00034 }
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.
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.
string decorateSchema::fText [private] |
Definition at line 38 of file decorateSchema.h.
Referenced by draw().