OpenASIP 2.2
Loading...
Searching...
No Matches
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.
 
 UnitPortFigure (UnitPortFigure &old)
 Copying not allowed.
 

Private Attributes

std::string name_
 Name of the port.
 

Static Private Attributes

static const wxColour DEFAULT_COLOUR = wxColour(0, 0, 0)
 Default colour for the figure.
 
static const wxColour DEFAULT_BG_COLOUR = wxColour(255, 255, 255)
 Default background colour for the figure.
 

Additional Inherited Members

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

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 
)

The Constructor.

Definition at line 51 of file UnitPortFigure.cc.

51 : Figure(), name_(name) {
52 size_ = wxSize(std::max(
53 ((MathTools::requiredBits(bitWidth)+(bitWidth/31))<<1)+
57}
Figure()
Definition Figure.cc:44
wxSize size_
wxSize of the Figure's bounding rectangle.
Definition Figure.hh:86
static const int PORT_MIN_WIDTH
Minimum Width of a port.
static const int PORT_WIDTH
Default Width of a port.
static const int PORT_BASE_WIDTH
Constant used for port width calculation.
static int requiredBits(unsigned long int number)
std::string name() const
std::string name_
Name of the port.

References MachineCanvasLayoutConstraints::PORT_BASE_WIDTH, MachineCanvasLayoutConstraints::PORT_MIN_WIDTH, MachineCanvasLayoutConstraints::PORT_WIDTH, MathTools::requiredBits(), and Figure::size_.

Here is the call graph for this function:

◆ ~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}
wxColour highlight_
Highlight colour.
Definition Figure.hh:99
bool highlighted_
Tells if the figure is highlighted.
Definition Figure.hh:101
wxPoint location_
Top-left location of the Figure's bounding rectangle.
Definition Figure.hh:84
static const wxColour DEFAULT_BG_COLOUR
Default background colour for the figure.
static const wxColour DEFAULT_COLOUR
Default colour for the figure.

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}
std::vector< Figure * > children_
Figure's children.
Definition Figure.hh:90
wxPoint location() const
bool xSet() const
static const int SOCKET_MIN_SPACE
Space dividing connected sockets.
static const int SOCKET_WIDTH
Width of a socket.

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: