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

#include <ADFPrintout.hh>

Inheritance diagram for ADFPrintout:
Inheritance graph
Collaboration diagram for ADFPrintout:
Collaboration graph

Public Member Functions

 ADFPrintout (MachineCanvas &canvas, const wxString &name)
 
virtual ~ADFPrintout ()
 
virtual bool OnPrintPage (int page)
 

Private Attributes

MachineCanvascanvas_
 Machine canvas to print. More...
 

Detailed Description

Printout of an ADF-document.

Handles printing of the machine canvas to printing DCs.

Definition at line 45 of file ADFPrintout.hh.

Constructor & Destructor Documentation

◆ ADFPrintout()

ADFPrintout::ADFPrintout ( MachineCanvas canvas,
const wxString &  name 
)

The Contructor.

Definition at line 40 of file ADFPrintout.cc.

40  :
41  wxPrintout(name),
42  canvas_(canvas) {
43 
44 }

◆ ~ADFPrintout()

ADFPrintout::~ADFPrintout ( )
virtual

The Destructor.

Definition at line 49 of file ADFPrintout.cc.

49  {
50 }

Member Function Documentation

◆ OnPrintPage()

bool ADFPrintout::OnPrintPage ( int  page)
virtual

Called by the framework when a page should be printed.

Definition at line 57 of file ADFPrintout.cc.

57  {
58 
59 
60  wxDC* dc = GetDC();
61 
62  dc->Clear();
63 
64  int machWidth = 0;
65  int machHeight = 0;
66 
67  int paperWidth = 0;
68  int paperHeight = 0;
69 
70  canvas_.GetVirtualSize(&machWidth, &machHeight);
71  dc->GetSize(&paperWidth, &paperHeight);
72 
73  double scaleX = ((double) paperHeight / (double) machHeight) * 0.9;
74  double scaleY = ((double) paperWidth / (double) machWidth) * 0.9;
75 
76  double scale = 0;
77 
78  // Keep aspect ratio by scaling X and Y with the same variable.
79  if (scaleX < scaleY) {
80  scale = scaleX;
81  } else {
82  scale = scaleY;
83  }
84 
85  if (scale > 1) {
86  // Do not scale up.
87  scale = 1;
88  }
89 
90  // Add a 20-pixel marigin to keep the figure in the printable area of
91  // the paper.
92  dc->SetDeviceOrigin(20, 20);
93  dc->SetClippingRegion(0, 0, machWidth + 40, machHeight + 40);
94  // scale the DC to fit the paper.
95  dc->SetUserScale(scale, scale);
96 
97  canvas_.OnDraw(*dc);
98 
99  return true;
100 }

References canvas_, and MachineCanvas::OnDraw().

Here is the call graph for this function:

Member Data Documentation

◆ canvas_

MachineCanvas& ADFPrintout::canvas_
private

Machine canvas to print.

Definition at line 54 of file ADFPrintout.hh.

Referenced by OnPrintPage().


The documentation for this class was generated from the following files:
ADFPrintout::canvas_
MachineCanvas & canvas_
Machine canvas to print.
Definition: ADFPrintout.hh:54
MachineCanvas::OnDraw
virtual void OnDraw(wxDC &dc)
Definition: MachineCanvas.cc:101