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.

172 lines
6.1 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2009-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. /**
  25. * @file event_handlers_tracks_vias_sizes.cpp
  26. * @brief Handlers for popup and toolbars events relative to the tracks and vias sizes.
  27. */
  28. #include <fctsys.h>
  29. #include <class_drawpanel.h>
  30. #include <confirm.h>
  31. #include <pcb_edit_frame.h>
  32. #include <dialog_helpers.h>
  33. #include <pcbnew_id.h>
  34. #include <pcbnew.h>
  35. #include <class_board.h>
  36. #include <class_module.h>
  37. /* Event handler for tracks and vias size selection (and some options)
  38. * relative to toolbars and popup events
  39. */
  40. void PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event( wxCommandEvent& event )
  41. {
  42. int ii;
  43. int id = event.GetId();
  44. /* Note: none of these events require aborting the current command (if any)
  45. * (like move, edit or block command)
  46. * so we do not test for a current command in progress and call
  47. * m_canvas->m_endMouseCaptureCallback( m_canvas, &dc );
  48. */
  49. switch( id )
  50. {
  51. case ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH:
  52. GetDesignSettings().m_UseConnectedTrackWidth =
  53. not GetDesignSettings().m_UseConnectedTrackWidth;
  54. break;
  55. case ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES:
  56. GetDesignSettings().m_UseConnectedTrackWidth = false;
  57. GetDesignSettings().SetTrackWidthIndex( 0 );
  58. GetDesignSettings().SetViaSizeIndex( 0 );
  59. break;
  60. case ID_POPUP_PCB_SELECT_AUTO_WIDTH:
  61. m_canvas->MoveCursorToCrossHair();
  62. GetDesignSettings().m_UseConnectedTrackWidth = true;
  63. break;
  64. case ID_POPUP_PCB_SELECT_WIDTH1: // this is the default Netclass selection
  65. case ID_POPUP_PCB_SELECT_WIDTH2: // this is a custom value selection
  66. case ID_POPUP_PCB_SELECT_WIDTH3:
  67. case ID_POPUP_PCB_SELECT_WIDTH4:
  68. case ID_POPUP_PCB_SELECT_WIDTH5:
  69. case ID_POPUP_PCB_SELECT_WIDTH6:
  70. case ID_POPUP_PCB_SELECT_WIDTH7:
  71. case ID_POPUP_PCB_SELECT_WIDTH8:
  72. case ID_POPUP_PCB_SELECT_WIDTH9:
  73. case ID_POPUP_PCB_SELECT_WIDTH10:
  74. case ID_POPUP_PCB_SELECT_WIDTH11:
  75. case ID_POPUP_PCB_SELECT_WIDTH12:
  76. case ID_POPUP_PCB_SELECT_WIDTH13:
  77. case ID_POPUP_PCB_SELECT_WIDTH14:
  78. case ID_POPUP_PCB_SELECT_WIDTH15:
  79. case ID_POPUP_PCB_SELECT_WIDTH16:
  80. m_canvas->MoveCursorToCrossHair();
  81. GetDesignSettings().m_UseConnectedTrackWidth = false;
  82. ii = id - ID_POPUP_PCB_SELECT_WIDTH1;
  83. GetDesignSettings().SetTrackWidthIndex( ii );
  84. break;
  85. case ID_POPUP_PCB_SELECT_VIASIZE1: // this is the default Netclass selection
  86. case ID_POPUP_PCB_SELECT_VIASIZE2: // this is a custom value selection
  87. case ID_POPUP_PCB_SELECT_VIASIZE3:
  88. case ID_POPUP_PCB_SELECT_VIASIZE4:
  89. case ID_POPUP_PCB_SELECT_VIASIZE5:
  90. case ID_POPUP_PCB_SELECT_VIASIZE6:
  91. case ID_POPUP_PCB_SELECT_VIASIZE7:
  92. case ID_POPUP_PCB_SELECT_VIASIZE8:
  93. case ID_POPUP_PCB_SELECT_VIASIZE9:
  94. case ID_POPUP_PCB_SELECT_VIASIZE10:
  95. case ID_POPUP_PCB_SELECT_VIASIZE11:
  96. case ID_POPUP_PCB_SELECT_VIASIZE12:
  97. case ID_POPUP_PCB_SELECT_VIASIZE13:
  98. case ID_POPUP_PCB_SELECT_VIASIZE14:
  99. case ID_POPUP_PCB_SELECT_VIASIZE15:
  100. case ID_POPUP_PCB_SELECT_VIASIZE16:
  101. // select the new current value for via size (via diameter)
  102. m_canvas->MoveCursorToCrossHair();
  103. ii = id - ID_POPUP_PCB_SELECT_VIASIZE1;
  104. GetDesignSettings().SetViaSizeIndex( ii );
  105. break;
  106. case ID_AUX_TOOLBAR_PCB_TRACK_WIDTH:
  107. ii = m_SelTrackWidthBox->GetSelection();
  108. if( ii == int( m_SelTrackWidthBox->GetCount() - 2 ) )
  109. {
  110. // this is the separator
  111. m_SelTrackWidthBox->SetSelection( GetDesignSettings().GetTrackWidthIndex() );
  112. }
  113. else if( ii == int( m_SelTrackWidthBox->GetCount() - 1 ) )
  114. {
  115. m_SelTrackWidthBox->SetSelection( GetDesignSettings().GetTrackWidthIndex() );
  116. DoShowBoardSetupDialog( _( "Tracks & Vias" ) );
  117. }
  118. else
  119. GetDesignSettings().SetTrackWidthIndex( ii );
  120. break;
  121. case ID_AUX_TOOLBAR_PCB_VIA_SIZE:
  122. ii = m_SelViaSizeBox->GetSelection();
  123. if( ii == int( m_SelViaSizeBox->GetCount() - 2 ) )
  124. {
  125. // this is the separator
  126. m_SelViaSizeBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
  127. }
  128. else if( ii == int( m_SelViaSizeBox->GetCount() - 1 ) )
  129. {
  130. m_SelViaSizeBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
  131. DoShowBoardSetupDialog( _( "Tracks & Vias" ) );
  132. }
  133. else
  134. GetDesignSettings().SetViaSizeIndex( ii );
  135. break;
  136. default:
  137. wxLogDebug( wxT( "PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event() error") );
  138. break;
  139. }
  140. // Refresh track in progress, if any, by forcing a mouse event,
  141. // to call the current function attached to the mouse
  142. /*if( m_canvas->IsMouseCaptured() )
  143. {
  144. wxMouseEvent event(wxEVT_MOTION);
  145. wxPostEvent( m_canvas, event );
  146. }*/
  147. //+hp
  148. //Refresh canvas, that we can see changes instantly. I use this because it dont,t throw mouse up-left corner.
  149. if( m_canvas->IsMouseCaptured() )
  150. m_canvas->Refresh();
  151. }