From 643c97a2f467b8990af2886a9e8fde308431289d Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Thu, 5 Mar 2020 22:00:30 -0500 Subject: [PATCH] ADDED: Schematic plotting can use a dedicated color theme ADDED: PDF, PS, and SVG plots can optionally include the page background color Fixes #1830 --- common/plotters/PDF_plotter.cpp | 4 - common/plotters/plotter.cpp | 6 - demos/video/video.pro | 36 +- eeschema/dialogs/dialog_plot_schematic.cpp | 25 + eeschema/dialogs/dialog_plot_schematic.h | 4 +- .../dialogs/dialog_plot_schematic_base.cpp | 134 ++-- .../dialogs/dialog_plot_schematic_base.fbp | 695 ++++++------------ eeschema/dialogs/dialog_plot_schematic_base.h | 25 +- eeschema/eeschema_settings.cpp | 6 + eeschema/eeschema_settings.h | 14 +- eeschema/lib_arc.cpp | 5 +- eeschema/lib_circle.cpp | 5 +- eeschema/lib_field.cpp | 24 +- eeschema/lib_field.h | 2 + eeschema/lib_pin.cpp | 3 +- eeschema/lib_polyline.cpp | 5 +- eeschema/lib_rectangle.cpp | 5 +- eeschema/lib_text.cpp | 3 +- eeschema/plot_schematic_DXF.cpp | 11 +- eeschema/plot_schematic_HPGL.cpp | 5 +- eeschema/plot_schematic_PDF.cpp | 20 +- eeschema/plot_schematic_PS.cpp | 20 +- eeschema/plot_schematic_SVG.cpp | 30 +- eeschema/sch_bitmap.cpp | 5 +- eeschema/sch_bus_entry.cpp | 3 +- eeschema/sch_field.cpp | 3 +- eeschema/sch_junction.cpp | 3 +- eeschema/sch_line.cpp | 3 +- eeschema/sch_no_connect.cpp | 3 +- eeschema/sch_sheet.cpp | 9 +- eeschema/sch_text.cpp | 3 +- include/plotter.h | 11 +- 32 files changed, 501 insertions(+), 629 deletions(-) diff --git a/common/plotters/PDF_plotter.cpp b/common/plotters/PDF_plotter.cpp index 31efacb630..68ef28dce0 100644 --- a/common/plotters/PDF_plotter.cpp +++ b/common/plotters/PDF_plotter.cpp @@ -62,10 +62,6 @@ bool PDF_PLOTTER::OpenFile( const wxString& aFullFilename ) return true; } -void PDF_PLOTTER::SetPageSettings( const PAGE_INFO& aPageSettings ) -{ - pageInfo = aPageSettings; -} void PDF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil, double aScale, bool aMirror ) diff --git a/common/plotters/plotter.cpp b/common/plotters/plotter.cpp index 677bb87925..c24b0123c0 100644 --- a/common/plotters/plotter.cpp +++ b/common/plotters/plotter.cpp @@ -593,9 +593,3 @@ void PLOTTER::PlotPoly( const SHAPE_LINE_CHAIN& aCornerList, FILL_T aFill, PlotPoly( cornerList, aFill, aWidth, aData ); } - - -void PLOTTER::SetPageSettings( const PAGE_INFO& aPageSettings ) -{ - pageInfo = aPageSettings; -} diff --git a/demos/video/video.pro b/demos/video/video.pro index c0db125e81..28f10c7a90 100644 --- a/demos/video/video.pro +++ b/demos/video/video.pro @@ -1,6 +1,6 @@ -update=25/08/2019 19:59:15 +update=Thu 05 Mar 2020 20:34:10 EST version=1 -last_client=kicad +last_client=eeschema [general] version=1 RootSch=video.sch @@ -13,22 +13,6 @@ EquName1=devcms [eeschema] version=1 LibDir= -[schematic_editor] -version=1 -PageLayoutDescrFile= -PlotDirectoryName= -SubpartIdSeparator=0 -SubpartFirstId=65 -NetFmtName=Pcbnew -SpiceAjustPassiveValues=0 -LabSize=50 -ERC_WriteFile=0 -ERC_TestSimilarLabels=1 -ERC_CheckUniqueGlobalLabels=1 -ERC_CheckBusDriverConflicts=1 -ERC_CheckBusEntryConflicts=1 -ERC_CheckBusToBusConflicts=1 -ERC_CheckBusToNetConflicts=1 [pcbnew] version=1 PageLayoutDescrFile= @@ -270,3 +254,19 @@ uViaDrill=0.127 dPairWidth=0.2 dPairGap=0.25 dPairViaGap=0.25 +[schematic_editor] +version=1 +PageLayoutDescrFile= +PlotDirectoryName=/home/jon/Desktop/plot_tests/ +SubpartIdSeparator=0 +SubpartFirstId=65 +NetFmtName=Pcbnew +SpiceAjustPassiveValues=0 +LabSize=50 +ERC_WriteFile=0 +ERC_TestSimilarLabels=1 +ERC_CheckUniqueGlobalLabels=1 +ERC_CheckBusDriverConflicts=1 +ERC_CheckBusEntryConflicts=1 +ERC_CheckBusToBusConflicts=1 +ERC_CheckBusToNetConflicts=1 diff --git a/eeschema/dialogs/dialog_plot_schematic.cpp b/eeschema/dialogs/dialog_plot_schematic.cpp index 73a837d43a..550377d865 100644 --- a/eeschema/dialogs/dialog_plot_schematic.cpp +++ b/eeschema/dialogs/dialog_plot_schematic.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include @@ -85,6 +86,19 @@ void DIALOG_PLOT_SCHEMATIC::initDlg() { auto cfg = dynamic_cast( Kiface().KifaceSettings() ); + for( COLOR_SETTINGS* settings : Pgm().GetSettingsManager().GetColorSettingsList() ) + { + int idx = m_colorTheme->Append( settings->GetName(), static_cast( settings ) ); + + if( settings->GetFilename() == cfg->m_PlotPanel.color_theme ) + m_colorTheme->SetSelection( idx ); + } + + m_colorTheme->Enable( cfg->m_PlotPanel.color ); + + m_plotBackgroundColor->Enable( cfg->m_PlotPanel.color ); + m_plotBackgroundColor->SetValue( cfg->m_PlotPanel.background_color ); + // Set color or B&W plot option setModeColor( cfg->m_PlotPanel.color ); @@ -114,9 +128,11 @@ void DIALOG_PLOT_SCHEMATIC::initDlg() break; case PLOT_FORMAT::DXF: m_plotFormatOpt->SetSelection( 3 ); + m_plotBackgroundColor->Disable(); break; case PLOT_FORMAT::HPGL: m_plotFormatOpt->SetSelection( 4 ); + m_plotBackgroundColor->Disable(); break; } @@ -247,6 +263,12 @@ void DIALOG_PLOT_SCHEMATIC::OnUpdateUI( wxUpdateUIEvent& event ) m_plotOriginTitle->Enable( fmt == PLOT_FORMAT::HPGL ); m_plotOriginOpt->Enable( fmt == PLOT_FORMAT::HPGL ); m_penWidth.Enable( fmt == PLOT_FORMAT::HPGL ); + + m_plotBackgroundColor->Enable( + fmt == PLOT_FORMAT::POST || fmt == PLOT_FORMAT::PDF || fmt == PLOT_FORMAT::SVG ); + + m_colorTheme->Enable( fmt != PLOT_FORMAT::HPGL ); + m_ModeColorOption->Enable( fmt != PLOT_FORMAT::HPGL ); } } @@ -257,7 +279,10 @@ void DIALOG_PLOT_SCHEMATIC::getPlotOptions() auto cfg = dynamic_cast( Kiface().KifaceSettings() ); + cfg->m_PlotPanel.background_color = m_plotBackgroundColor->GetValue(); cfg->m_PlotPanel.color = getModeColor(); + cfg->m_PlotPanel.color_theme = static_cast( + m_colorTheme->GetClientData( m_colorTheme->GetSelection() ) )->GetFilename(); cfg->m_PlotPanel.frame_reference = getPlotFrameRef(); cfg->m_PlotPanel.format = static_cast( GetPlotFileFormat() ); cfg->m_PlotPanel.hpgl_origin = GetPlotOriginCenter(); diff --git a/eeschema/dialogs/dialog_plot_schematic.h b/eeschema/dialogs/dialog_plot_schematic.h index 648dec941a..8c2fb6a5b6 100644 --- a/eeschema/dialogs/dialog_plot_schematic.h +++ b/eeschema/dialogs/dialog_plot_schematic.h @@ -154,5 +154,7 @@ public: // outside a dialog. This is the reason we need aFrame as parameter static bool plotOneSheetSVG( EDA_DRAW_FRAME* aFrame, const wxString& aFileName, SCH_SCREEN* aScreen, - bool aPlotBlackAndWhite, bool aPlotFrameRef ); + bool aPlotBlackAndWhite, bool aPlotFrameRef, + bool aPlotBackgroundColor = false, + COLOR_SETTINGS* aColors = nullptr ); }; diff --git a/eeschema/dialogs/dialog_plot_schematic_base.cpp b/eeschema/dialogs/dialog_plot_schematic_base.cpp index f3b6b66412..59ba32a96e 100644 --- a/eeschema/dialogs/dialog_plot_schematic_base.cpp +++ b/eeschema/dialogs/dialog_plot_schematic_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -14,144 +14,160 @@ DIALOG_PLOT_SCHEMATIC_BASE::DIALOG_PLOT_SCHEMATIC_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) { this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize ); - + wxBoxSizer* bMainSizer; bMainSizer = new wxBoxSizer( wxVERTICAL ); - + wxBoxSizer* bSizerDir; bSizerDir = new wxBoxSizer( wxHORIZONTAL ); - + m_staticTextOutputDirectory = new wxStaticText( this, wxID_ANY, _("Output directory:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextOutputDirectory->Wrap( -1 ); bSizerDir->Add( m_staticTextOutputDirectory, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - + m_outputDirectoryName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_outputDirectoryName->SetToolTip( _("Target directory for plot files. Can be absolute or relative to the schematic main file location.") ); - + bSizerDir->Add( m_outputDirectoryName, 1, wxALIGN_CENTER_VERTICAL|wxLEFT, 4 ); - - m_browseButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); + + m_browseButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); m_browseButton->SetMinSize( wxSize( 30,28 ) ); - + bSizerDir->Add( m_browseButton, 0, wxRIGHT, 5 ); - - + + bMainSizer->Add( bSizerDir, 0, wxALL|wxEXPAND, 7 ); - + m_optionsSizer = new wxBoxSizer( wxHORIZONTAL ); - + wxString m_plotFormatOptChoices[] = { _("Postscript"), _("PDF"), _("SVG"), _("DXF"), _("HPGL") }; int m_plotFormatOptNChoices = sizeof( m_plotFormatOptChoices ) / sizeof( wxString ); m_plotFormatOpt = new wxRadioBox( this, wxID_ANY, _("Output Format"), wxDefaultPosition, wxDefaultSize, m_plotFormatOptNChoices, m_plotFormatOptChoices, 1, wxRA_SPECIFY_COLS ); m_plotFormatOpt->SetSelection( 2 ); m_optionsSizer->Add( m_plotFormatOpt, 0, wxALIGN_TOP|wxEXPAND|wxLEFT|wxRIGHT, 5 ); - + wxStaticBoxSizer* sbOptions; sbOptions = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options") ), wxVERTICAL ); - + wxGridBagSizer* gbSizer1; gbSizer1 = new wxGridBagSizer( 0, 0 ); gbSizer1->SetFlexibleDirection( wxBOTH ); gbSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - + m_staticText4 = new wxStaticText( sbOptions->GetStaticBox(), wxID_ANY, _("Page size:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText4->Wrap( -1 ); gbSizer1->Add( m_staticText4, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 ); - + wxString m_paperSizeOptionChoices[] = { _("Schematic size"), _("A4"), _("A") }; int m_paperSizeOptionNChoices = sizeof( m_paperSizeOptionChoices ) / sizeof( wxString ); m_paperSizeOption = new wxChoice( sbOptions->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_paperSizeOptionNChoices, m_paperSizeOptionChoices, 0 ); m_paperSizeOption->SetSelection( 0 ); gbSizer1->Add( m_paperSizeOption, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxRIGHT|wxLEFT, 5 ); - + m_PlotFrameRefOpt = new wxCheckBox( sbOptions->GetStaticBox(), wxID_ANY, _("Plot border and title block"), wxDefaultPosition, wxDefaultSize, 0 ); - m_PlotFrameRefOpt->SetValue(true); + m_PlotFrameRefOpt->SetValue(true); m_PlotFrameRefOpt->SetToolTip( _("Print the frame references.") ); - + gbSizer1->Add( m_PlotFrameRefOpt, wxGBPosition( 1, 0 ), wxGBSpan( 1, 2 ), wxALL, 5 ); - + wxStaticText* bOutputModeLabel; bOutputModeLabel = new wxStaticText( sbOptions->GetStaticBox(), wxID_ANY, _("Output mode:"), wxDefaultPosition, wxDefaultSize, 0 ); bOutputModeLabel->Wrap( -1 ); gbSizer1->Add( bOutputModeLabel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - + wxString m_ModeColorOptionChoices[] = { _("Color"), _("Black and White") }; int m_ModeColorOptionNChoices = sizeof( m_ModeColorOptionChoices ) / sizeof( wxString ); m_ModeColorOption = new wxChoice( sbOptions->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_ModeColorOptionNChoices, m_ModeColorOptionChoices, 0 ); m_ModeColorOption->SetSelection( 0 ); gbSizer1->Add( m_ModeColorOption, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxALL, 5 ); - + + m_plotBackgroundColor = new wxCheckBox( sbOptions->GetStaticBox(), wxID_ANY, _("Plot sheet background color"), wxDefaultPosition, wxDefaultSize, 0 ); + m_plotBackgroundColor->SetToolTip( _("Plot the background color if the output format supports it") ); + + gbSizer1->Add( m_plotBackgroundColor, wxGBPosition( 3, 0 ), wxGBSpan( 1, 3 ), wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 ); + + m_staticText9 = new wxStaticText( sbOptions->GetStaticBox(), wxID_ANY, _("Color theme:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText9->Wrap( -1 ); + gbSizer1->Add( m_staticText9, wxGBPosition( 4, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + + wxArrayString m_colorThemeChoices; + m_colorTheme = new wxChoice( sbOptions->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_colorThemeChoices, 0 ); + m_colorTheme->SetSelection( 0 ); + m_colorTheme->SetToolTip( _("Select the color theme to use for plotting") ); + + gbSizer1->Add( m_colorTheme, wxGBPosition( 4, 1 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 ); + m_lineWidthLabel = new wxStaticText( sbOptions->GetStaticBox(), wxID_ANY, _("Default line width:"), wxDefaultPosition, wxDefaultSize, 0 ); m_lineWidthLabel->Wrap( -1 ); - gbSizer1->Add( m_lineWidthLabel, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - + gbSizer1->Add( m_lineWidthLabel, wxGBPosition( 5, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + m_lineWidthCtrl = new wxTextCtrl( sbOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_lineWidthCtrl->SetToolTip( _("Selection of the default pen thickness used to draw items, when their thickness is set to 0.") ); - - gbSizer1->Add( m_lineWidthCtrl, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxALL, 5 ); - + + gbSizer1->Add( m_lineWidthCtrl, wxGBPosition( 5, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxALL, 5 ); + m_lineWidthUnits = new wxStaticText( sbOptions->GetStaticBox(), wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); m_lineWidthUnits->Wrap( -1 ); - gbSizer1->Add( m_lineWidthUnits, wxGBPosition( 3, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxTOP, 5 ); - - + gbSizer1->Add( m_lineWidthUnits, wxGBPosition( 5, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxTOP, 5 ); + + gbSizer1->AddGrowableCol( 1 ); - + sbOptions->Add( gbSizer1, 1, wxEXPAND, 5 ); - - + + m_optionsSizer->Add( sbOptions, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - + m_HPGLOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("HPGL Options") ), wxVERTICAL ); - + wxGridBagSizer* gbSizer2; gbSizer2 = new wxGridBagSizer( 0, 0 ); gbSizer2->SetFlexibleDirection( wxBOTH ); gbSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - + m_plotOriginTitle = new wxStaticText( m_HPGLOptionsSizer->GetStaticBox(), wxID_ANY, _("Position:"), wxDefaultPosition, wxDefaultSize, 0 ); m_plotOriginTitle->Wrap( -1 ); gbSizer2->Add( m_plotOriginTitle, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 ); - + wxString m_plotOriginOptChoices[] = { _("Bottom left"), _("Center on page") }; int m_plotOriginOptNChoices = sizeof( m_plotOriginOptChoices ) / sizeof( wxString ); m_plotOriginOpt = new wxChoice( m_HPGLOptionsSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_plotOriginOptNChoices, m_plotOriginOptChoices, 0 ); m_plotOriginOpt->SetSelection( 0 ); gbSizer2->Add( m_plotOriginOpt, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - + m_penWidthLabel = new wxStaticText( m_HPGLOptionsSizer->GetStaticBox(), wxID_ANY, _("Pen width:"), wxDefaultPosition, wxDefaultSize, 0 ); m_penWidthLabel->Wrap( -1 ); gbSizer2->Add( m_penWidthLabel, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 ); - + m_penWidthCtrl = new wxTextCtrl( m_HPGLOptionsSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); gbSizer2->Add( m_penWidthCtrl, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxALL, 5 ); - + m_penWidthUnits = new wxStaticText( m_HPGLOptionsSizer->GetStaticBox(), wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); m_penWidthUnits->Wrap( -1 ); gbSizer2->Add( m_penWidthUnits, wxGBPosition( 1, 2 ), wxGBSpan( 1, 1 ), wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); - - + + gbSizer2->AddGrowableCol( 1 ); - + m_HPGLOptionsSizer->Add( gbSizer2, 1, wxEXPAND, 5 ); - - + + m_optionsSizer->Add( m_HPGLOptionsSizer, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - - + + bMainSizer->Add( m_optionsSizer, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - + wxBoxSizer* bSizerMsgPanel; bSizerMsgPanel = new wxBoxSizer( wxVERTICAL ); - + m_MessagesBox = new WX_HTML_REPORT_PANEL( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_MessagesBox->SetMinSize( wxSize( 300,150 ) ); - + bSizerMsgPanel->Add( m_MessagesBox, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - - + + bMainSizer->Add( bSizerMsgPanel, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - + m_sdbSizer1 = new wxStdDialogButtonSizer(); m_sdbSizer1OK = new wxButton( this, wxID_OK ); m_sdbSizer1->AddButton( m_sdbSizer1OK ); @@ -160,14 +176,14 @@ DIALOG_PLOT_SCHEMATIC_BASE::DIALOG_PLOT_SCHEMATIC_BASE( wxWindow* parent, wxWind m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL ); m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); m_sdbSizer1->Realize(); - + bMainSizer->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 5 ); - - + + this->SetSizer( bMainSizer ); this->Layout(); bMainSizer->Fit( this ); - + // Connect Events this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnCloseWindow ) ); this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnUpdateUI ) ); @@ -188,5 +204,5 @@ DIALOG_PLOT_SCHEMATIC_BASE::~DIALOG_PLOT_SCHEMATIC_BASE() m_paperSizeOption->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnPageSizeSelected ), NULL, this ); m_sdbSizer1Apply->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnPlotCurrent ), NULL, this ); m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnPlotAll ), NULL, this ); - + } diff --git a/eeschema/dialogs/dialog_plot_schematic_base.fbp b/eeschema/dialogs/dialog_plot_schematic_base.fbp index a72f893b67..4a24e59a72 100644 --- a/eeschema/dialogs/dialog_plot_schematic_base.fbp +++ b/eeschema/dialogs/dialog_plot_schematic_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -14,6 +14,7 @@ dialog_plot_schematic_base 1000 none + 1 Dialog_plot_schematic_base @@ -52,41 +53,7 @@ - - - - - - - - - OnCloseWindow - - - - - - - - - - - - - - - - - - - - - - - - - OnUpdateUI @@ -135,6 +102,7 @@ 0 wxID_ANY Output directory: + 0 0 @@ -160,29 +128,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -247,33 +192,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -298,6 +216,7 @@ 1 1 + 0 0 @@ -311,9 +230,10 @@ 0 0 - wxID_ANY Browse + + 0 0 @@ -328,11 +248,12 @@ protected 1 + + Resizable - 1 - wxBU_AUTODRAW + ; forward_declare 0 @@ -344,29 +265,6 @@ OnOutputDirectoryBrowseClicked - - - - - - - - - - - - - - - - - - - - - - - @@ -444,30 +342,7 @@ - - - - - - - - - - - - - - - - - OnPlotFormatSelection - - - - - - @@ -482,7 +357,6 @@ wxVERTICAL 1 none - 5 wxEXPAND @@ -534,6 +408,7 @@ 0 wxID_ANY Page size: + 0 0 @@ -559,29 +434,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -649,30 +501,7 @@ - OnPageSizeSelected - - - - - - - - - - - - - - - - - - - - - - @@ -740,30 +569,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -802,6 +607,7 @@ 0 wxID_ANY Output mode: + 0 0 @@ -827,29 +633,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -917,30 +700,204 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + 5 + 3 + 0 + wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND + 3 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Plot sheet background color + + 0 + + + 0 + + 1 + m_plotBackgroundColor + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + Plot the background color if the output format supports it + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + 1 + 0 + wxALIGN_CENTER_VERTICAL|wxALL + 4 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Color theme: + 0 + + 0 + + + 0 + + 1 + m_staticText9 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + 1 + 1 + wxALL|wxEXPAND + 4 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_colorTheme + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + ; ; forward_declare + 0 + Select the color theme to use for plotting + + wxFILTER_NONE + wxDefaultValidator + + + + @@ -948,7 +905,7 @@ 1 0 wxALIGN_CENTER_VERTICAL|wxLEFT - 3 + 5 1 1 @@ -979,6 +936,7 @@ 0 wxID_ANY Default line width: + 0 0 @@ -1004,29 +962,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -1034,7 +969,7 @@ 1 1 wxEXPAND|wxALL - 3 + 5 1 1 @@ -1094,33 +1029,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1128,7 +1036,7 @@ 1 2 wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxTOP - 3 + 5 1 1 @@ -1159,6 +1067,7 @@ 0 wxID_ANY mm + 0 0 @@ -1184,29 +1093,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -1225,7 +1111,6 @@ wxVERTICAL 1 protected - 5 wxEXPAND @@ -1277,6 +1162,7 @@ 0 wxID_ANY Position: + 0 0 @@ -1302,29 +1188,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -1392,30 +1255,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -1454,6 +1293,7 @@ 0 wxID_ANY Pen width: + 0 0 @@ -1479,29 +1319,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -1569,33 +1386,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1634,6 +1424,7 @@ 0 wxID_ANY mm + 0 0 @@ -1659,29 +1450,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -1754,29 +1522,6 @@ wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - @@ -1798,13 +1543,7 @@ m_sdbSizer1 protected OnPlotCurrent - - - - OnPlotAll - - diff --git a/eeschema/dialogs/dialog_plot_schematic_base.h b/eeschema/dialogs/dialog_plot_schematic_base.h index ca3d9f9961..5d1930e255 100644 --- a/eeschema/dialogs/dialog_plot_schematic_base.h +++ b/eeschema/dialogs/dialog_plot_schematic_base.h @@ -1,12 +1,11 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __DIALOG_PLOT_SCHEMATIC_BASE_H__ -#define __DIALOG_PLOT_SCHEMATIC_BASE_H__ +#pragma once #include #include @@ -21,10 +20,10 @@ class WX_HTML_REPORT_PANEL; #include #include #include +#include #include #include #include -#include #include #include #include @@ -43,7 +42,7 @@ class WX_HTML_REPORT_PANEL; class DIALOG_PLOT_SCHEMATIC_BASE : public DIALOG_SHIM { private: - + protected: wxStaticText* m_staticTextOutputDirectory; wxTextCtrl* m_outputDirectoryName; @@ -54,6 +53,9 @@ class DIALOG_PLOT_SCHEMATIC_BASE : public DIALOG_SHIM wxChoice* m_paperSizeOption; wxCheckBox* m_PlotFrameRefOpt; wxChoice* m_ModeColorOption; + wxCheckBox* m_plotBackgroundColor; + wxStaticText* m_staticText9; + wxChoice* m_colorTheme; wxStaticText* m_lineWidthLabel; wxTextCtrl* m_lineWidthCtrl; wxStaticText* m_lineWidthUnits; @@ -68,7 +70,7 @@ class DIALOG_PLOT_SCHEMATIC_BASE : public DIALOG_SHIM wxButton* m_sdbSizer1OK; wxButton* m_sdbSizer1Apply; wxButton* m_sdbSizer1Cancel; - + // Virtual event handlers, overide them in your derived class virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); } virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } @@ -77,13 +79,12 @@ class DIALOG_PLOT_SCHEMATIC_BASE : public DIALOG_SHIM virtual void OnPageSizeSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnPlotCurrent( wxCommandEvent& event ) { event.Skip(); } virtual void OnPlotAll( wxCommandEvent& event ) { event.Skip(); } - - + + public: - - DIALOG_PLOT_SCHEMATIC_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Plot Schematic Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + + DIALOG_PLOT_SCHEMATIC_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Plot Schematic Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_PLOT_SCHEMATIC_BASE(); - + }; -#endif //__DIALOG_PLOT_SCHEMATIC_BASE_H__ diff --git a/eeschema/eeschema_settings.cpp b/eeschema/eeschema_settings.cpp index 3a42db4cc1..0b038c83f3 100644 --- a/eeschema/eeschema_settings.cpp +++ b/eeschema/eeschema_settings.cpp @@ -177,8 +177,14 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() : APP_SETTINGS_BASE( "eeschema", eeschema m_params.emplace_back( new PARAM_MAP( "field_editor.fields_group_by", &m_FieldEditorPanel.fields_group_by, {} ) ); + m_params.emplace_back( + new PARAM( "plot.background_color", &m_PlotPanel.background_color, false ) ); + m_params.emplace_back( new PARAM( "plot.color", &m_PlotPanel.color, true ) ); + m_params.emplace_back( + new PARAM( "plot.color_theme", &m_PlotPanel.color_theme, wxT( "user" ) ) ); + m_params.emplace_back( new PARAM( "plot.format", &m_PlotPanel.format, 0 ) ); m_params.emplace_back( new PARAM( "plot.frame_reference", diff --git a/eeschema/eeschema_settings.h b/eeschema/eeschema_settings.h index e5c52eb1e1..296a87b69f 100644 --- a/eeschema/eeschema_settings.h +++ b/eeschema/eeschema_settings.h @@ -130,12 +130,14 @@ public: struct PANEL_PLOT { - bool color; - int format; - bool frame_reference; - int hpgl_paper_size; - double hpgl_pen_size; - bool hpgl_origin; + bool background_color; + bool color; + wxString color_theme; + int format; + bool frame_reference; + int hpgl_paper_size; + double hpgl_pen_size; + bool hpgl_origin; }; struct PANEL_SYM_CHOOSER diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp index 508490d5cd..687b830551 100644 --- a/eeschema/lib_arc.cpp +++ b/eeschema/lib_arc.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include // Helper function @@ -272,7 +273,7 @@ void LIB_ARC::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR ) { - aPlotter->SetColor( GetLayerColor( LAYER_DEVICE_BACKGROUND ) ); + aPlotter->SetColor( aPlotter->ColorSettings()->GetColor( LAYER_DEVICE_BACKGROUND ) ); aPlotter->Arc( pos, -t2, -t1, m_Radius, FILLED_WITH_BG_BODYCOLOR, 0 ); } @@ -282,7 +283,7 @@ void LIB_ARC::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, if( !already_filled || pen_size > 0 ) { pen_size = std::max( 0, pen_size ); - aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) ); + aPlotter->SetColor( aPlotter->ColorSettings()->GetColor( LAYER_DEVICE ) ); aPlotter->Arc( pos, -t2, -t1, m_Radius, already_filled ? NO_FILL : m_Fill, pen_size ); } } diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp index cae301a324..a8c7ce8609 100644 --- a/eeschema/lib_circle.cpp +++ b/eeschema/lib_circle.cpp @@ -35,6 +35,7 @@ #include #include +#include #include @@ -175,7 +176,7 @@ void LIB_CIRCLE::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR ) { - aPlotter->SetColor( GetLayerColor( LAYER_DEVICE_BACKGROUND ) ); + aPlotter->SetColor( aPlotter->ColorSettings()->GetColor( LAYER_DEVICE_BACKGROUND ) ); aPlotter->Circle( pos, GetRadius() * 2, FILLED_WITH_BG_BODYCOLOR, 0 ); } @@ -185,7 +186,7 @@ void LIB_CIRCLE::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, if( !already_filled || pen_size > 0 ) { pen_size = std::max( 0, pen_size ); - aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) ); + aPlotter->SetColor( aPlotter->ColorSettings()->GetColor( LAYER_DEVICE ) ); aPlotter->Circle( pos, GetRadius() * 2, already_filled ? NO_FILL : m_Fill, pen_size ); } } diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index c2fac92953..e0f60a379c 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -39,6 +39,7 @@ #include #include #include +#include LIB_FIELD::LIB_FIELD(LIB_PART * aParent, int idfield ) : @@ -297,7 +298,14 @@ void LIB_FIELD::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, EDA_TEXT_VJUSTIFY_T vjustify = GR_TEXT_VJUSTIFY_CENTER; wxPoint textpos = aTransform.TransformCoordinate( BoundaryBox.Centre() ) + aOffset; - aPlotter->Text( textpos, GetDefaultColor(), GetShownText(), orient, GetTextSize(), + COLOR4D color; + + if( aPlotter->GetColorMode() ) + color = aPlotter->ColorSettings()->GetColor( GetDefaultLayer() ); + else + color = COLOR4D::BLACK; + + aPlotter->Text( textpos, color, GetShownText(), orient, GetTextSize(), hjustify, vjustify, GetPenSize(), IsItalic(), IsBold() ); } @@ -357,17 +365,23 @@ void LIB_FIELD::ViewGetLayers( int aLayers[], int& aCount ) const } -COLOR4D LIB_FIELD::GetDefaultColor() +SCH_LAYER_ID LIB_FIELD::GetDefaultLayer() { switch( m_id ) { - case REFERENCE: return GetLayerColor( LAYER_REFERENCEPART ); - case VALUE: return GetLayerColor( LAYER_VALUEPART ); - default: return GetLayerColor( LAYER_FIELDS ); + case REFERENCE: return LAYER_REFERENCEPART; + case VALUE: return LAYER_VALUEPART; + default: return LAYER_FIELDS; } } +COLOR4D LIB_FIELD::GetDefaultColor() +{ + return GetLayerColor( GetDefaultLayer() ); +} + + wxString LIB_FIELD::GetName( bool aTranslate ) const { switch( m_id ) diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h index eb6acdcada..0ae3f81f6f 100644 --- a/eeschema/lib_field.h +++ b/eeschema/lib_field.h @@ -172,6 +172,8 @@ public: COLOR4D GetDefaultColor() override; + SCH_LAYER_ID GetDefaultLayer(); + void BeginEdit( const wxPoint aStartPoint ) override; void Offset( const wxPoint& aOffset ) override; diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index ed5476c846..4dd43d2b52 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include @@ -868,7 +869,7 @@ void LIB_PIN::PrintPinElectricalTypeName( wxDC* aDC, wxPoint& aPosition, int aOr void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrientation ) { int MapX1, MapY1, x1, y1; - COLOR4D color = GetLayerColor( LAYER_PIN ); + COLOR4D color = aPlotter->ColorSettings()->GetColor( LAYER_PIN ); aPlotter->SetColor( color ); aPlotter->SetCurrentLineWidth( GetPenSize() ); diff --git a/eeschema/lib_polyline.cpp b/eeschema/lib_polyline.cpp index 93f9c8d198..c1dbb34bd3 100644 --- a/eeschema/lib_polyline.cpp +++ b/eeschema/lib_polyline.cpp @@ -34,6 +34,7 @@ #include #include +#include #include @@ -147,7 +148,7 @@ void LIB_POLYLINE::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR ) { - aPlotter->SetColor( GetLayerColor( LAYER_DEVICE_BACKGROUND ) ); + aPlotter->SetColor( aPlotter->ColorSettings()->GetColor( LAYER_DEVICE_BACKGROUND ) ); aPlotter->PlotPoly( cornerList, FILLED_WITH_BG_BODYCOLOR, 0 ); } @@ -157,7 +158,7 @@ void LIB_POLYLINE::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, if( !already_filled || pen_size > 0 ) { pen_size = std::max( 0, pen_size ); - aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) ); + aPlotter->SetColor( aPlotter->ColorSettings()->GetColor( LAYER_DEVICE ) ); aPlotter->PlotPoly( cornerList, already_filled ? NO_FILL : m_Fill, pen_size ); } } diff --git a/eeschema/lib_rectangle.cpp b/eeschema/lib_rectangle.cpp index b0fb774be5..8f620458a9 100644 --- a/eeschema/lib_rectangle.cpp +++ b/eeschema/lib_rectangle.cpp @@ -34,6 +34,7 @@ #include #include +#include #include @@ -140,7 +141,7 @@ void LIB_RECTANGLE::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR ) { - aPlotter->SetColor( GetLayerColor( LAYER_DEVICE_BACKGROUND ) ); + aPlotter->SetColor( aPlotter->ColorSettings()->GetColor( LAYER_DEVICE_BACKGROUND ) ); aPlotter->Rect( pos, end, FILLED_WITH_BG_BODYCOLOR, 0 ); } @@ -150,7 +151,7 @@ void LIB_RECTANGLE::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, if( !already_filled || pen_size > 0 ) { pen_size = std::max( 0, pen_size ); - aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) ); + aPlotter->SetColor( aPlotter->ColorSettings()->GetColor( LAYER_DEVICE ) ); aPlotter->Rect( pos, end, already_filled ? NO_FILL : m_Fill, pen_size ); } } diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index 7b16df8df1..8d264cf152 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include @@ -287,7 +288,7 @@ void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill, COLOR4D color; if( plotter->GetColorMode() ) // Used normal color or selected color - color = GetDefaultColor(); + color = plotter->ColorSettings()->GetColor( LAYER_DEVICE ); else color = COLOR4D::BLACK; diff --git a/eeschema/plot_schematic_DXF.cpp b/eeschema/plot_schematic_DXF.cpp index 1f76a90d25..45b0f5d5a0 100644 --- a/eeschema/plot_schematic_DXF.cpp +++ b/eeschema/plot_schematic_DXF.cpp @@ -112,10 +112,13 @@ bool DIALOG_PLOT_SCHEMATIC::PlotOneSheetDXF( const wxString& aFileName, { DXF_PLOTTER* plotter = new DXF_PLOTTER(); + auto colors = static_cast( + m_colorTheme->GetClientData( m_colorTheme->GetSelection() ) ); + const PAGE_INFO& pageInfo = aScreen->GetPageSettings(); plotter->SetPageSettings( pageInfo ); plotter->SetColorMode( getModeColor() ); - plotter->SetColorSettings( Pgm().GetSettingsManager().GetColorSettings() ); + plotter->SetColorSettings( colors ); // Currently, plot units are in decimil plotter->SetViewport( aPlotOffset, IU_PER_MILS/10, aScale, false ); @@ -134,12 +137,16 @@ bool DIALOG_PLOT_SCHEMATIC::PlotOneSheetDXF( const wxString& aFileName, if( aPlotFrameRef ) { + COLOR4D color = plotter->GetColorMode() ? + plotter->ColorSettings()->GetColor( LAYER_SCHEMATIC_WORKSHEET ) : + COLOR4D::BLACK; + PlotWorkSheet( plotter, m_parent->GetTitleBlock(), m_parent->GetPageSettings(), aScreen->m_ScreenNumber, aScreen->m_NumberOfScreens, m_parent->GetScreenDesc(), aScreen->GetFileName(), - GetLayerColor( ( SCH_LAYER_ID )LAYER_WORKSHEET ) ); + color ); } aScreen->Plot( plotter ); diff --git a/eeschema/plot_schematic_HPGL.cpp b/eeschema/plot_schematic_HPGL.cpp index dd4cae5cfb..7897f81905 100644 --- a/eeschema/plot_schematic_HPGL.cpp +++ b/eeschema/plot_schematic_HPGL.cpp @@ -202,16 +202,13 @@ bool DIALOG_PLOT_SCHEMATIC::Plot_1_Page_HPGL( const wxString& aFileName, plotter->SetPenDiameter( m_HPGLPenSize ); plotter->StartPlot(); - plotter->SetColorSettings( Pgm().GetSettingsManager().GetColorSettings() ); - plotter->SetColor( BLACK ); - if( getPlotFrameRef() ) PlotWorkSheet( plotter, m_parent->GetTitleBlock(), m_parent->GetPageSettings(), aScreen->m_ScreenNumber, aScreen->m_NumberOfScreens, m_parent->GetScreenDesc(), aScreen->GetFileName(), - GetLayerColor( ( SCH_LAYER_ID )LAYER_WORKSHEET ) ); + COLOR4D::BLACK ); aScreen->Plot( plotter ); diff --git a/eeschema/plot_schematic_PDF.cpp b/eeschema/plot_schematic_PDF.cpp index 1291867127..92f95af92a 100644 --- a/eeschema/plot_schematic_PDF.cpp +++ b/eeschema/plot_schematic_PDF.cpp @@ -59,11 +59,14 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotFrameRef ) else sheetList.push_back( m_parent->GetCurrentSheet() ); + auto colors = static_cast( + m_colorTheme->GetClientData( m_colorTheme->GetSelection() ) ); + // Allocate the plotter and set the job level parameter PDF_PLOTTER* plotter = new PDF_PLOTTER(); plotter->SetDefaultLineWidth( GetDefaultLineThickness() ); plotter->SetColorMode( getModeColor() ); - plotter->SetColorSettings( Pgm().GetSettingsManager().GetColorSettings() ); + plotter->SetColorSettings( colors ); plotter->SetCreator( wxT( "Eeschema-PDF" ) ); plotter->SetTitle( m_parent->GetTitleBlock().GetTitle() ); @@ -148,15 +151,26 @@ void DIALOG_PLOT_SCHEMATIC::plotOneSheetPDF( PLOTTER* aPlotter, SCH_SCREEN* aScreen, bool aPlotFrameRef ) { + if( m_plotBackgroundColor->GetValue() ) + { + aPlotter->SetColor( aPlotter->ColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND ) ); + wxPoint end( aPlotter->PageSettings().GetWidthIU(), + aPlotter->PageSettings().GetHeightIU() ); + aPlotter->Rect( wxPoint( 0, 0 ), end, FILLED_SHAPE, 1.0 ); + } + if( aPlotFrameRef ) { - aPlotter->SetColor( BLACK ); + COLOR4D color = aPlotter->GetColorMode() ? + aPlotter->ColorSettings()->GetColor( LAYER_SCHEMATIC_WORKSHEET ) : + COLOR4D::BLACK; + PlotWorkSheet( aPlotter, m_parent->GetTitleBlock(), m_parent->GetPageSettings(), aScreen->m_ScreenNumber, aScreen->m_NumberOfScreens, m_parent->GetScreenDesc(), aScreen->GetFileName(), - GetLayerColor( ( SCH_LAYER_ID )LAYER_WORKSHEET ) ); + color ); } aScreen->Plot( aPlotter ); diff --git a/eeschema/plot_schematic_PS.cpp b/eeschema/plot_schematic_PS.cpp index 519b1cb0e7..27e0925384 100644 --- a/eeschema/plot_schematic_PS.cpp +++ b/eeschema/plot_schematic_PS.cpp @@ -136,13 +136,16 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetPS( const wxString& aFileName, double aScale, bool aPlotFrameRef ) { + auto colors = static_cast( + m_colorTheme->GetClientData( m_colorTheme->GetSelection() ) ); + PS_PLOTTER* plotter = new PS_PLOTTER(); plotter->SetPageSettings( aPageInfo ); plotter->SetDefaultLineWidth( GetDefaultLineThickness() ); plotter->SetColorMode( getModeColor() ); + plotter->SetColorSettings( colors ); // Currently, plot units are in decimil plotter->SetViewport( aPlot0ffset, IU_PER_MILS/10, aScale, false ); - plotter->SetColorSettings( Pgm().GetSettingsManager().GetColorSettings() ); // Init : plotter->SetCreator( wxT( "Eeschema-PS" ) ); @@ -157,15 +160,26 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetPS( const wxString& aFileName, plotter->StartPlot(); + if( m_plotBackgroundColor ) + { + plotter->SetColor( plotter->ColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND ) ); + wxPoint end( plotter->PageSettings().GetWidthIU(), + plotter->PageSettings().GetHeightIU() ); + plotter->Rect( wxPoint( 0, 0 ), end, FILLED_SHAPE, 1.0 ); + } + if( aPlotFrameRef ) { - plotter->SetColor( BLACK ); + COLOR4D color = plotter->GetColorMode() ? + plotter->ColorSettings()->GetColor( LAYER_SCHEMATIC_WORKSHEET ) : + COLOR4D::BLACK; + PlotWorkSheet( plotter, m_parent->GetTitleBlock(), m_parent->GetPageSettings(), aScreen->m_ScreenNumber, aScreen->m_NumberOfScreens, m_parent->GetScreenDesc(), aScreen->GetFileName(), - GetLayerColor( ( SCH_LAYER_ID )LAYER_WORKSHEET ) ); + color ); } aScreen->Plot( plotter ); diff --git a/eeschema/plot_schematic_SVG.cpp b/eeschema/plot_schematic_SVG.cpp index fe318627c3..2b3d0a0fcc 100644 --- a/eeschema/plot_schematic_SVG.cpp +++ b/eeschema/plot_schematic_SVG.cpp @@ -48,6 +48,9 @@ void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef ) SCH_SHEET_PATH oldsheetpath = m_parent->GetCurrentSheet(); SCH_SHEET_LIST sheetList; + auto colors = static_cast( + m_colorTheme->GetClientData( m_colorTheme->GetSelection() ) ); + if( aPrintAll ) sheetList.BuildSheetList( g_RootSheet ); else @@ -70,7 +73,8 @@ void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef ) bool success = plotOneSheetSVG( m_parent, plotFileName.GetFullPath(), screen, getModeColor() ? false : true, - aPrintFrameRef ); + aPrintFrameRef, m_plotBackgroundColor->GetValue(), + colors ); if( !success ) { @@ -102,15 +106,20 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG( EDA_DRAW_FRAME* aFrame, const wxString& aFileName, SCH_SCREEN* aScreen, bool aPlotBlackAndWhite, - bool aPlotFrameRef ) + bool aPlotFrameRef, + bool aPlotBackgroundColor, + COLOR_SETTINGS* aColors ) { SVG_PLOTTER* plotter = new SVG_PLOTTER(); + if( !aColors ) + aColors = aFrame->GetColorSettings(); + const PAGE_INFO& pageInfo = aScreen->GetPageSettings(); plotter->SetPageSettings( pageInfo ); plotter->SetDefaultLineWidth( GetDefaultLineThickness() ); plotter->SetColorMode( aPlotBlackAndWhite ? false : true ); - plotter->SetColorSettings( Pgm().GetSettingsManager().GetColorSettings() ); + plotter->SetColorSettings( aColors ); wxPoint plot_offset; double scale = 1.0; // Currently, plot units are in decimil @@ -129,15 +138,26 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG( EDA_DRAW_FRAME* aFrame, plotter->StartPlot(); + if( aPlotBackgroundColor ) + { + plotter->SetColor( plotter->ColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND ) ); + wxPoint end( plotter->PageSettings().GetWidthIU(), + plotter->PageSettings().GetHeightIU() ); + plotter->Rect( wxPoint( 0, 0 ), end, FILLED_SHAPE, 1.0 ); + } + if( aPlotFrameRef ) { - plotter->SetColor( BLACK ); + COLOR4D color = plotter->GetColorMode() ? + plotter->ColorSettings()->GetColor( LAYER_SCHEMATIC_WORKSHEET ) : + COLOR4D::BLACK; + PlotWorkSheet( plotter, aFrame->GetTitleBlock(), aFrame->GetPageSettings(), aScreen->m_ScreenNumber, aScreen->m_NumberOfScreens, aFrame->GetScreenDesc(), aScreen->GetFileName(), - GetLayerColor( ( SCH_LAYER_ID )LAYER_WORKSHEET ) ); + color ); } aScreen->Plot( plotter ); diff --git a/eeschema/sch_bitmap.cpp b/eeschema/sch_bitmap.cpp index ebfade20cd..6025db6de6 100644 --- a/eeschema/sch_bitmap.cpp +++ b/eeschema/sch_bitmap.cpp @@ -28,6 +28,8 @@ #include #include +#include +#include #include #include #include @@ -183,7 +185,8 @@ bool SCH_BITMAP::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy void SCH_BITMAP::Plot( PLOTTER* aPlotter ) { - m_image->PlotImage( aPlotter, m_pos, GetLayerColor( GetLayer() ), GetPenSize() ); + m_image->PlotImage( + aPlotter, m_pos, aPlotter->ColorSettings()->GetColor( GetLayer() ), GetPenSize() ); } diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index d2e59ab2d5..15167433df 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -36,6 +36,7 @@ #include #include #include +#include SCH_BUS_ENTRY_BASE::SCH_BUS_ENTRY_BASE( KICAD_T aType, const wxPoint& pos, char shape ) : @@ -351,7 +352,7 @@ bool SCH_BUS_ENTRY_BASE::HitTest( const EDA_RECT& aRect, bool aContained, int aA void SCH_BUS_ENTRY_BASE::Plot( PLOTTER* aPlotter ) { aPlotter->SetCurrentLineWidth( GetPenSize() ); - aPlotter->SetColor( GetLayerColor( GetLayer() ) ); + aPlotter->SetColor( aPlotter->ColorSettings()->GetColor( GetLayer() ) ); aPlotter->MoveTo( m_pos ); aPlotter->FinishTo( m_End() ); } diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 52e19213b2..ee2fadfdec 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -432,7 +433,7 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter ) wxCHECK_RET( parent != NULL && parent->Type() == SCH_COMPONENT_T, wxT( "Cannot plot field with invalid parent." ) ); - COLOR4D color = GetLayerColor( GetLayer() ); + COLOR4D color = aPlotter->ColorSettings()->GetColor( GetLayer() ); if( !IsVisible() ) return; diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index 55883730d9..3270c5e137 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -39,6 +39,7 @@ #include #include #include +#include int SCH_JUNCTION::m_symbolSize = Mils2iu( 40 ); // Default diameter of the junction symbol @@ -194,7 +195,7 @@ bool SCH_JUNCTION::doIsConnected( const wxPoint& aPosition ) const void SCH_JUNCTION::Plot( PLOTTER* aPlotter ) { - aPlotter->SetColor( GetLayerColor( GetLayer() ) ); + aPlotter->SetColor( aPlotter->ColorSettings()->GetColor( GetLayer() ) ); aPlotter->Circle( m_pos, GetEffectiveSymbolSize(), FILLED_SHAPE ); } diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index ef3b7a2cea..f18b952499 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -758,7 +759,7 @@ void SCH_LINE::Plot( PLOTTER* aPlotter ) if( m_color != COLOR4D::UNSPECIFIED ) aPlotter->SetColor( m_color ); else - aPlotter->SetColor( GetLayerColor( GetLayer() ) ); + aPlotter->SetColor( aPlotter->ColorSettings()->GetColor( GetLayer() ) ); aPlotter->SetCurrentLineWidth( GetPenSize() ); diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp index 70376c35e2..4a3166b057 100644 --- a/eeschema/sch_no_connect.cpp +++ b/eeschema/sch_no_connect.cpp @@ -38,6 +38,7 @@ #include #include #include +#include SCH_NO_CONNECT::SCH_NO_CONNECT( const wxPoint& pos ) : @@ -193,7 +194,7 @@ void SCH_NO_CONNECT::Plot( PLOTTER* aPlotter ) pY = m_pos.y; aPlotter->SetCurrentLineWidth( GetPenSize() ); - aPlotter->SetColor( GetLayerColor( GetLayer() ) ); + aPlotter->SetColor( aPlotter->ColorSettings()->GetColor( LAYER_NOCONNECT ) ); aPlotter->MoveTo( wxPoint( pX - delta, pY - delta ) ); aPlotter->FinishTo( wxPoint( pX + delta, pY + delta ) ); aPlotter->MoveTo( wxPoint( pX + delta, pY - delta ) ); diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 9a0c773854..eba596ca5d 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -888,7 +889,7 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter ) wxPoint pos_sheetname, pos_filename; wxPoint pos; - aPlotter->SetColor( GetLayerColor( GetLayer() ) ); + aPlotter->SetColor( aPlotter->ColorSettings()->GetColor( GetLayer() ) ); int thickness = GetPenSize(); aPlotter->SetCurrentLineWidth( thickness ); @@ -932,7 +933,7 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter ) thickness = GetDefaultLineThickness(); thickness = Clamp_Text_PenSize( thickness, size, false ); - aPlotter->SetColor( GetLayerColor( LAYER_SHEETNAME ) ); + txtcolor = aPlotter->ColorSettings()->GetColor( LAYER_SHEETNAME ); aPlotter->Text( pos_sheetname, txtcolor, wxT( "Sheet: " ) + Text, name_orientation, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, @@ -947,14 +948,14 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter ) thickness = GetDefaultLineThickness(); thickness = Clamp_Text_PenSize( thickness, size, false ); - aPlotter->SetColor( GetLayerColor( LAYER_SHEETFILENAME ) ); + txtcolor = aPlotter->ColorSettings()->GetColor( LAYER_SHEETFILENAME ); aPlotter->Text( pos_filename, txtcolor, wxT( "File: " ) + Text, name_orientation, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, thickness, italic, false ); } - aPlotter->SetColor( GetLayerColor( GetLayer() ) ); + aPlotter->SetColor( aPlotter->ColorSettings()->GetColor( GetLayer() ) ); /* Draw texts : SheetLabel */ for( SCH_SHEET_PIN* sheetPin : m_pins ) diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 92a6f15da2..d99e3c0c4e 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -43,6 +43,7 @@ #include #include +#include #include #include @@ -513,7 +514,7 @@ bool SCH_TEXT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) void SCH_TEXT::Plot( PLOTTER* aPlotter ) { static std::vector Poly; - COLOR4D color = GetLayerColor( GetLayer() ); + COLOR4D color = aPlotter->ColorSettings()->GetColor( GetLayer() ); int tmp = GetThickness(); int thickness = GetPenSize(); diff --git a/include/plotter.h b/include/plotter.h index c174971d4f..5057710b9b 100644 --- a/include/plotter.h +++ b/include/plotter.h @@ -144,7 +144,15 @@ public: COLOR_SETTINGS* ColorSettings() { return m_colors; } - virtual void SetPageSettings( const PAGE_INFO& aPageSettings ); + virtual void SetPageSettings( const PAGE_INFO& aPageSettings ) + { + pageInfo = aPageSettings; + } + + PAGE_INFO& PageSettings() + { + return pageInfo; + } /** * Set the line width for the next drawing. @@ -889,7 +897,6 @@ public: /** PDF can have multiple pages, so SetPageSettings can be called * with the outputFile open (but not inside a page stream!) */ - virtual void SetPageSettings( const PAGE_INFO& aPageSettings ) override; virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil, double aScale, bool aMirror ) override; virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,