OpenASIP  2.0
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 
41 using std::vector;
42 
43 const wxColour BusChainFigure::DEFAULT_COLOUR = wxColour(255, 150, 150);
44 
45 /**
46  * The Constructor.
47  */
49  minSize_ = wxSize(
52  size_ = minSize_;
53 }
54 
55 /**
56  * The Destructor.
57  */
59 }
60 
61 /**
62  * Lays out the segments in a column, spaced evenly.
63  *
64  * @param dc Device context.
65  */
66 void
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  */
101 void
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 }
BridgeFigure::setDirection
void setDirection(BridgeFigure::Direction direction)
MachineCanvasLayoutConstraints::BRIDGE_SPACE
static const int BRIDGE_SPACE
Space dividing buses and bridges.
Definition: MachineCanvasLayoutConstraints.hh:81
BusChainFigure::DEFAULT_COLOUR
static const wxColour DEFAULT_COLOUR
Default colour for the figure.
Definition: BusChainFigure.hh:63
MachineCanvasLayoutConstraints::BUS_MIN_WIDTH
static const int BUS_MIN_WIDTH
Minimum width of a bus.
Definition: MachineCanvasLayoutConstraints.hh:71
BusChainFigure::BusChainFigure
BusChainFigure()
Definition: BusChainFigure.cc:48
BridgeFigure::direction
Direction direction() const
BusChainFigure.hh
BridgeFigure::DIR_BIDIR
@ DIR_BIDIR
Definition: BridgeFigure.hh:49
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
BridgeFigure
Definition: BridgeFigure.hh:46
BridgeFigure.hh
BusChainFigure::drawSelf
virtual void drawSelf(wxDC *)
Definition: BusChainFigure.cc:102
BusChainFigure::~BusChainFigure
virtual ~BusChainFigure()
Definition: BusChainFigure.cc:58
Figure::minSize_
wxSize minSize_
Figure's minimum size.
Definition: Figure.hh:88
ConnectionFigure::target
Figure * target() const
MachineCanvasLayoutConstraints.hh
BusChainFigure::layoutChildren
virtual void layoutChildren(wxDC *)
Definition: BusChainFigure.cc:67
BridgeFigure::DIR_LEFT
@ DIR_LEFT
Definition: BridgeFigure.hh:49
MachineCanvasLayoutConstraints::BUS_MIN_HEIGHT
static const int BUS_MIN_HEIGHT
Minimum height of a bus.
Definition: MachineCanvasLayoutConstraints.hh:73