From 08e0d8d98ae24b53f06bbe93d2fdea2e154ed9b4 Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Sat, 7 Oct 2023 08:30:29 +0300 Subject: [PATCH] ADDED: Manager dialog for generative objects. --- pcbnew/CMakeLists.txt | 2 + pcbnew/dialogs/dialog_generators.cpp | 467 ++++++++++++++++++++ pcbnew/dialogs/dialog_generators.h | 84 ++++ pcbnew/dialogs/dialog_generators_base.cpp | 101 +++++ pcbnew/dialogs/dialog_generators_base.fbp | 502 ++++++++++++++++++++++ pcbnew/dialogs/dialog_generators_base.h | 68 +++ pcbnew/tools/pcb_actions.cpp | 8 + pcbnew/tools/pcb_actions.h | 2 + 8 files changed, 1234 insertions(+) create mode 100644 pcbnew/dialogs/dialog_generators.cpp create mode 100644 pcbnew/dialogs/dialog_generators.h create mode 100644 pcbnew/dialogs/dialog_generators_base.cpp create mode 100644 pcbnew/dialogs/dialog_generators_base.fbp create mode 100644 pcbnew/dialogs/dialog_generators_base.h diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 3cdf340f2c..44caf5778b 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -82,6 +82,8 @@ set( PCBNEW_DIALOGS dialogs/dialog_gencad_export_options.cpp dialogs/dialog_gendrill.cpp dialogs/dialog_gendrill_base.cpp + dialogs/dialog_generators.cpp + dialogs/dialog_generators_base.cpp dialogs/dialog_get_footprint_by_name_base.cpp dialogs/dialog_global_deletion.cpp dialogs/dialog_global_deletion_base.cpp diff --git a/pcbnew/dialogs/dialog_generators.cpp b/pcbnew/dialogs/dialog_generators.cpp new file mode 100644 index 0000000000..f341bd2df2 --- /dev/null +++ b/pcbnew/dialogs/dialog_generators.cpp @@ -0,0 +1,467 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2023 Alex Shvartzkop + * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "dialog_generators.h" + +#include +#include +#include +#include +#include +#include + + +void DIALOG_GENERATORS::clearModels() +{ + for( auto& [name, ptr] : m_dataModels ) + { + if( ptr ) + ptr->DecRef(); + } + + m_dataModels.clear(); + m_columnNameTypes.clear(); + m_dataViews.clear(); +} + + +void DIALOG_GENERATORS::clearModel( const wxString& aName ) +{ + if( m_dataModels[aName] ) + { + m_dataModels[aName]->DeleteAllItems(); + m_dataModels[aName]->ClearColumns(); + } + + m_columnNameTypes[aName].clear(); +} + + +void DIALOG_GENERATORS::deleteModel( const wxString& aName ) +{ + if( m_dataModels[aName] ) + m_dataModels[aName]->DecRef(); + + for( size_t i = 0; i < m_Notebook->GetPageCount(); i++ ) + { + wxWindow* page = m_Notebook->GetPage( i ); + if( page->GetName() == aName ) + { + m_Notebook->DeletePage( i ); + break; + } + } + + m_dataViews.erase( aName ); + m_dataModels.erase( aName ); + m_columnNameTypes.erase( aName ); +} + + +void DIALOG_GENERATORS::RebuildModels() +{ + wxString lastPageName; + std::set lastUUIDs; + + if( auto page = m_Notebook->GetCurrentPage() ) + { + lastPageName = page->GetName(); + wxDataViewCtrl* dataView = m_dataViews[lastPageName]; + + int uuidCol = dataView->GetColumnCount() - 1; + + wxDataViewItemArray selections; + dataView->GetSelections( selections ); + + for( wxDataViewItem& item : selections ) + { + wxVariant var; + dataView->GetModel()->GetValue( var, item, uuidCol ); + lastUUIDs.emplace( var.GetString() ); + } + } + + int newPageId = -1; + + std::map>>> dataMap; + + for( PCB_GENERATOR* gen : m_currentBoard->Generators() ) + { + std::vector> rowData = gen->GetRowData(); + + const KIID uuid = gen->m_Uuid; + rowData.emplace_back( wxS( "UUID" ), uuid.AsString() ); + + dataMap[gen->GetName()][uuid] = rowData; + } + + std::vector toDelete; + for( size_t i = 0; i < m_Notebook->GetPageCount(); i++ ) + { + wxWindow* page = m_Notebook->GetPage( i ); + + if( dataMap.find(page->GetName()) == dataMap.end() ) + { + toDelete.emplace_back( page->GetName() ); + } + } + + for( const wxString& name : toDelete ) + deleteModel( name ); + + for( auto& [typeName, uuidToRowMap] : dataMap ) + { + bool exists = false; + for( size_t i = 0; i < m_Notebook->GetPageCount(); i++ ) + { + if( m_Notebook->GetPage( i )->GetName() == typeName ) + { + exists = true; + break; + } + } + + if( exists ) + { + clearModel( typeName ); + } + else + { + wxString title = typeName + wxString::Format( " (%d)", int( uuidToRowMap.size() ) ); + addPage( typeName, title ); + } + } + + for( auto& [typeName, uuidToRowMap] : dataMap ) + { + std::vector>& thisColNameTypes = m_columnNameTypes[typeName]; + std::map nameToColIdMap; + std::set columnsSet; + + for( auto& [uuid, rowMap] : uuidToRowMap ) + { + for( auto& [colName, value] : rowMap ) + { + if( columnsSet.find( colName ) == columnsSet.end() ) + { + int colId = columnsSet.size(); + columnsSet.emplace( colName ); + + nameToColIdMap[colName] = colId; + thisColNameTypes.emplace_back( colName, "string" ); + } + } + } + + wxDataViewListStore* store = new wxDataViewListStore(); + + for( auto& [name, type] : thisColNameTypes ) + store->AppendColumn( type ); + + int colCount = thisColNameTypes.size(); + + for( auto& [uuid, rowMap] : uuidToRowMap ) + { + wxVector values( colCount ); + + for( auto& [dataName, value] : rowMap ) + { + values[nameToColIdMap[dataName]] = value; + } + + store->AppendItem( values ); + } + + m_dataModels[typeName] = store; + } + + m_Notebook->DeleteAllPages(); + + int pageId = 0; + for( auto& [typeName, model] : m_dataModels ) + { + wxString title = typeName + wxString::Format( " (%d)", model->GetItemCount() ); + wxDataViewCtrl* dataView = addPage( typeName, title ); + + if( typeName == lastPageName ) + newPageId = pageId; + + dataView->AssociateModel( model ); + + int colId = 0; + for( auto& [name, type] : m_columnNameTypes[typeName] ) + { + int flags = wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE; + + if( name == wxS( "UUID" ) ) + flags |= wxDATAVIEW_COL_HIDDEN; + + dataView->AppendTextColumn( name, colId, wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_AUTOSIZE, + wxALIGN_LEFT, flags ); + + colId++; + } + + m_dataViews[typeName] = dataView; + + pageId++; + } + + if( newPageId != -1 ) + { + m_Notebook->SetSelection( newPageId ); + + wxDataViewCtrl* dataView = m_dataViews[lastPageName]; + int uuidCol = dataView->GetColumnCount() - 1; + wxDataViewListStore* model = m_dataModels[lastPageName]; + size_t itemCount = model->GetItemCount(); + wxDataViewItemArray newSelections; + + for( size_t itemId = 0; itemId < itemCount; itemId++ ) + { + wxVariant var; + model->GetValueByRow( var, itemId, uuidCol ); + + if( lastUUIDs.find( var.GetString() ) != lastUUIDs.end() ) + newSelections.push_back( model->GetItem( itemId ) ); + } + + dataView->SetSelections( newSelections ); + } +} + + +wxDataViewCtrl* DIALOG_GENERATORS::addPage( const wxString& aName, const wxString& aTitle ) +{ + wxPanel* panelPage = + new wxPanel( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + + panelPage->SetName( aName ); + + wxBoxSizer* bSizerPage1; + bSizerPage1 = new wxBoxSizer( wxVERTICAL ); + + bSizerPage1->SetMinSize( wxSize( -1, 320 ) ); + wxDataViewCtrl* dataView = new wxDataViewCtrl( panelPage, wxID_ANY, wxDefaultPosition, + wxDefaultSize, wxDV_MULTIPLE | wxDV_ROW_LINES ); + + dataView->Bind( wxEVT_DATAVIEW_SELECTION_CHANGED, &DIALOG_GENERATORS::OnItemSelected, this ); + + bSizerPage1->Add( dataView, 1, wxEXPAND | wxALL, 5 ); + + + bSizerPage1->Add( 0, 8, 0, wxEXPAND, 5 ); + + + panelPage->SetSizer( bSizerPage1 ); + panelPage->Layout(); + bSizerPage1->Fit( panelPage ); + m_Notebook->AddPage( panelPage, aTitle, false ); + + return dataView; +} + + +void DIALOG_GENERATORS::onUnitsChanged( wxCommandEvent& event ) +{ + m_units = m_frame->GetUserUnits(); + + RebuildModels(); + + event.Skip(); +} + + +void DIALOG_GENERATORS::onBoardChanged( wxCommandEvent& event ) +{ + m_currentBoard = m_frame->GetBoard(); + + if( m_currentBoard != nullptr ) + m_currentBoard->AddListener( this ); + + RebuildModels(); + + event.Skip(); +} + + +void DIALOG_GENERATORS::OnBoardItemAdded( BOARD& aBoard, BOARD_ITEM* aBoardItem ) +{ + RebuildModels(); +} + + +void DIALOG_GENERATORS::OnBoardItemsAdded( BOARD& aBoard, std::vector& aBoardItems ) +{ + RebuildModels(); +} + + +void DIALOG_GENERATORS::OnBoardItemRemoved( BOARD& aBoard, BOARD_ITEM* aBoardItem ) +{ + RebuildModels(); +} + + +void DIALOG_GENERATORS::OnBoardItemsRemoved( BOARD& aBoard, std::vector& aBoardItems ) +{ + RebuildModels(); +} + + +void DIALOG_GENERATORS::OnBoardItemChanged( BOARD& aBoard, BOARD_ITEM* aBoardItem ) +{ + RebuildModels(); +} + + +void DIALOG_GENERATORS::OnBoardItemsChanged( BOARD& aBoard, std::vector& aBoardItems ) +{ + RebuildModels(); +} + + +DIALOG_GENERATORS::DIALOG_GENERATORS( PCB_EDIT_FRAME* aEditorFrame, wxWindow* aParent ) : + DIALOG_GENERATORS_BASE( aParent ) +{ + SetName( DIALOG_GENERATORS_WINDOW_NAME ); + + m_frame = aEditorFrame; + m_currentBoard = m_frame->GetBoard(); + + m_Notebook->DeleteAllPages(); + + RebuildModels(); + + Bind( EDA_EVT_UNITS_CHANGED, &DIALOG_GENERATORS::onUnitsChanged, this ); + Bind( EDA_EVT_BOARD_CHANGED, &DIALOG_GENERATORS::onBoardChanged, this ); + + if( m_currentBoard != nullptr ) + { + m_currentBoard->AddListener( this ); + } +} + + +DIALOG_GENERATORS::~DIALOG_GENERATORS() +{ + clearModels(); + + if( m_currentBoard != nullptr ) + m_currentBoard->RemoveListener( this ); +} + + +wxDataViewListStore* DIALOG_GENERATORS::getCurrentModel() +{ + wxString pageName = m_Notebook->GetCurrentPage()->GetName(); + return m_dataModels[pageName]; +} + + +void DIALOG_GENERATORS::OnItemSelected( wxDataViewEvent& aEvent ) +{ + wxDataViewListStore* model = getCurrentModel(); + wxString pageName = m_Notebook->GetCurrentPage()->GetName(); + wxDataViewCtrl* dataView = m_dataViews[pageName]; + + if( !model ) + return; + + int uuidCol = dataView->GetColumnCount() - 1; + std::vector boardItems; + EDA_ITEMS edaItems; + + wxDataViewItemArray selections; + dataView->GetSelections( selections ); + + for( wxDataViewItem& viewItem : selections ) + { + wxVariant var; + model->GetValue( var, viewItem, uuidCol ); + + BOARD_ITEM* brdItem = m_currentBoard->GetItem( var.GetString() ); + + if( !brdItem || brdItem->Type() != KICAD_T::PCB_GENERATOR_T ) + continue; + + boardItems.push_back( brdItem ); + edaItems.push_back( brdItem ); + } + + m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear ); + m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectItems, &edaItems ); + m_frame->FocusOnItems( boardItems ); +} + + +void DIALOG_GENERATORS::OnRebuildSelectedClick( wxCommandEvent& event ) +{ + RebuildModels(); +} + + +void DIALOG_GENERATORS::OnRebuildTypeClick( wxCommandEvent& event ) +{ + wxDataViewListStore* model = getCurrentModel(); + wxString pageName = m_Notebook->GetCurrentPage()->GetName(); + + if( !model ) + return; + + int uuidCol = m_columnNameTypes[pageName].size() - 1; + EDA_ITEMS items; + + for( size_t row = 0; row < model->GetItemCount(); row++ ) + { + wxVariant var; + model->GetValueByRow( var, row, uuidCol ); + + BOARD_ITEM* item = m_currentBoard->GetItem( var.GetString() ); + + if( !item || item->Type() != KICAD_T::PCB_GENERATOR_T ) + continue; + + items.push_back( item ); + } + + m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear ); + m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectItems, &items ); + m_frame->GetToolManager()->RunAction( PCB_ACTIONS::regenerateSelected ); + RebuildModels(); +} + + +void DIALOG_GENERATORS::OnRebuildAllClick( wxCommandEvent& event ) +{ + m_frame->GetToolManager()->RunAction( PCB_ACTIONS::regenerateAll ); + RebuildModels(); +} + + +void DIALOG_GENERATORS::OnCancelClick( wxCommandEvent& event ) +{ + GENERATOR_TOOL* genTool = m_frame->GetToolManager()->GetTool(); + genTool->DestroyManagerDialog(); +} diff --git a/pcbnew/dialogs/dialog_generators.h b/pcbnew/dialogs/dialog_generators.h new file mode 100644 index 0000000000..3b33431159 --- /dev/null +++ b/pcbnew/dialogs/dialog_generators.h @@ -0,0 +1,84 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2023 Alex Shvartzkop + * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef DIALOG_GENERATORS_H_ +#define DIALOG_GENERATORS_H_ + +#include "dialog_generators_base.h" +#include +#include + +class PCB_EDIT_FRAME; + +#define DIALOG_GENERATORS_WINDOW_NAME wxT( "DialogGeneratorsWindowName" ) + + +class DIALOG_GENERATORS : public DIALOG_GENERATORS_BASE, public BOARD_LISTENER +{ +public: + DIALOG_GENERATORS( PCB_EDIT_FRAME* aEditorFrame, wxWindow* aParent ); + ~DIALOG_GENERATORS(); + + void RebuildModels(); + +private: + void OnItemSelected( wxDataViewEvent& aEvent ); + + void OnRebuildSelectedClick( wxCommandEvent& event ) override; + void OnRebuildTypeClick( wxCommandEvent& event ) override; + void OnRebuildAllClick( wxCommandEvent& event ) override; + + void OnCancelClick( wxCommandEvent& aEvent ) override; + + wxDataViewListStore* getCurrentModel(); + void clearModels(); + + void clearModel( const wxString& aName ); + + void deleteModel( const wxString& aName ); + + wxDataViewCtrl* addPage( const wxString& aName, const wxString& aTitle ); + + void onUnitsChanged( wxCommandEvent& event ); + void onBoardChanged( wxCommandEvent& event ); + + virtual void OnBoardItemAdded( BOARD& aBoard, BOARD_ITEM* aBoardItem ) override; + virtual void OnBoardItemsAdded( BOARD& aBoard, std::vector& aBoardItems ) override; + virtual void OnBoardItemRemoved( BOARD& aBoard, BOARD_ITEM* aBoardItem ) override; + virtual void OnBoardItemsRemoved( BOARD& aBoard, + std::vector& aBoardItems ) override; + virtual void OnBoardItemChanged( BOARD& aBoard, BOARD_ITEM* aBoardItem ) override; + virtual void OnBoardItemsChanged( BOARD& aBoard, + std::vector& aBoardItems ) override; + + std::map>> m_columnNameTypes; + std::map m_dataModels; + std::map m_dataViews; + + BOARD* m_currentBoard; + PCB_EDIT_FRAME* m_frame; +}; + + +#endif // DIALOG_GENERATORS_H_ \ No newline at end of file diff --git a/pcbnew/dialogs/dialog_generators_base.cpp b/pcbnew/dialogs/dialog_generators_base.cpp new file mode 100644 index 0000000000..d1d9a0d8bb --- /dev/null +++ b/pcbnew/dialogs/dialog_generators_base.cpp @@ -0,0 +1,101 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "dialog_generators_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DIALOG_GENERATORS_BASE::DIALOG_GENERATORS_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize ); + + wxBoxSizer* m_MainSizer; + m_MainSizer = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bSizer13; + bSizer13 = new wxBoxSizer( wxVERTICAL ); + + m_Notebook = new wxNotebook( this, ID_NOTEBOOK1, wxDefaultPosition, wxDefaultSize, 0 ); + m_Notebook->SetMinSize( wxSize( 640,-1 ) ); + + m_panelPage1 = new wxPanel( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizerPage1; + bSizerPage1 = new wxBoxSizer( wxVERTICAL ); + + bSizerPage1->SetMinSize( wxSize( -1,320 ) ); + m_dataview1 = new wxDataViewCtrl( m_panelPage1, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + m_dataview1->SetToolTip( _("Click on items to highlight them on the board.") ); + + bSizerPage1->Add( m_dataview1, 1, wxEXPAND|wxALL, 5 ); + + + bSizerPage1->Add( 0, 8, 0, wxEXPAND, 5 ); + + + m_panelPage1->SetSizer( bSizerPage1 ); + m_panelPage1->Layout(); + bSizerPage1->Fit( m_panelPage1 ); + m_Notebook->AddPage( m_panelPage1, _("Generators A (%s)"), false ); + + bSizer13->Add( m_Notebook, 1, wxEXPAND, 10 ); + + + m_MainSizer->Add( bSizer13, 1, wxEXPAND, 5 ); + + m_sizerButtons = new wxBoxSizer( wxHORIZONTAL ); + + m_rebuildSelected = new wxButton( this, wxID_ANY, _("Rebuild selected"), wxDefaultPosition, wxDefaultSize, 0 ); + m_sizerButtons->Add( m_rebuildSelected, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 ); + + m_rebuildThisType = new wxButton( this, wxID_ANY, _("Rebuild this type"), wxDefaultPosition, wxDefaultSize, 0 ); + m_rebuildThisType->Hide(); + + m_sizerButtons->Add( m_rebuildThisType, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 ); + + + m_sizerButtons->Add( 0, 8, 1, wxEXPAND, 5 ); + + m_rebuildAll = new wxButton( this, wxID_ANY, _("Rebuild All"), wxDefaultPosition, wxDefaultSize, 0 ); + m_sizerButtons->Add( m_rebuildAll, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + + m_sdbSizer = new wxStdDialogButtonSizer(); + m_sdbSizerCancel = new wxButton( this, wxID_CANCEL ); + m_sdbSizer->AddButton( m_sdbSizerCancel ); + m_sdbSizer->Realize(); + + m_sizerButtons->Add( m_sdbSizer, 0, wxEXPAND|wxALL, 5 ); + + + m_MainSizer->Add( m_sizerButtons, 0, wxEXPAND|wxLEFT, 5 ); + + + this->SetSizer( m_MainSizer ); + this->Layout(); + m_MainSizer->Fit( this ); + + // Connect Events + this->Connect( wxEVT_ACTIVATE, wxActivateEventHandler( DIALOG_GENERATORS_BASE::OnActivateDlg ) ); + this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_GENERATORS_BASE::OnClose ) ); + m_Notebook->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_GENERATORS_BASE::OnChangingNotebookPage ), NULL, this ); + m_rebuildSelected->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GENERATORS_BASE::OnRebuildSelectedClick ), NULL, this ); + m_rebuildThisType->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GENERATORS_BASE::OnRebuildTypeClick ), NULL, this ); + m_rebuildAll->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GENERATORS_BASE::OnRebuildAllClick ), NULL, this ); + m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GENERATORS_BASE::OnCancelClick ), NULL, this ); +} + +DIALOG_GENERATORS_BASE::~DIALOG_GENERATORS_BASE() +{ + // Disconnect Events + this->Disconnect( wxEVT_ACTIVATE, wxActivateEventHandler( DIALOG_GENERATORS_BASE::OnActivateDlg ) ); + this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_GENERATORS_BASE::OnClose ) ); + m_Notebook->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_GENERATORS_BASE::OnChangingNotebookPage ), NULL, this ); + m_rebuildSelected->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GENERATORS_BASE::OnRebuildSelectedClick ), NULL, this ); + m_rebuildThisType->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GENERATORS_BASE::OnRebuildTypeClick ), NULL, this ); + m_rebuildAll->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GENERATORS_BASE::OnRebuildAllClick ), NULL, this ); + m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GENERATORS_BASE::OnCancelClick ), NULL, this ); + +} diff --git a/pcbnew/dialogs/dialog_generators_base.fbp b/pcbnew/dialogs/dialog_generators_base.fbp new file mode 100644 index 0000000000..0f09992eb7 --- /dev/null +++ b/pcbnew/dialogs/dialog_generators_base.fbp @@ -0,0 +1,502 @@ + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + dialog_generators_base + 1000 + none + + + 1 + dialog_generators_base + + . + + 1 + 1 + 1 + 1 + UI + 0 + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + -1,-1 + DIALOG_GENERATORS_BASE + + -1,-1 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h + Generator Objects + + 0 + + + + OnActivateDlg + OnClose + + + m_MainSizer + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + + bSizer13 + wxVERTICAL + none + + 10 + wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_NOTEBOOK1 + + 0 + + + 0 + 640,-1 + 1 + m_Notebook + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + OnChangingNotebookPage + + + Generators A (%s) + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_panelPage1 + 1 + + + protected + 1 + + Resizable + 1 + + ; + 0 + + + + wxTAB_TRAVERSAL + + -1,320 + bSizerPage1 + wxVERTICAL + none + + 5 + wxEXPAND|wxALL + 1 + + + + 1 + 1 + + + 0 + wxID_ANY + + + m_dataview1 + protected + + + + ; ; forward_declare + Click on items to highlight them on the board. + + + + + + + 5 + wxEXPAND + 0 + + 8 + protected + 0 + + + + + + + + + + + 5 + wxEXPAND|wxLEFT + 0 + + + m_sizerButtons + wxHORIZONTAL + protected + + 5 + wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Rebuild selected + + 0 + + 0 + + + 0 + + 1 + m_rebuildSelected + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnRebuildSelectedClick + + + + 5 + wxTOP|wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 1 + wxID_ANY + Rebuild this type + + 0 + + 0 + + + 0 + + 1 + m_rebuildThisType + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnRebuildTypeClick + + + + 5 + wxEXPAND + 1 + + 8 + protected + 0 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Rebuild All + + 0 + + 0 + + + 0 + + 1 + m_rebuildAll + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnRebuildAllClick + + + + 5 + wxEXPAND|wxALL + 0 + + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + + m_sdbSizer + protected + OnCancelClick + + + + + + + + diff --git a/pcbnew/dialogs/dialog_generators_base.h b/pcbnew/dialogs/dialog_generators_base.h new file mode 100644 index 0000000000..6181b2b3e7 --- /dev/null +++ b/pcbnew/dialogs/dialog_generators_base.h @@ -0,0 +1,68 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include +#include "dialog_shim.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + +#define ID_NOTEBOOK1 1000 + +/////////////////////////////////////////////////////////////////////////////// +/// Class DIALOG_GENERATORS_BASE +/////////////////////////////////////////////////////////////////////////////// +class DIALOG_GENERATORS_BASE : public DIALOG_SHIM +{ + private: + + protected: + wxNotebook* m_Notebook; + wxPanel* m_panelPage1; + wxDataViewCtrl* m_dataview1; + wxBoxSizer* m_sizerButtons; + wxButton* m_rebuildSelected; + wxButton* m_rebuildThisType; + wxButton* m_rebuildAll; + wxStdDialogButtonSizer* m_sdbSizer; + wxButton* m_sdbSizerCancel; + + // Virtual event handlers, override them in your derived class + virtual void OnActivateDlg( wxActivateEvent& event ) { event.Skip(); } + virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } + virtual void OnChangingNotebookPage( wxNotebookEvent& event ) { event.Skip(); } + virtual void OnRebuildSelectedClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnRebuildTypeClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnRebuildAllClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } + + + public: + + DIALOG_GENERATORS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Generator Objects"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + + ~DIALOG_GENERATORS_BASE(); + +}; + diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index 50b4e6f38b..5524dcef9f 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -2418,6 +2418,14 @@ TOOL_ACTION PCB_ACTIONS::genRemove( TOOL_ACTION_ARGS() .Scope( AS_CONTEXT ) ); +TOOL_ACTION PCB_ACTIONS::generatorsShowManager( TOOL_ACTION_ARGS() + .Name( "pcbnew.Generator.showManager" ) + .Scope( AS_GLOBAL ) + .MenuText( _( "Generators Manager" ) ) + .Tooltip( _( "Show a manager dialog for Generator objects" ) ) + .Icon( BITMAPS::pin_table ) ); + + // LENGTH_TUNER_TOOL // TOOL_ACTION PCB_ACTIONS::ddAppendBoard( TOOL_ACTION_ARGS() diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index 0624812f76..320ce4818f 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -281,6 +281,8 @@ public: static TOOL_ACTION genRevertEdit; static TOOL_ACTION genRemove; + static TOOL_ACTION generatorsShowManager; + // Point Editor static TOOL_ACTION pointEditorAddCorner; static TOOL_ACTION pointEditorRemoveCorner;