KiCad PCB EDA Suite
events_called_functions.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) 2011-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
5 * Copyright (C) 1992-2022 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
25#include <gerbview.h>
26#include <gerbview_frame.h>
27#include <gerbview_id.h>
28#include <gerber_file_image.h>
31#include <tool/tool_manager.h>
32#include <tool/selection.h>
34#include <gerbview_painter.h>
35#include <view/view.h>
38
39
40// Event table:
41
42BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME )
43 EVT_CLOSE( GERBVIEW_FRAME::OnCloseWindow )
44 EVT_SIZE( GERBVIEW_FRAME::OnSize )
45
46 // Menu Files:
49
51 GERBVIEW_FRAME::OnDrlFileHistory )
52 EVT_MENU( ID_GERBVIEW_DRILL_FILE_LIST_CLEAR, GERBVIEW_FRAME::OnClearDrlFileHistory )
53
55 GERBVIEW_FRAME::OnZipFileHistory )
56 EVT_MENU( ID_GERBVIEW_ZIP_FILE_LIST_CLEAR, GERBVIEW_FRAME::OnClearZipFileHistory )
57
59 GERBVIEW_FRAME::OnJobFileHistory )
60 EVT_MENU( ID_GERBVIEW_JOB_FILE_LIST_CLEAR, GERBVIEW_FRAME::OnClearJobFileHistory )
61
62 EVT_MENU( wxID_EXIT, GERBVIEW_FRAME::OnQuit )
63
64 EVT_COMBOBOX( ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER, GERBVIEW_FRAME::OnSelectActiveLayer )
65
67
68 // Option toolbar
70 GERBVIEW_FRAME::OnSelectDisplayMode )
71
72 // Auxiliary horizontal toolbar
76 GERBVIEW_FRAME::OnSelectHighlightChoice )
79 EVT_MENU( ID_GRID_SETTINGS, GERBVIEW_FRAME::OnGridSettings )
80
81 EVT_UPDATE_UI( ID_ON_GRID_SELECT, GERBVIEW_FRAME::OnUpdateSelectGrid )
84 GERBVIEW_FRAME::OnUpdateLayerSelectBox )
86 GERBVIEW_FRAME::OnUpdateDrawMode )
87
88 // Drop files event
89 EVT_DROP_FILES( GERBVIEW_FRAME::OnDropFiles )
90
91END_EVENT_TABLE()
92
93
94void GERBVIEW_FRAME::OnSelectHighlightChoice( wxCommandEvent& event )
95{
96 auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() )->GetSettings();
97
98 switch( event.GetId() )
99 {
101 settings->m_componentHighlightString = m_SelComponentBox->GetStringSelection();
102 break;
103
105 settings->m_netHighlightString = m_SelNetnameBox->GetStringSelection();
106 break;
107
109 settings->m_attributeHighlightString = m_SelAperAttributesBox->GetStringSelection();
110 break;
111
112 }
113
114 GetCanvas()->GetView()->UpdateAllItems( KIGFX::COLOR );
115 GetCanvas()->Refresh();
116}
117
118
119void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event )
120{
121 GERBER_FILE_IMAGE* gerber_image = GetGbrImage( GetActiveLayer() );
122
123 if( gerber_image )
124 {
125 int d_code = m_DCodeSelector->GetSelectedDCodeId();
126
127 auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>(
128 GetCanvas()->GetView()->GetPainter() )->GetSettings();
129 gerber_image->m_Selected_Tool = d_code;
130 settings->m_dcodeHighlightValue = d_code;
131
133 GetCanvas()->Refresh();
134 }
135}
136
137
138void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event )
139{
140 SetActiveLayer( event.GetSelection(), true );
141
142 // Rebuild the DCode list in toolbar (but not the Layer Box) after change
143 syncLayerBox( false );
144
145 // Reinit highlighted dcode
146 auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>
147 ( GetCanvas()->GetView()->GetPainter() )->GetSettings();
148 int dcodeSelected = m_DCodeSelector->GetSelectedDCodeId();
149 settings->m_dcodeHighlightValue = dcodeSelected;
151 GetCanvas()->Refresh();
152}
153
154
155void GERBVIEW_FRAME::OnSelectDisplayMode( wxCommandEvent& event )
156{
157 switch( event.GetId() )
158 {
162 }
163
164 GetCanvas()->Refresh();
165}
166
167
168void GERBVIEW_FRAME::OnQuit( wxCommandEvent& event )
169{
170 Close( true );
171}
172
173
175{
176 // call my base class
178
180
181 wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_LayersManager );
182 pane_info.Caption( _( "Layers Manager" ) );
183 m_auimgr.Update();
184
186}
wxAuiManager m_auimgr
The base class for create windows for drawing purpose.
virtual void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
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
Update the board display after modifying it by a python script (note: it is automatically called by a...
Hold the image data and parameters for one gerber file and layer parameters.
void SetLayersManagerTabsText()
Update the layer manager tabs labels.
void OnQuit(wxCommandEvent &event)
Called on request of application quit.
void ShowChangedLanguage() override
void syncLayerBox(bool aRebuildLayerBox=false)
Update the currently "selected" layer within m_SelLayerBox.
int GetActiveLayer() const
Return the active layer.
DCODE_SELECTION_BOX * m_DCodeSelector
GERBER_LAYER_WIDGET * m_LayersManager
void SetActiveLayer(int aLayer, bool doLayerWidgetUpdate=true)
change the currently active layer to aLayer and update the GERBER_LAYER_WIDGET.
GERBER_FILE_IMAGE * GetGbrImage(int aIdx) const
void SetDisplayMode(int aMode)
void OnSelectActiveLayer(wxCommandEvent &event)
Select the active layer:
void ReFillLayerWidget()
Change out all the layers in m_Layers; called upon loading new gerber files.
void OnSelectDisplayMode(wxCommandEvent &event)
Called on a display mode selection.
void OnClearGbrFileHistory(wxCommandEvent &aEvent)
void OnSelectActiveDCode(wxCommandEvent &event)
Select the active DCode for the current active layer.
void OnGbrFileHistory(wxCommandEvent &event)
Delete the current data and loads a Gerber file selected from history list on current layer.
Methods for drawing GerbView specific items.
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1479
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:213
#define EVT_SELECT_DCODE
#define _(s)
EVT_TOOL_RANGE(ID_START_COMMAND_3D, ID_MENU_COMMAND_END, EDA_3D_VIEWER_FRAME::Process_Special_Functions) EDA_3D_VIEWER_FRAME
GERBVIEW_FRAME::OnZipFileHistory ID_TB_OPTIONS_SHOW_GBR_MODE_2
GERBVIEW_FRAME::OnZipFileHistory GERBVIEW_FRAME::OnSelectDisplayMode GERBVIEW_FRAME::OnUpdateLayerSelectBox EVT_UPDATE_UI_RANGE(ID_TB_OPTIONS_SHOW_GBR_MODE_0, ID_TB_OPTIONS_SHOW_GBR_MODE_2, GERBVIEW_FRAME::OnUpdateDrawMode) void GERBVIEW_FRAME
GERBVIEW_FRAME::OnZipFileHistory GERBVIEW_FRAME::OnSelectDisplayMode EVT_CHOICE(ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice) EVT_UPDATE_UI(ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER
EVT_MENU_RANGE(ID_GERBVIEW_DRILL_FILE1, ID_GERBVIEW_DRILL_FILEMAX, GERBVIEW_FRAME::OnDrlFileHistory) EVT_MENU_RANGE(ID_GERBVIEW_ZIP_FILE1
EVT_UPDATE_UI(ID_LOAD_FOOTPRINT_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard) EVT_UPDATE_UI(ID_ADD_FOOTPRINT_TO_BOARD
@ ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE
Definition: gerbview_id.h:44
@ ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER
Definition: gerbview_id.h:47
@ ID_GERBVIEW_DRILL_FILEMAX
Definition: gerbview_id.h:55
@ ID_GERBVIEW_JOB_FILE_LIST_CLEAR
Definition: gerbview_id.h:62
@ ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE
Definition: gerbview_id.h:43
@ ID_GERBVIEW_DRILL_FILE1
Definition: gerbview_id.h:54
@ ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE
Definition: gerbview_id.h:40
@ ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE
Definition: gerbview_id.h:45
@ ID_GERBVIEW_JOB_FILEMAX
Definition: gerbview_id.h:61
@ ID_GERBVIEW_ZIP_FILE_LIST_CLEAR
Definition: gerbview_id.h:68
@ ID_TB_OPTIONS_SHOW_GBR_MODE_1
Definition: gerbview_id.h:49
@ ID_TB_OPTIONS_SHOW_GBR_MODE_0
Definition: gerbview_id.h:48
@ ID_GERBVIEW_JOB_FILE1
Definition: gerbview_id.h:60
@ ID_GERBVIEW_ZIP_FILE1
Definition: gerbview_id.h:66
@ ID_GERBVIEW_DRILL_FILE_LIST_CLEAR
Definition: gerbview_id.h:56
@ ID_ON_GRID_SELECT
Definition: id.h:145
@ ID_FILE_LIST_CLEAR
Definition: id.h:87
@ ID_ON_ZOOM_SELECT
Definition: id.h:143
@ ID_FILEMAX
Definition: id.h:85
@ ID_FILE1
Definition: id.h:84
@ ID_GRID_SETTINGS
Definition: id.h:146
@ COLOR
Color has changed.
Definition: view_item.h:48