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 3508 of file mathplot.cpp.

References drawn, and plotWindow.

3508  : wxPrintout( title )
3509 {
3510  drawn = false;
3511  plotWindow = drawWindow;
3512 }
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 3583 of file mathplot.cpp.

3584 {
3585  return page == 1;
3586 }
bool mpPrintout::OnPrintPage ( int  page)
override

Definition at line 3515 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().

3516 {
3517  wxDC* trgDc = GetDC();
3518 
3519  if( (trgDc) && (page == 1) )
3520  {
3521  wxCoord m_prnX, m_prnY;
3522  int marginX = 50;
3523  int marginY = 50;
3524  trgDc->GetSize( &m_prnX, &m_prnY );
3525 
3526  m_prnX -= (2 * marginX);
3527  m_prnY -= (2 * marginY);
3528  trgDc->SetDeviceOrigin( marginX, marginY );
3529 
3530 #ifdef MATHPLOT_DO_LOGGING
3531  wxLogMessage( wxT( "Print Size: %d x %d\n" ), m_prnX, m_prnY );
3532  wxLogMessage( wxT( "Screen Size: %d x %d\n" ), plotWindow->GetScrX(),
3533  plotWindow->GetScrY() );
3534 #endif
3535 
3536  // Set the scale according to the page:
3537  plotWindow->Fit(
3542  &m_prnX,
3543  &m_prnY );
3544 
3545  // Get the colours of the plotWindow to restore them ath the end
3546  wxColour oldBgColour = plotWindow->GetBackgroundColour();
3547  wxColour oldFgColour = plotWindow->GetForegroundColour();
3548  wxColour oldAxColour = plotWindow->GetAxesColour();
3549 
3550  // Draw background, ensuring to use white background for printing.
3551  trgDc->SetPen( *wxTRANSPARENT_PEN );
3552  // wxBrush brush( plotWindow->GetBackgroundColour() );
3553  wxBrush brush = *wxWHITE_BRUSH;
3554  trgDc->SetBrush( brush );
3555  trgDc->DrawRectangle( 0, 0, m_prnX, m_prnY );
3556 
3557  // Draw all the layers:
3558  // trgDc->SetDeviceOrigin( m_prnX>>1, m_prnY>>1); // Origin at the center
3559  mpLayer* layer;
3560 
3561  for( unsigned int li = 0; li < plotWindow->CountAllLayers(); li++ )
3562  {
3563  layer = plotWindow->GetLayer( li );
3564  layer->Plot( *trgDc, *plotWindow );
3565  }
3566 
3567  ;
3568  // Restore device origin
3569  // trgDc->SetDeviceOrigin(0, 0);
3570  // Restore colours
3571  plotWindow->SetColourTheme( oldBgColour, oldFgColour, oldAxColour );
3572  // Restore drawing
3575  plotWindow->GetDesiredYmax(), NULL, NULL );
3576  plotWindow->UpdateAll();
3577  }
3578 
3579  return true;
3580 }
mpWindow * plotWindow
Definition: mathplot.h:1684
mpLayer * GetLayer(int position)
Definition: mathplot.cpp:3042
const wxColour & GetAxesColour()
Get axes draw colour.
Definition: mathplot.h:1401
int GetScrY(void) const
Get current view&#39;s Y dimension in device context units.
Definition: mathplot.h:1140
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2841
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:3205
int GetScrX(void) const
Get current view&#39;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:2033
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: