2016-08-15 15:16:47 +00:00
|
|
|
/*
|
|
|
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2016 CERN
|
2021-07-26 23:47:26 +00:00
|
|
|
* Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2016-08-15 15:16:47 +00: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 15:16:48 +00:00
|
|
|
|
2016-08-15 15:16:47 +00:00
|
|
|
#ifndef __PNS_KICAD_IFACE_H
|
|
|
|
#define __PNS_KICAD_IFACE_H
|
|
|
|
|
|
|
|
#include <unordered_set>
|
|
|
|
|
|
|
|
#include "pns_router.h"
|
|
|
|
|
|
|
|
class PNS_PCBNEW_RULE_RESOLVER;
|
2016-08-15 15:16:48 +00:00
|
|
|
class PNS_PCBNEW_DEBUG_DECORATOR;
|
2016-08-15 15:16:47 +00:00
|
|
|
|
|
|
|
class BOARD;
|
2016-06-21 15:06:28 +00:00
|
|
|
class BOARD_COMMIT;
|
2017-10-30 17:21:07 +00:00
|
|
|
class PCB_DISPLAY_OPTIONS;
|
2019-05-12 11:49:58 +00: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;
|
2017-01-25 09:33:49 +00:00
|
|
|
|
2020-10-08 22:01:09 +00:00
|
|
|
namespace PNS
|
|
|
|
{
|
|
|
|
class SIZES_SETTINGS;
|
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
namespace KIGFX
|
|
|
|
{
|
2016-08-15 15:16:47 +00:00
|
|
|
class VIEW;
|
2017-11-02 20:41:29 +00:00
|
|
|
}
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2020-11-11 15:30:37 +00:00
|
|
|
class PNS_KICAD_IFACE_BASE : public PNS::ROUTER_IFACE
|
|
|
|
{
|
2016-08-15 15:16:47 +00:00
|
|
|
public:
|
2019-12-30 14:26:33 +00:00
|
|
|
PNS_KICAD_IFACE_BASE();
|
|
|
|
~PNS_KICAD_IFACE_BASE();
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2019-12-30 14:26:33 +00:00
|
|
|
void EraseView() override {};
|
2016-08-15 15:16:47 +00:00
|
|
|
void SetBoard( BOARD* aBoard );
|
2016-09-24 18:53:15 +00:00
|
|
|
void SyncWorld( PNS::NODE* aWorld ) override;
|
2020-10-05 19:54:12 +00:00
|
|
|
bool IsAnyLayerVisible( const LAYER_RANGE& aLayer ) const override { return true; };
|
2022-06-08 22:30:57 +00:00
|
|
|
bool IsFlashedOnLayer( const PNS::ITEM* aItem, int aLayer ) const override;
|
|
|
|
bool IsItemVisible( const PNS::ITEM* aItem ) const override { return true; };
|
2019-12-30 14:26:33 +00:00
|
|
|
void HideItem( PNS::ITEM* aItem ) override {}
|
2021-01-03 21:14:44 +00:00
|
|
|
void DisplayItem( const PNS::ITEM* aItem, int aClearance, bool aEdit = false ) override {}
|
2020-10-14 00:04:47 +00:00
|
|
|
void DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, int aColor = -1 ) override {}
|
2016-09-24 18:53:15 +00:00
|
|
|
void AddItem( PNS::ITEM* aItem ) override;
|
2021-02-08 01:06:56 +00:00
|
|
|
void UpdateItem( PNS::ITEM* aItem ) override;
|
2016-09-24 18:53:15 +00:00
|
|
|
void RemoveItem( PNS::ITEM* aItem ) override;
|
2019-12-30 14:26:33 +00:00
|
|
|
void Commit() override {}
|
2020-10-08 22:01:09 +00:00
|
|
|
bool ImportSizes( PNS::SIZES_SETTINGS& aSizes, PNS::ITEM* aStartItem, int aNet ) override;
|
2021-04-04 17:58:51 +00:00
|
|
|
int StackupHeight( int aFirstLayer, int aSecondLayer ) const override;
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2019-12-30 14:26:33 +00:00
|
|
|
void UpdateNet( int aNetCode ) override {}
|
|
|
|
|
2021-07-26 23:47:26 +00:00
|
|
|
void SetDebugDecorator( PNS::DEBUG_DECORATOR* aDec );
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2021-10-24 02:46:31 +00:00
|
|
|
void SetStartLayer( int aLayer ) { m_startLayer = aLayer; }
|
|
|
|
|
2021-12-02 22:25:35 +00:00
|
|
|
virtual PNS::NODE* GetWorld() const override { return m_world; };
|
2020-04-16 22:29:28 +00:00
|
|
|
|
2021-12-02 22:25:35 +00:00
|
|
|
BOARD* GetBoard() const { return m_board; }
|
|
|
|
|
|
|
|
virtual EDA_UNITS GetUnits() const { return EDA_UNITS::MILLIMETRES; };
|
2020-04-16 22:29:28 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
PNS::RULE_RESOLVER* GetRuleResolver() override;
|
|
|
|
PNS::DEBUG_DECORATOR* GetDebugDecorator() override;
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2019-12-30 14:26:33 +00:00
|
|
|
protected:
|
2016-08-15 15:16:47 +00:00
|
|
|
PNS_PCBNEW_RULE_RESOLVER* m_ruleResolver;
|
2019-12-30 14:26:33 +00:00
|
|
|
PNS::DEBUG_DECORATOR* m_debugDecorator;
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
std::unique_ptr<PNS::SOLID> syncPad( PAD* aPad );
|
2021-06-11 21:07:02 +00:00
|
|
|
std::unique_ptr<PNS::SEGMENT> syncTrack( PCB_TRACK* aTrack );
|
|
|
|
std::unique_ptr<PNS::ARC> syncArc( PCB_ARC* aArc );
|
|
|
|
std::unique_ptr<PNS::VIA> syncVia( PCB_VIA* aVia );
|
2018-08-27 13:51:37 +00:00
|
|
|
bool syncTextItem( PNS::NODE* aWorld, EDA_TEXT* aText, PCB_LAYER_ID aLayer );
|
2020-10-04 23:34:59 +00: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 10:54:28 +00:00
|
|
|
bool inheritTrackWidth( PNS::ITEM* aItem, int* aInheritedWidth );
|
2020-10-08 22:01:09 +00:00
|
|
|
|
2020-11-11 15:30:37 +00:00
|
|
|
protected:
|
2020-04-16 22:29:28 +00:00
|
|
|
PNS::NODE* m_world;
|
2020-11-11 15:30:37 +00:00
|
|
|
BOARD* m_board;
|
2021-10-24 02:46:31 +00:00
|
|
|
int m_startLayer;
|
2019-12-30 14:26:33 +00:00
|
|
|
};
|
|
|
|
|
2020-11-11 15:30:37 +00:00
|
|
|
class PNS_KICAD_IFACE : public PNS_KICAD_IFACE_BASE
|
|
|
|
{
|
2019-12-30 14:26:33 +00:00
|
|
|
public:
|
|
|
|
PNS_KICAD_IFACE();
|
|
|
|
~PNS_KICAD_IFACE();
|
|
|
|
|
|
|
|
void SetHostTool( PCB_TOOL_BASE* aTool );
|
|
|
|
|
|
|
|
void SetView( KIGFX::VIEW* aView );
|
|
|
|
void EraseView() override;
|
2020-10-05 19:54:12 +00:00
|
|
|
bool IsAnyLayerVisible( const LAYER_RANGE& aLayer ) const override;
|
|
|
|
bool IsItemVisible( const PNS::ITEM* aItem ) const override;
|
2019-12-30 14:26:33 +00:00
|
|
|
void HideItem( PNS::ITEM* aItem ) override;
|
2021-01-03 21:14:44 +00:00
|
|
|
void DisplayItem( const PNS::ITEM* aItem, int aClearance, bool aEdit = false ) override;
|
2020-10-14 00:04:47 +00:00
|
|
|
void DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, int aColor = -1 ) override;
|
2019-12-30 14:26:33 +00:00
|
|
|
void Commit() override;
|
|
|
|
void AddItem( PNS::ITEM* aItem ) override;
|
2021-02-08 01:06:56 +00:00
|
|
|
void UpdateItem( PNS::ITEM* aItem ) override;
|
2019-12-30 14:26:33 +00:00
|
|
|
void RemoveItem( PNS::ITEM* aItem ) override;
|
2020-04-02 09:33:55 +00:00
|
|
|
|
2019-12-30 14:26:33 +00:00
|
|
|
void UpdateNet( int aNetCode ) override;
|
|
|
|
|
2021-12-02 22:25:35 +00:00
|
|
|
EDA_UNITS GetUnits() const override;
|
2021-10-24 02:46:31 +00:00
|
|
|
|
2019-12-30 14:26:33 +00:00
|
|
|
private:
|
2020-10-17 12:52:18 +00:00
|
|
|
struct OFFSET
|
|
|
|
{
|
2020-04-02 09:33:55 +00:00
|
|
|
VECTOR2I p_old, p_new;
|
2020-02-28 22:09:19 +00:00
|
|
|
};
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
std::map<PAD*, OFFSET> m_fpOffsets;
|
2020-10-17 12:52:18 +00:00
|
|
|
KIGFX::VIEW* m_view;
|
|
|
|
KIGFX::VIEW_GROUP* m_previewItems;
|
|
|
|
std::unordered_set<BOARD_ITEM*> m_hiddenItems;
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2020-10-17 12:52:18 +00:00
|
|
|
PCB_TOOL_BASE* m_tool;
|
|
|
|
std::unique_ptr<BOARD_COMMIT> m_commit;
|
2016-08-15 15:16:47 +00:00
|
|
|
};
|
|
|
|
|
2019-12-30 14:26:33 +00:00
|
|
|
|
2016-08-15 15:16:47 +00:00
|
|
|
#endif
|