2016-08-15 15:16:47 +00:00
|
|
|
/*
|
|
|
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
|
|
|
*
|
2016-08-15 15:16:48 +00:00
|
|
|
* Copyright (C) 2013-2016 CERN
|
2023-03-04 18:02:05 +00:00
|
|
|
* Copyright (C) 2016-2023 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/>.
|
|
|
|
*/
|
|
|
|
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2018-02-02 20:57:12 +00:00
|
|
|
#include <board_connected_item.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <board_design_settings.h>
|
2023-08-22 12:06:33 +00:00
|
|
|
#include <netinfo.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <footprint.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <pad.h>
|
2021-06-11 21:07:02 +00:00
|
|
|
#include <pcb_track.h>
|
2020-11-11 23:05:59 +00:00
|
|
|
#include <zone.h>
|
2020-10-04 23:34:59 +00:00
|
|
|
#include <pcb_shape.h>
|
2023-10-19 10:38:26 +00:00
|
|
|
#include <pcb_generator.h>
|
2020-10-04 23:34:59 +00:00
|
|
|
#include <pcb_text.h>
|
2016-06-21 15:06:28 +00:00
|
|
|
#include <board_commit.h>
|
2021-07-29 09:47:43 +00:00
|
|
|
#include <layer_ids.h>
|
2016-08-15 15:16:47 +00:00
|
|
|
#include <geometry/convex_hull.h>
|
2018-02-22 10:19:33 +00:00
|
|
|
#include <confirm.h>
|
2021-12-02 22:25:35 +00:00
|
|
|
#include <tools/pcb_tool_base.h>
|
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <settings/app_settings.h>
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2023-09-18 23:52:27 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2016-08-15 15:16:47 +00:00
|
|
|
#include <pcb_painter.h>
|
|
|
|
|
|
|
|
#include <geometry/shape.h>
|
|
|
|
#include <geometry/shape_line_chain.h>
|
2018-02-04 12:09:30 +00:00
|
|
|
#include <geometry/shape_arc.h>
|
2020-01-07 17:12:59 +00:00
|
|
|
#include <geometry/shape_simple.h>
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2020-10-08 21:57:08 +00:00
|
|
|
#include <drc/drc_rule.h>
|
|
|
|
#include <drc/drc_engine.h>
|
|
|
|
|
2022-10-16 21:21:14 +00:00
|
|
|
#include <connectivity/connectivity_data.h>
|
|
|
|
|
2021-06-01 05:17:57 +00:00
|
|
|
#include <wx/log.h>
|
|
|
|
|
2019-12-05 13:43:55 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2020-07-03 23:33:36 +00:00
|
|
|
#include <advanced_config.h>
|
2021-12-26 00:36:12 +00:00
|
|
|
#include <pcbnew_settings.h>
|
2022-01-03 16:14:55 +00:00
|
|
|
#include <macros.h>
|
2020-07-03 23:33:36 +00:00
|
|
|
|
2016-08-15 15:16:47 +00:00
|
|
|
#include "pns_kicad_iface.h"
|
2019-05-17 00:13:21 +00:00
|
|
|
#include "pns_arc.h"
|
2020-10-08 22:01:09 +00:00
|
|
|
#include "pns_sizes_settings.h"
|
2016-08-15 15:16:47 +00:00
|
|
|
#include "pns_item.h"
|
2023-03-06 19:48:42 +00:00
|
|
|
#include "pns_line.h"
|
2016-08-15 15:16:47 +00:00
|
|
|
#include "pns_solid.h"
|
|
|
|
#include "pns_segment.h"
|
|
|
|
#include "pns_node.h"
|
|
|
|
#include "pns_router.h"
|
2016-08-15 15:16:48 +00:00
|
|
|
#include "pns_debug_decorator.h"
|
2016-08-15 15:16:47 +00:00
|
|
|
#include "router_preview_item.h"
|
|
|
|
|
2019-07-24 15:19:03 +00:00
|
|
|
typedef VECTOR2I::extended_type ecoord;
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2022-08-03 09:10:23 +00:00
|
|
|
struct CLEARANCE_CACHE_KEY
|
|
|
|
{
|
|
|
|
const PNS::ITEM* A;
|
|
|
|
const PNS::ITEM* B;
|
|
|
|
bool Flag;
|
|
|
|
|
|
|
|
bool operator==(const CLEARANCE_CACHE_KEY& other) const
|
|
|
|
{
|
|
|
|
return A == other.A && B == other.B && Flag == other.Flag;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
template <>
|
|
|
|
struct hash<CLEARANCE_CACHE_KEY>
|
|
|
|
{
|
|
|
|
std::size_t operator()( const CLEARANCE_CACHE_KEY& k ) const
|
|
|
|
{
|
2024-03-29 22:11:23 +00:00
|
|
|
size_t retval = 0xBADC0FFEE0DDF00D;
|
|
|
|
hash_combine( retval, hash<const void*>()( k.A ), hash<const void*>()( k.B ), hash<int>()( k.Flag ) );
|
|
|
|
return retval;
|
2022-08-03 09:10:23 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
class PNS_PCBNEW_RULE_RESOLVER : public PNS::RULE_RESOLVER
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-04-16 22:29:28 +00:00
|
|
|
PNS_PCBNEW_RULE_RESOLVER( BOARD* aBoard, PNS::ROUTER_IFACE* aRouterIface );
|
2016-08-15 15:16:47 +00:00
|
|
|
virtual ~PNS_PCBNEW_RULE_RESOLVER();
|
|
|
|
|
2023-11-07 11:57:06 +00:00
|
|
|
int Clearance( const PNS::ITEM* aA, const PNS::ITEM* aB,
|
|
|
|
bool aUseClearanceEpsilon = true ) override;
|
2021-01-01 00:29:05 +00:00
|
|
|
|
2023-11-07 11:57:06 +00:00
|
|
|
PNS::NET_HANDLE DpCoupledNet( PNS::NET_HANDLE aNet ) override;
|
|
|
|
int DpNetPolarity( PNS::NET_HANDLE aNet ) override;
|
|
|
|
bool DpNetPair( const PNS::ITEM* aItem, PNS::NET_HANDLE& aNetP,
|
|
|
|
PNS::NET_HANDLE& aNetN ) override;
|
2023-08-22 12:06:33 +00:00
|
|
|
|
2023-11-07 11:57:06 +00:00
|
|
|
int NetCode( PNS::NET_HANDLE aNet ) override;
|
|
|
|
wxString NetName( PNS::NET_HANDLE aNet ) override;
|
2019-07-24 15:19:03 +00:00
|
|
|
|
2023-11-07 11:57:06 +00:00
|
|
|
bool IsInNetTie( const PNS::ITEM* aA ) override;
|
|
|
|
bool IsNetTieExclusion( const PNS::ITEM* aItem, const VECTOR2I& aCollisionPos,
|
|
|
|
const PNS::ITEM* aCollidingItem ) override;
|
2022-08-19 17:34:53 +00:00
|
|
|
|
2023-12-09 21:06:16 +00:00
|
|
|
bool IsDrilledHole( const PNS::ITEM* aItem ) override;
|
|
|
|
bool IsNonPlatedSlot( const PNS::ITEM* aItem ) override;
|
|
|
|
|
2023-11-07 11:57:06 +00:00
|
|
|
/**
|
|
|
|
* @return true if \a aObstacle is a keepout. Set \a aEnforce if said keepout's rules
|
|
|
|
* exclude \a aItem.
|
|
|
|
*/
|
|
|
|
bool IsKeepout( const PNS::ITEM* aObstacle, const PNS::ITEM* aItem, bool* aEnforce ) override;
|
2022-09-14 21:02:30 +00:00
|
|
|
|
2023-11-07 11:57:06 +00:00
|
|
|
bool QueryConstraint( PNS::CONSTRAINT_TYPE aType, const PNS::ITEM* aItemA,
|
|
|
|
const PNS::ITEM* aItemB, int aLayer,
|
|
|
|
PNS::CONSTRAINT* aConstraint ) override;
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2022-08-29 20:21:46 +00:00
|
|
|
int ClearanceEpsilon() const override { return m_clearanceEpsilon; }
|
2021-04-18 13:50:06 +00:00
|
|
|
|
2023-05-31 21:20:28 +00:00
|
|
|
void ClearCacheForItems( std::vector<const PNS::ITEM*>& aItems ) override;
|
2022-11-16 21:05:12 +00:00
|
|
|
void ClearCaches() override;
|
2023-10-01 14:12:24 +00:00
|
|
|
void ClearTemporaryCaches() override;
|
2021-11-25 20:38:04 +00:00
|
|
|
|
2023-11-07 11:57:06 +00:00
|
|
|
private:
|
|
|
|
BOARD_ITEM* getBoardItem( const PNS::ITEM* aItem, int aLayer, int aIdx = 0 );
|
|
|
|
|
2020-11-11 15:30:37 +00:00
|
|
|
private:
|
2020-04-16 22:29:28 +00:00
|
|
|
PNS::ROUTER_IFACE* m_routerIface;
|
2020-10-31 15:33:02 +00:00
|
|
|
BOARD* m_board;
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_TRACK m_dummyTracks[2];
|
|
|
|
PCB_ARC m_dummyArcs[2];
|
|
|
|
PCB_VIA m_dummyVias[2];
|
2021-03-29 23:41:17 +00:00
|
|
|
int m_clearanceEpsilon;
|
2020-11-11 15:30:37 +00:00
|
|
|
|
2022-08-03 09:10:23 +00:00
|
|
|
std::unordered_map<CLEARANCE_CACHE_KEY, int> m_clearanceCache;
|
2023-10-01 14:12:24 +00:00
|
|
|
std::unordered_map<CLEARANCE_CACHE_KEY, int> m_tempClearanceCache;
|
2016-08-15 15:16:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-10-31 15:33:02 +00:00
|
|
|
PNS_PCBNEW_RULE_RESOLVER::PNS_PCBNEW_RULE_RESOLVER( BOARD* aBoard,
|
|
|
|
PNS::ROUTER_IFACE* aRouterIface ) :
|
2020-04-16 22:29:28 +00:00
|
|
|
m_routerIface( aRouterIface ),
|
2020-10-31 15:33:02 +00:00
|
|
|
m_board( aBoard ),
|
2021-04-08 01:30:18 +00:00
|
|
|
m_dummyTracks{ { aBoard }, { aBoard } },
|
|
|
|
m_dummyArcs{ { aBoard }, { aBoard } },
|
2022-11-16 20:52:58 +00:00
|
|
|
m_dummyVias{ { aBoard }, { aBoard } }
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2023-06-21 17:14:41 +00:00
|
|
|
for( PCB_TRACK& track : m_dummyTracks )
|
|
|
|
track.SetFlags( ROUTER_TRANSIENT );
|
|
|
|
|
|
|
|
for( PCB_ARC& arc : m_dummyArcs )
|
|
|
|
arc.SetFlags( ROUTER_TRANSIENT );
|
|
|
|
|
|
|
|
for ( PCB_VIA& via : m_dummyVias )
|
|
|
|
via.SetFlags( ROUTER_TRANSIENT );
|
|
|
|
|
2021-03-29 23:41:17 +00:00
|
|
|
if( aBoard )
|
|
|
|
m_clearanceEpsilon = aBoard->GetDesignSettings().GetDRCEpsilon();
|
|
|
|
else
|
|
|
|
m_clearanceEpsilon = 0;
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
|
2016-08-15 15:16:47 +00:00
|
|
|
PNS_PCBNEW_RULE_RESOLVER::~PNS_PCBNEW_RULE_RESOLVER()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
|
2022-08-19 17:34:53 +00:00
|
|
|
bool PNS_PCBNEW_RULE_RESOLVER::IsInNetTie( const PNS::ITEM* aA )
|
|
|
|
{
|
2023-04-06 16:59:43 +00:00
|
|
|
BOARD_ITEM* item = aA->BoardItem();
|
2022-08-19 17:34:53 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
return item && item->GetParentFootprint() && item->GetParentFootprint()->IsNetTie();
|
2022-08-19 17:34:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PNS_PCBNEW_RULE_RESOLVER::IsNetTieExclusion( const PNS::ITEM* aItem,
|
|
|
|
const VECTOR2I& aCollisionPos,
|
|
|
|
const PNS::ITEM* aCollidingItem )
|
|
|
|
{
|
2023-03-04 18:02:05 +00:00
|
|
|
wxCHECK( aItem && aCollidingItem, false );
|
|
|
|
|
2022-08-19 17:34:53 +00:00
|
|
|
std::shared_ptr<DRC_ENGINE> drcEngine = m_board->GetDesignSettings().m_DRCEngine;
|
2023-04-06 16:59:43 +00:00
|
|
|
BOARD_ITEM* item = aItem->BoardItem();
|
|
|
|
BOARD_ITEM* collidingItem = aCollidingItem->BoardItem();
|
2022-08-19 17:34:53 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
FOOTPRINT* collidingFp = collidingItem->GetParentFootprint();
|
2023-04-06 16:59:43 +00:00
|
|
|
FOOTPRINT* itemFp = item ? item->GetParentFootprint() : nullptr;
|
2023-02-15 02:08:30 +00:00
|
|
|
|
|
|
|
if( collidingFp && itemFp && ( collidingFp == itemFp ) && itemFp->IsNetTie() )
|
|
|
|
{
|
|
|
|
// Two items colliding from the same net tie footprint are not checked
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-03-06 12:12:11 +00:00
|
|
|
if( drcEngine )
|
2022-08-19 17:34:53 +00:00
|
|
|
{
|
2023-08-22 12:06:33 +00:00
|
|
|
return drcEngine->IsNetTieExclusion( NetCode( aItem->Net() ), ToLAYER_ID( aItem->Layer() ),
|
2022-08-19 17:34:53 +00:00
|
|
|
aCollisionPos, collidingItem );
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-11-07 11:57:06 +00:00
|
|
|
bool PNS_PCBNEW_RULE_RESOLVER::IsKeepout( const PNS::ITEM* aObstacle, const PNS::ITEM* aItem,
|
|
|
|
bool* aEnforce )
|
2022-09-14 21:02:30 +00:00
|
|
|
{
|
|
|
|
auto checkKeepout =
|
|
|
|
[]( const ZONE* aKeepout, const BOARD_ITEM* aOther )
|
|
|
|
{
|
2023-11-27 08:52:18 +00:00
|
|
|
if( !aOther )
|
|
|
|
return false;
|
|
|
|
|
2022-09-14 21:02:30 +00:00
|
|
|
if( aKeepout->GetDoNotAllowTracks() && aOther->IsType( { PCB_ARC_T, PCB_TRACE_T } ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if( aKeepout->GetDoNotAllowVias() && aOther->Type() == PCB_VIA_T )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if( aKeepout->GetDoNotAllowPads() && aOther->Type() == PCB_PAD_T )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// Incomplete test, but better than nothing:
|
|
|
|
if( aKeepout->GetDoNotAllowFootprints() && aOther->Type() == PCB_PAD_T )
|
|
|
|
{
|
|
|
|
return !aKeepout->GetParentFootprint()
|
|
|
|
|| aKeepout->GetParentFootprint() != aOther->GetParentFootprint();
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
2023-11-07 11:57:06 +00:00
|
|
|
if( aObstacle->Parent() && aObstacle->Parent()->Type() == PCB_ZONE_T )
|
2022-09-14 21:02:30 +00:00
|
|
|
{
|
2023-11-07 11:57:06 +00:00
|
|
|
const ZONE* zone = static_cast<ZONE*>( aObstacle->Parent() );
|
2023-07-15 16:55:12 +00:00
|
|
|
|
2023-11-07 11:57:06 +00:00
|
|
|
if( zone->GetIsRuleArea() )
|
|
|
|
{
|
|
|
|
*aEnforce = checkKeepout( zone, getBoardItem( aItem, aObstacle->Layer() ) );
|
|
|
|
return true;
|
|
|
|
}
|
2022-09-14 21:02:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-30 12:52:34 +00:00
|
|
|
static bool isCopper( const PNS::ITEM* aItem )
|
2021-01-02 16:32:03 +00:00
|
|
|
{
|
2022-08-30 12:52:34 +00:00
|
|
|
if ( !aItem )
|
|
|
|
return false;
|
|
|
|
|
2023-04-08 14:02:48 +00:00
|
|
|
const BOARD_ITEM *parent = aItem->Parent();
|
2021-01-02 16:32:03 +00:00
|
|
|
|
2023-04-08 14:02:48 +00:00
|
|
|
return !parent || parent->IsOnCopperLayer();
|
2021-01-02 16:32:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-30 12:52:34 +00:00
|
|
|
static bool isHole( const PNS::ITEM* aItem )
|
|
|
|
{
|
|
|
|
if ( !aItem )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return aItem->OfKind( PNS::ITEM::HOLE_T );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-12-09 21:06:16 +00:00
|
|
|
static bool isEdge( const PNS::ITEM* aItem )
|
2023-05-21 18:57:47 +00:00
|
|
|
{
|
2023-12-09 21:06:16 +00:00
|
|
|
if ( !aItem )
|
2023-05-21 18:57:47 +00:00
|
|
|
return false;
|
|
|
|
|
2023-12-09 21:06:16 +00:00
|
|
|
const PCB_SHAPE *parent = dynamic_cast<PCB_SHAPE*>( aItem->BoardItem() );
|
2023-05-21 18:57:47 +00:00
|
|
|
|
2023-12-09 21:06:16 +00:00
|
|
|
return parent && ( parent->IsOnLayer( Edge_Cuts ) || parent->IsOnLayer( Margin ) );
|
2023-05-21 18:57:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-12-09 21:06:16 +00:00
|
|
|
bool PNS_PCBNEW_RULE_RESOLVER::IsDrilledHole( const PNS::ITEM* aItem )
|
2023-05-21 18:57:47 +00:00
|
|
|
{
|
|
|
|
if( !isHole( aItem ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( PAD* pad = dynamic_cast<PAD*>( aItem->Parent() ) )
|
2023-12-09 21:06:16 +00:00
|
|
|
return pad->GetDrillSizeX() && pad->GetDrillSizeX() == pad->GetDrillSizeY();
|
2023-05-21 18:57:47 +00:00
|
|
|
|
|
|
|
// Via holes are (currently) always round
|
|
|
|
|
2023-12-09 21:06:16 +00:00
|
|
|
return true;
|
2023-05-21 18:57:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-12-09 21:06:16 +00:00
|
|
|
bool PNS_PCBNEW_RULE_RESOLVER::IsNonPlatedSlot( const PNS::ITEM* aItem )
|
2021-01-01 00:29:05 +00:00
|
|
|
{
|
2023-12-09 21:06:16 +00:00
|
|
|
if( !isHole( aItem ) )
|
2022-08-30 12:52:34 +00:00
|
|
|
return false;
|
|
|
|
|
2023-12-09 21:06:16 +00:00
|
|
|
BOARD_ITEM* parent = aItem->Parent();
|
2021-02-11 22:07:15 +00:00
|
|
|
|
2023-12-09 21:06:16 +00:00
|
|
|
if( !parent && aItem->ParentPadVia() )
|
|
|
|
parent = aItem->ParentPadVia()->Parent();
|
|
|
|
|
|
|
|
if( parent )
|
|
|
|
{
|
|
|
|
if( parent->Type() == PCB_PAD_T )
|
|
|
|
{
|
|
|
|
PAD* pad = static_cast<PAD*>( parent );
|
|
|
|
|
|
|
|
return pad->GetAttribute() == PAD_ATTRIB::NPTH
|
|
|
|
&& pad->GetDrillSizeX() != pad->GetDrillSizeY();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Via holes are (currently) always round, and always plated
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2021-01-01 00:29:05 +00:00
|
|
|
}
|
|
|
|
|
2020-10-08 22:01:09 +00:00
|
|
|
|
2023-11-07 11:57:06 +00:00
|
|
|
BOARD_ITEM* PNS_PCBNEW_RULE_RESOLVER::getBoardItem( const PNS::ITEM* aItem, int aLayer, int aIdx )
|
|
|
|
{
|
|
|
|
switch( aItem->Kind() )
|
|
|
|
{
|
|
|
|
case PNS::ITEM::ARC_T:
|
|
|
|
m_dummyArcs[aIdx].SetLayer( ToLAYER_ID( aLayer ) );
|
|
|
|
m_dummyArcs[aIdx].SetNet( static_cast<NETINFO_ITEM*>( aItem->Net() ) );
|
|
|
|
m_dummyArcs[aIdx].SetStart( aItem->Anchor( 0 ) );
|
|
|
|
m_dummyArcs[aIdx].SetEnd( aItem->Anchor( 1 ) );
|
|
|
|
return &m_dummyArcs[aIdx];
|
|
|
|
|
|
|
|
case PNS::ITEM::VIA_T:
|
|
|
|
case PNS::ITEM::HOLE_T:
|
|
|
|
m_dummyVias[aIdx].SetLayer( ToLAYER_ID( aLayer ) );
|
|
|
|
m_dummyVias[aIdx].SetNet( static_cast<NETINFO_ITEM*>( aItem->Net() ) );
|
|
|
|
m_dummyVias[aIdx].SetStart( aItem->Anchor( 0 ) );
|
|
|
|
return &m_dummyVias[aIdx];
|
|
|
|
|
|
|
|
case PNS::ITEM::SEGMENT_T:
|
|
|
|
case PNS::ITEM::LINE_T:
|
|
|
|
m_dummyTracks[aIdx].SetLayer( ToLAYER_ID( aLayer ) );
|
|
|
|
m_dummyTracks[aIdx].SetNet( static_cast<NETINFO_ITEM*>( aItem->Net() ) );
|
|
|
|
m_dummyTracks[aIdx].SetStart( aItem->Anchor( 0 ) );
|
|
|
|
m_dummyTracks[aIdx].SetEnd( aItem->Anchor( 1 ) );
|
|
|
|
return &m_dummyTracks[aIdx];
|
|
|
|
|
|
|
|
default:
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-10 18:29:41 +00:00
|
|
|
bool PNS_PCBNEW_RULE_RESOLVER::QueryConstraint( PNS::CONSTRAINT_TYPE aType,
|
|
|
|
const PNS::ITEM* aItemA, const PNS::ITEM* aItemB,
|
|
|
|
int aLayer, PNS::CONSTRAINT* aConstraint )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2020-10-08 21:57:08 +00:00
|
|
|
std::shared_ptr<DRC_ENGINE> drcEngine = m_board->GetDesignSettings().m_DRCEngine;
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2020-10-08 21:57:08 +00:00
|
|
|
if( !drcEngine )
|
|
|
|
return false;
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2021-01-01 22:29:15 +00:00
|
|
|
DRC_CONSTRAINT_T hostType;
|
2016-10-18 15:40:22 +00:00
|
|
|
|
2020-10-08 21:57:08 +00:00
|
|
|
switch ( aType )
|
|
|
|
{
|
2023-11-01 14:11:40 +00:00
|
|
|
case PNS::CONSTRAINT_TYPE::CT_CLEARANCE: hostType = CLEARANCE_CONSTRAINT; break;
|
|
|
|
case PNS::CONSTRAINT_TYPE::CT_WIDTH: hostType = TRACK_WIDTH_CONSTRAINT; break;
|
|
|
|
case PNS::CONSTRAINT_TYPE::CT_DIFF_PAIR_GAP: hostType = DIFF_PAIR_GAP_CONSTRAINT; break;
|
|
|
|
case PNS::CONSTRAINT_TYPE::CT_LENGTH: hostType = LENGTH_CONSTRAINT; break;
|
|
|
|
case PNS::CONSTRAINT_TYPE::CT_DIFF_PAIR_SKEW: hostType = SKEW_CONSTRAINT; break;
|
|
|
|
case PNS::CONSTRAINT_TYPE::CT_MAX_UNCOUPLED: hostType = MAX_UNCOUPLED_CONSTRAINT; break;
|
|
|
|
case PNS::CONSTRAINT_TYPE::CT_VIA_DIAMETER: hostType = VIA_DIAMETER_CONSTRAINT; break;
|
|
|
|
case PNS::CONSTRAINT_TYPE::CT_VIA_HOLE: hostType = HOLE_SIZE_CONSTRAINT; break;
|
|
|
|
case PNS::CONSTRAINT_TYPE::CT_HOLE_CLEARANCE: hostType = HOLE_CLEARANCE_CONSTRAINT; break;
|
|
|
|
case PNS::CONSTRAINT_TYPE::CT_EDGE_CLEARANCE: hostType = EDGE_CLEARANCE_CONSTRAINT; break;
|
|
|
|
case PNS::CONSTRAINT_TYPE::CT_HOLE_TO_HOLE: hostType = HOLE_TO_HOLE_CONSTRAINT; break;
|
|
|
|
case PNS::CONSTRAINT_TYPE::CT_PHYSICAL_CLEARANCE: hostType = PHYSICAL_CLEARANCE_CONSTRAINT; break;
|
|
|
|
default: return false; // should not happen
|
2020-10-08 21:57:08 +00:00
|
|
|
}
|
|
|
|
|
2023-04-06 16:59:43 +00:00
|
|
|
BOARD_ITEM* parentA = aItemA ? aItemA->BoardItem() : nullptr;
|
|
|
|
BOARD_ITEM* parentB = aItemB ? aItemB->BoardItem() : nullptr;
|
2020-10-31 23:23:23 +00:00
|
|
|
DRC_CONSTRAINT hostConstraint;
|
2020-10-12 19:55:36 +00:00
|
|
|
|
2020-10-31 15:33:02 +00:00
|
|
|
// A track being routed may not have a BOARD_ITEM associated yet.
|
2020-11-11 00:18:35 +00:00
|
|
|
if( aItemA && !parentA )
|
2023-11-07 11:57:06 +00:00
|
|
|
parentA = getBoardItem( aItemA, aLayer, 0 );
|
2020-10-31 23:23:23 +00:00
|
|
|
|
|
|
|
if( aItemB && !parentB )
|
2023-11-07 11:57:06 +00:00
|
|
|
parentB = getBoardItem( aItemB, aLayer, 1 );
|
2020-10-08 22:01:09 +00:00
|
|
|
|
2020-10-12 19:55:36 +00:00
|
|
|
if( parentA )
|
2022-10-25 11:30:25 +00:00
|
|
|
hostConstraint = drcEngine->EvalRules( hostType, parentA, parentB, ToLAYER_ID( aLayer ) );
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2020-10-08 21:57:08 +00:00
|
|
|
if( hostConstraint.IsNull() )
|
|
|
|
return false;
|
2020-10-08 22:01:09 +00:00
|
|
|
|
2022-07-09 17:24:19 +00:00
|
|
|
if( hostConstraint.GetSeverity() == RPT_SEVERITY_IGNORE )
|
|
|
|
{
|
|
|
|
aConstraint->m_Value.SetMin( -1 );
|
|
|
|
aConstraint->m_RuleName = hostConstraint.GetName();
|
|
|
|
aConstraint->m_Type = aType;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-10-08 22:01:09 +00:00
|
|
|
switch ( aType )
|
|
|
|
{
|
|
|
|
case PNS::CONSTRAINT_TYPE::CT_CLEARANCE:
|
|
|
|
case PNS::CONSTRAINT_TYPE::CT_WIDTH:
|
|
|
|
case PNS::CONSTRAINT_TYPE::CT_DIFF_PAIR_GAP:
|
2020-10-10 18:29:41 +00:00
|
|
|
case PNS::CONSTRAINT_TYPE::CT_VIA_DIAMETER:
|
|
|
|
case PNS::CONSTRAINT_TYPE::CT_VIA_HOLE:
|
2021-01-01 00:29:05 +00:00
|
|
|
case PNS::CONSTRAINT_TYPE::CT_HOLE_CLEARANCE:
|
|
|
|
case PNS::CONSTRAINT_TYPE::CT_EDGE_CLEARANCE:
|
|
|
|
case PNS::CONSTRAINT_TYPE::CT_HOLE_TO_HOLE:
|
2023-10-14 11:11:46 +00:00
|
|
|
case PNS::CONSTRAINT_TYPE::CT_LENGTH:
|
|
|
|
case PNS::CONSTRAINT_TYPE::CT_DIFF_PAIR_SKEW:
|
2023-10-15 21:45:18 +00:00
|
|
|
case PNS::CONSTRAINT_TYPE::CT_MAX_UNCOUPLED:
|
2023-11-01 14:11:40 +00:00
|
|
|
case PNS::CONSTRAINT_TYPE::CT_PHYSICAL_CLEARANCE:
|
2020-10-08 22:01:09 +00:00
|
|
|
aConstraint->m_Value = hostConstraint.GetValue();
|
2020-10-09 13:26:09 +00:00
|
|
|
aConstraint->m_RuleName = hostConstraint.GetName();
|
2020-10-08 22:01:09 +00:00
|
|
|
aConstraint->m_Type = aType;
|
|
|
|
return true;
|
|
|
|
|
2020-10-11 10:19:07 +00:00
|
|
|
default:
|
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-05-31 21:20:28 +00:00
|
|
|
void PNS_PCBNEW_RULE_RESOLVER::ClearCacheForItems( std::vector<const PNS::ITEM*>& aItems )
|
2021-11-25 20:38:04 +00:00
|
|
|
{
|
2023-05-31 21:20:28 +00:00
|
|
|
int n_pruned = 0;
|
|
|
|
std::set<const PNS::ITEM*> remainingItems( aItems.begin(), aItems.end() );
|
|
|
|
|
|
|
|
/* We need to carefully check both A and B item pointers in the cache against dirty/invalidated
|
|
|
|
items in the set, as the clearance relation is commutative ( CL[a,b] == CL[b,a] ). The code
|
|
|
|
below is a bit ugly, but works in O(n*log(m)) and is run once or twice during ROUTER::Move() call
|
|
|
|
- so I hope it still gets better performance than no cache at all */
|
|
|
|
for( auto it = m_clearanceCache.begin(); it != m_clearanceCache.end(); )
|
|
|
|
{
|
|
|
|
bool dirty = remainingItems.find( it->first.A ) != remainingItems.end();
|
|
|
|
dirty |= remainingItems.find( it->first.B) != remainingItems.end();
|
2022-08-03 09:10:23 +00:00
|
|
|
|
2023-05-31 21:20:28 +00:00
|
|
|
if( dirty )
|
|
|
|
{
|
|
|
|
it = m_clearanceCache.erase( it );
|
|
|
|
n_pruned++;
|
|
|
|
} else
|
|
|
|
it++;
|
|
|
|
}
|
|
|
|
#if 0
|
|
|
|
printf("ClearCache : n_pruned %d\n", n_pruned );
|
|
|
|
#endif
|
2021-11-25 20:38:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-16 21:05:12 +00:00
|
|
|
void PNS_PCBNEW_RULE_RESOLVER::ClearCaches()
|
|
|
|
{
|
|
|
|
m_clearanceCache.clear();
|
2023-10-01 14:12:24 +00:00
|
|
|
m_tempClearanceCache.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PNS_PCBNEW_RULE_RESOLVER::ClearTemporaryCaches()
|
|
|
|
{
|
|
|
|
m_tempClearanceCache.clear();
|
2022-11-16 21:05:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-06-03 21:20:47 +00:00
|
|
|
int PNS_PCBNEW_RULE_RESOLVER::Clearance( const PNS::ITEM* aA, const PNS::ITEM* aB,
|
|
|
|
bool aUseClearanceEpsilon )
|
2017-01-25 09:33:49 +00:00
|
|
|
{
|
2022-08-03 09:10:23 +00:00
|
|
|
CLEARANCE_CACHE_KEY key = { aA, aB, aUseClearanceEpsilon };
|
2020-11-11 15:30:37 +00:00
|
|
|
|
2023-10-01 14:12:24 +00:00
|
|
|
// Search cache (used for actual board items)
|
|
|
|
auto it = m_clearanceCache.find( key );
|
2020-11-11 15:30:37 +00:00
|
|
|
if( it != m_clearanceCache.end() )
|
|
|
|
return it->second;
|
|
|
|
|
2023-10-01 14:12:24 +00:00
|
|
|
// Search cache (used for temporary items within an algorithm)
|
|
|
|
it = m_tempClearanceCache.find( key );
|
|
|
|
if( it != m_tempClearanceCache.end() )
|
|
|
|
return it->second;
|
|
|
|
|
2020-10-08 21:57:08 +00:00
|
|
|
PNS::CONSTRAINT constraint;
|
2022-10-23 23:13:05 +00:00
|
|
|
int rv = 0;
|
|
|
|
LAYER_RANGE layers;
|
|
|
|
|
|
|
|
if( !aB )
|
|
|
|
layers = aA->Layers();
|
|
|
|
else if( isEdge( aA ) )
|
|
|
|
layers = aB->Layers();
|
|
|
|
else if( isEdge( aB ) )
|
|
|
|
layers = aA->Layers();
|
2021-02-25 22:56:34 +00:00
|
|
|
else
|
2022-10-23 23:13:05 +00:00
|
|
|
layers = aA->Layers().Intersection( aB->Layers() );
|
2020-10-08 22:01:09 +00:00
|
|
|
|
2022-10-25 11:30:25 +00:00
|
|
|
// Normalize layer range (no -1 magic numbers)
|
2022-10-25 17:26:34 +00:00
|
|
|
layers = layers.Intersection( LAYER_RANGE( PCBNEW_LAYER_ID_START, PCB_LAYER_ID_COUNT - 1 ) );
|
2022-10-25 11:30:25 +00:00
|
|
|
|
2022-10-23 23:13:05 +00:00
|
|
|
for( int layer = layers.Start(); layer <= layers.End(); ++layer )
|
2021-01-01 00:29:05 +00:00
|
|
|
{
|
2023-12-09 21:06:16 +00:00
|
|
|
if( IsDrilledHole( aA ) && IsDrilledHole( aB ) )
|
2022-08-30 12:52:34 +00:00
|
|
|
{
|
|
|
|
if( QueryConstraint( PNS::CONSTRAINT_TYPE::CT_HOLE_TO_HOLE, aA, aB, layer, &constraint ) )
|
|
|
|
{
|
|
|
|
if( constraint.m_Value.Min() > rv )
|
|
|
|
rv = constraint.m_Value.Min();
|
|
|
|
}
|
|
|
|
}
|
2023-04-07 12:40:52 +00:00
|
|
|
else if( isHole( aA ) || isHole( aB ) )
|
2022-08-30 12:52:34 +00:00
|
|
|
{
|
|
|
|
if( QueryConstraint( PNS::CONSTRAINT_TYPE::CT_HOLE_CLEARANCE, aA, aB, layer, &constraint ) )
|
|
|
|
{
|
|
|
|
if( constraint.m_Value.Min() > rv )
|
|
|
|
rv = constraint.m_Value.Min();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( isCopper( aA ) && ( !aB || isCopper( aB ) ) )
|
2022-10-23 23:13:05 +00:00
|
|
|
{
|
|
|
|
if( QueryConstraint( PNS::CONSTRAINT_TYPE::CT_CLEARANCE, aA, aB, layer, &constraint ) )
|
|
|
|
{
|
|
|
|
if( constraint.m_Value.Min() > rv )
|
|
|
|
rv = constraint.m_Value.Min();
|
|
|
|
}
|
|
|
|
}
|
2023-05-21 18:57:47 +00:00
|
|
|
|
|
|
|
// No 'else'; non-plated milled holes get both HOLE_CLEARANCE and EDGE_CLEARANCE
|
2023-12-09 21:06:16 +00:00
|
|
|
if( isEdge( aA ) || IsNonPlatedSlot( aA ) || isEdge( aB ) || IsNonPlatedSlot( aB ) )
|
2020-10-18 19:58:03 +00:00
|
|
|
{
|
2022-10-23 23:13:05 +00:00
|
|
|
if( QueryConstraint( PNS::CONSTRAINT_TYPE::CT_EDGE_CLEARANCE, aA, aB, layer, &constraint ) )
|
|
|
|
{
|
|
|
|
if( constraint.m_Value.Min() > rv )
|
|
|
|
rv = constraint.m_Value.Min();
|
|
|
|
}
|
2020-10-18 19:58:03 +00:00
|
|
|
}
|
2023-11-01 14:11:40 +00:00
|
|
|
|
|
|
|
if( QueryConstraint( PNS::CONSTRAINT_TYPE::CT_PHYSICAL_CLEARANCE, aA, aB, layer, &constraint ) )
|
|
|
|
{
|
|
|
|
if( constraint.m_Value.Min() > rv )
|
|
|
|
rv = constraint.m_Value.Min();
|
|
|
|
}
|
2020-10-08 22:01:09 +00:00
|
|
|
}
|
2020-10-08 21:57:08 +00:00
|
|
|
|
2022-12-24 12:31:41 +00:00
|
|
|
if( aUseClearanceEpsilon && rv > 0 )
|
|
|
|
rv = std::max( 0, rv - m_clearanceEpsilon );
|
2022-06-03 21:20:47 +00:00
|
|
|
|
2023-05-31 21:20:28 +00:00
|
|
|
|
|
|
|
/* It makes no sense to put items that have no owning NODE in the cache - they can be allocated on stack
|
|
|
|
and we can't really invalidate them in the cache when they are destroyed. Probably a better idea would be
|
2023-10-01 14:12:24 +00:00
|
|
|
to use a static unique counter in PNS::ITEM constructor to generate the cache keys. */
|
|
|
|
/* However, algorithms DO greatly benefit from using the cache, so ownerless items need to be cached.
|
|
|
|
In order to easily clear those only, a temporary cache is created. If this doesn't seem nice, an alternative
|
|
|
|
is clearing the full cache once it reaches a certain size. Also not pretty, but VERY effective
|
|
|
|
to keep things interactive. */
|
|
|
|
if( aA && aB )
|
2023-05-31 21:20:28 +00:00
|
|
|
{
|
2023-10-01 14:12:24 +00:00
|
|
|
if ( aA->Owner() && aB->Owner() )
|
|
|
|
m_clearanceCache[ key ] = rv;
|
|
|
|
else
|
|
|
|
m_tempClearanceCache[ key ] = rv;
|
2023-05-31 21:20:28 +00:00
|
|
|
}
|
|
|
|
|
2021-01-01 00:29:05 +00:00
|
|
|
return rv;
|
|
|
|
}
|
2020-10-08 21:57:08 +00:00
|
|
|
|
2020-10-08 22:01:09 +00:00
|
|
|
|
2020-10-18 10:54:28 +00:00
|
|
|
bool PNS_KICAD_IFACE_BASE::inheritTrackWidth( PNS::ITEM* aItem, int* aInheritedWidth )
|
2020-10-08 22:01:09 +00:00
|
|
|
{
|
|
|
|
VECTOR2I p;
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
assert( aItem->Owner() != nullptr );
|
2020-10-08 22:01:09 +00:00
|
|
|
|
2021-04-08 01:30:18 +00:00
|
|
|
auto tryGetTrackWidth =
|
2023-09-15 17:58:24 +00:00
|
|
|
[]( PNS::ITEM* aPnsItem ) -> int
|
2021-04-05 22:48:28 +00:00
|
|
|
{
|
2023-09-15 17:58:24 +00:00
|
|
|
switch( aPnsItem->Kind() )
|
|
|
|
{
|
|
|
|
case PNS::ITEM::SEGMENT_T: return static_cast<PNS::SEGMENT*>( aPnsItem )->Width();
|
|
|
|
case PNS::ITEM::ARC_T: return static_cast<PNS::ARC*>( aPnsItem )->Width();
|
|
|
|
default: return -1;
|
|
|
|
}
|
|
|
|
};
|
2021-04-05 22:48:28 +00:00
|
|
|
|
|
|
|
int itemTrackWidth = tryGetTrackWidth( aItem );
|
|
|
|
|
|
|
|
if( itemTrackWidth > 0 )
|
|
|
|
{
|
|
|
|
*aInheritedWidth = itemTrackWidth;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-10-08 22:01:09 +00:00
|
|
|
switch( aItem->Kind() )
|
|
|
|
{
|
2023-09-15 17:58:24 +00:00
|
|
|
case PNS::ITEM::VIA_T: p = static_cast<PNS::VIA*>( aItem )->Pos(); break;
|
|
|
|
case PNS::ITEM::SOLID_T: p = static_cast<PNS::SOLID*>( aItem )->Pos(); break;
|
|
|
|
default: return false;
|
2020-10-08 22:01:09 +00:00
|
|
|
}
|
|
|
|
|
2022-08-29 20:21:46 +00:00
|
|
|
const PNS::JOINT* jt = static_cast<const PNS::NODE*>( aItem->Owner() )->FindJoint( p, aItem );
|
2020-10-08 22:01:09 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
assert( jt != nullptr );
|
2020-10-08 22:01:09 +00:00
|
|
|
|
|
|
|
int mval = INT_MAX;
|
|
|
|
|
2022-08-29 20:21:46 +00:00
|
|
|
PNS::ITEM_SET linkedSegs( jt->CLinks() );
|
2021-04-05 22:48:28 +00:00
|
|
|
linkedSegs.ExcludeItem( aItem ).FilterKinds( PNS::ITEM::SEGMENT_T | PNS::ITEM::ARC_T );
|
2020-10-08 22:01:09 +00:00
|
|
|
|
|
|
|
for( PNS::ITEM* item : linkedSegs.Items() )
|
|
|
|
{
|
2021-04-05 22:48:28 +00:00
|
|
|
int w = tryGetTrackWidth( item );
|
2023-09-15 18:04:12 +00:00
|
|
|
|
|
|
|
if( w > 0 )
|
|
|
|
mval = std::min( w, mval );
|
2020-10-08 22:01:09 +00:00
|
|
|
}
|
|
|
|
|
2020-10-18 10:54:28 +00:00
|
|
|
if( mval == INT_MAX )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
*aInheritedWidth = mval;
|
|
|
|
return true;
|
2020-10-08 22:01:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
bool PNS_KICAD_IFACE_BASE::ImportSizes( PNS::SIZES_SETTINGS& aSizes, PNS::ITEM* aStartItem,
|
2023-08-22 12:06:33 +00:00
|
|
|
PNS::NET_HANDLE aNet )
|
2020-10-08 22:01:09 +00:00
|
|
|
{
|
2020-10-11 10:19:07 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
|
|
|
|
PNS::CONSTRAINT constraint;
|
2020-10-08 22:01:09 +00:00
|
|
|
|
2021-10-24 02:46:31 +00:00
|
|
|
if( aStartItem && m_startLayer < 0 )
|
|
|
|
m_startLayer = aStartItem->Layer();
|
|
|
|
|
2023-01-31 22:48:09 +00:00
|
|
|
aSizes.SetClearance( bds.m_MinClearance );
|
2021-03-30 18:48:36 +00:00
|
|
|
aSizes.SetMinClearance( bds.m_MinClearance );
|
2022-10-07 12:20:56 +00:00
|
|
|
aSizes.SetClearanceSource( _( "board minimum clearance" ) );
|
2021-03-30 18:48:36 +00:00
|
|
|
|
2023-01-20 14:19:06 +00:00
|
|
|
if( m_ruleResolver->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_CLEARANCE, aStartItem, nullptr,
|
|
|
|
m_startLayer, &constraint ) )
|
|
|
|
{
|
|
|
|
if( constraint.m_Value.Min() > bds.m_MinClearance )
|
|
|
|
{
|
2023-01-31 22:48:09 +00:00
|
|
|
aSizes.SetClearance( constraint.m_Value.Min() );
|
2023-01-20 14:19:06 +00:00
|
|
|
aSizes.SetClearanceSource( constraint.m_RuleName );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-18 10:54:28 +00:00
|
|
|
int trackWidth = bds.m_TrackMinWidth;
|
|
|
|
bool found = false;
|
2022-10-07 12:20:56 +00:00
|
|
|
aSizes.SetWidthSource( _( "board minimum track width" ) );
|
2020-10-08 22:01:09 +00:00
|
|
|
|
2021-12-15 15:48:34 +00:00
|
|
|
if( bds.m_UseConnectedTrackWidth && !bds.m_TempOverrideTrackWidth && aStartItem != nullptr )
|
2020-10-08 22:01:09 +00:00
|
|
|
{
|
2020-10-18 10:54:28 +00:00
|
|
|
found = inheritTrackWidth( aStartItem, &trackWidth );
|
2021-07-03 17:21:51 +00:00
|
|
|
|
|
|
|
if( found )
|
|
|
|
aSizes.SetWidthSource( _( "existing track" ) );
|
2020-10-08 22:01:09 +00:00
|
|
|
}
|
2020-10-17 12:56:20 +00:00
|
|
|
|
2020-10-18 10:54:28 +00:00
|
|
|
if( !found && bds.UseNetClassTrack() && aStartItem )
|
2020-10-08 22:01:09 +00:00
|
|
|
{
|
2020-10-11 10:19:07 +00:00
|
|
|
if( m_ruleResolver->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_WIDTH, aStartItem, nullptr,
|
2021-10-24 02:46:31 +00:00
|
|
|
m_startLayer, &constraint ) )
|
2020-10-08 22:01:09 +00:00
|
|
|
{
|
2021-04-22 02:43:26 +00:00
|
|
|
trackWidth = std::max( trackWidth, constraint.m_Value.Opt() );
|
|
|
|
found = true;
|
2021-07-03 17:21:51 +00:00
|
|
|
|
|
|
|
if( trackWidth == constraint.m_Value.Opt() )
|
|
|
|
aSizes.SetWidthSource( constraint.m_RuleName );
|
2020-10-08 22:01:09 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-17 12:56:20 +00:00
|
|
|
|
2020-10-18 10:54:28 +00:00
|
|
|
if( !found )
|
2020-10-08 22:01:09 +00:00
|
|
|
{
|
2021-04-22 02:43:26 +00:00
|
|
|
trackWidth = std::max( trackWidth, bds.GetCurrentTrackWidth() );
|
2021-07-03 17:21:51 +00:00
|
|
|
|
|
|
|
if( bds.UseNetClassTrack() )
|
|
|
|
aSizes.SetWidthSource( _( "netclass 'Default'" ) );
|
|
|
|
else if( trackWidth == bds.GetCurrentTrackWidth() )
|
|
|
|
aSizes.SetWidthSource( _( "user choice" ) );
|
2020-10-08 22:01:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aSizes.SetTrackWidth( trackWidth );
|
2023-05-26 03:10:00 +00:00
|
|
|
aSizes.SetBoardMinTrackWidth( bds.m_TrackMinWidth );
|
2021-12-15 15:48:34 +00:00
|
|
|
aSizes.SetTrackWidthIsExplicit( !bds.m_UseConnectedTrackWidth || bds.m_TempOverrideTrackWidth );
|
2020-10-08 22:01:09 +00:00
|
|
|
|
2020-10-11 10:19:07 +00:00
|
|
|
int viaDiameter = bds.m_ViasMinSize;
|
|
|
|
int viaDrill = bds.m_MinThroughDrill;
|
2020-10-08 22:01:09 +00:00
|
|
|
|
2023-08-07 22:29:16 +00:00
|
|
|
PNS::VIA dummyVia, coupledVia;
|
|
|
|
|
|
|
|
if( aStartItem )
|
|
|
|
{
|
|
|
|
dummyVia.SetNet( aStartItem->Net() );
|
|
|
|
coupledVia.SetNet( m_ruleResolver->DpCoupledNet( aStartItem->Net() ) );
|
|
|
|
}
|
|
|
|
|
2020-10-10 23:14:12 +00:00
|
|
|
if( bds.UseNetClassVia() && aStartItem ) // netclass value
|
2020-10-08 22:01:09 +00:00
|
|
|
{
|
2023-08-07 22:29:16 +00:00
|
|
|
if( m_ruleResolver->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_VIA_DIAMETER, &dummyVia,
|
2021-10-24 02:46:31 +00:00
|
|
|
nullptr, m_startLayer, &constraint ) )
|
2020-10-10 18:29:41 +00:00
|
|
|
{
|
2021-04-22 02:43:26 +00:00
|
|
|
viaDiameter = std::max( viaDiameter, constraint.m_Value.Opt() );
|
2020-10-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
|
2023-08-07 22:29:16 +00:00
|
|
|
if( m_ruleResolver->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_VIA_HOLE, &dummyVia,
|
2022-10-05 15:44:25 +00:00
|
|
|
nullptr, m_startLayer, &constraint ) )
|
2020-10-10 18:29:41 +00:00
|
|
|
{
|
2021-04-22 02:43:26 +00:00
|
|
|
viaDrill = std::max( viaDrill, constraint.m_Value.Opt() );
|
2020-10-10 18:29:41 +00:00
|
|
|
}
|
2020-10-08 22:01:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
viaDiameter = bds.GetCurrentViaSize();
|
|
|
|
viaDrill = bds.GetCurrentViaDrill();
|
|
|
|
}
|
|
|
|
|
|
|
|
aSizes.SetViaDiameter( viaDiameter );
|
|
|
|
aSizes.SetViaDrill( viaDrill );
|
|
|
|
|
2020-10-11 10:19:07 +00:00
|
|
|
int diffPairWidth = bds.m_TrackMinWidth;
|
|
|
|
int diffPairGap = bds.m_MinClearance;
|
|
|
|
int diffPairViaGap = bds.m_MinClearance;
|
2020-10-08 22:01:09 +00:00
|
|
|
|
2022-10-07 12:20:56 +00:00
|
|
|
aSizes.SetDiffPairWidthSource( _( "board minimum track width" ) );
|
|
|
|
aSizes.SetDiffPairGapSource( _( "board minimum clearance" ) );
|
|
|
|
|
2021-04-13 03:10:15 +00:00
|
|
|
found = false;
|
|
|
|
|
|
|
|
// First try to pick up diff pair width from starting track, if enabled
|
|
|
|
if( bds.m_UseConnectedTrackWidth && aStartItem )
|
|
|
|
found = inheritTrackWidth( aStartItem, &diffPairWidth );
|
|
|
|
|
|
|
|
// Next, pick up gap from netclass, and width also if we didn't get a starting width above
|
2020-10-09 00:38:08 +00:00
|
|
|
if( bds.UseNetClassDiffPair() && aStartItem )
|
2020-10-08 22:01:09 +00:00
|
|
|
{
|
2021-04-13 03:10:15 +00:00
|
|
|
if( !found && m_ruleResolver->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_WIDTH, aStartItem,
|
2021-10-24 02:46:31 +00:00
|
|
|
nullptr, m_startLayer, &constraint ) )
|
2020-10-11 10:19:07 +00:00
|
|
|
{
|
2021-04-22 02:43:26 +00:00
|
|
|
diffPairWidth = std::max( diffPairWidth, constraint.m_Value.Opt() );
|
2022-10-07 12:20:56 +00:00
|
|
|
|
|
|
|
if( diffPairWidth == constraint.m_Value.Opt() )
|
|
|
|
aSizes.SetDiffPairWidthSource( constraint.m_RuleName );
|
2020-10-11 10:19:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( m_ruleResolver->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_DIFF_PAIR_GAP, aStartItem,
|
2021-10-24 02:46:31 +00:00
|
|
|
nullptr, m_startLayer, &constraint ) )
|
2020-10-11 10:19:07 +00:00
|
|
|
{
|
2021-04-22 02:43:26 +00:00
|
|
|
diffPairGap = std::max( diffPairGap, constraint.m_Value.Opt() );
|
|
|
|
diffPairViaGap = std::max( diffPairViaGap, constraint.m_Value.Opt() );
|
2022-10-07 12:20:56 +00:00
|
|
|
|
|
|
|
if( diffPairGap == constraint.m_Value.Opt() )
|
|
|
|
aSizes.SetDiffPairGapSource( constraint.m_RuleName );
|
2020-10-11 10:19:07 +00:00
|
|
|
}
|
2020-10-08 22:01:09 +00:00
|
|
|
}
|
2021-03-02 12:11:45 +00:00
|
|
|
else
|
2020-10-08 22:01:09 +00:00
|
|
|
{
|
2021-03-02 12:11:45 +00:00
|
|
|
diffPairWidth = bds.GetCurrentDiffPairWidth();
|
|
|
|
diffPairGap = bds.GetCurrentDiffPairGap();
|
|
|
|
diffPairViaGap = bds.GetCurrentDiffPairViaGap();
|
2022-10-07 12:20:56 +00:00
|
|
|
|
|
|
|
aSizes.SetDiffPairWidthSource( _( "user choice" ) );
|
|
|
|
aSizes.SetDiffPairGapSource( _( "user choice" ) );
|
2020-10-08 22:01:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aSizes.SetDiffPairWidth( diffPairWidth );
|
|
|
|
aSizes.SetDiffPairGap( diffPairGap );
|
|
|
|
aSizes.SetDiffPairViaGap( diffPairViaGap );
|
2022-08-24 11:12:43 +00:00
|
|
|
aSizes.SetDiffPairViaGapSameAsTraceGap( false );
|
2020-10-08 22:01:09 +00:00
|
|
|
|
2023-08-07 22:29:16 +00:00
|
|
|
int holeToHoleMin = bds.m_HoleToHoleMin;
|
2023-02-18 00:48:55 +00:00
|
|
|
|
2021-02-25 14:21:50 +00:00
|
|
|
if( m_ruleResolver->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_HOLE_TO_HOLE, &dummyVia,
|
|
|
|
&dummyVia, UNDEFINED_LAYER, &constraint ) )
|
|
|
|
{
|
|
|
|
holeToHoleMin = constraint.m_Value.Min();
|
|
|
|
}
|
|
|
|
|
|
|
|
aSizes.SetHoleToHole( holeToHoleMin );
|
2021-01-05 00:03:14 +00:00
|
|
|
|
2023-02-18 00:55:52 +00:00
|
|
|
if( m_ruleResolver->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_HOLE_TO_HOLE, &dummyVia,
|
|
|
|
&coupledVia, UNDEFINED_LAYER, &constraint ) )
|
|
|
|
{
|
|
|
|
holeToHoleMin = constraint.m_Value.Min();
|
|
|
|
}
|
|
|
|
|
|
|
|
aSizes.SetDiffPairHoleToHole( holeToHoleMin );
|
|
|
|
|
2020-10-08 22:01:09 +00:00
|
|
|
return true;
|
2017-01-25 09:33:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-04 17:58:51 +00:00
|
|
|
int PNS_KICAD_IFACE_BASE::StackupHeight( int aFirstLayer, int aSecondLayer ) const
|
|
|
|
{
|
2021-05-11 02:11:58 +00:00
|
|
|
if( !m_board || !m_board->GetDesignSettings().m_UseHeightForLengthCalcs )
|
2021-04-04 17:58:51 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
BOARD_STACKUP& stackup = m_board->GetDesignSettings().GetStackupDescriptor();
|
|
|
|
|
|
|
|
return stackup.GetLayerDistance( ToLAYER_ID( aFirstLayer ), ToLAYER_ID( aSecondLayer ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-08-22 12:06:33 +00:00
|
|
|
PNS::NET_HANDLE PNS_PCBNEW_RULE_RESOLVER::DpCoupledNet( PNS::NET_HANDLE aNet )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2023-10-15 21:45:18 +00:00
|
|
|
return m_board->DpCoupledNet( static_cast<NETINFO_ITEM*>( aNet ) );
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-08-22 12:06:33 +00:00
|
|
|
int PNS_PCBNEW_RULE_RESOLVER::NetCode( PNS::NET_HANDLE aNet )
|
2018-05-19 00:50:52 +00:00
|
|
|
{
|
2023-08-22 12:06:33 +00:00
|
|
|
return m_routerIface->GetNetCode( aNet );
|
2018-05-19 00:50:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-08-22 12:06:33 +00:00
|
|
|
wxString PNS_PCBNEW_RULE_RESOLVER::NetName( PNS::NET_HANDLE aNet )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2023-08-22 12:06:33 +00:00
|
|
|
return m_routerIface->GetNetName( aNet );
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
|
2023-08-22 12:06:33 +00:00
|
|
|
int PNS_PCBNEW_RULE_RESOLVER::DpNetPolarity( PNS::NET_HANDLE aNet )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2023-08-22 12:06:33 +00:00
|
|
|
wxString refName;
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2023-08-22 12:06:33 +00:00
|
|
|
if( NETINFO_ITEM* net = static_cast<NETINFO_ITEM*>( aNet ) )
|
|
|
|
refName = net->GetNetname();
|
2023-03-06 19:48:42 +00:00
|
|
|
|
2023-08-22 12:06:33 +00:00
|
|
|
wxString dummy1;
|
|
|
|
|
2023-10-15 21:45:18 +00:00
|
|
|
return m_board->MatchDpSuffix( refName, dummy1 );
|
2023-08-22 12:06:33 +00:00
|
|
|
}
|
2020-10-17 12:52:18 +00:00
|
|
|
|
2023-08-22 12:06:33 +00:00
|
|
|
|
|
|
|
bool PNS_PCBNEW_RULE_RESOLVER::DpNetPair( const PNS::ITEM* aItem, PNS::NET_HANDLE& aNetP,
|
|
|
|
PNS::NET_HANDLE& aNetN )
|
|
|
|
{
|
|
|
|
if( !aItem || !aItem->Net() )
|
2020-10-17 12:52:18 +00:00
|
|
|
return false;
|
|
|
|
|
2023-08-22 12:06:33 +00:00
|
|
|
wxString netNameP = static_cast<NETINFO_ITEM*>( aItem->Net() )->GetNetname();
|
2021-09-20 20:17:32 +00:00
|
|
|
wxString netNameN, netNameCoupled;
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2023-10-15 21:45:18 +00:00
|
|
|
int r = m_board->MatchDpSuffix( netNameP, netNameCoupled );
|
2016-08-15 15:16:47 +00:00
|
|
|
|
|
|
|
if( r == 0 )
|
2020-10-17 12:52:18 +00:00
|
|
|
{
|
2016-08-15 15:16:47 +00:00
|
|
|
return false;
|
2020-10-17 12:52:18 +00:00
|
|
|
}
|
2016-08-15 15:16:47 +00:00
|
|
|
else if( r == 1 )
|
|
|
|
{
|
|
|
|
netNameN = netNameCoupled;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
netNameN = netNameP;
|
|
|
|
netNameP = netNameCoupled;
|
|
|
|
}
|
|
|
|
|
2023-08-22 12:06:33 +00:00
|
|
|
PNS::NET_HANDLE netInfoP = m_board->FindNet( netNameP );
|
|
|
|
PNS::NET_HANDLE netInfoN = m_board->FindNet( netNameN );
|
2016-08-15 15:16:47 +00:00
|
|
|
|
|
|
|
if( !netInfoP || !netInfoN )
|
|
|
|
return false;
|
|
|
|
|
2023-08-22 12:06:33 +00:00
|
|
|
aNetP = netInfoP;
|
|
|
|
aNetN = netInfoN;
|
2016-08-15 15:16:47 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
class PNS_PCBNEW_DEBUG_DECORATOR: public PNS::DEBUG_DECORATOR
|
2016-08-15 15:16:48 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-07-19 23:56:05 +00:00
|
|
|
PNS_PCBNEW_DEBUG_DECORATOR( KIGFX::VIEW* aView = nullptr ) :
|
2020-12-02 18:42:37 +00:00
|
|
|
PNS::DEBUG_DECORATOR(),
|
2021-07-19 23:56:05 +00:00
|
|
|
m_view( nullptr ),
|
2022-12-30 06:07:44 +00:00
|
|
|
m_items( nullptr ),
|
|
|
|
m_depth( 0 )
|
2016-08-15 15:16:48 +00:00
|
|
|
{
|
2016-08-15 15:16:53 +00:00
|
|
|
SetView( aView );
|
2016-08-15 15:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~PNS_PCBNEW_DEBUG_DECORATOR()
|
|
|
|
{
|
2021-04-08 03:16:56 +00:00
|
|
|
PNS_PCBNEW_DEBUG_DECORATOR::Clear();
|
2016-08-17 13:09:48 +00:00
|
|
|
delete m_items;
|
2016-08-15 15:16:48 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
void SetView( KIGFX::VIEW* aView )
|
2016-08-15 15:16:48 +00:00
|
|
|
{
|
|
|
|
Clear();
|
|
|
|
delete m_items;
|
2021-07-19 23:56:05 +00:00
|
|
|
m_items = nullptr;
|
2016-08-15 15:16:48 +00:00
|
|
|
m_view = aView;
|
2016-08-15 15:16:53 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
if( m_view == nullptr )
|
2016-08-15 15:16:48 +00:00
|
|
|
return;
|
2016-08-15 15:16:53 +00:00
|
|
|
|
2022-12-30 06:07:44 +00:00
|
|
|
if( m_view->GetGAL() )
|
|
|
|
m_depth = m_view->GetGAL()->GetMinDepth();
|
|
|
|
|
2016-08-15 15:16:48 +00:00
|
|
|
m_items = new KIGFX::VIEW_GROUP( m_view );
|
2018-08-28 21:57:31 +00:00
|
|
|
m_items->SetLayer( LAYER_SELECT_OVERLAY ) ;
|
2016-08-15 15:16:48 +00:00
|
|
|
m_view->Add( m_items );
|
|
|
|
}
|
|
|
|
|
2022-12-30 06:07:44 +00:00
|
|
|
void AddPoint( const VECTOR2I& aP, const KIGFX::COLOR4D& aColor, int aSize,
|
2023-08-31 12:25:13 +00:00
|
|
|
const wxString& aName = wxT( "" ),
|
2022-12-30 06:07:44 +00:00
|
|
|
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override
|
|
|
|
|
|
|
|
{
|
|
|
|
SHAPE_LINE_CHAIN sh;
|
|
|
|
|
|
|
|
sh.SetWidth( 10000 );
|
|
|
|
|
|
|
|
sh.Append( aP.x - aSize, aP.y - aSize );
|
|
|
|
sh.Append( aP.x + aSize, aP.y + aSize );
|
|
|
|
sh.Append( aP.x, aP.y );
|
|
|
|
sh.Append( aP.x - aSize, aP.y + aSize );
|
|
|
|
sh.Append( aP.x + aSize, aP.y - aSize );
|
|
|
|
|
|
|
|
AddShape( &sh, aColor, sh.Width(), aName, aSrcLoc );
|
|
|
|
}
|
|
|
|
|
|
|
|
void AddItem( const PNS::ITEM* aItem, const KIGFX::COLOR4D& aColor, int aOverrideWidth = 0,
|
2023-08-31 12:25:13 +00:00
|
|
|
const wxString& aName = wxT( "" ),
|
2023-02-22 01:43:21 +00:00
|
|
|
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override
|
2022-12-30 06:07:44 +00:00
|
|
|
{
|
|
|
|
if( !m_view || !aItem )
|
|
|
|
return;
|
|
|
|
|
|
|
|
ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aItem, m_view );
|
|
|
|
|
|
|
|
pitem->SetColor( aColor.WithAlpha( 0.5 ) );
|
|
|
|
pitem->SetWidth( aOverrideWidth );
|
|
|
|
pitem->SetDepth( nextDepth() );
|
|
|
|
|
|
|
|
m_items->Add( pitem );
|
|
|
|
m_view->Update( m_items );
|
|
|
|
}
|
|
|
|
|
|
|
|
void AddShape( const BOX2I& aBox, const KIGFX::COLOR4D& aColor, int aOverrideWidth = 0,
|
2023-08-31 12:25:13 +00:00
|
|
|
const wxString& aName = wxT( "" ),
|
2022-12-30 06:07:44 +00:00
|
|
|
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
2016-08-15 15:16:48 +00:00
|
|
|
SHAPE_LINE_CHAIN l;
|
2022-12-30 06:07:44 +00:00
|
|
|
l.SetWidth( aOverrideWidth );
|
|
|
|
|
|
|
|
VECTOR2I o = aBox.GetOrigin();
|
|
|
|
VECTOR2I s = aBox.GetSize();
|
2016-08-15 15:16:48 +00:00
|
|
|
|
2022-12-30 06:07:44 +00:00
|
|
|
l.Append( o );
|
|
|
|
l.Append( o.x + s.x, o.y );
|
|
|
|
l.Append( o.x + s.x, o.y + s.y );
|
|
|
|
l.Append( o.x, o.y + s.y );
|
|
|
|
l.Append( o );
|
2016-08-15 15:16:48 +00:00
|
|
|
|
2022-12-30 06:07:44 +00:00
|
|
|
AddShape( &l, aColor, aOverrideWidth, aName, aSrcLoc );
|
|
|
|
}
|
2016-08-15 15:16:48 +00:00
|
|
|
|
2022-12-30 06:07:44 +00:00
|
|
|
void AddShape( const SHAPE* aShape, const KIGFX::COLOR4D& aColor, int aOverrideWidth = 0,
|
2023-08-31 12:25:13 +00:00
|
|
|
const wxString& aName = wxT( "" ),
|
2023-02-22 01:43:21 +00:00
|
|
|
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override
|
2022-12-30 06:07:44 +00:00
|
|
|
{
|
|
|
|
if( !m_view || !aShape )
|
|
|
|
return;
|
|
|
|
|
|
|
|
ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( *aShape, m_view );
|
|
|
|
|
|
|
|
pitem->SetColor( aColor.WithAlpha( 0.5 ) );
|
|
|
|
pitem->SetWidth( aOverrideWidth );
|
|
|
|
pitem->SetDepth( nextDepth() );
|
|
|
|
|
|
|
|
m_items->Add( pitem );
|
|
|
|
m_view->Update( m_items );
|
2016-08-15 15:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Clear() override
|
|
|
|
{
|
2016-08-15 15:16:53 +00:00
|
|
|
if( m_view && m_items )
|
2016-08-15 15:16:48 +00:00
|
|
|
{
|
|
|
|
m_items->FreeItems();
|
2016-12-09 11:04:32 +00:00
|
|
|
m_view->Update( m_items );
|
2022-12-30 06:07:44 +00:00
|
|
|
|
|
|
|
if( m_view->GetGAL() )
|
|
|
|
m_depth = m_view->GetGAL()->GetMinDepth();
|
2016-08-15 15:16:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2022-12-30 06:07:44 +00:00
|
|
|
double nextDepth()
|
|
|
|
{
|
|
|
|
// Use different depths so that the transculent shapes won't overwrite each other.
|
|
|
|
|
|
|
|
m_depth++;
|
|
|
|
|
|
|
|
if( m_depth >= 0 && m_view->GetGAL() )
|
|
|
|
m_depth = m_view->GetGAL()->GetMinDepth();
|
|
|
|
|
|
|
|
return m_depth;
|
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:48 +00:00
|
|
|
KIGFX::VIEW* m_view;
|
|
|
|
KIGFX::VIEW_GROUP* m_items;
|
2022-12-30 06:07:44 +00:00
|
|
|
|
|
|
|
double m_depth;
|
2016-08-15 15:16:48 +00:00
|
|
|
};
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
|
2019-12-30 14:26:33 +00:00
|
|
|
PNS::DEBUG_DECORATOR* PNS_KICAD_IFACE_BASE::GetDebugDecorator()
|
2016-08-15 15:16:48 +00:00
|
|
|
{
|
|
|
|
return m_debugDecorator;
|
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2019-12-30 14:26:33 +00:00
|
|
|
PNS_KICAD_IFACE_BASE::PNS_KICAD_IFACE_BASE()
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
|
|
|
m_ruleResolver = nullptr;
|
2016-08-15 15:16:48 +00:00
|
|
|
m_board = nullptr;
|
2020-04-16 22:29:28 +00:00
|
|
|
m_world = nullptr;
|
2019-12-30 14:26:33 +00:00
|
|
|
m_debugDecorator = nullptr;
|
2021-10-24 02:46:31 +00:00
|
|
|
m_startLayer = -1;
|
2019-12-30 14:26:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PNS_KICAD_IFACE::PNS_KICAD_IFACE()
|
|
|
|
{
|
2017-10-31 11:03:58 +00:00
|
|
|
m_tool = nullptr;
|
2016-08-15 15:16:48 +00:00
|
|
|
m_view = nullptr;
|
2016-08-15 15:16:47 +00:00
|
|
|
m_previewItems = nullptr;
|
2022-08-17 18:02:42 +00:00
|
|
|
m_commitFlags = 0;
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
|
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
|
|
|
}
|
2016-08-15 15:16:48 +00:00
|
|
|
|
2019-12-30 14:26:33 +00:00
|
|
|
|
|
|
|
PNS_KICAD_IFACE::~PNS_KICAD_IFACE()
|
|
|
|
{
|
2020-04-16 22:29:28 +00:00
|
|
|
delete m_ruleResolver;
|
|
|
|
delete m_debugDecorator;
|
|
|
|
|
2023-08-31 12:25:13 +00:00
|
|
|
if( m_previewItems )
|
2016-08-17 13:09:48 +00:00
|
|
|
{
|
|
|
|
m_previewItems->FreeItems();
|
|
|
|
delete m_previewItems;
|
|
|
|
}
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
std::unique_ptr<PNS::SOLID> PNS_KICAD_IFACE_BASE::syncPad( PAD* aPad )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
LAYER_RANGE layers( 0, MAX_CU_LAYERS - 1 );
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2020-06-27 21:44:56 +00:00
|
|
|
// ignore non-copper pads except for those with holes
|
2020-10-05 13:55:52 +00:00
|
|
|
if( ( aPad->GetLayerSet() & LSET::AllCuMask() ).none() && aPad->GetDrillSize().x == 0 )
|
2021-07-19 23:56:05 +00:00
|
|
|
return nullptr;
|
2016-08-15 15:16:47 +00:00
|
|
|
|
|
|
|
switch( aPad->GetAttribute() )
|
|
|
|
{
|
2021-05-01 14:46:50 +00:00
|
|
|
case PAD_ATTRIB::PTH:
|
|
|
|
case PAD_ATTRIB::NPTH:
|
2016-08-15 15:16:47 +00:00
|
|
|
break;
|
|
|
|
|
2021-05-01 14:46:50 +00:00
|
|
|
case PAD_ATTRIB::CONN:
|
|
|
|
case PAD_ATTRIB::SMD:
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
|
|
|
LSET lmsk = aPad->GetLayerSet();
|
|
|
|
bool is_copper = false;
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
for( int i = 0; i < MAX_CU_LAYERS; i++ )
|
|
|
|
{
|
|
|
|
if( lmsk[i] )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
is_copper = true;
|
2016-08-15 15:16:53 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
if( aPad->GetAttribute() != PAD_ATTRIB::NPTH )
|
|
|
|
layers = LAYER_RANGE( i );
|
2016-08-15 15:16:53 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
break;
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
if( !is_copper )
|
|
|
|
return nullptr;
|
|
|
|
|
2016-08-15 15:16:47 +00:00
|
|
|
break;
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2016-08-15 15:16:47 +00:00
|
|
|
|
|
|
|
default:
|
2022-02-05 02:06:25 +00:00
|
|
|
wxLogTrace( wxT( "PNS" ), wxT( "unsupported pad type 0x%x" ), aPad->GetAttribute() );
|
2021-07-19 23:56:05 +00:00
|
|
|
return nullptr;
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
|
2020-10-26 23:49:11 +00:00
|
|
|
std::unique_ptr<PNS::SOLID> solid = std::make_unique<PNS::SOLID>();
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2021-05-01 14:46:50 +00:00
|
|
|
if( aPad->GetAttribute() == PAD_ATTRIB::NPTH )
|
2020-08-21 04:49:40 +00:00
|
|
|
solid->SetRoutable( false );
|
|
|
|
|
2016-08-15 15:16:47 +00:00
|
|
|
solid->SetLayers( layers );
|
2023-08-22 12:06:33 +00:00
|
|
|
solid->SetNet( aPad->GetNet() );
|
2016-08-15 15:16:47 +00:00
|
|
|
solid->SetParent( aPad );
|
2019-10-31 13:00:01 +00:00
|
|
|
solid->SetPadToDie( aPad->GetPadToDieLength() );
|
2022-01-16 21:15:20 +00:00
|
|
|
solid->SetOrientation( aPad->GetOrientation() );
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2022-09-05 18:44:41 +00:00
|
|
|
if( aPad->IsFreePad() )
|
|
|
|
solid->SetIsFreePad();
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I wx_c = aPad->ShapePos();
|
|
|
|
VECTOR2I offset = aPad->GetOffset();
|
2016-08-15 15:16:47 +00:00
|
|
|
|
|
|
|
VECTOR2I c( wx_c.x, wx_c.y );
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
RotatePoint( offset, aPad->GetOrientation() );
|
2016-08-15 15:16:47 +00:00
|
|
|
|
|
|
|
solid->SetPos( VECTOR2I( c.x - offset.x, c.y - offset.y ) );
|
2016-12-09 11:04:32 +00:00
|
|
|
solid->SetOffset( VECTOR2I( offset.x, offset.y ) );
|
2020-10-07 13:17:04 +00:00
|
|
|
|
2021-11-27 00:53:28 +00:00
|
|
|
if( aPad->GetDrillSize().x > 0 )
|
2023-04-28 10:03:24 +00:00
|
|
|
solid->SetHole( new PNS::HOLE( aPad->GetEffectiveHoleShape()->Clone() ) );
|
2020-10-07 13:17:04 +00:00
|
|
|
|
2023-10-13 11:25:52 +00:00
|
|
|
// We generate a single SOLID for a pad, so we have to treat it as ALWAYS_FLASHED and then
|
|
|
|
// perform layer-specific flashing tests internally.
|
|
|
|
const std::shared_ptr<SHAPE>& shape = aPad->GetEffectiveShape( UNDEFINED_LAYER,
|
|
|
|
FLASHING::ALWAYS_FLASHED );
|
2020-10-07 13:17:04 +00:00
|
|
|
|
2023-10-13 11:25:52 +00:00
|
|
|
if( shape->HasIndexableSubshapes() && shape->GetIndexableSubshapeCount() == 1 )
|
2023-10-13 02:55:34 +00:00
|
|
|
{
|
2023-10-13 11:25:52 +00:00
|
|
|
std::vector<const SHAPE*> subshapes;
|
|
|
|
shape->GetIndexableSubshapes( subshapes );
|
2023-10-13 02:55:34 +00:00
|
|
|
|
2023-10-13 11:25:52 +00:00
|
|
|
solid->SetShape( subshapes[0]->Clone() );
|
2023-10-13 02:55:34 +00:00
|
|
|
}
|
2023-10-13 11:25:52 +00:00
|
|
|
// For anything that's not a single shape we use a polygon. Multiple shapes have a tendency
|
|
|
|
// to confuse the hull generator. https://gitlab.com/kicad/code/kicad/-/issues/15553
|
2023-10-13 02:55:34 +00:00
|
|
|
else
|
|
|
|
{
|
2023-10-13 11:25:52 +00:00
|
|
|
const std::shared_ptr<SHAPE_POLY_SET>& poly = aPad->GetEffectivePolygon( ERROR_OUTSIDE );
|
|
|
|
|
|
|
|
if( poly->OutlineCount() )
|
|
|
|
solid->SetShape( new SHAPE_SIMPLE( poly->Outline( 0 ) ) );
|
2023-10-13 02:55:34 +00:00
|
|
|
}
|
2016-08-15 15:16:47 +00:00
|
|
|
|
|
|
|
return solid;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
std::unique_ptr<PNS::SEGMENT> PNS_KICAD_IFACE_BASE::syncTrack( PCB_TRACK* aTrack )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2020-10-26 23:49:11 +00:00
|
|
|
auto segment = std::make_unique<PNS::SEGMENT>( SEG( aTrack->GetStart(), aTrack->GetEnd() ),
|
2023-08-22 12:06:33 +00:00
|
|
|
aTrack->GetNet() );
|
2016-08-30 15:28:35 +00:00
|
|
|
|
|
|
|
segment->SetWidth( aTrack->GetWidth() );
|
|
|
|
segment->SetLayers( LAYER_RANGE( aTrack->GetLayer() ) );
|
|
|
|
segment->SetParent( aTrack );
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2023-10-22 17:33:33 +00:00
|
|
|
if( aTrack->IsLocked() )
|
2016-08-30 15:28:35 +00:00
|
|
|
segment->Mark( PNS::MK_LOCKED );
|
|
|
|
|
2023-10-22 17:33:33 +00:00
|
|
|
if( PCB_GENERATOR* generator = dynamic_cast<PCB_GENERATOR*>( aTrack->GetParentGroup() ) )
|
|
|
|
{
|
2023-11-12 09:17:03 +00:00
|
|
|
if( !generator->HasFlag( IN_EDIT ) )
|
2023-10-22 17:33:33 +00:00
|
|
|
segment->Mark( PNS::MK_LOCKED );
|
|
|
|
}
|
|
|
|
|
2016-08-30 15:28:35 +00:00
|
|
|
return segment;
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
std::unique_ptr<PNS::ARC> PNS_KICAD_IFACE_BASE::syncArc( PCB_ARC* aArc )
|
2019-05-17 00:13:21 +00:00
|
|
|
{
|
2023-08-22 12:06:33 +00:00
|
|
|
auto arc = std::make_unique<PNS::ARC>( SHAPE_ARC( aArc->GetStart(), aArc->GetMid(),
|
|
|
|
aArc->GetEnd(), aArc->GetWidth() ),
|
|
|
|
aArc->GetNet() );
|
2019-05-17 00:13:21 +00:00
|
|
|
|
|
|
|
arc->SetLayers( LAYER_RANGE( aArc->GetLayer() ) );
|
|
|
|
arc->SetParent( aArc );
|
|
|
|
|
2023-10-22 17:33:33 +00:00
|
|
|
if( aArc->IsLocked() )
|
2019-05-17 00:13:21 +00:00
|
|
|
arc->Mark( PNS::MK_LOCKED );
|
|
|
|
|
2023-10-22 17:33:33 +00:00
|
|
|
if( PCB_GENERATOR* generator = dynamic_cast<PCB_GENERATOR*>( aArc->GetParentGroup() ) )
|
|
|
|
{
|
2023-11-12 09:17:03 +00:00
|
|
|
if( !generator->HasFlag( IN_EDIT ) )
|
2023-10-22 17:33:33 +00:00
|
|
|
arc->Mark( PNS::MK_LOCKED );
|
|
|
|
}
|
|
|
|
|
2019-05-17 00:13:21 +00:00
|
|
|
return arc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
std::unique_ptr<PNS::VIA> PNS_KICAD_IFACE_BASE::syncVia( PCB_VIA* aVia )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID top, bottom;
|
2016-08-15 15:16:47 +00:00
|
|
|
aVia->LayerPair( &top, &bottom );
|
|
|
|
|
2020-10-26 23:49:11 +00:00
|
|
|
auto via = std::make_unique<PNS::VIA>( aVia->GetPosition(),
|
|
|
|
LAYER_RANGE( aVia->TopLayer(), aVia->BottomLayer() ),
|
|
|
|
aVia->GetWidth(),
|
|
|
|
aVia->GetDrillValue(),
|
2023-08-22 12:06:33 +00:00
|
|
|
aVia->GetNet(),
|
2020-10-26 23:49:11 +00:00
|
|
|
aVia->GetViaType() );
|
2016-08-30 15:28:35 +00:00
|
|
|
|
2020-08-16 19:36:58 +00:00
|
|
|
via->SetParent( aVia );
|
2020-07-27 19:41:50 +00:00
|
|
|
|
2023-10-22 17:33:33 +00:00
|
|
|
if( aVia->IsLocked() )
|
2020-08-16 19:36:58 +00:00
|
|
|
via->Mark( PNS::MK_LOCKED );
|
2020-07-27 19:41:50 +00:00
|
|
|
|
2023-10-22 17:33:33 +00:00
|
|
|
if( PCB_GENERATOR* generator = dynamic_cast<PCB_GENERATOR*>( aVia->GetParentGroup() ) )
|
|
|
|
{
|
2023-11-12 09:17:03 +00:00
|
|
|
if( !generator->HasFlag( IN_EDIT ) )
|
2023-10-22 17:33:33 +00:00
|
|
|
via->Mark( PNS::MK_LOCKED );
|
|
|
|
}
|
|
|
|
|
2020-12-20 21:29:43 +00:00
|
|
|
via->SetIsFree( aVia->GetIsFree() );
|
2023-04-28 10:03:24 +00:00
|
|
|
via->SetHole( PNS::HOLE::MakeCircularHole( aVia->GetPosition(), aVia->GetDrillValue() / 2 ) );
|
2021-01-01 00:29:05 +00:00
|
|
|
|
2020-12-09 23:12:44 +00:00
|
|
|
return via;
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
|
2018-02-19 09:24:57 +00:00
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
bool PNS_KICAD_IFACE_BASE::syncZone( PNS::NODE* aWorld, ZONE* aZone, SHAPE_POLY_SET* aBoardOutline )
|
2018-02-03 09:39:46 +00:00
|
|
|
{
|
2023-11-07 11:57:06 +00:00
|
|
|
static wxString msg;
|
2021-01-30 00:32:48 +00:00
|
|
|
SHAPE_POLY_SET* poly;
|
2018-02-03 09:39:46 +00:00
|
|
|
|
2023-11-07 11:57:06 +00:00
|
|
|
if( !aZone->GetIsRuleArea() )
|
2018-02-03 09:39:46 +00:00
|
|
|
return false;
|
|
|
|
|
2023-11-07 11:57:06 +00:00
|
|
|
LSET layers = aZone->GetLayerSet();
|
2018-02-03 09:39:46 +00:00
|
|
|
|
2021-01-30 00:32:48 +00:00
|
|
|
poly = aZone->Outline();
|
|
|
|
poly->CacheTriangulation( false );
|
2018-02-03 09:39:46 +00:00
|
|
|
|
2021-01-30 00:32:48 +00:00
|
|
|
if( !poly->IsTriangulationUpToDate() )
|
|
|
|
{
|
2022-09-19 16:09:59 +00:00
|
|
|
UNITS_PROVIDER unitsProvider( pcbIUScale, GetUnits() );
|
2023-11-07 11:57:06 +00:00
|
|
|
msg.Printf( _( "%s is malformed." ), aZone->GetItemDescription( &unitsProvider ) );
|
|
|
|
|
|
|
|
KIDIALOG dlg( nullptr, msg, KIDIALOG::KD_WARNING );
|
|
|
|
dlg.ShowDetailedText( _( "This zone cannot be handled by the router.\n"
|
|
|
|
"Please verify it is not a self-intersecting polygon." ) );
|
2021-01-30 00:32:48 +00:00
|
|
|
dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
|
|
|
|
dlg.ShowModal();
|
2020-08-12 18:42:40 +00:00
|
|
|
|
2021-01-30 00:32:48 +00:00
|
|
|
return false;
|
|
|
|
}
|
2020-08-12 18:42:40 +00:00
|
|
|
|
2021-01-30 00:32:48 +00:00
|
|
|
for( int layer = F_Cu; layer <= B_Cu; layer++ )
|
|
|
|
{
|
|
|
|
if( !layers[ layer ] )
|
|
|
|
continue;
|
2020-08-12 18:42:40 +00:00
|
|
|
|
2024-03-12 23:49:31 +00:00
|
|
|
for( int polyId = 0; polyId < poly->TriangulatedPolyCount(); polyId++ )
|
2018-02-03 09:39:46 +00:00
|
|
|
{
|
2024-03-12 23:49:31 +00:00
|
|
|
const SHAPE_POLY_SET::TRIANGULATED_POLYGON* tri = poly->TriangulatedPolygon( polyId );
|
2018-02-03 09:39:46 +00:00
|
|
|
|
2018-09-12 20:39:41 +00:00
|
|
|
for( size_t i = 0; i < tri->GetTriangleCount(); i++)
|
2018-02-03 09:39:46 +00:00
|
|
|
{
|
|
|
|
VECTOR2I a, b, c;
|
|
|
|
tri->GetTriangle( i, a, b, c );
|
2020-10-20 10:33:51 +00:00
|
|
|
SHAPE_SIMPLE* triShape = new SHAPE_SIMPLE;
|
2018-02-03 09:39:46 +00:00
|
|
|
|
|
|
|
triShape->Append( a );
|
|
|
|
triShape->Append( b );
|
|
|
|
triShape->Append( c );
|
|
|
|
|
2020-10-26 23:49:11 +00:00
|
|
|
std::unique_ptr<PNS::SOLID> solid = std::make_unique<PNS::SOLID>();
|
2018-02-03 09:39:46 +00:00
|
|
|
|
|
|
|
solid->SetLayer( layer );
|
2023-08-22 12:06:33 +00:00
|
|
|
solid->SetNet( nullptr );
|
2018-02-03 09:39:46 +00:00
|
|
|
solid->SetParent( aZone );
|
|
|
|
solid->SetShape( triShape );
|
2021-11-25 23:41:47 +00:00
|
|
|
solid->SetIsCompoundShapePrimitive();
|
2018-02-03 09:39:46 +00:00
|
|
|
solid->SetRoutable( false );
|
|
|
|
|
|
|
|
aWorld->Add( std::move( solid ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-08-27 13:51:37 +00:00
|
|
|
|
2023-05-02 15:02:45 +00:00
|
|
|
bool PNS_KICAD_IFACE_BASE::syncTextItem( PNS::NODE* aWorld, PCB_TEXT* aText, PCB_LAYER_ID aLayer )
|
2018-08-27 13:51:37 +00:00
|
|
|
{
|
|
|
|
if( !IsCopperLayer( aLayer ) )
|
|
|
|
return false;
|
|
|
|
|
2022-01-04 23:00:00 +00:00
|
|
|
std::unique_ptr<PNS::SOLID> solid = std::make_unique<PNS::SOLID>();
|
2023-05-02 15:02:45 +00:00
|
|
|
SHAPE_SIMPLE* shape = new SHAPE_SIMPLE;
|
2022-01-03 16:14:55 +00:00
|
|
|
|
2022-01-04 23:00:00 +00:00
|
|
|
solid->SetLayer( aLayer );
|
2023-08-22 12:06:33 +00:00
|
|
|
solid->SetNet( nullptr );
|
2023-05-02 15:02:45 +00:00
|
|
|
solid->SetParent( aText );
|
|
|
|
solid->SetShape( shape ); // takes ownership
|
2022-01-04 23:00:00 +00:00
|
|
|
solid->SetRoutable( false );
|
2018-08-27 13:51:37 +00:00
|
|
|
|
2023-05-28 16:20:11 +00:00
|
|
|
SHAPE_POLY_SET cornerBuffer;
|
2018-08-27 13:51:37 +00:00
|
|
|
|
2023-05-28 16:20:11 +00:00
|
|
|
aText->TransformShapeToPolygon( cornerBuffer, aText->GetLayer(), 0,
|
|
|
|
m_board->GetDesignSettings().m_MaxError, ERROR_OUTSIDE );
|
2018-08-27 13:51:37 +00:00
|
|
|
|
2023-05-14 10:40:14 +00:00
|
|
|
if( !cornerBuffer.OutlineCount() )
|
|
|
|
return false;
|
|
|
|
|
2023-05-02 15:02:45 +00:00
|
|
|
for( const VECTOR2I& pt : cornerBuffer.Outline( 0 ).CPoints() )
|
|
|
|
shape->Append( pt );
|
2018-08-27 13:51:37 +00:00
|
|
|
|
|
|
|
aWorld->Add( std::move( solid ) );
|
2023-05-02 15:02:45 +00:00
|
|
|
|
2018-08-27 13:51:37 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
bool PNS_KICAD_IFACE_BASE::syncGraphicalItem( PNS::NODE* aWorld, PCB_SHAPE* aItem )
|
2018-02-03 09:39:46 +00:00
|
|
|
{
|
2020-11-20 21:22:27 +00:00
|
|
|
if( aItem->GetLayer() == Edge_Cuts
|
|
|
|
|| aItem->GetLayer() == Margin
|
|
|
|
|| IsCopperLayer( aItem->GetLayer() ) )
|
|
|
|
{
|
2021-11-25 23:41:47 +00:00
|
|
|
std::vector<SHAPE*> shapes = aItem->MakeEffectiveShapes();
|
|
|
|
|
|
|
|
for( SHAPE* shape : shapes )
|
2020-11-20 21:22:27 +00:00
|
|
|
{
|
|
|
|
std::unique_ptr<PNS::SOLID> solid = std::make_unique<PNS::SOLID>();
|
2018-02-04 12:09:30 +00:00
|
|
|
|
2020-11-20 21:22:27 +00:00
|
|
|
if( aItem->GetLayer() == Edge_Cuts || aItem->GetLayer() == Margin )
|
|
|
|
solid->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
|
|
|
|
else
|
|
|
|
solid->SetLayer( aItem->GetLayer() );
|
2018-02-04 12:09:30 +00:00
|
|
|
|
2020-11-26 17:42:02 +00:00
|
|
|
if( aItem->GetLayer() == Edge_Cuts )
|
|
|
|
{
|
|
|
|
switch( shape->Type() )
|
|
|
|
{
|
|
|
|
case SH_SEGMENT: static_cast<SHAPE_SEGMENT*>( shape )->SetWidth( 0 ); break;
|
|
|
|
case SH_ARC: static_cast<SHAPE_ARC*>( shape )->SetWidth( 0 ); break;
|
|
|
|
case SH_LINE_CHAIN: static_cast<SHAPE_LINE_CHAIN*>( shape )->SetWidth( 0 ); break;
|
|
|
|
default: /* remaining shapes don't have width */ break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-30 19:39:07 +00:00
|
|
|
solid->SetAnchorPoints( aItem->GetConnectionPoints() );
|
2023-08-22 12:06:33 +00:00
|
|
|
solid->SetNet( aItem->GetNet() );
|
2020-11-20 21:22:27 +00:00
|
|
|
solid->SetParent( aItem );
|
2021-11-25 23:41:47 +00:00
|
|
|
solid->SetShape( shape ); // takes ownership
|
|
|
|
|
|
|
|
if( shapes.size() > 1 )
|
|
|
|
solid->SetIsCompoundShapePrimitive();
|
|
|
|
|
2020-11-20 21:22:27 +00:00
|
|
|
aWorld->Add( std::move( solid ) );
|
|
|
|
}
|
2018-02-04 12:09:30 +00:00
|
|
|
|
2020-11-20 21:22:27 +00:00
|
|
|
return true;
|
2018-02-04 12:09:30 +00:00
|
|
|
}
|
|
|
|
|
2020-11-20 21:22:27 +00:00
|
|
|
return false;
|
2018-02-03 09:39:46 +00:00
|
|
|
}
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2019-08-15 07:21:48 +00:00
|
|
|
|
2019-12-30 14:26:33 +00:00
|
|
|
void PNS_KICAD_IFACE_BASE::SetBoard( BOARD* aBoard )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
|
|
|
m_board = aBoard;
|
2022-02-05 02:06:25 +00:00
|
|
|
wxLogTrace( wxT( "PNS" ), wxT( "m_board = %p" ), m_board );
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-05 19:54:12 +00:00
|
|
|
bool PNS_KICAD_IFACE::IsAnyLayerVisible( const LAYER_RANGE& aLayer ) const
|
2019-08-15 07:21:48 +00:00
|
|
|
{
|
|
|
|
if( !m_view )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for( int i = aLayer.Start(); i <= aLayer.End(); i++ )
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
2019-08-15 07:21:48 +00:00
|
|
|
if( m_view->IsLayerVisible( i ) )
|
|
|
|
return true;
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2019-08-15 07:21:48 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-06-08 22:30:57 +00:00
|
|
|
bool PNS_KICAD_IFACE_BASE::IsFlashedOnLayer( const PNS::ITEM* aItem, int aLayer ) const
|
2020-08-16 19:36:58 +00:00
|
|
|
{
|
2020-08-25 16:39:56 +00:00
|
|
|
/// Default is all layers
|
|
|
|
if( aLayer < 0 )
|
|
|
|
return true;
|
|
|
|
|
2023-04-06 16:59:43 +00:00
|
|
|
if( aItem->Parent() )
|
2020-08-16 19:36:58 +00:00
|
|
|
{
|
2020-10-17 12:52:18 +00:00
|
|
|
switch( aItem->Parent()->Type() )
|
|
|
|
{
|
|
|
|
case PCB_VIA_T:
|
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
const PCB_VIA* via = static_cast<const PCB_VIA*>( aItem->Parent() );
|
2020-08-16 19:36:58 +00:00
|
|
|
|
2022-10-25 11:30:25 +00:00
|
|
|
return via->FlashLayer( ToLAYER_ID( aLayer ) );
|
2020-10-17 12:52:18 +00:00
|
|
|
}
|
2020-08-16 19:36:58 +00:00
|
|
|
|
2020-10-17 12:52:18 +00:00
|
|
|
case PCB_PAD_T:
|
|
|
|
{
|
2020-11-12 22:30:02 +00:00
|
|
|
const PAD* pad = static_cast<const PAD*>( aItem->Parent() );
|
2020-08-16 19:36:58 +00:00
|
|
|
|
2022-10-25 11:30:25 +00:00
|
|
|
return pad->FlashLayer( ToLAYER_ID( aLayer ) );
|
2020-10-17 12:52:18 +00:00
|
|
|
}
|
2020-08-16 19:36:58 +00:00
|
|
|
|
2020-10-17 12:52:18 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2020-08-16 19:36:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return aItem->Layers().Overlaps( aLayer );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-04-09 19:25:22 +00:00
|
|
|
bool PNS_KICAD_IFACE_BASE::IsFlashedOnLayer( const PNS::ITEM* aItem,
|
|
|
|
const LAYER_RANGE& aLayer ) const
|
|
|
|
{
|
|
|
|
LAYER_RANGE test = aItem->Layers().Intersection( aLayer );
|
|
|
|
|
|
|
|
if( aItem->Parent() )
|
|
|
|
{
|
|
|
|
switch( aItem->Parent()->Type() )
|
|
|
|
{
|
|
|
|
case PCB_VIA_T:
|
|
|
|
{
|
|
|
|
const PCB_VIA* via = static_cast<const PCB_VIA*>( aItem->Parent() );
|
|
|
|
|
|
|
|
for( int layer = test.Start(); layer <= test.End(); ++layer )
|
|
|
|
{
|
|
|
|
if( via->FlashLayer( ToLAYER_ID( layer ) ) )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PCB_PAD_T:
|
|
|
|
{
|
|
|
|
const PAD* pad = static_cast<const PAD*>( aItem->Parent() );
|
|
|
|
|
|
|
|
for( int layer = test.Start(); layer <= test.End(); ++layer )
|
|
|
|
{
|
|
|
|
if( pad->FlashLayer( ToLAYER_ID( layer ) ) )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return test.Start() <= test.End();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-05 19:54:12 +00:00
|
|
|
bool PNS_KICAD_IFACE::IsItemVisible( const PNS::ITEM* aItem ) const
|
2019-10-10 13:33:21 +00:00
|
|
|
{
|
2020-10-17 12:52:18 +00:00
|
|
|
// by default, all items are visible (new ones created by the router have parent == NULL
|
|
|
|
// as they have not been committed yet to the BOARD)
|
2019-10-15 13:30:56 +00:00
|
|
|
if( !m_view || !aItem->Parent() )
|
2020-02-29 19:41:31 +00:00
|
|
|
return true;
|
2019-10-10 13:33:21 +00:00
|
|
|
|
2020-11-08 17:16:00 +00:00
|
|
|
BOARD_ITEM* item = aItem->Parent();
|
|
|
|
bool isOnVisibleLayer = true;
|
|
|
|
RENDER_SETTINGS* settings = m_view->GetPainter()->GetSettings();
|
2019-10-15 13:30:56 +00:00
|
|
|
|
2020-11-08 17:16:00 +00:00
|
|
|
if( settings->GetHighContrast() )
|
|
|
|
isOnVisibleLayer = item->IsOnLayer( settings->GetPrimaryHighContrastLayer() );
|
2019-10-10 13:33:21 +00:00
|
|
|
|
2022-02-24 21:31:17 +00:00
|
|
|
if( m_view->IsVisible( item ) && isOnVisibleLayer )
|
2020-11-08 17:16:00 +00:00
|
|
|
{
|
2022-02-24 21:31:17 +00:00
|
|
|
for( PCB_LAYER_ID layer : item->GetLayerSet().Seq() )
|
|
|
|
{
|
|
|
|
if( item->ViewGetLOD( layer, m_view ) < m_view->GetScale() )
|
|
|
|
return true;
|
|
|
|
}
|
2020-11-08 17:16:00 +00:00
|
|
|
}
|
2019-10-10 13:33:21 +00:00
|
|
|
|
2019-12-07 17:47:16 +00:00
|
|
|
// Items hidden in the router are not hidden on the board
|
|
|
|
if( m_hiddenItems.find( item ) != m_hiddenItems.end() )
|
|
|
|
return true;
|
|
|
|
|
2019-10-10 13:33:21 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-30 14:26:33 +00:00
|
|
|
void PNS_KICAD_IFACE_BASE::SyncWorld( PNS::NODE *aWorld )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
|
|
|
if( !m_board )
|
|
|
|
{
|
2022-02-05 02:06:25 +00:00
|
|
|
wxLogTrace( wxT( "PNS" ), wxT( "No board attached, aborting sync." ) );
|
2016-08-15 15:16:47 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-07-26 19:36:13 +00:00
|
|
|
int worstClearance = m_board->GetMaxClearanceValue();
|
2021-02-01 16:58:22 +00:00
|
|
|
|
|
|
|
m_world = aWorld;
|
|
|
|
|
2020-10-04 14:19:33 +00:00
|
|
|
for( BOARD_ITEM* gitem : m_board->Drawings() )
|
2018-02-03 09:39:46 +00:00
|
|
|
{
|
2022-01-30 10:52:52 +00:00
|
|
|
if ( gitem->Type() == PCB_SHAPE_T || gitem->Type() == PCB_TEXTBOX_T )
|
2018-02-09 12:00:57 +00:00
|
|
|
{
|
2020-10-04 23:34:59 +00:00
|
|
|
syncGraphicalItem( aWorld, static_cast<PCB_SHAPE*>( gitem ) );
|
2018-02-09 12:00:57 +00:00
|
|
|
}
|
2018-08-27 13:51:37 +00:00
|
|
|
else if( gitem->Type() == PCB_TEXT_T )
|
|
|
|
{
|
2020-10-04 23:34:59 +00:00
|
|
|
syncTextItem( aWorld, static_cast<PCB_TEXT*>( gitem ), gitem->GetLayer() );
|
2018-08-27 13:51:37 +00:00
|
|
|
}
|
2018-02-03 09:39:46 +00:00
|
|
|
}
|
|
|
|
|
2020-10-10 22:09:00 +00:00
|
|
|
SHAPE_POLY_SET buffer;
|
|
|
|
SHAPE_POLY_SET* boardOutline = nullptr;
|
|
|
|
|
|
|
|
if( m_board->GetBoardPolygonOutlines( buffer ) )
|
|
|
|
boardOutline = &buffer;
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
for( ZONE* zone : m_board->Zones() )
|
2018-02-03 09:39:46 +00:00
|
|
|
{
|
2020-10-10 22:09:00 +00:00
|
|
|
syncZone( aWorld, zone, boardOutline );
|
2018-02-03 09:39:46 +00:00
|
|
|
}
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
for( FOOTPRINT* footprint : m_board->Footprints() )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
for( PAD* pad : footprint->Pads() )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2020-10-05 19:54:12 +00:00
|
|
|
if( std::unique_ptr<PNS::SOLID> solid = syncPad( pad ) )
|
2016-08-30 15:28:35 +00:00
|
|
|
aWorld->Add( std::move( solid ) );
|
2017-12-18 17:51:44 +00:00
|
|
|
|
2021-01-01 00:29:05 +00:00
|
|
|
worstClearance = std::max( worstClearance, pad->GetLocalClearance() );
|
2022-06-27 21:07:25 +00:00
|
|
|
|
|
|
|
if( pad->GetProperty() == PAD_PROP::CASTELLATED )
|
|
|
|
{
|
|
|
|
std::unique_ptr<SHAPE> hole;
|
2022-07-22 22:05:25 +00:00
|
|
|
hole.reset( pad->GetEffectiveHoleShape()->Clone() );
|
2022-06-27 21:07:25 +00:00
|
|
|
aWorld->AddEdgeExclusion( std::move( hole ) );
|
|
|
|
}
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
2018-08-27 13:51:37 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
syncTextItem( aWorld, &footprint->Reference(), footprint->Reference().GetLayer() );
|
|
|
|
syncTextItem( aWorld, &footprint->Value(), footprint->Value().GetLayer() );
|
2018-08-27 13:51:37 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
for( ZONE* zone : footprint->Zones() )
|
2020-10-10 22:09:00 +00:00
|
|
|
syncZone( aWorld, zone, boardOutline );
|
2019-10-28 09:15:03 +00:00
|
|
|
|
2023-06-06 15:09:34 +00:00
|
|
|
for( PCB_FIELD* field : footprint->Fields() )
|
|
|
|
syncTextItem( aWorld, static_cast<PCB_TEXT*>( field ), field->GetLayer() );
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
for( BOARD_ITEM* item : footprint->GraphicalItems() )
|
2018-08-27 13:51:37 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
if( item->Type() == PCB_SHAPE_T || item->Type() == PCB_TEXTBOX_T )
|
2018-08-27 13:51:37 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
syncGraphicalItem( aWorld, static_cast<PCB_SHAPE*>( item ) );
|
2018-08-27 13:51:37 +00:00
|
|
|
}
|
2023-03-30 11:49:23 +00:00
|
|
|
else if( item->Type() == PCB_TEXT_T )
|
2018-08-27 13:51:37 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
syncTextItem( aWorld, static_cast<PCB_TEXT*>( item ), item->GetLayer() );
|
2018-08-27 13:51:37 +00:00
|
|
|
}
|
|
|
|
}
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
for( PCB_TRACK* t : m_board->Tracks() )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
|
|
|
KICAD_T type = t->Type();
|
|
|
|
|
2019-01-12 15:24:00 +00:00
|
|
|
if( type == PCB_TRACE_T )
|
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
if( std::unique_ptr<PNS::SEGMENT> segment = syncTrack( t ) )
|
2016-06-21 15:06:28 +00:00
|
|
|
aWorld->Add( std::move( segment ) );
|
2019-01-12 15:24:00 +00:00
|
|
|
}
|
2019-05-17 00:13:21 +00:00
|
|
|
else if( type == PCB_ARC_T )
|
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
if( std::unique_ptr<PNS::ARC> arc = syncArc( static_cast<PCB_ARC*>( t ) ) )
|
2019-05-17 00:13:21 +00:00
|
|
|
aWorld->Add( std::move( arc ) );
|
|
|
|
}
|
2019-01-12 15:24:00 +00:00
|
|
|
else if( type == PCB_VIA_T )
|
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
if( std::unique_ptr<PNS::VIA> via = syncVia( static_cast<PCB_VIA*>( t ) ) )
|
2016-08-30 15:28:35 +00:00
|
|
|
aWorld->Add( std::move( via ) );
|
|
|
|
}
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
|
2020-11-11 17:17:11 +00:00
|
|
|
// NB: if this were ever to become a long-lived object we would need to dirty its
|
|
|
|
// clearance cache here....
|
2016-08-17 13:09:48 +00:00
|
|
|
delete m_ruleResolver;
|
2020-04-16 22:29:28 +00:00
|
|
|
m_ruleResolver = new PNS_PCBNEW_RULE_RESOLVER( m_board, this );
|
2016-08-15 15:16:47 +00:00
|
|
|
|
|
|
|
aWorld->SetRuleResolver( m_ruleResolver );
|
2021-04-18 13:50:06 +00:00
|
|
|
aWorld->SetMaxClearance( worstClearance + m_ruleResolver->ClearanceEpsilon() );
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
|
2016-08-15 15:16:47 +00:00
|
|
|
void PNS_KICAD_IFACE::EraseView()
|
|
|
|
{
|
2023-05-12 21:03:54 +00:00
|
|
|
for( BOARD_ITEM* item : m_hiddenItems )
|
2016-12-02 17:58:12 +00:00
|
|
|
m_view->SetVisible( item, true );
|
2016-08-15 15:16:47 +00:00
|
|
|
|
|
|
|
m_hiddenItems.clear();
|
|
|
|
|
|
|
|
if( m_previewItems )
|
|
|
|
{
|
|
|
|
m_previewItems->FreeItems();
|
2016-12-02 17:58:12 +00:00
|
|
|
m_view->Update( m_previewItems );
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
2016-08-15 15:16:48 +00:00
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
if( m_debugDecorator )
|
2016-08-15 15:16:48 +00:00
|
|
|
m_debugDecorator->Clear();
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2019-12-30 14:26:33 +00:00
|
|
|
void PNS_KICAD_IFACE_BASE::SetDebugDecorator( PNS::DEBUG_DECORATOR *aDec )
|
|
|
|
{
|
|
|
|
m_debugDecorator = aDec;
|
|
|
|
}
|
2016-08-15 15:16:53 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-12-08 16:01:27 +00:00
|
|
|
void PNS_KICAD_IFACE::DisplayItem( const PNS::ITEM* aItem, int aClearance, bool aEdit, int aFlags )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2021-07-13 22:51:07 +00:00
|
|
|
if( aItem->IsVirtual() )
|
|
|
|
return;
|
|
|
|
|
2023-12-08 16:01:27 +00:00
|
|
|
if( ZONE* zone = dynamic_cast<ZONE*>( aItem->Parent() ) )
|
|
|
|
{
|
|
|
|
if( zone->GetIsRuleArea() )
|
|
|
|
aFlags |= PNS_SEMI_SOLID;
|
|
|
|
}
|
|
|
|
|
|
|
|
ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aItem, m_view, aFlags );
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2021-12-06 15:51:10 +00:00
|
|
|
// Note: SEGMENT_T is used for placed tracks; LINE_T is used for the routing head
|
|
|
|
static int tracks = PNS::ITEM::SEGMENT_T | PNS::ITEM::ARC_T | PNS::ITEM::LINE_T;
|
2021-12-02 13:20:23 +00:00
|
|
|
static int tracksOrVias = tracks | PNS::ITEM::VIA_T;
|
2021-12-01 19:43:10 +00:00
|
|
|
|
2016-08-15 15:16:47 +00:00
|
|
|
if( aClearance >= 0 )
|
2017-01-25 09:33:49 +00:00
|
|
|
{
|
2016-08-15 15:16:47 +00:00
|
|
|
pitem->SetClearance( aClearance );
|
|
|
|
|
2021-12-26 00:36:12 +00:00
|
|
|
auto* settings = static_cast<PCBNEW_SETTINGS*>( m_tool->GetManager()->GetSettings() );
|
|
|
|
|
2022-02-12 16:32:55 +00:00
|
|
|
switch( settings->m_Display.m_TrackClearance )
|
2017-01-25 09:33:49 +00:00
|
|
|
{
|
2022-02-12 16:32:55 +00:00
|
|
|
case SHOW_WITH_VIA_ALWAYS:
|
|
|
|
case SHOW_WITH_VIA_WHILE_ROUTING_OR_DRAGGING:
|
2021-12-02 13:20:23 +00:00
|
|
|
pitem->ShowClearance( aItem->OfKind( tracksOrVias ) );
|
2019-11-07 14:23:09 +00:00
|
|
|
break;
|
|
|
|
|
2022-02-12 16:32:55 +00:00
|
|
|
case SHOW_WITH_VIA_WHILE_ROUTING:
|
2021-12-02 13:20:23 +00:00
|
|
|
pitem->ShowClearance( aItem->OfKind( tracksOrVias ) && !aEdit );
|
2019-11-07 14:23:09 +00:00
|
|
|
break;
|
|
|
|
|
2022-02-12 16:32:55 +00:00
|
|
|
case SHOW_WHILE_ROUTING:
|
2021-12-02 13:20:23 +00:00
|
|
|
pitem->ShowClearance( aItem->OfKind( tracks ) && !aEdit );
|
2021-12-01 19:43:10 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
pitem->ShowClearance( false );
|
2019-11-07 14:23:09 +00:00
|
|
|
break;
|
2017-01-25 09:33:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_previewItems->Add( pitem );
|
2016-12-09 11:04:32 +00:00
|
|
|
m_view->Update( m_previewItems );
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
|
2023-02-01 17:36:52 +00:00
|
|
|
void PNS_KICAD_IFACE::DisplayPathLine( const SHAPE_LINE_CHAIN& aLine, int aImportance )
|
|
|
|
{
|
|
|
|
ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aLine, m_view );
|
2023-12-17 13:46:57 +00:00
|
|
|
pitem->SetDepth( pitem->GetOriginDepth() - ROUTER_PREVIEW_ITEM::PathOverlayDepth );
|
2023-02-01 17:36:52 +00:00
|
|
|
|
|
|
|
COLOR4D color;
|
|
|
|
|
|
|
|
if( aImportance >= 1 )
|
|
|
|
color = COLOR4D( 1.0, 1.0, 0.0, 0.6 );
|
|
|
|
else if( aImportance == 0 )
|
|
|
|
color = COLOR4D( 0.7, 0.7, 0.7, 0.6 );
|
|
|
|
|
|
|
|
pitem->SetColor( color );
|
|
|
|
|
|
|
|
m_previewItems->Add( pitem );
|
|
|
|
m_view->Update( m_previewItems );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-08-22 12:06:33 +00:00
|
|
|
void PNS_KICAD_IFACE::DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, PNS::NET_HANDLE aNet )
|
2020-10-14 00:04:47 +00:00
|
|
|
{
|
2022-03-07 23:44:31 +00:00
|
|
|
ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aRatline, m_view );
|
2022-10-16 21:21:14 +00:00
|
|
|
|
|
|
|
KIGFX::RENDER_SETTINGS* renderSettings = m_view->GetPainter()->GetSettings();
|
|
|
|
KIGFX::PCB_RENDER_SETTINGS* rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( renderSettings );
|
|
|
|
bool colorByNet = rs->GetNetColorMode() != NET_COLOR_MODE::OFF;
|
|
|
|
COLOR4D defaultColor = rs->GetColor( nullptr, LAYER_RATSNEST );
|
|
|
|
COLOR4D color = defaultColor;
|
|
|
|
|
|
|
|
std::shared_ptr<CONNECTIVITY_DATA> connectivity = m_board->GetConnectivity();
|
|
|
|
std::set<int> highlightedNets = rs->GetHighlightNetCodes();
|
|
|
|
std::map<int, KIGFX::COLOR4D>& netColors = rs->GetNetColorMap();
|
|
|
|
std::map<wxString, KIGFX::COLOR4D>& ncColors = rs->GetNetclassColorMap();
|
|
|
|
const std::map<int, wxString>& ncMap = connectivity->GetNetclassMap();
|
2023-08-22 12:06:33 +00:00
|
|
|
int netCode = -1;
|
2022-10-16 21:21:14 +00:00
|
|
|
|
2023-08-22 12:06:33 +00:00
|
|
|
if( NETINFO_ITEM* net = static_cast<NETINFO_ITEM*>( aNet ) )
|
|
|
|
netCode = net->GetNetCode();
|
|
|
|
|
|
|
|
if( colorByNet && netColors.count( netCode ) )
|
|
|
|
color = netColors.at( netCode );
|
|
|
|
else if( colorByNet && ncMap.count( netCode ) && ncColors.count( ncMap.at( netCode ) ) )
|
|
|
|
color = ncColors.at( ncMap.at( netCode ) );
|
2022-10-16 21:21:14 +00:00
|
|
|
else
|
|
|
|
color = defaultColor;
|
|
|
|
|
|
|
|
if( color == COLOR4D::UNSPECIFIED )
|
|
|
|
color = defaultColor;
|
|
|
|
|
|
|
|
pitem->SetColor( color.Brightened( 0.5 ).WithAlpha( std::min( 1.0, color.a + 0.4 ) ) );
|
|
|
|
|
2020-10-14 00:04:47 +00:00
|
|
|
m_previewItems->Add( pitem );
|
|
|
|
m_view->Update( m_previewItems );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
void PNS_KICAD_IFACE::HideItem( PNS::ITEM* aItem )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2020-10-17 12:52:18 +00:00
|
|
|
BOARD_ITEM* parent = aItem->Parent();
|
2016-08-15 15:16:47 +00:00
|
|
|
|
|
|
|
if( parent )
|
|
|
|
{
|
2016-12-09 11:04:32 +00:00
|
|
|
if( m_view->IsVisible( parent ) )
|
2016-08-15 15:16:47 +00:00
|
|
|
m_hiddenItems.insert( parent );
|
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
m_view->SetVisible( parent, false );
|
2016-12-09 11:04:32 +00:00
|
|
|
m_view->Update( parent, KIGFX::APPEARANCE );
|
2023-05-12 21:03:54 +00:00
|
|
|
|
|
|
|
for( ZONE* td : m_board->Zones() )
|
|
|
|
{
|
|
|
|
if( td->IsTeardropArea()
|
|
|
|
&& td->GetBoundingBox().Intersects( aItem->Parent()->GetBoundingBox() )
|
|
|
|
&& td->Outline()->Collide( aItem->Shape() ) )
|
|
|
|
{
|
|
|
|
m_view->SetVisible( td, false );
|
|
|
|
m_view->Update( td, KIGFX::APPEARANCE );
|
|
|
|
}
|
|
|
|
}
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
|
2019-12-30 14:26:33 +00:00
|
|
|
void PNS_KICAD_IFACE_BASE::RemoveItem( PNS::ITEM* aItem )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
void PNS_KICAD_IFACE::RemoveItem( PNS::ITEM* aItem )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2020-10-17 12:52:18 +00:00
|
|
|
BOARD_ITEM* parent = aItem->Parent();
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2021-02-17 00:47:42 +00:00
|
|
|
if( aItem->OfKind( PNS::ITEM::SOLID_T ) )
|
2020-02-28 22:09:19 +00:00
|
|
|
{
|
2020-11-12 22:30:02 +00:00
|
|
|
PAD* pad = static_cast<PAD*>( parent );
|
2020-10-17 12:52:18 +00:00
|
|
|
VECTOR2I pos = static_cast<PNS::SOLID*>( aItem )->Pos();
|
2020-02-28 22:09:19 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
m_fpOffsets[ pad ].p_old = pos;
|
2020-02-28 22:09:19 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:47 +00:00
|
|
|
if( parent )
|
|
|
|
{
|
2016-06-21 15:06:28 +00:00
|
|
|
m_commit->Remove( parent );
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
|
2021-02-08 01:06:56 +00:00
|
|
|
void PNS_KICAD_IFACE_BASE::UpdateItem( PNS::ITEM* aItem )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-10-07 01:19:25 +00:00
|
|
|
void PNS_KICAD_IFACE::modifyBoardItem( PNS::ITEM* aItem )
|
2021-02-08 01:06:56 +00:00
|
|
|
{
|
|
|
|
BOARD_ITEM* board_item = aItem->Parent();
|
|
|
|
|
|
|
|
switch( aItem->Kind() )
|
|
|
|
{
|
|
|
|
case PNS::ITEM::ARC_T:
|
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
PNS::ARC* arc = static_cast<PNS::ARC*>( aItem );
|
|
|
|
PCB_ARC* arc_board = static_cast<PCB_ARC*>( board_item );
|
2021-02-08 01:06:56 +00:00
|
|
|
const SHAPE_ARC* arc_shape = static_cast<const SHAPE_ARC*>( arc->Shape() );
|
2024-02-24 23:24:54 +00:00
|
|
|
|
|
|
|
m_commit->Modify( arc_board );
|
|
|
|
|
2023-02-19 03:40:07 +00:00
|
|
|
arc_board->SetStart( VECTOR2I( arc_shape->GetP0() ) );
|
|
|
|
arc_board->SetEnd( VECTOR2I( arc_shape->GetP1() ) );
|
|
|
|
arc_board->SetMid( VECTOR2I( arc_shape->GetArcMid() ) );
|
2021-02-08 01:06:56 +00:00
|
|
|
arc_board->SetWidth( arc->Width() );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PNS::ITEM::SEGMENT_T:
|
|
|
|
{
|
|
|
|
PNS::SEGMENT* seg = static_cast<PNS::SEGMENT*>( aItem );
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_TRACK* track = static_cast<PCB_TRACK*>( board_item );
|
|
|
|
const SEG& s = seg->Seg();
|
2024-02-24 23:24:54 +00:00
|
|
|
|
|
|
|
m_commit->Modify( track );
|
|
|
|
|
2023-02-19 03:40:07 +00:00
|
|
|
track->SetStart( VECTOR2I( s.A.x, s.A.y ) );
|
|
|
|
track->SetEnd( VECTOR2I( s.B.x, s.B.y ) );
|
2021-02-08 01:06:56 +00:00
|
|
|
track->SetWidth( seg->Width() );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PNS::ITEM::VIA_T:
|
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_VIA* via_board = static_cast<PCB_VIA*>( board_item );
|
2021-02-08 01:06:56 +00:00
|
|
|
PNS::VIA* via = static_cast<PNS::VIA*>( aItem );
|
2024-02-24 23:24:54 +00:00
|
|
|
|
|
|
|
m_commit->Modify( via_board );
|
|
|
|
|
2023-02-19 03:40:07 +00:00
|
|
|
via_board->SetPosition( VECTOR2I( via->Pos().x, via->Pos().y ) );
|
2021-02-08 01:06:56 +00:00
|
|
|
via_board->SetWidth( via->Diameter() );
|
|
|
|
via_board->SetDrill( via->Drill() );
|
2023-08-22 12:06:33 +00:00
|
|
|
via_board->SetNet( static_cast<NETINFO_ITEM*>( via->Net() ) );
|
2021-02-08 01:06:56 +00:00
|
|
|
via_board->SetViaType( via->ViaType() ); // MUST be before SetLayerPair()
|
|
|
|
via_board->SetIsFree( via->IsFree() );
|
|
|
|
via_board->SetLayerPair( ToLAYER_ID( via->Layers().Start() ),
|
|
|
|
ToLAYER_ID( via->Layers().End() ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PNS::ITEM::SOLID_T:
|
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
PAD* pad = static_cast<PAD*>( aItem->Parent() );
|
2021-02-08 01:06:56 +00:00
|
|
|
VECTOR2I pos = static_cast<PNS::SOLID*>( aItem )->Pos();
|
|
|
|
|
2024-02-24 23:24:54 +00:00
|
|
|
// Don't add to commit; we'll add the parent footprints when processing the m_fpOffsets
|
|
|
|
|
2023-10-07 01:19:25 +00:00
|
|
|
m_fpOffsets[pad].p_old = pad->GetPosition();
|
|
|
|
m_fpOffsets[pad].p_new = pos;
|
2021-02-08 01:06:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-02-24 23:24:54 +00:00
|
|
|
default:
|
|
|
|
m_commit->Modify( aItem->Parent() );
|
|
|
|
break;
|
2021-02-08 01:06:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-10-07 01:19:25 +00:00
|
|
|
void PNS_KICAD_IFACE::UpdateItem( PNS::ITEM* aItem )
|
|
|
|
{
|
|
|
|
modifyBoardItem( aItem );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-30 14:26:33 +00:00
|
|
|
void PNS_KICAD_IFACE_BASE::AddItem( PNS::ITEM* aItem )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-10-07 01:19:25 +00:00
|
|
|
BOARD_CONNECTED_ITEM* PNS_KICAD_IFACE::createBoardItem( PNS::ITEM* aItem )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2024-03-20 17:34:18 +00:00
|
|
|
BOARD_CONNECTED_ITEM* newBoardItem = nullptr;
|
|
|
|
NETINFO_ITEM* net = static_cast<NETINFO_ITEM*>( aItem->Net() );
|
|
|
|
|
|
|
|
if( !net )
|
|
|
|
net = NETINFO_LIST::OrphanedItem();
|
2016-08-15 15:16:47 +00:00
|
|
|
|
|
|
|
switch( aItem->Kind() )
|
|
|
|
{
|
2019-05-17 00:13:21 +00:00
|
|
|
case PNS::ITEM::ARC_T:
|
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
PNS::ARC* arc = static_cast<PNS::ARC*>( aItem );
|
|
|
|
PCB_ARC* new_arc = new PCB_ARC( m_board, static_cast<const SHAPE_ARC*>( arc->Shape() ) );
|
2019-05-17 00:13:21 +00:00
|
|
|
new_arc->SetWidth( arc->Width() );
|
|
|
|
new_arc->SetLayer( ToLAYER_ID( arc->Layers().Start() ) );
|
2023-12-11 03:59:36 +00:00
|
|
|
new_arc->SetNet( net );
|
2024-03-20 17:34:18 +00:00
|
|
|
newBoardItem = new_arc;
|
2019-05-17 00:13:21 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
case PNS::ITEM::SEGMENT_T:
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
PNS::SEGMENT* seg = static_cast<PNS::SEGMENT*>( aItem );
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_TRACK* track = new PCB_TRACK( m_board );
|
2023-10-07 01:19:25 +00:00
|
|
|
const SEG& s = seg->Seg();
|
2023-02-19 03:40:07 +00:00
|
|
|
track->SetStart( VECTOR2I( s.A.x, s.A.y ) );
|
|
|
|
track->SetEnd( VECTOR2I( s.B.x, s.B.y ) );
|
2016-08-15 15:16:47 +00:00
|
|
|
track->SetWidth( seg->Width() );
|
|
|
|
track->SetLayer( ToLAYER_ID( seg->Layers().Start() ) );
|
2023-12-11 03:59:36 +00:00
|
|
|
track->SetNet( net );
|
2024-03-20 17:34:18 +00:00
|
|
|
newBoardItem = track;
|
2016-08-15 15:16:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
case PNS::ITEM::VIA_T:
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_VIA* via_board = new PCB_VIA( m_board );
|
2016-08-29 17:31:13 +00:00
|
|
|
PNS::VIA* via = static_cast<PNS::VIA*>( aItem );
|
2023-02-19 03:40:07 +00:00
|
|
|
via_board->SetPosition( VECTOR2I( via->Pos().x, via->Pos().y ) );
|
2016-08-15 15:16:47 +00:00
|
|
|
via_board->SetWidth( via->Diameter() );
|
|
|
|
via_board->SetDrill( via->Drill() );
|
2023-12-11 03:59:36 +00:00
|
|
|
via_board->SetNet( net );
|
2016-08-15 15:16:47 +00:00
|
|
|
via_board->SetViaType( via->ViaType() ); // MUST be before SetLayerPair()
|
2020-12-20 21:29:43 +00:00
|
|
|
via_board->SetIsFree( via->IsFree() );
|
2016-08-15 15:16:47 +00:00
|
|
|
via_board->SetLayerPair( ToLAYER_ID( via->Layers().Start() ),
|
|
|
|
ToLAYER_ID( via->Layers().End() ) );
|
2024-03-20 17:34:18 +00:00
|
|
|
newBoardItem = via_board;
|
2016-08-15 15:16:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-02-28 22:09:19 +00:00
|
|
|
case PNS::ITEM::SOLID_T:
|
|
|
|
{
|
2023-10-07 01:19:25 +00:00
|
|
|
PAD* pad = static_cast<PAD*>( aItem->Parent() );
|
2020-10-17 12:52:18 +00:00
|
|
|
VECTOR2I pos = static_cast<PNS::SOLID*>( aItem )->Pos();
|
2020-02-28 22:09:19 +00:00
|
|
|
|
2023-10-07 01:19:25 +00:00
|
|
|
m_fpOffsets[pad].p_new = pos;
|
|
|
|
return nullptr;
|
2020-02-28 22:09:19 +00:00
|
|
|
}
|
|
|
|
|
2023-12-18 18:36:14 +00:00
|
|
|
default:
|
|
|
|
return nullptr;
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
|
2023-12-11 03:59:36 +00:00
|
|
|
if( net->GetNetCode() <= 0 )
|
|
|
|
{
|
2024-03-20 17:34:18 +00:00
|
|
|
NETINFO_ITEM* newNetInfo = newBoardItem->GetNet();
|
|
|
|
|
2023-12-11 03:59:36 +00:00
|
|
|
newNetInfo->SetParent( m_board );
|
|
|
|
newNetInfo->SetNetClass( m_board->GetDesignSettings().m_NetSettings->m_DefaultNetClass );
|
|
|
|
}
|
|
|
|
|
2024-03-20 17:34:18 +00:00
|
|
|
return newBoardItem;
|
2023-10-07 01:19:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PNS_KICAD_IFACE::AddItem( PNS::ITEM* aItem )
|
|
|
|
{
|
2023-10-19 10:38:26 +00:00
|
|
|
BOARD_CONNECTED_ITEM* boardItem = createBoardItem( aItem );
|
2023-10-07 01:19:25 +00:00
|
|
|
|
2023-10-19 10:38:26 +00:00
|
|
|
if( boardItem )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2023-10-19 10:38:26 +00:00
|
|
|
aItem->SetParent( boardItem );
|
|
|
|
boardItem->ClearFlags();
|
2016-06-21 15:06:28 +00:00
|
|
|
|
2023-10-19 10:38:26 +00:00
|
|
|
m_commit->Add( boardItem );
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
|
2016-08-15 15:16:47 +00:00
|
|
|
void PNS_KICAD_IFACE::Commit()
|
|
|
|
{
|
2021-11-25 14:51:36 +00:00
|
|
|
std::set<FOOTPRINT*> processedFootprints;
|
2020-02-28 22:09:19 +00:00
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
EraseView();
|
2020-02-28 22:09:19 +00:00
|
|
|
|
2023-05-12 21:03:54 +00:00
|
|
|
for( const auto& [ pad, fpOffset ] : m_fpOffsets )
|
2020-02-28 22:09:19 +00:00
|
|
|
{
|
2023-05-12 21:03:54 +00:00
|
|
|
VECTOR2I offset = fpOffset.p_new - fpOffset.p_old;
|
2023-06-24 18:54:50 +00:00
|
|
|
FOOTPRINT* footprint = pad->GetParentFootprint();
|
2022-10-14 10:12:25 +00:00
|
|
|
VECTOR2I p_orig = footprint->GetPosition();
|
|
|
|
VECTOR2I p_new = p_orig + offset;
|
2020-02-28 22:09:19 +00:00
|
|
|
|
2021-11-25 14:51:36 +00:00
|
|
|
if( processedFootprints.find( footprint ) != processedFootprints.end() )
|
2020-02-28 22:09:19 +00:00
|
|
|
continue;
|
|
|
|
|
2021-11-25 14:51:36 +00:00
|
|
|
processedFootprints.insert( footprint );
|
2021-02-17 00:47:42 +00:00
|
|
|
m_commit->Modify( footprint );
|
2022-10-14 10:12:25 +00:00
|
|
|
footprint->SetPosition( p_new );
|
2020-02-28 22:09:19 +00:00
|
|
|
}
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
m_fpOffsets.clear();
|
2020-02-28 22:09:19 +00:00
|
|
|
|
2023-10-19 10:38:26 +00:00
|
|
|
m_commit->Push( _( "Routing" ), m_commitFlags );
|
2019-12-05 13:43:55 +00:00
|
|
|
m_commit = std::make_unique<BOARD_COMMIT>( m_tool );
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
|
2021-12-02 22:25:35 +00:00
|
|
|
EDA_UNITS PNS_KICAD_IFACE::GetUnits() const
|
|
|
|
{
|
|
|
|
return static_cast<EDA_UNITS>( m_tool->GetManager()->GetSettings()->m_System.units );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-24 15:14:38 +00:00
|
|
|
void PNS_KICAD_IFACE::SetView( KIGFX::VIEW* aView )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2022-02-05 02:06:25 +00:00
|
|
|
wxLogTrace( wxT( "PNS" ), wxT( "SetView %p" ), aView );
|
2016-08-15 15:16:53 +00:00
|
|
|
|
2016-08-15 15:16:47 +00:00
|
|
|
if( m_previewItems )
|
|
|
|
{
|
|
|
|
m_previewItems->FreeItems();
|
|
|
|
delete m_previewItems;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_view = aView;
|
|
|
|
m_previewItems = new KIGFX::VIEW_GROUP( m_view );
|
2018-08-28 21:57:31 +00:00
|
|
|
m_previewItems->SetLayer( LAYER_SELECT_OVERLAY ) ;
|
2020-03-29 16:42:24 +00:00
|
|
|
|
2019-12-30 14:26:33 +00:00
|
|
|
if(m_view)
|
|
|
|
m_view->Add( m_previewItems );
|
2016-08-15 15:16:48 +00:00
|
|
|
|
2016-08-17 13:09:48 +00:00
|
|
|
delete m_debugDecorator;
|
2019-12-30 14:26:33 +00:00
|
|
|
|
2021-02-25 16:18:13 +00:00
|
|
|
auto dec = new PNS_PCBNEW_DEBUG_DECORATOR();
|
2019-12-30 14:26:33 +00:00
|
|
|
m_debugDecorator = dec;
|
2020-07-03 23:33:36 +00:00
|
|
|
|
2021-05-28 22:09:21 +00:00
|
|
|
dec->SetDebugEnabled( ADVANCED_CFG::GetCfg().m_ShowRouterDebugGraphics );
|
2021-05-29 16:40:00 +00:00
|
|
|
|
|
|
|
if( ADVANCED_CFG::GetCfg().m_ShowRouterDebugGraphics )
|
|
|
|
dec->SetView( m_view );
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
|
2016-06-21 15:06:28 +00:00
|
|
|
|
2023-08-22 12:06:33 +00:00
|
|
|
int PNS_KICAD_IFACE::GetNetCode( PNS::NET_HANDLE aNet ) const
|
|
|
|
{
|
|
|
|
if( aNet )
|
|
|
|
return static_cast<NETINFO_ITEM*>( aNet )->GetNetCode();
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString PNS_KICAD_IFACE::GetNetName( PNS::NET_HANDLE aNet ) const
|
|
|
|
{
|
|
|
|
if( aNet )
|
|
|
|
return static_cast<NETINFO_ITEM*>( aNet )->GetNetname();
|
|
|
|
else
|
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PNS_KICAD_IFACE::UpdateNet( PNS::NET_HANDLE aNet )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2023-08-22 12:06:33 +00:00
|
|
|
wxLogTrace( wxT( "PNS" ), wxT( "Update-net %s" ), GetNetName( aNet ) );
|
2019-12-30 14:26:33 +00:00
|
|
|
}
|
2016-12-09 11:04:32 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-09-12 13:59:20 +00:00
|
|
|
PNS::NET_HANDLE PNS_KICAD_IFACE_BASE::GetOrphanedNetHandle()
|
|
|
|
{
|
|
|
|
return NETINFO_LIST::OrphanedItem();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-30 14:26:33 +00:00
|
|
|
PNS::RULE_RESOLVER* PNS_KICAD_IFACE_BASE::GetRuleResolver()
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
|
|
|
return m_ruleResolver;
|
|
|
|
}
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
|
2019-05-12 11:49:58 +00:00
|
|
|
void PNS_KICAD_IFACE::SetHostTool( PCB_TOOL_BASE* aTool )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2017-10-31 11:03:58 +00:00
|
|
|
m_tool = aTool;
|
2019-12-05 13:43:55 +00:00
|
|
|
m_commit = std::make_unique<BOARD_COMMIT>( m_tool );
|
2017-10-31 11:03:58 +00:00
|
|
|
}
|