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, see <https://www.gnu.org/licenses/>.
18 */
19
23#include <pcb_edit_frame.h>
25#include <widgets/wx_grid.h>
26#include <grid_tricks.h>
27
28
29
31 BOARD_DESIGN_SETTINGS& aBrdSettings ) :
33 m_frame( aFrame ),
34 m_brdSettings( &aBrdSettings )
35{
37 [&]() -> LSET
38 {
39 return LSET();
40 } );
41
42 m_layerOffsetsGrid->SetTable( m_layerPropsTable, true );
43 m_layerOffsetsGrid->PushEventHandler( new GRID_TRICKS( m_layerOffsetsGrid ) );
44 m_layerOffsetsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
45
46 wxGridCellAttr* attr = new wxGridCellAttr;
47 attr->SetRenderer( new GRID_CELL_LAYER_RENDERER( nullptr ) );
48 attr->SetReadOnly();
49 m_layerOffsetsGrid->SetColAttr( 0, attr );
50}
51
52
57
58
60{
61 for( PCB_LAYER_ID layer : LSET::AllCuMask().UIOrder() )
62 {
63 if( m_brdSettings->IsLayerEnabled( layer ) )
64 {
65 if( m_brdSettings->m_ZoneLayerProperties.contains( layer ) )
66 m_layerPropsTable->AddItem( layer, m_brdSettings->m_ZoneLayerProperties.at( layer ) );
67 else
68 m_layerPropsTable->AddItem( layer, ZONE_LAYER_PROPERTIES() );
69 }
70 }
71
72 Layout();
73
74 return true;
75}
76
77
79{
80 if( m_layerPropsTable->GetNumberRows() != aCopperLayerCount )
81 {
82 LSET enabled = LSET::AllCuMask( aCopperLayerCount );
83 LSET existing;
84
85 for( int row = m_layerPropsTable->GetNumberRows() - 1; row >= 0; --row )
86 {
87 PCB_LAYER_ID layer = m_layerPropsTable->GetItems()[row].first;
88
89 if( enabled.test( layer ) )
90 existing.set( layer );
91 else
92 m_layerPropsTable->DeleteRows( row, 1 );
93 }
94
95 for( PCB_LAYER_ID layer : enabled )
96 {
97 if( !existing.test( layer ) )
98 m_layerPropsTable->AddItem( layer, ZONE_LAYER_PROPERTIES() );
99 }
100
101 Layout();
102 }
103}
104
105
107{
108 if( !m_layerOffsetsGrid->CommitPendingChanges() )
109 return false;
110
111 for( const auto& [layer, props] : m_layerPropsTable->GetItems() )
112 m_brdSettings->m_ZoneLayerProperties[layer] = props;
113
114 return true;
115}
116
117
119{
120 BOARD_DESIGN_SETTINGS* savedSettings = m_brdSettings;
121
122 m_brdSettings = &aBoard->GetDesignSettings();
124
125 m_brdSettings = savedSettings;
126}
BASE_SET & set(size_t pos)
Definition base_set.h:116
Container for design settings for a BOARD object.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition board.cpp:1149
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition grid_tricks.h:57
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
static const LSET & AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
Definition lset.cpp:604
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition lset.cpp:595
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
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:56