OpenASIP 2.2
Loading...
Searching...
No Matches
BusChainFigure.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file BusChainFigure.cc
26 *
27 * Definition of BusChainFigure class.
28 *
29 * @author Ari Metsähalme 2004 (ari.metsahalme-no.spam-tut.fi)
30 * @note rating: yellow
31 * @note reviewed Jul 27 2004 by ml, pj, am
32 */
33
34#include <vector>
35
36#include "BusChainFigure.hh"
37#include "BridgeFigure.hh"
39
40
41using std::vector;
42
43const wxColour BusChainFigure::DEFAULT_COLOUR = wxColour(255, 150, 150);
44
45/**
46 * The Constructor.
47 */
54
55/**
56 * The Destructor.
57 */
60
61/**
62 * Lays out the segments in a column, spaced evenly.
63 *
64 * @param dc Device context.
65 */
66void
68
71 int x = location_.x;
72
73 for(unsigned int i = 0; i < children_.size(); i++) {
74
75 children_[i]->setLocation(wxPoint(x, y));
76 children_[i]->setWidth(size_.GetWidth());
77
78 // set bridge direction
79 BridgeFigure* br = dynamic_cast<BridgeFigure*>(children_[i]);
80 if (br != NULL && br->direction() != BridgeFigure::DIR_BIDIR &&
81 br->target() == children_[i-1]) {
82
84 }
85
86 children_[i]->layout(dc);
87 y += children_[i]->bounds().GetHeight() +
89 height += children_[i]->bounds().GetHeight() +
91 }
92
93 size_.SetHeight(height);
94}
95
96/**
97 * Fills the background of the bus chain with a solid color.
98 *
99 * @param dc The device context.
100 */
101void
103 wxPen pen = wxPen(DEFAULT_COLOUR, 1, wxSOLID);
104 dc->SetPen(pen);
105 wxBrush brush = wxBrush(DEFAULT_COLOUR, wxSOLID);
106 dc->SetBrush(brush);
107 dc->DrawRectangle(location_.x, location_.y, size_.GetWidth(),
108 size_.GetHeight());
109}
void setDirection(BridgeFigure::Direction direction)
Direction direction() const
virtual void drawSelf(wxDC *)
virtual ~BusChainFigure()
static const wxColour DEFAULT_COLOUR
Default colour for the figure.
virtual void layoutChildren(wxDC *)
Figure * target() const
wxSize minSize_
Figure's minimum size.
Definition Figure.hh:88
std::vector< Figure * > children_
Figure's children.
Definition Figure.hh:90
wxSize size_
wxSize of the Figure's bounding rectangle.
Definition Figure.hh:86
wxPoint location_
Top-left location of the Figure's bounding rectangle.
Definition Figure.hh:84
static const int BUS_MIN_WIDTH
Minimum width of a bus.
static const int BRIDGE_SPACE
Space dividing buses and bridges.
static const int BUS_MIN_HEIGHT
Minimum height of a bus.