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 1702 of file mathplot.h.

Constructor & Destructor Documentation

◆ mpPrintout()

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

Definition at line 2988 of file mathplot.cpp.

2988 : wxPrintout( title )
2989{
2990 drawn = false;
2991 plotWindow = drawWindow;
2992}
bool drawn
Definition: mathplot.h:1713
mpWindow * plotWindow
Definition: mathplot.h:1714

References drawn, and plotWindow.

◆ ~mpPrintout()

virtual mpPrintout::~mpPrintout ( )
inlinevirtual

Definition at line 1706 of file mathplot.h.

1706{};

Member Function Documentation

◆ HasPage()

bool mpPrintout::HasPage ( int  page)
override

Definition at line 3057 of file mathplot.cpp.

3058{
3059 return page == 1;
3060}

◆ OnPrintPage()

bool mpPrintout::OnPrintPage ( int  page)
override

Definition at line 2995 of file mathplot.cpp.

2996{
2997 wxDC* trgDc = GetDC();
2998
2999 if( (trgDc) && (page == 1) )
3000 {
3001 wxCoord m_prnX, m_prnY;
3002 int marginX = 50;
3003 int marginY = 50;
3004 trgDc->GetSize( &m_prnX, &m_prnY );
3005
3006 m_prnX -= (2 * marginX);
3007 m_prnY -= (2 * marginY);
3008 trgDc->SetDeviceOrigin( marginX, marginY );
3009
3010 // Set the scale according to the page:
3011 plotWindow->Fit(
3016 &m_prnX,
3017 &m_prnY );
3018
3019 // Get the colours of the plotWindow to restore them ath the end
3020 wxColour oldBgColour = plotWindow->GetBackgroundColour();
3021 wxColour oldFgColour = plotWindow->GetForegroundColour();
3022 wxColour oldAxColour = plotWindow->GetAxesColour();
3023
3024 // Draw background, ensuring to use white background for printing.
3025 trgDc->SetPen( *wxTRANSPARENT_PEN );
3026 // wxBrush brush( plotWindow->GetBackgroundColour() );
3027 wxBrush brush = *wxWHITE_BRUSH;
3028 trgDc->SetBrush( brush );
3029 trgDc->DrawRectangle( 0, 0, m_prnX, m_prnY );
3030
3031 // Draw all the layers:
3032 // trgDc->SetDeviceOrigin( m_prnX>>1, m_prnY>>1); // Origin at the center
3033 mpLayer* layer;
3034
3035 for( unsigned int li = 0; li < plotWindow->CountAllLayers(); li++ )
3036 {
3037 layer = plotWindow->GetLayer( li );
3038 layer->Plot( *trgDc, *plotWindow );
3039 }
3040
3041 ;
3042 // Restore device origin
3043 // trgDc->SetDeviceOrigin(0, 0);
3044 // Restore colours
3045 plotWindow->SetColourTheme( oldBgColour, oldFgColour, oldAxColour );
3046 // Restore drawing
3049 plotWindow->GetDesiredYmax(), NULL, NULL );
3051 }
3052
3053 return true;
3054}
virtual void Plot(wxDC &dc, mpWindow &w)=0
Plot given view of layer to the given device context.
void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour)
Set Color theme.
Definition: mathplot.cpp:2748
const wxColour & GetAxesColour()
Get axes draw colour.
Definition: mathplot.h:1426
double GetDesiredYmax() const
Returns the top layer-border coordinate that the user wants the mpWindow to show (it may be not exact...
Definition: mathplot.h:1324
mpLayer * GetLayer(int position) const
Definition: mathplot.cpp:2600
double GetDesiredYmin() const
Returns the bottom-border layer coordinate that the user wants the mpWindow to show (it may be not ex...
Definition: mathplot.h:1318
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2403
double GetDesiredXmax() const
Returns the right-border layer coordinate that the user wants the mpWindow to show (it may be not exa...
Definition: mathplot.h:1312
double GetDesiredXmin() const
Returns the left-border layer coordinate that the user wants the mpWindow to show (it may be not exac...
Definition: mathplot.h:1306
unsigned int CountAllLayers() const
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:1293
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:1910

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

◆ SetDrawState()

void mpPrintout::SetDrawState ( bool  drawState)
inline

Definition at line 1708 of file mathplot.h.

1708{ drawn = drawState; };

Member Data Documentation

◆ drawn

bool mpPrintout::drawn
private

Definition at line 1713 of file mathplot.h.

Referenced by mpPrintout().

◆ plotWindow

mpWindow* mpPrintout::plotWindow
private

Definition at line 1714 of file mathplot.h.

Referenced by mpPrintout(), and OnPrintPage().


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