KiCad PCB EDA Suite
dialog_plot_schematic.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-2022 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 <bitmaps.h>
28#include <common.h> // For ExpandEnvVarSubstitutions
31#include <eeschema_settings.h>
32#include <kiface_base.h>
33#include <locale_io.h>
37#include <reporter.h>
38#include <trace_helpers.h>
41#include <wx_filename.h>
42
43#include <sch_edit_frame.h>
44#include <sch_painter.h>
45#include <schematic.h>
46#include <sch_screen.h>
47
48#include <wx/dirdlg.h>
49#include <wx/msgdlg.h>
50#include <wx/stdpaths.h>
51#include <wx/log.h>
52
53
54// static members (static to remember last state):
57
58
72};
73
74
75static const wxChar* plot_sheet_list( int aSize )
76{
77 switch( aSize )
78 {
79 default:
80 case PAGE_DEFAULT: return nullptr;
81 case HPGL_PAGE_SIZE_A5: return wxT( "A5" );
82 case HPGL_PAGE_SIZE_A4: return wxT( "A4" );
83 case HPGL_PAGE_SIZE_A3: return wxT( "A3" );
84 case HPGL_PAGE_SIZE_A2: return wxT( "A2" );
85 case HPGL_PAGE_SIZE_A1: return wxT( "A1" );
86 case HPGL_PAGE_SIZE_A0: return wxT( "A0" );
87 case HPGL_PAGE_SIZE_A: return wxT( "A" );
88 case HPGL_PAGE_SIZE_B: return wxT( "B" );
89 case HPGL_PAGE_SIZE_C: return wxT( "C" );
90 case HPGL_PAGE_SIZE_D: return wxT( "D" );
91 case HPGL_PAGE_SIZE_E: return wxT( "E" );
92 }
93}
94
95
98 m_parent( parent ),
99 m_plotFormat( PLOT_FORMAT::UNDEFINED ),
100 m_HPGLPenSize( 1.0 ),
101 m_defaultLineWidth( parent, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits ),
102 m_penWidth( parent, m_penWidthLabel, m_penWidthCtrl, m_penWidthUnits )
103{
104 m_configChanged = false;
105
107
108 m_MessagesBox->SetFileName( Prj().GetProjectPath() + wxT( "report.txt" ) );
109
110 SetupStandardButtons( { { wxID_OK, _( "Plot All Pages" ) },
111 { wxID_APPLY, _( "Plot Current Page" ) },
112 { wxID_CANCEL, _( "Close" ) } } );
113
114 initDlg();
115
116 // Now all widgets have the size fixed, call FinishDialogSettings
118}
119
120
122{
123 auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
124 wxASSERT( cfg );
125
126 if( cfg )
127 {
129 {
130 int idx = m_colorTheme->Append( settings->GetName(), static_cast<void*>( settings ) );
131
132 if( settings->GetFilename() == cfg->m_PlotPanel.color_theme )
133 m_colorTheme->SetSelection( idx );
134 }
135
136 m_colorTheme->Enable( cfg->m_PlotPanel.color );
137
138 m_plotBackgroundColor->Enable( cfg->m_PlotPanel.color );
139 m_plotBackgroundColor->SetValue( cfg->m_PlotPanel.background_color );
140
141 // Set color or B&W plot option
142 setModeColor( cfg->m_PlotPanel.color );
143
144 // Set plot or not frame reference option
145 setPlotDrawingSheet( cfg->m_PlotPanel.frame_reference );
146
147 setOpenFileAfterPlot( cfg->m_PlotPanel.open_file_after_plot );
148
149 // HPGL plot origin and unit system configuration
150 m_plotOriginOpt->SetSelection( cfg->m_PlotPanel.hpgl_origin );
151
152 m_HPGLPaperSizeSelect = cfg->m_PlotPanel.hpgl_paper_size;
153
154 // HPGL Pen Size is stored in mm in config
155 m_HPGLPenSize = cfg->m_PlotPanel.hpgl_pen_size * schIUScale.IU_PER_MM;
156
157 // Switch to the last save plot format
158 PLOT_FORMAT fmt = static_cast<PLOT_FORMAT>( cfg->m_PlotPanel.format );
159
160 switch( fmt )
161 {
162 default:
163 case PLOT_FORMAT::POST: m_plotFormatOpt->SetSelection( 0 ); break;
164 case PLOT_FORMAT::PDF: m_plotFormatOpt->SetSelection( 1 ); break;
165 case PLOT_FORMAT::SVG: m_plotFormatOpt->SetSelection( 2 ); break;
166 case PLOT_FORMAT::DXF: m_plotFormatOpt->SetSelection( 3 ); break;
167 case PLOT_FORMAT::HPGL: m_plotFormatOpt->SetSelection( 4 ); break;
168 }
169
170 if( fmt == PLOT_FORMAT::DXF || fmt == PLOT_FORMAT::HPGL )
171 m_plotBackgroundColor->Disable();
172
173 // Set the default line width (pen width which should be used for
174 // items that do not have a pen size defined (like frame ref)
175 // the default line width is stored in mils in config
176 m_defaultLineWidth.SetValue( schIUScale.MilsToIU( cfg->m_Drawing.default_line_thickness ) );
177 }
178
179 // Initialize HPGL specific widgets
181
182 // Plot directory
184 wxString path = settings.m_PlotDirectoryName;
185#ifdef __WINDOWS__
186 path.Replace( '/', '\\' );
187#endif
188 m_outputDirectoryName->SetValue( path );
189}
190
191
197{
198 // Build the absolute path of current output directory to preselect it in the file browser.
199 wxString path = ExpandEnvVarSubstitutions( m_outputDirectoryName->GetValue(), &Prj() );
200
201 // When editing a schematic that is not part of a project in the stand alone mode, the
202 // project path is not defined so point to the users document path to save the plot files.
203 if( Prj().IsNullProject() )
204 {
205 path = wxStandardPaths::Get().GetDocumentsDir();
206 }
207 else
208 {
209 // Build the absolute path of current output directory to preselect it in the file browser.
211 path = Prj().AbsolutePath( path );
212 }
213
214 wxDirDialog dirDialog( this, _( "Select Output Directory" ), path );
215
216 if( dirDialog.ShowModal() == wxID_CANCEL )
217 return;
218
219 wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
220
221 wxFileName fn( Prj().AbsolutePath( m_parent->Schematic().Root().GetFileName() ) );
222 wxString defaultPath = fn.GetPathWithSep();
223 wxString msg;
224 wxFileName relPathTest; // Used to test if we can make the path relative
225
226 relPathTest.Assign( dirDialog.GetPath() );
227
228 // Test if making the path relative is possible before asking the user if they want to do it
229 if( relPathTest.MakeRelativeTo( defaultPath ) )
230 {
231 msg.Printf( _( "Do you want to use a path relative to\n'%s'?" ), defaultPath );
232
233 wxMessageDialog dialog( this, msg, _( "Plot Output Directory" ),
234 wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT );
235
236 if( dialog.ShowModal() == wxID_YES )
237 dirName.MakeRelativeTo( defaultPath );
238 }
239
240 m_outputDirectoryName->SetValue( dirName.GetFullPath() );
241}
242
243
245{
246 switch( m_plotFormatOpt->GetSelection() )
247 {
248 default:
249 case 0: return PLOT_FORMAT::POST;
250 case 1: return PLOT_FORMAT::PDF;
251 case 2: return PLOT_FORMAT::SVG;
252 case 3: return PLOT_FORMAT::DXF;
253 case 4: return PLOT_FORMAT::HPGL;
254 }
255}
256
257
258void DIALOG_PLOT_SCHEMATIC::OnPageSizeSelected( wxCommandEvent& event )
259{
262 else
263 m_pageSizeSelect = m_paperSizeOption->GetSelection();
264}
265
266
267void DIALOG_PLOT_SCHEMATIC::OnUpdateUI( wxUpdateUIEvent& event )
268{
270
271 if( fmt != m_plotFormat )
272 {
273 m_plotFormat = fmt;
274
275 wxArrayString paperSizes;
276 paperSizes.push_back( _( "Schematic size" ) );
277
278 int selection;
279
280 if( fmt == PLOT_FORMAT::HPGL )
281 {
282 paperSizes.push_back( _( "A5" ) );
283 paperSizes.push_back( _( "A4" ) );
284 paperSizes.push_back( _( "A3" ) );
285 paperSizes.push_back( _( "A2" ) );
286 paperSizes.push_back( _( "A1" ) );
287 paperSizes.push_back( _( "A0" ) );
288 paperSizes.push_back( _( "A" ) );
289 paperSizes.push_back( _( "B" ) );
290 paperSizes.push_back( _( "C" ) );
291 paperSizes.push_back( _( "D" ) );
292 paperSizes.push_back( _( "E" ) );
293
294 selection = m_HPGLPaperSizeSelect;
295 }
296 else
297 {
298 paperSizes.push_back( _( "A4" ) );
299 paperSizes.push_back( _( "A" ) );
300
301 selection = m_pageSizeSelect;
302 }
303
304 m_openFileAfterPlot->Enable( fmt == PLOT_FORMAT::PDF );
305
306 m_paperSizeOption->Set( paperSizes );
307 m_paperSizeOption->SetSelection( selection );
308
310 fmt == PLOT_FORMAT::POST || fmt == PLOT_FORMAT::PDF || fmt == PLOT_FORMAT::SVG );
311
312 m_plotOriginTitle->Enable( fmt == PLOT_FORMAT::HPGL );
313 m_plotOriginOpt->Enable( fmt == PLOT_FORMAT::HPGL );
315
316 m_plotBackgroundColor->Enable(
317 fmt == PLOT_FORMAT::POST || fmt == PLOT_FORMAT::PDF || fmt == PLOT_FORMAT::SVG );
318
319 m_colorTheme->Enable( fmt != PLOT_FORMAT::HPGL );
320 m_ModeColorOption->Enable( fmt != PLOT_FORMAT::HPGL );
321 }
322}
323
324
326{
328
329 EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
330 wxASSERT( cfg );
331
333
334 if( cfg )
335 {
338 cfg->m_PlotPanel.color_theme = colors->GetFilename();
340 cfg->m_PlotPanel.format = static_cast<int>( GetPlotFileFormat() );
341 cfg->m_PlotPanel.hpgl_origin = m_plotOriginOpt->GetSelection();
344
345 // HPGL Pen Size is stored in mm in config
347 }
348
349 aSettings->LoadColors( colors );
350 aSettings->SetMinPenWidth( (int) m_defaultLineWidth.GetValue() );
351
352 if( m_plotBackgroundColor->GetValue() )
354 else
355 aSettings->SetBackgroundColor( COLOR4D::UNSPECIFIED );
356
357 // Plot directory
358 wxString path = m_outputDirectoryName->GetValue();
359 path.Replace( '\\', '/' );
360
362
363 if( settings.m_PlotDirectoryName != path )
364 m_configChanged = true;
365
366 settings.m_PlotDirectoryName = path;
367}
368
369
371{
372 int selection = m_colorTheme->GetSelection();
373
374 if( selection < 0 )
375 return m_parent->GetSettingsManager()->GetColorSettings( "_builtin_default" );
376
377 return static_cast<COLOR_SETTINGS*>( m_colorTheme->GetClientData( selection ) );
378}
379
380
381void DIALOG_PLOT_SCHEMATIC::OnPlotCurrent( wxCommandEvent& event )
382{
383 plotSchematic( false );
384}
385
386
387void DIALOG_PLOT_SCHEMATIC::OnPlotAll( wxCommandEvent& event )
388{
389 plotSchematic( true );
390}
391
392
394{
396
397 getPlotOptions( &renderSettings );
398
399 switch( GetPlotFileFormat() )
400 {
401 default:
403 createPSFiles( aPlotAll, getPlotDrawingSheet(), &renderSettings );
404 break;
405 case PLOT_FORMAT::DXF:
406 createDXFFiles( aPlotAll, getPlotDrawingSheet(), &renderSettings );
407 break;
408 case PLOT_FORMAT::PDF:
409 createPDFFile( aPlotAll, getPlotDrawingSheet(), &renderSettings );
410 break;
411 case PLOT_FORMAT::SVG:
412 createSVGFiles( aPlotAll, getPlotDrawingSheet(), &renderSettings );
413 break;
415 createHPGLFiles( aPlotAll, getPlotDrawingSheet(), &renderSettings );
416 break;
417 }
418}
419
420
421wxFileName DIALOG_PLOT_SCHEMATIC::createPlotFileName( const wxString& aPlotFileName,
422 const wxString& aExtension,
423 REPORTER* aReporter )
424{
425 wxFileName retv;
426 wxFileName tmp;
427
428 tmp.SetPath( getOutputPath() );
429 retv.SetPath( tmp.GetPath() );
430
431 if( !aPlotFileName.IsEmpty() )
432 retv.SetName( aPlotFileName );
433 else
434 retv.SetName( _( "Schematic" ) );
435
436 retv.SetExt( aExtension );
437
438 if( !EnsureFileDirectoryExists( &tmp, retv.GetFullName(), aReporter ) || !tmp.IsDirWritable() )
439 {
440 wxString msg = wxString::Format( _( "Failed to write plot files to folder '%s'." ),
441 tmp.GetPath() );
442 aReporter->Report( msg, RPT_SEVERITY_ERROR );
443 retv.Clear();
444
446 settings.m_PlotDirectoryName.Clear();
447
448 m_configChanged = true;
449 }
450 else
451 {
452 retv.SetPath( tmp.GetPath() );
453 }
454
455 wxLogTrace( tracePathsAndFiles, "Writing plot file '%s'.", retv.GetFullPath() );
456
457 return retv;
458}
459
460
461void DIALOG_PLOT_SCHEMATIC::createDXFFiles( bool aPlotAll, bool aPlotDrawingSheet,
462 RENDER_SETTINGS* aRenderSettings )
463{
464 SCH_EDIT_FRAME* schframe = m_parent;
465 SCH_SHEET_PATH oldsheetpath = schframe->GetCurrentSheet();
466
467 /* When printing all pages, the printed page is not the current page. In complex hierarchies,
468 * we must update symbol references and other parameters in the given printed SCH_SCREEN,
469 * according to the sheet path because in complex hierarchies a SCH_SCREEN (a drawing ) is
470 * shared between many sheets and symbol references depend on the actual sheet path used.
471 */
472 SCH_SHEET_LIST sheetList;
473
474 if( aPlotAll )
475 {
476 sheetList.BuildSheetList( &schframe->Schematic().Root(), true );
477 sheetList.SortByPageNumbers();
478 }
479 else
480 {
481 sheetList.push_back( schframe->GetCurrentSheet() );
482 }
483
484 REPORTER& reporter = m_MessagesBox->Reporter();
485
486 for( unsigned i = 0; i < sheetList.size(); i++ )
487 {
488 schframe->SetCurrentSheet( sheetList[i] );
490 schframe->SetSheetNumberAndCount();
491
492 SCH_SCREEN* screen = schframe->GetCurrentSheet().LastScreen();
493 wxPoint plot_offset;
494 wxString msg;
495
496 try
497 {
498 wxString fname = schframe->GetUniqueFilenameForCurrentSheet();
499
500 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
501 // main project folder (or the folder specified by the caller),
502 // so replace separators to create a unique filename:
503 fname.Replace( "/", "_" );
504 fname.Replace( "\\", "_" );
506 wxFileName plotFileName = createPlotFileName( fname, ext, &reporter );
507
508 if( !plotFileName.IsOk() )
509 return;
510
511 if( plotOneSheetDXF( plotFileName.GetFullPath(), screen, aRenderSettings,
512 plot_offset, 1.0, aPlotDrawingSheet ) )
513 {
514 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
515 reporter.Report( msg, RPT_SEVERITY_ACTION );
516 }
517 else // Error
518 {
519 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
520 reporter.Report( msg, RPT_SEVERITY_ERROR );
521 }
522 }
523 catch( IO_ERROR& e )
524 {
525 msg.Printf( wxT( "DXF Plotter exception: %s"), e.What() );
526 reporter.Report( msg, RPT_SEVERITY_ERROR );
527 schframe->SetCurrentSheet( oldsheetpath );
529 schframe->SetSheetNumberAndCount();
530 return;
531 }
532 }
533
534 reporter.ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
535
536 schframe->SetCurrentSheet( oldsheetpath );
538 schframe->SetSheetNumberAndCount();
539}
540
541
542bool DIALOG_PLOT_SCHEMATIC::plotOneSheetDXF( const wxString& aFileName,
543 SCH_SCREEN* aScreen,
544 RENDER_SETTINGS* aRenderSettings,
545 const wxPoint& aPlotOffset,
546 double aScale,
547 bool aPlotFrameRef )
548{
549 aRenderSettings->LoadColors( getColorSettings() );
550 aRenderSettings->SetDefaultPenWidth( 0 );
551
552 const PAGE_INFO& pageInfo = aScreen->GetPageSettings();
553 DXF_PLOTTER* plotter = new DXF_PLOTTER();
554
555 plotter->SetRenderSettings( aRenderSettings );
556 plotter->SetPageSettings( pageInfo );
557 plotter->SetColorMode( getModeColor() );
558
559 // Currently, plot units are in decimil
560 plotter->SetViewport( aPlotOffset, schIUScale.IU_PER_MILS/10, aScale, false );
561
562 // Init :
563 plotter->SetCreator( wxT( "Eeschema-DXF" ) );
564
565 if( ! plotter->OpenFile( aFileName ) )
566 {
567 delete plotter;
568 return false;
569 }
570
571 LOCALE_IO toggle;
572
574
575 if( aPlotFrameRef )
576 {
577 wxString sheetName = m_parent->GetCurrentSheet().Last()->GetName();
578 wxString sheetPath = m_parent->GetCurrentSheet().PathHumanReadable();
580
581 PlotDrawingSheet( plotter, &m_parent->Prj(), m_parent->GetTitleBlock(), pageInfo,
582 aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(),
583 aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(),
584 plotter->GetColorMode() ? color : COLOR4D::BLACK,
585 aScreen->GetVirtualPageNumber() == 1 );
586 }
587
588 aScreen->Plot( plotter );
589
590 // finish
591 plotter->EndPlot();
592 delete plotter;
593
594 return true;
595}
596
597
599{
601
602 if( m_HPGLPenSize > schIUScale.mmToIU( 2 ) )
604
605 if( m_HPGLPenSize < schIUScale.mmToIU( 0.01 ) )
607}
608
609
610void DIALOG_PLOT_SCHEMATIC::createHPGLFiles( bool aPlotAll, bool aPlotFrameRef,
611 RENDER_SETTINGS* aRenderSettings )
612{
613 SCH_SCREEN* screen = m_parent->GetScreen();
614 SCH_SHEET_PATH oldsheetpath = m_parent->GetCurrentSheet();
615
616 /* When printing all pages, the printed page is not the current page. In complex hierarchies,
617 * we must update symbol references and other parameters in the given printed SCH_SCREEN,
618 * according to the sheet path because in complex hierarchies a SCH_SCREEN (a drawing ) is
619 * shared between many sheets and symbol references depend on the actual sheet path used.
620 */
621 SCH_SHEET_LIST sheetList;
622
623 if( aPlotAll )
624 {
625 sheetList.BuildSheetList( &m_parent->Schematic().Root(), true );
626 sheetList.SortByPageNumbers();
627 }
628 else
629 {
630 sheetList.push_back( m_parent->GetCurrentSheet() );
631 }
632
633 REPORTER& reporter = m_MessagesBox->Reporter();
634
636
637 for( unsigned i = 0; i < sheetList.size(); i++ )
638 {
639 m_parent->SetCurrentSheet( sheetList[i] );
642
643 screen = m_parent->GetCurrentSheet().LastScreen();
644
645 if( !screen ) // LastScreen() may return NULL
646 screen = m_parent->GetScreen();
647
648 const PAGE_INFO& curPage = screen->GetPageSettings();
649
650 PAGE_INFO plotPage = curPage;
651
652 // if plotting on a page size other than curPage
653 if( m_paperSizeOption->GetSelection() != PAGE_DEFAULT )
654 plotPage.SetType( plot_sheet_list( m_paperSizeOption->GetSelection() ) );
655
656 // Calculation of conversion scales.
657 double plot_scale = (double) plotPage.GetWidthMils() / curPage.GetWidthMils();
658
659 // Calculate offsets
660 wxPoint plotOffset;
661 wxString msg;
662
664 {
665 plotOffset.x = plotPage.GetWidthIU( schIUScale.IU_PER_MILS ) / 2;
666 plotOffset.y = -plotPage.GetHeightIU( schIUScale.IU_PER_MILS ) / 2;
667 }
668
669 try
670 {
671 wxString fname = m_parent->GetUniqueFilenameForCurrentSheet();
672 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
673 // main project folder (or the folder specified by the caller),
674 // so replace separators to create a unique filename:
675 fname.Replace( "/", "_" );
676 fname.Replace( "\\", "_" );
678 wxFileName plotFileName = createPlotFileName( fname, ext, &reporter );
679
680 if( !plotFileName.IsOk() )
681 return;
682
683 LOCALE_IO toggle;
684
685 if( plotOneSheetHpgl( plotFileName.GetFullPath(), screen, plotPage, aRenderSettings,
686 plotOffset, plot_scale, aPlotFrameRef, getPlotOriginAndUnits() ) )
687 {
688 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
689 reporter.Report( msg, RPT_SEVERITY_ACTION );
690 }
691 else
692 {
693 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
694 reporter.Report( msg, RPT_SEVERITY_ERROR );
695 }
696 }
697 catch( IO_ERROR& e )
698 {
699 msg.Printf( wxT( "HPGL Plotter exception: %s"), e.What() );
700 reporter.Report( msg, RPT_SEVERITY_ERROR );
701 }
702 }
703
704 reporter.ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
705
706 m_parent->SetCurrentSheet( oldsheetpath );
709}
710
711
712bool DIALOG_PLOT_SCHEMATIC::plotOneSheetHpgl( const wxString& aFileName,
713 SCH_SCREEN* aScreen,
714 const PAGE_INFO& aPageInfo,
715 RENDER_SETTINGS* aRenderSettings,
716 const wxPoint& aPlot0ffset,
717 double aScale,
718 bool aPlotFrameRef,
719 HPGL_PLOT_ORIGIN_AND_UNITS aOriginAndUnits )
720{
721 HPGL_PLOTTER* plotter = new HPGL_PLOTTER();
722 // Currently, plot units are in decimil
723
724 plotter->SetPageSettings( aPageInfo );
725 plotter->SetRenderSettings( aRenderSettings );
727 plotter->SetColorMode( getModeColor() );
728 plotter->SetViewport( aPlot0ffset, schIUScale.IU_PER_MILS/10, aScale, false );
729
730 // TODO this could be configurable
731 plotter->SetTargetChordLength( schIUScale.mmToIU( 0.6 ) );
732
733 switch( aOriginAndUnits )
734 {
737 default:
738 plotter->SetUserCoords( false );
739 break;
741 plotter->SetUserCoords( true );
742 plotter->SetUserCoordsFit( false );
743 break;
745 plotter->SetUserCoords( true );
746 plotter->SetUserCoordsFit( true );
747 break;
748 }
749
750 // Init :
751 plotter->SetCreator( wxT( "Eeschema-HPGL" ) );
752
753 if( !plotter->OpenFile( aFileName ) )
754 {
755 delete plotter;
756 return false;
757 }
758
759 LOCALE_IO toggle;
760
761 // Pen num and pen speed are not initialized here.
762 // Default HPGL driver values are used
763 plotter->SetPenDiameter( m_HPGLPenSize );
765
766 if( aPlotFrameRef )
767 {
768 wxString sheetName = m_parent->GetCurrentSheet().Last()->GetName();
769 wxString sheetPath = m_parent->GetCurrentSheet().PathHumanReadable();
770
771 PlotDrawingSheet( plotter, &m_parent->Prj(), m_parent->GetTitleBlock(), aPageInfo,
772 aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(),
773 aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(),
774 COLOR4D::BLACK, aScreen->GetVirtualPageNumber() == 1 );
775 }
776
777 aScreen->Plot( plotter );
778
779 plotter->EndPlot();
780 delete plotter;
781
782 return true;
783}
784
785
786void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotDrawingSheet,
787 RENDER_SETTINGS* aRenderSettings )
788{
789 SCH_SHEET_PATH oldsheetpath = m_parent->GetCurrentSheet(); // sheetpath is saved here
790
791 /* When printing all pages, the printed page is not the current page. In complex hierarchies,
792 * we must update symbol references and other parameters in the given printed SCH_SCREEN,
793 * according to the sheet path because in complex hierarchies a SCH_SCREEN (a drawing ) is
794 * shared between many sheets and symbol references depend on the actual sheet path used.
795 */
796 SCH_SHEET_LIST sheetList;
797
798 if( aPlotAll )
799 {
800 sheetList.BuildSheetList( &m_parent->Schematic().Root(), true );
801 sheetList.SortByPageNumbers();
802 }
803 else
804 {
805 sheetList.push_back( m_parent->GetCurrentSheet() );
806 }
807
808 // Allocate the plotter and set the job level parameter
809 PDF_PLOTTER* plotter = new PDF_PLOTTER();
810 plotter->SetRenderSettings( aRenderSettings );
811 plotter->SetColorMode( getModeColor() );
812 plotter->SetCreator( wxT( "Eeschema-PDF" ) );
814
815 wxString msg;
816 wxFileName plotFileName;
817 REPORTER& reporter = m_MessagesBox->Reporter();
818 LOCALE_IO toggle; // Switch the locale to standard C
819
820 for( unsigned i = 0; i < sheetList.size(); i++ )
821 {
822 m_parent->SetCurrentSheet( sheetList[i] );
826
827 if( i == 0 )
828 {
829 try
830 {
831 wxString fname = m_parent->GetUniqueFilenameForCurrentSheet();
832
833 // The sub sheet can be in a sub_hierarchy, but we plot the file in the main
834 // project folder (or the folder specified by the caller), so replace separators
835 // to create a unique filename:
836 fname.Replace( "/", "_" );
837 fname.Replace( "\\", "_" );
839 plotFileName = createPlotFileName( fname, ext, &reporter );
840
841 if( !plotFileName.IsOk() )
842 return;
843
844 if( !plotter->OpenFile( plotFileName.GetFullPath() ) )
845 {
846 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
847 reporter.Report( msg, RPT_SEVERITY_ERROR );
848 delete plotter;
849 return;
850 }
851
852 // Open the plotter and do the first page
853 setupPlotPagePDF( plotter, screen );
854 plotter->StartPlot( sheetList[i].GetPageNumber(), _("Root") );
855 }
856 catch( const IO_ERROR& e )
857 {
858 // Cannot plot PDF file
859 msg.Printf( wxT( "PDF Plotter exception: %s" ), e.What() );
860 reporter.Report( msg, RPT_SEVERITY_ERROR );
861
862 restoreEnvironment( plotter, oldsheetpath );
863 return;
864 }
865
866 }
867 else
868 {
869 /* For the following pages you need to close the (finished) page,
870 * reconfigure, and then start a new one */
871 plotter->ClosePage();
872 setupPlotPagePDF( plotter, screen );
873 plotter->StartPage( sheetList[i].GetPageNumber(),
874 sheetList[i].Last()->GetFields()[SHEETNAME].GetShownText() );
875 }
876
877 plotOneSheetPDF( plotter, screen, aPlotDrawingSheet );
878 }
879
880 // Everything done, close the plot and restore the environment
881 msg.Printf( _( "Plotted to '%s'.\n" ), plotFileName.GetFullPath() );
882 reporter.Report( msg, RPT_SEVERITY_ACTION );
883 reporter.ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
884
885 restoreEnvironment( plotter, oldsheetpath );
886
888 wxLaunchDefaultApplication( plotFileName.GetFullPath() );
889}
890
891
893 SCH_SHEET_PATH& aOldsheetpath )
894{
895 aPlotter->EndPlot();
896 delete aPlotter;
897
898 // Restore the previous sheet
899 m_parent->SetCurrentSheet( aOldsheetpath );
902}
903
904
906 bool aPlotDrawingSheet )
907{
908 if( m_plotBackgroundColor->GetValue() && aPlotter->GetColorMode() )
909 {
910 aPlotter->SetColor( aPlotter->RenderSettings()->GetBackgroundColor() );
911 wxPoint end( aPlotter->PageSettings().GetWidthIU( schIUScale.IU_PER_MILS ),
913 aPlotter->Rect( wxPoint( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 );
914 }
915
916 if( aPlotDrawingSheet )
917 {
919
920 if( aPlotter->GetColorMode() )
922
923 wxString sheetName = m_parent->GetCurrentSheet().Last()->GetName();
924 wxString sheetPath = m_parent->GetCurrentSheet().PathHumanReadable();
925
926 PlotDrawingSheet( aPlotter, &aScreen->Schematic()->Prj(), m_parent->GetTitleBlock(),
928 aScreen->GetPageNumber(), aScreen->GetPageCount(), sheetName, sheetPath,
929 aScreen->GetFileName(), color, aScreen->GetVirtualPageNumber() == 1 );
930 }
931
932 aScreen->Plot( aPlotter );
933}
934
935
937{
938 PAGE_INFO plotPage; // page size selected to plot
939
940 // Considerations on page size and scaling requests
941 const PAGE_INFO& actualPage = aScreen->GetPageSettings(); // page size selected in schematic
942
943 switch( m_pageSizeSelect )
944 {
945 case PAGE_SIZE_A:
946 plotPage.SetType( wxT( "A" ) );
947 plotPage.SetPortrait( actualPage.IsPortrait() );
948 break;
949
950 case PAGE_SIZE_A4:
951 plotPage.SetType( wxT( "A4" ) );
952 plotPage.SetPortrait( actualPage.IsPortrait() );
953 break;
954
955 case PAGE_SIZE_AUTO:
956 default:
957 plotPage = actualPage;
958 break;
959 }
960
961 double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
962 double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
963 double scale = std::min( scalex, scaley );
964 aPlotter->SetPageSettings( plotPage );
965
966 // Currently, plot units are in decimil
967 aPlotter->SetViewport( wxPoint( 0, 0 ), schIUScale.IU_PER_MILS/10, scale, false );
968}
969
970
971void DIALOG_PLOT_SCHEMATIC::createPSFiles( bool aPlotAll, bool aPlotFrameRef,
972 RENDER_SETTINGS* aRenderSettings )
973{
974 SCH_SHEET_PATH oldsheetpath = m_parent->GetCurrentSheet(); // sheetpath is saved here
975 PAGE_INFO plotPage; // page size selected to plot
976 wxString msg;
977 REPORTER& reporter = m_MessagesBox->Reporter();
978
979 /* When printing all pages, the printed page is not the current page.
980 * In complex hierarchies, we must update symbol references and other parameters in the
981 * given printed SCH_SCREEN, accordant to the sheet path because in complex hierarchies
982 * a SCH_SCREEN (a drawing ) is shared between many sheets and symbol references
983 * depend on the actual sheet path used.
984 */
985 SCH_SHEET_LIST sheetList;
986
987 if( aPlotAll )
988 {
989 sheetList.BuildSheetList( &m_parent->Schematic().Root(), true );
990 sheetList.SortByPageNumbers();
991 }
992 else
993 {
994 sheetList.push_back( m_parent->GetCurrentSheet() );
995 }
996
997 for( unsigned i = 0; i < sheetList.size(); i++ )
998 {
999 m_parent->SetCurrentSheet( sheetList[i] );
1002
1004 PAGE_INFO actualPage = screen->GetPageSettings();
1005
1006 switch( m_pageSizeSelect )
1007 {
1008 case PAGE_SIZE_A:
1009 plotPage.SetType( wxT( "A" ) );
1010 plotPage.SetPortrait( actualPage.IsPortrait() );
1011 break;
1012
1013 case PAGE_SIZE_A4:
1014 plotPage.SetType( wxT( "A4" ) );
1015 plotPage.SetPortrait( actualPage.IsPortrait() );
1016 break;
1017
1018 case PAGE_SIZE_AUTO:
1019 default:
1020 plotPage = actualPage;
1021 break;
1022 }
1023
1024 double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
1025 double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
1026 double scale = std::min( scalex, scaley );
1027 wxPoint plot_offset;
1028
1029 try
1030 {
1031 wxString fname = m_parent->GetUniqueFilenameForCurrentSheet();
1032
1033 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
1034 // main project folder (or the folder specified by the caller),
1035 // so replace separators to create a unique filename:
1036 fname.Replace( "/", "_" );
1037 fname.Replace ("\\", "_" );
1038 wxString ext = PS_PLOTTER::GetDefaultFileExtension();
1039 wxFileName plotFileName = createPlotFileName( fname, ext, &reporter );
1040
1041 if( !plotFileName.IsOk() )
1042 return;
1043
1044 if( plotOneSheetPS( plotFileName.GetFullPath(), screen, aRenderSettings, plotPage,
1045 plot_offset, scale, aPlotFrameRef ) )
1046 {
1047 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
1048 reporter.Report( msg, RPT_SEVERITY_ACTION );
1049 }
1050 else
1051 {
1052 // Error
1053 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
1054 reporter.Report( msg, RPT_SEVERITY_ERROR );
1055 }
1056
1057 }
1058 catch( IO_ERROR& e )
1059 {
1060 msg.Printf( wxT( "PS Plotter exception: %s"), e.What() );
1061 reporter.Report( msg, RPT_SEVERITY_ERROR );
1062 }
1063 }
1064
1065 reporter.ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
1066
1067 m_parent->SetCurrentSheet( oldsheetpath );
1070}
1071
1072
1073bool DIALOG_PLOT_SCHEMATIC::plotOneSheetPS( const wxString& aFileName,
1074 SCH_SCREEN* aScreen,
1075 RENDER_SETTINGS* aRenderSettings,
1076 const PAGE_INFO& aPageInfo,
1077 const wxPoint& aPlot0ffset,
1078 double aScale,
1079 bool aPlotFrameRef )
1080{
1081 PS_PLOTTER* plotter = new PS_PLOTTER();
1082 plotter->SetRenderSettings( aRenderSettings );
1083 plotter->SetPageSettings( aPageInfo );
1084 plotter->SetColorMode( getModeColor() );
1085
1086 // Currently, plot units are in decimil
1087 plotter->SetViewport( aPlot0ffset, schIUScale.IU_PER_MILS/10, aScale, false );
1088
1089 // Init :
1090 plotter->SetCreator( wxT( "Eeschema-PS" ) );
1091
1092 if( ! plotter->OpenFile( aFileName ) )
1093 {
1094 delete plotter;
1095 return false;
1096 }
1097
1098 LOCALE_IO toggle; // Switch the locale to standard C
1099
1101
1102 if( m_plotBackgroundColor->GetValue() && plotter->GetColorMode() )
1103 {
1105 wxPoint end( plotter->PageSettings().GetWidthIU( schIUScale.IU_PER_MILS ),
1107 plotter->Rect( wxPoint( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 );
1108 }
1109
1110 if( aPlotFrameRef )
1111 {
1112 wxString sheetName = m_parent->GetCurrentSheet().Last()->GetName();
1113 wxString sheetPath = m_parent->GetCurrentSheet().PathHumanReadable();
1115
1116 PlotDrawingSheet( plotter, &aScreen->Schematic()->Prj(), m_parent->GetTitleBlock(),
1117 aPageInfo, aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(),
1118 aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(),
1119 plotter->GetColorMode() ? color : COLOR4D::BLACK,
1120 aScreen->GetVirtualPageNumber() == 1 );
1121 }
1122
1123 aScreen->Plot( plotter );
1124
1125 plotter->EndPlot();
1126 delete plotter;
1127
1128 return true;
1129}
1130
1131
1132void DIALOG_PLOT_SCHEMATIC::createSVGFiles( bool aPrintAll, bool aPrintFrameRef,
1133 RENDER_SETTINGS* aRenderSettings )
1134{
1135 wxString msg;
1136 REPORTER& reporter = m_MessagesBox->Reporter();
1137 SCH_SHEET_PATH oldsheetpath = m_parent->GetCurrentSheet();
1138 SCH_SHEET_LIST sheetList;
1139
1140 if( aPrintAll )
1141 {
1142 sheetList.BuildSheetList( &m_parent->Schematic().Root(), true );
1143 sheetList.SortByPageNumbers();
1144 }
1145 else
1146 {
1147 sheetList.push_back( m_parent->GetCurrentSheet() );
1148 }
1149
1150 for( unsigned i = 0; i < sheetList.size(); i++ )
1151 {
1152 SCH_SCREEN* screen;
1153 m_parent->SetCurrentSheet( sheetList[i] );
1156 screen = m_parent->GetCurrentSheet().LastScreen();
1157
1158 try
1159 {
1160 wxString fname = m_parent->GetUniqueFilenameForCurrentSheet();
1161
1162 // The sub sheet can be in a sub_hierarchy, but we plot the file in the
1163 // main project folder (or the folder specified by the caller),
1164 // so replace separators to create a unique filename:
1165 fname.Replace( "/", "_" );
1166 fname.Replace( "\\", "_" );
1167 wxString ext = SVG_PLOTTER::GetDefaultFileExtension();
1168 wxFileName plotFileName = createPlotFileName( fname, ext, &reporter );
1169
1170 if( !plotFileName.IsOk() )
1171 return;
1172
1173 bool success = plotOneSheetSVG( plotFileName.GetFullPath(), screen, aRenderSettings,
1174 getModeColor() ? false : true, aPrintFrameRef );
1175
1176 if( !success )
1177 {
1178 msg.Printf( _( "Failed to create file '%s'." ), plotFileName.GetFullPath() );
1179 reporter.Report( msg, RPT_SEVERITY_ERROR );
1180 }
1181 else
1182 {
1183 msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
1184 reporter.Report( msg, RPT_SEVERITY_ACTION );
1185 }
1186 }
1187 catch( const IO_ERROR& e )
1188 {
1189 // Cannot plot SVG file
1190 msg.Printf( wxT( "SVG Plotter exception: %s" ), e.What() );
1191 reporter.Report( msg, RPT_SEVERITY_ERROR );
1192 break;
1193 }
1194 }
1195
1196 reporter.ReportTail( _( "Done" ), RPT_SEVERITY_INFO );
1197
1198 m_parent->SetCurrentSheet( oldsheetpath );
1201}
1202
1203
1204bool DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG( const wxString& aFileName,
1205 SCH_SCREEN* aScreen,
1206 RENDER_SETTINGS* aRenderSettings,
1207 bool aPlotBlackAndWhite,
1208 bool aPlotFrameRef )
1209{
1210 const PAGE_INFO& pageInfo = aScreen->GetPageSettings();
1211
1212 SVG_PLOTTER* plotter = new SVG_PLOTTER();
1213 plotter->SetRenderSettings( aRenderSettings );
1214 plotter->SetPageSettings( pageInfo );
1215 plotter->SetColorMode( aPlotBlackAndWhite ? false : true );
1216 wxPoint plot_offset;
1217 double scale = 1.0;
1218
1219 // Currently, plot units are in decimil
1220 plotter->SetViewport( plot_offset, schIUScale.IU_PER_MILS/10, scale, false );
1221
1222 // Init :
1223 plotter->SetCreator( wxT( "Eeschema-SVG" ) );
1224
1225 if( ! plotter->OpenFile( aFileName ) )
1226 {
1227 delete plotter;
1228 return false;
1229 }
1230
1231 LOCALE_IO toggle;
1232
1234
1235 if( m_plotBackgroundColor->GetValue() && plotter->GetColorMode() )
1236 {
1238 wxPoint end( plotter->PageSettings().GetWidthIU( schIUScale.IU_PER_MILS ),
1240 plotter->Rect( wxPoint( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 );
1241 }
1242
1243 if( aPlotFrameRef )
1244 {
1245 wxString sheetName = m_parent->GetCurrentSheet().Last()->GetName();
1246 wxString sheetPath = m_parent->GetCurrentSheet().PathHumanReadable();
1248
1249 PlotDrawingSheet( plotter, &aScreen->Schematic()->Prj(), m_parent->GetTitleBlock(),
1250 pageInfo, aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(),
1251 aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(),
1252 plotter->GetColorMode() ? color : COLOR4D::BLACK,
1253 aScreen->GetVirtualPageNumber() == 1 );
1254 }
1255
1256 aScreen->Plot( plotter );
1257
1258 plotter->EndPlot();
1259 delete plotter;
1260
1261 return true;
1262}
1263
1264
1266{
1267 wxString msg;
1268 wxString extMsg;
1269 wxFileName fn;
1270
1271 extMsg.Printf( _( "Falling back to user path '%s'." ),
1272 wxStandardPaths::Get().GetDocumentsDir() );
1273
1274 // Build the absolute path of current output directory to preselect it in the file browser.
1275 std::function<bool( wxString* )> textResolver =
1276 [&]( wxString* token ) -> bool
1277 {
1278 return m_parent->Schematic().ResolveTextVar( token, 0 );
1279 };
1280
1281 wxString path = m_outputDirectoryName->GetValue();
1282 path = ExpandTextVars( path, &textResolver, nullptr, &Prj() );
1284
1285 fn.SetPath( path );
1286
1287 // If the contents of the path edit control results in an absolute path, return it as is.
1288 if( fn.IsAbsolute() )
1289 return path;
1290
1291 // When editing a schematic that is not part of a project in the stand alone mode, the
1292 // project path is not defined.
1293 if( Prj().IsNullProject() )
1294 {
1295 SCH_SCREEN* screen = m_parent->Schematic().RootScreen();
1296
1297 if( screen && !screen->GetFileName().IsEmpty() )
1298 {
1299 fn = screen->GetFileName();
1300 msg.Printf( _( "Cannot normalize path '%s%s'." ), fn.GetPathWithSep(), path );
1301 fn.SetPath( fn.GetPathWithSep() + path );
1302
1303 // Normalize always returns true for a non-empty file name so clear the file name
1304 // and extension so that only the path is normalized.
1305 fn.SetName( wxEmptyString );
1306 fn.SetExt( wxEmptyString );
1307
1308 if( fn.Normalize( FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS ) )
1309 {
1310 path = fn.GetPath();
1311 }
1312 else
1313 {
1314 wxMessageDialog dlg( this, msg, _( "Warning" ), wxOK | wxCENTER | wxRESIZE_BORDER
1315 | wxICON_EXCLAMATION | wxSTAY_ON_TOP );
1316
1317 dlg.SetExtendedMessage( extMsg );
1318 dlg.ShowModal();
1319
1320 path = wxStandardPaths::Get().GetDocumentsDir();
1321 }
1322 }
1323 else
1324 {
1325 msg = _( "No project or path defined for the current schematic." );
1326
1327 wxMessageDialog dlg( this, msg, _( "Warning" ), wxOK | wxCENTER | wxRESIZE_BORDER
1328 | wxICON_EXCLAMATION | wxSTAY_ON_TOP );
1329 dlg.SetExtendedMessage( extMsg );
1330 dlg.ShowModal();
1331
1332 // Always fall back to user's document path if no other absolute path can be normalized.
1333 path = wxStandardPaths::Get().GetDocumentsDir();
1334 }
1335 }
1336 else
1337 {
1338 msg.Printf( _( "Cannot normalize path '%s%s'." ), Prj().GetProjectPath(), path );
1339
1340 // Build the absolute path of current output directory and the project path.
1341 fn.SetPath( Prj().GetProjectPath() + path );
1342
1343 if( fn.Normalize( FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS ) )
1344 {
1345 path = fn.GetPath();
1346 }
1347 else
1348 {
1349 wxMessageDialog dlg( this, msg, _( "Warning" ),
1350 wxOK | wxCENTER | wxRESIZE_BORDER | wxICON_EXCLAMATION |
1351 wxSTAY_ON_TOP );
1352
1353 dlg.SetExtendedMessage( extMsg );
1354 dlg.ShowModal();
1355
1356 path = wxStandardPaths::Get().GetDocumentsDir();
1357 }
1358 }
1359
1360 return path;
1361}
int color
Definition: DXF_plotter.cpp:57
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
@ small_folder
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
Color settings are a bit different than most of the settings objects in that there can be more than o...
COLOR4D GetColor(int aLayer) const
Class DIALOG_PLOT_SCHEMATIC_BASE.
WX_HTML_REPORT_PANEL * m_MessagesBox
DIALOG_PLOT_SCHEMATIC(SCH_EDIT_FRAME *parent)
void OnPageSizeSelected(wxCommandEvent &event) override
void OnPlotAll(wxCommandEvent &event) override
void restoreEnvironment(PDF_PLOTTER *aPlotter, SCH_SHEET_PATH &aOldsheetpath)
Everything done, close the plot and restore the environment.
void createDXFFiles(bool aPlotAll, bool aPlotDrawingSheet, RENDER_SETTINGS *aRenderSettings)
bool plotOneSheetDXF(const wxString &aFileName, SCH_SCREEN *aScreen, RENDER_SETTINGS *aRenderSettings, const wxPoint &aPlotOffset, double aScale, bool aPlotFrameRef)
bool plotOneSheetHpgl(const wxString &aFileName, SCH_SCREEN *aScreen, const PAGE_INFO &aPageInfo, RENDER_SETTINGS *aRenderSettings, const wxPoint &aPlot0ffset, double aScale, bool aPlotFrameRef, HPGL_PLOT_ORIGIN_AND_UNITS aOriginAndUnits)
void OnOutputDirectoryBrowseClicked(wxCommandEvent &event) override
Set the m_outputDirectoryName variable to the selected directory from directory dialog.
void createSVGFiles(bool aPrintAll, bool aPrintFrameRef, RENDER_SETTINGS *aRenderSettings)
wxFileName createPlotFileName(const wxString &aPlotFileName, const wxString &aExtension, REPORTER *aReporter=nullptr)
Create a file name with an absolute path name.
void createPSFiles(bool aPlotAll, bool aPlotFrameRef, RENDER_SETTINGS *aSettings)
void setupPlotPagePDF(PLOTTER *aPlotter, SCH_SCREEN *aScreen)
void OnPlotCurrent(wxCommandEvent &event) override
HPGL_PLOT_ORIGIN_AND_UNITS getPlotOriginAndUnits()
void setModeColor(bool aColor)
void createHPGLFiles(bool aPlotAll, bool aPlotFrameRef, RENDER_SETTINGS *aRenderSettings)
void setPlotDrawingSheet(bool aPlot)
void setOpenFileAfterPlot(bool aOpenFileAfterPlot)
void getPlotOptions(RENDER_SETTINGS *aSettings)
COLOR_SETTINGS * getColorSettings()
void plotOneSheetPDF(PLOTTER *aPlotter, SCH_SCREEN *aScreen, bool aPlotDrawingSheet)
bool plotOneSheetSVG(const wxString &aFileName, SCH_SCREEN *aScreen, RENDER_SETTINGS *aRenderSettings, bool aPlotBlackAndWhite, bool aPlotFrameRef)
bool plotOneSheetPS(const wxString &aFileName, SCH_SCREEN *aScreen, RENDER_SETTINGS *aRenderSettings, const PAGE_INFO &aPageInfo, const wxPoint &aPlot0ffset, double aScale, bool aPlotFrameRef)
void plotSchematic(bool aPlotAll)
void OnUpdateUI(wxUpdateUIEvent &event) override
void createPDFFile(bool aPlotAll, bool aPlotDrawingSheet, RENDER_SETTINGS *aRenderSettings)
wxString getOutputPath()
Determine the best absolute path to plot files given the contents of the path edit control.
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
static wxString GetDefaultFileExtension()
Definition: plotter_dxf.h:47
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
SETTINGS_MANAGER * GetSettingsManager() const
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:76
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
wxString GetFilename() const
Definition: json_settings.h:73
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:93
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 void SetBackgroundColor(const COLOR4D &aColor)=0
Set the background color.
virtual const COLOR4D & GetBackgroundColor() const =0
Return current background color settings.
void SetMinPenWidth(int aWidth)
Store schematic specific render settings.
Definition: sch_painter.h:71
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:41
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
void SetPortrait(bool aIsPortrait)
Rotate the paper page 90 degrees.
Definition: page_info.cpp:187
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
Definition: page_info.h:153
int GetHeightMils() const
Definition: page_info.h:133
int GetWidthMils() const
Definition: page_info.h:130
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
Definition: page_info.h:144
bool IsPortrait() const
Definition: page_info.h:117
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:120
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:110
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:143
void SetRenderSettings(RENDER_SETTINGS *aSettings)
Definition: plotter.h:140
virtual void SetTitle(const wxString &aTitle)
Definition: plotter.h:161
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:141
virtual void SetCreator(const wxString &aCreator)
Definition: plotter.h:159
bool GetColorMode() const
Definition: plotter.h:138
PAGE_INFO & PageSettings()
Definition: plotter.h:144
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:137
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 const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
Definition: project.cpp:304
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:62
virtual bool EndPlot() override
Definition: PS_plotter.cpp:926
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:384
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
Definition: PS_plotter.cpp:546
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:765
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.
bool ResolveTextVar(wxString *token, int aDepth) const
Definition: schematic.cpp:123
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:172
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:117
const std::map< wxString, wxString > * GetProperties()
Definition: schematic.h:78
SCH_SHEET & Root() const
Definition: schematic.h:90
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:75
const TITLE_BLOCK & GetTitleBlock() const override
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
const PAGE_INFO & GetPageSettings() const override
Schematic editor (Eeschema) main window.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_SHEET_PATH & GetCurrentSheet() const
SCHEMATIC & Schematic() const
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
wxString GetUniqueFilenameForCurrentSheet()
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:86
void Plot(PLOTTER *aPlotter) const
Plot all the schematic objects to aPlotter.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
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...
void UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
SCH_SCREEN * LastScreen()
wxString GetPageNumber() const
wxString PathHumanReadable(bool aUseShortRootName=true) const
Return the sheet path in a human readable form made from the sheet names.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:299
wxString GetName() const
Definition: sch_sheet.h:101
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
std::vector< COLOR_SETTINGS * > GetColorSettingsList()
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
virtual void SetColor(const COLOR4D &color) override
The SetColor implementation is split with the subclasses: The PSLIKE computes the rgb values,...
static wxString GetDefaultFileExtension()
const wxString & GetTitle() const
Definition: title_block.h:63
virtual long long int GetValue()
Return the current value in Internal Units.
void Enable(bool aEnable)
Enable/disable the label, widget and units label.
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
void SetFileName(const wxString &aReportFileName)
@ BLACK
Definition: color4d.h:44
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:295
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
Definition: common.cpp:57
const wxString ExpandEnvVarSubstitutions(const wxString &aString, PROJECT *aProject)
Replace any environment variable & text variable references with their values.
Definition: common.cpp:267
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)
static const wxChar * plot_sheet_list(int aSize)
@ HPGL_PAGE_SIZE_B
@ HPGL_PAGE_SIZE_D
@ HPGL_PAGE_SIZE_A1
@ HPGL_PAGE_SIZE_E
@ HPGL_PAGE_SIZE_A5
@ HPGL_PAGE_SIZE_A4
@ HPGL_PAGE_SIZE_C
@ HPGL_PAGE_SIZE_A
@ HPGL_PAGE_SIZE_A3
@ HPGL_PAGE_SIZE_A2
@ HPGL_PAGE_SIZE_A0
@ PAGE_SIZE_AUTO
@ PAGE_SIZE_A
@ PAGE_SIZE_A4
HPGL_PLOT_ORIGIN_AND_UNITS
#define _(s)
@ FILLED_SHAPE
const wxChar *const tracePathsAndFiles
Flag to enable path and file name debug output.
@ LAYER_SCHEMATIC_DRAWINGSHEET
Definition: layer_ids.h:382
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:376
PLOT_FORMAT
The set of supported output plot formats.
Definition: plotter.h:70
Plotting engine (DXF)
Plotting engine (HPGL)
Plotting engines similar to ps (PostScript, Gerber, svg)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_INFO
@ RPT_SEVERITY_ACTION
@ SHEETNAME
Definition: sch_sheet.h:43
const int scale
const double IU_PER_MM
Definition: base_units.h:77
const double IU_PER_MILS
Definition: base_units.h:78
constexpr int MilsToIU(int mils) const
Definition: base_units.h:94
constexpr int mmToIU(double mm) const
Definition: base_units.h:89
wxLogTrace helper definitions.
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().
Definition: wx_filename.h:38