KiCad PCB EDA Suite
footprint_wizard_frame.cpp File Reference
#include <fctsys.h>
#include <kiface_i.h>
#include <gal/graphics_abstraction_layer.h>
#include <class_drawpanel.h>
#include <pcb_draw_panel_gal.h>
#include <pcb_edit_frame.h>
#include <pcbnew.h>
#include <3d_viewer/eda_3d_viewer.h>
#include <msgpanel.h>
#include <macros.h>
#include <bitmaps.h>
#include <grid_tricks.h>
#include <eda_dockart.h>
#include <class_board.h>
#include <class_module.h>
#include <footprint_edit_frame.h>
#include <pcbnew_id.h>
#include "footprint_wizard_frame.h"
#include <footprint_info.h>
#include <wx/grid.h>
#include <wx/tokenzr.h>
#include <wx/numformatter.h>
#include <wx/statline.h>
#include <hotkeys.h>
#include <wildcards_and_files_ext.h>
#include <base_units.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <tool/common_tools.h>
#include "tools/selection_tool.h"
#include "tools/pcbnew_control.h"
#include "tools/pcb_actions.h"

Go to the source code of this file.

Macros

#define MODAL_MODE_EXTRASTYLE   wxFRAME_FLOAT_ON_PARENT
 
#define AUI_PERSPECTIVE_KEY   wxT( "Fpwizard_auiPerspective" )
 

