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 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 
63  if( displ_opts.m_ContrastModeDisplay )
64  GetCanvas()->Refresh();
65  break;
66 
68  ArchiveModulesOnBoard( false );
69  break;
70 
72  ArchiveModulesOnBoard( true );
73  break;
74 
75  default:
76  wxLogDebug( wxT( "PCB_EDIT_FRAME::Process_Special_Functions() unknown event id %d" ), id );
77  break;
78  }
79 }
80 
81 
83 {
84  PCB_LAYER_ID curLayer = GetActiveLayer();
85  auto displ_opts = GetDisplayOptions();
86 
87  // Check if the specified layer matches the present layer
88  if( layer == curLayer )
89  return;
90 
91  // Copper layers cannot be selected unconditionally; how many
92  // of those layers are currently enabled needs to be checked.
93  if( IsCopperLayer( layer ) )
94  {
95  // If only one copper layer is enabled, the only such layer
96  // that can be selected to is the "Back" layer (so the
97  // selection of any other copper layer is disregarded).
98  if( GetBoard()->GetCopperLayerCount() < 2 )
99  {
100  if( layer != B_Cu )
101  return;
102  }
103  // If more than one copper layer is enabled, the "Copper"
104  // and "Component" layers can be selected, but the total
105  // number of copper layers determines which internal
106  // layers are also capable of being selected.
107  else
108  {
109  if( layer != B_Cu && layer != F_Cu && layer >= GetBoard()->GetCopperLayerCount() - 1 )
110  return;
111  }
112  }
113 
114  // Is yet more checking required? E.g. when the layer to be selected
115  // is a non-copper layer, or when switching between a copper layer
116  // and a non-copper layer, or vice-versa?
117  // ...
118 
119  SetActiveLayer( layer );
120 
121  if( displ_opts.m_ContrastModeDisplay )
122  GetCanvas()->Refresh();
123 }
124 
125 
127 {
128  switch( aItem->Type() )
129  {
130  case PCB_TEXT_T:
131  InstallTextOptionsFrame( aItem );
132  break;
133 
134  case PCB_PAD_T:
135  InstallPadOptionsFrame( static_cast<D_PAD*>( aItem ) );
136  break;
137 
138  case PCB_MODULE_T:
139  InstallFootprintPropertiesDialog( static_cast<MODULE*>( aItem ) );
140  break;
141 
142  case PCB_TARGET_T:
143  ShowTargetOptionsDialog( static_cast<PCB_TARGET*>( aItem ) );
144  break;
145 
146  case PCB_DIMENSION_T:
147  ShowDimensionPropertyDialog( static_cast<DIMENSION*>( aItem ) );
148  break;
149 
150  case PCB_MODULE_TEXT_T:
151  InstallTextOptionsFrame( aItem );
152  break;
153 
154  case PCB_LINE_T:
156  break;
157 
158  case PCB_ZONE_AREA_T:
159  Edit_Zone_Params( static_cast<ZONE_CONTAINER*>( aItem ) );
160  break;
161 
162  default:
163  break;
164  }
165 }
166 
167 
169 {
170  if( aDimension == NULL )
171  return;
172 
173  DIALOG_TEXT_PROPERTIES dlg( this, aDimension );
174  dlg.ShowModal();
175 }
176 
void Edit_Zone_Params(ZONE_CONTAINER *zone_container)
Function Edit_Zone_Params Edit params (layer, clearance, ...) for a zone outline.
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,...
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:102
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 returns the display options current in use Display options are relative to...
Definitions for tracks, vias and zones.
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
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
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
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:101
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.
void InstallPadOptionsFrame(D_PAD *pad)
Module description (excepted pads)
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:82
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:823
void InstallFootprintPropertiesDialog(MODULE *Module)
DIMENSION.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212