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 if( sheetList.empty() )
138 {
139 if( aReporter )
140 aReporter->Report( _( "No sheets to plot." ), RPT_SEVERITY_ERROR );
141
142 return;
143 }
144
145 wxCHECK( m_schematic, /* void */ );
146
147 // Allocate the plotter and set the job level parameter
148 PDF_PLOTTER* plotter = new PDF_PLOTTER( &m_schematic->Prj() );
149 plotter->SetRenderSettings( aRenderSettings );
150 plotter->SetColorMode( !aPlotOpts.m_blackAndWhite );
151 plotter->SetCreator( wxT( "Eeschema-PDF" ) );
153 &m_schematic->Prj() ) );
154
155 wxString msg;
156 wxFileName plotFileName;
157 LOCALE_IO toggle; // Switch the locale to standard C
158
159 for( unsigned i = 0; i < sheetList.size(); i++ )
160 {
161 m_schematic->SetCurrentSheet( sheetList[i] );
164
166 wxString sheetName = sheetList[i].Last()->GetFields()[SHEETNAME].GetShownText( false );
167
168 if( aPlotOpts.m_PDFMetadata )
169 {
170 msg = wxS( "AUTHOR" );
171
172 if( m_schematic->ResolveTextVar( &sheetList[i], &msg, 0 ) )
173 plotter->SetAuthor( msg );
174
175 msg = wxS( "SUBJECT" );
176
177 if( m_schematic->ResolveTextVar( &sheetList[i], &msg, 0 ) )
178 plotter->SetSubject( msg );
179 }
180
181 if( i == 0 )
182 {
183 try
184 {
186 plotFileName = getOutputFilenameSingle( aPlotOpts, aReporter, ext );
187
188 m_lastOutputFilePath = plotFileName.GetFullPath();
189
190 if( !plotFileName.IsOk() )
191 return;
192
193 if( !plotter->OpenFile( plotFileName.GetFullPath() ) )
194 {
195 if( aReporter )
196 {
197 msg.Printf( _( "Failed to create file '%s'." ),
198 plotFileName.GetFullPath() );
199 aReporter->Report( msg, RPT_SEVERITY_ERROR );
200 }
201 delete plotter;
202 return;
203 }
204
205 // Open the plotter and do the first page
206 setupPlotPagePDF( plotter, screen, aPlotOpts );
207
208 plotter->StartPlot( sheetList[i].GetPageNumber(), sheetName );
209 }
210 catch( const IO_ERROR& e )
211 {
212 // Cannot plot PDF file
213 if( aReporter )
214 {
215 msg.Printf( wxT( "PDF Plotter exception: %s" ), e.What() );
216 aReporter->Report( msg, RPT_SEVERITY_ERROR );
217 }
218
219 restoreEnvironment( plotter, oldsheetpath );
220 return;
221 }
222 }
223 else
224 {
225 /* For the following pages you need to close the (finished) page,
226 * reconfigure, and then start a new one */
227 plotter->ClosePage();
228 setupPlotPagePDF( plotter, screen, aPlotOpts );
229 plotter->StartPage( sheetList[i].GetPageNumber(), sheetName );
230 }
231
232 plotOneSheetPDF( plotter, screen, aPlotOpts );
233 }
234
235 // Everything done, close the plot and restore the environment
236 if( aReporter )
237 {
238 msg.Printf( _( "Plotted to '%s'.\n" ), plotFileName.GetFullPath() );
239 aReporter->Report( msg, RPT_SEVERITY_ACTION );
240 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
241 }
242
243 restoreEnvironment( plotter, oldsheetpath );
244}
245
246
248 const SCH_PLOT_OPTS& aPlotOpts )
249{
250 if( aPlotOpts.m_useBackgroundColor && aPlotter->GetColorMode() )
251 {
252 aPlotter->SetColor( aPlotter->RenderSettings()->GetBackgroundColor() );
255 aPlotter->Rect( VECTOR2I( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 );
256 }
257
258 if( aPlotOpts.m_plotDrawingSheet )
259 {
260 COLOR4D color = COLOR4D::BLACK;
261
262 if( aPlotter->GetColorMode() )
264
265 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
266 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
267 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
268
269 PlotDrawingSheet( aPlotter, &aScreen->Schematic()->Prj(),
270 aScreen->GetTitleBlock(),
271 actualPage,
272 aScreen->Schematic()->GetProperties(),
273 aScreen->GetPageNumber(), aScreen->GetPageCount(), sheetName, sheetPath,
274 aScreen->GetFileName(), color, aScreen->GetVirtualPageNumber() == 1 );
275 }
276
277 aScreen->Plot( aPlotter, aPlotOpts );
278}
279
280
282 const SCH_PLOT_OPTS& aPlotOpts )
283{
284 PAGE_INFO plotPage; // page size selected to plot
285
286 // Considerations on page size and scaling requests
287 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
288
289 switch( aPlotOpts.m_pageSizeSelect )
290 {
291 case PAGE_SIZE_A:
292 plotPage.SetType( wxT( "A" ) );
293 plotPage.SetPortrait( actualPage.IsPortrait() );
294 break;
295
296 case PAGE_SIZE_A4:
297 plotPage.SetType( wxT( "A4" ) );
298 plotPage.SetPortrait( actualPage.IsPortrait() );
299 break;
300
301 case PAGE_SIZE_AUTO:
302 default:
303 plotPage = actualPage;
304 break;
305 }
306
307 double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
308 double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
309 double scale = std::min( scalex, scaley );
310 aPlotter->SetPageSettings( plotPage );
311
312 // Currently, plot units are in decimil
313 aPlotter->SetViewport( VECTOR2I( 0, 0 ), schIUScale.IU_PER_MILS / 10, scale, false );
314}
315
316
318 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
319{
320 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet(); // sheetpath is saved here
321 PAGE_INFO plotPage; // page size selected to plot
322 wxString msg;
323
324 /* When printing all pages, the printed page is not the current page.
325 * In complex hierarchies, we must update symbol references and other parameters in the
326 * given printed SCH_SCREEN, accordant to the sheet path because in complex hierarchies
327 * a SCH_SCREEN (a drawing ) is shared between many sheets and symbol references
328 * depend on the actual sheet path used.
329 */
330 SCH_SHEET_LIST sheetList;
331
332 if( aPlotOpts.m_plotAll )
333 {
334 sheetList.BuildSheetList( &m_schematic->Root(), true );
335 sheetList.SortByPageNumbers();
336
337 // remove the non-selected pages if we are in plot pages mode
338 if( aPlotOpts.m_plotPages.size() > 0 )
339 {
340 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
341 }
342 }
343 else
344 {
345 sheetList.push_back( m_schematic->CurrentSheet() );
346 }
347
348 for( unsigned i = 0; i < sheetList.size(); i++ )
349 {
350 m_schematic->SetCurrentSheet( sheetList[i] );
353
355 PAGE_INFO actualPage = screen->GetPageSettings();
356
357 switch( aPlotOpts.m_pageSizeSelect )
358 {
359 case PAGE_SIZE_A:
360 plotPage.SetType( wxT( "A" ) );
361 plotPage.SetPortrait( actualPage.IsPortrait() );
362 break;
363
364 case PAGE_SIZE_A4:
365 plotPage.SetType( wxT( "A4" ) );
366 plotPage.SetPortrait( actualPage.IsPortrait() );
367 break;
368
369 case PAGE_SIZE_AUTO:
370 default: plotPage = actualPage; break;
371 }
372
373 double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
374 double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
375 double scale = std::min( scalex, scaley );
376 VECTOR2I plot_offset;
377
378 try
379 {
381
382 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
383 // main project folder (or the folder specified by the caller),
384 // so replace separators to create a unique filename:
385 fname.Replace( "/", "_" );
386 fname.Replace( "\\", "_" );
388 wxFileName plotFileName = createPlotFileName( aPlotOpts, fname, ext, aReporter );
389
390 m_lastOutputFilePath = plotFileName.GetFullPath();
391
392 if( !plotFileName.IsOk() )
393 return;
394
395 if( plotOneSheetPS( plotFileName.GetFullPath(), screen, aRenderSettings, actualPage,
396 plot_offset, scale, aPlotOpts ) )
397 {
398 if( aReporter )
399 {
400 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
401 aReporter->Report( msg, RPT_SEVERITY_ACTION );
402 }
403 }
404 else
405 {
406 if( aReporter )
407 {
408 // Error
409 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
410 aReporter->Report( msg, RPT_SEVERITY_ERROR );
411 }
412 }
413 }
414 catch( IO_ERROR& e )
415 {
416 if( aReporter )
417 {
418 msg.Printf( wxT( "PS Plotter exception: %s" ), e.What() );
419 aReporter->Report( msg, RPT_SEVERITY_ERROR );
420 }
421 }
422 }
423
424 if( aReporter )
425 {
426 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
427 }
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 LOCALE_IO toggle; // Switch the locale to standard C
456
458
459 if( aPlotOpts.m_useBackgroundColor && plotter->GetColorMode() )
460 {
462
465 plotter->Rect( VECTOR2I( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 );
466 }
467
468 if( aPlotOpts.m_plotDrawingSheet )
469 {
470 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
471 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
473
474 PlotDrawingSheet( plotter, &aScreen->Schematic()->Prj(),
475 aScreen->GetTitleBlock(),
476 aPageInfo, aScreen->Schematic()->GetProperties(),
477 aScreen->GetPageNumber(), aScreen->GetPageCount(), sheetName, sheetPath,
478 aScreen->GetFileName(), plotter->GetColorMode() ? color : COLOR4D::BLACK,
479 aScreen->GetVirtualPageNumber() == 1 );
480 }
481
482 aScreen->Plot( plotter, aPlotOpts );
483
484 plotter->EndPlot();
485 delete plotter;
486
487 return true;
488}
489
490
492 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
493{
494 wxString msg;
495 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet();
496 SCH_SHEET_LIST sheetList;
497
498 if( aPlotOpts.m_plotAll )
499 {
500 sheetList.BuildSheetList( &m_schematic->Root(), true );
501 sheetList.SortByPageNumbers();
502
503 // remove the non-selected pages if we are in plot pages mode
504 if( aPlotOpts.m_plotPages.size() > 0 )
505 {
506 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
507 }
508 }
509 else
510 {
511 // in eeschema, this prints the current page
512 sheetList.push_back( m_schematic->CurrentSheet() );
513 }
514
515 for( unsigned i = 0; i < sheetList.size(); i++ )
516 {
517 SCH_SCREEN* screen;
518
519 m_schematic->SetCurrentSheet( sheetList[i] );
522
523 screen = m_schematic->CurrentSheet().LastScreen();
524
525 try
526 {
528
529 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
530 // main project folder (or the folder specified by the caller),
531 // so replace separators to create a unique filename:
532 fname.Replace( "/", "_" );
533 fname.Replace( "\\", "_" );
535 wxFileName plotFileName = createPlotFileName( aPlotOpts, fname, ext, aReporter );
536
537 m_lastOutputFilePath = plotFileName.GetFullPath();
538
539 if( !plotFileName.IsOk() )
540 return;
541
542 bool success = plotOneSheetSVG( plotFileName.GetFullPath(), screen, aRenderSettings,
543 aPlotOpts );
544
545 if( !success )
546 {
547 if( aReporter )
548 {
549 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
550 aReporter->Report( msg, RPT_SEVERITY_ERROR );
551 }
552 }
553 else
554 {
555 if( aReporter )
556 {
557 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
558 aReporter->Report( msg, RPT_SEVERITY_ACTION );
559 }
560 }
561 }
562 catch( const IO_ERROR& e )
563 {
564 if( aReporter )
565 {
566 // Cannot plot SVG file
567 msg.Printf( wxT( "SVG Plotter exception: %s" ), e.What() );
568 aReporter->Report( msg, RPT_SEVERITY_ERROR );
569 }
570 break;
571 }
572 }
573
574 if( aReporter )
575 {
576 aReporter->ReportTail( _( "Done" ), RPT_SEVERITY_INFO );
577 }
578
579 restoreEnvironment( nullptr, oldsheetpath );
580}
581
582
583bool SCH_PLOTTER::plotOneSheetSVG( const wxString& aFileName, SCH_SCREEN* aScreen,
584 RENDER_SETTINGS* aRenderSettings,
585 const SCH_PLOT_OPTS& aPlotOpts )
586{
587 PAGE_INFO plotPage;
588 // Adjust page size and scaling requests
589 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
590
591 switch( aPlotOpts.m_pageSizeSelect )
592 {
593 case PAGE_SIZE_A:
594 plotPage.SetType( wxT( "A" ) );
595 plotPage.SetPortrait( actualPage.IsPortrait() );
596 break;
597
598 case PAGE_SIZE_A4:
599 plotPage.SetType( wxT( "A4" ) );
600 plotPage.SetPortrait( actualPage.IsPortrait() );
601 break;
602
603 case PAGE_SIZE_AUTO:
604 default:
605 plotPage = actualPage;
606 break;
607 }
608
609 SVG_PLOTTER* plotter = new SVG_PLOTTER();
610 plotter->SetRenderSettings( aRenderSettings );
611 plotter->SetPageSettings( plotPage );
612 plotter->SetColorMode( aPlotOpts.m_blackAndWhite ? false : true );
613 VECTOR2I plot_offset;
614
615 double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
616 double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
617 double scale = std::min( scalex, scaley );
618
619 // Currently, plot units are in decimil
620 plotter->SetViewport( plot_offset, schIUScale.IU_PER_MILS / 10, scale, false );
621
622 // Init :
623 plotter->SetCreator( wxT( "Eeschema-SVG" ) );
624
625 if( !plotter->OpenFile( aFileName ) )
626 {
627 delete plotter;
628 return false;
629 }
630
631 LOCALE_IO toggle;
632
634
635 if( aPlotOpts.m_useBackgroundColor && plotter->GetColorMode() )
636 {
640 plotter->Rect( VECTOR2I( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 );
641 }
642
643 if( aPlotOpts.m_plotDrawingSheet )
644 {
645 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
646 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
648
649 PlotDrawingSheet( plotter, &aScreen->Schematic()->Prj(),
650 aScreen->GetTitleBlock(),
651 actualPage, aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(),
652 aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(),
653 plotter->GetColorMode() ? color : COLOR4D::BLACK,
654 aScreen->GetVirtualPageNumber() == 1 );
655 }
656
657 aScreen->Plot( plotter, aPlotOpts );
658
659 plotter->EndPlot();
660 delete plotter;
661
662 return true;
663}
664
665
667 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
668{
669 SCH_SCREEN* screen = m_schematic->RootScreen();
670 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet();
671
672 /* When printing all pages, the printed page is not the current page. In complex hierarchies,
673 * we must update symbol references and other parameters in the given printed SCH_SCREEN,
674 * according to the sheet path because in complex hierarchies a SCH_SCREEN (a drawing ) is
675 * shared between many sheets and symbol references depend on the actual sheet path used.
676 */
677 SCH_SHEET_LIST sheetList;
678
679 if( aPlotOpts.m_plotAll )
680 {
681 sheetList.BuildSheetList( &m_schematic->Root(), true );
682 sheetList.SortByPageNumbers();
683
684 // remove the non-selected pages if we are in plot pages mode
685 if( aPlotOpts.m_plotPages.size() > 0 )
686 {
687 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
688 }
689 }
690 else
691 {
692 // in eeschema, this prints the current page
693 sheetList.push_back( m_schematic->CurrentSheet() );
694 }
695
696 for( unsigned i = 0; i < sheetList.size(); i++ )
697 {
698 m_schematic->SetCurrentSheet( sheetList[i] );
701
702 screen = m_schematic->CurrentSheet().LastScreen();
703
704 if( !screen ) // LastScreen() may return NULL
705 screen = m_schematic->RootScreen();
706
707 const PAGE_INFO& curPage = screen->GetPageSettings();
708
709 PAGE_INFO plotPage = curPage;
710
711 // if plotting on a page size other than curPage
712 plotPage.SetType( plot_sheet_list( aPlotOpts.m_HPGLPaperSizeSelect ) );
713
714 // Calculation of conversion scales.
715 double plot_scale = (double) plotPage.GetWidthMils() / curPage.GetWidthMils();
716
717 // Calculate offsets
718 VECTOR2I plotOffset;
719 wxString msg;
720
721 if( aPlotOpts.m_HPGLPlotOrigin == HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER )
722 {
723 plotOffset.x = plotPage.GetWidthIU( schIUScale.IU_PER_MILS ) / 2;
724 plotOffset.y = -plotPage.GetHeightIU( schIUScale.IU_PER_MILS ) / 2;
725 }
726
727 try
728 {
730 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
731 // main project folder (or the folder specified by the caller),
732 // so replace separators to create a unique filename:
733 fname.Replace( "/", "_" );
734 fname.Replace( "\\", "_" );
736 wxFileName plotFileName = createPlotFileName( aPlotOpts, fname, ext, aReporter );
737
738 if( !plotFileName.IsOk() )
739 return;
740
741 LOCALE_IO toggle;
742
743 if( plotOneSheetHpgl( plotFileName.GetFullPath(), screen, curPage, aRenderSettings,
744 plotOffset, plot_scale, aPlotOpts ) )
745 {
746 if( aReporter )
747 {
748 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
749 aReporter->Report( msg, RPT_SEVERITY_ACTION );
750 }
751 }
752 else
753 {
754 if( aReporter )
755 {
756 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
757 aReporter->Report( msg, RPT_SEVERITY_ERROR );
758 }
759 }
760 }
761 catch( IO_ERROR& e )
762 {
763 if( aReporter )
764 {
765 msg.Printf( wxT( "HPGL Plotter exception: %s" ), e.What() );
766 aReporter->Report( msg, RPT_SEVERITY_ERROR );
767 }
768 }
769 }
770
771 if( aReporter )
772 {
773 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
774 }
775
776 restoreEnvironment( nullptr, oldsheetpath );
777}
778
779
780bool SCH_PLOTTER::plotOneSheetHpgl( const wxString& aFileName, SCH_SCREEN* aScreen,
781 const PAGE_INFO& aPageInfo, RENDER_SETTINGS* aRenderSettings,
782 const VECTOR2I& aPlot0ffset, double aScale,
783 const SCH_PLOT_OPTS& aPlotOpts )
784{
785 HPGL_PLOTTER* plotter = new HPGL_PLOTTER();
786 // Currently, plot units are in decimil
787
788 plotter->SetPageSettings( aPageInfo );
789 plotter->SetRenderSettings( aRenderSettings );
791 plotter->SetViewport( aPlot0ffset, schIUScale.IU_PER_MILS/10, aScale, false );
792
793 // TODO this could be configurable
794 plotter->SetTargetChordLength( schIUScale.mmToIU( 0.6 ) );
795
796 switch( aPlotOpts.m_HPGLPlotOrigin )
797 {
798 case HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT:
799 case HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER:
800 default:
801 plotter->SetUserCoords( false );
802 break;
803 case HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE:
804 plotter->SetUserCoords( true );
805 plotter->SetUserCoordsFit( false );
806 break;
807 case HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT:
808 plotter->SetUserCoords( true );
809 plotter->SetUserCoordsFit( true );
810 break;
811 }
812
813 // Init :
814 plotter->SetCreator( wxT( "Eeschema-HPGL" ) );
815
816 if( !plotter->OpenFile( aFileName ) )
817 {
818 delete plotter;
819 return false;
820 }
821
822 LOCALE_IO toggle;
823
824 // Pen num and pen speed are not initialized here.
825 // Default HPGL driver values are used
826 plotter->SetPenDiameter( aPlotOpts.m_HPGLPenSize );
828
829 if( aPlotOpts.m_plotDrawingSheet )
830 {
831 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
832 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
833
834 PlotDrawingSheet( plotter, &m_schematic->Prj(),
835 aScreen->GetTitleBlock(),
836 aPageInfo,
837 aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(),
838 aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(),
839 COLOR4D::BLACK, aScreen->GetVirtualPageNumber() == 1 );
840 }
841
842 aScreen->Plot( plotter, aPlotOpts );
843
844 plotter->EndPlot();
845
846 delete plotter;
847
848 return true;
849}
850
851
853 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
854{
855 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet();
856
857 /* When printing all pages, the printed page is not the current page. In complex hierarchies,
858 * we must update symbol references and other parameters in the given printed SCH_SCREEN,
859 * according to the sheet path because in complex hierarchies a SCH_SCREEN (a drawing ) is
860 * shared between many sheets and symbol references depend on the actual sheet path used.
861 */
862 SCH_SHEET_LIST sheetList;
863
864 if( aPlotOpts.m_plotAll )
865 {
866 sheetList.BuildSheetList( &m_schematic->Root(), true );
867 sheetList.SortByPageNumbers();
868
869 // remove the non-selected pages if we are in plot pages mode
870 if( aPlotOpts.m_plotPages.size() > 0 )
871 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
872 }
873 else
874 {
875 // in eeschema, this prints the current page
876 sheetList.push_back( m_schematic->CurrentSheet() );
877 }
878
879 for( unsigned i = 0; i < sheetList.size(); i++ )
880 {
881 m_schematic->SetCurrentSheet( sheetList[i] );
884
886 VECTOR2I plot_offset;
887 wxString msg;
888
889 try
890 {
892
893 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
894 // main project folder (or the folder specified by the caller),
895 // so replace separators to create a unique filename:
896 fname.Replace( "/", "_" );
897 fname.Replace( "\\", "_" );
899 wxFileName plotFileName = createPlotFileName( aPlotOpts, fname, ext, aReporter );
900
901 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 );
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->SetRenderSettings( aRenderSettings );
957 plotter->SetPageSettings( pageInfo );
958 plotter->SetColorMode( !aPlotOpts.m_blackAndWhite );
959
960 // Currently, plot units are in decimil
961 plotter->SetViewport( aPlotOffset, schIUScale.IU_PER_MILS / 10, aScale, false );
962
963 // Init :
964 plotter->SetCreator( wxT( "Eeschema-DXF" ) );
965
966 if( !plotter->OpenFile( aFileName ) )
967 {
968 delete plotter;
969 return false;
970 }
971
972 LOCALE_IO toggle;
973
975
976 if( aPlotOpts.m_plotDrawingSheet )
977 {
978 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
979 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
981
982 PlotDrawingSheet( plotter, &m_schematic->Prj(),
983 aScreen->GetTitleBlock(),
984 pageInfo,
985 aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(),
986 aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(),
987 plotter->GetColorMode() ? color : COLOR4D::BLACK,
988 aScreen->GetVirtualPageNumber() == 1 );
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 );
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 retv.Clear();
1042
1044 settings.m_PlotDirectoryName.Clear();
1045 }
1046 else
1047 {
1048 retv.SetPath( tmp.GetPath() );
1049 }
1050
1051 wxLogTrace( tracePathsAndFiles, "Writing plot file '%s'.", retv.GetFullPath() );
1052
1053 return retv;
1054}
1055
1056
1057void SCH_PLOTTER::Plot( PLOT_FORMAT aPlotFormat, const SCH_PLOT_OPTS& aPlotOpts,
1058 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
1059{
1060 SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
1061
1062 m_colorSettings = settingsMgr.GetColorSettings( aPlotOpts.m_theme );
1063
1064 switch( aPlotFormat )
1065 {
1066 default:
1067 case PLOT_FORMAT::POST: createPSFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1068 case PLOT_FORMAT::DXF: createDXFFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1069 case PLOT_FORMAT::PDF: createPDFFile( aPlotOpts, aRenderSettings, aReporter ); break;
1070 case PLOT_FORMAT::SVG: createSVGFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1071 case PLOT_FORMAT::HPGL: createHPGLFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1072 }
1073}
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:187
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:120
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:156
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:312
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
Definition: schematic.h:161
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:253
const std::map< wxString, wxString > * GetProperties()
Definition: schematic.h:95
SCH_SHEET & Root() const
Definition: schematic.h:125
wxString GetUniqueFilenameForCurrentSheet()
Definition: schematic.cpp:628
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
Definition: schematic.cpp:644
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
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:369
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:398
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:391
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