44 wxWindow* aParent, std::list<SCH_SHEET_PATH> aSheetPath,
45 std::shared_ptr<SHEET_SYNCHRONIZATION_AGENT> aAgent,
SCH_SHEET* aInitialSheet ) :
60 int initialSelection = -1;
61 int firstUnsyncedPage = -1;
62 std::unordered_map<wxString, std::list<PANEL_SYNC_SHEET_PINS*>> sheet_instances;
64 for(
const auto& sheet_path : aSheetPath )
66 auto sheet = sheet_path.Last();
67 wxString fileName = sheet->GetFileName();
69 ++count, *
m_agent, sheet_path );
71 m_notebook->AddPage( page, sheet->GetShownName(
true ), {}, hasUndefined );
74 if( aInitialSheet && sheet == aInitialSheet )
75 initialSelection = count;
77 if( firstUnsyncedPage < 0 && hasUndefined )
78 firstUnsyncedPage = count;
80 if( sheet_instances.find( fileName ) == sheet_instances.end() )
82 sheet_instances.try_emplace( fileName, std::list<PANEL_SYNC_SHEET_PINS*>{ page } );
86 sheet_instances[fileName].push_back( page );
92 for(
auto& [sheet_name, panel_list] : sheet_instances )
94 if( panel_list.size() > 1 )
96 std::list<std::shared_ptr<SHEET_SYNCHRONIZATION_NOTIFIER>> sheet_change_notifiers;
97 std::list<SHEET_SYNCHRONIZATION_MODEL*> sheet_sync_models;
99 for(
auto& panel : panel_list )
103 sheet_sync_models.push_back(
model );
104 sheet_change_notifiers.push_back(
105 std::make_shared<SHEET_FILE_CHANGE_NOTIFIER>(
model, panel ) );
108 for(
auto& notifier : sheet_change_notifiers )
110 for(
auto& other : sheet_sync_models )
112 if( notifier->GetOwner() != other )
114 other->AddNotifier( notifier );
123 if( initialSelection >= 0 )
125 else if( firstUnsyncedPage >= 0 )
126 m_notebook->SetSelection( firstUnsyncedPage );
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
DIALOG_SYNC_SHEET_PINS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Synchronize sheet pins and hierarchical labels"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)