OpenASIP  2.0
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"
37 #include "SocketPortConnFigure.hh"
39 
40 const wxColour SocketPortConnFigure::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  dc->SetPen(pen);
64  drawConnection(dc);
65 }
66 
67 /**
68  * Draws the connection line on the dc.
69  */
70 void
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  */
85 void
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);
100  setLocation(
101  wxPoint(target_->location().x - 1 + xOffset,
102  source_->location().y + yOffset*2));
103  }
104 }
ConnectionFigure
Definition: ConnectionFigure.hh:44
SocketPortConnFigure::SocketPortConnFigure
SocketPortConnFigure()
Definition: SocketPortConnFigure.cc:45
ConnectionFigure::target_
Figure * target_
Target of connection.
Definition: ConnectionFigure.hh:58
SocketPortConnFigure.hh
Figure::setLocation
void setLocation(wxPoint point)
Figure::bounds
virtual wxRect bounds() const
SocketPortConnFigure::~SocketPortConnFigure
virtual ~SocketPortConnFigure()
Definition: SocketPortConnFigure.cc:51
SocketPortConnFigure::layoutSelf
virtual void layoutSelf(wxDC *dc)
Definition: SocketPortConnFigure.cc:86
Figure::setWidth
void setWidth(int width)
Definition: Figure.cc:81
SocketPortConnFigure::DEFAULT_COLOUR
static const wxColour DEFAULT_COLOUR
Default colour for the figure.
Definition: SocketPortConnFigure.hh:62
Figure::location
wxPoint location() const
assert
#define assert(condition)
Definition: Application.hh:86
Application.hh
MachineCanvasLayoutConstraints::PORT_WIDTH
static const int PORT_WIDTH
Default Width of a port.
Definition: MachineCanvasLayoutConstraints.hh:51
ConnectionFigure::source_
Figure * source_
Source of connection.
Definition: ConnectionFigure.hh:56
SocketPortConnFigure::drawSelf
virtual void drawSelf(wxDC *dc)
Definition: SocketPortConnFigure.cc:60
MachineCanvasLayoutConstraints.hh
Figure::setHeight
void setHeight(int height)
Definition: Figure.cc:95
SocketPortConnFigure::drawConnection
virtual void drawConnection(wxDC *dc)
Definition: SocketPortConnFigure.cc:71