KiCad PCB EDA Suite
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 (C) 1992-2016 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 
30 #include <fctsys.h>
31 #include <confirm.h>
32 #include <gerbview_frame.h>
33 #include <gerber_file_image.h>
34 #include <gerber_file_image_list.h>
35 #include <gerbview_layer_widget.h>
36 #include <view/view.h>
37 #include <base_screen.h>
38 
39 #include <tool/tool_manager.h>
40 
42 {
43  if( GetGerberLayout() == NULL )
44  return false;
45 
46  if( query && GetScreen()->IsModify() )
47  {
48  if( !IsOK( this, _( "Current data will be lost?" ) ) )
49  return false;
50  }
51 
52  if( GetCanvas() )
53  {
54  if( m_toolManager )
56 
57  GetCanvas()->GetView()->Clear();
58 
59  // Reinit the worksheet view, cleared by GetView()->Clear():
61  }
62 
64 
66 
67  SetActiveLayer( 0 );
69  syncLayerBox();
70  return true;
71 }
72 
73 
75 {
76  int layer = GetActiveLayer();
77  wxString msg;
78 
79  msg.Printf( _( "Clear layer %d?" ), layer + 1 );
80 
81  if( query && !IsOK( this, msg ) )
82  return;
83 
84  if( m_toolManager )
86 
87  GetImagesList()->DeleteImage( layer );
88 
90  syncLayerBox();
91  GetCanvas()->Refresh();
92 }
bool Clear_DrawLayers(bool query)
void DeleteAllImages()
remove all loaded data in list, and delete all images.
Model changes (required full reload)
Definition: tool_base.h:82
This file is part of the common library.
void syncLayerBox(bool aRebuildLayerBox=false)
Function syncLayerBox updates the currently "selected" layer within m_SelLayerBox The currently activ...
void SetPageSettings(const PAGE_INFO &aPageSettings) override
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
void SetActiveLayer(int aLayer, bool doLayerWidgetUpdate=true)
Function SetActiveLayer will change the currently active layer to aLayer and update the GERBER_LAYER_...
void SetBoundingBox(const EDA_RECT &aBox)
Definition: gbr_layout.h:88
void Erase_Current_DrawLayer(bool query)
#define NULL
void Clear()
Function Clear() Removes all items from the view.
Definition: view.cpp:1111
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Function ResetTools() Resets all tools (i.e.
virtual KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
GBR_LAYOUT * GetGerberLayout() const
const PAGE_INFO & GetPageSettings() const override
int GetActiveLayer() const
Function SetActiveLayer returns the active layer.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:48
#define _(s)
Definition: 3d_actions.cpp:33
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
void DeleteImage(int aIdx)
delete the loaded data of image aIdx.
BASE_SCREEN class implementation.
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Accessors to GERBER_FILE_IMAGE_LIST and GERBER_FILE_IMAGE data.
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:283
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
void ReFillLayerWidget()
Function ReFillLayerWidget changes out all the layers in m_Layers; called upon loading new gerber fil...