KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <confirm.h>
22#include <lset.h>
23#include <pcb_edit_frame.h>
24#include <project.h>
25#include <tool/tool_manager.h>
28
29#include <board.h>
32
35#include <drc/drc_item.h>
36
37
38bool PCB_EDIT_FRAME::Clear_Pcb( bool doAskAboutUnsavedChanges, bool aFinal )
39{
40 if( GetBoard() == nullptr )
41 return false;
42
44 return false;
45
46 if( doAskAboutUnsavedChanges && !GetBoard()->IsEmpty() )
47 {
48 if( !IsOK( this, _( "Current Board will be lost and this operation cannot be undone. "
49 "Continue?" ) ) )
50 {
51 return false;
52 }
53 }
54
55 // Release the lock file, if exists
57
58 // Clear undo and redo lists because we want a full deletion
60 GetScreen()->SetContentModified( false );
61
62 if( !aFinal )
63 {
64 // delete the old BOARD and create a new BOARD so that the default
65 // layer names are put into the BOARD.
66 SetBoard( new BOARD() );
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 // Default user defined layers count set to 4
83
84 // Update display (some options depend on the board setup)
85 GetBoard()->SetVisibleLayers( LSET().set() );
88 m_appearancePanel->OnBoardChanged();
90
91 Zoom_Automatique( false );
92 }
93 else if( m_isClosing )
94 {
95 if( m_toolManager )
97
98 // Clear the view so we don't attempt redraws (particularly of the RATSNEST_VIEW_ITEM,
99 // which causes all manner of grief).
100 GetCanvas()->GetView()->Clear();
101 }
102
103 return true;
104}
105
106
108{
109 if( GetBoard() == nullptr )
110 return;
111
112 m_boardFootprintUuids.clear();
113
114 // ClearUndoRedoList frees only the wrappers, leaking the tab history's transient item copies.
116
117 GetScreen()->SetContentModified( false );
118
119 // Clear the view so we don't attempt redraws
120 GetCanvas()->GetView()->Clear();
121
122 if( !m_isClosing )
123 {
124 BOARD* newBoard = new BOARD;
125
127 newBoard->GetDesignSettings() = cfg->m_DesignSettings;
128
129 newBoard->SynchronizeNetsAndNetClasses( true );
130
131 // This board will only be used to hold a footprint for editing
132 newBoard->SetBoardUse( BOARD_USE::FPHOLDER );
133
134 // Setup our own severities for the Footprint Checker.
135 // These are not (at present) user-editable.
136 std::map<int, SEVERITY>& drcSeverities = newBoard->GetDesignSettings().m_DRCSeverities;
137
138 for( int errorCode = DRCE_FIRST; errorCode <= DRCE_LAST; ++errorCode )
139 drcSeverities[ errorCode ] = RPT_SEVERITY_ERROR;
140
143
144 drcSeverities[ DRCE_PADSTACK ] = RPT_SEVERITY_WARNING;
145
147
148 // clear filename, to avoid overwriting an old file
149 newBoard->SetFileName( wxEmptyString );
150
151 // Install newBoard before freeing the tab-owned boards so nothing aliased is deleted.
152 detachTabsForFullClear( newBoard );
153
155 }
156 else
157 {
158 if( m_toolManager )
160 }
161}
@ FPHOLDER
Definition board.h:401
void SetContentModified(bool aModified=true)
Definition base_screen.h:55
void InitDataPoints(const VECTOR2I &aPageSizeInternalUnits)
std::map< int, SEVERITY > m_DRCSeverities
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:409
void SetVisibleLayers(const LSET &aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition board.cpp:1216
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition board.h:421
void SetFileName(const wxString &aFileName)
Definition board.h:450
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition board.cpp:3402
void ResetNetHighLight()
Reset all high light data to the init state.
Definition board.cpp:4047
void SetCopperLayerCount(int aCount)
Definition board.cpp:1137
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition board.cpp:1299
void SetEnabledLayers(const LSET &aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
Definition board.cpp:1203
void SetUserDefinedLayerCount(int aCount)
Definition board.cpp:1153
UNDO_REDO_CONTAINER m_undoList
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
UNDO_REDO_CONTAINER m_redoList
bool m_isClosing
Set by the close window event handler after frames are asked if they can close.
void ReleaseFile()
Release the current file marked in use.
virtual void Zoom_Automatique(bool aWarpPointer)
Redraw the screen with best zoom level and the best centering that shows all the page or the board.
void detachTabsForFullClear(BOARD *aReplacement)
Install aReplacement as the active document non-destructively, then drop every tab context and free t...
void Clear_Pcb()
Delete all and reinitialize the current board.
Definition initpcb.cpp:107
std::map< KIID, KIID > m_boardFootprintUuids
FOOTPRINT_EDITOR_SETTINGS * GetSettings()
void freeUndoRedoCommandsWithItems(UNDO_REDO_CONTAINER &aUndo, UNDO_REDO_CONTAINER &aRedo)
Free both the transient board items and the command wrappers in the given lists.
void Clear()
Remove all items from the view.
Definition view.cpp:1234
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
APPEARANCE_CONTROLS * m_appearancePanel
const VECTOR2I GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
BOARD * GetBoard() const
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void SetBoard(BOARD *aBoard, PROGRESS_REPORTER *aReporter=nullptr) override
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
bool CloseFootprintFieldsTableDialog()
void ReCreateLayerBox(bool aForceResizeToolbar=true)
Recreate the layer box by clearing the old list and building a new one from the new layer names and c...
bool Clear_Pcb(bool doAskAboutUnsavedChanges, bool aFinal=false)
Delete all and reinitialize the current board.
Definition initpcb.cpp:38
void ReCreateAuxiliaryToolbar() override
void UpdateTitle()
Set the main window title bar text.
TOOL_MANAGER * m_toolManager
@ SHUTDOWN
Tool is being shut down.
Definition tool_base.h:80
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition tool_base.h:76
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition confirm.cpp:274
This file is part of the common library.
@ DRCE_PADSTACK
Definition drc_item.h:60
@ DRCE_DRILLED_HOLES_TOO_CLOSE
Definition drc_item.h:50
@ DRCE_FIRST
Definition drc_item.h:36
@ DRCE_FOOTPRINT_TYPE_MISMATCH
Definition drc_item.h:84
@ DRCE_DRILLED_HOLES_COLOCATED
Definition drc_item.h:51
@ DRCE_LAST
Definition drc_item.h:131
#define _(s)
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR