You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

179 lines
5.4 KiB

4 years ago
18 years ago
18 years ago
11 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
5 years ago
18 years ago
5 years ago
5 years ago
5 years ago
18 years ago
5 years ago
18 years ago
5 years ago
  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. #include <kiface_base.h>
  27. #include <confirm.h>
  28. #include <gestfich.h>
  29. #include <pcb_edit_frame.h>
  30. #include <pcbnew_id.h>
  31. #include <board.h>
  32. #include <footprint.h>
  33. #include <pad.h>
  34. #include <zone.h>
  35. #include <pcb_target.h>
  36. #include <pcb_dimension.h>
  37. #include <dialog_drc.h>
  38. #include <connectivity/connectivity_data.h>
  39. #include <tool/tool_manager.h>
  40. #include <tools/pcb_actions.h>
  41. #include <tools/drc_tool.h>
  42. #include <dialogs/dialog_dimension_properties.h>
  43. #include <pcb_layer_box_selector.h>
  44. // Handles the selection of command events.
  45. void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
  46. {
  47. int id = event.GetId();
  48. const PCB_DISPLAY_OPTIONS& displ_opts = GetDisplayOptions();
  49. switch( id ) // Execute command
  50. {
  51. case 0:
  52. break;
  53. case ID_TOOLBARH_PCB_SELECT_LAYER:
  54. SetActiveLayer( ToLAYER_ID( m_SelLayerBox->GetLayerSelection() ) );
  55. if( displ_opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL )
  56. GetCanvas()->Refresh();
  57. break;
  58. case ID_MENU_EXPORT_FOOTPRINTS_TO_LIBRARY:
  59. ExportFootprintsToLibrary( false );
  60. break;
  61. case ID_MENU_EXPORT_FOOTPRINTS_TO_NEW_LIBRARY:
  62. ExportFootprintsToLibrary( true );
  63. break;
  64. default:
  65. break;
  66. }
  67. }
  68. void PCB_EDIT_FRAME::SwitchLayer( PCB_LAYER_ID layer )
  69. {
  70. PCB_LAYER_ID curLayer = GetActiveLayer();
  71. auto displ_opts = GetDisplayOptions();
  72. // Check if the specified layer matches the present layer
  73. if( layer == curLayer )
  74. return;
  75. // Copper layers cannot be selected unconditionally; how many of those layers are currently
  76. // enabled needs to be checked.
  77. if( IsCopperLayer( layer ) )
  78. {
  79. // If only one copper layer is enabled, the only such layer that can be selected to is
  80. // the "Back" layer (so the selection of any other copper layer is disregarded).
  81. if( GetBoard()->GetCopperLayerCount() < 2 )
  82. {
  83. if( layer != B_Cu )
  84. return;
  85. }
  86. // If more than one copper layer is enabled, the "Copper" and "Component" layers can be
  87. // selected, but the total number of copper layers determines which internal layers are
  88. // also capable of being selected.
  89. else
  90. {
  91. if( layer != B_Cu && layer != F_Cu && layer >= GetBoard()->GetCopperLayerCount() - 1 )
  92. return;
  93. }
  94. }
  95. // Is yet more checking required? E.g. when the layer to be selected is a non-copper layer,
  96. // or when switching between a copper layer and a non-copper layer, or vice-versa?
  97. SetActiveLayer( layer );
  98. if( displ_opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL )
  99. GetCanvas()->Refresh();
  100. }
  101. void PCB_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem )
  102. {
  103. switch( aItem->Type() )
  104. {
  105. case PCB_BITMAP_T:
  106. ShowBitmapPropertiesDialog( aItem);
  107. break;
  108. case PCB_TEXT_T:
  109. case PCB_FP_TEXT_T:
  110. ShowTextPropertiesDialog( aItem );
  111. break;
  112. case PCB_TEXTBOX_T:
  113. case PCB_FP_TEXTBOX_T:
  114. ShowTextBoxPropertiesDialog( aItem );
  115. break;
  116. case PCB_PAD_T:
  117. ShowPadPropertiesDialog( static_cast<PAD*>( aItem ) );
  118. break;
  119. case PCB_FOOTPRINT_T:
  120. ShowFootprintPropertiesDialog( static_cast<FOOTPRINT*>( aItem ) );
  121. break;
  122. case PCB_TARGET_T:
  123. ShowTargetOptionsDialog( static_cast<PCB_TARGET*>( aItem ) );
  124. break;
  125. case PCB_DIM_ALIGNED_T:
  126. case PCB_DIM_CENTER_T:
  127. case PCB_DIM_RADIAL_T:
  128. case PCB_DIM_ORTHOGONAL_T:
  129. case PCB_DIM_LEADER_T:
  130. {
  131. DIALOG_DIMENSION_PROPERTIES dlg( this, static_cast<PCB_DIMENSION_BASE*>( aItem ) );
  132. dlg.ShowQuasiModal();
  133. break;
  134. }
  135. case PCB_SHAPE_T:
  136. ShowGraphicItemPropertiesDialog( aItem );
  137. break;
  138. case PCB_ZONE_T:
  139. Edit_Zone_Params( static_cast<ZONE*>( aItem ) );
  140. break;
  141. case PCB_GROUP_T:
  142. m_toolManager->RunAction( PCB_ACTIONS::groupProperties, true, aItem );
  143. break;
  144. case PCB_MARKER_T:
  145. m_toolManager->GetTool<DRC_TOOL>()->CrossProbe( static_cast<PCB_MARKER*>( aItem ) );
  146. break;
  147. default:
  148. break;
  149. }
  150. }