Migrate Pcbnew/footprint viewer/footprint editor to the new UI update system

This commit is contained in:
Ian McInerney 2020-08-14 00:09:17 +01:00
parent fd4388710d
commit e8b11c911e
23 changed files with 1028 additions and 739 deletions

View File

@ -517,6 +517,7 @@ set( PCB_COMMON_SRCS
${CMAKE_SOURCE_DIR}/pcbnew/tools/grid_helper.cpp ${CMAKE_SOURCE_DIR}/pcbnew/tools/grid_helper.cpp
${CMAKE_SOURCE_DIR}/pcbnew/tools/pcb_actions.cpp ${CMAKE_SOURCE_DIR}/pcbnew/tools/pcb_actions.cpp
${CMAKE_SOURCE_DIR}/pcbnew/tools/pcb_editor_conditions.cpp
${CMAKE_SOURCE_DIR}/pcbnew/tools/pcb_viewer_tools.cpp ${CMAKE_SOURCE_DIR}/pcbnew/tools/pcb_viewer_tools.cpp
widgets/net_selector.cpp widgets/net_selector.cpp

View File

@ -100,7 +100,7 @@ void ACTION_TOOLBAR::AddScaledSeparator( wxWindow* aWindow )
} }
void ACTION_TOOLBAR::AddToolContextMenu( const TOOL_ACTION& aAction, CONDITIONAL_MENU* aMenu ) void ACTION_TOOLBAR::AddToolContextMenu( const TOOL_ACTION& aAction, ACTION_MENU* aMenu )
{ {
int toolId = aAction.GetUIId(); int toolId = aAction.GetUIId();
@ -208,10 +208,12 @@ void ACTION_TOOLBAR::onToolRightClick( wxAuiToolBarEvent& aEvent )
return; return;
// Update and show the menu // Update and show the menu
CONDITIONAL_MENU* menu = it->second; ACTION_MENU* menu = it->second;
SELECTION dummySel; SELECTION dummySel;
if( CONDITIONAL_MENU* condMenu = dynamic_cast<CONDITIONAL_MENU*>( menu ) )
condMenu->Evaluate( dummySel );
menu->Evaluate( dummySel );
menu->UpdateAll(); menu->UpdateAll();
PopupMenu( menu ); PopupMenu( menu );

View File

@ -65,6 +65,12 @@ SELECTION_CONDITION EDITOR_CONDITIONS::CurrentTool( const TOOL_ACTION& aTool )
} }
SELECTION_CONDITION EDITOR_CONDITIONS::NoActiveTool()
{
return std::bind( &EDITOR_CONDITIONS::noToolFunc, _1, m_frame );
}
SELECTION_CONDITION EDITOR_CONDITIONS::GridVisible() SELECTION_CONDITION EDITOR_CONDITIONS::GridVisible()
{ {
// The grid visibility check requires a draw frame // The grid visibility check requires a draw frame
@ -141,6 +147,12 @@ bool EDITOR_CONDITIONS::toolFunc( const SELECTION& aSelection, EDA_BASE_FRAME* a
} }
bool EDITOR_CONDITIONS::noToolFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame )
{
return aFrame->ToolStackIsEmpty();
}
bool EDITOR_CONDITIONS::gridFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame ) bool EDITOR_CONDITIONS::gridFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame )
{ {
return aFrame->IsGridVisible(); return aFrame->IsGridVisible();

View File

@ -179,9 +179,21 @@ SELECTION_CONDITION operator||( const SELECTION_CONDITION& aConditionA,
return std::bind( &SELECTION_CONDITIONS::orBoolFunc, aConditionA, std::ref( aConditionB ), _1 ); return std::bind( &SELECTION_CONDITIONS::orBoolFunc, aConditionA, std::ref( aConditionB ), _1 );
} }
SELECTION_CONDITION operator||( SELECTION_BOOL aConditionA,
const SELECTION_CONDITION& aConditionB )
{
return aConditionB || aConditionA;
}
SELECTION_CONDITION operator&&( const SELECTION_CONDITION& aConditionA, SELECTION_CONDITION operator&&( const SELECTION_CONDITION& aConditionA,
SELECTION_BOOL aConditionB ) SELECTION_BOOL aConditionB )
{ {
return std::bind( &SELECTION_CONDITIONS::andBoolFunc, aConditionA, std::ref( aConditionB ), _1 ); return std::bind( &SELECTION_CONDITIONS::andBoolFunc, aConditionA, std::ref( aConditionB ), _1 );
} }
SELECTION_CONDITION operator&&( SELECTION_BOOL aConditionA,
const SELECTION_CONDITION& aConditionB )
{
return aConditionB && aConditionA;
}

View File

@ -43,7 +43,6 @@
#include <settings/settings_manager.h> #include <settings/settings_manager.h>
#include <tool/action_toolbar.h> #include <tool/action_toolbar.h>
#include <tool/common_tools.h> #include <tool/common_tools.h>
#include <tool/editor_conditions.h>
#include <tool/tool_dispatcher.h> #include <tool/tool_dispatcher.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tool/zoom_tool.h> #include <tool/zoom_tool.h>
@ -51,6 +50,7 @@
#include <display_footprints_frame.h> #include <display_footprints_frame.h>
#include <tools/cvpcb_actions.h> #include <tools/cvpcb_actions.h>
#include <tools/pcb_actions.h> #include <tools/pcb_actions.h>
#include <tools/pcb_editor_conditions.h> // Shared conditions with other pcbnew frames
#include <tools/pcb_viewer_tools.h> // shared tools with other pcbnew frames #include <tools/pcb_viewer_tools.h> // shared tools with other pcbnew frames
#include <tools/cvpcb_fpviewer_selection_tool.h> #include <tools/cvpcb_fpviewer_selection_tool.h>
#include <widgets/infobar.h> #include <widgets/infobar.h>
@ -185,8 +185,8 @@ void DISPLAY_FOOTPRINTS_FRAME::setupUIConditions()
{ {
PCB_BASE_FRAME::setupUIConditions(); PCB_BASE_FRAME::setupUIConditions();
ACTION_MANAGER* mgr = m_toolManager->GetActionManager(); ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
EDITOR_CONDITIONS cond( this ); PCB_EDITOR_CONDITIONS cond( this );
wxASSERT( mgr ); wxASSERT( mgr );
@ -209,35 +209,11 @@ void DISPLAY_FOOTPRINTS_FRAME::setupUIConditions()
return GetAutoZoom(); return GetAutoZoom();
}; };
auto padNumCond =
[this] ( const SELECTION& aSel )
{
return GetDisplayOptions().m_DisplayPadNum;
};
auto padFillCond =
[this] ( const SELECTION& aSel )
{
return !GetDisplayOptions().m_DisplayPadFill;
};
auto textFillCond =
[this] ( const SELECTION& aSel )
{
return !GetDisplayOptions().m_DisplayTextFill;
};
auto graphicsFillCond =
[this] ( const SELECTION& aSel )
{
return !GetDisplayOptions().m_DisplayGraphicsFill;
};
mgr->SetConditions( PCB_ACTIONS::zoomFootprintAutomatically, CHECK( autoZoomCond ) ); mgr->SetConditions( PCB_ACTIONS::zoomFootprintAutomatically, CHECK( autoZoomCond ) );
mgr->SetConditions( PCB_ACTIONS::showPadNumbers, CHECK( padNumCond ) ); mgr->SetConditions( PCB_ACTIONS::showPadNumbers, CHECK( cond.PadNumbersDisplay() ) );
mgr->SetConditions( PCB_ACTIONS::padDisplayMode, CHECK( padFillCond ) ); mgr->SetConditions( PCB_ACTIONS::padDisplayMode, CHECK( !cond.PadFillDisplay() ) );
mgr->SetConditions( PCB_ACTIONS::textOutlines, CHECK( textFillCond ) ); mgr->SetConditions( PCB_ACTIONS::textOutlines, CHECK( !cond.TextFillDisplay() ) );
mgr->SetConditions( PCB_ACTIONS::graphicsOutlines, CHECK( graphicsFillCond ) ); mgr->SetConditions( PCB_ACTIONS::graphicsOutlines, CHECK( !cond.GraphicsFillDisplay() ) );
#undef CHECK #undef CHECK
} }

View File

@ -29,7 +29,7 @@
#include <wx/aui/auibar.h> #include <wx/aui/auibar.h>
#include <tool/tool_event.h> #include <tool/tool_event.h>
class CONDITIONAL_MENU; class ACTION_MENU;
class EDA_BASE_FRAME; class EDA_BASE_FRAME;
class TOOL_MANAGER; class TOOL_MANAGER;
class TOOL_ACTION; class TOOL_ACTION;
@ -77,7 +77,7 @@ public:
* @param aAction is the action to get the menu * @param aAction is the action to get the menu
* @param aMenu is the context menu * @param aMenu is the context menu
*/ */
void AddToolContextMenu( const TOOL_ACTION& aAction, CONDITIONAL_MENU* aMenu ); void AddToolContextMenu( const TOOL_ACTION& aAction, ACTION_MENU* aMenu );
/** /**
* Clear the toolbar and remove all associated menus. * Clear the toolbar and remove all associated menus.
@ -111,7 +111,7 @@ protected:
TOOL_MANAGER* m_toolManager; TOOL_MANAGER* m_toolManager;
std::map<int, bool> m_toolKinds; std::map<int, bool> m_toolKinds;
std::map<int, const TOOL_ACTION*> m_toolActions; std::map<int, const TOOL_ACTION*> m_toolActions;
std::map<int, CONDITIONAL_MENU*> m_toolMenus; std::map<int, ACTION_MENU*> m_toolMenus;
}; };
#endif #endif

View File

@ -84,6 +84,13 @@ public:
*/ */
SELECTION_CONDITION CurrentTool( const TOOL_ACTION& aTool ); SELECTION_CONDITION CurrentTool( const TOOL_ACTION& aTool );
/**
* Creates a functor testing if there are no tools active in the frame.
*
* @return Functor testing the frame has no tools running
*/
SELECTION_CONDITION NoActiveTool();
/** /**
* Creates a functor testing if the grid is visible in a frame. * Creates a functor testing if the grid is visible in a frame.
* *
@ -120,7 +127,7 @@ public:
*/ */
SELECTION_CONDITION CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE aType ); SELECTION_CONDITION CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE aType );
private: protected:
///> Helper function used by ContentModified() ///> Helper function used by ContentModified()
static bool contentModifiedFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame ); static bool contentModifiedFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame );
@ -136,6 +143,9 @@ private:
///> Helper function used by CurrentTool() ///> Helper function used by CurrentTool()
static bool toolFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame, const TOOL_ACTION& aTool ); static bool toolFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame, const TOOL_ACTION& aTool );
///> Helper function used by NoActiveTool()
static bool noToolFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame );
///> Helper function used by GridVisible() ///> Helper function used by GridVisible()
static bool gridFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame ); static bool gridFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame );

View File

