KiCad PCB EDA Suite
moduleframe.cpp File Reference

Footprint (module) editor main window. More...

#include <fctsys.h>
#include <pgm_base.h>
#include <kiway.h>
#include <project.h>
#include <kicad_plugin.h>
#include <class_drawpanel.h>
#include <pcb_draw_panel_gal.h>
#include <confirm.h>
#include <wxPcbStruct.h>
#include <dialog_helpers.h>
#include <3d_viewer/eda_3d_viewer.h>
#include <msgpanel.h>
#include <fp_lib_table.h>
#include <bitmaps.h>
#include <gal/graphics_abstraction_layer.h>
#include <class_board.h>
#include <class_module.h>
#include <pcbnew.h>
#include <pcbnew_id.h>
#include <hotkeys.h>
#include <dialogs/dialog_modedit_display_options.h>
#include <dialog_hotkeys_editor.h>
#include <module_editor_frame.h>
#include <modview_frame.h>
#include <wildcards_and_files_ext.h>
#include <class_pcb_layer_widget.h>
#include <invoke_pcb_dialog.h>
#include <tool/tool_manager.h>
#include <tool/common_tools.h>
#include <tool/tool_dispatcher.h>
#include <tool/zoom_tool.h>
#include "tools/selection_tool.h"
#include "tools/edit_tool.h"
#include "tools/drawing_tool.h"
#include "tools/point_editor.h"
#include "tools/pcbnew_control.h"
#include "tools/module_editor_tools.h"
#include "tools/placement_tool.h"
#include "tools/picker_tool.h"
#include "tools/pad_tool.h"
#include "tools/pcb_actions.h"

Go to the source code of this file.

Macros

#define FOOTPRINT_EDIT_FRAME_NAME   wxT( "ModEditFrame" )
 

