FAUST compiler  0.9.9.6b8
blockSchema.h
Go to the documentation of this file.
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 #ifndef __BLOCKSCHEMA__
23 #define __BLOCKSCHEMA__
24 
25 
26 #include "schema.h"
27 #include <vector>
28 #include <string>
29 
35 class blockSchema : public schema
36 {
37  protected:
38  const string fText;
39  const string fColor;
40  const string fLink;
41 
42  // fields only defined after place() is called
43  vector<point> fInputPoint;
44  vector<point> fOutputPoint;
45 
46 
47  public:
48  friend schema* makeBlockSchema ( unsigned int inputs,
49  unsigned int outputs,
50  const string& name,
51  const string& color,
52  const string& link);
53 
54  virtual void place(double x, double y, int orientation);
55  virtual void draw(device& dev);
56  virtual point inputPoint(unsigned int i) const;
57  virtual point outputPoint(unsigned int i) const;
58  virtual void collectTraits(collector& c);
59 
60  protected:
61  blockSchema ( unsigned int inputs, unsigned int outputs,
62  double width, double height,
63  const string& name, const string& color,
64  const string& link);
65 
66  void placeInputPoints();
67  void placeOutputPoints();
68 
69  void drawRectangle(device& dev);
70  void drawText(device& dev);
71  void drawOrientationMark(device& dev);
72  void drawInputArrows(device& dev);
73 // void drawOutputWires(device& dev);
74 
77 
78 };
79 
80 #endif
81 
82 
vector< point > fInputPoint
input connection points
Definition: blockSchema.h:43
friend schema * makeBlockSchema(unsigned int inputs, unsigned int outputs, const string &name, const string &color, const string &link)
Build a simple colored blockSchema with a certain number of inputs and outputs, a text to be displaye...
Definition: blockSchema.cpp:41
const string fLink
option URL link
Definition: blockSchema.h:40
void drawText(device &dev)
Draw the text centered on the box.
unsigned int outputs() const
Definition: schema.h:129
void placeInputPoints()
Computes the input points according to the position and the orientation of the blockSchema.
const string fText
Text to be displayed.
Definition: blockSchema.h:38
vector< point > fOutputPoint
output connection points
Definition: blockSchema.h:44
void placeOutputPoints()
Computes the output points according to the position and the orientation of the blockSchema.
virtual void draw(device &dev)
Draw the blockSchema on the device.
virtual void collectTraits(collector &c)
Draw horizontal arrows from the input points to the blockSchema rectangle.
unsigned int inputs() const
Definition: schema.h:128
double y() const
Definition: schema.h:139
double width() const
Definition: schema.h:126
Definition: device.h:32
A simple rectangular box with a text and inputs and outputs.
Definition: blockSchema.h:35
virtual point outputPoint(unsigned int i) const
Returns an output point.
blockSchema(unsigned int inputs, unsigned int outputs, double width, double height, const string &name, const string &color, const string &link)
Build a simple colored blockSchema with a certain number of inputs and outputs, a text to be displaye...
Definition: blockSchema.cpp:62
void drawInputArrows(device &dev)
Draw horizontal arrows from the input points to the blockSchema rectangle.
double x() const
Definition: schema.h:138
int orientation() const
Definition: schema.h:140
void drawOrientationMark(device &dev)
Draw the orientation mark, a small point that indicates the first input (like integrated circuits) ...
Definition: schema.h:40
virtual point inputPoint(unsigned int i) const
Returns an input point.
Definition: blockSchema.cpp:99
const char * name(Symbol *sym)
Returns the name of a symbol.
Definition: symbol.hh:98
An abstract block diagram schema.
Definition: schema.h:97
double height() const
Definition: schema.h:127
void collectOutputWires(collector &c)
Draw horizontal line from the blockSchema rectangle to the output points.
void collectInputWires(collector &c)
Draw horizontal arrows from the input points to the blockSchema rectangle.
void drawRectangle(device &dev)
Draw the colored rectangle with the optional link.
virtual void place(double x, double y, int orientation)
Define the graphic position of the blockSchema.
Definition: blockSchema.cpp:85
const string fColor
color of the box
Definition: blockSchema.h:39