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.

137 lines
4.1 KiB

11 years ago
11 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2007 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2014 KiCad Developers, see CHANGELOG.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. #include <fctsys.h>
  25. #include <class_drawpanel.h>
  26. //#include <general.h>
  27. //#include <protos.h>
  28. #include <libeditframe.h>
  29. #include <class_libentry.h>
  30. void LIB_EDIT_FRAME::SaveCopyInUndoList( EDA_ITEM* ItemToCopy )
  31. {
  32. LIB_PART* CopyItem;
  33. PICKED_ITEMS_LIST* lastcmd;
  34. CopyItem = new LIB_PART( * (LIB_PART*) ItemToCopy );
  35. // Clear current flags (which can be temporary set by a current edit command).
  36. CopyItem->ClearStatus();
  37. lastcmd = new PICKED_ITEMS_LIST();
  38. ITEM_PICKER wrapper( CopyItem, UR_LIBEDIT );
  39. lastcmd->PushItem(wrapper);
  40. GetScreen()->PushCommandToUndoList( lastcmd );
  41. // Clear redo list, because after new save there is no redo to do.
  42. GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList );
  43. }
  44. void LIB_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event )
  45. {
  46. if( GetScreen()->GetRedoCommandCount() <= 0 )
  47. return;
  48. PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST();
  49. LIB_PART* part = GetCurPart();
  50. ITEM_PICKER wrapper( part, UR_LIBEDIT );
  51. lastcmd->PushItem( wrapper );
  52. GetScreen()->PushCommandToUndoList( lastcmd );
  53. lastcmd = GetScreen()->PopCommandFromRedoList();
  54. wrapper = lastcmd->PopItem();
  55. part = (LIB_PART*) wrapper.GetItem();
  56. // Do not delete the previous part by calling SetCurPart( part )
  57. // which calls delete <previous part>.
  58. // <previous part> is now put in undo list and is owned by this list
  59. // Just set the current part to the part which come from the redo list
  60. m_my_part = part;
  61. if( !part )
  62. return;
  63. if( !m_aliasName.IsEmpty() && !part->HasAlias( m_aliasName ) )
  64. m_aliasName = part->GetName();
  65. m_drawItem = NULL;
  66. UpdateAliasSelectList();
  67. UpdatePartSelectList();
  68. SetShowDeMorgan( part->HasConversion() );
  69. DisplayLibInfos();
  70. DisplayCmpDoc();
  71. OnModify();
  72. m_canvas->Refresh();
  73. }
  74. void LIB_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event )
  75. {
  76. if( GetScreen()->GetUndoCommandCount() <= 0 )
  77. return;
  78. PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST();
  79. LIB_PART* part = GetCurPart();
  80. ITEM_PICKER wrapper( part, UR_LIBEDIT );
  81. lastcmd->PushItem( wrapper );
  82. GetScreen()->PushCommandToRedoList( lastcmd );
  83. lastcmd = GetScreen()->PopCommandFromUndoList();
  84. wrapper = lastcmd->PopItem();
  85. part = (LIB_PART* ) wrapper.GetItem();
  86. // Do not delete the previous part by calling SetCurPart( part ),
  87. // which calls delete <previous part>.
  88. // <previous part> is now put in redo list and is owned by this list.
  89. // Just set the current part to the part which come from the undo list
  90. m_my_part = part;
  91. if( !part )
  92. return;
  93. if( !m_aliasName.IsEmpty() && !part->HasAlias( m_aliasName ) )
  94. m_aliasName = part->GetName();
  95. m_drawItem = NULL;
  96. UpdateAliasSelectList();
  97. UpdatePartSelectList();
  98. SetShowDeMorgan( part->HasConversion() );
  99. DisplayLibInfos();
  100. DisplayCmpDoc();
  101. OnModify();
  102. m_canvas->Refresh();
  103. }