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

#include <FitWidthCmd.hh>

Inheritance diagram for FitWidthCmd:
Inheritance graph
Collaboration diagram for FitWidthCmd:
Collaboration graph

Public Member Functions

 FitWidthCmd ()
 
virtual ~FitWidthCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual FitWidthCmdcreate () 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 width.

Definition at line 40 of file FitWidthCmd.hh.

Constructor & Destructor Documentation

◆ FitWidthCmd()

FitWidthCmd::FitWidthCmd ( )

The Constructor.

Definition at line 47 of file FitWidthCmd.cc.

Referenced by create().

◆ ~FitWidthCmd()

FitWidthCmd::~FitWidthCmd ( )
virtual

The Destructor.

Definition at line 56 of file FitWidthCmd.cc.

56  {
57 }

Member Function Documentation

◆ create()

FitWidthCmd * FitWidthCmd::create ( ) const
virtual

Creates and returns a new instance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 105 of file FitWidthCmd.cc.

105  {
106  return new FitWidthCmd();
107 }

References FitWidthCmd().

Here is the call graph for this function:

◆ Do()

bool FitWidthCmd::Do ( )
virtual

Executes the command.

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

Implements GUICommand.

Definition at line 67 of file FitWidthCmd.cc.

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

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 FitWidthCmd::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 116 of file FitWidthCmd.cc.

116  {
118 }

References ProDeConstants::CMD_ICON_ZOOM_FIT_WID.

◆ id()

int FitWidthCmd::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 94 of file FitWidthCmd.cc.

94  {
96 }

References ProDeConstants::COMMAND_ZOOM_FIT_WID.

◆ isEnabled()

bool FitWidthCmd::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 FitWidthCmd.cc.

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

◆ shortName()

string FitWidthCmd::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 FitWidthCmd.cc.

127  {
129 }

References ProDeConstants::CMD_SNAME_ZOOM_FIT_WID.


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
ProDeConstants::CMD_NAME_ZOOM_FIT_WID
static const std::string CMD_NAME_ZOOM_FIT_WID
Command name for the "Fit Width" command.
Definition: ProDeConstants.hh:164
CanvasConstants::MAX_ZOOM_FACTOR
static const double MAX_ZOOM_FACTOR
Maximum zoom factor.
Definition: CanvasConstants.hh:47
ProDeConstants::CMD_SNAME_ZOOM_FIT_WID
static const std::string CMD_SNAME_ZOOM_FIT_WID
Command name for the "Fit Width" command.
Definition: ProDeConstants.hh:278
ProDeConstants::COMMAND_ZOOM_FIT_WID
@ COMMAND_ZOOM_FIT_WID
Definition: ProDeConstants.hh:451
EditorCommand::EditorCommand
EditorCommand(std::string name, wxWindow *parent=NULL)
Definition: EditorCommand.cc:42
EditorCommand::view
wxView * view() const
Definition: EditorCommand.cc:76
ProDeConstants::CMD_ICON_ZOOM_FIT_WID
static const std::string CMD_ICON_ZOOM_FIT_WID
Icon location for the "Fit Width" command.
Definition: ProDeConstants.hh:336
CanvasConstants::AUTOZOOM_STEP
static const double AUTOZOOM_STEP
More precise step for automatic canvas resizing.
Definition: CanvasConstants.hh:51
FitWidthCmd::FitWidthCmd
FitWidthCmd()
Definition: FitWidthCmd.cc:47
MDFView
Definition: MDFView.hh:59