KiCad PCB EDA Suite
mpPrintout Class Reference

Printout class used by mpWindow to draw in the objects to be printed. More...

#include <mathplot.h>

Inheritance diagram for mpPrintout:

Public Member Functions

 mpPrintout (mpWindow *drawWindow, const wxChar *title=_T("wxMathPlot print output"))
 
virtual ~mpPrintout ()
 
void SetDrawState (bool drawState)
 
bool OnPrintPage (int page) override
 
bool HasPage (int page) override
 

Private Attributes

bool drawn
 
mpWindowplotWindow
 

Detailed Description

Printout class used by mpWindow to draw in the objects to be printed.

The object itself can then used by the default wxWidgets printing system to print mppWindow objects.

Definition at line 1672 of file mathplot.h.

Constructor & Destructor Documentation

mpPrintout::mpPrintout ( mpWindow drawWindow,
const wxChar *  title = _T("wxMathPlot print output") 
)

Definition at line 3479 of file mathplot.cpp.

References drawn, and plotWindow.

3479  : wxPrintout( title )
3480 {
3481  drawn = false;
3482  plotWindow = drawWindow;
3483 }
bool drawn
Definition: mathplot.h:1683
mpWindow * plotWindow
Definition: mathplot.h:1684
virtual mpPrintout::~mpPrintout ( )
inlinevirtual

Definition at line 1676 of file mathplot.h.

1676 {};

Member Function Documentation

bool mpPrintout::HasPage ( int  page)
override

Definition at line 3554 of file mathplot.cpp.

3555 {
3556  return page == 1;
3557 }
bool mpPrintout::OnPrintPage ( int  page)
override

Definition at line 3486 of file mathplot.cpp.

References mpWindow::CountAllLayers(), mpWindow::Fit(), mpWindow::GetAxesColour(), mpWindow::GetDesiredXmax(), mpWindow::GetDesiredXmin(), mpWindow::GetDesiredYmax(), mpWindow::GetDesiredYmin(), mpWindow::GetLayer(), mpWindow::GetScrX(), mpWindow::GetScrY(), mpLayer::Plot(), plotWindow, mpWindow::SetColourTheme(), and mpWindow::UpdateAll().

3487 {
3488  wxDC* trgDc = GetDC();
3489 
3490  if( (trgDc) && (page == 1) )
3491  {
3492  wxCoord m_prnX, m_prnY;
3493  int marginX = 50;
3494  int marginY = 50;
3495  trgDc->GetSize( &m_prnX, &m_prnY );
3496 
3497  m_prnX -= (2 * marginX);
3498  m_prnY -= (2 * marginY);
3499  trgDc->SetDeviceOrigin( marginX, marginY );
3500 
3501 #ifdef MATHPLOT_DO_LOGGING
3502  wxLogMessage( wxT( "Print Size: %d x %d\n" ), m_prnX, m_prnY );
3503  wxLogMessage( wxT( "Screen Size: %d x %d\n" ), plotWindow->GetScrX(),
3504  plotWindow->GetScrY() );
3505 #endif
3506 
3507  // Set the scale according to the page:
3508  plotWindow->Fit(
3513  &m_prnX,
3514  &m_prnY );
3515 
3516  // Get the colours of the plotWindow to restore them ath the end
3517  wxColour oldBgColour = plotWindow->GetBackgroundColour();
3518  wxColour oldFgColour = plotWindow->GetForegroundColour();
3519  wxColour oldAxColour = plotWindow->GetAxesColour();
3520 
3521  // Draw background, ensuring to use white background for printing.
3522  trgDc->SetPen( *wxTRANSPARENT_PEN );
3523  // wxBrush brush( plotWindow->GetBackgroundColour() );
3524  wxBrush brush = *wxWHITE_BRUSH;
3525  trgDc->SetBrush( brush );
3526  trgDc->DrawRectangle( 0, 0, m_prnX, m_prnY );
3527 
3528  // Draw all the layers:
3529  // trgDc->SetDeviceOrigin( m_prnX>>1, m_prnY>>1); // Origin at the center
3530  mpLayer* layer;
3531 
3532  for( unsigned int li = 0; li < plotWindow->CountAllLayers(); li++ )
3533  {
3534  layer = plotWindow->GetLayer( li );
3535  layer->Plot( *trgDc, *plotWindow );
3536  }
3537 
3538  ;
3539  // Restore device origin
3540  // trgDc->SetDeviceOrigin(0, 0);
3541  // Restore colours
3542  plotWindow->SetColourTheme( oldBgColour, oldFgColour, oldAxColour );
3543  // Restore drawing
3546  plotWindow->GetDesiredYmax(), NULL, NULL );
3547  plotWindow->UpdateAll();
3548  }
3549 
3550  return true;
3551 }
mpWindow * plotWindow
Definition: mathplot.h:1684
mpLayer * GetLayer(int position)
Definition: mathplot.cpp:3015
const wxColour & GetAxesColour()
Get axes draw colour.
Definition: mathplot.h:1401
int GetScrY(void) const
Get current view's Y dimension in device context units.
Definition: mathplot.h:1140
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2814
double GetDesiredXmax()
Returns the right-border layer coordinate that the user wants the mpWindow to show (it may be not exa...
Definition: mathplot.h:1293
void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour)
Set Color theme.
Definition: mathplot.cpp:3178
int GetScrX(void) const
Get current view's X dimension in device context units.
Definition: mathplot.h:1131
unsigned int CountAllLayers()
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:1276
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:2006
double GetDesiredYmin()
Returns the bottom-border layer coordinate that the user wants the mpWindow to show (it may be not ex...
Definition: mathplot.h:1298
virtual void Plot(wxDC &dc, mpWindow &w)=0
Plot given view of layer to the given device context.
double GetDesiredXmin()
Returns the left-border layer coordinate that the user wants the mpWindow to show (it may be not exac...
Definition: mathplot.h:1288
double GetDesiredYmax()
Returns the top layer-border coordinate that the user wants the mpWindow to show (it may be not exact...
Definition: mathplot.h:1303
void mpPrintout::SetDrawState ( bool  drawState)
inline

Definition at line 1678 of file mathplot.h.

1678 { drawn = drawState; };
bool drawn
Definition: mathplot.h:1683

Member Data Documentation

bool mpPrintout::drawn
private

Definition at line 1683 of file mathplot.h.

Referenced by mpPrintout().

mpWindow* mpPrintout::plotWindow
private

Definition at line 1684 of file mathplot.h.

Referenced by mpPrintout(), and OnPrintPage().


The documentation for this class was generated from the following files: