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
63{
64 for( PCB_LAYER_ID layer : LSET::AllCuMask().UIOrder() )
65 {
66 if( m_brdSettings->IsLayerEnabled( layer ) )
67 {
68 if( m_brdSettings->m_ZoneLayerProperties.contains( layer ) )
69 m_layerPropsTable->AddItem( layer, m_brdSettings->m_ZoneLayerProperties.at( layer ) );
70 else
71 m_layerPropsTable->AddItem( layer, ZONE_LAYER_PROPERTIES() );
72 }
73 }
74
75 Layout();
76
77 return true;
78}
79
80
82{
83 if( m_layerPropsTable->GetNumberRows() != aCopperLayerCount )
84 {
85 LSET enabled = LSET::AllCuMask( aCopperLayerCount );
86 LSET existing;
87
88 for( int row = m_layerPropsTable->GetNumberRows() - 1; row >= 0; --row )
89 {
90 PCB_LAYER_ID layer = m_layerPropsTable->GetItems()[row].first;
91
92 if( enabled.test( layer ) )
93 existing.set( layer );
94 else
95 m_layerPropsTable->DeleteRows( row, 1 );
96 }
97
98 for( PCB_LAYER_ID layer : enabled )
99 {
100 if( !existing.test( layer ) )
101 m_layerPropsTable->AddItem( layer, ZONE_LAYER_PROPERTIES() );
102 }
103
104 Layout();
105 }
106}
107
108
110{
111 if( !m_layerOffsetsGrid->CommitPendingChanges() )
112 return false;
113
114 for( const auto& [layer, props] : m_layerPropsTable->GetItems() )
115 m_brdSettings->m_ZoneLayerProperties[layer] = props;
116
117 return true;
118}
119
120
122{
123 BOARD_DESIGN_SETTINGS* savedSettings = m_brdSettings;
124
125 m_brdSettings = &aBoard->GetDesignSettings();
127
128 m_brdSettings = savedSettings;
129}
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:1069
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
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