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.

126 lines
3.8 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
  5. * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  6. * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
  7. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, you may find one here:
  21. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  22. * or you may search the http://www.gnu.org website for the version 2 license,
  23. * or you may write to the Free Software Foundation, Inc.,
  24. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  25. */
  26. /**
  27. * @file attribut.cpp
  28. * @brief Track attribute flags editing.
  29. */
  30. #include <fctsys.h>
  31. #include <class_drawpanel.h>
  32. #include <gr_basic.h>
  33. #include <pcb_edit_frame.h>
  34. #include <msgpanel.h>
  35. #include <pcbnew.h>
  36. #include <protos.h>
  37. #include <class_track.h>
  38. #include <class_board.h>
  39. /* Attribute change for 1 track segment.
  40. * Attributes are
  41. * TRACK_LOCKED protection against global delete
  42. * TRACK_AR AutoRouted segment
  43. */
  44. void PCB_EDIT_FRAME::Attribut_Segment( TRACK* track, wxDC* DC, bool Flag_On )
  45. {
  46. if( track == NULL )
  47. return;
  48. OnModify();
  49. m_canvas->CrossHairOff( DC ); // Erase cursor shape
  50. track->SetState( TRACK_LOCKED, Flag_On );
  51. track->Draw( m_canvas, DC, GR_OR | GR_HIGHLIGHT );
  52. m_canvas->CrossHairOn( DC ); // Display cursor shape
  53. MSG_PANEL_ITEMS items;
  54. track->GetMsgPanelInfo( m_UserUnits, items );
  55. SetMsgPanel( items );
  56. }
  57. /* Attribute change for an entire track */
  58. void PCB_EDIT_FRAME::Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On )
  59. {
  60. TRACK* Track;
  61. int nb_segm;
  62. if( track == NULL )
  63. return;
  64. m_canvas->CrossHairOff( DC ); // Erase cursor shape
  65. Track = GetBoard()->MarkTrace( GetBoard()->m_Track, track, &nb_segm, NULL, NULL, true );
  66. DrawTraces( m_canvas, DC, Track, nb_segm, GR_OR | GR_HIGHLIGHT );
  67. for( ; (Track != NULL) && (nb_segm > 0); nb_segm-- )
  68. {
  69. Track->SetState( TRACK_LOCKED, Flag_On );
  70. Track->SetState( BUSY, false );
  71. Track = Track->Next();
  72. }
  73. m_canvas->CrossHairOn( DC ); // Display cursor shape
  74. OnModify();
  75. }
  76. /* Modify the flag TRACK_LOCKED according to Flag_On value,
  77. * for all the segments related to net_code.
  78. * if net_code < 0 all the segments are modified.
  79. */
  80. void PCB_EDIT_FRAME::Attribut_net( wxDC* DC, int net_code, bool Flag_On )
  81. {
  82. TRACK* Track = GetBoard()->m_Track;
  83. /* search the first segment for the selected net_code */
  84. if( net_code >= 0 )
  85. {
  86. for( ; Track != NULL; Track = Track->Next() )
  87. {
  88. if( net_code == Track->GetNetCode() )
  89. break;
  90. }
  91. }
  92. m_canvas->CrossHairOff( DC ); // Erase cursor shape
  93. while( Track ) /* Flag change */
  94. {
  95. if( ( net_code >= 0 ) && ( net_code != Track->GetNetCode() ) )
  96. break;
  97. OnModify();
  98. Track->SetState( TRACK_LOCKED, Flag_On );
  99. Track->Draw( m_canvas, DC, GR_OR | GR_HIGHLIGHT );
  100. Track = Track->Next();
  101. }
  102. m_canvas->CrossHairOn( DC ); // Display cursor shape
  103. OnModify();
  104. }