KiCad PCB EDA Suite
Loading...
Searching...
No Matches
clear_gbr_drawlayers.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) 2016 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
25
26#include <confirm.h>
27#include <gerbview_frame.h>
28#include <gerber_file_image.h>
30#include <view/view.h>
31#include <base_screen.h>
33
34#include <tool/tool_manager.h>
35
37{
38 if( GetGerberLayout() == nullptr )
39 return false;
40
41 if( query && GetScreen()->IsContentModified() )
42 {
43 if( !IsOK( this, _( "Current data will be lost?" ) ) )
44 return false;
45 }
46
47 if( GetCanvas() )
48 {
49 if( m_toolManager )
51
52 GetCanvas()->GetView()->Clear();
53
54 // Reinit the drawing-sheet view, cleared by GetView()->Clear():
56 }
57
59
61
62 SetActiveLayer( 0 );
65 return true;
66}
67
68
70{
71 int layer = GetActiveLayer();
72 wxString msg;
73
74 msg.Printf( _( "Clear layer %d?" ), layer + 1 );
75
76 if( query && !IsOK( this, msg ) )
77 return;
78
79 if( m_toolManager )
81
82 RemapLayers( GetImagesList()->RemoveImage( layer ) );
83
86 GetCanvas()->Refresh();
87}
BASE_SCREEN class implementation.
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
virtual bool IsContentModified() const
Get if the contents of the frame have been modified since the last save.
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
void SetBoundingBox(const BOX2I &aBox)
May be re-implemented for each derived class in order to handle all the types given by its member dat...
Definition gbr_layout.h:74
void DeleteAllImages()
Remove all loaded data in list, and delete all images, freeing the memory.
const PAGE_INFO & GetPageSettings() const override
void SetPageSettings(const PAGE_INFO &aPageSettings) override
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Accessors to GERBER_FILE_IMAGE_LIST and GERBER_FILE_IMAGE data.
void syncLayerBox(bool aRebuildLayerBox=false)
Update the currently "selected" layer within m_SelLayerBox.
GBR_LAYOUT * GetGerberLayout() const
int GetActiveLayer() const
Return the active layer.
void SetActiveLayer(int aLayer, bool doLayerWidgetUpdate=true)
change the currently active layer to aLayer and update the GERBER_LAYER_WIDGET.
bool Clear_DrawLayers(bool query)
void RemapLayers(const std::unordered_map< int, int > &remapping)
Takes a layer remapping and reorders the layers.
void ReFillLayerWidget()
Change out all the layers in m_Layers; called upon loading new gerber files.
void Erase_Current_DrawLayer(bool query)
void Clear()
Remove all items from the view.
Definition view.cpp:1218
TOOL_MANAGER * m_toolManager
@ 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.
#define _(s)