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 fX(0),
00079 fY(0),
00080 fOrientation(0)
00081 {}
00082 virtual ~schema() {}
00083
00084
00085 double width() const { return fWidth; }
00086 double height() const { return fHeight; }
00087 unsigned int inputs() const { return fInputs; }
00088 unsigned int outputs() const { return fOutputs; }
00089
00090
00091 void beginPlace (double x, double y, int orientation)
00092 { fX = x; fY = y; fOrientation = orientation; }
00093 void endPlace () { fPlaced = true; }
00094
00095
00096 bool placed() const { return fPlaced; }
00097 double x() const { return fX; }
00098 double y() const { return fY; }
00099 int orientation() const { return fOrientation; }
00100
00101
00102
00103 virtual void place(double x, double y, int orientation) = 0;
00104 virtual void draw(device& dev) = 0;
00105 virtual point inputPoint(unsigned int i) const = 0;
00106 virtual point outputPoint(unsigned int i)const = 0;
00107 };
00108
00109
00110
00111 schema* makeBlockSchema (unsigned int inputs,
00112 unsigned int outputs,
00113 const string& name,
00114 const string& color,
00115 const string& link);
00116
00117 schema* makeCableSchema (unsigned int n=1);
00118 schema* makeCutSchema ();
00119 schema* makeEnlargedSchema (schema* s, double width);
00120 schema* makeParSchema (schema* s1, schema* s2);
00121 schema* makeSeqSchema (schema* s1, schema* s2);
00122 schema* makeMergeSchema (schema* s1, schema* s2);
00123 schema* makeSplitSchema (schema* s1, schema* s2);
00124 schema* makeRecSchema (schema* s1, schema* s2);
00125 schema* makeTopSchema (schema* s1, double margin, const string& text, const string& link);
00126 schema* makeDecorateSchema (schema* s1, double margin, const string& text);
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 #endif
00137
00138