KiCad PCB EDA Suite
footprint_wizard_frame.cpp File Reference
#include <kiface_base.h>
#include <pcb_draw_panel_gal.h>
#include <pcb_edit_frame.h>
#include <3d_viewer/eda_3d_viewer_frame.h>
#include <widgets/msgpanel.h>
#include <bitmaps.h>
#include <grid_tricks.h>
#include <board.h>
#include <footprint_edit_frame.h>
#include <footprint_editor_settings.h>
#include <pcbnew_id.h>
#include <pcbnew_settings.h>
#include "footprint_wizard_frame.h"
#include <wx/listbox.h>
#include <wx/tokenzr.h>
#include <wx/numformatter.h>
#include <wildcards_and_files_ext.h>
#include <base_units.h>
#include <pgm_base.h>
#include <settings/color_settings.h>
#include <settings/settings_manager.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <tool/action_toolbar.h>
#include <tool/common_tools.h>
#include "tools/pcb_selection_tool.h"
#include "tools/pcb_control.h"
#include "tools/pcb_actions.h"

Go to the source code of this file.

Functions

 EVT_GRID_CMD_CELL_CHANGED (ID_FOOTPRINT_WIZARD_PARAMETER_LIST, FOOTPRINT_WIZARD_FRAME::ParametersUpdated) FOOTPRINT_WIZARD_FRAME
 

Function Documentation

◆ EVT_GRID_CMD_CELL_CHANGED()

Definition at line 72 of file footprint_wizard_frame.cpp.

