2019-07-27 19:09:43 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2023-05-11 10:42:53 +00:00
|
|
|
* Copyright (C) 2009-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2019-07-27 19:09:43 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PANEL_SETUP_BOARD_STACKUP_H
|
|
|
|
#define PANEL_SETUP_BOARD_STACKUP_H
|
|
|
|
|
|
|
|
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2019-07-27 19:09:43 +00:00
|
|
|
#include <widgets/unit_binder.h>
|
2021-04-08 23:51:30 +00:00
|
|
|
#include <wx/gdicmn.h>
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
#include "panel_board_stackup_base.h"
|
2021-04-16 21:07:06 +00:00
|
|
|
#include "board_stackup.h"
|
2019-09-09 14:45:21 +00:00
|
|
|
#include "stackup_predefined_prms.h"
|
2019-09-09 18:30:43 +00:00
|
|
|
#include "dielectric_material.h"
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
class wxBitmapComboBox;
|
|
|
|
class PANEL_SETUP_LAYERS;
|
|
|
|
|
|
|
|
|
|
|
|
// A helper class to handle UI items managed by m_fgGridSizer
|
|
|
|
// in PANEL_SETUP_BOARD_STACKUP
|
|
|
|
// these items are shown or not in m_fgGridSizer, depending on
|
|
|
|
// the enabled layers in the current board.
|
|
|
|
// So we need to store the list of these UI items int m_fgGridSizer
|
|
|
|
// row by row
|
|
|
|
struct BOARD_STACKUP_ROW_UI_ITEM
|
|
|
|
{
|
2019-11-11 18:34:48 +00:00
|
|
|
BOARD_STACKUP_ITEM* m_Item; // The BOARD_STACKUP_ITEM managed by this BOARD_STACKUP_ROW_UI_ITEM
|
2019-11-14 15:26:05 +00:00
|
|
|
int m_SubItem; // For multilayer dielectric, the index in sublayer list.
|
|
|
|
// Must be >= 0 and < m_Item sublayer count. Used only for dielectic
|
|
|
|
// 0 is the base list of parameters (always existing)
|
2023-05-11 13:37:48 +00:00
|
|
|
int m_Row; // The row number in the parent grid
|
2019-07-27 19:09:43 +00:00
|
|
|
bool m_isEnabled; // True if the row is in board
|
|
|
|
// false if not (this row is not shown on the panel)
|
|
|
|
wxStaticBitmap* m_Icon; // Color icon in first column (column 1)
|
|
|
|
wxStaticText* m_LayerName; // string shown in column 2
|
|
|
|
wxControl* m_LayerTypeCtrl; // control shown in column 3
|
2019-09-09 18:30:43 +00:00
|
|
|
wxControl* m_MaterialCtrl; // control shown in column 4, with m_MaterialButt
|
|
|
|
wxButton* m_MaterialButt; // control shown in column 4, with m_MaterialCtrl
|
2019-07-27 19:09:43 +00:00
|
|
|
wxControl* m_ThicknessCtrl; // control shown in column 5
|
|
|
|
wxControl* m_ThicknessLockCtrl;// control shown in column 6
|
|
|
|
wxControl* m_ColorCtrl; // control shown in column 7
|
|
|
|
wxControl* m_EpsilonCtrl; // control shown in column 8
|
|
|
|
wxControl* m_LossTgCtrl; // control shown in column 9
|
|
|
|
|
2021-08-16 18:57:15 +00:00
|
|
|
COLOR4D m_UserColor; // User-specified color (if any)
|
2021-04-08 23:51:30 +00:00
|
|
|
|
2023-05-11 13:37:48 +00:00
|
|
|
BOARD_STACKUP_ROW_UI_ITEM( BOARD_STACKUP_ITEM* aItem, int aSubItem, int aRow ) :
|
2021-04-08 23:51:30 +00:00
|
|
|
m_Item( aItem ),
|
|
|
|
m_SubItem( aSubItem ),
|
2023-05-11 13:37:48 +00:00
|
|
|
m_Row( aRow ),
|
|
|
|
m_isEnabled( false ),
|
2021-04-08 23:51:30 +00:00
|
|
|
m_Icon( nullptr ),
|
|
|
|
m_LayerName( nullptr ),
|
2019-09-09 18:30:43 +00:00
|
|
|
m_LayerTypeCtrl( nullptr ),
|
2021-04-08 23:51:30 +00:00
|
|
|
m_MaterialCtrl( nullptr ),
|
|
|
|
m_MaterialButt( nullptr ),
|
|
|
|
m_ThicknessCtrl( nullptr ),
|
|
|
|
m_ThicknessLockCtrl( nullptr ),
|
2019-09-09 18:30:43 +00:00
|
|
|
m_ColorCtrl( nullptr ),
|
2021-04-08 23:51:30 +00:00
|
|
|
m_EpsilonCtrl( nullptr ),
|
2021-08-16 18:57:15 +00:00
|
|
|
m_LossTgCtrl( nullptr )
|
2019-07-27 19:09:43 +00:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class PANEL_SETUP_BOARD_STACKUP : public PANEL_SETUP_BOARD_STACKUP_BASE
|
|
|
|
{
|
|
|
|
public:
|
2023-05-11 10:42:53 +00:00
|
|
|
PANEL_SETUP_BOARD_STACKUP( wxWindow* aParentWindow, PCB_EDIT_FRAME* aFrame,
|
2019-09-24 12:33:28 +00:00
|
|
|
PANEL_SETUP_LAYERS* aPanelLayers );
|
2019-07-27 19:09:43 +00:00
|
|
|
~PANEL_SETUP_BOARD_STACKUP();
|
|
|
|
|
|
|
|
void ImportSettingsFrom( BOARD* aBoard );
|
|
|
|
|
2019-09-06 09:26:27 +00:00
|
|
|
/** Must be called if the copper layers count has changed
|
|
|
|
* or solder mask, solder paste or silkscreen layers are
|
|
|
|
* enabled or disabled
|
|
|
|
* Rebuild the Layer Stack Panel if the new layer set differs
|
|
|
|
* from the current layet set
|
|
|
|
*/
|
2019-07-27 19:09:43 +00:00
|
|
|
void OnLayersOptionsChanged( LSET aNewLayerSet );
|
|
|
|
|
2021-02-24 02:31:12 +00:00
|
|
|
/// @return the number of copper layers configured for the board stackup
|
|
|
|
int GetCopperLayerCount() const;
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
/// @return the BOARD_STACKUP_ITEM managed by the row aRow
|
|
|
|
BOARD_STACKUP_ITEM* GetStackupItem( int aRow );
|
|
|
|
/// @return the BOARD_STACKUP_ITEM sublayermanaged by the row aRow
|
|
|
|
int GetSublayerId( int aRow );
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
/// Return the color currently selected for the row aRow
|
|
|
|
wxColor GetSelectedColor( int aRow ) const;
|
|
|
|
|
2019-09-06 09:26:27 +00:00
|
|
|
// Called by wxWidgets: transfer current settings stored in m_stackup to the board
|
2019-07-27 19:09:43 +00:00
|
|
|
bool TransferDataFromWindow() override;
|
|
|
|
|
|
|
|
private:
|
2023-05-11 13:37:48 +00:00
|
|
|
/** Creates the controls in a BOARD_STACKUP_ROW_UI_ITEM relative to the aStackupItem.
|
2019-11-14 15:26:05 +00:00
|
|
|
* @return a BOARD_STACKUP_ROW_UI_ITEM filled with corresponding widgets
|
|
|
|
* @param aRow is the row index in the row list
|
|
|
|
* @param aStackupItem is the stackup item controlled by the created
|
|
|
|
* BOARD_STACKUP_ROW_UI_ITEM.
|
|
|
|
* @param aSublayerIdx is used only for BS_ITEM_TYPE_DIELECTRIC stackup items.
|
|
|
|
* this is the index of the sublayer to used inside aStackupItem
|
|
|
|
* (from 0 to sub layer count - 1)
|
|
|
|
*/
|
2023-10-01 23:47:25 +00:00
|
|
|
void lazyBuildRowUI( BOARD_STACKUP_ROW_UI_ITEM& ui_row_item, int aPos );
|
2019-11-14 15:26:05 +00:00
|
|
|
|
2019-09-09 18:30:43 +00:00
|
|
|
/** add a Spacer in m_fgGridSizer when a empty cell is needed
|
|
|
|
*/
|
2023-10-01 23:47:25 +00:00
|
|
|
wxControl* addSpacer( int aPos );
|
2019-09-09 18:30:43 +00:00
|
|
|
|
2019-07-27 19:09:43 +00:00
|
|
|
/** Populate m_fgGridSizer with items to handle stackup parameters
|
|
|
|
* This is a full list:
|
|
|
|
* all copper layers and all tech layers that are supported by the stackup
|
|
|
|
* items not in the current board stackup will be not shown, but they are
|
|
|
|
* existing in list
|
2023-02-10 17:58:04 +00:00
|
|
|
* @param aCreateInitialStackup = true to create a initial stackup list for the dialog
|
|
|
|
* @param aRelinkStackup = true to re-link m_stackup to m_brdSettings
|
2019-11-14 15:26:05 +00:00
|
|
|
* false to build the stackup panel from the existing stackup list.
|
2019-07-27 19:09:43 +00:00
|
|
|
*/
|
2023-02-10 17:58:04 +00:00
|
|
|
void buildLayerStackPanel( bool aCreateInitialStackup = false, bool aRelinkStackup = false );
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
/** Synchronize the full stackup shown in m_fgGridSizer according to the stackup of the
|
2019-07-27 19:09:43 +00:00
|
|
|
* current board and optionally update the stackup params (thickness, color ... )
|
|
|
|
* @param aFullSync = true to update stackup params, false to only update the list
|
|
|
|
* of shown items
|
|
|
|
*/
|
|
|
|
void synchronizeWithBoard( bool aFullSync );
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
/** Show or do not show items in m_fgGridSizer according to the stackup of the
|
|
|
|
* current board.
|
2021-06-09 19:32:58 +00:00
|
|
|
* The panel stackup stores all possible layers (because the number of layers is set
|
2019-11-14 15:26:05 +00:00
|
|
|
* from an other panel), but only some of them must be actually shown on screen
|
|
|
|
*/
|
|
|
|
void showOnlyActiveLayers();
|
|
|
|
|
2019-07-27 19:09:43 +00:00
|
|
|
/** Populate m_fgGridSizer with items to handle stackup parameters
|
|
|
|
* If previous items are in list, remove old items
|
2019-11-14 15:26:05 +00:00
|
|
|
* New prms are added
|
|
|
|
* must be called after adding or deleting a dielectric parameter set
|
2023-02-10 17:58:04 +00:00
|
|
|
* @param aRelinkItems will recreate the links between m_stackup and m_brdSettings
|
2019-07-27 19:09:43 +00:00
|
|
|
*/
|
2023-02-10 17:58:04 +00:00
|
|
|
void rebuildLayerStackPanel( bool aRelinkItems = false );
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-09-06 09:26:27 +00:00
|
|
|
/** Transfer current UI settings to m_stackup but not to the board
|
|
|
|
*/
|
|
|
|
bool transferDataFromUIToStackup();
|
|
|
|
|
2021-02-24 02:31:12 +00:00
|
|
|
/**
|
|
|
|
* Updates the enabled copper layers when the dropdown is changed
|
|
|
|
*/
|
|
|
|
void updateCopperLayerCount();
|
|
|
|
|
2021-04-08 19:53:33 +00:00
|
|
|
/**
|
|
|
|
* Recompute the board thickness and update the textbox
|
2022-02-18 17:09:02 +00:00
|
|
|
* @return the computed value
|
2021-04-08 19:53:33 +00:00
|
|
|
*/
|
2022-02-18 17:09:02 +00:00
|
|
|
int computeBoardThickness();
|
2021-04-08 19:53:33 +00:00
|
|
|
|
2022-09-27 06:40:41 +00:00
|
|
|
/**
|
|
|
|
* Set the widths of dielectric layers to sensible defaults
|
|
|
|
* @param targetThickness target thickness of PCB in IU
|
|
|
|
*/
|
|
|
|
void setDefaultLayerWidths( int targetThickness );
|
|
|
|
|
2019-07-27 19:09:43 +00:00
|
|
|
void onColorSelected( wxCommandEvent& event );
|
2019-11-11 18:34:48 +00:00
|
|
|
void onMaterialChange( wxCommandEvent& event );
|
|
|
|
void onThicknessChange( wxCommandEvent& event );
|
|
|
|
void onExportToClipboard( wxCommandEvent& event ) override;
|
|
|
|
void onAddDielectricLayer( wxCommandEvent& event ) override;
|
|
|
|
void onRemoveDielectricLayer( wxCommandEvent& event ) override;
|
|
|
|
void onRemoveDielUI( wxUpdateUIEvent& event ) override;
|
2021-07-16 18:36:45 +00:00
|
|
|
void onCopperLayersSelCount( wxCommandEvent& event ) override;
|
|
|
|
void onAdjustDielectricThickness( wxCommandEvent& event ) override;
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
/** Update the icons color (swatches in first grid column)
|
|
|
|
* @param aRow is the row (index in m_rowUiItemsList) that manages the icon to update.
|
|
|
|
* if -1 all icons will be updated
|
|
|
|
*/
|
|
|
|
void updateIconColor( int aRow = -1 );
|
|
|
|
|
|
|
|
/** @return the color of the BOARD_STACKUP_ITEM at row aRow,
|
|
|
|
* to draw a bitmap color according to the selected color
|
|
|
|
* or the best default color (for dielectric or copper item)
|
|
|
|
* @param aRow is the row index to find the color.
|
|
|
|
*/
|
|
|
|
wxColor getColorIconItem( int aRow );
|
|
|
|
|
|
|
|
/** creates a bitmap combobox to select a layer color
|
|
|
|
* @return the created wxBitmapComboBox
|
2021-06-09 19:32:58 +00:00
|
|
|
* @param aStackupItem = the BOARD_STACKUP_ITEM related to the bitmap combobox
|
2019-07-27 19:09:43 +00:00
|
|
|
* (to set the user color, if any)
|
|
|
|
* can be nullptr
|
|
|
|
* @param aRow = the row index in the wxFlexGridSizer (used to build a wxWidget unique id)
|
|
|
|
*/
|
2021-08-23 18:58:18 +00:00
|
|
|
wxBitmapComboBox* createColorBox( BOARD_STACKUP_ITEM* aStackupItem, int aRow );
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2023-12-24 16:18:06 +00:00
|
|
|
void onUnitsChanged( wxCommandEvent& event );
|
|
|
|
|
2019-07-27 19:09:43 +00:00
|
|
|
/**
|
2023-05-11 10:42:53 +00:00
|
|
|
* disconnect event handlers connected to wxControl items found in list m_controlItemsList
|
2019-07-27 19:09:43 +00:00
|
|
|
*/
|
|
|
|
void disconnectEvents();
|
|
|
|
|
2020-08-04 23:40:59 +00:00
|
|
|
private:
|
|
|
|
BOARD_STACKUP m_stackup;
|
2023-05-11 10:42:53 +00:00
|
|
|
PANEL_SETUP_LAYERS* m_panelLayers; // The associated PANEL_SETUP_LAYERS, to know enabled
|
|
|
|
// layers and copper layer names
|
|
|
|
LSET m_enabledLayers; // The current enabled layers in this panel restricted
|
|
|
|
// to allowed layers in stackup. (When this doesn't
|
|
|
|
// match the enabled layers in PANEL_SETUP_LAYERS the
|
|
|
|
// stackup is not up to date.)
|
|
|
|
|
|
|
|
DIELECTRIC_SUBSTRATE_LIST m_delectricMatList; // List of currently available
|
|
|
|
// dielectric materials
|
|
|
|
DIELECTRIC_SUBSTRATE_LIST m_solderMaskMatList; // List of currently available
|
|
|
|
// solder mask materials
|
|
|
|
DIELECTRIC_SUBSTRATE_LIST m_silkscreenMatList; // List of currently available
|
|
|
|
// solder mask materials
|
|
|
|
std::vector<BOARD_STACKUP_ROW_UI_ITEM> m_rowUiItemsList; // List of items in m_fgGridSizer
|
|
|
|
|
|
|
|
BOARD* m_board;
|
2019-07-27 19:09:43 +00:00
|
|
|
BOARD_DESIGN_SETTINGS* m_brdSettings;
|
2023-05-11 10:42:53 +00:00
|
|
|
PCB_EDIT_FRAME* m_frame;
|
2023-12-24 16:18:06 +00:00
|
|
|
EDA_UNITS m_lastUnits;
|
2023-05-11 10:42:53 +00:00
|
|
|
wxSize m_numericTextCtrlSize; // Best size for wxTextCtrls with units
|
|
|
|
wxSize m_numericFieldsSize; // Best size for wxTextCtrls without units
|
|
|
|
wxArrayString m_core_prepreg_choice; // Used to display the option list in dialog
|
|
|
|
wxSize m_colorSwatchesSize; // Size of swatches in the wxBitmapComboBox.
|
|
|
|
wxSize m_colorIconsSize; // Size of swatches in the grid (left column)
|
|
|
|
|
|
|
|
std::vector<wxControl*> m_controlItemsList; // List of ctrls (wxChoice, wxTextCtrl, etc.)
|
|
|
|
// with added event handlers
|
2019-07-27 19:09:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // #ifndef PANEL_SETUP_BOARD_STACKUP_H
|