OpenASIP  2.0
SegmentFigure.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2010 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 SegmentFigure.cc
26  *
27  * Definition of SegmentFigure class.
28  *
29  * @author Ari Metsähalme 2003 (ari.metsahalme-no.spam-tut.fi)
30  * @author Pekka Jääskeläinen 2010
31  * @note rating: yellow
32  * @note reviewed Jul 27 2004 by ml, pj, am
33  */
34 
35 #include "SegmentFigure.hh"
37 #include "MathTools.hh"
38 
39 const wxColour SegmentFigure::DEFAULT_COLOUR = wxColour(0, 0, 0);
40 
41 
42 /**
43  * The Constructor.
44  */
45 SegmentFigure::SegmentFigure(int bitWidth): Figure(), last_(false) {
46  minSize_ = wxSize(
49  std::max(0,MathTools::requiredBits(bitWidth)-2) +
50  bitWidth/63);
51  size_ = minSize_;
52 }
53 
54 /**
55  * The Destructor.
56  */
58 }
59 
60 /**
61  * Draws the segment's Figure on the given device context.
62  *
63  * @param dc The device context.
64  */
65 void
67 
68  wxPen pen = wxPen(DEFAULT_COLOUR, 1, wxSOLID);
69  wxBrush brush = wxBrush(DEFAULT_COLOUR, wxSOLID);
70  if (highlighted_) {
71  pen = wxPen(highlight_, 1, wxSOLID);
72  brush = wxBrush(highlight_, wxSOLID);
73  }
74 
75  dc->SetPen(pen);
76  dc->SetBrush(brush);
77 
78  if (!last_) {
79 
80  // draw arrow
81  const int arrowSize = 8;
82  wxPoint arrowPoints[3];
83  arrowPoints[0] = wxPoint(
84  location_.x + size_.GetWidth() - arrowSize,
85  location_.y - arrowSize / 2 + size_.GetHeight() / 2);
86  arrowPoints[1] = wxPoint(
87  arrowPoints[0].x + arrowSize, arrowPoints[0].y + arrowSize / 2);
88  arrowPoints[2] = wxPoint(
89  arrowPoints[0].x, arrowPoints[0].y + arrowSize);
90  dc->DrawPolygon(3, arrowPoints);
91  dc->DrawRectangle(
92  location_.x, location_.y, size_.GetWidth() - arrowSize,
93  size_.GetHeight());
94 
95  } else {
96  dc->DrawRectangle(
97  location_.x, location_.y, size_.GetWidth(), size_.GetHeight());
98  }
99 }
MachineCanvasLayoutConstraints::BUS_MIN_WIDTH
static const int BUS_MIN_WIDTH
Minimum width of a bus.
Definition: MachineCanvasLayoutConstraints.hh:71
MachineCanvasLayoutConstraints::SEGMENT_HEIGHT_BASE
static const int SEGMENT_HEIGHT_BASE
Height of a segment.
Definition: MachineCanvasLayoutConstraints.hh:69
Figure::highlight_
wxColour highlight_
Highlight colour.
Definition: Figure.hh:99
Figure::size_
wxSize size_
wxSize of the Figure's bounding rectangle.
Definition: Figure.hh:86
SegmentFigure::last_
bool last_
True if segment is the last segment in a bus.
Definition: SegmentFigure.hh:63
Figure
Definition: Figure.hh:50
Figure::location_
wxPoint location_
Top-left location of the Figure's bounding rectangle.
Definition: Figure.hh:84
SegmentFigure.hh
SegmentFigure::SegmentFigure
SegmentFigure(int bitWidth)
Definition: SegmentFigure.cc:45
MathTools::requiredBits
static int requiredBits(unsigned long int number)
SegmentFigure::~SegmentFigure
virtual ~SegmentFigure()
Definition: SegmentFigure.cc:57
Figure::highlighted_
bool highlighted_
Tells if the figure is highlighted.
Definition: Figure.hh:101
Figure::minSize_
wxSize minSize_
Figure's minimum size.
Definition: Figure.hh:88
false
find Finds info of the inner loops in the false
Definition: InnerLoopFinder.cc:81
MachineCanvasLayoutConstraints.hh
MathTools.hh
SegmentFigure::drawSelf
virtual void drawSelf(wxDC *dc)
Definition: SegmentFigure.cc:66
SegmentFigure::DEFAULT_COLOUR
static const wxColour DEFAULT_COLOUR
Default colour for the figure.
Definition: SegmentFigure.hh:66