Tighten ownership model of PNS::ITEM.
In particular, ownership must be explicitly set. It is no longer inherited through copy/clone/etc.
This commit is contained in:
parent
9646e3c1c0
commit
b2a45023bc
|
@ -40,7 +40,7 @@ HOLE::~HOLE()
|
||||||
|
|
||||||
HOLE* HOLE::Clone() const
|
HOLE* HOLE::Clone() const
|
||||||
{
|
{
|
||||||
HOLE* h = new HOLE( nullptr, m_holeShape->Clone() );
|
HOLE* h = new HOLE( m_holeShape->Clone() );
|
||||||
|
|
||||||
h->SetLayers( Layers() );
|
h->SetLayers( Layers() );
|
||||||
h->SetOwner( nullptr );
|
h->SetOwner( nullptr );
|
||||||
|
@ -131,7 +131,7 @@ void HOLE::Move( const VECTOR2I& delta )
|
||||||
HOLE* HOLE::MakeCircularHole( const VECTOR2I& pos, int radius )
|
HOLE* HOLE::MakeCircularHole( const VECTOR2I& pos, int radius )
|
||||||
{
|
{
|
||||||
SHAPE_CIRCLE* circle = new SHAPE_CIRCLE( pos, radius );
|
SHAPE_CIRCLE* circle = new SHAPE_CIRCLE( pos, radius );
|
||||||
HOLE* hole = new HOLE( nullptr, circle );
|
HOLE* hole = new HOLE( circle );
|
||||||
|
|
||||||
hole->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
|
hole->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
|
||||||
return hole;
|
return hole;
|
||||||
|
|
|
@ -33,14 +33,18 @@ namespace PNS
|
||||||
class HOLE : public ITEM
|
class HOLE : public ITEM
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HOLE( ITEM* aParentPadVia, SHAPE* aShape ) :
|
HOLE( SHAPE* aShape ) :
|
||||||
ITEM( ITEM::HOLE_T ),
|
ITEM( ITEM::HOLE_T ),
|
||||||
m_holeShape( aShape ),
|
m_holeShape( aShape ),
|
||||||
m_parentPadVia( aParentPadVia )
|
m_parentPadVia( nullptr )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
HOLE( const ITEM& aOther ) : ITEM( aOther ) {}
|
HOLE( const ITEM& aOther ) :
|
||||||
|
ITEM( aOther ),
|
||||||
|
m_parentPadVia( nullptr )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~HOLE();
|
virtual ~HOLE();
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ public:
|
||||||
m_movable = aOther.m_movable;
|
m_movable = aOther.m_movable;
|
||||||
m_kind = aOther.m_kind;
|
m_kind = aOther.m_kind;
|
||||||
m_parent = aOther.m_parent;
|
m_parent = aOther.m_parent;
|
||||||
m_owner = aOther.m_owner; // fixme: wtf this was null?
|
m_owner = nullptr;
|
||||||
m_marker = aOther.m_marker;
|
m_marker = aOther.m_marker;
|
||||||
m_rank = aOther.m_rank;
|
m_rank = aOther.m_rank;
|
||||||
m_routable = aOther.m_routable;
|
m_routable = aOther.m_routable;
|
||||||
|
|
|
@ -1098,12 +1098,7 @@ std::unique_ptr<PNS::SOLID> PNS_KICAD_IFACE_BASE::syncPad( PAD* aPad )
|
||||||
solid->SetOffset( VECTOR2I( offset.x, offset.y ) );
|
solid->SetOffset( VECTOR2I( offset.x, offset.y ) );
|
||||||
|
|
||||||
if( aPad->GetDrillSize().x > 0 )
|
if( aPad->GetDrillSize().x > 0 )
|
||||||
{
|
solid->SetHole( new PNS::HOLE( aPad->GetEffectiveHoleShape()->Clone() ) );
|
||||||
SHAPE_SEGMENT* slot = (SHAPE_SEGMENT*) aPad->GetEffectiveHoleShape()->Clone();
|
|
||||||
PNS::HOLE* hole = new PNS::HOLE( solid.get(), slot );
|
|
||||||
|
|
||||||
solid->SetHole( hole );
|
|
||||||
}
|
|
||||||
|
|
||||||
// We generate a single SOLID for a pad, so we have to treat it as ALWAYS_FLASHED and then
|
// 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.
|
// perform layer-specific flashing tests internally.
|
||||||
|
@ -1176,11 +1171,7 @@ std::unique_ptr<PNS::VIA> PNS_KICAD_IFACE_BASE::syncVia( PCB_VIA* aVia )
|
||||||
via->Mark( PNS::MK_LOCKED );
|
via->Mark( PNS::MK_LOCKED );
|
||||||
|
|
||||||
via->SetIsFree( aVia->GetIsFree() );
|
via->SetIsFree( aVia->GetIsFree() );
|
||||||
|
via->SetHole( PNS::HOLE::MakeCircularHole( aVia->GetPosition(), aVia->GetDrillValue() / 2 ) );
|
||||||
SHAPE* holeShape = new SHAPE_CIRCLE( aVia->GetPosition(), aVia->GetDrillValue() / 2 );
|
|
||||||
PNS::HOLE* viaHole = new PNS::HOLE( via.get(), holeShape );
|
|
||||||
|
|
||||||
via->SetHole( viaHole );
|
|
||||||
|
|
||||||
return via;
|
return via;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ LINE::LINE( const LINE& aOther )
|
||||||
{
|
{
|
||||||
m_via = aOther.m_via->Clone();
|
m_via = aOther.m_via->Clone();
|
||||||
m_via->SetOwner( this );
|
m_via->SetOwner( this );
|
||||||
|
m_via->SetNet( m_net );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_marker = aOther.m_marker;
|
m_marker = aOther.m_marker;
|
||||||
|
@ -82,6 +83,7 @@ LINE& LINE::operator=( const LINE& aOther )
|
||||||
{
|
{
|
||||||
m_via = aOther.m_via->Clone();
|
m_via = aOther.m_via->Clone();
|
||||||
m_via->SetOwner( this );
|
m_via->SetOwner( this );
|
||||||
|
m_via->SetNet( m_net );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_marker = aOther.m_marker;
|
m_marker = aOther.m_marker;
|
||||||
|
@ -1267,11 +1269,7 @@ bool LINE::HasLockedSegments() const
|
||||||
|
|
||||||
void LINE::Clear()
|
void LINE::Clear()
|
||||||
{
|
{
|
||||||
if( m_via && m_via->BelongsTo( this ) )
|
RemoveVia();
|
||||||
{
|
|
||||||
delete m_via;
|
|
||||||
m_via = nullptr;
|
|
||||||
}
|
|
||||||
m_line.Clear();
|
m_line.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,19 +113,14 @@ public:
|
||||||
|
|
||||||
virtual void SetHole( HOLE* aHole ) override
|
virtual void SetHole( HOLE* aHole ) override
|
||||||
{
|
{
|
||||||
if( m_hole )
|
if( m_hole && m_hole->BelongsTo( this ) )
|
||||||
{
|
delete m_hole;
|
||||||
assert( m_hole->Owner() == nullptr );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_hole = aHole;
|
m_hole = aHole;
|
||||||
m_hole->SetNet( Net() );
|
m_hole->SetParentPadVia( this );
|
||||||
m_hole->SetOwner( this );
|
m_hole->SetOwner( this );
|
||||||
|
m_hole->SetLayers( m_layers ); // fixme: backdrill vias can have hole layer set different
|
||||||
if( m_hole )
|
// than copper layer set
|
||||||
{
|
|
||||||
m_hole->SetLayers( m_layers ); // fixme: backdrill vias can have hole layer set different than copper layer set
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool HasHole() const override { return m_hole != nullptr; }
|
virtual bool HasHole() const override { return m_hole != nullptr; }
|
||||||
|
|
|
@ -55,11 +55,11 @@ public:
|
||||||
m_hole( nullptr )
|
m_hole( nullptr )
|
||||||
{
|
{
|
||||||
m_diameter = 2; // Dummy value
|
m_diameter = 2; // Dummy value
|
||||||
m_drill = 0;
|
m_drill = 1; // Dummy value
|
||||||
m_viaType = VIATYPE::THROUGH;
|
m_viaType = VIATYPE::THROUGH;
|
||||||
m_isFree = false;
|
m_isFree = false;
|
||||||
m_isVirtual = false;
|
m_isVirtual = false;
|
||||||
SetHole( HOLE::MakeCircularHole( m_pos, m_diameter / 2 ) );
|
SetHole( HOLE::MakeCircularHole( m_pos, m_drill / 2 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
VIA( const VECTOR2I& aPos, const LAYER_RANGE& aLayers, int aDiameter, int aDrill,
|
VIA( const VECTOR2I& aPos, const LAYER_RANGE& aLayers, int aDiameter, int aDrill,
|
||||||
|
@ -171,15 +171,14 @@ public:
|
||||||
|
|
||||||
virtual void SetHole( HOLE* aHole ) override
|
virtual void SetHole( HOLE* aHole ) override
|
||||||
{
|
{
|
||||||
if( m_hole && m_hole->Owner() == this )
|
if( m_hole && m_hole->BelongsTo( this ) )
|
||||||
delete m_hole;
|
delete m_hole;
|
||||||
|
|
||||||
m_hole = aHole;
|
m_hole = aHole;
|
||||||
m_hole->SetParentPadVia( this );
|
m_hole->SetParentPadVia( this );
|
||||||
m_hole->SetOwner( this );
|
m_hole->SetOwner( this );
|
||||||
|
m_hole->SetLayers( m_layers ); // fixme: backdrill vias can have hole layer set different
|
||||||
if( m_hole )
|
// than copper layer set
|
||||||
m_hole->SetLayers( m_layers ); // fixme: backdrill vias can have hole layer set different than copper layer set
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool HasHole() const override { return true; }
|
virtual bool HasHole() const override { return true; }
|
||||||
|
|
Loading…
Reference in New Issue