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

#include <BusFigure.hh>

Inheritance diagram for BusFigure:
Inheritance graph
Collaboration diagram for BusFigure:
Collaboration graph

Public Member Functions

 BusFigure (unsigned int slot)
 
virtual ~BusFigure ()
 
virtual wxRect virtualBounds () const
 
- 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
 
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 layoutSelf (wxDC *)
 
virtual void layoutChildren (wxDC *)
 
virtual void drawSelf (wxDC *)
 
- Protected Member Functions inherited from Figure
void drawChildren (wxDC *dc)
 

Private Member Functions

BusFigureoperator= (BusFigure &old)
 Assignment not allowed. More...
 
 BusFigure (BusFigure &old)
 Copying not allowed. More...
 

Private Attributes

unsigned int slot_
 Slot of the bus. More...
 

Static Private Attributes

static const wxColour DEFAULT_COLOUR = wxColour(150, 150, 150)
 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 bus.

Definition at line 48 of file BusFigure.hh.

Constructor & Destructor Documentation

◆ BusFigure() [1/2]

BusFigure::BusFigure ( unsigned int  slot)

◆ ~BusFigure()

BusFigure::~BusFigure ( )
virtual

The Destructor.

Definition at line 58 of file BusFigure.cc.

58 {}

◆ BusFigure() [2/2]

BusFigure::BusFigure ( BusFigure old)
private

Copying not allowed.

Member Function Documentation

◆ drawSelf()

void BusFigure::drawSelf ( wxDC *  dc)
protectedvirtual

Draws the Figure of the bus on the given device context if it has no segments, otherwise only the segments are drawn.

Parameters
dcThe device context.

Reimplemented from Figure.

Definition at line 128 of file BusFigure.cc.

128  {
129 
130  if (children_.empty()) {
131  wxPen pen = wxPen(DEFAULT_COLOUR, 1, wxSOLID);
132  wxBrush brush = wxBrush(DEFAULT_COLOUR, wxSOLID);
133  dc->SetPen(pen);
134  dc->SetBrush(brush);
135 
136  dc->DrawRectangle(location_.x, location_.y,
137  size_.GetWidth(), size_.GetHeight());
138  }
139 
140  // Draw slot label.
141  int slotLabelWidth;
142  int slotLabelHeight;
143  wxString slotLabel = WxConversion::toWxString(slot_);
144  dc->GetTextExtent(slotLabel, &slotLabelWidth, &slotLabelHeight);
145 
146  int slotLabelX = location_.x - slotLabelWidth - 10;
147  int slotLabelY =
148  ((size_.GetHeight() / 2) + location_.y) - (slotLabelHeight / 2);
149 
150  dc->SetBackgroundMode(wxTRANSPARENT);
151  dc->SetTextForeground(*wxBLACK);
152  dc->DrawText(slotLabel, slotLabelX, slotLabelY);
153 }

References Figure::children_, DEFAULT_COLOUR, Figure::location_, Figure::size_, slot_, and WxConversion::toWxString().

Here is the call graph for this function:

◆ layoutChildren()

void BusFigure::layoutChildren ( wxDC *  dc)
protectedvirtual

Lays ouf the segments in a column, spaced evenly.

Parameters
dcDevice context.

Reimplemented from Figure.

Definition at line 84 of file BusFigure.cc.

84  {
85 
86  int segY = location_.y;
87  int segX = location_.x;
88 
89  for(unsigned int i = 0; i < children_.size(); i++) {
90  children_[i]->setLocation(wxPoint(segX, segY));
91  children_[i]->setWidth(size_.GetWidth());
92  children_[i]->layout(dc);
93  segY += children_[i]->bounds().GetHeight() +
95  }
96 }

References Figure::children_, Figure::location_, MachineCanvasLayoutConstraints::SEGMENT_SPACE, and Figure::size_.

◆ layoutSelf()

void BusFigure::layoutSelf ( wxDC *  )
protectedvirtual

Calculates and sets bus size according to the size of segments.

Reimplemented from Figure.

Definition at line 102 of file BusFigure.cc.

102  {
103 
104  if (children_.size() > 0) {
105  int segsHeight = 0;
106 
107  vector<Figure*>::const_iterator i = children_.begin();
108  for (; i != children_.end(); i++) {
109  segsHeight += (*i)->bounds().GetHeight();
110  }
111 
112  dynamic_cast<SegmentFigure*>(children_.back())->setLast(true);
113 
114  segsHeight += (children_.size() - 1)
116 
117  size_.SetHeight(segsHeight);
118  }
119 }

References Figure::children_, MachineCanvasLayoutConstraints::SEGMENT_SPACE, and Figure::size_.

◆ operator=()

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

Assignment not allowed.

◆ virtualBounds()

wxRect BusFigure::virtualBounds ( ) const
virtual

Returns the virtual bounds of a bus, which are a bit higher than the visible bounds to make selection easier.

Returns
The virtual bounds of a bus.

Reimplemented from Figure.

Definition at line 67 of file BusFigure.cc.

67  {
68  if (childCount() <= 1) {
69  wxRect virtualLocation = wxRect(
70  wxPoint(location_.x, location_.y - size_.GetHeight()),
71  wxSize(size_.GetWidth(), size_.GetHeight() * 3));
72  return virtualLocation;
73  } else {
74  return wxRect(location_, size_);
75  }
76 }

References Figure::childCount(), Figure::location_, and Figure::size_.

Here is the call graph for this function:

Member Data Documentation

◆ DEFAULT_COLOUR

const wxColour BusFigure::DEFAULT_COLOUR = wxColour(150, 150, 150)
staticprivate

Default colour for the figure.

Definition at line 69 of file BusFigure.hh.

Referenced by drawSelf().

◆ slot_

unsigned int BusFigure::slot_
private

Slot of the bus.

Definition at line 67 of file BusFigure.hh.

Referenced by drawSelf().


The documentation for this class was generated from the following files:
WxConversion::toWxString
static wxString toWxString(const std::string &source)
BusFigure::slot_
unsigned int slot_
Slot of the bus.
Definition: BusFigure.hh:67
MachineCanvasLayoutConstraints::BUS_MIN_WIDTH
static const int BUS_MIN_WIDTH
Minimum width of a bus.
Definition: MachineCanvasLayoutConstraints.hh:71
BusFigure::DEFAULT_COLOUR
static const wxColour DEFAULT_COLOUR
Default colour for the figure.
Definition: BusFigure.hh:69
Figure::children_
std::vector< Figure * > children_
Figure's children.
Definition: Figure.hh:90
SegmentFigure
Definition: SegmentFigure.hh:46
Figure::size_
wxSize size_
wxSize of the Figure's bounding rectangle.
Definition: Figure.hh:86
Figure::location_
wxPoint location_
Top-left location of the Figure's bounding rectangle.
Definition: Figure.hh:84
MachineCanvasLayoutConstraints::SEGMENT_SPACE
static const int SEGMENT_SPACE
Space dividing segments.
Definition: MachineCanvasLayoutConstraints.hh:67
Figure::minSize_
wxSize minSize_
Figure's minimum size.
Definition: Figure.hh:88
Figure::childCount
int childCount() const
Figure::Figure
Figure()
Definition: Figure.cc:44
MachineCanvasLayoutConstraints::BUS_MIN_HEIGHT
static const int BUS_MIN_HEIGHT
Minimum height of a bus.
Definition: MachineCanvasLayoutConstraints.hh:73