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
27#include <pcb_edit_frame.h>
29#include <widgets/wx_grid.h>
30#include <grid_tricks.h>
31
32
33
35 BOARD_DESIGN_SETTINGS& aBrdSettings ) :
37 m_frame( aFrame ),
38 m_brdSettings( &aBrdSettings )
39{
41 [&]() -> LSET
42 {
43 return LSET();
44 } );
45
46 m_layerOffsetsGrid->SetTable( m_layerPropsTable, true );
47 m_layerOffsetsGrid->PushEventHandler( new GRID_TRICKS( m_layerOffsetsGrid ) );
48 m_layerOffsetsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
49
50 wxGridCellAttr* attr = new wxGridCellAttr;
51 attr->SetRenderer( new GRID_CELL_LAYER_RENDERER( nullptr ) );
52 attr->SetReadOnly();
53 m_layerOffsetsGrid->SetColAttr( 0, attr );
54}
55
56
61
62
64{
65 for( PCB_LAYER_ID layer : LSET::AllCuMask().UIOrder() )
66 {
67 if( m_brdSettings->IsLayerEnabled( layer ) )
68 {
69 if( m_brdSettings->m_ZoneLayerProperties.contains( layer ) )
70 m_layerPropsTable->AddItem( layer, m_brdSettings->m_ZoneLayerProperties.at( layer ) );
71 else
72 m_layerPropsTable->AddItem( layer, ZONE_LAYER_PROPERTIES() );
73 }
74 }
75
76 Layout();
77
78 return true;
79}
80
81
83{
84 if( m_layerPropsTable->GetNumberRows() != aCopperLayerCount )
85 {
86 LSET enabled = LSET::AllCuMask( aCopperLayerCount );
87 LSET existing;
88
89 for( int row = m_layerPropsTable->GetNumberRows() - 1; row >= 0; --row )
90 {
91 PCB_LAYER_ID layer = m_layerPropsTable->GetItems()[row].first;
92
93 if( enabled.test( layer ) )
94 existing.set( layer );
95 else
96 m_layerPropsTable->DeleteRows( row, 1 );
97 }
98
99 for( PCB_LAYER_ID layer : enabled )
100 {
101 if( !existing.test( layer ) )
102 m_layerPropsTable->AddItem( layer, ZONE_LAYER_PROPERTIES() );
103 }
104
105 Layout();
106 }
107}
108
109
111{
112 if( !m_layerOffsetsGrid->CommitPendingChanges() )
113 return false;
114
115 for( const auto& [layer, props] : m_layerPropsTable->GetItems() )
116 m_brdSettings->m_ZoneLayerProperties[layer] = props;
117
118 return true;
119}
120
121
123{
124 BOARD_DESIGN_SETTINGS* savedSettings = m_brdSettings;
125
126 m_brdSettings = &aBoard->GetDesignSettings();
128
129 m_brdSettings = savedSettings;
130}
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:322
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition board.cpp:1082
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:599
static LSET AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
Definition lset.cpp:608
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:60