1 /************************************************************************
2 ************************************************************************
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.
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.
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 ************************************************************************/
23 #include "topSchema.h"
31 * Creates a new top schema
33 schema
* makeTopSchema (schema
* s
, double margin
, const string
& text
, const string
& link
)
35 return new topSchema (makeDecorateSchema(s
, margin
/2, text
), margin
/2, "", link
);
40 * A topSchema is a schema surrounded by a dashed rectangle with a
41 * label on the top left. The rectangle is placed at half the margin
42 * parameter. Arrows are added to the outputs. The constructor is
43 * made private to enforce the usage of makeTopSchema.
45 topSchema::topSchema( schema
* s
, double margin
, const string
& text
, const string
& link
)
46 : schema(0, 0, s
->width()+2*margin
, s
->height()+2*margin
),
56 * Define the graphic position of the schema. Computes the graphic
57 * position of all the elements, in particular the inputs and outputs.
58 * This method must be called before draw(), otherwise draw is not allowed
60 void topSchema::place(double ox
, double oy
, int orientation
)
62 beginPlace(ox
, oy
, orientation
);
64 fSchema
->place(ox
+fMargin
, oy
+fMargin
, orientation
);
69 * Top schema has no input
71 point
topSchema::inputPoint(unsigned int i
) const
74 assert (i
< inputs());
79 * Top schema has no output
81 point
topSchema::outputPoint(unsigned int i
) const
84 assert (i
< outputs());
89 * Draw the enlarged schema. This methos can only
90 * be called after the block have been placed
92 void topSchema::draw(device
& dev
)
96 // draw a background white rectangle
97 dev
.rect(x(), y(), width()-1, height()-1, "#ffffff", fLink
.c_str());
100 dev
.label(x()+fMargin
, y()+fMargin
/2, fText
.c_str());
104 // draw arrows at output points of schema
105 for (unsigned int i
=0; i
<fSchema
->outputs(); i
++) {
106 point p
= fSchema
->outputPoint(i
);
107 dev
.fleche(p
.x
, p
.y
, 0, orientation());
112 * Draw the enlarged schema. This methos can only
113 * be called after the block have been placed
115 void topSchema::collectTraits(collector
& c
)
118 fSchema
->collectTraits(c
);
120 // draw arrows at output points of schema
121 for (unsigned int i
=0; i
<fSchema
->inputs(); i
++) {
122 point p
= fSchema
->inputPoint(i
);
126 // draw arrows at output points of schema
127 for (unsigned int i
=0; i
<fSchema
->outputs(); i
++) {
128 point p
= fSchema
->outputPoint(i
);