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

#include <ContentsFigure.hh>

Inheritance diagram for ContentsFigure:
Inheritance graph
Collaboration diagram for ContentsFigure:
Collaboration graph

Public Member Functions

 ContentsFigure ()
 
virtual ~ContentsFigure ()
 
virtual void addChild (Figure *child)
 
- 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)
 
int childCount () const
 
Figurechild (int index) const
 
virtual void layout (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 draw (wxDC *dc)
 
- Protected Member Functions inherited from Figure
virtual void drawSelf (wxDC *dc)
 
void drawChildren (wxDC *dc)
 

Private Member Functions

ContentsFigureoperator= (ContentsFigure &old)
 Assignment not allowed. More...
 
 ContentsFigure (ContentsFigure &old)
 Copying not allowed. More...
 

Private Attributes

UnitContainerFigureunits_
 Contains all the units. More...
 
BusContainerFigurebuses_
 Contains all the buses. More...
 
SocketContainerFiguresockets_
 Contains all the sockets. 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 container EditPart for the whole machine.

Definition at line 49 of file ContentsFigure.hh.

Constructor & Destructor Documentation

◆ ContentsFigure() [1/2]

ContentsFigure::ContentsFigure ( )

The Constructor.

Definition at line 48 of file ContentsFigure.cc.

48  :
49  Figure(), units_(NULL), buses_(NULL), sockets_(NULL) {
50 }

◆ ~ContentsFigure()

ContentsFigure::~ContentsFigure ( )
virtual

The Destructor.

Definition at line 55 of file ContentsFigure.cc.

55  {
56 }

◆ ContentsFigure() [2/2]

ContentsFigure::ContentsFigure ( ContentsFigure old)
private

Copying not allowed.

Member Function Documentation

◆ addChild()

void ContentsFigure::addChild ( Figure figure)
virtual

Overloaded implementation allows only addition of certain types of Figures for layout purposes.

These are UnitContainerFigure, BusContainerFigure and SocketContainerFigure.

Parameters
figureChild figure to add.

Reimplemented from Figure.

Definition at line 68 of file ContentsFigure.cc.

68  {
69 
70  Figure::addChild(figure);
71 
72  UnitContainerFigure* units = dynamic_cast<UnitContainerFigure*>(figure);
73  if (units != NULL) {
74  units_ = units;
75  return;
76  }
77 
78  BusContainerFigure* buses = dynamic_cast<BusContainerFigure*>(figure);
79  if (buses != NULL) {
80  buses_ = buses;
81  return;
82  }
83 
84  SocketContainerFigure* sockets =
85  dynamic_cast<SocketContainerFigure*>(figure);
86  if (sockets != NULL) {
87  sockets_ = sockets;
88  return;
89  }
90 
91  // added a non supported type of a child figure
92  assert(false);
93 }

References Figure::addChild(), assert, buses_, sockets_, and units_.

Here is the call graph for this function:

◆ draw()

void ContentsFigure::draw ( wxDC *  dc)
protectedvirtual

Draws figure on a given device context.

Figure::draw() is overridden to enseure that the containers are drawn in the correct order. (sockets over busses)

Parameters
dcDevice context to draw figures on.

Reimplemented from Figure.

Definition at line 104 of file ContentsFigure.cc.

104  {
105  if (units_ != NULL) {
106  units_->draw(dc);
107  }
108  if (buses_ != NULL) {
109  buses_->draw(dc);
110  }
111  if (sockets_ != NULL) {
112  sockets_->draw(dc);
113  }
114 }

References buses_, Figure::draw(), sockets_, and units_.

Here is the call graph for this function:

◆ layoutChildren()

void ContentsFigure::layoutChildren ( wxDC *  dc)
protectedvirtual

Lays out the subcontainers.

Parameters
dcDevice context.

Reimplemented from Figure.

Definition at line 122 of file ContentsFigure.cc.

122  {
123 
124  int containerX =
126  int containerY =
128 
129  // first layout units if there are any
130 
131  if (units_ != NULL) {
132  units_->setLocation(wxPoint(containerX, containerY));
133  units_->layout(dc);
134  containerY += units_->bounds().GetHeight() +
136  }
137 
138  // then layout buses
139 
140  if (buses_ != NULL) {
141 
143  wxPoint(containerX,
145 
146  if (units_ != NULL && units_->bounds().GetWidth() >
148  buses_->setWidth(units_->bounds().GetWidth());
149  } else {
151  }
152 
153  buses_->layout(dc);
154  }
155 
156  // layout sockets
157 
158  if (sockets_ != NULL) {
159 
160  sockets_->setLocation(wxPoint(containerX, containerY));
161 
162  if (buses_ != NULL) {
163  sockets_->setHeight(buses_->bounds().GetHeight() +
165  sockets_->setWidth(buses_->bounds().GetWidth() +
167  } else if (units_ != NULL) {
168  sockets_->setWidth(units_->bounds().GetWidth() +
170  }
171 
172  sockets_->layout(dc);
173 
174  if (buses_ != NULL) {
175  buses_->setWidth(sockets_->bounds().GetWidth());
176  buses_->layout(dc);
177  }
178  }
179 }

References Figure::bounds(), MachineCanvasLayoutConstraints::BUS_MIN_WIDTH, MachineCanvasLayoutConstraints::BUS_SPACE, buses_, MachineCanvasLayoutConstraints::CONNECTIONS_SPACE, Figure::layout(), Figure::location_, Figure::setHeight(), Figure::setLocation(), Figure::setWidth(), sockets_, units_, MachineCanvasLayoutConstraints::VIEW_LEFT_MARGIN, and MachineCanvasLayoutConstraints::VIEW_MARGIN.

Here is the call graph for this function:

◆ layoutSelf()

void ContentsFigure::layoutSelf ( wxDC *  )
protectedvirtual

Calculates and sets the size of the container.

Depends on the sizes of the child containers: height will be equal to the size of the unit container plus the height of the socket or the bus container, whichever is higher. Width will be equal to the width of the unit container, or the socket container if it is wider.

Reimplemented from Figure.

Definition at line 191 of file ContentsFigure.cc.

191  {
192 
193  int width = 0;
194  int height = 0;
195 
196  if (units_ != NULL) {
197  width = units_->bounds().GetWidth();
198  height = units_->bounds().GetHeight();
199  }
200 
201  int higher = 0;
202 
203  if (sockets_ != NULL) {
204  higher = sockets_->bounds().GetHeight();
205  if (sockets_->bounds().GetWidth() > width) {
206  width = sockets_->bounds().GetWidth();
207  }
208  }
209 
210  if (buses_ != NULL) {
211  if (buses_->bounds().GetHeight() > higher) {
212  higher = buses_->bounds().GetHeight();
213  }
214  if (buses_->bounds().GetWidth() > width) {
215  width = buses_->bounds().GetWidth();
216  }
217  }
218 
219  height += higher + MachineCanvasLayoutConstraints::VIEW_MARGIN * 2;
221 
222  if (units_ != NULL && (buses_ != NULL || sockets_ != NULL)) {
224  }
225 
226  size_.SetWidth(width);
227  size_.SetHeight(height);
228 }

References Figure::bounds(), buses_, MachineCanvasLayoutConstraints::CONNECTIONS_SPACE, Figure::size_, sockets_, units_, and MachineCanvasLayoutConstraints::VIEW_MARGIN.

Here is the call graph for this function:

◆ operator=()

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

Assignment not allowed.

Member Data Documentation

◆ buses_

BusContainerFigure* ContentsFigure::buses_
private

Contains all the buses.

Definition at line 69 of file ContentsFigure.hh.

Referenced by addChild(), draw(), layoutChildren(), and layoutSelf().

◆ sockets_

SocketContainerFigure* ContentsFigure::sockets_
private

Contains all the sockets.

Definition at line 71 of file ContentsFigure.hh.

Referenced by addChild(), draw(), layoutChildren(), and layoutSelf().

◆ units_

UnitContainerFigure* ContentsFigure::units_
private

Contains all the units.

Definition at line 67 of file ContentsFigure.hh.

Referenced by addChild(), draw(), layoutChildren(), and layoutSelf().


The documentation for this class was generated from the following files:
ContentsFigure::units_
UnitContainerFigure * units_
Contains all the units.
Definition: ContentsFigure.hh:67
Figure::setLocation
void setLocation(wxPoint point)
Figure::bounds
virtual wxRect bounds() const
MachineCanvasLayoutConstraints::BUS_MIN_WIDTH
static const int BUS_MIN_WIDTH
Minimum width of a bus.
Definition: MachineCanvasLayoutConstraints.hh:71
Figure::setWidth
void setWidth(int width)
Definition: Figure.cc:81
BusContainerFigure
Definition: BusContainerFigure.hh:47
SocketContainerFigure
Definition: SocketContainerFigure.hh:46
ContentsFigure::buses_
BusContainerFigure * buses_
Contains all the buses.
Definition: ContentsFigure.hh:69
assert
#define assert(condition)
Definition: Application.hh:86
Figure::size_
wxSize size_
wxSize of the Figure's bounding rectangle.
Definition: Figure.hh:86
Figure::addChild
virtual void addChild(Figure *child)
ContentsFigure::sockets_
SocketContainerFigure * sockets_
Contains all the sockets.
Definition: ContentsFigure.hh:71
MachineCanvasLayoutConstraints::CONNECTIONS_SPACE
static const int CONNECTIONS_SPACE
Space reserved for port-socket-connections.
Definition: MachineCanvasLayoutConstraints.hh:87
Figure::location_
wxPoint location_
Top-left location of the Figure's bounding rectangle.
Definition: Figure.hh:84
UnitContainerFigure
Definition: UnitContainerFigure.hh:46
MachineCanvasLayoutConstraints::VIEW_MARGIN
static const int VIEW_MARGIN
Top margin for the whole processor view.
Definition: MachineCanvasLayoutConstraints.hh:83
MachineCanvasLayoutConstraints::BUS_SPACE
static const int BUS_SPACE
Space between buses and bus chains.
Definition: MachineCanvasLayoutConstraints.hh:75
Figure::draw
virtual void draw(wxDC *dc)
Definition: Figure.cc:138
MachineCanvasLayoutConstraints::VIEW_LEFT_MARGIN
static const int VIEW_LEFT_MARGIN
Left margin.
Definition: MachineCanvasLayoutConstraints.hh:85
Figure::Figure
Figure()
Definition: Figure.cc:44
Figure::layout
virtual void layout(wxDC *dc)
Definition: Figure.cc:109
Figure::setHeight
void setHeight(int height)
Definition: Figure.cc:95