KiCad PCB EDA Suite
PLEDITOR_PRINTOUT Class Reference

Custom print out for printing schematics. More...

Inheritance diagram for PLEDITOR_PRINTOUT:

Public Member Functions

 PLEDITOR_PRINTOUT (PL_EDITOR_FRAME *aParent, const wxString &aTitle)
 
bool OnPrintPage (int aPageNum) override
 
bool HasPage (int aPageNum) override
 
void GetPageInfo (int *minPage, int *maxPage, int *selPageFrom, int *selPageTo) override
 
void PrintPage (int aPageNum)
 

Private Attributes

PL_EDITOR_FRAMEm_parent
 

Detailed Description

Custom print out for printing schematics.

Definition at line 50 of file dialogs_for_printing.cpp.

Constructor & Destructor Documentation

◆ PLEDITOR_PRINTOUT()

PLEDITOR_PRINTOUT::PLEDITOR_PRINTOUT ( PL_EDITOR_FRAME aParent,
const wxString &  aTitle 
)
inline

Definition at line 56 of file dialogs_for_printing.cpp.

56  :
57  wxPrintout( aTitle )
58  {
59  wxASSERT( aParent != NULL );
60  m_parent = aParent;
61  }
#define NULL
PL_EDITOR_FRAME * m_parent

References m_parent, and NULL.

Member Function Documentation

◆ GetPageInfo()

void PLEDITOR_PRINTOUT::GetPageInfo ( int *  minPage,
int *  maxPage,
int *  selPageFrom,
int *  selPageTo 
)
override

Definition at line 149 of file dialogs_for_printing.cpp.

151 {
152  *minPage = *selPageFrom = 1;
153  *maxPage = *selPageTo = 2;
154 }

◆ HasPage()

bool PLEDITOR_PRINTOUT::HasPage ( int  aPageNum)
inlineoverride

Definition at line 64 of file dialogs_for_printing.cpp.

64 { return ( aPageNum <= 2 ); }

◆ OnPrintPage()

bool PLEDITOR_PRINTOUT::OnPrintPage ( int  aPageNum)
override

Definition at line 142 of file dialogs_for_printing.cpp.

143 {
144  PrintPage( aPageNum );
145  return true;
146 }
void PrintPage(int aPageNum)

◆ PrintPage()

void PLEDITOR_PRINTOUT::PrintPage ( int  aPageNum)

Definition at line 159 of file dialogs_for_printing.cpp.

