38#include <wx/dcprint.h>
40#include <wx/dcmemory.h>
47 wxASSERT( aParent !=
nullptr );
56 *minPage = *selPageFrom = 1;
69 if( !wxPrintout::OnBeginDocument( startPage, endPage ) )
81 wxCHECK_MSG( page >= 1 && page <= (
int)sheetList.size(),
false,
82 wxT(
"Cannot print invalid page number." ) );
84 wxCHECK_MSG( sheetList[ page - 1].LastScreen() !=
nullptr,
false,
85 wxT(
"Cannot print page with NULL screen." ) );
88 msg.Printf(
_(
"Print page %d" ), page );
158 FitThisSizeToPaper( pageSizeIU );
161 fitRect = GetLogicalPaperRect();
164 fitRect = wxRect( 0, 0, 6000, 4000 );
166 if( wxMemoryDC* memdc =
dynamic_cast<wxMemoryDC*
>( dc ) )
168 wxBitmap& bm = memdc->GetSelectedBitmap();
169 fitRect = wxRect( 0, 0, bm.GetWidth(), bm.GetHeight() );
176 dc_scale = ppi / inch2Iu;
177 dc->SetUserScale( dc_scale, dc_scale );
184 int xoffset = ( fitRect.width - pageSizeIU.x ) / 2;
185 int yoffset = ( fitRect.height - pageSizeIU.y ) / 2;
189 if( dc->CanUseTransformMatrix() && aForPrinting )
191 wxAffineMatrix2D matrix;
194 if( ( fitRect.width > fitRect.height ) != ( pageSizeIU.x > pageSizeIU.y ) )
198 matrix.Translate( 0, -pageSizeIU.y );
201 std::swap( pageSizeIU.x, pageSizeIU.y );
202 FitThisSizeToPaper( pageSizeIU );
203 fitRect = GetLogicalPaperRect();
205 xoffset = ( fitRect.width - pageSizeIU.x ) / 2;
206 yoffset = ( fitRect.height - pageSizeIU.y ) / 2;
210 std::swap( xoffset, yoffset );
211 std::swap( fitRect.width, fitRect.height );
215 matrix.Translate( xoffset, yoffset );
216 dc->SetTransformMatrix( matrix );
218 fitRect.x -= xoffset;
219 fitRect.y -= yoffset;
221 else if( aForPrinting )
223 SetLogicalOrigin( 0, 0 );
225 OffsetLogicalOrigin( xoffset, yoffset );
228 dc->SetLogicalFunction( wxCOPY );
241 bgColor = COLOR4D::WHITE;
246 GRSFilledRect( dc, fitRect.GetX(), fitRect.GetY(), fitRect.GetRight(), fitRect.GetBottom(), 0,
267 if( printDrawingSheet )
275 aScreen->
Print( &renderSettings );
293 std::unique_ptr<KIGFX::SCH_PAINTER> painter = std::make_unique<KIGFX::SCH_PAINTER>( gal );
305 wxSize dcPPI = dc->GetPPI();
308 pageSizePix = GetLogicalPageRect();
311 dc->SetUserScale( 1, 1 );
313 if( wxMemoryDC* memdc =
dynamic_cast<wxMemoryDC*
>( dc ) )
315 wxBitmap& bm = memdc->GetSelectedBitmap();
316 pageSizePix = wxRect( 0, 0, bm.GetWidth(), bm.GetHeight() );
324 const VECTOR2D pageSizeIn( (
double) pageSizePix.width / dcPPI.x,
325 (
double) pageSizePix.height / dcPPI.y );
328 galPrint->SetSheetSize( pageSizeIn );
331 view->SetPainter( painter.get() );
333 view->SetScale( 1.0 );
358 bgColor = COLOR4D::WHITE;
403 view->SetLayerVisible( i,
true );
423 double scaleX = (double) pageSizeIU.
x / drawingAreaBBox.
GetWidth();
424 double scaleY = (double) pageSizeIU.
y / drawingAreaBBox.
GetHeight();
426 double print_scale = std::min( scaleX, scaleY );
432 gal->
ResizeScreen( pageSizePix.GetWidth(),pageSizePix.GetHeight() );
436 view->UseDrawPriority(
true );
constexpr EDA_IU_SCALE schIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
VECTOR2I m_DrawOrg
offsets for drawing the circuit on the screen
VECTOR2I m_StartVisu
Coordinates in drawing units of the current view position (upper left corner of device)
const wxString & GetPageNumber() const
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr size_type GetHeight() const
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)
Changes the page number displayed in the title block.
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
virtual void SetDrawBgColor(const COLOR4D &aColor)
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, BASE_SCREEN *aScreen, const std::map< wxString, wxString > *aProperties, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
Prints the drawing-sheet (frame and title block).
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.
CAIRO_ANTIALIASING_MODE cairo_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)
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 SetPrintDC(wxDC *aDC)
void SetIsPrinting(bool isPrinting)
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
static constexpr int VIEW_MAX_LAYERS
Rendering order modifier for layers that are marked as top layers.
std::unique_ptr< VIEW > DataReference() const
Return a new VIEW object that shares the same set of VIEW_ITEMs and LAYERs.
const VECTOR2D GetSizeIU(double aIUScale) const
Gets the page size in internal units.
virtual SETTINGS_MANAGER & GetSettingsManager() const
SCH_SHEET_LIST Hierarchy() const override
Return the full schematic flattened hierarchical sheet list.
const std::map< wxString, wxString > * GetProperties()
SCH_RENDER_SETTINGS * GetRenderSettings()
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
EESCHEMA_SETTINGS * eeconfig() const
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Returns a pointer to the active color theme settings.
COLOR4D GetDrawBgColor() const override
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
Schematic editor (Eeschema) main window.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_SHEET_PATH & GetCurrentSheet() const
SCHEMATIC & Schematic() const
void RecomputeIntersheetRefs()
Update the schematic's page reference map for all global labels, and refresh the labels so that they ...
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
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
const KIGFX::SCH_VIEW * m_view
SCH_PRINTOUT(SCH_EDIT_FRAME *aParent, const wxString &aTitle, bool aUseCairo)
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
const wxString & GetFileName() const
void Print(const SCH_RENDER_SETTINGS *aSettings)
Print all the items in the screen to aDC.
SCHEMATIC * Schematic() const
bool CheckIfOnDrawList(const SCH_ITEM *aItem) 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...
void UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
SCH_SCREEN * LastScreen()
int CountSheets() const
Count the number of sheets found in "this" sheet including all of the subsheets.
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
void GRForceBlackPen(bool flagforce)
void GRResetPenAndBrush(wxDC *DC)
void GRSFilledRect(wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, const COLOR4D &aColor, const COLOR4D &aBgColor)
#define LAYER_ID_COUNT
Must update this if you add any enums after GerbView!
@ LAYER_DRAWINGSHEET
drawingsheet frame and titleblock
@ LAYER_SELECT_OVERLAY
currently selected items overlay
@ LAYER_SCHEMATIC_DRAWINGSHEET
@ LAYER_SCHEMATIC_BACKGROUND
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
PGM_BASE & Pgm()
The global Program "get" accessor.
constexpr double SCH_WORLD_UNIT(1e-7/0.0254)
std::vector< FAB_LAYER_COLOR > dummy
#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
wxSize ToWxSize(const VECTOR2I &aSize)
#define ZOOM_MIN_LIMIT_EESCHEMA
#define ZOOM_MAX_LIMIT_EESCHEMA