39#include <unordered_map>
44 wxWindow* aParent, std::list<SCH_SHEET_PATH> aSheetPath,
45 std::shared_ptr<SHEET_SYNCHRONIZATION_AGENT> aAgent ) :
48 m_currentTemplate( nullptr )
60 std::unordered_map<wxString, std::list<PANEL_SYNC_SHEET_PINS*>> sheet_instances;
62 for(
const auto& sheet_path : aSheetPath )
64 auto sheet = sheet_path.Last();
65 wxString fileName = sheet->GetFileName();
67 ++count, *
m_agent, sheet_path );
71 if( sheet_instances.find( fileName ) == sheet_instances.end() )
73 sheet_instances.try_emplace( fileName, std::list<PANEL_SYNC_SHEET_PINS*>{ page } );
77 sheet_instances[fileName].push_back( page );
83 for(
auto& [sheet_name, panel_list] : sheet_instances )
85 if( panel_list.size() > 1 )
87 std::list<std::shared_ptr<SHEET_SYNCHRONIZATION_NOTIFIER>> sheet_change_notifiers;
88 std::list<SHEET_SYNCHRONIZATION_MODEL*> sheet_sync_models;
90 for(
auto& panel : panel_list )
94 sheet_sync_models.push_back( model );
95 sheet_change_notifiers.push_back(
96 std::make_shared<SHEET_FILE_CHANGE_NOTIFIER>( model, panel ) );
99 for(
auto& notifier : sheet_change_notifiers )
101 for(
auto& other : sheet_sync_models )
103 if( notifier->GetOwner() != other )
133 auto post_end_place_item =
134 std::shared_ptr<std::nullptr_t>(
nullptr,
135 [&]( std::nullptr_t )
145 m_currentTemplate = *m_placementTemplateSet.begin();
157 if( template_item->GetText() != new_item->GetText()
158 || template_item->GetShape() != new_item->GetShape() )
164 template_item->SetText( new_item->GetText() );
165 template_item->SetShape( new_item->GetShape() );
167 panel->GetSheetPath(),
169 ? SHEET_SYNCHRONIZATION_ITEM_KIND::HIERLABEL
170 : SHEET_SYNCHRONIZATION_ITEM_KIND::SHEET_PIN );
173 panel->UpdateForms();
182 std::set<EDA_ITEM*>
const& aPlacementTemplateSet )
184 if( aPlacementTemplateSet.empty() )
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Class DIALOG_SYNC_SHEET_PINS_BASE.
SCH_HIERLABEL * GetPlacementTemplate() const
Get the Placement Template SHEET_PIN / HIERLABEL used for place a new HIERLABEL/SHEET_PIN.
PlaceItemKind m_placeItemKind
std::set< EDA_ITEM * > m_placementTemplateSet
SCH_SHEET * m_lastEditSheet
std::unordered_map< SCH_SHEET *, PANEL_SYNC_SHEET_PINS * > m_panels
The same sheet may have multiple instances.
void EndPlaceItem(EDA_ITEM *aNewItem)
End place a new HIERLABEL/SHEET_PIN , and add the new item to the corresponding table.
std::shared_ptr< SHEET_SYNCHRONIZATION_AGENT > m_agent
It's the agent that performs modification and placement.
EDA_ITEM * m_currentTemplate
DIALOG_SYNC_SHEET_PINS(wxWindow *aParent, std::list< SCH_SHEET_PATH > aSheetPath, std::shared_ptr< SHEET_SYNCHRONIZATION_AGENT > aAgent)
void OnClose(wxCloseEvent &aEvent)
void PreparePlacementTemplate(SCH_SHEET *aSheet, PlaceItemKind aKind, std::set< EDA_ITEM * > const &aPlacementTemplateSet)
Either the selected HIERLABEL or SHEET_PIN will be used as templates for placing the new ones.
bool CanPlaceMore() const
Check if there are more items to be placed.
~DIALOG_SYNC_SHEET_PINS() override
A base class for most all the KiCad significant classes used in schematics and boards.
bool HasUndefinedSheetPing() const
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
void AddNotifier(std::shared_ptr< SHEET_SYNCHRONIZATION_NOTIFIER > aNotifier)
static const std::map< BOOKCTRL_ICON_INDEX, BITMAPS > & GetBookctrlPageIcon()