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

#include <ProximMachineCanvasTool.hh>

Inheritance diagram for ProximMachineCanvasTool:
Inheritance graph
Collaboration diagram for ProximMachineCanvasTool:
Collaboration graph

Public Member Functions

 ProximMachineCanvasTool (MachineCanvas *canvas)
 
virtual ~ProximMachineCanvasTool ()
 
virtual void activate ()
 
virtual void deactivate ()
 
virtual void onMouseEvent (wxMouseEvent &event, wxDC &dc)
 
- Public Member Functions inherited from MachineCanvasTool
virtual ~MachineCanvasTool ()
 
virtual Figurefigure ()
 

Private Member Functions

void popupMenu (int x, int y)
 

Private Attributes

MachineCanvascanvas_
 MachineCanvas where the tools is used. More...
 

Additional Inherited Members

- Protected Member Functions inherited from MachineCanvasTool
 MachineCanvasTool (MachineCanvas *canvas)
 
- Protected Attributes inherited from MachineCanvasTool
MachineCanvascanvas_
 Machine canvas where the tool is used. More...
 

Detailed Description

MachineCanvasTool for Proxim MachineWindow.

Definition at line 45 of file ProximMachineCanvasTool.hh.

Constructor & Destructor Documentation

◆ ProximMachineCanvasTool()

ProximMachineCanvasTool::ProximMachineCanvasTool ( MachineCanvas canvas)

The Constructor.

Parameters
canvasMachineCanvas where the tool is used.

Definition at line 52 of file ProximMachineCanvasTool.cc.

52  :
53  MachineCanvasTool(canvas),
54  canvas_(canvas) {
55 
56 }

◆ ~ProximMachineCanvasTool()

ProximMachineCanvasTool::~ProximMachineCanvasTool ( )
virtual

The Destructor.

Definition at line 62 of file ProximMachineCanvasTool.cc.

62  {
63 }

Member Function Documentation

◆ activate()

void ProximMachineCanvasTool::activate ( )
virtual

Called when the tool is activated.

Implements MachineCanvasTool.

Definition at line 155 of file ProximMachineCanvasTool.cc.

155  {
156  // do nothing
157 }

◆ deactivate()

void ProximMachineCanvasTool::deactivate ( )
virtual

Called when the tool is deactivated.

Implements MachineCanvasTool.

Definition at line 164 of file ProximMachineCanvasTool.cc.

164  {
165  // do nothing
166 }

◆ onMouseEvent()

void ProximMachineCanvasTool::onMouseEvent ( wxMouseEvent &  event,
wxDC &  dc 
)
virtual

Handles mouse events on the canvas.

Implements MachineCanvasTool.

Definition at line 70 of file ProximMachineCanvasTool.cc.

70  {
71 
72  // Get event position and translate "raw" coordinates to logical ones.
73  wxPoint position = event.GetPosition();
74  int x = position.x;
75  int y = position.y;
76  long logicalX = dc.DeviceToLogicalX(position.x);
77  long logicalY = dc.DeviceToLogicalY(position.y);
78 
79  // Check if there is an EditPart at the cursor position.
80  EditPart* part = canvas_->findEditPart(logicalX, logicalY);
81 
82 
84  if (part != NULL && part->canHandle(&request)) {
85  ComponentCommand* command = part->performRequest(&request);
86  command->Do();
87  delete command;
88  } else {
90  }
91 
92  if (event.LeftDClick()) {
94  if (part != NULL && part->canHandle(&request)) {
95  ComponentCommand* command = part->performRequest(&request);
96  command->setParentWindow(wxGetApp().GetTopWindow());
97  command->Do();
98  delete command;
99  }
100  }
101 
102  if (event.LeftDown()) {
105  Request statusRequest(Request::DETAILS_REQUEST);
106  if (part != NULL && part->canHandle(&statusRequest)) {
107  canvas_->select(part);
108  ComponentCommand* command = part->performRequest(&statusRequest);
109  command->Do();
110  delete command;
111  }
112  }
113 
114  if (event.RightDown()) {
115  popupMenu(x, y);
116  }
117 }

References EditPart::canHandle(), canvas_, ProximMachineStateWindow::clearDetails(), MachineCanvas::clearSelection(), Request::DETAILS_REQUEST, ComponentCommand::Do(), MachineCanvas::findEditPart(), ProximToolbox::machineStateWindow(), Request::MODIFY_REQUEST, EditPart::performRequest(), popupMenu(), MachineCanvas::select(), ComponentCommand::setParentWindow(), ProximMachineStateWindow::setStatusText(), and Request::STATUS_REQUEST.

Here is the call graph for this function:

◆ popupMenu()

void ProximMachineCanvasTool::popupMenu ( int  x,
int  y 
)
private

Pops a menu at the given position.