160 {
161  wxPoint tmp_startvisu;
162  wxSize pageSizeIU; // Page size in internal units
163  wxPoint old_org;
164  wxRect fitRect;
165  wxDC* dc = GetDC();
166  BASE_SCREEN* screen = m_parent->GetScreen();
167 
168  // Save current offsets and clip box.
169  tmp_startvisu = screen->m_StartVisu;
170  old_org = screen->m_DrawOrg;
171 
172  // Change scale factor and offset to print the whole page.
173 
174  pageSizeIU = m_parent->GetPageSettings().GetSizeIU();
175  FitThisSizeToPaper( pageSizeIU );
176  fitRect = GetLogicalPaperRect();
177 
178  int xoffset = ( fitRect.width - pageSizeIU.x ) / 2;
179  int yoffset = ( fitRect.height - pageSizeIU.y ) / 2;
180 
181  OffsetLogicalOrigin( xoffset, yoffset );
182 
183  GRResetPenAndBrush( dc );
184  GRForceBlackPen( true );
185 
186  COLOR4D bg_color = m_parent->GetDrawBgColor();
188 
189  screen->SetVirtualPageNumber( aPageNum );
190 
191  KIGFX::DS_RENDER_SETTINGS renderSettings;
192  renderSettings.SetDefaultPenWidth( 1 );
193  renderSettings.SetLayerColor( LAYER_DRAWINGSHEET, COLOR4D( RED ) );
194  renderSettings.SetPrintDC( dc );
195 
196  // Ensure the scaling factor (used only in printing) of bitmaps is up to date
198 
199  for( DS_DATA_ITEM* dataItem : model.GetItems() )
200  {
201  if( dataItem->GetType() == DS_DATA_ITEM::DS_BITMAP )
202  {
203  BITMAP_BASE* bitmap = static_cast<DS_DATA_ITEM_BITMAP*>( dataItem )->m_ImageBitmap;
204  bitmap->SetPixelSizeIu( IU_PER_MILS * 1000 / bitmap->GetPPI() );
205  }
206  }
207 
208  m_parent->PrintDrawingSheet( &renderSettings, screen, IU_PER_MILS, wxEmptyString );
209 
210  m_parent->SetDrawBgColor( bg_color );
211 
212  GRForceBlackPen( false );
213 
214  screen->m_StartVisu = tmp_startvisu;
215  screen->m_DrawOrg = old_org;
216 
217  // PrintDrawingSheet clears the current display list when calling BuildDrawItemsList()
218  // So rebuild and redraw it.
220 }
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:118
Handle the graphic items list to draw/plot the frame and title block.
Definition: ds_data_model.h:38
void SetVirtualPageNumber(int aPageNumber)
Definition: base_screen.h:80
PL_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
const PAGE_INFO & GetPageSettings() const override
virtual void SetDrawBgColor(COLOR4D aColor)
std::vector< DS_DATA_ITEM * > & GetItems()
void DisplayWorksheet()
Build and update the list of WS_DRAW_ITEM_xxx showing the frame layout.
Store page-layout-specific render settings.
Definition: ds_painter.h:46
This class handle bitmap images in KiCad.
Definition: bitmap_base.h:51
wxPoint m_StartVisu
Coordinates in drawing units of the current view position (upper left corner of device)
Definition: base_screen.h:97
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
void GRForceBlackPen(bool flagforce)
Function GRForceBlackPen.
Definition: gr_basic.cpp:199
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:40
void SetLayerColor(int aLayer, const COLOR4D &aColor)
Change the color used to draw a layer.
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, BASE_SCREEN *aScreen, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
Prints the drawing-sheet (frame and title block).
Definition: color4d.h:59
void SetPixelSizeIu(double aPixSize)
Definition: bitmap_base.h:68
Definition: color4d.h:48
PL_EDITOR_FRAME * m_parent
Drawing sheet structure type definitions.
Definition: ds_data_item.h:95
wxPoint m_DrawOrg
offsets for drawing the circuit on the screen
Definition: base_screen.h:92
#define IU_PER_MILS
Definition: plotter.cpp:137
virtual COLOR4D GetDrawBgColor() const
drawingsheet frame and titleblock
void SetDefaultPenWidth(int aWidth)
void SetPrintDC(wxDC *aDC)
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
int GetPPI() const
Definition: bitmap_base.h:135
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98

References PL_DRAW_PANEL_GAL::DisplayWorksheet(), DS_DATA_ITEM::DS_BITMAP, PL_EDITOR_FRAME::GetCanvas(), EDA_DRAW_FRAME::GetDrawBgColor(), DS_DATA_MODEL::GetItems(), PL_EDITOR_FRAME::GetPageSettings(), BITMAP_BASE::GetPPI(), EDA_DRAW_FRAME::GetScreen(), DS_DATA_MODEL::GetTheInstance(), GRForceBlackPen(), GRResetPenAndBrush(), IU_PER_MILS, LAYER_DRAWINGSHEET, BASE_SCREEN::m_DrawOrg, PLEDITOR_PREVIEW_FRAME::m_parent, BASE_SCREEN::m_StartVisu, EDA_DRAW_FRAME::PrintDrawingSheet(), RED, KIGFX::RENDER_SETTINGS::SetDefaultPenWidth(), EDA_DRAW_FRAME::SetDrawBgColor(), KIGFX::RENDER_SETTINGS::SetLayerColor(), BITMAP_BASE::SetPixelSizeIu(), KIGFX::RENDER_SETTINGS::SetPrintDC(), BASE_SCREEN::SetVirtualPageNumber(), and WHITE.

Member Data Documentation

◆ m_parent

PL_EDITOR_FRAME* PLEDITOR_PRINTOUT::m_parent
private

Definition at line 53 of file dialogs_for_printing.cpp.

Referenced by PLEDITOR_PRINTOUT().


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