00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "splitSchema.h"
00024 #include <iostream>
00025 #include <assert.h>
00026
00027 using namespace std;
00028
00034 schema* makeSplitSchema (schema* s1, schema* s2)
00035 {
00036
00037 schema * a = makeEnlargedSchema(s1, dWire);
00038 schema * b = makeEnlargedSchema(s2, dWire);
00039
00040
00041 double hgap = (a->height()+b->height())/4;
00042
00043 return new splitSchema(a,b,hgap);
00044 }
00045
00046
00052 splitSchema::splitSchema (schema* s1, schema* s2, double hgap)
00053 : schema( s1->inputs(),
00054 s2->outputs(),
00055 s1->width() + s2->width() + hgap,
00056 max(s1->height(), s2->height()) ),
00057 fSchema1(s1),
00058 fSchema2(s2),
00059 fHorzGap(hgap)
00060 {
00061 }
00062
00063
00068 void splitSchema::place(double ox, double oy, int orientation)
00069 {
00070 beginPlace(ox, oy, orientation);
00071
00072 double dy1 = max(0.0, fSchema2->height()-fSchema1->height()) / 2.0;
00073 double dy2 = max(0.0, fSchema1->height()-fSchema2->height()) / 2.0;
00074
00075 if (orientation == kLeftRight) {
00076 fSchema1->place(ox, oy+dy1, orientation);
00077 fSchema2->place(ox+fSchema1->width()+fHorzGap, oy+dy2, orientation);
00078 } else {
00079 fSchema2->place(ox, oy+dy2, orientation);
00080 fSchema1->place(ox+fSchema2->width()+fHorzGap, oy+dy1, orientation);
00081 }
00082 endPlace();
00083 }
00084
00088 point splitSchema::inputPoint(unsigned int i) const
00089 {
00090 return fSchema1->inputPoint(i);
00091 }
00092
00093
00097 point splitSchema::outputPoint(unsigned int i) const
00098 {
00099 return fSchema2->outputPoint(i);
00100 }
00101
00102
00106 void splitSchema::draw(device& dev)
00107 {
00108 assert(placed());
00109
00110
00111 fSchema1->draw(dev);
00112 fSchema2->draw(dev);
00113
00114 unsigned int r = fSchema1->outputs();
00115 assert(r>0);
00116
00117
00118 for (unsigned int i=0; i<fSchema2->inputs(); i++) {
00119 point p = fSchema1->outputPoint(i%r);
00120 point q = fSchema2->inputPoint(i);
00121 dev.trait(p.x, p.y, q.x, q.y);
00122 }
00123 }
00124
00125