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-2021 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>
29 #include <gerber_file_image_list.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 
42 BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME )
43  EVT_CLOSE( GERBVIEW_FRAME::OnCloseWindow )
44  EVT_SIZE( GERBVIEW_FRAME::OnSize )
45 
46  // Menu Files:
49 
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 END_EVENT_TABLE()
88 
89 
90 void GERBVIEW_FRAME::OnSelectHighlightChoice( wxCommandEvent& event )
91 {
92  auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() )->GetSettings();
93 
94  switch( event.GetId() )
95  {
97  settings->m_componentHighlightString = m_SelComponentBox->GetStringSelection();
98  break;
99 
101  settings->m_netHighlightString = m_SelNetnameBox->GetStringSelection();
102  break;
103 
105  settings->m_attributeHighlightString = m_SelAperAttributesBox->GetStringSelection();
106  break;
107 
108  }
109 
110  GetCanvas()->GetView()->UpdateAllItems( KIGFX::COLOR );
111  GetCanvas()->Refresh();
112 }
113 
114 
115 void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event )
116 {
117  GERBER_FILE_IMAGE* gerber_image = GetGbrImage( GetActiveLayer() );
118 
119  if( gerber_image )
120  {
121  int d_code = m_DCodeSelector->GetSelectedDCodeId();
122 
123  auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>(
124  GetCanvas()->GetView()->GetPainter() )->GetSettings();
125  gerber_image->m_Selected_Tool = d_code;
126  settings->m_dcodeHighlightValue = d_code;
127 
129  GetCanvas()->Refresh();
130  }
131 }
132 
133 
134 void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event )
135 {
136  SetActiveLayer( event.GetSelection(), true );
137 
138  // Rebuild the DCode list in toolbar (but not the Layer Box) after change
139  syncLayerBox( false );
140 
141  // Reinit highlighted dcode
142  auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>
143  ( GetCanvas()->GetView()->GetPainter() )->GetSettings();
144  int dcodeSelected = m_DCodeSelector->GetSelectedDCodeId();
145  settings->m_dcodeHighlightValue = dcodeSelected;
147  GetCanvas()->Refresh();
148 }
149 
150 
151 void GERBVIEW_FRAME::OnSelectDisplayMode( wxCommandEvent& event )
152 {
153  switch( event.GetId() )
154  {
158  }
159 
160  GetCanvas()->Refresh();
161 }
162 
163 
164 void GERBVIEW_FRAME::OnQuit( wxCommandEvent& event )
165 {
166  Close( true );
167 }
168 
169 
171 {
172  // call my base class
174 
176 
177  wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_LayersManager );
178  pane_info.Caption( _( "Layers Manager" ) );
179  m_auimgr.Update();
180 
182 }
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.
Definition: id.h:87
EVT_UPDATE_UI(ID_LOAD_FOOTPRINT_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard) EVT_UPDATE_UI(ID_ADD_FOOTPRINT_TO_BOARD
void OnQuit(wxCommandEvent &event)
Called on request of application quit.
void OnClearDrlFileHistory(wxCommandEvent &aEvent)
GERBER_LAYER_WIDGET * m_LayersManager
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1430
Hold the image data and parameters for one gerber file and layer parameters.
void SetActiveLayer(int aLayer, bool doLayerWidgetUpdate=true)
change the currently active layer to aLayer and update the GERBER_LAYER_WIDGET.
void OnGbrFileHistory(wxCommandEvent &event)
Delete the current data and loads a Gerber file selected from history list on current layer.
GERBVIEW_FRAME::OnZipFileHistory ID_TB_OPTIONS_SHOW_GBR_MODE_2
wxAuiManager m_auimgr
Color has changed.
Definition: view_item.h:53
The base class for create windows for drawing purpose.
void OnSelectActiveDCode(wxCommandEvent &event)
Select the active DCode for the current active layer.
void OnSelectDisplayMode(wxCommandEvent &event)
Called on a display mode selection.
void SetLayersManagerTabsText()
Update the layer manager tabs labels.
EVT_MENU_RANGE(ID_GERBVIEW_DRILL_FILE1, ID_GERBVIEW_DRILL_FILEMAX, GERBVIEW_FRAME::OnDrlFileHistory) EVT_MENU_RANGE(ID_GERBVIEW_ZIP_FILE1
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
virtual void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
GERBER_FILE_IMAGE * GetGbrImage(int aIdx) const
void ShowChangedLanguage() override
#define _(s)
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
void OnClearGbrFileHistory(wxCommandEvent &aEvent)
#define EVT_SELECT_DCODE
DCODE_SELECTION_BOX * m_DCodeSelector
int GetActiveLayer() const
Return the active layer.
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...
void OnDrlFileHistory(wxCommandEvent &event)
Delete the current data and load a drill file in Excellon format selected from history list on curren...
Definition: id.h:86
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_TOOL_RANGE(ID_START_COMMAND_3D, ID_MENU_COMMAND_END, EDA_3D_VIEWER_FRAME::Process_Special_Functions) EDA_3D_VIEWER_FRAME
void ReFillLayerWidget()
Change out all the layers in m_Layers; called upon loading new gerber files.
void OnSelectActiveLayer(wxCommandEvent &event)
Select the active layer:
void SetDisplayMode(int aMode)