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

#include <MachineCanvas.hh>

Inheritance diagram for MachineCanvas:
Inheritance graph
Collaboration diagram for MachineCanvas:
Collaboration graph

Public Member Functions

 MachineCanvas (wxWindow *parent, EditPolicyFactory *policyFactory, ChildFrame *parentFrame=nullptr)
 
virtual ~MachineCanvas ()
 
virtual void OnDraw (wxDC &dc)
 
double zoomFactor ()
 
void setZoomFactor (double factor)
 
void zoomIn ()
 
void zoomOut ()
 
wxSize getFigureSize () const
 
void setTool (MachineCanvasTool *tool)
 
MachineCanvasTooltool ()
 
void setMachine (TTAMachine::Machine *machine)
 
void updateMachine ()
 
EditPartselection ()
 
EditPartfindEditPart (int x, int y)
 
EditPartfindEditPart (const TTAMachine::MachinePart *model)
 
bool hasEditPart (const EditPart *part) const
 
int findEditPartsInRange (int x, int y, int range, std::vector< EditPart * > &found)
 
void highlight (TTAMachine::MachinePart *model, const wxColour &colour)
 
void clearHighlights ()
 
void clearSelection ()
 
void select (EditPart *part)
 
void refreshToolFigure ()
 
void addMove (const TTAMachine::Bus *bus, const TTAMachine::Port *source, const TTAMachine::Port *target)
 
void clearMoves ()
 
bool saveEPS (const std::string &filename, const std::string &title, const std::string &creator="")
 
bool savePNG (const std::string &filename)
 
MachineCanvasOptionsoptions ()
 

Protected Member Functions

void onMouseEvent (wxMouseEvent &event)
 
void refreshLogicalRect (const wxRect &rectangle)
 

Private Attributes

MachineCanvasTooltool_
 Tool which handles mouse events on the MachineCanvas. More...
 
TTAMachine::Machinemachine_
 Machine to draw on the canvas. More...
 
EditPolicyFactoryeditPolicyFactory_
 EditPolicyFactory which creates edit policies for machine components. More...
 
ChildFrameparent_
 Parent frame which holds the MachineCanvas. More...
 
double zoomFactor_
 Zoom factor of the canvas. More...
 
bool dirty_
 Tells if the figures need to be laid out before next draw. More...
 
RootEditPartroot_
 Root of the machine EditPart hierarchy. More...
 
EditPartselection_
 Pointer to the the selected component. More...
 
wxRect toolBounds_
 Bounding box of the last tool figure drawn. More...
 
std::vector< Figure * > moveFigures_
 Move figures to be drawn on the canvas. More...
 
MachineCanvasOptions options_
 

Detailed Description

Machine Object Model visualization canvas.

MachineCanvas is a window which can be utilized to display visualization of a machine object model. The visualization is interactive, and behaviour of machine components can be defined using custom EditPolicies and custom MachineCanvasTools.

Definition at line 64 of file MachineCanvas.hh.

Constructor & Destructor Documentation

◆ MachineCanvas()

MachineCanvas::MachineCanvas ( wxWindow *  parent,
EditPolicyFactory policyFactory,
ChildFrame parentFrame = nullptr 
)

The Constructor, with a parameter for parent frame.

Parameters
parentParent frame of the canvas.
policyFactoryEditPolicyFactory for creating edit policies.

Definition at line 70 of file MachineCanvas.cc.

71  :
72  wxScrolledWindow(parent), tool_(NULL), machine_(NULL),
73  editPolicyFactory_(policyFactory), parent_(parentFrame),
74  zoomFactor_(1.0), dirty_(true), root_(NULL),
75  selection_(NULL), toolBounds_(0, 0, 0, 0) {
76 
77  root_ = new RootEditPart();
78 
79  SetScrollRate(20, 20);
80  SetVirtualSize(1000, 800);
81 }

◆ ~MachineCanvas()

MachineCanvas::~MachineCanvas ( )
virtual

The Destructor.

Definition at line 88 of file MachineCanvas.cc.

88  {
89  if (root_ != NULL) {
90  delete root_;
91  }
92  clearMoves();
93 }

References clearMoves(), and root_.

Here is the call graph for this function:

Member Function Documentation

◆ addMove()

void MachineCanvas::addMove ( const TTAMachine::Bus bus,
const TTAMachine::Port source,
const TTAMachine::Port target 
)

Adds a move to be drawn on the canvas.

Parameters
busTransport bus of the move.
sourceSource port of the move.
targetTarget port of the move.

Definition at line 541 of file MachineCanvas.cc.

