OpenASIP 2.2
Loading...
Searching...
No Matches
UnitPortFigure.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 UnitPortFigure.cc
26 *
27 * Definition of UnitPortFigure 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 "UnitPortFigure.hh"
38#include "MathTools.hh"
39
40#include "InputSocketFigure.hh"
41#include "OutputSocketFigure.hh"
42
43using std::vector;
44
45const wxColour UnitPortFigure::DEFAULT_COLOUR = wxColour(0, 0, 0);
46const wxColour UnitPortFigure::DEFAULT_BG_COLOUR = wxColour(255, 255, 255);
47
48/**
49 * The Constructor.
50 */
58
59/**
60 * The Destructor.
61 */
64
65/**
66 * Sets the x-coordinate for its child sockets.
67 */
68void
70 int socketX = location_.x;
71 bool oneSet = false;
72
73 for (unsigned int i = 0; i < children_.size(); i++) {
74
75 children_[i]->setWidth(size_.GetWidth());
76
77 if (!oneSet && !children_[i]->xSet()) {
78 children_[i]->setX(location_.x);
79 oneSet = true;
82 } else if (children_[i]->location().x == 0) {
83 children_[i]->setPreferredX(socketX);
84 }
85 }
86}
87
88/**
89 * Draws the port's Figure on the given device context.
90 *
91 * @param dc The device context.
92 */
93void
95 wxPen pen = wxPen(DEFAULT_COLOUR, 1, wxSOLID);
96 dc->SetPen(pen);
97 wxBrush brush = wxBrush(DEFAULT_BG_COLOUR, wxSOLID);
98 if (highlighted_) {
99 brush = wxBrush(highlight_, wxSOLID);
100 }
101 dc->SetBrush(brush);
102 dc->DrawRectangle(location_.x, location_.y, size_.GetWidth(),
103 size_.GetHeight());
104}
105
106/**
107 * Returns name of the port.
108 *
109 * @return Name of the port.
110 */
111std::string
113 return name_;
114}
wxColour highlight_
Highlight colour.
Definition Figure.hh:99
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() const
bool highlighted_
Tells if the figure is highlighted.
Definition Figure.hh:101
bool xSet() const
wxPoint location_
Top-left location of the Figure's bounding rectangle.
Definition Figure.hh:84
static const int PORT_MIN_WIDTH
Minimum Width of a port.
static const int SOCKET_MIN_SPACE
Space dividing connected sockets.
static const int SOCKET_WIDTH
Width of a socket.
static const int PORT_WIDTH
Default Width of a port.
static const int PORT_BASE_WIDTH
Constant used for port width calculation.
static int requiredBits(unsigned long int number)
std::string name() const
UnitPortFigure(std::string name, int bitWidth)
static const wxColour DEFAULT_BG_COLOUR
Default background colour for the figure.
virtual ~UnitPortFigure()
static const wxColour DEFAULT_COLOUR
Default colour for the figure.
virtual void layoutChildren(wxDC *)
virtual void drawSelf(wxDC *dc)
std::string name_
Name of the port.