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 <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/selection_tool.h"
#include "tools/pcbnew_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 74 of file footprint_wizard_frame.cpp.

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