541  {
542  std::string procName = "MachineCanvas::addMove";
543  EditPart* busEditPart = findEditPart(bus);
544 
545  if (busEditPart == NULL) {
546  throw InstanceNotFound(__FILE__, __LINE__, procName);
547  }
548 
549  Figure* busFigure = busEditPart->figure();
550  Figure* sourceFigure = NULL;
551  Figure* targetFigure = NULL;
552 
553  if (source != NULL) {
554  EditPart* sourceEditPart = findEditPart(source);
555  if (sourceEditPart == NULL) {
556  throw InstanceNotFound(__FILE__, __LINE__, procName);
557  }
558  sourceFigure = sourceEditPart->figure();
559  }
560 
561  if (target != NULL) {
562  EditPart* targetEditPart = findEditPart(target);
563  if (targetEditPart == NULL) {
564  throw InstanceNotFound(__FILE__, __LINE__, procName);
565  }
566  targetFigure = targetEditPart->figure();
567  }
568 
569  moveFigures_.push_back(
570  new MoveFigure(busFigure, sourceFigure, targetFigure));
571 }

References EditPart::figure(), findEditPart(), and moveFigures_.

Referenced by ProximMachineStateWindow::addMoves().

Here is the call graph for this function:

◆ clearHighlights()

void MachineCanvas::clearHighlights ( )

Clears highlighting of all machine components.

Definition at line 527 of file MachineCanvas.cc.

527  {
528  if (root_ != NULL && root_->contents() != NULL) {
530  }
531 }

References Figure::clearHighlight(), RootEditPart::contents(), EditPart::figure(), and root_.

Referenced by ProximMachineStateWindow::onToggleUtilizations(), and ProximMachineStateWindow::setUtilizationHighlights().

Here is the call graph for this function:

◆ clearMoves()

void MachineCanvas::clearMoves ( )

Clears list of moves to be drawn on the canvas.

Definition at line 577 of file MachineCanvas.cc.

References SequenceTools::deleteAllItems(), and moveFigures_.

Referenced by ProximMachineStateWindow::addMoves(), ProximMachineStateWindow::onToggleMoves(), updateMachine(), and ~MachineCanvas().

Here is the call graph for this function:

◆ clearSelection()

void MachineCanvas::clearSelection ( )

Clears component selection.

Definition at line 395 of file MachineCanvas.cc.

395  {
396  if (selection_ != NULL) {
397  selection_->setSelected(false);
398  }
399  selection_ = NULL;
400  Refresh();
401 }

References selection_, and EditPart::setSelected().

Referenced by MDFView::clearSelection(), SelectTool::leftClick(), ProximMachineCanvasTool::onMouseEvent(), ProximMachineStateWindow::onSimulationStop(), and updateMachine().

Here is the call graph for this function:

◆ findEditPart() [1/2]

EditPart * MachineCanvas::findEditPart ( const TTAMachine::MachinePart model)

Finds an edit part corresponding the given machine part.

Parameters
modelMachinePart to find
Returns
Pointer to the found edit part, or NULL if no edit part was found.

Definition at line 436 of file MachineCanvas.cc.

436  {
437  EditPart* part = NULL;
438  if (root_ != NULL && root_->contents() != NULL) {
439  part = root_->contents()->find(model);
440  }
441  return part;
442 }

References RootEditPart::contents(), EditPart::find(), and root_.

Here is the call graph for this function:

◆ findEditPart() [2/2]

EditPart * MachineCanvas::findEditPart ( int  x,
int  y 
)

Finds an edit part at the given coordinates on the canvas.

Parameters
xX-coordinate of the position to search.
yY-coordinate of the position to search.
Returns
Pointer to the found edit part, or NULL if no edit part was found.

Definition at line 421 of file MachineCanvas.cc.

421  {
422  EditPart* part = NULL;
423  if (root_ != NULL && root_->contents() != NULL) {
424  part = root_->contents()->find(wxPoint(x, y));
425  }
426  return part;
427 }

References RootEditPart::contents(), EditPart::find(), and root_.

Referenced by addMove(), ProximMachineCanvasTool::onMouseEvent(), ConnectTool::onMouseEvent(), SelectTool::onMouseEvent(), and ProximMachineStateWindow::onSimulationStop().

Here is the call graph for this function:

◆ findEditPartsInRange()

int MachineCanvas::findEditPartsInRange ( int  x,
int  y,
int  range,
std::vector< EditPart * > &  found 
)

Finds EditParts around coordinates that are in given range.

Parameters
xX-coordinate of the position to search.
yY-coordinate of the position to search.
rangeSearch range from position (x, y).
foundFound EditParts after call.
Returns
Number of found EditParts. Zero if found nothing.

