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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <gerbview.h>
22#include <gerbview_frame.h>
23#include <gerbview_id.h>
24#include <gerber_file_image.h>
27#include <tool/tool_manager.h>
28#include <tool/selection.h>
30#include <gerbview_painter.h>
31#include <view/view.h>
34
35
36// Event table:
37
38BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME )
39 EVT_CLOSE( GERBVIEW_FRAME::OnCloseWindow )
40 EVT_SIZE( GERBVIEW_FRAME::OnSize )
41
42 // Menu Files:
45
47 GERBVIEW_FRAME::OnDrlFileHistory )
49
51 GERBVIEW_FRAME::OnZipFileHistory )
53
55 GERBVIEW_FRAME::OnJobFileHistory )
57
58 EVT_MENU( wxID_EXIT, GERBVIEW_FRAME::OnQuit )
59
60 EVT_COMBOBOX( ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER, GERBVIEW_FRAME::OnSelectActiveLayer )
61
63
64 // Auxiliary horizontal toolbar
65 EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice )
66 EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice )
68 GERBVIEW_FRAME::OnSelectHighlightChoice )
69 EVT_CHOICE( ID_ON_ZOOM_SELECT, GERBVIEW_FRAME::OnSelectZoom )
70 EVT_CHOICE( ID_ON_GRID_SELECT, GERBVIEW_FRAME::OnSelectGrid )
71
72 EVT_UPDATE_UI( ID_ON_GRID_SELECT, GERBVIEW_FRAME::OnUpdateSelectGrid )
73 EVT_UPDATE_UI( ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE, GERBVIEW_FRAME::OnUpdateSelectDCode )
74
75 // Drop files event
76 EVT_DROP_FILES( GERBVIEW_FRAME::OnDropFiles )
77
78END_EVENT_TABLE()
79
80
81void GERBVIEW_FRAME::OnSelectHighlightChoice( wxCommandEvent& event )
82{
83 auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() )->GetSettings();
84
85 switch( event.GetId() )
86 {
87 case ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE:
88 settings->m_componentHighlightString = m_SelComponentBox->GetStringSelection();
89 break;
90
91 case ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE:
92 settings->m_netHighlightString = m_SelNetnameBox->GetStringSelection();
93 break;
94
95 case ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE:
96 settings->m_attributeHighlightString = m_SelAperAttributesBox->GetStringSelection();
97 break;
98
99 }
100
101 GetCanvas()->GetView()->UpdateAllItems( KIGFX::COLOR );
102 GetCanvas()->Refresh();
103}
104
105
106void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event )
107{
108 GERBER_FILE_IMAGE* gerber_image = GetGbrImage( GetActiveLayer() );
109
110 if( gerber_image )
111 {
112 int d_code = m_DCodeSelector->GetSelectedDCodeId();
113
114 auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>(
115 GetCanvas()->GetView()->GetPainter() )->GetSettings();
116 gerber_image->m_Selected_Tool = d_code;
117 settings->m_dcodeHighlightValue = d_code;
118
120 GetCanvas()->Refresh();
121 }
122}
123
124
125void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event )
126{
127 SetActiveLayer( event.GetSelection(), true );
128
129 // Rebuild the DCode list in toolbar (but not the Layer Box) after change
130 syncLayerBox( false );
131
132 // Reinit highlighted dcode
133 auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>
134 ( GetCanvas()->GetView()->GetPainter() )->GetSettings();
135 int dcodeSelected = m_DCodeSelector->GetSelectedDCodeId();
136 settings->m_dcodeHighlightValue = dcodeSelected;
138 GetCanvas()->Refresh();
139}
140
141
142void GERBVIEW_FRAME::OnQuit( wxCommandEvent& event )
143{
144 Close( true );
145}
146
147
149{
150 // call my base class
152
153 m_LayersManager->SetLayersManagerTabsText();
154
155 wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_LayersManager );
156 pane_info.Caption( _( "Layers Manager" ) );
157 m_auimgr.Update();
158
160}
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 OnQuit(wxCommandEvent &event)
Called on request of application quit.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
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.
GERBVIEW_FRAME(KIWAY *aKiway, wxWindow *aParent)
void OnSelectHighlightChoice(wxCommandEvent &event)
Handles the changing of the highlighted component/net/attribute.
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.
virtual GERBVIEW_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition view.cpp:1686
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition view.h:225
#define EVT_SELECT_DCODE
#define _(s)
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:38
@ ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER
Definition gerbview_id.h:41
@ ID_GERBVIEW_DRILL_FILEMAX
Definition gerbview_id.h:49
@ ID_GERBVIEW_JOB_FILE_LIST_CLEAR
Definition gerbview_id.h:56
@ ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE
Definition gerbview_id.h:37
@ ID_GERBVIEW_DRILL_FILE1
Definition gerbview_id.h:48
@ ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE
Definition gerbview_id.h:34
@ ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE
Definition gerbview_id.h:39
@ ID_GERBVIEW_JOB_FILEMAX
Definition gerbview_id.h:55
@ ID_GERBVIEW_ZIP_FILE_LIST_CLEAR
Definition gerbview_id.h:62
@ ID_GERBVIEW_JOB_FILE1
Definition gerbview_id.h:54
@ ID_GERBVIEW_ZIP_FILE1
Definition gerbview_id.h:60
@ ID_GERBVIEW_DRILL_FILE_LIST_CLEAR
Definition gerbview_id.h:50
@ ID_ON_GRID_SELECT
Definition id.h:112
@ ID_FILE_LIST_CLEAR
Definition id.h:58
@ ID_ON_ZOOM_SELECT
Definition id.h:111
@ ID_FILEMAX
Definition id.h:56
@ ID_FILE1
Definition id.h:55
EVT_MENU(ID_COMPARE_PROJECT_BRANCHES, KICAD_MANAGER_FRAME::OnCompareProjectBranches) KICAD_MANAGER_FRAME
@ COLOR
Color has changed.
Definition view_item.h:50