KiCad PCB EDA Suite
pcbnew/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 <fctsys.h>
28 #include <pgm_base.h>
29 #include <kiface_i.h>
30 #include <confirm.h>
31 #include <gestfich.h>
32 #include <pcb_edit_frame.h>
33 #include <pcbnew_id.h>
34 #include <footprint_edit_frame.h>
35 #include <class_board.h>
36 #include <class_module.h>
37 #include <class_track.h>
38 #include <class_zone.h>
39 #include <class_pcb_target.h>
40 #include <class_dimension.h>
41 #include <pcb_layer_box_selector.h>
42 #include <dialog_drc.h>
43 #include <array_creator.h>
45 #include <tool/tool_manager.h>
46 #include <tools/pcb_actions.h>
48 
49 // Handles the selection of command events.
50 void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
51 {
52  int id = event.GetId();
53  const PCB_DISPLAY_OPTIONS& displ_opts = GetDisplayOptions();
54 
55  switch( id ) // Execute command
56  {
57  case 0:
58  break;
59 
62 
64  GetCanvas()->Refresh();
65  break;
66 
68  ArchiveModulesOnBoard( false );
69  break;
70 
72  ArchiveModulesOnBoard( true );
73  break;
74 
75  default:
76  break;
77  }
78 }
79 
80 
82 {
83  PCB_LAYER_ID curLayer = GetActiveLayer();
84  auto displ_opts = GetDisplayOptions();
85 
86  // Check if the specified layer matches the present layer
87  if( layer == curLayer )
88  return;
89 
90  // Copper layers cannot be selected unconditionally; how many
91  // of those layers are currently enabled needs to be checked.
92  if( IsCopperLayer( layer ) )
93  {
94  // If only one copper layer is enabled, the only such layer
95  // that can be selected to is the "Back" layer (so the
96  // selection of any other copper layer is disregarded).
97  if( GetBoard()->GetCopperLayerCount() < 2 )
98  {
99  if( layer != B_Cu )
100  return;
101  }
102  // If more than one copper layer is enabled, the "Copper"
103  // and "Component" layers can be selected, but the total
104  // number of copper layers determines which internal
105  // layers are also capable of being selected.
106  else
107  {
108  if( layer != B_Cu && layer != F_Cu && layer >= GetBoard()->GetCopperLayerCount() - 1 )
109  return;
110  }
111  }
112 
113  // Is yet more checking required? E.g. when the layer to be selected
114  // is a non-copper layer, or when switching between a copper layer
115  // and a non-copper layer, or vice-versa?
116  // ...
117 
118  SetActiveLayer( layer );
119 
120  if( displ_opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL )
121  GetCanvas()->Refresh();
122 }
123 
124 
126 {
127  switch( aItem->Type() )
128  {
129  case PCB_TEXT_T:
130  InstallTextOptionsFrame( aItem );
131  break;
132 
133  case PCB_PAD_T:
134  InstallPadOptionsFrame( static_cast<D_PAD*>( aItem ) );
135  break;
136 
137  case PCB_MODULE_T:
138  InstallFootprintPropertiesDialog( static_cast<MODULE*>( aItem ) );
139  break;
140 
141  case PCB_TARGET_T:
142  ShowTargetOptionsDialog( static_cast<PCB_TARGET*>( aItem ) );
143  break;
144 
145  case PCB_DIM_ALIGNED_T:
146  case PCB_DIM_CENTER_T:
148  case PCB_DIM_LEADER_T:
149  ShowDimensionPropertyDialog( static_cast<DIMENSION*>( aItem ) );
150  break;
151 
152  case PCB_MODULE_TEXT_T:
153  InstallTextOptionsFrame( aItem );
154  break;
155 
156  case PCB_LINE_T:
158  break;
159 
160  case PCB_ZONE_AREA_T:
161  Edit_Zone_Params( static_cast<ZONE_CONTAINER*>( aItem ) );
162  break;
163 
164  default:
165  break;
166  }
167 }
168 
169 
171 {
172  if( aDimension == NULL )
173  return;
174 
175  DIALOG_DIMENSION_PROPERTIES dlg( this, aDimension );
176  dlg.ShowModal();
177 }
178 
void Edit_Zone_Params(ZONE_CONTAINER *zone_container)
Function Edit_Zone_Params Edit params (layer, clearance, ...) for a zone outline.
class ALIGNED_DIMENSION, a linear dimension (graphic item)
Definition: typeinfo.h:101
class LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:102
void OnEditItemRequest(BOARD_ITEM *aItem) override
Function OnEditItemRequest Install the corresponding dialog editor for the given item.
This file is part of the common library TODO brief description.
This file is part of the common library.
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
class CENTER_DIMENSION, a center point marking (graphic item)
Definition: typeinfo.h:103
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void InstallGraphicItemPropertiesDialog(BOARD_ITEM *aItem)
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:106
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
void ShowTargetOptionsDialog(PCB_TARGET *aTarget)
void InstallTextOptionsFrame(BOARD_ITEM *aText)
Routine for main window class to launch text properties dialog.
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Function GetDisplayOptions Display options control the way tracks, vias, outlines and other things ar...
A single base class (TRACK) represents both tracks and vias, with subclasses for curved tracks (ARC) ...
virtual PCB_LAYER_ID GetActiveLayer() const
DIMENSION class definition.
LAYER_NUM GetLayerSelection() const
class MODULE, a footprint
Definition: typeinfo.h:89
PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
PCB_LAYER_ID
A quick note on layer IDs:
#define NULL
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
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:105
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
see class PGM_BASE
void Process_Special_Functions(wxCommandEvent &event)
Definition: pcbnew/edit.cpp:50
void ArchiveModulesOnBoard(bool aStoreInNewLib, const wxString &aLibName=wxEmptyString, wxString *aLibPath=NULL)
Function ArchiveModulesOnBoard Save modules in a library:
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
PCB_TARGET class definition.
class ORTHOGONAL_DIMENSION, a linear dimension constrained to x/y
Definition: typeinfo.h:104
void InstallPadOptionsFrame(D_PAD *pad)
BOARD * GetBoard() const
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
void ShowDimensionPropertyDialog(DIMENSION *aDimension)
void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer) override
Definition: pcbnew/edit.cpp:81
void SetActiveLayer(PCB_LAYER_ID aLayer) override
Function SetActiveLayer will change the currently active layer to aLayer and also update the PCB_LAYE...
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:856
void InstallFootprintPropertiesDialog(MODULE *Module)
Abstract dimension API.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193