Definition at line 454 of file MachineCanvas.cc.

455  {
456  if (root_ != NULL && root_->contents() != NULL) {
457  return root_->contents()->findInRange(wxPoint(x, y),
458  static_cast<float>(range), found);
459  }
460  return 0;
461 }

References RootEditPart::contents(), EditPart::findInRange(), and root_.

Referenced by ConnectTool::onMouseEvent().

Here is the call graph for this function:

◆ getFigureSize()

wxSize MachineCanvas::getFigureSize ( ) const

Return the original size of the currently loaded Machine Figure

Definition at line 294 of file MachineCanvas.cc.

294  {
295  return root_->contents()->figure()->bounds().GetSize();
296 }

References Figure::bounds(), RootEditPart::contents(), EditPart::figure(), and root_.

Referenced by FitHeightCmd::Do(), FitWindowCmd::Do(), and FitWidthCmd::Do().

Here is the call graph for this function:

◆ hasEditPart()

bool MachineCanvas::hasEditPart ( const EditPart part) const

Looks for given EditPart recursively.

Parameters
partPart to look up.
Returns
True if canvas has given EditPart.

Definition at line 470 of file MachineCanvas.cc.

470  {
471  if (root_ != NULL && root_->contents() != NULL) {
472  return root_->contents()->hasEditPartRecursive(part);
473  }
474  return false;
475 }

References RootEditPart::contents(), EditPart::hasEditPartRecursive(), and root_.

Referenced by ConnectTool::figure().

Here is the call graph for this function:

◆ highlight()

void MachineCanvas::highlight ( TTAMachine::MachinePart component,
const wxColour &  colour 
)

Highlights figure of a machine component.

Definition at line 510 of file MachineCanvas.cc.

511  {
512 
513  if (root_->contents() == NULL) {
514  return;
515  }
516 
517  EditPart* editPart = root_->contents()->find(component);
518  if (editPart != NULL && editPart->figure() != NULL) {
519  editPart->figure()->highlight(colour);
520  }
521 }

References RootEditPart::contents(), EditPart::figure(), EditPart::find(), Figure::highlight(), and root_.

Referenced by ProximMachineStateWindow::setUtilizationHighlights().

Here is the call graph for this function:

◆ OnDraw()

void MachineCanvas::OnDraw ( wxDC &  dc)
virtual

Called when the window needs to be drawn again.

Parameters
dcThe device context where to do the actual drawing.

Definition at line 101 of file MachineCanvas.cc.

101  {
102 
103  wxBrush backgroundBrush(*wxLIGHT_GREY, wxSOLID);
104  dc.SetBackground(backgroundBrush);
105 
106 #if wxCHECK_VERSION(3, 0, 0)
107  // Do not call Clear() for wxSVGFileDC object cause its not implemented
108  try {
109  (void)dynamic_cast<wxSVGFileDC&> (dc);
110  } catch (const std::bad_cast& e) {
111  dc.Clear();
112  }
113 #else
114  dc.Clear();
115 #endif
116 
117  // Set the canvas font.
118  dc.SetFont(wxFont(10, wxDEFAULT, wxNORMAL, wxNORMAL));
119 
120  // Set scaling factor.
121  dc.SetUserScale(zoomFactor_, zoomFactor_);
122  // draw machine
123  if (root_->contents() != NULL) {
124  if (dirty_) {
125  root_->contents()->figure()->layout(&dc);
126  // Set Canvas virtual size according to the size needed by the
127  // figures.
128  wxRect bounds = root_->contents()->figure()->bounds();
129  SetVirtualSize(int(bounds.GetWidth() * zoomFactor()),
130  int(bounds.GetHeight() * zoomFactor()));
131 
132  dirty_ = false;
133  }
134  root_->contents()->figure()->draw(&dc);
135 
136  }
137 
138  // draw tool figure
139  if (tool() != NULL) {
140  Figure* toolFigure = tool()->figure();
141  if (toolFigure != NULL) {
142  toolFigure->layout(&dc);
143  toolFigure->draw(&dc);
144  }
145  }
146 
147  // Draw moves.
148  for (unsigned i = 0; i < moveFigures_.size(); i++) {
149  moveFigures_[i]->draw(&dc);
150  }
151 
152  // Draw selection rectangle.
153  if (selection() != NULL) {
154  SelectionFigure figure(selection()->figure());
155  figure.layout(&dc);
156  figure.draw(&dc);
157  }
158 }

