KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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 <stambaughw@gmail.com>
7 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, 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 );
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()->GetField( FIELD_T::SHEET_NAME )->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 SCH_SHEET_PATH parentSheet = sheetList[i];
230
231 if( parentSheet.size() > 1 )
232 {
233 // The sheet path is the full path to the sheet, so we need to remove the last
234 // sheet name to get the parent sheet path
235 parentSheet.pop_back();
236 }
237
238 wxString parentSheetName =
239 parentSheet.Last()->GetField( FIELD_T::SHEET_NAME )->GetShownText( false );
240
241 plotter->StartPage( sheetList[i].GetPageNumber(), sheetName,
242 parentSheet.GetPageNumber(), parentSheetName );
243 }
244
245 plotOneSheetPDF( plotter, screen, aPlotOpts );
246 }
247
248 // Everything done, close the plot and restore the environment
249 if( aReporter )
250 {
251 msg.Printf( _( "Plotted to '%s'.\n" ), plotFileName.GetFullPath() );
252 aReporter->Report( msg, RPT_SEVERITY_ACTION );
253 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
254 }
255
256 restoreEnvironment( plotter, oldsheetpath );
257}
258
259
261 const SCH_PLOT_OPTS& aPlotOpts )
262{
263 if( aPlotOpts.m_useBackgroundColor && aPlotter->GetColorMode() )
264 {
265 aPlotter->SetColor( aPlotter->RenderSettings()->GetBackgroundColor() );
266
267 // Use page size selected in schematic to know the schematic bg area
268 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
270 actualPage.GetHeightIU( schIUScale.IU_PER_MILS ) );
271
272 aPlotter->Rect( VECTOR2I( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 );
273 }
274
275 if( aPlotOpts.m_plotDrawingSheet )
276 {
277 COLOR4D color = COLOR4D::BLACK;
278
279 if( aPlotter->GetColorMode() )
281
282 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
283 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
284 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
285
286 PlotDrawingSheet( aPlotter, &aScreen->Schematic()->Prj(),
287 aScreen->GetTitleBlock(),
288 actualPage,
289 aScreen->Schematic()->GetProperties(),
290 aScreen->GetPageNumber(), aScreen->GetPageCount(), sheetName, sheetPath,
291 aScreen->GetFileName(), color, aScreen->GetVirtualPageNumber() == 1 );
292 }
293
294 aScreen->Plot( aPlotter, aPlotOpts );
295}
296
297
299 const SCH_PLOT_OPTS& aPlotOpts )
300{
301 PAGE_INFO plotPage; // page size selected to plot
302
303 // Considerations on page size and scaling requests
304 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
305
306 switch( aPlotOpts.m_pageSizeSelect )
307 {
308 case PAGE_SIZE_A:
309 plotPage.SetType( wxT( "A" ) );
310 plotPage.SetPortrait( actualPage.IsPortrait() );
311 break;
312
313 case PAGE_SIZE_A4:
314 plotPage.SetType( wxT( "A4" ) );
315 plotPage.SetPortrait( actualPage.IsPortrait() );
316 break;
317
318 case PAGE_SIZE_AUTO:
319 default:
320 plotPage = actualPage;
321 break;
322 }
323
324 double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
325 double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
326 double scale = std::min( scalex, scaley );
327 aPlotter->SetPageSettings( plotPage );
328
329 // Currently, plot units are in decimil
330 aPlotter->SetViewport( VECTOR2I( 0, 0 ), schIUScale.IU_PER_MILS / 10, scale, false );
331}
332
333
335 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
336{
337 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet(); // sheetpath is saved here
338 PAGE_INFO plotPage; // page size selected to plot
339 wxString msg;
340
341 /* When printing all pages, the printed page is not the current page.
342 * In complex hierarchies, we must update symbol references and other parameters in the
343 * given printed SCH_SCREEN, accordant to the sheet path because in complex hierarchies
344 * a SCH_SCREEN (a drawing ) is shared between many sheets and symbol references
345 * depend on the actual sheet path used.
346 */
347 SCH_SHEET_LIST sheetList;
348
349 if( aPlotOpts.m_plotAll )
350 {
351 sheetList.BuildSheetList( &m_schematic->Root(), true );
352 sheetList.SortByPageNumbers();
353
354 // remove the non-selected pages if we are in plot pages mode
355 if( aPlotOpts.m_plotPages.size() > 0 )
356 {
357 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
358 }
359 }
360 else
361 {
362 sheetList.push_back( m_schematic->CurrentSheet() );
363 }
364
365 for( unsigned i = 0; i < sheetList.size(); i++ )
366 {
367 m_schematic->SetCurrentSheet( sheetList[i] );
370
372 PAGE_INFO actualPage = screen->GetPageSettings();
373
374 switch( aPlotOpts.m_pageSizeSelect )
375 {
376 case PAGE_SIZE_A:
377 plotPage.SetType( wxT( "A" ) );
378 plotPage.SetPortrait( actualPage.IsPortrait() );
379 break;
380
381 case PAGE_SIZE_A4:
382 plotPage.SetType( wxT( "A4" ) );
383 plotPage.SetPortrait( actualPage.IsPortrait() );
384 break;
385
386 case PAGE_SIZE_AUTO:
387 default:
388 plotPage = actualPage;
389 break;
390 }
391
392 double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
393 double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
394 double scale = std::min( scalex, scaley );
395 VECTOR2I plot_offset;
396
397 try
398 {
400
401 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
402 // main project folder (or the folder specified by the caller),
403 // so replace separators to create a unique filename:
404 fname.Replace( "/", "_" );
405 fname.Replace( "\\", "_" );
407 wxFileName plotFileName = createPlotFileName( aPlotOpts, fname, ext, aReporter );
408
409 m_lastOutputFilePath = plotFileName.GetFullPath();
410
411 if( !plotFileName.IsOk() )
412 {
413 if( aReporter )
414 {
415 // Error
416 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
417 aReporter->Report( msg, RPT_SEVERITY_ERROR );
418 }
419 }
420 else if( plotOneSheetPS( plotFileName.GetFullPath(), screen, aRenderSettings,
421 actualPage, plot_offset, scale, aPlotOpts ) )
422 {
423 if( aReporter )
424 {
425 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
426 aReporter->Report( msg, RPT_SEVERITY_ACTION );
427 }
428 }
429 else
430 {
431 if( aReporter )
432 {
433 // Error
434 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
435 aReporter->Report( msg, RPT_SEVERITY_ERROR );
436 }
437 }
438 }
439 catch( IO_ERROR& e )
440 {
441 if( aReporter )
442 {
443 msg.Printf( wxT( "PS Plotter exception: %s" ), e.What() );
444 aReporter->Report( msg, RPT_SEVERITY_ERROR );
445 }
446 }
447 }
448
449 if( aReporter )
450 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
451
452 restoreEnvironment( nullptr, oldsheetpath );
453}
454
455
456bool SCH_PLOTTER::plotOneSheetPS( const wxString& aFileName, SCH_SCREEN* aScreen,
457 RENDER_SETTINGS* aRenderSettings, const PAGE_INFO& aPageInfo,
458 const VECTOR2I& aPlot0ffset, double aScale,
459 const SCH_PLOT_OPTS& aPlotOpts )
460{
461 PS_PLOTTER* plotter = new PS_PLOTTER();
462 plotter->SetRenderSettings( aRenderSettings );
463 plotter->SetPageSettings( aPageInfo );
464 plotter->SetColorMode( !aPlotOpts.m_blackAndWhite );
465
466 // Currently, plot units are in decimil
467 plotter->SetViewport( aPlot0ffset, schIUScale.IU_PER_MILS / 10, aScale, false );
468
469 // Init :
470 plotter->SetCreator( wxT( "Eeschema-PS" ) );
471
472 if( !plotter->OpenFile( aFileName ) )
473 {
474 delete plotter;
475 return false;
476 }
477
478 LOCALE_IO toggle; // Switch the locale to standard C
479
481
482 if( aPlotOpts.m_useBackgroundColor && plotter->GetColorMode() )
483 {
485
486 // Use page size selected in schematic to know the schematic bg area
487 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
489 actualPage.GetHeightIU( schIUScale.IU_PER_MILS ) );
490
491 plotter->Rect( VECTOR2I( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 );
492 }
493
494 if( aPlotOpts.m_plotDrawingSheet )
495 {
496 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
497 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
499
500 PlotDrawingSheet( plotter, &aScreen->Schematic()->Prj(),
501 aScreen->GetTitleBlock(),
502 aPageInfo, aScreen->Schematic()->GetProperties(),
503 aScreen->GetPageNumber(), aScreen->GetPageCount(), sheetName, sheetPath,
504 aScreen->GetFileName(), plotter->GetColorMode() ? color : COLOR4D::BLACK,
505 aScreen->GetVirtualPageNumber() == 1 );
506 }
507
508 aScreen->Plot( plotter, aPlotOpts );
509
510 plotter->EndPlot();
511 delete plotter;
512
513 return true;
514}
515
516
518 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
519{
520 wxString msg;
521 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet();
522 SCH_SHEET_LIST sheetList;
523
524 if( aPlotOpts.m_plotAll )
525 {
526 sheetList.BuildSheetList( &m_schematic->Root(), true );
527 sheetList.SortByPageNumbers();
528
529 // remove the non-selected pages if we are in plot pages mode
530 if( aPlotOpts.m_plotPages.size() > 0 )
531 {
532 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
533 }
534 }
535 else
536 {
537 // in Eeschema, this prints the current page
538 sheetList.push_back( m_schematic->CurrentSheet() );
539 }
540
541 for( unsigned i = 0; i < sheetList.size(); i++ )
542 {
543 SCH_SCREEN* screen;
544
545 m_schematic->SetCurrentSheet( sheetList[i] );
548
549 screen = m_schematic->CurrentSheet().LastScreen();
550
551 try
552 {
554
555 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
556 // main project folder (or the folder specified by the caller),
557 // so replace separators to create a unique filename:
558 fname.Replace( "/", "_" );
559 fname.Replace( "\\", "_" );
561 wxFileName plotFileName = createPlotFileName( aPlotOpts, fname, ext, aReporter );
562
563 m_lastOutputFilePath = plotFileName.GetFullPath();
564
565 if( !plotFileName.IsOk() )
566 return;
567
568 bool success = plotOneSheetSVG( plotFileName.GetFullPath(), screen, aRenderSettings,
569 aPlotOpts );
570
571 if( !success )
572 {
573 if( aReporter )
574 {
575 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
576 aReporter->Report( msg, RPT_SEVERITY_ERROR );
577 }
578 }
579 else
580 {
581 if( aReporter )
582 {
583 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
584 aReporter->Report( msg, RPT_SEVERITY_ACTION );
585 }
586 }
587 }
588 catch( const IO_ERROR& e )
589 {
590 if( aReporter )
591 {
592 // Cannot plot SVG file
593 msg.Printf( wxT( "SVG Plotter exception: %s" ), e.What() );
594 aReporter->Report( msg, RPT_SEVERITY_ERROR );
595 }
596 break;
597 }
598 }
599
600 if( aReporter )
601 {
602 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
603 }
604
605 restoreEnvironment( nullptr, oldsheetpath );
606}
607
608
609bool SCH_PLOTTER::plotOneSheetSVG( const wxString& aFileName, SCH_SCREEN* aScreen,
610 RENDER_SETTINGS* aRenderSettings,
611 const SCH_PLOT_OPTS& aPlotOpts )
612{
613 PAGE_INFO plotPage;
614
615 // Adjust page size and scaling requests
616 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
617
618 switch( aPlotOpts.m_pageSizeSelect )
619 {
620 case PAGE_SIZE_A:
621 plotPage.SetType( wxT( "A" ) );
622 plotPage.SetPortrait( actualPage.IsPortrait() );
623 break;
624
625 case PAGE_SIZE_A4:
626 plotPage.SetType( wxT( "A4" ) );
627 plotPage.SetPortrait( actualPage.IsPortrait() );
628 break;
629
630 case PAGE_SIZE_AUTO:
631 default:
632 plotPage = actualPage;
633 break;
634 }
635
636 SVG_PLOTTER* plotter = new SVG_PLOTTER();
637 plotter->SetRenderSettings( aRenderSettings );
638 plotter->SetPageSettings( plotPage );
639 plotter->SetColorMode( aPlotOpts.m_blackAndWhite ? false : true );
640 VECTOR2I plot_offset;
641
642 double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
643 double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
644 double scale = std::min( scalex, scaley );
645
646 // Currently, plot units are in decimil
647 plotter->SetViewport( plot_offset, schIUScale.IU_PER_MILS / 10, scale, false );
648
649 // Init :
650 plotter->SetCreator( wxT( "Eeschema-SVG" ) );
651
652 if( !plotter->OpenFile( aFileName ) )
653 {
654 delete plotter;
655 return false;
656 }
657
658 LOCALE_IO toggle;
659
661
662 if( aPlotOpts.m_useBackgroundColor && plotter->GetColorMode() )
663 {
665
666 // Use page size selected in schematic to know the schematic bg area
668 actualPage.GetHeightIU( schIUScale.IU_PER_MILS ) );
669
670 plotter->Rect( VECTOR2I( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 );
671 }
672
673 if( aPlotOpts.m_plotDrawingSheet )
674 {
675 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
676 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
678
679 PlotDrawingSheet( plotter, &aScreen->Schematic()->Prj(),
680 aScreen->GetTitleBlock(),
681 actualPage, aScreen->Schematic()->GetProperties(),
682 aScreen->GetPageNumber(),
683 aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(),
684 plotter->GetColorMode() ? color : COLOR4D::BLACK,
685 aScreen->GetVirtualPageNumber() == 1 );
686 }
687
688 aScreen->Plot( plotter, aPlotOpts );
689
690 plotter->EndPlot();
691 delete plotter;
692
693 return true;
694}
695
696
698 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
699{
700 SCH_SCREEN* screen = m_schematic->RootScreen();
701 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet();
702
703 /* When printing all pages, the printed page is not the current page. In complex hierarchies,
704 * we must update symbol references and other parameters in the given printed SCH_SCREEN,
705 * according to the sheet path because in complex hierarchies a SCH_SCREEN (a drawing ) is
706 * shared between many sheets and symbol references depend on the actual sheet path used.
707 */
708 SCH_SHEET_LIST sheetList;
709
710 if( aPlotOpts.m_plotAll )
711 {
712 sheetList.BuildSheetList( &m_schematic->Root(), true );
713 sheetList.SortByPageNumbers();
714
715 // remove the non-selected pages if we are in plot pages mode
716 if( aPlotOpts.m_plotPages.size() > 0 )
717 {
718 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
719 }
720 }
721 else
722 {
723 // in Eeschema, this prints the current page
724 sheetList.push_back( m_schematic->CurrentSheet() );
725 }
726
727 for( unsigned i = 0; i < sheetList.size(); i++ )
728 {
729 m_schematic->SetCurrentSheet( sheetList[i] );
732
733 screen = m_schematic->CurrentSheet().LastScreen();
734
735 if( !screen ) // LastScreen() may return NULL
736 screen = m_schematic->RootScreen();
737
738 const PAGE_INFO& curPage = screen->GetPageSettings();
739
740 PAGE_INFO plotPage = curPage;
741
742 // if plotting on a page size other than curPage
743 plotPage.SetType( plot_sheet_list( aPlotOpts.m_HPGLPaperSizeSelect ) );
744
745 // Calculation of conversion scales.
746 double plot_scale = (double) plotPage.GetWidthMils() / curPage.GetWidthMils();
747
748 // Calculate offsets
749 VECTOR2I plotOffset;
750 wxString msg;
751
752 if( aPlotOpts.m_HPGLPlotOrigin == HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER )
753 {
754 plotOffset.x = plotPage.GetWidthIU( schIUScale.IU_PER_MILS ) / 2;
755 plotOffset.y = -plotPage.GetHeightIU( schIUScale.IU_PER_MILS ) / 2;
756 }
757
758 try
759 {
761 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
762 // main project folder (or the folder specified by the caller),
763 // so replace separators to create a unique filename:
764 fname.Replace( "/", "_" );
765 fname.Replace( "\\", "_" );
767 wxFileName plotFileName = createPlotFileName( aPlotOpts, fname, ext, aReporter );
768
769 if( !plotFileName.IsOk() )
770 return;
771
772 LOCALE_IO toggle;
773
774 if( plotOneSheetHpgl( plotFileName.GetFullPath(), screen, curPage, aRenderSettings,
775 plotOffset, plot_scale, aPlotOpts ) )
776 {
777 if( aReporter )
778 {
779 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
780 aReporter->Report( msg, RPT_SEVERITY_ACTION );
781 }
782 }
783 else
784 {
785 if( aReporter )
786 {
787 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
788 aReporter->Report( msg, RPT_SEVERITY_ERROR );
789 }
790 }
791 }
792 catch( IO_ERROR& e )
793 {
794 if( aReporter )
795 {
796 msg.Printf( wxT( "HPGL Plotter exception: %s" ), e.What() );
797 aReporter->Report( msg, RPT_SEVERITY_ERROR );
798 }
799 }
800 }
801
802 if( aReporter )
803 {
804 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
805 }
806
807 restoreEnvironment( nullptr, oldsheetpath );
808}
809
810
811bool SCH_PLOTTER::plotOneSheetHpgl( const wxString& aFileName, SCH_SCREEN* aScreen,
812 const PAGE_INFO& aPageInfo, RENDER_SETTINGS* aRenderSettings,
813 const VECTOR2I& aPlot0ffset, double aScale,
814 const SCH_PLOT_OPTS& aPlotOpts )
815{
816 HPGL_PLOTTER* plotter = new HPGL_PLOTTER();
817 // Currently, plot units are in decimil
818
819 plotter->SetPageSettings( aPageInfo );
820 plotter->SetRenderSettings( aRenderSettings );
822 plotter->SetViewport( aPlot0ffset, schIUScale.IU_PER_MILS/10, aScale, false );
823
824 // TODO this could be configurable
825 plotter->SetTargetChordLength( schIUScale.mmToIU( 0.6 ) );
826
827 switch( aPlotOpts.m_HPGLPlotOrigin )
828 {
829 case HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT:
830 case HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER:
831 default:
832 plotter->SetUserCoords( false );
833 break;
834 case HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE:
835 plotter->SetUserCoords( true );
836 plotter->SetUserCoordsFit( false );
837 break;
838 case HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT:
839 plotter->SetUserCoords( true );
840 plotter->SetUserCoordsFit( true );
841 break;
842 }
843
844 // Init :
845 plotter->SetCreator( wxT( "Eeschema-HPGL" ) );
846
847 if( !plotter->OpenFile( aFileName ) )
848 {
849 delete plotter;
850 return false;
851 }
852
853 LOCALE_IO toggle;
854
855 // Pen num and pen speed are not initialized here.
856 // Default HPGL driver values are used
857 plotter->SetPenDiameter( aPlotOpts.m_HPGLPenSize );
859
860 if( aPlotOpts.m_plotDrawingSheet )
861 {
862 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
863 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
864
865 PlotDrawingSheet( plotter, &m_schematic->Prj(),
866 aScreen->GetTitleBlock(),
867 aPageInfo,
868 aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(),
869 aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(),
870 COLOR4D::BLACK, aScreen->GetVirtualPageNumber() == 1 );
871 }
872
873 aScreen->Plot( plotter, aPlotOpts );
874
875 plotter->EndPlot();
876
877 delete plotter;
878
879 return true;
880}
881
882
884 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
885{
886 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet();
887
888 /* When printing all pages, the printed page is not the current page. In complex hierarchies,
889 * we must update symbol references and other parameters in the given printed SCH_SCREEN,
890 * according to the sheet path because in complex hierarchies a SCH_SCREEN (a drawing ) is
891 * shared between many sheets and symbol references depend on the actual sheet path used.
892 */
893 SCH_SHEET_LIST sheetList;
894
895 if( aPlotOpts.m_plotAll )
896 {
897 sheetList.BuildSheetList( &m_schematic->Root(), true );
898 sheetList.SortByPageNumbers();
899
900 // remove the non-selected pages if we are in plot pages mode
901 if( aPlotOpts.m_plotPages.size() > 0 )
902 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
903 }
904 else
905 {
906 // in Eeschema, this prints the current page
907 sheetList.push_back( m_schematic->CurrentSheet() );
908 }
909
910 for( unsigned i = 0; i < sheetList.size(); i++ )
911 {
912 m_schematic->SetCurrentSheet( sheetList[i] );
915
917 VECTOR2I plot_offset;
918 wxString msg;
919
920 try
921 {
923
924 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
925 // main project folder (or the folder specified by the caller),
926 // so replace separators to create a unique filename:
927 fname.Replace( "/", "_" );
928 fname.Replace( "\\", "_" );
930 wxFileName plotFileName = createPlotFileName( aPlotOpts, fname, ext, aReporter );
931
932 m_lastOutputFilePath = plotFileName.GetFullPath();
933
934 if( !plotFileName.IsOk() )
935 return;
936
937 if( plotOneSheetDXF( plotFileName.GetFullPath(), screen, aRenderSettings, plot_offset,
938 1.0, aPlotOpts ) )
939 {
940 if( aReporter )
941 {
942 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
943 aReporter->Report( msg, RPT_SEVERITY_ACTION );
944 }
945 }
946 else // Error
947 {
948 if( aReporter )
949 {
950 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
951 aReporter->Report( msg, RPT_SEVERITY_ERROR );
952 }
953 }
954 }
955 catch( IO_ERROR& e )
956 {
957 if( aReporter )
958 {
959 msg.Printf( wxT( "DXF Plotter exception: %s" ), e.What() );
960 aReporter->Report( msg, RPT_SEVERITY_ERROR );
961 }
962
963 m_schematic->SetCurrentSheet( oldsheetpath );
966 return;
967 }
968 }
969
970 if( aReporter )
971 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
972
973 restoreEnvironment( nullptr, oldsheetpath );
974}
975
976
977bool SCH_PLOTTER::plotOneSheetDXF( const wxString& aFileName, SCH_SCREEN* aScreen,
978 RENDER_SETTINGS* aRenderSettings, const VECTOR2I& aPlotOffset,
979 double aScale, const SCH_PLOT_OPTS& aPlotOpts )
980{
981 aRenderSettings->LoadColors( m_colorSettings );
982 aRenderSettings->SetDefaultPenWidth( 0 );
983
984 const PAGE_INFO& pageInfo = aScreen->GetPageSettings();
985 DXF_PLOTTER* plotter = new DXF_PLOTTER();
986
987 plotter->SetRenderSettings( aRenderSettings );
988 plotter->SetPageSettings( pageInfo );
989 plotter->SetColorMode( !aPlotOpts.m_blackAndWhite );
990
991 // Currently, plot units are in decimil
992 plotter->SetViewport( aPlotOffset, schIUScale.IU_PER_MILS / 10, aScale, false );
993
994 // Init :
995 plotter->SetCreator( wxT( "Eeschema-DXF" ) );
996
997 if( !plotter->OpenFile( aFileName ) )
998 {
999 delete plotter;
1000 return false;
1001 }
1002
1003 LOCALE_IO toggle;
1004
1006
1007 if( aPlotOpts.m_plotDrawingSheet )
1008 {
1009 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
1010 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
1012
1013 PlotDrawingSheet( plotter, &m_schematic->Prj(),
1014 aScreen->GetTitleBlock(),
1015 pageInfo,
1016 aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(),
1017 aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(),
1018 plotter->GetColorMode() ? color : COLOR4D::BLACK,
1019 aScreen->GetVirtualPageNumber() == 1 );
1020 }
1021
1022 aScreen->Plot( plotter, aPlotOpts );
1023
1024 // finish
1025 plotter->EndPlot();
1026 delete plotter;
1027
1028 return true;
1029}
1030
1031
1033{
1034 if( aPlotter )
1035 {
1036 aPlotter->EndPlot();
1037 delete aPlotter;
1038 }
1039
1040 // Restore the initial sheet
1041 m_schematic->SetCurrentSheet( aOldsheetpath );
1044}
1045
1046
1048 const wxString& aPlotFileName,
1049 const wxString& aExtension, REPORTER* aReporter )
1050{
1051 wxFileName retv;
1052 wxFileName tmp;
1053
1054 tmp.SetPath( aPlotOpts.m_outputDirectory );
1055 retv.SetPath( tmp.GetPath() );
1056
1057 if( !aPlotFileName.IsEmpty() )
1058 retv.SetName( aPlotFileName );
1059 else
1060 retv.SetName( _( "Schematic" ) );
1061
1062 retv.SetExt( aExtension );
1063
1064 if( !EnsureFileDirectoryExists( &tmp, retv.GetFullName(), aReporter ) || !tmp.IsDirWritable() )
1065 {
1066 if( aReporter )
1067 {
1068 wxString msg = wxString::Format( _( "Failed to write plot files to folder '%s'." ),
1069 tmp.GetPath() );
1070 aReporter->Report( msg, RPT_SEVERITY_ERROR );
1071 }
1072
1073 retv.Clear();
1074
1076 settings.m_PlotDirectoryName.Clear();
1077 }
1078 else
1079 {
1080 retv.SetPath( tmp.GetPath() );
1081 }
1082
1083 wxLogTrace( tracePathsAndFiles, "Writing plot file '%s'.", retv.GetFullPath() );
1084
1085 return retv;
1086}
1087
1088
1089void SCH_PLOTTER::Plot( PLOT_FORMAT aPlotFormat, const SCH_PLOT_OPTS& aPlotOpts,
1090 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
1091{
1092 SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
1093
1094 m_colorSettings = settingsMgr.GetColorSettings( aPlotOpts.m_theme );
1095
1096 switch( aPlotFormat )
1097 {
1098 default:
1099 case PLOT_FORMAT::POST: createPSFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1100 case PLOT_FORMAT::DXF: createDXFFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1101 case PLOT_FORMAT::PDF: createPDFFile( aPlotOpts, aRenderSettings, aReporter ); break;
1102 case PLOT_FORMAT::SVG: createSVGFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1103 case PLOT_FORMAT::HPGL: createHPGLFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1104 }
1105}
int color
Definition: DXF_plotter.cpp:60
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:42
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:188
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:121
virtual void ClosePage()
Close the current page in the PDF document (and emit its compressed stream).
virtual bool EndPlot() override
virtual bool OpenFile(const wxString &aFullFilename) override
Open or create the plot file aFullFilename.
virtual bool StartPlot(const wxString &aPageNumber) override
The PDF engine supports multiple pages; the first one is opened 'for free' the following are to be cl...
static wxString GetDefaultFileExtension()
virtual void StartPage(const wxString &aPageNumber, const wxString &aPageName=wxEmptyString, const wxString &aParentPageNumber=wxEmptyString, const wxString &aParentPageName=wxEmptyString)
Start a new page in the PDF document.
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:125
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:159
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:158
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:136
virtual void SetCreator(const wxString &aCreator)
Definition: plotter.h:157
bool GetColorMode() const
Definition: plotter.h:133
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:160
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:64
virtual bool EndPlot() override
Definition: PS_plotter.cpp:877
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:332
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
Definition: PS_plotter.cpp:500
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:727
static wxString GetDefaultFileExtension()
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:73
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:101
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:69
PROJECT & Prj() const
Return a reference to the project this schematic is part of.
Definition: schematic.h:84
void SetCurrentSheet(const SCH_SHEET_PATH &aPath)
Definition: schematic.h:153
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:306
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:202
bool ResolveTextVar(const SCH_SHEET_PATH *aSheetPath, wxString *token, int aDepth) const
Definition: schematic.cpp:247
const std::map< wxString, wxString > * GetProperties()
Definition: schematic.h:87
SCH_SHEET & Root() const
Definition: schematic.h:117
wxString GetUniqueFilenameForCurrentSheet()
Get the unique file name for the current sheet.
Definition: schematic.cpp:640
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
Definition: schematic.cpp:656
SCH_SHEET_PATH & CurrentSheet() const
Definition: schematic.h:148
Schematic editor (Eeschema) main window.
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
Definition: sch_field.cpp:192
void Plot(PLOT_FORMAT aPlotFormat, const SCH_PLOT_OPTS &aPlotOpts, SCH_RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter=nullptr)
Perform the plotting of the schematic using the given aPlotFormat and a\ aPlotSettings.
wxFileName getOutputFilenameSingle(const SCH_PLOT_OPTS &aPlotOpts, REPORTER *aReporter, const wxString &ext)
Return the output filename for formats where the output is a single file.
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:222
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:221
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:220
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:134
const wxString & GetFileName() const
Definition: sch_screen.h:147
SCHEMATIC * Schematic() const
Definition: sch_screen.cpp:102
const TITLE_BLOCK & GetTitleBlock() const
Definition: sch_screen.h:158
void Plot(PLOTTER *aPlotter, const SCH_PLOT_OPTS &aPlotOpts) const
Plot all the schematic objects to aPlotter.
Definition: sch_screen.cpp:859
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void TrimToPageNumbers(const std::vector< wxString > &aPageInclusions)
Truncates the list by removing sheet's with page numbers not in the given list.
void SortByPageNumbers(bool aUpdateVirtualPageNums=true)
Sort the list of sheets by page number.
void SortByHierarchicalPageNumbers(bool aUpdateVirtualPageNums=true)
This works like SortByPageNumbers, but it sorts the sheets first by their hierarchical depth and then...
void BuildSheetList(SCH_SHEET *aSheet, bool aCheckIntegrity)
Build the list of sheets and their sheet path from aSheet.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
wxString 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.
size_t size() const
Forwarded method from std::vector.
void pop_back()
Forwarded method from std::vector.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
Definition: sch_sheet.cpp:369
wxString GetName() const
Definition: sch_sheet.h:113
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieve 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:372
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:484
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:477
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:1071
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
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
VECTOR2I end
wxLogTrace helper definitions.
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695