KiCad PCB EDA Suite
footprint_wizard_frame.cpp File Reference
#include <fctsys.h>
#include <kiface_i.h>
#include <pcb_draw_panel_gal.h>
#include <pcb_edit_frame.h>
#include <3d_viewer/eda_3d_viewer.h>
#include <msgpanel.h>
#include <macros.h>
#include <bitmaps.h>
#include <grid_tricks.h>
#include <class_board.h>
#include <footprint_edit_frame.h>
#include <pcbnew_id.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 <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <tool/action_toolbar.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 509 of file footprint_wizard_frame.cpp.

Function Documentation

◆ EVT_GRID_CMD_CELL_CHANGED()

Definition at line 69 of file footprint_wizard_frame.cpp.

77  :
78  PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Wizard" ),
79  wxDefaultPosition, wxDefaultSize,
80  aParent ? KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT
81  : KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP,
83  m_wizardListShown( false )
84 {
85  wxASSERT( aFrameType == FRAME_FOOTPRINT_WIZARD );
86 
87  // This frame is always show modal:
88  SetModal( true );
89 
90  // Give an icon
91  wxIcon icon;
92  icon.CopyFromBitmap( KiBitmap( module_wizard_xpm) );
93  SetIcon( icon );
94 
95  m_wizardName.Empty();
96 
97  SetBoard( new BOARD() );
98 
99  // Ensure all layers and items are visible:
101  SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
102  GetScreen()->m_Center = true; // Center coordinate origins on screen.
103 
104  LoadSettings( config() );
105 
106  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
107 
108  // Set some display options here, because the FOOTPRINT_WIZARD_FRAME
109  // does not have a config menu to do that:
110 
111  // the footprint wizard frame has no config menu. so use some settings
112  // from the caller, or force some options:
113  PCB_BASE_FRAME* caller = dynamic_cast<PCB_BASE_FRAME*>( aParent );
114 
115  if( caller )
116  SetUserUnits( caller->GetUserUnits() );
117 
118  PCB_DISPLAY_OPTIONS disp_opts = GetDisplayOptions();
119  // In viewer, the default net clearance is not known (it depends on the actual board).
120  // So we do not show the default clearance, by setting it to 0
121  // The footprint or pad specific clearance will be shown
122  GetBoard()->GetDesignSettings().GetDefault()->SetClearance(0);
123 
124  disp_opts.m_DisplayPadIsol = true;
125  disp_opts.m_DisplayPadNum = true;
126  SetDisplayOptions( disp_opts );
127 
129 
130  GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
131 
132  // Create GAL canvas
133 #ifdef __WXMAC__
134  // Cairo renderer doesn't handle Retina displays
136 #else
138 #endif
139  PCB_DRAW_PANEL_GAL* gal_drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
140  GetGalDisplayOptions(), backend );
141  SetCanvas( gal_drawPanel );
142 
143  // Create the manager and dispatcher & route draw panel events to the dispatcher
144  m_toolManager = new TOOL_MANAGER;
145  m_toolManager->SetEnvironment( GetBoard(), gal_drawPanel->GetView(),
146  gal_drawPanel->GetViewControls(), this );
147  m_actions = new PCB_ACTIONS();
148  m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
149  gal_drawPanel->SetEventDispatcher( m_toolDispatcher );
150 
151  m_toolManager->RegisterTool( new PCBNEW_CONTROL );
152  m_toolManager->RegisterTool( new SELECTION_TOOL ); // for std context menus (zoom & grid)
153  m_toolManager->RegisterTool( new COMMON_TOOLS );
154  m_toolManager->InitTools();
155 
156  // Run the control tool, it is supposed to be always active
157  m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
158 
159  // Create the toolbars
160  ReCreateHToolbar();
161  ReCreateVToolbar();
162 
163  // Create the parameters panel
164  m_parametersPanel = new wxPanel( this, wxID_ANY );
165 
166  m_pageList = new wxListBox( m_parametersPanel, ID_FOOTPRINT_WIZARD_PAGE_LIST,
167  wxDefaultPosition, wxDefaultSize, 0, NULL,
168  wxLB_HSCROLL | wxNO_BORDER );
169 
170  auto divider = new wxStaticLine( m_parametersPanel, wxID_ANY,
171  wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
172 
173  m_parameterGrid = new WX_GRID( m_parametersPanel, ID_FOOTPRINT_WIZARD_PARAMETER_LIST );
174  initParameterGrid();
175  m_parameterGrid->PushEventHandler( new GRID_TRICKS( m_parameterGrid ) );
176 
177  ReCreatePageList();
178 
179  wxBoxSizer* parametersSizer = new wxBoxSizer( wxHORIZONTAL );
180  parametersSizer->Add( m_pageList, 0, wxEXPAND, 5 );
181  parametersSizer->Add( divider, 0, wxEXPAND, 5 );
182  parametersSizer->Add( m_parameterGrid, 1, wxEXPAND, 5 );
183  m_parametersPanel->SetSizer( parametersSizer );
184  m_parametersPanel->Layout();
185 
186  // Create the build message box
187  m_buildMessageBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
188  wxDefaultPosition, wxDefaultSize,
189  wxTE_MULTILINE | wxTE_READONLY | wxNO_BORDER );
190 
191  DisplayWizardInfos();
192 
193  m_auimgr.SetManagedWindow( this );
194 
195  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
196  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6)
197  .BestSize( -1, m_MsgFrameHeight ) );
198 
199  m_auimgr.AddPane( m_parametersPanel, EDA_PANE().Palette().Name( "Params" ).Left().Position(0)
200  .Caption( _( "Parameters" ) ).MinSize( 360, 180 ) );
201  m_auimgr.AddPane( m_buildMessageBox, EDA_PANE().Palette().Name( "Output" ).Left().Position(1)
202  .CaptionVisible( false ).MinSize( 360, -1 ) );
203 
204  m_auimgr.AddPane( GetCanvas(), wxAuiPaneInfo().Name( "DrawFrame" ).CentrePane() );
205 
206  auto& galOpts = GetGalDisplayOptions();
207  galOpts.m_fullscreenCursor = true;
208  galOpts.m_forceDisplayCursor = true;
209  galOpts.m_axesEnabled = true;
210 
211  GetCanvas()->GetView()->SetScale( GetZoomLevelCoeff() / GetScreen()->GetZoom() );
212  ActivateGalCanvas();
213  updateView();
214 
215  SetActiveLayer( F_Cu );
216  GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false );
217 
218  // Do not Run a dialog here: on some Window Managers, it creates issues.
219  // Reason: the FOOTPRINT_WIZARD_FRAME is run as modal;
220  // It means the call to FOOTPRINT_WIZARD_FRAME::ShowModal will change the
221  // Event Loop Manager, and stop the one created by the dialog.
222  // It does not happen on all W.M., perhaps due to the way the order events are called
223  // See the call in onActivate instead
224 }
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
static TOOL_ACTION zoomFitScreen
Definition: actions.h:93
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:531
void SetVisibleAlls()
Function SetVisibleAlls changes the bit-mask of visible element categories and layers.
#define FOOTPRINT_WIZARD_FRAME_NAME
Class PCBNEW_CONTROL.
Class TOOL_MANAGER.
Definition: tool_manager.h:50
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.
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define _(s)
virtual KIGFX::PCB_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
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:62
NETCLASSPTR GetDefault() const
Function GetDefault.
EDA_UNITS_T GetUserUnits() const
Return the user units currently in use.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:161
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, EDA_BASE_FRAME *aFrame)
Sets the work environment (model, view, view controls and the parent window).
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.

References _, F_Cu, FRAME_FOOTPRINT_WIZARD, EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL, 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, ID_POPUP_GRID_LEVEL_1000, KiBitmap(), LAYER_NO_CONNECTS, PCAD2KICAD::Left, BOARD::SetElementVisibility(), TOOL_MANAGER::SetEnvironment(), EDA_DRAW_PANEL_GAL::SetEventDispatcher(), BOARD::SetVisibleAlls(), and ACTIONS::zoomFitScreen.