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 48 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 54 of file dialogs_for_printing.cpp.

54  :
55  wxPrintout( aTitle )
56  {
57  wxASSERT( aParent != nullptr );
58  m_parent = aParent;
59  }
PL_EDITOR_FRAME * m_parent

References m_parent.

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 62 of file dialogs_for_printing.cpp.

62 { 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 157 of file dialogs_for_printing.cpp.

158 {
159  wxPoint tmp_startvisu;
160  wxSize pageSizeIU; // Page size in internal units
161  wxPoint old_org;
162  wxRect fitRect;
163  wxDC* dc = GetDC();
164  BASE_SCREEN* screen = m_parent->GetScreen();
165 
166  // Save current offsets and clip box.
167  tmp_startvisu = screen->m_StartVisu;
168  old_org = screen->m_DrawOrg;
169 
170  // Change scale factor and offset to print the whole page.
171 
172  pageSizeIU = m_parent->GetPageSettings().GetSizeIU();
173  FitThisSizeToPaper( pageSizeIU );
174  fitRect = GetLogicalPaperRect();
175 
176  int xoffset = ( fitRect.width - pageSizeIU.x ) / 2;
177  int yoffset = ( fitRect.height - pageSizeIU.y ) / 2;
178 
179  OffsetLogicalOrigin( xoffset, yoffset );
180 
181  GRResetPenAndBrush( dc );
182  GRForceBlackPen( true );
183 
184  COLOR4D bg_color = m_parent->GetDrawBgColor();
186 
187  screen->SetVirtualPageNumber( aPageNum );
188 
189  KIGFX::DS_RENDER_SETTINGS renderSettings;
190  renderSettings.SetDefaultPenWidth( 1 );
191  renderSettings.SetLayerColor( LAYER_DRAWINGSHEET, COLOR4D( RED ) );
192  renderSettings.SetPrintDC( dc );
193 
194  // Ensure the scaling factor (used only in printing) of bitmaps is up to date
196 
197  for( DS_DATA_ITEM* dataItem : model.GetItems() )
198  {
199  if( dataItem->GetType() == DS_DATA_ITEM::DS_BITMAP )
200  {
201  BITMAP_BASE* bitmap = static_cast<DS_DATA_ITEM_BITMAP*>( dataItem )->m_ImageBitmap;
202  bitmap->SetPixelSizeIu( IU_PER_MILS * 1000 / bitmap->GetPPI() );
203  }
204  }
205 
206  m_parent->PrintDrawingSheet( &renderSettings, screen, IU_PER_MILS, wxEmptyString );
207 
208  m_parent->SetDrawBgColor( bg_color );
209 
210  GRForceBlackPen( false );
211 
212  screen->m_StartVisu = tmp_startvisu;
213  screen->m_DrawOrg = old_org;
214 
215  // PrintDrawingSheet clears the current display list when calling BuildDrawItemsList()
216  // So rebuild and redraw it.
218 }
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:107
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:76
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
std::vector< DS_DATA_ITEM * > & GetItems()
void DisplayDrawingSheet()
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:93
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
void GRForceBlackPen(bool flagforce)
Definition: gr_basic.cpp:185
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.
drawingsheet frame and titleblock
Definition: layer_ids.h:224
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:88
#define IU_PER_MILS
Definition: plotter.cpp:130
virtual COLOR4D GetDrawBgColor() const
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.
virtual void SetDrawBgColor(const COLOR4D &aColor)
int GetPPI() const
Definition: bitmap_base.h:135
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References PL_DRAW_PANEL_GAL::DisplayDrawingSheet(), 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 51 of file dialogs_for_printing.cpp.

Referenced by PLEDITOR_PRINTOUT().


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