From f3457794cf16ee66929069cd89464df271946d26 Mon Sep 17 00:00:00 2001 From: Eldar Khayrullin Date: Sun, 16 Apr 2017 20:07:31 +0300 Subject: [PATCH] Pcbnew: add option to plot DXF editable text Add option to plot DXF oneline ASCII text as editable text (in non-outline mode) Fixes: lp:1423515 * https://bugs.launchpad.net/kicad/+bug/1423515 --- common/common_plotDXF_functions.cpp | 2 +- pcbnew/dialogs/dialog_plot.cpp | 23 ++++++++ pcbnew/dialogs/dialog_plot.h | 3 +- pcbnew/dialogs/dialog_plot_base.cpp | 8 +++ pcbnew/dialogs/dialog_plot_base.fbp | 90 ++++++++++++++++++++++++++++- pcbnew/dialogs/dialog_plot_base.h | 4 +- 6 files changed, 126 insertions(+), 4 deletions(-) diff --git a/common/common_plotDXF_functions.cpp b/common/common_plotDXF_functions.cpp index c001516cd7..fcbe7e8d6a 100644 --- a/common/common_plotDXF_functions.cpp +++ b/common/common_plotDXF_functions.cpp @@ -741,7 +741,7 @@ void DXF_PLOTTER::Text( const wxPoint& aPos, if( textAsLines || containsNonAsciiChars( aText ) || aMultilineAllowed ) { // output text as graphics. - // Perhaps miltiline texts could be handled as DXF text entity + // Perhaps multiline texts could be handled as DXF text entity // but I do not want spend time about this (JPC) PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic, aBold, aMultilineAllowed ); diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp index 5d01bdf0d1..5d756b3775 100644 --- a/pcbnew/dialogs/dialog_plot.cpp +++ b/pcbnew/dialogs/dialog_plot.cpp @@ -197,6 +197,9 @@ void DIALOG_PLOT::Init_Dialog() // Plot outline mode m_plotOutlineModeOpt->SetValue( m_plotOpts.GetPlotOutlineMode() ); + // Plot text mode + m_plotTextAsLineOpt->SetValue( m_plotOpts.GetTextMode() == PLOTTEXTMODE_DEFAULT ); + // Plot mirror option m_plotMirrorOpt->SetValue( m_plotOpts.GetMirror() ); @@ -298,6 +301,14 @@ void DIALOG_PLOT::CreateDrillFile( wxCommandEvent& event ) } +void DIALOG_PLOT::OnChangeOutlineMode( wxCommandEvent& event ) +{ + m_plotTextAsLineOpt->Enable( !m_plotOutlineModeOpt->GetValue() ); + if( !m_plotTextAsLineOpt->IsEnabled() ) + m_plotTextAsLineOpt->SetValue( true ); +} + + void DIALOG_PLOT::OnSetScaleOpt( wxCommandEvent& event ) { /* Disable sheet reference for scale != 1:1 */ @@ -388,6 +399,8 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event ) m_plotPSNegativeOpt->Enable( true ); m_forcePSA4OutputOpt->Enable( false ); m_forcePSA4OutputOpt->SetValue( false ); + m_plotTextAsLineOpt->Enable( false ); + m_plotTextAsLineOpt->SetValue( false ); m_PlotOptionsSizer->Hide( m_GerberOptionsSizer ); m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer ); @@ -411,6 +424,8 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event ) m_PSFineAdjustWidthOpt->Enable( true ); m_plotPSNegativeOpt->Enable( true ); m_forcePSA4OutputOpt->Enable( true ); + m_plotTextAsLineOpt->Enable( false ); + m_plotTextAsLineOpt->SetValue( true ); m_PlotOptionsSizer->Hide( m_GerberOptionsSizer ); m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer ); @@ -439,6 +454,8 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event ) m_plotPSNegativeOpt->SetValue( false ); m_forcePSA4OutputOpt->Enable( false ); m_forcePSA4OutputOpt->SetValue( false ); + m_plotTextAsLineOpt->Enable( false ); + m_plotTextAsLineOpt->SetValue( true ); m_PlotOptionsSizer->Show( m_GerberOptionsSizer ); m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer ); @@ -463,6 +480,8 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event ) m_plotPSNegativeOpt->SetValue( false ); m_plotPSNegativeOpt->Enable( false ); m_forcePSA4OutputOpt->Enable( true ); + m_plotTextAsLineOpt->Enable( false ); + m_plotTextAsLineOpt->SetValue( true ); m_PlotOptionsSizer->Hide( m_GerberOptionsSizer ); m_PlotOptionsSizer->Show( m_HPGLOptionsSizer ); @@ -493,6 +512,8 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event ) m_PlotOptionsSizer->Hide( m_GerberOptionsSizer ); m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer ); m_PlotOptionsSizer->Hide( m_PSOptionsSizer ); + + OnChangeOutlineMode( event ); break; default: @@ -568,6 +589,8 @@ void DIALOG_PLOT::applyPlotSettings() tempOptions.SetPlotMode( m_plotModeOpt->GetSelection() == 1 ? SKETCH : FILLED ); tempOptions.SetPlotOutlineMode( m_plotOutlineModeOpt->GetValue() ); tempOptions.SetPlotViaOnMaskLayer( m_plotNoViaOnMaskOpt->GetValue() ); + tempOptions.SetTextMode( m_plotTextAsLineOpt->GetValue() ? + PLOTTEXTMODE_DEFAULT : PLOTTEXTMODE_NATIVE ); // Update settings from text fields. Rewrite values back to the fields, // since the values may have been constrained by the setters. diff --git a/pcbnew/dialogs/dialog_plot.h b/pcbnew/dialogs/dialog_plot.h index 5fa534e77e..81aee9069b 100644 --- a/pcbnew/dialogs/dialog_plot.h +++ b/pcbnew/dialogs/dialog_plot.h @@ -66,10 +66,11 @@ private: void OnRightClick( wxMouseEvent& event ) override; void OnPopUpLayers( wxCommandEvent& event ) override; void SetPlotFormat( wxCommandEvent& event ) override; + void OnChangeOutlineMode( wxCommandEvent& event ) override; void OnSetScaleOpt( wxCommandEvent& event ) override; void CreateDrillFile( wxCommandEvent& event ) override; void OnGerberX2Checked( wxCommandEvent& event ) override; - virtual void onRunDRC( wxCommandEvent& event ) override; + void onRunDRC( wxCommandEvent& event ) override; // other functions void applyPlotSettings(); diff --git a/pcbnew/dialogs/dialog_plot_base.cpp b/pcbnew/dialogs/dialog_plot_base.cpp index fb5d57860d..c65fc8c880 100644 --- a/pcbnew/dialogs/dialog_plot_base.cpp +++ b/pcbnew/dialogs/dialog_plot_base.cpp @@ -134,6 +134,12 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr bSizerPlotItems->Add( m_plotOutlineModeOpt, 0, wxALL, 2 ); + m_plotTextAsLineOpt = new wxCheckBox( sbOptionsSizer->GetStaticBox(), wxID_ANY, _("Plot all text as lines"), wxDefaultPosition, wxDefaultSize, 0 ); + m_plotTextAsLineOpt->SetValue(true); + m_plotTextAsLineOpt->SetToolTip( _("Otherwise plot oneline ASCII text as editable text") ); + + bSizerPlotItems->Add( m_plotTextAsLineOpt, 0, wxALL, 2 ); + bSizer192->Add( bSizerPlotItems, 0, wxEXPAND, 5 ); @@ -415,6 +421,7 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr m_plotFormatOpt->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::SetPlotFormat ), NULL, this ); m_browseButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnOutputDirectoryBrowseClicked ), NULL, this ); m_layerCheckListBox->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( DIALOG_PLOT_BASE::OnRightClick ), NULL, this ); + m_plotOutlineModeOpt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnChangeOutlineMode ), NULL, this ); m_scaleOpt->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnSetScaleOpt ), NULL, this ); m_useGerberX2Attributes->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnGerberX2Checked ), NULL, this ); m_plotButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::Plot ), NULL, this ); @@ -437,6 +444,7 @@ DIALOG_PLOT_BASE::~DIALOG_PLOT_BASE() m_plotFormatOpt->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::SetPlotFormat ), NULL, this ); m_browseButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnOutputDirectoryBrowseClicked ), NULL, this ); m_layerCheckListBox->Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( DIALOG_PLOT_BASE::OnRightClick ), NULL, this ); + m_plotOutlineModeOpt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnChangeOutlineMode ), NULL, this ); m_scaleOpt->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnSetScaleOpt ), NULL, this ); m_useGerberX2Attributes->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnGerberX2Checked ), NULL, this ); m_plotButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::Plot ), NULL, this ); diff --git a/pcbnew/dialogs/dialog_plot_base.fbp b/pcbnew/dialogs/dialog_plot_base.fbp index 0fbe516857..0902b5cb0e 100644 --- a/pcbnew/dialogs/dialog_plot_base.fbp +++ b/pcbnew/dialogs/dialog_plot_base.fbp @@ -44,7 +44,7 @@ -1,-1 DIALOG_PLOT_BASE - 733,808 + 733,809 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Plot @@ -1666,6 +1666,94 @@ + OnChangeOutlineMode + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Plot all text as lines + + 0 + + + 0 + + 1 + m_plotTextAsLineOpt + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Otherwise plot oneline ASCII text as editable text + + wxFILTER_NONE + wxDefaultValidator + + + + + diff --git a/pcbnew/dialogs/dialog_plot_base.h b/pcbnew/dialogs/dialog_plot_base.h index 2507581324..7e7c4077f4 100644 --- a/pcbnew/dialogs/dialog_plot_base.h +++ b/pcbnew/dialogs/dialog_plot_base.h @@ -79,6 +79,7 @@ class DIALOG_PLOT_BASE : public DIALOG_SHIM wxCheckBox* m_plotPSNegativeOpt; wxCheckBox* m_useAuxOriginCheckBox; wxCheckBox* m_plotOutlineModeOpt; + wxCheckBox* m_plotTextAsLineOpt; wxStaticText* m_staticText11; wxChoice* m_drillShapeOpt; wxStaticText* m_staticText12; @@ -121,6 +122,7 @@ class DIALOG_PLOT_BASE : public DIALOG_SHIM virtual void OnRightClick( wxMouseEvent& event ) { event.Skip(); } virtual void SetPlotFormat( wxCommandEvent& event ) { event.Skip(); } virtual void OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) { event.Skip(); } + virtual void OnChangeOutlineMode( wxCommandEvent& event ) { event.Skip(); } virtual void OnSetScaleOpt( wxCommandEvent& event ) { event.Skip(); } virtual void OnGerberX2Checked( wxCommandEvent& event ) { event.Skip(); } virtual void Plot( wxCommandEvent& event ) { event.Skip(); } @@ -132,7 +134,7 @@ class DIALOG_PLOT_BASE : public DIALOG_SHIM public: - DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Plot"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 733,808 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Plot"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 733,809 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_PLOT_BASE(); void DIALOG_PLOT_BASEOnContextMenu( wxMouseEvent &event )