OpenASIP  2.0
MoveFigure.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 MoveFigure.cc
26  *
27  * Implementation of MoveFigure class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2005 (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include "MoveFigure.hh"
35 
36 const wxColour MoveFigure::DEFAULT_COLOUR = wxColour(255, 255, 0);
37 
38 /**
39  * The Constructor.
40  *
41  * @param bus Figure of the bus which transports the move.
42  * @param source Figure of the source port of the move.
43  * @param target Figure of the target port of the move.
44  */
45 MoveFigure::MoveFigure(Figure* bus, Figure* source, Figure* target):
46  Figure(), bus_(bus), source_(source), target_(target) {
47 
48  laidOut_ = true;
49 }
50 
51 
52 /**
53  * The Destructor.
54  */
56 }
57 
58 
59 /**
60  * Draws the move figure on a device context.
61  *
62  * @param dc Device context where to draw the figure.
63  */
64 void
66 
67  assert(bus_ != NULL);
68 
69  wxPen pen = wxPen(DEFAULT_COLOUR, 4, wxSOLID);
70  wxBrush brush = wxBrush(DEFAULT_COLOUR, wxSOLID);
71  dc->SetPen(pen);
72  dc->SetBrush(brush);
73 
75  int busY = bus_->location().y + bus_->bounds().GetHeight()/2;
76 
77  int sourceX = 0;
78  int targetX = 0;
79 
80  // Draw source port -> bus line.
81  if (source_ != NULL) {
82  sourceX = source_->location().x + source_->bounds().GetWidth()/2;
83  int sourceY = source_->location().y + offset * 2;
84  dc->DrawLine(sourceX, sourceY, sourceX, busY);
85  int size = std::max(
86  std::min(source_->bounds().GetWidth(),
89  dc->DrawCircle(sourceX, busY, size/2);
90  }
91 
92  // Draw bus -> target port line.
93  if (target_ != NULL) {
94  targetX = target_->location().x + target_->bounds().GetWidth()/2;
95  int targetY = target_->location().y + offset * 2;
96  dc->DrawLine(targetX, targetY, targetX, busY);
97  int size = std::max(
98  std::min(target_->bounds().GetWidth(),
101  dc->DrawCircle(targetX, busY, size/2);
102  }
103 
104  // Draw line on the bus.
105  if (target_ != NULL && source_ != NULL) {
106  dc->DrawLine(sourceX, busY, targetX, busY);
107  } else {
108  // Source or target missing. Draw move over the whole bus.
109  sourceX = bus_->location().x;
110  targetX = bus_->location().x + bus_->bounds().GetWidth();
111  dc->DrawLine(sourceX, busY, targetX, busY);
112  }
113 }
Figure::bounds
virtual wxRect bounds() const
Figure::laidOut_
bool laidOut_
Tells whether the Figure and its children have been laid out or not.
Definition: Figure.hh:95
MoveFigure::source_
Figure * source_
Figure of the source port.
Definition: MoveFigure.hh:55
MoveFigure::drawSelf
virtual void drawSelf(wxDC *dc)
Definition: MoveFigure.cc:65
MachineCanvasLayoutConstraints::SOCKET_WIDTH
static const int SOCKET_WIDTH
Width of a socket.
Definition: MachineCanvasLayoutConstraints.hh:59
Figure::location
wxPoint location() const
MoveFigure::MoveFigure
MoveFigure(Figure *bus, Figure *source, Figure *target)
Definition: MoveFigure.cc:45
MoveFigure::bus_
Figure * bus_
Figure of the bus where the move is done.
Definition: MoveFigure.hh:53
assert
#define assert(condition)
Definition: Application.hh:86
MoveFigure::target_
Figure * target_
Figure of the TargetPort.
Definition: MoveFigure.hh:57
MoveFigure::DEFAULT_COLOUR
static const wxColour DEFAULT_COLOUR
Default colour of the figure.
Definition: MoveFigure.hh:51
Figure
Definition: Figure.hh:50
MachineCanvasLayoutConstraints::PORT_WIDTH
static const int PORT_WIDTH
Default Width of a port.
Definition: MachineCanvasLayoutConstraints.hh:51
MachineCanvasLayoutConstraints::BUS_SPACE
static const int BUS_SPACE
Space between buses and bus chains.
Definition: MachineCanvasLayoutConstraints.hh:75
MoveFigure.hh
MachineCanvasLayoutConstraints.hh
MoveFigure::~MoveFigure
virtual ~MoveFigure()
Definition: MoveFigure.cc:55