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