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