Place and connect two diagrams in merge composition. More...
#include <mergeSchema.h>
Inherits schema.
Public Member Functions | |
virtual void | place (double ox, double oy, int orientation) |
Places the two subschema horizontaly, centered, with enough gap for the connections. | |
virtual void | draw (device &dev) |
Draw the two sub schema and the connections between them. | |
virtual point | inputPoint (unsigned int i) const |
The inputs of s1 :> s2 are the inputs of s1. | |
virtual point | outputPoint (unsigned int i) const |
The outputs of s1 :> s2 are the outputs of s2. | |
Private Member Functions | |
mergeSchema (schema *s1, schema *s2, double hgap) | |
Constructor for a merge schema s1 :> s2 where the outputs of s1 are merged to the inputs of s2. | |
Private Attributes | |
schema * | fSchema1 |
schema * | fSchema2 |
double | fHorzGap |
Friends | |
schema * | makeMergeSchema (schema *s1, schema *s2) |
Creates a new merge schema. |
Place and connect two diagrams in merge composition.
Definition at line 33 of file mergeSchema.h.
Constructor for a merge schema s1 :> s2 where the outputs of s1 are merged to the inputs of s2.
The constructor is private in order to enforce the usage of makeMergeSchema
Definition at line 50 of file mergeSchema.cpp.
void mergeSchema::draw | ( | device & | dev | ) | [virtual] |
Draw the two sub schema and the connections between them.
Implements schema.
Definition at line 105 of file mergeSchema.cpp.
References schema::draw(), fSchema1, fSchema2, schema::inputPoint(), schema::inputs(), schema::outputPoint(), schema::outputs(), schema::placed(), device::trait(), point::x, and point::y.
00106 { 00107 assert(placed()); 00108 00109 // draw the two subdiagrams 00110 fSchema1->draw(dev); 00111 fSchema2->draw(dev); 00112 00113 unsigned int r = fSchema2->inputs(); 00114 assert(r>0); 00115 00116 // draw the connections between them 00117 for (unsigned int i=0; i<fSchema1->outputs(); i++) { 00118 point p = fSchema1->outputPoint(i); 00119 point q = fSchema2->inputPoint(i%r); 00120 dev.trait(p.x, p.y, q.x, q.y); 00121 } 00122 }
point mergeSchema::inputPoint | ( | unsigned int | i | ) | const [virtual] |
The inputs of s1 :> s2 are the inputs of s1.
Implements schema.
Definition at line 87 of file mergeSchema.cpp.
References fSchema1, and schema::inputPoint().
00088 { 00089 return fSchema1->inputPoint(i); 00090 }
point mergeSchema::outputPoint | ( | unsigned int | i | ) | const [virtual] |
The outputs of s1 :> s2 are the outputs of s2.
Implements schema.
Definition at line 96 of file mergeSchema.cpp.
References fSchema2, and schema::outputPoint().
00097 { 00098 return fSchema2->outputPoint(i); 00099 }
void mergeSchema::place | ( | double | ox, | |
double | oy, | |||
int | orientation | |||
) | [virtual] |
Places the two subschema horizontaly, centered, with enough gap for the connections.
Implements schema.
Definition at line 66 of file mergeSchema.cpp.
References schema::beginPlace(), schema::endPlace(), fHorzGap, fSchema1, fSchema2, schema::height(), kLeftRight, max(), schema::place(), and schema::width().
00067 { 00068 beginPlace(ox, oy, orientation); 00069 00070 double dy1 = max(0.0, fSchema2->height()-fSchema1->height()) / 2.0; 00071 double dy2 = max(0.0, fSchema1->height()-fSchema2->height()) / 2.0; 00072 00073 if (orientation == kLeftRight) { 00074 fSchema1->place(ox, oy+dy1, orientation); 00075 fSchema2->place(ox+fSchema1->width()+fHorzGap, oy+dy2, orientation); 00076 } else { 00077 fSchema2->place(ox, oy+dy2, orientation); 00078 fSchema1->place(ox+fSchema2->width()+fHorzGap, oy+dy1, orientation); 00079 } 00080 endPlace(); 00081 }
Creates a new merge schema.
Cables are enlarged to dWire. The horizontal gap between the two subschema is such that the connections are not too slopy.
Definition at line 35 of file mergeSchema.cpp.
00036 { 00037 // avoid ugly diagram by ensuring at least dWire width 00038 schema * a = makeEnlargedSchema(s1, dWire); 00039 schema * b = makeEnlargedSchema(s2, dWire); 00040 double hgap = (a->height()+b->height())/4; 00041 return new mergeSchema(a,b,hgap); 00042 }
double mergeSchema::fHorzGap [private] |
Definition at line 37 of file mergeSchema.h.
Referenced by place().
schema* mergeSchema::fSchema1 [private] |
Definition at line 35 of file mergeSchema.h.
Referenced by draw(), inputPoint(), and place().
schema* mergeSchema::fSchema2 [private] |
Definition at line 36 of file mergeSchema.h.
Referenced by draw(), outputPoint(), and place().