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.

2081 lines
64 KiB

14 years ago
14 years ago
14 years ago
12 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
8 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
14 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
14 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
14 years ago
14 years ago
14 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
14 years ago
14 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
14 years ago
12 years ago
12 years ago
12 years ago
16 years ago
14 years ago
16 years ago
14 years ago
16 years ago
14 years ago
16 years ago
14 years ago
16 years ago
16 years ago
14 years ago
14 years ago
16 years ago
14 years ago
16 years ago
16 years ago
14 years ago
16 years ago
14 years ago
16 years ago
16 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
  1. /**
  2. * @file dialog_pad_properties.cpp
  3. * @brief dialog pad properties editor.
  4. */
  5. /*
  6. * This program source code file is part of KiCad, a free EDA CAD application.
  7. *
  8. * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
  9. * Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com
  10. * Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
  11. * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License
  15. * as published by the Free Software Foundation; either version 2
  16. * of the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, you may find one here:
  25. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  26. * or you may search the http://www.gnu.org website for the version 2 license,
  27. * or you may write to the Free Software Foundation, Inc.,
  28. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  29. */
  30. #include <fctsys.h>
  31. #include <common.h>
  32. #include <gr_basic.h>
  33. #include <gal/graphics_abstraction_layer.h>
  34. #include <view/view_controls.h>
  35. #include <trigo.h>
  36. #include <class_drawpanel.h>
  37. #include <confirm.h>
  38. #include <pcbnew.h>
  39. #include <pcb_base_frame.h>
  40. #include <base_units.h>
  41. #include <unit_format.h>
  42. #include <board_commit.h>
  43. #include <bitmaps.h>
  44. #include <class_board.h>
  45. #include <class_module.h>
  46. #include <pcb_painter.h>
  47. #include <dialog_pad_properties.h>
  48. #include <html_messagebox.h>
  49. // list of pad shapes, ordered like the pad shape wxChoice in dialog.
  50. static PAD_SHAPE_T code_shape[] = {
  51. PAD_SHAPE_CIRCLE,
  52. PAD_SHAPE_OVAL,
  53. PAD_SHAPE_RECT,
  54. PAD_SHAPE_TRAPEZOID,
  55. PAD_SHAPE_ROUNDRECT,
  56. PAD_SHAPE_CUSTOM, // choice = CHOICE_SHAPE_CUSTOM_CIRC_ANCHOR
  57. PAD_SHAPE_CUSTOM // choice = PAD_SHAPE_CUSTOM_RECT_ANCHOR
  58. };
  59. // the ordered index of the pad shape wxChoice in dialog.
  60. // keep it consistent with code_shape[] and dialog strings
  61. enum CODE_CHOICE {
  62. CHOICE_SHAPE_CIRCLE = 0,
  63. CHOICE_SHAPE_OVAL,
  64. CHOICE_SHAPE_RECT,
  65. CHOICE_SHAPE_TRAPEZOID,
  66. CHOICE_SHAPE_ROUNDRECT,
  67. CHOICE_SHAPE_CUSTOM_CIRC_ANCHOR,
  68. CHOICE_SHAPE_CUSTOM_RECT_ANCHOR
  69. };
  70. static PAD_ATTR_T code_type[] = {
  71. PAD_ATTRIB_STANDARD,
  72. PAD_ATTRIB_SMD,
  73. PAD_ATTRIB_CONN,
  74. PAD_ATTRIB_HOLE_NOT_PLATED
  75. };
  76. // Default mask layers setup for pads according to the pad type
  77. static const LSET std_pad_layers[] = {
  78. // PAD_ATTRIB_STANDARD:
  79. D_PAD::StandardMask(),
  80. // PAD_ATTRIB_SMD:
  81. D_PAD::SMDMask(),
  82. // PAD_ATTRIB_CONN:
  83. D_PAD::ConnSMDMask(),
  84. // PAD_ATTRIB_HOLE_NOT_PLATED:
  85. D_PAD::UnplatedHoleMask()
  86. };
  87. void PCB_BASE_FRAME::InstallPadOptionsFrame( D_PAD* aPad )
  88. {
  89. DIALOG_PAD_PROPERTIES dlg( this, aPad );
  90. dlg.ShowModal();
  91. }
  92. DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aPad ) :
  93. DIALOG_PAD_PROPERTIES_BASE( aParent ),
  94. m_OrientValidator( 1, &m_OrientValue )
  95. {
  96. m_canUpdate = false;
  97. m_parent = aParent;
  98. m_currentPad = aPad; // aPad can be NULL, if the dialog is called
  99. // from the footprint editor to set default pad setup
  100. m_board = m_parent->GetBoard();
  101. m_OrientValidator.SetRange( -360.0, 360.0 );
  102. m_PadOrientCtrl->SetValidator( m_OrientValidator );
  103. m_OrientValidator.SetWindow( m_PadOrientCtrl );
  104. m_cbShowPadOutline->SetValue( m_drawPadOutlineMode );
  105. m_FlippedWarningIcon->SetBitmap( KiBitmap( dialog_warning_xpm ) );
  106. m_nonCopperWarningIcon->SetBitmap( KiBitmap( dialog_warning_xpm ) );
  107. m_padMaster = &m_parent->GetDesignSettings().m_Pad_Master;
  108. m_dummyPad = new D_PAD( (MODULE*) NULL );
  109. if( aPad )
  110. *m_dummyPad = *aPad;
  111. else // We are editing a "master" pad, i.e. a template to create new pads
  112. *m_dummyPad = *m_padMaster;
  113. initValues();
  114. wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
  115. infoFont.SetSymbolicSize( wxFONTSIZE_SMALL );
  116. m_staticTextInfoNegVal->SetFont( infoFont );
  117. m_staticTextInfoPosValue->SetFont( infoFont );
  118. m_nonCopperNote->SetFont( infoFont );
  119. // Usually, TransferDataToWindow is called by OnInitDialog
  120. // calling it here fixes all widgets sizes, and FinishDialogSettings can
  121. // safely fix minsizes
  122. TransferDataToWindow();
  123. // Initialize canvas to be able to display the dummy pad:
  124. prepareCanvas();
  125. m_sdbSizerOK->SetDefault();
  126. m_canUpdate = true;
  127. // Now all widgets have the size fixed, call FinishDialogSettings
  128. FinishDialogSettings();
  129. }
  130. bool DIALOG_PAD_PROPERTIES::m_drawPadOutlineMode = false; // Stores the pad draw option during a session
  131. void DIALOG_PAD_PROPERTIES::OnInitDialog( wxInitDialogEvent& event )
  132. {
  133. m_PadNumCtrl->SetFocus();
  134. m_PadNumCtrl->SetSelection( -1, -1 );
  135. m_selectedColor = COLOR4D( 1.0, 1.0, 1.0, 0.7 );
  136. // Needed on some WM to be sure the pad is redrawn according to the final size
  137. // of the canvas, with the right zoom factor
  138. redraw();
  139. }
  140. void DIALOG_PAD_PROPERTIES::OnCancel( wxCommandEvent& event )
  141. {
  142. // Mandatory to avoid m_panelShowPadGal trying to draw something
  143. // in a non valid context during closing process:
  144. if( m_parent->IsGalCanvasActive() )
  145. m_panelShowPadGal->StopDrawing();
  146. // Now call default handler for wxID_CANCEL command event
  147. event.Skip();
  148. }
  149. void DIALOG_PAD_PROPERTIES::enablePrimitivePage( bool aEnable )
  150. {
  151. // Enable or disable the widgets in page managing custom shape primitives
  152. m_listCtrlPrimitives->Enable( aEnable );
  153. m_buttonDel->Enable( aEnable );
  154. m_buttonEditShape->Enable( aEnable );
  155. m_buttonAddShape->Enable( aEnable );
  156. m_buttonDup->Enable( aEnable );
  157. m_buttonGeometry->Enable( aEnable );
  158. m_buttonImport->Enable( aEnable );
  159. }
  160. void DIALOG_PAD_PROPERTIES::prepareCanvas()
  161. {
  162. // Initialize the canvases (legacy or gal) to display the pad
  163. // Enable the suitable canvas and make some inits
  164. // Show the X and Y axis. It is usefull because pad shape can have an offset
  165. // or be a complex shape.
  166. KIGFX::COLOR4D axis_color = LIGHTBLUE;
  167. m_axisOrigin = new KIGFX::ORIGIN_VIEWITEM( axis_color,
  168. KIGFX::ORIGIN_VIEWITEM::CROSS,
  169. Millimeter2iu( 0.2 ),
  170. VECTOR2D( m_dummyPad->GetPosition() ) );
  171. m_axisOrigin->SetDrawAtZero( true );
  172. if( m_parent->IsGalCanvasActive() )
  173. {
  174. m_panelShowPadGal->UseColorScheme( &m_parent->Settings().Colors() );
  175. m_panelShowPadGal->SwitchBackend( m_parent->GetGalCanvas()->GetBackend() );
  176. m_panelShowPadGal->GetViewControls()->
  177. EnableMousewheelPan( m_parent->GetCanvas()->GetEnableMousewheelPan() );
  178. m_panelShowPadGal->Show();
  179. m_panelShowPad->Hide();
  180. KIGFX::VIEW* view = m_panelShowPadGal->GetView();
  181. // fix the pad render mode (filled/not filled)
  182. KIGFX::PCB_RENDER_SETTINGS* settings =
  183. static_cast<KIGFX::PCB_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
  184. bool filled = !m_cbShowPadOutline->IsChecked();
  185. settings->SetSketchMode( LAYER_PADS_TH, !filled );
  186. settings->SetSketchMode( LAYER_PAD_FR, !filled );
  187. settings->SetSketchMode( LAYER_PAD_BK, !filled );
  188. settings->SetSketchModeGraphicItems( !filled );
  189. // gives a non null grid size (0.001mm) because GAL layer does not like a 0 size grid:
  190. double gridsize = 0.001 * IU_PER_MM;
  191. view->GetGAL()->SetGridSize( VECTOR2D( gridsize, gridsize ) );
  192. view->Add( m_dummyPad );
  193. view->Add( m_axisOrigin );
  194. m_panelShowPadGal->StartDrawing();
  195. Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_PAD_PROPERTIES::OnResize ) );
  196. }
  197. else
  198. {
  199. m_panelShowPad->Show();
  200. m_panelShowPadGal->Hide();
  201. }
  202. }
  203. void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
  204. {
  205. wxPaintDC dc( m_panelShowPad );
  206. PAD_DRAWINFO drawInfo;
  207. COLOR4D color = COLOR4D::BLACK;
  208. if( m_dummyPad->GetLayerSet()[F_Cu] )
  209. {
  210. color = m_parent->Settings().Colors().GetItemColor( LAYER_PAD_FR );
  211. }
  212. if( m_dummyPad->GetLayerSet()[B_Cu] )
  213. {
  214. color = color.LegacyMix( m_parent->Settings().Colors().GetItemColor( LAYER_PAD_BK ) );
  215. }
  216. // What could happen: the pad color is *actually* black, or no
  217. // copper was selected
  218. if( color == BLACK )
  219. color = LIGHTGRAY;
  220. drawInfo.m_Color = color;
  221. drawInfo.m_HoleColor = DARKGRAY;
  222. drawInfo.m_Offset = m_dummyPad->GetPosition();
  223. drawInfo.m_Display_padnum = true;
  224. drawInfo.m_Display_netname = true;
  225. drawInfo.m_ShowPadFilled = !m_drawPadOutlineMode;
  226. if( m_dummyPad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED )
  227. drawInfo.m_ShowNotPlatedHole = true;
  228. // Shows the local pad clearance
  229. drawInfo.m_PadClearance = m_dummyPad->GetLocalClearance();
  230. wxSize dc_size = dc.GetSize();
  231. dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 );
  232. // Calculate a suitable scale to fit the available draw area
  233. int dim = m_dummyPad->GetBoundingRadius() *2;
  234. // Invalid x size. User could enter zero, or have deleted all text prior to
  235. // entering a new value; this is also treated as zero. If dim is left at
  236. // zero, the drawing scale is zero and we get a crash.
  237. if( dim == 0 )
  238. {
  239. // If drill size has been set, use that. Otherwise default to 1mm.
  240. dim = m_dummyPad->GetDrillSize().x;
  241. if( dim == 0 )
  242. dim = Millimeter2iu( 1.0 );
  243. }
  244. if( m_dummyPad->GetLocalClearance() > 0 )
  245. dim += m_dummyPad->GetLocalClearance() * 2;
  246. double scale = (double) dc_size.x / dim;
  247. // If the pad is a circle, use the x size here instead.
  248. int ysize;
  249. if( m_dummyPad->GetShape() == PAD_SHAPE_CIRCLE )
  250. ysize = m_dummyPad->GetSize().x;
  251. else
  252. ysize = m_dummyPad->GetSize().y;
  253. dim = ysize + std::abs( m_dummyPad->GetDelta().x );
  254. // Invalid y size. See note about x size above.
  255. if( dim == 0 )
  256. {
  257. dim = m_dummyPad->GetDrillSize().y;
  258. if( dim == 0 )
  259. dim = Millimeter2iu( 0.1 );
  260. }
  261. if( m_dummyPad->GetLocalClearance() > 0 )
  262. dim += m_dummyPad->GetLocalClearance() * 2;
  263. double altscale = (double) dc_size.y / dim;
  264. scale = std::min( scale, altscale );
  265. // Give a margin
  266. scale *= 0.7;
  267. dc.SetUserScale( scale, scale );
  268. GRResetPenAndBrush( &dc );
  269. m_dummyPad->DrawShape( NULL, &dc, drawInfo );
  270. // draw selected primitives:
  271. long select = m_listCtrlPrimitives->GetFirstSelected();
  272. wxPoint start, end, center;
  273. while( select >= 0 )
  274. {
  275. PAD_CS_PRIMITIVE& primitive = m_primitives[select];
  276. // The best way to calculate parameters to draw a primitive is to
  277. // use a dummy DRAWSEGMENT and use its methods
  278. // Note: in legacy canvas, the pad has the 0,0 position
  279. DRAWSEGMENT dummySegment;
  280. primitive.ExportTo( &dummySegment );
  281. dummySegment.Rotate( wxPoint( 0, 0), m_dummyPad->GetOrientation() );
  282. switch( primitive.m_Shape )
  283. {
  284. case S_SEGMENT: // usual segment : line with rounded ends
  285. if( !m_drawPadOutlineMode )
  286. GRFilledSegment( NULL, &dc, dummySegment.GetStart(), dummySegment.GetEnd(),
  287. primitive.m_Thickness, m_selectedColor );
  288. else
  289. GRCSegm( NULL, &dc, dummySegment.GetStart(), dummySegment.GetEnd(),
  290. primitive.m_Thickness, m_selectedColor );
  291. break;
  292. case S_ARC: // Arc with rounded ends
  293. if( !m_drawPadOutlineMode )
  294. GRArc1( NULL, &dc, dummySegment.GetArcEnd(), dummySegment.GetArcStart(),
  295. dummySegment.GetCenter(), primitive.m_Thickness, m_selectedColor );
  296. else
  297. {
  298. GRArc1( NULL, &dc, dummySegment.GetArcEnd(), dummySegment.GetArcStart(),
  299. dummySegment.GetCenter(), 0, m_selectedColor );
  300. /* GRArc1( NULL, &dc, dummySegment.GetArcEnd(), dummySegment.GetArcStart(),
  301. dummySegment.GetCenter() - primitive.m_Thickness, 0, m_selectedColor );*/
  302. }
  303. break;
  304. case S_CIRCLE: // ring or circle
  305. if( primitive.m_Thickness )
  306. {
  307. if( !m_drawPadOutlineMode )
  308. GRCircle( NULL, &dc, dummySegment.GetCenter(), primitive.m_Radius,
  309. primitive.m_Thickness, m_selectedColor );
  310. else
  311. {
  312. GRCircle( NULL, &dc, dummySegment.GetCenter(),
  313. primitive.m_Radius + primitive.m_Thickness/2, 0,
  314. m_selectedColor );
  315. GRCircle( NULL, &dc, dummySegment.GetCenter(),
  316. primitive.m_Radius - primitive.m_Thickness/2, 0,
  317. m_selectedColor );
  318. }
  319. }
  320. else
  321. {
  322. if( !m_drawPadOutlineMode )
  323. GRFilledCircle( NULL, &dc, dummySegment.GetCenter(),
  324. primitive.m_Radius, m_selectedColor );
  325. else
  326. GRCircle( NULL, &dc, dummySegment.GetCenter(),
  327. primitive.m_Radius, 0, m_selectedColor );
  328. }
  329. break;
  330. case S_POLYGON: // polygon
  331. {
  332. std::vector<wxPoint> poly = dummySegment.BuildPolyPointsList();
  333. GRClosedPoly( NULL, &dc, poly.size(), &poly[0],
  334. m_drawPadOutlineMode ? false : true,
  335. primitive.m_Thickness, m_selectedColor, m_selectedColor );
  336. }
  337. break;
  338. default:
  339. break;
  340. }
  341. select = m_listCtrlPrimitives->GetNextSelected( select );
  342. }
  343. // Draw X and Y axis. This is particularly useful to show the
  344. // reference position of pads with offset and no hole, or custom pad shapes
  345. const int linethickness = 0;
  346. GRLine( NULL, &dc, -int( dc_size.x/scale ), 0, int( dc_size.x/scale ), 0,
  347. linethickness, LIGHTBLUE ); // X axis
  348. GRLine( NULL, &dc, 0, -int( dc_size.y/scale ), 0, int( dc_size.y/scale ),
  349. linethickness, LIGHTBLUE ); // Y axis
  350. event.Skip();
  351. }
  352. void DIALOG_PAD_PROPERTIES::updateRoundRectCornerValues()
  353. {
  354. // Note:
  355. // To avoid generating a wxEVT_TEXT event from m_tcCornerSizeRatio
  356. // we use ChangeValue instead of SetValue, to set the displayed string
  357. if( m_dummyPad->GetShape() == PAD_SHAPE_ROUNDRECT )
  358. {
  359. m_tcCornerSizeRatio->ChangeValue( wxString::Format( "%.1f",
  360. m_dummyPad->GetRoundRectRadiusRatio()*100 ) );
  361. m_staticTextCornerRadiusValue->SetLabel( StringFromValue( g_UserUnit,
  362. m_dummyPad->GetRoundRectCornerRadius() ) );
  363. }
  364. else if( m_dummyPad->GetShape() == PAD_SHAPE_RECT )
  365. {
  366. m_tcCornerSizeRatio->ChangeValue( "0" );
  367. m_staticTextCornerRadiusValue->SetLabel( "0" );
  368. }
  369. else
  370. {
  371. m_tcCornerSizeRatio->ChangeValue( wxEmptyString );
  372. m_staticTextCornerRadiusValue->SetLabel( wxEmptyString );
  373. }
  374. }
  375. void DIALOG_PAD_PROPERTIES::onCornerSizePercentChange( wxCommandEvent& event )
  376. {
  377. if( m_dummyPad->GetShape() != PAD_SHAPE_ROUNDRECT )
  378. return;
  379. wxString value = m_tcCornerSizeRatio->GetValue();
  380. double rrRadiusRatioPercent;
  381. if( value.ToDouble( &rrRadiusRatioPercent ) )
  382. {
  383. // Clamp rrRadiusRatioPercent to acceptable value (0.0 to 50.0)
  384. if( rrRadiusRatioPercent < 0.0 )
  385. {
  386. rrRadiusRatioPercent = 0.0;
  387. m_tcCornerSizeRatio->ChangeValue( "0.0" );
  388. }
  389. if( rrRadiusRatioPercent > 50.0 )
  390. {
  391. rrRadiusRatioPercent = 0.5;
  392. m_tcCornerSizeRatio->ChangeValue( "50.0" );
  393. }
  394. transferDataToPad( m_dummyPad );
  395. m_staticTextCornerRadiusValue->SetLabel( StringFromValue( g_UserUnit,
  396. m_dummyPad->GetRoundRectCornerRadius() ) );
  397. redraw();
  398. }
  399. }
  400. void DIALOG_PAD_PROPERTIES::initValues()
  401. {
  402. wxString msg;
  403. double angle;
  404. // Disable pad net name wxTextCtrl if the caller is the footprint editor
  405. // because nets are living only in the board managed by the board editor
  406. m_canEditNetName = m_parent->IsType( FRAME_PCB );
  407. // Setup layers names from board
  408. // Should be made first, before calling m_rbCopperLayersSel->SetSelection()
  409. m_rbCopperLayersSel->SetString( 0, m_board->GetLayerName( F_Cu ) );
  410. m_rbCopperLayersSel->SetString( 1, m_board->GetLayerName( B_Cu ) );
  411. m_PadLayerAdhCmp->SetLabel( m_board->GetLayerName( F_Adhes ) );
  412. m_PadLayerAdhCu->SetLabel( m_board->GetLayerName( B_Adhes ) );
  413. m_PadLayerPateCmp->SetLabel( m_board->GetLayerName( F_Paste ) );
  414. m_PadLayerPateCu->SetLabel( m_board->GetLayerName( B_Paste ) );
  415. m_PadLayerSilkCmp->SetLabel( m_board->GetLayerName( F_SilkS ) );
  416. m_PadLayerSilkCu->SetLabel( m_board->GetLayerName( B_SilkS ) );
  417. m_PadLayerMaskCmp->SetLabel( m_board->GetLayerName( F_Mask ) );
  418. m_PadLayerMaskCu->SetLabel( m_board->GetLayerName( B_Mask ) );
  419. m_PadLayerECO1->SetLabel( m_board->GetLayerName( Eco1_User ) );
  420. m_PadLayerECO2->SetLabel( m_board->GetLayerName( Eco2_User ) );
  421. m_PadLayerDraft->SetLabel( m_board->GetLayerName( Dwgs_User ) );
  422. m_isFlipped = false;
  423. if( m_currentPad )
  424. {
  425. m_isFlipped = m_currentPad->IsFlipped();
  426. if( m_isFlipped )
  427. m_staticModuleSideValue->SetLabel( _( "Back side (footprint is mirrored)" ) );
  428. else
  429. m_staticModuleSideValue->SetLabel( _( "Front side" ) );
  430. // Diplay footprint rotation ( angles are in 0.1 degree )
  431. MODULE* footprint = m_currentPad->GetParent();
  432. if( footprint )
  433. msg.Printf( "%.1f", footprint->GetOrientationDegrees() );
  434. else
  435. msg = _("No footprint" );
  436. m_staticModuleRotValue->SetLabel( msg );
  437. }
  438. if( m_isFlipped )
  439. {
  440. wxPoint pt = m_dummyPad->GetOffset();
  441. pt.y = -pt.y;
  442. m_dummyPad->SetOffset( pt );
  443. wxSize sz = m_dummyPad->GetDelta();
  444. sz.y = -sz.y;
  445. m_dummyPad->SetDelta( sz );
  446. // flip pad's layers
  447. m_dummyPad->SetLayerSet( FlipLayerMask( m_dummyPad->GetLayerSet() ) );
  448. // flip custom pad shapes
  449. m_dummyPad->FlipPrimitives();
  450. }
  451. m_primitives = m_dummyPad->GetPrimitives();
  452. m_FlippedWarningSizer->Show( m_isFlipped );
  453. m_PadNumCtrl->SetValue( m_dummyPad->GetName() );
  454. m_PadNetNameCtrl->SetValue( m_dummyPad->GetNetname() );
  455. // Set the unit name in dialog:
  456. wxStaticText* unitTexts[] =
  457. {
  458. m_PadPosX_Unit, m_PadPosY_Unit,
  459. m_PadDrill_X_Unit, m_PadDrill_Y_Unit,
  460. m_PadShapeSizeX_Unit, m_PadShapeSizeY_Unit,
  461. m_PadShapeOffsetX_Unit,m_PadShapeOffsetY_Unit,
  462. m_PadShapeDelta_Unit, m_PadLengthDie_Unit,
  463. m_NetClearanceUnits, m_SolderMaskMarginUnits, m_SolderPasteMarginUnits,
  464. m_ThermalWidthUnits, m_ThermalGapUnits, m_staticTextCornerSizeUnit
  465. };
  466. for( unsigned ii = 0; ii < DIM( unitTexts ); ++ii )
  467. unitTexts[ii]->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
  468. // Display current pad parameters units:
  469. PutValueInLocalUnits( *m_PadPosition_X_Ctrl, m_dummyPad->GetPosition().x );
  470. PutValueInLocalUnits( *m_PadPosition_Y_Ctrl, m_dummyPad->GetPosition().y );
  471. PutValueInLocalUnits( *m_PadDrill_X_Ctrl, m_dummyPad->GetDrillSize().x );
  472. PutValueInLocalUnits( *m_PadDrill_Y_Ctrl, m_dummyPad->GetDrillSize().y );
  473. PutValueInLocalUnits( *m_ShapeSize_X_Ctrl, m_dummyPad->GetSize().x );
  474. PutValueInLocalUnits( *m_ShapeSize_Y_Ctrl, m_dummyPad->GetSize().y );
  475. PutValueInLocalUnits( *m_ShapeOffset_X_Ctrl, m_dummyPad->GetOffset().x );
  476. PutValueInLocalUnits( *m_ShapeOffset_Y_Ctrl, m_dummyPad->GetOffset().y );
  477. if( m_dummyPad->GetDelta().x )
  478. {
  479. PutValueInLocalUnits( *m_ShapeDelta_Ctrl, m_dummyPad->GetDelta().x );
  480. m_trapDeltaDirChoice->SetSelection( 0 );
  481. }
  482. else
  483. {
  484. PutValueInLocalUnits( *m_ShapeDelta_Ctrl, m_dummyPad->GetDelta().y );
  485. m_trapDeltaDirChoice->SetSelection( 1 );
  486. }
  487. PutValueInLocalUnits( *m_LengthPadToDieCtrl, m_dummyPad->GetPadToDieLength() );
  488. PutValueInLocalUnits( *m_NetClearanceValueCtrl, m_dummyPad->GetLocalClearance() );
  489. PutValueInLocalUnits( *m_SolderMaskMarginCtrl, m_dummyPad->GetLocalSolderMaskMargin() );
  490. PutValueInLocalUnits( *m_ThermalWidthCtrl, m_dummyPad->GetThermalWidth() );
  491. PutValueInLocalUnits( *m_ThermalGapCtrl, m_dummyPad->GetThermalGap() );
  492. // These 2 parameters are usually < 0, so prepare entering a negative value, if current is 0
  493. PutValueInLocalUnits( *m_SolderPasteMarginCtrl, m_dummyPad->GetLocalSolderPasteMargin() );
  494. if( m_dummyPad->GetLocalSolderPasteMargin() == 0 )
  495. m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) + m_SolderPasteMarginCtrl->GetValue() );
  496. msg.Printf( wxT( "%f" ), m_dummyPad->GetLocalSolderPasteMarginRatio() * 100.0 );
  497. if( m_dummyPad->GetLocalSolderPasteMarginRatio() == 0.0 && msg[0] == '0' )
  498. // Sometimes Printf adds a sign if the value is small
  499. m_SolderPasteMarginRatioCtrl->SetValue( wxT( "-" ) + msg );
  500. else
  501. m_SolderPasteMarginRatioCtrl->SetValue( msg );
  502. switch( m_dummyPad->GetZoneConnection() )
  503. {
  504. default:
  505. case PAD_ZONE_CONN_INHERITED:
  506. m_ZoneConnectionChoice->SetSelection( 0 );
  507. m_ZoneConnectionCustom->SetSelection( 0 );
  508. break;
  509. case PAD_ZONE_CONN_FULL:
  510. m_ZoneConnectionChoice->SetSelection( 1 );
  511. m_ZoneConnectionCustom->SetSelection( 1 );
  512. break;
  513. case PAD_ZONE_CONN_THERMAL:
  514. m_ZoneConnectionChoice->SetSelection( 2 );
  515. m_ZoneConnectionCustom->SetSelection( 0 );
  516. break;
  517. case PAD_ZONE_CONN_NONE:
  518. m_ZoneConnectionChoice->SetSelection( 3 );
  519. m_ZoneConnectionCustom->SetSelection( 0 );
  520. break;
  521. }
  522. if( m_dummyPad->GetCustomShapeInZoneOpt() == CUST_PAD_SHAPE_IN_ZONE_CONVEXHULL )
  523. m_ZoneCustomPadShape->SetSelection( 1 );
  524. else
  525. m_ZoneCustomPadShape->SetSelection( 0 );
  526. if( m_currentPad )
  527. {
  528. angle = m_currentPad->GetOrientation();
  529. MODULE* footprint = m_currentPad->GetParent();
  530. if( footprint )
  531. angle -= footprint->GetOrientation();
  532. if( m_isFlipped )
  533. angle = -angle;
  534. m_dummyPad->SetOrientation( angle );
  535. }
  536. angle = m_dummyPad->GetOrientation();
  537. NORMALIZE_ANGLE_180( angle ); // ? normalizing is in D_PAD::SetOrientation()
  538. // Set layers used by this pad: :
  539. setPadLayersList( m_dummyPad->GetLayerSet() );
  540. // Pad Orient
  541. switch( int( angle ) )
  542. {
  543. case 0:
  544. m_PadOrient->SetSelection( 0 );
  545. break;
  546. case 900:
  547. m_PadOrient->SetSelection( 1 );
  548. break;
  549. case -900:
  550. m_PadOrient->SetSelection( 2 );
  551. break;
  552. case 1800:
  553. case -1800:
  554. m_PadOrient->SetSelection( 3 );
  555. break;
  556. default:
  557. m_PadOrient->SetSelection( 4 );
  558. break;
  559. }
  560. switch( m_dummyPad->GetShape() )
  561. {
  562. default:
  563. case PAD_SHAPE_CIRCLE:
  564. m_PadShape->SetSelection( CHOICE_SHAPE_CIRCLE );
  565. break;
  566. case PAD_SHAPE_OVAL:
  567. m_PadShape->SetSelection( CHOICE_SHAPE_OVAL );
  568. break;
  569. case PAD_SHAPE_RECT:
  570. m_PadShape->SetSelection( CHOICE_SHAPE_RECT );
  571. break;
  572. case PAD_SHAPE_TRAPEZOID:
  573. m_PadShape->SetSelection( CHOICE_SHAPE_TRAPEZOID );
  574. break;
  575. case PAD_SHAPE_ROUNDRECT:
  576. m_PadShape->SetSelection( CHOICE_SHAPE_ROUNDRECT );
  577. break;
  578. case PAD_SHAPE_CUSTOM:
  579. if( m_dummyPad->GetAnchorPadShape() == PAD_SHAPE_RECT )
  580. m_PadShape->SetSelection( CHOICE_SHAPE_CUSTOM_RECT_ANCHOR );
  581. else
  582. m_PadShape->SetSelection( CHOICE_SHAPE_CUSTOM_CIRC_ANCHOR );
  583. break;
  584. }
  585. enablePrimitivePage( PAD_SHAPE_CUSTOM == m_dummyPad->GetShape() );
  586. m_OrientValue = angle / 10.0;
  587. // Type of pad selection
  588. m_PadType->SetSelection( 0 );
  589. for( unsigned ii = 0; ii < DIM( code_type ); ii++ )
  590. {
  591. if( code_type[ii] == m_dummyPad->GetAttribute() )
  592. {
  593. m_PadType->SetSelection( ii );
  594. break;
  595. }
  596. }
  597. // Enable/disable Pad name,and pad length die
  598. // (disable for NPTH pads (mechanical pads)
  599. bool enable = m_dummyPad->GetAttribute() != PAD_ATTRIB_HOLE_NOT_PLATED;
  600. m_PadNumCtrl->Enable( enable );
  601. m_PadNetNameCtrl->Enable( m_canEditNetName && enable && m_currentPad != NULL );
  602. m_LengthPadToDieCtrl->Enable( enable );
  603. if( m_dummyPad->GetDrillShape() != PAD_DRILL_SHAPE_OBLONG )
  604. m_DrillShapeCtrl->SetSelection( 0 );
  605. else
  606. m_DrillShapeCtrl->SetSelection( 1 );
  607. // Update some dialog widgets state (Enable/disable options):
  608. wxCommandEvent cmd_event;
  609. setPadLayersList( m_dummyPad->GetLayerSet() );
  610. OnDrillShapeSelected( cmd_event );
  611. OnPadShapeSelection( cmd_event );
  612. updateRoundRectCornerValues();
  613. // Update basic shapes list
  614. displayPrimitivesList();
  615. }
  616. // A small helper function, to display coordinates:
  617. static wxString formatCoord( wxPoint aCoord )
  618. {
  619. return wxString::Format( "(X:%s Y:%s)",
  620. CoordinateToString( aCoord.x, true ),
  621. CoordinateToString( aCoord.y, true ) );
  622. }
  623. void DIALOG_PAD_PROPERTIES::displayPrimitivesList()
  624. {
  625. m_listCtrlPrimitives->ClearAll();
  626. wxListItem itemCol;
  627. itemCol.SetImage(-1);
  628. for( int ii = 0; ii < 5; ++ii )
  629. m_listCtrlPrimitives->InsertColumn(ii, itemCol);
  630. wxString bs_info[5];
  631. for( unsigned ii = 0; ii < m_primitives.size(); ++ii )
  632. {
  633. const PAD_CS_PRIMITIVE& primitive = m_primitives[ii];
  634. for( unsigned jj = 0; jj < 5; ++jj )
  635. bs_info[jj].Empty();
  636. bs_info[4] = wxString::Format( _( "width %s" ),
  637. CoordinateToString( primitive.m_Thickness, true ) );
  638. switch( primitive.m_Shape )
  639. {
  640. case S_SEGMENT: // usual segment : line with rounded ends
  641. bs_info[0] = _( "Segment" );
  642. bs_info[1] = _( "from " ) + formatCoord( primitive.m_Start );
  643. bs_info[2] = _( "to " ) + formatCoord( primitive.m_End );
  644. break;
  645. case S_ARC: // Arc with rounded ends
  646. bs_info[0] = _( "Arc" );
  647. bs_info[1] = _( "center " ) + formatCoord( primitive.m_Start ); // Center
  648. bs_info[2] = _( "start " ) + formatCoord( primitive.m_End ); // Start point
  649. bs_info[3] = wxString::Format( _( "angle %s" ), FMT_ANGLE( primitive.m_ArcAngle ) );
  650. break;
  651. case S_CIRCLE: // ring or circle
  652. if( primitive.m_Thickness )
  653. bs_info[0] = _( "ring" );
  654. else
  655. bs_info[0] = _( "circle" );
  656. bs_info[1] = formatCoord( primitive.m_Start );
  657. bs_info[2] = wxString::Format( _( "radius %s" ),
  658. CoordinateToString( primitive.m_Radius, true ) );
  659. break;
  660. case S_POLYGON: // polygon
  661. bs_info[0] = "Polygon";
  662. bs_info[1] = wxString::Format( _( "corners count %d" ), (int) primitive.m_Poly.size() );
  663. break;
  664. default:
  665. bs_info[0] = "Unknown primitive";
  666. break;
  667. }
  668. long tmp = m_listCtrlPrimitives->InsertItem(ii, bs_info[0]);
  669. m_listCtrlPrimitives->SetItemData(tmp, ii);
  670. for( int jj = 0, col = 0; jj < 5; ++jj )
  671. {
  672. m_listCtrlPrimitives->SetItem(tmp, col++, bs_info[jj]);
  673. }
  674. }
  675. // Now columns are filled, ensure correct width of columns
  676. for( unsigned ii = 0; ii < 5; ++ii )
  677. m_listCtrlPrimitives->SetColumnWidth( ii, wxLIST_AUTOSIZE );
  678. }
  679. void DIALOG_PAD_PROPERTIES::OnResize( wxSizeEvent& event )
  680. {
  681. redraw();
  682. event.Skip();
  683. }
  684. void DIALOG_PAD_PROPERTIES::onChangePadMode( wxCommandEvent& event )
  685. {
  686. m_drawPadOutlineMode = m_cbShowPadOutline->GetValue();
  687. if( m_parent->IsGalCanvasActive() )
  688. {
  689. KIGFX::VIEW* view = m_panelShowPadGal->GetView();
  690. // fix the pad render mode (filled/not filled)
  691. KIGFX::PCB_RENDER_SETTINGS* settings =
  692. static_cast<KIGFX::PCB_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
  693. settings->SetSketchMode( LAYER_PADS_TH, m_drawPadOutlineMode );
  694. settings->SetSketchMode( LAYER_PAD_FR, m_drawPadOutlineMode );
  695. settings->SetSketchMode( LAYER_PAD_BK, m_drawPadOutlineMode );
  696. settings->SetSketchModeGraphicItems( m_drawPadOutlineMode );
  697. }
  698. redraw();
  699. }
  700. void DIALOG_PAD_PROPERTIES::OnPadShapeSelection( wxCommandEvent& event )
  701. {
  702. bool is_custom = false;
  703. switch( m_PadShape->GetSelection() )
  704. {
  705. case CHOICE_SHAPE_CIRCLE:
  706. m_ShapeDelta_Ctrl->Enable( false );
  707. m_trapDeltaDirChoice->Enable( false );
  708. m_ShapeSize_Y_Ctrl->Enable( false );
  709. m_ShapeOffset_X_Ctrl->Enable( false );
  710. m_ShapeOffset_Y_Ctrl->Enable( false );
  711. break;
  712. case CHOICE_SHAPE_OVAL:
  713. m_ShapeDelta_Ctrl->Enable( false );
  714. m_trapDeltaDirChoice->Enable( false );
  715. m_ShapeSize_Y_Ctrl->Enable( true );
  716. m_ShapeOffset_X_Ctrl->Enable( true );
  717. m_ShapeOffset_Y_Ctrl->Enable( true );
  718. break;
  719. case CHOICE_SHAPE_RECT:
  720. m_ShapeDelta_Ctrl->Enable( false );
  721. m_trapDeltaDirChoice->Enable( false );
  722. m_ShapeSize_Y_Ctrl->Enable( true );
  723. m_ShapeOffset_X_Ctrl->Enable( true );
  724. m_ShapeOffset_Y_Ctrl->Enable( true );
  725. break;
  726. case CHOICE_SHAPE_TRAPEZOID:
  727. m_ShapeDelta_Ctrl->Enable( true );
  728. m_trapDeltaDirChoice->Enable( true );
  729. m_ShapeSize_Y_Ctrl->Enable( true );
  730. m_ShapeOffset_X_Ctrl->Enable( true );
  731. m_ShapeOffset_Y_Ctrl->Enable( true );
  732. break;
  733. case CHOICE_SHAPE_ROUNDRECT:
  734. m_ShapeDelta_Ctrl->Enable( false );
  735. m_trapDeltaDirChoice->Enable( false );
  736. m_ShapeSize_Y_Ctrl->Enable( true );
  737. m_ShapeOffset_X_Ctrl->Enable( true );
  738. m_ShapeOffset_Y_Ctrl->Enable( true );
  739. // Ensure m_tcCornerSizeRatio contains the right value:
  740. m_tcCornerSizeRatio->ChangeValue( wxString::Format( "%.1f",
  741. m_dummyPad->GetRoundRectRadiusRatio()*100 ) );
  742. break;
  743. case CHOICE_SHAPE_CUSTOM_CIRC_ANCHOR: // PAD_SHAPE_CUSTOM, circular anchor
  744. case CHOICE_SHAPE_CUSTOM_RECT_ANCHOR: // PAD_SHAPE_CUSTOM, rect anchor
  745. is_custom = true;
  746. m_ShapeDelta_Ctrl->Enable( false );
  747. m_trapDeltaDirChoice->Enable( false );
  748. m_ShapeSize_Y_Ctrl->Enable(
  749. m_PadShape->GetSelection() == CHOICE_SHAPE_CUSTOM_RECT_ANCHOR );
  750. m_ShapeOffset_X_Ctrl->Enable( false );
  751. m_ShapeOffset_Y_Ctrl->Enable( false );
  752. break;
  753. }
  754. enablePrimitivePage( is_custom );
  755. // A few widgets are enabled only for rounded rect pads:
  756. m_tcCornerSizeRatio->Enable( m_PadShape->GetSelection() == CHOICE_SHAPE_ROUNDRECT );
  757. // PAD_SHAPE_CUSTOM type has constraints for zone connection and thermal shape:
  758. // only not connected or solid connection is allowed to avoid destroying the shape.
  759. // Enable/disable options only available for custom shaped pads
  760. m_ZoneConnectionChoice->Enable( !is_custom );
  761. m_ZoneConnectionCustom->Enable( is_custom );
  762. m_ThermalWidthCtrl->Enable( !is_custom );
  763. m_ThermalGapCtrl->Enable( !is_custom );
  764. m_sbSizerZonesSettings->Show( !is_custom );
  765. m_sbSizerCustomShapedZonesSettings->Show( is_custom );
  766. transferDataToPad( m_dummyPad );
  767. updateRoundRectCornerValues();
  768. redraw();
  769. }
  770. void DIALOG_PAD_PROPERTIES::OnDrillShapeSelected( wxCommandEvent& event )
  771. {
  772. if( m_PadType->GetSelection() == 1 || m_PadType->GetSelection() == 2 )
  773. {
  774. // pad type = SMD or CONN: no hole allowed
  775. m_PadDrill_X_Ctrl->Enable( false );
  776. m_PadDrill_Y_Ctrl->Enable( false );
  777. }
  778. else
  779. {
  780. switch( m_DrillShapeCtrl->GetSelection() )
  781. {
  782. case 0: //CIRCLE:
  783. m_PadDrill_X_Ctrl->Enable( true );
  784. m_PadDrill_Y_Ctrl->Enable( false );
  785. break;
  786. case 1: //OVALE:
  787. m_PadDrill_X_Ctrl->Enable( true );
  788. m_PadDrill_Y_Ctrl->Enable( true );
  789. break;
  790. }
  791. }
  792. transferDataToPad( m_dummyPad );
  793. redraw();
  794. }
  795. void DIALOG_PAD_PROPERTIES::PadOrientEvent( wxCommandEvent& event )
  796. {
  797. switch( m_PadOrient->GetSelection() )
  798. {
  799. case 0:
  800. m_dummyPad->SetOrientation( 0 );
  801. break;
  802. case 1:
  803. m_dummyPad->SetOrientation( 900 );
  804. break;
  805. case 2:
  806. m_dummyPad->SetOrientation( -900 );
  807. break;
  808. case 3:
  809. m_dummyPad->SetOrientation( 1800 );
  810. break;
  811. default:
  812. break;
  813. }
  814. m_OrientValue = m_dummyPad->GetOrientation() / 10.0;
  815. m_OrientValidator.TransferToWindow();
  816. transferDataToPad( m_dummyPad );
  817. redraw();
  818. }
  819. void DIALOG_PAD_PROPERTIES::PadTypeSelected( wxCommandEvent& event )
  820. {
  821. unsigned ii = m_PadType->GetSelection();
  822. if( ii >= DIM( code_type ) ) // catches < 0 also
  823. ii = 0;
  824. LSET layer_mask = std_pad_layers[ii];
  825. setPadLayersList( layer_mask );
  826. // Enable/disable drill dialog items:
  827. event.SetId( m_DrillShapeCtrl->GetSelection() );
  828. OnDrillShapeSelected( event );
  829. if( ii == 0 || ii == DIM( code_type )-1 )
  830. m_DrillShapeCtrl->Enable( true );
  831. else
  832. m_DrillShapeCtrl->Enable( false );
  833. // Enable/disable Pad name,and pad length die
  834. // (disable for NPTH pads (mechanical pads)
  835. bool enable = ii != 3;
  836. m_PadNumCtrl->Enable( enable );
  837. m_PadNetNameCtrl->Enable( m_canEditNetName && enable && m_currentPad != NULL );
  838. m_LengthPadToDieCtrl->Enable( enable );
  839. }
  840. void DIALOG_PAD_PROPERTIES::setPadLayersList( LSET layer_mask )
  841. {
  842. LSET cu_set = layer_mask & LSET::AllCuMask();
  843. if( cu_set == LSET( F_Cu ) )
  844. m_rbCopperLayersSel->SetSelection( 0 );
  845. else if( cu_set == LSET( B_Cu ) )
  846. m_rbCopperLayersSel->SetSelection( 1 );
  847. else if( cu_set.any() )
  848. m_rbCopperLayersSel->SetSelection( 2 );
  849. else
  850. m_rbCopperLayersSel->SetSelection( 3 );
  851. m_PadLayerAdhCmp->SetValue( layer_mask[F_Adhes] );
  852. m_PadLayerAdhCu->SetValue( layer_mask[B_Adhes] );
  853. m_PadLayerPateCmp->SetValue( layer_mask[F_Paste] );
  854. m_PadLayerPateCu->SetValue( layer_mask[B_Paste] );
  855. m_PadLayerSilkCmp->SetValue( layer_mask[F_SilkS] );
  856. m_PadLayerSilkCu->SetValue( layer_mask[B_SilkS] );
  857. m_PadLayerMaskCmp->SetValue( layer_mask[F_Mask] );
  858. m_PadLayerMaskCu->SetValue( layer_mask[B_Mask] );
  859. m_PadLayerECO1->SetValue( layer_mask[Eco1_User] );
  860. m_PadLayerECO2->SetValue( layer_mask[Eco2_User] );
  861. m_PadLayerDraft->SetValue( layer_mask[Dwgs_User] );
  862. }
  863. // Called when select/deselect a layer.
  864. void DIALOG_PAD_PROPERTIES::OnSetLayers( wxCommandEvent& event )
  865. {
  866. transferDataToPad( m_dummyPad );
  867. redraw();
  868. }
  869. // test if all values are acceptable for the pad
  870. bool DIALOG_PAD_PROPERTIES::padValuesOK()
  871. {
  872. bool error = transferDataToPad( m_dummyPad );
  873. bool skip_tstoffset = false; // the offset prm is not always tested
  874. wxArrayString error_msgs;
  875. wxString msg;
  876. // Test for incorrect values
  877. if( (m_dummyPad->GetSize().x <= 0) ||
  878. ((m_dummyPad->GetSize().y <= 0) && (m_dummyPad->GetShape() != PAD_SHAPE_CIRCLE)) )
  879. {
  880. error_msgs.Add( _( "Pad size must be greater than zero" ) );
  881. }
  882. if( (m_dummyPad->GetSize().x < m_dummyPad->GetDrillSize().x) ||
  883. (m_dummyPad->GetSize().y < m_dummyPad->GetDrillSize().y) )
  884. {
  885. error_msgs.Add( _( "Incorrect value for pad drill: pad drill bigger than pad size" ) );
  886. skip_tstoffset = true; // offset prm will be not tested because if the drill value
  887. // is incorrect the offset prm is always seen as incorrect, even if it is 0
  888. }
  889. if( m_dummyPad->GetLocalClearance() < 0 )
  890. {
  891. error_msgs.Add( _( "Pad local clearance must be zero or greater than zero" ) );
  892. }
  893. // Some pads need a negative solder mask clearance (mainly for BGA with small pads)
  894. // However the negative solder mask clearance must not create negative mask size
  895. // Therefore test for minimal acceptable negative value
  896. // Hovewer, a negative value can give strange result with custom shapes, so it is not
  897. // allowed for custom pad shape
  898. if( m_dummyPad->GetLocalSolderMaskMargin() < 0 )
  899. {
  900. if( m_dummyPad->GetShape() == PAD_SHAPE_CUSTOM )
  901. error_msgs.Add( _( "Pad local solder mask clearance must be zero or greater than zero" ) );
  902. else
  903. {
  904. int min_smClearance = -std::min( m_dummyPad->GetSize().x, m_dummyPad->GetSize().y )/2;
  905. if( m_dummyPad->GetLocalSolderMaskMargin() <= min_smClearance )
  906. {
  907. error_msgs.Add( wxString::Format(
  908. _( "Pad local solder mask clearance must be greater than %s" ),
  909. StringFromValue( g_UserUnit, min_smClearance, true ) ) );
  910. }
  911. }
  912. }
  913. // Some pads need a positive solder paste clearance (mainly for BGA with small pads)
  914. // Hovewer, a positive value can create issues if the resulting shape is too big.
  915. // (like a solder paste creating a solder paste area on a neighbour pad or on the solder mask)
  916. // So we could ask for user to confirm the choice
  917. // Currently there are no test
  918. LSET padlayers_mask = m_dummyPad->GetLayerSet();
  919. if( padlayers_mask == 0 )
  920. error_msgs.Add( _( "Error: pad has no layer" ) );
  921. if( !padlayers_mask[F_Cu] && !padlayers_mask[B_Cu] )
  922. {
  923. if( m_dummyPad->GetDrillSize().x || m_dummyPad->GetDrillSize().y )
  924. {
  925. // Note: he message is shown in an HTML window
  926. msg = _( "Error: the pad is not on a copper layer and has a hole" );
  927. if( m_dummyPad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED )
  928. {
  929. msg += wxT( "<br><br><i>" );
  930. msg += _( "For NPTH pad, set pad size value to pad drill value,"
  931. " if you do not want this pad plotted in gerber files"
  932. );
  933. }
  934. error_msgs.Add( msg );
  935. }
  936. }
  937. if( !skip_tstoffset )
  938. {
  939. wxPoint max_size;
  940. max_size.x = std::abs( m_dummyPad->GetOffset().x );
  941. max_size.y = std::abs( m_dummyPad->GetOffset().y );
  942. max_size.x += m_dummyPad->GetDrillSize().x / 2;
  943. max_size.y += m_dummyPad->GetDrillSize().y / 2;
  944. if( ( m_dummyPad->GetSize().x / 2 < max_size.x ) ||
  945. ( m_dummyPad->GetSize().y / 2 < max_size.y ) )
  946. {
  947. error_msgs.Add( _( "Incorrect value for pad offset" ) );
  948. }
  949. }
  950. if( error )
  951. {
  952. error_msgs.Add( _( "Too large value for pad delta size" ) );
  953. }
  954. switch( m_dummyPad->GetAttribute() )
  955. {
  956. case PAD_ATTRIB_HOLE_NOT_PLATED: // Not plated, but through hole, a hole is expected
  957. case PAD_ATTRIB_STANDARD : // Pad through hole, a hole is also expected
  958. if( m_dummyPad->GetDrillSize().x <= 0 ||
  959. ( m_dummyPad->GetDrillSize().y <= 0 && m_dummyPad->GetDrillShape() == PAD_DRILL_SHAPE_OBLONG ) )
  960. error_msgs.Add( _( "Error: Through hole pad: drill diameter set to 0" ) );
  961. break;
  962. case PAD_ATTRIB_CONN: // Connector pads are smd pads, just they do not have solder paste.
  963. if( padlayers_mask[B_Paste] || padlayers_mask[F_Paste] )
  964. error_msgs.Add( _( "Error: Connector pads are not on the solder paste layer\n"
  965. "Use SMD pads instead" ) );
  966. // Fall trough
  967. case PAD_ATTRIB_SMD: // SMD and Connector pads (One external copper layer only)
  968. {
  969. LSET innerlayers_mask = padlayers_mask & LSET::InternalCuMask();
  970. if( ( padlayers_mask[F_Cu] && padlayers_mask[B_Cu] ) ||
  971. innerlayers_mask.count() != 0 )
  972. error_msgs.Add( _( "Error: only one external copper layer allowed for SMD or Connector pads" ) );
  973. }
  974. break;
  975. }
  976. if( m_dummyPad->GetShape() == PAD_SHAPE_ROUNDRECT )
  977. {
  978. wxString value = m_tcCornerSizeRatio->GetValue();
  979. double rrRadiusRatioPercent;
  980. if( !value.ToDouble( &rrRadiusRatioPercent ) )
  981. error_msgs.Add( _( "Incorrect corner size value" ) );
  982. else
  983. {
  984. if( rrRadiusRatioPercent < 0.0 )
  985. error_msgs.Add( _( "Incorrect (negative) corner size value" ) );
  986. else if( rrRadiusRatioPercent > 50.0 )
  987. error_msgs.Add( _( "Corner size value must be smaller than 50%" ) );
  988. }
  989. }
  990. if( m_dummyPad->GetShape() == PAD_SHAPE_CUSTOM )
  991. {
  992. if( !m_dummyPad->MergePrimitivesAsPolygon( ) )
  993. error_msgs.Add(
  994. _( "Incorrect pad shape: the shape must be equivalent to only one polygon" ) );
  995. }
  996. if( error_msgs.GetCount() )
  997. {
  998. HTML_MESSAGE_BOX dlg( this, _("Pad setup errors list" ) );
  999. dlg.ListSet( error_msgs );
  1000. dlg.ShowModal();
  1001. }
  1002. return error_msgs.GetCount() == 0;
  1003. }
  1004. void DIALOG_PAD_PROPERTIES::redraw()
  1005. {
  1006. if( m_parent->IsGalCanvasActive() )
  1007. {
  1008. KIGFX::VIEW* view = m_panelShowPadGal->GetView();
  1009. m_panelShowPadGal->StopDrawing();
  1010. // The layer used to place primitive items selected when editing custom pad shapes
  1011. // we use here a layer never used in a pad:
  1012. #define SELECTED_ITEMS_LAYER Dwgs_User
  1013. view->SetTopLayer( SELECTED_ITEMS_LAYER );
  1014. KIGFX::PCB_RENDER_SETTINGS* settings =
  1015. static_cast<KIGFX::PCB_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
  1016. settings->SetLayerColor( SELECTED_ITEMS_LAYER, m_selectedColor );
  1017. view->Update( m_dummyPad );
  1018. // delete previous items if highlight list
  1019. while( m_highligth.size() )
  1020. {
  1021. delete m_highligth.back(); // the dtor also removes item from view
  1022. m_highligth.pop_back();
  1023. }
  1024. // highlight selected primitives:
  1025. long select = m_listCtrlPrimitives->GetFirstSelected();
  1026. while( select >= 0 )
  1027. {
  1028. PAD_CS_PRIMITIVE& primitive = m_primitives[select];
  1029. DRAWSEGMENT* dummySegment = new DRAWSEGMENT;
  1030. dummySegment->SetLayer( SELECTED_ITEMS_LAYER );
  1031. primitive.ExportTo( dummySegment );
  1032. dummySegment->Rotate( wxPoint( 0, 0), m_dummyPad->GetOrientation() );
  1033. dummySegment->Move( m_dummyPad->GetPosition() );
  1034. // Update selected primitive (highligth selected)
  1035. switch( primitive.m_Shape )
  1036. {
  1037. case S_SEGMENT:
  1038. case S_ARC:
  1039. break;
  1040. case S_CIRCLE: // ring or circle
  1041. if( primitive.m_Thickness == 0 ) // filled circle
  1042. { // the filled circle option does not exist in a DRAWSEGMENT
  1043. // but it is easy to create it with a circle having the
  1044. // right radius and outline width
  1045. wxPoint end = dummySegment->GetCenter();
  1046. end.x += primitive.m_Radius/2;
  1047. dummySegment->SetEnd( end );
  1048. dummySegment->SetWidth( primitive.m_Radius );
  1049. }
  1050. break;
  1051. case S_POLYGON:
  1052. break;
  1053. default:
  1054. delete dummySegment;
  1055. dummySegment = nullptr;
  1056. break;
  1057. }
  1058. if( dummySegment )
  1059. {
  1060. view->Add( dummySegment );
  1061. m_highligth.push_back( dummySegment );
  1062. }
  1063. select = m_listCtrlPrimitives->GetNextSelected( select );
  1064. }
  1065. BOX2I bbox = m_dummyPad->ViewBBox();
  1066. if( bbox.GetSize().x > 0 && bbox.GetSize().y > 0 )
  1067. {
  1068. // gives a size to the full drawable area
  1069. BOX2I drawbox;
  1070. drawbox.Move( m_dummyPad->GetPosition() );
  1071. drawbox.Inflate( bbox.GetSize().x*2, bbox.GetSize().y*2 );
  1072. view->SetBoundary( drawbox );
  1073. // Autozoom
  1074. view->SetViewport( BOX2D( bbox.GetOrigin(), bbox.GetSize() ) );
  1075. // Add a margin
  1076. view->SetScale( m_panelShowPadGal->GetView()->GetScale() * 0.7 );
  1077. m_panelShowPadGal->StartDrawing();
  1078. m_panelShowPadGal->Refresh();
  1079. }
  1080. }
  1081. else
  1082. {
  1083. m_panelShowPad->Refresh();
  1084. }
  1085. }
  1086. bool DIALOG_PAD_PROPERTIES::TransferDataToWindow()
  1087. {
  1088. if( !wxDialog::TransferDataToWindow() )
  1089. return false;
  1090. if( !m_panelGeneral->TransferDataToWindow() )
  1091. return false;
  1092. if( !m_localSettingsPanel->TransferDataToWindow() )
  1093. return false;
  1094. return true;
  1095. }
  1096. bool DIALOG_PAD_PROPERTIES::TransferDataFromWindow()
  1097. {
  1098. BOARD_COMMIT commit( m_parent );
  1099. if( !wxDialog::TransferDataFromWindow() )
  1100. return false;
  1101. if( !m_panelGeneral->TransferDataFromWindow() )
  1102. return false;
  1103. if( !m_localSettingsPanel->TransferDataFromWindow() )
  1104. return false;
  1105. if( !padValuesOK() )
  1106. return false;
  1107. bool rastnestIsChanged = false;
  1108. int isign = m_isFlipped ? -1 : 1;
  1109. transferDataToPad( m_padMaster );
  1110. // m_padMaster is a pattern: ensure there is no net for this pad:
  1111. m_padMaster->SetNetCode( NETINFO_LIST::UNCONNECTED );
  1112. if( !m_currentPad ) // Set current Pad parameters
  1113. return true;
  1114. commit.Modify( m_currentPad );
  1115. // redraw the area where the pad was, without pad (delete pad on screen)
  1116. m_currentPad->SetFlags( DO_NOT_DRAW );
  1117. m_parent->GetCanvas()->RefreshDrawingRect( m_currentPad->GetBoundingBox() );
  1118. m_currentPad->ClearFlags( DO_NOT_DRAW );
  1119. // Update values
  1120. m_currentPad->SetShape( m_padMaster->GetShape() );
  1121. m_currentPad->SetAttribute( m_padMaster->GetAttribute() );
  1122. if( m_currentPad->GetPosition() != m_padMaster->GetPosition() )
  1123. {
  1124. m_currentPad->SetPosition( m_padMaster->GetPosition() );
  1125. rastnestIsChanged = true;
  1126. }
  1127. wxSize size;
  1128. MODULE* footprint = m_currentPad->GetParent();
  1129. if( footprint )
  1130. {
  1131. footprint->SetLastEditTime();
  1132. // compute the pos 0 value, i.e. pad position for footprint with orientation = 0
  1133. // i.e. relative to footprint origin (footprint position)
  1134. wxPoint pt = m_currentPad->GetPosition() - footprint->GetPosition();
  1135. RotatePoint( &pt, -footprint->GetOrientation() );
  1136. m_currentPad->SetPos0( pt );
  1137. m_currentPad->SetOrientation( m_padMaster->GetOrientation() * isign
  1138. + footprint->GetOrientation() );
  1139. }
  1140. m_currentPad->SetSize( m_padMaster->GetSize() );
  1141. size = m_padMaster->GetDelta();
  1142. size.y *= isign;
  1143. m_currentPad->SetDelta( size );
  1144. m_currentPad->SetDrillSize( m_padMaster->GetDrillSize() );
  1145. m_currentPad->SetDrillShape( m_padMaster->GetDrillShape() );
  1146. wxPoint offset = m_padMaster->GetOffset();
  1147. offset.y *= isign;
  1148. m_currentPad->SetOffset( offset );
  1149. m_currentPad->SetPadToDieLength( m_padMaster->GetPadToDieLength() );
  1150. if( m_padMaster->GetShape() != PAD_SHAPE_CUSTOM )
  1151. m_padMaster->DeletePrimitivesList();
  1152. m_currentPad->SetAnchorPadShape( m_padMaster->GetAnchorPadShape() );
  1153. m_currentPad->SetPrimitives( m_padMaster->GetPrimitives() );
  1154. if( m_isFlipped )
  1155. {
  1156. m_currentPad->SetLayerSet( FlipLayerMask( m_currentPad->GetLayerSet() ) );
  1157. m_currentPad->FlipPrimitives();
  1158. }
  1159. if( m_currentPad->GetLayerSet() != m_padMaster->GetLayerSet() )
  1160. {
  1161. rastnestIsChanged = true;
  1162. m_currentPad->SetLayerSet( m_padMaster->GetLayerSet() );
  1163. }
  1164. if( m_isFlipped )
  1165. {
  1166. m_currentPad->SetLayerSet( FlipLayerMask( m_currentPad->GetLayerSet() ) );
  1167. }
  1168. m_currentPad->SetName( m_padMaster->GetName() );
  1169. wxString padNetname;
  1170. // For PAD_ATTRIB_HOLE_NOT_PLATED, ensure there is no net name selected
  1171. if( m_padMaster->GetAttribute() != PAD_ATTRIB_HOLE_NOT_PLATED )
  1172. padNetname = m_PadNetNameCtrl->GetValue();
  1173. if( m_currentPad->GetNetname() != padNetname )
  1174. {
  1175. const NETINFO_ITEM* netinfo = m_board->FindNet( padNetname );
  1176. if( !padNetname.IsEmpty() && netinfo == NULL )
  1177. {
  1178. DisplayError( NULL, _( "Unknown netname, netname not changed" ) );
  1179. }
  1180. else if( netinfo )
  1181. {
  1182. rastnestIsChanged = true;
  1183. m_currentPad->SetNetCode( netinfo->GetNet() );
  1184. }
  1185. }
  1186. m_currentPad->SetLocalClearance( m_padMaster->GetLocalClearance() );
  1187. m_currentPad->SetLocalSolderMaskMargin( m_padMaster->GetLocalSolderMaskMargin() );
  1188. m_currentPad->SetLocalSolderPasteMargin( m_padMaster->GetLocalSolderPasteMargin() );
  1189. m_currentPad->SetLocalSolderPasteMarginRatio( m_padMaster->GetLocalSolderPasteMarginRatio() );
  1190. m_currentPad->SetThermalWidth( m_padMaster->GetThermalWidth() );
  1191. m_currentPad->SetThermalGap( m_padMaster->GetThermalGap() );
  1192. m_currentPad->SetRoundRectRadiusRatio( m_padMaster->GetRoundRectRadiusRatio() );
  1193. if( m_currentPad->GetShape() == PAD_SHAPE_CUSTOM )
  1194. {
  1195. if( m_padMaster->GetZoneConnection() == PAD_ZONE_CONN_FULL )
  1196. m_currentPad->SetZoneConnection( PAD_ZONE_CONN_FULL );
  1197. else
  1198. m_currentPad->SetZoneConnection( PAD_ZONE_CONN_NONE );
  1199. }
  1200. else
  1201. m_currentPad->SetZoneConnection( m_padMaster->GetZoneConnection() );
  1202. // rounded rect pads with radius ratio = 0 are in fact rect pads.
  1203. // So set the right shape (and perhaps issues with a radius = 0)
  1204. if( m_currentPad->GetShape() == PAD_SHAPE_ROUNDRECT &&
  1205. m_currentPad->GetRoundRectRadiusRatio() == 0.0 )
  1206. {
  1207. m_currentPad->SetShape( PAD_SHAPE_RECT );
  1208. }
  1209. // define the way the clearance area is defined in zones
  1210. m_currentPad->SetCustomShapeInZoneOpt( m_padMaster->GetCustomShapeInZoneOpt() );
  1211. if( footprint )
  1212. footprint->CalculateBoundingBox();
  1213. m_parent->SetMsgPanel( m_currentPad );
  1214. // redraw the area where the pad was
  1215. m_parent->GetCanvas()->RefreshDrawingRect( m_currentPad->GetBoundingBox() );
  1216. commit.Push( _( "Modify pad" ) );
  1217. if( rastnestIsChanged ) // The net ratsnest must be recalculated
  1218. m_board->m_Status_Pcb = 0;
  1219. return true;
  1220. }
  1221. bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad )
  1222. {
  1223. wxString msg;
  1224. int x, y;
  1225. if( !Validate() )
  1226. return true;
  1227. if( !m_panelGeneral->Validate() )
  1228. return true;
  1229. if( !m_localSettingsPanel->Validate() )
  1230. return true;
  1231. m_OrientValidator.TransferFromWindow();
  1232. aPad->SetAttribute( code_type[m_PadType->GetSelection()] );
  1233. aPad->SetShape( code_shape[m_PadShape->GetSelection()] );
  1234. aPad->SetAnchorPadShape( m_PadShape->GetSelection() == CHOICE_SHAPE_CUSTOM_RECT_ANCHOR ?
  1235. PAD_SHAPE_RECT : PAD_SHAPE_CIRCLE );
  1236. if( aPad->GetShape() == PAD_SHAPE_CUSTOM )
  1237. aPad->SetPrimitives( m_primitives );
  1238. // Read pad clearances values:
  1239. aPad->SetLocalClearance( ValueFromTextCtrl( *m_NetClearanceValueCtrl ) );
  1240. aPad->SetLocalSolderMaskMargin( ValueFromTextCtrl( *m_SolderMaskMarginCtrl ) );
  1241. aPad->SetLocalSolderPasteMargin( ValueFromTextCtrl( *m_SolderPasteMarginCtrl ) );
  1242. aPad->SetThermalWidth( ValueFromTextCtrl( *m_ThermalWidthCtrl ) );
  1243. aPad->SetThermalGap( ValueFromTextCtrl( *m_ThermalGapCtrl ) );
  1244. double dtmp = 0.0;
  1245. msg = m_SolderPasteMarginRatioCtrl->GetValue();
  1246. msg.ToDouble( &dtmp );
  1247. // A -50% margin ratio means no paste on a pad, the ratio must be >= -50%
  1248. if( dtmp < -50.0 )
  1249. dtmp = -50.0;
  1250. // A margin ratio is always <= 0
  1251. // 0 means use full pad copper area
  1252. if( dtmp > 0.0 )
  1253. dtmp = 0.0;
  1254. aPad->SetLocalSolderPasteMarginRatio( dtmp / 100 );
  1255. switch( m_ZoneConnectionChoice->GetSelection() )
  1256. {
  1257. default:
  1258. case 0:
  1259. aPad->SetZoneConnection( PAD_ZONE_CONN_INHERITED );
  1260. break;
  1261. case 1:
  1262. aPad->SetZoneConnection( PAD_ZONE_CONN_FULL );
  1263. break;
  1264. case 2:
  1265. aPad->SetZoneConnection( PAD_ZONE_CONN_THERMAL );
  1266. break;
  1267. case 3:
  1268. aPad->SetZoneConnection( PAD_ZONE_CONN_NONE );
  1269. break;
  1270. }
  1271. // Custom shape has only 2 options:
  1272. if( aPad->GetShape() == PAD_SHAPE_CUSTOM )
  1273. {
  1274. if( m_ZoneConnectionCustom->GetSelection() == 0 )
  1275. aPad->SetZoneConnection( PAD_ZONE_CONN_NONE );
  1276. else
  1277. aPad->SetZoneConnection( PAD_ZONE_CONN_FULL );
  1278. }
  1279. // Read pad position:
  1280. x = ValueFromTextCtrl( *m_PadPosition_X_Ctrl );
  1281. y = ValueFromTextCtrl( *m_PadPosition_Y_Ctrl );
  1282. aPad->SetPosition( wxPoint( x, y ) );
  1283. aPad->SetPos0( wxPoint( x, y ) );
  1284. // Read pad drill:
  1285. x = ValueFromTextCtrl( *m_PadDrill_X_Ctrl );
  1286. y = ValueFromTextCtrl( *m_PadDrill_Y_Ctrl );
  1287. if( m_DrillShapeCtrl->GetSelection() == 0 )
  1288. {
  1289. aPad->SetDrillShape( PAD_DRILL_SHAPE_CIRCLE );
  1290. y = x;
  1291. }
  1292. else
  1293. aPad->SetDrillShape( PAD_DRILL_SHAPE_OBLONG );
  1294. aPad->SetDrillSize( wxSize( x, y ) );
  1295. // Read pad shape size:
  1296. x = ValueFromTextCtrl( *m_ShapeSize_X_Ctrl );
  1297. y = ValueFromTextCtrl( *m_ShapeSize_Y_Ctrl );
  1298. if( aPad->GetShape() == PAD_SHAPE_CIRCLE )
  1299. y = x;
  1300. // for custom shped pads, the pad size is the anchor pad size:
  1301. if( aPad->GetShape() == PAD_SHAPE_CUSTOM && aPad->GetAnchorPadShape() == PAD_SHAPE_CIRCLE )
  1302. y = x;
  1303. aPad->SetSize( wxSize( x, y ) );
  1304. // Read pad length die
  1305. aPad->SetPadToDieLength( ValueFromTextCtrl( *m_LengthPadToDieCtrl ) );
  1306. // For a trapezoid, test delta value (be sure delta is not too large for pad size)
  1307. // remember DeltaSize.x is the Y size variation
  1308. bool error = false;
  1309. if( aPad->GetShape() == PAD_SHAPE_TRAPEZOID )
  1310. {
  1311. wxSize delta;
  1312. // For a trapezoid, only one of delta.x or delta.y is not 0, depending on
  1313. // the direction.
  1314. if( m_trapDeltaDirChoice->GetSelection() == 0 )
  1315. delta.x = ValueFromTextCtrl( *m_ShapeDelta_Ctrl );
  1316. else
  1317. delta.y = ValueFromTextCtrl( *m_ShapeDelta_Ctrl );
  1318. if( delta.x < 0 && delta.x <= -aPad->GetSize().y )
  1319. {
  1320. delta.x = -aPad->GetSize().y + 2;
  1321. error = true;
  1322. }
  1323. if( delta.x > 0 && delta.x >= aPad->GetSize().y )
  1324. {
  1325. delta.x = aPad->GetSize().y - 2;
  1326. error = true;
  1327. }
  1328. if( delta.y < 0 && delta.y <= -aPad->GetSize().x )
  1329. {
  1330. delta.y = -aPad->GetSize().x + 2;
  1331. error = true;
  1332. }
  1333. if( delta.y > 0 && delta.y >= aPad->GetSize().x )
  1334. {
  1335. delta.y = aPad->GetSize().x - 2;
  1336. error = true;
  1337. }
  1338. aPad->SetDelta( delta );
  1339. }
  1340. // Read pad shape offset:
  1341. x = ValueFromTextCtrl( *m_ShapeOffset_X_Ctrl );
  1342. y = ValueFromTextCtrl( *m_ShapeOffset_Y_Ctrl );
  1343. aPad->SetOffset( wxPoint( x, y ) );
  1344. aPad->SetOrientation( m_OrientValue * 10.0 );
  1345. aPad->SetName( m_PadNumCtrl->GetValue() );
  1346. // Check if user has set an existing net name
  1347. const NETINFO_ITEM* netinfo = m_board->FindNet( m_PadNetNameCtrl->GetValue() );
  1348. if( netinfo != NULL )
  1349. aPad->SetNetCode( netinfo->GetNet() );
  1350. else
  1351. aPad->SetNetCode( NETINFO_LIST::UNCONNECTED );
  1352. // Clear some values, according to the pad type and shape
  1353. switch( aPad->GetShape() )
  1354. {
  1355. case PAD_SHAPE_CIRCLE:
  1356. aPad->SetOffset( wxPoint( 0, 0 ) );
  1357. aPad->SetDelta( wxSize( 0, 0 ) );
  1358. x = aPad->GetSize().x;
  1359. aPad->SetSize( wxSize( x, x ) );
  1360. break;
  1361. case PAD_SHAPE_RECT:
  1362. aPad->SetDelta( wxSize( 0, 0 ) );
  1363. break;
  1364. case PAD_SHAPE_OVAL:
  1365. aPad->SetDelta( wxSize( 0, 0 ) );
  1366. break;
  1367. case PAD_SHAPE_TRAPEZOID:
  1368. break;
  1369. case PAD_SHAPE_ROUNDRECT:
  1370. aPad->SetDelta( wxSize( 0, 0 ) );
  1371. break;
  1372. case PAD_SHAPE_CUSTOM:
  1373. aPad->SetOffset( wxPoint( 0, 0 ) );
  1374. aPad->SetDelta( wxSize( 0, 0 ) );
  1375. // The pad custom has a "anchor pad" (a basic shape: round or rect pad)
  1376. // that is the minimal area of this pad, and is usefull to ensure a hole
  1377. // diameter is acceptable, and is used in Gerber files as flashed area
  1378. // reference
  1379. if( aPad->GetAnchorPadShape() == PAD_SHAPE_CIRCLE )
  1380. {
  1381. x = aPad->GetSize().x;
  1382. aPad->SetSize( wxSize( x, x ) );
  1383. }
  1384. // define the way the clearance area is defined in zones
  1385. aPad->SetCustomShapeInZoneOpt( m_ZoneCustomPadShape->GetSelection() == 0 ?
  1386. CUST_PAD_SHAPE_IN_ZONE_OUTLINE :
  1387. CUST_PAD_SHAPE_IN_ZONE_CONVEXHULL );
  1388. break;
  1389. default:
  1390. ;
  1391. }
  1392. switch( aPad->GetAttribute() )
  1393. {
  1394. case PAD_ATTRIB_STANDARD:
  1395. break;
  1396. case PAD_ATTRIB_CONN:
  1397. case PAD_ATTRIB_SMD:
  1398. // SMD and PAD_ATTRIB_CONN has no hole.
  1399. // basically, SMD and PAD_ATTRIB_CONN are same type of pads
  1400. // PAD_ATTRIB_CONN has just a default non technical layers that differs from SMD
  1401. // and are intended to be used in virtual edge board connectors
  1402. // However we can accept a non null offset,
  1403. // mainly to allow complex pads build from a set of basic pad shapes
  1404. aPad->SetDrillSize( wxSize( 0, 0 ) );
  1405. break;
  1406. case PAD_ATTRIB_HOLE_NOT_PLATED:
  1407. // Mechanical purpose only:
  1408. // no offset, no net name, no pad name allowed
  1409. aPad->SetOffset( wxPoint( 0, 0 ) );
  1410. aPad->SetName( wxEmptyString );
  1411. aPad->SetNetCode( NETINFO_LIST::UNCONNECTED );
  1412. break;
  1413. default:
  1414. DisplayError( NULL, wxT( "Error: unknown pad type" ) );
  1415. break;
  1416. }
  1417. if( aPad->GetShape() == PAD_SHAPE_ROUNDRECT )
  1418. {
  1419. wxString value = m_tcCornerSizeRatio->GetValue();
  1420. double rrRadiusRatioPercent;
  1421. if( value.ToDouble( &rrRadiusRatioPercent ) )
  1422. aPad->SetRoundRectRadiusRatio( rrRadiusRatioPercent / 100.0 );
  1423. }
  1424. LSET padLayerMask;
  1425. switch( m_rbCopperLayersSel->GetSelection() )
  1426. {
  1427. case 0:
  1428. padLayerMask.set( F_Cu );
  1429. break;
  1430. case 1:
  1431. padLayerMask.set( B_Cu );
  1432. break;
  1433. case 2:
  1434. padLayerMask |= LSET::AllCuMask();
  1435. break;
  1436. case 3: // No copper layers
  1437. break;
  1438. }
  1439. if( m_PadLayerAdhCmp->GetValue() )
  1440. padLayerMask.set( F_Adhes );
  1441. if( m_PadLayerAdhCu->GetValue() )
  1442. padLayerMask.set( B_Adhes );
  1443. if( m_PadLayerPateCmp->GetValue() )
  1444. padLayerMask.set( F_Paste );
  1445. if( m_PadLayerPateCu->GetValue() )
  1446. padLayerMask.set( B_Paste );
  1447. if( m_PadLayerSilkCmp->GetValue() )
  1448. padLayerMask.set( F_SilkS );
  1449. if( m_PadLayerSilkCu->GetValue() )
  1450. padLayerMask.set( B_SilkS );
  1451. if( m_PadLayerMaskCmp->GetValue() )
  1452. padLayerMask.set( F_Mask );
  1453. if( m_PadLayerMaskCu->GetValue() )
  1454. padLayerMask.set( B_Mask );
  1455. if( m_PadLayerECO1->GetValue() )
  1456. padLayerMask.set( Eco1_User );
  1457. if( m_PadLayerECO2->GetValue() )
  1458. padLayerMask.set( Eco2_User );
  1459. if( m_PadLayerDraft->GetValue() )
  1460. padLayerMask.set( Dwgs_User );
  1461. aPad->SetLayerSet( padLayerMask );
  1462. return error;
  1463. }
  1464. void DIALOG_PAD_PROPERTIES::OnValuesChanged( wxCommandEvent& event )
  1465. {
  1466. if( m_canUpdate )
  1467. {
  1468. transferDataToPad( m_dummyPad );
  1469. // If the pad size has changed, update the displayed values
  1470. // for rounded rect pads
  1471. updateRoundRectCornerValues();
  1472. redraw();
  1473. }
  1474. }
  1475. void DIALOG_PAD_PROPERTIES::editPrimitive()
  1476. {
  1477. long select = m_listCtrlPrimitives->GetFirstSelected();
  1478. if( select < 0 )
  1479. {
  1480. wxMessageBox( _( "No shape selected" ) );
  1481. return;
  1482. }
  1483. PAD_CS_PRIMITIVE& shape = m_primitives[select];
  1484. if( shape.m_Shape == S_POLYGON )
  1485. {
  1486. DIALOG_PAD_PRIMITIVE_POLY_PROPS dlg( this, &shape );
  1487. if( dlg.ShowModal() != wxID_OK )
  1488. return;
  1489. dlg.TransferDataFromWindow();
  1490. }
  1491. else
  1492. {
  1493. DIALOG_PAD_PRIMITIVES_PROPERTIES dlg( this, &shape );
  1494. if( dlg.ShowModal() != wxID_OK )
  1495. return;
  1496. dlg.TransferDataFromWindow();
  1497. }
  1498. displayPrimitivesList();
  1499. if( m_canUpdate )
  1500. {
  1501. transferDataToPad( m_dummyPad );
  1502. redraw();
  1503. }
  1504. }
  1505. void DIALOG_PAD_PROPERTIES::OnPrimitiveSelection( wxListEvent& event )
  1506. {
  1507. // Called on a double click on the basic shapes list
  1508. // To Do: highligth the primitive(s) currently selected.
  1509. redraw();
  1510. }
  1511. /// Called on a double click on the basic shapes list
  1512. void DIALOG_PAD_PROPERTIES::onPrimitiveDClick( wxMouseEvent& event )
  1513. {
  1514. editPrimitive();
  1515. }
  1516. // Called on a click on basic shapes list panel button
  1517. void DIALOG_PAD_PROPERTIES::onEditPrimitive( wxCommandEvent& event )
  1518. {
  1519. editPrimitive();
  1520. }
  1521. // Called on a click on basic shapes list panel button
  1522. void DIALOG_PAD_PROPERTIES::onDeletePrimitive( wxCommandEvent& event )
  1523. {
  1524. long select = m_listCtrlPrimitives->GetFirstSelected();
  1525. if( select < 0 )
  1526. return;
  1527. // Multiple selections are allowed. get them and remove corresponding shapes
  1528. std::vector<long> indexes;
  1529. indexes.push_back( select );
  1530. while( ( select = m_listCtrlPrimitives->GetNextSelected( select ) ) >= 0 )
  1531. indexes.push_back( select );
  1532. // Erase all select shapes
  1533. for( unsigned ii = indexes.size(); ii > 0; --ii )
  1534. m_primitives.erase( m_primitives.begin() + indexes[ii-1] );
  1535. displayPrimitivesList();
  1536. if( m_canUpdate )
  1537. {
  1538. transferDataToPad( m_dummyPad );
  1539. redraw();
  1540. }
  1541. }
  1542. void DIALOG_PAD_PROPERTIES::onAddPrimitive( wxCommandEvent& event )
  1543. {
  1544. // Ask user for shape type
  1545. wxString shapelist[] =
  1546. {
  1547. _( "Segment" ), _( "Arc" ), _( "ring/circle" ), _( "polygon" )
  1548. };
  1549. int type = wxGetSingleChoiceIndex( wxEmptyString, _( "Select shape type:" ),
  1550. DIM( shapelist ), shapelist, 0, this );
  1551. STROKE_T listtype[] =
  1552. {
  1553. S_SEGMENT, S_ARC, S_CIRCLE, S_POLYGON
  1554. };
  1555. PAD_CS_PRIMITIVE primitive( listtype[type] );
  1556. if( listtype[type] == S_POLYGON )
  1557. {
  1558. DIALOG_PAD_PRIMITIVE_POLY_PROPS dlg( this, &primitive );
  1559. if( dlg.ShowModal() != wxID_OK )
  1560. return;
  1561. }
  1562. else
  1563. {
  1564. DIALOG_PAD_PRIMITIVES_PROPERTIES dlg( this, &primitive );
  1565. if( dlg.ShowModal() != wxID_OK )
  1566. return;
  1567. }
  1568. m_primitives.push_back( primitive );
  1569. displayPrimitivesList();
  1570. if( m_canUpdate )
  1571. {
  1572. transferDataToPad( m_dummyPad );
  1573. redraw();
  1574. }
  1575. }
  1576. void DIALOG_PAD_PROPERTIES::onImportPrimitives( wxCommandEvent& event )
  1577. {
  1578. wxMessageBox( "Not yet available" );
  1579. }
  1580. void DIALOG_PAD_PROPERTIES::onGeometryTransform( wxCommandEvent& event )
  1581. {
  1582. long select = m_listCtrlPrimitives->GetFirstSelected();
  1583. if( select < 0 )
  1584. {
  1585. wxMessageBox( _( "No shape selected" ) );
  1586. return;
  1587. }
  1588. // Multiple selections are allowed. Build selected shapes list
  1589. std::vector<PAD_CS_PRIMITIVE*> shapeList;
  1590. shapeList.push_back( &m_primitives[select] );
  1591. while( ( select = m_listCtrlPrimitives->GetNextSelected( select ) ) >= 0 )
  1592. shapeList.push_back( &m_primitives[select] );
  1593. DIALOG_PAD_PRIMITIVES_TRANSFORM dlg( this, shapeList, false );
  1594. if( dlg.ShowModal() != wxID_OK )
  1595. return;
  1596. // Transfert new settings:
  1597. dlg.Transform();
  1598. displayPrimitivesList();
  1599. if( m_canUpdate )
  1600. {
  1601. transferDataToPad( m_dummyPad );
  1602. redraw();
  1603. }
  1604. }
  1605. void DIALOG_PAD_PROPERTIES::onDuplicatePrimitive( wxCommandEvent& event )
  1606. {
  1607. long select = m_listCtrlPrimitives->GetFirstSelected();
  1608. if( select < 0 )
  1609. {
  1610. wxMessageBox( _( "No shape selected" ) );
  1611. return;
  1612. }
  1613. // Multiple selections are allowed. Build selected shapes list
  1614. std::vector<PAD_CS_PRIMITIVE*> shapeList;
  1615. shapeList.push_back( &m_primitives[select] );
  1616. while( ( select = m_listCtrlPrimitives->GetNextSelected( select ) ) >= 0 )
  1617. shapeList.push_back( &m_primitives[select] );
  1618. DIALOG_PAD_PRIMITIVES_TRANSFORM dlg( this, shapeList, true );
  1619. if( dlg.ShowModal() != wxID_OK )
  1620. return;
  1621. // Transfer new settings
  1622. // save duplicates to a separate vector to avoid m_primitives reallocation,
  1623. // as shapeList contains pointers to its elements
  1624. std::vector<PAD_CS_PRIMITIVE> duplicates;
  1625. dlg.Transform( &duplicates, dlg.GetDuplicateCount() );
  1626. std::move( duplicates.begin(), duplicates.end(), std::back_inserter( m_primitives ) );
  1627. displayPrimitivesList();
  1628. if( m_canUpdate )
  1629. {
  1630. transferDataToPad( m_dummyPad );
  1631. redraw();
  1632. }
  1633. }