KiCad PCB EDA Suite
dialog_keepout_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 <dick@softplc.com>
6  * Copyright (C) 1992-2019 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 <fctsys.h>
27 #include <kiface_i.h>
28 #include <confirm.h>
29 #include <pcb_edit_frame.h>
30 #include <pcbnew_settings.h>
31 #include <footprint_edit_frame.h>
32 #include <class_zone.h>
33 #include <zones.h>
34 #include <zone_settings.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 
43 {
44 public:
46 
47 private:
51  bool m_isFpEditor;
53 
54  bool TransferDataToWindow() override;
55  bool TransferDataFromWindow() override;
56 
57  void OnLayerSelection( wxDataViewEvent& event ) override;
58 };
59 
60 
62 {
63  DIALOG_KEEPOUT_AREA_PROPERTIES dlg( aCaller, aSettings );
64 
65  return dlg.ShowModal();
66 }
67 
68 
70  ZONE_SETTINGS* aSettings ) :
72 {
73  m_parent = aParent;
74 
75  m_ptr = aSettings;
76  m_zonesettings = *aSettings;
77 
78  m_isFpEditor = dynamic_cast<FOOTPRINT_EDIT_FRAME*>( aParent ) != nullptr;
79 
80  bool fpEditorMode = m_parent->IsType( FRAME_FOOTPRINT_EDITOR );
81  m_zonesettings.SetupLayersList( m_layers, m_parent, true, fpEditorMode );
82 
83  m_sdbSizerButtonsOK->SetDefault();
84 
86 }
87 
88 
90 {
91  // Init keepout parameters:
95 
97 
99  {
101  m_OutlineAppearanceCtrl->SetSelection( 0 );
102  break;
104  m_OutlineAppearanceCtrl->SetSelection( 1 );
105  break;
107  m_OutlineAppearanceCtrl->SetSelection( 2 );
108  break;
109  }
110 
112 
113  return true;
114 }
115 
116 
118 {
119  if( event.GetColumn() != 0 )
120  return;
121 
122  int row = m_layers->ItemToRow( event.GetItem() );
123  wxVariant layerID;
124  m_layers->GetValue( layerID, row, LAYER_LIST_COLUMN_NAME );
125  bool selected = m_layers->GetToggleValue( row, LAYER_LIST_COLUMN_CHECK );
126 
127  // In footprint editor, we have only 3 possible layer selection: C_Cu, inner layers, B_Cu.
128  // So row LAYER_LIST_ROW_ALL_INNER_LAYERS selection is fp editor specific.
129  // in board editor, this row is a normal selection
131  {
132  if( selected )
134  else
135  m_zonesettings.m_Layers &= ~LSET::InternalCuMask();
136  }
137  else
138  m_zonesettings.m_Layers.set( ToLAYER_ID( layerID.GetInteger() ), selected );
139 }
140 
141 
143 {
144  // Init keepout parameters:
149 
150  // Test for not allowed items: should have at least one item not allowed:
154  {
155  DisplayError( NULL, _("Tracks, vias, and pads are allowed. The keepout will have no effect." ) );
156  return false;
157  }
158 
159  if( m_zonesettings.m_Layers.count() == 0 )
160  {
161  DisplayError( NULL, _( "No layers selected." ) );
162  return false;
163  }
164 
165  switch( m_OutlineAppearanceCtrl->GetSelection() )
166  {
167  case 0:
169  break;
170  case 1:
172  break;
173  case 2:
175  break;
176  }
177 
178  auto cfg = m_parent->GetSettings();
179  cfg->m_Zones.hatching_style = static_cast<int>( m_zonesettings.m_Zone_HatchingStyle );
180 
182  m_zonesettings.m_ZonePriority = 0; // for a keepout, this param is not used.
183 
185  return true;
186 }
187 
188 
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
int InvokeKeepoutAreaEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeKeepoutAreaEditor invokes up a modal dialog window for copper zone editing.
This file is part of the common library.
void FinishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:115
#define LAYER_LIST_COLUMN_NAME
#define LAYER_LIST_ROW_ALL_INNER_LAYERS
void SetDoNotAllowVias(bool aEnable)
LSET is a set of PCB_LAYER_IDs.
#define NULL
DIALOG_KEEPOUT_AREA_PROPERTIES(PCB_BASE_FRAME *aParent, ZONE_SETTINGS *aSettings)
int m_ZonePriority
Priority (0 ... N) of the zone.
Definition: zone_settings.h:72
ZONE_HATCH_STYLE m_Zone_HatchingStyle
Option to show the zone area (outlines only, short hatches or full hatches.
Definition: zone_settings.h:91
static LSET InternalCuMask()
Function InternalCuMask() returns a complete set of internal copper layers, which is all Cu layers ex...
Definition: lset.cpp:646
void OnLayerSelection(wxDataViewEvent &event) override
void SetIsKeepout(bool aEnable)
const bool GetDoNotAllowVias() const
void SetDoNotAllowTracks(bool aEnable)
#define LAYER_LIST_COLUMN_CHECK
ZONE_SETTINGS * m_ptr
the pointer to the zone settings of the zone to edit
Class DIALOG_KEEPOUT_AREA_PROPERTIES_BASE.
const bool GetDoNotAllowTracks() const
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:58
bool IsType(FRAME_T aType) const
#define _(s)
Definition: 3d_actions.cpp:33
const bool GetDoNotAllowCopperPour() const
void SetDoNotAllowCopperPour(bool aEnable)
void SetupLayersList(wxDataViewListCtrl *aList, PCB_BASE_FRAME *aFrame, bool aShowCopper, bool aFpEditorMode=false)
A helper routine for the various zone dialogs (copper, non-copper, keepout).
ZONE_SETTINGS m_zonesettings
the working copy of zone settings
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:823
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
PCBNEW_SETTINGS * GetSettings()