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

#include <FitHeightCmd.hh>

Inheritance diagram for FitHeightCmd:
Inheritance graph
Collaboration diagram for FitHeightCmd:
Collaboration graph

Public Member Functions

 FitHeightCmd ()
 
virtual ~FitHeightCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual FitHeightCmdcreate () 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 height.

Definition at line 40 of file FitHeightCmd.hh.

Constructor & Destructor Documentation

◆ FitHeightCmd()

FitHeightCmd::FitHeightCmd ( )

The Constructor.

Definition at line 47 of file FitHeightCmd.cc.

Referenced by create().

◆ ~FitHeightCmd()

FitHeightCmd::~FitHeightCmd ( )
virtual

The Destructor.

Definition at line 56 of file FitHeightCmd.cc.

56  {
57 }

Member Function Documentation

◆ create()

FitHeightCmd * FitHeightCmd::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 FitHeightCmd.cc.

104  {
105  return new FitHeightCmd();
106 }

References FitHeightCmd().

Here is the call graph for this function:

◆ Do()

bool FitHeightCmd::Do ( )
virtual

Executes the command.

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

Implements GUICommand.

Definition at line 67 of file FitHeightCmd.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 height is smaller
76  // than the window height.
77  double factor = CanvasConstants::MAX_ZOOM_FACTOR;
78  while (cSize.GetHeight() < factor*figureSize.GetHeight()) {
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 FitHeightCmd::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 FitHeightCmd.cc.

115  {
117 }

References ProDeConstants::CMD_ICON_ZOOM_FIT_HEI.

◆ id()

int FitHeightCmd::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 FitHeightCmd.cc.

93  {
95 }

References ProDeConstants::COMMAND_ZOOM_FIT_HEI.

◆ isEnabled()

bool FitHeightCmd::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 138 of file FitHeightCmd.cc.

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

◆ shortName()

string FitHeightCmd::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 125 of file FitHeightCmd.cc.

125  {
127 }

References ProDeConstants::CMD_SNAME_ZOOM_FIT_HEI.


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_SNAME_ZOOM_FIT_HEI
static const std::string CMD_SNAME_ZOOM_FIT_HEI
Command name for the "Fit Height" command.
Definition: ProDeConstants.hh:276
CanvasConstants::MAX_ZOOM_FACTOR
static const double MAX_ZOOM_FACTOR
Maximum zoom factor.
Definition: CanvasConstants.hh:47
ProDeConstants::COMMAND_ZOOM_FIT_HEI
@ COMMAND_ZOOM_FIT_HEI
Definition: ProDeConstants.hh:450
ProDeConstants::CMD_NAME_ZOOM_FIT_HEI
static const std::string CMD_NAME_ZOOM_FIT_HEI
Command name for the "Fit Height" command.
Definition: ProDeConstants.hh:162
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_HEI
static const std::string CMD_ICON_ZOOM_FIT_HEI
Icon location for the "Fit Height" command.
Definition: ProDeConstants.hh:334
FitHeightCmd::FitHeightCmd
FitHeightCmd()
Definition: FitHeightCmd.cc:47
CanvasConstants::AUTOZOOM_STEP
static const double AUTOZOOM_STEP
More precise step for automatic canvas resizing.
Definition: CanvasConstants.hh:51
MDFView
Definition: MDFView.hh:59