~ubuntu-branches/ubuntu/feisty/faust/feisty

« back to all changes in this revision

Viewing changes to compiler/draw/reprParam.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mario Lang
  • Date: 2006-10-09 11:05:30 UTC
  • mfrom: (1.1.1 upstream) (2.1.1 edgy)
  • Revision ID: james.westby@ubuntu.com-20061009110530-zvktdvpq5zewdxso
Tags: 0.9.8-1
* New upstream release.
* Upgrade Standards-Version to 3.7.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/************************************************************************
2
 
 ************************************************************************
3
 
    FAUST compiler
4
 
        Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale
5
 
    ---------------------------------------------------------------------
6
 
    This program is free software; you can redistribute it and/or modify
7
 
    it under the terms of the GNU General Public License as published by
8
 
    the Free Software Foundation; either version 2 of the License, or
9
 
    (at your option) any later version.
10
 
 
11
 
    This program is distributed in the hope that it will be useful,
12
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
    GNU General Public License for more details.
15
 
 
16
 
    You should have received a copy of the GNU General Public License
17
 
    along with this program; if not, write to the Free Software
18
 
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
 
 ************************************************************************
20
 
 ************************************************************************/
21
 
 
22
 
 
23
 
 
24
 
// reprParam.cpp
25
 
 
26
 
#include "reprParam.h"
27
 
#include <iostream>
28
 
#include <string.h>
29
 
#include <complex> //for arctan()
30
 
 
31
 
reprParam::reprParam(const char* _nom,float l,float h,vector<float> i,vector<float> o) // in and out param
32
 
{
33
 
        nom=_nom;
34
 
        largeur=l;
35
 
        hauteur=h;
36
 
        ins=i;
37
 
        outs=o;
38
 
}
39
 
 
40
 
void reprParam::draw(device& dev,vector<wire*>& allWires,float x,float y,vector<wire*> wi,vector<wire*> wo,int sens)
41
 
{
42
 
        int i,j;
43
 
        float pente=0;
44
 
        if(sens == 1) //sens +
45
 
        {
46
 
                dev.rect(x,y,largeur,hauteur);
47
 
                for(i=0;i<(int)ins.size();i++)
48
 
                        {
49
 
                                dev.rond(x,y+ins[i],rayonIO);
50
 
 
51
 
                                if(wi.size() != 0)
52
 
                                {
53
 
                                        if(wi[i]->getLinkedToSize() != 0 && (int)wi[i]->getLSeg().size()==1) // -> merge
54
 
                                                for(j=0;j<wi[i]->getLinkedToSize();j++)
55
 
                                                {
56
 
                                                        if(wi[i]->getLinkedTo(j)->getLastSegment().x2-wi[i]->getLinkedTo(j)->getLastSegment().x1 != 0)
57
 
                                                        {
58
 
                                                                pente=(wi[i]->getLinkedTo(j)->getLastSegment().y2-wi[i]->getLinkedTo(j)->getLastSegment().y1)/(wi[i]->getLinkedTo(j)->getLastSegment().x2-wi[i]->getLinkedTo(j)->getLastSegment().x1);
59
 
                                                                dev.fleche(x,y+ins[i],atan(pente)*360/(2*3.1415926),sens);
60
 
                                                        }
61
 
                                                }       
62
 
                                        else if(wi[i]->getLastSegment().x2-wi[i]->getLastSegment().x1 != 0)
63
 
                                        {
64
 
                                                pente=(wi[i]->getLastSegment().y2-wi[i]->getLastSegment().y1)/(wi[i]->getLastSegment().x2-wi[i]->getLastSegment().x1);
65
 
                                                dev.fleche(x,y+ins[i],atan(pente)*360/(2*3.1415926),sens);
66
 
                                        }       
67
 
                                }
68
 
                        }
69
 
 
70
 
                for(i=0;i<(int)outs.size();i++)
71
 
                        dev.rond(x+largeur,y+outs[i],rayonIO);
72
 
 
73
 
                        // mark for sens:
74
 
                dev.markSens(x,y,sens);
75
 
 
76
 
                // display name:
77
 
                dev.text(x+largeur/2,y+hauteur/2,nom);
78
 
     }
79
 
        else //sens -
80
 
        {
81
 
                dev.rect(x-largeur,y-hauteur,largeur,hauteur);
82
 
                for(i=0;i<(int)ins.size();i++)
83
 
                        {
84
 
                                dev.rond(x,y-ins[i],rayonIO);
85
 
                                
86
 
                                if(wi.size() != 0)
87
 
                                {
88
 
                                        if(wi[i]->getLinkedToSize() != 0 && (int)wi[i]->getLSeg().size()==1) // -> merge
89
 
                                                for(j=0;j<wi[i]->getLinkedToSize();j++)
90
 
                                                {
91
 
                                                        if(wi[i]->getLinkedTo(j)->getLastSegment().x2-wi[i]->getLinkedTo(j)->getLastSegment().x1 != 0)
92
 
                                                        {
93
 
                                                                pente=(wi[i]->getLinkedTo(j)->getLastSegment().y2-wi[i]->getLinkedTo(j)->getLastSegment().y1)/(wi[i]->getLinkedTo(j)->getLastSegment().x2-wi[i]->getLinkedTo(j)->getLastSegment().x1);
94
 
                                                                dev.fleche(x,y-ins[i],atan(pente)*360/(2*3.1415926),sens);
95
 
                                                        }
96
 
                                                }       
97
 
                                        else if(wi[i]->getLastSegment().x2-wi[i]->getLastSegment().x1 != 0)
98
 
                                        {
99
 
                                                pente=(wi[i]->getLastSegment().y2-wi[i]->getLastSegment().y1)/(wi[i]->getLastSegment().x2-wi[i]->getLastSegment().x1);
100
 
                                                dev.fleche(x,y-ins[i],atan(pente)*360/(2*3.1415926),sens);
101
 
                                        }
102
 
                                }
103
 
                        }
104
 
 
105
 
                for(i=0;i<(int)outs.size();i++)
106
 
                        dev.rond(x-largeur,y-outs[i],rayonIO);
107
 
 
108
 
                // mark for sens:
109
 
                        dev.markSens(x,y,sens);
110
 
 
111
 
                // display name:
112
 
                dev.text(x-largeur/2,y-hauteur/2,nom);     
113
 
        }
114
 
 
115
 
        cout<<"Param dessine"<<endl;
116
 
}
117