KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_setup_zone_hatch_offsets.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
26#include <pcb_edit_frame.h>
28#include <widgets/wx_grid.h>
29#include <grid_tricks.h>
30
31
32
34 BOARD_DESIGN_SETTINGS& aBrdSettings ) :
36 m_frame( aFrame ),
37 m_brdSettings( &aBrdSettings )
38{
40 [&]() -> LSET
41 {
42 return LSET();
43 } );
44
45 m_layerOffsetsGrid->SetTable( m_layerPropsTable, true );
46 m_layerOffsetsGrid->PushEventHandler( new GRID_TRICKS( m_layerOffsetsGrid ) );
47 m_layerOffsetsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
48
49 wxGridCellAttr* attr = new wxGridCellAttr;
50 attr->SetRenderer( new GRID_CELL_LAYER_RENDERER( nullptr ) );
51 attr->SetReadOnly();
52 m_layerOffsetsGrid->SetColAttr( 0, attr );
53}
54
55
60
61
67
68
70{
71 for( PCB_LAYER_ID layer : LSET::AllCuMask() )
72 {
73 if( aBrdSettings.IsLayerEnabled( layer ) )
74 {
75 if( aBrdSettings.m_ZoneLayerProperties.contains( layer ) )
76 m_layerPropsTable->AddItem( layer, aBrdSettings.m_ZoneLayerProperties.at( layer ) );
77 else
78 m_layerPropsTable->AddItem( layer, ZONE_LAYER_PROPERTIES() );
79 }
80 }
81}
82
83
85{
86 if( m_layerPropsTable->GetNumberRows() != aCopperLayerCount )
87 {
88 LSET enabled = LSET::AllCuMask( aCopperLayerCount );
89 LSET existing;
90
91 for( int row = m_layerPropsTable->GetNumberRows() - 1; row >= 0; --row )
92 {
93 PCB_LAYER_ID layer = m_layerPropsTable->GetItems()[row].first;
94
95 if( enabled.test( layer ) )
96 existing.set( layer );
97 else
98 m_layerPropsTable->DeleteRows( row, 1 );
99 }
100
101 for( PCB_LAYER_ID layer : enabled )
102 {
103 if( !existing.test( layer ) )
104 m_layerPropsTable->AddItem( layer, ZONE_LAYER_PROPERTIES() );
105 }
106
107 if( DIALOG_SHIM* dlg = dynamic_cast<DIALOG_SHIM*>( wxGetTopLevelParent( this ) ) )
108 dlg->Layout();
109 }
110}
111
112
114{
115 if( !m_layerOffsetsGrid->CommitPendingChanges() )
116 return false;
117
118 for( const auto& [layer, props] : m_layerPropsTable->GetItems() )
119 m_brdSettings->m_ZoneLayerProperties[layer] = props;
120
121 return true;
122}
123
124
126{
127 BOARD_DESIGN_SETTINGS* savedSettings = m_brdSettings;
128
129 m_brdSettings = &aBoard->GetDesignSettings();
131
132 m_brdSettings = savedSettings;
133}
BASE_SET & set(size_t pos)
Definition base_set.h:116
Container for design settings for a BOARD object.
std::map< PCB_LAYER_ID, ZONE_LAYER_PROPERTIES > m_ZoneLayerProperties
bool IsLayerEnabled(PCB_LAYER_ID aLayerId) const
Test whether a given layer aLayerId is enabled.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:322
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition board.cpp:1044
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition dialog_shim.h:68
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition grid_tricks.h:61
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition lset.cpp:582
static LSET AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
Definition lset.cpp:591
PANEL_SETUP_ZONE_HATCH_OFFSETS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
LAYER_PROPERTIES_GRID_TABLE * m_layerPropsTable
void LoadFromSettings(const BOARD_DESIGN_SETTINGS &aBrdSettings)
PANEL_SETUP_ZONE_HATCH_OFFSETS(wxWindow *aParentWindow, PCB_BASE_FRAME *aFrame, BOARD_DESIGN_SETTINGS &aBrdSettings)
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60