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

#include <UnitPortFigure.hh>

Inheritance diagram for UnitPortFigure:
Inheritance graph
Collaboration diagram for UnitPortFigure:
Collaboration graph

Public Member Functions

 UnitPortFigure (std::string name, int bitWidth)
 
virtual ~UnitPortFigure ()
 
std::string name () 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
 
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 layoutChildren (wxDC *)
 
virtual void drawSelf (wxDC *dc)
 
- Protected Member Functions inherited from Figure
void drawChildren (wxDC *dc)
 
virtual void layoutSelf (wxDC *)
 

Private Member Functions

UnitPortFigureoperator= (UnitPortFigure &old)
 Assignment not allowed. More...
 
 UnitPortFigure (UnitPortFigure &old)
 Copying not allowed. More...
 

Private Attributes

std::string name_
 Name of the port. More...
 

Static Private Attributes

static const wxColour DEFAULT_COLOUR = wxColour(0, 0, 0)
 Default colour for the figure. More...
 
static const wxColour DEFAULT_BG_COLOUR = wxColour(255, 255, 255)
 Default background 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 port.

Definition at line 46 of file UnitPortFigure.hh.

Constructor & Destructor Documentation

◆ UnitPortFigure() [1/2]

UnitPortFigure::UnitPortFigure ( std::string  name,
int  bitWidth 
)

◆ ~UnitPortFigure()

UnitPortFigure::~UnitPortFigure ( )
virtual

The Destructor.

Definition at line 62 of file UnitPortFigure.cc.

62  {
63 }

◆ UnitPortFigure() [2/2]

UnitPortFigure::UnitPortFigure ( UnitPortFigure old)
private

Copying not allowed.

Member Function Documentation

◆ drawSelf()

void UnitPortFigure::drawSelf ( wxDC *  dc)
protectedvirtual

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

Parameters
dcThe device context.

Reimplemented from Figure.

Reimplemented in TriggeringPortFigure.

Definition at line 94 of file UnitPortFigure.cc.

94  {
95  wxPen pen = wxPen(DEFAULT_COLOUR, 1, wxSOLID);
96  dc->SetPen(pen);
97  wxBrush brush = wxBrush(DEFAULT_BG_COLOUR, wxSOLID);
98  if (highlighted_) {
99  brush = wxBrush(highlight_, wxSOLID);
100  }
101  dc->SetBrush(brush);
102  dc->DrawRectangle(location_.x, location_.y, size_.GetWidth(),
103  size_.GetHeight());
104 }

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

◆ layoutChildren()

void UnitPortFigure::layoutChildren ( wxDC *  )
protectedvirtual

Sets the x-coordinate for its child sockets.

Reimplemented from Figure.

Definition at line 69 of file UnitPortFigure.cc.

69  {
70  int socketX = location_.x;
71  bool oneSet = false;
72 
73  for (unsigned int i = 0; i < children_.size(); i++) {
74 
75  children_[i]->setWidth(size_.GetWidth());
76 
77  if (!oneSet && !children_[i]->xSet()) {
78  children_[i]->setX(location_.x);
79  oneSet = true;
82  } else if (children_[i]->location().x == 0) {
83  children_[i]->setPreferredX(socketX);
84  }
85  }
86 }

References Figure::children_, Figure::location(), Figure::location_, Figure::size_, MachineCanvasLayoutConstraints::SOCKET_MIN_SPACE, MachineCanvasLayoutConstraints::SOCKET_WIDTH, and Figure::xSet().

Here is the call graph for this function:

◆ name()

std::string UnitPortFigure::name ( ) const

Returns name of the port.

Returns
Name of the port.

Definition at line 112 of file UnitPortFigure.cc.

112  {
113  return name_;
114 }

References name_.

Referenced by UnitFigure::layoutChildren().

◆ operator=()

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

Assignment not allowed.

Member Data Documentation

◆ DEFAULT_BG_COLOUR

const wxColour UnitPortFigure::DEFAULT_BG_COLOUR = wxColour(255, 255, 255)
staticprivate

Default background colour for the figure.

Definition at line 65 of file UnitPortFigure.hh.

Referenced by drawSelf().

◆ DEFAULT_COLOUR

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

Default colour for the figure.

Definition at line 63 of file UnitPortFigure.hh.

Referenced by drawSelf().

◆ name_

std::string UnitPortFigure::name_
private

Name of the port.

Definition at line 68 of file UnitPortFigure.hh.

Referenced by name().


The documentation for this class was generated from the following files:
UnitPortFigure::name
std::string name() const
Definition: UnitPortFigure.cc:112
MachineCanvasLayoutConstraints::PORT_BASE_WIDTH
static const int PORT_BASE_WIDTH
Constant used for port width calculation.
Definition: MachineCanvasLayoutConstraints.hh:55
MachineCanvasLayoutConstraints::PORT_MIN_WIDTH
static const int PORT_MIN_WIDTH
Minimum Width of a port.
Definition: MachineCanvasLayoutConstraints.hh:53
Figure::children_
std::vector< Figure * > children_
Figure's children.
Definition: Figure.hh:90
MachineCanvasLayoutConstraints::SOCKET_WIDTH
static const int SOCKET_WIDTH
Width of a socket.
Definition: MachineCanvasLayoutConstraints.hh:59
Figure::highlight_
wxColour highlight_
Highlight colour.
Definition: Figure.hh:99
MachineCanvasLayoutConstraints::SOCKET_MIN_SPACE
static const int SOCKET_MIN_SPACE
Space dividing connected sockets.
Definition: MachineCanvasLayoutConstraints.hh:65
Figure::location
wxPoint location() const
Figure::size_
wxSize size_
wxSize of the Figure's bounding rectangle.
Definition: Figure.hh:86
UnitPortFigure::DEFAULT_COLOUR
static const wxColour DEFAULT_COLOUR
Default colour for the figure.
Definition: UnitPortFigure.hh:63
UnitPortFigure::name_
std::string name_
Name of the port.
Definition: UnitPortFigure.hh:68
Figure::location_
wxPoint location_
Top-left location of the Figure's bounding rectangle.
Definition: Figure.hh:84
Figure::xSet
bool xSet() const
MachineCanvasLayoutConstraints::PORT_WIDTH
static const int PORT_WIDTH
Default Width of a port.
Definition: MachineCanvasLayoutConstraints.hh:51
MathTools::requiredBits
static int requiredBits(unsigned long int number)
UnitPortFigure::DEFAULT_BG_COLOUR
static const wxColour DEFAULT_BG_COLOUR
Default background colour for the figure.
Definition: UnitPortFigure.hh:65
Figure::highlighted_
bool highlighted_
Tells if the figure is highlighted.
Definition: Figure.hh:101
Figure::Figure
Figure()
Definition: Figure.cc:44