|
FAUST compiler
0.9.9.6b8
|
00001 /************************************************************************ 00002 ************************************************************************ 00003 FAUST compiler 00004 Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale 00005 --------------------------------------------------------------------- 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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 // draw a background white rectangle 00097 dev.rect(x(), y(), width()-1, height()-1, "#ffffff", fLink.c_str()); 00098 00099 // draw the label 00100 dev.label(x()+fMargin, y()+fMargin/2, fText.c_str()); 00101 00102 fSchema->draw(dev); 00103 00104 // draw arrows at output points of schema 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 } 00110 00115 void topSchema::collectTraits(collector& c) 00116 { 00117 assert(placed()); 00118 fSchema->collectTraits(c); 00119 00120 // draw arrows at output points of schema 00121 for (unsigned int i=0; i<fSchema->inputs(); i++) { 00122 point p = fSchema->inputPoint(i); 00123 c.addOutput(p);; 00124 } 00125 00126 // draw arrows at output points of schema 00127 for (unsigned int i=0; i<fSchema->outputs(); i++) { 00128 point p = fSchema->outputPoint(i); 00129 c.addInput(p);; 00130 } 00131 00132 00133 }
1.8.0