KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_plotter.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 1992-2018 Jean-Pierre Charras jp.charras at wanadoo.fr
5 * Copyright (C) 1992-2010 Lorenzo Marcantonio
6 * Copyright (C) 2011 Wayne Stambaugh <[email protected]>
7 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
23#include <wx/log.h>
24#include <common.h>
25#include <sch_plotter.h>
29
30#include <pgm_base.h>
31#include <trace_helpers.h>
32
33#include <sch_edit_frame.h>
34#include <sch_painter.h>
35#include <schematic.h>
36#include <sch_screen.h>
38
39// Note:
40// We need to switch between sheets to plot a hierarchy and update references and sheet number
41// Use SCHEMATIC::SetCurrentSheet( xxx ) to switch to a sheet.
42// Do not use SCH_EDIT_FRAME::SetCurrentSheet( xxx ) to switch to a sheet, because the new sheet
43// is not displayed, but SCH_EDIT_FRAME::SetCurrentSheet() has side effects to the current VIEW
44// (clear some data used to show the sheet on screen) and does not fully restore the "old" screen
45
46
48 m_schematic( aSchematic )
49{
50 m_colorSettings = nullptr;
51}
52
53
55 m_schematic( &aFrame->Schematic() )
56{
57 m_colorSettings = nullptr;
58}
59
60
62 REPORTER* aReporter, const wxString& aExt )
63{
64 if( !aPlotOpts.m_outputFile.empty() )
65 {
66 return aPlotOpts.m_outputFile;
67 }
68 else
69 {
70 wxString fname = m_schematic->GetUniqueFilenameForCurrentSheet();
71
72 // The sub sheet can be in a sub_hierarchy, but we plot the file in the main
73 // project folder (or the folder specified by the caller), so replace separators
74 // to create a unique filename:
75 fname.Replace( "/", "_" );
76 fname.Replace( "\\", "_" );
77
78 return createPlotFileName( aPlotOpts, fname, aExt, aReporter );
79 }
80
81}
82
83
85 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
86{
87 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet(); // sheetpath is saved here
88
89 /* When printing all pages, the printed page is not the current page. In complex hierarchies,
90 * we must update symbol references and other parameters in the given printed SCH_SCREEN,
91 * according to the sheet path because in complex hierarchies a SCH_SCREEN (a drawing ) is
92 * shared between many sheets and symbol references depend on the actual sheet path used.
93 */
94 SCH_SHEET_LIST sheetList;
95
96 if( aPlotOpts.m_plotAll || aPlotOpts.m_plotPages.size() > 0 )
97 {
98 sheetList.BuildSheetList( &m_schematic->Root(), true );
100
101 // remove the non-selected pages if we are in plot pages mode
102 if( aPlotOpts.m_plotPages.size() > 0 )
103 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
104 }
105 else
106 {
107 // in Eeschema, this prints the current page
108 sheetList.push_back( m_schematic->CurrentSheet() );
109 }
110
111 if( sheetList.empty() )
112 {
113 if( aReporter )
114 aReporter->Report( _( "No sheets to plot." ), RPT_SEVERITY_ERROR );
115
116 return;
117 }
118
119 wxCHECK( m_schematic, /* void */ );
120
121 // Allocate the plotter and set the job level parameter
122 PDF_PLOTTER* plotter = new PDF_PLOTTER( &m_schematic->Project() );
123 plotter->SetRenderSettings( aRenderSettings );
124 plotter->SetColorMode( !aPlotOpts.m_blackAndWhite );
125 plotter->SetCreator( wxT( "Eeschema-PDF" ) );
126 plotter->SetTitle( ExpandTextVars( m_schematic->RootScreen()->GetTitleBlock().GetTitle(),
127 &m_schematic->Project() ) );
128
129 wxString msg;
130 wxFileName plotFileName;
131
132 for( unsigned i = 0; i < sheetList.size(); i++ )
133 {
134 m_schematic->SetCurrentSheet( sheetList[i] );
135 m_schematic->CurrentSheet().UpdateAllScreenReferences();
136 m_schematic->SetSheetNumberAndCount();
137
138 SCH_SCREEN* screen = m_schematic->CurrentSheet().LastScreen();
139 wxString sheetName = sheetList[i].Last()->GetField( FIELD_T::SHEET_NAME )->GetShownText( false );
140
141 if( aPlotOpts.m_PDFMetadata )
142 {
143 msg = wxS( "AUTHOR" );
144
145 if( m_schematic->ResolveTextVar( &sheetList[i], &msg, 0 ) )
146 plotter->SetAuthor( msg );
147
148 msg = wxS( "SUBJECT" );
149
150 if( m_schematic->ResolveTextVar( &sheetList[i], &msg, 0 ) )
151 plotter->SetSubject( msg );
152 }
153
154 if( i == 0 )
155 {
156 try
157 {
159 plotFileName = getOutputFilenameSingle( aPlotOpts, aReporter, ext );
160
161 m_lastOutputFilePath = plotFileName.GetFullPath();
163
164 if( !plotFileName.IsOk() )
165 return;
166
167 if( !plotter->OpenFile( plotFileName.GetFullPath() ) )
168 {
169 if( aReporter )
170 {
171 msg.Printf( _( "Failed to create file '%s'." ),
172 plotFileName.GetFullPath() );
173 aReporter->Report( msg, RPT_SEVERITY_ERROR );
174 }
175 delete plotter;
176 return;
177 }
178
179 // Open the plotter and do the first page
180 setupPlotPagePDF( plotter, screen, aPlotOpts );
181
182 plotter->StartPlot( sheetList[i].GetPageNumber(), sheetName );
183 }
184 catch( const IO_ERROR& e )
185 {
186 // Cannot plot PDF file
187 if( aReporter )
188 {
189 msg.Printf( wxT( "PDF Plotter exception: %s" ), e.What() );
190 aReporter->Report( msg, RPT_SEVERITY_ERROR );
191 }
192
193 restoreEnvironment( plotter, oldsheetpath );
194 return;
195 }
196 }
197 else
198 {
199 /* For the following pages you need to close the (finished) page,
200 * reconfigure, and then start a new one */
201 plotter->ClosePage();
202 setupPlotPagePDF( plotter, screen, aPlotOpts );
203 SCH_SHEET_PATH parentSheet = sheetList[i];
204
205 if( parentSheet.size() > 1 )
206 {
207 // The sheet path is the full path to the sheet, so we need to remove the last
208 // sheet name to get the parent sheet path
209 parentSheet.pop_back();
210 }
211
212 wxString parentSheetName =
213 parentSheet.Last()->GetField( FIELD_T::SHEET_NAME )->GetShownText( false );
214
215 plotter->StartPage( sheetList[i].GetPageNumber(), sheetName,
216 parentSheet.GetPageNumber(), parentSheetName );
217 }
218
219 plotOneSheetPDF( plotter, screen, aPlotOpts );
220 }
221
222 // Everything done, close the plot and restore the environment
223 if( aReporter )
224 {
225 msg.Printf( _( "Plotted to '%s'.\n" ), plotFileName.GetFullPath() );
226 aReporter->Report( msg, RPT_SEVERITY_ACTION );
227 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
228 }
229
230 restoreEnvironment( plotter, oldsheetpath );
231}
232
233
235 const SCH_PLOT_OPTS& aPlotOpts )
236{
237 if( aPlotOpts.m_useBackgroundColor && aPlotter->GetColorMode() )
238 {
239 aPlotter->SetColor( aPlotter->RenderSettings()->GetBackgroundColor() );
240
241 // Use page size selected in schematic to know the schematic bg area
242 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
243 VECTOR2I end( actualPage.GetWidthIU( schIUScale.IU_PER_MILS ),
244 actualPage.GetHeightIU( schIUScale.IU_PER_MILS ) );
245
246 aPlotter->Rect( VECTOR2I( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 );
247 }
248
249 if( aPlotOpts.m_plotDrawingSheet )
250 {
251 COLOR4D color = COLOR4D::BLACK;
252
253 if( aPlotter->GetColorMode() )
255
256 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
257 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
258 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
259
260 SCHEMATIC* sch = aScreen->Schematic();
261 wxString variantName = sch->GetCurrentVariant();
262 wxString variantDesc = sch->GetVariantDescription( variantName );
263
264 PlotDrawingSheet( aPlotter, &sch->Project(), aScreen->GetTitleBlock(), actualPage, sch->GetProperties(),
265 aScreen->GetPageNumber(), aScreen->GetPageCount(), sheetName, sheetPath,
266 aScreen->GetFileName(), color, aScreen->GetVirtualPageNumber() == 1, variantName,
267 variantDesc );
268 }
269
270 aScreen->Plot( aPlotter, aPlotOpts );
271}
272
273
275 const SCH_PLOT_OPTS& aPlotOpts )
276{
277 PAGE_INFO plotPage; // page size selected to plot
278
279 // Considerations on page size and scaling requests
280 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
281
282 switch( aPlotOpts.m_pageSizeSelect )
283 {
284 case PAGE_SIZE_A:
285 plotPage.SetType( wxT( "A" ) );
286 plotPage.SetPortrait( actualPage.IsPortrait() );
287 break;
288
289 case PAGE_SIZE_A4:
290 plotPage.SetType( wxT( "A4" ) );
291 plotPage.SetPortrait( actualPage.IsPortrait() );
292 break;
293
294 case PAGE_SIZE_AUTO:
295 default:
296 plotPage = actualPage;
297 break;
298 }
299
300 double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
301 double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
302 double scale = std::min( scalex, scaley );
303 aPlotter->SetPageSettings( plotPage );
304
305 // Currently, plot units are in decimil
306 aPlotter->SetViewport( VECTOR2I( 0, 0 ), schIUScale.IU_PER_MILS / 10, scale, false );
307}
308
309
311 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
312{
313 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet(); // sheetpath is saved here
314 PAGE_INFO plotPage; // page size selected to plot
315 wxString msg;
316
317 /* When printing all pages, the printed page is not the current page.
318 * In complex hierarchies, we must update symbol references and other parameters in the
319 * given printed SCH_SCREEN, accordant to the sheet path because in complex hierarchies
320 * a SCH_SCREEN (a drawing ) is shared between many sheets and symbol references
321 * depend on the actual sheet path used.
322 */
323 SCH_SHEET_LIST sheetList;
324
325 if( aPlotOpts.m_plotAll )
326 {
327 sheetList.BuildSheetList( &m_schematic->Root(), true );
328 sheetList.SortByPageNumbers();
329
330 // remove the non-selected pages if we are in plot pages mode
331 if( aPlotOpts.m_plotPages.size() > 0 )
332 {
333 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
334 }
335 }
336 else
337 {
338 sheetList.push_back( m_schematic->CurrentSheet() );
339 }
340
341 for( unsigned i = 0; i < sheetList.size(); i++ )
342 {
343 m_schematic->SetCurrentSheet( sheetList[i] );
344 m_schematic->CurrentSheet().UpdateAllScreenReferences();
345 m_schematic->SetSheetNumberAndCount();
346
347 SCH_SCREEN* screen = m_schematic->CurrentSheet().LastScreen();
348 PAGE_INFO actualPage = screen->GetPageSettings();
349
350 switch( aPlotOpts.m_pageSizeSelect )
351 {
352 case PAGE_SIZE_A:
353 plotPage.SetType( wxT( "A" ) );
354 plotPage.SetPortrait( actualPage.IsPortrait() );
355 break;
356
357 case PAGE_SIZE_A4:
358 plotPage.SetType( wxT( "A4" ) );
359 plotPage.SetPortrait( actualPage.IsPortrait() );
360 break;
361
362 case PAGE_SIZE_AUTO:
363 default:
364 plotPage = actualPage;
365 break;
366 }
367
368 double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
369 double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
370 double scale = std::min( scalex, scaley );
371 VECTOR2I plot_offset;
372
373 try
374 {
375 wxString fname = m_schematic->GetUniqueFilenameForCurrentSheet();
376
377 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
378 // main project folder (or the folder specified by the caller),
379 // so replace separators to create a unique filename:
380 fname.Replace( "/", "_" );
381 fname.Replace( "\\", "_" );
383 wxFileName plotFileName = createPlotFileName( aPlotOpts, fname, ext, aReporter );
384
385 m_lastOutputFilePath = plotFileName.GetFullPath();
387
388 if( !plotFileName.IsOk() )
389 {
390 if( aReporter )
391 {
392 // Error
393 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
394 aReporter->Report( msg, RPT_SEVERITY_ERROR );
395 }
396 }
397 else if( plotOneSheetPS( plotFileName.GetFullPath(), screen, aRenderSettings,
398 actualPage, plot_offset, scale, aPlotOpts ) )
399 {
400 if( aReporter )
401 {
402 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
403 aReporter->Report( msg, RPT_SEVERITY_ACTION );
404 }
405 }
406 else
407 {
408 if( aReporter )
409 {
410 // Error
411 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
412 aReporter->Report( msg, RPT_SEVERITY_ERROR );
413 }
414 }
415 }
416 catch( IO_ERROR& e )
417 {
418 if( aReporter )
419 {
420 msg.Printf( wxT( "PS Plotter exception: %s" ), e.What() );
421 aReporter->Report( msg, RPT_SEVERITY_ERROR );
422 }
423 }
424 }
425
426 if( aReporter )
427 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
428
429 restoreEnvironment( nullptr, oldsheetpath );
430}
431
432
433bool SCH_PLOTTER::plotOneSheetPS( const wxString& aFileName, SCH_SCREEN* aScreen,
434 RENDER_SETTINGS* aRenderSettings, const PAGE_INFO& aPageInfo,
435 const VECTOR2I& aPlot0ffset, double aScale,
436 const SCH_PLOT_OPTS& aPlotOpts )
437{
438 PS_PLOTTER* plotter = new PS_PLOTTER();
439 plotter->SetRenderSettings( aRenderSettings );
440 plotter->SetPageSettings( aPageInfo );
441 plotter->SetColorMode( !aPlotOpts.m_blackAndWhite );
442
443 // Currently, plot units are in decimil
444 plotter->SetViewport( aPlot0ffset, schIUScale.IU_PER_MILS / 10, aScale, false );
445
446 // Init :
447 plotter->SetCreator( wxT( "Eeschema-PS" ) );
448
449 if( !plotter->OpenFile( aFileName ) )
450 {
451 delete plotter;
452 return false;
453 }
454
455 plotter->StartPlot( m_schematic->CurrentSheet().GetPageNumber() );
456
457 if( aPlotOpts.m_useBackgroundColor && plotter->GetColorMode() )
458 {
460
461 // Use page size selected in schematic to know the schematic bg area
462 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
463 VECTOR2I end( actualPage.GetWidthIU( schIUScale.IU_PER_MILS ),
464 actualPage.GetHeightIU( schIUScale.IU_PER_MILS ) );
465
466 plotter->Rect( VECTOR2I( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0, 0 );
467 }
468
469 if( aPlotOpts.m_plotDrawingSheet )
470 {
471 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
472 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
474
475 SCHEMATIC* sch = aScreen->Schematic();
476 wxString variantName = sch->GetCurrentVariant();
477 wxString variantDesc = sch->GetVariantDescription( variantName );
478
479 PlotDrawingSheet( plotter, &sch->Project(), aScreen->GetTitleBlock(), aPageInfo, sch->GetProperties(),
480 aScreen->GetPageNumber(), aScreen->GetPageCount(), sheetName, sheetPath,
481 aScreen->GetFileName(), plotter->GetColorMode() ? color : COLOR4D::BLACK,
482 aScreen->GetVirtualPageNumber() == 1, variantName, variantDesc );
483 }
484
485 aScreen->Plot( plotter, aPlotOpts );
486
487 plotter->EndPlot();
488 delete plotter;
489
490 return true;
491}
492
493
495 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
496{
497 wxString msg;
498 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet();
499 SCH_SHEET_LIST sheetList;
500
501 if( aPlotOpts.m_plotAll )
502 {
503 sheetList.BuildSheetList( &m_schematic->Root(), true );
504 sheetList.SortByPageNumbers();
505
506 // remove the non-selected pages if we are in plot pages mode
507 if( aPlotOpts.m_plotPages.size() > 0 )
508 {
509 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
510 }
511 }
512 else
513 {
514 // in Eeschema, this prints the current page
515 sheetList.push_back( m_schematic->CurrentSheet() );
516 }
517
518 for( unsigned i = 0; i < sheetList.size(); i++ )
519 {
520 SCH_SCREEN* screen;
521
522 m_schematic->SetCurrentSheet( sheetList[i] );
523 m_schematic->CurrentSheet().UpdateAllScreenReferences();
524 m_schematic->SetSheetNumberAndCount();
525
526 screen = m_schematic->CurrentSheet().LastScreen();
527
528 try
529 {
530 wxString fname = m_schematic->GetUniqueFilenameForCurrentSheet();
531
532 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
533 // main project folder (or the folder specified by the caller),
534 // so replace separators to create a unique filename:
535 fname.Replace( "/", "_" );
536 fname.Replace( "\\", "_" );
538 wxFileName plotFileName = createPlotFileName( aPlotOpts, fname, ext, aReporter );
539
540 m_lastOutputFilePath = plotFileName.GetFullPath();
542
543 if( !plotFileName.IsOk() )
544 return;
545
546 bool success = plotOneSheetSVG( plotFileName.GetFullPath(), screen, aRenderSettings,
547 aPlotOpts );
548
549 if( !success )
550 {
551 if( aReporter )
552 {
553 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
554 aReporter->Report( msg, RPT_SEVERITY_ERROR );
555 }
556 }
557 else
558 {
559 if( aReporter )
560 {
561 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
562 aReporter->Report( msg, RPT_SEVERITY_ACTION );
563 }
564 }
565 }
566 catch( const IO_ERROR& e )
567 {
568 if( aReporter )
569 {
570 // Cannot plot SVG file
571 msg.Printf( wxT( "SVG Plotter exception: %s" ), e.What() );
572 aReporter->Report( msg, RPT_SEVERITY_ERROR );
573 }
574 break;
575 }
576 }
577
578 if( aReporter )
579 {
580 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
581 }
582
583 restoreEnvironment( nullptr, oldsheetpath );
584}
585
586
587bool SCH_PLOTTER::plotOneSheetSVG( const wxString& aFileName, SCH_SCREEN* aScreen,
588 RENDER_SETTINGS* aRenderSettings,
589 const SCH_PLOT_OPTS& aPlotOpts )
590{
591 PAGE_INFO plotPage;
592
593 // Adjust page size and scaling requests
594 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
595
596 switch( aPlotOpts.m_pageSizeSelect )
597 {
598 case PAGE_SIZE_A:
599 plotPage.SetType( wxT( "A" ) );
600 plotPage.SetPortrait( actualPage.IsPortrait() );
601 break;
602
603 case PAGE_SIZE_A4:
604 plotPage.SetType( wxT( "A4" ) );
605 plotPage.SetPortrait( actualPage.IsPortrait() );
606 break;
607
608 case PAGE_SIZE_AUTO:
609 default:
610 plotPage = actualPage;
611 break;
612 }
613
614 SVG_PLOTTER* plotter = new SVG_PLOTTER();
615 plotter->SetRenderSettings( aRenderSettings );
616 plotter->SetPageSettings( plotPage );
617 plotter->SetColorMode( aPlotOpts.m_blackAndWhite ? false : true );
618 VECTOR2I plot_offset;
619
620 double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
621 double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
622 double scale = std::min( scalex, scaley );
623
624 // Currently, plot units are in decimil
625 plotter->SetViewport( plot_offset, schIUScale.IU_PER_MILS / 10, scale, false );
626
627 // Init :
628 plotter->SetCreator( wxT( "Eeschema-SVG" ) );
629
630 if( !plotter->OpenFile( aFileName ) )
631 {
632 delete plotter;
633 return false;
634 }
635
636 plotter->StartPlot( m_schematic->CurrentSheet().GetPageNumber() );
637
638 if( aPlotOpts.m_useBackgroundColor && plotter->GetColorMode() )
639 {
641
642 // Use page size selected in schematic to know the schematic bg area
643 VECTOR2I end( actualPage.GetWidthIU( schIUScale.IU_PER_MILS ),
644 actualPage.GetHeightIU( schIUScale.IU_PER_MILS ) );
645
646 plotter->Rect( VECTOR2I( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0, 0 );
647 }
648
649 if( aPlotOpts.m_plotDrawingSheet )
650 {
651 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
652 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
654
655 SCHEMATIC* sch = aScreen->Schematic();
656 wxString variantName = sch->GetCurrentVariant();
657 wxString variantDesc = sch->GetVariantDescription( variantName );
658
659 PlotDrawingSheet( plotter, &sch->Project(), aScreen->GetTitleBlock(), actualPage, sch->GetProperties(),
660 aScreen->GetPageNumber(), aScreen->GetPageCount(), sheetName, sheetPath,
661 aScreen->GetFileName(), plotter->GetColorMode() ? color : COLOR4D::BLACK,
662 aScreen->GetVirtualPageNumber() == 1, variantName, variantDesc );
663 }
664
665 aScreen->Plot( plotter, aPlotOpts );
666
667 plotter->EndPlot();
668 delete plotter;
669
670 return true;
671}
672
673
675 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
676{
677 wxString msg;
678 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet();
679 SCH_SHEET_LIST sheetList;
680
681 if( aPlotOpts.m_plotAll )
682 {
683 sheetList.BuildSheetList( &m_schematic->Root(), true );
684 sheetList.SortByPageNumbers();
685
686 if( aPlotOpts.m_plotPages.size() > 0 )
687 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
688 }
689 else
690 {
691 sheetList.push_back( m_schematic->CurrentSheet() );
692 }
693
694 for( unsigned i = 0; i < sheetList.size(); i++ )
695 {
696 SCH_SCREEN* screen;
697
698 m_schematic->SetCurrentSheet( sheetList[i] );
699 m_schematic->CurrentSheet().UpdateAllScreenReferences();
700 m_schematic->SetSheetNumberAndCount();
701
702 screen = m_schematic->CurrentSheet().LastScreen();
703
704 try
705 {
706 wxString fname = m_schematic->GetUniqueFilenameForCurrentSheet();
707
708 fname.Replace( "/", "_" );
709 fname.Replace( "\\", "_" );
710
712 wxFileName plotFileName = createPlotFileName( aPlotOpts, fname, ext, aReporter );
713
714 m_lastOutputFilePath = plotFileName.GetFullPath();
716
717 if( !plotFileName.IsOk() )
718 return;
719
720 bool success = plotOneSheetPNG( plotFileName.GetFullPath(), screen, aRenderSettings,
721 aPlotOpts );
722
723 if( aReporter )
724 {
725 if( !success )
726 {
727 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
728 aReporter->Report( msg, RPT_SEVERITY_ERROR );
729 }
730 else
731 {
732 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
733 aReporter->Report( msg, RPT_SEVERITY_ACTION );
734 }
735 }
736 }
737 catch( const IO_ERROR& e )
738 {
739 if( aReporter )
740 {
741 msg.Printf( wxT( "PNG Plotter exception: %s" ), e.What() );
742 aReporter->Report( msg, RPT_SEVERITY_ERROR );
743 }
744
745 break;
746 }
747 }
748
749 if( aReporter )
750 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
751
752 restoreEnvironment( nullptr, oldsheetpath );
753}
754
755
756bool SCH_PLOTTER::plotOneSheetPNG( const wxString& aFileName, SCH_SCREEN* aScreen,
757 RENDER_SETTINGS* aRenderSettings,
758 const SCH_PLOT_OPTS& aPlotOpts )
759{
760 PAGE_INFO plotPage;
761 const PAGE_INFO& actualPage = aScreen->GetPageSettings();
762
763 switch( aPlotOpts.m_pageSizeSelect )
764 {
765 case PAGE_SIZE_A:
766 plotPage.SetType( wxT( "A" ) );
767 plotPage.SetPortrait( actualPage.IsPortrait() );
768 break;
769
770 case PAGE_SIZE_A4:
771 plotPage.SetType( wxT( "A4" ) );
772 plotPage.SetPortrait( actualPage.IsPortrait() );
773 break;
774
775 case PAGE_SIZE_AUTO:
776 default:
777 plotPage = actualPage;
778 break;
779 }
780
781 int dpi = std::clamp( aPlotOpts.m_pngDPI, MIN_PNG_DPI, MAX_PNG_DPI );
782
783 int pixelW = KiROUND( static_cast<double>( plotPage.GetWidthMils() ) * dpi / 1000.0 );
784 int pixelH = KiROUND( static_cast<double>( plotPage.GetHeightMils() ) * dpi / 1000.0 );
785
786 PNG_PLOTTER* plotter = new PNG_PLOTTER();
787
788 plotter->SetPixelSize( pixelW, pixelH );
789 plotter->SetResolution( dpi );
790 plotter->SetAntialias( aPlotOpts.m_pngAntialias );
791
792 // Schematic IU is Y-down (matches Cairo); leave SetYAxisReversed at its default of false.
793 // pcbnew sets it true because PCB IU is Y-up. Do not copy that wiring here.
794
795 plotter->SetRenderSettings( aRenderSettings );
796 plotter->SetPageSettings( plotPage );
797 plotter->SetColorMode( !aPlotOpts.m_blackAndWhite );
798
799 VECTOR2I plot_offset;
800 double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
801 double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
802 double scale = std::min( scalex, scaley );
803
804 plotter->SetViewport( plot_offset, schIUScale.IU_PER_MILS / 10, scale, false );
805 plotter->SetCreator( wxT( "Eeschema-PNG" ) );
806
807 if( !plotter->OpenFile( aFileName ) )
808 {
809 delete plotter;
810 return false;
811 }
812
813 plotter->StartPlot( m_schematic->CurrentSheet().GetPageNumber() );
814
815 if( aPlotOpts.m_useBackgroundColor && plotter->GetColorMode() )
816 {
818
819 VECTOR2I end( actualPage.GetWidthIU( schIUScale.IU_PER_MILS ),
820 actualPage.GetHeightIU( schIUScale.IU_PER_MILS ) );
821
822 plotter->Rect( VECTOR2I( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0, 0 );
823 }
824
825 if( aPlotOpts.m_plotDrawingSheet )
826 {
827 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
828 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
830
831 SCHEMATIC* sch = aScreen->Schematic();
832 wxString variantName = sch->GetCurrentVariant();
833 wxString variantDesc = sch->GetVariantDescription( variantName );
834
835 PlotDrawingSheet( plotter, &sch->Project(), aScreen->GetTitleBlock(), actualPage,
836 sch->GetProperties(), aScreen->GetPageNumber(), aScreen->GetPageCount(),
837 sheetName, sheetPath, aScreen->GetFileName(),
838 plotter->GetColorMode() ? color : COLOR4D::BLACK,
839 aScreen->GetVirtualPageNumber() == 1, variantName, variantDesc );
840 }
841
842 aScreen->Plot( plotter, aPlotOpts );
843
844 bool success = plotter->EndPlot();
845 delete plotter;
846
847 return success;
848}
849
850
852 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
853{
854 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet();
855
856 /* When printing all pages, the printed page is not the current page. In complex hierarchies,
857 * we must update symbol references and other parameters in the given printed SCH_SCREEN,
858 * according to the sheet path because in complex hierarchies a SCH_SCREEN (a drawing ) is
859 * shared between many sheets and symbol references depend on the actual sheet path used.
860 */
861 SCH_SHEET_LIST sheetList;
862
863 if( aPlotOpts.m_plotAll )
864 {
865 sheetList.BuildSheetList( &m_schematic->Root(), true );
866 sheetList.SortByPageNumbers();
867
868 // remove the non-selected pages if we are in plot pages mode
869 if( aPlotOpts.m_plotPages.size() > 0 )
870 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
871 }
872 else
873 {
874 // in Eeschema, this prints the current page
875 sheetList.push_back( m_schematic->CurrentSheet() );
876 }
877
878 for( unsigned i = 0; i < sheetList.size(); i++ )
879 {
880 m_schematic->SetCurrentSheet( sheetList[i] );
881 m_schematic->CurrentSheet().UpdateAllScreenReferences();
882 m_schematic->SetSheetNumberAndCount();
883
884 SCH_SCREEN* screen = m_schematic->CurrentSheet().LastScreen();
885 VECTOR2I plot_offset;
886 wxString msg;
887
888 try
889 {
890 wxString fname = m_schematic->GetUniqueFilenameForCurrentSheet();
891
892 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
893 // main project folder (or the folder specified by the caller),
894 // so replace separators to create a unique filename:
895 fname.Replace( "/", "_" );
896 fname.Replace( "\\", "_" );
898 wxFileName plotFileName = createPlotFileName( aPlotOpts, fname, ext, aReporter );
899
900 m_lastOutputFilePath = plotFileName.GetFullPath();
902
903 if( !plotFileName.IsOk() )
904 return;
905
906 if( plotOneSheetDXF( plotFileName.GetFullPath(), screen, aRenderSettings, plot_offset,
907 1.0, aPlotOpts ) )
908 {
909 if( aReporter )
910 {
911 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
912 aReporter->Report( msg, RPT_SEVERITY_ACTION );
913 }
914 }
915 else // Error
916 {
917 if( aReporter )
918 {
919 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
920 aReporter->Report( msg, RPT_SEVERITY_ERROR );
921 }
922 }
923 }
924 catch( IO_ERROR& e )
925 {
926 if( aReporter )
927 {
928 msg.Printf( wxT( "DXF Plotter exception: %s" ), e.What() );
929 aReporter->Report( msg, RPT_SEVERITY_ERROR );
930 }
931
932 m_schematic->SetCurrentSheet( oldsheetpath );
933 m_schematic->CurrentSheet().UpdateAllScreenReferences();
934 m_schematic->SetSheetNumberAndCount();
935 return;
936 }
937 }
938
939 if( aReporter )
940 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
941
942 restoreEnvironment( nullptr, oldsheetpath );
943}
944
945
946bool SCH_PLOTTER::plotOneSheetDXF( const wxString& aFileName, SCH_SCREEN* aScreen,
947 RENDER_SETTINGS* aRenderSettings, const VECTOR2I& aPlotOffset,
948 double aScale, const SCH_PLOT_OPTS& aPlotOpts )
949{
950 aRenderSettings->LoadColors( m_colorSettings );
951 aRenderSettings->SetDefaultPenWidth( 0 );
952
953 const PAGE_INFO& pageInfo = aScreen->GetPageSettings();
954 DXF_PLOTTER* plotter = new DXF_PLOTTER();
955
956 plotter->SetUnits( aPlotOpts.m_DXF_File_Unit );
957
958 plotter->SetRenderSettings( aRenderSettings );
959 plotter->SetPageSettings( pageInfo );
960 plotter->SetColorMode( !aPlotOpts.m_blackAndWhite );
961
962 // Currently, plot units are in decimil
963 plotter->SetViewport( aPlotOffset, schIUScale.IU_PER_MILS / 10, aScale, false );
964
965 // Init :
966 plotter->SetCreator( wxT( "Eeschema-DXF" ) );
967
968 if( !plotter->OpenFile( aFileName ) )
969 {
970 delete plotter;
971 return false;
972 }
973
974 plotter->StartPlot( m_schematic->CurrentSheet().GetPageNumber() );
975
976 if( aPlotOpts.m_plotDrawingSheet )
977 {
978 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
979 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
981
982 wxString variantName = m_schematic->GetCurrentVariant();
983 wxString variantDesc = m_schematic->GetVariantDescription( variantName );
984
985 PlotDrawingSheet( plotter, &m_schematic->Project(), aScreen->GetTitleBlock(), pageInfo,
986 m_schematic->GetProperties(), aScreen->GetPageNumber(), aScreen->GetPageCount(), sheetName,
987 sheetPath, aScreen->GetFileName(), plotter->GetColorMode() ? color : COLOR4D::BLACK,
988 aScreen->GetVirtualPageNumber() == 1, variantName, variantDesc );
989 }
990
991 aScreen->Plot( plotter, aPlotOpts );
992
993 // finish
994 plotter->EndPlot();
995 delete plotter;
996
997 return true;
998}
999
1000
1002{
1003 if( aPlotter )
1004 {
1005 aPlotter->EndPlot();
1006 delete aPlotter;
1007 }
1008
1009 // Restore the initial sheet
1010 m_schematic->SetCurrentSheet( aOldsheetpath );
1011 m_schematic->CurrentSheet().UpdateAllScreenReferences();
1012 m_schematic->SetSheetNumberAndCount();
1013}
1014
1015
1017 const wxString& aPlotFileName,
1018 const wxString& aExtension, REPORTER* aReporter )
1019{
1020 wxFileName retv;
1021 wxFileName tmp;
1022
1023 tmp.SetPath( aPlotOpts.m_outputDirectory );
1024 retv.SetPath( tmp.GetPath() );
1025
1026 if( !aPlotFileName.IsEmpty() )
1027 retv.SetName( aPlotFileName );
1028 else
1029 retv.SetName( _( "Schematic" ) );
1030
1031 retv.SetExt( aExtension );
1032
1033 if( !EnsureFileDirectoryExists( &tmp, retv.GetFullName(), aReporter ) || !tmp.IsDirWritable() )
1034 {
1035 if( aReporter )
1036 {
1037 wxString msg = wxString::Format( _( "Failed to write plot files to folder '%s'." ),
1038 tmp.GetPath() );
1039 aReporter->Report( msg, RPT_SEVERITY_ERROR );
1040 }
1041
1042 retv.Clear();
1043
1044 SCHEMATIC_SETTINGS& settings = m_schematic->Settings();
1045 settings.m_PlotDirectoryName.Clear();
1046 }
1047 else
1048 {
1049 retv.SetPath( tmp.GetPath() );
1050 }
1051
1052 wxLogTrace( tracePathsAndFiles, "Writing plot file '%s'.", retv.GetFullPath() );
1053
1054 return retv;
1055}
1056
1057
1058void SCH_PLOTTER::Plot( PLOT_FORMAT aPlotFormat, const SCH_PLOT_OPTS& aPlotOpts,
1059 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
1060{
1061 m_outputFilePaths.clear();
1062
1063 wxString oldVariant = m_schematic->GetCurrentVariant();
1064 m_schematic->SetCurrentVariant( aPlotOpts.m_variant );
1066
1067 switch( aPlotFormat )
1068 {
1069 default:
1070 case PLOT_FORMAT::POST: createPSFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1071 case PLOT_FORMAT::DXF: createDXFFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1072 case PLOT_FORMAT::PDF: createPDFFile( aPlotOpts, aRenderSettings, aReporter ); break;
1073 case PLOT_FORMAT::SVG: createSVGFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1074 case PLOT_FORMAT::PNG: createPNGFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1075 case PLOT_FORMAT::HPGL: /* no longer supported */ break;
1076 }
1077
1078 m_schematic->SetCurrentVariant( oldVariant );
1079}
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:123
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:986
int GetPageCount() const
Definition base_screen.h:68
int GetVirtualPageNumber() const
Definition base_screen.h:71
const wxString & GetPageNumber() const
static const COLOR4D BLACK
Definition color4d.h:402
static wxString GetDefaultFileExtension()
void SetUnits(DXF_UNITS aUnit)
Set the units to use for plotting the DXF file.
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the scale/position for the DXF plot.
virtual bool StartPlot(const wxString &aPageNumber) override
Open the DXF plot with a skeleton header.
virtual bool EndPlot() override
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
void SetDefaultPenWidth(int aWidth)
virtual void LoadColors(const COLOR_SETTINGS *aSettings)
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
virtual const COLOR4D & GetBackgroundColor() const =0
Return current background color settings.
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition page_info.h:75
void SetPortrait(bool aIsPortrait)
Rotate the paper page 90 degrees.
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
Definition page_info.h:164
bool SetType(PAGE_SIZE_TYPE aPageSize, bool aIsPortrait=false)
Set the name of the page type and also the sizes and margins commonly associated with that type name.
double GetHeightMils() const
Definition page_info.h:143
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
Definition page_info.h:155
double GetWidthMils() const
Definition page_info.h:138
bool IsPortrait() const
Definition page_info.h:124
virtual void ClosePage()
Close the current page in the PDF document (and emit its compressed stream).
virtual bool EndPlot() override
virtual bool OpenFile(const wxString &aFullFilename) override
Open or create the plot file aFullFilename.
virtual bool StartPlot(const wxString &aPageNumber) override
The PDF engine supports multiple pages; the first one is opened 'for free' the following are to be cl...
static wxString GetDefaultFileExtension()
virtual void StartPage(const wxString &aPageNumber, const wxString &aPageName=wxEmptyString, const wxString &aParentPageNumber=wxEmptyString, const wxString &aParentPageName=wxEmptyString)
Start a new page in the PDF document.
Base plotter engine class.
Definition plotter.h:133
virtual bool OpenFile(const wxString &aFullFilename)
Open or create the plot file aFullFilename.
Definition plotter.cpp:73
virtual void SetAuthor(const wxString &aAuthor)
Definition plotter.h:187
virtual void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition plotter.h:166
void SetRenderSettings(RENDER_SETTINGS *aSettings)
Definition plotter.h:163
virtual void SetTitle(const wxString &aTitle)
Definition plotter.h:186
RENDER_SETTINGS * RenderSettings()
Definition plotter.h:164
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width, int aCornerRadius=0)=0
virtual void SetCreator(const wxString &aCreator)
Definition plotter.h:185
bool GetColorMode() const
Definition plotter.h:161
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror)=0
Set the plot offset and scaling for the current plot.
virtual void SetColorMode(bool aColorMode)
Plot in B/W or color.
Definition plotter.h:160
virtual void SetSubject(const wxString &aSubject)
Definition plotter.h:188
virtual void SetColor(const COLOR4D &color)=0
PNG rasterization plotter using Cairo graphics library.
Definition plotter_png.h:40
void SetPixelSize(int aWidth, int aHeight)
Set the output image dimensions in pixels.
Definition plotter_png.h:64
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T aFill, int aWidth, int aCornerRadius=0) override
void SetResolution(int aDPI)
Set the output resolution in dots per inch.
Definition plotter_png.h:56
virtual bool EndPlot() override
void SetAntialias(bool aEnable)
Enable or disable anti-aliasing.
Definition plotter_png.h:84
virtual void SetColor(const COLOR4D &aColor) override
static wxString GetDefaultFileExtension()
Definition plotter_png.h:50
virtual bool OpenFile(const wxString &aFullFilename) override
Open or create the plot file aFullFilename.
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
virtual bool StartPlot(const wxString &aPageNumber) override
virtual void SetColor(const COLOR4D &color) override
The SetColor implementation is split with the subclasses: the PSLIKE computes the rgb values,...
virtual bool EndPlot() override
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width, int aCornerRadius=0) override
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
virtual bool StartPlot(const wxString &aPageNumber) override
The code within this function (and the CloseFilePS function) creates postscript files whose contents ...
static wxString GetDefaultFileExtension()
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:71
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
Definition reporter.h:100
virtual REPORTER & ReportTail(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Places the report at the end of the list, for objects that support report ordering.
Definition reporter.h:110
These are loaded from Eeschema settings but then overwritten by the project settings.
Holds all the data relating to one schematic.
Definition schematic.h:90
wxString GetVariantDescription(const wxString &aVariantName) const
Return the description for a variant.
PROJECT & Project() const
Return a reference to the project this schematic is part of.
Definition schematic.h:105
wxString GetCurrentVariant() const
Return the current variant being edited.
const std::map< wxString, wxString > * GetProperties()
Definition schematic.h:108
Schematic editor (Eeschema) main window.
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0, const wxString &aVariantName=wxEmptyString) const
void Plot(PLOT_FORMAT aPlotFormat, const SCH_PLOT_OPTS &aPlotOpts, SCH_RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter=nullptr)
Perform the plotting of the schematic using the given aPlotFormat and a\ aPlotSettings.
wxFileName getOutputFilenameSingle(const SCH_PLOT_OPTS &aPlotOpts, REPORTER *aReporter, const wxString &ext)
Return the output filename for formats where the output is a single file.
void createSVGFiles(const SCH_PLOT_OPTS &aPlotOpts, SCH_RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
void createPSFiles(const SCH_PLOT_OPTS &aPlotOpts, SCH_RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
void plotOneSheetPDF(PLOTTER *aPlotter, SCH_SCREEN *aScreen, const SCH_PLOT_OPTS &aPlotOpts)
wxFileName createPlotFileName(const SCH_PLOT_OPTS &aPlotOpts, const wxString &aPlotFileName, const wxString &aExtension, REPORTER *aReporter=nullptr)
Create a file name with an absolute path name.
SCH_PLOTTER(SCH_EDIT_FRAME *aFrame)
Constructor for usage with a frame having the schematic we want to print loaded.
bool plotOneSheetDXF(const wxString &aFileName, SCH_SCREEN *aScreen, RENDER_SETTINGS *aRenderSettings, const VECTOR2I &aPlotOffset, double aScale, const SCH_PLOT_OPTS &aPlotOpts)
void createDXFFiles(const SCH_PLOT_OPTS &aPlotOpts, SCH_RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
wxString m_lastOutputFilePath
void restoreEnvironment(PDF_PLOTTER *aPlotter, SCH_SHEET_PATH &aOldsheetpath)
Everything done, close the plot and restore the environment.
std::vector< wxString > m_outputFilePaths
void createPNGFiles(const SCH_PLOT_OPTS &aPlotOpts, SCH_RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
bool plotOneSheetSVG(const wxString &aFileName, SCH_SCREEN *aScreen, RENDER_SETTINGS *aRenderSettings, const SCH_PLOT_OPTS &aPlotOpts)
void setupPlotPagePDF(PLOTTER *aPlotter, SCH_SCREEN *aScreen, const SCH_PLOT_OPTS &aPlotOpts)
bool plotOneSheetPNG(const wxString &aFileName, SCH_SCREEN *aScreen, RENDER_SETTINGS *aRenderSettings, const SCH_PLOT_OPTS &aPlotOpts)
void createPDFFile(const SCH_PLOT_OPTS &aPlotOpts, SCH_RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
COLOR_SETTINGS * m_colorSettings
bool plotOneSheetPS(const wxString &aFileName, SCH_SCREEN *aScreen, RENDER_SETTINGS *aRenderSettings, const PAGE_INFO &aPageInfo, const VECTOR2I &aPlot0ffset, double aScale, const SCH_PLOT_OPTS &aPlotOpts)
SCHEMATIC * m_schematic
const PAGE_INFO & GetPageSettings() const
Definition sch_screen.h:137
const wxString & GetFileName() const
Definition sch_screen.h:150
SCHEMATIC * Schematic() const
TITLE_BLOCK & GetTitleBlock()
Definition sch_screen.h:161
void Plot(PLOTTER *aPlotter, const SCH_PLOT_OPTS &aPlotOpts) const
Plot all the schematic objects to aPlotter.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void TrimToPageNumbers(const std::vector< wxString > &aPageInclusions)
Truncates the list by removing sheet's with page numbers not in the given list.
void SortByPageNumbers(bool aUpdateVirtualPageNums=true)
Sort the list of sheets by page number.
void SortByHierarchicalPageNumbers(bool aUpdateVirtualPageNums=true)
This works like SortByPageNumbers, but it sorts the sheets first by their hierarchical depth and then...
void BuildSheetList(SCH_SHEET *aSheet, bool aCheckIntegrity)
Build the list of sheets and their sheet path from aSheet.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
wxString GetPageNumber() const
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
size_t size() const
Forwarded method from std::vector.
void pop_back()
Forwarded method from std::vector.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
virtual bool StartPlot(const wxString &aPageNumber) override
Create SVG file header.
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width, int aCornerRadius=0) override
virtual bool EndPlot() override
static wxString GetDefaultFileExtension()
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, int aFlags)
Definition common.cpp:59
bool EnsureFileDirectoryExists(wxFileName *aTargetFullFileName, const wxString &aBaseFilename, REPORTER *aReporter)
Make aTargetFullFileName absolute and create the path of this file if it doesn't yet exist.
Definition common.cpp:725
The common library.
void PlotDrawingSheet(PLOTTER *plotter, const PROJECT *aProject, const TITLE_BLOCK &aTitleBlock, const PAGE_INFO &aPageInfo, const std::map< wxString, wxString > *aProperties, const wxString &aSheetNumber, int aSheetCount, const wxString &aSheetName, const wxString &aSheetPath, const wxString &aFilename, COLOR4D aColor, bool aIsFirstPage, const wxString &aVariantName, const wxString &aVariantDesc)
#define _(s)
@ FILLED_SHAPE
Fill with object color.
Definition eda_shape.h:61
const wxChar *const tracePathsAndFiles
Flag to enable path and file name debug output.
@ LAYER_SCHEMATIC_DRAWINGSHEET
Definition layer_ids.h:494
@ LAYER_SCHEMATIC_BACKGROUND
Definition layer_ids.h:486
see class PGM_BASE
PLOT_FORMAT
The set of supported output plot formats.
Definition plotter.h:60
constexpr int MIN_PNG_DPI
Definition plotter_png.h:29
constexpr int MAX_PNG_DPI
Definition plotter_png.h:30
Plotting engines similar to ps (PostScript, Gerber, svg)
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_INFO
@ RPT_SEVERITY_ACTION
@ PAGE_SIZE_AUTO
Definition sch_plotter.h:45
@ PAGE_SIZE_A
Definition sch_plotter.h:47
@ PAGE_SIZE_A4
Definition sch_plotter.h:46
COLOR_SETTINGS * GetColorSettings(const wxString &aName)
const int scale
std::vector< wxString > m_plotPages
Definition sch_plotter.h:55
wxString m_theme
Definition sch_plotter.h:64
DXF_UNITS m_DXF_File_Unit
Definition sch_plotter.h:71
wxString m_outputDirectory
Definition sch_plotter.h:66
bool m_pngAntialias
Definition sch_plotter.h:74
wxString m_outputFile
Definition sch_plotter.h:67
bool m_blackAndWhite
Definition sch_plotter.h:58
wxString m_variant
Definition sch_plotter.h:68
bool m_useBackgroundColor
Definition sch_plotter.h:60
bool m_plotDrawingSheet
Definition sch_plotter.h:54
VECTOR2I end
wxLogTrace helper definitions.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683