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

#include <Figure.hh>

Inheritance diagram for Figure:
Inheritance graph
Collaboration diagram for Figure:
Collaboration graph

Public Member Functions

 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)
 
void drawChildren (wxDC *dc)
 
virtual void layoutSelf (wxDC *)
 
virtual void layoutChildren (wxDC *)
 

Protected Attributes

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...
 

Private Member Functions

Figureoperator= (Figure &old)
 Assignment not allowed. More...
 
 Figure (Figure &old)
 Copying not allowed. More...
 

Detailed Description

Abstract base class for classes that represent the visuals of a machine block.

Can draw itself on the given device context. May contain other Figures as children, and in that case, knows also how to layout them.

Definition at line 50 of file Figure.hh.

Constructor & Destructor Documentation

◆ Figure() [1/2]

Figure::Figure ( )

The Constructor.

Definition at line 44 of file Figure.cc.

44  :
45  location_(wxPoint(0,0)), size_(wxSize(0,0)), minSize_(wxSize(0,0)),
46  xSet_(false), laidOut_(false), drawn_(false), highlight_(*wxRED),
47  highlighted_(false), options_(NULL) {
48 }

◆ ~Figure()

Figure::~Figure ( )
virtual

The Destructor.

Definition at line 53 of file Figure.cc.

53  {
54 }

◆ Figure() [2/2]

Figure::Figure ( Figure old)
private

Copying not allowed.

Member Function Documentation

◆ addChild()

virtual void Figure::addChild ( Figure child)
virtual

Reimplemented in ContentsFigure.

Referenced by ContentsFigure::addChild(), and EditPart::addChild().

◆ bounds()

virtual wxRect Figure::bounds ( ) const
virtual

◆ child()

Figure* Figure::child ( int  index) const

◆ childCount()

int Figure::childCount ( ) const

◆ clearHighlight()

void Figure::clearHighlight ( )

Clears highlighting of the figure.

The highlight is cleared next time the figure is drawn. This function has no effect if the figure isn't highlighted.

Definition at line 165 of file Figure.cc.

165  {
166  highlighted_ = false;
167  // Clear highlighting of child figures.
168  vector<Figure*>::iterator i = children_.begin();
169  for (; i != children_.end(); i++) {
170  (*i)->clearHighlight();
171  }
172 }

References children_, and highlighted_.

Referenced by MachineCanvas::clearHighlights().

◆ clearXSetFlag()

void Figure::clearXSetFlag ( )

◆ draw()

void Figure::draw ( wxDC *  dc)
virtual

Draws the Figure and its children on the given device context.

Parameters
dcThe device context to draw the Figure on.
Note
The Figure must be laid out before drawing!

Reimplemented in ContentsFigure.

Definition at line 138 of file Figure.cc.

138  {
139  assert(laidOut_ == true);
140  drawSelf(dc);
141  drawChildren(dc);
142  drawn_ = true;
143 }

References assert, drawChildren(), drawn_, drawSelf(), and laidOut_.

Referenced by ContentsFigure::draw(), and MachineCanvas::OnDraw().

Here is the call graph for this function:

◆ drawChildren()

void Figure::drawChildren ( wxDC *  dc)
protected

Draws the Figure's children.

Parameters
dcThe device context to draw the children on.

Definition at line 151 of file Figure.cc.

151  {
152  vector<Figure*>::iterator i = children_.begin();
153  for (; i != children_.end(); i++) {
154  (*i)->draw(dc);
155  }
156 }

References children_.

Referenced by draw().

◆ drawSelf()

virtual void Figure::drawSelf ( wxDC *  dc)
protectedvirtual

◆ highlight()

void Figure::highlight ( const wxColour &  colour)

Highlights the figure with given colour.

The figure is highlighted next time it's drawn.

Parameters
colourHighlight colour.

Definition at line 182 of file Figure.cc.

182  {
183 
184  highlight_ = colour;
185  highlighted_ = true;
186  // Highlight child figures.
187  vector<Figure*>::iterator i = children_.begin();
188  for (; i != children_.end(); i++) {
189  (*i)->highlight(colour);
190  }
191 }

References children_, highlight_, and highlighted_.

Referenced by MachineCanvas::highlight().

◆ layout()

void Figure::layout ( wxDC *  dc)
virtual

Lays out the Figure and its children.

Parameters
dcThe device context to layout children on.

Reimplemented in UnitFigure.

Definition at line 109 of file Figure.cc.

109  {
110  layoutChildren(dc);
111  layoutSelf(dc);
112  laidOut_ = true;
113 }

References laidOut_, layoutChildren(), and layoutSelf().

Referenced by ContentsFigure::layoutChildren(), MachineCanvas::OnDraw(), and MachineCanvas::refreshToolFigure().

Here is the call graph for this function:

◆ layoutChildren()

void Figure::layoutChildren ( wxDC *  dc)
protectedvirtual

Empty default implementation that can be used if no specific laying out needs to be done or the Figure doesn't have children.

Tells all children to layout themselves.

Parameters
dcDevice context.

Reimplemented in ContentsFigure, BusFigure, UnitFigure, BusContainerFigure, BidirBridgeFigure, BusChainFigure, UnitContainerFigure, UnitPortFigure, and SocketContainerFigure.

Definition at line 124 of file Figure.cc.

124  {
125  vector<Figure*>::iterator i = children_.begin();
126  for (; i != children_.end(); i++) {
127  (*i)->layout(dc);
128  }
129 }

References children_.

Referenced by layout().

◆ layoutSelf()

virtual void Figure::layoutSelf ( wxDC *  )
protectedvirtual

◆ location()

wxPoint Figure::location ( ) const

◆ operator=()

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

Assignment not allowed.

◆ options()

MachineCanvasOptions * Figure::options ( )

Returns the options object used by this figure and it's children.

Returns
Current figure options.

Definition at line 199 of file Figure.cc.

199  {
200  return options_;
201 }

References options_.

Referenced by UnitFigure::drawSelf(), UnitFigure::layoutSelf(), and setOptions().

◆ setBounds()

void Figure::setBounds ( wxSize  bounds)

Sets the size of the Figure's bounding rectangle.

Parameters
boundsNew size.

Definition at line 62 of file Figure.cc.

62  {
63  if (bounds.GetHeight() < size_.GetHeight()) {
64  size_.SetHeight(minSize_.GetHeight());
65  } else {
66  size_.SetHeight(bounds.GetHeight());
67  }
68  if (bounds.GetWidth() < size_.GetWidth()) {
69  size_.SetWidth(minSize_.GetWidth());
70  } else {
71  size_.SetWidth(bounds.GetWidth());
72  }
73 }

References bounds(), minSize_, and size_.

Here is the call graph for this function:

◆ setHeight()

void Figure::setHeight ( int  height)

Sets the height of the Figure.

Parameters
heightNew height.

Definition at line 95 of file Figure.cc.

95  {
96  if (height < minSize_.GetHeight()) {
97  size_.SetHeight(minSize_.GetHeight());
98  } else {
99  size_.SetHeight(height);
100  }
101 }

References minSize_, and size_.

Referenced by ContentsFigure::layoutChildren(), SocketPortConnFigure::layoutSelf(), and SocketBusConnFigure::layoutSelf().

◆ setLocation()

void Figure::setLocation ( wxPoint  point)

◆ setOptions()

void Figure::setOptions ( MachineCanvasOptions options)

Sets the options object used for setting drawing options.

Options are set recursively for figure children.

Parameters
optionsOptions to set.

Definition at line 212 of file Figure.cc.

212  {
213  vector<Figure*>::iterator i = children_.begin();
214  for (; i != children_.end(); i++) {
215  (*i)->setOptions(options);
216  }
217  options_ = options;
218 }

References children_, options(), and options_.

Referenced by MachineCanvas::updateMachine().

Here is the call graph for this function:

◆ setPreferredX()

void Figure::setPreferredX ( int  x)

◆ setWidth()

void Figure::setWidth ( int  width)

Sets the width of the Figure.

Parameters
widthNew width.

Definition at line 81 of file Figure.cc.

81  {
82  if (width < minSize_.GetWidth()) {
83  size_.SetWidth(minSize_.GetWidth());
84  } else {
85  size_.SetWidth(width);
86  }
87 }

References minSize_, and size_.

Referenced by ContentsFigure::layoutChildren(), SocketPortConnFigure::layoutSelf(), and SocketBusConnFigure::layoutSelf().

◆ setX()

void Figure::setX ( int  x)

◆ setY()

void Figure::setY ( int  y)

◆ virtualBounds()

virtual wxRect Figure::virtualBounds ( ) const
virtual

◆ xSet()

bool Figure::xSet ( ) const

Member Data Documentation

◆ children_

std::vector<Figure*> Figure::children_
protected

◆ drawn_

bool Figure::drawn_
protected

Tells whether the Figure and its children have been drawn or not.

Definition at line 97 of file Figure.hh.

Referenced by draw().

◆ highlight_

wxColour Figure::highlight_
protected

◆ highlighted_

bool Figure::highlighted_
protected

◆ laidOut_

bool Figure::laidOut_
protected

Tells whether the Figure and its children have been laid out or not.

Definition at line 95 of file Figure.hh.

Referenced by draw(), UnitFigure::layout(), layout(), and MoveFigure::MoveFigure().

◆ location_

wxPoint Figure::location_
protected

◆ minSize_

wxSize Figure::minSize_
protected

◆ options_

MachineCanvasOptions* Figure::options_
protected

Options which are used for customizing figures.

Definition at line 104 of file Figure.hh.

Referenced by options(), and setOptions().

◆ size_

wxSize Figure::size_
protected

◆ xSet_

bool Figure::xSet_
protected

Tells if x-coordinate has been fixed.

Definition at line 93 of file Figure.hh.


The documentation for this class was generated from the following files:
Figure::drawSelf
virtual void drawSelf(wxDC *dc)
Figure::bounds
virtual wxRect bounds() const
Figure::laidOut_
bool laidOut_
Tells whether the Figure and its children have been laid out or not.
Definition: Figure.hh:95
Figure::drawChildren
void drawChildren(wxDC *dc)
Definition: Figure.cc:151
Figure::children_
std::vector< Figure * > children_
Figure's children.
Definition: Figure.hh:90
Figure::highlight_
wxColour highlight_
Highlight colour.
Definition: Figure.hh:99
Figure::layoutSelf
virtual void layoutSelf(wxDC *)
Figure::options_
MachineCanvasOptions * options_
Options which are used for customizing figures.
Definition: Figure.hh:104
assert
#define assert(condition)
Definition: Application.hh:86
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
Figure::xSet_
bool xSet_
Tells if x-coordinate has been fixed.
Definition: Figure.hh:93
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::options
MachineCanvasOptions * options()
Definition: Figure.cc:199
Figure::drawn_
bool drawn_
Tells whether the Figure and its children have been drawn or not.
Definition: Figure.hh:97
Figure::layoutChildren
virtual void layoutChildren(wxDC *)
Definition: Figure.cc:124