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
24#include <pcb_edit_frame.h>
26#include <widgets/wx_grid.h>
27#include <grid_tricks.h>
28
29
30
32 BOARD_DESIGN_SETTINGS& aBrdSettings ) :
34 m_frame( aFrame ),
35 m_brdSettings( &aBrdSettings )
36{
38 [&]() -> LSET
39 {
40 return LSET();
41 } );
42
43 m_layerOffsetsGrid->SetTable( m_layerPropsTable, true );
44 m_layerOffsetsGrid->PushEventHandler( new GRID_TRICKS( m_layerOffsetsGrid ) );
45 m_layerOffsetsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
46
47 wxGridCellAttr* attr = new wxGridCellAttr;
48 attr->SetRenderer( new GRID_CELL_LAYER_RENDERER( nullptr ) );
49 attr->SetReadOnly();
50 m_layerOffsetsGrid->SetColAttr( 0, attr );
51}
52
53
58
59
61{
62 m_prototypeZoneFills->SetValue( m_frame->Prj().GetLocalSettings().m_PrototypeZoneFill );
64
65 return true;
66}
67
68
70{
71 int rowCount = m_layerPropsTable->GetNumberRows();
72
73 if( rowCount > 0 )
74 m_layerPropsTable->DeleteRows( 0, rowCount );
75
76 for( PCB_LAYER_ID layer : LSET::AllCuMask().UIOrder() )
77 {
78 if( m_brdSettings->IsLayerEnabled( layer ) )
79 {
80 if( m_brdSettings->m_ZoneLayerProperties.contains( layer ) )
81 m_layerPropsTable->AddItem( layer, m_brdSettings->m_ZoneLayerProperties.at( layer ) );
82 else
83 m_layerPropsTable->AddItem( layer, ZONE_LAYER_PROPERTIES() );
84 }
85 }
86
87 Layout();
88}
89
90
92{
93 if( m_layerPropsTable->GetNumberRows() != aCopperLayerCount )
94 {
95 LSET enabled = LSET::AllCuMask( aCopperLayerCount );
96 LSET existing;
97
98 for( int row = m_layerPropsTable->GetNumberRows() - 1; row >= 0; --row )
99 {
100 PCB_LAYER_ID layer = m_layerPropsTable->GetItems()[row].first;
101
102 if( enabled.test( layer ) )
103 existing.set( layer );
104 else
105 m_layerPropsTable->DeleteRows( row, 1 );
106 }
107
108 for( PCB_LAYER_ID layer : enabled )
109 {
110 if( !existing.test( layer ) )
111 m_layerPropsTable->AddItem( layer, ZONE_LAYER_PROPERTIES() );
112 }
113
114 Layout();
115 }
116}
117
118
120{
121 if( !m_layerOffsetsGrid->CommitPendingChanges() )
122 return false;
123
124 m_frame->Prj().GetLocalSettings().m_PrototypeZoneFill = m_prototypeZoneFills->GetValue();
125
126 for( const auto& [layer, props] : m_layerPropsTable->GetItems() )
127 m_brdSettings->m_ZoneLayerProperties[layer] = props;
128
129 return true;
130}
131
132
134{
135 BOARD_DESIGN_SETTINGS* savedSettings = m_brdSettings;
136
137 m_brdSettings = &aBoard->GetDesignSettings();
139
140 m_brdSettings = savedSettings;
141}
BASE_SET & set(size_t pos)
Definition base_set.h:126
Container for design settings for a BOARD object.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:409
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition board.cpp:1299
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