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
256 VECTOR2I end( actualPage.GetWidthIU( schIUScale.IU_PER_MILS ),
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
469 VECTOR2I end( actualPage.GetWidthIU( schIUScale.IU_PER_MILS ),
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 // Adjust page size and scaling requests
596 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
597
598 switch( aPlotOpts.m_pageSizeSelect )
599 {
600 case PAGE_SIZE_A:
601 plotPage.SetType( wxT( "A" ) );
602 plotPage.SetPortrait( actualPage.IsPortrait() );
603 break;
604
605 case PAGE_SIZE_A4:
606 plotPage.SetType( wxT( "A4" ) );
607 plotPage.SetPortrait( actualPage.IsPortrait() );
608 break;
609
610 case PAGE_SIZE_AUTO:
611 default:
612 plotPage = actualPage;
613 break;
614 }
615
616 SVG_PLOTTER* plotter = new SVG_PLOTTER();
617 plotter->SetRenderSettings( aRenderSettings );
618 plotter->SetPageSettings( plotPage );
619 plotter->SetColorMode( aPlotOpts.m_blackAndWhite ? false : true );
620 VECTOR2I plot_offset;
621
622 double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
623 double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
624 double scale = std::min( scalex, scaley );
625
626 // Currently, plot units are in decimil
627 plotter->SetViewport( plot_offset, schIUScale.IU_PER_MILS / 10, scale, false );
628
629 // Init :
630 plotter->SetCreator( wxT( "Eeschema-SVG" ) );
631
632 if( !plotter->OpenFile( aFileName ) )
633 {
634 delete plotter;
635 return false;
636 }
637
638 LOCALE_IO toggle;
639
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 );
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 PlotDrawingSheet( plotter, &aScreen->Schematic()->Prj(),
660 aScreen->GetTitleBlock(),
661 actualPage, aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(),
662 aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(),
663 plotter->GetColorMode() ? color : COLOR4D::BLACK,
664 aScreen->GetVirtualPageNumber() == 1 );
665 }
666
667 aScreen->Plot( plotter, aPlotOpts );
668
669 plotter->EndPlot();
670 delete plotter;
671
672 return true;
673}
674
675
677 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
678{
679 SCH_SCREEN* screen = m_schematic->RootScreen();
680 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet();
681
682 /* When printing all pages, the printed page is not the current page. In complex hierarchies,
683 * we must update symbol references and other parameters in the given printed SCH_SCREEN,
684 * according to the sheet path because in complex hierarchies a SCH_SCREEN (a drawing ) is
685 * shared between many sheets and symbol references depend on the actual sheet path used.
686 */
687 SCH_SHEET_LIST sheetList;
688
689 if( aPlotOpts.m_plotAll )
690 {
691 sheetList.BuildSheetList( &m_schematic->Root(), true );
692 sheetList.SortByPageNumbers();
693
694 // remove the non-selected pages if we are in plot pages mode
695 if( aPlotOpts.m_plotPages.size() > 0 )
696 {
697 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
698 }
699 }
700 else
701 {
702 // in eeschema, this prints the current page
703 sheetList.push_back( m_schematic->CurrentSheet() );
704 }
705
706 for( unsigned i = 0; i < sheetList.size(); i++ )
707 {
708 m_schematic->SetCurrentSheet( sheetList[i] );
711
712 screen = m_schematic->CurrentSheet().LastScreen();
713
714 if( !screen ) // LastScreen() may return NULL
715 screen = m_schematic->RootScreen();
716
717 const PAGE_INFO& curPage = screen->GetPageSettings();
718
719 PAGE_INFO plotPage = curPage;
720
721 // if plotting on a page size other than curPage
722 plotPage.SetType( plot_sheet_list( aPlotOpts.m_HPGLPaperSizeSelect ) );
723
724 // Calculation of conversion scales.
725 double plot_scale = (double) plotPage.GetWidthMils() / curPage.GetWidthMils();
726
727 // Calculate offsets
728 VECTOR2I plotOffset;
729 wxString msg;
730
731 if( aPlotOpts.m_HPGLPlotOrigin == HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER )
732 {
733 plotOffset.x = plotPage.GetWidthIU( schIUScale.IU_PER_MILS ) / 2;
734 plotOffset.y = -plotPage.GetHeightIU( schIUScale.IU_PER_MILS ) / 2;
735 }
736
737 try
738 {
740 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
741 // main project folder (or the folder specified by the caller),
742 // so replace separators to create a unique filename:
743 fname.Replace( "/", "_" );
744 fname.Replace( "\\", "_" );
746 wxFileName plotFileName = createPlotFileName( aPlotOpts, fname, ext, aReporter );
747
748 if( !plotFileName.IsOk() )
749 return;
750
751 LOCALE_IO toggle;
752
753 if( plotOneSheetHpgl( plotFileName.GetFullPath(), screen, curPage, aRenderSettings,
754 plotOffset, plot_scale, aPlotOpts ) )
755 {
756 if( aReporter )
757 {
758 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
759 aReporter->Report( msg, RPT_SEVERITY_ACTION );
760 }
761 }
762 else
763 {
764 if( aReporter )
765 {
766 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
767 aReporter->Report( msg, RPT_SEVERITY_ERROR );
768 }
769 }
770 }
771 catch( IO_ERROR& e )
772 {
773 if( aReporter )
774 {
775 msg.Printf( wxT( "HPGL Plotter exception: %s" ), e.What() );
776 aReporter->Report( msg, RPT_SEVERITY_ERROR );
777 }
778 }
779 }
780
781 if( aReporter )
782 {
783 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
784 }
785
786 restoreEnvironment( nullptr, oldsheetpath );
787}
788
789
790bool SCH_PLOTTER::plotOneSheetHpgl( const wxString& aFileName, SCH_SCREEN* aScreen,
791 const PAGE_INFO& aPageInfo, RENDER_SETTINGS* aRenderSettings,
792 const VECTOR2I& aPlot0ffset, double aScale,
793 const SCH_PLOT_OPTS& aPlotOpts )
794{
795 HPGL_PLOTTER* plotter = new HPGL_PLOTTER();
796 // Currently, plot units are in decimil
797
798 plotter->SetPageSettings( aPageInfo );
799 plotter->SetRenderSettings( aRenderSettings );
801 plotter->SetViewport( aPlot0ffset, schIUScale.IU_PER_MILS/10, aScale, false );
802
803 // TODO this could be configurable
804 plotter->SetTargetChordLength( schIUScale.mmToIU( 0.6 ) );
805
806 switch( aPlotOpts.m_HPGLPlotOrigin )
807 {
808 case HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT:
809 case HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER:
810 default:
811 plotter->SetUserCoords( false );
812 break;
813 case HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE:
814 plotter->SetUserCoords( true );
815 plotter->SetUserCoordsFit( false );
816 break;
817 case HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT:
818 plotter->SetUserCoords( true );
819 plotter->SetUserCoordsFit( true );
820 break;
821 }
822
823 // Init :
824 plotter->SetCreator( wxT( "Eeschema-HPGL" ) );
825
826 if( !plotter->OpenFile( aFileName ) )
827 {
828 delete plotter;
829 return false;
830 }
831
832 LOCALE_IO toggle;
833
834 // Pen num and pen speed are not initialized here.
835 // Default HPGL driver values are used
836 plotter->SetPenDiameter( aPlotOpts.m_HPGLPenSize );
838
839 if( aPlotOpts.m_plotDrawingSheet )
840 {
841 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
842 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
843
844 PlotDrawingSheet( plotter, &m_schematic->Prj(),
845 aScreen->GetTitleBlock(),
846 aPageInfo,
847 aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(),
848 aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(),
849 COLOR4D::BLACK, aScreen->GetVirtualPageNumber() == 1 );
850 }
851
852 aScreen->Plot( plotter, aPlotOpts );
853
854 plotter->EndPlot();
855
856 delete plotter;
857
858 return true;
859}
860
861
863 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
864{
865 SCH_SHEET_PATH oldsheetpath = m_schematic->CurrentSheet();
866
867 /* When printing all pages, the printed page is not the current page. In complex hierarchies,
868 * we must update symbol references and other parameters in the given printed SCH_SCREEN,
869 * according to the sheet path because in complex hierarchies a SCH_SCREEN (a drawing ) is
870 * shared between many sheets and symbol references depend on the actual sheet path used.
871 */
872 SCH_SHEET_LIST sheetList;
873
874 if( aPlotOpts.m_plotAll )
875 {
876 sheetList.BuildSheetList( &m_schematic->Root(), true );
877 sheetList.SortByPageNumbers();
878
879 // remove the non-selected pages if we are in plot pages mode
880 if( aPlotOpts.m_plotPages.size() > 0 )
881 sheetList.TrimToPageNumbers( aPlotOpts.m_plotPages );
882 }
883 else
884 {
885 // in eeschema, this prints the current page
886 sheetList.push_back( m_schematic->CurrentSheet() );
887 }
888
889 for( unsigned i = 0; i < sheetList.size(); i++ )
890 {
891 m_schematic->SetCurrentSheet( sheetList[i] );
894
896 VECTOR2I plot_offset;
897 wxString msg;
898
899 try
900 {
902
903 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
904 // main project folder (or the folder specified by the caller),
905 // so replace separators to create a unique filename:
906 fname.Replace( "/", "_" );
907 fname.Replace( "\\", "_" );
909 wxFileName plotFileName = createPlotFileName( aPlotOpts, fname, ext, aReporter );
910
911 m_lastOutputFilePath = plotFileName.GetFullPath();
912
913 if( !plotFileName.IsOk() )
914 return;
915
916 if( plotOneSheetDXF( plotFileName.GetFullPath(), screen, aRenderSettings, plot_offset,
917 1.0, aPlotOpts ) )
918 {
919 if( aReporter )
920 {
921 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
922 aReporter->Report( msg, RPT_SEVERITY_ACTION );
923 }
924 }
925 else // Error
926 {
927 if( aReporter )
928 {
929 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
930 aReporter->Report( msg, RPT_SEVERITY_ERROR );
931 }
932 }
933 }
934 catch( IO_ERROR& e )
935 {
936 if( aReporter )
937 {
938 msg.Printf( wxT( "DXF Plotter exception: %s" ), e.What() );
939 aReporter->Report( msg, RPT_SEVERITY_ERROR );
940 }
941
942 m_schematic->SetCurrentSheet( oldsheetpath );
945 return;
946 }
947 }
948
949 if( aReporter )
950 aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
951
952 restoreEnvironment( nullptr, oldsheetpath );
953}
954
955
956bool SCH_PLOTTER::plotOneSheetDXF( const wxString& aFileName, SCH_SCREEN* aScreen,
957 RENDER_SETTINGS* aRenderSettings, const VECTOR2I& aPlotOffset,
958 double aScale, const SCH_PLOT_OPTS& aPlotOpts )
959{
960 aRenderSettings->LoadColors( m_colorSettings );
961 aRenderSettings->SetDefaultPenWidth( 0 );
962
963 const PAGE_INFO& pageInfo = aScreen->GetPageSettings();
964 DXF_PLOTTER* plotter = new DXF_PLOTTER();
965
966 plotter->SetRenderSettings( aRenderSettings );
967 plotter->SetPageSettings( pageInfo );
968 plotter->SetColorMode( !aPlotOpts.m_blackAndWhite );
969
970 // Currently, plot units are in decimil
971 plotter->SetViewport( aPlotOffset, schIUScale.IU_PER_MILS / 10, aScale, false );
972
973 // Init :
974 plotter->SetCreator( wxT( "Eeschema-DXF" ) );
975
976 if( !plotter->OpenFile( aFileName ) )
977 {
978 delete plotter;
979 return false;
980 }
981
982 LOCALE_IO toggle;
983
985
986 if( aPlotOpts.m_plotDrawingSheet )
987 {
988 wxString sheetName = m_schematic->CurrentSheet().Last()->GetName();
989 wxString sheetPath = m_schematic->CurrentSheet().PathHumanReadable();
991
992 PlotDrawingSheet( plotter, &m_schematic->Prj(),
993 aScreen->GetTitleBlock(),
994 pageInfo,
995 aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(),
996 aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(),
997 plotter->GetColorMode() ? color : COLOR4D::BLACK,
998 aScreen->GetVirtualPageNumber() == 1 );
999 }
1000
1001 aScreen->Plot( plotter, aPlotOpts );
1002
1003 // finish
1004 plotter->EndPlot();
1005 delete plotter;
1006
1007 return true;
1008}
1009
1010
1012{
1013 if( aPlotter )
1014 {
1015 aPlotter->EndPlot();
1016 delete aPlotter;
1017 }
1018
1019 // Restore the initial sheet
1020 m_schematic->SetCurrentSheet( aOldsheetpath );
1023}
1024
1025
1027 const wxString& aPlotFileName,
1028 const wxString& aExtension, REPORTER* aReporter )
1029{
1030 wxFileName retv;
1031 wxFileName tmp;
1032
1033 tmp.SetPath( aPlotOpts.m_outputDirectory );
1034 retv.SetPath( tmp.GetPath() );
1035
1036 if( !aPlotFileName.IsEmpty() )
1037 retv.SetName( aPlotFileName );
1038 else
1039 retv.SetName( _( "Schematic" ) );
1040
1041 retv.SetExt( aExtension );
1042
1043 if( !EnsureFileDirectoryExists( &tmp, retv.GetFullName(), aReporter ) || !tmp.IsDirWritable() )
1044 {
1045 if( aReporter )
1046 {
1047 wxString msg = wxString::Format( _( "Failed to write plot files to folder '%s'." ),
1048 tmp.GetPath() );
1049 aReporter->Report( msg, RPT_SEVERITY_ERROR );
1050 }
1051 retv.Clear();
1052
1054 settings.m_PlotDirectoryName.Clear();
1055 }
1056 else
1057 {
1058 retv.SetPath( tmp.GetPath() );
1059 }
1060
1061 wxLogTrace( tracePathsAndFiles, "Writing plot file '%s'.", retv.GetFullPath() );
1062
1063 return retv;
1064}
1065
1066
1067void SCH_PLOTTER::Plot( PLOT_FORMAT aPlotFormat, const SCH_PLOT_OPTS& aPlotOpts,
1068 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter )
1069{
1070 SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
1071
1072 m_colorSettings = settingsMgr.GetColorSettings( aPlotOpts.m_theme );
1073
1074 switch( aPlotFormat )
1075 {
1076 default:
1077 case PLOT_FORMAT::POST: createPSFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1078 case PLOT_FORMAT::DXF: createDXFFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1079 case PLOT_FORMAT::PDF: createPDFFile( aPlotOpts, aRenderSettings, aReporter ); break;
1080 case PLOT_FORMAT::SVG: createSVGFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1081 case PLOT_FORMAT::HPGL: createHPGLFiles( aPlotOpts, aRenderSettings, aReporter ); break;
1082 }
1083}
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:82
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:161
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:312
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
Definition: schematic.h:166
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:208
bool ResolveTextVar(const SCH_SHEET_PATH *aSheetPath, wxString *token, int aDepth) const
Definition: schematic.cpp:253
const std::map< wxString, wxString > * GetProperties()
Definition: schematic.h:100
SCH_SHEET & Root() const
Definition: schematic.h:130
wxString GetUniqueFilenameForCurrentSheet()
Definition: schematic.cpp:646
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
Definition: schematic.cpp:662
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:97
Schematic editor (Eeschema) main window.
void Plot(PLOT_FORMAT aPlotFormat, const SCH_PLOT_OPTS &aPlotOpts, SCH_RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter=nullptr)
Perform the plotting of the schematic using the given aPlotFormat and aPlotSettings.
wxFileName getOutputFilenameSingle(const SCH_PLOT_OPTS &aPlotOpts, REPORTER *aReporter, const wxString &ext)
Returns the output filename for formats where the output is a single file.
Definition: sch_plotter.cpp:87
void createSVGFiles(const SCH_PLOT_OPTS &aPlotOpts, SCH_RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
void createPSFiles(const SCH_PLOT_OPTS &aPlotOpts, SCH_RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
void plotOneSheetPDF(PLOTTER *aPlotter, SCH_SCREEN *aScreen, const SCH_PLOT_OPTS &aPlotOpts)
wxFileName createPlotFileName(const SCH_PLOT_OPTS &aPlotOpts, const wxString &aPlotFileName, const wxString &aExtension, REPORTER *aReporter=nullptr)
Create a file name with an absolute path name.
SCH_PLOTTER(SCH_EDIT_FRAME *aFrame)
Constructor for usage with a frame having the schematic we want to print loaded.
Definition: sch_plotter.cpp:80
bool plotOneSheetDXF(const wxString &aFileName, SCH_SCREEN *aScreen, RENDER_SETTINGS *aRenderSettings, const VECTOR2I &aPlotOffset, double aScale, const SCH_PLOT_OPTS &aPlotOpts)
void createDXFFiles(const SCH_PLOT_OPTS &aPlotOpts, SCH_RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
void createHPGLFiles(const SCH_PLOT_OPTS &aPlotOpts, SCH_RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
wxString m_lastOutputFilePath
Definition: sch_plotter.h:221
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:220
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:219
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:130
const wxString & GetFileName() const
Definition: sch_screen.h:143
SCHEMATIC * Schematic() const
Definition: sch_screen.cpp:100
const TITLE_BLOCK & GetTitleBlock() const
Definition: sch_screen.h:154
void Plot(PLOTTER *aPlotter, const SCH_PLOT_OPTS &aPlotOpts) const
Plot all the schematic objects to aPlotter.
Definition: sch_screen.cpp:898
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:106
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:447
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:440
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
wxLogTrace helper definitions.
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695