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 (C) 1992-2023, 2024 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, you may find one here:
21 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22 * or you may search the http://www.gnu.org website for the version 2 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
27#include <wx/log.h>
28#include <common.h>
29#include <sch_plotter.h>
30#include <locale_io.h>
34
35#include <pgm_base.h>
36#include <trace_helpers.h>
37
38#include <sch_edit_frame.h>
39#include <sch_painter.h>
40#include <schematic.h>
41#include <sch_screen.h>
43
44// Note:
45// We need to switch between sheets to plot a hierarchy and update references and sheet number
46// Use SCHEMATIC::SetCurrentSheet( xxx ) to switch to a sheet.
47// Do not use SCH_EDIT_FRAME::SetCurrentSheet( xxx ) to switch to a sheet, because the new sheet
48// is not displayed, but SCH_EDIT_FRAME::SetCurrentSheet() has side effects to the current VIEW
49// (clear some data used to show the sheet on screen) and does not fully restore the "old" screen
50
51
52static const wxChar* plot_sheet_list( HPGL_PAGE_SIZE aSize )
53{
54 switch( aSize )
55 {
56 default:
57 case HPGL_PAGE_SIZE::DEFAULT: return nullptr;
58 case HPGL_PAGE_SIZE::SIZE_A5: return wxT( "A5" );
59 case HPGL_PAGE_SIZE::SIZE_A4: return wxT( "A4" );
60 case HPGL_PAGE_SIZE::SIZE_A3: return wxT( "A3" );
61 case HPGL_PAGE_SIZE::SIZE_A2: return wxT( "A2" );
62 case HPGL_PAGE_SIZE::SIZE_A1: return wxT( "A1" );
63 case HPGL_PAGE_SIZE::SIZE_A0: return wxT( "A0" );
64 case HPGL_PAGE_SIZE::SIZE_A: return wxT( "A" );
65 case HPGL_PAGE_SIZE::SIZE_B: return wxT( "B" );
66 case HPGL_PAGE_SIZE::SIZE_C: return wxT( "C" );
67 case HPGL_PAGE_SIZE::SIZE_D: return wxT( "D" );
68 case HPGL_PAGE_SIZE::SIZE_E: return wxT( "E" );
69 }
70}
71
72
74 m_schematic( aSchematic )
75{
76 m_colorSettings = nullptr;
77}
78
79
81 m_schematic( &aFrame->Schematic() )
82{
83 m_colorSettings = nullptr;
84}
85
86
88 REPORTER* aReporter, const wxString& aExt )
89{
90 if( !aPlotOpts.m_outputFile.empty() )
91 {
92 return aPlotOpts.m_outputFile;
93 }
94 else
95 {
97
98 // The sub sheet can be in a sub_hierarchy, but we plot the file in the main
99 // project folder (or the folder specified by the caller), so replace separators
100 // to create a unique filename:
101 fname.Replace( "/", "_" );
102 fname.Replace( "\\", "_" );
103
104 return createPlotFileName( aPlotOpts, fname, aExt, aReporter );
105 }
106
107}
108
109
111 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
112{
113 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet(); // sheetpath is saved here
114
115 /* When printing all pages, the printed page is not the current page. In complex hierarchies,
116 * we must update symbol references and other parameters in the given printed SCH_SCREEN,
117 * according to the sheet path because in complex hierarchies a SCH_SCREEN (a drawing ) is
118 * shared between many sheets and symbol references depend on the actual sheet path used.
119 */
120 SCH_SHEET_LIST sheetList;
121
122 if( aPlotOpts.m_plotAll || aPlotOpts.m_plotPages.size() > 0 )
123 {
124 sheetList.BuildSheetList( &m_schematic->Root(), true );
125 sheetList.SortByPageNumbers();
126
127 // remove the non-selected pages if we are in plot pages mode
128 if( aPlotOpts.m_plotPages.size() > 0 )
129 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
130 }
131 else
132 {
133 // in eeschema, this prints the current page
134 sheetList.push_back( m_schematic->CurrentSheet() );
135 }
136
137 wxCHECK( m_schematic, /* void */ );
138
139 // Allocate the plotter and set the job level parameter
140 PDF_PLOTTER* plotter = new PDF_PLOTTER( &m_schematic->Prj() );
141 plotter->SetRenderSettings( aRenderSettings );
142 plotter->SetColorMode( !aPlotOpts.m_blackAndWhite );
143 plotter->SetCreator( wxT( "Eeschema-PDF" ) );
145 &m_schematic->Prj() ) );
146
147 wxString msg;
148 wxFileName plotFileName;
149 LOCALE_IO toggle; // Switch the locale to standard C
150
151 for( unsigned i = 0; i < sheetList.size(); i++ )
152 {
153 m_schematic->SetCurrentSheet( sheetList[i] );
156
158 wxString sheetName = sheetList[i].Last()->GetFields()[SHEETNAME].GetShownText( false );
159
160 if( aPlotOpts.m_PDFMetadata )
161 {
162 msg = wxS( "AUTHOR" );
163
164 if( m_schematic->ResolveTextVar( &sheetList[i], &msg, 0 ) )
165 plotter->SetAuthor( msg );
166
167 msg = wxS( "SUBJECT" );
168
169 if( m_schematic->ResolveTextVar( &sheetList[i], &msg, 0 ) )
170 plotter->SetSubject( msg );
171 }
172
173 if( i == 0 )
174 {
175 try
176 {
178 plotFileName = getOutputFilenameSingle( aPlotOpts, aReporter, ext );
179
180 m_lastOutputFilePath = plotFileName.GetFullPath();
181
182 if( !plotFileName.IsOk() )
183 return;
184
185 if( !plotter->OpenFile( plotFileName.GetFullPath() ) )
186 {
187 if( aReporter )
188 {
189 msg.Printf( _( "Failed to create file '%s'." ),
190 plotFileName.GetFullPath() );
191 aReporter->Report( msg, RPT_SEVERITY_ERROR );
192 }
193 delete plotter;
194 return;
195 }
196
197 // Open the plotter and do the first page
198 setupPlotPagePDF( plotter, screen, aPlotOpts );
199
200 plotter->StartPlot( sheetList[i].GetPageNumber(), sheetName );
201 }
202 catch( const IO_ERROR& e )
203 {
204 // Cannot plot PDF file
205 if( aReporter )
206 {
207 msg.Printf( wxT( "PDF Plotter exception: %s" ), e.What() );
208 aReporter->Report( msg, RPT_SEVERITY_ERROR );
209 }
210
211 restoreEnvironment( plotter, oldsheetpath );
212 return;
213 }
214 }
215 else
216 {
217 /* For the following pages you need to close the (finished) page,
218 * reconfigure, and then start a new one */
219 plotter->ClosePage();
220 setupPlotPagePDF( plotter, screen, aPlotOpts );
221 plotter->StartPage( sheetList[i].GetPageNumber(), sheetName );
222 }
223
224 plotOneSheetPDF( plotter, screen, aPlotOpts );
225 }
226
227 // Everything done, close the plot and restore the environment
228 if( aReporter )
229 {
230 msg.Printf( _( "Plotted to '%s'.\n" ), plotFileName.GetFullPath() );
231 aReporter->Report( msg, RPT_SEVERITY_ACTION );
232 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
233 }
234
235 restoreEnvironment( plotter, oldsheetpath );
236}
237
238
240 const SCH_PLOT_OPTS& aPlotOpts )
241{
242 if( aPlotOpts.m_useBackgroundColor && aPlotter->GetColorMode() )
243 {
244 aPlotter->SetColor( aPlotter->RenderSettings()->GetBackgroundColor() );
247 aPlotter->Rect( VECTOR2I( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 );
248 }
249
250 if( aPlotOpts.m_plotDrawingSheet )
251 {
252 COLOR4D color = COLOR4D::BLACK;
253
254 if( aPlotter->GetColorMode() )
256
257 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
258 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
259 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
260
261 PlotDrawingSheet( aPlotter, &aScreen->Schematic()->Prj(),
262 aScreen->GetTitleBlock(),
263 actualPage,
264 aScreen->Schematic()->GetProperties(),
265 aScreen->GetPageNumber(), aScreen->GetPageCount(), sheetName, sheetPath,
266 aScreen->GetFileName(), color, aScreen->GetVirtualPageNumber() == 1 );
267 }
268
269 aScreen->Plot( aPlotter, aPlotOpts );
270}
271
272
274 const SCH_PLOT_OPTS& aPlotOpts )
275{
276 PAGE_INFO plotPage; // page size selected to plot
277
278 // Considerations on page size and scaling requests
279 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
280
281 switch( aPlotOpts.m_pageSizeSelect )
282 {
283 case PAGE_SIZE_A:
284 plotPage.SetType( wxT( "A" ) );
285 plotPage.SetPortrait( actualPage.IsPortrait() );
286 break;
287
288 case PAGE_SIZE_A4:
289 plotPage.SetType( wxT( "A4" ) );
290 plotPage.SetPortrait( actualPage.IsPortrait() );
291 break;
292
293 case PAGE_SIZE_AUTO:
294 default:
295 plotPage = actualPage;
296 break;
297 }
298
299 double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
300 double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
301 double scale = std::min( scalex, scaley );
302 aPlotter->SetPageSettings( plotPage );
303
304 // Currently, plot units are in decimil
305 aPlotter->SetViewport( VECTOR2I( 0, 0 ), schIUScale.IU_PER_MILS / 10, scale, false );
306}
307
308
310 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
311{
312 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet(); // sheetpath is saved here
313 PAGE_INFO plotPage; // page size selected to plot
314 wxString msg;
315
316 /* When printing all pages, the printed page is not the current page.
317 * In complex hierarchies, we must update symbol references and other parameters in the
318 * given printed SCH_SCREEN, accordant to the sheet path because in complex hierarchies
319 * a SCH_SCREEN (a drawing ) is shared between many sheets and symbol references
320 * depend on the actual sheet path used.
321 */
322 SCH_SHEET_LIST sheetList;
323
324 if( aPlotOpts.m_plotAll )
325 {
326 sheetList.BuildSheetList( &m_schematic->Root(), true );
327 sheetList.SortByPageNumbers();
328
329 // remove the non-selected pages if we are in plot pages mode
330 if( aPlotOpts.m_plotPages.size() > 0 )
331 {
332 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
333 }
334 }
335 else
336 {
337 sheetList.push_back( m_schematic->CurrentSheet() );
338 }
339
340 for( unsigned i = 0; i < sheetList.size(); i++ )
341 {
342 m_schematic->SetCurrentSheet( sheetList[i] );
345
347 PAGE_INFO actualPage = screen->GetPageSettings();
348
349 switch( aPlotOpts.m_pageSizeSelect )
350 {
351 case PAGE_SIZE_A:
352 plotPage.SetType( wxT( "A" ) );
353 plotPage.SetPortrait( actualPage.IsPortrait() );
354 break;
355
356 case PAGE_SIZE_A4:
357 plotPage.SetType( wxT( "A4" ) );
358 plotPage.SetPortrait( actualPage.IsPortrait() );
359 break;
360
361 case PAGE_SIZE_AUTO:
362 default: plotPage = actualPage; break;
363 }
364
365 double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
366 double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
367 double scale = std::min( scalex, scaley );
368 VECTOR2I plot_offset;
369
370 try
371 {
373
374 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
375 // main project folder (or the folder specified by the caller),
376 // so replace separators to create a unique filename:
377 fname.Replace( "/", "_" );
378 fname.Replace( "\\", "_" );
380 wxFileName plotFileName = createPlotFileName( aPlotOpts, fname, ext, aReporter );
381
382 m_lastOutputFilePath = plotFileName.GetFullPath();
383
384 if( !plotFileName.IsOk() )
385 return;
386
387 if( plotOneSheetPS( plotFileName.GetFullPath(), screen, aRenderSettings, actualPage,
388 plot_offset, scale, aPlotOpts ) )
389 {
390 if( aReporter )
391 {
392 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
393 aReporter->Report( msg, RPT_SEVERITY_ACTION );
394 }
395 }
396 else
397 {
398 if( aReporter )
399 {
400 // Error
401 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
402 aReporter->Report( msg, RPT_SEVERITY_ERROR );
403 }
404 }
405 }
406 catch( IO_ERROR& e )
407 {
408 if( aReporter )
409 {
410 msg.Printf( wxT( "PS Plotter exception: %s" ), e.What() );
411 aReporter->Report( msg, RPT_SEVERITY_ERROR );
412 }
413 }
414 }
415
416 if( aReporter )
417 {
418 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
419 }
420
421 restoreEnvironment( nullptr, oldsheetpath );
422}
423
424
425bool SCH_PLOTTER::plotOneSheetPS( const wxString& aFileName, SCH_SCREEN* aScreen,
426 RENDER_SETTINGS* aRenderSettings, const PAGE_INFO& aPageInfo,
427 const VECTOR2I& aPlot0ffset, double aScale,
428 const SCH_PLOT_OPTS& aPlotOpts )
429{
430 PS_PLOTTER* plotter = new PS_PLOTTER();
431 plotter->SetRenderSettings( aRenderSettings );
432 plotter->SetPageSettings( aPageInfo );
433 plotter->SetColorMode( !aPlotOpts.m_blackAndWhite );
434
435 // Currently, plot units are in decimil
436 plotter->SetViewport( aPlot0ffset, schIUScale.IU_PER_MILS / 10, aScale, false );
437
438 // Init :
439 plotter->SetCreator( wxT( "Eeschema-PS" ) );
440
441 if( !plotter->OpenFile( aFileName ) )
442 {
443 delete plotter;
444 return false;
445 }
446
447 LOCALE_IO toggle; // Switch the locale to standard C
448
450
451 if( aPlotOpts.m_useBackgroundColor && plotter->GetColorMode() )
452 {
454
457 plotter->Rect( VECTOR2I( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 );
458 }
459
460 if( aPlotOpts.m_plotDrawingSheet )
461 {
462 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
463 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
465
466 PlotDrawingSheet( plotter, &aScreen->Schematic()->Prj(),
467 aScreen->GetTitleBlock(),
468 aPageInfo, aScreen->Schematic()->GetProperties(),
469 aScreen->GetPageNumber(), aScreen->GetPageCount(), sheetName, sheetPath,
470 aScreen->GetFileName(), plotter->GetColorMode() ? color : COLOR4D::BLACK,
471 aScreen->GetVirtualPageNumber() == 1 );
472 }
473
474 aScreen->Plot( plotter, aPlotOpts );
475
476 plotter->EndPlot();
477 delete plotter;
478
479 return true;
480}
481
482
484 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
485{
486 wxString msg;
487 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet();
488 SCH_SHEET_LIST sheetList;
489
490 if( aPlotOpts.m_plotAll )
491 {
492 sheetList.BuildSheetList( &m_schematic->Root(), true );
493 sheetList.SortByPageNumbers();
494
495 // remove the non-selected pages if we are in plot pages mode
496 if( aPlotOpts.m_plotPages.size() > 0 )
497 {
498 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
499 }
500 }
501 else
502 {
503 // in eeschema, this prints the current page
504 sheetList.push_back( m_schematic->CurrentSheet() );
505 }
506
507 for( unsigned i = 0; i < sheetList.size(); i++ )
508 {
509 SCH_SCREEN* screen;
510
511 m_schematic->SetCurrentSheet( sheetList[i] );
514
515 screen = m_schematic->CurrentSheet().LastScreen();
516
517 try
518 {
520
521 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
522 // main project folder (or the folder specified by the caller),
523 // so replace separators to create a unique filename:
524 fname.Replace( "/", "_" );
525 fname.Replace( "\\", "_" );
527 wxFileName plotFileName = createPlotFileName( aPlotOpts, fname, ext, aReporter );
528
529 m_lastOutputFilePath = plotFileName.GetFullPath();
530
531 if( !plotFileName.IsOk() )
532 return;
533
534 bool success = plotOneSheetSVG( plotFileName.GetFullPath(), screen, aRenderSettings,
535 aPlotOpts );
536
537 if( !success )
538 {
539 if( aReporter )
540 {
541 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
542 aReporter->Report( msg, RPT_SEVERITY_ERROR );
543 }
544 }
545 else
546 {
547 if( aReporter )
548 {
549 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
550 aReporter->Report( msg, RPT_SEVERITY_ACTION );
551 }
552 }
553 }
554 catch( const IO_ERROR& e )
555 {
556 if( aReporter )
557 {
558 // Cannot plot SVG file
559 msg.Printf( wxT( "SVG Plotter exception: %s" ), e.What() );
560 aReporter->Report( msg, RPT_SEVERITY_ERROR );
561 }
562 break;
563 }
564 }
565
566 if( aReporter )
567 {
568 aReporter->ReportTail( _( "Done" ), RPT_SEVERITY_INFO );
569 }
570
571 restoreEnvironment( nullptr, oldsheetpath );
572}
573
574
575bool SCH_PLOTTER::plotOneSheetSVG( const wxString& aFileName, SCH_SCREEN* aScreen,
576 RENDER_SETTINGS* aRenderSettings,
577 const SCH_PLOT_OPTS& aPlotOpts )
578{
579 PAGE_INFO plotPage;
580 // Adjust page size and scaling requests
581 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
582
583 switch( aPlotOpts.m_pageSizeSelect )
584 {
585 case PAGE_SIZE_A:
586 plotPage.SetType( wxT( "A" ) );
587 plotPage.SetPortrait( actualPage.IsPortrait() );
588 break;
589
590 case PAGE_SIZE_A4:
591 plotPage.SetType( wxT( "A4" ) );
592 plotPage.SetPortrait( actualPage.IsPortrait() );
593 break;
594
595 case PAGE_SIZE_AUTO:
596 default:
597 plotPage = actualPage;
598 break;
599 }
600
601 SVG_PLOTTER* plotter = new SVG_PLOTTER();
602 plotter->SetRenderSettings( aRenderSettings );
603 plotter->SetPageSettings( plotPage );
604 plotter->SetColorMode( aPlotOpts.m_blackAndWhite ? false : true );
605 VECTOR2I plot_offset;
606
607 double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
608 double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
609 double scale = std::min( scalex, scaley );
610
611 // Currently, plot units are in decimil
612 plotter->SetViewport( plot_offset, schIUScale.IU_PER_MILS / 10, scale, false );
613
614 // Init :
615 plotter->SetCreator( wxT( "Eeschema-SVG" ) );
616
617 if( !plotter->OpenFile( aFileName ) )
618 {
619 delete plotter;
620 return false;
621 }
622
623 LOCALE_IO toggle;
624
626
627 if( aPlotOpts.m_useBackgroundColor && plotter->GetColorMode() )
628 {
632 plotter->Rect( VECTOR2I( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 );
633 }
634
635 if( aPlotOpts.m_plotDrawingSheet )
636 {
637 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
638 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
640
641 PlotDrawingSheet( plotter, &aScreen->Schematic()->Prj(),
642 aScreen->GetTitleBlock(),
643 actualPage, aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(),
644 aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(),
645 plotter->GetColorMode() ? color : COLOR4D::BLACK,
646 aScreen->GetVirtualPageNumber() == 1 );
647 }
648
649 aScreen->Plot( plotter, aPlotOpts );
650
651 plotter->EndPlot();
652 delete plotter;
653
654 return true;
655}
656
657
659 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
660{
661 SCH_SCREEN* screen = m_schematic->RootScreen();
662 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet();
663
664 /* When printing all pages, the printed page is not the current page. In complex hierarchies,
665 * we must update symbol references and other parameters in the given printed SCH_SCREEN,
666 * according to the sheet path because in complex hierarchies a SCH_SCREEN (a drawing ) is
667 * shared between many sheets and symbol references depend on the actual sheet path used.
668 */
669 SCH_SHEET_LIST sheetList;
670
671 if( aPlotOpts.m_plotAll )
672 {
673 sheetList.BuildSheetList( &m_schematic->Root(), true );
674 sheetList.SortByPageNumbers();
675
676 // remove the non-selected pages if we are in plot pages mode
677 if( aPlotOpts.m_plotPages.size() > 0 )
678 {
679 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
680 }
681 }
682 else
683 {
684 // in eeschema, this prints the current page
685 sheetList.push_back( m_schematic->CurrentSheet() );
686 }
687
688 for( unsigned i = 0; i < sheetList.size(); i++ )
689 {
690 m_schematic->SetCurrentSheet( sheetList[i] );
693
694 screen = m_schematic->CurrentSheet().LastScreen();
695
696 if( !screen ) // LastScreen() may return NULL
697 screen = m_schematic->RootScreen();
698
699 const PAGE_INFO& curPage = screen->GetPageSettings();
700
701 PAGE_INFO plotPage = curPage;
702
703 // if plotting on a page size other than curPage
704 plotPage.SetType( plot_sheet_list( aPlotOpts.m_HPGLPaperSizeSelect ) );
705
706 // Calculation of conversion scales.
707 double plot_scale = (double) plotPage.GetWidthMils() / curPage.GetWidthMils();
708
709 // Calculate offsets
710 VECTOR2I plotOffset;
711 wxString msg;
712
713 if( aPlotOpts.m_HPGLPlotOrigin == HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER )
714 {
715 plotOffset.x = plotPage.GetWidthIU( schIUScale.IU_PER_MILS ) / 2;
716 plotOffset.y = -plotPage.GetHeightIU( schIUScale.IU_PER_MILS ) / 2;
717 }
718
719 try
720 {
722 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
723 // main project folder (or the folder specified by the caller),
724 // so replace separators to create a unique filename:
725 fname.Replace( "/", "_" );
726 fname.Replace( "\\", "_" );
728 wxFileName plotFileName = createPlotFileName( aPlotOpts, fname, ext, aReporter );
729
730 if( !plotFileName.IsOk() )
731 return;
732
733 LOCALE_IO toggle;
734
735 if( plotOneSheetHpgl( plotFileName.GetFullPath(), screen, curPage, aRenderSettings,
736 plotOffset, plot_scale, aPlotOpts ) )
737 {
738 if( aReporter )
739 {
740 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
741 aReporter->Report( msg, RPT_SEVERITY_ACTION );
742 }
743 }
744 else
745 {
746 if( aReporter )
747 {
748 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
749 aReporter->Report( msg, RPT_SEVERITY_ERROR );
750 }
751 }
752 }
753 catch( IO_ERROR& e )
754 {
755 if( aReporter )
756 {
757 msg.Printf( wxT( "HPGL Plotter exception: %s" ), e.What() );
758 aReporter->Report( msg, RPT_SEVERITY_ERROR );
759 }
760 }
761 }
762
763 if( aReporter )
764 {
765 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
766 }
767
768 restoreEnvironment( nullptr, oldsheetpath );
769}
770
771
772bool SCH_PLOTTER::plotOneSheetHpgl( const wxString& aFileName, SCH_SCREEN* aScreen,
773 const PAGE_INFO& aPageInfo, RENDER_SETTINGS* aRenderSettings,
774 const VECTOR2I& aPlot0ffset, double aScale,
775 const SCH_PLOT_OPTS& aPlotOpts )
776{
777 HPGL_PLOTTER* plotter = new HPGL_PLOTTER();
778 // Currently, plot units are in decimil
779
780 plotter->SetPageSettings( aPageInfo );
781 plotter->SetRenderSettings( aRenderSettings );
783 plotter->SetViewport( aPlot0ffset, schIUScale.IU_PER_MILS/10, aScale, false );
784
785 // TODO this could be configurable
786 plotter->SetTargetChordLength( schIUScale.mmToIU( 0.6 ) );
787
788 switch( aPlotOpts.m_HPGLPlotOrigin )
789 {
790 case HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT:
791 case HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER:
792 default:
793 plotter->SetUserCoords( false );
794 break;
795 case HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE:
796 plotter->SetUserCoords( true );
797 plotter->SetUserCoordsFit( false );
798 break;
799 case HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT:
800 plotter->SetUserCoords( true );
801 plotter->SetUserCoordsFit( true );
802 break;
803 }
804
805 // Init :
806 plotter->SetCreator( wxT( "Eeschema-HPGL" ) );
807
808 if( !plotter->OpenFile( aFileName ) )
809 {
810 delete plotter;
811 return false;
812 }
813
814 LOCALE_IO toggle;
815
816 // Pen num and pen speed are not initialized here.
817 // Default HPGL driver values are used
818 plotter->SetPenDiameter( aPlotOpts.m_HPGLPenSize );
820
821 if( aPlotOpts.m_plotDrawingSheet )
822 {
823 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
824 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
825
826 PlotDrawingSheet( plotter, &m_schematic->Prj(),
827 aScreen->GetTitleBlock(),
828 aPageInfo,
829 aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(),
830 aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(),
831 COLOR4D::BLACK, aScreen->GetVirtualPageNumber() == 1 );
832 }
833
834 aScreen->Plot( plotter, aPlotOpts );
835
836 plotter->EndPlot();
837
838 delete plotter;
839
840 return true;
841}
842
843
845 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
846{
847 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet();
848
849 /* When printing all pages, the printed page is not the current page. In complex hierarchies,
850 * we must update symbol references and other parameters in the given printed SCH_SCREEN,
851 * according to the sheet path because in complex hierarchies a SCH_SCREEN (a drawing ) is
852 * shared between many sheets and symbol references depend on the actual sheet path used.
853 */
854 SCH_SHEET_LIST sheetList;
855
856 if( aPlotOpts.m_plotAll )
857 {
858 sheetList.BuildSheetList( &m_schematic->Root(), true );
859 sheetList.SortByPageNumbers();
860
861 // remove the non-selected pages if we are in plot pages mode
862 if( aPlotOpts.m_plotPages.size() > 0 )
863 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
864 }
865 else
866 {
867 // in eeschema, this prints the current page
868 sheetList.push_back( m_schematic->CurrentSheet() );
869 }
870
871 for( unsigned i = 0; i < sheetList.size(); i++ )
872 {
873 m_schematic->SetCurrentSheet( sheetList[i] );
876
878 VECTOR2I plot_offset;
879 wxString msg;
880
881 try
882 {
884
885 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
886 // main project folder (or the folder specified by the caller),
887 // so replace separators to create a unique filename:
888 fname.Replace( "/", "_" );
889 fname.Replace( "\\", "_" );
891 wxFileName plotFileName = createPlotFileName( aPlotOpts, fname, ext, aReporter );
892
893 m_lastOutputFilePath = plotFileName.GetFullPath();
894
895 if( !plotFileName.IsOk() )
896 return;
897
898 if( plotOneSheetDXF( plotFileName.GetFullPath(), screen, aRenderSettings, plot_offset,
899 1.0, aPlotOpts ) )
900 {
901 if( aReporter )
902 {
903 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
904 aReporter->Report( msg, RPT_SEVERITY_ACTION );
905 }
906 }
907 else // Error
908 {
909 if( aReporter )
910 {
911 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
912 aReporter->Report( msg, RPT_SEVERITY_ERROR );
913 }
914 }
915 }
916 catch( IO_ERROR& e )
917 {
918 if( aReporter )
919 {
920 msg.Printf( wxT( "DXF Plotter exception: %s" ), e.What() );
921 aReporter->Report( msg, RPT_SEVERITY_ERROR );
922 }
923
924 m_schematic->SetCurrentSheet( oldsheetpath );
927 return;
928 }
929 }
930
931 if( aReporter )
932 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
933
934 restoreEnvironment( nullptr, oldsheetpath );
935}
936
937
938bool SCH_PLOTTER::plotOneSheetDXF( const wxString& aFileName, SCH_SCREEN* aScreen,
939 RENDER_SETTINGS* aRenderSettings, const VECTOR2I& aPlotOffset,
940 double aScale, const SCH_PLOT_OPTS& aPlotOpts )
941{
942 aRenderSettings->LoadColors( m_colorSettings );
943 aRenderSettings->SetDefaultPenWidth( 0 );
944
945 const PAGE_INFO& pageInfo = aScreen->GetPageSettings();
946 DXF_PLOTTER* plotter = new DXF_PLOTTER();
947
948 plotter->SetRenderSettings( aRenderSettings );
949 plotter->SetPageSettings( pageInfo );
950 plotter->SetColorMode( !aPlotOpts.m_blackAndWhite );
951
952 // Currently, plot units are in decimil
953 plotter->SetViewport( aPlotOffset, schIUScale.IU_PER_MILS / 10, aScale, false );
954
955 // Init :
956 plotter->SetCreator( wxT( "Eeschema-DXF" ) );
957
958 if( !plotter->OpenFile( aFileName ) )
959 {
960 delete plotter;
961 return false;
962 }
963
964 LOCALE_IO toggle;
965
967
968 if( aPlotOpts.m_plotDrawingSheet )
969 {
970 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
971 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
973
974 PlotDrawingSheet( plotter, &m_schematic->Prj(),
975 aScreen->GetTitleBlock(),
976 pageInfo,
977 aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(),
978 aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(),
979 plotter->GetColorMode() ? color : COLOR4D::BLACK,
980 aScreen->GetVirtualPageNumber() == 1 );
981 }
982
983 aScreen->Plot( plotter, aPlotOpts );
984
985 // finish
986 plotter->EndPlot();
987 delete plotter;
988
989 return true;
990}
991
992
994{
995 if( aPlotter )
996 {
997 aPlotter->EndPlot();
998 delete aPlotter;
999 }
1000
1001 // Restore the initial sheet
1002 m_schematic->SetCurrentSheet( aOldsheetpath );
1005}
1006
1007
1009 const wxString& aPlotFileName,
1010 const wxString& aExtension, REPORTER* aReporter )
1011{
1012 wxFileName retv;
1013 wxFileName tmp;
1014
1015 tmp.SetPath( aPlotOpts.m_outputDirectory );
1016 retv.SetPath( tmp.GetPath() );
1017
1018 if( !aPlotFileName.IsEmpty() )
1019 retv.SetName( aPlotFileName );
1020 else
1021 retv.SetName( _( "Schematic" ) );
1022
1023 retv.SetExt( aExtension );
1024
1025 if( !EnsureFileDirectoryExists( &tmp, retv.GetFullName(), aReporter ) || !tmp.IsDirWritable() )
1026 {
1027 if( aReporter )
1028 {
1029 wxString msg = wxString::Format( _( "Failed to write plot files to folder '%s'." ),
1030 tmp.GetPath() );
1031 aReporter->Report( msg, RPT_SEVERITY_ERROR );
1032 }
1033 retv.Clear();
1034
1036 settings.m_PlotDirectoryName.Clear();
1037 }
1038 else
1039 {
1040 retv.SetPath( tmp.GetPath() );
1041 }
1042
1043 wxLogTrace( tracePathsAndFiles, "Writing plot file '%s'.", retv.GetFullPath() );
1044
1045 return retv;
1046}
1047
1048
1049void SCH_PLOTTER::Plot( PLOT_FORMAT aPlotFormat, const SCH_PLOT_OPTS& aPlotOpts,
1050 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
1051{
1052 SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
1053
1054 m_colorSettings = settingsMgr.GetColorSettings( aPlotOpts.m_theme );
1055
1056 switch( aPlotFormat )
1057 {
1058 default:
1059 case PLOT_FORMAT::POST: createPSFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1060 case PLOT_FORMAT::DXF: createDXFFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1061 case PLOT_FORMAT::PDF: createPDFFile( aPlotOpts, aRenderSettings, aReporter ); break;
1062 case PLOT_FORMAT::SVG: createSVGFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1063 case PLOT_FORMAT::HPGL: createHPGLFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1064 }
1065}
int color
Definition: DXF_plotter.cpp:58
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:110
int GetPageCount() const
Definition: base_screen.h:72
int GetVirtualPageNumber() const
Definition: base_screen.h:75
const wxString & GetPageNumber() const
Definition: base_screen.cpp:70
static wxString GetDefaultFileExtension()
Definition: plotter_dxf.h:41
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
void SetUserCoordsFit(bool user_coords_fit)
Set whether the user coordinate system is fit to content.
Definition: plotter_hpgl.h:59
void SetTargetChordLength(double chord_len)
Set the target length of chords used to draw approximated circles and arcs.
static wxString GetDefaultFileExtension()
Definition: plotter_hpgl.h:43
void SetUserCoords(bool user_coords)
Switch to the user coordinate system.
Definition: plotter_hpgl.h:56
virtual bool StartPlot(const wxString &aPageNumber) override
At the start of the HPGL plot pen speed and number are requested.
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 SetPenDiameter(double diameter)
virtual bool EndPlot() override
HPGL end of plot: sort and emit graphics, pen return and release.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:77
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
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.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:49
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:59
void SetPortrait(bool aIsPortrait)
Rotate the paper page 90 degrees.
Definition: page_info.cpp:189
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
Definition: page_info.h:162
double GetHeightMils() const
Definition: page_info.h:141
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
Definition: page_info.h:153
double GetWidthMils() const
Definition: page_info.h:136
bool IsPortrait() const
Definition: page_info.h:122
bool SetType(const wxString &aStandardPageDescriptionName, bool aIsPortrait=false)
Set the name of the page type and also the sizes and margins commonly associated with that type name.
Definition: page_info.cpp:122
virtual void StartPage(const wxString &aPageNumber, const wxString &aPageName=wxEmptyString)
Start a new page in the PDF document.
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 SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
Base plotter engine class.
Definition: plotter.h:105
virtual bool OpenFile(const wxString &aFullFilename)
Open or create the plot file aFullFilename.
Definition: plotter.cpp:75
virtual void SetAuthor(const wxString &aAuthor)
Definition: plotter.h:156
virtual void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: plotter.h:138
void SetRenderSettings(RENDER_SETTINGS *aSettings)
Definition: plotter.h:135
virtual void SetTitle(const wxString &aTitle)
Definition: plotter.h:155
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:136
virtual void SetCreator(const wxString &aCreator)
Definition: plotter.h:154
bool GetColorMode() const
Definition: plotter.h:133
PAGE_INFO & PageSettings()
Definition: plotter.h:139
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:132
virtual void SetSubject(const wxString &aSubject)
Definition: plotter.h:157
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
virtual void SetColor(const COLOR4D &color)=0
virtual void SetColor(const COLOR4D &color) override
The SetColor implementation is split with the subclasses: the PSLIKE computes the rgb values,...
Definition: PS_plotter.cpp:63
virtual bool EndPlot() override
Definition: PS_plotter.cpp:890
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
Definition: PS_plotter.cpp:335
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
Definition: PS_plotter.cpp:503
virtual bool StartPlot(const wxString &aPageNumber) override
The code within this function (and the CloseFilePS function) creates postscript files whose contents ...
Definition: PS_plotter.cpp:729
static wxString GetDefaultFileExtension()
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:72
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:100
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
These are loaded from Eeschema settings but then overwritten by the project settings.
Holds all the data relating to one schematic.
Definition: schematic.h:77
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:152
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:314
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
Definition: schematic.h:157
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:208
bool ResolveTextVar(const SCH_SHEET_PATH *aSheetPath, wxString *token, int aDepth) const
Definition: schematic.cpp:255
const std::map< wxString, wxString > * GetProperties()
Definition: schematic.h:95
SCH_SHEET & Root() const
Definition: schematic.h:121
wxString GetUniqueFilenameForCurrentSheet()
Definition: schematic.cpp:630
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
Definition: schematic.cpp:646
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:92
Schematic editor (Eeschema) main window.
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 aPlotSettings.
wxFileName getOutputFilenameSingle(const SCH_PLOT_OPTS &aPlotOpts, REPORTER *aReporter, const wxString &ext)
Returns the output filename for formats where the output is a single file.
Definition: sch_plotter.cpp:87
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.
Definition: sch_plotter.cpp:80
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)
void createHPGLFiles(const SCH_PLOT_OPTS &aPlotOpts, SCH_RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
wxString m_lastOutputFilePath
Definition: sch_plotter.h:221
void restoreEnvironment(PDF_PLOTTER *aPlotter, SCH_SHEET_PATH &aOldsheetpath)
Everything done, close the plot and restore the environment.
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 plotOneSheetHpgl(const wxString &aFileName, SCH_SCREEN *aScreen, const PAGE_INFO &aPageInfo, RENDER_SETTINGS *aRenderSettings, const VECTOR2I &aPlot0ffset, double aScale, const SCH_PLOT_OPTS &aPlotOpts)
void createPDFFile(const SCH_PLOT_OPTS &aPlotOpts, SCH_RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
COLOR_SETTINGS * m_colorSettings
Definition: sch_plotter.h:220
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
Definition: sch_plotter.h:219
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:130
const wxString & GetFileName() const
Definition: sch_screen.h:143
SCHEMATIC * Schematic() const
Definition: sch_screen.cpp:100
const TITLE_BLOCK & GetTitleBlock() const
Definition: sch_screen.h:154
void Plot(PLOTTER *aPlotter, const SCH_PLOT_OPTS &aPlotOpts) const
Plot all the schematic objects to aPlotter.
Definition: sch_screen.cpp:898
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 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 PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false) const
Return the sheet path in a human readable form made from the sheet names.
void UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
SCH_SCREEN * LastScreen()
wxString GetPageNumber() const
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
wxString GetName() const
Definition: sch_sheet.h:107
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
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=USE_DEFAULT_LINE_WIDTH) override
virtual bool EndPlot() override
static wxString GetDefaultFileExtension()
const wxString & GetTitle() const
Definition: title_block.h:63
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:369
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
Definition: common.cpp:59
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)
#define _(s)
const wxChar *const tracePathsAndFiles
Flag to enable path and file name debug output.
@ LAYER_SCHEMATIC_DRAWINGSHEET
Definition: layer_ids.h:399
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:392
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
see class PGM_BASE
PLOT_FORMAT
The set of supported output plot formats.
Definition: plotter.h:65
Plotting engine (HPGL)
Plotting engines similar to ps (PostScript, Gerber, svg)
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_INFO
@ RPT_SEVERITY_ACTION
static const wxChar * plot_sheet_list(HPGL_PAGE_SIZE aSize)
Definition: sch_plotter.cpp:52
@ PAGE_SIZE_AUTO
Definition: sch_plotter.h:57
@ PAGE_SIZE_A
Definition: sch_plotter.h:59
@ PAGE_SIZE_A4
Definition: sch_plotter.h:58
HPGL_PAGE_SIZE
Definition: sch_plotter.h:64
@ SHEETNAME
Definition: sch_sheet.h:45
const int scale
const double IU_PER_MILS
Definition: base_units.h:77
constexpr int mmToIU(double mm) const
Definition: base_units.h:88
std::vector< wxString > m_plotPages
Definition: sch_plotter.h:84
wxString m_theme
Definition: sch_plotter.h:94
wxString m_outputDirectory
Definition: sch_plotter.h:96
HPGL_PLOT_ORIGIN_AND_UNITS m_HPGLPlotOrigin
Definition: sch_plotter.h:99
wxString m_outputFile
Definition: sch_plotter.h:97
int m_pageSizeSelect
Definition: sch_plotter.h:87
bool m_PDFMetadata
Definition: sch_plotter.h:93
bool m_blackAndWhite
Definition: sch_plotter.h:86
HPGL_PAGE_SIZE m_HPGLPaperSizeSelect
Definition: sch_plotter.h:90
double m_HPGLPenSize
Definition: sch_plotter.h:89
bool m_useBackgroundColor
Definition: sch_plotter.h:88
bool m_plotDrawingSheet
Definition: sch_plotter.h:83
wxLogTrace helper definitions.
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:691