OpenASIP  2.0
Public Member Functions | List of all members
FitWindowCmd Class Reference

#include <FitWindowCmd.hh>

Inheritance diagram for FitWindowCmd:
Inheritance graph
Collaboration diagram for FitWindowCmd:
Collaboration graph

Public Member Functions

 FitWindowCmd ()
 
virtual ~FitWindowCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual FitWindowCmdcreate () const
 
virtual std::string icon () const
 
virtual std::string shortName () const
 
virtual bool isEnabled ()
 
- Public Member Functions inherited from EditorCommand
 EditorCommand (std::string name, wxWindow *parent=NULL)
 
virtual ~EditorCommand ()
 
void setView (wxView *view)
 
wxView * view () const
 
- Public Member Functions inherited from GUICommand
 GUICommand (std::string name, wxWindow *parent)
 
virtual ~GUICommand ()
 
virtual bool isChecked () const
 
void setParentWindow (wxWindow *view)
 
wxWindow * parentWindow () const
 
std::string name () const
 

Detailed Description

EditorCommand for zooming the canvas to fit the window.

Definition at line 40 of file FitWindowCmd.hh.

Constructor & Destructor Documentation

◆ FitWindowCmd()

FitWindowCmd::FitWindowCmd ( )

The Constructor.

Definition at line 46 of file FitWindowCmd.cc.

Referenced by create().

◆ ~FitWindowCmd()

FitWindowCmd::~FitWindowCmd ( )
virtual

The Destructor.

Definition at line 55 of file FitWindowCmd.cc.

55  {
56 }

Member Function Documentation

◆ create()

FitWindowCmd * FitWindowCmd::create ( ) const
virtual

Creates and returns a new instance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 104 of file FitWindowCmd.cc.

104  {
105  return new FitWindowCmd();
106 }

References FitWindowCmd().

Here is the call graph for this function:

◆ Do()

bool FitWindowCmd::Do ( )
virtual

Executes the command.

Returns
true, if the command was succesfully executed, false otherwise.

Implements GUICommand.

Definition at line 66 of file FitWindowCmd.cc.

66  {
67 
68  MDFView* mView = dynamic_cast<MDFView*>(view());
69  MachineCanvas* canvas = mView->canvas();
70 
71  wxSize figureSize = canvas->getFigureSize();
72  wxSize cSize = canvas->GetSize();
73 
74  // decrease zoom factor from maximum until the figure fits in the window
75  double factor = CanvasConstants::MAX_ZOOM_FACTOR;
76  while (cSize.GetWidth() < factor*figureSize.GetWidth() ||
77  cSize.GetHeight() < factor*figureSize.GetHeight()) {
78 
79  factor = factor - CanvasConstants::AUTOZOOM_STEP;
80  }
81 
82  canvas->setZoomFactor(factor);
83  return true;
84 }

References CanvasConstants::AUTOZOOM_STEP, MDFView::canvas(), MachineCanvas::getFigureSize(), CanvasConstants::MAX_ZOOM_FACTOR, MachineCanvas::setZoomFactor(), and EditorCommand::view().

Here is the call graph for this function:

◆ icon()

string FitWindowCmd::icon ( ) const
virtual

Returns path to the command's icon file.

Returns
Full path to the command's icon file.

Reimplemented from EditorCommand.

Definition at line 115 of file FitWindowCmd.cc.

115  {
117 }

References ProDeConstants::CMD_ICON_ZOOM_FIT_WIN.

◆ id()

int FitWindowCmd::id ( ) const
virtual

Returns id of this command.

Returns
ID for this command to be used in menus and toolbars.

Implements GUICommand.

Definition at line 93 of file FitWindowCmd.cc.

93  {
95 }

References ProDeConstants::COMMAND_ZOOM_FIT_WIN.

◆ isEnabled()

bool FitWindowCmd::isEnabled ( )
virtual

Returns true when the command is executable, false when not.

This command is executable when a document is open.

Returns
True, if a document is open.

Reimplemented from EditorCommand.

Definition at line 140 of file FitWindowCmd.cc.

140  {
141  wxDocManager* manager = wxGetApp().docManager();
142  if (manager->GetCurrentView() != NULL) {
143  return true;
144  }
145  return false;
146 }

◆ shortName()

string FitWindowCmd::shortName ( ) const
virtual

Returns short version of the command name.

Returns
Short name of the command to be used in the toolbar.

Reimplemented from GUICommand.

Definition at line 127 of file FitWindowCmd.cc.

127  {
129 }

References ProDeConstants::CMD_SNAME_ZOOM_FIT_WIN.


The documentation for this class was generated from the following files:
MachineCanvas::getFigureSize
wxSize getFigureSize() const
Definition: MachineCanvas.cc:294
MachineCanvas
Definition: MachineCanvas.hh:64
MachineCanvas::setZoomFactor
void setZoomFactor(double factor)
Definition: MachineCanvas.cc:188
MDFView::canvas
MachineCanvas * canvas() const
Definition: MDFView.cc:229
CanvasConstants::MAX_ZOOM_FACTOR
static const double MAX_ZOOM_FACTOR
Maximum zoom factor.
Definition: CanvasConstants.hh:47
ProDeConstants::CMD_ICON_ZOOM_FIT_WIN
static const std::string CMD_ICON_ZOOM_FIT_WIN
Icon location for the "Fit Window" command.
Definition: ProDeConstants.hh:332
ProDeConstants::COMMAND_ZOOM_FIT_WIN
@ COMMAND_ZOOM_FIT_WIN
Definition: ProDeConstants.hh:449
EditorCommand::EditorCommand
EditorCommand(std::string name, wxWindow *parent=NULL)
Definition: EditorCommand.cc:42
EditorCommand::view
wxView * view() const
Definition: EditorCommand.cc:76
ProDeConstants::CMD_NAME_ZOOM_FIT_WIN
static const std::string CMD_NAME_ZOOM_FIT_WIN
Command name for the "Fit Window" command.
Definition: ProDeConstants.hh:160
CanvasConstants::AUTOZOOM_STEP
static const double AUTOZOOM_STEP
More precise step for automatic canvas resizing.
Definition: CanvasConstants.hh:51
ProDeConstants::CMD_SNAME_ZOOM_FIT_WIN
static const std::string CMD_SNAME_ZOOM_FIT_WIN
Command name for the "Fit Window" command.
Definition: ProDeConstants.hh:274
MDFView
Definition: MDFView.hh:59
FitWindowCmd::FitWindowCmd
FitWindowCmd()
Definition: FitWindowCmd.cc:46