KiCad PCB EDA Suite
dialog_non_copper_zones_properties.cpp
Go to the documentation of this file.
1 
4 /*
5  * This program source code file is part of KiCad, a free EDA CAD application.
6  *
7  * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
8  * Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
9  * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, you may find one here:
23  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
24  * or you may search the http://www.gnu.org website for the version 2 license,
25  * or you may write to the Free Software Foundation, Inc.,
26  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
27  */
28 
29 #include <fctsys.h>
30 #include <kiface_i.h>
31 #include <confirm.h>
32 #include <pcb_edit_frame.h>
33 #include <widgets/unit_binder.h>
34 #include <class_zone.h>
35 #include <zones.h>
36 
38 
39 
41 {
42 private:
45  ZONE_SETTINGS m_settings; // working copy of zone settings
47 
48  bool TransferDataToWindow() override;
49  bool TransferDataFromWindow() override;
50 
51  void OnLayerSelection( wxDataViewEvent& event ) override;
52 
53 public:
55 };
56 
57 
59 {
60  DIALOG_NON_COPPER_ZONES_EDITOR dlg( aParent, aSettings );
61 
62  return dlg.ShowModal();
63 }
64 
65 
67  ZONE_SETTINGS* aSettings ) :
69  m_minWidth( aParent, m_MinWidthLabel, m_MinWidthCtrl, m_MinWidthUnits, true )
70 {
71  m_parent = aParent;
72 
73  m_ptr = aSettings;
74  m_settings = *aSettings;
76 
77  m_sdbSizerButtonsOK->SetDefault();
78 
80 }
81 
82 
84 {
87 
89  {
90  case ZONE_CONTAINER::NO_HATCH: m_OutlineAppearanceCtrl->SetSelection( 0 ); break;
91  case ZONE_CONTAINER::DIAGONAL_EDGE: m_OutlineAppearanceCtrl->SetSelection( 1 ); break;
92  case ZONE_CONTAINER::DIAGONAL_FULL: m_OutlineAppearanceCtrl->SetSelection( 2 ); break;
93  }
94 
96 
97  return true;
98 }
99 
100 
102 {
103  if( event.GetColumn() != 0 )
104  return;
105 
106  int row = m_layers->ItemToRow( event.GetItem() );
107 
108  if( m_layers->GetToggleValue( row, 0 ) )
109  {
110  wxVariant layerID;
111  m_layers->GetValue( layerID, row, 2 );
112  m_settings.m_CurrentZone_Layer = ToLAYER_ID( layerID.GetInteger() );
113 
114  // Turn all other checkboxes off.
115  for( int ii = 0; ii < m_layers->GetItemCount(); ++ii )
116  {
117  if( ii != row )
118  m_layers->SetToggleValue( false, ii, 0 );
119  }
120  }
121 }
122 
123 
125 {
127 
128  m_settings.m_FillMode = ZFM_POLYGONS; // Use always polygon fill mode
129 
130  switch( m_OutlineAppearanceCtrl->GetSelection() )
131  {
135  }
136 
137  wxConfigBase* cfg = Kiface().KifaceSettings();
138  wxASSERT( cfg );
139 
141 
143 
144  // Get the layer selection for this zone
145  int layer = -1;
146  for( int ii = 0; ii < m_layers->GetItemCount(); ++ii )
147  {
148  if( m_layers->GetToggleValue( (unsigned) ii, 0 ) )
149  {
150  layer = ii;
151  break;
152  }
153  }
154 
155  if( layer < 0 )
156  {
157  DisplayError( this, _( "No layer selected." ) );
158  return false;
159  }
160 
161  *m_ptr = m_settings;
162  return true;
163 }
164 
165 
int m_Zone_HatchingStyle
Option to show the zone area (outlines only, short hatches or full hatches.
Definition: zone_settings.h:72
This file is part of the common library.
int InvokeNonCopperZonesEditor(PCB_BASE_FRAME *aParent, ZONE_SETTINGS *aSettings)
Function InvokeNonCopperZonesEditor invokes up a modal dialog window for non-copper zone editing.
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:103
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.
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:116
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).
virtual int GetValue()
Function GetValue Returns the current value in Internal Units.
Class DIALOG_NONCOPPER_ZONES_PROPERTIES_BASE.
Class ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:48
ZONE_FILL_MODE m_FillMode
Definition: zone_settings.h:59
DIALOG_NON_COPPER_ZONES_EDITOR(PCB_BASE_FRAME *aParent, ZONE_SETTINGS *aSettings)
virtual void SetValue(int aValue)
Function SetValue Sets new value (in Internal Units) for the text field, taking care of units convers...
void OnLayerSelection(wxDataViewEvent &event) override
#define ZONE_NET_OUTLINES_STYLE_KEY
Definition: zones.h:29
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:243
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:813
PCB_LAYER_ID m_CurrentZone_Layer
Layer used to create the current zone.
Definition: zone_settings.h:69
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
int m_ZoneMinThickness
Min thickness value in filled areas.
Definition: zone_settings.h:64