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 <class_drawpanel.h>
32 #include <confirm.h>
33 
34 #include <gerbview_frame.h>
38 
40 {
41  if( GetGerberLayout() == NULL )
42  return false;
43 
44  if( query && GetScreen()->IsModify() )
45  {
46  if( !IsOK( this, _( "Current data will be lost?" ) ) )
47  return false;
48  }
49 
51 
53 
54  setActiveLayer( 0 );
56  syncLayerBox();
57  return true;
58 }
59 
60 
62 {
63  int layer = getActiveLayer();
64  wxString msg;
65 
66  msg.Printf( _( "Clear layer %d?" ), layer + 1 );
67 
68  if( query && !IsOK( this, msg ) )
69  return;
70 
71  SetCurItem( NULL );
72 
73  GetImagesList()->DeleteImage( layer );
74 
76  syncLayerBox();
77  m_canvas->Refresh();
78 }
bool Clear_DrawLayers(bool query)
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:325
void DeleteAllImages()
remove all loaded data in list, and delete all images.
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 SetCurItem(GERBER_DRAW_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
void SetBoundingBox(const EDA_RECT &aBox)
void Erase_Current_DrawLayer(bool query)
virtual BASE_SCREEN * GetScreen() const
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:314
GBR_LAYOUT * GetGerberLayout() const
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Accessors to GERBER_FILE_IMAGE_LIST and GERBER_FILE_IMAGE data.
void setActiveLayer(int aLayer, bool doLayerWidgetUpdate=true)
Function setActiveLayer will change the currently active layer to aLayer and also update the GERBER_L...
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:92
Class EDA_RECT handles the component boundary box.
int getActiveLayer()
Function getActiveLayer returns the active layer.
void DeleteImage(int aIdx)
delete the loaded data of image aIdx.
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:129
void ReFillLayerWidget()
Function ReFillLayerWidget changes out all the layers in m_Layers and may be called upon loading new ...