KiCad PCB EDA Suite
footprint_wizard_frame.cpp File Reference
#include <kiface_i.h>
#include <pcb_draw_panel_gal.h>
#include <pcb_edit_frame.h>
#include <3d_viewer/eda_3d_viewer.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/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 71 of file footprint_wizard_frame.cpp.

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

References _, 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_DisplayPadIsol, PCB_DISPLAY_OPTIONS::m_DisplayPadNum, module_wizard_xpm, NULL, NETCLASS::SetClearance(), BOARD::SetElementVisibility(), TOOL_MANAGER::SetEnvironment(), EDA_DRAW_PANEL_GAL::SetEventDispatcher(), BOARD::SetVisibleAlls(), and ACTIONS::zoomFitScreen.