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 <kiface_i.h>
28 #include <confirm.h>
29 #include <gestfich.h>
30 #include <pcb_edit_frame.h>
31 #include <pcbnew_id.h>
32 #include <board.h>
33 #include <footprint.h>
34 #include <pad.h>
35 #include <zone.h>
36 #include <pcb_target.h>
37 #include <pcb_dimension.h>
38 #include <pcb_layer_box_selector.h>
39 #include <dialog_drc.h>
41 #include <tool/tool_manager.h>
42 #include <tools/pcb_actions.h>
44 
45 // Handles the selection of command events.
46 void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
47 {
48  int id = event.GetId();
49  const PCB_DISPLAY_OPTIONS& displ_opts = GetDisplayOptions();
50 
51  switch( id ) // Execute command
52  {
53  case 0:
54  break;
55 
58 
60  GetCanvas()->Refresh();
61  break;
62 
65  break;
66 
69  break;
70 
71  default:
72  break;
73  }
74 }
75 
76 
78 {
79  PCB_LAYER_ID curLayer = GetActiveLayer();
80  auto displ_opts = GetDisplayOptions();
81 
82  // Check if the specified layer matches the present layer
83  if( layer == curLayer )
84  return;
85 
86  // Copper layers cannot be selected unconditionally; how many of those layers are currently
87  // enabled needs to be checked.
88  if( IsCopperLayer( layer ) )
89  {
90  // If only one copper layer is enabled, the only such layer that can be selected to is
91  // the "Back" layer (so the selection of any other copper layer is disregarded).
92  if( GetBoard()->GetCopperLayerCount() < 2 )
93  {
94  if( layer != B_Cu )
95  return;
96  }
97  // If more than one copper layer is enabled, the "Copper" and "Component" layers can be
98  // selected, but the total number of copper layers determines which internal layers are
99  // also capable of being selected.
100  else
101  {
102  if( layer != B_Cu && layer != F_Cu && layer >= GetBoard()->GetCopperLayerCount() - 1 )
103  return;
104  }
105  }
106 
107  // Is yet more checking required? E.g. when the layer to be selected is a non-copper layer,
108  // or when switching between a copper layer and a non-copper layer, or vice-versa?
109 
110  SetActiveLayer( layer );
111 
112  if( displ_opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL )
113  GetCanvas()->Refresh();
114 }
115 
116 
118 {
119  switch( aItem->Type() )
120  {
121  case PCB_TEXT_T:
122  ShowTextPropertiesDialog( aItem );
123  break;
124 
125  case PCB_PAD_T:
126  ShowPadPropertiesDialog( static_cast<PAD*>( aItem ) );
127  break;
128 
129  case PCB_FOOTPRINT_T:
130  ShowFootprintPropertiesDialog( static_cast<FOOTPRINT*>( aItem ) );
131  break;
132 
133  case PCB_TARGET_T:
134  ShowTargetOptionsDialog( static_cast<PCB_TARGET*>( aItem ) );
135  break;
136 
137  case PCB_DIM_ALIGNED_T:
138  case PCB_DIM_CENTER_T:
140  case PCB_DIM_LEADER_T:
141  ShowDimensionPropertiesDialog( static_cast<PCB_DIMENSION_BASE*>( aItem ) );
142  break;
143 
144  case PCB_FP_TEXT_T:
145  ShowTextPropertiesDialog( aItem );
146  break;
147 
148  case PCB_SHAPE_T:
150  break;
151 
152  case PCB_ZONE_T:
153  Edit_Zone_Params( static_cast<ZONE*>( aItem ) );
154  break;
155 
156  case PCB_GROUP_T:
158  break;
159 
160  default:
161  break;
162  }
163 }
164 
165 
167 {
168  if( aDimension == nullptr )
169  return;
170 
171  DIALOG_DIMENSION_PROPERTIES dlg( this, aDimension );
172  dlg.ShowQuasiModal();
173 }
174 
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:100
class PCB_DIM_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:117
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:80
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
class PCB_DIM_CENTER, 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:143
class PAD, a pad in a footprint
Definition: typeinfo.h:89
Abstract dimension API.
Definition: pcb_dimension.h:95
void ShowTargetOptionsDialog(PCB_TARGET *aTarget)
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 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)
void ExportFootprintsToLibrary(bool aStoreInNewLib, const wxString &aLibName=wxEmptyString, wxString *aLibPath=nullptr)
Save footprints in a library:
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
class ZONE, a copper pour area
Definition: typeinfo.h:105
void ShowDimensionPropertiesDialog(PCB_DIMENSION_BASE *aDimension)
Definition: edit.cpp:166
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:158
void Process_Special_Functions(wxCommandEvent &event)
Definition: edit.cpp:46
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:103
BOARD * GetBoard() const
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
void ShowPadPropertiesDialog(PAD *aPad)
void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer) override
Definition: edit.cpp:77
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:219
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113