OpenASIP  2.0
BusContainerFigure.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 BusContainerFigure.cc
26  *
27  * Definition of BusContainerFigure class.
28  *
29  * @author Ari Metsähalme 2003 (ari.metsahalme-no.spam-tut.fi)
30  * @note rating: yellow
31  * @note reviewed Jul 22 2004 by tr, ml, jm, am
32  */
33 
34 #include <vector>
35 
36 #include "BusContainerFigure.hh"
37 #include "BusFigure.hh"
38 #include "BridgeFigure.hh"
40 #include "BusChainFigure.hh"
41 
42 using std::vector;
43 
44 /**
45  * The Constructor.
46  */
48 }
49 
50 /**
51  * The Destructor.
52  */
54 }
55 
56 /**
57  * Lays out buses and bridges.
58  *
59  * @param dc Device context.
60  */
61 void
63 
64  int busX = location_.x;
65  int busY = location_.y;
66 
67  vector<Figure*>::iterator i = children_.begin();
68  while (i != children_.end()) {
69  (*i)->setLocation(wxPoint(busX, busY));
70  (*i)->setWidth(size_.GetWidth());
71  (*i)->layout(dc);
72 
73  busY += (*i)->bounds().GetHeight() +
75 
76  i++;
77  }
78 }
79 
80 /**
81  * Calculates and sets the size of the container.
82  *
83  * Depends on the size and amount of buses.
84  */
85 void
87 
88  int height = 0;
89 
90  vector<Figure*>::const_iterator i = children_.begin();
91  while (i != children_.end()) {
92  height += (*i)->bounds().GetHeight();
93  i++;
94  }
95 
97  size_.SetHeight(height);
98 
99  if (size_.GetWidth() == 0) {
100  size_.SetWidth(children_[0]->bounds().GetWidth());
101  }
102 }
Figure::bounds
virtual wxRect bounds() const
BusContainerFigure::BusContainerFigure
BusContainerFigure()
Definition: BusContainerFigure.cc:47
BusContainerFigure::layoutSelf
virtual void layoutSelf(wxDC *)
Definition: BusContainerFigure.cc:86
BusChainFigure.hh
BusContainerFigure.hh
Figure::children_
std::vector< Figure * > children_
Figure's children.
Definition: Figure.hh:90
Figure::size_
wxSize size_
wxSize of the Figure's bounding rectangle.
Definition: Figure.hh:86
Figure
Definition: Figure.hh:50
Figure::location_
wxPoint location_
Top-left location of the Figure's bounding rectangle.
Definition: Figure.hh:84
BusContainerFigure::~BusContainerFigure
virtual ~BusContainerFigure()
Definition: BusContainerFigure.cc:53
BridgeFigure.hh
MachineCanvasLayoutConstraints::BUS_SPACE
static const int BUS_SPACE
Space between buses and bus chains.
Definition: MachineCanvasLayoutConstraints.hh:75
BusContainerFigure::layoutChildren
virtual void layoutChildren(wxDC *)
Definition: BusContainerFigure.cc:62
MachineCanvasLayoutConstraints.hh
BusFigure.hh