2016-08-15 17:16:47 +02:00
|
|
|
/*
|
|
|
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2016 CERN
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2016-08-15 17:16:47 +02:00
|
|
|
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
|
|
|
*
|
|
|
|
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2016-08-15 17:16:48 +02:00
|
|
|
|
2016-08-15 17:16:47 +02:00
|
|
|
#ifndef __PNS_KICAD_IFACE_H
|
|
|
|
#define __PNS_KICAD_IFACE_H
|
|
|
|
|
|
|
|
#include <unordered_set>
|
2025-08-26 10:33:36 -07:00
|
|
|
#include <unordered_map>
|
|
|
|
#include <vector>
|
2016-08-15 17:16:47 +02:00
|
|
|
|
|
|
|
#include "pns_router.h"
|
|
|
|
|
|
|
|
class PNS_PCBNEW_RULE_RESOLVER;
|
2016-08-15 17:16:48 +02:00
|
|
|
class PNS_PCBNEW_DEBUG_DECORATOR;
|
2016-08-15 17:16:47 +02:00
|
|
|
|
|
|
|
class BOARD;
|
2016-06-21 17:06:28 +02:00
|
|
|
class BOARD_COMMIT;
|
2023-05-02 16:02:45 +01:00
|
|
|
class PCB_TEXT;
|
2017-10-30 18:21:07 +01:00
|
|
|
class PCB_DISPLAY_OPTIONS;
|
2019-05-12 12:49:58 +01:00
|
|
|
class PCB_TOOL_BASE;
|
2020-11-13 15:15:52 +00:00
|
|
|
class FOOTPRINT;
|
2020-11-12 22:30:02 +00:00
|
|
|
class PAD;
|
2022-08-30 13:52:34 +01:00
|
|
|
class EDA_TEXT;
|
2025-02-10 20:57:51 +00:00
|
|
|
class LENGTH_DELAY_CALCULATION_ITEM;
|
2025-08-26 10:33:36 -07:00
|
|
|
class BOARD_ITEM;
|
|
|
|
class EDA_GROUP;
|
2017-01-25 10:33:49 +01:00
|
|
|
|
2020-10-09 00:01:09 +02:00
|
|
|
namespace PNS
|
|
|
|
{
|
|
|
|
class SIZES_SETTINGS;
|
|
|
|
}
|
|
|
|
|
2016-08-15 17:16:53 +02:00
|
|
|
namespace KIGFX
|
|
|
|
{
|
2016-08-15 17:16:47 +02:00
|
|
|
class VIEW;
|
2017-11-02 21:41:29 +01:00
|
|
|
}
|
2016-08-15 17:16:47 +02:00
|
|
|
|
2020-11-11 15:30:37 +00:00
|
|
|
class PNS_KICAD_IFACE_BASE : public PNS::ROUTER_IFACE
|
|
|
|
{
|
2016-08-15 17:16:47 +02:00
|
|
|
public:
|
2019-12-30 15:26:33 +01:00
|
|
|
PNS_KICAD_IFACE_BASE();
|
2024-03-31 15:09:04 +02:00
|
|
|
~PNS_KICAD_IFACE_BASE() override;
|
2016-08-15 17:16:47 +02:00
|
|
|
|
2019-12-30 15:26:33 +01:00
|
|
|
void EraseView() override {};
|
2016-08-15 17:16:47 +02:00
|
|
|
void SetBoard( BOARD* aBoard );
|
2016-09-24 14:53:15 -04:00
|
|
|
void SyncWorld( PNS::NODE* aWorld ) override;
|
2024-07-21 10:49:18 -07:00
|
|
|
bool IsAnyLayerVisible( const PNS_LAYER_RANGE& aLayer ) const override { return true; };
|
2022-06-09 00:30:57 +02:00
|
|
|
bool IsFlashedOnLayer( const PNS::ITEM* aItem, int aLayer ) const override;
|
2024-07-21 10:49:18 -07:00
|
|
|
bool IsFlashedOnLayer( const PNS::ITEM* aItem, const PNS_LAYER_RANGE& aLayer ) const override;
|
2022-06-09 00:30:57 +02:00
|
|
|
bool IsItemVisible( const PNS::ITEM* aItem ) const override { return true; };
|
2024-09-29 09:34:47 +02:00
|
|
|
bool IsPNSCopperLayer( int aPNSLayer ) const override;
|
|
|
|
bool IsKicadCopperLayer( PCB_LAYER_ID aPcbnewLayer ) const;
|
2019-12-30 15:26:33 +01:00
|
|
|
void HideItem( PNS::ITEM* aItem ) override {}
|
2022-09-11 22:17:45 +01:00
|
|
|
void DisplayItem( const PNS::ITEM* aItem, int aClearance, bool aEdit = false,
|
2023-12-08 16:01:27 +00:00
|
|
|
int aFlags = 0 ) override {}
|
2023-02-01 20:36:52 +03:00
|
|
|
void DisplayPathLine( const SHAPE_LINE_CHAIN& aLine, int aImportance ) override {}
|
2023-08-22 13:06:33 +01:00
|
|
|
void DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, PNS::NET_HANDLE aNet ) override {}
|
2016-09-24 14:53:15 -04:00
|
|
|
void AddItem( PNS::ITEM* aItem ) override;
|
2021-02-07 17:06:56 -08:00
|
|
|
void UpdateItem( PNS::ITEM* aItem ) override;
|
2016-09-24 14:53:15 -04:00
|
|
|
void RemoveItem( PNS::ITEM* aItem ) override;
|
2019-12-30 15:26:33 +01:00
|
|
|
void Commit() override {}
|
2024-08-15 21:45:34 +01:00
|
|
|
bool ImportSizes( PNS::SIZES_SETTINGS& aSizes, PNS::ITEM* aStartItem, PNS::NET_HANDLE aNet,
|
|
|
|
VECTOR2D aStartPosition ) override;
|
2021-04-04 13:58:51 -04:00
|
|
|
int StackupHeight( int aFirstLayer, int aSecondLayer ) const override;
|
2016-08-15 17:16:47 +02:00
|
|
|
|
2023-08-22 13:06:33 +01:00
|
|
|
int GetNetCode( PNS::NET_HANDLE aNet ) const override { return -1; }
|
|
|
|
wxString GetNetName( PNS::NET_HANDLE aNet ) const override { return wxEmptyString; }
|
|
|
|
void UpdateNet( PNS::NET_HANDLE aNet ) override {}
|
2023-09-12 15:59:20 +02:00
|
|
|
PNS::NET_HANDLE GetOrphanedNetHandle() override;
|
2019-12-30 15:26:33 +01:00
|
|
|
|
2021-07-26 19:47:26 -04:00
|
|
|
void SetDebugDecorator( PNS::DEBUG_DECORATOR* aDec );
|
2016-08-15 17:16:47 +02:00
|
|
|
|
2025-03-27 21:26:37 +00:00
|
|
|
long long int CalculateRoutedPathLength( const PNS::ITEM_SET& aLine, const PNS::SOLID* aStartPad,
|
2025-02-10 20:57:51 +00:00
|
|
|
const PNS::SOLID* aEndPad, const NETCLASS* aNetClass ) override;
|
|
|
|
int64_t CalculateRoutedPathDelay( const PNS::ITEM_SET& aLine, const PNS::SOLID* aStartPad,
|
|
|
|
const PNS::SOLID* aEndPad, const NETCLASS* aNetClass ) override;
|
|
|
|
int64_t CalculateLengthForDelay( int64_t aDesiredDelay, int aWidth, bool aIsDiffPairCoupled,
|
|
|
|
int aDiffPairCouplingGap, int aPNSLayer, const NETCLASS* aNetClass ) override;
|
|
|
|
int64_t CalculateDelayForShapeLineChain( const SHAPE_LINE_CHAIN& aShape, int aWidth, bool aIsDiffPairCoupled,
|
|
|
|
int aDiffPairCouplingGap, int aPNSLayer,
|
|
|
|
const NETCLASS* aNetClass ) override;
|
|
|
|
|
2024-09-13 15:50:12 -07:00
|
|
|
PCB_LAYER_ID GetBoardLayerFromPNSLayer( int aLayer ) const override;
|
|
|
|
int GetPNSLayerFromBoardLayer( PCB_LAYER_ID aLayer ) const override;
|
2024-07-21 10:49:18 -07:00
|
|
|
|
|
|
|
void SetStartLayerFromPCBNew( PCB_LAYER_ID aLayer );
|
|
|
|
void SetStartLayerFromPNS( int aLayer ) { m_startLayer = aLayer; }
|
|
|
|
|
|
|
|
PNS_LAYER_RANGE SetLayersFromPCBNew( PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer );
|
2021-10-23 22:46:31 -04:00
|
|
|
|
2021-12-02 22:25:35 +00:00
|
|
|
virtual PNS::NODE* GetWorld() const override { return m_world; };
|
2020-04-17 00:29:28 +02:00
|
|
|
|
2021-12-02 22:25:35 +00:00
|
|
|
BOARD* GetBoard() const { return m_board; }
|
|
|
|
|
2025-03-01 20:24:37 +00:00
|
|
|
virtual EDA_UNITS GetUnits() const { return EDA_UNITS::MM; };
|
2020-04-17 00:29:28 +02:00
|
|
|
|
2016-09-24 14:53:15 -04:00
|
|
|
PNS::RULE_RESOLVER* GetRuleResolver() override;
|
|
|
|
PNS::DEBUG_DECORATOR* GetDebugDecorator() override;
|
2016-08-15 17:16:47 +02:00
|
|
|
|
2019-12-30 15:26:33 +01:00
|
|
|
protected:
|
2016-08-15 17:16:47 +02:00
|
|
|
PNS_PCBNEW_RULE_RESOLVER* m_ruleResolver;
|
2019-12-30 15:26:33 +01:00
|
|
|
PNS::DEBUG_DECORATOR* m_debugDecorator;
|
2016-08-15 17:16:47 +02:00
|
|
|
|
2024-09-15 13:26:01 -04:00
|
|
|
std::vector<std::unique_ptr<PNS::SOLID>> syncPad( PAD* aPad );
|
2021-06-11 22:07:02 +01:00
|
|
|
std::unique_ptr<PNS::SEGMENT> syncTrack( PCB_TRACK* aTrack );
|
|
|
|
std::unique_ptr<PNS::ARC> syncArc( PCB_ARC* aArc );
|
2024-10-19 19:37:07 -04:00
|
|
|
std::unique_ptr<PNS::VIA> syncVia( PCB_VIA* aVia );
|
2025-03-10 15:45:11 +00:00
|
|
|
bool syncTextItem( PNS::NODE* aWorld, BOARD_ITEM* aItem, PCB_LAYER_ID aLayer );
|
2020-10-05 00:34:59 +01:00
|
|
|
bool syncGraphicalItem( PNS::NODE* aWorld, PCB_SHAPE* aItem );
|
2020-11-11 23:05:59 +00:00
|
|
|
bool syncZone( PNS::NODE* aWorld, ZONE* aZone, SHAPE_POLY_SET* aBoardOutline );
|
2020-10-18 11:54:28 +01:00
|
|
|
bool inheritTrackWidth( PNS::ITEM* aItem, int* aInheritedWidth );
|
2025-02-10 20:57:51 +00:00
|
|
|
std::vector<LENGTH_DELAY_CALCULATION_ITEM> getLengthDelayCalculationItems( const PNS::ITEM_SET& aLine,
|
|
|
|
const NETCLASS* aNetClass ) const;
|
2020-10-09 00:01:09 +02:00
|
|
|
|
2020-11-11 15:30:37 +00:00
|
|
|
protected:
|
2020-04-17 00:29:28 +02:00
|
|
|
PNS::NODE* m_world;
|
2020-11-11 15:30:37 +00:00
|
|
|
BOARD* m_board;
|
2024-07-21 10:49:18 -07:00
|
|
|
int m_startLayer; // The starting layer, in PNS layer coordinates
|
2019-12-30 15:26:33 +01:00
|
|
|
};
|
|
|
|
|
2020-11-11 15:30:37 +00:00
|
|
|
class PNS_KICAD_IFACE : public PNS_KICAD_IFACE_BASE
|
|
|
|
{
|
2019-12-30 15:26:33 +01:00
|
|
|
public:
|
|
|
|
PNS_KICAD_IFACE();
|
2024-03-31 15:09:04 +02:00
|
|
|
~PNS_KICAD_IFACE() override;
|
2019-12-30 15:26:33 +01:00
|
|
|
|
2023-10-07 04:19:25 +03:00
|
|
|
virtual void SetHostTool( PCB_TOOL_BASE* aTool );
|
2019-12-30 15:26:33 +01:00
|
|
|
|
|
|
|
void SetView( KIGFX::VIEW* aView );
|
|
|
|
void EraseView() override;
|
2024-07-21 10:49:18 -07:00
|
|
|
bool IsAnyLayerVisible( const PNS_LAYER_RANGE& aLayer ) const override;
|
2020-10-05 20:54:12 +01:00
|
|
|
bool IsItemVisible( const PNS::ITEM* aItem ) const override;
|
2019-12-30 15:26:33 +01:00
|
|
|
void HideItem( PNS::ITEM* aItem ) override;
|
2023-12-08 16:01:27 +00:00
|
|
|
void DisplayItem( const PNS::ITEM* aItem, int aClearance, bool aEdit = false,
|
|
|
|
int aFlags = 0 ) override;
|
2023-02-01 20:36:52 +03:00
|
|
|
void DisplayPathLine( const SHAPE_LINE_CHAIN& aLine, int aImportance ) override;
|
2023-08-22 13:06:33 +01:00
|
|
|
void DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, PNS::NET_HANDLE aNet ) override;
|
2019-12-30 15:26:33 +01:00
|
|
|
void Commit() override;
|
|
|
|
void AddItem( PNS::ITEM* aItem ) override;
|
2021-02-07 17:06:56 -08:00
|
|
|
void UpdateItem( PNS::ITEM* aItem ) override;
|
2019-12-30 15:26:33 +01:00
|
|
|
void RemoveItem( PNS::ITEM* aItem ) override;
|
2020-04-02 11:33:55 +02:00
|
|
|
|
2023-08-22 13:06:33 +01:00
|
|
|
int GetNetCode( PNS::NET_HANDLE aNet ) const override;
|
|
|
|
wxString GetNetName( PNS::NET_HANDLE aNet ) const override;
|
|
|
|
void UpdateNet( PNS::NET_HANDLE aNet ) override;
|
2019-12-30 15:26:33 +01:00
|
|
|
|
2021-12-02 22:25:35 +00:00
|
|
|
EDA_UNITS GetUnits() const override;
|
2021-10-23 22:46:31 -04:00
|
|
|
|
2022-08-17 14:02:42 -04:00
|
|
|
void SetCommitFlags( int aCommitFlags ) { m_commitFlags = aCommitFlags; }
|
|
|
|
|
2023-10-07 04:19:25 +03:00
|
|
|
protected:
|
|
|
|
BOARD_CONNECTED_ITEM* createBoardItem( PNS::ITEM* aItem );
|
|
|
|
void modifyBoardItem( PNS::ITEM* aItem );
|
|
|
|
|
2020-10-17 13:52:18 +01:00
|
|
|
struct OFFSET
|
|
|
|
{
|
2020-04-02 11:33:55 +02:00
|
|
|
VECTOR2I p_old, p_new;
|
2020-02-28 23:09:19 +01:00
|
|
|
};
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
std::map<PAD*, OFFSET> m_fpOffsets;
|
2020-10-17 13:52:18 +01:00
|
|
|
KIGFX::VIEW* m_view;
|
|
|
|
KIGFX::VIEW_GROUP* m_previewItems;
|
|
|
|
std::unordered_set<BOARD_ITEM*> m_hiddenItems;
|
2016-08-15 17:16:47 +02:00
|
|
|
|
2025-08-26 10:33:36 -07:00
|
|
|
std::unordered_map<BOARD_ITEM*, EDA_GROUP*> m_itemGroups;
|
|
|
|
std::unordered_map<BOARD_ITEM*, std::vector<BOARD_ITEM*>> m_replacementMap;
|
|
|
|
|
2020-10-17 13:52:18 +01:00
|
|
|
PCB_TOOL_BASE* m_tool;
|
|
|
|
std::unique_ptr<BOARD_COMMIT> m_commit;
|
2022-08-17 14:02:42 -04:00
|
|
|
int m_commitFlags;
|
2016-08-15 17:16:47 +02:00
|
|
|
};
|
|
|
|
|
2019-12-30 15:26:33 +01:00
|
|
|
|
2016-08-15 17:16:47 +02:00
|
|
|
#endif
|