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-2022 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 
33 #define LAYER_LIST_COLUMN_CHECK 0
34 #define LAYER_LIST_COLUMN_ICON 1
35 #define LAYER_LIST_COLUMN_NAME 2
36 #define LAYER_LIST_ROW_ALL_INNER_LAYERS 1
37 
38 
40 {
41 public:
43 
44 private:
48  bool m_isFpEditor;
50 
51  bool TransferDataToWindow() override;
52  bool TransferDataFromWindow() override;
53 
54  void OnLayerSelection( wxDataViewEvent& event ) override;
55 };
56 
57 
59 {
60  DIALOG_RULE_AREA_PROPERTIES dlg( aCaller, aSettings );
61 
62  return dlg.ShowModal();
63 }
64 
65 
67  ZONE_SETTINGS* aSettings ) :
69 {
70  m_parent = aParent;
71 
72  m_ptr = aSettings;
73  m_zonesettings = *aSettings;
74 
76 
77  BOARD* board = m_parent->GetBoard();
79 
81 
82  m_sdbSizerButtonsOK->SetDefault();
83 
85 }
86 
87 
89 {
90  // Init keepout parameters:
96 
97  m_cbLocked->SetValue( m_zonesettings.m_Locked );
98 
100 
101  m_tcName->SetValue( m_zonesettings.m_Name );
102 
104  {
105  case ZONE_BORDER_DISPLAY_STYLE::NO_HATCH: m_OutlineDisplayCtrl->SetSelection( 0 ); break;
106  case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE: m_OutlineDisplayCtrl->SetSelection( 1 ); break;
107  case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL: m_OutlineDisplayCtrl->SetSelection( 2 ); break;
108  }
109 
111 
112  return true;
113 }
114 
115 
116 void DIALOG_RULE_AREA_PROPERTIES::OnLayerSelection( wxDataViewEvent& event )
117 {
118  if( event.GetColumn() != 0 )
119  return;
120 
121  int row = m_layers->ItemToRow( event.GetItem() );
122  wxVariant layerID;
123  m_layers->GetValue( layerID, row, LAYER_LIST_COLUMN_NAME );
124  bool selected = m_layers->GetToggleValue( row, LAYER_LIST_COLUMN_CHECK );
125 
126  // In footprint editor, we have only 3 possible layer selection: C_Cu, inner layers, B_Cu.
127  // So row LAYER_LIST_ROW_ALL_INNER_LAYERS selection is fp editor specific.
128  // in board editor, this row is a normal selection
130  {
131  if( selected )
133  else
134  m_zonesettings.m_Layers &= ~LSET::InternalCuMask();
135  }
136  else
137  {
138  m_zonesettings.m_Layers.set( ToLAYER_ID( layerID.GetInteger() ), selected );
139  }
140 }
141 
142 
144 {
145  // Init keepout parameters:
152 
153  if( m_zonesettings.m_Layers.count() == 0 )
154  {
155  DisplayError( this, _( "No layers selected." ) );
156  return false;
157  }
158 
159  switch( m_OutlineDisplayCtrl->GetSelection() )
160  {
161  case 0:
163  break;
164  case 1:
166  break;
167  case 2:
169  break;
170  }
171 
172  auto cfg = m_parent->GetPcbNewSettings();
174 
176  m_zonesettings.m_Locked = m_cbLocked->GetValue();
177  m_zonesettings.m_ZonePriority = 0; // for a keepout, this param is not used.
178 
179  m_zonesettings.m_Name = m_tcName->GetValue();
180 
182  return true;
183 }
184 
185 
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:759
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:279
Class DIALOG_RULE_AREA_PROPERTIES_BASE.
const bool GetDoNotAllowFootprints() const
This file is part of the common library.
#define LAYER_LIST_COLUMN_CHECK
ZONE_BORDER_DISPLAY_STYLE m_ZoneBorderDisplayStyle
Option to show the zone area (outlines only, short hatches or full hatches.
#define LAYER_LIST_COLUMN_NAME
wxString m_Name
Definition: zone_settings.h:95
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 SetupLayersList(wxDataViewListCtrl *aList, PCB_BASE_FRAME *aFrame, LSET aLayers, bool aFpEditorMode)
A helper routine for the various zone dialogs (copper, non-copper, keepout).
void SetDoNotAllowFootprints(bool aEnable)
ZONE_SETTINGS m_zonesettings
the working copy of zone settings
void SetDoNotAllowVias(bool aEnable)
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:516
void SetDoNotAllowPads(bool aEnable)
DIALOG_RULE_AREA_PROPERTIES(PCB_BASE_FRAME *aParent, ZONE_SETTINGS *aSettings)
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:719
#define LAYER_LIST_ROW_ALL_INNER_LAYERS
#define _(s)
const bool GetDoNotAllowVias() const
void SetDoNotAllowTracks(bool aEnable)
void SetIsRuleArea(bool aEnable)
const bool GetDoNotAllowTracks() const
int InvokeRuleAreaEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeRuleAreaEditor invokes up a modal dialog window for copper zone editing.
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:67
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
const bool GetDoNotAllowPads() const
bool IsType(FRAME_T aType) const
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191
int GetCopperLayerCount() const
Definition: board.cpp:455
const bool GetDoNotAllowCopperPour() const
PCBNEW_SETTINGS * GetPcbNewSettings() const
void OnLayerSelection(wxDataViewEvent &event) override
ZONE_SETTINGS * m_ptr
the pointer to the zone settings of the zone to edit
static LSET AllBoardTechMask()
Return a mask holding board technical layers (no CU layer) on both side.
Definition: lset.cpp:836
void SetDoNotAllowCopperPour(bool aEnable)
BOARD * GetBoard() const
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:914
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.