39#include <wx/bookctrl.h>
43 wxNotebook* aNoteBook,
int aIndex,
48 m_noteBook( aNoteBook ),
50 m_sheetFileName( aSheet->GetFileName() ),
78 std::map<int, wxDataViewCtrl*> view_idx = std::map<int, wxDataViewCtrl*>{
84 for(
auto& [idx, view] : view_idx )
86 auto model = wxObjectDataPtr<SHEET_SYNCHRONIZATION_MODEL>(
88 view->AssociateModel( model.get() );
89 m_models.try_emplace( idx, std::move( model ) );
92 for(
auto& [idx, view] : view_idx )
104 std::set<wxString> dedup_labels_ori_text;
105 std::vector<SCH_HIERLABEL*> dedup_labels_ori;
107 for(
const auto& item : labels_ori )
111 if( dedup_labels_ori_text.count( label->
GetText() ) == 0 )
113 dedup_labels_ori_text.insert( label->
GetText() );
114 dedup_labels_ori.push_back( label );
120 for(
size_t i = 0; i < pins_ori.size(); i++ )
124 if( label->GetText() == cur_pin->
GetText() && label->GetShape() == cur_pin->
GetShape() )
126 associated_list.push_back(
127 std::make_shared<ASSOCIATED_SCH_LABEL_PIN>( label, cur_pin ) );
128 pins_ori.erase( pins_ori.begin() + i );
133 labels_list.push_back(
134 std::make_shared<SCH_HIERLABEL_SYNCHRONIZATION_ITEM>( label,
m_sheet ) );
137 for(
const auto& item : dedup_labels_ori )
140 for(
const auto&
pin : pins_ori )
141 pins_list.push_back( std::make_shared<SCH_SHEET_PIN_SYNCHRONIZATION_ITEM>(
217 for(
auto& idx : { labelIdx, pinIdx } )
228 for(
const auto& item : { labelItem, pinItem } )
235 std::static_pointer_cast<SCH_HIERLABEL_SYNCHRONIZATION_ITEM>( labelItem )->GetLabel();
237 std::static_pointer_cast<SCH_SHEET_PIN_SYNCHRONIZATION_ITEM>( pinItem )->GetPin();
246 pin_ptr->SetText( label_ptr->GetText() );
247 pin_ptr->SetShape( label_ptr->GetShape() );
256 label_ptr->SetText( pin_ptr->GetText() );
257 label_ptr->SetShape( pin_ptr->GetShape() );
264 std::make_shared<ASSOCIATED_SCH_LABEL_PIN>( label_ptr, pin_ptr ) );
302 wxDataViewItemArray
array;
313 wxDataViewItemArray
array;
324 wxDataViewItemArray indexes;
331 for(
auto& item : items )
333 auto associated = std::static_pointer_cast<ASSOCIATED_SCH_LABEL_PIN>( item );
335 std::make_shared<SCH_HIERLABEL_SYNCHRONIZATION_ITEM>( associated->GetLabel(),
338 std::make_shared<SCH_SHEET_PIN_SYNCHRONIZATION_ITEM>( associated->GetPin(),
352 m_models[aIdex]->OnRowSelected( {} );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
virtual const wxString & GetText() const
Return the string associated with the text object.
EE_TYPE OfType(KICAD_T aType) const
Class PANEL_SYNC_SHEET_PINS_BASE.
wxBitmapButton * m_btnUndo
wxButton * m_btnAddSheetPins
wxButton * m_btnAddLabels
wxStaticText * m_labelSheetName
wxDataViewCtrl * m_viewSheetPins
wxDataViewCtrl * m_viewAssociated
wxStaticText * m_labelSymName
wxBitmapButton * m_btnUseLabelAsTemplate
wxDataViewCtrl * m_viewSheetLabels
wxBitmapButton * m_btnUsePinAsTemplate
SHEET_SYNCHRONIZATION_MODEL_PTR GetModel(int aKind) const
void PostProcessModelSelection(int aIdex, wxDataViewItem const &aItem)
void OnBtnUsePinAsTemplateClicked(wxCommandEvent &event) override
void OnBtnRmPinsClicked(wxCommandEvent &event) override
void UpdatePageImage() const
void GenericSync(SYNC_DIRECTION direction)
void OnBtnAddLabelsClicked(wxCommandEvent &event) override
void OnViewSheetLabelCellClicked(wxDataViewEvent &event) override
void OnViewMatchedCellClicked(wxDataViewEvent &event) override
const wxString & GetSheetFileName() const
bool HasUndefinedSheetPing() const
void OnBtnUseLabelAsTemplateClicked(wxCommandEvent &event) override
void OnBtnRmLabelsClicked(wxCommandEvent &event) override
~PANEL_SYNC_SHEET_PINS() override
void OnBtnAddSheetPinsClicked(wxCommandEvent &event) override
void OnBtnUndoClicked(wxCommandEvent &event) override
SHEET_SYNCHRONIZATION_AGENT & m_agent
PANEL_SYNC_SHEET_PINS(wxWindow *aParent, SCH_SHEET *aSheet, wxNotebook *aNoteBook, int aIndex, SHEET_SYNCHRONIZATION_AGENT &aAgent, const SCH_SHEET_PATH &aPath)
void OnViewSheetPinCellClicked(wxDataViewEvent &event) override
SYNC_SHEET_PINT_MODELS m_models
LABEL_FLAG_SHAPE GetShape() const
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
wxString GetFileName() const
Return the filename corresponding to this sheet.
SCH_SCREEN * GetScreen() const
std::vector< SCH_SHEET_PIN * > & GetPins()
wxString GetShownName(bool aAllowExtraText) const
Agent for all the modifications while syncing the sheet pin and hierarchical label.
void PlaceHieraLable(SCH_SHEET *aSheet, SCH_SHEET_PATH const &aPath, SCH_SHEET_PIN *aPin)
void ModifyItem(SHEET_SYNCHRONIZATION_ITEM &aItem, std::function< void()> const &aDoModify, const SCH_SHEET_PATH &aPath)
void PlaceSheetPin(SCH_SHEET *aSheet, SCH_SHEET_PATH const &aPath, SCH_HIERLABEL *aLabel)
static wxString GetColName(int col)
wxObjectDataPtr< SHEET_SYNCHRONIZATION_MODEL > SHEET_SYNCHRONIZATION_MODEL_PTR
std::vector< SHEET_SYNCHRONIZATION_ITE_PTR > SHEET_SYNCHRONIZATION_ITEM_LIST
std::shared_ptr< SHEET_SYNCHRONIZATION_ITEM > SHEET_SYNCHRONIZATION_ITE_PTR