From bd71cec82661cd124e26e013e52ab0d861e5d0e9 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 13 May 2023 11:45:25 +0200 Subject: [PATCH] Bitmap2component: enhancement: add more PCB layers in PCB layer list selector. --- bitmap2component/bitmap2cmp_gui.cpp | 24 ++-- bitmap2component/bitmap2cmp_gui_base.cpp | 22 +-- bitmap2component/bitmap2cmp_gui_base.fbp | 170 ++++++++++++++--------- bitmap2component/bitmap2cmp_gui_base.h | 5 +- bitmap2component/bitmap2component.cpp | 15 +- bitmap2component/bitmap2component.h | 7 +- 6 files changed, 144 insertions(+), 99 deletions(-) diff --git a/bitmap2component/bitmap2cmp_gui.cpp b/bitmap2component/bitmap2cmp_gui.cpp index 0c0a2bccba..2b633332b2 100644 --- a/bitmap2component/bitmap2cmp_gui.cpp +++ b/bitmap2component/bitmap2cmp_gui.cpp @@ -278,17 +278,15 @@ void BM2CMP_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) m_rbOutputFormat->SetSelection( format ); - if( format == PCBNEW_KICAD_MOD ) - m_rbPCBLayer->Enable( true ); - else - m_rbPCBLayer->Enable( false ); + bool enable = format == PCBNEW_KICAD_MOD; + m_chPCBLayer->Enable( enable ); int last_layer = cfg->m_LastModLayer; - if( last_layer > static_cast( MOD_LYR_FINAL ) ) // Out of range - m_rbPCBLayer->SetSelection( MOD_LYR_FSILKS ); - else - m_rbPCBLayer->SetSelection( last_layer ); + if( last_layer < 0 || last_layer > static_cast( MOD_LYR_FINAL ) ) // Out of range + last_layer = MOD_LYR_FSILKS; + + m_chPCBLayer->SetSelection( last_layer ); } @@ -303,7 +301,7 @@ void BM2CMP_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) cfg->m_Threshold = m_sliderThreshold->GetValue(); cfg->m_Negative = m_checkNegative->IsChecked(); cfg->m_LastFormat = m_rbOutputFormat->GetSelection(); - cfg->m_LastModLayer = m_rbPCBLayer->GetSelection(); + cfg->m_LastModLayer = m_chPCBLayer->GetSelection(); cfg->m_Units = m_PixelUnit->GetSelection(); } @@ -900,7 +898,7 @@ void BM2CMP_FRAME::ExportToBuffer( std::string& aOutput, OUTPUT_FMT_ID aFormat ) BMP2CMP_MOD_LAYER modLayer = MOD_LYR_FSILKS; if( aFormat == PCBNEW_KICAD_MOD ) - modLayer = (BMP2CMP_MOD_LAYER) m_rbPCBLayer->GetSelection(); + modLayer = (BMP2CMP_MOD_LAYER) m_chPCBLayer->GetSelection(); BITMAPCONV_INFO converter( aOutput ); converter.ConvertBitmap( potrace_bitmap, aFormat, m_outputSizeX.GetOutputDPI(), @@ -913,8 +911,6 @@ void BM2CMP_FRAME::ExportToBuffer( std::string& aOutput, OUTPUT_FMT_ID aFormat ) void BM2CMP_FRAME::OnFormatChange( wxCommandEvent& event ) { - if( m_rbOutputFormat->GetSelection() == PCBNEW_KICAD_MOD ) - m_rbPCBLayer->Enable( true ); - else - m_rbPCBLayer->Enable( false ); + bool enable = m_rbOutputFormat->GetSelection() == PCBNEW_KICAD_MOD; + m_chPCBLayer->Enable( enable ); } diff --git a/bitmap2component/bitmap2cmp_gui_base.cpp b/bitmap2component/bitmap2cmp_gui_base.cpp index 53ca962baa..351fa5a8a0 100644 --- a/bitmap2component/bitmap2cmp_gui_base.cpp +++ b/bitmap2component/bitmap2cmp_gui_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) +// C++ code generated with wxFormBuilder (version 3.10.1-282-g1fa54006) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -100,9 +100,6 @@ BM2CMP_FRAME_BASE::BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxS m_buttonLoad = new wxButton( this, wxID_ANY, _("Load Source Image"), wxDefaultPosition, wxDefaultSize, 0 ); brightSizer->Add( m_buttonLoad, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - brightSizer->Add( 0, 10, 1, wxEXPAND, 5 ); - wxStaticBoxSizer* sbSizerImgPrms; sbSizerImgPrms = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Output Size") ), wxVERTICAL ); @@ -152,18 +149,21 @@ BM2CMP_FRAME_BASE::BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxS sbSizer2->Add( m_sliderThreshold, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); m_checkNegative = new wxCheckBox( sbSizer2->GetStaticBox(), wxID_ANY, _("Negative"), wxDefaultPosition, wxDefaultSize, 0 ); - sbSizer2->Add( m_checkNegative, 0, wxTOP|wxBOTTOM, 5 ); + sbSizer2->Add( m_checkNegative, 0, wxBOTTOM, 5 ); brightSizer->Add( sbSizer2, 0, wxALL|wxEXPAND, 5 ); - wxString m_rbPCBLayerChoices[] = { _("Front silk screen"), _("Front solder mask"), _("User layer Eco1"), _("User layer Eco2") }; - int m_rbPCBLayerNChoices = sizeof( m_rbPCBLayerChoices ) / sizeof( wxString ); - m_rbPCBLayer = new wxRadioBox( this, wxID_ANY, _("Board Layer for Outline"), wxDefaultPosition, wxDefaultSize, m_rbPCBLayerNChoices, m_rbPCBLayerChoices, 1, wxRA_SPECIFY_COLS ); - m_rbPCBLayer->SetSelection( 1 ); - m_rbPCBLayer->SetToolTip( _("Choose the board layer to place the outline.\nThe reference designator and value are always placed on the silk screen layer (but will be marked invisible).") ); + m_sizerPcbLayer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Pcb Layer for Graphics") ), wxVERTICAL ); - brightSizer->Add( m_rbPCBLayer, 0, wxALL|wxEXPAND, 5 ); + wxString m_chPCBLayerChoices[] = { _("Front silk screen"), _("Front solder mask"), _("Front Fab layer"), _("User layer drawings"), _("User layer comments"), _("User layer Eco1"), _("User layer Eco2") }; + int m_chPCBLayerNChoices = sizeof( m_chPCBLayerChoices ) / sizeof( wxString ); + m_chPCBLayer = new wxChoice( m_sizerPcbLayer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_chPCBLayerNChoices, m_chPCBLayerChoices, 0 ); + m_chPCBLayer->SetSelection( 0 ); + m_sizerPcbLayer->Add( m_chPCBLayer, 0, wxALL|wxEXPAND, 5 ); + + + brightSizer->Add( m_sizerPcbLayer, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); wxString m_rbOutputFormatChoices[] = { _("Symbol (.kicad_sym file)"), _("Footprint (.kicad_mod file)"), _("Postscript (.ps file)"), _("Drawing Sheet (.kicad_wks file)") }; int m_rbOutputFormatNChoices = sizeof( m_rbOutputFormatChoices ) / sizeof( wxString ); diff --git a/bitmap2component/bitmap2cmp_gui_base.fbp b/bitmap2component/bitmap2cmp_gui_base.fbp index 22fe3d1994..244d7ddfb3 100644 --- a/bitmap2component/bitmap2cmp_gui_base.fbp +++ b/bitmap2component/bitmap2cmp_gui_base.fbp @@ -36,6 +36,7 @@ 1 + 0 1 impl_virtual @@ -88,6 +89,7 @@ Dock 0 Left + 0 1 1 @@ -144,6 +146,7 @@ Dock 0 Left + 0 1 1 @@ -204,6 +207,7 @@ Dock 0 Left + 0 1 1 @@ -264,6 +268,7 @@ Dock 0 Left + 0 1 1 @@ -363,6 +368,7 @@ Dock 0 Left + 0 1 1 @@ -424,6 +430,7 @@ Dock 0 Left + 0 1 1 @@ -485,6 +492,7 @@ Dock 0 Left + 0 1 1 @@ -546,6 +554,7 @@ Dock 0 Left + 0 1 1 @@ -607,6 +616,7 @@ Dock 0 Left + 0 1 1 @@ -668,6 +678,7 @@ Dock 0 Left + 0 1 1 @@ -729,6 +740,7 @@ Dock 0 Left + 0 1 1 @@ -790,6 +802,7 @@ Dock 0 Left + 0 1 1 @@ -851,6 +864,7 @@ Dock 0 Left + 0 1 1 @@ -912,6 +926,7 @@ Dock 0 Left + 0 1 1 @@ -973,6 +988,7 @@ Dock 0 Left + 0 1 1 @@ -1053,6 +1069,7 @@ Dock 0 Left + 0 1 1 @@ -1097,16 +1114,6 @@ OnLoadFile - - 5 - wxEXPAND - 1 - - 10 - protected - 0 - - 5 wxALL|wxEXPAND @@ -1145,6 +1152,7 @@ Dock 0 Left + 0 1 1 @@ -1218,6 +1226,7 @@ Dock 0 Left + 0 1 1 @@ -1279,6 +1288,7 @@ Dock 0 Left + 0 1 1 @@ -1344,6 +1354,7 @@ Dock 0 Left + 0 1 1 @@ -1410,6 +1421,7 @@ Dock 0 Left + 0 1 1 @@ -1490,6 +1502,7 @@ Dock 0 Left + 0 1 1 @@ -1551,6 +1564,7 @@ Dock 0 Left + 0 1 1 @@ -1595,7 +1609,7 @@ 5 - wxTOP|wxBOTTOM + wxBOTTOM 0 1 @@ -1619,6 +1633,7 @@ Dock 0 Left + 0 1 1 @@ -1662,68 +1677,81 @@ 5 - wxALL|wxEXPAND + wxEXPAND|wxRIGHT|wxLEFT 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Front silk screen" "Front solder mask" "User layer Eco1" "User layer Eco2" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 + wxID_ANY - Board Layer for Outline - 1 - - 0 - - - 0 + Pcb Layer for Graphics - 1 - m_rbPCBLayer - 1 - - + m_sizerPcbLayer + wxVERTICAL + 1 protected - 1 - - Resizable - 1 - 1 - - wxRA_SPECIFY_COLS - - 0 - Choose the board layer to place the outline. The reference designator and value are always placed on the silk screen layer (but will be marked invisible). - - wxFILTER_NONE - wxDefaultValidator - - - - + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Front silk screen" "Front solder mask" "Front Fab layer" "User layer drawings" "User layer comments" "User layer Eco1" "User layer Eco2" + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_chPCBLayer + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + @@ -1752,6 +1780,7 @@ Dock 0 Left + 0 1 1 @@ -1823,6 +1852,7 @@ Dock 0 Left + 0 1 1 @@ -1897,6 +1927,7 @@ Dock 0 Left + 0 1 1 @@ -1948,6 +1979,7 @@ 1 + 0 1 1 diff --git a/bitmap2component/bitmap2cmp_gui_base.h b/bitmap2component/bitmap2cmp_gui_base.h index 058655cc28..6baa4f89ac 100644 --- a/bitmap2component/bitmap2cmp_gui_base.h +++ b/bitmap2component/bitmap2cmp_gui_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) +// C++ code generated with wxFormBuilder (version 3.10.1-282-g1fa54006) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -69,7 +69,8 @@ class BM2CMP_FRAME_BASE : public KIWAY_PLAYER wxStaticText* m_ThresholdText; wxSlider* m_sliderThreshold; wxCheckBox* m_checkNegative; - wxRadioBox* m_rbPCBLayer; + wxStaticBoxSizer* m_sizerPcbLayer; + wxChoice* m_chPCBLayer; wxRadioBox* m_rbOutputFormat; wxButton* m_buttonExportFile; wxButton* m_buttonExportClipboard; diff --git a/bitmap2component/bitmap2component.cpp b/bitmap2component/bitmap2component.cpp index 6c906c8f3f..f80bfeb568 100644 --- a/bitmap2component/bitmap2component.cpp +++ b/bitmap2component/bitmap2component.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 1992-2019 jean-pierre.charras - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -170,6 +170,18 @@ const char* BITMAPCONV_INFO::getBoardLayerName( BMP2CMP_MOD_LAYER aChoice ) layerName = "F.Mask"; break; + case MOD_LYR_FAB: + layerName = "F.Fab"; + break; + + case MOD_LYR_DRAWINGS: + layerName = "Dwgs.User"; + break; + + case MOD_LYR_COMMENTS: + layerName = "Cmts.User"; + break; + case MOD_LYR_ECO1: layerName = "Eco1.User"; break; @@ -179,7 +191,6 @@ const char* BITMAPCONV_INFO::getBoardLayerName( BMP2CMP_MOD_LAYER aChoice ) break; case MOD_LYR_FSILKS: - default: // case MOD_LYR_FSILKS only unless there is a bug break; } diff --git a/bitmap2component/bitmap2component.h b/bitmap2component/bitmap2component.h index 76c0b8ff04..813526c1df 100644 --- a/bitmap2component/bitmap2component.h +++ b/bitmap2component/bitmap2component.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KICAD, a free EDA CAD application. * - * Copyright (C) 1992-2014 Kicad Developers, see change_log.txt for contributors. + * Copyright (C) 1992-2023 Kicad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -38,10 +38,15 @@ enum OUTPUT_FMT_ID FINAL_FMT = KICAD_WKS_LOGO }; +// for consistency this enum should conform to the +// indices in m_cbPcbLayer from bitmap2cmp_gui.cpp enum BMP2CMP_MOD_LAYER { MOD_LYR_FSILKS = 0, MOD_LYR_FSOLDERMASK, + MOD_LYR_FAB, + MOD_LYR_DRAWINGS, + MOD_LYR_COMMENTS, MOD_LYR_ECO1, MOD_LYR_ECO2, MOD_LYR_FINAL = MOD_LYR_ECO2