39#include <wx/bookctrl.h>
48 wxNotebook* aNoteBook,
int aIndex,
52 m_index( aIndex ), m_sheetFileName( aSheet->GetFileName() ), m_agent( aAgent ),
64 m_labelSheetName->SetLabel( aSheet->GetFileName() );
65 m_labelSymName->SetLabel( aSheet->GetShownName(
true ) );
68 for(
auto& [idx, view] : m_views )
70 auto model = wxObjectDataPtr<SHEET_SYNCHRONIZATION_MODEL>(
72 view->AssociateModel( model.get() );
73 m_models.try_emplace( idx, std::move( model ) );
81 wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_AUTOSIZE );
85 wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_AUTOSIZE );
91 for(
auto& [idx, view] : m_views )
92 PostProcessModelSelection( idx, {} );
103 std::set<wxString> dedup_labels_ori_text;
104 std::vector<SCH_HIERLABEL*> dedup_labels_ori;
106 for(
const auto& item : labels_ori )
110 if( dedup_labels_ori_text.count( label->
GetText() ) == 0 )
112 dedup_labels_ori_text.insert( label->
GetText() );
113 dedup_labels_ori.push_back( label );
117 std::sort( dedup_labels_ori.begin(), dedup_labels_ori.end(),
120 return StrNumCmp( label1->GetText(), label2->GetText(), true ) < 0;
125 for(
size_t i = 0; i < pins_ori.size(); i++ )
129 if( label->GetText() == cur_pin->
GetText() && label->GetShape() == cur_pin->
GetShape() )
131 associated_list.push_back(
132 std::make_shared<ASSOCIATED_SCH_LABEL_PIN>( label, cur_pin ) );
133 pins_ori.erase( pins_ori.begin() + i );
138 labels_list.push_back(
139 std::make_shared<SCH_HIERLABEL_SYNCHRONIZATION_ITEM>( label,
m_sheet ) );
142 for(
const auto& item : dedup_labels_ori )
145 for(
const auto&
pin : pins_ori )
146 pins_list.push_back( std::make_shared<SCH_SHEET_PIN_SYNCHRONIZATION_ITEM>(
185 wxDataViewItemArray selected_items;
186 std::set<EDA_ITEM*> selected_items_set;
189 for(
const auto& it : selected_items )
193 selected_items_set.insert( item->GetItem() );
196 if( selected_items_set.empty() )
206 wxDataViewItemArray selected_items;
207 std::set<EDA_ITEM*> selected_items_set;
210 for(
const auto& it : selected_items )
215 selected_items_set.insert( item->GetItem() );
218 if( selected_items_set.empty() )
230 for(
auto& idx : { labelIdx, pinIdx } )
241 for(
const auto& item : { labelItem, pinItem } )
248 std::static_pointer_cast<SCH_HIERLABEL_SYNCHRONIZATION_ITEM>( labelItem )->GetLabel();
250 std::static_pointer_cast<SCH_SHEET_PIN_SYNCHRONIZATION_ITEM>( pinItem )->GetPin();
259 pin_ptr->SetText( label_ptr->GetText() );
260 pin_ptr->SetShape( label_ptr->GetShape() );
269 label_ptr->SetText( pin_ptr->GetText() );
270 label_ptr->SetShape( pin_ptr->GetShape() );
277 std::make_shared<ASSOCIATED_SCH_LABEL_PIN>( label_ptr, pin_ptr ) );
315 wxDataViewItemArray
array;
326 wxDataViewItemArray
array;
337 wxDataViewItemArray indexes;
344 for(
auto& item : items )
346 auto associated = std::static_pointer_cast<ASSOCIATED_SCH_LABEL_PIN>( item );
348 std::make_shared<SCH_HIERLABEL_SYNCHRONIZATION_ITEM>( associated->GetLabel(),
351 std::make_shared<SCH_SHEET_PIN_SYNCHRONIZATION_ITEM>( associated->GetPin(),
365 m_models[aIdex]->OnRowSelected( {} );
367 const bool has_selected_row =
m_views[aIdex]->GetSelectedItemsCount() > 0;
374 btn->Enable( has_selected_row );
381 btn->Enable( has_selected_row );
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
wxDataViewCtrl * m_viewSheetPins
wxDataViewCtrl * m_viewAssociated
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
SYNC_SHEET_PINT_VIEWS m_views
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.
SCH_SCREEN * GetScreen() const
std::vector< SCH_SHEET_PIN * > & GetPins()
Agent for all the modifications while syncing the sheet pin and hierarchical label.
void PlaceHieraLable(SCH_SHEET *aSheet, SCH_SHEET_PATH const &aPath, std::set< EDA_ITEM * > const &aPins)
void PlaceSheetPin(SCH_SHEET *aSheet, SCH_SHEET_PATH const &aPath, std::set< EDA_ITEM * > const &aLabels)
void ModifyItem(SHEET_SYNCHRONIZATION_ITEM &aItem, std::function< void()> const &aDoModify, const SCH_SHEET_PATH &aPath)
static wxString GetColName(int col)
wxString getElectricalTypeLabel(LABEL_FLAG_SHAPE aType)
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