OpenASIP
2.0
|
#include <MachineCanvas.hh>
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) |
MachineCanvasTool * | tool () |
void | setMachine (TTAMachine::Machine *machine) |
void | updateMachine () |
EditPart * | selection () |
EditPart * | findEditPart (int x, int y) |
EditPart * | findEditPart (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) |
MachineCanvasOptions & | options () |
Protected Member Functions | |
void | onMouseEvent (wxMouseEvent &event) |
void | refreshLogicalRect (const wxRect &rectangle) |
Private Attributes | |
MachineCanvasTool * | tool_ |
Tool which handles mouse events on the MachineCanvas. More... | |
TTAMachine::Machine * | machine_ |
Machine to draw on the canvas. More... | |
EditPolicyFactory * | editPolicyFactory_ |
EditPolicyFactory which creates edit policies for machine components. More... | |
ChildFrame * | parent_ |
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... | |
RootEditPart * | root_ |
Root of the machine EditPart hierarchy. More... | |
EditPart * | selection_ |
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_ |
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.
MachineCanvas::MachineCanvas | ( | wxWindow * | parent, |
EditPolicyFactory * | policyFactory, | ||
ChildFrame * | parentFrame = nullptr |
||
) |
The Constructor, with a parameter for parent frame.
parent | Parent frame of the canvas. |
policyFactory | EditPolicyFactory for creating edit policies. |
Definition at line 70 of file MachineCanvas.cc.
|
virtual |
The Destructor.
Definition at line 88 of file MachineCanvas.cc.
References clearMoves(), and root_.
void MachineCanvas::addMove | ( | const TTAMachine::Bus * | bus, |
const TTAMachine::Port * | source, | ||
const TTAMachine::Port * | target | ||
) |
Adds a move to be drawn on the canvas.
bus | Transport bus of the move. |
source | Source port of the move. |
target | Target port of the move. |
Definition at line 541 of file MachineCanvas.cc.
References EditPart::figure(), findEditPart(), and moveFigures_.
Referenced by ProximMachineStateWindow::addMoves().
void MachineCanvas::clearHighlights | ( | ) |
Clears highlighting of all machine components.
Definition at line 527 of file MachineCanvas.cc.
References Figure::clearHighlight(), RootEditPart::contents(), EditPart::figure(), and root_.
Referenced by ProximMachineStateWindow::onToggleUtilizations(), and ProximMachineStateWindow::setUtilizationHighlights().
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().
void MachineCanvas::clearSelection | ( | ) |
Clears component selection.
Definition at line 395 of file MachineCanvas.cc.
References selection_, and EditPart::setSelected().
Referenced by MDFView::clearSelection(), SelectTool::leftClick(), ProximMachineCanvasTool::onMouseEvent(), ProximMachineStateWindow::onSimulationStop(), and updateMachine().
EditPart * MachineCanvas::findEditPart | ( | const TTAMachine::MachinePart * | model | ) |
Finds an edit part corresponding the given machine part.
model | MachinePart to find |
Definition at line 436 of file MachineCanvas.cc.
References RootEditPart::contents(), EditPart::find(), and root_.
EditPart * MachineCanvas::findEditPart | ( | int | x, |
int | y | ||
) |
Finds an edit part at the given coordinates on the canvas.
x | X-coordinate of the position to search. |
y | Y-coordinate of the position to search. |
Definition at line 421 of file MachineCanvas.cc.
References RootEditPart::contents(), EditPart::find(), and root_.
Referenced by addMove(), ProximMachineCanvasTool::onMouseEvent(), ConnectTool::onMouseEvent(), SelectTool::onMouseEvent(), and ProximMachineStateWindow::onSimulationStop().
int MachineCanvas::findEditPartsInRange | ( | int | x, |
int | y, | ||
int | range, | ||
std::vector< EditPart * > & | found | ||
) |
Finds EditParts around coordinates that are in given range.
x | X-coordinate of the position to search. |
y | Y-coordinate of the position to search. |
range | Search range from position (x, y). |
found | Found EditParts after call. |
Definition at line 454 of file MachineCanvas.cc.
References RootEditPart::contents(), EditPart::findInRange(), and root_.
Referenced by ConnectTool::onMouseEvent().
wxSize MachineCanvas::getFigureSize | ( | ) | const |
Return the original size of the currently loaded Machine Figure
Definition at line 294 of file MachineCanvas.cc.
References Figure::bounds(), RootEditPart::contents(), EditPart::figure(), and root_.
Referenced by FitHeightCmd::Do(), FitWindowCmd::Do(), and FitWidthCmd::Do().
bool MachineCanvas::hasEditPart | ( | const EditPart * | part | ) | const |
Looks for given EditPart recursively.
part | Part to look up. |
Definition at line 470 of file MachineCanvas.cc.
References RootEditPart::contents(), EditPart::hasEditPartRecursive(), and root_.
Referenced by ConnectTool::figure().
void MachineCanvas::highlight | ( | TTAMachine::MachinePart * | component, |
const wxColour & | colour | ||
) |
Highlights figure of a machine component.
Definition at line 510 of file MachineCanvas.cc.
References RootEditPart::contents(), EditPart::figure(), EditPart::find(), Figure::highlight(), and root_.
Referenced by ProximMachineStateWindow::setUtilizationHighlights().
|
virtual |
Called when the window needs to be drawn again.
dc | The device context where to do the actual drawing. |
Definition at line 101 of file MachineCanvas.cc.
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().
|
protected |
Handles mouse events on the canvas.
Passes the mouse event to the active tool.
event | Mouse event to pass to the active tool. |
Definition at line 265 of file MachineCanvas.cc.
References MachineCanvasTool::onMouseEvent(), setZoomFactor(), tool_, CanvasConstants::ZOOM_STEP, zoomFactor(), and zoomFactor_.
MachineCanvasOptions & MachineCanvas::options | ( | ) |
Returns the current options used by machine canvas figures.
Definition at line 681 of file MachineCanvas.cc.
References options_.
Referenced by ToggleUnitDetailsCmd::Do(), ToggleUnitDetailsCmd::isChecked(), ProximMachineStateWindow::onToggleUnitInfo(), and ProximMachineStateWindow::onUpdateUIEvent().
|
protected |
Refreshes area of the MachineCanvas bound by a logical coordinate rectangle.
rectangle | Area to refresh. |
Definition at line 329 of file MachineCanvas.cc.
References zoomFactor_.
Referenced by refreshToolFigure().
void MachineCanvas::refreshToolFigure | ( | ) |
Refreshes the tool figures on the canvas.
Definition at line 164 of file MachineCanvas.cc.
References Figure::bounds(), MachineCanvasTool::figure(), Figure::layout(), refreshLogicalRect(), tool(), and toolBounds_.
Referenced by ConnectTool::onMouseEvent().
bool MachineCanvas::saveEPS | ( | const std::string & | filename, |
const std::string & | title, | ||
const std::string & | creator = "" |
||
) |
Saves the machine figure to an eps file.
filename | Name of the eps file. |
title | Title of the eps document. |
creator | Creator of the eps document. |
Definition at line 617 of file MachineCanvas.cc.
References EPSDC::EndPage(), OnDraw(), EPSDC::setCreator(), EPSDC::setTitle(), EPSDC::StartPage(), and EPSDC::writeToStream().
Referenced by ProDeExportCmd::Do(), and ProximMachineStateWindow::onExport().
bool MachineCanvas::savePNG | ( | const std::string & | filename | ) |
Saves the machine figure to a .png file.
filename | Name of the .png file. |
Definition at line 648 of file MachineCanvas.cc.
References OnDraw(), and WxConversion::toWxString().
Referenced by ProDeExportCmd::Do(), and ProximMachineStateWindow::onExport().
void MachineCanvas::select | ( | EditPart * | part | ) |
Marks an edit part selected.
Previous selection is cleared.
part | Edit part to select. |
Definition at line 485 of file MachineCanvas.cc.
References EditPart::model(), EditPart::parent(), selection_, and EditPart::setSelected().
Referenced by ConnectTool::leftClick(), SelectTool::leftClick(), ProximMachineCanvasTool::onMouseEvent(), and ProximMachineStateWindow::onSimulationStop().
EditPart * MachineCanvas::selection | ( | ) |
Returns pointer to the EditPart of the selected component.
Definition at line 409 of file MachineCanvas.cc.
References selection_.
Referenced by OnDraw(), ConnectTool::onMouseEvent(), ProximMachineStateWindow::onSimulationStop(), and MDFView::selection().
void MachineCanvas::setMachine | ( | TTAMachine::Machine * | machine | ) |
Sets the machine which is dispalyed on the canvas.
machine | Machine to display on the canvas. |
Definition at line 386 of file MachineCanvas.cc.
References machine, machine_, and updateMachine().
Referenced by ProximMachineStateWindow::onProgramLoaded(), MDFView::OnUpdate(), and ProximMachineStateWindow::reset().
void MachineCanvas::setTool | ( | MachineCanvasTool * | tool | ) |
Sets the active tool.
tool | MachineCanvasTool to activate. |
Definition at line 305 of file MachineCanvas.cc.
References MachineCanvasTool::activate(), MachineCanvasTool::deactivate(), tool(), and tool_.
Referenced by ProximMachineStateWindow::createContents(), SelectCmd::Do(), EditConnectionsCmd::Do(), and MDFView::OnCreate().
void MachineCanvas::setZoomFactor | ( | double | factor | ) |
Sets the zoom factor of the canvas.
factor | New zoom factor of the canvas. |
Definition at line 188 of file MachineCanvas.cc.
References dirty_, CanvasConstants::MAX_ZOOM_FACTOR, CanvasConstants::MIN_ZOOM_FACTOR, and zoomFactor_.
Referenced by FitHeightCmd::Do(), FitWidthCmd::Do(), FitWindowCmd::Do(), onMouseEvent(), zoomIn(), and zoomOut().
MachineCanvasTool * MachineCanvas::tool | ( | ) |
Returns pointer to the current tool of the canvas.
Definition at line 318 of file MachineCanvas.cc.
References tool_.
Referenced by BridgeDialog::BridgeDialog(), BridgeDialog::onCancel(), OnDraw(), BridgeDialog::onOK(), refreshToolFigure(), and setTool().
void MachineCanvas::updateMachine | ( | ) |
Updates the machine from the machine object model.
Definition at line 345 of file MachineCanvas.cc.
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().
double MachineCanvas::zoomFactor | ( | ) |
Returns the zoom factor of the canvas.
Definition at line 230 of file MachineCanvas.cc.
References zoomFactor_.
Referenced by OnDraw(), onMouseEvent(), zoomIn(), and zoomOut().
void MachineCanvas::zoomIn | ( | ) |
Zooms in the canvas by a predefined factor
Definition at line 240 of file MachineCanvas.cc.
References setZoomFactor(), CanvasConstants::ZOOM_STEP, and zoomFactor().
Referenced by ZoomInCmd::Do(), and ProximMachineStateWindow::onZoom().
void MachineCanvas::zoomOut | ( | ) |
Zooms out the canvas by a predefined factor
Definition at line 251 of file MachineCanvas.cc.
References setZoomFactor(), CanvasConstants::ZOOM_STEP, and zoomFactor().
Referenced by ZoomOutCmd::Do(), and ProximMachineStateWindow::onZoom().
|
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().
|
private |
EditPolicyFactory which creates edit policies for machine components.
Definition at line 123 of file MachineCanvas.hh.
Referenced by updateMachine().
|
private |
Machine to draw on the canvas.
Definition at line 121 of file MachineCanvas.hh.
Referenced by setMachine(), and updateMachine().
|
private |
Move figures to be drawn on the canvas.
Definition at line 140 of file MachineCanvas.hh.
Referenced by addMove(), clearMoves(), and OnDraw().
|
private |
Definition at line 142 of file MachineCanvas.hh.
Referenced by options(), and updateMachine().
|
private |
Parent frame which holds the MachineCanvas.
Definition at line 125 of file MachineCanvas.hh.
Referenced by updateMachine().
|
private |
Root of the machine EditPart hierarchy.
Definition at line 132 of file MachineCanvas.hh.
Referenced by clearHighlights(), findEditPart(), findEditPartsInRange(), getFigureSize(), hasEditPart(), highlight(), OnDraw(), updateMachine(), and ~MachineCanvas().
|
private |
Pointer to the the selected component.
Definition at line 135 of file MachineCanvas.hh.
Referenced by clearSelection(), select(), and selection().
|
private |
Tool which handles mouse events on the MachineCanvas.
Definition at line 119 of file MachineCanvas.hh.
Referenced by onMouseEvent(), setTool(), and tool().
|
private |
Bounding box of the last tool figure drawn.
Definition at line 137 of file MachineCanvas.hh.
Referenced by refreshToolFigure().
|
private |
Zoom factor of the canvas.
Definition at line 128 of file MachineCanvas.hh.
Referenced by OnDraw(), onMouseEvent(), refreshLogicalRect(), setZoomFactor(), and zoomFactor().