KiCad PCB EDA Suite
initpcb.cpp
Go to the documentation of this file.
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 
29 #include <fctsys.h>
30 #include <confirm.h>
31 #include <wxPcbStruct.h>
32 
33 #include <class_board.h>
34 
35 #include <pcbnew.h>
36 #include <module_editor_frame.h>
37 
38 
39 bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery )
40 {
41  if( GetBoard() == NULL )
42  return false;
43 
44  if( aQuery && !GetBoard()->IsEmpty() )
45  {
46  if( !IsOK( this,
47  _( "Current Board will be lost and this operation cannot be undone. Continue ?" ) ) )
48  return false;
49  }
50 
51  // Clear undo and redo lists because we want a full deletion
53  GetScreen()->ClrModify();
54 
55  // Items visibility flags will be set because a new board will be created.
56  // Grid and ratsnest can be left to their previous state
57  bool showGrid = IsElementVisible( LAYER_GRID );
58  bool showRats = IsElementVisible( LAYER_RATSNEST );
59 
60  // delete the old BOARD and create a new BOARD so that the default
61  // layer names are put into the BOARD.
62  SetBoard( new BOARD() );
63  SetElementVisibility( LAYER_GRID, showGrid );
65 
66  SetCurItem( NULL );
67 
68  // clear filename, to avoid overwriting an old file
69  GetBoard()->SetFileName( wxEmptyString );
70 
72 
74 
75  // Enable all layers (SetCopperLayerCount() will adjust the copper layers enabled)
76  GetBoard()->SetEnabledLayers( LSET().set() );
77 
78  // Default copper layers count set to 2: double layer board
80 
81  // Update display (some options depend on the board setup)
82  GetBoard()->SetVisibleLayers( LSET().set() );
86  UpdateTitle();
87 
88  Zoom_Automatique( false );
89 
90  return true;
91 }
92 
93 
95 {
96  if( GetBoard() == NULL )
97  return false;
98 
99  if( aQuery && GetScreen()->IsModify() && !GetBoard()->IsEmpty() )
100  {
101  if( !IsOK( this,
102  _( "Current Footprint will be lost and this operation cannot be undone. Continue ?" ) ) )
103  return false;
104  }
105 
106  // Clear undo and redo lists because we want a full deletion
108  GetScreen()->ClrModify();
109 
110  BOARD* board = new BOARD;
111 
112  // Transfer current design settings
113  if( GetBoard() )
115 
116  SetBoard( board );
117 
118  SetCurItem( NULL );
119 
120  // clear filename, to avoid overwriting an old file
121  GetBoard()->SetFileName( wxEmptyString );
122 
124 
125  Zoom_Automatique( false );
126 
127  return true;
128 }
void UpdateTitle()
Function UpdateTitle sets the main window title bar text.
Definition: pcbframe.cpp:1021
Definition of class FOOTPRINT_EDIT_FRAME.
void SetElementVisibility(GAL_LAYER_ID aElement, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
Definition: pcbframe.cpp:933
BOARD_DESIGN_SETTINGS & GetDesignSettings() const override
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame...
This file is part of the common library.
Class BOARD to handle a board.
bool Clear_Pcb(bool aQuery)
Function Clear_Pcb delete all and reinitialize the current board.
Definition: initpcb.cpp:39
void ResetHighLight()
Function ResetHighLight Reset all high light data to the init state.
Definition: class_board.h:348
void SetCurItem(BOARD_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
void SetCopperLayerCount(int aCount)
void ReCreateLayerBox(bool aForceResizeToolbar=true)
Re create the layer Box by clearing the old list, and building le new one, from the new layers names ...
Definition: tool_pcb.cpp:712
BOARD * GetBoard() const
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:69
void Zoom_Automatique(bool aWarpPointer)
Function Zoom_Automatique redraws the screen with best zoom level and the best centering that shows a...
Definition: zoom.cpp:77
bool IsElementVisible(GAL_LAYER_ID aElement) const
Function IsElementVisible tests whether a given element category is visible.
Definition: pcbframe.cpp:927
bool Clear_Pcb(bool aQuery)
Function Clear_Pcb delete all and reinitialize the current board.
Definition: initpcb.cpp:94
Class LSET is a set of PCB_LAYER_IDs.
void SetVisibleLayers(LSET aLayerMask)
Function SetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
virtual void ClearUndoRedoList()
Function ClearUndoRedoList clear undo and redo list, using ClearUndoORRedoList() picked items are del...
void SetDesignSettings(const BOARD_DESIGN_SETTINGS &aDesignSettings)
Function SetDesignSettings.
Definition: class_board.h:543
void SetFileName(const wxString &aFileName)
Definition: class_board.h:232
void SetBoard(BOARD *aBoard) override
>
Definition: pcbframe.cpp:503
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
virtual void SetBoard(BOARD *aBoard) override
>
PCB_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
const wxSize GetPageSizeIU() const override
Function GetPageSizeIU works off of GetPageSettings() to return the size of the paper page in the int...
void ReFillLayerWidget()
Function ReFillLayerWidget changes out all the layers in m_Layers and may be called upon loading a ne...
Definition: pcbframe.cpp:578
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:111
void SetEnabledLayers(LSET aLayerMask)
Function SetEnabledLayers is a proxy function that calls the correspondent function in m_BoardSetting...
void ReCreateAuxiliaryToolbar() override
Definition: tool_pcb.cpp:544