00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <stdlib.h>
00023 #include "topSchema.h"
00024 #include <iostream>
00025 #include <assert.h>
00026 #include <cstdlib>
00027
00028 using namespace std;
00029
00033 schema* makeTopSchema (schema* s, double margin, const string& text, const string& link)
00034 {
00035 return new topSchema (makeDecorateSchema(s, margin/2, text), margin/2, "", link);
00036 }
00037
00038
00045 topSchema::topSchema( schema* s, double margin, const string& text, const string& link )
00046 : schema(0, 0, s->width()+2*margin, s->height()+2*margin),
00047 fSchema(s),
00048 fMargin(margin),
00049 fText(text),
00050 fLink(link)
00051 {
00052 }
00053
00054
00060 void topSchema::place(double ox, double oy, int orientation)
00061 {
00062 beginPlace(ox, oy, orientation);
00063
00064 fSchema->place(ox+fMargin, oy+fMargin, orientation);
00065 endPlace();
00066 }
00067
00071 point topSchema::inputPoint(unsigned int i) const
00072 {
00073 assert (placed());
00074 assert (i < inputs());
00075 exit(1);
00076 }
00077
00081 point topSchema::outputPoint(unsigned int i) const
00082 {
00083 assert (placed());
00084 assert (i < outputs());
00085 exit(1);
00086 }
00087
00092 void topSchema::draw(device& dev)
00093 {
00094 assert(placed());
00095
00096
00097 dev.rect(x(), y(), width()-1, height()-1, "#ffffff", fLink.c_str());
00098
00099
00100 dev.label(x()+fMargin, y()+fMargin/2, fText.c_str());
00101
00102 fSchema->draw(dev);
00103
00104
00105 for (unsigned int i=0; i<fSchema->outputs(); i++) {
00106 point p = fSchema->outputPoint(i);
00107 dev.fleche(p.x, p.y, 0, orientation());
00108 }
00109 }