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 // Auxiliary horizontal toolbar
69 EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice )
70 EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice )
72 GERBVIEW_FRAME::OnSelectHighlightChoice )
73 EVT_CHOICE( ID_ON_ZOOM_SELECT, GERBVIEW_FRAME::OnSelectZoom )
74 EVT_CHOICE( ID_ON_GRID_SELECT, GERBVIEW_FRAME::OnSelectGrid )
75
76 EVT_UPDATE_UI( ID_ON_GRID_SELECT, GERBVIEW_FRAME::OnUpdateSelectGrid )
79 GERBVIEW_FRAME::OnUpdateLayerSelectBox )
80
81 // Drop files event
82 EVT_DROP_FILES( GERBVIEW_FRAME::OnDropFiles )
83
84END_EVENT_TABLE()
85
86
87void GERBVIEW_FRAME::OnSelectHighlightChoice( wxCommandEvent& event )
88{
89 auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() )->GetSettings();
90
91 switch( event.GetId() )
92 {
94 settings->m_componentHighlightString = m_SelComponentBox->GetStringSelection();
95 break;
96
98 settings->m_netHighlightString = m_SelNetnameBox->GetStringSelection();
99 break;
100
102 settings->m_attributeHighlightString = m_SelAperAttributesBox->GetStringSelection();
103 break;
104
105 }
106
107 GetCanvas()->GetView()->UpdateAllItems( KIGFX::COLOR );
108 GetCanvas()->Refresh();
109}
110
111
112void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event )
113{
114 GERBER_FILE_IMAGE* gerber_image = GetGbrImage( GetActiveLayer() );
115
116 if( gerber_image )
117 {
118 int d_code = m_DCodeSelector->GetSelectedDCodeId();
119
120 auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>(
121 GetCanvas()->GetView()->GetPainter() )->GetSettings();
122 gerber_image->m_Selected_Tool = d_code;
123 settings->m_dcodeHighlightValue = d_code;
124
126 GetCanvas()->Refresh();
127 }
128}
129
130
131void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event )
132{
133 SetActiveLayer( event.GetSelection(), true );
134
135 // Rebuild the DCode list in toolbar (but not the Layer Box) after change
136 syncLayerBox( false );
137
138 // Reinit highlighted dcode
139 auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>
140 ( GetCanvas()->GetView()->GetPainter() )->GetSettings();
141 int dcodeSelected = m_DCodeSelector->GetSelectedDCodeId();
142 settings->m_dcodeHighlightValue = dcodeSelected;
144 GetCanvas()->Refresh();
145}
146
147
148void GERBVIEW_FRAME::OnQuit( wxCommandEvent& event )
149{
150 Close( true );
151}
152
153
155{
156 // call my base class
158
160
161 wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_LayersManager );
162 pane_info.Caption( _( "Layers Manager" ) );
163 m_auimgr.Update();
164
166}
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 OnSelectActiveLayer(wxCommandEvent &event)
Select the active layer:
void ReFillLayerWidget()
Change out all the layers in m_Layers; called upon loading new gerber files.
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:1545
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:217
#define EVT_SELECT_DCODE
#define _(s)
GERBVIEW_FRAME::OnZipFileHistory GERBVIEW_FRAME::OnSelectHighlightChoice EVT_UPDATE_UI(ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER, GERBVIEW_FRAME::OnUpdateLayerSelectBox) void GERBVIEW_FRAME
EVT_MENU_RANGE(ID_GERBVIEW_DRILL_FILE1, ID_GERBVIEW_DRILL_FILEMAX, GERBVIEW_FRAME::OnDrlFileHistory) EVT_MENU_RANGE(ID_GERBVIEW_ZIP_FILE1
@ 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_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:86
@ ID_ON_ZOOM_SELECT
Definition: id.h:143
@ ID_FILEMAX
Definition: id.h:84
@ ID_FILE1
Definition: id.h:83
@ COLOR
Color has changed.
Definition: view_item.h:53