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