Fetch board finish before exporting stackup to clipboard.

Also fixes some backward logic in setting modified flag.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17089
This commit is contained in:
Jeff Young 2024-05-23 18:28:15 +01:00
parent 884051fae1
commit 032b5a6d65
6 changed files with 40 additions and 20 deletions

View File

@ -80,26 +80,34 @@ bool PANEL_SETUP_BOARD_FINISH::TransferDataFromWindow()
{
BOARD_STACKUP& brd_stackup = m_brdSettings->GetStackupDescriptor();
wxArrayString finish_list = GetStandardCopperFinishes( false );
int finish = m_choiceFinish->GetSelection() >= 0 ? m_choiceFinish->GetSelection() : 0;
bool modified = brd_stackup.m_FinishType == finish_list[finish];
brd_stackup.m_FinishType = finish_list[finish];
int edge = m_choiceEdgeConn->GetSelection();
modified |= brd_stackup.m_EdgeConnectorConstraints == (BS_EDGE_CONNECTOR_CONSTRAINTS) edge;
brd_stackup.m_EdgeConnectorConstraints = (BS_EDGE_CONNECTOR_CONSTRAINTS) edge;
brd_stackup.m_CastellatedPads = m_cbCastellatedPads->GetValue();
modified |= brd_stackup.m_EdgePlating == m_cbEgdesPlated->GetValue();
brd_stackup.m_EdgePlating = m_cbEgdesPlated->GetValue();
if( modified )
if( TransferDataFromWindow( brd_stackup ) )
m_frame->OnModify();
return true;
}
bool PANEL_SETUP_BOARD_FINISH::TransferDataFromWindow( BOARD_STACKUP& aStackup )
{
wxArrayString finish_list = GetStandardCopperFinishes( false );
int finish = m_choiceFinish->GetSelection() >= 0 ? m_choiceFinish->GetSelection() : 0;
bool modified = aStackup.m_FinishType != finish_list[finish];
aStackup.m_FinishType = finish_list[finish];
int edge = m_choiceEdgeConn->GetSelection();
modified |= aStackup.m_EdgeConnectorConstraints != (BS_EDGE_CONNECTOR_CONSTRAINTS) edge;
aStackup.m_EdgeConnectorConstraints = (BS_EDGE_CONNECTOR_CONSTRAINTS) edge;
modified |= aStackup.m_CastellatedPads != m_cbCastellatedPads->GetValue();
aStackup.m_CastellatedPads = m_cbCastellatedPads->GetValue();
modified |= aStackup.m_EdgePlating != m_cbEgdesPlated->GetValue();
aStackup.m_EdgePlating = m_cbEgdesPlated->GetValue();
return modified;
}
void PANEL_SETUP_BOARD_FINISH::ImportSettingsFrom( BOARD* aBoard )
{
BOARD* savedBrd = m_board;

View File

@ -44,6 +44,8 @@ public:
// Called by wxWidgets: transfer current settings stored in m_stackup to the board
bool TransferDataFromWindow() override;
bool TransferDataFromWindow( BOARD_STACKUP& aStackup );
private:
void synchronizeWithBoard();

View File

@ -38,6 +38,7 @@
#include <math/util.h> // for KiROUND
#include "panel_board_stackup.h"
#include "panel_board_finish.h"
#include <panel_setup_layers.h>
#include "board_stackup_reporter.h"
#include <bitmaps.h>
@ -73,7 +74,8 @@ static void drawBitmap( wxBitmap& aBitmap, wxColor aColor );
PANEL_SETUP_BOARD_STACKUP::PANEL_SETUP_BOARD_STACKUP( wxWindow* aParentWindow,
PCB_EDIT_FRAME* aFrame,
PANEL_SETUP_LAYERS* aPanelLayers ):
PANEL_SETUP_LAYERS* aPanelLayers,
PANEL_SETUP_BOARD_FINISH* aPanelFinish ):
PANEL_SETUP_BOARD_STACKUP_BASE( aParentWindow ),
m_delectricMatList( DIELECTRIC_SUBSTRATE_LIST::DL_MATERIAL_DIELECTRIC ),
m_solderMaskMatList( DIELECTRIC_SUBSTRATE_LIST::DL_MATERIAL_SOLDERMASK ),
@ -83,6 +85,7 @@ PANEL_SETUP_BOARD_STACKUP::PANEL_SETUP_BOARD_STACKUP( wxWindow* aParentWindow,
m_lastUnits( aFrame->GetUserUnits() )
{
m_panelLayers = aPanelLayers;
m_panelFinish = aPanelFinish;
m_brdSettings = &m_board->GetDesignSettings();
m_panel1->SetBorders( false, false, true, true );
@ -423,6 +426,8 @@ void PANEL_SETUP_BOARD_STACKUP::onExportToClipboard( wxCommandEvent& event )
if( !transferDataFromUIToStackup() )
return;
m_panelFinish->TransferDataFromWindow( m_stackup );
// Build a ASCII representation of stackup and copy it in the clipboard
wxString report = BuildStackupReport( m_stackup, m_frame->GetUserUnits() );

View File

@ -37,6 +37,7 @@
class wxBitmapComboBox;
class PANEL_SETUP_LAYERS;
class PANEL_SETUP_BOARD_FINISH;
// A helper class to handle UI items managed by m_fgGridSizer
@ -90,7 +91,8 @@ class PANEL_SETUP_BOARD_STACKUP : public PANEL_SETUP_BOARD_STACKUP_BASE
{
public:
PANEL_SETUP_BOARD_STACKUP( wxWindow* aParentWindow, PCB_EDIT_FRAME* aFrame,
PANEL_SETUP_LAYERS* aPanelLayers );
PANEL_SETUP_LAYERS* aPanelLayers,
PANEL_SETUP_BOARD_FINISH* aPanelFinish );
~PANEL_SETUP_BOARD_STACKUP();
void ImportSettingsFrom( BOARD* aBoard );
@ -234,6 +236,7 @@ private:
// to allowed layers in stackup. (When this doesn't
// match the enabled layers in PANEL_SETUP_LAYERS the
// stackup is not up to date.)
PANEL_SETUP_BOARD_FINISH* m_panelFinish;
DIELECTRIC_SUBSTRATE_LIST m_delectricMatList; // List of currently available
// dielectric materials

View File

@ -57,6 +57,7 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :
_( "Import Settings from Another Board..." ), wxSize( 980, 600 ) ),
m_frame( aFrame ),
m_layers( nullptr ),
m_boardFinish( nullptr ),
m_physicalStackup( nullptr ),
m_currentPage( 0 ),
m_layersPage( 0 ),
@ -100,7 +101,8 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :
[this]( wxWindow* aParent ) -> wxWindow*
{
m_layers = RESOLVE_PAGE( PANEL_SETUP_LAYERS, m_layersPage );
return new PANEL_SETUP_BOARD_STACKUP( aParent, m_frame, m_layers );
m_boardFinish = RESOLVE_PAGE( PANEL_SETUP_BOARD_FINISH, m_boardFinishPage );
return new PANEL_SETUP_BOARD_STACKUP( aParent, m_frame, m_layers, m_boardFinish );
}, _( "Physical Stackup" ) );
m_boardFinishPage = m_treebook->GetPageCount();
@ -277,6 +279,7 @@ void DIALOG_BOARD_SETUP::onAuxiliaryAction( wxCommandEvent& aEvent )
m_layers = RESOLVE_PAGE( PANEL_SETUP_LAYERS, m_layersPage );
m_physicalStackup = RESOLVE_PAGE( PANEL_SETUP_BOARD_STACKUP, m_physicalStackupPage );
m_boardFinish = RESOLVE_PAGE( PANEL_SETUP_BOARD_FINISH, m_boardFinishPage );
// Flag so user can stop work if it will result in deleted inner copper layers
// and still clean up this function properly.
@ -339,9 +342,7 @@ void DIALOG_BOARD_SETUP::onAuxiliaryAction( wxCommandEvent& aEvent )
{
m_physicalStackup->ImportSettingsFrom( otherBoard );
m_layers->ImportSettingsFrom( otherBoard );
RESOLVE_PAGE( PANEL_SETUP_BOARD_FINISH,
m_boardFinishPage )->ImportSettingsFrom( otherBoard );
m_boardFinish->ImportSettingsFrom( otherBoard );
}
if( importDlg.m_TextAndGraphicsOpt->GetValue() )

View File

@ -52,6 +52,7 @@ protected:
PCB_EDIT_FRAME* m_frame;
PANEL_SETUP_LAYERS* m_layers;
PANEL_SETUP_BOARD_FINISH* m_boardFinish;
PANEL_SETUP_BOARD_STACKUP* m_physicalStackup;
public: