66 for(
size_t i = 0; i <
m_Notebook->GetPageCount(); i++ )
69 if( page->GetName() == aName )
84 wxString lastPageName;
85 std::set<wxString> lastUUIDs;
89 lastPageName = page->GetName();
90 wxDataViewCtrl* dataView =
m_dataViews[lastPageName];
92 int uuidCol = dataView->GetColumnCount() - 1;
94 wxDataViewItemArray selections;
95 dataView->GetSelections( selections );
97 for( wxDataViewItem& item : selections )
100 dataView->GetModel()->GetValue( var, item, uuidCol );
101 lastUUIDs.emplace( var.GetString() );
107 std::map<wxString, std::map<KIID, std::vector<std::pair<wxString, wxVariant>>>> dataMap;
111 std::vector<std::pair<wxString, wxVariant>> rowData = gen->GetRowData();
113 const KIID uuid = gen->m_Uuid;
114 rowData.emplace_back( wxS(
"UUID" ), uuid.
AsString() );
116 dataMap[gen->GetName()][uuid] = rowData;
119 std::vector<wxString> toDelete;
120 for(
size_t i = 0; i <
m_Notebook->GetPageCount(); i++ )
124 if( dataMap.find(page->GetName()) == dataMap.end() )
126 toDelete.emplace_back( page->GetName() );
130 for(
const wxString&
name : toDelete )
133 for(
auto& [typeName, uuidToRowMap] : dataMap )
136 for(
size_t i = 0; i <
m_Notebook->GetPageCount(); i++ )
138 if(
m_Notebook->GetPage( i )->GetName() == typeName )
151 wxString title = typeName + wxString::Format(
" (%d)",
int( uuidToRowMap.size() ) );
156 for(
auto& [typeName, uuidToRowMap] : dataMap )
158 std::vector<std::pair<wxString, wxString>>& thisColNameTypes =
m_columnNameTypes[typeName];
159 std::map<wxString, int> nameToColIdMap;
160 std::set<wxString> columnsSet;
162 for(
auto& [uuid, rowMap] : uuidToRowMap )
164 for(
auto& [colName, value] : rowMap )
166 if( columnsSet.find( colName ) == columnsSet.end() )
168 int colId = columnsSet.size();
169 columnsSet.emplace( colName );
171 nameToColIdMap[colName] = colId;
172 thisColNameTypes.emplace_back( colName,
"string" );
177 wxDataViewListStore* store =
new wxDataViewListStore();
179 for(
auto& [
name, type] : thisColNameTypes )
180 store->AppendColumn( type );
182 int colCount = thisColNameTypes.size();
184 for(
auto& [uuid, rowMap] : uuidToRowMap )
186 wxVector<wxVariant> values( colCount );
188 for(
auto& [dataName, value] : rowMap )
190 values[nameToColIdMap[dataName]] = value;
193 store->AppendItem( values );
204 wxString title = typeName + wxString::Format(
" (%d)", model->GetItemCount() );
205 wxDataViewCtrl* dataView =
addPage( typeName, title );
207 if( typeName == lastPageName )
210 dataView->AssociateModel( model );
215 int flags = wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE;
217 if(
name == wxS(
"UUID" ) )
218 flags |= wxDATAVIEW_COL_HIDDEN;
220 dataView->AppendTextColumn(
name, colId, wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_AUTOSIZE,
221 wxALIGN_LEFT, flags );
231 if( newPageId != -1 )
235 wxDataViewCtrl* dataView =
m_dataViews[lastPageName];
236 int uuidCol = dataView->GetColumnCount() - 1;
237 wxDataViewListStore* model =
m_dataModels[lastPageName];
238 size_t itemCount = model->GetItemCount();
239 wxDataViewItemArray newSelections;
241 for(
size_t itemId = 0; itemId < itemCount; itemId++ )
244 model->GetValueByRow( var, itemId, uuidCol );
246 if( lastUUIDs.find( var.GetString() ) != lastUUIDs.end() )
247 newSelections.push_back( model->GetItem( itemId ) );
250 dataView->SetSelections( newSelections );
258 new wxPanel(
m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
260 panelPage->SetName( aName );
262 wxBoxSizer* bSizerPage1;
263 bSizerPage1 =
new wxBoxSizer( wxVERTICAL );
265 bSizerPage1->SetMinSize( wxSize( -1, 320 ) );
266 wxDataViewCtrl* dataView =
new wxDataViewCtrl( panelPage, wxID_ANY, wxDefaultPosition,
267 wxDefaultSize, wxDV_MULTIPLE | wxDV_ROW_LINES );
271 bSizerPage1->Add( dataView, 1, wxEXPAND | wxALL, 5 );
274 bSizerPage1->Add( 0, 8, 0, wxEXPAND, 5 );
277 panelPage->SetSizer( bSizerPage1 );
279 bSizerPage1->Fit( panelPage );
280 m_Notebook->AddPage( panelPage, aTitle,
false );
346 std::vector<BOARD_ITEM*>& aAddedItems,
347 std::vector<BOARD_ITEM*>& aRemovedItems,
348 std::vector<BOARD_ITEM*>& aDeletedItems )
387 wxString pageName =
m_Notebook->GetCurrentPage()->GetName();
395 wxString pageName =
m_Notebook->GetCurrentPage()->GetName();
401 int uuidCol = dataView->GetColumnCount() - 1;
402 std::vector<BOARD_ITEM*> boardItems;
405 wxDataViewItemArray selections;
406 dataView->GetSelections( selections );
408 for( wxDataViewItem& viewItem : selections )
411 model->GetValue( var, viewItem, uuidCol );
415 if( !brdItem || brdItem->
Type() != KICAD_T::PCB_GENERATOR_T )
418 boardItems.push_back( brdItem );
419 edaItems.push_back( brdItem );
437 wxString pageName =
m_Notebook->GetCurrentPage()->GetName();
445 for(
size_t row = 0; row < model->GetItemCount(); row++ )
448 model->GetValueByRow( var, row, uuidCol );
452 if( !item || item->
Type() != KICAD_T::PCB_GENERATOR_T )
455 items.push_back( item );
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Information pertinent to a Pcbnew printed circuit board.
const GENERATORS & Generators() const
void AddListener(BOARD_LISTENER *aListener)
Add a listener to the board to receive calls whenever something on the board has been modified.
BOARD_ITEM * GetItem(const KIID &aID) const
void RemoveListener(BOARD_LISTENER *aListener)
Remove the specified listener.
Class DIALOG_GENERATORS_BASE.
void OnRebuildTypeClick(wxCommandEvent &event) override
virtual void OnBoardItemsChanged(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems) override
DIALOG_GENERATORS(PCB_EDIT_FRAME *aEditorFrame, wxWindow *aParent)
void OnRebuildSelectedClick(wxCommandEvent &event) override
wxDataViewCtrl * addPage(const wxString &aName, const wxString &aTitle)
void OnItemSelected(wxDataViewEvent &aEvent)
void deleteModel(const wxString &aName)
std::map< wxString, wxDataViewListStore * > m_dataModels
void OnCancelClick(wxCommandEvent &aEvent) override
void clearModel(const wxString &aName)
void OnRebuildAllClick(wxCommandEvent &event) override
virtual void OnBoardCompositeUpdate(BOARD &aBoard, std::vector< BOARD_ITEM * > &aAddedItems, std::vector< BOARD_ITEM * > &aRemovedItems, std::vector< BOARD_ITEM * > &aDeletedItems) override
virtual void OnBoardItemRemoved(BOARD &aBoard, BOARD_ITEM *aBoardItem) override
virtual void OnBoardItemAdded(BOARD &aBoard, BOARD_ITEM *aBoardItem) override
wxDataViewListStore * getCurrentModel()
std::map< wxString, wxDataViewCtrl * > m_dataViews
void onUnitsChanged(wxCommandEvent &event)
std::map< wxString, std::vector< std::pair< wxString, wxString > > > m_columnNameTypes
virtual void OnBoardItemsAdded(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems) override
virtual void OnBoardItemsRemoved(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems) override
virtual void OnBoardItemChanged(BOARD &aBoard, BOARD_ITEM *aBoardItem) override
void onBoardChanged(wxCommandEvent &event)
KICAD_T Type() const
Returns the type of object.
wxString AsString() const
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION regenerateAll
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
static TOOL_ACTION regenerateSelected
void FocusOnItems(std::vector< BOARD_ITEM * > aItems, PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
The main frame for Pcbnew.
EDA_UNITS GetUserUnits() const
#define DIALOG_GENERATORS_WINDOW_NAME
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.