From 0af5695e51733445c0f246eb688c98201601cd76 Mon Sep 17 00:00:00 2001 From: Eldar Khayrullin Date: Sat, 22 Apr 2017 23:15:08 +0300 Subject: [PATCH] Pcbnew: add option to plot DXF lines in outline mode. Add option to plot dialog to plot DXF layers *.Cu, *.Adhes, *.Paste, and *.Mask in outline mode or line mode. Fixes lp:1643330 https://bugs.launchpad.net/kicad/+bug/1643330 --- common/common_plotDXF_functions.cpp | 5 +- pcbnew/dialogs/dialog_plot.cpp | 14 ++++ pcbnew/dialogs/dialog_plot_base.cpp | 8 ++- pcbnew/dialogs/dialog_plot_base.fbp | 102 ++++++++++++++++++++++++++-- pcbnew/dialogs/dialog_plot_base.h | 5 +- pcbnew/pcb_plot_params.cpp | 3 + pcbnew/pcb_plot_params.h | 6 ++ pcbnew/plot_board_layers.cpp | 6 +- 8 files changed, 134 insertions(+), 15 deletions(-) diff --git a/common/common_plotDXF_functions.cpp b/common/common_plotDXF_functions.cpp index 4eb2c47c34..c001516cd7 100644 --- a/common/common_plotDXF_functions.cpp +++ b/common/common_plotDXF_functions.cpp @@ -449,7 +449,7 @@ void DXF_PLOTTER::PlotPoly( const std::vector& aCornerList, // Now, output the final polygon to DXF file: last = path.PointCount() - 1; - VECTOR2I point = path.CPoint( 0 ); + VECTOR2I point = path.CPoint( 0 ); wxPoint startPoint( point.x, point.y ); MoveTo( startPoint ); @@ -505,7 +505,8 @@ void DXF_PLOTTER::SetDash( bool dashed ) void DXF_PLOTTER::ThickSegment( const wxPoint& aStart, const wxPoint& aEnd, int aWidth, EDA_DRAW_MODE_T aPlotMode, void* aData ) { - segmentAsOval( aStart, aEnd, aWidth, aPlotMode ); + MoveTo( aStart ); + FinishTo( aEnd ); } /* Plot an arc in DXF format diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp index ff67b194d8..bf336c6577 100644 --- a/pcbnew/dialogs/dialog_plot.cpp +++ b/pcbnew/dialogs/dialog_plot.cpp @@ -201,6 +201,9 @@ void DIALOG_PLOT::Init_Dialog() // Plot mode setPlotModeChoiceSelection( m_plotOpts.GetPlotMode() ); + // Plot outline mode + m_plotOutlineModeOpt->SetValue( m_plotOpts.GetPlotOutlineMode() ); + // Plot mirror option m_plotMirrorOpt->SetValue( m_plotOpts.GetMirror() ); @@ -369,6 +372,8 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event ) m_drillShapeOpt->Enable( true ); m_plotModeOpt->Enable( false ); setPlotModeChoiceSelection( FILLED ); + m_plotOutlineModeOpt->Enable( false ); + m_plotOutlineModeOpt->SetValue( false ); m_plotMirrorOpt->Enable( true ); m_useAuxOriginCheckBox->Enable( false ); m_useAuxOriginCheckBox->SetValue( false ); @@ -392,6 +397,8 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event ) case PLOT_FORMAT_POST: m_drillShapeOpt->Enable( true ); m_plotModeOpt->Enable( true ); + m_plotOutlineModeOpt->Enable( false ); + m_plotOutlineModeOpt->SetValue( false ); m_plotMirrorOpt->Enable( true ); m_useAuxOriginCheckBox->Enable( false ); m_useAuxOriginCheckBox->SetValue( false ); @@ -415,6 +422,8 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event ) m_drillShapeOpt->SetSelection( 0 ); m_plotModeOpt->Enable( false ); setPlotModeChoiceSelection( FILLED ); + m_plotOutlineModeOpt->Enable( false ); + m_plotOutlineModeOpt->SetValue( false ); m_plotMirrorOpt->Enable( false ); m_plotMirrorOpt->SetValue( false ); m_useAuxOriginCheckBox->Enable( true ); @@ -442,6 +451,8 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event ) case PLOT_FORMAT_HPGL: m_drillShapeOpt->Enable( true ); m_plotModeOpt->Enable( true ); + m_plotOutlineModeOpt->Enable( false ); + m_plotOutlineModeOpt->SetValue( false ); m_plotMirrorOpt->Enable( true ); m_useAuxOriginCheckBox->Enable( false ); m_useAuxOriginCheckBox->SetValue( false ); @@ -464,6 +475,8 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event ) case PLOT_FORMAT_DXF: m_drillShapeOpt->Enable( true ); m_plotModeOpt->Enable( false ); + setPlotModeChoiceSelection( FILLED ); + m_plotOutlineModeOpt->Enable( true ); m_plotMirrorOpt->Enable( false ); m_plotMirrorOpt->SetValue( false ); m_useAuxOriginCheckBox->Enable( true ); @@ -556,6 +569,7 @@ void DIALOG_PLOT::applyPlotSettings() ( m_drillShapeOpt->GetSelection() ) ); tempOptions.SetMirror( m_plotMirrorOpt->GetValue() ); tempOptions.SetPlotMode( m_plotModeOpt->GetSelection() == 1 ? SKETCH : FILLED ); + tempOptions.SetPlotOutlineMode( m_plotOutlineModeOpt->GetValue() ); tempOptions.SetPlotViaOnMaskLayer( m_plotNoViaOnMaskOpt->GetValue() ); // Update settings from text fields. Rewrite values back to the fields, diff --git a/pcbnew/dialogs/dialog_plot_base.cpp b/pcbnew/dialogs/dialog_plot_base.cpp index 2610f6d207..fb5d57860d 100644 --- a/pcbnew/dialogs/dialog_plot_base.cpp +++ b/pcbnew/dialogs/dialog_plot_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Feb 16 2016) +// C++ code generated with wxFormBuilder (version Dec 21 2016) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -128,6 +128,12 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr bSizerPlotItems->Add( m_useAuxOriginCheckBox, 0, wxALL, 2 ); + m_plotOutlineModeOpt = new wxCheckBox( sbOptionsSizer->GetStaticBox(), wxID_ANY, _("Plot lines in outline mode"), wxDefaultPosition, wxDefaultSize, 0 ); + m_plotOutlineModeOpt->SetValue(true); + m_plotOutlineModeOpt->SetToolTip( _("Otherwise plot with sketch lines in layers that don't support polygons (*.SilkS, *_User, Edge.Cuts, Margin, *.CrtYd, *.Fab) and plot in outline mode in other layers (*.Cu, *.Adhes, *.Paste, *.Mask)") ); + + bSizerPlotItems->Add( m_plotOutlineModeOpt, 0, wxALL, 2 ); + bSizer192->Add( bSizerPlotItems, 0, wxEXPAND, 5 ); diff --git a/pcbnew/dialogs/dialog_plot_base.fbp b/pcbnew/dialogs/dialog_plot_base.fbp index 8c66c17dd9..0fbe516857 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,673 + 733,808 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Plot @@ -88,7 +88,7 @@ - + m_MainSizer wxVERTICAL @@ -1603,6 +1603,94 @@ + + 2 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Plot lines in outline mode + + 0 + + + 0 + + 1 + m_plotOutlineModeOpt + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Otherwise plot with sketch lines in layers that don't support polygons (*.SilkS, *_User, Edge.Cuts, Margin, *.CrtYd, *.Fab) and plot in outline mode in other layers (*.Cu, *.Adhes, *.Paste, *.Mask) + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2870,11 +2958,11 @@ - + 2 wxALL 0 - + 1 1 1 @@ -4013,11 +4101,11 @@ - + 5 wxEXPAND 1 - + sbSizerMsg wxVERTICAL @@ -4104,7 +4192,7 @@ - + 5 wxALIGN_RIGHT|wxRIGHT|wxLEFT 0 diff --git a/pcbnew/dialogs/dialog_plot_base.h b/pcbnew/dialogs/dialog_plot_base.h index 5d1849b2b4..2507581324 100644 --- a/pcbnew/dialogs/dialog_plot_base.h +++ b/pcbnew/dialogs/dialog_plot_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Feb 16 2016) +// C++ code generated with wxFormBuilder (version Dec 21 2016) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -78,6 +78,7 @@ class DIALOG_PLOT_BASE : public DIALOG_SHIM wxCheckBox* m_plotMirrorOpt; wxCheckBox* m_plotPSNegativeOpt; wxCheckBox* m_useAuxOriginCheckBox; + wxCheckBox* m_plotOutlineModeOpt; wxStaticText* m_staticText11; wxChoice* m_drillShapeOpt; wxStaticText* m_staticText12; @@ -131,7 +132,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,673 ), 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,808 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_PLOT_BASE(); void DIALOG_PLOT_BASEOnContextMenu( wxMouseEvent &event ) diff --git a/pcbnew/pcb_plot_params.cpp b/pcbnew/pcb_plot_params.cpp index 980d51fa87..32f9436680 100644 --- a/pcbnew/pcb_plot_params.cpp +++ b/pcbnew/pcb_plot_params.cpp @@ -88,6 +88,7 @@ PCB_PLOT_PARAMS::PCB_PLOT_PARAMS() m_plotFrameRef = false; m_plotViaOnMaskLayer = false; m_plotMode = FILLED; + m_plotOutlineMode = true; m_useAuxOrigin = false; m_HPGLPenNum = 1; m_HPGLPenSpeed = 20; // this param is always in cm/s @@ -242,6 +243,8 @@ bool PCB_PLOT_PARAMS::operator==( const PCB_PLOT_PARAMS &aPcbPlotParams ) const return false; if( m_plotMode != aPcbPlotParams.m_plotMode ) return false; + if( m_plotOutlineMode != aPcbPlotParams.m_plotOutlineMode ) + return false; if( m_useAuxOrigin != aPcbPlotParams.m_useAuxOrigin ) return false; if( m_HPGLPenNum != aPcbPlotParams.m_HPGLPenNum ) diff --git a/pcbnew/pcb_plot_params.h b/pcbnew/pcb_plot_params.h index 1e17071d0c..6900356e19 100644 --- a/pcbnew/pcb_plot_params.h +++ b/pcbnew/pcb_plot_params.h @@ -54,6 +54,9 @@ private: */ EDA_DRAW_MODE_T m_plotMode; + /// Plot lines in outline mode + bool m_plotOutlineMode; + /// Plot format type (chooses the driver to be used) PlotFormat m_format; @@ -184,6 +187,9 @@ public: void SetPlotMode( EDA_DRAW_MODE_T aPlotMode ) { m_plotMode = aPlotMode; } EDA_DRAW_MODE_T GetPlotMode() const { return m_plotMode; } + void SetPlotOutlineMode( bool aFlag ) { m_plotOutlineMode = aFlag; } + bool GetPlotOutlineMode() const { return m_plotOutlineMode; } + void SetDrillMarksType( DrillMarksType aVal ) { m_drillMarks = aVal; } DrillMarksType GetDrillMarksType() const { return m_drillMarks; } diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index 57137c1680..c1cb28560a 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -223,7 +223,7 @@ void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, PCB_LAYER_ID aLayer, case F_SilkS: case B_SilkS: - if( plotOpt.GetFormat() == PLOT_FORMAT_DXF ) + if ( plotOpt.GetPlotOutlineMode() ) PlotLayerOutlines( aBoard, aPlotter, layer_mask, plotOpt ); else PlotSilkScreen( aBoard, aPlotter, layer_mask, plotOpt ); @@ -264,7 +264,7 @@ void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, PCB_LAYER_ID aLayer, plotOpt.SetSkipPlotNPTH_Pads( false ); plotOpt.SetDrillMarksType( PCB_PLOT_PARAMS::NO_DRILL_SHAPE ); - if( plotOpt.GetFormat() == PLOT_FORMAT_DXF ) + if ( plotOpt.GetPlotOutlineMode() ) PlotLayerOutlines( aBoard, aPlotter, layer_mask, plotOpt ); else PlotSilkScreen( aBoard, aPlotter, layer_mask, plotOpt ); @@ -274,7 +274,7 @@ void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, PCB_LAYER_ID aLayer, plotOpt.SetSkipPlotNPTH_Pads( false ); plotOpt.SetDrillMarksType( PCB_PLOT_PARAMS::NO_DRILL_SHAPE ); - if( plotOpt.GetFormat() == PLOT_FORMAT_DXF ) + if ( plotOpt.GetPlotOutlineMode() ) PlotLayerOutlines( aBoard, aPlotter, layer_mask, plotOpt ); else PlotStandardLayer( aBoard, aPlotter, layer_mask, plotOpt );