kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #40865
[Patch] cvpcb Usability Improvements
Attached is a patchset that includes some upgrades to the usability of
cvpcb, namely the following:
* Include a line below the footprint description giving the URI of the
source library. This allows people to see where the library is from. It is
located in a 3rd line below the footprint description, since I figured this
placement is the least obtrusive. It is also only displayed for the
selection from the footprint list (not the component footprint) since the
description field is not displayed for the component. (requested in
https://bugs.launchpad.net/kicad/+bug/1782805)
* Implement the ability for the escape key to close the window, since it
has a cancel button on it this seems like a useful feature. This will
prompt the user to save the changes if there are any, and will only operate
when the assignment window has focus, so if escape is pressed in the
footprint viewer window it will not close the main window. (requested in
https://bugs.launchpad.net/kicad/+bug/1830483)
* Implement the ability to delete individual footprint associations using
the delete key or a right-click menu option. (requested in
https://bugs.launchpad.net/kicad/+bug/1818883)
* Implement a cut/copy/paste system for the footprint associations that
operates on a 1->1 or 1->many arrangement. When more than 1 component is
selected for the copy/cut command, only the 1st selected one is used. It
can paste this to any number of selected components. This is also available
through the right-click menu. (requested in
https://bugs.launchpad.net/kicad/+bug/1794883).
These changes work for both master and 5.1, and I think would be useful to
include in 5.1.3 (one of those reports requesting the features is actually
already targeted to 5.1.3).
-Ian
From 9426d1c1c0037224a4e0f26fc142e68ffae31ed2 Mon Sep 17 00:00:00 2001
From: Ian McInerney <Ian.S.McInerney@xxxxxxxx>
Date: Tue, 28 May 2019 00:21:22 +0100
Subject: [PATCH 1/3] cvpcb: Added library location to status bar
Fixes: lp:1782805
* https://bugs.launchpad.net/kicad/+bug/1782805
---
cvpcb/cvpcb_mainframe.cpp | 32 ++++++++++++++++++++++++++++----
cvpcb/cvpcb_mainframe.h | 1 +
2 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp
index da1a5b0a4..0fe9da09d 100644
--- a/cvpcb/cvpcb_mainframe.cpp
+++ b/cvpcb/cvpcb_mainframe.cpp
@@ -163,7 +163,7 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
auto bottomPanel = new wxPanel( this );
auto panelSizer = new wxBoxSizer( wxVERTICAL );
- wxFlexGridSizer* fgSizerStatus = new wxFlexGridSizer( 2, 1, 0, 0 );
+ wxFlexGridSizer* fgSizerStatus = new wxFlexGridSizer( 3, 1, 0, 0 );
fgSizerStatus->SetFlexibleDirection( wxBOTH );
fgSizerStatus->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
@@ -171,7 +171,10 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
fgSizerStatus->Add( m_statusLine1, 0, 0, 5 );
m_statusLine2 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
- fgSizerStatus->Add( m_statusLine2, 0, wxBOTTOM, 3 );
+ fgSizerStatus->Add( m_statusLine2, 0, 0, 5 );
+
+ m_statusLine3 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
+ fgSizerStatus->Add( m_statusLine3, 0, wxBOTTOM, 3 );
panelSizer->Add( fgSizerStatus, 1, wxEXPAND|wxLEFT, 2 );
@@ -182,6 +185,7 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
statusFont.SetSymbolicSize( wxFONTSIZE_SMALL );
m_statusLine1->SetFont( statusFont );
m_statusLine2->SetFont( statusFont );
+ m_statusLine3->SetFont( statusFont );
// Add buttons:
auto buttonsSizer = new wxBoxSizer( wxHORIZONTAL );
@@ -690,6 +694,24 @@ void CVPCB_MAINFRAME::DisplayStatus()
}
SetStatusText( msg, 1 );
+
+
+ msg.Empty();
+
+ if( module ) // can be NULL if no netlist loaded
+ {
+ FP_LIB_TABLE* fptbl = Prj().PcbFootprintLibs( Kiway() );
+
+ wxString modLib = module->GetLibNickname();
+
+ if( fptbl->HasLibrary( modLib ) )
+ {
+ msg = wxString::Format( _( "Library location: %s" ),
+ fptbl->GetFullURI( modLib ) );
+ }
+ }
+
+ SetStatusText( msg, 2 );
}
@@ -939,9 +961,11 @@ wxString CVPCB_MAINFRAME::GetSelectedFootprint()
void CVPCB_MAINFRAME::SetStatusText( const wxString& aText, int aNumber )
{
- wxASSERT( aNumber < 2 );
+ wxASSERT( aNumber < 3 );
- if( aNumber == 1 )
+ if( aNumber == 2 )
+ m_statusLine3->SetLabel( aText );
+ else if( aNumber == 1 )
m_statusLine2->SetLabel( aText );
else
m_statusLine1->SetLabel( aText );
diff --git a/cvpcb/cvpcb_mainframe.h b/cvpcb/cvpcb_mainframe.h
index 8e2bc3e52..da17d9e39 100644
--- a/cvpcb/cvpcb_mainframe.h
+++ b/cvpcb/cvpcb_mainframe.h
@@ -68,6 +68,7 @@ class CVPCB_MAINFRAME : public KIWAY_PLAYER
wxTextCtrl* m_tcFilterString;
wxStaticText* m_statusLine1;
wxStaticText* m_statusLine2;
+ wxStaticText* m_statusLine3;
wxButton* m_saveAndContinue;
public:
--
2.17.2
From 19b8c310c16d8a53a125969fe765d74219cae8fd Mon Sep 17 00:00:00 2001
From: Ian McInerney <Ian.S.McInerney@xxxxxxxx>
Date: Wed, 29 May 2019 18:46:28 +0100
Subject: [PATCH 2/3] cvpcb: Allow the escape key to close the window
Fixes: lp:1830483
* https://bugs.launchpad.net/kicad/+bug/1830483
---
cvpcb/cvpcb_id.h | 1 +
cvpcb/cvpcb_mainframe.cpp | 16 ++++++++++++++++
cvpcb/cvpcb_mainframe.h | 1 +
3 files changed, 18 insertions(+)
diff --git a/cvpcb/cvpcb_id.h b/cvpcb/cvpcb_id.h
index b1c8bb6bb..c46e9b15d 100644
--- a/cvpcb/cvpcb_id.h
+++ b/cvpcb/cvpcb_id.h
@@ -56,5 +56,6 @@ enum id_cvpcb_frm
ID_CVPCB_EQUFILES_LIST_EDIT,
ID_CVPCB_LIB_TABLE_EDIT,
ID_CVPCB_FILTER_TEXT_EDIT,
+ ID_CVPCB_ESCAPE_KEY,
ID_TB_MEASUREMENT_TOOL
};
diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp
index 0fe9da09d..a066a1612 100644
--- a/cvpcb/cvpcb_mainframe.cpp
+++ b/cvpcb/cvpcb_mainframe.cpp
@@ -93,6 +93,9 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, KIWAY_PLAYER )
EVT_CLOSE( CVPCB_MAINFRAME::OnCloseWindow )
EVT_SIZE( CVPCB_MAINFRAME::OnSize )
+ // Handle the escape key
+ EVT_TOOL( ID_CVPCB_ESCAPE_KEY, CVPCB_MAINFRAME::OnEscapeKey )
+
// UI event handlers
EVT_UPDATE_UI( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, CVPCB_MAINFRAME::OnFilterFPbyKeywords)
EVT_UPDATE_UI( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST, CVPCB_MAINFRAME::OnFilterFPbyPinCount )
@@ -218,6 +221,13 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_saveAndContinue->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CVPCB_MAINFRAME::OnSaveAndContinue ), NULL, this );
m_footprintListBox->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( CVPCB_MAINFRAME::OnFootprintRightClick ), NULL, this );
m_compListBox->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( CVPCB_MAINFRAME::OnComponentRightClick ), NULL, this );
+
+ // Add an accelerator to make escape close the window
+ wxAcceleratorEntry entries[1];
+ entries[0].Set( wxACCEL_NORMAL, WXK_ESCAPE, ID_CVPCB_ESCAPE_KEY );
+ wxAcceleratorTable accel( 1, entries );
+ SetAcceleratorTable( accel );
+
}
@@ -369,6 +379,12 @@ void CVPCB_MAINFRAME::ToPreviousNA( wxCommandEvent& event )
}
+void CVPCB_MAINFRAME::OnEscapeKey( wxCommandEvent &aEvent )
+{
+ Close( false );
+}
+
+
void CVPCB_MAINFRAME::OnOK( wxCommandEvent& aEvent )
{
SaveFootprintAssociation( false );
diff --git a/cvpcb/cvpcb_mainframe.h b/cvpcb/cvpcb_mainframe.h
index da17d9e39..cbdd4e5c9 100644
--- a/cvpcb/cvpcb_mainframe.h
+++ b/cvpcb/cvpcb_mainframe.h
@@ -122,6 +122,7 @@ public:
void OnCloseWindow( wxCloseEvent& Event );
void OnSize( wxSizeEvent& SizeEvent );
void OnKeyDown( wxKeyEvent& aEvent );
+ void OnEscapeKey( wxCommandEvent& aEvent );
void ReCreateHToolbar();
virtual void ReCreateMenuBar() override;
void ShowChangedLanguage() override;
--
2.17.2
From 489ce93dc719c00ca21c2f30267d4639d8838cec Mon Sep 17 00:00:00 2001
From: Ian McInerney <Ian.S.McInerney@xxxxxxxx>
Date: Fri, 31 May 2019 16:53:57 +0100
Subject: [PATCH 3/3] cvpcb: Implement delete/cut/copy/paste for individual
associations
Fixes: lp:1794883
* https://bugs.launchpad.net/kicad/+bug/1794883
---
cvpcb/components_listbox.cpp | 19 +++++++-
cvpcb/cvpcb_id.h | 6 ++-
cvpcb/cvpcb_mainframe.cpp | 94 +++++++++++++++++++++++++++++++++---
cvpcb/cvpcb_mainframe.h | 33 +++++++++++--
cvpcb/toolbars_cvpcb.cpp | 2 +-
5 files changed, 140 insertions(+), 14 deletions(-)
diff --git a/cvpcb/components_listbox.cpp b/cvpcb/components_listbox.cpp
index f8a97191d..729efeb84 100644
--- a/cvpcb/components_listbox.cpp
+++ b/cvpcb/components_listbox.cpp
@@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
- * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
+ * Copyright (C) 1992-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
@@ -113,6 +113,8 @@ void COMPONENTS_LISTBOX::OnChar( wxKeyEvent& event )
{
int key = event.GetKeyCode();
+ wxCommandEvent dummy;
+
switch( key )
{
case WXK_TAB:
@@ -135,6 +137,21 @@ void COMPONENTS_LISTBOX::OnChar( wxKeyEvent& event )
event.Skip();
return;
+ case WXK_DELETE:
+ GetParent()->DelAssociation( dummy );
+ return;
+
+ case WXK_CONTROL_X:
+ GetParent()->CutAssociation( dummy );
+ return;
+
+ case WXK_CONTROL_C:
+ GetParent()->CopyAssociation( dummy );
+ return;
+
+ case WXK_CONTROL_V:
+ GetParent()->PasteAssociation( dummy );
+ return;
default:
break;
diff --git a/cvpcb/cvpcb_id.h b/cvpcb/cvpcb_id.h
index c46e9b15d..ad3716870 100644
--- a/cvpcb/cvpcb_id.h
+++ b/cvpcb/cvpcb_id.h
@@ -42,7 +42,8 @@ enum id_cvpcb_frm
ID_CVPCB_CREATE_SCREENCMP = ID_END_LIST,
ID_CVPCB_GOTO_FIRSTNA,
ID_CVPCB_GOTO_PREVIOUSNA,
- ID_CVPCB_DEL_ASSOCIATIONS,
+ ID_CVPCB_DEL_ALL_ASSOCIATIONS,
+ ID_CVPCB_DEL_ASSOCIATION,
ID_CVPCB_AUTO_ASSOCIE,
ID_CVPCB_COMPONENT_LIST,
ID_CVPCB_FOOTPRINT_LIST,
@@ -56,6 +57,9 @@ enum id_cvpcb_frm
ID_CVPCB_EQUFILES_LIST_EDIT,
ID_CVPCB_LIB_TABLE_EDIT,
ID_CVPCB_FILTER_TEXT_EDIT,
+ ID_CVPCB_CUT_ASSOCIATION,
+ ID_CVPCB_COPY_ASSOCIATION,
+ ID_CVPCB_PASTE_ASSOCIATION,
ID_CVPCB_ESCAPE_KEY,
ID_TB_MEASUREMENT_TOOL
};
diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp
index a066a1612..f922ed1a8 100644
--- a/cvpcb/cvpcb_mainframe.cpp
+++ b/cvpcb/cvpcb_mainframe.cpp
@@ -3,7 +3,7 @@
*
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2011-2016 Wayne Stambaugh <stambaughw@xxxxxxxxxxx>
- * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
+ * Copyright (C) 1992-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
@@ -73,7 +73,11 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, KIWAY_PLAYER )
EVT_TOOL( ID_CVPCB_CREATE_SCREENCMP, CVPCB_MAINFRAME::DisplayModule )
EVT_TOOL( ID_CVPCB_GOTO_FIRSTNA, CVPCB_MAINFRAME::ToFirstNA )
EVT_TOOL( ID_CVPCB_GOTO_PREVIOUSNA, CVPCB_MAINFRAME::ToPreviousNA )
- EVT_TOOL( ID_CVPCB_DEL_ASSOCIATIONS, CVPCB_MAINFRAME::DelAssociations )
+ EVT_TOOL( ID_CVPCB_DEL_ALL_ASSOCIATIONS, CVPCB_MAINFRAME::DelAllAssociations )
+ EVT_TOOL( ID_CVPCB_DEL_ASSOCIATION, CVPCB_MAINFRAME::DelAssociation )
+ EVT_TOOL( ID_CVPCB_CUT_ASSOCIATION, CVPCB_MAINFRAME::CutAssociation )
+ EVT_TOOL( ID_CVPCB_COPY_ASSOCIATION, CVPCB_MAINFRAME::CopyAssociation )
+ EVT_TOOL( ID_CVPCB_PASTE_ASSOCIATION, CVPCB_MAINFRAME::PasteAssociation )
EVT_TOOL( ID_CVPCB_AUTO_ASSOCIE, CVPCB_MAINFRAME::AutomaticFootprintMatching )
EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
CVPCB_MAINFRAME::OnSelectFilteringFootprint )
@@ -418,9 +422,82 @@ void CVPCB_MAINFRAME::OnQuit( wxCommandEvent& event )
}
-void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )
+void CVPCB_MAINFRAME::CutAssociation( wxCommandEvent& event )
{
- if( IsOK( this, _( "Delete selections" ) ) )
+ int itmIdx = m_compListBox->GetFirstSelected();
+
+ if( itmIdx == -1 )
+ return;
+
+ if( m_netlist.IsEmpty() )
+ return;
+
+ COMPONENT* component = m_netlist.GetComponent( itmIdx );
+
+ if( component && component->GetFPID().IsValid() )
+ {
+ m_clipboardBuffer = component->GetFPID().Format().wx_str();
+
+ SetNewPkg( wxEmptyString, itmIdx );
+ m_compListBox->RefreshItem( itmIdx );
+ }
+}
+
+
+void CVPCB_MAINFRAME::CopyAssociation( wxCommandEvent& event )
+{
+ int itmIdx = m_compListBox->GetFirstSelected();
+
+ if( itmIdx == -1 )
+ return;
+
+ if( m_netlist.IsEmpty() )
+ return;
+
+ COMPONENT* component = m_netlist.GetComponent( itmIdx );
+
+ if( component && component->GetFPID().IsValid() )
+ m_clipboardBuffer = component->GetFPID().Format().wx_str();
+}
+
+
+void CVPCB_MAINFRAME::PasteAssociation( wxCommandEvent& event )
+{
+ if( m_clipboardBuffer.IsEmpty() )
+ return;
+
+ int itmIdx = m_compListBox->GetFirstSelected();
+
+ while( itmIdx != -1 )
+ {
+ SetNewPkg( m_clipboardBuffer, itmIdx );
+ m_compListBox->RefreshItem( itmIdx );
+
+ itmIdx = m_compListBox->GetNextSelected( itmIdx );
+ }
+
+ DisplayStatus();
+}
+
+void CVPCB_MAINFRAME::DelAssociation( wxCommandEvent& event )
+{
+ int itmIdx = m_compListBox->GetFirstSelected();
+
+ while( itmIdx != -1 )
+ {
+ SetNewPkg( wxEmptyString, itmIdx );
+ m_compListBox->RefreshItem( itmIdx );
+
+ itmIdx = m_compListBox->GetNextSelected( itmIdx );
+ }
+
+ DisplayStatus();
+}
+
+
+void CVPCB_MAINFRAME::DelAllAssociations( wxCommandEvent& event )
+{
+ if( IsOK( this, _( "Delete all footprint assocations?" ) ) )
{
m_skipComponentSelect = true;
@@ -429,9 +506,6 @@ void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )
for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
{
- LIB_ID fpid;
-
- m_netlist.GetComponent( i )->SetFPID( fpid );
SetNewPkg( wxEmptyString );
}
@@ -475,6 +549,12 @@ void CVPCB_MAINFRAME::OnComponentRightClick( wxMouseEvent& event )
menu.Append( ID_CVPCB_CREATE_SCREENCMP, _( "View Footprint" ), _( "Show the assigned footprint in the footprint viewer" ) );
+ menu.Append( ID_CVPCB_CUT_ASSOCIATION, _( "Cut Footprint Association" ), _( "Cut the assigned footprint" ) );
+ menu.Append( ID_CVPCB_COPY_ASSOCIATION, _( "Copy Footprint Association" ), _( "Copy the assigned footprint" ) );
+ menu.Append( ID_CVPCB_PASTE_ASSOCIATION, _( "Paste Footprint Association" ), _( "Paste a footprint assignment" ) );
+
+ menu.Append( ID_CVPCB_DEL_ASSOCIATION, _( "Delete Footprint Association" ), _( "Delete the assigned footprint" ) );
+
PopupMenu( &menu );
}
diff --git a/cvpcb/cvpcb_mainframe.h b/cvpcb/cvpcb_mainframe.h
index cbdd4e5c9..1cb86b28c 100644
--- a/cvpcb/cvpcb_mainframe.h
+++ b/cvpcb/cvpcb_mainframe.h
@@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
- * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
+ * Copyright (C) 1992-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
@@ -70,6 +70,7 @@ class CVPCB_MAINFRAME : public KIWAY_PLAYER
wxStaticText* m_statusLine2;
wxStaticText* m_statusLine3;
wxButton* m_saveAndContinue;
+ wxString m_clipboardBuffer;
public:
wxArrayString m_ModuleLibNames;
@@ -133,10 +134,34 @@ public:
void ToPreviousNA( wxCommandEvent& event );
/**
- * Function DelAssociations
- * removes all component footprint associations already made
+ * Function DelAllAssociations
+ * Removes all component footprint associations already made
*/
- void DelAssociations( wxCommandEvent& event );
+ void DelAllAssociations( wxCommandEvent& event );
+
+ /**
+ * Function DelAssociation
+ * Removes association from selected footprints
+ */
+ void DelAssociation( wxCommandEvent& event );
+
+ /**
+ * Function CutAssociation
+ * Cuts the footprint name for the 1st selected component to the clipboard
+ */
+ void CutAssociation( wxCommandEvent& event );
+
+ /**
+ * Function CopyAssociation
+ * Copies the footprint name for the 1st selected component to the clipboard
+ */
+ void CopyAssociation( wxCommandEvent& event );
+
+ /**
+ * Function PasteAssociation
+ * Paste the footprint from the clipboard onto the selected components
+ */
+ void PasteAssociation( wxCommandEvent& event );
void OnConfigurePaths( wxCommandEvent& aEvent );
diff --git a/cvpcb/toolbars_cvpcb.cpp b/cvpcb/toolbars_cvpcb.cpp
index 6334c53ad..482f9e16f 100644
--- a/cvpcb/toolbars_cvpcb.cpp
+++ b/cvpcb/toolbars_cvpcb.cpp
@@ -63,7 +63,7 @@ void CVPCB_MAINFRAME::ReCreateHToolbar()
KiScaledBitmap( auto_associe_xpm, this ),
_( "Perform automatic footprint association" ) );
- m_mainToolBar->AddTool( ID_CVPCB_DEL_ASSOCIATIONS, wxEmptyString,
+ m_mainToolBar->AddTool( ID_CVPCB_DEL_ALL_ASSOCIATIONS, wxEmptyString,
KiScaledBitmap( delete_association_xpm, this ),
_( "Delete all footprint associations" ) );
--
2.17.2
Follow ups