References Figure::bounds(), RootEditPart::contents(), dirty_, Figure::draw(), EditPart::figure(), MachineCanvasTool::figure(), Figure::layout(), moveFigures_, root_, selection(), tool(), zoomFactor(), and zoomFactor_.

Referenced by MDFView::OnDraw(), ADFPrintout::OnPrintPage(), saveEPS(), and savePNG().

Here is the call graph for this function:

◆ onMouseEvent()

void MachineCanvas::onMouseEvent ( wxMouseEvent &  event)
protected

Handles mouse events on the canvas.

Passes the mouse event to the active tool.

Parameters
eventMouse event to pass to the active tool.

Definition at line 265 of file MachineCanvas.cc.

265  {
266 
267  wxClientDC dc(this);
268  PrepareDC(dc);
269  dc.SetUserScale(zoomFactor_, zoomFactor_);
270 
271  // Zoomin/out with mousewheel
272  if (event.GetEventType() == wxEVT_MOUSEWHEEL) {
273  double factor;
274 
275  if (event.GetWheelRotation() > 0) {
277  } else {
279  }
280  setZoomFactor(factor);
281  }
282 
283  if (tool_ != NULL) {
284  tool_->onMouseEvent(event, dc);
285  }
286 }

References MachineCanvasTool::onMouseEvent(), setZoomFactor(), tool_, CanvasConstants::ZOOM_STEP, zoomFactor(), and zoomFactor_.

Here is the call graph for this function:

◆ options()

MachineCanvasOptions & MachineCanvas::options ( )

Returns the current options used by machine canvas figures.

Returns
Current machine canvas options.

Definition at line 681 of file MachineCanvas.cc.

681  {
682  return options_;
683 }

References options_.

Referenced by ToggleUnitDetailsCmd::Do(), ToggleUnitDetailsCmd::isChecked(), ProximMachineStateWindow::onToggleUnitInfo(), and ProximMachineStateWindow::onUpdateUIEvent().

◆ refreshLogicalRect()

void MachineCanvas::refreshLogicalRect ( const wxRect &  rectangle)
protected

Refreshes area of the MachineCanvas bound by a logical coordinate rectangle.

Parameters
rectangleArea to refresh.

Definition at line 329 of file MachineCanvas.cc.

329  {
330 
331  int x = 0;
332  int y = 0;
333  CalcScrolledPosition(int(rectangle.x * zoomFactor_),
334  int(rectangle.y * zoomFactor_), &x, &y);
335  wxRect zoomed(x, y, int(rectangle.width * zoomFactor_),
336  int(rectangle.height * zoomFactor_));
337 
338  RefreshRect(zoomed);
339 }

References zoomFactor_.

Referenced by refreshToolFigure().

◆ refreshToolFigure()

void MachineCanvas::refreshToolFigure ( )

Refreshes the tool figures on the canvas.

Definition at line 164 of file MachineCanvas.cc.

164  {
165 
166  if (toolBounds_.GetWidth() > 0 && toolBounds_.GetHeight() > 0) {
167  // Clear previous tool figure.
169  }
170 
171  Figure* toolFigure = tool()->figure();
172  if (toolFigure != NULL) {
173  // Draw new tool figure.
174  toolFigure->layout(NULL);
175  toolBounds_ = toolFigure->bounds();
177  } else {
178  toolBounds_ = wxRect(0, 0, 0, 0);
179  }
180 }

References Figure::bounds(), MachineCanvasTool::figure(), Figure::layout(), refreshLogicalRect(), tool(), and toolBounds_.

Referenced by ConnectTool::onMouseEvent().

Here is the call graph for this function:

◆ saveEPS()

bool MachineCanvas::saveEPS ( const std::string &  filename,
const std::string &  title,
const std::string &  creator = "" 
)

Saves the machine figure to an eps file.

Parameters
filenameName of the eps file.
titleTitle of the eps document.
creatorCreator of the eps document.
Returns
True, if the eps was succesfully saved.

Definition at line 617 of file MachineCanvas.cc.

618  {
619 
620  EPSDC dc;
621  dc.setCreator(creator);
622 
623  dc.setTitle(title);
624  dc.StartPage();
625  OnDraw(dc);
626  dc.EndPage();
627 
628  std::ofstream file(filename.c_str());
629 
630  if (file.bad()) {
631  return false;
632  }
633 
634  dc.writeToStream(file);
635  file.close();
636 
637  return true;
638 }

References EPSDC::EndPage(), OnDraw(), EPSDC::setCreator(), EPSDC::setTitle(), EPSDC::StartPage(), and EPSDC::writeToStream().

Referenced by ProDeExportCmd::Do(), and ProximMachineStateWindow::onExport().

