00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __SCHEMA__
00023 #define __SCHEMA__
00024
00025
00026 #include "device.h"
00027 #include <vector>
00028 #include <string>
00029
00030 using namespace std;
00031
00032 const double dWire = 8;
00033
00034 const double dLetter = 4.3;
00035 const double dHorz = 4;
00036 const double dVert = 4;
00037
00038
00039 struct point
00040 {
00041 double x;
00042 double y;
00043
00044 point() : x(0.0), y(0.0) {}
00045 point(double f) : x(f),y(f) {}
00046 point(double u, double v) : x(u), y(v) {}
00047 point(const point& p) : x(p.x), y(p.y) {}
00048 };
00049
00050 enum { kLeftRight=1, kRightLeft=-1 };
00051
00052
00056 class schema
00057 {
00058 private:
00059 const unsigned int fInputs;
00060 const unsigned int fOutputs;
00061 const double fWidth;
00062 const double fHeight;
00063
00064
00065 bool fPlaced;
00066 double fX;
00067 double fY;
00068 int fOrientation;
00069
00070 public:
00071
00072 schema(unsigned int inputs, unsigned int outputs, double width, double height)
00073 : fInputs(inputs),
00074 fOutputs(outputs),
00075 fWidth(width),
00076 fHeight(height),
00077 fPlaced(false)
00078 {}
00079 virtual ~schema() {}
00080
00081
00082 double width() { return fWidth; }
00083 double height() { return fHeight; }
00084 unsigned int inputs() { return fInputs; }
00085 unsigned int outputs() { return fOutputs; }
00086
00087
00088 void beginPlace (double x, double y, int orientation)
00089 { fX = x; fY = y; fOrientation = orientation; }
00090 void endPlace () { fPlaced = true; }
00091
00092
00093 bool placed() { return fPlaced; }
00094 double x() { return fX; }
00095 double y() { return fY; }
00096 int orientation() { return fOrientation; }
00097
00098
00099
00100 virtual void place(double x, double y, int orientation) = 0;
00101 virtual void draw(device& dev) = 0;
00102 virtual point inputPoint(unsigned int i) = 0;
00103 virtual point outputPoint(unsigned int i) = 0;
00104 };
00105
00106
00107
00108 schema* makeBlockSchema (unsigned int inputs,
00109 unsigned int outputs,
00110 const string& name,
00111 const string& color,
00112 const string& link);
00113
00114 schema* makeCableSchema (unsigned int n=1);
00115 schema* makeCutSchema ();
00116 schema* makeEnlargedSchema (schema* s, double width);
00117 schema* makeParSchema (schema* s1, schema* s2);
00118 schema* makeSeqSchema (schema* s1, schema* s2);
00119 schema* makeMergeSchema (schema* s1, schema* s2);
00120 schema* makeSplitSchema (schema* s1, schema* s2);
00121 schema* makeRecSchema (schema* s1, schema* s2);
00122 schema* makeTopSchema (schema* s1, double margin, const string& text, const string& link);
00123 schema* makeDecorateSchema (schema* s1, double margin, const string& text);
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 #endif
00134
00135