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

3022 : wxPrintout( title )
3023{
3024 drawn = false;
3025 plotWindow = drawWindow;
3026}
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 3091 of file mathplot.cpp.

3092{
3093 return page == 1;
3094}

◆ OnPrintPage()

bool mpPrintout::OnPrintPage ( int  page)
override

Definition at line 3029 of file mathplot.cpp.

3030{
3031 wxDC* trgDc = GetDC();
3032
3033 if( (trgDc) && (page == 1) )
3034 {
3035 wxCoord m_prnX, m_prnY;
3036 int marginX = 50;
3037 int marginY = 50;
3038 trgDc->GetSize( &m_prnX, &m_prnY );
3039
3040 m_prnX -= (2 * marginX);
3041 m_prnY -= (2 * marginY);
3042 trgDc->SetDeviceOrigin( marginX, marginY );
3043
3044 // Set the scale according to the page:
3045 plotWindow->Fit(
3050 &m_prnX,
3051 &m_prnY );
3052
3053 // Get the colours of the plotWindow to restore them ath the end
3054 wxColour oldBgColour = plotWindow->GetBackgroundColour();
3055 wxColour oldFgColour = plotWindow->GetForegroundColour();
3056 wxColour oldAxColour = plotWindow->GetAxesColour();
3057
3058 // Draw background, ensuring to use white background for printing.
3059 trgDc->SetPen( *wxTRANSPARENT_PEN );
3060 // wxBrush brush( plotWindow->GetBackgroundColour() );
3061 wxBrush brush = *wxWHITE_BRUSH;
3062 trgDc->SetBrush( brush );
3063 trgDc->DrawRectangle( 0, 0, m_prnX, m_prnY );
3064
3065 // Draw all the layers:
3066 // trgDc->SetDeviceOrigin( m_prnX>>1, m_prnY>>1); // Origin at the center
3067 mpLayer* layer;
3068
3069 for( unsigned int li = 0; li < plotWindow->CountAllLayers(); li++ )
3070 {
3071 layer = plotWindow->GetLayer( li );
3072 layer->Plot( *trgDc, *plotWindow );
3073 }
3074
3075 ;
3076 // Restore device origin
3077 // trgDc->SetDeviceOrigin(0, 0);
3078 // Restore colours
3079 plotWindow->SetColourTheme( oldBgColour, oldFgColour, oldAxColour );
3080 // Restore drawing
3083 plotWindow->GetDesiredYmax(), NULL, NULL );
3085 }
3086
3087 return true;
3088}
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:2782
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:2634
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:2437
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:1932

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: