← Back to team overview

kicad-developers team mailing list archive

[PATCH v3] pcbnew: add option to set custom drill mark size during print

 

To help manaul drilling, the print dialog provides option to
print small drill marks.
This patch adds one more option to set custom drill mark size,
while keeping backward compability with previously saved
configuration values.

Fixes: lp:1287362
https://bugs.launchpad.net/kicad/+bug/128736
Signed-off-by: Zoltan Gyarmati <zgyarmati@xxxxxxxxxxxx>
---
Changes -> v2:
    * fix code style
    * use constexpr variable instead of magic number

Changes -> v3:
    * rework on the top of the print refactor changes

 pcbnew/dialogs/dialog_print_pcbnew.cpp | 41 ++++++++++++++++++++++++--
 pcbnew/pcbnew_printout.cpp             |  6 ++++
 pcbnew/pcbnew_printout.h               |  7 +++--
 pcbnew/pcbplot.h                       |  1 +
 4 files changed, 50 insertions(+), 5 deletions(-)

diff --git a/pcbnew/dialogs/dialog_print_pcbnew.cpp b/pcbnew/dialogs/dialog_print_pcbnew.cpp
index 00c1d54d6..9e3ecf14e 100644
--- a/pcbnew/dialogs/dialog_print_pcbnew.cpp
+++ b/pcbnew/dialogs/dialog_print_pcbnew.cpp
@@ -63,6 +63,8 @@ private:
     void onSelectAllClick( wxCommandEvent& event );
     void onDeselectAllClick( wxCommandEvent& event );
 
+    void onDrillMarksChoiceChange( wxCommandEvent& event );
+
     ///> (Un)checks all items in a checklist box
     void setListBoxValue( wxCheckListBox* aList, bool aValue );
 
@@ -96,6 +98,8 @@ private:
     wxCheckBox* m_checkboxNoEdge;
     wxCheckBox* m_checkboxMirror;
     wxChoice* m_drillMarksChoice;
+    wxTextCtrl* m_drillMarkSizeCtrl;
+    UNIT_BINDER* m_drillMarkSizeUnitBinder;
     wxRadioBox* m_boxPagination;
 };
 
@@ -144,6 +148,8 @@ bool DIALOG_PRINT_PCBNEW::TransferDataToWindow()
 
     // Options to plot pads and vias holes
     m_drillMarksChoice->SetSelection( settings()->m_drillMarks );
+    m_drillMarkSizeUnitBinder->Enable( settings()->m_drillMarks == PCBNEW_PRINTOUT_SETTINGS::CUSTOM_DRILL_SHAPE );
+    m_drillMarkSizeUnitBinder->SetValue( settings()->m_drillShapeCustomSize );
 
     // Print all layers one one page or separately
     m_boxPagination->SetSelection( settings()->m_pagination );
@@ -165,10 +171,22 @@ void DIALOG_PRINT_PCBNEW::createExtraOptions()
     // Drill marks option
     auto drillMarksLabel = new wxStaticText( box, wxID_ANY, _( "Drill marks:" ) );
     std::vector<wxString> drillMarkChoices =
-            { _( "No drill mark" ), _( "Small mark" ), _( "Real drill" ) };
+            { _( "No drill mark" ), _( "Small mark" ), _( "Real drill" ), _( "Custom size" ) };
     m_drillMarksChoice = new wxChoice( box, wxID_ANY, wxDefaultPosition,
             wxDefaultSize, drillMarkChoices.size(), drillMarkChoices.data(), 0 );
     m_drillMarksChoice->SetSelection( 0 );
+    m_drillMarksChoice->Connect( wxEVT_COMMAND_CHOICE_SELECTED,
+                                 wxCommandEventHandler( DIALOG_PRINT_PCBNEW::onDrillMarksChoiceChange ),
+                                 NULL, this );
+    
+    // Custom drill size entry
+    auto drillSizeLabel = new wxStaticText( box, wxID_ANY, _( "Drill size:" ) );
+    m_drillMarkSizeCtrl = new wxTextCtrl( box, wxID_ANY, wxEmptyString,
+                                    wxDefaultPosition, wxDefaultSize, 0 );
+    auto m_drillMarkSizeUnits = new wxStaticText(box, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 );
+    m_drillMarkSizeUnitBinder = new UNIT_BINDER(m_parent, drillSizeLabel, m_drillMarkSizeCtrl,
+                              m_drillMarkSizeUnits, true, false);
+
 
     // Print mirrored
     m_checkboxMirror = new wxCheckBox( box, wxID_ANY, _( "Print mirrored" ) );
@@ -184,9 +202,17 @@ void DIALOG_PRINT_PCBNEW::createExtraOptions()
             wxBOTTOM | wxRIGHT | wxLEFT | wxALIGN_CENTER_VERTICAL, 5 );
     optionsSizer->Add( m_drillMarksChoice, wxGBPosition( rows, 1 ), wxGBSpan( 1, cols - 1 ),
             wxBOTTOM | wxRIGHT | wxLEFT, 5 );
-    optionsSizer->Add( m_checkboxMirror, wxGBPosition( rows + 1, 0 ), wxGBSpan( 1, cols ),
+    
+    optionsSizer->Add( drillSizeLabel, wxGBPosition( rows + 1, 0 ), wxGBSpan( 1, 1 ),
+            wxBOTTOM | wxRIGHT | wxLEFT | wxALIGN_CENTER_VERTICAL, 5 );
+    optionsSizer->Add( m_drillMarkSizeCtrl, wxGBPosition( rows + 1 , 1 ), wxGBSpan( 1, 1 ),
+            wxBOTTOM | wxRIGHT | wxLEFT, 5 );
+    optionsSizer->Add( m_drillMarkSizeUnits, wxGBPosition( rows + 1, 2 ), wxGBSpan( 1, cols - 2 ),
+            wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
+    
+    optionsSizer->Add( m_checkboxMirror, wxGBPosition( rows + 2, 0 ), wxGBSpan( 1, cols ),
             wxBOTTOM | wxRIGHT | wxLEFT, 5 );
-    optionsSizer->Add( m_boxPagination, wxGBPosition( rows + 2, 0 ), wxGBSpan( 1, cols ), wxALL | wxEXPAND, 5 );
+    optionsSizer->Add( m_boxPagination, wxGBPosition( rows + 3, 0 ), wxGBSpan( 1, cols ), wxALL | wxEXPAND, 5 );
 }
 
 
@@ -260,6 +286,13 @@ void DIALOG_PRINT_PCBNEW::onDeselectAllClick( wxCommandEvent& event )
 }
 
 
+void DIALOG_PRINT_PCBNEW::onDrillMarksChoiceChange( wxCommandEvent& event )
+{
+    const auto selectedOption = event.GetSelection();
+    m_drillMarkSizeUnitBinder->Enable(selectedOption == PCBNEW_PRINTOUT_SETTINGS::CUSTOM_DRILL_SHAPE);
+}
+
+
 void DIALOG_PRINT_PCBNEW::setListBoxValue( wxCheckListBox* aList, bool aValue )
 {
     for( unsigned int i = 0; i < aList->GetCount(); ++i )
@@ -319,6 +352,8 @@ void DIALOG_PRINT_PCBNEW::saveSettings()
 
     settings()->m_drillMarks =
         (PCBNEW_PRINTOUT_SETTINGS::DRILL_MARK_SHAPE_T) m_drillMarksChoice->GetSelection();
+    
+    settings()->m_drillShapeCustomSize = m_drillMarkSizeUnitBinder->GetValue();
 
     settings()->m_pagination = m_boxPagination->GetSelection() == 0
         ? PCBNEW_PRINTOUT_SETTINGS::LAYER_PER_PAGE : PCBNEW_PRINTOUT_SETTINGS::ALL_LAYERS;
diff --git a/pcbnew/pcbnew_printout.cpp b/pcbnew/pcbnew_printout.cpp
index a21121e1f..b4aa5f686 100644
--- a/pcbnew/pcbnew_printout.cpp
+++ b/pcbnew/pcbnew_printout.cpp
@@ -45,6 +45,7 @@ void PCBNEW_PRINTOUT_SETTINGS::Load( wxConfigBase* aConfig )
 {
     BOARD_PRINTOUT_SETTINGS::Load( aConfig );
     aConfig->Read( OPTKEY_PRINT_PADS_DRILL, (int*) &m_drillMarks, FULL_DRILL_SHAPE );
+    aConfig->Read( OPTKEY_PRINT_PADS_DRILL_SIZE, &m_drillShapeCustomSize, SMALL_DRILL );
     aConfig->Read( OPTKEY_PRINT_PAGE_PER_LAYER, (int*) &m_pagination, ALL_LAYERS );
 }
 
@@ -53,6 +54,7 @@ void PCBNEW_PRINTOUT_SETTINGS::Save( wxConfigBase* aConfig )
 {
     BOARD_PRINTOUT_SETTINGS::Save( aConfig );
     aConfig->Write( OPTKEY_PRINT_PADS_DRILL, (int) m_drillMarks );
+    aConfig->Write( OPTKEY_PRINT_PADS_DRILL_SIZE, m_drillShapeCustomSize );
     aConfig->Write( OPTKEY_PRINT_PAGE_PER_LAYER, (int) m_pagination );
 }
 
@@ -183,6 +185,10 @@ void PCBNEW_PRINTOUT::setupPainter( const std::unique_ptr<KIGFX::PAINTER>& aPain
         case PCBNEW_PRINTOUT_SETTINGS::FULL_DRILL_SHAPE:
             painter->SetDrillMarks( true );
             break;
+
+        case PCBNEW_PRINTOUT_SETTINGS::CUSTOM_DRILL_SHAPE:
+            painter->SetDrillMarks( false, m_pcbnewSettings.m_drillShapeCustomSize );
+            break;
     }
 
     painter->GetSettings()->SetLayerColor( LAYER_PADS_PLATEDHOLES, COLOR4D::WHITE );
diff --git a/pcbnew/pcbnew_printout.h b/pcbnew/pcbnew_printout.h
index 8881735a5..6976d28bc 100644
--- a/pcbnew/pcbnew_printout.h
+++ b/pcbnew/pcbnew_printout.h
@@ -32,8 +32,11 @@ struct PCBNEW_PRINTOUT_SETTINGS : BOARD_PRINTOUT_SETTINGS
     enum DRILL_MARK_SHAPE_T {
         NO_DRILL_SHAPE,
         SMALL_DRILL_SHAPE,
-        FULL_DRILL_SHAPE
-    } m_drillMarks;             ///< Drill marks shape
+        FULL_DRILL_SHAPE,
+        CUSTOM_DRILL_SHAPE
+    } m_drillMarks;       ///< Drill marks shape
+    
+    int m_drillShapeCustomSize;  
 
     enum PAGINATION_T {
         LAYER_PER_PAGE,
diff --git a/pcbnew/pcbplot.h b/pcbnew/pcbplot.h
index a98ad9602..ce507b450 100644
--- a/pcbnew/pcbplot.h
+++ b/pcbnew/pcbplot.h
@@ -57,6 +57,7 @@ class REPORTER;
 #define OPTKEY_PRINT_MONOCHROME_MODE wxT( "PrintMonochrome" )
 #define OPTKEY_PRINT_PAGE_PER_LAYER  wxT( "PrintSinglePage" )
 #define OPTKEY_PRINT_PADS_DRILL      wxT( "PrintPadsDrillOpt" )
+#define OPTKEY_PRINT_PADS_DRILL_SIZE wxT( "PrintPadsDrillCustomSize" ) 
 #define OPTKEY_PLOT_X_FINESCALE_ADJ  wxT( "PlotXFineScaleAdj" )
 #define OPTKEY_PLOT_Y_FINESCALE_ADJ  wxT( "PlotYFineScaleAdj" )
 #define CONFIG_PS_FINEWIDTH_ADJ      wxT( "PSPlotFineWidthAdj" )
-- 
2.17.1