Here is the call graph for this function:

◆ savePNG()

bool MachineCanvas::savePNG ( const std::string &  filename)

Saves the machine figure to a .png file.

Parameters
filenameName of the .png file.
Returns
True, if the png was succesfully saved.

Definition at line 648 of file MachineCanvas.cc.

648  {
649 
650  // Refresh machine figure to get the canvas size.
651  wxClientDC clientDC(this);
652  OnDraw(clientDC);
653 
654  // Add minimum coordinates to maximum coordinates to create margins
655  // of equal width.
656  int width = clientDC.MaxX() + clientDC.MinX();
657  int height = clientDC.MaxY() + clientDC.MinY();
658 
659  // Create bitmap and a MemoryDC which writes the bitmap.
660  wxMemoryDC bitmapDC;
661  wxBitmap bitmap(width, height);
662  bitmapDC.SelectObject(bitmap);
663  OnDraw(bitmapDC);
664 
665  wxString file = WxConversion::toWxString(filename);
666 
667  // Save bitmap.
668  if (bitmap.SaveFile(file, wxBITMAP_TYPE_PNG)) {
669  return true;
670  }
671 
672  return false;
673 }

References OnDraw(), and WxConversion::toWxString().

Referenced by ProDeExportCmd::Do(), and ProximMachineStateWindow::onExport().

Here is the call graph for this function:

◆ select()

void MachineCanvas::select ( EditPart part)

Marks an edit part selected.

Previous selection is cleared.

Parameters
partEdit part to select.

Definition at line 485 of file MachineCanvas.cc.

485  {
486  if (selection_ != NULL) {
487  selection_->setSelected(false);
488  }
489 
490  // segments are not supported so we should select the parent
491  // bus instead the segment (a very long standing irritating bug)
492  TTAMachine::Segment* segment =
493  dynamic_cast<TTAMachine::Segment*>(part->model());
494  if (segment != NULL) {
495  // clicked segment, selecting parent bus instead
496  part = part->parent();
497  }
498 
499  selection_ = part;
500  if (selection_ != NULL) {
501  selection_->setSelected(true);
502  }
503  Refresh();
504 }

References EditPart::model(), EditPart::parent(), selection_, and EditPart::setSelected().

Referenced by ConnectTool::leftClick(), SelectTool::leftClick(), ProximMachineCanvasTool::onMouseEvent(), and ProximMachineStateWindow::onSimulationStop().

Here is the call graph for this function:

◆ selection()

EditPart * MachineCanvas::selection ( )

Returns pointer to the EditPart of the selected component.

Returns
Pointer to the selected EditPart, or null if selection is empty.

Definition at line 409 of file MachineCanvas.cc.

409  {
410  return selection_;
411 }

References selection_.

Referenced by OnDraw(), ConnectTool::onMouseEvent(), ProximMachineStateWindow::onSimulationStop(), and MDFView::selection().

◆ setMachine()

void MachineCanvas::setMachine ( TTAMachine::Machine machine)

Sets the machine which is dispalyed on the canvas.

Parameters
machineMachine to display on the canvas.

Definition at line 386 of file MachineCanvas.cc.

386  {
387  machine_ = machine;
388  updateMachine();
389 }

References machine, machine_, and updateMachine().

Referenced by ProximMachineStateWindow::onProgramLoaded(), MDFView::OnUpdate(), and ProximMachineStateWindow::reset().

Here is the call graph for this function:

◆ setTool()

void MachineCanvas::setTool ( MachineCanvasTool tool)

Sets the active tool.

Parameters
toolMachineCanvasTool to activate.

Definition at line 305 of file MachineCanvas.cc.

305  {
306  if (tool_ != NULL) {
307  tool_->deactivate();
308  delete (tool_);
309  }
310  tool_ = tool;
311  tool_->activate();
312 }

References MachineCanvasTool::activate(), MachineCanvasTool::deactivate(), tool(), and tool_.

Referenced by ProximMachineStateWindow::createContents(), SelectCmd::Do(), EditConnectionsCmd::Do(), and MDFView::OnCreate().

Here is the call graph for this function:

◆ setZoomFactor()

void MachineCanvas::setZoomFactor ( double  factor)

Sets the zoom factor of the canvas.

Parameters
factorNew zoom factor of the canvas.

Definition at line 188 of file MachineCanvas.cc.

