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.

170 lines
6.0 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: dialog_global_edit_tracks_and_vias.cpp
  3. // Author: jean-pierre Charras
  4. // Created: 30 oct 2009
  5. // Licence: GPL
  6. /////////////////////////////////////////////////////////////////////////////
  7. #include "fctsys.h"
  8. #include "common.h"
  9. #include "confirm.h"
  10. #include "pcbnew.h"
  11. #include "wxPcbStruct.h"
  12. #include "class_drawpanel.h"
  13. #include "dialog_global_edit_tracks_and_vias.h"
  14. /**
  15. * DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS_BASE, derived from DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS_BASE_BASE
  16. * @see dialog_global_edit_tracks_and_vias_base.h and dialog_global_edit_tracks_and_vias_base.cpp,
  17. * automatically created by wxFormBuilder
  18. */
  19. DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS(
  20. WinEDA_PcbFrame* aParent, int aNetcode ) :
  21. DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS_BASE( aParent )
  22. {
  23. m_Parent = aParent;
  24. m_Netcode = aNetcode;
  25. MyInit();
  26. Layout();
  27. GetSizer()->Fit( this );
  28. GetSizer()->SetSizeHints( this );
  29. }
  30. /*************************************************/
  31. void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::MyInit()
  32. /*************************************************/
  33. {
  34. SetFocus();
  35. wxString msg;
  36. // Display current setup for tracks and vias
  37. int Internal_Unit = m_Parent->m_InternalUnits;
  38. BOARD* board = m_Parent->GetBoard();
  39. NETCLASSES& netclasses = board->m_NetClasses;
  40. NETINFO_ITEM* net = board->FindNet( m_Netcode );
  41. NETCLASS* netclass = netclasses.GetDefault();
  42. if( net )
  43. {
  44. m_CurrentNetName->SetLabel( net->GetNetname() );
  45. m_CurrentNetclassName->SetLabel( board->m_CurrentNetClassName );
  46. netclass = netclasses.Find( board->m_CurrentNetClassName );
  47. }
  48. // Enable/disable the option "copy current to net" if we ause only default netclass values
  49. if( ! board->m_TrackWidthSelector && !board->m_ViaSizeSelector )
  50. {
  51. m_Net2CurrValueButton->Enable(false);
  52. m_Net2CurrValueText->Enable(false);
  53. }
  54. // Display current values, and current netclass values:
  55. int value = netclass->GetTrackWidth();
  56. msg = ReturnStringFromValue( g_UnitMetric, value, Internal_Unit, true );
  57. m_gridDisplayCurrentSettings->SetCellValue( 0, 0, msg );
  58. if( board->m_TrackWidthSelector )
  59. {
  60. value = board->GetCurrentTrackWidth();
  61. msg = ReturnStringFromValue( g_UnitMetric, value, Internal_Unit, true );
  62. }
  63. else
  64. msg = _( "Default" );
  65. m_gridDisplayCurrentSettings->SetCellValue( 1, 0, msg );
  66. // recompute the column widths here, after setting texts
  67. value = netclass->GetViaDiameter();
  68. msg = ReturnStringFromValue( g_UnitMetric, value, Internal_Unit, true );
  69. m_gridDisplayCurrentSettings->SetCellValue( 0, 1, msg );
  70. if( board->m_ViaSizeSelector )
  71. {
  72. value = board->GetCurrentViaSize();
  73. msg = ReturnStringFromValue( g_UnitMetric, value, Internal_Unit, true );
  74. }
  75. else
  76. msg = _( "Default" );
  77. m_gridDisplayCurrentSettings->SetCellValue( 1, 1, msg );
  78. value = netclass->GetViaDrill();
  79. msg = ReturnStringFromValue( g_UnitMetric, value, Internal_Unit, true );
  80. m_gridDisplayCurrentSettings->SetCellValue( 0, 2, msg );
  81. value = board->GetCurrentViaDrill();
  82. if( value >= 0 )
  83. msg = ReturnStringFromValue( g_UnitMetric, value, Internal_Unit, true );
  84. else
  85. msg = _( "Default" );
  86. m_gridDisplayCurrentSettings->SetCellValue( 1, 2, msg );
  87. value = netclass->GetuViaDiameter();
  88. msg = ReturnStringFromValue( g_UnitMetric, value, Internal_Unit, true );
  89. m_gridDisplayCurrentSettings->SetCellValue( 0, 3, msg );
  90. #if 0 // Currently we use always the default netclass value
  91. value = board->GetCurrentMicroViaSize();
  92. msg = ReturnStringFromValue( g_UnitMetric, value, Internal_Unit, true );
  93. #endif
  94. msg = _( "Default" );
  95. m_gridDisplayCurrentSettings->SetCellValue( 1, 3, msg );
  96. value = netclass->GetuViaDrill();
  97. msg = ReturnStringFromValue( g_UnitMetric, value, Internal_Unit, true );
  98. m_gridDisplayCurrentSettings->SetCellValue( 0, 4, msg );
  99. #if 0 // Currently we use always the default netclass value
  100. value = board->GetCurrentMicroViaDrill();
  101. if( value >= 0 )
  102. msg = ReturnStringFromValue( g_UnitMetric, value, Internal_Unit, true );
  103. else
  104. #endif
  105. msg = _( "Default" );
  106. m_gridDisplayCurrentSettings->SetCellValue( 1, 4, msg );
  107. // Set all cells Roead Only
  108. for( int ii = 0; ii < m_gridDisplayCurrentSettings->GetNumberRows(); ii++ )
  109. {
  110. for( int jj = 0; jj < m_gridDisplayCurrentSettings->GetNumberCols(); jj++ )
  111. m_gridDisplayCurrentSettings->SetReadOnly( ii, jj, true );
  112. }
  113. m_gridDisplayCurrentSettings->Fit( );
  114. }
  115. /*******************************************************************/
  116. void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnOkClick( wxCommandEvent& event )
  117. /*******************************************************************/
  118. {
  119. bool change = false;
  120. switch( event.GetId() )
  121. {
  122. case ID_CURRENT_VALUES_TO_CURRENT_NET:
  123. change = m_Parent->Change_Net_Tracks_And_Vias_Sizes( m_Netcode, false );
  124. break;
  125. case ID_NETCLASS_VALUES_TO_CURRENT_NET:
  126. change = m_Parent->Change_Net_Tracks_And_Vias_Sizes( m_Netcode, true );
  127. break;
  128. case ID_ALL_TRACKS_VIAS:
  129. change = m_Parent->Reset_All_Tracks_And_Vias_To_Netclass_Values( true, true );
  130. break;
  131. case ID_ALL_VIAS:
  132. change = m_Parent->Reset_All_Tracks_And_Vias_To_Netclass_Values( false, true );
  133. break;
  134. case ID_ALL_TRACKS:
  135. change = m_Parent->Reset_All_Tracks_And_Vias_To_Netclass_Values( true, false );
  136. break;
  137. }
  138. EndModal( 1 );
  139. if( change )
  140. m_Parent->DrawPanel->Refresh();
  141. }
  142. /*******************************
  143. *event handler for wxID_CANCEL
  144. ******************************/
  145. void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnCancelClick( wxCommandEvent& event )
  146. {
  147. EndModal( 0 );
  148. }