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 AUI_PERSPECTIVE_KEY   wxT( "Fpwizard_auiPerspective" )
 

Functions

 EVT_GRID_CMD_CELL_CHANGED (ID_FOOTPRINT_WIZARD_PARAMETER_LIST, FOOTPRINT_WIZARD_FRAME::ParametersUpdated) FOOTPRINT_WIZARD_FRAME
 

Macro Definition Documentation

◆ AUI_PERSPECTIVE_KEY

#define AUI_PERSPECTIVE_KEY   wxT( "Fpwizard_auiPerspective" )

Definition at line 546 of file footprint_wizard_frame.cpp.

Function Documentation

◆ EVT_GRID_CMD_CELL_CHANGED()

Definition at line 86 of file footprint_wizard_frame.cpp.

96  :
97  PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Wizard" ),
98  wxDefaultPosition, wxDefaultSize,
99  aParent ? KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT
100  : KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP,
102  m_wizardListShown( false )
103 {
104  wxASSERT( aFrameType == FRAME_PCB_FOOTPRINT_WIZARD );
105 
106  // This frame is always show modal:
107  SetModal( true );
108 
109  m_showAxis = true; // true to draw axis.
110 
111  // Give an icon
112  wxIcon icon;
113  icon.CopyFromBitmap( KiBitmap( module_wizard_xpm) );
114  SetIcon( icon );
115 
116  m_hotkeysDescrList = g_Module_Viewer_Hotkeys_Descr;
117  m_wizardName.Empty();
118 
119  SetBoard( new BOARD() );
120 
121  // Ensure all layers and items are visible:
123  SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
124  GetScreen()->m_Center = true; // Center coordinate origins on screen.
125 
126  LoadSettings( config() );
127 
128  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
129 
130  // Set some display options here, because the FOOTPRINT_WIZARD_FRAME
131  // does not have a config menu to do that:
132 
133  // the footprint wizard frame has no config menu. so use some settings
134  // from the caller, or force some options:
135  PCB_BASE_FRAME* caller = dynamic_cast<PCB_BASE_FRAME*>( aParent );
136 
137  if( caller )
138  SetUserUnits( caller->GetUserUnits() );
139 
140  auto disp_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
141  // In viewer, the default net clearance is not known (it depends on the actual board).
142  // So we do not show the default clearance, by setting it to 0
143  // The footprint or pad specific clearance will be shown
144  GetBoard()->GetDesignSettings().GetDefault()->SetClearance(0);
145 
146  disp_opts->m_DisplayPadIsol = true;
147  disp_opts->m_DisplayPadNum = true;
149 
150  GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
151 
152  // Create GAL canvas
153 #ifdef __WXMAC__
154  // Cairo renderer doesn't handle Retina displays
156 #else
158 #endif
159  PCB_DRAW_PANEL_GAL* gal_drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
160  GetGalDisplayOptions(), backend );
161  SetGalCanvas( gal_drawPanel );
162 
163  // Create the manager and dispatcher & route draw panel events to the dispatcher
164  m_toolManager = new TOOL_MANAGER;
165  m_toolManager->SetEnvironment( GetBoard(), gal_drawPanel->GetView(),
166  gal_drawPanel->GetViewControls(), this );
167  m_actions = new PCB_ACTIONS();
168  m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
169  gal_drawPanel->SetEventDispatcher( m_toolDispatcher );
170 
171  m_toolManager->RegisterTool( new PCBNEW_CONTROL );
172  m_toolManager->RegisterTool( new SELECTION_TOOL ); // for std context menus (zoom & grid)
173  m_toolManager->RegisterTool( new COMMON_TOOLS );
174  m_toolManager->InitTools();
175 
176  // Run the control tool, it is supposed to be always active
177  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
178 
179  // Create the toolbars
180  ReCreateHToolbar();
181  ReCreateVToolbar();
182 
183  // Create the parameters panel
184  m_parametersPanel = new wxPanel( this, wxID_ANY );
185 
186  m_pageList = new wxListBox( m_parametersPanel, ID_FOOTPRINT_WIZARD_PAGE_LIST,
187  wxDefaultPosition, wxDefaultSize, 0, NULL,
188  wxLB_HSCROLL | wxNO_BORDER );
189 
190  auto divider = new wxStaticLine( m_parametersPanel, wxID_ANY,
191  wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
192 
193  m_parameterGrid = new WX_GRID( m_parametersPanel, ID_FOOTPRINT_WIZARD_PARAMETER_LIST );
194  initParameterGrid();
195  m_parameterGrid->PushEventHandler( new GRID_TRICKS( m_parameterGrid ) );
196 
197  ReCreatePageList();
198 
199  wxBoxSizer* parametersSizer = new wxBoxSizer( wxHORIZONTAL );
200  parametersSizer->Add( m_pageList, 0, wxEXPAND, 5 );
201  parametersSizer->Add( divider, 0, wxEXPAND, 5 );
202  parametersSizer->Add( m_parameterGrid, 1, wxEXPAND, 5 );
203  m_parametersPanel->SetSizer( parametersSizer );
204  m_parametersPanel->Layout();
205 
206  // Create the build message box
207  m_buildMessageBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
208  wxDefaultPosition, wxDefaultSize,
209  wxTE_MULTILINE | wxTE_READONLY | wxNO_BORDER );
210 
211  DisplayWizardInfos();
212 
213  m_auimgr.SetManagedWindow( this );
214  m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );
215 
216  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
217  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
218 
219  m_auimgr.AddPane( m_parametersPanel, EDA_PANE().Palette().Name( "Params" ).Left().Position(0)
220  .Caption( _( "Parameters" ) ).MinSize( 360, 180 ) );
221  m_auimgr.AddPane( m_buildMessageBox, EDA_PANE().Palette().Name( "Output" ).Left().Position(1)
222  .CaptionVisible( false ).MinSize( 360, -1 ) );
223 
224  m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
225 
226  m_auimgr.AddPane( (wxWindow*) GetGalCanvas(),
227  wxAuiPaneInfo().Name( "DrawFrameGal" ).CentrePane().Hide() );
228 
229  auto& galOpts = GetGalDisplayOptions();
230  galOpts.m_fullscreenCursor = true;
231  galOpts.m_forceDisplayCursor = true;
232  galOpts.m_axesEnabled = true;
233 
234  UseGalCanvas( backend != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE );
235  updateView();
236 
237  SetActiveLayer( F_Cu );
238  // Now Drawpanel is sized, we can use BestZoom to show the component (if any)
239 #ifdef USE_WX_GRAPHICS_CONTEXT
240  GetScreen()->SetScalingFactor( BestZoom() );
241 #else
242  Zoom_Automatique( false );
243 #endif
244 
245  // Do not Run a dialog here: on some Window Managers, it creates issues.
246  // Reason: the FOOTPRINT_WIZARD_FRAME is run as modal;
247  // It means the call to FOOTPRINT_WIZARD_FRAME::ShowModal will change the
248  // Event Loop Manager, and stop the one created by the dialog.
249  // It does not happen on all W.M., perhaps due to the way the order events are called
250  // See the call in onActivate instead
251 }
struct EDA_HOTKEY_CONFIG g_Module_Viewer_Hotkeys_Descr[]
show a marker on pads with no nets
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel.
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 mouse and command handling (such as cut, copy, and paste) to a WX_GR...
Definition: grid_tricks.h:51
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, EDA_DRAW_FRAME *aFrame)
Sets the work environment (model, view, view controls and the parent window).
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:534
void SetVisibleAlls()
Function SetVisibleAlls changes the bit-mask of visible element categories and layers.
#define FOOTPRINT_WIZARD_FRAME_NAME
Definition: draw_frame.h:53
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.
GAL not used (the legacy wxDC engine is used)
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:289
#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
NETCLASSPTR GetDefault() const
Function GetDefault.
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.
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.

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_FOOTPRINT_WIZARD_PAGE_LIST, ID_FOOTPRINT_WIZARD_PARAMETER_LIST, ID_POPUP_GRID_LEVEL_1000, KiBitmap(), LAYER_NO_CONNECTS, PCAD2KICAD::Left, BOARD::SetElementVisibility(), TOOL_MANAGER::SetEnvironment(), EDA_DRAW_PANEL_GAL::SetEventDispatcher(), and BOARD::SetVisibleAlls().