188  {
189 
190  // Limit the min/max size of the zoom factor
191  if (factor > CanvasConstants::MAX_ZOOM_FACTOR) {
193  } else if (factor < CanvasConstants::MIN_ZOOM_FACTOR) {
195  }
196 
197  // when scrolling, try to:
198  // * On X direction, keep the middle pointing to same position in machine
199  // * On Y direction, keep the upper edge of the windows pointer to
200  // same position in the machine.
201  // This code calculates this and does the scrolling.
202  int x, y;
203  int xSize, ySize;
204  int scrollUnitX, scrollUnitY;
205  GetScrollPixelsPerUnit(&scrollUnitX, &scrollUnitY);
206  GetViewStart(&x, &y);
207  x *= scrollUnitX;
208  y *= scrollUnitY;
209  GetSize(&xSize, &ySize);
210  double xPos = (x + (xSize >> 1)) / zoomFactor_;
211  double yPos = y / zoomFactor_;
212  x = std::max(static_cast<int>(xPos * factor) - (xSize >> 1), 0);
213  y = static_cast<int>(yPos * factor);
214  Scroll((x + (scrollUnitX >> 1)) / scrollUnitX,
215  (y + (scrollUnitY >> 1)) / scrollUnitY);
216 
217  // then do the zooming
218  zoomFactor_ = factor;
219  dirty_ = true;
220  Refresh();
221 }

References dirty_, CanvasConstants::MAX_ZOOM_FACTOR, CanvasConstants::MIN_ZOOM_FACTOR, and zoomFactor_.

Referenced by FitHeightCmd::Do(), FitWidthCmd::Do(), FitWindowCmd::Do(), onMouseEvent(), zoomIn(), and zoomOut().

◆ tool()

MachineCanvasTool * MachineCanvas::tool ( )

Returns pointer to the current tool of the canvas.

Definition at line 318 of file MachineCanvas.cc.

318  {
319  return tool_;
320 }

References tool_.

Referenced by BridgeDialog::BridgeDialog(), BridgeDialog::onCancel(), OnDraw(), BridgeDialog::onOK(), refreshToolFigure(), and setTool().

◆ updateMachine()

void MachineCanvas::updateMachine ( )

Updates the machine from the machine object model.

Definition at line 345 of file MachineCanvas.cc.

345  {
346 
347  clearSelection();
348  clearMoves();
349  dirty_ = true;
350 
351  if (machine_ == NULL) {
352  root_->setContents(NULL);
353  return;
354  }
355 
357  EditPart* contents = factory.createEditPart(machine_);
358  assert(root_ != NULL);
359  root_->setContents(contents);
360  contents->figure()->setOptions(&options_);
361 
362  if (parent_ != nullptr) {
363 
364  wxString text(_T(""));
365  BinaryEncoding* bem(nullptr);
366  try {
367  bem = BEMGenerator(*machine_).generate();
368  int width = bem->width();
369  text = wxString::Format(_T("Instruction width: %u"), width);
370  } catch (...) {
371  text = _T("BEM could not be generated");
372  }
373  delete bem;
374  parent_->setStatus(text, 1);
375  }
376 
377  Refresh();
378 }

References assert, clearMoves(), clearSelection(), MachineEditPartFactory::createEditPart(), dirty_, editPolicyFactory_, EditPart::figure(), BEMGenerator::generate(), machine_, options_, parent_, root_, RootEditPart::setContents(), Figure::setOptions(), ChildFrame::setStatus(), and BinaryEncoding::width().

Referenced by ToggleUnitDetailsCmd::Do(), ProximMachineStateWindow::onToggleUnitInfo(), and setMachine().

Here is the call graph for this function:

◆ zoomFactor()

double MachineCanvas::zoomFactor ( )

Returns the zoom factor of the canvas.

Returns
Zoom factor of the canvas.

Definition at line 230 of file MachineCanvas.cc.

230  {
231  return zoomFactor_;
232 }

References zoomFactor_.

Referenced by OnDraw(), onMouseEvent(), zoomIn(), and zoomOut().

◆ zoomIn()

void MachineCanvas::zoomIn ( )

Zooms in the canvas by a predefined factor

Definition at line 240 of file MachineCanvas.cc.

240  {
241  double factor = zoomFactor() + CanvasConstants::ZOOM_STEP;
242  setZoomFactor(factor);
243 }

References setZoomFactor(), CanvasConstants::ZOOM_STEP, and zoomFactor().

Referenced by ZoomInCmd::Do(), and ProximMachineStateWindow::onZoom().

Here is the call graph for this function:

◆ zoomOut()

void MachineCanvas::zoomOut ( )

Zooms out the canvas by a predefined factor

Definition at line 251 of file MachineCanvas.cc.

251  {
252  double factor = zoomFactor() - CanvasConstants::ZOOM_STEP;
253  setZoomFactor(factor);
254 }

