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 00023 #include "cableSchema.h" 00024 #include <assert.h> 00025 #include <iostream> 00026 00027 using namespace std; 00028 00032 schema* makeCableSchema (unsigned int n) 00033 { 00034 assert(n>0); 00035 return new cableSchema(n); 00036 } 00037 00038 00042 cableSchema::cableSchema (unsigned int n) 00043 : schema (n, n, 0, n*dWire) 00044 { 00045 for (unsigned int i=0; i<n; i++) fPoint.push_back(point(0)); 00046 } 00047 00048 00052 void cableSchema::place(double ox, double oy, int orientation) 00053 { 00054 beginPlace(ox, oy, orientation); 00055 if (orientation == kLeftRight) { 00056 for (unsigned int i=0; i<inputs(); i++) { 00057 fPoint[i] = point(ox, oy + dWire/2.0 + i*dWire); 00058 } 00059 } else { 00060 for (unsigned int i=0; i<inputs(); i++) { 00061 fPoint[i] = point(ox, oy + height() - dWire/2.0 - i*dWire); 00062 } 00063 } 00064 endPlace(); 00065 } 00066 00067 00068 00073 void cableSchema::draw(device& dev) 00074 { 00075 } 00076 00080 point cableSchema::inputPoint(unsigned int i) const 00081 { 00082 assert(i<inputs()); 00083 return fPoint[i]; 00084 } 00085 00089 point cableSchema::outputPoint(unsigned int i) const 00090 { 00091 assert(i<outputs()); 00092 return fPoint[i]; 00093 }