Functions

 EVT_TOOL (ID_FOOTPRINT_WIZARD_SELECT_WIZARD, FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard) EVT_TOOL(ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT
 
FOOTPRINT_WIZARD_FRAME::DefaultParameters EVT_TOOL (ID_FOOTPRINT_WIZARD_NEXT, FOOTPRINT_WIZARD_FRAME::Process_Special_Functions) EVT_TOOL(ID_FOOTPRINT_WIZARD_PREVIOUS
 
FOOTPRINT_WIZARD_FRAME::DefaultParameters FOOTPRINT_WIZARD_FRAME::Process_Special_Functions EVT_TOOL (ID_FOOTPRINT_WIZARD_DONE, FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint) EVT_TOOL(ID_FOOTPRINT_WIZARD_SHOW_3D_VIEW
 
FOOTPRINT_WIZARD_FRAME::DefaultParameters FOOTPRINT_WIZARD_FRAME::Process_Special_Functions FOOTPRINT_WIZARD_FRAME::Show3D_Frame EVT_GRID_CMD_CELL_CHANGED (ID_FOOTPRINT_WIZARD_PARAMETER_LIST, FOOTPRINT_WIZARD_FRAME::ParametersUpdated) FOOTPRINT_WIZARD_FRAME
 

Macro Definition Documentation

#define AUI_PERSPECTIVE_KEY   wxT( "Fpwizard_auiPerspective" )
#define MODAL_MODE_EXTRASTYLE   wxFRAME_FLOAT_ON_PARENT

Function Documentation

Definition at line 98 of file footprint_wizard_frame.cpp.

References PCAD2KICAD::Center, F_Cu, FRAME_PCB_FOOTPRINT_WIZARD, g_Module_Viewer_Hotkeys_Descr, EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO, EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL, GetBoard(), BOARD_DESIGN_SETTINGS::GetDefault(), BOARD::GetDesignSettings(), EDA_DRAW_FRAME::GetUserUnits(), EDA_DRAW_PANEL_GAL::GetView(), EDA_DRAW_PANEL_GAL::GetViewControls(), ID_POPUP_GRID_LEVEL_1000, KiBitmap(), LAYER_NO_CONNECTS, PCAD2KICAD::Left, BOARD::SetElementVisibility(), TOOL_MANAGER::SetEnvironment(), EDA_DRAW_PANEL_GAL::SetEventDispatcher(), and BOARD::SetVisibleAlls().

120  :
121  PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Wizard" ),
122  wxDefaultPosition, wxDefaultSize,
124  : KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP,
126 {
127  wxASSERT( aFrameType == FRAME_PCB_FOOTPRINT_WIZARD );
128 
129  // This frame is always show modal:
130  SetModal( true );
131 
132  m_showAxis = true; // true to draw axis.
133 
134  // Give an icon
135  wxIcon icon;
136  icon.CopyFromBitmap( KiBitmap( module_wizard_xpm) );
137  SetIcon( icon );
138 
139  m_hotkeysDescrList = g_Module_Viewer_Hotkeys_Descr;
140  m_wizardName.Empty();
141 
142  SetBoard( new BOARD() );
143 
144  // Ensure all layers and items are visible:
146  SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
147  GetScreen()->m_Center = true; // Center coordinate origins on screen.
148 
149  LoadSettings( config() );
150 
151  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
152 
153  // Set some display options here, because the FOOTPRINT_WIZARD_FRAME
154  // does not have a config menu to do that:
155 
156  // the footprint wizard frame has no config menu. so use some settings
157  // from the caller, or force some options:
158  PCB_BASE_FRAME* caller = dynamic_cast<PCB_BASE_FRAME*>( aParent );
159 
160  if( caller )
161  {
162  SetUserUnits( caller->GetUserUnits() );
163  }
164 
165  auto disp_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
166  // In viewer, the default net clearance is not known (it depends on the actual board).
167  // So we do not show the default clearance, by setting it to 0
168  // The footprint or pad specific clearance will be shown
169  GetBoard()->GetDesignSettings().GetDefault()->SetClearance(0);
170 
171  disp_opts->m_DisplayPadIsol = true;
172  disp_opts->m_DisplayPadNum = true;
174 
175  GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
176 
177  ReCreateHToolbar();
178  ReCreateVToolbar();
179 
180  // Create GAL canvas
181 #ifdef __WXMAC__
182  // Cairo renderer doesn't handle Retina displays
184 #else
186 #endif
187  PCB_DRAW_PANEL_GAL* gal_drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
188  GetGalDisplayOptions(), backend );
189  SetGalCanvas( gal_drawPanel );
190 
191  // Create the parameters panel
192  m_parametersPanel = new wxPanel( this, wxID_ANY );
193 
194  m_pageList = new wxListBox( m_parametersPanel, ID_FOOTPRINT_WIZARD_PAGE_LIST,
195  wxDefaultPosition, wxDefaultSize, 0, NULL,
196  wxLB_HSCROLL | wxNO_BORDER );
197 
198  auto divider = new wxStaticLine( m_parametersPanel, wxID_ANY,
199  wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
200 
201  m_parameterGrid = new wxGrid( m_parametersPanel, ID_FOOTPRINT_WIZARD_PARAMETER_LIST );
202  initParameterGrid();
203  m_parameterGrid->PushEventHandler( new GRID_TRICKS( m_parameterGrid ) );
204 
205  ReCreatePageList();
206 
207  wxBoxSizer* parametersSizer = new wxBoxSizer( wxHORIZONTAL );
208  parametersSizer->Add( m_pageList, 0, wxEXPAND, 5 );
209  parametersSizer->Add( divider, 0, wxEXPAND, 5 );
210  parametersSizer->Add( m_parameterGrid, 1, wxEXPAND, 5 );
211  m_parametersPanel->SetSizer( parametersSizer );
212  m_parametersPanel->Layout();
213 
214  // Create the build message box
215  m_buildMessageBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
216  wxDefaultPosition, wxDefaultSize,
217  wxTE_MULTILINE | wxTE_READONLY | wxNO_BORDER );
218 
219  DisplayWizardInfos();
220 
221  m_auimgr.SetManagedWindow( this );
222  m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );
223 
224  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
225  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
226 
227  m_auimgr.AddPane( m_parametersPanel, EDA_PANE().Palette().Name( "Params" ).Left().Position(0)
228  .Caption( _( "Parameters" ) ).MinSize( 360, 180 ) );
229  m_auimgr.AddPane( m_buildMessageBox, EDA_PANE().Palette().Name( "Output" ).Left().Position(1)
230  .CaptionVisible( false ).MinSize( 360, -1 ) );
231 
232  m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
233 
234  m_auimgr.AddPane( (wxWindow*) GetGalCanvas(),
235  wxAuiPaneInfo().Name( "DrawFrameGal" ).CentrePane().Hide() );
236 
237  // Create the manager and dispatcher & route draw panel events to the dispatcher
238  m_toolManager = new TOOL_MANAGER;
239  m_toolManager->SetEnvironment( GetBoard(), gal_drawPanel->GetView(),
240  gal_drawPanel->GetViewControls(), this );
241  m_actions = new PCB_ACTIONS();
242  m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
243  gal_drawPanel->SetEventDispatcher( m_toolDispatcher );
244 
245  m_toolManager->RegisterTool( new PCBNEW_CONTROL );
246  m_toolManager->RegisterTool( new SELECTION_TOOL ); // for std context menus (zoom & grid)
247  m_toolManager->RegisterTool( new COMMON_TOOLS );
248  m_toolManager->InitTools();
249 
250  // Run the control tool, it is supposed to be always active
251  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
252 
253  auto& galOpts = GetGalDisplayOptions();
254  galOpts.m_fullscreenCursor = true;
255  galOpts.m_forceDisplayCursor = true;
256  galOpts.m_axesEnabled = true;
257 
258  UseGalCanvas( backend != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE );
259  updateView();
260 
261  SetActiveLayer( F_Cu );
262  // Now Drawpanel is sized, we can use BestZoom to show the component (if any)
263 #ifdef USE_WX_GRAPHICS_CONTEXT
264  GetScreen()->SetScalingFactor( BestZoom() );
265 #else
266  Zoom_Automatique( false );
267 #endif
268 
269  // Do not Run a dialog here: on some Window Managers, it creates issues.
270  // Reason: the FOOTPRINT_WIZARD_FRAME is run as modal;
271  // It means the call to FOOTPRINT_WIZARD_FRAME::ShowModal will change the
272  // Event Loop Manager, and stop the one created by the dialog.
273  // It does not happen on all W.M., perhaps due to the way the order events are called
274 // SelectFootprintWizard();
275 }
struct EDA_HOTKEY_CONFIG g_Module_Viewer_Hotkeys_Descr[]
show a marker on pads with no nets
NETCLASSPTR GetDefault() const
Function GetDefault.
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
Class SELECTION_TOOL.
Class GRID_TRICKS is used to add cut, copy, and paste to an otherwise unmodied wxGrid instance...
Definition: grid_tricks.h:51
void SetVisibleAlls()
Function SetVisibleAlls changes the bit-mask of visible element categories and layers.
#define FOOTPRINT_WIZARD_FRAME_NAME
Definition: draw_frame.h:52
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
Class PCBNEW_CONTROL.
Class TOOL_MANAGER.
Definition: tool_manager.h:49
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings...
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, wxWindow *aFrame)
Sets the work environment (model, view, view controls and the parent window).
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:284
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:538
#define KICAD_DEFAULT_DRAWFRAME_STYLE
Specialization of the wxAuiPaneInfo class for KiCad panels.
Class COMMON_TOOLS.
Definition: common_tools.h:38
Class TOOL_DISPATCHER.
BOARD * GetBoard()
Class PCB_ACTIONS.
Definition: pcb_actions.h:42
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:170
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools...
#define MODAL_MODE_EXTRASTYLE
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel...
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...