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 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 // Allocate the plotter and set the job level parameter
138 PDF_PLOTTER* plotter = new PDF_PLOTTER();
139 plotter->SetRenderSettings( aRenderSettings );
140 plotter->SetColorMode( !aPlotOpts.m_blackAndWhite );
141 plotter->SetCreator( wxT( "Eeschema-PDF" ) );
143 &m_schematic->Prj() ) );
144
145 wxString msg;
146 wxFileName plotFileName;
147 LOCALE_IO toggle; // Switch the locale to standard C
148
149 for( unsigned i = 0; i < sheetList.size(); i++ )
150 {
151 m_schematic->SetCurrentSheet( sheetList[i] );
154
156 wxString sheetName = sheetList[i].Last()->GetFields()[SHEETNAME].GetShownText( false );
157
158 if( aPlotOpts.m_PDFMetadata )
159 {
160 msg = wxS( "AUTHOR" );
161
162 if( m_schematic->ResolveTextVar( &sheetList[i], &msg, 0 ) )
163 plotter->SetAuthor( msg );
164
165 msg = wxS( "SUBJECT" );
166
167 if( m_schematic->ResolveTextVar( &sheetList[i], &msg, 0 ) )
168 plotter->SetSubject( msg );
169 }
170
171 if( i == 0 )
172 {
173 try
174 {
176 plotFileName = getOutputFilenameSingle( aPlotOpts, aReporter, ext );
177
178 m_lastOutputFilePath = plotFileName.GetFullPath();
179
180 if( !plotFileName.IsOk() )
181 return;
182
183 if( !plotter->OpenFile( plotFileName.GetFullPath() ) )
184 {
185 if( aReporter )
186 {
187 msg.Printf( _( "Failed to create file '%s'." ),
188 plotFileName.GetFullPath() );
189 aReporter->Report( msg, RPT_SEVERITY_ERROR );
190 }
191 delete plotter;
192 return;
193 }
194
195 // Open the plotter and do the first page
196 setupPlotPagePDF( plotter, screen, aPlotOpts );
197
198 plotter->StartPlot( sheetList[i].GetPageNumber(), sheetName );
199 }
200 catch( const IO_ERROR& e )
201 {
202 // Cannot plot PDF file
203 if( aReporter )
204 {
205 msg.Printf( wxT( "PDF Plotter exception: %s" ), e.What() );
206 aReporter->Report( msg, RPT_SEVERITY_ERROR );
207 }
208
209 restoreEnvironment( plotter, oldsheetpath );
210 return;
211 }
212 }
213 else
214 {
215 /* For the following pages you need to close the (finished) page,
216 * reconfigure, and then start a new one */
217 plotter->ClosePage();
218 setupPlotPagePDF( plotter, screen, aPlotOpts );
219 plotter->StartPage( sheetList[i].GetPageNumber(), sheetName );
220 }
221
222 plotOneSheetPDF( plotter, screen, aPlotOpts );
223 }
224
225 // Everything done, close the plot and restore the environment
226 if( aReporter )
227 {
228 msg.Printf( _( "Plotted to '%s'.\n" ), plotFileName.GetFullPath() );
229 aReporter->Report( msg, RPT_SEVERITY_ACTION );
230 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
231 }
232
233 restoreEnvironment( plotter, oldsheetpath );
234}
235
236
238 const SCH_PLOT_OPTS& aPlotOpts )
239{
240 if( aPlotOpts.m_useBackgroundColor && aPlotter->GetColorMode() )
241 {
242 aPlotter->SetColor( aPlotter->RenderSettings()->GetBackgroundColor() );
245 aPlotter->Rect( VECTOR2I( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 );
246 }
247
248 if( aPlotOpts.m_plotDrawingSheet )
249 {
250 COLOR4D color = COLOR4D::BLACK;
251
252 if( aPlotter->GetColorMode() )
254
255 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
256 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
257 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
258
259 PlotDrawingSheet( aPlotter, &aScreen->Schematic()->Prj(),
260 aScreen->GetTitleBlock(),
261 actualPage,
262 aScreen->Schematic()->GetProperties(),
263 aScreen->GetPageNumber(), aScreen->GetPageCount(), sheetName, sheetPath,
264 aScreen->GetFileName(), color, aScreen->GetVirtualPageNumber() == 1 );
265 }
266
267 aScreen->Plot( aPlotter, aPlotOpts );
268}
269
270
272 const SCH_PLOT_OPTS& aPlotOpts )
273{
274 PAGE_INFO plotPage; // page size selected to plot
275
276 // Considerations on page size and scaling requests
277 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
278
279 switch( aPlotOpts.m_pageSizeSelect )
280 {
281 case PAGE_SIZE_A:
282 plotPage.SetType( wxT( "A" ) );
283 plotPage.SetPortrait( actualPage.IsPortrait() );
284 break;
285
286 case PAGE_SIZE_A4:
287 plotPage.SetType( wxT( "A4" ) );
288 plotPage.SetPortrait( actualPage.IsPortrait() );
289 break;
290
291 case PAGE_SIZE_AUTO:
292 default:
293 plotPage = actualPage;
294 break;
295 }
296
297 double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
298 double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
299 double scale = std::min( scalex, scaley );
300 aPlotter->SetPageSettings( plotPage );
301
302 // Currently, plot units are in decimil
303 aPlotter->SetViewport( VECTOR2I( 0, 0 ), schIUScale.IU_PER_MILS / 10, scale, false );
304}
305
306
308 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
309{
310 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet(); // sheetpath is saved here
311 PAGE_INFO plotPage; // page size selected to plot
312 wxString msg;
313
314 /* When printing all pages, the printed page is not the current page.
315 * In complex hierarchies, we must update symbol references and other parameters in the
316 * given printed SCH_SCREEN, accordant to the sheet path because in complex hierarchies
317 * a SCH_SCREEN (a drawing ) is shared between many sheets and symbol references
318 * depend on the actual sheet path used.
319 */
320 SCH_SHEET_LIST sheetList;
321
322 if( aPlotOpts.m_plotAll )
323 {
324 sheetList.BuildSheetList( &m_schematic->Root(), true );
325 sheetList.SortByPageNumbers();
326
327 // remove the non-selected pages if we are in plot pages mode
328 if( aPlotOpts.m_plotPages.size() > 0 )
329 {
330 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
331 }
332 }
333 else
334 {
335 sheetList.push_back( m_schematic->CurrentSheet() );
336 }
337
338 for( unsigned i = 0; i < sheetList.size(); i++ )
339 {
340 m_schematic->SetCurrentSheet( sheetList[i] );
343
345 PAGE_INFO actualPage = screen->GetPageSettings();
346
347 switch( aPlotOpts.m_pageSizeSelect )
348 {
349 case PAGE_SIZE_A:
350 plotPage.SetType( wxT( "A" ) );
351 plotPage.SetPortrait( actualPage.IsPortrait() );
352 break;
353
354 case PAGE_SIZE_A4:
355 plotPage.SetType( wxT( "A4" ) );
356 plotPage.SetPortrait( actualPage.IsPortrait() );
357 break;
358
359 case PAGE_SIZE_AUTO:
360 default: plotPage = actualPage; break;
361 }
362
363 double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
364 double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
365 double scale = std::min( scalex, scaley );
366 VECTOR2I plot_offset;
367
368 try
369 {
371
372 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
373 // main project folder (or the folder specified by the caller),
374 // so replace separators to create a unique filename:
375 fname.Replace( "/", "_" );
376 fname.Replace( "\\", "_" );
378 wxFileName plotFileName = createPlotFileName( aPlotOpts, fname, ext, aReporter );
379
380 m_lastOutputFilePath = plotFileName.GetFullPath();
381
382 if( !plotFileName.IsOk() )
383 return;
384
385 if( plotOneSheetPS( plotFileName.GetFullPath(), screen, aRenderSettings, actualPage,
386 plot_offset, scale, aPlotOpts ) )
387 {
388 if( aReporter )
389 {
390 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
391 aReporter->Report( msg, RPT_SEVERITY_ACTION );
392 }
393 }
394 else
395 {
396 if( aReporter )
397 {
398 // Error
399 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
400 aReporter->Report( msg, RPT_SEVERITY_ERROR );
401 }
402 }
403 }
404 catch( IO_ERROR& e )
405 {
406 if( aReporter )
407 {
408 msg.Printf( wxT( "PS Plotter exception: %s" ), e.What() );
409 aReporter->Report( msg, RPT_SEVERITY_ERROR );
410 }
411 }
412 }
413
414 if( aReporter )
415 {
416 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
417 }
418
419 restoreEnvironment( nullptr, oldsheetpath );
420}
421
422
423bool SCH_PLOTTER::plotOneSheetPS( const wxString& aFileName, SCH_SCREEN* aScreen,
424 RENDER_SETTINGS* aRenderSettings, const PAGE_INFO& aPageInfo,
425 const VECTOR2I& aPlot0ffset, double aScale,
426 const SCH_PLOT_OPTS& aPlotOpts )
427{
428 PS_PLOTTER* plotter = new PS_PLOTTER();
429 plotter->SetRenderSettings( aRenderSettings );
430 plotter->SetPageSettings( aPageInfo );
431 plotter->SetColorMode( !aPlotOpts.m_blackAndWhite );
432
433 // Currently, plot units are in decimil
434 plotter->SetViewport( aPlot0ffset, schIUScale.IU_PER_MILS / 10, aScale, false );
435
436 // Init :
437 plotter->SetCreator( wxT( "Eeschema-PS" ) );
438
439 if( !plotter->OpenFile( aFileName ) )
440 {
441 delete plotter;
442 return false;
443 }
444
445 LOCALE_IO toggle; // Switch the locale to standard C
446
448
449 if( aPlotOpts.m_useBackgroundColor && plotter->GetColorMode() )
450 {
452
455 plotter->Rect( VECTOR2I( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 );
456 }
457
458 if( aPlotOpts.m_plotDrawingSheet )
459 {
460 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
461 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
463
464 PlotDrawingSheet( plotter, &aScreen->Schematic()->Prj(),
465 aScreen->GetTitleBlock(),
466 aPageInfo, aScreen->Schematic()->GetProperties(),
467 aScreen->GetPageNumber(), aScreen->GetPageCount(), sheetName, sheetPath,
468 aScreen->GetFileName(), plotter->GetColorMode() ? color : COLOR4D::BLACK,
469 aScreen->GetVirtualPageNumber() == 1 );
470 }
471
472 aScreen->Plot( plotter, aPlotOpts );
473
474 plotter->EndPlot();
475 delete plotter;
476
477 return true;
478}
479
480
482 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
483{
484 wxString msg;
485 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet();
486 SCH_SHEET_LIST sheetList;
487
488 if( aPlotOpts.m_plotAll )
489 {
490 sheetList.BuildSheetList( &m_schematic->Root(), true );
491 sheetList.SortByPageNumbers();
492
493 // remove the non-selected pages if we are in plot pages mode
494 if( aPlotOpts.m_plotPages.size() > 0 )
495 {
496 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
497 }
498 }
499 else
500 {
501 // in eeschema, this prints the current page
502 sheetList.push_back( m_schematic->CurrentSheet() );
503 }
504
505 for( unsigned i = 0; i < sheetList.size(); i++ )
506 {
507 SCH_SCREEN* screen;
508
509 m_schematic->SetCurrentSheet( sheetList[i] );
512
513 screen = m_schematic->CurrentSheet().LastScreen();
514
515 try
516 {
518
519 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
520 // main project folder (or the folder specified by the caller),
521 // so replace separators to create a unique filename:
522 fname.Replace( "/", "_" );
523 fname.Replace( "\\", "_" );
525 wxFileName plotFileName = createPlotFileName( aPlotOpts, fname, ext, aReporter );
526
527 m_lastOutputFilePath = plotFileName.GetFullPath();
528
529 if( !plotFileName.IsOk() )
530 return;
531
532 bool success = plotOneSheetSVG( plotFileName.GetFullPath(), screen, aRenderSettings,
533 aPlotOpts );
534
535 if( !success )
536 {
537 if( aReporter )
538 {
539 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
540 aReporter->Report( msg, RPT_SEVERITY_ERROR );
541 }
542 }
543 else
544 {
545 if( aReporter )
546 {
547 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
548 aReporter->Report( msg, RPT_SEVERITY_ACTION );
549 }
550 }
551 }
552 catch( const IO_ERROR& e )
553 {
554 if( aReporter )
555 {
556 // Cannot plot SVG file
557 msg.Printf( wxT( "SVG Plotter exception: %s" ), e.What() );
558 aReporter->Report( msg, RPT_SEVERITY_ERROR );
559 }
560 break;
561 }
562 }
563
564 if( aReporter )
565 {
566 aReporter->ReportTail( _( "Done" ), RPT_SEVERITY_INFO );
567 }
568
569 restoreEnvironment( nullptr, oldsheetpath );
570}
571
572
573bool SCH_PLOTTER::plotOneSheetSVG( const wxString& aFileName, SCH_SCREEN* aScreen,
574 RENDER_SETTINGS* aRenderSettings,
575 const SCH_PLOT_OPTS& aPlotOpts )
576{
577 PAGE_INFO plotPage;
578 // Adjust page size and scaling requests
579 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
580
581 switch( aPlotOpts.m_pageSizeSelect )
582 {
583 case PAGE_SIZE_A:
584 plotPage.SetType( wxT( "A" ) );
585 plotPage.SetPortrait( actualPage.IsPortrait() );
586 break;
587
588 case PAGE_SIZE_A4:
589 plotPage.SetType( wxT( "A4" ) );
590 plotPage.SetPortrait( actualPage.IsPortrait() );
591 break;
592
593 case PAGE_SIZE_AUTO:
594 default:
595 plotPage = actualPage;
596 break;
597 }
598
599 SVG_PLOTTER* plotter = new SVG_PLOTTER();
600 plotter->SetRenderSettings( aRenderSettings );
601 plotter->SetPageSettings( plotPage );
602 plotter->SetColorMode( aPlotOpts.m_blackAndWhite ? false : true );
603 VECTOR2I plot_offset;
604
605 double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
606 double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
607 double scale = std::min( scalex, scaley );
608
609 // Currently, plot units are in decimil
610 plotter->SetViewport( plot_offset, schIUScale.IU_PER_MILS / 10, scale, false );
611
612 // Init :
613 plotter->SetCreator( wxT( "Eeschema-SVG" ) );
614
615 if( !plotter->OpenFile( aFileName ) )
616 {
617 delete plotter;
618 return false;
619 }
620
621 LOCALE_IO toggle;
622
624
625 if( aPlotOpts.m_useBackgroundColor && plotter->GetColorMode() )
626 {
630 plotter->Rect( VECTOR2I( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 );
631 }
632
633 if( aPlotOpts.m_plotDrawingSheet )
634 {
635 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
636 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
638
639 PlotDrawingSheet( plotter, &aScreen->Schematic()->Prj(),
640 aScreen->GetTitleBlock(),
641 actualPage, aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(),
642 aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(),
643 plotter->GetColorMode() ? color : COLOR4D::BLACK,
644 aScreen->GetVirtualPageNumber() == 1 );
645 }
646
647 aScreen->Plot( plotter, aPlotOpts );
648
649 plotter->EndPlot();
650 delete plotter;
651
652 return true;
653}
654
655
657 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
658{
659 SCH_SCREEN* screen = m_schematic->RootScreen();
660 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet();
661
662 /* When printing all pages, the printed page is not the current page. In complex hierarchies,
663 * we must update symbol references and other parameters in the given printed SCH_SCREEN,
664 * according to the sheet path because in complex hierarchies a SCH_SCREEN (a drawing ) is
665 * shared between many sheets and symbol references depend on the actual sheet path used.
666 */
667 SCH_SHEET_LIST sheetList;
668
669 if( aPlotOpts.m_plotAll )
670 {
671 sheetList.BuildSheetList( &m_schematic->Root(), true );
672 sheetList.SortByPageNumbers();
673
674 // remove the non-selected pages if we are in plot pages mode
675 if( aPlotOpts.m_plotPages.size() > 0 )
676 {
677 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
678 }
679 }
680 else
681 {
682 // in eeschema, this prints the current page
683 sheetList.push_back( m_schematic->CurrentSheet() );
684 }
685
686 for( unsigned i = 0; i < sheetList.size(); i++ )
687 {
688 m_schematic->SetCurrentSheet( sheetList[i] );
691
692 screen = m_schematic->CurrentSheet().LastScreen();
693
694 if( !screen ) // LastScreen() may return NULL
695 screen = m_schematic->RootScreen();
696
697 const PAGE_INFO& curPage = screen->GetPageSettings();
698
699 PAGE_INFO plotPage = curPage;
700
701 // if plotting on a page size other than curPage
702 plotPage.SetType( plot_sheet_list( aPlotOpts.m_HPGLPaperSizeSelect ) );
703
704 // Calculation of conversion scales.
705 double plot_scale = (double) plotPage.GetWidthMils() / curPage.GetWidthMils();
706
707 // Calculate offsets
708 VECTOR2I plotOffset;
709 wxString msg;
710
711 if( aPlotOpts.m_HPGLPlotOrigin == HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER )
712 {
713 plotOffset.x = plotPage.GetWidthIU( schIUScale.IU_PER_MILS ) / 2;
714 plotOffset.y = -plotPage.GetHeightIU( schIUScale.IU_PER_MILS ) / 2;
715 }
716
717 try
718 {
720 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
721 // main project folder (or the folder specified by the caller),
722 // so replace separators to create a unique filename:
723 fname.Replace( "/", "_" );
724 fname.Replace( "\\", "_" );
726 wxFileName plotFileName = createPlotFileName( aPlotOpts, fname, ext, aReporter );
727
728 if( !plotFileName.IsOk() )
729 return;
730
731 LOCALE_IO toggle;
732
733 if( plotOneSheetHpgl( plotFileName.GetFullPath(), screen, curPage, aRenderSettings,
734 plotOffset, plot_scale, aPlotOpts ) )
735 {
736 if( aReporter )
737 {
738 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
739 aReporter->Report( msg, RPT_SEVERITY_ACTION );
740 }
741 }
742 else
743 {
744 if( aReporter )
745 {
746 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
747 aReporter->Report( msg, RPT_SEVERITY_ERROR );
748 }
749 }
750 }
751 catch( IO_ERROR& e )
752 {
753 if( aReporter )
754 {
755 msg.Printf( wxT( "HPGL Plotter exception: %s" ), e.What() );
756 aReporter->Report( msg, RPT_SEVERITY_ERROR );
757 }
758 }
759 }
760
761 if( aReporter )
762 {
763 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
764 }
765
766 restoreEnvironment( nullptr, oldsheetpath );
767}
768
769
770bool SCH_PLOTTER::plotOneSheetHpgl( const wxString& aFileName, SCH_SCREEN* aScreen,
771 const PAGE_INFO& aPageInfo, RENDER_SETTINGS* aRenderSettings,
772 const VECTOR2I& aPlot0ffset, double aScale,
773 const SCH_PLOT_OPTS& aPlotOpts )
774{
775 HPGL_PLOTTER* plotter = new HPGL_PLOTTER();
776 // Currently, plot units are in decimil
777
778 plotter->SetPageSettings( aPageInfo );
779 plotter->SetRenderSettings( aRenderSettings );
781 plotter->SetViewport( aPlot0ffset, schIUScale.IU_PER_MILS/10, aScale, false );
782
783 // TODO this could be configurable
784 plotter->SetTargetChordLength( schIUScale.mmToIU( 0.6 ) );
785
786 switch( aPlotOpts.m_HPGLPlotOrigin )
787 {
788 case HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT:
789 case HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER:
790 default:
791 plotter->SetUserCoords( false );
792 break;
793 case HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE:
794 plotter->SetUserCoords( true );
795 plotter->SetUserCoordsFit( false );
796 break;
797 case HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT:
798 plotter->SetUserCoords( true );
799 plotter->SetUserCoordsFit( true );
800 break;
801 }
802
803 // Init :
804 plotter->SetCreator( wxT( "Eeschema-HPGL" ) );
805
806 if( !plotter->OpenFile( aFileName ) )
807 {
808 delete plotter;
809 return false;
810 }
811
812 LOCALE_IO toggle;
813
814 // Pen num and pen speed are not initialized here.
815 // Default HPGL driver values are used
816 plotter->SetPenDiameter( aPlotOpts.m_HPGLPenSize );
818
819 if( aPlotOpts.m_plotDrawingSheet )
820 {
821 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
822 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
823
824 PlotDrawingSheet( plotter, &m_schematic->Prj(),
825 aScreen->GetTitleBlock(),
826 aPageInfo,
827 aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(),
828 aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(),
829 COLOR4D::BLACK, aScreen->GetVirtualPageNumber() == 1 );
830 }
831
832 aScreen->Plot( plotter, aPlotOpts );
833
834 plotter->EndPlot();
835
836 delete plotter;
837
838 return true;
839}
840
841
843 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
844{
845 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet();
846
847 /* When printing all pages, the printed page is not the current page. In complex hierarchies,
848 * we must update symbol references and other parameters in the given printed SCH_SCREEN,
849 * according to the sheet path because in complex hierarchies a SCH_SCREEN (a drawing ) is
850 * shared between many sheets and symbol references depend on the actual sheet path used.
851 */
852 SCH_SHEET_LIST sheetList;
853
854 if( aPlotOpts.m_plotAll )
855 {
856 sheetList.BuildSheetList( &m_schematic->Root(), true );
857 sheetList.SortByPageNumbers();
858
859 // remove the non-selected pages if we are in plot pages mode
860 if( aPlotOpts.m_plotPages.size() > 0 )
861 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
862 }
863 else
864 {
865 // in eeschema, this prints the current page
866 sheetList.push_back( m_schematic->CurrentSheet() );
867 }
868
869 for( unsigned i = 0; i < sheetList.size(); i++ )
870 {
871 m_schematic->SetCurrentSheet( sheetList[i] );
874
876 VECTOR2I plot_offset;
877 wxString msg;
878
879 try
880 {
882
883 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
884 // main project folder (or the folder specified by the caller),
885 // so replace separators to create a unique filename:
886 fname.Replace( "/", "_" );
887 fname.Replace( "\\", "_" );
889 wxFileName plotFileName = createPlotFileName( aPlotOpts, fname, ext, aReporter );
890
891 m_lastOutputFilePath = plotFileName.GetFullPath();
892
893 if( !plotFileName.IsOk() )
894 return;
895
896 if( plotOneSheetDXF( plotFileName.GetFullPath(), screen, aRenderSettings, plot_offset,
897 1.0, aPlotOpts ) )
898 {
899 if( aReporter )
900 {
901 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
902 aReporter->Report( msg, RPT_SEVERITY_ACTION );
903 }
904 }
905 else // Error
906 {
907 if( aReporter )
908 {
909 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
910 aReporter->Report( msg, RPT_SEVERITY_ERROR );
911 }
912 }
913 }
914 catch( IO_ERROR& e )
915 {
916 if( aReporter )
917 {
918 msg.Printf( wxT( "DXF Plotter exception: %s" ), e.What() );
919 aReporter->Report( msg, RPT_SEVERITY_ERROR );
920 }
921
922 m_schematic->SetCurrentSheet( oldsheetpath );
925 return;
926 }
927 }
928
929 if( aReporter )
930 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
931
932 restoreEnvironment( nullptr, oldsheetpath );
933}
934
935
936bool SCH_PLOTTER::plotOneSheetDXF( const wxString& aFileName, SCH_SCREEN* aScreen,
937 RENDER_SETTINGS* aRenderSettings, const VECTOR2I& aPlotOffset,
938 double aScale, const SCH_PLOT_OPTS& aPlotOpts )
939{
940 aRenderSettings->LoadColors( m_colorSettings );
941 aRenderSettings->SetDefaultPenWidth( 0 );
942
943 const PAGE_INFO& pageInfo = aScreen->GetPageSettings();
944 DXF_PLOTTER* plotter = new DXF_PLOTTER();
945
946 plotter->SetRenderSettings( aRenderSettings );
947 plotter->SetPageSettings( pageInfo );
948 plotter->SetColorMode( !aPlotOpts.m_blackAndWhite );
949
950 // Currently, plot units are in decimil
951 plotter->SetViewport( aPlotOffset, schIUScale.IU_PER_MILS / 10, aScale, false );
952
953 // Init :
954 plotter->SetCreator( wxT( "Eeschema-DXF" ) );
955
956 if( !plotter->OpenFile( aFileName ) )
957 {
958 delete plotter;
959 return false;
960 }
961
962 LOCALE_IO toggle;
963
965
966 if( aPlotOpts.m_plotDrawingSheet )
967 {
968 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
969 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
971
972 PlotDrawingSheet( plotter, &m_schematic->Prj(),
973 aScreen->GetTitleBlock(),
974 pageInfo,
975 aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(),
976 aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(),
977 plotter->GetColorMode() ? color : COLOR4D::BLACK,
978 aScreen->GetVirtualPageNumber() == 1 );
979 }
980
981 aScreen->Plot( plotter, aPlotOpts );
982
983 // finish
984 plotter->EndPlot();
985 delete plotter;
986
987 return true;
988}
989
990
992{
993 if( aPlotter )
994 {
995 aPlotter->EndPlot();
996 delete aPlotter;
997 }
998
999 // Restore the initial sheet
1000 m_schematic->SetCurrentSheet( aOldsheetpath );
1003}
1004
1005
1007 const wxString& aPlotFileName,
1008 const wxString& aExtension, REPORTER* aReporter )
1009{
1010 wxFileName retv;
1011 wxFileName tmp;
1012
1013 tmp.SetPath( aPlotOpts.m_outputDirectory );
1014 retv.SetPath( tmp.GetPath() );
1015
1016 if( !aPlotFileName.IsEmpty() )
1017 retv.SetName( aPlotFileName );
1018 else
1019 retv.SetName( _( "Schematic" ) );
1020
1021 retv.SetExt( aExtension );
1022
1023 if( !EnsureFileDirectoryExists( &tmp, retv.GetFullName(), aReporter ) || !tmp.IsDirWritable() )
1024 {
1025 if( aReporter )
1026 {
1027 wxString msg = wxString::Format( _( "Failed to write plot files to folder '%s'." ),
1028 tmp.GetPath() );
1029 aReporter->Report( msg, RPT_SEVERITY_ERROR );
1030 }
1031 retv.Clear();
1032
1034 settings.m_PlotDirectoryName.Clear();
1035 }
1036 else
1037 {
1038 retv.SetPath( tmp.GetPath() );
1039 }
1040
1041 wxLogTrace( tracePathsAndFiles, "Writing plot file '%s'.", retv.GetFullPath() );
1042
1043 return retv;
1044}
1045
1046
1047void SCH_PLOTTER::Plot( PLOT_FORMAT aPlotFormat, const SCH_PLOT_OPTS& aPlotOpts,
1048 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
1049{
1050 SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
1051
1052 m_colorSettings = settingsMgr.GetColorSettings( aPlotOpts.m_theme );
1053
1054 switch( aPlotFormat )
1055 {
1056 default:
1057 case PLOT_FORMAT::POST: createPSFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1058 case PLOT_FORMAT::DXF: createDXFFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1059 case PLOT_FORMAT::PDF: createPDFFile( aPlotOpts, aRenderSettings, aReporter ); break;
1060 case PLOT_FORMAT::SVG: createSVGFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1061 case PLOT_FORMAT::HPGL: createHPGLFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1062 }
1063}
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:71
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:104
virtual bool OpenFile(const wxString &aFullFilename)
Open or create the plot file aFullFilename.
Definition: plotter.cpp:74
virtual void SetAuthor(const wxString &aAuthor)
Definition: plotter.h:155
virtual void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: plotter.h:137
void SetRenderSettings(RENDER_SETTINGS *aSettings)
Definition: plotter.h:134
virtual void SetTitle(const wxString &aTitle)
Definition: plotter.h:154
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:135
virtual void SetCreator(const wxString &aCreator)
Definition: plotter.h:153
bool GetColorMode() const
Definition: plotter.h:132
PAGE_INFO & PageSettings()
Definition: plotter.h:138
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:131
virtual void SetSubject(const wxString &aSubject)
Definition: plotter.h:156
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:896
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:735
static wxString GetDefaultFileExtension()
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:71
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:99
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
These settings were stored in SCH_BASE_FRAME previously.
Holds all the data relating to one schematic.
Definition: schematic.h:75
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:136
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:287
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
Definition: schematic.h:141
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:197
bool ResolveTextVar(const SCH_SHEET_PATH *aSheetPath, wxString *token, int aDepth) const
Definition: schematic.cpp:228
const std::map< wxString, wxString > * GetProperties()
Definition: schematic.h:93
SCH_SHEET & Root() const
Definition: schematic.h:105
wxString GetUniqueFilenameForCurrentSheet()
Definition: schematic.cpp:611
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
Definition: schematic.cpp:627
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:90
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:218
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:217
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:216
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:131
const wxString & GetFileName() const
Definition: sch_screen.h:144
SCHEMATIC * Schematic() const
Definition: sch_screen.cpp:97
const TITLE_BLOCK & GetTitleBlock() const
Definition: sch_screen.h:155
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 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:362
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
Definition: common.cpp:58
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:395
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:389
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1059
see class PGM_BASE
PLOT_FORMAT
The set of supported output plot formats.
Definition: plotter.h:64
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:56
@ PAGE_SIZE_A
Definition: sch_plotter.h:58
@ PAGE_SIZE_A4
Definition: sch_plotter.h:57
HPGL_PAGE_SIZE
Definition: sch_plotter.h:63
@ 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:83
wxString m_theme
Definition: sch_plotter.h:92
wxString m_outputDirectory
Definition: sch_plotter.h:94
HPGL_PLOT_ORIGIN_AND_UNITS m_HPGLPlotOrigin
Definition: sch_plotter.h:97
wxString m_outputFile
Definition: sch_plotter.h:95
int m_pageSizeSelect
Definition: sch_plotter.h:86
bool m_PDFMetadata
Definition: sch_plotter.h:91
bool m_blackAndWhite
Definition: sch_plotter.h:85
HPGL_PAGE_SIZE m_HPGLPaperSizeSelect
Definition: sch_plotter.h:89
double m_HPGLPenSize
Definition: sch_plotter.h:88
bool m_useBackgroundColor
Definition: sch_plotter.h:87
bool m_plotDrawingSheet
Definition: sch_plotter.h:82
wxLogTrace helper definitions.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588