40 wxWindow* aParent, std::list<SCH_SHEET_PATH> aSheetPath,
41 std::shared_ptr<SHEET_SYNCHRONIZATION_AGENT> aAgent,
SCH_SHEET* aInitialSheet ) :
56 int initialSelection = -1;
57 int firstUnsyncedPage = -1;
58 std::unordered_map<wxString, std::list<PANEL_SYNC_SHEET_PINS*>> sheet_instances;
60 for(
const auto& sheet_path : aSheetPath )
62 auto sheet = sheet_path.Last();
63 wxString fileName = sheet->GetFileName();
65 ++count, *
m_agent, sheet_path );
67 m_notebook->AddPage( page, sheet->GetShownName(
true ), {}, hasUndefined );
70 if( aInitialSheet && sheet == aInitialSheet )
71 initialSelection = count;
73 if( firstUnsyncedPage < 0 && hasUndefined )
74 firstUnsyncedPage = count;
76 if( sheet_instances.find( fileName ) == sheet_instances.end() )
78 sheet_instances.try_emplace( fileName, std::list<PANEL_SYNC_SHEET_PINS*>{ page } );
82 sheet_instances[fileName].push_back( page );
88 for(
auto& [sheet_name, panel_list] : sheet_instances )
90 if( panel_list.size() > 1 )
92 std::list<std::shared_ptr<SHEET_SYNCHRONIZATION_NOTIFIER>> sheet_change_notifiers;
93 std::list<SHEET_SYNCHRONIZATION_MODEL*> sheet_sync_models;
95 for(
auto& panel : panel_list )
99 sheet_sync_models.push_back(
model );
100 sheet_change_notifiers.push_back(
101 std::make_shared<SHEET_FILE_CHANGE_NOTIFIER>(
model, panel ) );
104 for(
auto& notifier : sheet_change_notifiers )
106 for(
auto& other : sheet_sync_models )
108 if( notifier->GetOwner() != other )
110 other->AddNotifier( notifier );
119 if( initialSelection >= 0 )
121 else if( firstUnsyncedPage >= 0 )
122 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)