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-2018 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 <class_zone.h>
31 #include <zones.h>
32 #include <zone_settings.h>
34 
35 
37 {
38 public:
40 
41 private:
43  wxConfigBase* m_config;
46 
48  bool TransferDataToWindow() override;
49  bool TransferDataFromWindow() override;
50 
51  void OnLayerSelection( wxDataViewEvent& event ) override;
52 };
53 
54 
56 {
57  DIALOG_KEEPOUT_AREA_PROPERTIES dlg( aCaller, aSettings );
58 
59  return dlg.ShowModal();
60 }
61 
62 
64  ZONE_SETTINGS* aSettings ) :
66 {
67  m_parent = aParent;
69 
70  m_ptr = aSettings;
71  m_zonesettings = *aSettings;
73 
74  m_sdbSizerButtonsOK->SetDefault();
75 
77 }
78 
79 
81 {
82  // Init keepout parameters:
86 
88 
90  {
91  case ZONE_CONTAINER::NO_HATCH: m_OutlineAppearanceCtrl->SetSelection( 0 ); break;
92  case ZONE_CONTAINER::DIAGONAL_EDGE: m_OutlineAppearanceCtrl->SetSelection( 1 ); break;
93  case ZONE_CONTAINER::DIAGONAL_FULL: m_OutlineAppearanceCtrl->SetSelection( 2 ); break;
94  }
95 
96  return true;
97 }
98 
99 
101 {
102  if( event.GetColumn() != 0 )
103  return;
104 
105  int row = m_layers->ItemToRow( event.GetItem() );
106  wxVariant layerID;
107  m_layers->GetValue( layerID, row, 2 );
108  bool selected = m_layers->GetToggleValue( row, 0 );
109 
110  m_zonesettings.m_Layers.set( ToLAYER_ID( layerID.GetInteger() ), selected );
111 }
112 
113 
115 {
116  // Init keepout parameters:
121 
122  // Test for not allowed items: should have at least one item not allowed:
126  {
127  DisplayError( NULL, _("Tracks, vias, and pads are allowed. The keepout will have no effect." ) );
128  return false;
129  }
130 
131  if( m_zonesettings.m_Layers.count() == 0 )
132  {
133  DisplayError( NULL, _( "No layers selected." ) );
134  return false;
135  }
136 
137  switch( m_OutlineAppearanceCtrl->GetSelection() )
138  {
142  }
143 
144  if( m_config )
146 
148  m_zonesettings.m_ZonePriority = 0; // for a keepout, this param is not used.
149 
151  return true;
152 }
153 
154 
int m_Zone_HatchingStyle
Option to show the zone area (outlines only, short hatches or full hatches.
Definition: zone_settings.h:72
const bool GetDoNotAllowTracks() const
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.
const bool GetDoNotAllowCopperPour() const
void FinishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Classes to handle copper zones.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
void SetupLayersList(wxDataViewListCtrl *aList, PCB_BASE_FRAME *aFrame, bool aShowCopper)
A helper routine for the various zone dialogs (copper, non-copper, keepout).
void SetDoNotAllowVias(bool aEnable)
DIALOG_KEEPOUT_AREA_PROPERTIES(PCB_BASE_FRAME *aParent, ZONE_SETTINGS *aSettings)
int m_ZonePriority
Priority (0 ... N) of the zone.
Definition: zone_settings.h:61
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:103
void OnLayerSelection(wxDataViewEvent &event) override
void SetIsKeepout(bool aEnable)
void SetDoNotAllowTracks(bool aEnable)
ZONE_SETTINGS * m_ptr
the pointer to the zone settings of the zone to edit
Class DIALOG_KEEPOUT_AREA_PROPERTIES_BASE.
Class ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:48
const bool GetDoNotAllowVias() const
void SetDoNotAllowCopperPour(bool aEnable)
#define ZONE_NET_OUTLINES_STYLE_KEY
Definition: zones.h:29
ZONE_SETTINGS m_zonesettings
the working copy of zone settings
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:245
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:810
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...