X-Git-Url: https://scm.cri.ensmp.fr/git/Faustine.git/blobdiff_plain/c7f552fd8888da2f0d8cfb228fe0f28d3df3a12c..b4b6f2ea75b9f0f3ca918f5b84016610bf7a4d4f:/interpretor/preprocessor/faust-0.9.47mr3/compiler/draw/schema/enlargedSchema.cpp diff --git a/interpretor/preprocessor/faust-0.9.47mr3/compiler/draw/schema/enlargedSchema.cpp b/interpretor/preprocessor/faust-0.9.47mr3/compiler/draw/schema/enlargedSchema.cpp new file mode 100644 index 0000000..53e523e --- /dev/null +++ b/interpretor/preprocessor/faust-0.9.47mr3/compiler/draw/schema/enlargedSchema.cpp @@ -0,0 +1,152 @@ +/************************************************************************ + ************************************************************************ + FAUST compiler + Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale + --------------------------------------------------------------------- + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + ************************************************************************ + ************************************************************************/ + +#include "enlargedSchema.h" +#include +#include + +using namespace std; + +/** + * Returns an enlarged schema, but only if really needed + * that is if the requiered width is greater that the schema width. + */ +schema* makeEnlargedSchema ( schema* s, double width ) +{ + if (width > s->width()) { + return new enlargedSchema(s, width); + } else { + return s; + } +} + +/** + * Put additional space left and right of a schema so that the result has + * a certain width. The wires are prolonged accordingly. + */ +enlargedSchema::enlargedSchema( schema* s, double width ) + : schema(s->inputs(), s->outputs(), width, s->height()), + fSchema(s) +{ + for (unsigned int i=0; iwidth())/2; + fSchema->place(ox+dx, oy, orientation); + + if (orientation == kRightLeft) { + dx = -dx; + } + + for (unsigned int i=0; i < inputs(); i++) { + point p = fSchema->inputPoint(i); + fInputPoint[i] = point(p.x-dx, p.y); //, p.z); + } + + for (unsigned int i=0; i < outputs(); i++) { + point p = fSchema->outputPoint(i); + fOutputPoint[i] = point(p.x+dx, p.y); //, p.z); + } + + endPlace(); +} + +/** + * Returns an input point + */ +point enlargedSchema::inputPoint(unsigned int i) const +{ + assert (placed()); + assert (i < inputs()); + return fInputPoint[i]; +} + +/** + * Returns an output point + */ +point enlargedSchema::outputPoint(unsigned int i) const +{ + assert (placed()); + assert (i < outputs()); + return fOutputPoint[i]; +} + +/** + * Draw the enlarged schema. This methos can only + * be called after the block have been placed + */ +void enlargedSchema::draw(device& dev) +{ + assert(placed()); + + fSchema->draw(dev); +#if 0 + // draw enlarge input wires + for (unsigned int i=0; iinputPoint(i); + if ( (p.z>=0) && (q.z>=0) ) dev.trait(p.x, p.y, q.x, q.y); + } + + // draw enlarge output wires + for (unsigned int i=0; ioutputPoint(i); + if ( (p.z>=0) && (q.z>=0) ) dev.trait(p.x, p.y, q.x, q.y); + } +#endif +} + +/** + * Draw the enlarged schema. This methos can only + * be called after the block have been placed + */ +void enlargedSchema::collectTraits(collector& c) +{ + assert(placed()); + + fSchema->collectTraits(c); + + // draw enlarge input wires + for (unsigned int i=0; iinputPoint(i); + c.addTrait(trait(p,q)); // in->out direction + } + + // draw enlarge output wires + for (unsigned int i=0; ioutputPoint(i); + point p = outputPoint(i); + c.addTrait(trait(q,p)); // in->out direction + } +}