From 546c7ed218b783f311f7716ca80b0cc9ef42c07e Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Sat, 7 Oct 2023 04:19:25 +0300 Subject: [PATCH] Introduce GENERATOR_TOOL. --- pcbnew/CMakeLists.txt | 7 + pcbnew/pcb_edit_frame.cpp | 2 + pcbnew/router/pns_kicad_iface.cpp | 40 ++-- pcbnew/router/pns_kicad_iface.h | 7 +- pcbnew/router/pns_tool_base.cpp | 6 + pcbnew/router/pns_tool_base.h | 2 + pcbnew/tools/generator_tool.cpp | 269 ++++++++++++++++++++++ pcbnew/tools/generator_tool.h | 70 ++++++ pcbnew/tools/generator_tool_pns_proxy.cpp | 144 ++++++++++++ pcbnew/tools/generator_tool_pns_proxy.h | 50 ++++ 10 files changed, 581 insertions(+), 16 deletions(-) create mode 100644 pcbnew/tools/generator_tool.cpp create mode 100644 pcbnew/tools/generator_tool.h create mode 100644 pcbnew/tools/generator_tool_pns_proxy.cpp create mode 100644 pcbnew/tools/generator_tool_pns_proxy.h diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index e9c15fdd32..34aa930c6b 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -18,6 +18,7 @@ include_directories( BEFORE ${INC_BEFORE} ) include_directories( ./dialogs ./autorouter + ./generators ${CMAKE_SOURCE_DIR}/3d-viewer ${CMAKE_SOURCE_DIR}/3d-viewer/dialogs ${CMAKE_SOURCE_DIR}/common @@ -229,6 +230,9 @@ set( PCBNEW_MICROWAVE_SRCS microwave/microwave_tool.cpp ) +set( PCBNEW_GENERATORS_SRCS + ) + set( PCBNEW_DRC_SRCS drc/drc_interactive_courtyard_clearance.cpp drc/drc_report.cpp @@ -266,6 +270,7 @@ set( PCBNEW_NETLIST_SRCS set( PCBNEW_CLASS_SRCS ${PCBNEW_DIALOGS} ${PCBNEW_EXPORTERS} + ${PCBNEW_GENERATORS_SRCS} ${PCBNEW_DRC_SRCS} ${PCBNEW_IMPORT_GFX} ${PCBNEW_NETLIST_SRCS} @@ -355,6 +360,8 @@ set( PCBNEW_CLASS_SRCS tools/tool_event_utils.cpp tools/zone_create_helper.cpp tools/zone_filler_tool.cpp + tools/generator_tool.cpp + tools/generator_tool_pns_proxy.cpp footprint_preview_panel.cpp footprint_tree_pane.cpp diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 152cfa8746..1d6ee2dc8a 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -70,6 +70,7 @@ #include #include #include +#include #include #include #include @@ -655,6 +656,7 @@ void PCB_EDIT_FRAME::setupTools() m_toolManager->RegisterTool( new PCB_VIEWER_TOOLS ); m_toolManager->RegisterTool( new CONVERT_TOOL ); m_toolManager->RegisterTool( new GROUP_TOOL ); + m_toolManager->RegisterTool( new GENERATOR_TOOL ); m_toolManager->RegisterTool( new SCRIPTING_TOOL ); m_toolManager->RegisterTool( new PROPERTIES_TOOL ); m_toolManager->InitTools(); diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index 8892410f0a..fee2757a7a 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -1813,12 +1813,10 @@ void PNS_KICAD_IFACE_BASE::UpdateItem( PNS::ITEM* aItem ) } -void PNS_KICAD_IFACE::UpdateItem( PNS::ITEM* aItem ) +void PNS_KICAD_IFACE::modifyBoardItem( PNS::ITEM* aItem ) { BOARD_ITEM* board_item = aItem->Parent(); - m_commit->Modify( board_item ); - switch( aItem->Kind() ) { case PNS::ITEM::ARC_T: @@ -1864,23 +1862,30 @@ void PNS_KICAD_IFACE::UpdateItem( PNS::ITEM* aItem ) PAD* pad = static_cast( aItem->Parent() ); VECTOR2I pos = static_cast( aItem )->Pos(); - m_fpOffsets[ pad ].p_old = pad->GetPosition(); - m_fpOffsets[ pad ].p_new = pos; + m_fpOffsets[pad].p_old = pad->GetPosition(); + m_fpOffsets[pad].p_new = pos; break; } - default: - break; + default: break; } } +void PNS_KICAD_IFACE::UpdateItem( PNS::ITEM* aItem ) +{ + BOARD_ITEM* board_item = aItem->Parent(); + m_commit->Modify( board_item ); + modifyBoardItem( aItem ); +} + + void PNS_KICAD_IFACE_BASE::AddItem( PNS::ITEM* aItem ) { } -void PNS_KICAD_IFACE::AddItem( PNS::ITEM* aItem ) +BOARD_CONNECTED_ITEM* PNS_KICAD_IFACE::createBoardItem( PNS::ITEM* aItem ) { BOARD_CONNECTED_ITEM* newBI = nullptr; @@ -1901,7 +1906,7 @@ void PNS_KICAD_IFACE::AddItem( PNS::ITEM* aItem ) { PNS::SEGMENT* seg = static_cast( aItem ); PCB_TRACK* track = new PCB_TRACK( m_board ); - const SEG& s = seg->Seg(); + const SEG& s = seg->Seg(); track->SetStart( VECTOR2I( s.A.x, s.A.y ) ); track->SetEnd( VECTOR2I( s.B.x, s.B.y ) ); track->SetWidth( seg->Width() ); @@ -1929,17 +1934,24 @@ void PNS_KICAD_IFACE::AddItem( PNS::ITEM* aItem ) case PNS::ITEM::SOLID_T: { - PAD* pad = static_cast( aItem->Parent() ); + PAD* pad = static_cast( aItem->Parent() ); VECTOR2I pos = static_cast( aItem )->Pos(); - m_fpOffsets[ pad ].p_new = pos; - return; + m_fpOffsets[pad].p_new = pos; + return nullptr; } - default: - break; + default: break; } + return newBI; +} + + +void PNS_KICAD_IFACE::AddItem( PNS::ITEM* aItem ) +{ + BOARD_CONNECTED_ITEM* newBI = createBoardItem( aItem ); + if( newBI ) { //newBI->SetLocalRatsnestVisible( m_dispOptions->m_ShowGlobalRatsnest ); diff --git a/pcbnew/router/pns_kicad_iface.h b/pcbnew/router/pns_kicad_iface.h index c05fc5c2b1..9888386e25 100644 --- a/pcbnew/router/pns_kicad_iface.h +++ b/pcbnew/router/pns_kicad_iface.h @@ -117,7 +117,7 @@ public: PNS_KICAD_IFACE(); ~PNS_KICAD_IFACE(); - void SetHostTool( PCB_TOOL_BASE* aTool ); + virtual void SetHostTool( PCB_TOOL_BASE* aTool ); void SetView( KIGFX::VIEW* aView ); void EraseView() override; @@ -140,7 +140,10 @@ public: void SetCommitFlags( int aCommitFlags ) { m_commitFlags = aCommitFlags; } -private: +protected: + BOARD_CONNECTED_ITEM* createBoardItem( PNS::ITEM* aItem ); + void modifyBoardItem( PNS::ITEM* aItem ); + struct OFFSET { VECTOR2I p_old, p_new; diff --git a/pcbnew/router/pns_tool_base.cpp b/pcbnew/router/pns_tool_base.cpp index 7d22b9ba33..8f17b05396 100644 --- a/pcbnew/router/pns_tool_base.cpp +++ b/pcbnew/router/pns_tool_base.cpp @@ -419,6 +419,12 @@ ROUTER *TOOL_BASE::Router() const } +PNS_KICAD_IFACE* TOOL_BASE::GetInterface() const +{ + return m_iface; +} + + const VECTOR2I TOOL_BASE::snapToItem( ITEM* aItem, const VECTOR2I& aP ) { if( !aItem || !m_iface->IsItemVisible( aItem ) ) diff --git a/pcbnew/router/pns_tool_base.h b/pcbnew/router/pns_tool_base.h index 1a504c208b..d6c543ffd7 100644 --- a/pcbnew/router/pns_tool_base.h +++ b/pcbnew/router/pns_tool_base.h @@ -51,6 +51,8 @@ public: ROUTER* Router() const; + PNS_KICAD_IFACE* GetInterface() const; + protected: bool checkSnap( ITEM* aItem ); diff --git a/pcbnew/tools/generator_tool.cpp b/pcbnew/tools/generator_tool.cpp new file mode 100644 index 0000000000..31dbe41794 --- /dev/null +++ b/pcbnew/tools/generator_tool.cpp @@ -0,0 +1,269 @@ +/* + * 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 "generator_tool.h" + +#include +#include +#include +#include + +#include + + +GENERATOR_TOOL::GENERATOR_TOOL() : + GENERATOR_TOOL_PNS_PROXY( "pcbnew.Generators" ), + m_mgrDialog( nullptr ) +{ +} + + +GENERATOR_TOOL::~GENERATOR_TOOL() +{ +} + + +void GENERATOR_TOOL::Reset( RESET_REASON aReason ) +{ + GENERATOR_TOOL_PNS_PROXY::Reset( aReason ); +} + + +void GENERATOR_TOOL::DestroyManagerDialog() +{ + if( m_mgrDialog ) + { + m_mgrDialog->Destroy(); + m_mgrDialog = nullptr; + } +} + + +int GENERATOR_TOOL::ShowGeneratorsManager( const TOOL_EVENT& aEvent ) +{ + PCB_EDIT_FRAME* pcbFrame = static_cast( frame() ); + + if( !pcbFrame ) + return 0; + + if( !m_mgrDialog ) + { + m_mgrDialog = new DIALOG_GENERATORS( pcbFrame, pcbFrame ); + } + else + { + m_mgrDialog->RebuildModels(); + } + + m_mgrDialog->Show( true ); + + return 0; +} + + +int GENERATOR_TOOL::ShowGeneratorProperties( const TOOL_EVENT& aEvent ) +{ + PCB_BASE_EDIT_FRAME* editFrame = getEditFrame(); + PCB_GENERATOR* gen = aEvent.Parameter(); + + gen->ShowPropertiesDialog( editFrame ); + + return 0; +} + + +int GENERATOR_TOOL::RegenerateAll( const TOOL_EVENT& aEvent ) +{ + BOARD_COMMIT localCommit( this ); + BOARD_COMMIT* commit = dynamic_cast( aEvent.Commit() ); + + if( !commit ) + commit = &localCommit; + + GENERATORS generators = board()->Generators(); + + std::sort( generators.begin(), generators.end(), + []( const PCB_GENERATOR* a, const PCB_GENERATOR* b ) -> bool + { + return a->GetUpdateOrder() < b->GetUpdateOrder(); + } ); + + for( PCB_GENERATOR* gen : generators ) + { + gen->EditStart( this, board(), frame(), commit ); + gen->Update( this, board(), frame(), commit ); + gen->EditPush( this, board(), frame(), commit ); + } + + return 0; +} + + +int GENERATOR_TOOL::RegenerateOutdated( const TOOL_EVENT& aEvent ) +{ + BOARD_COMMIT localCommit( this ); + BOARD_COMMIT* commit = dynamic_cast( aEvent.Commit() ); + + if( !commit ) + commit = &localCommit; + + GENERATORS generators = board()->Generators(); + + std::sort( generators.begin(), generators.end(), + []( const PCB_GENERATOR* a, const PCB_GENERATOR* b ) -> bool + { + return a->GetUpdateOrder() < b->GetUpdateOrder(); + } ); + + for( PCB_GENERATOR* gen : generators ) + { + gen->EditStart( this, board(), frame(), commit ); + gen->Update( this, board(), frame(), commit ); + gen->EditPush( this, board(), frame(), commit ); + } + + return 0; +} + + +int GENERATOR_TOOL::RegenerateSelected( const TOOL_EVENT& aEvent ) +{ + BOARD_COMMIT localCommit( this ); + BOARD_COMMIT* commit = dynamic_cast( aEvent.Commit() ); + + if( !commit ) + commit = &localCommit; + + PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool(); + + PCB_SELECTION sel = selTool->RequestSelection( + []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool ) + { + // Iterate from the back so we don't have to worry about removals. + for( int i = aCollector.GetCount() - 1; i >= 0; --i ) + { + BOARD_ITEM* item = aCollector[i]; + + if( item->Type() != PCB_GENERATOR_T ) + aCollector.Remove( item ); + } + } ); + + GENERATORS generators; + + for( EDA_ITEM* item : sel ) + { + if( PCB_GENERATOR* gen = dynamic_cast( item ) ) + generators.push_back( gen ); + } + + std::sort( generators.begin(), generators.end(), + []( const PCB_GENERATOR* a, const PCB_GENERATOR* b ) -> bool + { + return a->GetUpdateOrder() < b->GetUpdateOrder(); + } ); + + for( PCB_GENERATOR* gen : generators ) + { + gen->EditStart( this, board(), frame(), commit ); + gen->Update( this, board(), frame(), commit ); + gen->EditPush( this, board(), frame(), commit ); + } + + return 0; +} + + +int GENERATOR_TOOL::RegenerateItem( const TOOL_EVENT& aEvent ) +{ + BOARD_COMMIT localCommit( this ); + BOARD_COMMIT* commit = dynamic_cast( aEvent.Commit() ); + + if( !commit ) + commit = &localCommit; + + PCB_GENERATOR* gen = aEvent.Parameter(); + + gen->EditStart( this, board(), frame(), commit ); + gen->Update( this, board(), frame(), commit ); + gen->EditPush( this, board(), frame(), commit ); + + return 0; +} + + +int GENERATOR_TOOL::GenEditAction( const TOOL_EVENT& aEvent ) +{ + BOARD_COMMIT* commit = dynamic_cast( aEvent.Commit() ); + + wxCHECK( commit, 0 ); + + PCB_GENERATOR* gen = aEvent.Parameter(); + + if( aEvent.IsAction( &PCB_ACTIONS::genStartEdit ) ) + { + gen->EditStart( this, board(), frame(), commit ); + } + else if( aEvent.IsAction( &PCB_ACTIONS::genUpdateEdit ) ) + { + gen->Update( this, board(), frame(), commit ); + } + else if( aEvent.IsAction( &PCB_ACTIONS::genPushEdit ) ) + { + gen->EditPush( this, board(), frame(), commit ); + + wxASSERT( commit->Empty() ); + } + else if( aEvent.IsAction( &PCB_ACTIONS::genRevertEdit ) ) + { + gen->EditRevert( this, board(), frame(), commit ); + + wxASSERT( commit->Empty() ); + } + else if( aEvent.IsAction( &PCB_ACTIONS::genRemove ) ) + { + gen->Remove( this, board(), frame(), commit ); + } + + return 0; +} + + +void GENERATOR_TOOL::setTransitions() +{ + // Generator actions + Go( &GENERATOR_TOOL::ShowGeneratorsManager, PCB_ACTIONS::generatorsShowManager.MakeEvent() ); + Go( &GENERATOR_TOOL::ShowGeneratorProperties, PCB_ACTIONS::generatorProperties.MakeEvent() ); + + Go( &GENERATOR_TOOL::RegenerateAll, PCB_ACTIONS::regenerateAll.MakeEvent() ); + Go( &GENERATOR_TOOL::RegenerateOutdated, PCB_ACTIONS::regenerateOutdated.MakeEvent() ); + Go( &GENERATOR_TOOL::RegenerateSelected, PCB_ACTIONS::regenerateSelected.MakeEvent() ); + Go( &GENERATOR_TOOL::RegenerateItem, PCB_ACTIONS::regenerateItem.MakeEvent() ); + + Go( &GENERATOR_TOOL::GenEditAction, PCB_ACTIONS::genStartEdit.MakeEvent() ); + Go( &GENERATOR_TOOL::GenEditAction, PCB_ACTIONS::genUpdateEdit.MakeEvent() ); + Go( &GENERATOR_TOOL::GenEditAction, PCB_ACTIONS::genPushEdit.MakeEvent() ); + Go( &GENERATOR_TOOL::GenEditAction, PCB_ACTIONS::genRevertEdit.MakeEvent() ); + Go( &GENERATOR_TOOL::GenEditAction, PCB_ACTIONS::genRemove.MakeEvent() ); +} diff --git a/pcbnew/tools/generator_tool.h b/pcbnew/tools/generator_tool.h new file mode 100644 index 0000000000..2d85fa6094 --- /dev/null +++ b/pcbnew/tools/generator_tool.h @@ -0,0 +1,70 @@ +/* + * 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 GENERATOR_TOOL_H +#define GENERATOR_TOOL_H + +#include +#include + + +class DIALOG_GENERATORS; +class PCB_EDIT_FRAME; +class PROGRESS_REPORTER; +class WX_PROGRESS_REPORTER; + + +/** + * Handle actions specific to filling copper zones. + */ +class GENERATOR_TOOL : public GENERATOR_TOOL_PNS_PROXY +{ +public: + GENERATOR_TOOL(); + ~GENERATOR_TOOL(); + + /// @copydoc TOOL_INTERACTIVE::Reset() + void Reset( RESET_REASON aReason ) override; + + void DestroyManagerDialog(); + + int ShowGeneratorsManager( const TOOL_EVENT& aEvent ); + int ShowGeneratorProperties( const TOOL_EVENT& aEvent ); + + int RegenerateSelected( const TOOL_EVENT& aEvent ); + int RegenerateAll( const TOOL_EVENT& aEvent ); + int RegenerateOutdated( const TOOL_EVENT& aEvent ); + int RegenerateItem( const TOOL_EVENT& aEvent ); + int GenEditAction( const TOOL_EVENT& aEvent ); + +private: + ///< Set up handlers for various events. + void setTransitions() override; + + DIALOG_GENERATORS* m_mgrDialog; + +private: +}; + +#endif diff --git a/pcbnew/tools/generator_tool_pns_proxy.cpp b/pcbnew/tools/generator_tool_pns_proxy.cpp new file mode 100644 index 0000000000..fac6527cf9 --- /dev/null +++ b/pcbnew/tools/generator_tool_pns_proxy.cpp @@ -0,0 +1,144 @@ +/* + * 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 "generator_tool_pns_proxy.h" + +#include +#include +#include + +#include +#include +#include + + +class PNS_KICAD_IFACE_GENERATOR : public PNS_KICAD_IFACE +{ +public: + void Commit() override {} + + void SetHostTool( PCB_TOOL_BASE* aTool ) override + { + m_tool = aTool; + m_commit = nullptr; + m_addedItems.clear(); + m_removedItems.clear(); + } + + void AddItem( PNS::ITEM* aItem ) override + { + BOARD_ITEM* brdItem = createBoardItem( aItem ); + m_addedItems.emplace( brdItem ); + } + + void UpdateItem( PNS::ITEM* aItem ) override + { // + modifyBoardItem( aItem ); + } + + void RemoveItem( PNS::ITEM* aItem ) override + { + BOARD_ITEM* parent = aItem->Parent(); + + if( aItem->OfKind( PNS::ITEM::SOLID_T ) ) + { + PAD* pad = static_cast( parent ); + VECTOR2I pos = static_cast( aItem )->Pos(); + + m_fpOffsets[pad].p_old = pos; + return; + } + + if( parent ) + { + m_removedItems.emplace( parent ); + } + } + + std::set& AddedItems() { return m_addedItems; } + std::set& RemovedItems() { return m_removedItems; } + +private: + std::set m_addedItems; + std::set m_removedItems; +}; + + +void GENERATOR_TOOL_PNS_PROXY::ClearRouterCommit() +{ + static_cast( GetInterface() )->AddedItems().clear(); + static_cast( GetInterface() )->RemovedItems().clear(); +} + + +const std::set& GENERATOR_TOOL_PNS_PROXY::GetRouterCommitAddedItems() +{ + return static_cast( GetInterface() )->AddedItems(); +} + + +const std::set& GENERATOR_TOOL_PNS_PROXY::GetRouterCommitRemovedItems() +{ + return static_cast( GetInterface() )->RemovedItems(); +} + + +GENERATOR_TOOL_PNS_PROXY::GENERATOR_TOOL_PNS_PROXY( const std::string& aToolName ) : + PNS::TOOL_BASE( aToolName ) +{ +} + + +GENERATOR_TOOL_PNS_PROXY::~GENERATOR_TOOL_PNS_PROXY() +{ +} + + +void GENERATOR_TOOL_PNS_PROXY::Reset( RESET_REASON aReason ) +{ + delete m_gridHelper; + delete m_iface; + delete m_router; + + m_iface = new PNS_KICAD_IFACE_GENERATOR; + m_iface->SetBoard( board() ); + m_iface->SetView( getView() ); + m_iface->SetHostTool( this ); + + m_router = new PNS::ROUTER; + m_router->SetInterface( m_iface ); + m_router->ClearWorld(); + m_router->SyncWorld(); + + m_router->UpdateSizes( m_savedSizes ); + + PCBNEW_SETTINGS* settings = frame()->GetPcbNewSettings(); + + if( !settings->m_PnsSettings ) + settings->m_PnsSettings = std::make_unique( settings, "tools.pns" ); + + m_router->LoadSettings( settings->m_PnsSettings.get() ); + + m_gridHelper = new PCB_GRID_HELPER( m_toolMgr, frame()->GetMagneticItemsSettings() ); +} \ No newline at end of file diff --git a/pcbnew/tools/generator_tool_pns_proxy.h b/pcbnew/tools/generator_tool_pns_proxy.h new file mode 100644 index 0000000000..e044c6ab50 --- /dev/null +++ b/pcbnew/tools/generator_tool_pns_proxy.h @@ -0,0 +1,50 @@ +/* + * 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 GENERATOR_TOOL_PNS_PROXY_H +#define GENERATOR_TOOL_PNS_PROXY_H + +#include + +class BOARD_ITEM; + + +/** + * A proxy class to allow access to the PNS router from the generator tool. + */ +class GENERATOR_TOOL_PNS_PROXY : public PNS::TOOL_BASE +{ +public: + GENERATOR_TOOL_PNS_PROXY( const std::string& aToolName ); + ~GENERATOR_TOOL_PNS_PROXY(); + + /// @copydoc TOOL_INTERACTIVE::Reset() + void Reset( RESET_REASON aReason ) override; + + void ClearRouterCommit(); + const std::set& GetRouterCommitAddedItems(); + const std::set& GetRouterCommitRemovedItems(); +}; + +#endif // GENERATOR_TOOL_PNS_PROXY_H