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.

121 lines
3.6 KiB

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