References setZoomFactor(), CanvasConstants::ZOOM_STEP, and zoomFactor().

Referenced by ZoomOutCmd::Do(), and ProximMachineStateWindow::onZoom().

Here is the call graph for this function:

Member Data Documentation

◆ dirty_

bool MachineCanvas::dirty_
private

Tells if the figures need to be laid out before next draw.

Definition at line 130 of file MachineCanvas.hh.

Referenced by OnDraw(), setZoomFactor(), and updateMachine().

◆ editPolicyFactory_

EditPolicyFactory* MachineCanvas::editPolicyFactory_
private

EditPolicyFactory which creates edit policies for machine components.

Definition at line 123 of file MachineCanvas.hh.

Referenced by updateMachine().

◆ machine_

TTAMachine::Machine* MachineCanvas::machine_
private

Machine to draw on the canvas.

Definition at line 121 of file MachineCanvas.hh.

Referenced by setMachine(), and updateMachine().

◆ moveFigures_

std::vector<Figure*> MachineCanvas::moveFigures_
private

Move figures to be drawn on the canvas.

Definition at line 140 of file MachineCanvas.hh.

Referenced by addMove(), clearMoves(), and OnDraw().

◆ options_

MachineCanvasOptions MachineCanvas::options_
private

Definition at line 142 of file MachineCanvas.hh.

Referenced by options(), and updateMachine().

◆ parent_

ChildFrame* MachineCanvas::parent_
private

Parent frame which holds the MachineCanvas.

Definition at line 125 of file MachineCanvas.hh.

Referenced by updateMachine().

◆ root_

RootEditPart* MachineCanvas::root_
private

◆ selection_

EditPart* MachineCanvas::selection_
private

Pointer to the the selected component.

Definition at line 135 of file MachineCanvas.hh.

Referenced by clearSelection(), select(), and selection().

◆ tool_

MachineCanvasTool* MachineCanvas::tool_
private

Tool which handles mouse events on the MachineCanvas.

Definition at line 119 of file MachineCanvas.hh.

Referenced by onMouseEvent(), setTool(), and tool().

◆ toolBounds_

wxRect MachineCanvas::toolBounds_
private

Bounding box of the last tool figure drawn.

Definition at line 137 of file MachineCanvas.hh.

Referenced by refreshToolFigure().

◆ zoomFactor_

double MachineCanvas::zoomFactor_
private

Zoom factor of the canvas.

Definition at line 128 of file MachineCanvas.hh.

Referenced by OnDraw(), onMouseEvent(), refreshLogicalRect(), setZoomFactor(), and zoomFactor().


