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.

116 lines
3.0 KiB

++PCBNew * Removed Pcb_Frame argument from BOARD() constructor, since it precludes having a BOARD being edited by more than one editor, it was a bad design. And this meant removing m_PcbFrame from BOARD. * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed, such as dialog_mask_clearance, dialog_drc, etc. * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it with build_version.h's #define BOARD_FILE_VERSION, although there may be a better place for this constant. * Made the public functions in PARAM_CFG_ARRAY be type const. void SaveParam(..) const and void ReadParam(..) const * PARAM_CFG_BASE now has virtual destructor since we have various way of destroying the derived class and boost::ptr_vector must be told about this. * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use an automatic PARAM_CFG_ARRAY which is on the stack.\ * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array, since it has to access the current BOARD and the BOARD can change. Remember BOARD_DESIGN_SETTINGS are now in the BOARD. * Made the m_BoundingBox member private, this was a brutally hard task, and indicative of the lack of commitment to accessors and object oriented design on the part of KiCad developers. We must do better. Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox(). * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
14 years ago
18 years ago
  1. /**
  2. * @file pcbnew/initpcb.cpp
  3. */
  4. #include <fctsys.h>
  5. #include <class_drawpanel.h>
  6. #include <confirm.h>
  7. #include <wxPcbStruct.h>
  8. #include <class_board.h>
  9. #include <pcbnew.h>
  10. #include <module_editor_frame.h>
  11. /**
  12. * Function Clear_Pcb
  13. * delete all and reinitialize the current board
  14. * @param aQuery = true to prompt user for confirmation, false to initialize silently
  15. */
  16. bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery )
  17. {
  18. if( GetBoard() == NULL )
  19. return false;
  20. if( aQuery )
  21. {
  22. if( GetBoard()->m_Drawings || GetBoard()->m_Modules
  23. || GetBoard()->m_Track || GetBoard()->m_Zone )
  24. {
  25. if( !IsOK( this,
  26. _( "Current Board will be lost and this operation cannot be undone. Continue ?" ) ) )
  27. return false;
  28. }
  29. }
  30. // Clear undo and redo lists because we want a full deletion
  31. GetScreen()->ClearUndoRedoList();
  32. /* Items visibility flags will be set becuse a new board will be created.
  33. * Grid and ratsnest can be left to their previous state
  34. */
  35. bool showGrid = IsElementVisible( GRID_VISIBLE );
  36. bool showRats = IsElementVisible( RATSNEST_VISIBLE );
  37. // delete the old BOARD and create a new BOARD so that the default
  38. // layer names are put into the BOARD.
  39. SetBoard( new BOARD() );
  40. SetElementVisibility( GRID_VISIBLE, showGrid );
  41. SetElementVisibility( RATSNEST_VISIBLE, showRats );
  42. SetCurItem( NULL );
  43. // clear filename, to avoid overwriting an old file
  44. GetBoard()->SetFileName( wxEmptyString );
  45. // preserve grid size accross call to InitDataPoints()
  46. // wxRealPoint gridsize = GetScreen()->GetGridSize();
  47. GetScreen()->InitDataPoints( GetPageSizeIU() );
  48. // GetScreen()->SetGrid( gridsize );
  49. GetBoard()->ResetHighLight();
  50. // Enable all layers (SetCopperLayerCount() will adjust the copper layers enabled)
  51. GetBoard()->SetEnabledLayers( ALL_LAYERS );
  52. // Default copper layers count set to 2: double layer board
  53. GetBoard()->SetCopperLayerCount( 2 );
  54. // Update display:
  55. GetBoard()->SetVisibleLayers( ALL_LAYERS );
  56. ReFillLayerWidget();
  57. Zoom_Automatique( false );
  58. return true;
  59. }
  60. bool FOOTPRINT_EDIT_FRAME::Clear_Pcb( bool aQuery )
  61. {
  62. if( GetBoard() == NULL )
  63. return false;
  64. if( aQuery && GetScreen()->IsModify() )
  65. {
  66. if( GetBoard()->m_Modules )
  67. {
  68. if( !IsOK( this,
  69. _( "Current Footprint will be lost and this operation cannot be undone. Continue ?" ) ) )
  70. return false;
  71. }
  72. }
  73. // Clear undo and redo lists
  74. GetScreen()->ClearUndoRedoList();
  75. // Delete the current footprint
  76. GetBoard()->m_Modules.DeleteAll();
  77. // init pointeurs et variables
  78. GetBoard()->SetFileName( wxEmptyString );
  79. SetCurItem( NULL );
  80. // preserve grid size accross call to InitDataPoints()
  81. // wxRealPoint gridsize = GetScreen()->GetGridSize();
  82. GetScreen()->InitDataPoints( GetPageSizeIU() );
  83. // GetScreen()->SetGrid( gridsize );
  84. Zoom_Automatique( false );
  85. return true;
  86. }