OpenASIP 2.2
Loading...
Searching...
No Matches
SocketPortConnFigure.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 SocketPortConnFigure.cc
26 *
27 * Definition of SocketPortConnFigure class.
28 *
29 * @author Ari Metsähalme 2003 (ari.metsahalme-no.spam-tut.fi)
30 * @note reviewed Jul 27 2004 by ml, pj, am
31 * @note rating: yellow
32 */
33
34#include <vector>
35
36#include "Application.hh"
39
40const wxColour SocketPortConnFigure::DEFAULT_COLOUR = wxColour(0, 0, 0);
41
42/**
43 * The Constructor.
44 */
47
48/**
49 * The Destructor.
50 */
53
54/**
55 * Draws the connection's Figure on the given device context.
56 *
57 * @param dc The device context.
58 */
59void
61 assert(source_ != NULL && target_ != NULL);
62 wxPen pen = wxPen(DEFAULT_COLOUR, 1, wxSOLID);
63 dc->SetPen(pen);
65}
66
67/**
68 * Draws the connection line on the dc.
69 */
70void
72 int xOffset = source_->bounds().GetWidth() / 2;
73
75 // assumes that port is always "source"
76 dc->DrawLine(source_->location().x + xOffset,
77 source_->location().y + yOffset*2,
78 target_->location().x + xOffset,
79 target_->location().y);
80}
81
82/**
83 * Sets the figure's bounds.
84 */
85void
87 // assumes that port is always "source"
89 int xOffset = source_->bounds().GetWidth() / 2;
90
91 setHeight(target_->location().y - source_->location().y - yOffset*2);
92 if(source_->location().x < target_->location().x) {
93 setWidth(target_->location().x - source_->location().x + 3);
95 wxPoint(source_->location().x - 1 + xOffset,
96 source_->location().y + yOffset*2));
97
98 } else {
99 setWidth(source_->location().x - target_->location().x + 3);
101 wxPoint(target_->location().x - 1 + xOffset,
102 source_->location().y + yOffset*2));
103 }
104}
#define assert(condition)
Figure * source_
Source of connection.
Figure * target_
Target of connection.
void setHeight(int height)
Definition Figure.cc:95
virtual wxRect bounds() const
void setWidth(int width)
Definition Figure.cc:81
wxPoint location() const
void setLocation(wxPoint point)
static const int PORT_WIDTH
Default Width of a port.
virtual void drawConnection(wxDC *dc)
virtual void layoutSelf(wxDC *dc)
static const wxColour DEFAULT_COLOUR
Default colour for the figure.
virtual void drawSelf(wxDC *dc)