OpenASIP  2.0
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
SegmentFigure Class Reference

#include <SegmentFigure.hh>

Inheritance diagram for SegmentFigure:
Inheritance graph
Collaboration diagram for SegmentFigure:
Collaboration graph

Public Member Functions

 SegmentFigure (int bitWidth)
 
virtual ~SegmentFigure ()
 
void setLast (bool last)
 
- Public Member Functions inherited from Figure
 Figure ()
 
virtual ~Figure ()
 
wxPoint location () const
 
void setLocation (wxPoint point)
 
void setX (int x)
 
void setY (int y)
 
void setPreferredX (int x)
 
bool xSet () const
 
void clearXSetFlag ()
 
virtual wxRect bounds () const
 
virtual wxRect virtualBounds () const
 
void setBounds (wxSize bounds)
 
void setWidth (int width)
 
void setHeight (int height)
 
virtual void addChild (Figure *child)
 
int childCount () const
 
Figurechild (int index) const
 
virtual void layout (wxDC *dc)
 
virtual void draw (wxDC *dc)
 
void highlight (const wxColour &colour)
 
void clearHighlight ()
 
void setOptions (MachineCanvasOptions *options)
 
MachineCanvasOptionsoptions ()
 

Protected Member Functions

virtual void drawSelf (wxDC *dc)
 
- Protected Member Functions inherited from Figure
void drawChildren (wxDC *dc)
 
virtual void layoutSelf (wxDC *)
 
virtual void layoutChildren (wxDC *)
 

Private Member Functions

SegmentFigureoperator= (SegmentFigure &old)
 Assignment not allowed. More...
 
 SegmentFigure (SegmentFigure &old)
 Copying not allowed. More...
 

Private Attributes

bool last_
 True if segment is the last segment in a bus. More...
 

Static Private Attributes

static const wxColour DEFAULT_COLOUR = wxColour(0, 0, 0)
 Default colour for the figure. More...
 

Additional Inherited Members

- Protected Attributes inherited from Figure
wxPoint location_
 Top-left location of the Figure's bounding rectangle. More...
 
wxSize size_
 wxSize of the Figure's bounding rectangle. More...
 
wxSize minSize_
 Figure's minimum size. More...
 
std::vector< Figure * > children_
 Figure's children. More...
 
bool xSet_
 Tells if x-coordinate has been fixed. More...
 
bool laidOut_
 Tells whether the Figure and its children have been laid out or not. More...
 
bool drawn_
 Tells whether the Figure and its children have been drawn or not. More...
 
wxColour highlight_
 Highlight colour. More...
 
bool highlighted_
 Tells if the figure is highlighted. More...
 
MachineCanvasOptionsoptions_
 Options which are used for customizing figures. More...
 

Detailed Description

Figure of a segment.

Definition at line 46 of file SegmentFigure.hh.

Constructor & Destructor Documentation

◆ SegmentFigure() [1/2]

SegmentFigure::SegmentFigure ( int  bitWidth)

The Constructor.

Definition at line 45 of file SegmentFigure.cc.

45  : Figure(), last_(false) {
46  minSize_ = wxSize(
49  std::max(0,MathTools::requiredBits(bitWidth)-2) +
50  bitWidth/63);
51  size_ = minSize_;
52 }

References MachineCanvasLayoutConstraints::BUS_MIN_WIDTH, Figure::minSize_, MathTools::requiredBits(), MachineCanvasLayoutConstraints::SEGMENT_HEIGHT_BASE, and Figure::size_.

Here is the call graph for this function:

◆ ~SegmentFigure()

SegmentFigure::~SegmentFigure ( )
virtual

The Destructor.

Definition at line 57 of file SegmentFigure.cc.

57  {
58 }

◆ SegmentFigure() [2/2]

SegmentFigure::SegmentFigure ( SegmentFigure old)
private

Copying not allowed.

Member Function Documentation

◆ drawSelf()

void SegmentFigure::drawSelf ( wxDC *  dc)
protectedvirtual

Draws the segment's Figure on the given device context.

Parameters
dcThe device context.

Reimplemented from Figure.

Definition at line 66 of file SegmentFigure.cc.

66  {
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 }

References DEFAULT_COLOUR, Figure::highlight_, Figure::highlighted_, last_, Figure::location_, and Figure::size_.

◆ operator=()

SegmentFigure& SegmentFigure::operator= ( SegmentFigure old)
private

Assignment not allowed.

◆ setLast()

void SegmentFigure::setLast ( bool  last)

Member Data Documentation

◆ DEFAULT_COLOUR

const wxColour SegmentFigure::DEFAULT_COLOUR = wxColour(0, 0, 0)
staticprivate

Default colour for the figure.

Definition at line 66 of file SegmentFigure.hh.

Referenced by drawSelf().

◆ last_

bool SegmentFigure::last_
private

True if segment is the last segment in a bus.

Definition at line 63 of file SegmentFigure.hh.

Referenced by drawSelf().


The documentation for this class was generated from the following files:
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::location_
wxPoint location_
Top-left location of the Figure's bounding rectangle.
Definition: Figure.hh:84
MathTools::requiredBits
static int requiredBits(unsigned long int number)
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
Figure::Figure
Figure()
Definition: Figure.cc:44
SegmentFigure::DEFAULT_COLOUR
static const wxColour DEFAULT_COLOUR
Default colour for the figure.
Definition: SegmentFigure.hh:66