KiCad PCB EDA Suite
edit.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) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
7  * Copyright (C) 2017-2020 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
27 #include <pgm_base.h>
28 #include <kiface_i.h>
29 #include <confirm.h>
30 #include <gestfich.h>
31 #include <pcb_edit_frame.h>
32 #include <pcbnew_id.h>
33 #include <board.h>
34 #include <footprint.h>
35 #include <track.h>
36 #include <zone.h>
37 #include <pcb_target.h>
38 #include <dimension.h>
39 #include <pcb_layer_box_selector.h>
40 #include <dialog_drc.h>
42 #include <tool/tool_manager.h>
43 #include <tools/pcb_actions.h>
45 
46 // Handles the selection of command events.
47 void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
48 {
49  int id = event.GetId();
50  const PCB_DISPLAY_OPTIONS& displ_opts = GetDisplayOptions();
51 
52  switch( id ) // Execute command
53  {
54  case 0:
55  break;
56 
59 
61  GetCanvas()->Refresh();
62  break;
63 
66  break;
67 
70  break;
71 
72  default:
73  break;
74  }
75 }
76 
77 
79 {
80  PCB_LAYER_ID curLayer = GetActiveLayer();
81  auto displ_opts = GetDisplayOptions();
82 
83  // Check if the specified layer matches the present layer
84  if( layer == curLayer )
85  return;
86 
87  // Copper layers cannot be selected unconditionally; how many of those layers are currently
88  // enabled needs to be checked.
89  if( IsCopperLayer( layer ) )
90  {
91  // If only one copper layer is enabled, the only such layer that can be selected to is
92  // the "Back" layer (so the selection of any other copper layer is disregarded).
93  if( GetBoard()->GetCopperLayerCount() < 2 )
94  {
95  if( layer != B_Cu )
96  return;
97  }
98  // If more than one copper layer is enabled, the "Copper" and "Component" layers can be
99  // selected, but the total number of copper layers determines which internal layers are
100  // also capable of being selected.
101  else
102  {
103  if( layer != B_Cu && layer != F_Cu && layer >= GetBoard()->GetCopperLayerCount() - 1 )
104  return;
105  }
106  }
107 
108  // Is yet more checking required? E.g. when the layer to be selected is a non-copper layer,
109  // or when switching between a copper layer and a non-copper layer, or vice-versa?
110 
111  SetActiveLayer( layer );
112 
113  if( displ_opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL )
114  GetCanvas()->Refresh();
115 }
116 
117 
119 {
120  switch( aItem->Type() )
121  {
122  case PCB_TEXT_T:
123  ShowTextPropertiesDialog( aItem );
124  break;
125 
126  case PCB_PAD_T:
127  ShowPadPropertiesDialog( static_cast<PAD*>( aItem ) );
128  break;
129 
130  case PCB_FOOTPRINT_T:
131  ShowFootprintPropertiesDialog( static_cast<FOOTPRINT*>( aItem ) );
132  break;
133 
134  case PCB_TARGET_T:
135  ShowTargetOptionsDialog( static_cast<PCB_TARGET*>( aItem ) );
136  break;
137 
138  case PCB_DIM_ALIGNED_T:
139  case PCB_DIM_CENTER_T:
141  case PCB_DIM_LEADER_T:
142  ShowDimensionPropertiesDialog( static_cast<DIMENSION_BASE*>( aItem ) );
143  break;
144 
145  case PCB_FP_TEXT_T:
146  ShowTextPropertiesDialog( aItem );
147  break;
148 
149  case PCB_SHAPE_T:
151  break;
152 
153  case PCB_ZONE_T:
154  Edit_Zone_Params( static_cast<ZONE*>( aItem ) );
155  break;
156 
157  case PCB_GROUP_T:
159  break;
160 
161  default:
162  break;
163  }
164 }
165 
166 
168 {
169  if( aDimension == nullptr )
170  return;
171 
172  DIALOG_DIMENSION_PROPERTIES dlg( this, aDimension );
173  dlg.ShowQuasiModal();
174 }
175 
class ALIGNED_DIMENSION, a linear dimension (graphic item)
Definition: typeinfo.h:100
class LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:101
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
void OnEditItemRequest(BOARD_ITEM *aItem) override
Install the corresponding dialog editor for the given item.
Definition: edit.cpp:118
This file is part of the common library TODO brief description.
This file is part of the common library.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
class CENTER_DIMENSION, a center point marking (graphic item)
Definition: typeinfo.h:102
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
class PCB_TEXT, text on a layer
Definition: typeinfo.h:91
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
class PAD, a pad in a footprint
Definition: typeinfo.h:89
void ShowTargetOptionsDialog(PCB_TARGET *aTarget)
void ShowDimensionPropertiesDialog(DIMENSION_BASE *aDimension)
Definition: edit.cpp:167
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
void ShowTextPropertiesDialog(BOARD_ITEM *aText)
void ExportFootprintsToLibrary(bool aStoreInNewLib, const wxString &aLibName=wxEmptyString, wxString *aLibPath=NULL)
Save footprints in a library:
void ShowFootprintPropertiesDialog(FOOTPRINT *aFootprint)
virtual PCB_LAYER_ID GetActiveLayer() const
LAYER_NUM GetLayerSelection() const
Container for display options like enable/disable some optional drawings.
PCB_LAYER_ID
A quick note on layer IDs:
int ShowQuasiModal()
Inactive layers are shown normally (no high-contrast mode)
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
class ZONE, a copper pour area
Definition: typeinfo.h:105
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:104
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
void Edit_Zone_Params(ZONE *zone_container)
Edit params (layer, clearance, ...) for a zone outline.
void ShowGraphicItemPropertiesDialog(BOARD_ITEM *aItem)
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:157
see class PGM_BASE
void Process_Special_Functions(wxCommandEvent &event)
Definition: edit.cpp:47
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
class ORTHOGONAL_DIMENSION, a linear dimension constrained to x/y
Definition: typeinfo.h:103
BOARD * GetBoard() const
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
void ShowPadPropertiesDialog(PAD *aPad)
Abstract dimension API.
Definition: dimension.h:95
void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer) override
Definition: edit.cpp:78
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
void SetActiveLayer(PCB_LAYER_ID aLayer) override
Change the currently active layer to aLayer and also update the APPEARANCE_CONTROLS.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:905
static TOOL_ACTION groupProperties
Definition: pcb_actions.h:223
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:163