Add support of GAL in FOOTPRINT_WIZARD_FRAME.
Some refinements are needed (for instance the context menu shows the filter command if something is selected, that is useless in the footprint wizard.
This commit is contained in:
parent
08e04acb10
commit
595666d46e
|
@ -2,9 +2,9 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012-2015 Miguel Angel Ajo Pelayo <miguelangel@nbee.es>
|
* Copyright (C) 2012-2015 Miguel Angel Ajo Pelayo <miguelangel@nbee.es>
|
||||||
* Copyright (C) 2012-2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
* Copyright (C) 2012-2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||||
* Copyright (C) 2008-2015 Wayne Stambaugh <stambaughw@verizon.net>
|
* Copyright (C) 2008-2015 Wayne Stambaugh <stambaughw@verizon.net>
|
||||||
* Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -30,7 +30,9 @@
|
||||||
|
|
||||||
#include <fctsys.h>
|
#include <fctsys.h>
|
||||||
#include <kiface_i.h>
|
#include <kiface_i.h>
|
||||||
|
#include <gal/graphics_abstraction_layer.h>
|
||||||
#include <class_drawpanel.h>
|
#include <class_drawpanel.h>
|
||||||
|
#include <pcb_draw_panel_gal.h>
|
||||||
#include <pcb_edit_frame.h>
|
#include <pcb_edit_frame.h>
|
||||||
#include <pcbnew.h>
|
#include <pcbnew.h>
|
||||||
#include <3d_viewer/eda_3d_viewer.h>
|
#include <3d_viewer/eda_3d_viewer.h>
|
||||||
|
@ -56,6 +58,14 @@
|
||||||
#include <wildcards_and_files_ext.h>
|
#include <wildcards_and_files_ext.h>
|
||||||
#include <base_units.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"
|
||||||
|
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME )
|
BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME )
|
||||||
|
|
||||||
// Window events
|
// Window events
|
||||||
|
@ -142,8 +152,23 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway,
|
||||||
|
|
||||||
// Set some display options here, because the FOOTPRINT_WIZARD_FRAME
|
// Set some display options here, because the FOOTPRINT_WIZARD_FRAME
|
||||||
// does not have a config menu to do that:
|
// does not have a config menu to do that:
|
||||||
|
|
||||||
|
// the footprint wizard frame has no config menu. so use some settings
|
||||||
|
// from the caller, or force some options:
|
||||||
|
PCB_BASE_FRAME* caller = dynamic_cast<PCB_BASE_FRAME*>( aParent );
|
||||||
|
|
||||||
|
if( caller )
|
||||||
|
{
|
||||||
|
SetUserUnits( caller->GetUserUnits() );
|
||||||
|
}
|
||||||
|
|
||||||
auto disp_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
|
auto disp_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
|
||||||
disp_opts->m_DisplayPadIsol = false;
|
// In viewer, the default net clearance is not known (it depends on the actual board).
|
||||||
|
// So we do not show the default clearance, by setting it to 0
|
||||||
|
// The footprint or pad specific clearance will be shown
|
||||||
|
GetBoard()->GetDesignSettings().GetDefault()->SetClearance(0);
|
||||||
|
|
||||||
|
disp_opts->m_DisplayPadIsol = true;
|
||||||
disp_opts->m_DisplayPadNum = true;
|
disp_opts->m_DisplayPadNum = true;
|
||||||
GetBoard()->SetElementVisibility( LAYER_NO_CONNECTS, false );
|
GetBoard()->SetElementVisibility( LAYER_NO_CONNECTS, false );
|
||||||
|
|
||||||
|
@ -151,7 +176,13 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway,
|
||||||
|
|
||||||
ReCreateHToolbar();
|
ReCreateHToolbar();
|
||||||
ReCreateVToolbar();
|
ReCreateVToolbar();
|
||||||
SetActiveLayer( F_Cu );
|
|
||||||
|
// Create GAL canvas
|
||||||
|
EDA_DRAW_PANEL_GAL::GAL_TYPE backend = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO;
|
||||||
|
//EDA_DRAW_PANEL_GAL::GAL_TYPE backend = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
|
||||||
|
PCB_DRAW_PANEL_GAL* gal_drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
|
||||||
|
GetGalDisplayOptions(), backend );
|
||||||
|
SetGalCanvas( gal_drawPanel );
|
||||||
|
|
||||||
// Create the parameters panel
|
// Create the parameters panel
|
||||||
m_parametersPanel = new wxPanel( this, wxID_ANY );
|
m_parametersPanel = new wxPanel( this, wxID_ANY );
|
||||||
|
@ -196,6 +227,34 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway,
|
||||||
|
|
||||||
m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
|
m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
|
||||||
|
|
||||||
|
m_auimgr.AddPane( (wxWindow*) GetGalCanvas(),
|
||||||
|
wxAuiPaneInfo().Name( "DrawFrameGal" ).CentrePane().Hide() );
|
||||||
|
|
||||||
|
// Create the manager and dispatcher & route draw panel events to the dispatcher
|
||||||
|
m_toolManager = new TOOL_MANAGER;
|
||||||
|
m_toolManager->SetEnvironment( GetBoard(), gal_drawPanel->GetView(),
|
||||||
|
gal_drawPanel->GetViewControls(), this );
|
||||||
|
m_actions = new PCB_ACTIONS();
|
||||||
|
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
|
||||||
|
gal_drawPanel->SetEventDispatcher( m_toolDispatcher );
|
||||||
|
|
||||||
|
m_toolManager->RegisterTool( new PCBNEW_CONTROL );
|
||||||
|
m_toolManager->RegisterTool( new SELECTION_TOOL ); // for std context menus (zoom & grid)
|
||||||
|
m_toolManager->RegisterTool( new COMMON_TOOLS );
|
||||||
|
m_toolManager->InitTools();
|
||||||
|
|
||||||
|
// Run the control tool, it is supposed to be always active
|
||||||
|
m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
|
||||||
|
|
||||||
|
auto& galOpts = GetGalDisplayOptions();
|
||||||
|
galOpts.m_fullscreenCursor = true;
|
||||||
|
galOpts.m_forceDisplayCursor = true;
|
||||||
|
galOpts.m_axesEnabled = true;
|
||||||
|
|
||||||
|
UseGalCanvas( backend != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE );
|
||||||
|
updateView();
|
||||||
|
|
||||||
|
SetActiveLayer( F_Cu );
|
||||||
// Now Drawpanel is sized, we can use BestZoom to show the component (if any)
|
// Now Drawpanel is sized, we can use BestZoom to show the component (if any)
|
||||||
#ifdef USE_WX_GRAPHICS_CONTEXT
|
#ifdef USE_WX_GRAPHICS_CONTEXT
|
||||||
GetScreen()->SetScalingFactor( BestZoom() );
|
GetScreen()->SetScalingFactor( BestZoom() );
|
||||||
|
@ -217,10 +276,23 @@ FOOTPRINT_WIZARD_FRAME::~FOOTPRINT_WIZARD_FRAME()
|
||||||
// Delete the GRID_TRICKS.
|
// Delete the GRID_TRICKS.
|
||||||
m_parameterGrid->PopEventHandler( true );
|
m_parameterGrid->PopEventHandler( true );
|
||||||
|
|
||||||
|
if( IsGalCanvasActive() )
|
||||||
|
{
|
||||||
|
GetGalCanvas()->StopDrawing();
|
||||||
|
// Be sure any event cannot be fired after frame deletion:
|
||||||
|
GetGalCanvas()->SetEvtHandlerEnabled( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Be sure a active tool (if exists) is desactivated:
|
||||||
|
if( m_toolManager )
|
||||||
|
m_toolManager->DeactivateTool();
|
||||||
|
|
||||||
EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
|
EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
|
||||||
|
|
||||||
if( draw3DFrame )
|
if( draw3DFrame )
|
||||||
draw3DFrame->Destroy();
|
draw3DFrame->Destroy();
|
||||||
|
|
||||||
|
// Now this frame can be deleted
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -274,6 +346,36 @@ void FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FOOTPRINT_WIZARD_FRAME::updateView()
|
||||||
|
{
|
||||||
|
if( IsGalCanvasActive() )
|
||||||
|
{
|
||||||
|
auto dp = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() );
|
||||||
|
dp->UseColorScheme( &Settings().Colors() );
|
||||||
|
dp->DisplayBoard( GetBoard() );
|
||||||
|
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
||||||
|
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
|
||||||
|
UpdateMsgPanel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FOOTPRINT_WIZARD_FRAME::UpdateMsgPanel()
|
||||||
|
{
|
||||||
|
BOARD_ITEM* footprint = GetBoard()->m_Modules;
|
||||||
|
|
||||||
|
if( footprint )
|
||||||
|
{
|
||||||
|
MSG_PANEL_ITEMS items;
|
||||||
|
|
||||||
|
footprint->GetMsgPanelInfo( m_UserUnits, items );
|
||||||
|
SetMsgPanel( items );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ClearMsgPanel();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void FOOTPRINT_WIZARD_FRAME::initParameterGrid()
|
void FOOTPRINT_WIZARD_FRAME::initParameterGrid()
|
||||||
{
|
{
|
||||||
m_parameterGridPage = -1;
|
m_parameterGridPage = -1;
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012 Miguel Angel Ajo Pelayo, miguelangel@nbee.es
|
* Copyright (C) 2012 Miguel Angel Ajo Pelayo, miguelangel@nbee.es
|
||||||
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||||
* Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -86,9 +86,21 @@ public:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void OnSize( wxSizeEvent& event ) override;
|
void OnSize( wxSizeEvent& event ) override;
|
||||||
|
|
||||||
void OnGridSize( wxSizeEvent& aSizeEvent );
|
void OnGridSize( wxSizeEvent& aSizeEvent );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* redraws the message panel.
|
||||||
|
* display the current footprint info, or
|
||||||
|
* clear the message panel if nothing is loaded
|
||||||
|
*/
|
||||||
|
void UpdateMsgPanel() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rebuild the GAL view (reint tool manager, colors and drawings)
|
||||||
|
* must be run after any footprint change.
|
||||||
|
*/
|
||||||
|
void updateView();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function ExportSelectedFootprint();
|
* Function ExportSelectedFootprint();
|
||||||
* will let the caller exit from the wait loop, and get the built footprint
|
* will let the caller exit from the wait loop, and get the built footprint
|
||||||
|
@ -171,12 +183,22 @@ private:
|
||||||
|
|
||||||
bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 ) override;
|
bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 ) override;
|
||||||
|
|
||||||
|
///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription()
|
||||||
|
EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function OnHotKey
|
||||||
|
* handle hot key events.
|
||||||
|
* <p?
|
||||||
|
* Some commands are relative to the item under the mouse cursor. Commands are
|
||||||
|
* case insensitive
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
bool OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem = NULL ) override;
|
||||||
|
|
||||||
void LoadSettings( wxConfigBase* aCfg ) override;
|
void LoadSettings( wxConfigBase* aCfg ) override;
|
||||||
void SaveSettings( wxConfigBase* aCfg ) override;
|
void SaveSettings( wxConfigBase* aCfg ) override;
|
||||||
|
|
||||||
///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription()
|
|
||||||
EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override { return NULL; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function OnActivate
|
* Function OnActivate
|
||||||
* is called when the frame frame is activate to reload the libraries and component lists
|
* is called when the frame frame is activate to reload the libraries and component lists
|
||||||
|
|
|
@ -140,6 +140,7 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint()
|
||||||
DBG(printf( "footprintWizard->GetFootprint() returns NULL\n" );)
|
DBG(printf( "footprintWizard->GetFootprint() returns NULL\n" );)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateView();
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,6 +218,7 @@ void FOOTPRINT_WIZARD_FRAME::SelectFootprintWizard()
|
||||||
void FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard( wxCommandEvent& event )
|
void FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
SelectFootprintWizard();
|
SelectFootprintWizard();
|
||||||
|
updateView();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FOOTPRINT_WIZARD_FRAME::DefaultParameters( wxCommandEvent& event )
|
void FOOTPRINT_WIZARD_FRAME::DefaultParameters( wxCommandEvent& event )
|
||||||
|
@ -232,7 +234,6 @@ void FOOTPRINT_WIZARD_FRAME::DefaultParameters( wxCommandEvent& event )
|
||||||
ReCreateParameterList();
|
ReCreateParameterList();
|
||||||
ReloadFootprint();
|
ReloadFootprint();
|
||||||
DisplayWizardInfos();
|
DisplayWizardInfos();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <pcbnew.h>
|
#include <pcbnew.h>
|
||||||
#include <pcb_edit_frame.h>
|
#include <pcb_edit_frame.h>
|
||||||
#include <footprint_viewer_frame.h>
|
#include <footprint_viewer_frame.h>
|
||||||
|
#include <footprint_wizard_frame.h>
|
||||||
#include <pcbnew_id.h>
|
#include <pcbnew_id.h>
|
||||||
|
|
||||||
#include <hotkeys.h>
|
#include <hotkeys.h>
|
||||||
|
@ -626,3 +627,90 @@ bool FOOTPRINT_VIEWER_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aP
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
EDA_HOTKEY* FOOTPRINT_WIZARD_FRAME::GetHotKeyDescription( int aCommand ) const
|
||||||
|
{
|
||||||
|
EDA_HOTKEY* HK_Descr = GetDescriptorFromCommand( aCommand, common_Hotkey_List );
|
||||||
|
|
||||||
|
return HK_Descr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool FOOTPRINT_WIZARD_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
|
||||||
|
EDA_ITEM* aItem )
|
||||||
|
{
|
||||||
|
if( aHotKey == 0 )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
||||||
|
cmd.SetEventObject( this );
|
||||||
|
|
||||||
|
/* Convert lower to upper case (the usual toupper function has problem with non ascii
|
||||||
|
* codes like function keys */
|
||||||
|
if( (aHotKey >= 'a') && (aHotKey <= 'z') )
|
||||||
|
aHotKey += 'A' - 'a';
|
||||||
|
|
||||||
|
EDA_HOTKEY* HK_Descr = GetDescriptorFromHotkey( aHotKey, common_Hotkey_List );
|
||||||
|
|
||||||
|
if( HK_Descr == NULL )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
switch( HK_Descr->m_Idcommand )
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case HK_NOT_FOUND:
|
||||||
|
return false;
|
||||||
|
|
||||||
|
case HK_HELP: // Display Current hotkey list
|
||||||
|
DisplayHotkeyList( this, g_Module_Viewer_Hotkeys_Descr );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HK_RESET_LOCAL_COORD: // set local (relative) coordinate origin
|
||||||
|
GetScreen()->m_O_Curseur = GetCrossHairPosition();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HK_LEFT_CLICK:
|
||||||
|
OnLeftClick( aDC, aPosition );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HK_LEFT_DCLICK: // Simulate a double left click: generate 2 events
|
||||||
|
OnLeftClick( aDC, aPosition );
|
||||||
|
OnLeftDClick( aDC, aPosition );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HK_SWITCH_UNITS:
|
||||||
|
cmd.SetId( (GetUserUnits() == INCHES) ?
|
||||||
|
ID_TB_OPTIONS_SELECT_UNIT_MM : ID_TB_OPTIONS_SELECT_UNIT_INCH );
|
||||||
|
GetEventHandler()->ProcessEvent( cmd );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HK_ZOOM_IN:
|
||||||
|
cmd.SetId( ID_KEY_ZOOM_IN );
|
||||||
|
GetEventHandler()->ProcessEvent( cmd );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HK_ZOOM_OUT:
|
||||||
|
cmd.SetId( ID_KEY_ZOOM_OUT );
|
||||||
|
GetEventHandler()->ProcessEvent( cmd );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HK_ZOOM_REDRAW:
|
||||||
|
cmd.SetId( ID_ZOOM_REDRAW );
|
||||||
|
GetEventHandler()->ProcessEvent( cmd );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HK_ZOOM_CENTER:
|
||||||
|
cmd.SetId( ID_POPUP_ZOOM_CENTER );
|
||||||
|
GetEventHandler()->ProcessEvent( cmd );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HK_ZOOM_AUTO:
|
||||||
|
cmd.SetId( ID_ZOOM_PAGE );
|
||||||
|
GetEventHandler()->ProcessEvent( cmd );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue