diff --git a/eeschema/sync_sheet_pin/dialog_sync_sheet_pins.cpp b/eeschema/sync_sheet_pin/dialog_sync_sheet_pins.cpp index f275a7bfec..66a01d317b 100644 --- a/eeschema/sync_sheet_pin/dialog_sync_sheet_pins.cpp +++ b/eeschema/sync_sheet_pin/dialog_sync_sheet_pins.cpp @@ -39,12 +39,15 @@ #include #include -DIALOG_SYNC_SHEET_PINS::DIALOG_SYNC_SHEET_PINS( - wxWindow* aParent, std::list aSheetPath, - std::shared_ptr aAgent ) : + +DIALOG_SYNC_SHEET_PINS::DIALOG_SYNC_SHEET_PINS( wxWindow* aParent, + std::list aSheetPath, + std::shared_ptr aAgent ) : DIALOG_SYNC_SHEET_PINS_BASE( aParent ), - m_agent( std::move( aAgent ) ), m_lastEditSheet( nullptr ), - m_placeItemKind( PlaceItemKind::UNDEFINED ), m_placementTemplate( nullptr ) + m_agent( std::move( aAgent ) ), + m_lastEditSheet( nullptr ), + m_placeItemKind( PlaceItemKind::UNDEFINED ), + m_placementTemplate( nullptr ) { wxImageList* imageList = new wxImageList( SYNC_SHEET_PIN_PREFERENCE::NORMAL_WIDTH, SYNC_SHEET_PIN_PREFERENCE::NORMAL_HEIGHT ); @@ -122,6 +125,7 @@ void DIALOG_SYNC_SHEET_PINS::OnCloseBtnClick( wxCommandEvent& event ) Close(); } + void DIALOG_SYNC_SHEET_PINS::OnClose( wxCloseEvent& aEvent ) { aEvent.Skip(); diff --git a/eeschema/sync_sheet_pin/dialog_sync_sheet_pins.h b/eeschema/sync_sheet_pin/dialog_sync_sheet_pins.h index c4ae949ef2..15b21e6b58 100644 --- a/eeschema/sync_sheet_pin/dialog_sync_sheet_pins.h +++ b/eeschema/sync_sheet_pin/dialog_sync_sheet_pins.h @@ -37,6 +37,7 @@ class EDA_ITEM; class SHEET_SYNCHRONIZATION_AGENT; class PANEL_SYNC_SHEET_PINS; class SCH_HIERLABEL; + class DIALOG_SYNC_SHEET_PINS : public DIALOG_SYNC_SHEET_PINS_BASE { public: @@ -59,17 +60,17 @@ public: void EndPlaceItem( EDA_ITEM* aNewItem ); /** - * @brief Start place a new SHEET_PIN / HIERLABEL - * - * @param aSheet The sheet instance - * @param aKind SHEET_PIN / HIERLABEL - * @param aTemplate The template used for the new SHEET_PIN / HIERLABEL - */ + * Start place a new #SHEET_PIN/#HIERLABEL. + * + * @param aSheet The sheet instance + * @param aKind SHEET_PIN / HIERLABEL + * @param aTemplate The template used for the new SHEET_PIN / HIERLABEL + */ void BeginPlaceItem( SCH_SHEET* aSheet, PlaceItemKind aKind, EDA_ITEM* aTemplate ); /** - * @brief Get the Placement Template SHEET_PIN / HIERLABEL used for place a new HIERLABEL/SHEET_PIN - * + * Get the Placement Template SHEET_PIN / HIERLABEL used for place a new #HIERLABEL/#SHEET_PIN. + * * @return SCH_HIERLABEL* */ SCH_HIERLABEL* GetPlacementTemplate() const; @@ -79,6 +80,7 @@ private: //It's the agent that performs modification and placement std::shared_ptr m_agent; SCH_SHEET* m_lastEditSheet; + //The same sheet may have mutiple instances std::unordered_map m_panels; PlaceItemKind m_placeItemKind; diff --git a/eeschema/sync_sheet_pin/panel_sync_sheet_pins.cpp b/eeschema/sync_sheet_pin/panel_sync_sheet_pins.cpp index 537c5a0a52..1c461e3fed 100644 --- a/eeschema/sync_sheet_pin/panel_sync_sheet_pins.cpp +++ b/eeschema/sync_sheet_pin/panel_sync_sheet_pins.cpp @@ -42,10 +42,14 @@ PANEL_SYNC_SHEET_PINS::PANEL_SYNC_SHEET_PINS( wxWindow* aParent, SCH_SHEET* aSheet, wxNotebook* aNoteBook, int aIndex, SHEET_SYNCHRONIZATION_AGENT& aAgent, - SCH_SHEET_PATH aPath ) : + const SCH_SHEET_PATH& aPath ) : PANEL_SYNC_SHEET_PINS_BASE( aParent ), - m_sheet( aSheet ), m_noteBook( aNoteBook ), m_index( aIndex ), - m_sheetFileName( aSheet->GetFileName() ), m_agent( aAgent ), m_path( std::move( aPath ) ) + m_sheet( aSheet ), + m_noteBook( aNoteBook ), + m_index( aIndex ), + m_sheetFileName( aSheet->GetFileName() ), + m_agent( aAgent ), + m_path( std::move( aPath ) ) { m_btnUsePinAsTemplate->SetBitmap( KiBitmapBundle( BITMAPS::add_hierar_pin ) ); m_btnUseLabelAsTemplate->SetBitmap( KiBitmapBundle( BITMAPS::add_hierarchical_label ) ); @@ -101,6 +105,7 @@ void PANEL_SYNC_SHEET_PINS::UpdateForms() for( size_t i = 0; i < pins_ori.size(); i++ ) { SCH_SHEET_PIN* cur_pin = pins_ori[i]; + if( label->GetText() == cur_pin->GetText() && label->GetShape() == cur_pin->GetShape() ) { associated_list.push_back( @@ -109,11 +114,11 @@ void PANEL_SYNC_SHEET_PINS::UpdateForms() return; } } + labels_list.push_back( std::make_shared( label, m_sheet ) ); }; - for( const auto& item : labels_ori ) check_matched( static_cast( item ) ); @@ -141,8 +146,7 @@ void PANEL_SYNC_SHEET_PINS::UpdateForms() } -SHEET_SYNCHRONIZATION_MODEL_PTR -PANEL_SYNC_SHEET_PINS::GetModel( int aKind ) const +SHEET_SYNCHRONIZATION_MODEL_PTR PANEL_SYNC_SHEET_PINS::GetModel( int aKind ) const { return m_models.at( aKind ); } @@ -172,11 +176,15 @@ void PANEL_SYNC_SHEET_PINS::OnBtnAddLabelsClicked( wxCommandEvent& aEvent ) if( auto idx = m_models[SHEET_SYNCHRONIZATION_MODEL::SHEET_PIN]->GetSelectedIndex(); idx.has_value() ) + { if( SHEET_SYNCHRONIZATION_ITE_PTR item = m_models[SHEET_SYNCHRONIZATION_MODEL::SHEET_PIN]->GetSynchronizationItem( *idx ) ) + { m_agent.PlaceHieraLable( m_sheet, m_path, static_cast( item->GetItem() ) ); + } + } } @@ -186,11 +194,15 @@ void PANEL_SYNC_SHEET_PINS::OnBtnAddSheetPinsClicked( wxCommandEvent& aEvent ) if( auto idx = m_models[SHEET_SYNCHRONIZATION_MODEL::HIRE_LABEL]->GetSelectedIndex(); idx.has_value() ) + { if( SHEET_SYNCHRONIZATION_ITE_PTR item = m_models[SHEET_SYNCHRONIZATION_MODEL::HIRE_LABEL]->GetSynchronizationItem( *idx ) ) + { m_agent.PlaceSheetPin( m_sheet, m_path, static_cast( item->GetItem() ) ); + } + } } @@ -200,8 +212,10 @@ void PANEL_SYNC_SHEET_PINS::GenericSync( SYNC_DIRECTION direction ) wxDataViewItem pinIdx = m_viewSheetPins->GetSelection(); for( auto& idx : { labelIdx, pinIdx } ) + { if( !idx.IsOk() ) return; + } SHEET_SYNCHRONIZATION_ITE_PTR labelItem = m_models[SHEET_SYNCHRONIZATION_MODEL::HIRE_LABEL]->TakeItem( labelIdx ); @@ -209,8 +223,10 @@ void PANEL_SYNC_SHEET_PINS::GenericSync( SYNC_DIRECTION direction ) m_models[SHEET_SYNCHRONIZATION_MODEL::SHEET_PIN]->TakeItem( pinIdx ); for( const auto& item : { labelItem, pinItem } ) + { if( !item ) return; + } auto label_ptr = std::static_pointer_cast( labelItem )->GetLabel(); @@ -247,7 +263,9 @@ void PANEL_SYNC_SHEET_PINS::GenericSync( SYNC_DIRECTION direction ) for( auto idx : { SHEET_SYNCHRONIZATION_MODEL::HIRE_LABEL, SHEET_SYNCHRONIZATION_MODEL::SHEET_PIN } ) + { PostProcessModelSelection( idx, {} ); + } m_models[SHEET_SYNCHRONIZATION_MODEL::HIRE_LABEL]->DoNotify(); } @@ -317,6 +335,7 @@ void PANEL_SYNC_SHEET_PINS::OnBtnUndoClicked( wxCommandEvent& aEvent ) std::make_shared( associated->GetPin(), m_sheet ) ); } + PostProcessModelSelection( SHEET_SYNCHRONIZATION_MODEL::ASSOCIATED, {} ); UpdatePageImage(); } @@ -335,12 +354,14 @@ void PANEL_SYNC_SHEET_PINS::PostProcessModelSelection( int aIdex, wxDataViewItem { for( auto btn : { m_btnAddLabels, m_btnRmPins } ) btn->Enable( m_models[SHEET_SYNCHRONIZATION_MODEL::SHEET_PIN]->HasSelectedIndex() ); + break; } case SHEET_SYNCHRONIZATION_MODEL::HIRE_LABEL: { for( auto btn : { m_btnAddSheetPins, m_btnRmLabels } ) btn->Enable( m_models[SHEET_SYNCHRONIZATION_MODEL::HIRE_LABEL]->HasSelectedIndex() ); + break; } case SHEET_SYNCHRONIZATION_MODEL::ASSOCIATED: @@ -348,7 +369,8 @@ void PANEL_SYNC_SHEET_PINS::PostProcessModelSelection( int aIdex, wxDataViewItem m_btnUndo->Enable( m_models[SHEET_SYNCHRONIZATION_MODEL::ASSOCIATED]->HasSelectedIndex() ); break; } - default: break; + default: + break; } if( aIdex != SHEET_SYNCHRONIZATION_MODEL::ASSOCIATED ) diff --git a/eeschema/sync_sheet_pin/panel_sync_sheet_pins.h b/eeschema/sync_sheet_pin/panel_sync_sheet_pins.h index 0b5ace6b70..61ba2c1fc0 100644 --- a/eeschema/sync_sheet_pin/panel_sync_sheet_pins.h +++ b/eeschema/sync_sheet_pin/panel_sync_sheet_pins.h @@ -53,7 +53,7 @@ public: PANEL_SYNC_SHEET_PINS( wxWindow* aParent, SCH_SHEET* aSheet, wxNotebook* aNoteBook, int aIndex, - SHEET_SYNCHRONIZATION_AGENT& aAgent, SCH_SHEET_PATH aPath ); + SHEET_SYNCHRONIZATION_AGENT& aAgent, const SCH_SHEET_PATH& aPath ); ~PANEL_SYNC_SHEET_PINS() override; @@ -105,4 +105,4 @@ private: SCH_SHEET_PATH m_path; }; -#endif \ No newline at end of file +#endif diff --git a/eeschema/sync_sheet_pin/sheet_synchronization_agent.cpp b/eeschema/sync_sheet_pin/sheet_synchronization_agent.cpp index 4b6c1ccb14..34d0e6d234 100644 --- a/eeschema/sync_sheet_pin/sheet_synchronization_agent.cpp +++ b/eeschema/sync_sheet_pin/sheet_synchronization_agent.cpp @@ -36,8 +36,10 @@ SHEET_SYNCHRONIZATION_AGENT::SHEET_SYNCHRONIZATION_AGENT( DO_MODIFY_ITEM aDoMod TOOL_MANAGER* aToolManager, SCH_EDIT_FRAME* a_frame ) : m_doModify( std::move( aDoModify ) ), - m_doDelete( std::move( aNotifyItemChange ) ), m_doPlaceItem( std::move( aPlaceItem ) ), - m_toolManager( aToolManager ), m_frame( a_frame ) + m_doDelete( std::move( aNotifyItemChange ) ), + m_doPlaceItem( std::move( aPlaceItem ) ), + m_toolManager( aToolManager ), + m_frame( a_frame ) { } @@ -54,7 +56,7 @@ void SHEET_SYNCHRONIZATION_AGENT::ModifyItem( SHEET_SYNCHRONIZATION_ITEM& aItem, void SHEET_SYNCHRONIZATION_AGENT::ModifyItem( SCH_ITEM* sch_item, std::function aDoModify, - SCH_SHEET_PATH const& aPath, + const SCH_SHEET_PATH& aPath, SHEET_SYNCHRONIZATION_ITEM_KIND aKind ) { if( !aDoModify ) @@ -68,20 +70,20 @@ void SHEET_SYNCHRONIZATION_AGENT::ModifyItem( SCH_ITEM* sch_item, std::function< break; } case SHEET_SYNCHRONIZATION_ITEM_KIND::SHEET_PIN: - { SCH_SHEET_PATH path_cp = aPath; path_cp.pop_back(); m_doModify( sch_item, path_cp, aDoModify ); break; } - case SHEET_SYNCHRONIZATION_ITEM_KIND::HIERLABEL_AND_SHEET_PIN: break; + case SHEET_SYNCHRONIZATION_ITEM_KIND::HIERLABEL_AND_SHEET_PIN: + break; } } void SHEET_SYNCHRONIZATION_AGENT::RemoveItem( SHEET_SYNCHRONIZATION_ITEM& aItem, SCH_SHEET* aSheet, - SCH_SHEET_PATH const& aPath ) + const SCH_SHEET_PATH& aPath ) { if( !aSheet ) return; @@ -101,7 +103,8 @@ void SHEET_SYNCHRONIZATION_AGENT::RemoveItem( SHEET_SYNCHRONIZATION_ITEM& aItem, m_doDelete( aItem.GetItem(), path_cp ); break; } - case SHEET_SYNCHRONIZATION_ITEM_KIND::HIERLABEL_AND_SHEET_PIN: break; + case SHEET_SYNCHRONIZATION_ITEM_KIND::HIERLABEL_AND_SHEET_PIN: + break; } } diff --git a/eeschema/sync_sheet_pin/sheet_synchronization_agent.h b/eeschema/sync_sheet_pin/sheet_synchronization_agent.h index df85591506..5f78352d91 100644 --- a/eeschema/sync_sheet_pin/sheet_synchronization_agent.h +++ b/eeschema/sync_sheet_pin/sheet_synchronization_agent.h @@ -41,8 +41,7 @@ class SCH_ITEM; enum class SHEET_SYNCHRONIZATION_ITEM_KIND; /** - * @brief Agent for all the modifications while syncing the sheet pin and hierlabel - * + * Agent for all the modifications while syncing the sheet pin and hierarchical label. */ class SHEET_SYNCHRONIZATION_AGENT { @@ -69,9 +68,9 @@ public: ~SHEET_SYNCHRONIZATION_AGENT(); void ModifyItem( SHEET_SYNCHRONIZATION_ITEM& aItem, std::function aDoModify, - SCH_SHEET_PATH const& aPath ); + const SCH_SHEET_PATH& aPath ); - void ModifyItem( SCH_ITEM* aItem, std::function aDoModify, SCH_SHEET_PATH const& aPath, + void ModifyItem( SCH_ITEM* aItem, std::function aDoModify, const SCH_SHEET_PATH& aPath, SHEET_SYNCHRONIZATION_ITEM_KIND aKind ); void RemoveItem( SHEET_SYNCHRONIZATION_ITEM& aItem, SCH_SHEET* aSheet, diff --git a/eeschema/sync_sheet_pin/sheet_synchronization_item.cpp b/eeschema/sync_sheet_pin/sheet_synchronization_item.cpp index 392ce55f6c..0a73471267 100644 --- a/eeschema/sync_sheet_pin/sheet_synchronization_item.cpp +++ b/eeschema/sync_sheet_pin/sheet_synchronization_item.cpp @@ -143,14 +143,16 @@ int ASSOCIATED_SCH_LABEL_PIN::GetShape() const wxBitmap& ASSOCIATED_SCH_LABEL_PIN::GetBitmap() const { static auto label_and_pin_icon = ( []{ - wxBitmap left = KiBitmap( BITMAPS::add_hierar_pin, SYNC_SHEET_PIN_PREFERENCE::NORMAL_HEIGHT ); + wxBitmap left = KiBitmap( BITMAPS::add_hierar_pin, + SYNC_SHEET_PIN_PREFERENCE::NORMAL_HEIGHT ); wxBitmap right = - KiBitmap( BITMAPS::add_hierarchical_label, SYNC_SHEET_PIN_PREFERENCE::NORMAL_HEIGHT ); + KiBitmap( BITMAPS::add_hierarchical_label, + SYNC_SHEET_PIN_PREFERENCE::NORMAL_HEIGHT ); wxImage img( wxSize{ SYNC_SHEET_PIN_PREFERENCE::NORMAL_WIDTH * 2, SYNC_SHEET_PIN_PREFERENCE::NORMAL_HEIGHT } ); img.Paste( left.ConvertToImage(), 0, 0 ); img.Paste( right.ConvertToImage(), SYNC_SHEET_PIN_PREFERENCE::NORMAL_WIDTH, 0 ); - return wxBitmap(img); + return wxBitmap( img ); } )(); return label_and_pin_icon; diff --git a/eeschema/sync_sheet_pin/sheet_synchronization_item.h b/eeschema/sync_sheet_pin/sheet_synchronization_item.h index bbd0245ee6..23876476ab 100644 --- a/eeschema/sync_sheet_pin/sheet_synchronization_item.h +++ b/eeschema/sync_sheet_pin/sheet_synchronization_item.h @@ -44,6 +44,7 @@ enum class SHEET_SYNCHRONIZATION_ITEM_KIND }; using SCREEN_UPDATER = std::function; + class SHEET_SYNCHRONIZATION_ITEM { public: @@ -60,6 +61,7 @@ public: virtual SHEET_SYNCHRONIZATION_ITEM_KIND GetKind() const = 0; }; + class SCH_HIERLABEL_SYNCHRONIZATION_ITEM : public SHEET_SYNCHRONIZATION_ITEM { public: diff --git a/eeschema/sync_sheet_pin/sheet_synchronization_model.cpp b/eeschema/sync_sheet_pin/sheet_synchronization_model.cpp index cec18fe552..3096c81cb6 100644 --- a/eeschema/sync_sheet_pin/sheet_synchronization_model.cpp +++ b/eeschema/sync_sheet_pin/sheet_synchronization_model.cpp @@ -39,9 +39,11 @@ extern wxString getElectricalTypeLabel( LABEL_FLAG_SHAPE aType ); SHEET_SYNCHRONIZATION_MODEL::SHEET_SYNCHRONIZATION_MODEL( SHEET_SYNCHRONIZATION_AGENT& aAgent, SCH_SHEET* aSheet, - SCH_SHEET_PATH aPath ) : + SCH_SHEET_PATH& aPath ) : m_selectedIndex( std::optional() ), - m_agent( aAgent ), m_sheet( aSheet ), m_path( std::move( aPath ) ) + m_agent( aAgent ), + m_sheet( aSheet ), + m_path( std::move( aPath ) ) { } @@ -56,7 +58,9 @@ void SHEET_SYNCHRONIZATION_MODEL::GetValueByRow( wxVariant& aVariant, unsigned r switch( col ) { - case NAME: aVariant << wxDataViewIconText( item->GetName(), item->GetBitmap() ); break; + case NAME: + aVariant << wxDataViewIconText( item->GetName(), item->GetBitmap() ); + break; case SHAPE: aVariant = getElectricalTypeLabel( static_cast( item->GetShape() ) ); break; @@ -139,7 +143,9 @@ SHEET_SYNCHRONIZATION_MODEL::TakeItems( wxDataViewItemArray const& aItems ) for( unsigned i = 0; i < m_items.size(); i++ ) { if( rowsToBeRemove.find( i ) == rowsToBeRemove.end() ) + { items_remain.push_back( m_items[i] ); + } else { items_token.push_back( m_items[i] ); diff --git a/eeschema/sync_sheet_pin/sheet_synchronization_model.h b/eeschema/sync_sheet_pin/sheet_synchronization_model.h index 7790e4048e..b41fea7bf3 100644 --- a/eeschema/sync_sheet_pin/sheet_synchronization_model.h +++ b/eeschema/sync_sheet_pin/sheet_synchronization_model.h @@ -40,6 +40,7 @@ class SHEET_SYNCHRONIZATION_NOTIFIER; class SHEET_SYNCHRONIZATION_AGENT; class SCH_SHEET; class SCH_SHEET_PATH; + class SHEET_SYNCHRONIZATION_MODEL : public wxDataViewVirtualListModel { public: @@ -70,7 +71,7 @@ public: SHEET_SYNCHRONIZATION_MODEL( SHEET_SYNCHRONIZATION_AGENT& aAgent, SCH_SHEET* aSheet, - SCH_SHEET_PATH aPath ); + SCH_SHEET_PATH& aPath ); ~SHEET_SYNCHRONIZATION_MODEL() override; void GetValueByRow( wxVariant& variant, unsigned row, unsigned col ) const override; @@ -82,12 +83,12 @@ public: void RemoveItems( wxDataViewItemArray const& aItems ); /** - * @brief Add a new item, the notifiers are notified + * Add a new item, the notifiers are notified. */ bool AppendNewItem( std::shared_ptr aItem ); /** - * @brief Just append item to the list, the notifiers are not notified + * Just append item to the list, the notifiers are not notified. */ bool AppendItem( std::shared_ptr aItem ); diff --git a/eeschema/sync_sheet_pin/sheet_synchronization_notifier.cpp b/eeschema/sync_sheet_pin/sheet_synchronization_notifier.cpp index 098d0f2a71..a85be597cd 100644 --- a/eeschema/sync_sheet_pin/sheet_synchronization_notifier.cpp +++ b/eeschema/sync_sheet_pin/sheet_synchronization_notifier.cpp @@ -46,6 +46,7 @@ bool SHEET_FILE_CHANGE_NOTIFIER::ShouldIgnore() const return false; } + void SHEET_FILE_CHANGE_NOTIFIER::Sync() { m_panel->UpdateForms(); diff --git a/eeschema/sync_sheet_pin/sheet_synchronization_notifier.h b/eeschema/sync_sheet_pin/sheet_synchronization_notifier.h index 596aa2ac8c..4fe4591190 100644 --- a/eeschema/sync_sheet_pin/sheet_synchronization_notifier.h +++ b/eeschema/sync_sheet_pin/sheet_synchronization_notifier.h @@ -28,6 +28,7 @@ class SHEET_SYNCHRONIZATION_MODEL; class PANEL_SYNC_SHEET_PINS; + class SHEET_SYNCHRONIZATION_NOTIFIER { public: @@ -55,7 +56,7 @@ private: /** - * @brief Used to sync the modifications between the mutiple instances of a sheet file + * Used to sync the modifications between the mutiple instances of a sheet file. * */ class SHEET_FILE_CHANGE_NOTIFIER : public SHEET_SYNCHRONIZATION_NOTIFIER diff --git a/eeschema/tools/ee_actions.cpp b/eeschema/tools/ee_actions.cpp index 7bf67b932c..a5d920857e 100644 --- a/eeschema/tools/ee_actions.cpp +++ b/eeschema/tools/ee_actions.cpp @@ -504,30 +504,28 @@ TOOL_ACTION EE_ACTIONS::drawSheet( TOOL_ACTION_ARGS() .Parameter( SCH_SHEET_T ) ); TOOL_ACTION EE_ACTIONS::placeSheetPin( TOOL_ACTION_ARGS() - .Name( "eeschema.InteractiveDrawing.placeSheetPin" ) - .Scope( AS_GLOBAL ) - .FriendlyName( _( "Add Sheet Pin" ) ) - .Tooltip( _( "Add sheet pins" ) ) - .Icon( BITMAPS::add_hierar_pin ) - .Flags( AF_ACTIVATE ) ); + .Name( "eeschema.InteractiveDrawing.placeSheetPin" ) + .Scope( AS_GLOBAL ) + .FriendlyName( _( "Add Sheet Pin" ) ) + .Tooltip( _( "Add sheet pins" ) ) + .Icon( BITMAPS::add_hierar_pin ) + .Flags( AF_ACTIVATE ) ); -TOOL_ACTION EE_ACTIONS::syncSheetPins( - TOOL_ACTION_ARGS() - .Name( "eeschema.InteractiveDrawing.syncSheetPins" ) - .Scope( AS_GLOBAL ) - .FriendlyName( _( "Sync Sheet Pins" ) ) - .Tooltip( _( "Synchronize sheet pins and hierarchical labels”" ) ) - .Icon( BITMAPS::import_hierarchical_label ) - .Flags( AF_ACTIVATE ) ); +TOOL_ACTION EE_ACTIONS::syncSheetPins( TOOL_ACTION_ARGS() + .Name( "eeschema.InteractiveDrawing.syncSheetPins" ) + .Scope( AS_GLOBAL ) + .FriendlyName( _( "Sync Sheet Pins" ) ) + .Tooltip( _( "Synchronize sheet pins and hierarchical labels”" ) ) + .Icon( BITMAPS::import_hierarchical_label ) + .Flags( AF_ACTIVATE ) ); -TOOL_ACTION EE_ACTIONS::syncAllSheetsPins( - TOOL_ACTION_ARGS() - .Name( "eeschema.InteractiveDrawing.syncAllSheetsPins" ) - .Scope( AS_GLOBAL ) - .FriendlyName( _( "Sync Sheet Pins" ) ) - .Tooltip( _( "Synchronize sheet pins and hierarchical labels”" ) ) - .Icon( BITMAPS::import_hierarchical_label ) - .Flags( AF_ACTIVATE ) ); +TOOL_ACTION EE_ACTIONS::syncAllSheetsPins( TOOL_ACTION_ARGS() + .Name( "eeschema.InteractiveDrawing.syncAllSheetsPins" ) + .Scope( AS_GLOBAL ) + .FriendlyName( _( "Sync Sheet Pins" ) ) + .Tooltip( _( "Synchronize sheet pins and hierarchical labels”" ) ) + .Icon( BITMAPS::import_hierarchical_label ) + .Flags( AF_ACTIVATE ) ); TOOL_ACTION EE_ACTIONS::placeGlobalLabel( TOOL_ACTION_ARGS() .Name( "eeschema.InteractiveDrawing.placeGlobalLabel" ) diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index d584ba3333..86977594e0 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -1584,6 +1584,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) else { item = createNewSheetPin( sheet, cursorPos ); + if( m_dialogSyncSheetPin && m_dialogSyncSheetPin->GetPlacementTemplate() ) { auto label = static_cast( @@ -1746,7 +1747,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) if( m_dialogSyncSheetPin && m_dialogSyncSheetPin->GetPlacementTemplate() ) { m_dialogSyncSheetPin->EndPlaceItem( nullptr ); - m_dialogSyncSheetPin->Show(true); + m_dialogSyncSheetPin->Show( true ); } return 0; @@ -2562,7 +2563,7 @@ int SCH_DRAWING_TOOLS::SyncSheetsPins( const TOOL_EVENT& aEvent ) { VECTOR2I cursorPos = getViewControls()->GetMousePosition(); - if( EDA_ITEM* i = nullptr; static_cast(m_selectionTool->SelectPoint( cursorPos, { SCH_SHEET_T }, &i )) , i != nullptr ) + if( EDA_ITEM* i = nullptr; static_cast(m_selectionTool->SelectPoint( cursorPos, { SCH_SHEET_T }, &i ) ) , i != nullptr ) { sheet = dynamic_cast( i ); } @@ -2591,23 +2592,23 @@ int SCH_DRAWING_TOOLS::SyncAllSheetsPins( const TOOL_EVENT& aEvent ) std::vector sheetChildren; aScene->GetSheets( &sheetChildren ); - aVisited.insert(aScene); + aVisited.insert( aScene ); - for( SCH_ITEM* child : sheetChildren) + for( SCH_ITEM* child : sheetChildren ) { SCH_SHEET_PATH cp = aCurPath; SCH_SHEET* sheet = static_cast( child ); - cp.push_back(sheet); + cp.push_back( sheet ); aPaths.push_back( cp ); - getSheetChildren(aPaths , sheet->GetScreen() , aVisited ,cp); + getSheetChildren( aPaths, sheet->GetScreen(), aVisited, cp ); } }; std::list sheetPaths; std::set visited; SCH_SHEET_PATH current; - current.push_back(&m_frame->Schematic().Root()); - getSheetChildren(sheetPaths , m_frame->Schematic().Root().GetScreen() ,visited ,current ); + current.push_back( &m_frame->Schematic().Root() ); + getSheetChildren( sheetPaths, m_frame->Schematic().Root().GetScreen(), visited, current ); return doSyncSheetsPins( sheetPaths ); }