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.

130 lines
3.9 KiB

18 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2007-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 pcbnew/initpcb.cpp
  26. */
  27. #include <fctsys.h>
  28. #include <confirm.h>
  29. #include <pcb_edit_frame.h>
  30. #include <project.h>
  31. #include <project/net_settings.h>
  32. #include <project/project_file.h>
  33. #include <class_board.h>
  34. #include <pcbnew.h>
  35. #include <footprint_edit_frame.h>
  36. #include <widgets/appearance_controls.h>
  37. bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery, bool aFinal )
  38. {
  39. if( GetBoard() == NULL )
  40. return false;
  41. if( aQuery && !GetBoard()->IsEmpty() )
  42. {
  43. if( !IsOK( this,
  44. _( "Current Board will be lost and this operation cannot be undone. Continue?" ) ) )
  45. return false;
  46. }
  47. // Release the lock file, if exists
  48. ReleaseFile();
  49. // Clear undo and redo lists because we want a full deletion
  50. ClearUndoRedoList();
  51. GetScreen()->ClrModify();
  52. if( !aFinal )
  53. {
  54. // delete the old BOARD and create a new BOARD so that the default
  55. // layer names are put into the BOARD.
  56. SetBoard( new BOARD() );
  57. // clear filename, to avoid overwriting an old file
  58. GetBoard()->SetFileName( wxEmptyString );
  59. GetScreen()->InitDataPoints( GetPageSizeIU() );
  60. GetBoard()->ResetNetHighLight();
  61. // Enable all layers (SetCopperLayerCount() will adjust the copper layers enabled)
  62. GetBoard()->SetEnabledLayers( LSET().set() );
  63. // Default copper layers count set to 2: double layer board
  64. GetBoard()->SetCopperLayerCount( 2 );
  65. // Update display (some options depend on the board setup)
  66. GetBoard()->SetVisibleLayers( LSET().set() );
  67. ReCreateLayerBox();
  68. ReCreateAuxiliaryToolbar();
  69. m_appearancePanel->OnBoardChanged();
  70. UpdateTitle();
  71. Zoom_Automatique( false );
  72. }
  73. return true;
  74. }
  75. bool FOOTPRINT_EDIT_FRAME::Clear_Pcb( bool aQuery )
  76. {
  77. if( GetBoard() == NULL )
  78. return false;
  79. if( aQuery && IsContentModified() )
  80. {
  81. wxSafeYield( this, true ); // Allow frame to come to front before showing warning.
  82. if( !HandleUnsavedChanges( this, _( "The current footprint has been modified. "
  83. "Save changes?" ),
  84. [&]() -> bool { return SaveFootprint( GetBoard()->Modules().front() ); } ) )
  85. {
  86. return false;
  87. }
  88. }
  89. // Clear undo and redo lists because we want a full deletion
  90. ClearUndoRedoList();
  91. GetScreen()->ClrModify();
  92. BOARD* board = new BOARD;
  93. board->GetDesignSettings() = GetDesignSettings();
  94. board->SynchronizeNetsAndNetClasses();
  95. SetBoard( board );
  96. // clear filename, to avoid overwriting an old file
  97. GetBoard()->SetFileName( wxEmptyString );
  98. GetScreen()->InitDataPoints( GetPageSizeIU() );
  99. Zoom_Automatique( false );
  100. return true;
  101. }