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.

92 lines
3.0 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: dialog_mask_clearance.cpp
  3. // Author: jean-pierre Charras
  4. // Modified by:
  5. // Created: 17 feb 2009
  6. // Licence: GPL
  7. /////////////////////////////////////////////////////////////////////////////
  8. #include "fctsys.h"
  9. #include "common.h"
  10. #include "confirm.h"
  11. #include "pcbnew.h"
  12. #include "wxPcbStruct.h"
  13. #include "class_board_design_settings.h"
  14. #include "dialog_mask_clearance.h"
  15. /**
  16. * DIALOG_PADS_MASK_CLEARANCE_BASE, derived from DIALOG_PADS_MASK_CLEARANCE_BASE_BASE
  17. * @see dialog_dialog_mask_clearance_base.h and dialog_mask_clearance.cpp,
  18. * automatically created by wxFormBuilder
  19. */
  20. DIALOG_PADS_MASK_CLEARANCE::DIALOG_PADS_MASK_CLEARANCE( WinEDA_PcbFrame* parent ) :
  21. DIALOG_PADS_MASK_CLEARANCE_BASE( parent )
  22. {
  23. m_Parent = parent;
  24. MyInit();
  25. GetSizer()->SetSizeHints( this );
  26. Centre();
  27. }
  28. void DIALOG_PADS_MASK_CLEARANCE::MyInit()
  29. {
  30. SetFocus();
  31. m_SolderMaskMarginUnits->SetLabel( GetUnitsLabel( g_UnitMetric ) );
  32. m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UnitMetric ) );
  33. int Internal_Unit = m_Parent->m_InternalUnits;
  34. PutValueInLocalUnits( *m_SolderMaskMarginCtrl,
  35. g_DesignSettings.m_SolderMaskMargin,
  36. Internal_Unit );
  37. // These 2 parameters are usually < 0, so prepare entering a negative
  38. // value, if current is 0
  39. PutValueInLocalUnits( *m_SolderPasteMarginCtrl,
  40. g_DesignSettings.m_SolderPasteMargin,
  41. Internal_Unit );
  42. if( g_DesignSettings.m_SolderPasteMargin == 0 )
  43. m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) +
  44. m_SolderPasteMarginCtrl->GetValue() );
  45. wxString msg;
  46. if( g_DesignSettings.m_SolderPasteMarginRatio == 0 )
  47. msg.Printf( wxT( "-%f" ), g_DesignSettings.m_SolderPasteMarginRatio * 100.0 );
  48. else
  49. msg.Printf( wxT( "%f" ), g_DesignSettings.m_SolderPasteMarginRatio * 100.0 );
  50. m_SolderPasteMarginRatioCtrl->SetValue( msg );
  51. }
  52. /*******************************************************************/
  53. void DIALOG_PADS_MASK_CLEARANCE::OnButtonOkClick( wxCommandEvent& event )
  54. /*******************************************************************/
  55. {
  56. g_DesignSettings.m_SolderMaskMargin =
  57. ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl, m_Parent->m_InternalUnits );
  58. g_DesignSettings.m_SolderPasteMargin =
  59. ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl, m_Parent->m_InternalUnits );
  60. double dtmp;
  61. wxString msg = m_SolderPasteMarginRatioCtrl->GetValue();
  62. msg.ToDouble( &dtmp );
  63. // A margin ratio de -50% means no paste on a pad, the ratio must be >= 50 %
  64. if( dtmp < -50 )
  65. dtmp = -50;
  66. g_DesignSettings.m_SolderPasteMarginRatio = dtmp / 100;
  67. EndModal( 1 );
  68. }
  69. /*!
  70. * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
  71. */
  72. void DIALOG_PADS_MASK_CLEARANCE::OnButtonCancelClick( wxCommandEvent& event )
  73. {
  74. EndModal( 0 );
  75. }