Move footprint & symbol tree context menus to tool infrastructure.
Fixes: lp:1831692 * https://bugs.launchpad.net/kicad/+bug/1831692
This commit is contained in:
parent
c711ad5c7c
commit
2d40425e4d
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2017 Chris Pavlina <pavlina.chris@gmail.com>
|
||||
* Copyright (C) 2014 Henner Zeller <h.zeller@acm.org>
|
||||
* Copyright (C) 2014-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2014-2019 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
|
||||
|
@ -23,16 +23,13 @@
|
|||
#define LIB_TREE_MODEL_ADAPTER_H
|
||||
|
||||
#include <lib_id.h>
|
||||
|
||||
#include <lib_tree_model.h>
|
||||
|
||||
#include <wx/hashmap.h>
|
||||
#include <wx/dataview.h>
|
||||
#include <wx/headerctrl.h>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
|
||||
/**
|
||||
* Adapter class in the component selector Model-View-Adapter (mediated MVC)
|
||||
* architecture. The other pieces are in:
|
||||
|
@ -90,6 +87,9 @@
|
|||
* - `Compare()` - compare two rows, for sorting
|
||||
* - `HasDefaultCompare()` - whether sorted by default
|
||||
*/
|
||||
|
||||
class TOOL_INTERACTIVE;
|
||||
|
||||
class LIB_TREE_MODEL_ADAPTER: public wxDataViewModel
|
||||
{
|
||||
public:
|
||||
|
@ -251,6 +251,9 @@ public:
|
|||
void Thaw() { m_freeze--; }
|
||||
bool IsFrozen() const { return m_freeze; }
|
||||
|
||||
// Allows subclasses to nominate a context menu handler.
|
||||
virtual TOOL_INTERACTIVE* GetContextMenuTool() { return nullptr; }
|
||||
|
||||
protected:
|
||||
static wxDataViewItem ToItem( LIB_TREE_NODE const* aNode );
|
||||
static LIB_TREE_NODE const* ToNode( wxDataViewItem aItem );
|
||||
|
@ -258,40 +261,31 @@ protected:
|
|||
|
||||
LIB_TREE_NODE_ROOT m_tree;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
LIB_TREE_MODEL_ADAPTER();
|
||||
|
||||
/**
|
||||
* Check whether a container has columns too
|
||||
*/
|
||||
virtual bool HasContainerColumns( wxDataViewItem const& aItem ) const override;
|
||||
bool HasContainerColumns( wxDataViewItem const& aItem ) const override;
|
||||
|
||||
/**
|
||||
* Check whether an item can have children.
|
||||
*/
|
||||
virtual bool IsContainer( wxDataViewItem const& aItem ) const override;
|
||||
bool IsContainer( wxDataViewItem const& aItem ) const override;
|
||||
|
||||
/**
|
||||
* Get the parent of an item.
|
||||
*
|
||||
* @param aItem item to get the parent of
|
||||
* @return parent of aItem, or an invalid wxDataViewItem if parent is root
|
||||
*/
|
||||
virtual wxDataViewItem GetParent( wxDataViewItem const& aItem ) const override;
|
||||
wxDataViewItem GetParent( wxDataViewItem const& aItem ) const override;
|
||||
|
||||
unsigned int GetColumnCount() const override { return 2; }
|
||||
|
||||
/**
|
||||
* Return the number of columns in the model
|
||||
* Return the type of data stored in the column as indicated by wxVariant::GetType()
|
||||
*/
|
||||
virtual unsigned int GetColumnCount() const override { return 2; }
|
||||
|
||||
/**
|
||||
* Return the type of data stored in the column
|
||||
*
|
||||
* @return type of data as indicated by wxVariant::GetType()
|
||||
*/
|
||||
virtual wxString GetColumnType( unsigned int aCol ) const override { return "string"; }
|
||||
wxString GetColumnType( unsigned int aCol ) const override { return "string"; }
|
||||
|
||||
/**
|
||||
* Get the value of an item.
|
||||
|
@ -300,17 +294,17 @@ protected:
|
|||
* @param aItem item whose data will be placed into aVariant
|
||||
* @param aCol column number of the data
|
||||
*/
|
||||
virtual void GetValue( wxVariant& aVariant,
|
||||
wxDataViewItem const& aItem,
|
||||
unsigned int aCol ) const override;
|
||||
void GetValue( wxVariant& aVariant,
|
||||
wxDataViewItem const& aItem,
|
||||
unsigned int aCol ) const override;
|
||||
|
||||
/**
|
||||
* Set the value of an item. Does nothing - this model doesn't support
|
||||
* editing.
|
||||
*/
|
||||
virtual bool SetValue( wxVariant const& aVariant,
|
||||
wxDataViewItem const& aItem,
|
||||
unsigned int aCol ) override { return false; }
|
||||
bool SetValue( wxVariant const& aVariant,
|
||||
wxDataViewItem const& aItem,
|
||||
unsigned int aCol ) override { return false; }
|
||||
|
||||
/**
|
||||
* Get any formatting for an item.
|
||||
|
@ -320,9 +314,9 @@ protected:
|
|||
* @param aAttr receiver for attributes
|
||||
* @return true iff the item has non-default attributes
|
||||
*/
|
||||
virtual bool GetAttr( wxDataViewItem const& aItem,
|
||||
unsigned int aCol,
|
||||
wxDataViewItemAttr& aAttr ) const override;
|
||||
bool GetAttr( wxDataViewItem const& aItem,
|
||||
unsigned int aCol,
|
||||
wxDataViewItemAttr& aAttr ) const override;
|
||||
|
||||
private:
|
||||
CMP_FILTER_TYPE m_filter;
|
||||
|
|
|
@ -30,13 +30,15 @@
|
|||
#include <tool/action_menu.h>
|
||||
|
||||
TOOL_INTERACTIVE::TOOL_INTERACTIVE( TOOL_ID aId, const std::string& aName ) :
|
||||
TOOL_BASE( INTERACTIVE, aId, aName )
|
||||
TOOL_BASE( INTERACTIVE, aId, aName ),
|
||||
m_menu( *this )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TOOL_INTERACTIVE::TOOL_INTERACTIVE( const std::string& aName ) :
|
||||
TOOL_BASE( INTERACTIVE, TOOL_MANAGER::MakeToolId( aName ), aName )
|
||||
TOOL_BASE( INTERACTIVE, TOOL_MANAGER::MakeToolId( aName ), aName ),
|
||||
m_menu( *this )
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -653,7 +653,7 @@ bool TOOL_MANAGER::dispatchActivation( const TOOL_EVENT& aEvent )
|
|||
return false;
|
||||
}
|
||||
|
||||
void TOOL_MANAGER::dispatchContextMenu( const TOOL_EVENT& aEvent )
|
||||
void TOOL_MANAGER::DispatchContextMenu( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
for( TOOL_ID toolId : m_activeTools )
|
||||
{
|
||||
|
@ -887,7 +887,7 @@ void TOOL_MANAGER::saveViewControls( TOOL_STATE* aState )
|
|||
|
||||
if( m_menuActive )
|
||||
{
|
||||
// Context menu is active, so the cursor settings are overridden (see dispatchContextMenu())
|
||||
// Context menu is active, so the cursor settings are overridden (see DispatchContextMenu())
|
||||
auto it = m_cursorSettings.find( aState->theTool->GetId() );
|
||||
|
||||
if( it != m_cursorSettings.end() )
|
||||
|
@ -935,7 +935,7 @@ bool TOOL_MANAGER::processEvent( const TOOL_EVENT& aEvent )
|
|||
|
||||
dispatchInternal( aEvent );
|
||||
dispatchActivation( aEvent );
|
||||
dispatchContextMenu( aEvent );
|
||||
DispatchContextMenu( aEvent );
|
||||
|
||||
// Dispatch queue
|
||||
while( !m_eventQueue.empty() )
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2014 Henner Zeller <h.zeller@acm.org>
|
||||
* Copyright (C) 2014-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2014-2019 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
|
||||
|
@ -24,14 +24,12 @@
|
|||
|
||||
#include "lib_tree.h"
|
||||
#include <wxdataviewctrl_helpers.h>
|
||||
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/statbmp.h>
|
||||
#include <wx/html/htmlwin.h>
|
||||
|
||||
#include <lib_table_base.h>
|
||||
|
||||
#include <tool/tool_interactive.h>
|
||||
#include <tool/tool_manager.h>
|
||||
|
||||
LIB_TREE::LIB_TREE( wxWindow* aParent, LIB_TABLE* aLibTable, LIB_TREE_MODEL_ADAPTER::PTR& aAdapter,
|
||||
WIDGETS aWidgets, wxHtmlWindow* aDetails )
|
||||
|
@ -40,12 +38,8 @@ LIB_TREE::LIB_TREE( wxWindow* aParent, LIB_TABLE* aLibTable, LIB_TREE_MODEL_ADAP
|
|||
m_lib_table( aLibTable ),
|
||||
m_adapter( aAdapter ),
|
||||
m_query_ctrl( nullptr ),
|
||||
m_details_ctrl( nullptr ),
|
||||
m_menuActive( false )
|
||||
m_details_ctrl( nullptr )
|
||||
{
|
||||
// create space for context menu pointers, INVALID is the max value
|
||||
m_menus.resize( LIB_TREE_NODE::TYPE::INVALID + 1 );
|
||||
|
||||
auto sizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
// Search text control
|
||||
|
@ -412,14 +406,15 @@ void LIB_TREE::onPreselect( wxCommandEvent& aEvent )
|
|||
|
||||
void LIB_TREE::onContextMenu( wxDataViewEvent& aEvent )
|
||||
{
|
||||
auto const sel = m_tree_ctrl->GetSelection();
|
||||
auto type = sel.IsOk() ? m_adapter->GetTypeFor( sel ) : LIB_TREE_NODE::INVALID;
|
||||
|
||||
if( m_menus[type] )
|
||||
TOOL_INTERACTIVE* tool = m_adapter->GetContextMenuTool();
|
||||
|
||||
if( tool )
|
||||
{
|
||||
m_menuActive = true;
|
||||
PopupMenu( m_menus[type].get() );
|
||||
m_menuActive = false;
|
||||
tool->Activate();
|
||||
tool->GetToolMenu().ShowContextMenu();
|
||||
|
||||
TOOL_EVENT evt( TC_MOUSE, TA_MOUSE_CLICK, BUT_RIGHT );
|
||||
tool->GetManager()->DispatchContextMenu( evt );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2014 Henner Zeller <h.zeller@acm.org>
|
||||
* Copyright (C) 2014-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2014-2019 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
|
||||
|
@ -32,10 +32,10 @@ class wxDataViewCtrl;
|
|||
class wxTextCtrl;
|
||||
class wxHtmlWindow;
|
||||
class wxHtmlLinkEvent;
|
||||
class ACTION_MENU;
|
||||
class LIB_ID;
|
||||
class LIB_TABLE;
|
||||
|
||||
|
||||
/**
|
||||
* Widget displaying a tree of components with optional search text control and description panel.
|
||||
*/
|
||||
|
@ -89,25 +89,6 @@ public:
|
|||
*/
|
||||
void ExpandLibId( const LIB_ID& aLibId );
|
||||
|
||||
/**
|
||||
* Associates a right click context menu for a specific node type.
|
||||
* @param aType is the node type to have a menu associated.
|
||||
* @param aMenu is the associated menu.
|
||||
*/
|
||||
void SetMenu( LIB_TREE_NODE::TYPE aType, std::unique_ptr<wxMenu> aMenu )
|
||||
{
|
||||
m_menus[aType] = std::move( aMenu );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the status of right-click context menu.
|
||||
* @return True in case a right-click context menu is active.
|
||||
*/
|
||||
bool IsMenuActive() const
|
||||
{
|
||||
return m_menuActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Regenerates the tree.
|
||||
*/
|
||||
|
@ -170,7 +151,6 @@ protected:
|
|||
void onTreeSelect( wxDataViewEvent& aEvent );
|
||||
void onTreeActivate( wxDataViewEvent& aEvent );
|
||||
void onExpandCollapse( wxDataViewEvent& aEvent );
|
||||
void onUpdateUI( wxUpdateUIEvent& aEvent );
|
||||
|
||||
void onDetailsLink( wxHtmlLinkEvent& aEvent );
|
||||
void onPreselect( wxCommandEvent& aEvent );
|
||||
|
@ -183,12 +163,6 @@ protected:
|
|||
wxDataViewCtrl* m_tree_ctrl;
|
||||
wxHtmlWindow* m_details_ctrl;
|
||||
|
||||
///> Right click context menus for each tree level
|
||||
std::vector<std::unique_ptr<wxMenu>> m_menus;
|
||||
|
||||
///> Flag indicating whether a right-click context menu is active
|
||||
bool m_menuActive;
|
||||
|
||||
///> State of the widget before any filters applied
|
||||
STATE m_unfilteredState;
|
||||
};
|
||||
|
|
|
@ -40,8 +40,7 @@ TOOL_ACTION CVPCB_ACTIONS::selectionActivate( "cvpcb.InteractiveSelection",
|
|||
|
||||
CVPCB_SELECTION_TOOL::CVPCB_SELECTION_TOOL() :
|
||||
TOOL_INTERACTIVE( "cvpcb.InteractiveSelection" ),
|
||||
m_frame( nullptr ),
|
||||
m_menu( *this )
|
||||
m_frame( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -45,8 +45,6 @@ public:
|
|||
/// @copydoc TOOL_BASE::Reset()
|
||||
void Reset( RESET_REASON aReason ) override;
|
||||
|
||||
inline TOOL_MENU& GetToolMenu() { return m_menu; }
|
||||
|
||||
/**
|
||||
* Function Main()
|
||||
*
|
||||
|
@ -72,8 +70,6 @@ private:
|
|||
|
||||
/// Current state of selection (not really used: no selection in display footprints frame).
|
||||
SELECTION m_selection;
|
||||
|
||||
TOOL_MENU m_menu;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -35,12 +35,10 @@
|
|||
#include <msgpanel.h>
|
||||
#include <confirm.h>
|
||||
#include <eda_dockart.h>
|
||||
|
||||
#include <general.h>
|
||||
#include <eeschema_id.h>
|
||||
#include <lib_edit_frame.h>
|
||||
#include <class_library.h>
|
||||
|
||||
#include <lib_manager.h>
|
||||
#include <widgets/symbol_tree_pane.h>
|
||||
#include <widgets/lib_tree.h>
|
||||
|
@ -136,7 +134,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
SetShowElectricalType( true );
|
||||
m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs
|
||||
|
||||
m_my_part = NULL;
|
||||
m_my_part = nullptr;
|
||||
m_treePane = nullptr;
|
||||
m_libMgr = nullptr;
|
||||
m_unit = 1;
|
||||
|
@ -169,11 +167,12 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
|
||||
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
||||
|
||||
setupTools();
|
||||
|
||||
m_libMgr = new LIB_MANAGER( *this );
|
||||
SyncLibraries( true );
|
||||
m_treePane = new SYMBOL_TREE_PANE( this, m_libMgr );
|
||||
|
||||
setupTools();
|
||||
ReCreateMenuBar();
|
||||
ReCreateHToolbar();
|
||||
ReCreateVToolbar();
|
||||
|
@ -298,7 +297,7 @@ double LIB_EDIT_FRAME::BestZoom()
|
|||
|
||||
void LIB_EDIT_FRAME::RebuildSymbolUnitsList()
|
||||
{
|
||||
if( m_partSelectBox == NULL )
|
||||
if( !m_partSelectBox )
|
||||
return;
|
||||
|
||||
if( m_partSelectBox->GetCount() != 0 )
|
||||
|
@ -372,10 +371,10 @@ void LIB_EDIT_FRAME::OnUpdateSyncPinEdit( wxUpdateUIEvent& event )
|
|||
|
||||
void LIB_EDIT_FRAME::OnUpdatePartNumber( wxUpdateUIEvent& event )
|
||||
{
|
||||
if( m_partSelectBox == NULL )
|
||||
if( !m_partSelectBox )
|
||||
return;
|
||||
|
||||
LIB_PART* part = GetCurPart();
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
// Using the typical event.Enable() call doesn't seem to work with wxGTK
|
||||
// so use the pointer to alias combobox to directly enable or disable.
|
||||
|
@ -447,9 +446,7 @@ void LIB_EDIT_FRAME::SetCurPart( LIB_PART* aPart )
|
|||
|
||||
if( m_my_part != aPart )
|
||||
{
|
||||
if( m_my_part )
|
||||
delete m_my_part;
|
||||
|
||||
delete m_my_part;
|
||||
m_my_part = aPart;
|
||||
}
|
||||
|
||||
|
@ -512,7 +509,7 @@ void LIB_EDIT_FRAME::OnAddPartToSchematic( wxCommandEvent& event )
|
|||
{
|
||||
SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false );
|
||||
|
||||
if( schframe == NULL ) // happens when the schematic editor is not active (or closed)
|
||||
if( !schframe ) // happens when the schematic editor is not active (or closed)
|
||||
{
|
||||
DisplayErrorMessage( this, _( "No schematic currently open." ) );
|
||||
return;
|
||||
|
@ -525,7 +522,7 @@ void LIB_EDIT_FRAME::OnAddPartToSchematic( wxCommandEvent& event )
|
|||
component->Resolve( *Prj().SchSymbolLibTable() );
|
||||
|
||||
if( schframe->GetAutoplaceFields() )
|
||||
component->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false );
|
||||
component->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
|
||||
|
||||
schframe->Raise();
|
||||
schframe->GetToolManager()->RunAction( EE_ACTIONS::placeSymbol, true, component );
|
||||
|
@ -595,30 +592,31 @@ bool LIB_EDIT_FRAME::AddLibraryFile( bool aCreateNew )
|
|||
}
|
||||
|
||||
|
||||
LIB_ID LIB_EDIT_FRAME::GetTreeLIBID() const
|
||||
{
|
||||
return m_treePane->GetLibTree()->GetSelectedLibId();
|
||||
}
|
||||
|
||||
|
||||
LIB_PART* LIB_EDIT_FRAME::getTargetPart() const
|
||||
{
|
||||
LIB_ALIAS* alias = nullptr;
|
||||
|
||||
if( m_treePane->GetLibTree()->IsMenuActive() )
|
||||
LIB_ID libId = GetTreeLIBID();
|
||||
|
||||
if( libId.IsValid() )
|
||||
{
|
||||
LIB_ID libId = m_treePane->GetLibTree()->GetSelectedLibId();
|
||||
alias = m_libMgr->GetAlias( libId.GetLibItemName(), libId.GetLibNickname() );
|
||||
}
|
||||
else if( LIB_PART* part = GetCurPart() )
|
||||
{
|
||||
alias = part->GetAlias( 0 );
|
||||
LIB_ALIAS* alias = m_libMgr->GetAlias( libId.GetLibItemName(), libId.GetLibNickname() );
|
||||
return alias ? alias->GetPart() : nullptr;
|
||||
}
|
||||
|
||||
return alias ? alias->GetPart() : nullptr;
|
||||
return GetCurPart();
|
||||
}
|
||||
|
||||
|
||||
LIB_ID LIB_EDIT_FRAME::getTargetLibId() const
|
||||
{
|
||||
LIB_ID id = m_treePane->GetLibTree()->GetSelectedLibId();
|
||||
wxString nickname = id.GetLibNickname();
|
||||
LIB_ID id = GetTreeLIBID();
|
||||
|
||||
if( nickname.IsEmpty() && GetCurPart() )
|
||||
if( id.GetLibNickname().empty() && GetCurPart() )
|
||||
id = GetCurPart()->GetLibId();
|
||||
|
||||
return id;
|
||||
|
|
|
@ -124,7 +124,7 @@ public:
|
|||
public:
|
||||
LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent );
|
||||
|
||||
~LIB_EDIT_FRAME();
|
||||
~LIB_EDIT_FRAME() override;
|
||||
|
||||
/**
|
||||
* switches currently used canvas ( Cairo / OpenGL).
|
||||
|
@ -137,6 +137,11 @@ public:
|
|||
/** Sets the current library nickname and returns the old library nickname. */
|
||||
wxString SetCurLib( const wxString& aLibNickname );
|
||||
|
||||
/**
|
||||
* Return the LIB_ID of the library or symbol selected in the symbol tree.
|
||||
*/
|
||||
LIB_ID GetTreeLIBID() const;
|
||||
|
||||
/**
|
||||
* Return the current part being edited or NULL if none selected.
|
||||
*
|
||||
|
@ -471,9 +476,9 @@ public:
|
|||
|
||||
void SyncMenusAndToolbars() override;
|
||||
|
||||
virtual void SetScreen( BASE_SCREEN* aScreen ) override;
|
||||
void SetScreen( BASE_SCREEN* aScreen ) override;
|
||||
|
||||
virtual const BOX2I GetDocumentExtents() const override;
|
||||
const BOX2I GetDocumentExtents() const override;
|
||||
|
||||
void RebuildView();
|
||||
|
||||
|
|
|
@ -36,10 +36,11 @@
|
|||
#include <list>
|
||||
|
||||
|
||||
LIB_MANAGER::LIB_MANAGER( LIB_EDIT_FRAME& aFrame )
|
||||
: m_frame( aFrame ), m_syncHash( 0 )
|
||||
LIB_MANAGER::LIB_MANAGER( LIB_EDIT_FRAME& aFrame ) :
|
||||
m_frame( aFrame ),
|
||||
m_syncHash( 0 )
|
||||
{
|
||||
m_adapter = SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Create( this );
|
||||
m_adapter = SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Create( &m_frame, this );
|
||||
m_adapter->ShowUnits( false );
|
||||
}
|
||||
|
||||
|
@ -560,7 +561,8 @@ bool LIB_MANAGER::PartExists( const wxString& aAlias, const wxString& aLibrary )
|
|||
try
|
||||
{
|
||||
alias = symTable()->LoadSymbol( aLibrary, aAlias );
|
||||
} catch( IO_ERROR& )
|
||||
}
|
||||
catch( IO_ERROR& )
|
||||
{
|
||||
// checking if certain symbol exists, so its absence is perfectly fine
|
||||
}
|
||||
|
@ -686,8 +688,8 @@ std::set<LIB_PART*> LIB_MANAGER::getOriginalParts( const wxString& aLibrary )
|
|||
}
|
||||
catch( const IO_ERROR& e )
|
||||
{
|
||||
DisplayErrorMessage( &m_frame, wxString::Format( _( "Cannot enumerate library \"%s\"" ),
|
||||
aLibrary ),
|
||||
DisplayErrorMessage( &m_frame,
|
||||
wxString::Format( _( "Cannot enumerate library \"%s\"" ), aLibrary ),
|
||||
e.What() );
|
||||
}
|
||||
|
||||
|
@ -713,8 +715,9 @@ LIB_MANAGER::LIB_BUFFER& LIB_MANAGER::getLibraryBuffer( const wxString& aLibrary
|
|||
}
|
||||
|
||||
|
||||
LIB_MANAGER::PART_BUFFER::PART_BUFFER( LIB_PART* aPart, std::unique_ptr<SCH_SCREEN> aScreen )
|
||||
: m_screen( std::move( aScreen ) ), m_part( aPart )
|
||||
LIB_MANAGER::PART_BUFFER::PART_BUFFER( LIB_PART* aPart, std::unique_ptr<SCH_SCREEN> aScreen ) :
|
||||
m_screen( std::move( aScreen ) ),
|
||||
m_part( aPart )
|
||||
{
|
||||
m_original = new LIB_PART( *aPart );
|
||||
}
|
||||
|
|
|
@ -26,21 +26,32 @@
|
|||
#include <lib_manager.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <class_libentry.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/lib_control.h>
|
||||
|
||||
|
||||
LIB_TREE_MODEL_ADAPTER::PTR SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Create( LIB_MANAGER* aLibMgr )
|
||||
LIB_TREE_MODEL_ADAPTER::PTR SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Create( LIB_EDIT_FRAME* aParent,
|
||||
LIB_MANAGER* aLibMgr )
|
||||
{
|
||||
return PTR( new SYMBOL_TREE_SYNCHRONIZING_ADAPTER( aLibMgr ) );
|
||||
return PTR( new SYMBOL_TREE_SYNCHRONIZING_ADAPTER( aParent, aLibMgr ) );
|
||||
}
|
||||
|
||||
|
||||
SYMBOL_TREE_SYNCHRONIZING_ADAPTER::SYMBOL_TREE_SYNCHRONIZING_ADAPTER( LIB_MANAGER* aLibMgr )
|
||||
: m_libMgr( aLibMgr ),
|
||||
m_lastSyncHash( -1 )
|
||||
SYMBOL_TREE_SYNCHRONIZING_ADAPTER::SYMBOL_TREE_SYNCHRONIZING_ADAPTER( LIB_EDIT_FRAME* aParent,
|
||||
LIB_MANAGER* aLibMgr ) :
|
||||
m_frame( aParent ),
|
||||
m_libMgr( aLibMgr ),
|
||||
m_lastSyncHash( -1 )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TOOL_INTERACTIVE* SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetContextMenuTool()
|
||||
{
|
||||
return m_frame->GetToolManager()->GetTool<LIB_CONTROL>();
|
||||
}
|
||||
|
||||
|
||||
bool SYMBOL_TREE_SYNCHRONIZING_ADAPTER::IsContainer( const wxDataViewItem& aItem ) const
|
||||
{
|
||||
const LIB_TREE_NODE* node = ToNode( aItem );
|
||||
|
@ -181,18 +192,6 @@ LIB_TREE_NODE::PTR_VECTOR::iterator SYMBOL_TREE_SYNCHRONIZING_ADAPTER::deleteLib
|
|||
}
|
||||
|
||||
|
||||
LIB_TREE_NODE* SYMBOL_TREE_SYNCHRONIZING_ADAPTER::findLibrary( const wxString& aLibNickName )
|
||||
{
|
||||
for( auto& lib : m_tree.Children )
|
||||
{
|
||||
if( lib->Name == aLibNickName )
|
||||
return lib.get();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
void SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetValue( wxVariant& aVariant, wxDataViewItem const& aItem,
|
||||
unsigned int aCol ) const
|
||||
{
|
||||
|
|
|
@ -28,12 +28,13 @@
|
|||
#include <lib_tree_model_adapter.h>
|
||||
#include <map>
|
||||
|
||||
class LIB_EDIT_FRAME;
|
||||
class LIB_MANAGER;
|
||||
|
||||
class SYMBOL_TREE_SYNCHRONIZING_ADAPTER : public LIB_TREE_MODEL_ADAPTER
|
||||
{
|
||||
public:
|
||||
static PTR Create( LIB_MANAGER* aLibs );
|
||||
static PTR Create( LIB_EDIT_FRAME* aParent, LIB_MANAGER* aLibs );
|
||||
|
||||
bool IsContainer( const wxDataViewItem& aItem ) const override;
|
||||
|
||||
|
@ -41,21 +42,23 @@ public:
|
|||
std::function<void(int, int, const wxString&)> aProgressCallback = [](int, int, const wxString&){} );
|
||||
|
||||
int GetLibrariesCount() const override;
|
||||
|
||||
TOOL_INTERACTIVE* GetContextMenuTool() override;
|
||||
|
||||
protected:
|
||||
void updateLibrary( LIB_TREE_NODE_LIB& aLibNode );
|
||||
|
||||
LIB_TREE_NODE::PTR_VECTOR::iterator deleteLibrary( LIB_TREE_NODE::PTR_VECTOR::iterator& aLibNodeIt );
|
||||
|
||||
LIB_TREE_NODE* findLibrary( const wxString& aLibNickName );
|
||||
|
||||
void GetValue( wxVariant& aVariant, wxDataViewItem const& aItem,
|
||||
unsigned int aCol ) const override;
|
||||
bool GetAttr( wxDataViewItem const& aItem, unsigned int aCol,
|
||||
wxDataViewItemAttr& aAttr ) const override;
|
||||
|
||||
SYMBOL_TREE_SYNCHRONIZING_ADAPTER( LIB_MANAGER* aLibMgr );
|
||||
SYMBOL_TREE_SYNCHRONIZING_ADAPTER( LIB_EDIT_FRAME* aParent, LIB_MANAGER* aLibMgr );
|
||||
|
||||
protected:
|
||||
LIB_EDIT_FRAME* m_frame;
|
||||
LIB_MANAGER* m_libMgr;
|
||||
|
||||
///> Hashes to decide whether a library needs an update
|
||||
|
|
|
@ -160,8 +160,7 @@ EE_SELECTION_TOOL::EE_SELECTION_TOOL() :
|
|||
m_isLibEdit( false ),
|
||||
m_isLibView( false ),
|
||||
m_unit( 0 ),
|
||||
m_convert( 0 ),
|
||||
m_menu( *this )
|
||||
m_convert( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -81,8 +81,6 @@ public:
|
|||
*/
|
||||
SELECTION& GetSelection();
|
||||
|
||||
inline TOOL_MENU& GetToolMenu() { return m_menu; }
|
||||
|
||||
/**
|
||||
* Function RequestSelection()
|
||||
*
|
||||
|
@ -251,8 +249,6 @@ private:
|
|||
bool m_isLibView; // True when libview is the parent frame
|
||||
int m_unit; // Fixed unit filter (for symbol editor)
|
||||
int m_convert; // Fixed DeMorgan filter (for symbol editor)
|
||||
|
||||
TOOL_MENU m_menu;
|
||||
};
|
||||
|
||||
#endif //KICAD_SCH_SELECTION_TOOL_H
|
||||
|
|
|
@ -59,11 +59,10 @@ public:
|
|||
m_frame( nullptr ),
|
||||
m_view( nullptr ),
|
||||
m_selectionTool( nullptr ),
|
||||
m_isLibEdit( false ),
|
||||
m_menu( *this )
|
||||
m_isLibEdit( false )
|
||||
{};
|
||||
|
||||
virtual ~EE_TOOL_BASE() {};
|
||||
~EE_TOOL_BASE() override {};
|
||||
|
||||
/// @copydoc TOOL_INTERACTIVE::Init()
|
||||
bool Init() override
|
||||
|
@ -99,9 +98,6 @@ public:
|
|||
m_view = static_cast<KIGFX::SCH_VIEW*>( getView() );
|
||||
}
|
||||
|
||||
///> Get the tool's top-level context menu
|
||||
inline TOOL_MENU& GetToolMenu() { return m_menu; }
|
||||
|
||||
protected:
|
||||
///> Similar to getView()->Update(), but handles items that are redrawn by their parents.
|
||||
void updateView( EDA_ITEM* aItem ) const
|
||||
|
@ -142,9 +138,6 @@ protected:
|
|||
KIGFX::SCH_VIEW* m_view;
|
||||
EE_SELECTION_TOOL* m_selectionTool;
|
||||
bool m_isLibEdit;
|
||||
|
||||
/// Menu model displayed by the tool.
|
||||
TOOL_MENU m_menu;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -25,9 +25,10 @@
|
|||
#include <sch_painter.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/ee_actions.h>
|
||||
#include <tools/lib_control.h>
|
||||
#include <eeschema_id.h>
|
||||
#include <lib_edit_frame.h>
|
||||
#include <viewlib_frame.h>
|
||||
#include <tools/lib_control.h>
|
||||
|
||||
|
||||
TOOL_ACTION EE_ACTIONS::showElectricalTypes( "eeschema.SymbolLibraryControl.showElectricalTypes",
|
||||
|
@ -42,6 +43,63 @@ TOOL_ACTION EE_ACTIONS::showComponentTree( "eeschema.SymbolLibraryControl.showCo
|
|||
search_tree_xpm );
|
||||
|
||||
|
||||
bool LIB_CONTROL::Init()
|
||||
{
|
||||
if( m_isLibEdit )
|
||||
{
|
||||
CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
|
||||
LIB_EDIT_FRAME* editFrame = getEditFrame<LIB_EDIT_FRAME>();
|
||||
|
||||
auto libSelectedCondition = [ editFrame ] ( const SELECTION& aSel ) {
|
||||
LIB_ID sel = editFrame->GetTreeLIBID();
|
||||
return !sel.GetLibNickname().empty() && sel.GetLibItemName().empty();
|
||||
};
|
||||
auto symbolSelectedCondition = [ editFrame ] ( const SELECTION& aSel ) {
|
||||
LIB_ID sel = editFrame->GetTreeLIBID();
|
||||
return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty();
|
||||
};
|
||||
|
||||
ctxMenu.AddItem( ACTIONS::newLibrary, SELECTION_CONDITIONS::ShowAlways );
|
||||
ctxMenu.AddItem( ACTIONS::addLibrary, SELECTION_CONDITIONS::ShowAlways );
|
||||
ctxMenu.AddItem( ACTIONS::save, libSelectedCondition );
|
||||
ctxMenu.AddItem( ACTIONS::saveAs, libSelectedCondition );
|
||||
ctxMenu.AddItem( ACTIONS::revert, libSelectedCondition );
|
||||
|
||||
ctxMenu.AddSeparator( SELECTION_CONDITIONS::ShowAlways );
|
||||
ctxMenu.AddItem( EE_ACTIONS::newSymbol, SELECTION_CONDITIONS::ShowAlways );
|
||||
ctxMenu.AddItem( ID_LIBEDIT_EDIT_PART,
|
||||
_( "Edit Symbol" ), _( "Show selected symbol on editor canvas" ),
|
||||
edit_xpm, symbolSelectedCondition );
|
||||
|
||||
ctxMenu.AddSeparator( SELECTION_CONDITIONS::ShowAlways );
|
||||
ctxMenu.AddItem( ACTIONS::save, symbolSelectedCondition );
|
||||
ctxMenu.AddItem( ACTIONS::saveCopyAs, symbolSelectedCondition );
|
||||
ctxMenu.AddItem( ID_LIBEDIT_DUPLICATE_PART,
|
||||
_( "Duplicate" ), _( "Make a copy of the selected symbol" ),
|
||||
duplicate_xpm, symbolSelectedCondition );
|
||||
ctxMenu.AddItem( ID_LIBEDIT_REMOVE_PART,
|
||||
_( "Delete" ), _( "Remove the selected symbol from the library" ),
|
||||
delete_xpm, symbolSelectedCondition );
|
||||
ctxMenu.AddItem( ACTIONS::revert, symbolSelectedCondition );
|
||||
|
||||
ctxMenu.AddSeparator( SELECTION_CONDITIONS::ShowAlways );
|
||||
ctxMenu.AddItem( ID_LIBEDIT_CUT_PART, _( "Cut Symbol" ), "",
|
||||
cut_xpm, symbolSelectedCondition );
|
||||
ctxMenu.AddItem( ID_LIBEDIT_COPY_PART, _( "Copy Symbol" ), "",
|
||||
copy_xpm, symbolSelectedCondition );
|
||||
ctxMenu.AddItem( ID_LIBEDIT_PASTE_PART, _( "Paste Symbol" ), "",
|
||||
paste_xpm, SELECTION_CONDITIONS::ShowAlways );
|
||||
|
||||
ctxMenu.AddSeparator( symbolSelectedCondition );
|
||||
ctxMenu.AddItem( EE_ACTIONS::importSymbol, SELECTION_CONDITIONS::ShowAlways );
|
||||
ctxMenu.AddItem( ID_LIBEDIT_EXPORT_PART, _( "Export Symbol..." ), "",
|
||||
export_part_xpm, symbolSelectedCondition );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int LIB_CONTROL::AddLibrary( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
bool createNew = aEvent.IsAction( &ACTIONS::newLibrary );
|
||||
|
|
|
@ -44,6 +44,9 @@ public:
|
|||
|
||||
virtual ~LIB_CONTROL() { }
|
||||
|
||||
/// @copydoc TOOL_INTERACTIVE::Init()
|
||||
bool Init() override;
|
||||
|
||||
int AddLibrary( const TOOL_EVENT& aEvent );
|
||||
int AddSymbol( const TOOL_EVENT& aEvent );
|
||||
|
||||
|
|
|
@ -25,14 +25,9 @@
|
|||
#include "symbol_tree_pane.h"
|
||||
|
||||
#include <widgets/lib_tree.h>
|
||||
#include <eeschema_id.h>
|
||||
#include <lib_manager.h>
|
||||
#include <lib_edit_frame.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <menus_helpers.h>
|
||||
#include <tool/action_menu.h>
|
||||
#include <tool/actions.h>
|
||||
#include <tools/ee_actions.h>
|
||||
|
||||
SYMBOL_TREE_PANE::SYMBOL_TREE_PANE( LIB_EDIT_FRAME* aParent, LIB_MANAGER* aLibMgr )
|
||||
: wxPanel( aParent ),
|
||||
|
@ -50,46 +45,6 @@ SYMBOL_TREE_PANE::SYMBOL_TREE_PANE( LIB_EDIT_FRAME* aParent, LIB_MANAGER* aLibMg
|
|||
Layout();
|
||||
boxSizer->Fit( this );
|
||||
|
||||
// Setup right click-context menus
|
||||
std::unique_ptr<ACTION_MENU> menuLibrary = std::make_unique<ACTION_MENU>();
|
||||
|
||||
menuLibrary->Add( ACTIONS::newLibrary );
|
||||
menuLibrary->Add( ACTIONS::addLibrary );
|
||||
menuLibrary->Add( ACTIONS::save );
|
||||
menuLibrary->Add( ACTIONS::saveAs );
|
||||
menuLibrary->Add( ACTIONS::revert );
|
||||
|
||||
menuLibrary->AppendSeparator();
|
||||
menuLibrary->Add( EE_ACTIONS::newSymbol );
|
||||
menuLibrary->Add( EE_ACTIONS::importSymbol );
|
||||
menuLibrary->Add( _( "Paste Symbol" ), ID_LIBEDIT_PASTE_PART, paste_xpm );
|
||||
|
||||
std::unique_ptr<ACTION_MENU> menuPart = std::make_unique<ACTION_MENU>();
|
||||
menuPart->Add( _( "Edit Symbol" ), ID_LIBEDIT_EDIT_PART, edit_xpm );
|
||||
|
||||
menuPart->AppendSeparator();
|
||||
menuPart->Add( ACTIONS::save );
|
||||
menuPart->Add( ACTIONS::saveCopyAs );
|
||||
menuPart->Add( _( "Duplicate" ), ID_LIBEDIT_DUPLICATE_PART, duplicate_xpm );
|
||||
menuPart->Add( _( "Delete" ), ID_LIBEDIT_REMOVE_PART, delete_xpm );
|
||||
menuPart->Add( ACTIONS::revert );
|
||||
|
||||
menuPart->AppendSeparator();
|
||||
menuPart->Add( _( "Cut" ), ID_LIBEDIT_CUT_PART, cut_xpm );
|
||||
menuPart->Add( _( "Copy" ), ID_LIBEDIT_COPY_PART, copy_xpm );
|
||||
|
||||
menuPart->AppendSeparator();
|
||||
menuPart->Add( _( "Export Symbol..." ), ID_LIBEDIT_EXPORT_PART, export_part_xpm );
|
||||
|
||||
// Menu displayed when nothing is selected
|
||||
std::unique_ptr<ACTION_MENU> menuNoSelection = std::make_unique<ACTION_MENU>();
|
||||
menuLibrary->Add( ACTIONS::newLibrary );
|
||||
menuLibrary->Add( ACTIONS::addLibrary );
|
||||
|
||||
m_tree->SetMenu( LIB_TREE_NODE::LIBID, std::move( menuPart ) );
|
||||
m_tree->SetMenu( LIB_TREE_NODE::LIB, std::move( menuLibrary ) );
|
||||
m_tree->SetMenu( LIB_TREE_NODE::INVALID, std::move( menuNoSelection ) );
|
||||
|
||||
// Event handlers
|
||||
Bind( COMPONENT_SELECTED, &SYMBOL_TREE_PANE::onComponentSelected, this );
|
||||
}
|
||||
|
@ -110,8 +65,8 @@ void SYMBOL_TREE_PANE::Regenerate()
|
|||
|
||||
void SYMBOL_TREE_PANE::onComponentSelected( wxCommandEvent& aEvent )
|
||||
{
|
||||
wxCommandEvent evt( ID_LIBEDIT_EDIT_PART );
|
||||
m_libEditFrame->OnEditPart( evt );
|
||||
wxCommandEvent dummy;
|
||||
m_libEditFrame->OnEditPart( dummy );
|
||||
|
||||
// Make sure current-part highlighting doesn't get lost in seleciton highlighting
|
||||
m_tree->Unselect();
|
||||
|
|
|
@ -136,8 +136,7 @@ private:
|
|||
GERBVIEW_SELECTION_TOOL::GERBVIEW_SELECTION_TOOL() :
|
||||
TOOL_INTERACTIVE( "gerbview.InteractiveSelection" ),
|
||||
m_frame( NULL ), m_additive( false ), m_subtractive( false ),
|
||||
m_multiple( false ),
|
||||
m_menu( *this )
|
||||
m_multiple( false )
|
||||
{
|
||||
// these members are initialized to avoid warnings about non initialized vars
|
||||
m_preliminary = true;
|
||||
|
|
|
@ -75,11 +75,6 @@ public:
|
|||
*/
|
||||
SELECTION& GetSelection();
|
||||
|
||||
inline TOOL_MENU& GetToolMenu()
|
||||
{
|
||||
return m_menu;
|
||||
}
|
||||
|
||||
///> Select a single item under cursor event handler.
|
||||
int CursorSelection( const TOOL_EVENT& aEvent );
|
||||
|
||||
|
@ -233,9 +228,6 @@ private:
|
|||
|
||||
/// Determines if the selection is preliminary or final.
|
||||
bool m_preliminary;
|
||||
|
||||
/// Menu model displayed by the tool.
|
||||
TOOL_MENU m_menu;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#define __TOOL_INTERACTIVE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <tool/tool_menu.h>
|
||||
#include <tool/tool_event.h>
|
||||
#include <tool/tool_base.h>
|
||||
|
||||
|
@ -55,6 +55,8 @@ public:
|
|||
*/
|
||||
void Activate();
|
||||
|
||||
TOOL_MENU& GetToolMenu() { return m_menu; }
|
||||
|
||||
/**
|
||||
* Function SetContextMenu()
|
||||
*
|
||||
|
@ -103,15 +105,7 @@ public:
|
|||
void Yield( const T& returnValue );*/
|
||||
|
||||
protected:
|
||||
/* helper functions for constructing events for Wait() and Go() with less typing */
|
||||
const TOOL_EVENT evActivate( std::string aToolName = "" );
|
||||
const TOOL_EVENT evCommand( int aCommandId = -1 );
|
||||
const TOOL_EVENT evCommand( std::string aCommandStr = "" );
|
||||
const TOOL_EVENT evMotion();
|
||||
const TOOL_EVENT evClick( int aButton = BUT_ANY );
|
||||
const TOOL_EVENT evDrag( int aButton = BUT_ANY );
|
||||
const TOOL_EVENT evButtonUp( int aButton = BUT_ANY );
|
||||
const TOOL_EVENT evButtonDown(int aButton = BUT_ANY );
|
||||
TOOL_MENU m_menu;
|
||||
|
||||
private:
|
||||
/**
|
||||
|
|
|
@ -387,6 +387,11 @@ public:
|
|||
m_warpMouseAfterContextMenu = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function DispatchContextMenu()
|
||||
* Handles context menu related events.
|
||||
*/
|
||||
void DispatchContextMenu( const TOOL_EVENT& aEvent );
|
||||
|
||||
private:
|
||||
typedef std::pair<TOOL_EVENT_LIST, TOOL_STATE_FUNC> TRANSITION;
|
||||
|
@ -413,12 +418,6 @@ private:
|
|||
*/
|
||||
bool dispatchActivation( const TOOL_EVENT& aEvent );
|
||||
|
||||
/**
|
||||
* Function dispatchContextMenu()
|
||||
* Handles context menu related events.
|
||||
*/
|
||||
void dispatchContextMenu( const TOOL_EVENT& aEvent );
|
||||
|
||||
/**
|
||||
* Function invokeTool()
|
||||
* Invokes a tool by sending a proper event (in contrary to runTool, which makes the tool run
|
||||
|
|
|
@ -83,8 +83,7 @@ TOOL_ACTION PL_ACTIONS::addImage( "plEditor.InteractiveDrawing.addImage",
|
|||
PL_DRAWING_TOOLS::PL_DRAWING_TOOLS() :
|
||||
TOOL_INTERACTIVE( "plEditor.InteractiveDrawing" ),
|
||||
m_frame( nullptr ),
|
||||
m_selectionTool( nullptr ),
|
||||
m_menu( *this )
|
||||
m_selectionTool( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -50,8 +50,6 @@ public:
|
|||
/// @copydoc TOOL_INTERACTIVE::Reset()
|
||||
void Reset( RESET_REASON aReason ) override;
|
||||
|
||||
TOOL_MENU& GetToolMenu() { return m_menu; }
|
||||
|
||||
int DrawShape( const TOOL_EVENT& aEvent );
|
||||
int PlaceItem( const TOOL_EVENT& aEvent );
|
||||
|
||||
|
@ -62,9 +60,6 @@ private:
|
|||
private:
|
||||
PL_EDITOR_FRAME* m_frame;
|
||||
PL_SELECTION_TOOL* m_selectionTool;
|
||||
|
||||
/// Menu model displayed by the tool.
|
||||
TOOL_MENU m_menu;
|
||||
};
|
||||
|
||||
#endif /* PL_DRAWING_TOOLS_H */
|
||||
|
|
|
@ -59,8 +59,7 @@ TOOL_ACTION PL_ACTIONS::deleteItemCursor( "plEditor.InteractiveEdit.deleteTool",
|
|||
PL_EDIT_TOOL::PL_EDIT_TOOL() :
|
||||
TOOL_INTERACTIVE( "plEditor.InteractiveEdit" ),
|
||||
m_frame( nullptr ),
|
||||
m_selectionTool( nullptr ),
|
||||
m_menu( *this )
|
||||
m_selectionTool( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -80,9 +80,6 @@ private:
|
|||
PL_EDITOR_FRAME* m_frame;
|
||||
PL_SELECTION_TOOL* m_selectionTool;
|
||||
|
||||
/// Menu model displayed by the tool.
|
||||
TOOL_MENU m_menu;
|
||||
|
||||
///> Flag determining if anything is being dragged right now
|
||||
bool m_moveInProgress;
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ TOOL_ACTION PL_ACTIONS::pickerTool( "plEditor.Picker", AS_GLOBAL, 0, "", "", NUL
|
|||
PL_PICKER_TOOL::PL_PICKER_TOOL() :
|
||||
TOOL_INTERACTIVE( "plEditor.Picker" ),
|
||||
m_frame( nullptr ),
|
||||
m_menu( *this ),
|
||||
m_cursorCapture( false ),
|
||||
m_autoPanning( false )
|
||||
{
|
||||
|
|
|
@ -116,9 +116,6 @@ private:
|
|||
private:
|
||||
PL_EDITOR_FRAME* m_frame;
|
||||
|
||||
/// Menu model displayed by the tool.
|
||||
TOOL_MENU m_menu;
|
||||
|
||||
bool m_cursorCapture;
|
||||
bool m_autoPanning;
|
||||
|
||||
|
|
|
@ -83,8 +83,7 @@ PL_SELECTION_TOOL::PL_SELECTION_TOOL() :
|
|||
m_additive( false ),
|
||||
m_subtractive( false ),
|
||||
m_multiple( false ),
|
||||
m_skip_heuristics( false ),
|
||||
m_menu( *this )
|
||||
m_skip_heuristics( false )
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -74,8 +74,6 @@ public:
|
|||
*/
|
||||
SELECTION& GetSelection();
|
||||
|
||||
inline TOOL_MENU& GetToolMenu() { return m_menu; }
|
||||
|
||||
/**
|
||||
* Function RequestSelection()
|
||||
*
|
||||
|
@ -210,8 +208,6 @@ private:
|
|||
bool m_subtractive; // Items should be removed from selection
|
||||
bool m_multiple; // Multiple selection mode is active
|
||||
bool m_skip_heuristics; // Heuristics are not allowed when choosing item under cursor
|
||||
|
||||
TOOL_MENU m_menu;
|
||||
};
|
||||
|
||||
#endif //PL_SELECTION_TOOL_H
|
||||
|
|
|
@ -35,10 +35,8 @@
|
|||
#include <bitmaps.h>
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
#include <eda_dockart.h>
|
||||
|
||||
#include <class_board.h>
|
||||
#include <class_module.h>
|
||||
|
||||
#include <pcbnew.h>
|
||||
#include <pcbnew_id.h>
|
||||
#include <hotkeys.h>
|
||||
|
@ -47,17 +45,14 @@
|
|||
#include <wildcards_and_files_ext.h>
|
||||
#include <pcb_layer_widget.h>
|
||||
#include <invoke_pcb_dialog.h>
|
||||
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tool/common_tools.h>
|
||||
#include <tool/tool_dispatcher.h>
|
||||
#include <tool/zoom_tool.h>
|
||||
|
||||
#include <footprint_tree_pane.h>
|
||||
#include <widgets/lib_tree.h>
|
||||
#include <fp_lib_table.h>
|
||||
#include <footprint_info_impl.h>
|
||||
|
||||
#include <widgets/paged_dialog.h>
|
||||
#include <dialogs/panel_modedit_settings.h>
|
||||
#include <dialogs/panel_modedit_defaults.h>
|
||||
|
@ -191,12 +186,12 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent,
|
|||
|
||||
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
||||
|
||||
initLibraryTree();
|
||||
m_treePane = new FOOTPRINT_TREE_PANE( this );
|
||||
|
||||
// Create the manager and dispatcher & route draw panel events to the dispatcher
|
||||
setupTools();
|
||||
|
||||
initLibraryTree();
|
||||
m_treePane = new FOOTPRINT_TREE_PANE( this );
|
||||
|
||||
ReCreateMenuBar();
|
||||
ReCreateHToolbar();
|
||||
ReCreateVToolbar();
|
||||
|
@ -296,12 +291,17 @@ BOARD_ITEM_CONTAINER* FOOTPRINT_EDIT_FRAME::GetModel() const
|
|||
}
|
||||
|
||||
|
||||
LIB_ID FOOTPRINT_EDIT_FRAME::GetTreeFPID() const
|
||||
{
|
||||
return m_treePane->GetLibTree()->GetSelectedLibId();
|
||||
}
|
||||
|
||||
|
||||
LIB_ID FOOTPRINT_EDIT_FRAME::GetTargetFPID() const
|
||||
{
|
||||
LIB_ID id = m_treePane->GetLibTree()->GetSelectedLibId();
|
||||
wxString nickname = id.GetLibNickname();
|
||||
LIB_ID id = GetTreeFPID();
|
||||
|
||||
if( nickname.IsEmpty() )
|
||||
if( id.GetLibNickname().empty() )
|
||||
return GetLoadedFPID();
|
||||
|
||||
return id;
|
||||
|
|
|
@ -193,12 +193,16 @@ public:
|
|||
*/
|
||||
bool Clear_Pcb( bool aQuery );
|
||||
|
||||
/// Return the LIB_ID of the part selected in the footprint or the part being edited.
|
||||
LIB_ID GetTargetFPID() const;
|
||||
/// Return the LIB_ID of the part or library selected in the footprint tree.
|
||||
LIB_ID GetTreeFPID() const;
|
||||
|
||||
/// Return the LIB_ID of the part being edited.
|
||||
LIB_ID GetLoadedFPID() const;
|
||||
|
||||
/// Return the LIB_ID of the part selected in the footprint tree, or the loaded part if
|
||||
/// there is no selection in the tree.
|
||||
LIB_ID GetTargetFPID() const;
|
||||
|
||||
/**
|
||||
* Perform a geometric transform on the current footprint.
|
||||
*/
|
||||
|
|
|
@ -23,14 +23,10 @@
|
|||
|
||||
#include "footprint_tree_pane.h"
|
||||
#include "fp_tree_synchronizing_adapter.h"
|
||||
#include <tool/actions.h>
|
||||
#include <tool/action_menu.h>
|
||||
#include <widgets/lib_tree.h>
|
||||
#include <pcbnew_id.h>
|
||||
#include <footprint_edit_frame.h>
|
||||
#include <fp_lib_table.h>
|
||||
#include <menus_helpers.h>
|
||||
#include <tools/pcb_actions.h>
|
||||
|
||||
FOOTPRINT_TREE_PANE::FOOTPRINT_TREE_PANE( FOOTPRINT_EDIT_FRAME* aParent )
|
||||
: wxPanel( aParent ),
|
||||
|
@ -45,47 +41,7 @@ FOOTPRINT_TREE_PANE::FOOTPRINT_TREE_PANE( FOOTPRINT_EDIT_FRAME* aParent )
|
|||
SetSizer( boxSizer ); // should remove the previous sizer according to wxWidgets docs
|
||||
Layout();
|
||||
boxSizer->Fit( this );
|
||||
|
||||
// Setup right click-context menus
|
||||
std::unique_ptr<ACTION_MENU> menuLibrary = std::make_unique<ACTION_MENU>();
|
||||
menuLibrary->Add( ACTIONS::newLibrary );
|
||||
menuLibrary->Add( ACTIONS::addLibrary );
|
||||
menuLibrary->Add( ACTIONS::save );
|
||||
menuLibrary->Add( ACTIONS::saveAs );
|
||||
|
||||
menuLibrary->AppendSeparator();
|
||||
menuLibrary->Add( PCB_ACTIONS::newFootprint );
|
||||
#ifdef KICAD_SCRIPTING
|
||||
menuLibrary->Add( PCB_ACTIONS::createFootprint );
|
||||
#endif
|
||||
menuLibrary->Add( _( "Import Footprint..." ), ID_MODEDIT_IMPORT_PART, import_module_xpm );
|
||||
menuLibrary->Add( _( "Paste Footprint" ), ID_MODEDIT_PASTE_PART, paste_xpm );
|
||||
|
||||
std::unique_ptr<ACTION_MENU> menuPart = std::make_unique<ACTION_MENU>();
|
||||
menuPart->Add( _( "Edit Footprint" ), ID_MODEDIT_EDIT_MODULE, edit_xpm );
|
||||
|
||||
menuPart->AppendSeparator();
|
||||
menuPart->Add( ACTIONS::save );
|
||||
menuPart->Add( ACTIONS::saveCopyAs );
|
||||
menuPart->Add( PCB_ACTIONS::deleteFootprint );
|
||||
menuPart->Add( ACTIONS::revert );
|
||||
|
||||
menuPart->AppendSeparator();
|
||||
menuPart->Add( _( "Cut" ), ID_MODEDIT_CUT_PART, cut_xpm );
|
||||
menuPart->Add( _( "Copy" ), ID_MODEDIT_COPY_PART, copy_xpm );
|
||||
|
||||
menuPart->AppendSeparator();
|
||||
menuPart->Add( _( "Export Footprint..." ), ID_MODEDIT_EXPORT_PART, export_module_xpm );
|
||||
|
||||
// Menu displayed when nothing is selected
|
||||
std::unique_ptr<ACTION_MENU> menuNoSelection = std::make_unique<ACTION_MENU>();
|
||||
menuNoSelection->Add( ACTIONS::newLibrary );
|
||||
menuNoSelection->Add( ACTIONS::addLibrary );
|
||||
|
||||
m_tree->SetMenu( LIB_TREE_NODE::LIBID, std::move( menuPart ) );
|
||||
m_tree->SetMenu( LIB_TREE_NODE::LIB, std::move( menuLibrary ) );
|
||||
m_tree->SetMenu( LIB_TREE_NODE::INVALID, std::move( menuNoSelection ) );
|
||||
|
||||
|
||||
// Event handlers
|
||||
Bind( COMPONENT_SELECTED, &FOOTPRINT_TREE_PANE::onComponentSelected, this );
|
||||
m_tree->Bind( wxEVT_UPDATE_UI, &FOOTPRINT_TREE_PANE::onUpdateUI, this );
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include <footprint_info_impl.h>
|
||||
#include <class_board.h>
|
||||
#include <class_module.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/footprint_editor_tools.h>
|
||||
|
||||
|
||||
LIB_TREE_MODEL_ADAPTER::PTR FP_TREE_SYNCHRONIZING_ADAPTER::Create( FOOTPRINT_EDIT_FRAME* aFrame,
|
||||
|
@ -45,6 +47,12 @@ FP_TREE_SYNCHRONIZING_ADAPTER::FP_TREE_SYNCHRONIZING_ADAPTER( FOOTPRINT_EDIT_FRA
|
|||
}
|
||||
|
||||
|
||||
TOOL_INTERACTIVE* FP_TREE_SYNCHRONIZING_ADAPTER::GetContextMenuTool()
|
||||
{
|
||||
return m_frame->GetToolManager()->GetTool<MODULE_EDITOR_TOOLS>();
|
||||
}
|
||||
|
||||
|
||||
bool FP_TREE_SYNCHRONIZING_ADAPTER::IsContainer( const wxDataViewItem& aItem ) const
|
||||
{
|
||||
const LIB_TREE_NODE* node = ToNode( aItem );
|
||||
|
|
|
@ -41,6 +41,8 @@ public:
|
|||
|
||||
int GetLibrariesCount() const override;
|
||||
|
||||
TOOL_INTERACTIVE* GetContextMenuTool() override;
|
||||
|
||||
protected:
|
||||
FP_TREE_SYNCHRONIZING_ADAPTER( FOOTPRINT_EDIT_FRAME* aFrame, FP_LIB_TABLE* aLibs );
|
||||
|
||||
|
@ -53,6 +55,7 @@ protected:
|
|||
bool GetAttr( wxDataViewItem const& aItem, unsigned int aCol,
|
||||
wxDataViewItemAttr& aAttr ) const override;
|
||||
|
||||
protected:
|
||||
FOOTPRINT_EDIT_FRAME* m_frame;
|
||||
std::set<wxString> m_libMap; // Set to indicate libraries currently in tree
|
||||
};
|
||||
|
|
|
@ -58,12 +58,6 @@ public:
|
|||
/// @copydoc TOOL_INTERACTIVE::Reset()
|
||||
void Reset( RESET_REASON aReason ) override;
|
||||
|
||||
///> Get the DRAWING_TOOL top-level context menu
|
||||
inline TOOL_MENU& GetToolMenu()
|
||||
{
|
||||
return m_menu;
|
||||
}
|
||||
|
||||
///> The possible drawing modes of DRAWING_TOOL
|
||||
enum class MODE
|
||||
{
|
||||
|
|
|
@ -207,12 +207,7 @@ bool EDIT_TOOL::Init()
|
|||
{
|
||||
// Find the selection tool, so they can cooperate
|
||||
m_selectionTool = static_cast<SELECTION_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) );
|
||||
|
||||
if( !m_selectionTool )
|
||||
{
|
||||
DisplayError( NULL, _( "pcbnew.InteractiveSelection tool is not available" ) );
|
||||
return false;
|
||||
}
|
||||
wxASSERT_MSG( m_selectionTool, "pcbnew.InteractiveSelection tool is not available" );
|
||||
|
||||
auto editingModuleCondition = [ this ] ( const SELECTION& aSelection ) {
|
||||
return m_editModules;
|
||||
|
|
|
@ -115,7 +115,8 @@ TOOL_ACTION PCB_ACTIONS::defaultPadProperties( "pcbnew.ModuleEditor.defaultPadPr
|
|||
|
||||
|
||||
MODULE_EDITOR_TOOLS::MODULE_EDITOR_TOOLS() :
|
||||
PCB_TOOL_BASE( "pcbnew.ModuleEditor" )
|
||||
PCB_TOOL_BASE( "pcbnew.ModuleEditor" ),
|
||||
m_frame( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -127,6 +128,61 @@ MODULE_EDITOR_TOOLS::~MODULE_EDITOR_TOOLS()
|
|||
|
||||
void MODULE_EDITOR_TOOLS::Reset( RESET_REASON aReason )
|
||||
{
|
||||
m_frame = getEditFrame<FOOTPRINT_EDIT_FRAME>();
|
||||
}
|
||||
|
||||
|
||||
bool MODULE_EDITOR_TOOLS::Init()
|
||||
{
|
||||
// Build a context menu for the footprint tree
|
||||
//
|
||||
CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
|
||||
|
||||
auto libSelectedCondition = [ this ] ( const SELECTION& aSel ) {
|
||||
LIB_ID sel = m_frame->GetTreeFPID();
|
||||
return !sel.GetLibNickname().empty() && sel.GetLibItemName().empty();
|
||||
};
|
||||
auto fpSelectedCondition = [ this ] ( const SELECTION& aSel ) {
|
||||
LIB_ID sel = m_frame->GetTreeFPID();
|
||||
return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty();
|
||||
};
|
||||
|
||||
ctxMenu.AddItem( ACTIONS::newLibrary, SELECTION_CONDITIONS::ShowAlways );
|
||||
ctxMenu.AddItem( ACTIONS::addLibrary, SELECTION_CONDITIONS::ShowAlways );
|
||||
ctxMenu.AddItem( ACTIONS::save, libSelectedCondition );
|
||||
ctxMenu.AddItem( ACTIONS::saveAs, libSelectedCondition );
|
||||
ctxMenu.AddItem( ACTIONS::revert, libSelectedCondition );
|
||||
|
||||
ctxMenu.AddSeparator( SELECTION_CONDITIONS::ShowAlways );
|
||||
ctxMenu.AddItem( PCB_ACTIONS::newFootprint, SELECTION_CONDITIONS::ShowAlways );
|
||||
#ifdef KICAD_SCRIPTING
|
||||
ctxMenu.AddItem( PCB_ACTIONS::createFootprint, SELECTION_CONDITIONS::ShowAlways );
|
||||
#endif
|
||||
ctxMenu.AddItem( ID_MODEDIT_EDIT_MODULE,
|
||||
_( "Edit Footprint" ), _( "Show selected footprint on editor canvas" ),
|
||||
edit_xpm, fpSelectedCondition );
|
||||
|
||||
ctxMenu.AddSeparator( SELECTION_CONDITIONS::ShowAlways );
|
||||
ctxMenu.AddItem( ACTIONS::save, fpSelectedCondition );
|
||||
ctxMenu.AddItem( ACTIONS::saveCopyAs, fpSelectedCondition );
|
||||
ctxMenu.AddItem( PCB_ACTIONS::deleteFootprint, fpSelectedCondition );
|
||||
ctxMenu.AddItem( ACTIONS::revert, fpSelectedCondition );
|
||||
|
||||
ctxMenu.AddSeparator( SELECTION_CONDITIONS::ShowAlways );
|
||||
ctxMenu.AddItem( ID_MODEDIT_CUT_PART, _( "Cut Footprint" ), "",
|
||||
cut_xpm, fpSelectedCondition );
|
||||
ctxMenu.AddItem( ID_MODEDIT_COPY_PART, _( "Copy Footprint" ), "",
|
||||
copy_xpm, fpSelectedCondition );
|
||||
ctxMenu.AddItem( ID_MODEDIT_PASTE_PART, _( "Paste Footprint" ), "",
|
||||
paste_xpm, SELECTION_CONDITIONS::ShowAlways );
|
||||
|
||||
ctxMenu.AddSeparator( fpSelectedCondition );
|
||||
ctxMenu.AddItem( ID_MODEDIT_IMPORT_PART, _( "Import Footprint..." ), "",
|
||||
import_module_xpm, SELECTION_CONDITIONS::ShowAlways );
|
||||
ctxMenu.AddItem( ID_MODEDIT_EXPORT_PART, _( "Export Footprint..." ), "",
|
||||
export_module_xpm, fpSelectedCondition );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -187,12 +243,12 @@ int MODULE_EDITOR_TOOLS::Delete( const TOOL_EVENT& aEvent )
|
|||
|
||||
int MODULE_EDITOR_TOOLS::Properties( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
MODULE* footprint = frame()->GetBoard()->GetFirstModule();
|
||||
MODULE* footprint = m_frame->GetBoard()->GetFirstModule();
|
||||
|
||||
if( footprint )
|
||||
{
|
||||
getEditFrame<FOOTPRINT_EDIT_FRAME>()->OnEditItemRequest( footprint );
|
||||
frame()->GetGalCanvas()->Refresh();
|
||||
m_frame->GetGalCanvas()->Refresh();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -235,13 +291,13 @@ int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
|
|||
|
||||
PAD_PLACER placer;
|
||||
|
||||
frame()->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_PENCIL, _( "Add pads" ) );
|
||||
m_frame->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_PENCIL, _( "Add pads" ) );
|
||||
|
||||
wxASSERT( board()->GetFirstModule() );
|
||||
|
||||
doInteractiveItemPlacement( &placer, _( "Place pad" ), IPO_REPEAT | IPO_SINGLE_CLICK | IPO_ROTATE | IPO_FLIP );
|
||||
|
||||
frame()->SetNoToolSelected();
|
||||
m_frame->SetNoToolSelected();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -252,7 +308,7 @@ int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
|
|||
if( !board()->GetFirstModule() || !board()->GetFirstModule()->Pads().empty() )
|
||||
return 0;
|
||||
|
||||
DIALOG_ENUM_PADS settingsDlg( frame() );
|
||||
DIALOG_ENUM_PADS settingsDlg( m_frame );
|
||||
|
||||
if( settingsDlg.ShowModal() != wxID_OK )
|
||||
return 0;
|
||||
|
@ -262,7 +318,7 @@ int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
|
|||
GENERAL_COLLECTOR collector;
|
||||
const KICAD_T types[] = { PCB_PAD_T, EOT };
|
||||
|
||||
GENERAL_COLLECTORS_GUIDE guide = frame()->GetCollectorsGuide();
|
||||
GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide();
|
||||
guide.SetIgnoreMTextsMarkedNoShow( true );
|
||||
guide.SetIgnoreMTextsOnBack( true );
|
||||
guide.SetIgnoreMTextsOnFront( true );
|
||||
|
@ -273,7 +329,7 @@ int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
|
|||
wxString padPrefix = settingsDlg.GetPrefix();
|
||||
std::deque<int> storedPadNumbers;
|
||||
|
||||
frame()->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_HAND,
|
||||
m_frame->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_HAND,
|
||||
_( "Click on successive pads to renumber them" ) );
|
||||
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
|
@ -282,11 +338,11 @@ int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
|
|||
KIGFX::VIEW* view = m_toolMgr->GetView();
|
||||
VECTOR2I oldCursorPos; // store the previous mouse cursor position, during mouse drag
|
||||
std::list<D_PAD*> selectedPads;
|
||||
BOARD_COMMIT commit( frame() );
|
||||
BOARD_COMMIT commit( m_frame );
|
||||
std::map<wxString, std::pair<int, wxString>> oldNames;
|
||||
bool isFirstPoint = true; // used to be sure oldCursorPos will be initialized at least once.
|
||||
|
||||
STATUS_TEXT_POPUP statusPopup( frame() );
|
||||
STATUS_TEXT_POPUP statusPopup( m_frame );
|
||||
statusPopup.SetText( wxString::Format(
|
||||
_( "Click on pad %s%d\nPress Escape to cancel or double-click to commit" ),
|
||||
padPrefix.c_str(), seqPadNum ) );
|
||||
|
@ -432,8 +488,8 @@ int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
statusPopup.Hide();
|
||||
frame()->SetNoToolSelected();
|
||||
frame()->GetGalCanvas()->SetCursor( wxCURSOR_ARROW );
|
||||
m_frame->SetNoToolSelected();
|
||||
m_frame->GetGalCanvas()->SetCursor( wxCURSOR_ARROW );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -442,7 +498,7 @@ int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
|
|||
int MODULE_EDITOR_TOOLS::ExplodePadToShapes( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
|
||||
BOARD_COMMIT commit( frame() );
|
||||
BOARD_COMMIT commit( m_frame );
|
||||
|
||||
if( selection.Size() != 1 )
|
||||
return 0;
|
||||
|
@ -499,7 +555,7 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent )
|
|||
|
||||
std::vector<PAD_CS_PRIMITIVE> shapes;
|
||||
|
||||
BOARD_COMMIT commit( frame() );
|
||||
BOARD_COMMIT commit( m_frame );
|
||||
|
||||
for( auto item : selection )
|
||||
{
|
||||
|
@ -549,18 +605,17 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( multipleRefPadsFound )
|
||||
{
|
||||
DisplayErrorMessage( frame(),
|
||||
_( "Cannot convert items to a custom-shaped pad:\n"
|
||||
"selection contains more than one reference pad." ) );
|
||||
DisplayErrorMessage( m_frame, _( "Cannot convert items to a custom-shaped pad:\n"
|
||||
"selection contains more than one reference pad." ) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( illegalItemsFound )
|
||||
{
|
||||
DisplayErrorMessage( frame(),
|
||||
_( "Cannot convert items to a custom-shaped pad:\n"
|
||||
"selection contains unsupported items.\n"
|
||||
"Only graphical lines, circles, arcs and polygons are allowed." ) );
|
||||
DisplayErrorMessage( m_frame, _( "Cannot convert items to a custom-shaped pad:\n"
|
||||
"selection contains unsupported items.\n"
|
||||
"Only graphical lines, circles, arcs and polygons "
|
||||
"are allowed." ) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -603,10 +658,10 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( !anchor )
|
||||
{
|
||||
DisplayErrorMessage( frame(),
|
||||
_( "Cannot convert items to a custom-shaped pad:\n"
|
||||
"unable to determine the anchor point position.\n"
|
||||
"Consider adding a small anchor pad to the selection and try again.") );
|
||||
DisplayErrorMessage( m_frame, _( "Cannot convert items to a custom-shaped pad:\n"
|
||||
"unable to determine the anchor point position.\n"
|
||||
"Consider adding a small anchor pad to the selection "
|
||||
"and try again.") );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -626,9 +681,8 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( !result )
|
||||
{
|
||||
DisplayErrorMessage( frame(),
|
||||
_( "Cannot convert items to a custom-shaped pad:\n"
|
||||
"selected items do not form a single solid shape.") );
|
||||
DisplayErrorMessage( m_frame, _( "Cannot convert items to a custom-shaped pad:\n"
|
||||
"selected items do not form a single solid shape.") );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,13 +27,9 @@
|
|||
|
||||
#include <tools/pcb_tool_base.h>
|
||||
|
||||
namespace KIGFX
|
||||
{
|
||||
class VIEW;
|
||||
class VIEW_CONTROLS;
|
||||
}
|
||||
class BOARD;
|
||||
class PCB_EDIT_FRAME;
|
||||
|
||||
class FOOTPRINT_EDIT_FRAME;
|
||||
|
||||
|
||||
/**
|
||||
* Class MODULE_EDITOR_TOOLS
|
||||
|
@ -44,11 +40,14 @@ class MODULE_EDITOR_TOOLS : public PCB_TOOL_BASE
|
|||
{
|
||||
public:
|
||||
MODULE_EDITOR_TOOLS();
|
||||
~MODULE_EDITOR_TOOLS();
|
||||
~MODULE_EDITOR_TOOLS() override;
|
||||
|
||||
/// @copydoc TOOL_INTERACTIVE::Reset()
|
||||
void Reset( RESET_REASON aReason ) override;
|
||||
|
||||
/// @copydoc TOOL_INTERACTIVE::Init()
|
||||
bool Init() override;
|
||||
|
||||
int NewFootprint( const TOOL_EVENT& aEvent );
|
||||
int CreateFootprint( const TOOL_EVENT& aEvent );
|
||||
|
||||
|
@ -101,6 +100,8 @@ private:
|
|||
///> Sets up handlers for various events.
|
||||
void setTransitions() override;
|
||||
|
||||
private:
|
||||
FOOTPRINT_EDIT_FRAME* m_frame;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -101,7 +101,6 @@ bool GLOBAL_EDIT_TOOL::Init()
|
|||
{
|
||||
// Find the selection tool, so they can cooperate
|
||||
m_selectionTool = static_cast<SELECTION_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) );
|
||||
|
||||
wxASSERT_MSG( m_selectionTool, "pcbnew.InteractiveSelection tool is not available" );
|
||||
|
||||
return true;
|
||||
|
|
|
@ -329,8 +329,7 @@ public:
|
|||
|
||||
PCB_EDITOR_CONTROL::PCB_EDITOR_CONTROL() :
|
||||
PCB_TOOL_BASE( "pcbnew.EditorControl" ),
|
||||
m_frame( nullptr ),
|
||||
m_menu( *this )
|
||||
m_frame( nullptr )
|
||||
{
|
||||
m_placeOrigin.reset( new KIGFX::ORIGIN_VIEWITEM( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
|
||||
KIGFX::ORIGIN_VIEWITEM::CIRCLE_CROSS ) );
|
||||
|
|
|
@ -159,9 +159,6 @@ private:
|
|||
///> Pointer to the currently used edit frame.
|
||||
PCB_EDIT_FRAME* m_frame;
|
||||
|
||||
/// Menu model displayed by the tool.
|
||||
TOOL_MENU m_menu;
|
||||
|
||||
std::unique_ptr<KIGFX::ORIGIN_VIEWITEM> m_placeOrigin; ///> Place & drill origin marker
|
||||
|
||||
bool m_probingSchToPcb; ///> Recursion guard when cross-probing to EESchema
|
||||
|
|
|
@ -21,24 +21,20 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
|
||||
#include "pcb_tool_base.h"
|
||||
|
||||
#include <view/view_controls.h>
|
||||
#include <view/view.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <board_commit.h>
|
||||
|
||||
#include <class_module.h>
|
||||
#include <pcb_draw_panel_gal.h>
|
||||
|
||||
#include "selection_tool.h"
|
||||
#include "pcb_actions.h"
|
||||
#include "tool_event_utils.h"
|
||||
|
||||
void PCB_TOOL_BASE::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE* aPlacer,
|
||||
const wxString& aCommitMessage,
|
||||
int aOptions )
|
||||
const wxString& aCommitMessage, int aOptions )
|
||||
{
|
||||
using namespace std::placeholders;
|
||||
std::unique_ptr<BOARD_ITEM> newItem;
|
||||
|
@ -211,6 +207,7 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE* aPlacer
|
|||
view()->Remove( &preview );
|
||||
}
|
||||
|
||||
|
||||
bool PCB_TOOL_BASE::Init()
|
||||
{
|
||||
// A basic context manu. Many (but not all) tools will choose to override this.
|
||||
|
@ -230,14 +227,14 @@ bool PCB_TOOL_BASE::Init()
|
|||
|
||||
void PCB_TOOL_BASE::Reset( RESET_REASON aReason )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void PCB_TOOL_BASE::setTransitions()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
PCB_DISPLAY_OPTIONS* PCB_TOOL_BASE::displayOptions() const
|
||||
{
|
||||
return static_cast<PCB_DISPLAY_OPTIONS*>( frame()->GetDisplayOptions() );
|
||||
|
@ -248,6 +245,7 @@ PCB_DRAW_PANEL_GAL* PCB_TOOL_BASE::canvas() const
|
|||
return static_cast<PCB_DRAW_PANEL_GAL*>( frame()->GetGalCanvas() );
|
||||
}
|
||||
|
||||
|
||||
const SELECTION& PCB_TOOL_BASE::selection() const
|
||||
{
|
||||
auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
||||
|
@ -255,6 +253,7 @@ const SELECTION& PCB_TOOL_BASE::selection() const
|
|||
return selection;
|
||||
}
|
||||
|
||||
|
||||
SELECTION& PCB_TOOL_BASE::selection()
|
||||
{
|
||||
auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
||||
|
@ -268,6 +267,7 @@ void INTERACTIVE_PLACER_BASE::SnapItem( BOARD_ITEM *aItem )
|
|||
// Base implementation performs no snapping
|
||||
}
|
||||
|
||||
|
||||
bool INTERACTIVE_PLACER_BASE::PlaceItem( BOARD_ITEM *aItem, BOARD_COMMIT& aCommit )
|
||||
{
|
||||
aCommit.Add( aItem );
|
||||
|
|
|
@ -70,8 +70,8 @@ public:
|
|||
* Creates a tool with given id & name. The name must be unique. */
|
||||
PCB_TOOL_BASE( TOOL_ID aId, const std::string& aName ) :
|
||||
TOOL_INTERACTIVE ( aId, aName ),
|
||||
m_menu( *this ),
|
||||
m_editModules( false ) {};
|
||||
m_editModules( false )
|
||||
{};
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -79,8 +79,8 @@ public:
|
|||
* Creates a tool with given name. The name must be unique. */
|
||||
PCB_TOOL_BASE( const std::string& aName ) :
|
||||
TOOL_INTERACTIVE ( aName ),
|
||||
m_menu( *this ),
|
||||
m_editModules( false ) {};
|
||||
m_editModules( false )
|
||||
{};
|
||||
|
||||
virtual ~PCB_TOOL_BASE() {};
|
||||
|
||||
|
@ -147,9 +147,6 @@ protected:
|
|||
const SELECTION& selection() const;
|
||||
SELECTION& selection();
|
||||
|
||||
/// Menu model displayed by the tool.
|
||||
TOOL_MENU m_menu;
|
||||
|
||||
bool m_editModules;
|
||||
};
|
||||
|
||||
|
|
|
@ -194,7 +194,6 @@ SELECTION_TOOL::SELECTION_TOOL() :
|
|||
m_multiple( false ),
|
||||
m_skip_heuristics( false ),
|
||||
m_locked( true ),
|
||||
m_menu( *this ),
|
||||
m_priv( std::make_unique<PRIV>() )
|
||||
{
|
||||
}
|
||||
|
|
|
@ -96,13 +96,7 @@ public:
|
|||
* @param aFiltered is an optional vector, that is filled with items removed by the filter
|
||||
*/
|
||||
SELECTION& RequestSelection( CLIENT_SELECTION_FILTER aClientFilter,
|
||||
std::vector<BOARD_ITEM*>* aFiltered = NULL, bool aConfirmLockedItems = false );
|
||||
|
||||
|
||||
inline TOOL_MENU& GetToolMenu()
|
||||
{
|
||||
return m_menu;
|
||||
}
|
||||
std::vector<BOARD_ITEM*>* aFiltered = nullptr, bool aConfirmLockedItems = false );
|
||||
|
||||
///> Checks if the user has agreed to modify locked items for the given selection.
|
||||
SELECTION_LOCK_FLAGS CheckLock();
|
||||
|
@ -354,8 +348,6 @@ private:
|
|||
bool m_skip_heuristics; // Heuristics are not allowed when choosing item under cursor
|
||||
bool m_locked; // Other tools are not allowed to modify locked items
|
||||
|
||||
TOOL_MENU m_menu;
|
||||
|
||||
/// Private state (opaque pointer/compilation firewall)
|
||||
class PRIV;
|
||||
std::unique_ptr<PRIV> m_priv;
|
||||
|
|
Loading…
Reference in New Issue