From 6c32b6f955703113c6b56359ee50f139b7be854c Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 23 Jan 2018 12:15:19 +0100 Subject: [PATCH] Pin edit coupling: renamed and changed the description This commit aims at making the pin edit coupling easier to understand. It renames the mode to 'synchronized pin edit', shortens the description and inverts the logic to avoid double negation. To make the code clearer, two items have their name changed to fit the new description: - m_editPinsSeparately -> m_syncPinEdit - ID_LIBEDIT_EDIT_PIN_BY_PIN -> ID_LIBEDIT_SYNC_PIN_EDIT --- eeschema/block_libedit.cpp | 8 ++++---- eeschema/class_libentry.cpp | 9 ++++++--- eeschema/class_libentry.h | 5 ++--- eeschema/eeschema_id.h | 2 +- eeschema/libedit.cpp | 3 ++- eeschema/libeditframe.cpp | 32 +++++++++++++++----------------- eeschema/libeditframe.h | 12 ++++++------ eeschema/tool_lib.cpp | 11 ++++------- 8 files changed, 40 insertions(+), 42 deletions(-) diff --git a/eeschema/block_libedit.cpp b/eeschema/block_libedit.cpp index e0b1562567..34d9c7b38c 100644 --- a/eeschema/block_libedit.cpp +++ b/eeschema/block_libedit.cpp @@ -124,7 +124,7 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC ) if( GetCurPart() ) ItemCount = GetCurPart()->SelectItems( *block, m_unit, m_convert, - m_editPinsSeparately ); + m_syncPinEdit ); if( ItemCount ) { nextCmd = true; @@ -151,7 +151,7 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC ) case BLOCK_CUT: if( GetCurPart() ) ItemCount = GetCurPart()->SelectItems( *block, m_unit, m_convert, - m_editPinsSeparately ); + m_syncPinEdit ); if( ItemCount ) { @@ -176,7 +176,7 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC ) if( GetCurPart() ) ItemCount = GetCurPart()->SelectItems( *block, m_unit, m_convert, - m_editPinsSeparately ); + m_syncPinEdit ); if( ItemCount ) SaveCopyInUndoList( GetCurPart() ); @@ -200,7 +200,7 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC ) if( GetCurPart() ) ItemCount = GetCurPart()->SelectItems( *block, m_unit, m_convert, - m_editPinsSeparately ); + m_syncPinEdit ); if( ItemCount ) SaveCopyInUndoList( GetCurPart() ); diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index e9677e6aa3..46c5a80c21 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -925,7 +925,7 @@ void LIB_PART::ClearStatus() } -int LIB_PART::SelectItems( EDA_RECT& aRect, int aUnit, int aConvert, bool aEditPinByPin ) +int LIB_PART::SelectItems( EDA_RECT& aRect, int aUnit, int aConvert, bool aSyncPinEdit ) { int itemCount = 0; @@ -939,8 +939,11 @@ int LIB_PART::SelectItems( EDA_RECT& aRect, int aUnit, int aConvert, bool aEditP if( item.Type() != LIB_PIN_T ) continue; - // Specific rules for pins. - if( aEditPinByPin || m_unitsLocked + // Specific rules for pins: + // - do not select pins in other units when synchronized pin edit mode is disabled + // - do not select pins in other units when units are not interchangeable + // - in other cases verify if the pin belongs to the requested unit + if( !aSyncPinEdit || m_unitsLocked || ( item.m_Convert && item.m_Convert != aConvert ) ) continue; } diff --git a/eeschema/class_libentry.h b/eeschema/class_libentry.h index 2bee7de9c1..79cfeecce7 100644 --- a/eeschema/class_libentry.h +++ b/eeschema/class_libentry.h @@ -579,12 +579,11 @@ public: * @param aRect - The bounding rectangle to test in draw items are inside. * @param aUnit - The current unit number to test against. * @param aConvert - Are the draw items being selected a conversion. - * @param aEditPinByPin - Used to ignore pin selections when in edit pin - * by pin mode is enabled. + * @param aSyncPinEdit - Enable pin selection in other units. * @return The number of draw objects found inside the block select * rectangle. */ - int SelectItems( EDA_RECT& aRect, int aUnit, int aConvert, bool aEditPinByPin ); + int SelectItems( EDA_RECT& aRect, int aUnit, int aConvert, bool aSyncPinEdit ); /** * Clears all the draw items marked by a block select. diff --git a/eeschema/eeschema_id.h b/eeschema/eeschema_id.h index c641323b7a..8ca2335cfe 100644 --- a/eeschema/eeschema_id.h +++ b/eeschema/eeschema_id.h @@ -209,7 +209,7 @@ enum id_eeschema_frm /* Library editor horizontal toolbar IDs. */ ID_DE_MORGAN_NORMAL_BUTT, ID_DE_MORGAN_CONVERT_BUTT, - ID_LIBEDIT_EDIT_PIN_BY_PIN, + ID_LIBEDIT_SYNC_PIN_EDIT, ID_LIBEDIT_EDIT_PIN_BY_TABLE, ID_LIBEDIT_VIEW_DOC, ID_LIBEDIT_CHECK_PART, diff --git a/eeschema/libedit.cpp b/eeschema/libedit.cpp index 14e55103cd..71347198e5 100644 --- a/eeschema/libedit.cpp +++ b/eeschema/libedit.cpp @@ -130,7 +130,8 @@ bool LIB_EDIT_FRAME::LoadComponentFromCurrentLib( const wxString& aAliasName, in if( aConvert > 0 ) m_convert = aConvert; - m_editPinsSeparately = GetCurPart()->UnitsLocked() ? true : false; + // Enable synchronized pin edit mode for symbols with interchangeable units + m_syncPinEdit = !GetCurPart()->UnitsLocked(); GetScreen()->ClearUndoRedoList(); Zoom_Automatique( false ); diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index 9da51de76a..c4ba5493bc 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -124,7 +124,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_TOOL( ID_DE_MORGAN_NORMAL_BUTT, LIB_EDIT_FRAME::OnSelectBodyStyle ) EVT_TOOL( ID_DE_MORGAN_CONVERT_BUTT, LIB_EDIT_FRAME::OnSelectBodyStyle ) EVT_TOOL( ID_LIBEDIT_VIEW_DOC, LIB_EDIT_FRAME::OnViewEntryDoc ) - EVT_TOOL( ID_LIBEDIT_EDIT_PIN_BY_PIN, LIB_EDIT_FRAME::Process_Special_Functions ) + EVT_TOOL( ID_LIBEDIT_SYNC_PIN_EDIT, LIB_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_LIBEDIT_EDIT_PIN_BY_TABLE, LIB_EDIT_FRAME::OnOpenPinTable ) EVT_COMBOBOX( ID_LIBEDIT_SELECT_PART_NUMBER, LIB_EDIT_FRAME::OnSelectPart ) @@ -186,7 +186,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_UPDATE_UI( ID_LIBEDIT_SAVE_LIBRARY, LIB_EDIT_FRAME::OnUpdateSaveLib ) EVT_UPDATE_UI( ID_LIBEDIT_SAVE_LIBRARY_AS, LIB_EDIT_FRAME::OnUpdateSaveLibAs ) EVT_UPDATE_UI( ID_LIBEDIT_VIEW_DOC, LIB_EDIT_FRAME::OnUpdateViewDoc ) - EVT_UPDATE_UI( ID_LIBEDIT_EDIT_PIN_BY_PIN, LIB_EDIT_FRAME::OnUpdatePinByPin ) + EVT_UPDATE_UI( ID_LIBEDIT_SYNC_PIN_EDIT, LIB_EDIT_FRAME::OnUpdateSyncPinEdit ) EVT_UPDATE_UI( ID_LIBEDIT_EDIT_PIN_BY_TABLE, LIB_EDIT_FRAME::OnUpdatePinTable ) EVT_UPDATE_UI( ID_LIBEDIT_SELECT_PART_NUMBER, LIB_EDIT_FRAME::OnUpdatePartNumber ) EVT_UPDATE_UI( ID_LIBEDIT_SELECT_ALIAS, LIB_EDIT_FRAME::OnUpdateSelectAlias ) @@ -211,7 +211,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_drawSpecificConvert = true; m_drawSpecificUnit = false; m_hotkeysDescrList = g_Libedit_Hokeys_Descr; - m_editPinsSeparately = false; + m_syncPinEdit = false; m_repeatPinStep = DEFAULT_REPEAT_OFFSET_PIN; SetShowElectricalType( true ); @@ -620,13 +620,11 @@ void LIB_EDIT_FRAME::OnUpdateViewDoc( wxUpdateUIEvent& event ) } -void LIB_EDIT_FRAME::OnUpdatePinByPin( wxUpdateUIEvent& event ) +void LIB_EDIT_FRAME::OnUpdateSyncPinEdit( wxUpdateUIEvent& event ) { - LIB_PART* part = GetCurPart(); - - event.Enable( part && part->GetUnitCount() > 1 && !part->UnitsLocked() ); - - event.Check( m_editPinsSeparately ); + LIB_PART* part = GetCurPart(); + event.Enable( part && part->IsMulti() && !part->UnitsLocked() ); + event.Check( m_syncPinEdit ); } @@ -811,8 +809,8 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_LIBEDIT_CANCEL_EDITING: break; - case ID_LIBEDIT_EDIT_PIN_BY_PIN: - m_editPinsSeparately = m_mainToolBar->GetToolToggled( ID_LIBEDIT_EDIT_PIN_BY_PIN ); + case ID_LIBEDIT_SYNC_PIN_EDIT: + m_syncPinEdit = m_mainToolBar->GetToolToggled( ID_LIBEDIT_SYNC_PIN_EDIT ); break; case ID_POPUP_LIBEDIT_END_CREATE_ITEM: @@ -1076,8 +1074,8 @@ void LIB_EDIT_FRAME::SetCurPart( LIB_PART* aPart ) // retain in case this wxFrame is re-opened later on the same PROJECT Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_PART, partName ); - // Ensure pin editind can be coupled for multi unitz - m_editPinsSeparately = aPart && aPart->IsMulti() && aPart->UnitsLocked(); + // Ensure synchronized pin edit can be enabled only symbols with interchangeable units + m_syncPinEdit = aPart && aPart->IsMulti() && !aPart->UnitsLocked(); } @@ -1148,8 +1146,8 @@ void LIB_EDIT_FRAME::OnEditComponentProperties( wxCommandEvent& event ) // to the best value if( partLocked != GetCurPart()->UnitsLocked() ) { - // m_editPinsSeparately is set to the better value - m_editPinsSeparately = GetCurPart()->UnitsLocked() ? true : false; + // Enable synchronized pin edit mode for symbols with interchangeable units + m_syncPinEdit = !GetCurPart()->UnitsLocked(); // also set default edit options to the better value // Usually if units are locked, graphic items are specific to each unit // and if units are interchangeable, graphic items are common to units @@ -1512,9 +1510,9 @@ void LIB_EDIT_FRAME::OnOpenPinTable( wxCommandEvent& aEvent ) bool LIB_EDIT_FRAME::SynchronizePins() { - LIB_PART* part = GetCurPart(); + LIB_PART* part = GetCurPart(); - return !m_editPinsSeparately && part && part->IsMulti() && !part->UnitsLocked(); + return m_syncPinEdit && part && part->IsMulti() && !part->UnitsLocked(); } diff --git a/eeschema/libeditframe.h b/eeschema/libeditframe.h index 2c5bf7b1ea..33bb35b557 100644 --- a/eeschema/libeditframe.h +++ b/eeschema/libeditframe.h @@ -83,20 +83,20 @@ class LIB_EDIT_FRAME : public SCH_BASE_FRAME * Therefore deleting, moving pins are made for all pins at the same location * When units are interchangeable, synchronizing edition of pins is usually * the best way, because if units are interchangeable, it imply all similar - * pins are on the same location + * pins are on the same location. * When units are non interchangeable, do not synchronize edition of pins, because - * each part is specific, and there are no similar pins between units + * each part is specific, and there are no similar pins between units. * * Setting this to false allows editing each pin per part or body style * regardless other pins at the same location. * This requires the user to open each part or body style to make changes * to the other pins at the same location. * To know if others pins must be coupled when editing a pin, use - * SynchronizePins() instead of m_editPinsSeparately, because SynchronizePins() + * SynchronizePins() instead of m_syncPinEdit, because SynchronizePins() * is more reliable (takes in account the fact units are interchangeable, - * there are more than one unit ) + * there are more than one unit). */ - bool m_editPinsSeparately; + bool m_syncPinEdit; /** * the option to show the pin electrical name in the component editor @@ -344,7 +344,7 @@ public: void OnUpdateSaveLib( wxUpdateUIEvent& event ); void OnUpdateSaveLibAs( wxUpdateUIEvent& event ); void OnUpdateViewDoc( wxUpdateUIEvent& event ); - void OnUpdatePinByPin( wxUpdateUIEvent& event ); + void OnUpdateSyncPinEdit( wxUpdateUIEvent& event ); void OnUpdatePinTable( wxUpdateUIEvent& event ); void OnUpdatePartNumber( wxUpdateUIEvent& event ); void OnUpdateDeMorganNormal( wxUpdateUIEvent& event ); diff --git a/eeschema/tool_lib.cpp b/eeschema/tool_lib.cpp index 98649b722a..2640b2a4fd 100644 --- a/eeschema/tool_lib.cpp +++ b/eeschema/tool_lib.cpp @@ -205,13 +205,10 @@ void LIB_EDIT_FRAME::ReCreateHToolbar() m_mainToolBar->AddSeparator(); KiScaledSeparator( m_mainToolBar, this ); - msg = _( "Allows disabling pin edition coupling between units.\n" - "When not disabled, adding, deleting and moving pins are synchronized\n" - "between units for pins at the same location.\n" - "For instance, adding a pin to a unit also add a similar pin to other units at the same location.\n" - "However, pins can have a different number or size because they are specific to a unit.\n" - "Usually synchronization is enabled when units are interchangeable and disabled if not." ); - m_mainToolBar->AddTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, wxEmptyString, KiScaledBitmap( pin2pin_xpm, this ), + msg = _( "Synchronized pin edit mode\n" + "Synchronized pin edit mode propagates all pin changes to other units.\n" + "Normally enabled for multiunit parts with interchangeable units." ); + m_mainToolBar->AddTool( ID_LIBEDIT_SYNC_PIN_EDIT, wxEmptyString, KiScaledBitmap( pin2pin_xpm, this ), msg, wxITEM_CHECK ); m_mainToolBar->AddTool( ID_LIBEDIT_EDIT_PIN_BY_TABLE, wxEmptyString, KiScaledBitmap( pin_table_xpm, this ), _( "Show pin table" ) );