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 <pgm_base.h>
26 #include <gerbview.h>
27 #include <gerbview_frame.h>
28 #include <gerbview_id.h>
29 #include <gerber_file_image.h>
30 #include <gerber_file_image_list.h>
31 #include <dialog_helpers.h>
33 #include <tool/tool_manager.h>
34 #include <tool/selection.h>
36 #include <gerbview_painter.h>
37 #include <view/view.h>
40 
41 
42 // Event table:
43 
44 BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME )
45  EVT_CLOSE( GERBVIEW_FRAME::OnCloseWindow )
46  EVT_SIZE( GERBVIEW_FRAME::OnSize )
47 
48  // Menu Files:
51 
55 
57  GERBVIEW_FRAME::OnZipFileHistory )
58  EVT_MENU( ID_GERBVIEW_ZIP_FILE_LIST_CLEAR, GERBVIEW_FRAME::OnClearZipFileHistory )
59 
61  GERBVIEW_FRAME::OnJobFileHistory )
62  EVT_MENU( ID_GERBVIEW_JOB_FILE_LIST_CLEAR, GERBVIEW_FRAME::OnClearJobFileHistory )
63 
64  EVT_MENU( wxID_EXIT, GERBVIEW_FRAME::OnQuit )
65 
66  EVT_COMBOBOX( ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER, GERBVIEW_FRAME::OnSelectActiveLayer )
67 
69 
70  // Option toolbar
72  GERBVIEW_FRAME::OnSelectDisplayMode )
73 
74  // Auxiliary horizontal toolbar
78  GERBVIEW_FRAME::OnSelectHighlightChoice )
81 
82  EVT_UPDATE_UI( ID_ON_GRID_SELECT, GERBVIEW_FRAME::OnUpdateSelectGrid )
85  GERBVIEW_FRAME::OnUpdateLayerSelectBox )
87  GERBVIEW_FRAME::OnUpdateDrawMode )
88 
89 END_EVENT_TABLE()
90 
91 
92 void GERBVIEW_FRAME::OnSelectHighlightChoice( wxCommandEvent& event )
93 {
94  auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() )->GetSettings();
95 
96  switch( event.GetId() )
97  {
99  settings->m_componentHighlightString = m_SelComponentBox->GetStringSelection();
100  break;
101 
103  settings->m_netHighlightString = m_SelNetnameBox->GetStringSelection();
104  break;
105 
107  settings->m_attributeHighlightString = m_SelAperAttributesBox->GetStringSelection();
108  break;
109 
110  }
111 
112  GetCanvas()->GetView()->UpdateAllItems( KIGFX::COLOR );
113  GetCanvas()->Refresh();
114 }
115 
116 
117 void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event )
118 {
119  GERBER_FILE_IMAGE* gerber_image = GetGbrImage( GetActiveLayer() );
120 
121  if( gerber_image )
122  {
123  int d_code = m_DCodeSelector->GetSelectedDCodeId();
124 
125  auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>(
126  GetCanvas()->GetView()->GetPainter() )->GetSettings();
127  gerber_image->m_Selected_Tool = d_code;
128  settings->m_dcodeHighlightValue = d_code;
129 
131  GetCanvas()->Refresh();
132  }
133 }
134 
135 
136 void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event )
137 {
138  SetActiveLayer( event.GetSelection(), true );
139 
140  // Rebuild the DCode list in toolbar (but not the Layer Box) after change
141  syncLayerBox( false );
142 
143  // Reinit highlighted dcode
144  auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>
145  ( GetCanvas()->GetView()->GetPainter() )->GetSettings();
146  int dcodeSelected = m_DCodeSelector->GetSelectedDCodeId();
147  settings->m_dcodeHighlightValue = dcodeSelected;
149  GetCanvas()->Refresh();
150 }
151 
152 
153 void GERBVIEW_FRAME::OnSelectDisplayMode( wxCommandEvent& event )
154 {
155  switch( event.GetId() )
156  {
160  }
161 
162  GetCanvas()->Refresh();
163 }
164 
165 
166 void GERBVIEW_FRAME::OnQuit( wxCommandEvent& event )
167 {
168  Close( true );
169 }
170 
171 
173 {
174  // call my base class
176 
178 
179  wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_LayersManager );
180  pane_info.Caption( _( "Visibles" ) );
181  m_auimgr.Update();
182 
184 }
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:1415
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()
Function SetLayersManagerTabsText Update the layer manager tabs labels Useful when changing Language ...
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
GERBER_FILE_IMAGE * GetGbrImage(int aIdx) const
int GetSelectedDCodeId()
Function GetSelectedDCodeId.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
Helper dialog and control classes.
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
void OnClearGbrFileHistory(wxCommandEvent &aEvent)
#define EVT_SELECT_DCODE
virtual void OnSize(wxSizeEvent &event)
Recalculate the size of toolbars and display panel when the frame size changes.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
DCODE_SELECTION_BOX * m_DCodeSelector
int GetActiveLayer() const
Return the active layer.
see class PGM_BASE
#define _(s)
Definition: 3d_actions.cpp:33
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::Process_Special_Functions) EDA_3D_VIEWER
virtual void ShowChangedLanguage()
Redraw the menus and what not in current language.
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)