KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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
80 EVT_UPDATE_UI( ID_ON_GRID_SELECT, GERBVIEW_FRAME::OnUpdateSelectGrid )
83 GERBVIEW_FRAME::OnUpdateLayerSelectBox )
85 GERBVIEW_FRAME::OnUpdateDrawMode )
86
87 // Drop files event
88 EVT_DROP_FILES( GERBVIEW_FRAME::OnDropFiles )
89
90END_EVENT_TABLE()
91
92
93void GERBVIEW_FRAME::OnSelectHighlightChoice( wxCommandEvent& event )
94{
95 auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() )->GetSettings();
96
97 switch( event.GetId() )
98 {
100 settings->m_componentHighlightString = m_SelComponentBox->GetStringSelection();
101 break;
102
104 settings->m_netHighlightString = m_SelNetnameBox->GetStringSelection();
105 break;
106
108 settings->m_attributeHighlightString = m_SelAperAttributesBox->GetStringSelection();
109 break;
110
111 }
112
113 GetCanvas()->GetView()->UpdateAllItems( KIGFX::COLOR );
114 GetCanvas()->Refresh();
115}
116
117
118void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event )
119{
120 GERBER_FILE_IMAGE* gerber_image = GetGbrImage( GetActiveLayer() );
121
122 if( gerber_image )
123 {
124 int d_code = m_DCodeSelector->GetSelectedDCodeId();
125
126 auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>(
127 GetCanvas()->GetView()->GetPainter() )->GetSettings();
128 gerber_image->m_Selected_Tool = d_code;
129 settings->m_dcodeHighlightValue = d_code;
130
132 GetCanvas()->Refresh();
133 }
134}
135
136
137void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event )
138{
139 SetActiveLayer( event.GetSelection(), true );
140
141 // Rebuild the DCode list in toolbar (but not the Layer Box) after change
142 syncLayerBox( false );
143
144 // Reinit highlighted dcode
145 auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>
146 ( GetCanvas()->GetView()->GetPainter() )->GetSettings();
147 int dcodeSelected = m_DCodeSelector->GetSelectedDCodeId();
148 settings->m_dcodeHighlightValue = dcodeSelected;
150 GetCanvas()->Refresh();
151}
152
153
154void GERBVIEW_FRAME::OnSelectDisplayMode( wxCommandEvent& event )
155{
156 switch( event.GetId() )
157 {
161 }
162
163 GetCanvas()->Refresh();
164}
165
166
167void GERBVIEW_FRAME::OnQuit( wxCommandEvent& event )
168{
169 Close( true );
170}
171
172
174{
175 // call my base class
177
179
180 wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_LayersManager );
181 pane_info.Caption( _( "Layers Manager" ) );
182 m_auimgr.Update();
183
185}
wxAuiManager m_auimgr
virtual void OnSize(wxSizeEvent &aEvent)
The base class for create windows for drawing purpose.
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
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:1500
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:215
#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
@ COLOR
Color has changed.
Definition: view_item.h:53