KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_plotter.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 1992-2018 Jean-Pierre Charras jp.charras at wanadoo.fr
5 * Copyright (C) 1992-2010 Lorenzo Marcantonio
6 * Copyright (C) 2011 Wayne Stambaugh <[email protected]>
7 * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, you may find one here:
21 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22 * or you may search the http://www.gnu.org website for the version 2 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
27#include <wx/log.h>
28#include <common.h>
29#include <sch_plotter.h>
30#include <locale_io.h>
34
35#include <pgm_base.h>
36#include <trace_helpers.h>
37
38#include <sch_edit_frame.h>
39#include <sch_painter.h>
40#include <schematic.h>
41#include <sch_screen.h>
43
44// Note:
45// We need to switch between sheets to plot a hierarchy and update references and sheet number
46// Use SCHEMATIC::SetCurrentSheet( xxx ) to switch to a sheet.
47// Do not use SCH_EDIT_FRAME::SetCurrentSheet( xxx ) to switch to a sheet, because the new sheet
48// is not displayed, but SCH_EDIT_FRAME::SetCurrentSheet() has side effects to the current VIEW
49// (clear some data used to show the sheet on screen) and does not fully restore the "old" screen
50
51
52static const wxChar* plot_sheet_list( HPGL_PAGE_SIZE aSize )
53{
54 switch( aSize )
55 {
56 default:
57 case HPGL_PAGE_SIZE::DEFAULT: return nullptr;
58 case HPGL_PAGE_SIZE::SIZE_A5: return wxT( "A5" );
59 case HPGL_PAGE_SIZE::SIZE_A4: return wxT( "A4" );
60 case HPGL_PAGE_SIZE::SIZE_A3: return wxT( "A3" );
61 case HPGL_PAGE_SIZE::SIZE_A2: return wxT( "A2" );
62 case HPGL_PAGE_SIZE::SIZE_A1: return wxT( "A1" );
63 case HPGL_PAGE_SIZE::SIZE_A0: return wxT( "A0" );
64 case HPGL_PAGE_SIZE::SIZE_A: return wxT( "A" );
65 case HPGL_PAGE_SIZE::SIZE_B: return wxT( "B" );
66 case HPGL_PAGE_SIZE::SIZE_C: return wxT( "C" );
67 case HPGL_PAGE_SIZE::SIZE_D: return wxT( "D" );
68 case HPGL_PAGE_SIZE::SIZE_E: return wxT( "E" );
69 }
70}
71
72
74 m_schematic( aSchematic )
75{
76 m_colorSettings = nullptr;
77}
78
79
81 m_schematic( &aFrame->Schematic() )
82{
83 m_colorSettings = nullptr;
84}
85
86
88 REPORTER* aReporter, const wxString& aExt )
89{
90 if( !aPlotSettings.m_outputFile.empty() )
91 return aPlotSettings.m_outputFile;
92 else
93 {
95
96 // The sub sheet can be in a sub_hierarchy, but we plot the file in the main
97 // project folder (or the folder specified by the caller), so replace separators
98 // to create a unique filename:
99 fname.Replace( "/", "_" );
100 fname.Replace( "\\", "_" );
101
102 return createPlotFileName( aPlotSettings, fname, aExt, aReporter );
103 }
104
105}
106
107
109 RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
110{
111 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet(); // sheetpath is saved here
112
113 /* When printing all pages, the printed page is not the current page. In complex hierarchies,
114 * we must update symbol references and other parameters in the given printed SCH_SCREEN,
115 * according to the sheet path because in complex hierarchies a SCH_SCREEN (a drawing ) is
116 * shared between many sheets and symbol references depend on the actual sheet path used.
117 */
118 SCH_SHEET_LIST sheetList;
119
120 if( aPlotSettings.m_plotAll || aPlotSettings.m_plotPages.size() > 0 )
121 {
122 sheetList.BuildSheetList( &m_schematic->Root(), true );
123 sheetList.SortByPageNumbers();
124
125 // remove the non-selected pages if we are in plot pages mode
126 if( aPlotSettings.m_plotPages.size() > 0 )
127 sheetList.TrimToPageNumbers( aPlotSettings.m_plotPages );
128 }
129 else
130 {
131 // in eeschema, this prints the current page
132 sheetList.push_back( m_schematic->CurrentSheet() );
133 }
134
135 // Allocate the plotter and set the job level parameter
136 PDF_PLOTTER* plotter = new PDF_PLOTTER();
137 plotter->SetRenderSettings( aRenderSettings );
138 plotter->SetColorMode( !aPlotSettings.m_blackAndWhite );
139 plotter->SetCreator( wxT( "Eeschema-PDF" ) );
141 &m_schematic->Prj() ) );
142
143 wxString msg;
144 wxFileName plotFileName;
145 LOCALE_IO toggle; // Switch the locale to standard C
146
147 for( unsigned i = 0; i < sheetList.size(); i++ )
148 {
149 m_schematic->SetCurrentSheet( sheetList[i] );
152
154 wxString sheetName = sheetList[i].Last()->GetFields()[SHEETNAME].GetShownText( false );
155
156 if( i == 0 )
157 {
158 try
159 {
161 plotFileName = getOutputFilenameSingle( aPlotSettings, aReporter, ext );
162
163 m_lastOutputFilePath = plotFileName.GetFullPath();
164
165 if( !plotFileName.IsOk() )
166 return;
167
168 if( !plotter->OpenFile( plotFileName.GetFullPath() ) )
169 {
170 if( aReporter )
171 {
172 msg.Printf( _( "Failed to create file '%s'." ),
173 plotFileName.GetFullPath() );
174 aReporter->Report( msg, RPT_SEVERITY_ERROR );
175 }
176 delete plotter;
177 return;
178 }
179
180 // Open the plotter and do the first page
181 setupPlotPagePDF( plotter, screen, aPlotSettings );
182
183 plotter->StartPlot( sheetList[i].GetPageNumber(), sheetName );
184 }
185 catch( const IO_ERROR& e )
186 {
187 // Cannot plot PDF file
188 if( aReporter )
189 {
190 msg.Printf( wxT( "PDF Plotter exception: %s" ), e.What() );
191 aReporter->Report( msg, RPT_SEVERITY_ERROR );
192 }
193
194 restoreEnvironment( plotter, oldsheetpath );
195 return;
196 }
197 }
198 else
199 {
200 /* For the following pages you need to close the (finished) page,
201 * reconfigure, and then start a new one */
202 plotter->ClosePage();
203 setupPlotPagePDF( plotter, screen, aPlotSettings );
204 plotter->StartPage( sheetList[i].GetPageNumber(), sheetName );
205 }
206
207 plotOneSheetPDF( plotter, screen, aPlotSettings );
208 }
209
210 // Everything done, close the plot and restore the environment
211 if( aReporter )
212 {
213 msg.Printf( _( "Plotted to '%s'.\n" ), plotFileName.GetFullPath() );
214 aReporter->Report( msg, RPT_SEVERITY_ACTION );
215 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
216 }
217
218 restoreEnvironment( plotter, oldsheetpath );
219}
220
221
223 const SCH_PLOT_SETTINGS& aPlotSettings )
224{
225 if( aPlotSettings.m_useBackgroundColor && aPlotter->GetColorMode() )
226 {
227 aPlotter->SetColor( aPlotter->RenderSettings()->GetBackgroundColor() );
230 aPlotter->Rect( VECTOR2I( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 );
231 }
232
233 if( aPlotSettings.m_plotDrawingSheet )
234 {
235 COLOR4D color = COLOR4D::BLACK;
236
237 if( aPlotter->GetColorMode() )
239
240 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
241 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
242 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
243
244 PlotDrawingSheet( aPlotter, &aScreen->Schematic()->Prj(),
245 aScreen->GetTitleBlock(),
246 actualPage,
247 aScreen->Schematic()->GetProperties(),
248 aScreen->GetPageNumber(), aScreen->GetPageCount(), sheetName, sheetPath,
249 aScreen->GetFileName(), color, aScreen->GetVirtualPageNumber() == 1 );
250 }
251
252 aScreen->Plot( aPlotter, aPlotSettings );
253}
254
255
257 const SCH_PLOT_SETTINGS& aPlotSettings )
258{
259 PAGE_INFO plotPage; // page size selected to plot
260
261 // Considerations on page size and scaling requests
262 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
263
264 switch( aPlotSettings.m_pageSizeSelect )
265 {
266 case PAGE_SIZE_A:
267 plotPage.SetType( wxT( "A" ) );
268 plotPage.SetPortrait( actualPage.IsPortrait() );
269 break;
270
271 case PAGE_SIZE_A4:
272 plotPage.SetType( wxT( "A4" ) );
273 plotPage.SetPortrait( actualPage.IsPortrait() );
274 break;
275
276 case PAGE_SIZE_AUTO:
277 default:
278 plotPage = actualPage;
279 break;
280 }
281
282 double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
283 double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
284 double scale = std::min( scalex, scaley );
285 aPlotter->SetPageSettings( plotPage );
286
287 // Currently, plot units are in decimil
288 aPlotter->SetViewport( VECTOR2I( 0, 0 ), schIUScale.IU_PER_MILS / 10, scale, false );
289}
290
291
293 RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
294{
295 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet(); // sheetpath is saved here
296 PAGE_INFO plotPage; // page size selected to plot
297 wxString msg;
298
299 /* When printing all pages, the printed page is not the current page.
300 * In complex hierarchies, we must update symbol references and other parameters in the
301 * given printed SCH_SCREEN, accordant to the sheet path because in complex hierarchies
302 * a SCH_SCREEN (a drawing ) is shared between many sheets and symbol references
303 * depend on the actual sheet path used.
304 */
305 SCH_SHEET_LIST sheetList;
306
307 if( aPlotSettings.m_plotAll )
308 {
309 sheetList.BuildSheetList( &m_schematic->Root(), true );
310 sheetList.SortByPageNumbers();
311
312 // remove the non-selected pages if we are in plot pages mode
313 if( aPlotSettings.m_plotPages.size() > 0 )
314 {
315 sheetList.TrimToPageNumbers( aPlotSettings.m_plotPages );
316 }
317 }
318 else
319 {
320 sheetList.push_back( m_schematic->CurrentSheet() );
321 }
322
323 for( unsigned i = 0; i < sheetList.size(); i++ )
324 {
325 m_schematic->SetCurrentSheet( sheetList[i] );
328
330 PAGE_INFO actualPage = screen->GetPageSettings();
331
332 switch( aPlotSettings.m_pageSizeSelect )
333 {
334 case PAGE_SIZE_A:
335 plotPage.SetType( wxT( "A" ) );
336 plotPage.SetPortrait( actualPage.IsPortrait() );
337 break;
338
339 case PAGE_SIZE_A4:
340 plotPage.SetType( wxT( "A4" ) );
341 plotPage.SetPortrait( actualPage.IsPortrait() );
342 break;
343
344 case PAGE_SIZE_AUTO:
345 default: plotPage = actualPage; break;
346 }
347
348 double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
349 double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
350 double scale = std::min( scalex, scaley );
351 VECTOR2I plot_offset;
352
353 try
354 {
356
357 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
358 // main project folder (or the folder specified by the caller),
359 // so replace separators to create a unique filename:
360 fname.Replace( "/", "_" );
361 fname.Replace( "\\", "_" );
363 wxFileName plotFileName = createPlotFileName( aPlotSettings, fname, ext, aReporter );
364
365 m_lastOutputFilePath = plotFileName.GetFullPath();
366
367 if( !plotFileName.IsOk() )
368 return;
369
370 if( plotOneSheetPS( plotFileName.GetFullPath(), screen, aRenderSettings, actualPage,
371 plot_offset, scale, aPlotSettings ) )
372 {
373 if( aReporter )
374 {
375 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
376 aReporter->Report( msg, RPT_SEVERITY_ACTION );
377 }
378 }
379 else
380 {
381 if( aReporter )
382 {
383 // Error
384 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
385 aReporter->Report( msg, RPT_SEVERITY_ERROR );
386 }
387 }
388 }
389 catch( IO_ERROR& e )
390 {
391 if( aReporter )
392 {
393 msg.Printf( wxT( "PS Plotter exception: %s" ), e.What() );
394 aReporter->Report( msg, RPT_SEVERITY_ERROR );
395 }
396 }
397 }
398
399 if( aReporter )
400 {
401 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
402 }
403
404 restoreEnvironment( nullptr, oldsheetpath );
405}
406
407
408bool SCH_PLOTTER::plotOneSheetPS( const wxString& aFileName, SCH_SCREEN* aScreen,
409 RENDER_SETTINGS* aRenderSettings,
410 const PAGE_INFO& aPageInfo, const VECTOR2I& aPlot0ffset,
411 double aScale, const SCH_PLOT_SETTINGS& aPlotSettings )
412{
413 PS_PLOTTER* plotter = new PS_PLOTTER();
414 plotter->SetRenderSettings( aRenderSettings );
415 plotter->SetPageSettings( aPageInfo );
416 plotter->SetColorMode( !aPlotSettings.m_blackAndWhite );
417
418 // Currently, plot units are in decimil
419 plotter->SetViewport( aPlot0ffset, schIUScale.IU_PER_MILS / 10, aScale, false );
420
421 // Init :
422 plotter->SetCreator( wxT( "Eeschema-PS" ) );
423
424 if( !plotter->OpenFile( aFileName ) )
425 {
426 delete plotter;
427 return false;
428 }
429
430 LOCALE_IO toggle; // Switch the locale to standard C
431
433
434 if( aPlotSettings.m_useBackgroundColor && plotter->GetColorMode() )
435 {
437
440 plotter->Rect( VECTOR2I( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 );
441 }
442
443 if( aPlotSettings.m_plotDrawingSheet )
444 {
445 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
446 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
448
449 PlotDrawingSheet( plotter, &aScreen->Schematic()->Prj(),
450 aScreen->GetTitleBlock(),
451 aPageInfo, aScreen->Schematic()->GetProperties(),
452 aScreen->GetPageNumber(), aScreen->GetPageCount(), sheetName, sheetPath,
453 aScreen->GetFileName(), plotter->GetColorMode() ? color : COLOR4D::BLACK,
454 aScreen->GetVirtualPageNumber() == 1 );
455 }
456
457 aScreen->Plot( plotter, aPlotSettings );
458
459 plotter->EndPlot();
460 delete plotter;
461
462 return true;
463}
464
465
467 RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
468{
469 wxString msg;
470 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet();
471 SCH_SHEET_LIST sheetList;
472
473 if( aPlotSettings.m_plotAll )
474 {
475 sheetList.BuildSheetList( &m_schematic->Root(), true );
476 sheetList.SortByPageNumbers();
477
478 // remove the non-selected pages if we are in plot pages mode
479 if( aPlotSettings.m_plotPages.size() > 0 )
480 {
481 sheetList.TrimToPageNumbers( aPlotSettings.m_plotPages );
482 }
483 }
484 else
485 {
486 // in eeschema, this prints the current page
487 sheetList.push_back( m_schematic->CurrentSheet() );
488 }
489
490 for( unsigned i = 0; i < sheetList.size(); i++ )
491 {
492 SCH_SCREEN* screen;
493
494 m_schematic->SetCurrentSheet( sheetList[i] );
497
498 screen = m_schematic->CurrentSheet().LastScreen();
499
500 try
501 {
503
504 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
505 // main project folder (or the folder specified by the caller),
506 // so replace separators to create a unique filename:
507 fname.Replace( "/", "_" );
508 fname.Replace( "\\", "_" );
510 wxFileName plotFileName = createPlotFileName( aPlotSettings, fname, ext, aReporter );
511
512 m_lastOutputFilePath = plotFileName.GetFullPath();
513
514 if( !plotFileName.IsOk() )
515 return;
516
517 bool success = plotOneSheetSVG( plotFileName.GetFullPath(), screen, aRenderSettings,
518 aPlotSettings );
519
520 if( !success )
521 {
522 if( aReporter )
523 {
524 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
525 aReporter->Report( msg, RPT_SEVERITY_ERROR );
526 }
527 }
528 else
529 {
530 if( aReporter )
531 {
532 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
533 aReporter->Report( msg, RPT_SEVERITY_ACTION );
534 }
535 }
536 }
537 catch( const IO_ERROR& e )
538 {
539 if( aReporter )
540 {
541 // Cannot plot SVG file
542 msg.Printf( wxT( "SVG Plotter exception: %s" ), e.What() );
543 aReporter->Report( msg, RPT_SEVERITY_ERROR );
544 }
545 break;
546 }
547 }
548
549 if( aReporter )
550 {
551 aReporter->ReportTail( _( "Done" ), RPT_SEVERITY_INFO );
552 }
553
554 restoreEnvironment( nullptr, oldsheetpath );
555}
556
557
558bool SCH_PLOTTER::plotOneSheetSVG( const wxString& aFileName, SCH_SCREEN* aScreen,
559 RENDER_SETTINGS* aRenderSettings,
560 const SCH_PLOT_SETTINGS& aPlotSettings )
561{
562 PAGE_INFO plotPage;
563 // Adjust page size and scaling requests
564 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
565
566 switch( aPlotSettings.m_pageSizeSelect )
567 {
568 case PAGE_SIZE_A:
569 plotPage.SetType( wxT( "A" ) );
570 plotPage.SetPortrait( actualPage.IsPortrait() );
571 break;
572
573 case PAGE_SIZE_A4:
574 plotPage.SetType( wxT( "A4" ) );
575 plotPage.SetPortrait( actualPage.IsPortrait() );
576 break;
577
578 case PAGE_SIZE_AUTO:
579 default:
580 plotPage = actualPage;
581 break;
582 }
583
584 SVG_PLOTTER* plotter = new SVG_PLOTTER();
585 plotter->SetRenderSettings( aRenderSettings );
586 plotter->SetPageSettings( plotPage );
587 plotter->SetColorMode( aPlotSettings.m_blackAndWhite ? false : true );
588 VECTOR2I plot_offset;
589
590 double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
591 double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
592 double scale = std::min( scalex, scaley );
593
594 // Currently, plot units are in decimil
595 plotter->SetViewport( plot_offset, schIUScale.IU_PER_MILS / 10, scale, false );
596
597 // Init :
598 plotter->SetCreator( wxT( "Eeschema-SVG" ) );
599
600 if( !plotter->OpenFile( aFileName ) )
601 {
602 delete plotter;
603 return false;
604 }
605
606 LOCALE_IO toggle;
607
609
610 if( aPlotSettings.m_useBackgroundColor && plotter->GetColorMode() )
611 {
615 plotter->Rect( VECTOR2I( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 );
616 }
617
618 if( aPlotSettings.m_plotDrawingSheet )
619 {
620 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
621 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
623
624 PlotDrawingSheet( plotter, &aScreen->Schematic()->Prj(),
625 aScreen->GetTitleBlock(),
626 actualPage, aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(),
627 aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(),
628 plotter->GetColorMode() ? color : COLOR4D::BLACK,
629 aScreen->GetVirtualPageNumber() == 1 );
630 }
631
632 aScreen->Plot( plotter, aPlotSettings );
633
634 plotter->EndPlot();
635 delete plotter;
636
637 return true;
638}
639
640
642 RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
643{
644 SCH_SCREEN* screen = m_schematic->RootScreen();
645 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet();
646
647 /* When printing all pages, the printed page is not the current page. In complex hierarchies,
648 * we must update symbol references and other parameters in the given printed SCH_SCREEN,
649 * according to the sheet path because in complex hierarchies a SCH_SCREEN (a drawing ) is
650 * shared between many sheets and symbol references depend on the actual sheet path used.
651 */
652 SCH_SHEET_LIST sheetList;
653
654 if( aPlotSettings.m_plotAll )
655 {
656 sheetList.BuildSheetList( &m_schematic->Root(), true );
657 sheetList.SortByPageNumbers();
658
659 // remove the non-selected pages if we are in plot pages mode
660 if( aPlotSettings.m_plotPages.size() > 0 )
661 {
662 sheetList.TrimToPageNumbers( aPlotSettings.m_plotPages );
663 }
664 }
665 else
666 {
667 // in eeschema, this prints the current page
668 sheetList.push_back( m_schematic->CurrentSheet() );
669 }
670
671 for( unsigned i = 0; i < sheetList.size(); i++ )
672 {
673 m_schematic->SetCurrentSheet( sheetList[i] );
676
677 screen = m_schematic->CurrentSheet().LastScreen();
678
679 if( !screen ) // LastScreen() may return NULL
680 screen = m_schematic->RootScreen();
681
682 const PAGE_INFO& curPage = screen->GetPageSettings();
683
684 PAGE_INFO plotPage = curPage;
685
686 // if plotting on a page size other than curPage
687 plotPage.SetType( plot_sheet_list( aPlotSettings.m_HPGLPaperSizeSelect ) );
688
689 // Calculation of conversion scales.
690 double plot_scale = (double) plotPage.GetWidthMils() / curPage.GetWidthMils();
691
692 // Calculate offsets
693 VECTOR2I plotOffset;
694 wxString msg;
695
696 if( aPlotSettings.m_HPGLPlotOrigin == HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER )
697 {
698 plotOffset.x = plotPage.GetWidthIU( schIUScale.IU_PER_MILS ) / 2;
699 plotOffset.y = -plotPage.GetHeightIU( schIUScale.IU_PER_MILS ) / 2;
700 }
701
702 try
703 {
705 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
706 // main project folder (or the folder specified by the caller),
707 // so replace separators to create a unique filename:
708 fname.Replace( "/", "_" );
709 fname.Replace( "\\", "_" );
711 wxFileName plotFileName = createPlotFileName( aPlotSettings, fname, ext, aReporter );
712
713 if( !plotFileName.IsOk() )
714 return;
715
716 LOCALE_IO toggle;
717
718 if( plotOneSheetHpgl( plotFileName.GetFullPath(), screen, curPage, aRenderSettings,
719 plotOffset, plot_scale, aPlotSettings ) )
720 {
721 if( aReporter )
722 {
723 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
724 aReporter->Report( msg, RPT_SEVERITY_ACTION );
725 }
726 }
727 else
728 {
729 if( aReporter )
730 {
731 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
732 aReporter->Report( msg, RPT_SEVERITY_ERROR );
733 }
734 }
735 }
736 catch( IO_ERROR& e )
737 {
738 if( aReporter )
739 {
740 msg.Printf( wxT( "HPGL Plotter exception: %s" ), e.What() );
741 aReporter->Report( msg, RPT_SEVERITY_ERROR );
742 }
743 }
744 }
745
746 if( aReporter )
747 {
748 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
749 }
750
751 restoreEnvironment( nullptr, oldsheetpath );
752}
753
754
755bool SCH_PLOTTER::plotOneSheetHpgl( const wxString& aFileName,
756 SCH_SCREEN* aScreen,
757 const PAGE_INFO& aPageInfo,
758 RENDER_SETTINGS* aRenderSettings,
759 const VECTOR2I& aPlot0ffset,
760 double aScale,
761 const SCH_PLOT_SETTINGS& aPlotSettings )
762{
763 HPGL_PLOTTER* plotter = new HPGL_PLOTTER();
764 // Currently, plot units are in decimil
765
766 plotter->SetPageSettings( aPageInfo );
767 plotter->SetRenderSettings( aRenderSettings );
769 plotter->SetColorMode( !aPlotSettings.m_blackAndWhite );
770 plotter->SetViewport( aPlot0ffset, schIUScale.IU_PER_MILS/10, aScale, false );
771
772 // TODO this could be configurable
773 plotter->SetTargetChordLength( schIUScale.mmToIU( 0.6 ) );
774
775 switch( aPlotSettings.m_HPGLPlotOrigin )
776 {
777 case HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT:
778 case HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER:
779 default:
780 plotter->SetUserCoords( false );
781 break;
782 case HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE:
783 plotter->SetUserCoords( true );
784 plotter->SetUserCoordsFit( false );
785 break;
786 case HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT:
787 plotter->SetUserCoords( true );
788 plotter->SetUserCoordsFit( true );
789 break;
790 }
791
792 // Init :
793 plotter->SetCreator( wxT( "Eeschema-HPGL" ) );
794
795 if( !plotter->OpenFile( aFileName ) )
796 {
797 delete plotter;
798 return false;
799 }
800
801 LOCALE_IO toggle;
802
803 // Pen num and pen speed are not initialized here.
804 // Default HPGL driver values are used
805 plotter->SetPenDiameter( aPlotSettings.m_HPGLPenSize );
807
808 if( aPlotSettings.m_plotDrawingSheet )
809 {
810 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
811 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
812
813 PlotDrawingSheet( plotter, &m_schematic->Prj(),
814 aScreen->GetTitleBlock(),
815 aPageInfo,
816 aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(),
817 aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(),
818 COLOR4D::BLACK, aScreen->GetVirtualPageNumber() == 1 );
819 }
820
821 aScreen->Plot( plotter, aPlotSettings );
822
823 plotter->EndPlot();
824
825 delete plotter;
826
827 return true;
828}
829
830
832 RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
833{
834 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet();
835
836 /* When printing all pages, the printed page is not the current page. In complex hierarchies,
837 * we must update symbol references and other parameters in the given printed SCH_SCREEN,
838 * according to the sheet path because in complex hierarchies a SCH_SCREEN (a drawing ) is
839 * shared between many sheets and symbol references depend on the actual sheet path used.
840 */
841 SCH_SHEET_LIST sheetList;
842
843 if( aPlotSettings.m_plotAll )
844 {
845 sheetList.BuildSheetList( &m_schematic->Root(), true );
846 sheetList.SortByPageNumbers();
847
848 // remove the non-selected pages if we are in plot pages mode
849 if( aPlotSettings.m_plotPages.size() > 0 )
850 {
851 sheetList.TrimToPageNumbers( aPlotSettings.m_plotPages );
852 }
853 }
854 else
855 {
856 // in eeschema, this prints the current page
857 sheetList.push_back( m_schematic->CurrentSheet() );
858 }
859
860 for( unsigned i = 0; i < sheetList.size(); i++ )
861 {
862 m_schematic->SetCurrentSheet( sheetList[i] );
865
867 VECTOR2I plot_offset;
868 wxString msg;
869
870 try
871 {
873
874 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
875 // main project folder (or the folder specified by the caller),
876 // so replace separators to create a unique filename:
877 fname.Replace( "/", "_" );
878 fname.Replace( "\\", "_" );
880 wxFileName plotFileName = createPlotFileName( aPlotSettings, fname, ext, aReporter );
881
882 m_lastOutputFilePath = plotFileName.GetFullPath();
883
884 if( !plotFileName.IsOk() )
885 return;
886
887 if( plotOneSheetDXF( plotFileName.GetFullPath(), screen, aRenderSettings, plot_offset,
888 1.0, aPlotSettings ) )
889 {
890 if( aReporter )
891 {
892 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
893 aReporter->Report( msg, RPT_SEVERITY_ACTION );
894 }
895 }
896 else // Error
897 {
898 if( aReporter )
899 {
900 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
901 aReporter->Report( msg, RPT_SEVERITY_ERROR );
902 }
903 }
904 }
905 catch( IO_ERROR& e )
906 {
907 if( aReporter )
908 {
909 msg.Printf( wxT( "DXF Plotter exception: %s" ), e.What() );
910 aReporter->Report( msg, RPT_SEVERITY_ERROR );
911 }
912
913 m_schematic->SetCurrentSheet( oldsheetpath );
916 return;
917 }
918 }
919
920 if( aReporter )
921 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
922
923 restoreEnvironment( nullptr, oldsheetpath );
924}
925
926
927bool SCH_PLOTTER::plotOneSheetDXF( const wxString& aFileName, SCH_SCREEN* aScreen,
928 RENDER_SETTINGS* aRenderSettings, const VECTOR2I& aPlotOffset,
929 double aScale, const SCH_PLOT_SETTINGS& aPlotSettings )
930{
931 aRenderSettings->LoadColors( m_colorSettings );
932 aRenderSettings->SetDefaultPenWidth( 0 );
933
934 const PAGE_INFO& pageInfo = aScreen->GetPageSettings();
935 DXF_PLOTTER* plotter = new DXF_PLOTTER();
936
937 plotter->SetRenderSettings( aRenderSettings );
938 plotter->SetPageSettings( pageInfo );
939 plotter->SetColorMode( !aPlotSettings.m_blackAndWhite );
940
941 // Currently, plot units are in decimil
942 plotter->SetViewport( aPlotOffset, schIUScale.IU_PER_MILS / 10, aScale, false );
943
944 // Init :
945 plotter->SetCreator( wxT( "Eeschema-DXF" ) );
946
947 if( !plotter->OpenFile( aFileName ) )
948 {
949 delete plotter;
950 return false;
951 }
952
953 LOCALE_IO toggle;
954
956
957 if( aPlotSettings.m_plotDrawingSheet )
958 {
959 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
960 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
962
963 PlotDrawingSheet( plotter, &m_schematic->Prj(),
964 aScreen->GetTitleBlock(),
965 pageInfo,
966 aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(),
967 aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(),
968 plotter->GetColorMode() ? color : COLOR4D::BLACK,
969 aScreen->GetVirtualPageNumber() == 1 );
970 }
971
972 aScreen->Plot( plotter, aPlotSettings );
973
974 // finish
975 plotter->EndPlot();
976 delete plotter;
977
978 return true;
979}
980
981
983{
984 if( aPlotter )
985 {
986 aPlotter->EndPlot();
987 delete aPlotter;
988 }
989
990 // Restore the initial sheet
991 m_schematic->SetCurrentSheet( aOldsheetpath );
994}
995
996
997wxFileName SCH_PLOTTER::createPlotFileName( const SCH_PLOT_SETTINGS& aPlotSettings,
998 const wxString& aPlotFileName,
999 const wxString& aExtension, REPORTER* aReporter )
1000{
1001 wxFileName retv;
1002 wxFileName tmp;
1003
1004 tmp.SetPath( aPlotSettings.m_outputDirectory );
1005 retv.SetPath( tmp.GetPath() );
1006
1007 if( !aPlotFileName.IsEmpty() )
1008 retv.SetName( aPlotFileName );
1009 else
1010 retv.SetName( _( "Schematic" ) );
1011
1012 retv.SetExt( aExtension );
1013
1014 if( !EnsureFileDirectoryExists( &tmp, retv.GetFullName(), aReporter ) || !tmp.IsDirWritable() )
1015 {
1016 if( aReporter )
1017 {
1018 wxString msg = wxString::Format( _( "Failed to write plot files to folder '%s'." ),
1019 tmp.GetPath() );
1020 aReporter->Report( msg, RPT_SEVERITY_ERROR );
1021 }
1022 retv.Clear();
1023
1025 settings.m_PlotDirectoryName.Clear();
1026 }
1027 else
1028 {
1029 retv.SetPath( tmp.GetPath() );
1030 }
1031
1032 wxLogTrace( tracePathsAndFiles, "Writing plot file '%s'.", retv.GetFullPath() );
1033
1034 return retv;
1035}
1036
1037
1038void SCH_PLOTTER::Plot( PLOT_FORMAT aPlotFormat, const SCH_PLOT_SETTINGS& aPlotSettings,
1039 RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
1040{
1041 SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
1042
1043 m_colorSettings = settingsMgr.GetColorSettings( aPlotSettings.m_theme );
1044
1045 switch( aPlotFormat )
1046 {
1047 default:
1048 case PLOT_FORMAT::POST: createPSFiles( aPlotSettings, aRenderSettings, aReporter ); break;
1049 case PLOT_FORMAT::DXF: createDXFFiles( aPlotSettings, aRenderSettings, aReporter ); break;
1050 case PLOT_FORMAT::PDF: createPDFFile( aPlotSettings, aRenderSettings, aReporter ); break;
1051 case PLOT_FORMAT::SVG: createSVGFiles( aPlotSettings, aRenderSettings, aReporter ); break;
1052 case PLOT_FORMAT::HPGL: createHPGLFiles( aPlotSettings, aRenderSettings, aReporter ); break;
1053 }
1054}
int color
Definition: DXF_plotter.cpp:58
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
int GetPageCount() const
Definition: base_screen.h:72
int GetVirtualPageNumber() const
Definition: base_screen.h:75
const wxString & GetPageNumber() const
Definition: base_screen.cpp:71
static wxString GetDefaultFileExtension()
Definition: plotter_dxf.h:41
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the scale/position for the DXF plot.
virtual bool StartPlot(const wxString &aPageNumber) override
Open the DXF plot with a skeleton header.
virtual bool EndPlot() override
void SetUserCoordsFit(bool user_coords_fit)
Set whether the user coordinate system is fit to content.
Definition: plotter_hpgl.h:59
void SetTargetChordLength(double chord_len)
Set the target length of chords used to draw approximated circles and arcs.
static wxString GetDefaultFileExtension()
Definition: plotter_hpgl.h:43
void SetUserCoords(bool user_coords)
Switch to the user coordinate system.
Definition: plotter_hpgl.h:56
virtual bool StartPlot(const wxString &aPageNumber) override
At the start of the HPGL plot pen speed and number are requested.
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
virtual void SetPenDiameter(double diameter)
virtual bool EndPlot() override
HPGL end of plot: sort and emit graphics, pen return and release.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:77
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
void SetDefaultPenWidth(int aWidth)
virtual void LoadColors(const COLOR_SETTINGS *aSettings)
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
virtual const COLOR4D & GetBackgroundColor() const =0
Return current background color settings.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:49
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:58
void SetPortrait(bool aIsPortrait)
Rotate the paper page 90 degrees.
Definition: page_info.cpp:189
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
Definition: page_info.h:161
double GetHeightMils() const
Definition: page_info.h:140
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
Definition: page_info.h:152
double GetWidthMils() const
Definition: page_info.h:135
bool IsPortrait() const
Definition: page_info.h:121
bool SetType(const wxString &aStandardPageDescriptionName, bool aIsPortrait=false)
Set the name of the page type and also the sizes and margins commonly associated with that type name.
Definition: page_info.cpp:122
virtual void StartPage(const wxString &aPageNumber, const wxString &aPageName=wxEmptyString)
Start a new page in the PDF document.
virtual void ClosePage()
Close the current page in the PDF document (and emit its compressed stream).
virtual bool EndPlot() override
virtual bool OpenFile(const wxString &aFullFilename) override
Open or create the plot file aFullFilename.
virtual bool StartPlot(const wxString &aPageNumber) override
The PDF engine supports multiple pages; the first one is opened 'for free' the following are to be cl...
static wxString GetDefaultFileExtension()
Base plotter engine class.
Definition: plotter.h:104
virtual bool OpenFile(const wxString &aFullFilename)
Open or create the plot file aFullFilename.
Definition: plotter.cpp:74
virtual void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: plotter.h:137
void SetRenderSettings(RENDER_SETTINGS *aSettings)
Definition: plotter.h:134
virtual void SetTitle(const wxString &aTitle)
Definition: plotter.h:155
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:135
virtual void SetCreator(const wxString &aCreator)
Definition: plotter.h:153
bool GetColorMode() const
Definition: plotter.h:132
PAGE_INFO & PageSettings()
Definition: plotter.h:138
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror)=0
Set the plot offset and scaling for the current plot.
virtual void SetColorMode(bool aColorMode)
Plot in B/W or color.
Definition: plotter.h:131
virtual void 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:887
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:497
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:726
static wxString GetDefaultFileExtension()
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:71
virtual REPORTER & ReportTail(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Places the report at the end of the list, for objects that support report ordering.
Definition: reporter.h:99
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
These settings were stored in SCH_BASE_FRAME previously.
Holds all the data relating to one schematic.
Definition: schematic.h:75
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:136
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:287
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
Definition: schematic.h:141
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:197
const std::map< wxString, wxString > * GetProperties()
Definition: schematic.h:93
SCH_SHEET & Root() const
Definition: schematic.h:105
wxString GetUniqueFilenameForCurrentSheet()
Definition: schematic.cpp:607
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
Definition: schematic.cpp:623
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:90
Schematic editor (Eeschema) main window.
void createSVGFiles(const SCH_PLOT_SETTINGS &aPlotSettings, RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
void createDXFFiles(const SCH_PLOT_SETTINGS &aPlotSettings, RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
void createPSFiles(const SCH_PLOT_SETTINGS &aPlotSettings, RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
wxFileName getOutputFilenameSingle(const SCH_PLOT_SETTINGS &aPlotSettings, REPORTER *aReporter, const wxString &ext)
Returns the output filename for formats where the output is a single file.
Definition: sch_plotter.cpp:87
wxFileName createPlotFileName(const SCH_PLOT_SETTINGS &aPlotSettings, const wxString &aPlotFileName, const wxString &aExtension, REPORTER *aReporter=nullptr)
Create a file name with an absolute path name.
bool plotOneSheetHpgl(const wxString &aFileName, SCH_SCREEN *aScreen, const PAGE_INFO &aPageInfo, RENDER_SETTINGS *aRenderSettings, const VECTOR2I &aPlot0ffset, double aScale, const SCH_PLOT_SETTINGS &aPlotSettings)
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_SETTINGS &aPlotSettings)
bool plotOneSheetSVG(const wxString &aFileName, SCH_SCREEN *aScreen, RENDER_SETTINGS *aRenderSettings, const SCH_PLOT_SETTINGS &aPlotSettings)
void Plot(PLOT_FORMAT aPlotFormat, const SCH_PLOT_SETTINGS &aPlotSettings, RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter=nullptr)
Perform the plotting of the schematic using the given aPlotFormat and aPlotSettings.
wxString m_lastOutputFilePath
Definition: sch_plotter.h:220
void restoreEnvironment(PDF_PLOTTER *aPlotter, SCH_SHEET_PATH &aOldsheetpath)
Everything done, close the plot and restore the environment.
void setupPlotPagePDF(PLOTTER *aPlotter, SCH_SCREEN *aScreen, const SCH_PLOT_SETTINGS &aPlotSettings)
bool plotOneSheetPS(const wxString &aFileName, SCH_SCREEN *aScreen, RENDER_SETTINGS *aRenderSettings, const PAGE_INFO &aPageInfo, const VECTOR2I &aPlot0ffset, double aScale, const SCH_PLOT_SETTINGS &aPlotSettings)
COLOR_SETTINGS * m_colorSettings
Definition: sch_plotter.h:219
void createPDFFile(const SCH_PLOT_SETTINGS &aPlotSettings, RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
void plotOneSheetPDF(PLOTTER *aPlotter, SCH_SCREEN *aScreen, const SCH_PLOT_SETTINGS &aPlotSettings)
SCHEMATIC * m_schematic
Definition: sch_plotter.h:218
void createHPGLFiles(const SCH_PLOT_SETTINGS &aPlotSettings, RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:131
const wxString & GetFileName() const
Definition: sch_screen.h:144
SCHEMATIC * Schematic() const
Definition: sch_screen.cpp:97
void Plot(PLOTTER *aPlotter, const SCH_PLOT_SETTINGS &aPlotSettings) const
Plot all the schematic objects to aPlotter.
const TITLE_BLOCK & GetTitleBlock() const
Definition: sch_screen.h:155
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void TrimToPageNumbers(const std::vector< wxString > &aPageInclusions)
Truncates the list by removing sheet's with page numbers not in the given list.
void SortByPageNumbers(bool aUpdateVirtualPageNums=true)
Sort the list of sheets by page number.
void BuildSheetList(SCH_SHEET *aSheet, bool aCheckIntegrity)
Build the list of sheets and their sheet path from aSheet.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false) const
Return the sheet path in a human readable form made from the sheet names.
void UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
SCH_SCREEN * LastScreen()
wxString GetPageNumber() const
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
wxString GetName() const
Definition: sch_sheet.h:107
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
virtual bool StartPlot(const wxString &aPageNumber) override
Create SVG file header.
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
virtual bool EndPlot() override
static wxString GetDefaultFileExtension()
const wxString & GetTitle() const
Definition: title_block.h:63
bool EnsureFileDirectoryExists(wxFileName *aTargetFullFileName, const wxString &aBaseFilename, REPORTER *aReporter)
Make aTargetFullFileName absolute and create the path of this file if it doesn't yet exist.
Definition: common.cpp:345
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
Definition: common.cpp:58
The common library.
void PlotDrawingSheet(PLOTTER *plotter, const PROJECT *aProject, const TITLE_BLOCK &aTitleBlock, const PAGE_INFO &aPageInfo, const std::map< wxString, wxString > *aProperties, const wxString &aSheetNumber, int aSheetCount, const wxString &aSheetName, const wxString &aSheetPath, const wxString &aFilename, COLOR4D aColor, bool aIsFirstPage)
#define _(s)
const wxChar *const tracePathsAndFiles
Flag to enable path and file name debug output.
@ LAYER_SCHEMATIC_DRAWINGSHEET
Definition: layer_ids.h:388
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:382
see class PGM_BASE
PLOT_FORMAT
The set of supported output plot formats.
Definition: plotter.h:64
Plotting engine (HPGL)
Plotting engines similar to ps (PostScript, Gerber, svg)
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_INFO
@ RPT_SEVERITY_ACTION
static const wxChar * plot_sheet_list(HPGL_PAGE_SIZE aSize)
Definition: sch_plotter.cpp:52
@ PAGE_SIZE_AUTO
Definition: sch_plotter.h:56
@ PAGE_SIZE_A
Definition: sch_plotter.h:58
@ PAGE_SIZE_A4
Definition: sch_plotter.h:57
HPGL_PAGE_SIZE
Definition: sch_plotter.h:63
@ SHEETNAME
Definition: sch_sheet.h:45
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:119
const int scale
const double IU_PER_MILS
Definition: base_units.h:78
constexpr int mmToIU(double mm) const
Definition: base_units.h:89
double m_HPGLPenSize
Definition: sch_plotter.h:88
wxString m_theme
Definition: sch_plotter.h:91
HPGL_PAGE_SIZE m_HPGLPaperSizeSelect
Definition: sch_plotter.h:89
HPGL_PLOT_ORIGIN_AND_UNITS m_HPGLPlotOrigin
Definition: sch_plotter.h:96
bool m_useBackgroundColor
Definition: sch_plotter.h:87
std::vector< wxString > m_plotPages
Definition: sch_plotter.h:83
wxString m_outputDirectory
Definition: sch_plotter.h:93
wxString m_outputFile
Definition: sch_plotter.h:94
wxLogTrace helper definitions.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588