80  :
81  PCB_BASE_EDIT_FRAME( aKiway, aParent, aFrameType, _( "Footprint Wizard" ),
82  wxDefaultPosition, wxDefaultSize,
83  aParent ? KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT
84  : KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP,
86  m_wizardListShown( false )
87 {
88  wxASSERT( aFrameType == FRAME_FOOTPRINT_WIZARD );
89 
90  // This frame is always show modal:
91  SetModal( true );
92 
93  // Give an icon
94  wxIcon icon;
95  icon.CopyFromBitmap( KiBitmap( BITMAPS::module_wizard ) );
96  SetIcon( icon );
97 
98  m_wizardName.Empty();
99 
100  // Create the GAL canvas.
101  // Must be created before calling LoadSettings() that needs a valid GAL canvas
102  PCB_DRAW_PANEL_GAL* gal_drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ),
103  m_frameSize,
104  GetGalDisplayOptions(),
106  SetCanvas( gal_drawPanel );
107 
108  SetBoard( new BOARD() );
109 
110  // Ensure all layers and items are visible:
112  SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
113  GetScreen()->m_Center = true; // Center coordinate origins on screen.
114 
115  LoadSettings( config() );
116 
117  SetSize( m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
118 
119  // Set some display options here, because the FOOTPRINT_WIZARD_FRAME
120  // does not have a config menu to do that:
121 
122  // the footprint wizard frame has no config menu. so use some settings
123  // from the caller, or force some options:
124  PCB_BASE_FRAME* caller = dynamic_cast<PCB_BASE_FRAME*>( aParent );
125 
126  if( caller )
127  SetUserUnits( caller->GetUserUnits() );
128 
129  // In viewer, the default net clearance is not known (it depends on the actual board).
130  // So we do not show the default clearance, by setting it to 0
131  // The footprint or pad specific clearance will be shown
134 
135  PCB_DISPLAY_OPTIONS disp_opts = GetDisplayOptions();
136 
137  disp_opts.m_DisplayPadClearance = true;
138  disp_opts.m_DisplayPadNum = true;
139  SetDisplayOptions( disp_opts );
140 
141  // Create the manager and dispatcher & route draw panel events to the dispatcher
142  m_toolManager = new TOOL_MANAGER;
143  m_toolManager->SetEnvironment( GetBoard(), gal_drawPanel->GetView(),
144  gal_drawPanel->GetViewControls(), config(), this );
145  m_actions = new PCB_ACTIONS();
146  m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
147  gal_drawPanel->SetEventDispatcher( m_toolDispatcher );
148 
149  m_toolManager->RegisterTool( new PCB_CONTROL );
150  m_toolManager->RegisterTool( new PCB_SELECTION_TOOL ); // for std context menus (zoom & grid)
151  m_toolManager->RegisterTool( new COMMON_TOOLS );
152  m_toolManager->InitTools();
153 
154  // Run the control tool, it is supposed to be always active
155  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
156 
157  // Create the toolbars
158  ReCreateHToolbar();
159  ReCreateVToolbar();
160 
161  // Create the parameters panel
162  m_parametersPanel = new wxPanel( this, wxID_ANY );
163 
164  m_pageList = new wxListBox( m_parametersPanel, ID_FOOTPRINT_WIZARD_PAGE_LIST,
165  wxDefaultPosition, wxDefaultSize, 0, nullptr,
166  wxLB_HSCROLL | wxNO_BORDER );
167 
168  auto divider = new wxStaticLine( m_parametersPanel, wxID_ANY,
169  wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
170 
171  m_parameterGrid = new WX_GRID( m_parametersPanel, ID_FOOTPRINT_WIZARD_PARAMETER_LIST );
172  initParameterGrid();
173  m_parameterGrid->PushEventHandler( new GRID_TRICKS( m_parameterGrid ) );
174 
175  ReCreatePageList();
176 
177  wxBoxSizer* parametersSizer = new wxBoxSizer( wxHORIZONTAL );
178  parametersSizer->Add( m_pageList, 0, wxEXPAND, 5 );
179  parametersSizer->Add( divider, 0, wxEXPAND, 5 );
180  parametersSizer->Add( m_parameterGrid, 1, wxEXPAND, 5 );
181  m_parametersPanel->SetSizer( parametersSizer );
182  m_parametersPanel->Layout();
183 
184  // Create the build message box
185  m_buildMessageBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
186  wxDefaultPosition, wxDefaultSize,
187  wxTE_MULTILINE | wxTE_READONLY | wxNO_BORDER );
188 
189  DisplayWizardInfos();
190 
191  m_auimgr.SetManagedWindow( this );
192 
193  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
194  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6)
195  .BestSize( -1, m_msgFrameHeight ) );
196 
197  m_auimgr.AddPane( m_parametersPanel, EDA_PANE().Palette().Name( "Params" ).Left().Position(0)
198  .Caption( _( "Parameters" ) ).MinSize( 360, 180 ) );
199  m_auimgr.AddPane( m_buildMessageBox, EDA_PANE().Palette().Name( "Output" ).Left().Position(1)
200  .CaptionVisible( false ).MinSize( 360, -1 ) );
201 
202  m_auimgr.AddPane( GetCanvas(), wxAuiPaneInfo().Name( "DrawFrame" ).CentrePane() );
203 
204  auto& galOpts = GetGalDisplayOptions();
205  galOpts.m_fullscreenCursor = true;
206  galOpts.m_forceDisplayCursor = true;
207  galOpts.m_axesEnabled = true;
208 
209  ActivateGalCanvas();
210  updateView();
211 
212  SetActiveLayer( F_Cu );
213  GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false );
214 
215  // Do not Run a dialog here: on some Window Managers, it creates issues.
216  // Reason: the FOOTPRINT_WIZARD_FRAME is run as modal;
217  // It means the call to FOOTPRINT_WIZARD_FRAME::ShowModal will change the
218  // Event Loop Manager, and stop the one created by the dialog.
219  // It does not happen on all W.M., perhaps due to the way the order events are called
220  // See the call in onActivate instead
221 }
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
Definition: board.cpp:539
static constexpr GAL_TYPE GAL_FALLBACK
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition: grid_tricks.h:55
static TOOL_ACTION zoomFitScreen
Definition: actions.h:96
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
Definition: board.cpp:516
#define FOOTPRINT_WIZARD_FRAME_NAME
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
Master controller class:
Definition: tool_manager.h:54
Container for display options like enable/disable some optional drawings.
void SetClearance(int aClearance)
Definition: netclass.h:125
Handle actions that are shared between different frames in PcbNew.
Definition: pcb_control.h:46
#define _(s)
#define KICAD_DEFAULT_DRAWFRAME_STYLE
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
Specialization of the wxAuiPaneInfo class for KiCad panels.
Handles action that are shared between different applications.
Definition: common_tools.h:37
BOARD * GetBoard()
show a marker on pads with no nets
Definition: layer_ids.h:203
Gather all the actions that are shared by tools.
Definition: pcb_actions.h:48
Common, abstract interface for edit frames.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
Definition: layer_ids.h:71
NETCLASS * GetDefault() const
The selection tool: currently supports:
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
EDA_UNITS GetUserUnits() const
Return the user units currently in use.

References _, config, F_Cu, FRAME_FOOTPRINT_WIZARD, EDA_DRAW_PANEL_GAL::GAL_FALLBACK, GetBoard(), BOARD_DESIGN_SETTINGS::GetDefault(), BOARD::GetDesignSettings(), EDA_BASE_FRAME::GetUserUnits(), PCB_DRAW_PANEL_GAL::GetView(), EDA_DRAW_PANEL_GAL::GetViewControls(), ID_FOOTPRINT_WIZARD_PAGE_LIST, ID_FOOTPRINT_WIZARD_PARAMETER_LIST, KiBitmap(), LAYER_NO_CONNECTS, PCAD2KICAD::Left, PCB_DISPLAY_OPTIONS::m_DisplayPadClearance, PCB_DISPLAY_OPTIONS::m_DisplayPadNum, module_wizard, NETCLASS::SetClearance(), BOARD::SetElementVisibility(), TOOL_MANAGER::SetEnvironment(), EDA_DRAW_PANEL_GAL::SetEventDispatcher(), BOARD::SetVisibleAlls(), and ACTIONS::zoomFitScreen.