38#include <wx/dcprint.h>
40#include <wx/dcmemory.h>
47 wxASSERT( aParent !=
nullptr );
55 *minPage = *selPageFrom = 1;
56 *maxPage = *selPageTo =
m_parent->Schematic().Root().CountSheets();
62 return m_parent->Schematic().Root().CountSheets() >= pageNum;
68 if( !wxPrintout::OnBeginDocument( startPage, endPage ) )
80 wxCHECK_MSG( page >= 1 && page <= (
int)sheetList.size(),
false,
81 wxT(
"Cannot print invalid page number." ) );
83 wxCHECK_MSG( sheetList[ page - 1].LastScreen() !=
nullptr,
false,
84 wxT(
"Cannot print page with NULL screen." ) );
87 msg.Printf(
_(
"Print page %d" ), page );
88 m_parent->SetMsgPanel( msg, wxEmptyString );
93 m_parent->SetCurrentSheet( sheetList[ page - 1 ] );
94 m_parent->GetCurrentSheet().UpdateAllScreenReferences();
107 m_parent->SetCurrentSheet( oldsheetpath );
108 m_parent->GetCurrentSheet().UpdateAllScreenReferences();
110 screen =
m_parent->GetCurrentSheet().LastScreen();
137 std::unique_ptr<KIGFX::SCH_PAINTER> painter = std::make_unique<KIGFX::SCH_PAINTER>( gal );
138 std::unique_ptr<KIGFX::VIEW> view(
m_view->DataReference() );
140 painter->SetSchematic( &
m_parent->Schematic() );
148 wxSize dcPPI = dc->GetPPI();
152 pageSizePix = GetLogicalPageRect();
156 dc->SetUserScale( 1, 1 );
158 if( wxMemoryDC* memdc =
dynamic_cast<wxMemoryDC*
>( dc ) )
160 wxBitmap& bm = memdc->GetSelectedBitmap();
161 pageSizePix = wxRect( 0, 0, bm.GetWidth(), bm.GetHeight() );
169 const VECTOR2D pageSizeIn( (
double) pageSizePix.width / dcPPI.x,
170 (
double) pageSizePix.height / dcPPI.y );
173 galPrint->SetSheetSize( pageSizeIn );
176 view->SetPainter( painter.get() );
178 view->SetScale( 1.0 );
185 *dstSettings = *
m_parent->GetRenderSettings();
251 view->SetLayerVisible( i,
true );
262 if( !
m_parent->GetScreen()->CheckIfOnDrawList( schItem ) )
271 double scaleX = (double) pageSizeIU.
x / drawingAreaBBox.
GetWidth();
272 double scaleY = (double) pageSizeIU.
y / drawingAreaBBox.
GetHeight();
274 double print_scale = std::min( scaleX, scaleY );
285 gal->
ResizeScreen( pageSizePix.GetWidth(),pageSizePix.GetHeight() );
290 view->UseDrawPriority(
true );
constexpr EDA_IU_SCALE schIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
int GetVirtualPageNumber() const
const wxString & GetPageNumber() const
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr size_type GetHeight() const
static const COLOR4D WHITE
static const COLOR4D BLACK
Color settings are a bit different than most of the settings objects in that there can be more than o...
COLOR4D GetColor(int aLayer) const
void SetPageNumber(const std::string &aPageNumber)
Change the page number displayed in the title block.
void SetIsFirstPage(bool aIsFirstPage)
Change if this is first page.
A base class for most all the KiCad significant classes used in schematics and boards.
A color representation with 4 components: red, green, blue, alpha.
COLOR4D WithAlpha(double aAlpha) const
Return a color with the same color, but the given alpha.
GAL_ANTIALIASING_MODE antialiasing_mode
The grid style to draw the grid in.
static std::unique_ptr< GAL_PRINT > Create(GAL_DISPLAY_OPTIONS &aOptions, wxDC *aDC)
Abstract interface for drawing on a 2D-surface.
virtual void ResizeScreen(int aWidth, int aHeight)
Resize the canvas.
void SetZoomFactor(double aZoomFactor)
void SetLookAtPoint(const VECTOR2D &aPoint)
Get/set the Point in world space to look at.
virtual void ClearScreen()
Clear the screen.
void SetWorldUnitLength(double aWorldUnitLength)
Set the unit length.
void SetClearColor(const COLOR4D &aColor)
const VECTOR2I & GetScreenPixelSize() const
Return GAL canvas size in pixels.
virtual bool HasNativeLandscapeRotation() const =0
void SetLayerColor(int aLayer, const COLOR4D &aColor)
Change the color used to draw a layer.
void SetDefaultFont(const wxString &aFont)
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
void SetPrintBlackAndWhite(bool aPrintBlackAndWhite)
void SetIsPrinting(bool isPrinting)
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
static constexpr int VIEW_MAX_LAYERS
Maximum number of layers that may be shown.
const VECTOR2D GetSizeIU(double aIUScale) const
Gets the page size in internal units.
Schematic editor (Eeschema) main window.
Base class for any item which can be embedded within the SCHEMATIC container class,...
bool HasPage(int page) override
bool OnPrintPage(int page) override
void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo) override
SCH_PRINTOUT(SCH_EDIT_FRAME *aParent, const wxString &aTitle)
const KIGFX::SCH_VIEW * m_view
SCH_EDIT_FRAME * m_parent
Source VIEW object (note that actual printing only refers to this object)
bool PrintPage(SCH_SCREEN *aScreen, wxDC *aDC, bool aForPrinting)
Print the current SCH_SCREEN using a given wxDC.
bool OnBeginDocument(int startPage, int endPage) override
bool m_OverrideItemColors
void SetBackgroundColor(const COLOR4D &aColor) override
Set the background color.
const KIGFX::COLOR4D & GetBackgroundColor() const override
Return current background color settings.
bool m_ShowPinsElectricalType
void LoadColors(const COLOR_SETTINGS *aSettings) override
const PAGE_INFO & GetPageSettings() const
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void SortByPageNumbers(bool aUpdateVirtualPageNums=true)
Sort the list of sheets by page number.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
#define LAYER_ID_COUNT
Must update this if you add any enums after Gerbview!
@ LAYER_DRAWINGSHEET
Sheet frame and title block.
@ LAYER_SELECT_OVERLAY
Selected items overlay.
@ LAYER_SCHEMATIC_DRAWINGSHEET
@ LAYER_SCHEMATIC_BACKGROUND
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
constexpr double SCH_WORLD_UNIT(1e-7/0.0254)
COLOR_SETTINGS * GetColorSettings(const wxString &aName)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
bool monochrome
Whether or not to print in monochrome.
bool background
Whether or not to print background color.
wxString color_theme
Color theme to use for printing.
bool title_block
Whether or not to print title block.
bool use_theme
If false, display color theme will be used.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D
#define ZOOM_MIN_LIMIT_EESCHEMA
#define ZOOM_MAX_LIMIT_EESCHEMA