Introduce GENERATOR_TOOL.
This commit is contained in:
parent
be72e07e61
commit
546c7ed218
|
@ -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
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
#include <tools/pcb_point_editor.h>
|
||||
#include <tools/edit_tool.h>
|
||||
#include <tools/group_tool.h>
|
||||
#include <tools/generator_tool.h>
|
||||
#include <tools/drc_tool.h>
|
||||
#include <tools/global_edit_tool.h>
|
||||
#include <tools/convert_tool.h>
|
||||
|
@ -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();
|
||||
|
|
|
@ -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:
|
||||
|
@ -1869,18 +1867,25 @@ void PNS_KICAD_IFACE::UpdateItem( PNS::ITEM* aItem )
|
|||
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;
|
||||
|
||||
|
@ -1933,13 +1938,20 @@ void PNS_KICAD_IFACE::AddItem( PNS::ITEM* aItem )
|
|||
VECTOR2I pos = static_cast<PNS::SOLID*>( aItem )->Pos();
|
||||
|
||||
m_fpOffsets[pad].p_new = pos;
|
||||
return;
|
||||
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 );
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 ) )
|
||||
|
|
|
@ -51,6 +51,8 @@ public:
|
|||
|
||||
ROUTER* Router() const;
|
||||
|
||||
PNS_KICAD_IFACE* GetInterface() const;
|
||||
|
||||
protected:
|
||||
bool checkSnap( ITEM* aItem );
|
||||
|
||||
|
|
|
@ -0,0 +1,269 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2023 Alex Shvartzkop <dudesuchamazing@gmail.com>
|
||||
* 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 <collectors.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/pcb_selection_tool.h>
|
||||
#include <tools/pcb_actions.h>
|
||||
|
||||
#include <dialog_generators.h>
|
||||
|
||||
|
||||
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<PCB_EDIT_FRAME*>( 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_BASE_EDIT_FRAME>();
|
||||
PCB_GENERATOR* gen = aEvent.Parameter<PCB_GENERATOR*>();
|
||||
|
||||
gen->ShowPropertiesDialog( editFrame );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int GENERATOR_TOOL::RegenerateAll( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
BOARD_COMMIT localCommit( this );
|
||||
BOARD_COMMIT* commit = dynamic_cast<BOARD_COMMIT*>( 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<BOARD_COMMIT*>( 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<BOARD_COMMIT*>( aEvent.Commit() );
|
||||
|
||||
if( !commit )
|
||||
commit = &localCommit;
|
||||
|
||||
PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
|
||||
|
||||
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<PCB_GENERATOR*>( 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<BOARD_COMMIT*>( aEvent.Commit() );
|
||||
|
||||
if( !commit )
|
||||
commit = &localCommit;
|
||||
|
||||
PCB_GENERATOR* gen = aEvent.Parameter<PCB_GENERATOR*>();
|
||||
|
||||
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<BOARD_COMMIT*>( aEvent.Commit() );
|
||||
|
||||
wxCHECK( commit, 0 );
|
||||
|
||||
PCB_GENERATOR* gen = aEvent.Parameter<PCB_GENERATOR*>();
|
||||
|
||||
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() );
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2023 Alex Shvartzkop <dudesuchamazing@gmail.com>
|
||||
* 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 <tools/generator_tool_pns_proxy.h>
|
||||
#include <pcb_generator.h>
|
||||
|
||||
|
||||
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
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2023 Alex Shvartzkop <dudesuchamazing@gmail.com>
|
||||
* 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 <pad.h>
|
||||
#include <pcb_shape.h>
|
||||
#include <tools/pcb_grid_helper.h>
|
||||
|
||||
#include <router/pns_kicad_iface.h>
|
||||
#include <router/pns_solid.h>
|
||||
#include <router/pns_router.h>
|
||||
|
||||
|
||||
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<PAD*>( parent );
|
||||
VECTOR2I pos = static_cast<PNS::SOLID*>( aItem )->Pos();
|
||||
|
||||
m_fpOffsets[pad].p_old = pos;
|
||||
return;
|
||||
}
|
||||
|
||||
if( parent )
|
||||
{
|
||||
m_removedItems.emplace( parent );
|
||||
}
|
||||
}
|
||||
|
||||
std::set<BOARD_ITEM*>& AddedItems() { return m_addedItems; }
|
||||
std::set<BOARD_ITEM*>& RemovedItems() { return m_removedItems; }
|
||||
|
||||
private:
|
||||
std::set<BOARD_ITEM*> m_addedItems;
|
||||
std::set<BOARD_ITEM*> m_removedItems;
|
||||
};
|
||||
|
||||
|
||||
void GENERATOR_TOOL_PNS_PROXY::ClearRouterCommit()
|
||||
{
|
||||
static_cast<PNS_KICAD_IFACE_GENERATOR*>( GetInterface() )->AddedItems().clear();
|
||||
static_cast<PNS_KICAD_IFACE_GENERATOR*>( GetInterface() )->RemovedItems().clear();
|
||||
}
|
||||
|
||||
|
||||
const std::set<BOARD_ITEM*>& GENERATOR_TOOL_PNS_PROXY::GetRouterCommitAddedItems()
|
||||
{
|
||||
return static_cast<PNS_KICAD_IFACE_GENERATOR*>( GetInterface() )->AddedItems();
|
||||
}
|
||||
|
||||
|
||||
const std::set<BOARD_ITEM*>& GENERATOR_TOOL_PNS_PROXY::GetRouterCommitRemovedItems()
|
||||
{
|
||||
return static_cast<PNS_KICAD_IFACE_GENERATOR*>( 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<PNS::ROUTING_SETTINGS>( settings, "tools.pns" );
|
||||
|
||||
m_router->LoadSettings( settings->m_PnsSettings.get() );
|
||||
|
||||
m_gridHelper = new PCB_GRID_HELPER( m_toolMgr, frame()->GetMagneticItemsSettings() );
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2023 Alex Shvartzkop <dudesuchamazing@gmail.com>
|
||||
* 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 <router/pns_tool_base.h>
|
||||
|
||||
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<BOARD_ITEM*>& GetRouterCommitAddedItems();
|
||||
const std::set<BOARD_ITEM*>& GetRouterCommitRemovedItems();
|
||||
};
|
||||
|
||||
#endif // GENERATOR_TOOL_PNS_PROXY_H
|
Loading…
Reference in New Issue