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.

81 lines
2.6 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
  5. * Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
  6. * Copyright (C) 2004-2011 KiCad Developers, see change_log.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 busentry.cpp
  27. * @brief Code to handle manipulation of bus entry objects.
  28. */
  29. #include <fctsys.h>
  30. #include <gr_basic.h>
  31. #include <sch_draw_panel.h>
  32. #include <sch_edit_frame.h>
  33. #include <sch_bus_entry.h>
  34. static int s_LastShape = '\\';
  35. SCH_BUS_BUS_ENTRY* SCH_EDIT_FRAME::CreateBusBusEntry()
  36. {
  37. // Create and place a new bus entry at cursor position
  38. SCH_BUS_BUS_ENTRY* busEntry = new SCH_BUS_BUS_ENTRY( GetCrossHairPosition(), s_LastShape );
  39. busEntry->SetFlags( IS_NEW );
  40. GetScreen()->SetCurItem( busEntry );
  41. addCurrentItemToList();
  42. return busEntry;
  43. }
  44. SCH_BUS_WIRE_ENTRY* SCH_EDIT_FRAME::CreateBusWireEntry()
  45. {
  46. // Create and place a new bus entry at cursor position
  47. SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( GetCrossHairPosition(), s_LastShape );
  48. busEntry->SetFlags( IS_NEW );
  49. GetScreen()->SetCurItem( busEntry );
  50. addCurrentItemToList();
  51. return busEntry;
  52. }
  53. /* set the shape of BusEntry (shape = / or \ )
  54. */
  55. void SCH_EDIT_FRAME::SetBusEntryShape( wxDC* DC, SCH_BUS_ENTRY_BASE* BusEntry, char entry_shape )
  56. {
  57. if( BusEntry == NULL )
  58. return;
  59. /* Put old item in undo list if it is not currently in edit */
  60. if( BusEntry->GetFlags() == 0 )
  61. SaveCopyInUndoList( BusEntry, UR_CHANGED );
  62. s_LastShape = entry_shape == '/' ? '/' : '\\';
  63. BusEntry->SetBusEntryShape( s_LastShape );
  64. GetScreen()->TestDanglingEnds();
  65. OnModify( );
  66. }