Parameters
xX-coordinate of the popup location.
yY-coordinate of the popup location.

Definition at line 127 of file ProximMachineCanvasTool.cc.

127  {
128  wxMenu* popupMenu = new wxMenu();
129  popupMenu->Append(
131  popupMenu->Append(
133  popupMenu->AppendSeparator();
134  popupMenu->AppendCheckItem(
136  _T("Display Unit Info"));
137  popupMenu->AppendSeparator();
138  popupMenu->AppendCheckItem(
140  popupMenu->AppendCheckItem(
142  _T("Display utilizations"));
143 
144  popupMenu->AppendSeparator();
145  popupMenu->Append(
146  ProximMachineStateWindow::COMMAND_EXPORT, _T("Export figure..."));
147 
148  canvas_->PopupMenu(popupMenu, wxPoint(x, y));
149 }

References canvas_, ProximMachineStateWindow::COMMAND_EXPORT, ProximMachineStateWindow::COMMAND_TOGGLE_MOVES, ProximMachineStateWindow::COMMAND_TOGGLE_UNIT_INFO, ProximMachineStateWindow::COMMAND_TOGGLE_UTILIZATIONS, ProximMachineStateWindow::COMMAND_ZOOM_IN, and ProximMachineStateWindow::COMMAND_ZOOM_OUT.

Referenced by onMouseEvent().

Member Data Documentation

◆ canvas_

MachineCanvas* ProximMachineCanvasTool::canvas_
private

MachineCanvas where the tools is used.

Definition at line 56 of file ProximMachineCanvasTool.hh.

Referenced by onMouseEvent(), and popupMenu().


The documentation for this class was generated from the following files:
MachineCanvasTool::MachineCanvasTool
MachineCanvasTool(MachineCanvas *canvas)
Definition: MachineCanvasTool.cc:41
MachineCanvas::findEditPart
EditPart * findEditPart(int x, int y)
Definition: MachineCanvas.cc:421
ProximMachineStateWindow::setStatusText
void setStatusText(std::string status)
Definition: ProximMachineStateWindow.cc:274
ProximMachineStateWindow::COMMAND_ZOOM_OUT
@ COMMAND_ZOOM_OUT
Definition: ProximMachineStateWindow.hh:70
ProximMachineCanvasTool::popupMenu
void popupMenu(int x, int y)
Definition: ProximMachineCanvasTool.cc:127
ProximMachineStateWindow::COMMAND_TOGGLE_MOVES
@ COMMAND_TOGGLE_MOVES
Definition: ProximMachineStateWindow.hh:72
MachineCanvas::clearSelection
void clearSelection()
Definition: MachineCanvas.cc:395
EditPart::performRequest
ComponentCommand * performRequest(Request *request) const
Definition: EditPart.cc:297
ComponentCommand::Do
virtual bool Do()=0
ComponentCommand::setParentWindow
void setParentWindow(wxWindow *window)
Definition: ComponentCommand.cc:55
Request::DETAILS_REQUEST
@ DETAILS_REQUEST
Detailed info request.
Definition: Request.hh:53
ProximMachineStateWindow::COMMAND_TOGGLE_UNIT_INFO
@ COMMAND_TOGGLE_UNIT_INFO
Definition: ProximMachineStateWindow.hh:71
ProximMachineStateWindow::COMMAND_EXPORT
@ COMMAND_EXPORT
Definition: ProximMachineStateWindow.hh:74
EditPart
Definition: EditPart.hh:60
ProximMachineCanvasTool::canvas_
MachineCanvas * canvas_
MachineCanvas where the tools is used.
Definition: ProximMachineCanvasTool.hh:56
Request
Definition: Request.hh:43
ComponentCommand
Definition: ComponentCommand.hh:46
MachineCanvas::select
void select(EditPart *part)
Definition: MachineCanvas.cc:485
ProximMachineStateWindow::COMMAND_ZOOM_IN
@ COMMAND_ZOOM_IN
Definition: ProximMachineStateWindow.hh:69
ProximToolbox::machineStateWindow
static ProximMachineStateWindow * machineStateWindow()
Definition: ProximToolbox.cc:123
EditPart::canHandle
bool canHandle(Request *request) const
Definition: EditPart.cc:316
Request::MODIFY_REQUEST
@ MODIFY_REQUEST
Modfify request.
Definition: Request.hh:48
Request::STATUS_REQUEST
@ STATUS_REQUEST
Status request.
Definition: Request.hh:52
ProximMachineStateWindow::clearDetails
void clearDetails()
Definition: ProximMachineStateWindow.cc:488
ProximMachineStateWindow::COMMAND_TOGGLE_UTILIZATIONS
@ COMMAND_TOGGLE_UTILIZATIONS
Definition: ProximMachineStateWindow.hh:73