The documentation for this class was generated from the following files:
MachineCanvas::findEditPart
EditPart * findEditPart(int x, int y)
Definition: MachineCanvas.cc:421
BinaryEncoding
Definition: BinaryEncoding.hh:61
ChildFrame::setStatus
void setStatus(const wxString text, int field=0)
Definition: ChildFrame.cc:76
WxConversion::toWxString
static wxString toWxString(const std::string &source)
MachineCanvas::options_
MachineCanvasOptions options_
Definition: MachineCanvas.hh:142
MachineCanvas::setZoomFactor
void setZoomFactor(double factor)
Definition: MachineCanvas.cc:188
MachineCanvas::clearSelection
void clearSelection()
Definition: MachineCanvas.cc:395
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
Figure::bounds
virtual wxRect bounds() const
EditPart::find
EditPart * find(wxPoint point)
Definition: EditPart.cc:102
TTAMachine::Segment
Definition: Segment.hh:54
MachineCanvas::refreshLogicalRect
void refreshLogicalRect(const wxRect &rectangle)
Definition: MachineCanvas.cc:329
Figure::highlight
void highlight(const wxColour &colour)
Definition: Figure.cc:182
CanvasConstants::MAX_ZOOM_FACTOR
static const double MAX_ZOOM_FACTOR
Maximum zoom factor.
Definition: CanvasConstants.hh:47
MoveFigure
Definition: MoveFigure.hh:41
MachineCanvas::toolBounds_
wxRect toolBounds_
Bounding box of the last tool figure drawn.
Definition: MachineCanvas.hh:137
EPSDC::StartPage
virtual void StartPage()
Definition: EPSDC.cc:560
MachineCanvas::selection_
EditPart * selection_
Pointer to the the selected component.
Definition: MachineCanvas.hh:135
MachineCanvas::editPolicyFactory_
EditPolicyFactory * editPolicyFactory_
EditPolicyFactory which creates edit policies for machine components.
Definition: MachineCanvas.hh:123
CanvasConstants::MIN_ZOOM_FACTOR
static const double MIN_ZOOM_FACTOR
Minimum zoom factor.
Definition: CanvasConstants.hh:45
MachineCanvas::parent_
ChildFrame * parent_
Parent frame which holds the MachineCanvas.
Definition: MachineCanvas.hh:125
Figure::setOptions
void setOptions(MachineCanvasOptions *options)
Definition: Figure.cc:212
EditPart::hasEditPartRecursive
bool hasEditPartRecursive(const EditPart *part) const
Definition: EditPart.cc:274
MachineCanvas::zoomFactor_
double zoomFactor_
Zoom factor of the canvas.
Definition: MachineCanvas.hh:128
BEMGenerator
Definition: BEMGenerator.hh:61
RootEditPart::contents
EditPart * contents() const
MachineCanvas::machine_
TTAMachine::Machine * machine_
Machine to draw on the canvas.
Definition: MachineCanvas.hh:121
MachineCanvasTool::onMouseEvent
virtual void onMouseEvent(wxMouseEvent &event, wxDC &dc)=0
assert
#define assert(condition)
Definition: Application.hh:86
MachineCanvas::selection
EditPart * selection()
Definition: MachineCanvas.cc:409
EPSDC::setTitle
void setTitle(const std::string &title)
Definition: EPSDC.cc:189
SequenceTools::deleteAllItems
static void deleteAllItems(SequenceType &aSequence)
EPSDC::writeToStream
void writeToStream(std::ostream &stream)
Definition: EPSDC.cc:209
CanvasConstants::ZOOM_STEP
static const double ZOOM_STEP
Step between zoom levels.
Definition: CanvasConstants.hh:49
MachineCanvas::tool_
MachineCanvasTool * tool_
Tool which handles mouse events on the MachineCanvas.
Definition: MachineCanvas.hh:119
MachineCanvasTool::activate
virtual void activate()=0
Figure
Definition: Figure.hh:50
RootEditPart::setContents
void setContents(EditPart *contents)
Definition: RootEditPart.cc:63
BinaryEncoding::width
virtual int width(const TCEString &templateName) const
Definition: BinaryEncoding.cc:768
EPSDC
Definition: EPSDC.hh:48
MachineCanvas::updateMachine
void updateMachine()
Definition: MachineCanvas.cc:345
MachineCanvas::tool
MachineCanvasTool * tool()
Definition: MachineCanvas.cc:318
EditPart
Definition: EditPart.hh:60
SelectionFigure
Definition: SelectionFigure.hh:45
MachineCanvasTool::figure
virtual Figure * figure()
Definition: MachineCanvasTool.cc:59
Figure::clearHighlight
void clearHighlight()
Definition: Figure.cc:165
MachineCanvas::moveFigures_
std::vector< Figure * > moveFigures_
Move figures to be drawn on the canvas.
Definition: MachineCanvas.hh:140
MachineEditPartFactory
Definition: MachineEditPartFactory.hh:55
EditPart::model
TTAMachine::MachinePart * model() const
Figure::draw
virtual void draw(wxDC *dc)
Definition: Figure.cc:138
MachineCanvas::clearMoves
void clearMoves()
Definition: MachineCanvas.cc:577
EditPart::figure
Figure * figure() const
EditPart::parent
EditPart * parent() const
EditPart::findInRange
int findInRange(wxPoint point, float radius, std::vector< EditPart * > &found)
Definition: EditPart.cc:219
MachineCanvas::root_
RootEditPart * root_
Root of the machine EditPart hierarchy.
Definition: MachineCanvas.hh:132
Figure::layout
virtual void layout(wxDC *dc)
Definition: Figure.cc:109
EPSDC::EndPage
virtual void EndPage()
Definition: EPSDC.cc:568
EditPart::setSelected
void setSelected(bool select)
RootEditPart
Definition: RootEditPart.hh:44
MachineCanvas::dirty_
bool dirty_
Tells if the figures need to be laid out before next draw.
Definition: MachineCanvas.hh:130
MachineCanvas::zoomFactor
double zoomFactor()
Definition: MachineCanvas.cc:230
MachineCanvas::OnDraw
virtual void OnDraw(wxDC &dc)
Definition: MachineCanvas.cc:101
EPSDC::setCreator
void setCreator(const std::string &creator)
Definition: EPSDC.cc:199
MachineCanvasTool::deactivate
virtual void deactivate()=0
BEMGenerator::generate
BinaryEncoding * generate()
Definition: BEMGenerator.cc:104
InstanceNotFound
Definition: Exception.hh:304