Functions

 EVT_MENU_RANGE (ID_POPUP_PCB_ITEM_SELECTION_START, ID_POPUP_PCB_ITEM_SELECTION_END, PCB_BASE_FRAME::ProcessItemSelection) EVT_TOOL(ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART
 
FOOTPRINT_EDIT_FRAME::Process_Special_Functions EVT_TOOL_RANGE (ID_MODEDIT_PAD_TOOL, ID_MODEDIT_MEASUREMENT_TOOL, FOOTPRINT_EDIT_FRAME::OnVerticalToolbar) EVT_MENU(ID_PREFERENCES_HOTKEY_EXPORT_CONFIG
 
FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::ProcessPreferences EVT_MENU (ID_PREFERENCES_HOTKEY_IMPORT_CONFIG, FOOTPRINT_EDIT_FRAME::ProcessPreferences) EVT_MENU(ID_PREFERENCES_HOTKEY_SHOW_EDITOR
 
FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences EVT_MENU (ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, FOOTPRINT_EDIT_FRAME::ProcessPreferences) EVT_MENU(ID_PCB_LIB_WIZARD
 
FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences EVT_MENU (ID_PCB_LIB_TABLE_EDIT, FOOTPRINT_EDIT_FRAME::ProcessPreferences) EVT_MENU(wxID_PREFERENCES
 
FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences EVT_MENU (ID_PCB_DISPLAY_OPTIONS_SETUP, FOOTPRINT_EDIT_FRAME::ProcessPreferences) EVT_MENU_RANGE(ID_POPUP_PCB_START_RANGE
 
FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::Process_Special_Functions EVT_MENU_RANGE (ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions) EVT_MENU(ID_POPUP_MODEDIT_EDIT_BODY_ITEM
 
FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions EVT_MENU (ID_POPUP_MODEDIT_EDIT_WIDTH_ALL_EDGE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions) EVT_MENU(ID_POPUP_MODEDIT_EDIT_LAYER_ALL_EDGE
 
FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions EVT_UPDATE_UI (ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected) EVT_UPDATE_UI(ID_MODEDIT_LOAD_MODULE_FROM_BOARD
 
FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard EVT_UPDATE_UI (ID_MODEDIT_INSERT_MODULE_IN_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard) EVT_UPDATE_UI(ID_MODEDIT_UPDATE_MODULE_IN_BOARD
 
FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard FOOTPRINT_EDIT_FRAME::OnUpdateReplaceModuleInBoard EVT_UPDATE_UI_RANGE (ID_MODEDIT_PAD_TOOL, ID_MODEDIT_MEASUREMENT_TOOL, FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar) EVT_UPDATE_UI(ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH
 
FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard FOOTPRINT_EDIT_FRAME::OnUpdateReplaceModuleInBoard FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar EVT_UPDATE_UI (ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH, FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar) EVT_UPDATE_UI(ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE
 
FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard FOOTPRINT_EDIT_FRAME::OnUpdateReplaceModuleInBoard FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar EVT_UPDATE_UI (ID_GEN_IMPORT_DXF_FILE, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected) FOOTPRINT_EDIT_FRAME
 

Variables

FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences ID_POPUP_PCB_END_RANGE
 

Detailed Description

Footprint (module) editor main window.

Definition in file moduleframe.cpp.

Macro Definition Documentation

#define FOOTPRINT_EDIT_FRAME_NAME   wxT( "ModEditFrame" )

Function Documentation

Definition at line 212 of file moduleframe.cpp.

References PAGE_INFO::A4, F_SilkS, FRAME_PCB, g_Module_Editor_Hokeys_Descr, EDA_DRAW_PANEL_GAL::GetBackend(), GetBoard(), BOARD_DESIGN_SETTINGS::GetDefault(), BOARD::GetDesignSettings(), EDA_DRAW_FRAME::GetGalCanvas(), EDA_PANEINFO::HorizontalToolbarPane(), ID_POPUP_GRID_LEVEL_1000, ID_POPUP_GRID_USER, EDA_DRAW_FRAME::IsGalCanvasActive(), KiBitmap(), Kiway, LAYER_NO_CONNECTS, EDA_PANEINFO::LayersToolbarPane(), PCAD2KICAD::Left, BOARD_DESIGN_SETTINGS::m_SolderMaskMargin, EDA_PANEINFO::MessageToolbarPane(), KIWAY::Player(), PCAD2KICAD::Right, BOARD::SetElementVisibility(), BOARD::SetVisibleAlls(), and EDA_PANEINFO::VerticalToolbarPane().

219  :
220  PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB_MODULE_EDITOR, wxEmptyString,
221  wxDefaultPosition, wxDefaultSize,
222  KICAD_DEFAULT_DRAWFRAME_STYLE, GetFootprintEditorFrameName() )
223 {
224  m_showBorderAndTitleBlock = false; // true to show the frame references
225  m_showAxis = true; // true to show X and Y axis on screen
226  m_showGridAxis = true; // show the grid origin axis
227  m_hotkeysDescrList = g_Module_Editor_Hokeys_Descr;
228 
229  // Give an icon
230  wxIcon icon;
231  icon.CopyFromBitmap( KiBitmap( icon_modedit_xpm ) );
232  SetIcon( icon );
233 
234  // Show a title (frame title + footprint name):
235  updateTitle();
236 
237  // Create GAL canvas
238  PCB_BASE_FRAME* parentFrame = static_cast<PCB_BASE_FRAME*>( Kiway().Player( FRAME_PCB, true ) );
239  PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
240  GetGalDisplayOptions(),
241  parentFrame->GetGalCanvas()->GetBackend() );
242  SetGalCanvas( drawPanel );
243 
244  SetBoard( new BOARD() );
245  // In modedit, the default net clearance is not known.
246  // (it depends on the actual board)
247  // So we do not show the default clearance, by setting it to 0
248  // The footprint or pad specific clearance will be shown
249  GetBoard()->GetDesignSettings().GetDefault()->SetClearance( 0 );
250 
251  // Don't show the default board solder mask clearance in the footprint editor. Only the
252  // footprint or pad clearance setting should be shown if it is not 0.
254 
255  // restore the last footprint from the project, if any
256  restoreLastFootprint();
257 
258  // Ensure all layers and items are visible:
259  // In footprint editor, some layers have no meaning or
260  // cannot be used, but we show all of them, at least to be able
261  // to edit a bad layer
263 
264  // However the "no net" mark on pads is useless, because there is
265  // no net in footprint editor: make it non visible
267 
268  wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
269  m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas(), font.GetPointSize(), true );
270 
271  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
272  // initialize parameters in m_LayersManager
273  LoadSettings( config() );
274 
275  SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
276  GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
277  GetScreen()->SetCurItem( NULL );
278 
279  GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER );
280  GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
281 
282  // In modedit, set the default paper size to A4:
283  // this should be OK for all footprint to plot/print
284  SetPageSettings( PAGE_INFO( PAGE_INFO::A4 ) );
285 
286  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
287  ReCreateMenuBar();
288  ReCreateHToolbar();
289  ReCreateAuxiliaryToolbar();
290  ReCreateVToolbar();
291  ReCreateOptToolbar();
292 
293  if( m_canvas )
294  m_canvas->SetEnableBlockCommands( true );
295 
296  m_auimgr.SetManagedWindow( this );
297 
298  EDA_PANEINFO horiz;
299  horiz.HorizontalToolbarPane();
300 
301  EDA_PANEINFO vert;
302  vert.VerticalToolbarPane();
303 
304  EDA_PANEINFO mesg_pane;
305  mesg_pane.MessageToolbarPane();
306 
307  // Create a wxAuiPaneInfo for the Layers Manager, not derived from the template.
308  // LAYER_WIDGET is floatable, but initially docked at far right
309  EDA_PANEINFO lyrs;
310  lyrs.LayersToolbarPane();
311  lyrs.MinSize( m_Layers->GetBestSize() ); // updated in ReFillLayerWidget
312  lyrs.BestSize( m_Layers->GetBestSize() );
313  lyrs.Caption( _( "Visibles" ) );
314 
315  m_auimgr.AddPane( m_mainToolBar,
316  wxAuiPaneInfo( horiz ).Name( "m_mainToolBar" ).Top(). Row( 0 ) );
317 
318  m_auimgr.AddPane( m_auxiliaryToolBar,
319  wxAuiPaneInfo( horiz ).Name( "m_auxiliaryToolBar" ).Top().Row( 1 ) );
320 
321  // The main right vertical toolbar
322  m_auimgr.AddPane( m_drawToolBar,
323  wxAuiPaneInfo( vert ).Name( "m_VToolBar" ).Right().Layer(1) );
324 
325  // Add the layer manager ( most right side of pcbframe )
326  m_auimgr.AddPane( m_Layers, lyrs.Name( "m_LayersManagerToolBar" ).Right().Layer( 2 ) );
327  // Layers manager is visible
328  m_auimgr.GetPane( "m_LayersManagerToolBar" ).Show( true );
329 
330  // The left vertical toolbar (fast acces to display options)
331  m_auimgr.AddPane( m_optionsToolBar,
332  wxAuiPaneInfo( vert ).Name( "m_optionsToolBar" ). Left().Layer(1) );
333 
334  m_auimgr.AddPane( m_canvas,
335  wxAuiPaneInfo().Name( "DrawFrame" ).CentrePane() );
336  m_auimgr.AddPane( (wxWindow*) GetGalCanvas(),
337  wxAuiPaneInfo().Name( "DrawFrameGal" ).CentrePane().Hide() );
338 
339  m_auimgr.AddPane( m_messagePanel,
340  wxAuiPaneInfo( mesg_pane ).Name( "MsgPanel" ).Bottom().Layer(10) );
341 
342  // Create the manager and dispatcher & route draw panel events to the dispatcher
343  setupTools();
344  GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
345  UseGalCanvas( parentFrame->IsGalCanvasActive() );
346 
347  if( m_auimgr.GetPane( "m_LayersManagerToolBar" ).IsShown() )
348  {
349  m_Layers->ReFill();
350  m_Layers->ReFillRender();
351 
352  GetScreen()->m_Active_Layer = F_SilkS;
353  m_Layers->SelectLayer( F_SilkS );
354  m_Layers->OnLayerSelected();
355  }
356 
357  m_auimgr.Update();
358 
359  Raise(); // On some window managers, this is needed
360  Show( true );
361 
362  Zoom_Automatique( false );
363 }
EDA_PANEINFO & HorizontalToolbarPane()
Function HorizontalToolbarPane Change *this to a horizontal toolbar for KiCad.
Definition: wxstruct.h:487
int m_SolderMaskMargin
Solder mask margin.
#define KICAD_DEFAULT_DRAWFRAME_STYLE
Definition: wxstruct.h:55
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.
GAL_TYPE GetBackend() const
Function GetBackend Returns the type of backend currently used by GAL canvas.
Class PCB_LAYER_WIDGET is here to implement the abstract functions of LAYER_WIDGET so they may be tie...
void SetVisibleAlls()
Function SetVisibleAlls changes the bit-mask of visible element categories and layers.
EDA_PANEINFO & LayersToolbarPane()
Function LayersToolbarPane Change *this to a layers toolbar for KiCad.
Definition: wxstruct.h:539
Specialization of the wxAuiPaneInfo class for KiCad panels.
Definition: wxstruct.h:478
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
EDA_PANEINFO & VerticalToolbarPane()
Function VerticalToolbarPane Change *this to a vertical toolbar for KiCad.
Definition: wxstruct.h:505
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, KIWAY_PLAYER *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:302
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:532
bool IsGalCanvasActive() const
Function IsGalCanvasActive is used to check which canvas (GAL-based or standard) is currently in use...
Definition: draw_frame.h:862
static const wxChar A4[]
ID_POPUP_GRID_USER
Definition: draw_frame.cpp:108
BOARD * GetBoard()
EDA_PANEINFO & MessageToolbarPane()
Function MessageToolbarPane Change *this to a message pane for KiCad.
Definition: wxstruct.h:524
struct EDA_HOTKEY_CONFIG g_Module_Editor_Hokeys_Descr[]
Common, abstract interface for edit frames.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:870
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
KIWAY Kiway

Variable Documentation