@ -51,9 +51,14 @@ typedef bool ( &SELECTION_BOOL )( const SELECTION& );
SELECTION_CONDITION operator||( const SELECTION_CONDITION& aConditionA, SELECTION_CONDITION operator||( const SELECTION_CONDITION& aConditionA,
SELECTION_BOOL aConditionB ); SELECTION_BOOL aConditionB );
SELECTION_CONDITION operator||( SELECTION_BOOL aConditionA,
const SELECTION_CONDITION& aConditionB );
SELECTION_CONDITION operator&&( const SELECTION_CONDITION& aConditionA, SELECTION_CONDITION operator&&( const SELECTION_CONDITION& aConditionA,
SELECTION_BOOL aConditionB ); SELECTION_BOOL aConditionB );
SELECTION_CONDITION operator&&( SELECTION_BOOL aConditionA,
const SELECTION_CONDITION& aConditionB );
/** /**
* Class that groups generic conditions for selected items. * Class that groups generic conditions for selected items.

View File

@ -61,9 +61,11 @@
#include <tool/action_toolbar.h> #include <tool/action_toolbar.h>
#include <tool/common_control.h> #include <tool/common_control.h>
#include <tool/common_tools.h> #include <tool/common_tools.h>
#include <tool/selection.h>
#include <tool/tool_dispatcher.h> #include <tool/tool_dispatcher.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tool/zoom_tool.h> #include <tool/zoom_tool.h>
#include <tools/pcb_editor_conditions.h>
#include <tools/pcb_viewer_tools.h> #include <tools/pcb_viewer_tools.h>
#include <tools/position_relative_tool.h> #include <tools/position_relative_tool.h>
#include <widgets/infobar.h> #include <widgets/infobar.h>
@ -173,6 +175,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent,
// Create the manager and dispatcher & route draw panel events to the dispatcher // Create the manager and dispatcher & route draw panel events to the dispatcher
setupTools(); setupTools();
setupUIConditions();
initLibraryTree(); initLibraryTree();
m_treePane = new FOOTPRINT_TREE_PANE( this ); m_treePane = new FOOTPRINT_TREE_PANE( this );
@ -272,6 +275,12 @@ bool FOOTPRINT_EDIT_FRAME::IsContentModified()
} }
SELECTION& FOOTPRINT_EDIT_FRAME::GetCurrentSelection()
{
return m_toolManager->GetTool<SELECTION_TOOL>()->GetSelection();
}
void FOOTPRINT_EDIT_FRAME::SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ) void FOOTPRINT_EDIT_FRAME::SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType )
{ {
// switches currently used canvas (Cairo / OpenGL). // switches currently used canvas (Cairo / OpenGL).
@ -897,6 +906,104 @@ void FOOTPRINT_EDIT_FRAME::setupTools()
} }
void FOOTPRINT_EDIT_FRAME::setupUIConditions()
{
PCB_BASE_EDIT_FRAME::setupUIConditions();
ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
PCB_EDITOR_CONDITIONS cond( this );
wxASSERT( mgr );
#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
#define CHECK( x ) ACTION_CONDITIONS().Check( x )
auto haveFootprintCond =
[this]( const SELECTION& )
{
return GetBoard()->GetFirstModule() != nullptr;
};
auto footprintTargettedCond =
[this] ( const SELECTION& )
{
return !GetTargetFPID().GetLibItemName().empty();
};
mgr->SetConditions( ACTIONS::saveAs, ENABLE( footprintTargettedCond ) );
mgr->SetConditions( ACTIONS::revert, ENABLE( cond.ContentModified() ) );
mgr->SetConditions( PCB_ACTIONS::saveToBoard, ENABLE( cond.ContentModified() ) );
mgr->SetConditions( PCB_ACTIONS::saveToLibrary, ENABLE( cond.ContentModified() ) );
mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) );
mgr->SetConditions( ACTIONS::metricUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
mgr->SetConditions( ACTIONS::imperialUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
mgr->SetConditions( ACTIONS::acceleratedGraphics, CHECK( cond.CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) ) );
mgr->SetConditions( ACTIONS::standardGraphics, CHECK( cond.CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) ) );
mgr->SetConditions( ACTIONS::cut, ENABLE( SELECTION_CONDITIONS::NotEmpty ) );
mgr->SetConditions( ACTIONS::copy, ENABLE( SELECTION_CONDITIONS::NotEmpty ) );
mgr->SetConditions( ACTIONS::paste, ENABLE( SELECTION_CONDITIONS::Idle && cond.NoActiveTool() ) );
mgr->SetConditions( ACTIONS::pasteSpecial, ENABLE( SELECTION_CONDITIONS::Idle && cond.NoActiveTool() ) );
mgr->SetConditions( ACTIONS::doDelete, ENABLE( SELECTION_CONDITIONS::NotEmpty ) );
mgr->SetConditions( ACTIONS::duplicate, ENABLE( SELECTION_CONDITIONS::NotEmpty ) );
mgr->SetConditions( PCB_ACTIONS::padDisplayMode, CHECK( !cond.PadFillDisplay() ) );
mgr->SetConditions( PCB_ACTIONS::textOutlines, CHECK( !cond.TextFillDisplay() ) );
mgr->SetConditions( PCB_ACTIONS::graphicsOutlines, CHECK( !cond.GraphicsFillDisplay() ) );
mgr->SetConditions( ACTIONS::zoomTool, CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
mgr->SetConditions( ACTIONS::selectionTool, CHECK( cond.CurrentTool( ACTIONS::selectionTool ) ) );
auto highContrastCond =
[this] ( const SELECTION& )
{
return GetDisplayOptions().m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL;
};
auto footprintTreeCond =
[this] (const SELECTION& )
{
return IsSearchTreeShown();
};
mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastCond ) );
mgr->SetConditions( PCB_ACTIONS::toggleFootprintTree, CHECK( footprintTreeCond ) );
mgr->SetConditions( ACTIONS::print, ENABLE( haveFootprintCond ) );
mgr->SetConditions( PCB_ACTIONS::exportFootprint, ENABLE( haveFootprintCond ) );
mgr->SetConditions( PCB_ACTIONS::footprintProperties, ENABLE( haveFootprintCond ) );
mgr->SetConditions( PCB_ACTIONS::cleanupGraphics, ENABLE( haveFootprintCond ) );
// Only enable a tool if the part is edtable
#define CURRENT_EDIT_TOOL( action ) mgr->SetConditions( action, \
ACTION_CONDITIONS().Enable( haveFootprintCond ).Check( cond.CurrentTool( action ) ) )
CURRENT_EDIT_TOOL( ACTIONS::deleteTool );
CURRENT_EDIT_TOOL( ACTIONS::measureTool );
CURRENT_EDIT_TOOL( PCB_ACTIONS::placePad );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawLine );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawRectangle );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawCircle );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawArc );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawPolygon );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawZoneKeepout );
CURRENT_EDIT_TOOL( PCB_ACTIONS::placeText );
CURRENT_EDIT_TOOL( PCB_ACTIONS::setAnchor );
CURRENT_EDIT_TOOL( PCB_ACTIONS::gridSetOrigin );
#undef CURRENT_EDIT_TOOL
#undef ENABLE
#undef CHECK
}
void FOOTPRINT_EDIT_FRAME::ActivateGalCanvas() void FOOTPRINT_EDIT_FRAME::ActivateGalCanvas()
{ {
PCB_BASE_EDIT_FRAME::ActivateGalCanvas(); PCB_BASE_EDIT_FRAME::ActivateGalCanvas();

View File

@ -32,6 +32,7 @@ class EDGE_MODULE;
class FOOTPRINT_TREE_PANE; class FOOTPRINT_TREE_PANE;
class LIB_MANAGER; class LIB_MANAGER;
class FOOTPRINT_EDITOR_SETTINGS; class FOOTPRINT_EDITOR_SETTINGS;
class PCBNEW_SELECTION;
namespace PCB { struct IFACE; } // A KIFACE_I coded in pcbnew.c namespace PCB { struct IFACE; } // A KIFACE_I coded in pcbnew.c
@ -61,6 +62,7 @@ public:
///> @copydoc PCB_BASE_FRAME::GetModel() ///> @copydoc PCB_BASE_FRAME::GetModel()
BOARD_ITEM_CONTAINER* GetModel() const override; BOARD_ITEM_CONTAINER* GetModel() const override;
SELECTION& GetCurrentSelection() override;
/** /**
* Get if any footprints or libraries have been modified but not saved. * Get if any footprints or libraries have been modified but not saved.
@ -340,8 +342,6 @@ public:
void KiwayMailIn( KIWAY_EXPRESS& mail ) override; void KiwayMailIn( KIWAY_EXPRESS& mail ) override;
void SyncToolbars() override;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
protected: protected:
@ -373,6 +373,8 @@ protected:
* Run the Footprint Properties dialog and handle changes made in it. * Run the Footprint Properties dialog and handle changes made in it.
*/ */
void editFootprintProperties( MODULE* aFootprint ); void editFootprintProperties( MODULE* aFootprint );
void setupUIConditions() override;
}; };
#endif // FOOTPRINT_EDIT_FRAME_H #endif // FOOTPRINT_EDIT_FRAME_H

View File

