New rules engine needs non-connected items as well.
This commit is contained in:
parent
6e54856e67
commit
23d9e2e74a
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include "pns_layerset.h"
|
||||
|
||||
class BOARD_CONNECTED_ITEM;
|
||||
class BOARD_ITEM;
|
||||
|
||||
namespace PNS {
|
||||
|
||||
|
@ -143,8 +143,8 @@ public:
|
|||
*/
|
||||
std::string KindStr() const;
|
||||
|
||||
void SetParent( BOARD_CONNECTED_ITEM* aParent ) { m_parent = aParent; }
|
||||
BOARD_CONNECTED_ITEM* Parent() const { return m_parent; }
|
||||
void SetParent( BOARD_ITEM* aParent ) { m_parent = aParent; }
|
||||
BOARD_ITEM* Parent() const { return m_parent; }
|
||||
|
||||
void SetNet( int aNet ) { m_net = aNet; }
|
||||
int Net() const { return m_net; }
|
||||
|
@ -252,17 +252,17 @@ private:
|
|||
const NODE* aParentNode, bool aDifferentNetsOnly ) const;
|
||||
|
||||
protected:
|
||||
PnsKind m_kind;
|
||||
PnsKind m_kind;
|
||||
|
||||
BOARD_CONNECTED_ITEM* m_parent;
|
||||
NODE* m_owner;
|
||||
LAYER_RANGE m_layers;
|
||||
BOARD_ITEM* m_parent;
|
||||
NODE* m_owner;
|
||||
LAYER_RANGE m_layers;
|
||||
|
||||
bool m_movable;
|
||||
int m_net;
|
||||
mutable int m_marker;
|
||||
int m_rank;
|
||||
bool m_routable;
|
||||
bool m_movable;
|
||||
int m_net;
|
||||
mutable int m_marker;
|
||||
int m_rank;
|
||||
bool m_routable;
|
||||
};
|
||||
|
||||
template< typename T, typename S >
|
||||
|
|
|
@ -540,16 +540,24 @@ int PNS_PCBNEW_RULE_RESOLVER::DpNetPolarity( int aNet )
|
|||
|
||||
bool PNS_PCBNEW_RULE_RESOLVER::DpNetPair( const PNS::ITEM* aItem, int& aNetP, int& aNetN )
|
||||
{
|
||||
if( !aItem || !aItem->Parent() || !aItem->Parent()->GetNet() )
|
||||
if( !aItem || !aItem->Parent() || !aItem->Parent()->IsConnected() )
|
||||
return false;
|
||||
|
||||
wxString netNameP = aItem->Parent()->GetNet()->GetNetname();
|
||||
BOARD_CONNECTED_ITEM* cItem = static_cast<BOARD_CONNECTED_ITEM*>( aItem->Parent() );
|
||||
NETINFO_ITEM* netInfo = cItem->GetNet();
|
||||
|
||||
if( !netInfo )
|
||||
return false;
|
||||
|
||||
wxString netNameP = netInfo->GetNetname();
|
||||
wxString netNameN, netNameCoupled, netNameBase;
|
||||
|
||||
int r = matchDpSuffix( netNameP, netNameCoupled, netNameBase );
|
||||
|
||||
if( r == 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if( r == 1 )
|
||||
{
|
||||
netNameN = netNameCoupled;
|
||||
|
@ -982,7 +990,7 @@ bool PNS_KICAD_IFACE_BASE::syncTextItem( PNS::NODE* aWorld, EDA_TEXT* aText, PCB
|
|||
|
||||
solid->SetLayer( aLayer );
|
||||
solid->SetNet( -1 );
|
||||
solid->SetParent( nullptr );
|
||||
solid->SetParent( dynamic_cast<BOARD_ITEM*>( aText ) );
|
||||
solid->SetShape( new SHAPE_SEGMENT( start, end, textWidth ) );
|
||||
solid->SetRoutable( false );
|
||||
|
||||
|
@ -1032,7 +1040,7 @@ bool PNS_KICAD_IFACE_BASE::syncGraphicalItem( PNS::NODE* aWorld, PCB_SHAPE* aIte
|
|||
solid->SetLayer( aItem->GetLayer() );
|
||||
|
||||
solid->SetNet( -1 );
|
||||
solid->SetParent( nullptr );
|
||||
solid->SetParent( aItem );
|
||||
solid->SetShape( shape );
|
||||
solid->SetRoutable( false );
|
||||
|
||||
|
@ -1069,27 +1077,27 @@ bool PNS_KICAD_IFACE::IsOnLayer( const PNS::ITEM* aItem, int aLayer ) const
|
|||
if( aLayer < 0 )
|
||||
return true;
|
||||
|
||||
if( !aItem->Parent() )
|
||||
return aItem->Layers().Overlaps( aLayer );
|
||||
|
||||
switch( aItem->Parent()->Type() )
|
||||
if( aItem->Parent() )
|
||||
{
|
||||
case PCB_VIA_T:
|
||||
{
|
||||
const VIA* via = static_cast<const VIA*>( aItem->Parent() );
|
||||
switch( aItem->Parent()->Type() )
|
||||
{
|
||||
case PCB_VIA_T:
|
||||
{
|
||||
const VIA* via = static_cast<const VIA*>( aItem->Parent() );
|
||||
|
||||
return via->FlashLayer( static_cast<PCB_LAYER_ID>( aLayer ));
|
||||
}
|
||||
return via->FlashLayer( static_cast<PCB_LAYER_ID>( aLayer ));
|
||||
}
|
||||
|
||||
case PCB_PAD_T:
|
||||
{
|
||||
const D_PAD* pad = static_cast<const D_PAD*>( aItem->Parent() );
|
||||
case PCB_PAD_T:
|
||||
{
|
||||
const D_PAD* pad = static_cast<const D_PAD*>( aItem->Parent() );
|
||||
|
||||
return pad->FlashLayer( static_cast<PCB_LAYER_ID>( aLayer ));
|
||||
}
|
||||
return pad->FlashLayer( static_cast<PCB_LAYER_ID>( aLayer ));
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return aItem->Layers().Overlaps( aLayer );
|
||||
|
@ -1098,13 +1106,13 @@ bool PNS_KICAD_IFACE::IsOnLayer( const PNS::ITEM* aItem, int aLayer ) const
|
|||
|
||||
bool PNS_KICAD_IFACE::IsItemVisible( const PNS::ITEM* aItem ) const
|
||||
{
|
||||
// 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)
|
||||
// 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)
|
||||
if( !m_view || !aItem->Parent() )
|
||||
return true;
|
||||
|
||||
auto item = aItem->Parent();
|
||||
bool isOnVisibleLayer = true;
|
||||
BOARD_ITEM* item = aItem->Parent();
|
||||
bool isOnVisibleLayer = true;
|
||||
|
||||
if( m_view->GetPainter()->GetSettings()->GetHighContrast() )
|
||||
{
|
||||
|
@ -1312,7 +1320,7 @@ void PNS_KICAD_IFACE::DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, int aCol
|
|||
|
||||
void PNS_KICAD_IFACE::HideItem( PNS::ITEM* aItem )
|
||||
{
|
||||
BOARD_CONNECTED_ITEM* parent = aItem->Parent();
|
||||
BOARD_ITEM* parent = aItem->Parent();
|
||||
|
||||
if( parent )
|
||||
{
|
||||
|
@ -1333,12 +1341,12 @@ void PNS_KICAD_IFACE_BASE::RemoveItem( PNS::ITEM* aItem )
|
|||
|
||||
void PNS_KICAD_IFACE::RemoveItem( PNS::ITEM* aItem )
|
||||
{
|
||||
BOARD_CONNECTED_ITEM* parent = aItem->Parent();
|
||||
BOARD_ITEM* parent = aItem->Parent();
|
||||
|
||||
if ( aItem->OfKind(PNS::ITEM::SOLID_T) )
|
||||
{
|
||||
auto pad = static_cast<D_PAD*>( parent );
|
||||
auto pos = static_cast<PNS::SOLID*>( aItem )->Pos();
|
||||
D_PAD* pad = static_cast<D_PAD*>( parent );
|
||||
VECTOR2I pos = static_cast<PNS::SOLID*>( aItem )->Pos();
|
||||
|
||||
m_moduleOffsets[ pad ].p_old = pos;
|
||||
return;
|
||||
|
@ -1405,8 +1413,8 @@ void PNS_KICAD_IFACE::AddItem( PNS::ITEM* aItem )
|
|||
|
||||
case PNS::ITEM::SOLID_T:
|
||||
{
|
||||
auto pad = static_cast<D_PAD*>( aItem->Parent() );
|
||||
auto pos = static_cast<PNS::SOLID*>( aItem )->Pos();
|
||||
D_PAD* pad = static_cast<D_PAD*>( aItem->Parent() );
|
||||
VECTOR2I pos = static_cast<PNS::SOLID*>( aItem )->Pos();
|
||||
|
||||
m_moduleOffsets[ pad ].p_new = pos;
|
||||
return;
|
||||
|
|
|
@ -126,18 +126,19 @@ public:
|
|||
void UpdateNet( int aNetCode ) override;
|
||||
|
||||
private:
|
||||
struct OFFSET {
|
||||
struct OFFSET
|
||||
{
|
||||
VECTOR2I p_old, p_new;
|
||||
};
|
||||
|
||||
std::map<D_PAD*, OFFSET> m_moduleOffsets;
|
||||
KIGFX::VIEW* m_view;
|
||||
KIGFX::VIEW_GROUP* m_previewItems;
|
||||
std::unordered_set<BOARD_CONNECTED_ITEM*> m_hiddenItems;
|
||||
std::map<D_PAD*, OFFSET> m_moduleOffsets;
|
||||
KIGFX::VIEW* m_view;
|
||||
KIGFX::VIEW_GROUP* m_previewItems;
|
||||
std::unordered_set<BOARD_ITEM*> m_hiddenItems;
|
||||
|
||||
PCB_TOOL_BASE* m_tool;
|
||||
std::unique_ptr<BOARD_COMMIT> m_commit;
|
||||
const PCB_DISPLAY_OPTIONS* m_dispOptions;
|
||||
PCB_TOOL_BASE* m_tool;
|
||||
std::unique_ptr<BOARD_COMMIT> m_commit;
|
||||
const PCB_DISPLAY_OPTIONS* m_dispOptions;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1445,15 +1445,22 @@ int NODE::QueryJoints( const BOX2I& aBox,
|
|||
}
|
||||
|
||||
|
||||
ITEM *NODE::FindItemByParent( const BOARD_CONNECTED_ITEM* aParent )
|
||||
ITEM *NODE::FindItemByParent( const BOARD_ITEM* aParent )
|
||||
{
|
||||
INDEX::NET_ITEMS_LIST* l_cur = m_index->GetItemsForNet( aParent->GetNetCode() );
|
||||
|
||||
if( l_cur )
|
||||
if( aParent->IsConnected() )
|
||||
{
|
||||
for( ITEM* item : *l_cur )
|
||||
if( item->Parent() == aParent )
|
||||
return item;
|
||||
const BOARD_CONNECTED_ITEM* cItem = static_cast<const BOARD_CONNECTED_ITEM*>( aParent );
|
||||
|
||||
INDEX::NET_ITEMS_LIST* l_cur = m_index->GetItemsForNet( cItem->GetNetCode() );
|
||||
|
||||
if( l_cur )
|
||||
{
|
||||
for( ITEM* item : *l_cur )
|
||||
{
|
||||
if( item->Parent() == aParent )
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
|
@ -441,7 +441,7 @@ public:
|
|||
|
||||
void RemoveByMarker( int aMarker );
|
||||
|
||||
ITEM* FindItemByParent( const BOARD_CONNECTED_ITEM* aParent );
|
||||
ITEM* FindItemByParent( const BOARD_ITEM* aParent );
|
||||
|
||||
bool HasChildren() const
|
||||
{
|
||||
|
|
|
@ -1440,7 +1440,7 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
startItem = m_router->GetWorld()->FindItemByParent( static_cast<const BOARD_CONNECTED_ITEM*>( item ) );
|
||||
startItem = m_router->GetWorld()->FindItemByParent( item );
|
||||
|
||||
if( startItem)
|
||||
itemsToDrag.Add( startItem );
|
||||
|
|
Loading…
Reference in New Issue