KiCad PCB EDA Suite
dialog_rule_area_properties.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 (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6 * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <kiface_base.h>
27#include <confirm.h>
28#include <pcb_edit_frame.h>
29#include <pcbnew_settings.h>
30#include <zone_settings.h>
32#include <widgets/unit_binder.h>
33#include <wx/statbox.h>
34#include <wx/statline.h>
35#include <wx/radiobut.h>
36
37#define LAYER_LIST_COLUMN_CHECK 0
38#define LAYER_LIST_COLUMN_ICON 1
39#define LAYER_LIST_COLUMN_NAME 2
40#define LAYER_LIST_ROW_ALL_INNER_LAYERS 1
41
42
44{
45public:
47 CONVERT_SETTINGS* aConvertSettings );
48
49private:
50 bool TransferDataToWindow() override;
51 bool TransferDataFromWindow() override;
52
53 void OnLayerSelection( wxDataViewEvent& event ) override;
54
55private:
61
63 wxRadioButton* m_rbCenterline;
64 wxRadioButton* m_rbEnvelope;
66};
67
68
70 CONVERT_SETTINGS* aConvertSettings )
71{
72 DIALOG_RULE_AREA_PROPERTIES dlg( aCaller, aZoneSettings, aConvertSettings );
73
74 return dlg.ShowModal();
75}
76
77
79 ZONE_SETTINGS* aSettings,
80 CONVERT_SETTINGS* aConvertSettings ) :
82 m_outlineHatchPitch( aParent, m_stBorderHatchPitchText,
83 m_outlineHatchPitchCtrl, m_outlineHatchUnits ),
84 m_convertSettings( aConvertSettings ),
85 m_rbCenterline( nullptr ),
86 m_rbEnvelope( nullptr ),
87 m_cbDeleteOriginals( nullptr )
88{
89 m_parent = aParent;
90
91 m_ptr = aSettings;
92 m_zonesettings = *aSettings;
93
94 if( aConvertSettings )
95 {
96 wxStaticBox* bConvertBox = new wxStaticBox( this, wxID_ANY,
97 _( "Conversion Settings" ) );
98 wxStaticBoxSizer* bConvertSizer = new wxStaticBoxSizer( bConvertBox, wxVERTICAL );
99
100 m_rbCenterline = new wxRadioButton( this, wxID_ANY, _( "Use centerlines" ) );
101 bConvertSizer->Add( m_rbCenterline, 0, wxLEFT|wxRIGHT, 5 );
102
103 bConvertSizer->AddSpacer( 2 );
104 m_rbEnvelope = new wxRadioButton( this, wxID_ANY, _( "Create bounding hull" ) );
105 bConvertSizer->Add( m_rbEnvelope, 0, wxLEFT|wxRIGHT, 5 );
106
107 bConvertSizer->AddSpacer( 6 );
108 m_cbDeleteOriginals = new wxCheckBox( this, wxID_ANY,
109 _( "Delete source objects after conversion" ) );
110 bConvertSizer->Add( m_cbDeleteOriginals, 0, wxALL, 5 );
111
112 GetSizer()->Insert( 0, bConvertSizer, 0, wxALL|wxEXPAND, 10 );
113
114 wxStaticLine* line = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
115 wxLI_HORIZONTAL );
116 GetSizer()->Insert( 1, line, 0, wxLEFT|wxRIGHT|wxEXPAND, 10 );
117
118 SetTitle( _( "Convert to Rule Area" ) );
119 }
120
122
123 BOARD* board = m_parent->GetBoard();
125
127
129
131}
132
133
135{
137 {
139 m_rbEnvelope->SetValue( true );
140 else
141 m_rbCenterline->SetValue( true );
142
144 }
145
146 // Init keepout parameters:
152
154
155 m_tcName->SetValue( m_zonesettings.m_Name );
156
158 {
159 case ZONE_BORDER_DISPLAY_STYLE::NO_HATCH: m_OutlineDisplayCtrl->SetSelection( 0 ); break;
162 }
163
165
167
168 return true;
169}
170
171
173{
174 if( event.GetColumn() != 0 )
175 return;
176
177 int row = m_layers->ItemToRow( event.GetItem() );
178 wxVariant layerID;
179 m_layers->GetValue( layerID, row, LAYER_LIST_COLUMN_NAME );
180 bool selected = m_layers->GetToggleValue( row, LAYER_LIST_COLUMN_CHECK );
181
182 // In footprint editor, we have only 3 possible layer selection: C_Cu, inner layers, B_Cu.
183 // So row LAYER_LIST_ROW_ALL_INNER_LAYERS selection is fp editor specific.
184 // in board editor, this row is a normal selection
186 {
187 if( selected )
189 else
190 m_zonesettings.m_Layers &= ~LSET::InternalCuMask();
191 }
192 else
193 {
194 m_zonesettings.m_Layers.set( ToLAYER_ID( layerID.GetInteger() ), selected );
195 }
196}
197
198
200{
202 {
203 if( m_rbEnvelope->GetValue() )
205 else
207
209 }
210
211 // Init keepout parameters:
218
219 if( m_zonesettings.m_Layers.count() == 0 )
220 {
221 DisplayError( this, _( "No layers selected." ) );
222 return false;
223 }
224
225 switch( m_OutlineDisplayCtrl->GetSelection() )
226 {
227 case 0:
229 break;
230 case 1:
232 break;
233 case 2:
235 break;
236 }
237
240 return false;
241
243
244 m_zonesettings.m_Locked = m_cbLocked->GetValue();
245 m_zonesettings.m_ZonePriority = 0; // for a keepout, this param is not used.
246
247 m_zonesettings.m_Name = m_tcName->GetValue();
248
250 return true;
251}
252
253
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
int GetCopperLayerCount() const
Definition: board.cpp:545
Class DIALOG_RULE_AREA_PROPERTIES_BASE.
void OnLayerSelection(wxDataViewEvent &event) override
ZONE_SETTINGS m_zonesettings
the working copy of zone settings
ZONE_SETTINGS * m_ptr
the pointer to the zone settings of the zone to edit
DIALOG_RULE_AREA_PROPERTIES(PCB_BASE_FRAME *aParent, ZONE_SETTINGS *aSettings, CONVERT_SETTINGS *aConvertSettings)
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:97
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
bool IsType(FRAME_T aType) const
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:530
static LSET AllBoardTechMask()
Return a mask holding board technical layers (no CU layer) on both side.
Definition: lset.cpp:848
static LSET InternalCuMask()
Return a complete set of internal copper layers which is all Cu layers except F_Cu and B_Cu.
Definition: lset.cpp:733
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
BOARD * GetBoard() const
virtual long long int GetValue()
Return the current value in Internal Units.
virtual bool Validate(double aMin, double aMax, EDA_UNITS aUnits=EDA_UNITS::UNSCALED)
Validate the control against the given range, informing the user of any errors found.
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:70
void SetIsRuleArea(bool aEnable)
const bool GetDoNotAllowCopperPour() const
void SetDoNotAllowVias(bool aEnable)
const bool GetDoNotAllowFootprints() const
const bool GetDoNotAllowVias() const
void SetDoNotAllowTracks(bool aEnable)
const bool GetDoNotAllowTracks() const
unsigned m_ZonePriority
Definition: zone_settings.h:81
void SetupLayersList(wxDataViewListCtrl *aList, PCB_BASE_FRAME *aFrame, LSET aLayers, bool aFpEditorMode)
A helper routine for the various zone dialogs (copper, non-copper, keepout).
wxString m_Name
Definition: zone_settings.h:97
void SetDoNotAllowFootprints(bool aEnable)
void SetDoNotAllowPads(bool aEnable)
const bool GetDoNotAllowPads() const
ZONE_BORDER_DISPLAY_STYLE m_ZoneBorderDisplayStyle
Option to show the zone area (outlines only, short hatches or full hatches.
void SetDoNotAllowCopperPour(bool aEnable)
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:300
This file is part of the common library.
#define LAYER_LIST_ROW_ALL_INNER_LAYERS
int InvokeRuleAreaEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aZoneSettings, CONVERT_SETTINGS *aConvertSettings)
Function InvokeRuleAreaEditor invokes up a modal dialog window for copper zone editing.
#define LAYER_LIST_COLUMN_NAME
#define LAYER_LIST_COLUMN_CHECK
#define _(s)
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:41
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:932
@ CENTERLINE
@ BOUNDING_HULL
CONVERT_STRATEGY m_Strategy
constexpr int mmToIU(double mm) const
Definition: base_units.h:89
#define ZONE_BORDER_HATCH_MINDIST_MM
Definition: zones.h:40
#define ZONE_BORDER_HATCH_MAXDIST_MM
Definition: zones.h:41