@ -46,11 +46,13 @@
#include <tool/action_toolbar.h> #include <tool/action_toolbar.h>
#include <tool/common_control.h> #include <tool/common_control.h>
#include <tool/common_tools.h> #include <tool/common_tools.h>
#include <tool/selection.h>
#include <tool/tool_dispatcher.h> #include <tool/tool_dispatcher.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tool/zoom_tool.h> #include <tool/zoom_tool.h>
#include <tools/pcb_viewer_tools.h> #include <tools/pcb_viewer_tools.h>
#include <tools/pcb_actions.h> #include <tools/pcb_actions.h>
#include <tools/pcb_editor_conditions.h>
#include <tools/pcbnew_control.h> #include <tools/pcbnew_control.h>
#include <tools/pcbnew_picker_tool.h> #include <tools/pcbnew_picker_tool.h>
#include <tools/selection_tool.h> #include <tools/selection_tool.h>
@ -212,6 +214,7 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent
m_toolManager->InitTools(); m_toolManager->InitTools();
m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" ); m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
setupUIConditions();
ReCreateMenuBar(); ReCreateMenuBar();
ReCreateHToolbar(); ReCreateHToolbar();
ReCreateVToolbar(); ReCreateVToolbar();
@ -285,6 +288,52 @@ FOOTPRINT_VIEWER_FRAME::~FOOTPRINT_VIEWER_FRAME()
} }
SELECTION& FOOTPRINT_VIEWER_FRAME::GetCurrentSelection()
{
return m_toolManager->GetTool<SELECTION_TOOL>()->GetSelection();
}
void FOOTPRINT_VIEWER_FRAME::setupUIConditions()
{
PCB_BASE_FRAME::setupUIConditions();
ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
PCB_EDITOR_CONDITIONS cond( this );
wxASSERT( mgr );
#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
#define CHECK( x ) ACTION_CONDITIONS().Check( x )
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) );
mgr->SetConditions( ACTIONS::metricUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
mgr->SetConditions( ACTIONS::imperialUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
mgr->SetConditions( ACTIONS::zoomTool, CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
mgr->SetConditions( ACTIONS::measureTool, CHECK( cond.CurrentTool( ACTIONS::measureTool ) ) );
mgr->SetConditions( ACTIONS::selectionTool, CHECK( cond.CurrentTool( ACTIONS::selectionTool ) ) );
mgr->SetConditions( PCB_ACTIONS::showPadNumbers, CHECK( cond.PadNumbersDisplay() ) );
mgr->SetConditions( PCB_ACTIONS::padDisplayMode, CHECK( !cond.PadFillDisplay() ) );
mgr->SetConditions( PCB_ACTIONS::textOutlines, CHECK( !cond.TextFillDisplay() ) );
mgr->SetConditions( PCB_ACTIONS::graphicsOutlines, CHECK( !cond.GraphicsFillDisplay() ) );
auto autoZoomCond =
[this] ( const SELECTION& )
{
return GetAutoZoom();
};
mgr->SetConditions( PCB_ACTIONS::zoomFootprintAutomatically, CHECK( autoZoomCond ) );
#undef ENABLE
#undef CHECK
}
void FOOTPRINT_VIEWER_FRAME::OnCloseWindow( wxCloseEvent& Event ) void FOOTPRINT_VIEWER_FRAME::OnCloseWindow( wxCloseEvent& Event )
{ {
// A workaround to avoid flicker, in modal mode when modview frame is destroyed, // A workaround to avoid flicker, in modal mode when modview frame is destroyed,

View File

@ -34,6 +34,7 @@ class wxSashLayoutWindow;
class wxListBox; class wxListBox;
class FP_LIB_TABLE; class FP_LIB_TABLE;
class BOARD_ITEM; class BOARD_ITEM;
class SELECTION;
namespace PCB { struct IFACE; } namespace PCB { struct IFACE; }
@ -49,6 +50,8 @@ protected:
MAGNETIC_SETTINGS m_magneticItems; MAGNETIC_SETTINGS m_magneticItems;
void setupUIConditions() override;
public: public:
~FOOTPRINT_VIEWER_FRAME(); ~FOOTPRINT_VIEWER_FRAME();
@ -56,6 +59,8 @@ public:
///> @copydoc PCB_BASE_FRAME::GetModel() ///> @copydoc PCB_BASE_FRAME::GetModel()
BOARD_ITEM_CONTAINER* GetModel() const override; BOARD_ITEM_CONTAINER* GetModel() const override;
SELECTION& GetCurrentSelection() override;
virtual COLOR4D GetGridColor() override; virtual COLOR4D GetGridColor() override;
bool GetAutoZoom() override; bool GetAutoZoom() override;
@ -124,7 +129,6 @@ private:
void ReCreateVToolbar() override; void ReCreateVToolbar() override;
void ReCreateOptToolbar() override; void ReCreateOptToolbar() override;
void ReCreateMenuBar() override; void ReCreateMenuBar() override;
void SyncToolbars() override;
void OnLibFilter( wxCommandEvent& aEvent ); void OnLibFilter( wxCommandEvent& aEvent );
void OnFPFilter( wxCommandEvent& aEvent ); void OnFPFilter( wxCommandEvent& aEvent );

View File

@ -28,7 +28,7 @@
#include "pcbnew_id.h" #include "pcbnew_id.h"
#include <menus_helpers.h> #include <menus_helpers.h>
#include <tool/actions.h> #include <tool/actions.h>
#include <tool/conditional_menu.h> #include <tool/action_menu.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tools/pcb_actions.h> #include <tools/pcb_actions.h>
#include <class_board.h> #include <class_board.h>
@ -44,36 +44,29 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
wxMenuBar* oldMenuBar = GetMenuBar(); wxMenuBar* oldMenuBar = GetMenuBar();
WX_MENUBAR* menuBar = new WX_MENUBAR(); WX_MENUBAR* menuBar = new WX_MENUBAR();
auto modifiedDocumentCondition = [this]( const SELECTION& sel ) {
return IsContentModified();
};
auto haveFootprintCondition = [this]( const SELECTION& aSelection ) {
return GetBoard()->GetFirstModule() != nullptr;
};
auto footprintTargettedCondition = [this]( const SELECTION& aSelection ) {
return !GetTargetFPID().GetLibItemName().empty();
};
//-- File menu ---------------------------------------------------------- //-- File menu ----------------------------------------------------------
// //
CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool );
fileMenu->Add( ACTIONS::newLibrary );
fileMenu->Add( ACTIONS::addLibrary );
fileMenu->Add( PCB_ACTIONS::newFootprint );
fileMenu->AddItem( ACTIONS::newLibrary, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddItem( ACTIONS::addLibrary, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddItem( PCB_ACTIONS::newFootprint, SELECTION_CONDITIONS::ShowAlways );
#ifdef KICAD_SCRIPTING #ifdef KICAD_SCRIPTING
fileMenu->AddItem( PCB_ACTIONS::createFootprint, SELECTION_CONDITIONS::ShowAlways ); fileMenu->Add( PCB_ACTIONS::createFootprint );
#endif #endif
fileMenu->AddSeparator(); fileMenu->AppendSeparator();
if( IsCurrentFPFromBoard() )
fileMenu->AddItem( PCB_ACTIONS::saveToBoard, modifiedDocumentCondition );
else
fileMenu->AddItem( PCB_ACTIONS::saveToLibrary, modifiedDocumentCondition );
fileMenu->AddItem( ACTIONS::saveAs, footprintTargettedCondition );
fileMenu->AddItem( ACTIONS::revert, modifiedDocumentCondition );
fileMenu->AddSeparator(); if( IsCurrentFPFromBoard() )
fileMenu->Add( PCB_ACTIONS::saveToBoard );
else
fileMenu->Add( PCB_ACTIONS::saveToLibrary );
fileMenu->Add( ACTIONS::saveAs );
fileMenu->Add( ACTIONS::revert );
fileMenu->AppendSeparator();
ACTION_MENU* submenuImport = new ACTION_MENU( false ); ACTION_MENU* submenuImport = new ACTION_MENU( false );
submenuImport->SetTool( selTool ); submenuImport->SetTool( selTool );
@ -83,228 +76,175 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
submenuImport->Add( PCB_ACTIONS::importFootprint ); submenuImport->Add( PCB_ACTIONS::importFootprint );
submenuImport->Add( _( "&Import Graphics..." ), submenuImport->Add( _( "&Import Graphics..." ),
_( "Import 2D Drawing file to Footprint Editor on Drawings layer" ), _( "Import 2D Drawing file to Footprint Editor on Drawings layer" ),
ID_GEN_IMPORT_GRAPHICS_FILE, import_vector_xpm ); ID_GEN_IMPORT_GRAPHICS_FILE,
import_vector_xpm );
fileMenu->AddMenu( submenuImport, SELECTION_CONDITIONS::ShowAlways ); fileMenu->Add( submenuImport );
CONDITIONAL_MENU* submenuExport = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool );
submenuExport->SetTitle( _( "Export" ) ); submenuExport->SetTitle( _( "Export" ) );
submenuExport->SetIcon( export_xpm ); submenuExport->SetIcon( export_xpm );
submenuExport->AddItem( PCB_ACTIONS::exportFootprint, haveFootprintCondition ); submenuExport->Add( PCB_ACTIONS::exportFootprint );
submenuExport->AddItem( ID_MODEDIT_SAVE_PNG, _( "Export View as &PNG..." ), submenuExport->Add( _( "Export View as &PNG..." ),
_( "Create a PNG file from the current view" ), _( "Create a PNG file from the current view" ),
plot_xpm, SELECTION_CONDITIONS::ShowAlways ); ID_MODEDIT_SAVE_PNG,
plot_xpm );
fileMenu->AddMenu( submenuExport, SELECTION_CONDITIONS::ShowAlways ); fileMenu->Add( submenuExport );
fileMenu->AddSeparator(); fileMenu->AppendSeparator();
fileMenu->AddItem( ACTIONS::print, haveFootprintCondition ); fileMenu->Add( ACTIONS::print );
fileMenu->AddSeparator(); fileMenu->AppendSeparator();
fileMenu->AddClose( _( "Footprint Editor" ) ); fileMenu->AddClose( _( "Footprint Editor" ) );
fileMenu->Resolve();
//-- Edit menu ------------------------------------------------------- //-- Edit menu -------------------------------------------------------
// //
CONDITIONAL_MENU* editMenu = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* editMenu = new ACTION_MENU( false, selTool );
auto enableUndoCondition = [ this ] ( const SELECTION& sel ) { editMenu->Add( ACTIONS::undo );
return GetUndoCommandCount() > 0; editMenu->Add( ACTIONS::redo );
};
auto enableRedoCondition = [ this ] ( const SELECTION& sel ) {
return GetRedoCommandCount() > 0;
};
auto noActiveToolCondition = [ this ] ( const SELECTION& aSelection ) {
return ToolStackIsEmpty();
};
editMenu->AddItem( ACTIONS::undo, enableUndoCondition ); editMenu->AppendSeparator();
editMenu->AddItem( ACTIONS::redo, enableRedoCondition ); editMenu->Add( ACTIONS::cut );
editMenu->Add( ACTIONS::copy );
editMenu->Add( ACTIONS::paste );
editMenu->Add( ACTIONS::doDelete );
editMenu->Add( ACTIONS::duplicate );
editMenu->AddSeparator(); editMenu->AppendSeparator();
editMenu->AddItem( ACTIONS::cut, SELECTION_CONDITIONS::NotEmpty ); editMenu->Add( PCB_ACTIONS::footprintProperties );
editMenu->AddItem( ACTIONS::copy, SELECTION_CONDITIONS::NotEmpty ); editMenu->Add( PCB_ACTIONS::defaultPadProperties );
editMenu->AddItem( ACTIONS::paste, noActiveToolCondition );
editMenu->AddItem( ACTIONS::doDelete, SELECTION_CONDITIONS::NotEmpty );
editMenu->AddItem( ACTIONS::duplicate, SELECTION_CONDITIONS::NotEmpty );
editMenu->AddSeparator(); editMenu->AppendSeparator();
editMenu->AddItem( PCB_ACTIONS::footprintProperties, haveFootprintCondition ); editMenu->Add( PCB_ACTIONS::cleanupGraphics );
editMenu->AddItem( PCB_ACTIONS::defaultPadProperties, SELECTION_CONDITIONS::ShowAlways );
editMenu->AddSeparator();
editMenu->AddItem( PCB_ACTIONS::cleanupGraphics, haveFootprintCondition );
editMenu->Resolve();
//-- View menu ------------------------------------------------------- //-- View menu -------------------------------------------------------
// //
CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
auto gridShownCondition = [ this ] ( const SELECTION& aSel ) { viewMenu->Add( ACTIONS::showFootprintBrowser );
return IsGridVisible(); viewMenu->Add( ACTIONS::show3DViewer );
};
auto polarCoordsCondition = [ this ] ( const SELECTION& aSel ) {
return GetShowPolarCoords();
};
auto imperialUnitsCondition = [this]( const SELECTION& aSel ) {
return GetUserUnits() == EDA_UNITS::INCHES;
};
auto metricUnitsCondition = [this]( const SELECTION& aSel ) {
return GetUserUnits() == EDA_UNITS::MILLIMETRES;
};
auto fullCrosshairCondition = [ this ] ( const SELECTION& aSel ) {
return GetGalDisplayOptions().m_fullscreenCursor;
};
auto sketchPadsCondition = [ this ] ( const SELECTION& aSel ) {
return !GetDisplayOptions().m_DisplayPadFill;
};
auto sketchGraphicsCondition = [ this ] ( const SELECTION& aSel ) {
return !GetDisplayOptions().m_DisplayGraphicsFill;
};
auto sketchTextCondition = [ this ] ( const SELECTION& aSel ) {
return !GetDisplayOptions().m_DisplayTextFill;
};
auto contrastModeCondition = [ this ] ( const SELECTION& aSel ) {
return ( GetDisplayOptions().m_ContrastModeDisplay !=
HIGH_CONTRAST_MODE::NORMAL );
};
auto searchTreeShownCondition = [ this ] ( const SELECTION& aSel ) {
return IsSearchTreeShown();
};
viewMenu->AddItem( ACTIONS::showFootprintBrowser, SELECTION_CONDITIONS::ShowAlways ); viewMenu->AppendSeparator();
viewMenu->AddItem( ACTIONS::show3DViewer, SELECTION_CONDITIONS::ShowAlways ); viewMenu->Add( ACTIONS::zoomInCenter );
viewMenu->Add( ACTIONS::zoomOutCenter );
viewMenu->Add( ACTIONS::zoomFitScreen );
viewMenu->Add( ACTIONS::zoomTool );
viewMenu->Add( ACTIONS::zoomRedraw );
viewMenu->AddSeparator(); viewMenu->AppendSeparator();
viewMenu->AddItem( ACTIONS::zoomInCenter, SELECTION_CONDITIONS::ShowAlways ); viewMenu->Add( ACTIONS::toggleGrid, ACTION_MENU::CHECK );
viewMenu->AddItem( ACTIONS::zoomOutCenter, SELECTION_CONDITIONS::ShowAlways ); viewMenu->Add( ACTIONS::gridProperties );
viewMenu->AddItem( ACTIONS::zoomFitScreen, SELECTION_CONDITIONS::ShowAlways ); viewMenu->Add( PCB_ACTIONS::togglePolarCoords, ACTION_MENU::CHECK );
viewMenu->AddItem( ACTIONS::zoomTool, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomRedraw, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddSeparator();
viewMenu->AddCheckItem( ACTIONS::toggleGrid, gridShownCondition );
viewMenu->AddItem( ACTIONS::gridProperties, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddCheckItem( PCB_ACTIONS::togglePolarCoords, polarCoordsCondition );
// Units submenu // Units submenu
CONDITIONAL_MENU* unitsSubMenu = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* unitsSubMenu = new ACTION_MENU( false, selTool );
unitsSubMenu->SetTitle( _( "&Units" ) ); unitsSubMenu->SetTitle( _( "&Units" ) );
unitsSubMenu->SetIcon( unit_mm_xpm ); unitsSubMenu->SetIcon( unit_mm_xpm );
unitsSubMenu->AddCheckItem( ACTIONS::imperialUnits, imperialUnitsCondition ); unitsSubMenu->Add( ACTIONS::imperialUnits, ACTION_MENU::CHECK );
unitsSubMenu->AddCheckItem( ACTIONS::metricUnits, metricUnitsCondition ); unitsSubMenu->Add( ACTIONS::metricUnits, ACTION_MENU::CHECK );
viewMenu->AddMenu( unitsSubMenu ); viewMenu->Add( unitsSubMenu );
viewMenu->AddCheckItem( ACTIONS::toggleCursorStyle, fullCrosshairCondition ); viewMenu->Add( ACTIONS::toggleCursorStyle, ACTION_MENU::CHECK );
viewMenu->AddSeparator(); viewMenu->AppendSeparator();
// Drawing Mode Submenu // Drawing Mode Submenu
CONDITIONAL_MENU* drawingModeSubMenu = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* drawingModeSubMenu = new ACTION_MENU( false, selTool );
drawingModeSubMenu->SetTitle( _( "&Drawing Mode" ) ); drawingModeSubMenu->SetTitle( _( "&Drawing Mode" ) );
drawingModeSubMenu->SetIcon( add_zone_xpm ); drawingModeSubMenu->SetIcon( add_zone_xpm );
drawingModeSubMenu->AddCheckItem( PCB_ACTIONS::padDisplayMode, sketchPadsCondition ); drawingModeSubMenu->Add( PCB_ACTIONS::padDisplayMode, ACTION_MENU::CHECK );
drawingModeSubMenu->AddCheckItem( PCB_ACTIONS::graphicsOutlines, sketchGraphicsCondition ); drawingModeSubMenu->Add( PCB_ACTIONS::graphicsOutlines, ACTION_MENU::CHECK );
drawingModeSubMenu->AddCheckItem( PCB_ACTIONS::textOutlines, sketchTextCondition ); drawingModeSubMenu->Add( PCB_ACTIONS::textOutlines, ACTION_MENU::CHECK );
viewMenu->AddMenu( drawingModeSubMenu ); viewMenu->Add( drawingModeSubMenu );
// Contrast Mode Submenu // Contrast Mode Submenu
CONDITIONAL_MENU* contrastModeSubMenu = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* contrastModeSubMenu = new ACTION_MENU( false, selTool );
contrastModeSubMenu->SetTitle( _( "&Contrast Mode" ) ); contrastModeSubMenu->SetTitle( _( "&Contrast Mode" ) );
contrastModeSubMenu->SetIcon( contrast_mode_xpm ); contrastModeSubMenu->SetIcon( contrast_mode_xpm );
contrastModeSubMenu->AddCheckItem( ACTIONS::highContrastMode, contrastModeCondition ); contrastModeSubMenu->Add( ACTIONS::highContrastMode, ACTION_MENU::CHECK );
contrastModeSubMenu->AddItem( PCB_ACTIONS::layerAlphaDec, SELECTION_CONDITIONS::ShowAlways ); contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaDec );
contrastModeSubMenu->AddItem( PCB_ACTIONS::layerAlphaInc, SELECTION_CONDITIONS::ShowAlways ); contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaInc );
viewMenu->AddMenu( contrastModeSubMenu ); viewMenu->Add( contrastModeSubMenu );
viewMenu->AddSeparator(); viewMenu->AppendSeparator();
viewMenu->AddCheckItem( PCB_ACTIONS::toggleFootprintTree, searchTreeShownCondition ); viewMenu->Add( PCB_ACTIONS::toggleFootprintTree, ACTION_MENU::CHECK );
viewMenu->Resolve();
//-- Place menu ------------------------------------------------------- //-- Place menu -------------------------------------------------------
// //
CONDITIONAL_MENU* placeMenu = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* placeMenu = new ACTION_MENU( false, selTool );
placeMenu->AddItem( PCB_ACTIONS::placePad, haveFootprintCondition ); placeMenu->Add( PCB_ACTIONS::placePad );
placeMenu->AddSeparator(); placeMenu->AppendSeparator();
placeMenu->AddItem( PCB_ACTIONS::placeText, haveFootprintCondition ); placeMenu->Add( PCB_ACTIONS::placeText );
placeMenu->AddItem( PCB_ACTIONS::drawArc, haveFootprintCondition ); placeMenu->Add( PCB_ACTIONS::drawArc );
placeMenu->AddItem( PCB_ACTIONS::drawRectangle, haveFootprintCondition ); placeMenu->Add( PCB_ACTIONS::drawRectangle );
placeMenu->AddItem( PCB_ACTIONS::drawCircle, haveFootprintCondition ); placeMenu->Add( PCB_ACTIONS::drawCircle );
placeMenu->AddItem( PCB_ACTIONS::drawLine, haveFootprintCondition ); placeMenu->Add( PCB_ACTIONS::drawLine );
placeMenu->AddItem( PCB_ACTIONS::drawPolygon, haveFootprintCondition ); placeMenu->Add( PCB_ACTIONS::drawPolygon );
placeMenu->AddItem( PCB_ACTIONS::drawZoneKeepout, haveFootprintCondition ); placeMenu->Add( PCB_ACTIONS::drawZoneKeepout );
placeMenu->AddSeparator(); placeMenu->AppendSeparator();
placeMenu->AddItem( PCB_ACTIONS::setAnchor, haveFootprintCondition ); placeMenu->Add( PCB_ACTIONS::setAnchor );
placeMenu->AddItem( ACTIONS::gridSetOrigin, haveFootprintCondition ); placeMenu->Add( ACTIONS::gridSetOrigin );
placeMenu->Resolve();
//-- Inspect menu ------------------------------------------------------ //-- Inspect menu ------------------------------------------------------
// //
CONDITIONAL_MENU* inspectMenu = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* inspectMenu = new ACTION_MENU( false, selTool );
inspectMenu->Add( ACTIONS::measureTool );
inspectMenu->AddItem( ACTIONS::measureTool, haveFootprintCondition );
inspectMenu->Resolve();
//-- Tools menu -------------------------------------------------------- //-- Tools menu --------------------------------------------------------
// //
wxMenu* toolsMenu = new wxMenu; ACTION_MENU* toolsMenu = new ACTION_MENU( false, selTool );
AddMenuItem( toolsMenu, ID_MODEDIT_LOAD_MODULE_FROM_BOARD, toolsMenu->Add( _( "&Load Footprint from PCB..." ),
_( "&Load Footprint from PCB..." ), _( "Load a footprint from the current board into the editor" ),
_( "Load a footprint from the current board into the editor" ), ID_MODEDIT_LOAD_MODULE_FROM_BOARD,
KiBitmap( load_module_board_xpm ) ); load_module_board_xpm );
AddMenuItem( toolsMenu, ID_ADD_FOOTPRINT_TO_BOARD, toolsMenu->Add( _( "&Insert Footprint on PCB" ),
_( "&Insert Footprint on PCB" ), _( "Insert footprint onto current board" ),
_( "Insert footprint onto current board" ), ID_ADD_FOOTPRINT_TO_BOARD,
KiBitmap( insert_module_board_xpm ) ); insert_module_board_xpm );
//-- Preferences menu ------------------------------------------------- //-- Preferences menu -------------------------------------------------
// //
CONDITIONAL_MENU* prefsMenu = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* prefsMenu = new ACTION_MENU( false, selTool );
auto acceleratedGraphicsCondition = [ this ] ( const SELECTION& aSel ) { prefsMenu->Add( ACTIONS::configurePaths );
return GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL; prefsMenu->Add( ACTIONS::showFootprintLibTable );
}; prefsMenu->Add( _( "Preferences...\tCTRL+," ),
auto standardGraphicsCondition = [ this ] ( const SELECTION& aSel ) { _( "Show preferences for all open tools" ),
return GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO; wxID_PREFERENCES,
}; preference_xpm );
prefsMenu->AddItem( ACTIONS::configurePaths, SELECTION_CONDITIONS::ShowAlways ); prefsMenu->AppendSeparator();
prefsMenu->AddItem( ACTIONS::showFootprintLibTable, SELECTION_CONDITIONS::ShowAlways );
prefsMenu->AddItem( wxID_PREFERENCES,
_( "Preferences...\tCTRL+," ),
_( "Show preferences for all open tools" ),
preference_xpm, SELECTION_CONDITIONS::ShowAlways );
prefsMenu->AddSeparator();
AddMenuLanguageList( prefsMenu, selTool ); AddMenuLanguageList( prefsMenu, selTool );
prefsMenu->AddSeparator(); prefsMenu->AppendSeparator();
prefsMenu->AddCheckItem( ACTIONS::acceleratedGraphics, acceleratedGraphicsCondition ); prefsMenu->Add( ACTIONS::acceleratedGraphics, ACTION_MENU::CHECK );
prefsMenu->AddCheckItem( ACTIONS::standardGraphics, standardGraphicsCondition ); prefsMenu->Add( ACTIONS::standardGraphics, ACTION_MENU::CHECK );
prefsMenu->Resolve();
//--MenuBar ----------------------------------------------------------- //--MenuBar -----------------------------------------------------------
// //
menuBar->Append( fileMenu, _( "&File" ) ); menuBar->Append( fileMenu, _( "&File" ) );
menuBar->Append( editMenu, _( "&Edit" ) ); menuBar->Append( editMenu, _( "&Edit" ) );
menuBar->Append( viewMenu, _( "&View" ) ); menuBar->Append( viewMenu, _( "&View" ) );
menuBar->Append( placeMenu, _( "&Place" ) ); menuBar->Append( placeMenu, _( "&Place" ) );
menuBar->Append( inspectMenu, _( "&Inspect" ) ); menuBar->Append( inspectMenu, _( "&Inspect" ) );
menuBar->Append( toolsMenu, _( "&Tools" ) ); menuBar->Append( toolsMenu, _( "&Tools" ) );
menuBar->Append( prefsMenu, _( "P&references" ) ); menuBar->Append( prefsMenu, _( "P&references" ) );
AddStandardHelpMenu( menuBar ); AddStandardHelpMenu( menuBar );
SetMenuBar( menuBar ); SetMenuBar( menuBar );

View File

@ -51,17 +51,12 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
wxMenuBar* oldMenuBar = GetMenuBar(); wxMenuBar* oldMenuBar = GetMenuBar();
WX_MENUBAR* menuBar = new WX_MENUBAR(); WX_MENUBAR* menuBar = new WX_MENUBAR();
auto modifiedDocumentCondition = [ this ] ( const SELECTION& sel ) {
return IsContentModified();
};
// Recreate all menus: // Recreate all menus:
//-- File menu ----------------------------------------------------------- //-- File menu -----------------------------------------------------------
// //
CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool );
static ACTION_MENU* openRecentMenu; static ACTION_MENU* openRecentMenu;
auto& disp_opt = GetDisplayOptions();
if( Kiface().IsSingle() ) // not when under a project mgr if( Kiface().IsSingle() ) // not when under a project mgr
{ {
@ -80,31 +75,36 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
fileHistory.AddFilesToMenu(); fileHistory.AddFilesToMenu();
} }
fileMenu->AddItem( ACTIONS::doNew, SELECTION_CONDITIONS::ShowAlways ); fileMenu->Add( ACTIONS::doNew );
fileMenu->AddItem( ACTIONS::open, SELECTION_CONDITIONS::ShowAlways ); fileMenu->Add( ACTIONS::open );
fileMenu->AddMenu( openRecentMenu, FILE_HISTORY::FileHistoryNotEmpty( fileHistory ) );
fileMenu->AddItem( PCB_ACTIONS::appendBoard, SELECTION_CONDITIONS::ShowAlways ); wxMenuItem* item = fileMenu->Add( openRecentMenu );
fileMenu->AddSeparator(); // Add the file menu condition here since it needs the item ID for the submenu
ACTION_CONDITIONS cond;
cond.Enable( FILE_HISTORY::FileHistoryNotEmpty( fileHistory ) );
RegisterUIUpdateHandler( item->GetId(), cond );
fileMenu->Add( PCB_ACTIONS::appendBoard );
fileMenu->AppendSeparator();
} }
fileMenu->AddItem( ACTIONS::save, modifiedDocumentCondition ); fileMenu->Add( ACTIONS::save );
// Save as menu: // Save as menu:
// under a project mgr we do not want to modify the board filename // under a project mgr we do not want to modify the board filename
// to keep consistency with the project mgr which expects files names same as prj name // to keep consistency with the project mgr which expects files names same as prj name
// for main files // for main files
if( Kiface().IsSingle() ) if( Kiface().IsSingle() )
fileMenu->AddItem( ACTIONS::saveAs, SELECTION_CONDITIONS::ShowAlways ); fileMenu->Add( ACTIONS::saveAs );
else else
fileMenu->AddItem( ACTIONS::saveCopyAs, SELECTION_CONDITIONS::ShowAlways ); fileMenu->Add( ACTIONS::saveCopyAs );
fileMenu->AddSeparator(); fileMenu->AppendSeparator();
fileMenu->AddItem( ID_MENU_RECOVER_BOARD_AUTOSAVE, fileMenu->Add( _( "Resc&ue" ),
_( "Resc&ue" ), _( "Clear board and get last rescue file automatically saved by Pcbnew" ),
_( "Clear board and get last rescue file automatically saved by Pcbnew" ), ID_MENU_RECOVER_BOARD_AUTOSAVE,
rescue_xpm, SELECTION_CONDITIONS::ShowAlways ); rescue_xpm );
// Import submenu // Import submenu
ACTION_MENU* submenuImport = new ACTION_MENU( false ); ACTION_MENU* submenuImport = new ACTION_MENU( false );
@ -124,8 +124,8 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
ID_IMPORT_NON_KICAD_BOARD, import_brd_file_xpm ); ID_IMPORT_NON_KICAD_BOARD, import_brd_file_xpm );
} }
fileMenu->AddSeparator(); fileMenu->AppendSeparator();
fileMenu->AddMenu( submenuImport, SELECTION_CONDITIONS::ShowAlways ); fileMenu->Add( submenuImport );
// Export submenu // Export submenu
ACTION_MENU* submenuExport = new ACTION_MENU( false ); ACTION_MENU* submenuExport = new ACTION_MENU( false );
@ -150,7 +150,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
submenuExport->Add( _( "Hyperlynx..." ), "", submenuExport->Add( _( "Hyperlynx..." ), "",
ID_GEN_EXPORT_FILE_HYPERLYNX, export_step_xpm ); ID_GEN_EXPORT_FILE_HYPERLYNX, export_step_xpm );
fileMenu->AddMenu( submenuExport, SELECTION_CONDITIONS::ShowAlways ); fileMenu->Add( submenuExport );
// Fabrication Outputs submenu // Fabrication Outputs submenu
ACTION_MENU* submenuFabOutputs = new ACTION_MENU( false ); ACTION_MENU* submenuFabOutputs = new ACTION_MENU( false );
@ -164,22 +164,15 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
submenuFabOutputs->Add( PCB_ACTIONS::generateReportFile ); submenuFabOutputs->Add( PCB_ACTIONS::generateReportFile );
submenuFabOutputs->Add( PCB_ACTIONS::generateD356File ); submenuFabOutputs->Add( PCB_ACTIONS::generateD356File );
submenuFabOutputs->Add( PCB_ACTIONS::generateBOM ); submenuFabOutputs->Add( PCB_ACTIONS::generateBOM );
fileMenu->Add( submenuFabOutputs );
fileMenu->AddMenu( submenuFabOutputs, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AppendSeparator();
fileMenu->Add( PCB_ACTIONS::boardSetup );
auto enableBoardSetupCondition = [ this ] ( const SELECTION& sel ) { fileMenu->AppendSeparator();
if( DRC* tool = m_toolManager->GetTool<DRC>() ) fileMenu->Add( ACTIONS::pageSettings );
return !tool->IsDRCDialogShown(); fileMenu->Add( ACTIONS::print );
fileMenu->Add( ACTIONS::plot );
return true;
};
fileMenu->AddSeparator();
fileMenu->AddItem( PCB_ACTIONS::boardSetup, enableBoardSetupCondition );
fileMenu->AddSeparator();
fileMenu->AddItem( ACTIONS::pageSettings, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddItem( ACTIONS::print, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddItem( ACTIONS::plot, SELECTION_CONDITIONS::ShowAlways );
// Archive submenu // Archive submenu
ACTION_MENU* submenuArchive = new ACTION_MENU( false ); ACTION_MENU* submenuArchive = new ACTION_MENU( false );
@ -197,234 +190,144 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
"(if the library already exists it will be replaced)" ), "(if the library already exists it will be replaced)" ),
ID_MENU_CREATE_LIBRARY_AND_ARCHIVE_MODULES, library_archive_as_xpm ); ID_MENU_CREATE_LIBRARY_AND_ARCHIVE_MODULES, library_archive_as_xpm );
fileMenu->AddSeparator(); fileMenu->AppendSeparator();
fileMenu->AddMenu( submenuArchive, SELECTION_CONDITIONS::ShowAlways ); fileMenu->Add( submenuArchive );
fileMenu->AddSeparator(); fileMenu->AppendSeparator();
fileMenu->AddQuitOrClose( &Kiface(), _( "Pcbnew" ) ); fileMenu->AddQuitOrClose( &Kiface(), _( "Pcbnew" ) );
fileMenu->Resolve();
//-- Edit menu ----------------------------------------------------------- //-- Edit menu -----------------------------------------------------------
// //
CONDITIONAL_MENU* editMenu = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* editMenu = new ACTION_MENU( false, selTool );
auto enableUndoCondition = [ this ] ( const SELECTION& sel ) { editMenu->Add( ACTIONS::undo );
return GetUndoCommandCount() > 0; editMenu->Add( ACTIONS::redo );
};
auto enableRedoCondition = [ this ] ( const SELECTION& sel ) {
return GetRedoCommandCount() > 0;
};
auto noActiveToolCondition = [ this ] ( const SELECTION& aSelection ) {
return ToolStackIsEmpty();
};
editMenu->AddItem( ACTIONS::undo, enableUndoCondition ); editMenu->AppendSeparator();
editMenu->AddItem( ACTIONS::redo, enableRedoCondition ); editMenu->Add( ACTIONS::cut );
editMenu->Add( ACTIONS::copy );
editMenu->Add( ACTIONS::paste );
editMenu->Add( ACTIONS::doDelete );
editMenu->Add( ACTIONS::duplicate );
editMenu->AddSeparator(); editMenu->AppendSeparator();
editMenu->AddItem( ACTIONS::cut, SELECTION_CONDITIONS::NotEmpty ); editMenu->Add( ACTIONS::find );
editMenu->AddItem( ACTIONS::copy, SELECTION_CONDITIONS::NotEmpty );
editMenu->AddItem( ACTIONS::paste, noActiveToolCondition );
editMenu->AddItem( ACTIONS::doDelete, SELECTION_CONDITIONS::NotEmpty );
editMenu->AddItem( ACTIONS::duplicate, SELECTION_CONDITIONS::NotEmpty );
editMenu->AddSeparator(); editMenu->AppendSeparator();
editMenu->AddItem( ACTIONS::find, SELECTION_CONDITIONS::ShowAlways ); editMenu->Add( PCB_ACTIONS::editTracksAndVias );
editMenu->Add( PCB_ACTIONS::editTextAndGraphics );
editMenu->Add( PCB_ACTIONS::changeFootprints );
editMenu->Add( PCB_ACTIONS::swapLayers );
editMenu->AddSeparator(); editMenu->AppendSeparator();
editMenu->AddItem( PCB_ACTIONS::editTracksAndVias, SELECTION_CONDITIONS::ShowAlways ); editMenu->Add( PCB_ACTIONS::zoneFillAll );
editMenu->AddItem( PCB_ACTIONS::editTextAndGraphics, SELECTION_CONDITIONS::ShowAlways ); editMenu->Add( PCB_ACTIONS::zoneUnfillAll );
editMenu->AddItem( PCB_ACTIONS::changeFootprints, SELECTION_CONDITIONS::ShowAlways );
editMenu->AddItem( PCB_ACTIONS::swapLayers, SELECTION_CONDITIONS::ShowAlways );
editMenu->AddSeparator(); editMenu->AppendSeparator();
editMenu->AddItem( PCB_ACTIONS::zoneFillAll, SELECTION_CONDITIONS::ShowAlways ); editMenu->Add( ACTIONS::deleteTool );
editMenu->AddItem( PCB_ACTIONS::zoneUnfillAll, SELECTION_CONDITIONS::ShowAlways ); editMenu->Add( PCB_ACTIONS::globalDeletions );
editMenu->Add( PCB_ACTIONS::cleanupTracksAndVias );
editMenu->Add( PCB_ACTIONS::cleanupGraphics );
editMenu->AddSeparator();
editMenu->AddItem( ACTIONS::deleteTool, SELECTION_CONDITIONS::ShowAlways );
editMenu->AddItem( PCB_ACTIONS::globalDeletions, SELECTION_CONDITIONS::ShowAlways );
editMenu->AddItem( PCB_ACTIONS::cleanupTracksAndVias, SELECTION_CONDITIONS::ShowAlways );
editMenu->AddItem( PCB_ACTIONS::cleanupGraphics, SELECTION_CONDITIONS::ShowAlways );
editMenu->Resolve();
//----- View menu ----------------------------------------------------------- //----- View menu -----------------------------------------------------------
// //
CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
auto layersPaletteShownCondition = [ this ]( const SELECTION &aSel ) viewMenu->Add( PCB_ACTIONS::showLayersManager, ACTION_MENU::CHECK );
{ viewMenu->Add( PCB_ACTIONS::showMicrowaveToolbar, ACTION_MENU::CHECK );
return LayerManagerShown(); viewMenu->Add( ACTIONS::showFootprintBrowser );
}; viewMenu->Add( ACTIONS::show3DViewer );
auto microwaveToolbarShownCondition = [ this ]( const SELECTION &aSel )
{
return MicrowaveToolbarShown();
};
auto gridShownCondition = [ this ]( const SELECTION &aSel )
{
return IsGridVisible();
};
auto polarCoordsCondition = [ this ]( const SELECTION &aSel )
{
return GetShowPolarCoords();
};
auto imperialUnitsCondition = [this]( const SELECTION& aSel ) {
return GetUserUnits() == EDA_UNITS::INCHES;
};
auto metricUnitsCondition = [this]( const SELECTION& aSel ) {
return GetUserUnits() == EDA_UNITS::MILLIMETRES;
};
auto fullCrosshairCondition = [ this ]( const SELECTION &aSel )
{
return GetGalDisplayOptions().m_fullscreenCursor;
};
auto ratsnestShownCondition = [ &disp_opt ]( const SELECTION &aSel )
{
return disp_opt.m_ShowGlobalRatsnest;
};
auto curvedRatsnestCondition = [ &disp_opt ]( const SELECTION &aSel )
{
return disp_opt.m_DisplayRatsnestLinesCurved;
};
auto boardFlippedCondition = [ this ]( const SELECTION &aSel )
{
return GetCanvas()->GetView()->IsMirroredX();
};
auto zonesFilledCondition = [ &disp_opt ]( const SELECTION &aSel )
{
return disp_opt.m_ZoneDisplayMode == ZONE_DISPLAY_MODE::SHOW_FILLED;
};
auto zonesWireframedCondition = [ &disp_opt ]( const SELECTION &aSel )
{
return disp_opt.m_ZoneDisplayMode == ZONE_DISPLAY_MODE::HIDE_FILLED;
};
auto zonesOutlinedCondition = [ &disp_opt ]( const SELECTION &aSel )
{
return disp_opt.m_ZoneDisplayMode == ZONE_DISPLAY_MODE::SHOW_OUTLINED;
};
auto sketchTracksCondition = [ &disp_opt ]( const SELECTION &aSel )
{
return !disp_opt.m_DisplayPcbTrackFill;
};
auto sketchViasCondition = [ &disp_opt ]( const SELECTION &aSel )
{
return !disp_opt.m_DisplayViaFill;
};
auto sketchPadsCondition = [ disp_opt ]( const SELECTION &aSel )
{
return !disp_opt.m_DisplayPadFill;
};
auto contrastModeCondition = [ &disp_opt ]( const SELECTION &aSel )
{
return disp_opt.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL;
};
auto sketchGraphicsCondition = [ &disp_opt ]( const SELECTION &aSel )
{
return !disp_opt.m_DisplayGraphicsFill;
};
auto sketchTextOutlinesCondition = [ &disp_opt ]( const SELECTION &aSel )
{
return !disp_opt.m_DisplayTextFill;
};
viewMenu->AddCheckItem( PCB_ACTIONS::showLayersManager, layersPaletteShownCondition ); viewMenu->AppendSeparator();
viewMenu->AddCheckItem( PCB_ACTIONS::showMicrowaveToolbar, microwaveToolbarShownCondition ); viewMenu->Add( ACTIONS::zoomInCenter );
viewMenu->AddItem( ACTIONS::showFootprintBrowser, SELECTION_CONDITIONS::ShowAlways ); viewMenu->Add( ACTIONS::zoomOutCenter );
viewMenu->AddItem( ACTIONS::show3DViewer, SELECTION_CONDITIONS::ShowAlways ); viewMenu->Add( ACTIONS::zoomFitScreen );
viewMenu->Add( ACTIONS::zoomTool );
viewMenu->Add( ACTIONS::zoomRedraw );
viewMenu->AddSeparator(); viewMenu->AppendSeparator();
viewMenu->AddItem( ACTIONS::zoomInCenter, SELECTION_CONDITIONS::ShowAlways ); viewMenu->Add( ACTIONS::toggleGrid, ACTION_MENU::CHECK );
viewMenu->AddItem( ACTIONS::zoomOutCenter, SELECTION_CONDITIONS::ShowAlways ); viewMenu->Add( ACTIONS::gridProperties );
viewMenu->AddItem( ACTIONS::zoomFitScreen, SELECTION_CONDITIONS::ShowAlways ); viewMenu->Add( PCB_ACTIONS::togglePolarCoords, ACTION_MENU::CHECK );
viewMenu->AddItem( ACTIONS::zoomTool, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomRedraw, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddSeparator();
viewMenu->AddCheckItem( ACTIONS::toggleGrid, gridShownCondition );
viewMenu->AddItem( ACTIONS::gridProperties, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddCheckItem( PCB_ACTIONS::togglePolarCoords, polarCoordsCondition );
// Units submenu // Units submenu
CONDITIONAL_MENU* unitsSubMenu = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* unitsSubMenu = new ACTION_MENU( false, selTool );
unitsSubMenu->SetTitle( _( "&Units" ) ); unitsSubMenu->SetTitle( _( "&Units" ) );
unitsSubMenu->SetIcon( unit_mm_xpm ); unitsSubMenu->SetIcon( unit_mm_xpm );
unitsSubMenu->AddCheckItem( ACTIONS::imperialUnits, imperialUnitsCondition ); unitsSubMenu->Add( ACTIONS::imperialUnits, ACTION_MENU::CHECK );
unitsSubMenu->AddCheckItem( ACTIONS::metricUnits, metricUnitsCondition ); unitsSubMenu->Add( ACTIONS::metricUnits, ACTION_MENU::CHECK );
viewMenu->AddMenu( unitsSubMenu ); viewMenu->Add( unitsSubMenu );
viewMenu->AddCheckItem( ACTIONS::toggleCursorStyle, fullCrosshairCondition ); viewMenu->Add( ACTIONS::toggleCursorStyle, ACTION_MENU::CHECK );
viewMenu->AddSeparator(); viewMenu->AppendSeparator();
viewMenu->AddCheckItem( PCB_ACTIONS::showRatsnest, ratsnestShownCondition ); viewMenu->Add( PCB_ACTIONS::showRatsnest, ACTION_MENU::CHECK );
viewMenu->AddCheckItem( PCB_ACTIONS::ratsnestLineMode, curvedRatsnestCondition ); viewMenu->Add( PCB_ACTIONS::ratsnestLineMode, ACTION_MENU::CHECK );
viewMenu->AddSeparator(); viewMenu->AppendSeparator();
// Drawing Mode Submenu // Drawing Mode Submenu
CONDITIONAL_MENU* drawingModeSubMenu = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* drawingModeSubMenu = new ACTION_MENU( false, selTool );
drawingModeSubMenu->SetTitle( _( "&Drawing Mode" ) ); drawingModeSubMenu->SetTitle( _( "&Drawing Mode" ) );
drawingModeSubMenu->SetIcon( add_zone_xpm ); drawingModeSubMenu->SetIcon( add_zone_xpm );
drawingModeSubMenu->AddCheckItem( PCB_ACTIONS::zoneDisplayEnable, zonesFilledCondition ); drawingModeSubMenu->Add( PCB_ACTIONS::zoneDisplayEnable, ACTION_MENU::CHECK );
drawingModeSubMenu->AddCheckItem( PCB_ACTIONS::zoneDisplayDisable, zonesWireframedCondition ); drawingModeSubMenu->Add( PCB_ACTIONS::zoneDisplayDisable, ACTION_MENU::CHECK );
drawingModeSubMenu->AddCheckItem( PCB_ACTIONS::zoneDisplayOutlines, zonesOutlinedCondition ); drawingModeSubMenu->Add( PCB_ACTIONS::zoneDisplayOutlines, ACTION_MENU::CHECK );
drawingModeSubMenu->AddSeparator(); drawingModeSubMenu->AppendSeparator();
drawingModeSubMenu->AddCheckItem( PCB_ACTIONS::padDisplayMode, sketchPadsCondition ); drawingModeSubMenu->Add( PCB_ACTIONS::padDisplayMode, ACTION_MENU::CHECK );
drawingModeSubMenu->AddCheckItem( PCB_ACTIONS::viaDisplayMode, sketchViasCondition ); drawingModeSubMenu->Add( PCB_ACTIONS::viaDisplayMode, ACTION_MENU::CHECK );
drawingModeSubMenu->AddCheckItem( PCB_ACTIONS::trackDisplayMode, sketchTracksCondition ); drawingModeSubMenu->Add( PCB_ACTIONS::trackDisplayMode, ACTION_MENU::CHECK );
drawingModeSubMenu->AddSeparator(); drawingModeSubMenu->AppendSeparator();
drawingModeSubMenu->AddCheckItem( PCB_ACTIONS::graphicsOutlines, sketchGraphicsCondition ); drawingModeSubMenu->Add( PCB_ACTIONS::graphicsOutlines, ACTION_MENU::CHECK );
drawingModeSubMenu->AddCheckItem( PCB_ACTIONS::textOutlines, sketchTextOutlinesCondition ); drawingModeSubMenu->Add( PCB_ACTIONS::textOutlines, ACTION_MENU::CHECK );
viewMenu->AddMenu( drawingModeSubMenu ); viewMenu->Add( drawingModeSubMenu );
// Contrast Mode Submenu // Contrast Mode Submenu
CONDITIONAL_MENU* contrastModeSubMenu = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* contrastModeSubMenu = new ACTION_MENU( false, selTool );
contrastModeSubMenu->SetTitle( _( "&Contrast Mode" ) ); contrastModeSubMenu->SetTitle( _( "&Contrast Mode" ) );
contrastModeSubMenu->SetIcon( contrast_mode_xpm ); contrastModeSubMenu->SetIcon( contrast_mode_xpm );
contrastModeSubMenu->AddCheckItem( ACTIONS::highContrastMode, contrastModeCondition ); contrastModeSubMenu->Add( ACTIONS::highContrastMode, ACTION_MENU::CHECK );
contrastModeSubMenu->AddItem( PCB_ACTIONS::layerAlphaDec, SELECTION_CONDITIONS::ShowAlways ); contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaDec );
contrastModeSubMenu->AddItem( PCB_ACTIONS::layerAlphaInc, SELECTION_CONDITIONS::ShowAlways ); contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaInc );
viewMenu->AddMenu( contrastModeSubMenu ); viewMenu->Add( contrastModeSubMenu );
viewMenu->AddCheckItem( PCB_ACTIONS::flipBoard, boardFlippedCondition ); viewMenu->Add( PCB_ACTIONS::flipBoard, ACTION_MENU::CHECK );
#ifdef __APPLE__ #ifdef __APPLE__
viewMenu->AddSeparator(); viewMenu->AppendSeparator();
#endif #endif
viewMenu->Resolve();
//-- Place Menu ---------------------------------------------------------- //-- Place Menu ----------------------------------------------------------
// //
CONDITIONAL_MENU* placeMenu = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* placeMenu = new ACTION_MENU( false, selTool );
placeMenu->AddItem( PCB_ACTIONS::placeModule, SELECTION_CONDITIONS::ShowAlways ); placeMenu->Add( PCB_ACTIONS::placeModule );
placeMenu->AddItem( PCB_ACTIONS::drawVia, SELECTION_CONDITIONS::ShowAlways ); placeMenu->Add( PCB_ACTIONS::drawVia );
placeMenu->AddItem( PCB_ACTIONS::drawZone, SELECTION_CONDITIONS::ShowAlways ); placeMenu->Add( PCB_ACTIONS::drawZone );
placeMenu->AddItem( PCB_ACTIONS::drawZoneKeepout, SELECTION_CONDITIONS::ShowAlways ); placeMenu->Add( PCB_ACTIONS::drawZoneKeepout );
placeMenu->AddItem( PCB_ACTIONS::placeText, SELECTION_CONDITIONS::ShowAlways ); placeMenu->Add( PCB_ACTIONS::placeText );
placeMenu->AddItem( PCB_ACTIONS::drawArc, SELECTION_CONDITIONS::ShowAlways ); placeMenu->Add( PCB_ACTIONS::drawArc );
placeMenu->AddItem( PCB_ACTIONS::drawRectangle, SELECTION_CONDITIONS::ShowAlways ); placeMenu->Add( PCB_ACTIONS::drawRectangle );
placeMenu->AddItem( PCB_ACTIONS::drawCircle, SELECTION_CONDITIONS::ShowAlways ); placeMenu->Add( PCB_ACTIONS::drawCircle );
placeMenu->AddItem( PCB_ACTIONS::drawLine, SELECTION_CONDITIONS::ShowAlways ); placeMenu->Add( PCB_ACTIONS::drawLine );
placeMenu->AddItem( PCB_ACTIONS::drawPolygon, SELECTION_CONDITIONS::ShowAlways ); placeMenu->Add( PCB_ACTIONS::drawPolygon );
placeMenu->AddSeparator(); placeMenu->AppendSeparator();
placeMenu->AddItem( PCB_ACTIONS::drawDimension, SELECTION_CONDITIONS::ShowAlways ); placeMenu->Add( PCB_ACTIONS::drawDimension );
placeMenu->AddSeparator(); placeMenu->AppendSeparator();
placeMenu->AddItem( PCB_ACTIONS::placeTarget, SELECTION_CONDITIONS::ShowAlways ); placeMenu->Add( PCB_ACTIONS::placeTarget );
placeMenu->AddSeparator(); placeMenu->AppendSeparator();
placeMenu->AddItem( PCB_ACTIONS::drillOrigin, SELECTION_CONDITIONS::ShowAlways ); placeMenu->Add( PCB_ACTIONS::drillOrigin );
placeMenu->AddItem( ACTIONS::gridSetOrigin, SELECTION_CONDITIONS::ShowAlways ); placeMenu->Add( ACTIONS::gridSetOrigin );
placeMenu->AddSeparator(); placeMenu->AppendSeparator();
ACTION_MENU* autoplaceSubmenu = new ACTION_MENU( false ); ACTION_MENU* autoplaceSubmenu = new ACTION_MENU( false );
autoplaceSubmenu->SetTitle( _( "Auto-Place Footprints" ) ); autoplaceSubmenu->SetTitle( _( "Auto-Place Footprints" ) );
@ -434,68 +337,60 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
autoplaceSubmenu->Add( PCB_ACTIONS::autoplaceOffboardComponents ); autoplaceSubmenu->Add( PCB_ACTIONS::autoplaceOffboardComponents );
autoplaceSubmenu->Add( PCB_ACTIONS::autoplaceSelectedComponents ); autoplaceSubmenu->Add( PCB_ACTIONS::autoplaceSelectedComponents );
placeMenu->AddMenu( autoplaceSubmenu ); placeMenu->Add( autoplaceSubmenu );
placeMenu->Resolve();
//-- Route Menu ---------------------------------------------------------- //-- Route Menu ----------------------------------------------------------
// //
CONDITIONAL_MENU* routeMenu = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* routeMenu = new ACTION_MENU( false, selTool );
routeMenu->AddItem( PCB_ACTIONS::selectLayerPair, SELECTION_CONDITIONS::ShowAlways ); routeMenu->Add( PCB_ACTIONS::selectLayerPair );
routeMenu->AddSeparator(); routeMenu->AppendSeparator();
routeMenu->AddItem( PCB_ACTIONS::routeSingleTrack, SELECTION_CONDITIONS::ShowAlways ); routeMenu->Add( PCB_ACTIONS::routeSingleTrack );
routeMenu->AddItem( PCB_ACTIONS::routeDiffPair, SELECTION_CONDITIONS::ShowAlways ); routeMenu->Add( PCB_ACTIONS::routeDiffPair );
routeMenu->AddSeparator(); routeMenu->AppendSeparator();
routeMenu->AddItem( PCB_ACTIONS::routerTuneSingleTrace, SELECTION_CONDITIONS::ShowAlways ); routeMenu->Add( PCB_ACTIONS::routerTuneSingleTrace );
routeMenu->AddItem( PCB_ACTIONS::routerTuneDiffPair, SELECTION_CONDITIONS::ShowAlways ); routeMenu->Add( PCB_ACTIONS::routerTuneDiffPair );
routeMenu->AddItem( PCB_ACTIONS::routerTuneDiffPairSkew, SELECTION_CONDITIONS::ShowAlways ); routeMenu->Add( PCB_ACTIONS::routerTuneDiffPairSkew );
routeMenu->AddSeparator(); routeMenu->AppendSeparator();
routeMenu->AddItem( PCB_ACTIONS::routerSettingsDialog, SELECTION_CONDITIONS::ShowAlways ); routeMenu->Add( PCB_ACTIONS::routerSettingsDialog );
routeMenu->Resolve();
//-- Inspect Menu -------------------------------------------------------- //-- Inspect Menu --------------------------------------------------------
// //
CONDITIONAL_MENU* inspectMenu = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* inspectMenu = new ACTION_MENU( false, selTool );
inspectMenu->AddItem( PCB_ACTIONS::listNets, SELECTION_CONDITIONS::ShowAlways ); inspectMenu->Add( PCB_ACTIONS::listNets );
inspectMenu->AddItem( ACTIONS::measureTool, SELECTION_CONDITIONS::ShowAlways ); inspectMenu->Add( ACTIONS::measureTool );
inspectMenu->AddItem( PCB_ACTIONS::boardStatistics, SELECTION_CONDITIONS::ShowAlways ); inspectMenu->Add( PCB_ACTIONS::boardStatistics );
inspectMenu->AddSeparator(); inspectMenu->AppendSeparator();
inspectMenu->AddItem( PCB_ACTIONS::runDRC, SELECTION_CONDITIONS::ShowAlways ); inspectMenu->Add( PCB_ACTIONS::runDRC );
inspectMenu->Resolve();
//-- Tools menu ---------------------------------------------------------- //-- Tools menu ----------------------------------------------------------
// //
CONDITIONAL_MENU* toolsMenu = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* toolsMenu = new ACTION_MENU( false, selTool );
toolsMenu->AddItem( ACTIONS::updatePcbFromSchematic, SELECTION_CONDITIONS::ShowAlways ); toolsMenu->Add( ACTIONS::updatePcbFromSchematic );
toolsMenu->AddItem( ACTIONS::updateSchematicFromPcb, SELECTION_CONDITIONS::ShowAlways ); toolsMenu->Add( ACTIONS::updateSchematicFromPcb );
toolsMenu->AddItem( PCB_ACTIONS::showEeschema, SELECTION_CONDITIONS::ShowAlways ); toolsMenu->Add( PCB_ACTIONS::showEeschema );
toolsMenu->AddSeparator(); toolsMenu->AppendSeparator();
toolsMenu->AddItem( ACTIONS::showFootprintEditor, SELECTION_CONDITIONS::ShowAlways ); toolsMenu->Add( ACTIONS::showFootprintEditor );
toolsMenu->AddItem( PCB_ACTIONS::updateFootprints, SELECTION_CONDITIONS::ShowAlways ); toolsMenu->Add( PCB_ACTIONS::updateFootprints );
toolsMenu->AddItem( PCB_ACTIONS::boardReannotate, SELECTION_CONDITIONS::ShowAlways ); toolsMenu->Add( PCB_ACTIONS::boardReannotate );
toolsMenu->AddSeparator(); toolsMenu->AppendSeparator();
toolsMenu->AddItem( PCB_ACTIONS::removeUnusedPads, SELECTION_CONDITIONS::ShowAlways ); toolsMenu->Add( PCB_ACTIONS::removeUnusedPads );
toolsMenu->AddItem( PCB_ACTIONS::repairBoard, SELECTION_CONDITIONS::ShowAlways ); toolsMenu->Add( PCB_ACTIONS::repairBoard );
#if defined(KICAD_SCRIPTING_WXPYTHON) #if defined(KICAD_SCRIPTING_WXPYTHON)
auto pythonConsoleShownCondition = [] ( const SELECTION& aSel ) { toolsMenu->AppendSeparator();
wxMiniFrame* pythonConsole = (wxMiniFrame *) PCB_EDIT_FRAME::findPythonConsole(); toolsMenu->Add( PCB_ACTIONS::showPythonConsole );
return pythonConsole && pythonConsole->IsShown();
};
toolsMenu->AddSeparator();
toolsMenu->AddCheckItem( PCB_ACTIONS::showPythonConsole, pythonConsoleShownCondition );
#endif #endif
#if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU) #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
@ -506,68 +401,62 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
submenuActionPlugins->Add( _( "Refresh Plugins" ), submenuActionPlugins->Add( _( "Refresh Plugins" ),
_( "Reload all python plugins and refresh plugin menus" ), _( "Reload all python plugins and refresh plugin menus" ),
ID_TOOLBARH_PCB_ACTION_PLUGIN_REFRESH, reload_xpm ); ID_TOOLBARH_PCB_ACTION_PLUGIN_REFRESH,
reload_xpm );
#ifdef __APPLE__ #ifdef __APPLE__
submenuActionPlugins->Add( _( "Reveal Plugin Folder in Finder" ), submenuActionPlugins->Add( _( "Reveal Plugin Folder in Finder" ),
_( "Reveals the plugins folder in a Finder window" ), _( "Reveals the plugins folder in a Finder window" ),
ID_TOOLBARH_PCB_ACTION_PLUGIN_SHOW_FOLDER, folder_xpm ); ID_TOOLBARH_PCB_ACTION_PLUGIN_SHOW_FOLDER,
folder_xpm );
#else #else
submenuActionPlugins->Add( _( "Open Plugin Directory" ), submenuActionPlugins->Add( _( "Open Plugin Directory" ),
_( "Opens the directory in the default system file manager" ), _( "Opens the directory in the default system file manager" ),
ID_TOOLBARH_PCB_ACTION_PLUGIN_SHOW_FOLDER, folder_xpm ); ID_TOOLBARH_PCB_ACTION_PLUGIN_SHOW_FOLDER,
folder_xpm );
#endif #endif
submenuActionPlugins->AppendSeparator(); submenuActionPlugins->AppendSeparator();
toolsMenu->AddSeparator(); toolsMenu->AppendSeparator();
toolsMenu->AddMenu( submenuActionPlugins, SELECTION_CONDITIONS::ShowAlways ); toolsMenu->Add( submenuActionPlugins );
#endif #endif
toolsMenu->Resolve();
//-- Preferences menu ---------------------------------------------------- //-- Preferences menu ----------------------------------------------------
// //
CONDITIONAL_MENU* prefsMenu = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* prefsMenu = new ACTION_MENU( false, selTool );
auto acceleratedGraphicsCondition = [ this ] ( const SELECTION& aSel ) { prefsMenu->Add( ACTIONS::configurePaths );
return GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL; prefsMenu->Add( ACTIONS::showFootprintLibTable );
};
auto standardGraphicsCondition = [ this ] ( const SELECTION& aSel ) {
return GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO;
};
prefsMenu->AddItem( ACTIONS::configurePaths, SELECTION_CONDITIONS::ShowAlways );
prefsMenu->AddItem( ACTIONS::showFootprintLibTable, SELECTION_CONDITIONS::ShowAlways );
#ifdef BUILD_GITHUB_PLUGIN #ifdef BUILD_GITHUB_PLUGIN
prefsMenu->AddItem( ID_PCB_3DSHAPELIB_WIZARD, prefsMenu->Add( _( "Add &3D Shapes Libraries Wizard..." ),
_( "Add &3D Shapes Libraries Wizard..." ), _( "Download 3D shape libraries from GitHub" ),
_( "Download 3D shape libraries from GitHub" ), ID_PCB_3DSHAPELIB_WIZARD,
import3d_xpm, SELECTION_CONDITIONS::ShowAlways ); import3d_xpm );
#endif #endif
prefsMenu->AddItem( wxID_PREFERENCES, prefsMenu->Add( _( "Preferences...\tCTRL+," ),
_( "Preferences...\tCTRL+," ), _( "Show preferences for all open tools" ),
_( "Show preferences for all open tools" ), wxID_PREFERENCES,
preference_xpm, SELECTION_CONDITIONS::ShowAlways ); preference_xpm );
prefsMenu->AddSeparator(); prefsMenu->AppendSeparator();
AddMenuLanguageList( prefsMenu, selTool ); AddMenuLanguageList( prefsMenu, selTool );
prefsMenu->AddSeparator(); prefsMenu->AppendSeparator();
prefsMenu->AddCheckItem( ACTIONS::acceleratedGraphics, acceleratedGraphicsCondition ); prefsMenu->Add( ACTIONS::acceleratedGraphics, ACTION_MENU::CHECK );
prefsMenu->AddCheckItem( ACTIONS::standardGraphics, standardGraphicsCondition ); prefsMenu->Add( ACTIONS::standardGraphics, ACTION_MENU::CHECK );
prefsMenu->Resolve();
//--MenuBar ----------------------------------------------------------- //--MenuBar -----------------------------------------------------------
// //
menuBar->Append( fileMenu, _( "&File" ) ); menuBar->Append( fileMenu, _( "&File" ) );
menuBar->Append( editMenu, _( "&Edit" ) ); menuBar->Append( editMenu, _( "&Edit" ) );
menuBar->Append( viewMenu, _( "&View" ) ); menuBar->Append( viewMenu, _( "&View" ) );
menuBar->Append( placeMenu, _( "&Place" ) ); menuBar->Append( placeMenu, _( "&Place" ) );
menuBar->Append( routeMenu, _( "Ro&ute" ) ); menuBar->Append( routeMenu, _( "Ro&ute" ) );
menuBar->Append( inspectMenu, _( "&Inspect" ) ); menuBar->Append( inspectMenu, _( "&Inspect" ) );
menuBar->Append( toolsMenu, _( "&Tools" ) ); menuBar->Append( toolsMenu, _( "&Tools" ) );
menuBar->Append( prefsMenu, _( "P&references" ) ); menuBar->Append( prefsMenu, _( "P&references" ) );
AddStandardHelpMenu( menuBar ); AddStandardHelpMenu( menuBar );
SetMenuBar( menuBar ); SetMenuBar( menuBar );

View File

@ -57,6 +57,7 @@
#include <tool/action_toolbar.h> #include <tool/action_toolbar.h>
#include <tool/common_control.h> #include <tool/common_control.h>
#include <tool/common_tools.h> #include <tool/common_tools.h>
#include <tool/selection.h>
#include <tool/zoom_tool.h> #include <tool/zoom_tool.h>
#include <tools/selection_tool.h> #include <tools/selection_tool.h>
#include <tools/pcbnew_picker_tool.h> #include <tools/pcbnew_picker_tool.h>
@ -67,6 +68,7 @@
#include <tools/pcbnew_control.h> #include <tools/pcbnew_control.h>
#include <tools/pcb_editor_control.h> #include <tools/pcb_editor_control.h>
#include <tools/pcb_inspection_tool.h> #include <tools/pcb_inspection_tool.h>
#include <tools/pcb_editor_conditions.h>
#include <tools/pcb_viewer_tools.h> #include <tools/pcb_viewer_tools.h>
#include <tools/pcb_reannotate_tool.h> #include <tools/pcb_reannotate_tool.h>
#include <tools/placement_tool.h> #include <tools/placement_tool.h>
@ -219,6 +221,10 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
ReCreateOptToolbar(); ReCreateOptToolbar();
ReCreateMicrowaveVToolbar(); ReCreateMicrowaveVToolbar();
// We call this after the toolbars have been created to ensure the layer widget button handler
// doesn't cause problems
setupUIConditions();
m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this ); m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
// Create the infobar // Create the infobar
@ -443,6 +449,12 @@ bool PCB_EDIT_FRAME::isAutoSaveRequired() const
} }
SELECTION& PCB_EDIT_FRAME::GetCurrentSelection()
{
return m_toolManager->GetTool<SELECTION_TOOL>()->GetSelection();
}
void PCB_EDIT_FRAME::setupTools() void PCB_EDIT_FRAME::setupTools()
{ {
// Create the manager and dispatcher & route draw panel events to the dispatcher // Create the manager and dispatcher & route draw panel events to the dispatcher
@ -483,6 +495,188 @@ void PCB_EDIT_FRAME::setupTools()
} }
void PCB_EDIT_FRAME::setupUIConditions()
{
PCB_BASE_EDIT_FRAME::setupUIConditions();
ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
PCB_EDITOR_CONDITIONS cond( this );
wxASSERT( mgr );
#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
#define CHECK( x ) ACTION_CONDITIONS().Check( x )
mgr->SetConditions( ACTIONS::save, ENABLE( cond.ContentModified() ) );
mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) );
mgr->SetConditions( ACTIONS::togglePolarCoords, CHECK( cond.PolarCoordinates() ) );
mgr->SetConditions( ACTIONS::metricUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
mgr->SetConditions( ACTIONS::imperialUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
mgr->SetConditions( ACTIONS::acceleratedGraphics, CHECK( cond.CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) ) );
mgr->SetConditions( ACTIONS::standardGraphics, CHECK( cond.CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) ) );
mgr->SetConditions( ACTIONS::cut, ENABLE( SELECTION_CONDITIONS::NotEmpty ) );
mgr->SetConditions( ACTIONS::copy, ENABLE( SELECTION_CONDITIONS::NotEmpty ) );
mgr->SetConditions( ACTIONS::paste, ENABLE( SELECTION_CONDITIONS::Idle && cond.NoActiveTool() ) );
mgr->SetConditions( ACTIONS::pasteSpecial, ENABLE( SELECTION_CONDITIONS::Idle && cond.NoActiveTool() ) );
mgr->SetConditions( ACTIONS::doDelete, ENABLE( SELECTION_CONDITIONS::NotEmpty ) );
mgr->SetConditions( ACTIONS::duplicate, ENABLE( SELECTION_CONDITIONS::NotEmpty ) );
mgr->SetConditions( PCB_ACTIONS::padDisplayMode, CHECK( !cond.PadFillDisplay() ) );
mgr->SetConditions( PCB_ACTIONS::viaDisplayMode, CHECK( !cond.ViaFillDisplay() ) );
mgr->SetConditions( PCB_ACTIONS::trackDisplayMode, CHECK( !cond.TrackFillDisplay() ) );
mgr->SetConditions( PCB_ACTIONS::zoneDisplayEnable, CHECK( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_FILLED ) ) );
mgr->SetConditions( PCB_ACTIONS::zoneDisplayDisable, CHECK( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::HIDE_FILLED ) ) );
mgr->SetConditions( PCB_ACTIONS::zoneDisplayOutlines, CHECK( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_OUTLINED ) ) );
#if defined( KICAD_SCRIPTING_WXPYTHON )
auto pythonConsoleCond =
[] ( const SELECTION& )
{
if( IsWxPythonLoaded() )
{
wxWindow* console = PCB_EDIT_FRAME::findPythonConsole();
return console && console->IsShown();
}
return false;
};
mgr->SetConditions( PCB_ACTIONS::showPythonConsole, CHECK( pythonConsoleCond ) );
#endif
auto enableBoardSetupCondition =
[this] ( const SELECTION& )
{
if( DRC* tool = m_toolManager->GetTool<DRC>() )
return !tool->IsDRCDialogShown();
return true;
};
auto boardFlippedCond =
[this]( const SELECTION& )
{
return GetCanvas()->GetView()->IsMirroredX();
};
auto layerManagerCond =
[this] ( const SELECTION& )
{
return LayerManagerShown();
};
auto microwaveToolbarCond =
[this] ( const SELECTION& )
{
return MicrowaveToolbarShown();
};
auto highContrastCond =
[this] ( const SELECTION& )
{
return GetDisplayOptions().m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL;
};
auto globalRatsnestCond =
[this] (const SELECTION& )
{
return GetDisplayOptions().m_ShowGlobalRatsnest;
};
auto curvedRatsnestCond =
[this] (const SELECTION& )
{
return GetDisplayOptions().m_DisplayRatsnestLinesCurved;
};
mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastCond ) );
mgr->SetConditions( PCB_ACTIONS::flipBoard, CHECK( boardFlippedCond ) );
mgr->SetConditions( PCB_ACTIONS::showLayersManager, CHECK( layerManagerCond ) );
mgr->SetConditions( PCB_ACTIONS::showMicrowaveToolbar, CHECK( microwaveToolbarCond ) );
mgr->SetConditions( PCB_ACTIONS::showRatsnest, CHECK( globalRatsnestCond ) );
mgr->SetConditions( PCB_ACTIONS::ratsnestLineMode, CHECK( curvedRatsnestCond ) );
mgr->SetConditions( PCB_ACTIONS::boardSetup , ENABLE( enableBoardSetupCondition ) );
auto isHighlightMode =
[this]( const SELECTION& )
{
ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>();
return tool->GetRouterMode() == PNS::RM_MarkObstacles;
};
auto isShoveMode =
[this]( const SELECTION& )
{
ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>();
return tool->GetRouterMode() == PNS::RM_Shove;
};
auto isWalkaroundMode =
[this]( const SELECTION& )
{
ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>();
return tool->GetRouterMode() == PNS::RM_Walkaround;
};
mgr->SetConditions( PCB_ACTIONS::routerHighlightMode, CHECK( isHighlightMode ) );
mgr->SetConditions( PCB_ACTIONS::routerShoveMode, CHECK( isShoveMode ) );
mgr->SetConditions( PCB_ACTIONS::routerWalkaroundMode, CHECK( isWalkaroundMode ) );
// The layer indicator is special, so we register a callback directly that will regenerate the
// bitmap instead of using the conditions system
auto layerIndicatorUpdate =
[this] ( wxUpdateUIEvent& )
{
PrepareLayerIndicator();
};
Bind( wxEVT_UPDATE_UI, layerIndicatorUpdate, PCB_ACTIONS::selectLayerPair.GetUIId() );
#define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
CURRENT_TOOL( ACTIONS::zoomTool );
CURRENT_TOOL( ACTIONS::deleteTool );
CURRENT_TOOL( ACTIONS::measureTool );
CURRENT_TOOL( ACTIONS::selectionTool );
CURRENT_TOOL( PCB_ACTIONS::highlightNetTool );
CURRENT_TOOL( PCB_ACTIONS::localRatsnestTool );
CURRENT_TOOL( PCB_ACTIONS::placeModule );
CURRENT_TOOL( PCB_ACTIONS::routeSingleTrack);
CURRENT_TOOL( PCB_ACTIONS::drawVia );
CURRENT_TOOL( PCB_ACTIONS::drawZone );
CURRENT_TOOL( PCB_ACTIONS::drawZoneKeepout );
CURRENT_TOOL( PCB_ACTIONS::drawLine );
CURRENT_TOOL( PCB_ACTIONS::drawRectangle );
CURRENT_TOOL( PCB_ACTIONS::drawCircle );
CURRENT_TOOL( PCB_ACTIONS::drawArc );
CURRENT_TOOL( PCB_ACTIONS::drawPolygon );
CURRENT_TOOL( PCB_ACTIONS::placeText );
CURRENT_TOOL( PCB_ACTIONS::drawDimension );
CURRENT_TOOL( PCB_ACTIONS::placeTarget );
CURRENT_TOOL( PCB_ACTIONS::drillOrigin );
CURRENT_TOOL( PCB_ACTIONS::gridSetOrigin );
CURRENT_TOOL( PCB_ACTIONS::microwaveCreateLine );
CURRENT_TOOL( PCB_ACTIONS::microwaveCreateGap );
CURRENT_TOOL( PCB_ACTIONS::microwaveCreateStub );
CURRENT_TOOL( PCB_ACTIONS::microwaveCreateStubArc );
CURRENT_TOOL( PCB_ACTIONS::microwaveCreateFunctionShape );
#undef CURRENT_TOOL
#undef ENABLE
#undef CHECK
}
void PCB_EDIT_FRAME::OnQuit( wxCommandEvent& event ) void PCB_EDIT_FRAME::OnQuit( wxCommandEvent& event )
{ {
if( event.GetId() == wxID_EXIT ) if( event.GetId() == wxID_EXIT )
@ -1374,3 +1568,15 @@ wxString PCB_EDIT_FRAME::GetCurrentFileName() const
{ {
return GetBoard()->GetFileName(); return GetBoard()->GetFileName();
} }
bool PCB_EDIT_FRAME::LayerManagerShown()
{
return m_auimgr.GetPane( "LayersManager" ).IsShown();
}
bool PCB_EDIT_FRAME::MicrowaveToolbarShown()
{
return m_auimgr.GetPane( "MicrowaveToolbar" ).IsShown();
}

View File

@ -52,6 +52,7 @@ class DRAWSEGMENT;
class GENERAL_COLLECTOR; class GENERAL_COLLECTOR;
class GENERAL_COLLECTORS_GUIDE; class GENERAL_COLLECTORS_GUIDE;
class PCB_LAYER_WIDGET; class PCB_LAYER_WIDGET;
class SELECTION;
class MARKER_PCB; class MARKER_PCB;
class BOARD_ITEM; class BOARD_ITEM;
class PCB_LAYER_BOX_SELECTOR; class PCB_LAYER_BOX_SELECTOR;
@ -122,6 +123,7 @@ protected:
// The Tool Framework initalization // The Tool Framework initalization
void setupTools(); void setupTools();
void setupUIConditions() override;
/** /**
* switches currently used canvas (Cairo / OpenGL). * switches currently used canvas (Cairo / OpenGL).
@ -926,10 +928,10 @@ public:
void ProjectChanged() override; void ProjectChanged() override;
void SyncToolbars() override;
wxString GetCurrentFileName() const override; wxString GetCurrentFileName() const override;
SELECTION& GetCurrentSelection() override;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View File

@ -58,7 +58,6 @@
#include "invoke_pcb_dialog.h" #include "invoke_pcb_dialog.h"
#include "dialog_global_fp_lib_table_config.h" #include "dialog_global_fp_lib_table_config.h"
extern bool IsWxPythonLoaded();
namespace PCB { namespace PCB {

View File

@ -92,6 +92,8 @@ void RedirectStdio();
wxWindow* CreatePythonShellWindow( wxWindow* parent, const wxString& aFramenameId ); wxWindow* CreatePythonShellWindow( wxWindow* parent, const wxString& aFramenameId );
#endif #endif
bool IsWxPythonLoaded();
#if 0 && defined (KICAD_SCRIPTING_WXPYTHON) #if 0 && defined (KICAD_SCRIPTING_WXPYTHON)
// This definition of PyLOCK crashed Pcbnew under some conditions (JPC), // This definition of PyLOCK crashed Pcbnew under some conditions (JPC),
// especially reloading plugins // especially reloading plugins

View File

@ -215,73 +215,3 @@ void FOOTPRINT_EDIT_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent )
{ {
m_selLayerBox->SetLayerSelection( GetActiveLayer() ); m_selLayerBox->SetLayerSelection( GetActiveLayer() );
} }
void FOOTPRINT_EDIT_FRAME::SyncToolbars()
{
#define TOGGLE_TOOL( toolbar, tool ) toolbar->Toggle( tool, true, IsCurrentTool( tool ) )
if( !m_mainToolBar || !m_optionsToolBar || !m_drawToolBar )
return;
auto& opts = GetDisplayOptions();
if( IsCurrentFPFromBoard() )
m_mainToolBar->Toggle( PCB_ACTIONS::saveToBoard, IsContentModified() );
else
m_mainToolBar->Toggle( PCB_ACTIONS::saveToLibrary, IsContentModified() );
m_mainToolBar->Toggle( ACTIONS::undo, GetUndoCommandCount() > 0 );
m_mainToolBar->Toggle( ACTIONS::redo, GetRedoCommandCount() > 0 );
TOGGLE_TOOL( m_mainToolBar, ACTIONS::zoomTool );
m_mainToolBar->Toggle( PCB_ACTIONS::footprintProperties, GetBoard()->GetFirstModule() );
m_mainToolBar->Refresh();
bool hcm = opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL;
m_optionsToolBar->Toggle( ACTIONS::toggleGrid, IsGridVisible() );
m_optionsToolBar->Toggle( ACTIONS::metricUnits, GetUserUnits() != EDA_UNITS::INCHES );
m_optionsToolBar->Toggle( ACTIONS::imperialUnits, GetUserUnits() == EDA_UNITS::INCHES );
m_optionsToolBar->Toggle( ACTIONS::togglePolarCoords, GetShowPolarCoords() );
m_optionsToolBar->Toggle( PCB_ACTIONS::padDisplayMode, !opts.m_DisplayPadFill );
m_optionsToolBar->Toggle( PCB_ACTIONS::textOutlines, !opts.m_DisplayTextFill );
m_optionsToolBar->Toggle( PCB_ACTIONS::graphicsOutlines, !opts.m_DisplayGraphicsFill );
m_optionsToolBar->Toggle( ACTIONS::highContrastMode, hcm );
m_optionsToolBar->Toggle( PCB_ACTIONS::toggleFootprintTree, IsSearchTreeShown() );
m_optionsToolBar->Refresh();
if( GetLoadedFPID().empty() )
{
// If there is no footprint loaded, disable the editing tools
m_drawToolBar->Toggle( PCB_ACTIONS::placePad, false, false );
m_drawToolBar->Toggle( PCB_ACTIONS::drawLine, false, false );
m_drawToolBar->Toggle( PCB_ACTIONS::drawRectangle, false, false );
m_drawToolBar->Toggle( PCB_ACTIONS::drawCircle, false, false );
m_drawToolBar->Toggle( PCB_ACTIONS::drawArc, false, false );
m_drawToolBar->Toggle( PCB_ACTIONS::drawPolygon, false, false );
m_drawToolBar->Toggle( PCB_ACTIONS::drawZoneKeepout, false, false );
m_drawToolBar->Toggle( PCB_ACTIONS::placeText, false, false );
m_drawToolBar->Toggle( ACTIONS::deleteTool, false, false );
m_drawToolBar->Toggle( PCB_ACTIONS::setAnchor, false, false );
m_drawToolBar->Toggle( PCB_ACTIONS::gridSetOrigin, false, false );
m_drawToolBar->Toggle( ACTIONS::measureTool, false, false );
}
else
{
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::placePad );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawLine );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawRectangle );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawCircle );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawArc );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawPolygon );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawZoneKeepout );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::placeText );
TOGGLE_TOOL( m_drawToolBar, ACTIONS::deleteTool );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::setAnchor );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::gridSetOrigin );
TOGGLE_TOOL( m_drawToolBar, ACTIONS::measureTool );
}
TOGGLE_TOOL( m_drawToolBar, ACTIONS::selectionTool );
m_drawToolBar->Refresh();
}

View File

@ -130,29 +130,6 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateVToolbar()
} }
void FOOTPRINT_VIEWER_FRAME::SyncToolbars()
{
m_mainToolBar->Toggle( ACTIONS::zoomTool, IsCurrentTool( ACTIONS::zoomTool ) );
m_mainToolBar->Toggle( PCB_ACTIONS::zoomFootprintAutomatically, GetAutoZoom() );
m_mainToolBar->Refresh();
m_optionsToolBar->Toggle( ACTIONS::toggleGrid, IsGridVisible() );
m_optionsToolBar->Toggle( ACTIONS::selectionTool, IsCurrentTool( ACTIONS::selectionTool ) );
m_optionsToolBar->Toggle( ACTIONS::measureTool, IsCurrentTool( ACTIONS::measureTool ) );
m_optionsToolBar->Toggle( ACTIONS::metricUnits, GetUserUnits() != EDA_UNITS::INCHES );
m_optionsToolBar->Toggle( ACTIONS::imperialUnits, GetUserUnits() == EDA_UNITS::INCHES );
const PCB_DISPLAY_OPTIONS& opts = GetDisplayOptions();
m_optionsToolBar->Toggle( PCB_ACTIONS::showPadNumbers, opts.m_DisplayPadNum );
m_optionsToolBar->Toggle( PCB_ACTIONS::padDisplayMode, !opts.m_DisplayPadFill );
m_optionsToolBar->Toggle( PCB_ACTIONS::textOutlines, !opts.m_DisplayTextFill );
m_optionsToolBar->Toggle( PCB_ACTIONS::graphicsOutlines, !opts.m_DisplayGraphicsFill );
m_optionsToolBar->Refresh();
}
void FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar() void FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar()
{ {
SELECTION_TOOL* selTool = m_toolManager->GetTool<SELECTION_TOOL>(); SELECTION_TOOL* selTool = m_toolManager->GetTool<SELECTION_TOOL>();
@ -161,28 +138,27 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar()
wxMenuBar* oldMenuBar = GetMenuBar(); wxMenuBar* oldMenuBar = GetMenuBar();
WX_MENUBAR* menuBar = new WX_MENUBAR(); WX_MENUBAR* menuBar = new WX_MENUBAR();
//----- File menu ----------------------------------------------------------- //----- File menu -----------------------------------------------------------
// //
CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool );
fileMenu->AddClose( _( "Footprint Viewer" ) ); fileMenu->AddClose( _( "Footprint Viewer" ) );
fileMenu->Resolve();
//----- View menu ----------------------------------------------------------- //----- View menu -----------------------------------------------------------
// //
CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
viewMenu->AddSeparator(); viewMenu->AppendSeparator();
viewMenu->AddItem( ACTIONS::zoomInCenter, SELECTION_CONDITIONS::ShowAlways ); viewMenu->Add( ACTIONS::zoomInCenter );
viewMenu->AddItem( ACTIONS::zoomOutCenter, SELECTION_CONDITIONS::ShowAlways ); viewMenu->Add( ACTIONS::zoomOutCenter );
viewMenu->AddItem( ACTIONS::zoomFitScreen, SELECTION_CONDITIONS::ShowAlways ); viewMenu->Add( ACTIONS::zoomFitScreen );
viewMenu->AddItem( ACTIONS::zoomRedraw, SELECTION_CONDITIONS::ShowAlways ); viewMenu->Add( ACTIONS::zoomRedraw );
viewMenu->AddSeparator(); viewMenu->AppendSeparator();
viewMenu->AddItem( ACTIONS::show3DViewer, SELECTION_CONDITIONS::ShowAlways ); viewMenu->Add( ACTIONS::show3DViewer );
viewMenu->Resolve();
//----- Menubar ------------------------------------------------------------- //----- Menubar -------------------------------------------------------------
// //

View File

@ -49,7 +49,9 @@
#include <view/view.h> #include <view/view.h>
#include <wx/wupdlock.h> #include <wx/wupdlock.h>
extern bool IsWxPythonLoaded(); #if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON)
#include <python_scripting.h>
#endif
#define SEL_LAYER_HELP _( \ #define SEL_LAYER_HELP _( \
"Show active layer selections\nand select layer pair for route and place via" ) "Show active layer selections\nand select layer pair for route and place via" )
@ -386,39 +388,19 @@ void PCB_EDIT_FRAME::ReCreateVToolbar()
m_drawToolBar->Add( PCB_ACTIONS::gridSetOrigin, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( PCB_ACTIONS::gridSetOrigin, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( ACTIONS::measureTool, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( ACTIONS::measureTool, ACTION_TOOLBAR::TOGGLE );
auto isHighlightMode = SELECTION_TOOL* selTool = m_toolManager->GetTool<SELECTION_TOOL>();
[this]( const SELECTION& aSel ) ACTION_MENU* routeMenu = new ACTION_MENU( false, selTool );
{ routeMenu->Add( PCB_ACTIONS::routerHighlightMode, ACTION_MENU::CHECK );
ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>(); routeMenu->Add( PCB_ACTIONS::routerShoveMode, ACTION_MENU::CHECK );
return tool->GetRouterMode() == PNS::RM_MarkObstacles; routeMenu->Add( PCB_ACTIONS::routerWalkaroundMode, ACTION_MENU::CHECK );
};
auto isShoveMode = routeMenu->AppendSeparator();
[this]( const SELECTION& aSel ) routeMenu->Add( PCB_ACTIONS::routerSettingsDialog );
{
ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>();
return tool->GetRouterMode() == PNS::RM_Shove;
};
auto isWalkaroundMode =
[this]( const SELECTION& aSel )
{
ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>();
return tool->GetRouterMode() == PNS::RM_Walkaround;
};
SELECTION_TOOL* selTool = m_toolManager->GetTool<SELECTION_TOOL>();
CONDITIONAL_MENU* routeMenu = new CONDITIONAL_MENU( false, selTool );
routeMenu->AddCheckItem( PCB_ACTIONS::routerHighlightMode, isHighlightMode );
routeMenu->AddCheckItem( PCB_ACTIONS::routerShoveMode, isShoveMode );
routeMenu->AddCheckItem( PCB_ACTIONS::routerWalkaroundMode, isWalkaroundMode );
routeMenu->AddSeparator();
routeMenu->AddItem( PCB_ACTIONS::routerSettingsDialog, SELECTION_CONDITIONS::ShowAlways );
m_drawToolBar->AddToolContextMenu( PCB_ACTIONS::routeSingleTrack, routeMenu ); m_drawToolBar->AddToolContextMenu( PCB_ACTIONS::routeSingleTrack, routeMenu );
CONDITIONAL_MENU* zoneMenu = new CONDITIONAL_MENU( false, selTool ); ACTION_MENU* zoneMenu = new ACTION_MENU( false, selTool );
zoneMenu->AddItem( PCB_ACTIONS::zoneFillAll, SELECTION_CONDITIONS::ShowAlways ); zoneMenu->Add( PCB_ACTIONS::zoneFillAll );
zoneMenu->AddItem( PCB_ACTIONS::zoneUnfillAll, SELECTION_CONDITIONS::ShowAlways ); zoneMenu->Add( PCB_ACTIONS::zoneUnfillAll );
m_drawToolBar->AddToolContextMenu( PCB_ACTIONS::drawZone, zoneMenu ); m_drawToolBar->AddToolContextMenu( PCB_ACTIONS::drawZone, zoneMenu );
m_drawToolBar->Realize(); m_drawToolBar->Realize();
@ -682,95 +664,3 @@ void PCB_EDIT_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent )
{ {
m_SelLayerBox->SetLayerSelection( GetActiveLayer() ); m_SelLayerBox->SetLayerSelection( GetActiveLayer() );
} }
bool PCB_EDIT_FRAME::LayerManagerShown()
{
return m_auimgr.GetPane( "LayersManager" ).IsShown();
}
bool PCB_EDIT_FRAME::MicrowaveToolbarShown()
{
return m_auimgr.GetPane( "MicrowaveToolbar" ).IsShown();
}
void PCB_EDIT_FRAME::SyncToolbars()
{
#define TOGGLE_TOOL( toolbar, tool ) toolbar->Toggle( tool, IsCurrentTool( tool ) )
if( !m_mainToolBar || !m_optionsToolBar || !m_drawToolBar || !m_microWaveToolBar )
return;
auto& opts = GetDisplayOptions();
KIGFX::GAL_DISPLAY_OPTIONS& galOpts = GetGalDisplayOptions();
ZONE_DISPLAY_MODE zoneMode = opts.m_ZoneDisplayMode;
m_mainToolBar->Toggle( ACTIONS::save, IsContentModified() );
m_mainToolBar->Toggle( ACTIONS::undo, GetUndoCommandCount() > 0 );
m_mainToolBar->Toggle( ACTIONS::redo, GetRedoCommandCount() > 0 );
TOGGLE_TOOL( m_mainToolBar, ACTIONS::zoomTool );
#if defined(KICAD_SCRIPTING_WXPYTHON)
if( IsWxPythonLoaded() )
{
wxMiniFrame* console = (wxMiniFrame *) PCB_EDIT_FRAME::findPythonConsole();
m_mainToolBar->Toggle( PCB_ACTIONS::showPythonConsole, console && console->IsShown() );
}
#endif
m_mainToolBar->Refresh();
PrepareLayerIndicator();
m_optionsToolBar->Toggle( ACTIONS::toggleGrid, IsGridVisible() );
m_optionsToolBar->Toggle( ACTIONS::metricUnits, GetUserUnits() != EDA_UNITS::INCHES );
m_optionsToolBar->Toggle( ACTIONS::imperialUnits, GetUserUnits() == EDA_UNITS::INCHES );
m_optionsToolBar->Toggle( ACTIONS::togglePolarCoords, GetShowPolarCoords() );
m_optionsToolBar->Toggle( ACTIONS::toggleCursorStyle, galOpts.m_fullscreenCursor );
m_optionsToolBar->Toggle( PCB_ACTIONS::showRatsnest, opts.m_ShowGlobalRatsnest );
m_optionsToolBar->Toggle( PCB_ACTIONS::ratsnestLineMode, opts.m_DisplayRatsnestLinesCurved );
m_optionsToolBar->Toggle( PCB_ACTIONS::showLayersManager, LayerManagerShown() );
m_optionsToolBar->Toggle( PCB_ACTIONS::showMicrowaveToolbar, MicrowaveToolbarShown() );
m_optionsToolBar->Toggle( PCB_ACTIONS::zoneDisplayEnable,
zoneMode == ZONE_DISPLAY_MODE::SHOW_FILLED );
m_optionsToolBar->Toggle( PCB_ACTIONS::zoneDisplayDisable,
zoneMode == ZONE_DISPLAY_MODE::HIDE_FILLED );
m_optionsToolBar->Toggle( PCB_ACTIONS::zoneDisplayOutlines,
zoneMode == ZONE_DISPLAY_MODE::SHOW_OUTLINED );
m_optionsToolBar->Toggle( PCB_ACTIONS::trackDisplayMode, !opts.m_DisplayPcbTrackFill );
m_optionsToolBar->Toggle( PCB_ACTIONS::viaDisplayMode, !opts.m_DisplayViaFill );
m_optionsToolBar->Toggle( PCB_ACTIONS::padDisplayMode, !opts.m_DisplayPadFill );
m_optionsToolBar->Toggle( ACTIONS::highContrastMode,
opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL );
m_optionsToolBar->Refresh();
TOGGLE_TOOL( m_drawToolBar, ACTIONS::selectionTool );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::highlightNetTool );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::localRatsnestTool );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::placeModule );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::routeSingleTrack );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawVia );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawZone );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawZoneKeepout );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawLine );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawRectangle );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawCircle );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawArc );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawPolygon );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::placeText );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawDimension );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::placeTarget );
TOGGLE_TOOL( m_drawToolBar, ACTIONS::deleteTool );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drillOrigin );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::gridSetOrigin );
TOGGLE_TOOL( m_drawToolBar, ACTIONS::measureTool );
m_drawToolBar->Refresh();
TOGGLE_TOOL( m_microWaveToolBar, PCB_ACTIONS::microwaveCreateLine );
TOGGLE_TOOL( m_microWaveToolBar, PCB_ACTIONS::microwaveCreateGap );
TOGGLE_TOOL( m_microWaveToolBar, PCB_ACTIONS::microwaveCreateStub );
TOGGLE_TOOL( m_microWaveToolBar, PCB_ACTIONS::microwaveCreateStubArc );
TOGGLE_TOOL( m_microWaveToolBar, PCB_ACTIONS::microwaveCreateFunctionShape );
m_microWaveToolBar->Refresh();
}

View File

@ -0,0 +1,153 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Ian McInerney <ian.s.mcinerney at ieee.org>
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <pcb_base_frame.h>
#include <tool/selection.h>
#include <tools/pcb_editor_conditions.h>
#include <functional>
#include <wx/debug.h>
using namespace std::placeholders;
SELECTION_CONDITION PCB_EDITOR_CONDITIONS::PadNumbersDisplay()
{
// Requires a PCB_BASE_FRAME
PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
wxASSERT( drwFrame );
return std::bind( &PCB_EDITOR_CONDITIONS::padNumberDisplayFunc, _1, drwFrame );
}
SELECTION_CONDITION PCB_EDITOR_CONDITIONS::PadFillDisplay()
{
// Requires a PCB_BASE_FRAME
PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
wxASSERT( drwFrame );
return std::bind( &PCB_EDITOR_CONDITIONS::padFillDisplayFunc, _1, drwFrame );
}
SELECTION_CONDITION PCB_EDITOR_CONDITIONS::TextFillDisplay()
{
// Requires a PCB_BASE_FRAME
PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
wxASSERT( drwFrame );
return std::bind( &PCB_EDITOR_CONDITIONS::textFillDisplayFunc, _1, drwFrame );
}
SELECTION_CONDITION PCB_EDITOR_CONDITIONS::GraphicsFillDisplay()
{
// Requires a PCB_BASE_FRAME
PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
wxASSERT( drwFrame );
return std::bind( &PCB_EDITOR_CONDITIONS::graphicsFillDisplayFunc, _1, drwFrame );
}
SELECTION_CONDITION PCB_EDITOR_CONDITIONS::ViaFillDisplay()
{
// Requires a PCB_BASE_FRAME
PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
wxASSERT( drwFrame );
return std::bind( &PCB_EDITOR_CONDITIONS::viaFillDisplayFunc, _1, drwFrame );
}
SELECTION_CONDITION PCB_EDITOR_CONDITIONS::TrackFillDisplay()
{
// Requires a PCB_BASE_FRAME
PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
wxASSERT( drwFrame );
return std::bind( &PCB_EDITOR_CONDITIONS::trackFillDisplayFunc, _1, drwFrame );
}
SELECTION_CONDITION PCB_EDITOR_CONDITIONS::ZoneDisplayMode( ZONE_DISPLAY_MODE aMode )
{
// Requires a PCB_BASE_FRAME
PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
wxASSERT( drwFrame );
return std::bind( &PCB_EDITOR_CONDITIONS::zoneDisplayModeFunc, _1, drwFrame, aMode );
}
bool PCB_EDITOR_CONDITIONS::padNumberDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame )
{
return aFrame->GetDisplayOptions().m_DisplayPadNum;
}
bool PCB_EDITOR_CONDITIONS::padFillDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame )
{
return aFrame->GetDisplayOptions().m_DisplayPadFill;
}
bool PCB_EDITOR_CONDITIONS::textFillDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame )
{
return aFrame->GetDisplayOptions().m_DisplayTextFill;
}
bool PCB_EDITOR_CONDITIONS::graphicsFillDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame )
{
return aFrame->GetDisplayOptions().m_DisplayGraphicsFill;
}
bool PCB_EDITOR_CONDITIONS::viaFillDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame )
{
return aFrame->GetDisplayOptions().m_DisplayViaFill;
}
bool PCB_EDITOR_CONDITIONS::trackFillDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame )
{
return aFrame->GetDisplayOptions().m_DisplayPcbTrackFill;
}
bool PCB_EDITOR_CONDITIONS::zoneDisplayModeFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame,
ZONE_DISPLAY_MODE aMode )
{
return aFrame->GetDisplayOptions().m_ZoneDisplayMode == aMode;
}

View File

@ -0,0 +1,122 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Ian McInerney <ian.s.mcinerney at ieee.org>
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef PCB_EDITOR_CONDITIONS_H_
#define PCB_EDITOR_CONDITIONS_H_
#include <common.h>
#include <functional>
#include <tool/editor_conditions.h>
#include <tool/selection.h>
#include <tool/tool_action.h>
class EDA_BASE_FRAME;
class EDA_DRAW_FRAME;
class PCB_BASE_FRAME;
/**
* Class that groups generic conditions for PCB editor states.
*/
class PCB_EDITOR_CONDITIONS : public EDITOR_CONDITIONS
{
public:
PCB_EDITOR_CONDITIONS( PCB_BASE_FRAME* aFrame ) :
EDITOR_CONDITIONS( aFrame )
{}
/**
* Creates a functor that tests if the pad numbers are displayed
*
* @return Functor returning true if the pad numbers are displayed
*/
SELECTION_CONDITION PadNumbersDisplay();
/**
* Creates a functor that tests if the frame fills the pads
*
* @return Functor returning true if the pads are filled
*/
SELECTION_CONDITION PadFillDisplay();
/**
* Creates a functor that tests if the frame fills text items
*
* @return Functor returning true if the text items are filled
*/
SELECTION_CONDITION TextFillDisplay();
/**
* Creates a functor that tests if the frame fills graphics items
*
* @return Functor returning true if graphics items are filled
*/
SELECTION_CONDITION GraphicsFillDisplay();
/**
* Creates a functor that tests if the frame fills vias
*
* @return Functor returning true if vias are filled
*/
SELECTION_CONDITION ViaFillDisplay();
/**
* Creates a functor that tests if the frame fills vias
*
* @return Functor returning true if tracks are filled
*/
SELECTION_CONDITION TrackFillDisplay();
/**
* Creates a functor that tests the current zone display mode in the frame
*
* @param aMode is the mode to test for
* @return Functor returning true if the frame is using the specified mode
*/
SELECTION_CONDITION ZoneDisplayMode( ZONE_DISPLAY_MODE aMode );
protected:
///> Helper function used by PadNumbersDisplay()
static bool padNumberDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame );
///> Helper function used by PadFillDisplay()
static bool padFillDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame );
///> Helper function used by TextFillDisplay()
static bool textFillDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame );
///> Helper function used by GraphicsFillDisplay()
static bool graphicsFillDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame );
///> Helper function used by ViaFillDisplay()
static bool viaFillDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame );
///> Helper function used by TrackFillDisplay()
static bool trackFillDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame );
///> Helper function used by ZoneDisplayMode()
static bool zoneDisplayModeFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame,
ZONE_DISPLAY_MODE aMode );
};
#endif /* PCB_EDITOR_CONDITIONS_H_ */