OpenASIP  2.0
SocketBusConnFigure.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 SocketBusConnFigure.cc
26  *
27  * Definition of SocketBusConnFigure class.
28  *
29  * @author Ari Metsähalme 2003 (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 "Application.hh"
37 #include "SocketBusConnFigure.hh"
39 
40 const wxColour SocketBusConnFigure::DEFAULT_COLOUR = wxColour(0, 0, 0);
41 
42 /**
43  * The Constructor.
44  */
46 }
47 
48 /**
49  * The Destructor.
50  */
52 }
53 
54 /**
55  * Draws the connection's Figure on the given device context.
56  *
57  * @param dc The device context.
58  */
59 void
61  assert(source_ != NULL && target_ != NULL);
62  wxPen pen = wxPen(DEFAULT_COLOUR, 1, wxSOLID);
63  wxBrush brush = wxBrush(DEFAULT_COLOUR, wxSOLID);
64  dc->SetPen(pen);
65  dc->SetBrush(brush);
66  drawConnection(dc);
67 }
68 
69 
70 /**
71  * Draws the connection's Figure on the give device context.
72  */
73 void
75 
76  int xOffset = source_->bounds().GetWidth()/2;
77  int yOffset = target_->bounds().GetHeight()/2;
78 
79  // assumes that socket is always "source"
80  dc->DrawCircle(source_->location().x + xOffset,
81  target_->location().y + yOffset,
82  size_.GetWidth()/2);
83 }
84 
85 
86 /**
87  * Sets the figure's bounds.
88  */
89 void
92  wxPoint(
93  source_->location().x,
94  target_->location().y +
95  (target_->bounds().GetHeight()/2) -
97  int size = std::max(std::min(source_->bounds().GetWidth(),
100  setWidth(size);
101  setHeight(size);
102 
103 }
SocketBusConnFigure::SocketBusConnFigure
SocketBusConnFigure()
Definition: SocketBusConnFigure.cc:45
ConnectionFigure
Definition: ConnectionFigure.hh:44
SocketBusConnFigure::drawConnection
virtual void drawConnection(wxDC *dc)
Definition: SocketBusConnFigure.cc:74
ConnectionFigure::target_
Figure * target_
Target of connection.
Definition: ConnectionFigure.hh:58
Figure::setLocation
void setLocation(wxPoint point)
Figure::bounds
virtual wxRect bounds() const
Figure::setWidth
void setWidth(int width)
Definition: Figure.cc:81
MachineCanvasLayoutConstraints::SOCKET_WIDTH
static const int SOCKET_WIDTH
Width of a socket.
Definition: MachineCanvasLayoutConstraints.hh:59
Figure::location
wxPoint location() const
assert
#define assert(condition)
Definition: Application.hh:86
Figure::size_
wxSize size_
wxSize of the Figure's bounding rectangle.
Definition: Figure.hh:86
Application.hh
SocketBusConnFigure::~SocketBusConnFigure
virtual ~SocketBusConnFigure()
Definition: SocketBusConnFigure.cc:51
ConnectionFigure::source_
Figure * source_
Source of connection.
Definition: ConnectionFigure.hh:56
MachineCanvasLayoutConstraints::BUS_SPACE
static const int BUS_SPACE
Space between buses and bus chains.
Definition: MachineCanvasLayoutConstraints.hh:75
SocketBusConnFigure::drawSelf
virtual void drawSelf(wxDC *dc)
Definition: SocketBusConnFigure.cc:60
MachineCanvasLayoutConstraints.hh
Figure::setHeight
void setHeight(int height)
Definition: Figure.cc:95
SocketBusConnFigure::DEFAULT_COLOUR
static const wxColour DEFAULT_COLOUR
Default colour for the figure.
Definition: SocketBusConnFigure.hh:63
SocketBusConnFigure::layoutSelf
virtual void layoutSelf(wxDC *dc)
Definition: SocketBusConnFigure.cc:90
SocketBusConnFigure.hh