Remove a bunch of blind (and a few redundant) static_casts.
This commit is contained in:
parent
181ae7f450
commit
cf8294b5c2
|
@ -62,7 +62,7 @@ public:
|
|||
|
||||
virtual ~COLLECTOR() {}
|
||||
|
||||
virtual INSPECT_RESULT Inspect( EDA_ITEM* aItem, void* aTestData )
|
||||
virtual INSPECT_RESULT Inspect( EDA_ITEM* aTestItem, void* aTestData )
|
||||
{
|
||||
return INSPECT_RESULT::QUIT;
|
||||
};
|
||||
|
|
|
@ -82,7 +82,10 @@ void ARRAY_CREATOR::Invoke()
|
|||
|
||||
for ( int i = 0; i < m_selection.Size(); ++i )
|
||||
{
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( m_selection[ i ] );
|
||||
BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( m_selection[ i ] );
|
||||
|
||||
if( !item )
|
||||
continue;
|
||||
|
||||
if( item->Type() == PCB_PAD_T && !m_isFootprintEditor )
|
||||
{
|
||||
|
|
|
@ -426,13 +426,13 @@ void BOARD::Move( const VECTOR2I& aMoveVector ) // overload
|
|||
INSPECTOR_FUNC inspector =
|
||||
[&] ( EDA_ITEM* item, void* testData )
|
||||
{
|
||||
BOARD_ITEM* brdItem = static_cast<BOARD_ITEM*>( item );
|
||||
|
||||
if( BOARD_ITEM* board_item = dynamic_cast<BOARD_ITEM*>( item ) )
|
||||
{
|
||||
// aMoveVector was snapshotted, don't need "data".
|
||||
// Only move the top level group
|
||||
if( brdItem->GetParentGroup() == nullptr
|
||||
&& brdItem->GetParentFootprint() == nullptr )
|
||||
brdItem->Move( aMoveVector );
|
||||
if( !board_item->GetParentGroup() && !board_item->GetParentFootprint() )
|
||||
board_item->Move( aMoveVector );
|
||||
}
|
||||
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
};
|
||||
|
@ -2257,12 +2257,15 @@ BOARD::GroupLegalOpsField BOARD::GroupLegalOps( const PCB_SELECTION& selection )
|
|||
|
||||
for( EDA_ITEM* item : selection )
|
||||
{
|
||||
if( item->Type() == PCB_GROUP_T )
|
||||
if( BOARD_ITEM* board_item = dynamic_cast<BOARD_ITEM*>( item ) )
|
||||
{
|
||||
if( board_item->Type() == PCB_GROUP_T )
|
||||
hasGroup = true;
|
||||
|
||||
if( static_cast<BOARD_ITEM*>( item )->GetParentGroup() )
|
||||
if( board_item->GetParentGroup() )
|
||||
hasMember = true;
|
||||
}
|
||||
}
|
||||
|
||||
GroupLegalOpsField legalOps;
|
||||
|
||||
|
|
|
@ -269,7 +269,6 @@ void BOARD_COMMIT::Push( const wxString& aMessage, int aCommitFlags )
|
|||
{
|
||||
int changeType = ent.m_type & CHT_TYPE;
|
||||
int changeFlags = ent.m_type & CHT_FLAGS;
|
||||
BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( ent.m_item );
|
||||
|
||||
wxASSERT( ent.m_item );
|
||||
|
||||
|
@ -307,7 +306,10 @@ void BOARD_COMMIT::Push( const wxString& aMessage, int aCommitFlags )
|
|||
}
|
||||
}
|
||||
|
||||
if( m_isBoardEditor )
|
||||
BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( ent.m_item );
|
||||
wxCHECK2( boardItem, continue );
|
||||
|
||||
if( m_isBoardEditor && boardItem )
|
||||
{
|
||||
if( boardItem->Type() == PCB_VIA_T || boardItem->Type() == PCB_FOOTPRINT_T
|
||||
|| boardItem->IsOnLayer( F_Mask ) || boardItem->IsOnLayer( B_Mask ) )
|
||||
|
@ -519,25 +521,27 @@ void BOARD_COMMIT::Push( const wxString& aMessage, int aCommitFlags )
|
|||
|
||||
case CHT_MODIFY:
|
||||
{
|
||||
BOARD_ITEM* boardItemCopy = dynamic_cast<BOARD_ITEM*>( ent.m_copy );
|
||||
|
||||
if( !m_isFootprintEditor && !( aCommitFlags & SKIP_UNDO ) )
|
||||
{
|
||||
ITEM_PICKER itemWrapper( nullptr, boardItem, UNDO_REDO::CHANGED );
|
||||
wxASSERT( ent.m_copy );
|
||||
itemWrapper.SetLink( ent.m_copy );
|
||||
wxASSERT( boardItemCopy );
|
||||
itemWrapper.SetLink( boardItemCopy );
|
||||
undoList.PushItem( itemWrapper );
|
||||
}
|
||||
|
||||
if( !( aCommitFlags & SKIP_CONNECTIVITY ) )
|
||||
{
|
||||
if( ent.m_copy )
|
||||
connectivity->MarkItemNetAsDirty( static_cast<BOARD_ITEM*>( ent.m_copy ) );
|
||||
if( boardItemCopy )
|
||||
connectivity->MarkItemNetAsDirty( boardItemCopy );
|
||||
|
||||
connectivity->Update( boardItem );
|
||||
}
|
||||
|
||||
if( autofillZones )
|
||||
{
|
||||
dirtyIntersectingZones( static_cast<BOARD_ITEM*>( ent.m_copy ), changeType ); // before
|
||||
dirtyIntersectingZones( boardItemCopy, changeType ); // before
|
||||
dirtyIntersectingZones( boardItem, changeType ); // after
|
||||
}
|
||||
|
||||
|
@ -565,7 +569,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, int aCommitFlags )
|
|||
}
|
||||
|
||||
default:
|
||||
wxASSERT( false );
|
||||
UNIMPLEMENTED_FOR( boardItem->GetClass() );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -616,12 +620,16 @@ void BOARD_COMMIT::Push( const wxString& aMessage, int aCommitFlags )
|
|||
for( size_t i = num_changes; i < m_changes.size(); ++i )
|
||||
{
|
||||
COMMIT_LINE& ent = m_changes[i];
|
||||
BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( ent.m_item );
|
||||
BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( ent.m_item );
|
||||
BOARD_ITEM* boardItemCopy = dynamic_cast<BOARD_ITEM*>( ent.m_copy );
|
||||
|
||||
wxCHECK2( boardItem, continue );
|
||||
|
||||
if( !( aCommitFlags & SKIP_UNDO ) )
|
||||
{
|
||||
ITEM_PICKER itemWrapper( nullptr, boardItem, convert( ent.m_type & CHT_TYPE ) );
|
||||
itemWrapper.SetLink( ent.m_copy );
|
||||
wxASSERT( boardItemCopy );
|
||||
itemWrapper.SetLink( boardItemCopy );
|
||||
undoList.PushItem( itemWrapper );
|
||||
}
|
||||
else
|
||||
|
@ -686,9 +694,11 @@ EDA_ITEM* BOARD_COMMIT::parentObject( EDA_ITEM* aItem ) const
|
|||
|
||||
EDA_ITEM* BOARD_COMMIT::makeImage( EDA_ITEM* aItem ) const
|
||||
{
|
||||
BOARD_ITEM* clone = static_cast<BOARD_ITEM*>( aItem->Clone() );
|
||||
EDA_ITEM* clone = aItem->Clone();
|
||||
|
||||
if( BOARD_ITEM* board_item = dynamic_cast<BOARD_ITEM*>( clone ) )
|
||||
board_item->SetParentGroup( nullptr );
|
||||
|
||||
clone->SetParentGroup( nullptr );
|
||||
return clone;
|
||||
}
|
||||
|
||||
|
@ -709,43 +719,46 @@ void BOARD_COMMIT::Revert()
|
|||
for( auto it = m_changes.rbegin(); it != m_changes.rend(); ++it )
|
||||
{
|
||||
COMMIT_LINE& ent = *it;
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( ent.m_item );
|
||||
BOARD_ITEM* copy = static_cast<BOARD_ITEM*>( ent.m_copy );
|
||||
BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( ent.m_item );
|
||||
int changeType = ent.m_type & CHT_TYPE;
|
||||
int changeFlags = ent.m_type & CHT_FLAGS;
|
||||
|
||||
wxCHECK2( boardItem, continue );
|
||||
|
||||
switch( changeType )
|
||||
{
|
||||
case CHT_ADD:
|
||||
if( !( changeFlags & CHT_DONE ) )
|
||||
break;
|
||||
|
||||
view->Remove( item );
|
||||
connectivity->Remove( item );
|
||||
board->Remove( item, REMOVE_MODE::BULK );
|
||||
bulkRemovedItems.push_back( item );
|
||||
view->Remove( boardItem );
|
||||
connectivity->Remove( boardItem );
|
||||
board->Remove( boardItem, REMOVE_MODE::BULK );
|
||||
bulkRemovedItems.push_back( boardItem );
|
||||
break;
|
||||
|
||||
case CHT_REMOVE:
|
||||
if( !( changeFlags & CHT_DONE ) )
|
||||
break;
|
||||
|
||||
view->Add( item );
|
||||
connectivity->Add( item );
|
||||
board->Add( item, ADD_MODE::INSERT );
|
||||
bulkAddedItems.push_back( item );
|
||||
view->Add( boardItem );
|
||||
connectivity->Add( boardItem );
|
||||
board->Add( boardItem, ADD_MODE::INSERT );
|
||||
bulkAddedItems.push_back( boardItem );
|
||||
break;
|
||||
|
||||
case CHT_MODIFY:
|
||||
{
|
||||
view->Remove( item );
|
||||
connectivity->Remove( item );
|
||||
view->Remove( boardItem );
|
||||
connectivity->Remove( boardItem );
|
||||
|
||||
item->SwapItemData( copy );
|
||||
BOARD_ITEM* boardItemCopy = dynamic_cast<BOARD_ITEM*>( ent.m_copy );
|
||||
wxASSERT( boardItemCopy );
|
||||
boardItem->SwapItemData( boardItemCopy );
|
||||
|
||||
if( item->Type() == PCB_GROUP_T )
|
||||
if( boardItem->Type() == PCB_GROUP_T )
|
||||
{
|
||||
PCB_GROUP* group = static_cast<PCB_GROUP*>( item );
|
||||
PCB_GROUP* group = static_cast<PCB_GROUP*>( boardItem );
|
||||
|
||||
group->RunOnChildren( [&]( BOARD_ITEM* child )
|
||||
{
|
||||
|
@ -753,21 +766,21 @@ void BOARD_COMMIT::Revert()
|
|||
} );
|
||||
}
|
||||
|
||||
view->Add( item );
|
||||
connectivity->Add( item );
|
||||
board->OnItemChanged( item );
|
||||
itemsChanged.push_back( item );
|
||||
view->Add( boardItem );
|
||||
connectivity->Add( boardItem );
|
||||
board->OnItemChanged( boardItem );
|
||||
itemsChanged.push_back( boardItem );
|
||||
|
||||
delete copy;
|
||||
delete ent.m_copy;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
wxASSERT( false );
|
||||
UNIMPLEMENTED_FOR( boardItem->GetClass() );
|
||||
break;
|
||||
}
|
||||
|
||||
item->ClearEditFlags();
|
||||
boardItem->ClearEditFlags();
|
||||
}
|
||||
|
||||
if( bulkAddedItems.size() > 0 )
|
||||
|
|
|
@ -190,7 +190,7 @@ BOARD_ITEM* BOARD_ITEM::Duplicate() const
|
|||
if( dupe->GetParentGroup() )
|
||||
dupe->GetParentGroup()->AddItem( dupe );
|
||||
|
||||
return static_cast<BOARD_ITEM*>( dupe );
|
||||
return dupe;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -136,26 +136,16 @@ const std::vector<KICAD_T> GENERAL_COLLECTOR::DraggableItems = {
|
|||
};
|
||||
|
||||
|
||||
INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
||||
INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* aTestItem, void* aTestData )
|
||||
{
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( testItem );
|
||||
FOOTPRINT* footprint = item->GetParentFootprint();
|
||||
PCB_GROUP* group = nullptr;
|
||||
PAD* pad = nullptr;
|
||||
bool pad_through = false;
|
||||
PCB_VIA* via = nullptr;
|
||||
PCB_MARKER* marker = nullptr;
|
||||
ZONE* zone = nullptr;
|
||||
PCB_DIMENSION_BASE* dimension = nullptr;
|
||||
|
||||
#if 0 // debugging
|
||||
#if 1 // debugging
|
||||
static int breakhere = 0;
|
||||
|
||||
switch( item->Type() )
|
||||
switch( aTestItem->Type() )
|
||||
{
|
||||
case PCB_PAD_T:
|
||||
{
|
||||
FOOTPRINT* footprint = (FOOTPRINT*) item->GetParent();
|
||||
FOOTPRINT* footprint = (FOOTPRINT*) aTestItem->GetParent();
|
||||
|
||||
if( footprint->GetReference() == wxT( "Y2" ) )
|
||||
breakhere++;
|
||||
|
@ -190,7 +180,7 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
|
||||
case PCB_FOOTPRINT_T:
|
||||
{
|
||||
FOOTPRINT* footprint = (FOOTPRINT*) item;
|
||||
FOOTPRINT* footprint = (FOOTPRINT*) aTestItem;
|
||||
|
||||
if( footprint->GetReference() == wxT( "C98" ) )
|
||||
breakhere++;
|
||||
|
@ -208,7 +198,19 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
|
||||
#endif
|
||||
|
||||
switch( item->Type() )
|
||||
BOARD_ITEM* boardItem = nullptr;
|
||||
FOOTPRINT* footprint = nullptr;
|
||||
PCB_GROUP* group = nullptr;
|
||||
PAD* pad = nullptr;
|
||||
bool pad_through = false;
|
||||
PCB_VIA* via = nullptr;
|
||||
PCB_MARKER* marker = nullptr;
|
||||
ZONE* zone = nullptr;
|
||||
PCB_FIELD* field = nullptr;
|
||||
PCB_TEXT* text = nullptr;
|
||||
PCB_DIMENSION_BASE* dimension = nullptr;
|
||||
|
||||
switch( aTestItem->Type() )
|
||||
{
|
||||
case PCB_PAD_T:
|
||||
// there are pad specific visibility controls.
|
||||
|
@ -217,7 +219,8 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
// board side must be visible
|
||||
// if pad is a thru hole, then it can be visible when its parent footprint is not.
|
||||
// for through pads: pads on Front or Back board sides must be visible
|
||||
pad = static_cast<PAD*>( item );
|
||||
pad = static_cast<PAD*>( aTestItem );
|
||||
boardItem = pad;
|
||||
|
||||
if( ( pad->GetAttribute() != PAD_ATTRIB::SMD ) &&
|
||||
( pad->GetAttribute() != PAD_ATTRIB::CONN ) ) // a hole is present, so multiple layers
|
||||
|
@ -230,7 +233,8 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
break;
|
||||
|
||||
case PCB_VIA_T: // vias are on many layers, so layer test is specific
|
||||
via = static_cast<PCB_VIA*>( item );
|
||||
via = static_cast<PCB_VIA*>( aTestItem );
|
||||
boardItem = via;
|
||||
break;
|
||||
|
||||
case PCB_TRACE_T:
|
||||
|
@ -238,14 +242,17 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
if( m_Guide->IgnoreTracks() )
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
|
||||
boardItem = static_cast<PCB_TRACK*>( aTestItem );
|
||||
break;
|
||||
|
||||
case PCB_ZONE_T:
|
||||
zone = static_cast<ZONE*>( item );
|
||||
zone = static_cast<ZONE*>( aTestItem );
|
||||
boardItem = zone;
|
||||
break;
|
||||
|
||||
case PCB_TEXTBOX_T:
|
||||
case PCB_SHAPE_T:
|
||||
boardItem = static_cast<BOARD_ITEM*>( aTestItem );
|
||||
break;
|
||||
|
||||
case PCB_DIM_ALIGNED_T:
|
||||
|
@ -253,29 +260,32 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
case PCB_DIM_RADIAL_T:
|
||||
case PCB_DIM_ORTHOGONAL_T:
|
||||
case PCB_DIM_LEADER_T:
|
||||
dimension = static_cast<PCB_DIMENSION_BASE*>( item );
|
||||
dimension = static_cast<PCB_DIMENSION_BASE*>( aTestItem );
|
||||
boardItem = dimension;
|
||||
break;
|
||||
|
||||
case PCB_TARGET_T:
|
||||
boardItem = static_cast<BOARD_ITEM*>( aTestItem );
|
||||
break;
|
||||
|
||||
case PCB_FIELD_T:
|
||||
{
|
||||
PCB_FIELD* field = static_cast<PCB_FIELD*>( item );
|
||||
field = static_cast<PCB_FIELD*>( aTestItem );
|
||||
|
||||
if( field->IsReference() && m_Guide->IgnoreFPReferences() )
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
|
||||
if( field->IsValue() && m_Guide->IgnoreFPValues() )
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
|
||||
KI_FALLTHROUGH;
|
||||
|
||||
case PCB_TEXT_T:
|
||||
if( item->GetParentFootprint() )
|
||||
text = static_cast<PCB_TEXT*>( aTestItem );
|
||||
boardItem = text;
|
||||
|
||||
if( text->GetParentFootprint() )
|
||||
{
|
||||
PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
|
||||
PCB_LAYER_ID layer = item->GetLayer();
|
||||
PCB_LAYER_ID layer = text->GetLayer();
|
||||
|
||||
if( m_Guide->IgnoreHiddenFPText() )
|
||||
{
|
||||
|
@ -293,21 +303,28 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
break;
|
||||
|
||||
case PCB_FOOTPRINT_T:
|
||||
footprint = static_cast<FOOTPRINT*>( item );
|
||||
footprint = static_cast<FOOTPRINT*>( aTestItem );
|
||||
boardItem = footprint;
|
||||
break;
|
||||
|
||||
case PCB_GROUP_T:
|
||||
group = static_cast<PCB_GROUP*>( item );
|
||||
group = static_cast<PCB_GROUP*>( aTestItem );
|
||||
boardItem = group;
|
||||
break;
|
||||
|
||||
case PCB_MARKER_T:
|
||||
marker = static_cast<PCB_MARKER*>( item );
|
||||
marker = static_cast<PCB_MARKER*>( aTestItem );
|
||||
boardItem = marker;
|
||||
break;
|
||||
|
||||
default:
|
||||
boardItem = dynamic_cast<BOARD_ITEM*>( aTestItem );
|
||||
break;
|
||||
}
|
||||
|
||||
if( boardItem && !footprint )
|
||||
footprint = boardItem->GetParentFootprint();
|
||||
|
||||
// common tests:
|
||||
|
||||
if( footprint )
|
||||
|
@ -341,7 +358,7 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
{
|
||||
// Markers are not sensitive to the layer
|
||||
if( marker->HitTest( m_refPos ) )
|
||||
Append( item );
|
||||
Append( aTestItem );
|
||||
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
|
@ -350,7 +367,7 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
{
|
||||
// Groups are not sensitive to the layer ... ?
|
||||
if( group->HitTest( m_refPos ) )
|
||||
Append( item );
|
||||
Append( aTestItem );
|
||||
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
|
@ -367,8 +384,9 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
}
|
||||
}
|
||||
|
||||
if( ( item->IsOnLayer( m_Guide->GetPreferredLayer() ) )
|
||||
&& ( !item->IsLocked() || !m_Guide->IgnoreLockedItems() ) )
|
||||
if( boardItem
|
||||
&& ( boardItem->IsOnLayer( m_Guide->GetPreferredLayer() ) )
|
||||
&& ( !boardItem->IsLocked() || !m_Guide->IgnoreLockedItems() ) )
|
||||
{
|
||||
// footprints and their subcomponents: reference, value and pads are not sensitive
|
||||
// to the layer visibility controls. They all have their own separate visibility
|
||||
|
@ -382,7 +400,7 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
if( zone->HitTestForCorner( m_refPos, accuracy * 2 )
|
||||
|| zone->HitTestForEdge( m_refPos, accuracy ) )
|
||||
{
|
||||
Append( item );
|
||||
Append( aTestItem );
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
else if( !m_Guide->IgnoreZoneFills() )
|
||||
|
@ -392,32 +410,32 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
if( m_Guide->IsLayerVisible( layer )
|
||||
&& zone->HitTestFilledArea( layer, m_refPos ) )
|
||||
{
|
||||
Append( item );
|
||||
Append( aTestItem );
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( item == footprint )
|
||||
else if( aTestItem == footprint )
|
||||
{
|
||||
if( footprint->HitTest( m_refPos, accuracy )
|
||||
&& footprint->HitTestAccurate( m_refPos, accuracy ) )
|
||||
{
|
||||
Append( item );
|
||||
Append( aTestItem );
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
}
|
||||
else if( pad || via )
|
||||
{
|
||||
if( item->HitTest( m_refPos, accuracy ) )
|
||||
if( aTestItem->HitTest( m_refPos, accuracy ) )
|
||||
{
|
||||
Append( item );
|
||||
Append( aTestItem );
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PCB_LAYER_ID layer = item->GetLayer();
|
||||
PCB_LAYER_ID layer = boardItem->GetLayer();
|
||||
|
||||
if( m_Guide->IsLayerVisible( layer ) )
|
||||
{
|
||||
|
@ -428,16 +446,17 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
accuracy = KiROUND( accuracy * 1.5 );
|
||||
}
|
||||
|
||||
if( item->HitTest( m_refPos, accuracy ) )
|
||||
if( aTestItem->HitTest( m_refPos, accuracy ) )
|
||||
{
|
||||
Append( item );
|
||||
Append( aTestItem );
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( m_Guide->IncludeSecondary() && ( !item->IsLocked() || !m_Guide->IgnoreLockedItems() ) )
|
||||
if( m_Guide->IncludeSecondary()
|
||||
&& ( !boardItem || !boardItem->IsLocked() || !m_Guide->IgnoreLockedItems() ) )
|
||||
{
|
||||
// for now, "secondary" means "tolerate any visible layer". It has no effect on other
|
||||
// criteria, since there is a separate "ignore" control for those in the COLLECTORS_GUIDE
|
||||
|
@ -454,7 +473,7 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
if( zone->HitTestForCorner( m_refPos, accuracy * 2 )
|
||||
|| zone->HitTestForEdge( m_refPos, accuracy ) )
|
||||
{
|
||||
Append2nd( item );
|
||||
Append2nd( aTestItem );
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
else if( !m_Guide->IgnoreZoneFills() )
|
||||
|
@ -464,34 +483,30 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
if( m_Guide->IsLayerVisible( layer )
|
||||
&& zone->HitTestFilledArea( layer, m_refPos ) )
|
||||
{
|
||||
Append2nd( item );
|
||||
Append2nd( aTestItem );
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( item->Type() == PCB_FOOTPRINT_T )
|
||||
else if( aTestItem->Type() == PCB_FOOTPRINT_T )
|
||||
{
|
||||
if( footprint->HitTest( m_refPos, accuracy )
|
||||
&& footprint->HitTestAccurate( m_refPos, accuracy ) )
|
||||
{
|
||||
Append2nd( item );
|
||||
Append2nd( aTestItem );
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
}
|
||||
else if( pad || via )
|
||||
{
|
||||
if( item->HitTest( m_refPos, accuracy ) )
|
||||
if( aTestItem->HitTest( m_refPos, accuracy ) )
|
||||
{
|
||||
Append2nd( item );
|
||||
Append2nd( aTestItem );
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PCB_LAYER_ID layer = item->GetLayer();
|
||||
|
||||
if( m_Guide->IsLayerVisible( layer ) )
|
||||
else if( boardItem && m_Guide->IsLayerVisible( boardItem->GetLayer() ) )
|
||||
{
|
||||
if( dimension )
|
||||
{
|
||||
|
@ -500,14 +515,13 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
|||
accuracy = KiROUND( accuracy * 1.5 );
|
||||
}
|
||||
|
||||
if( item->HitTest( m_refPos, accuracy ) )
|
||||
if( aTestItem->HitTest( m_refPos, accuracy ) )
|
||||
{
|
||||
Append2nd( item );
|
||||
Append2nd( aTestItem );
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return INSPECT_RESULT::CONTINUE; // always when collecting
|
||||
}
|
||||
|
|
|
@ -209,7 +209,7 @@ protected:
|
|||
* "2nd" choice, which will be appended to the end of COLLECTOR's prime
|
||||
* "list" at the end of the search.
|
||||
*/
|
||||
std::vector<BOARD_ITEM*> m_List2nd;
|
||||
std::vector<EDA_ITEM*> m_List2nd;
|
||||
|
||||
/**
|
||||
* Determine which items are to be collected by Inspect().
|
||||
|
@ -275,7 +275,7 @@ public:
|
|||
m_List2nd.clear();
|
||||
}
|
||||
|
||||
void Append2nd( BOARD_ITEM* item )
|
||||
void Append2nd( EDA_ITEM* item )
|
||||
{
|
||||
m_List2nd.push_back( item );
|
||||
}
|
||||
|
@ -294,10 +294,10 @@ public:
|
|||
* Search and collect all the objects which match the test data.
|
||||
*
|
||||
* @param testItem An EDA_ITEM to examine.
|
||||
* @param testData is not used in this class.
|
||||
* @param aTestData is not used in this class.
|
||||
* @return SEARCH_QUIT if the Iterator is to stop the scan, else SCAN_CONTINUE
|
||||
*/
|
||||
INSPECT_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
|
||||
INSPECT_RESULT Inspect( EDA_ITEM* aTestItem, void* aTestData ) override;
|
||||
|
||||
/**
|
||||
* Scan a BOARD_ITEM using this class's Inspector method, which does the collection.
|
||||
|
|
|
@ -109,8 +109,11 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri
|
|||
|
||||
for( const EDA_ITEM* item : aSelected )
|
||||
{
|
||||
const BOARD_ITEM* boardItem = dynamic_cast<const BOARD_ITEM*>( item );
|
||||
const PCB_GROUP* group = dynamic_cast<const PCB_GROUP*>( item );
|
||||
BOARD_ITEM* clone;
|
||||
BOARD_ITEM* clone = nullptr;
|
||||
|
||||
wxCHECK2( boardItem, continue );
|
||||
|
||||
if( const PCB_FIELD* field = dynamic_cast<const PCB_FIELD*>( item ) )
|
||||
{
|
||||
|
@ -121,7 +124,7 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri
|
|||
if( group )
|
||||
clone = static_cast<BOARD_ITEM*>( group->DeepClone() );
|
||||
else
|
||||
clone = static_cast<BOARD_ITEM*>( item->Clone() );
|
||||
clone = static_cast<BOARD_ITEM*>( boardItem->Clone() );
|
||||
|
||||
// If it is only a footprint, clear the nets from the pads
|
||||
if( PAD* pad = dynamic_cast<PAD*>( clone ) )
|
||||
|
@ -198,39 +201,41 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri
|
|||
|
||||
m_formatter.Print( 0, "\n" );
|
||||
|
||||
for( EDA_ITEM* i : aSelected )
|
||||
for( EDA_ITEM* item : aSelected )
|
||||
{
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( i );
|
||||
BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item );
|
||||
BOARD_ITEM* copy = nullptr;
|
||||
|
||||
if( item->Type() == PCB_FIELD_T || item->Type() == PCB_TEXT_T )
|
||||
wxCHECK2( boardItem, continue );
|
||||
|
||||
if( boardItem->Type() == PCB_FIELD_T || boardItem->Type() == PCB_TEXT_T )
|
||||
{
|
||||
copy = static_cast<BOARD_ITEM*>( item->Clone() );
|
||||
copy = static_cast<BOARD_ITEM*>( boardItem->Clone() );
|
||||
|
||||
PCB_TEXT* textItem = static_cast<PCB_TEXT*>( copy );
|
||||
|
||||
if( textItem->GetText() == wxT( "${VALUE}" ) )
|
||||
textItem->SetText( item->GetParentFootprint()->GetValue() );
|
||||
textItem->SetText( boardItem->GetParentFootprint()->GetValue() );
|
||||
else if( textItem->GetText() == wxT( "${REFERENCE}" ) )
|
||||
textItem->SetText( item->GetParentFootprint()->GetReference() );
|
||||
textItem->SetText( boardItem->GetParentFootprint()->GetReference() );
|
||||
}
|
||||
else if( item->Type() == PCB_PAD_T )
|
||||
else if( boardItem->Type() == PCB_PAD_T )
|
||||
{
|
||||
// Create a parent to own the copied pad
|
||||
FOOTPRINT* footprint = new FOOTPRINT( m_board );
|
||||
PAD* pad = (PAD*) item->Clone();
|
||||
PAD* pad = (PAD*) boardItem->Clone();
|
||||
|
||||
footprint->SetPosition( pad->GetPosition() );
|
||||
footprint->Add( pad );
|
||||
copy = footprint;
|
||||
}
|
||||
else if( item->Type() == PCB_GROUP_T )
|
||||
else if( boardItem->Type() == PCB_GROUP_T )
|
||||
{
|
||||
copy = static_cast<PCB_GROUP*>( item )->DeepClone();
|
||||
copy = static_cast<PCB_GROUP*>( boardItem )->DeepClone();
|
||||
}
|
||||
else
|
||||
{
|
||||
copy = static_cast<BOARD_ITEM*>( item->Clone() );
|
||||
copy = static_cast<BOARD_ITEM*>( boardItem->Clone() );
|
||||
}
|
||||
|
||||
auto prepItem = [&]( BOARD_ITEM* aItem )
|
||||
|
|
|
@ -1212,9 +1212,9 @@ int BOARD_EDITOR_CONTROL::modifyLockSelected( MODIFY_MODE aMode )
|
|||
|
||||
for( EDA_ITEM* item : selection )
|
||||
{
|
||||
BOARD_ITEM* board_item = static_cast<BOARD_ITEM*>( item );
|
||||
BOARD_ITEM* board_item = dynamic_cast<BOARD_ITEM*>( item );
|
||||
|
||||
if( board_item->IsLocked() )
|
||||
if( board_item && board_item->IsLocked() )
|
||||
{
|
||||
aMode = OFF;
|
||||
break;
|
||||
|
@ -1226,7 +1226,9 @@ int BOARD_EDITOR_CONTROL::modifyLockSelected( MODIFY_MODE aMode )
|
|||
|
||||
for( EDA_ITEM* item : selection )
|
||||
{
|
||||
BOARD_ITEM* board_item = static_cast<BOARD_ITEM*>( item );
|
||||
BOARD_ITEM* board_item = dynamic_cast<BOARD_ITEM*>( item );
|
||||
|
||||
wxCHECK2( board_item, continue );
|
||||
|
||||
commit.Modify( board_item );
|
||||
|
||||
|
|
|
@ -581,8 +581,8 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent )
|
|||
return 0;
|
||||
}
|
||||
|
||||
BOARD_ITEM* a = static_cast<BOARD_ITEM*>( selection.GetItem( 0 ) );
|
||||
BOARD_ITEM* b = static_cast<BOARD_ITEM*>( selection.GetItem( 1 ) );
|
||||
BOARD_ITEM* a = dynamic_cast<BOARD_ITEM*>( selection.GetItem( 0 ) );
|
||||
BOARD_ITEM* b = dynamic_cast<BOARD_ITEM*>( selection.GetItem( 1 ) );
|
||||
|
||||
wxCHECK( a && b, 0 );
|
||||
|
||||
|
@ -1210,12 +1210,14 @@ int BOARD_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent )
|
|||
|
||||
dialog->DeleteAllPages();
|
||||
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.GetItem( 0 ) );
|
||||
BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( selection.GetItem( 0 ) );
|
||||
bool compileError = false;
|
||||
bool courtyardError = false;
|
||||
DRC_ENGINE drcEngine = makeDRCEngine( &compileError, &courtyardError );
|
||||
DRC_CONSTRAINT constraint;
|
||||
|
||||
wxCHECK( item, 0 );
|
||||
|
||||
WX_HTML_REPORT_BOX* r = nullptr;
|
||||
|
||||
if( item->Type() == PCB_TRACE_T )
|
||||
|
@ -1898,7 +1900,9 @@ void BOARD_INSPECTION_TOOL::calculateSelectionRatsnest( const VECTOR2I& aDelta )
|
|||
|
||||
for( std::size_t i = 0; i < queued_items.size(); ++i )
|
||||
{
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( queued_items[i] );
|
||||
BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( queued_items[i] );
|
||||
|
||||
wxCHECK2( item, continue );
|
||||
|
||||
if( item->Type() == PCB_FOOTPRINT_T )
|
||||
{
|
||||
|
|
|
@ -1524,7 +1524,9 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
|
|||
|
||||
for( std::unique_ptr<EDA_ITEM>& ptr : list )
|
||||
{
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( ptr.get() );
|
||||
BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( ptr.get() );
|
||||
|
||||
wxCHECK2( item, continue );
|
||||
|
||||
newItems.push_back( item );
|
||||
|
||||
|
|
|
@ -1348,14 +1348,15 @@ int EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
|
|||
else if( selection.Size() == 1 )
|
||||
{
|
||||
// Display properties dialog
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.Front() );
|
||||
|
||||
if( BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( selection.Front() ) )
|
||||
{
|
||||
// Do not handle undo buffer, it is done by the properties dialogs
|
||||
editFrame->OnEditItemRequest( item );
|
||||
|
||||
// Notify other tools of the changes
|
||||
m_toolMgr->ProcessEvent( EVENTS::SelectedItemsModified );
|
||||
}
|
||||
}
|
||||
else if( selection.Size() == 0 && getView()->IsLayerVisible( LAYER_DRAWINGSHEET ) )
|
||||
{
|
||||
DS_PROXY_VIEW_ITEM* ds = editFrame->GetCanvas()->GetDrawingSheet();
|
||||
|
@ -1380,12 +1381,13 @@ int EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
|
|||
|
||||
for( EDA_ITEM* eda_item : selCopy )
|
||||
{
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( eda_item );
|
||||
|
||||
if( BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( eda_item ) )
|
||||
{
|
||||
if( !( item->GetLayerSet() & visible ).any() )
|
||||
m_selectionTool->RemoveItemFromSel( item );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1490,7 +1492,8 @@ int EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
}
|
||||
|
||||
static_cast<BOARD_ITEM*>( item )->Rotate( refPt, rotateAngle );
|
||||
if( BOARD_ITEM* board_item = dynamic_cast<BOARD_ITEM*>( item ) )
|
||||
board_item->Rotate( refPt, rotateAngle );
|
||||
}
|
||||
|
||||
if( !localCommit.Empty() )
|
||||
|
@ -1752,28 +1755,33 @@ int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
if( m_dragging && selection.HasReferencePoint() )
|
||||
refPt = selection.GetReferencePoint();
|
||||
else
|
||||
refPt = static_cast<BOARD_ITEM*>( selection.GetItem( 0 ) )->GetPosition();
|
||||
else if( BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( selection.Front() ) )
|
||||
refPt = boardItem->GetPosition();
|
||||
}
|
||||
|
||||
bool leftRight = frame()->GetPcbNewSettings()->m_FlipLeftRight;
|
||||
|
||||
for( EDA_ITEM* item : selection )
|
||||
{
|
||||
if( !item->IsNew() && !item->IsMoving() && ( !IsFootprintEditor() || commit->Empty() ) )
|
||||
if( BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item ) )
|
||||
{
|
||||
commit->Modify( item );
|
||||
if( !boardItem->IsNew() && !boardItem->IsMoving()
|
||||
&& ( !IsFootprintEditor() || commit->Empty() ) )
|
||||
{
|
||||
commit->Modify( boardItem );
|
||||
|
||||
if( item->Type() == PCB_GROUP_T )
|
||||
if( boardItem->Type() == PCB_GROUP_T )
|
||||
{
|
||||
static_cast<PCB_GROUP*>( item )->RunOnDescendants( [&]( BOARD_ITEM* bItem )
|
||||
static_cast<PCB_GROUP*>( boardItem )->RunOnDescendants(
|
||||
[&]( BOARD_ITEM* descendant )
|
||||
{
|
||||
commit->Modify( bItem );
|
||||
commit->Modify( descendant );
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static_cast<BOARD_ITEM*>( item )->Flip( refPt, leftRight );
|
||||
boardItem->Flip( refPt, leftRight );
|
||||
}
|
||||
}
|
||||
|
||||
if( !localCommit.Empty() )
|
||||
|
@ -1807,7 +1815,10 @@ void EDIT_TOOL::DeleteItems( const PCB_SELECTION& aItems, bool aIsCut )
|
|||
|
||||
for( EDA_ITEM* item : aItems )
|
||||
{
|
||||
BOARD_ITEM* board_item = static_cast<BOARD_ITEM*>( item );
|
||||
BOARD_ITEM* board_item = dynamic_cast<BOARD_ITEM*>( item );
|
||||
|
||||
wxCHECK2( board_item, continue );
|
||||
|
||||
FOOTPRINT* parentFP = board_item->GetParentFootprint();
|
||||
PCB_GROUP* parentGroup = board_item->GetParentGroup();
|
||||
|
||||
|
@ -2090,46 +2101,47 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent )
|
|||
if( IsFootprintEditor() )
|
||||
commit.Modify( selection.Front() );
|
||||
|
||||
for( EDA_ITEM* selItem : selection )
|
||||
for( EDA_ITEM* item : selection )
|
||||
{
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selItem );
|
||||
BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item );
|
||||
|
||||
if( !item->IsNew() && !IsFootprintEditor() )
|
||||
{
|
||||
commit.Modify( item );
|
||||
wxCHECK2( boardItem, continue );
|
||||
|
||||
if( item->Type() == PCB_GROUP_T )
|
||||
if( !boardItem->IsNew() && !IsFootprintEditor() )
|
||||
{
|
||||
PCB_GROUP* group = static_cast<PCB_GROUP*>( item );
|
||||
commit.Modify( boardItem );
|
||||
|
||||
group->RunOnDescendants( [&]( BOARD_ITEM* bItem )
|
||||
if( boardItem->Type() == PCB_GROUP_T )
|
||||
{
|
||||
commit.Modify( bItem );
|
||||
PCB_GROUP* group = static_cast<PCB_GROUP*>( boardItem );
|
||||
|
||||
group->RunOnDescendants( [&]( BOARD_ITEM* descendant )
|
||||
{
|
||||
commit.Modify( descendant );
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if( !item->GetParent() || !item->GetParent()->IsSelected() )
|
||||
item->Move( translation );
|
||||
if( !boardItem->GetParent() || !boardItem->GetParent()->IsSelected() )
|
||||
boardItem->Move( translation );
|
||||
|
||||
switch( rotationAnchor )
|
||||
{
|
||||
case ROTATE_AROUND_ITEM_ANCHOR:
|
||||
item->Rotate( item->GetPosition(), angle );
|
||||
boardItem->Rotate( boardItem->GetPosition(), angle );
|
||||
break;
|
||||
case ROTATE_AROUND_SEL_CENTER:
|
||||
item->Rotate( selCenter, angle );
|
||||
case ROTATE_AROUND_SEL_CENTER: boardItem->Rotate( selCenter, angle );
|
||||
break;
|
||||
case ROTATE_AROUND_USER_ORIGIN:
|
||||
item->Rotate( frame()->GetScreen()->m_LocalOrigin, angle );
|
||||
boardItem->Rotate( frame()->GetScreen()->m_LocalOrigin, angle );
|
||||
break;
|
||||
case ROTATE_AROUND_AUX_ORIGIN:
|
||||
item->Rotate( board()->GetDesignSettings().GetAuxOrigin(), angle );
|
||||
boardItem->Rotate( board()->GetDesignSettings().GetAuxOrigin(), angle );
|
||||
break;
|
||||
}
|
||||
|
||||
if( !m_dragging )
|
||||
getView()->Update( item );
|
||||
getView()->Update( boardItem );
|
||||
}
|
||||
|
||||
commit.Push( _( "Move exact" ) );
|
||||
|
@ -2183,7 +2195,9 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
|
|||
for( EDA_ITEM* item : selection )
|
||||
{
|
||||
BOARD_ITEM* dupe_item = nullptr;
|
||||
BOARD_ITEM* orig_item = static_cast<BOARD_ITEM*>( item );
|
||||
BOARD_ITEM* orig_item = dynamic_cast<BOARD_ITEM*>( item );
|
||||
|
||||
wxCHECK2( orig_item, continue );
|
||||
|
||||
if( m_isFootprintEditor )
|
||||
{
|
||||
|
@ -2324,9 +2338,7 @@ void EDIT_TOOL::PadFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector,
|
|||
{
|
||||
for( int i = aCollector.GetCount() - 1; i >= 0; i-- )
|
||||
{
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( aCollector[i] );
|
||||
|
||||
if( item->Type() != PCB_PAD_T )
|
||||
if( aCollector[i]->Type() != PCB_PAD_T )
|
||||
aCollector.Remove( i );
|
||||
}
|
||||
}
|
||||
|
@ -2337,9 +2349,7 @@ void EDIT_TOOL::FootprintFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector,
|
|||
{
|
||||
for( int i = aCollector.GetCount() - 1; i >= 0; i-- )
|
||||
{
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( aCollector[i] );
|
||||
|
||||
if( item->Type() != PCB_FOOTPRINT_T )
|
||||
if( aCollector[i]->Type() != PCB_FOOTPRINT_T )
|
||||
aCollector.Remove( i );
|
||||
}
|
||||
}
|
||||
|
@ -2357,9 +2367,8 @@ bool EDIT_TOOL::updateModificationPoint( PCB_SELECTION& aSelection )
|
|||
// When there is only one item selected, the reference point is its position...
|
||||
if( aSelection.Size() == 1 )
|
||||
{
|
||||
auto item = static_cast<BOARD_ITEM*>( aSelection.Front() );
|
||||
auto pos = item->GetPosition();
|
||||
aSelection.SetReferencePoint( VECTOR2I( pos.x, pos.y ) );
|
||||
if( BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( aSelection.Front() ) )
|
||||
aSelection.SetReferencePoint( item->GetPosition() );
|
||||
}
|
||||
// ...otherwise modify items with regard to the grid-snapped center position
|
||||
else
|
||||
|
@ -2491,7 +2500,10 @@ int EDIT_TOOL::copyToClipboard( const TOOL_EVENT& aEvent )
|
|||
std::vector<BOARD_ITEM*> items;
|
||||
|
||||
for( EDA_ITEM* item : selection )
|
||||
items.push_back( static_cast<BOARD_ITEM*>( item ) );
|
||||
{
|
||||
if( BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item ) )
|
||||
items.push_back( boardItem );
|
||||
}
|
||||
|
||||
VECTOR2I refPoint;
|
||||
|
||||
|
|
|
@ -95,9 +95,9 @@ int EDIT_TOOL::Swap( const TOOL_EVENT& aEvent )
|
|||
if( item->Type() == PCB_GROUP_T )
|
||||
{
|
||||
PCB_GROUP* group = static_cast<PCB_GROUP*>( item );
|
||||
group->RunOnDescendants( [&]( BOARD_ITEM* bItem )
|
||||
group->RunOnDescendants( [&]( BOARD_ITEM* descendant )
|
||||
{
|
||||
commit->Modify( bItem );
|
||||
commit->Modify( descendant );
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -105,8 +105,10 @@ int EDIT_TOOL::Swap( const TOOL_EVENT& aEvent )
|
|||
|
||||
for( size_t i = 0; i < sorted.size() - 1; i++ )
|
||||
{
|
||||
BOARD_ITEM* a = static_cast<BOARD_ITEM*>( sorted[i] );
|
||||
BOARD_ITEM* b = static_cast<BOARD_ITEM*>( sorted[( i + 1 ) % sorted.size()] );
|
||||
BOARD_ITEM* a = dynamic_cast<BOARD_ITEM*>( sorted[i] );
|
||||
BOARD_ITEM* b = dynamic_cast<BOARD_ITEM*>( sorted[( i + 1 ) % sorted.size()] );
|
||||
|
||||
wxCHECK2( a && b, continue );
|
||||
|
||||
// Swap X,Y position
|
||||
VECTOR2I aPos = a->GetPosition(), bPos = b->GetPosition();
|
||||
|
@ -404,7 +406,10 @@ bool EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit
|
|||
orig_items.clear();
|
||||
|
||||
for( EDA_ITEM* item : selection.GetItemsSortedBySelectionOrder() )
|
||||
orig_items.push_back( static_cast<BOARD_ITEM*>( item ) );
|
||||
{
|
||||
if( BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item ) )
|
||||
orig_items.push_back( boardItem );
|
||||
}
|
||||
|
||||
updateStatusPopup( orig_items[ itemIdx ], itemIdx + 1, orig_items.size() );
|
||||
statusPopup.Popup();
|
||||
|
|
|
@ -91,7 +91,9 @@ std::vector<std::pair<BOARD_ITEM*, BOX2I>> GetBoundingBoxes( const T& aItems )
|
|||
|
||||
for( EDA_ITEM* item : aItems )
|
||||
{
|
||||
BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( item );
|
||||
BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item );
|
||||
|
||||
wxCHECK2( boardItem, continue );
|
||||
|
||||
if( item->Type() == PCB_FOOTPRINT_T )
|
||||
{
|
||||
|
@ -163,7 +165,9 @@ size_t ALIGN_DISTRIBUTE_TOOL::GetSelections( std::vector<std::pair<BOARD_ITEM*,
|
|||
|
||||
for( EDA_ITEM* item : selection )
|
||||
{
|
||||
BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( item );
|
||||
BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item );
|
||||
|
||||
wxCHECK2( boardItem, continue );
|
||||
|
||||
// We do not lock items in the footprint editor
|
||||
if( boardItem->IsLocked() && m_frame->IsType( FRAME_PCB_EDITOR ) )
|
||||
|
|
|
@ -126,28 +126,31 @@ int POSITION_RELATIVE_TOOL::RelativeItemSelectionMove( const VECTOR2I& aPosAncho
|
|||
VECTOR2I aggregateTranslation = aPosAnchor + aTranslation - GetSelectionAnchorPosition();
|
||||
|
||||
for( EDA_ITEM* item : m_selection )
|
||||
{
|
||||
if( BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item ) )
|
||||
{
|
||||
// Don't move a pad by itself unless editing the footprint
|
||||
if( item->Type() == PCB_PAD_T
|
||||
if( boardItem->Type() == PCB_PAD_T
|
||||
&& !frame()->GetPcbNewSettings()->m_AllowFreePads
|
||||
&& frame()->IsType( FRAME_PCB_EDITOR ) )
|
||||
{
|
||||
item = item->GetParent();
|
||||
boardItem = boardItem->GetParent();
|
||||
}
|
||||
|
||||
m_commit->Modify( item );
|
||||
m_commit->Modify( boardItem );
|
||||
|
||||
// If moving a group, record position of all the descendants for undo
|
||||
if( item->Type() == PCB_GROUP_T )
|
||||
if( boardItem->Type() == PCB_GROUP_T )
|
||||
{
|
||||
PCB_GROUP* group = static_cast<PCB_GROUP*>( item );
|
||||
group->RunOnDescendants( [&]( BOARD_ITEM* bItem )
|
||||
PCB_GROUP* group = static_cast<PCB_GROUP*>( boardItem );
|
||||
group->RunOnDescendants( [&]( BOARD_ITEM* descendant )
|
||||
{
|
||||
m_commit->Modify( bItem );
|
||||
m_commit->Modify( descendant );
|
||||
});
|
||||
}
|
||||
|
||||
static_cast<BOARD_ITEM*>( item )->Move( aggregateTranslation );
|
||||
boardItem->Move( aggregateTranslation );
|
||||
}
|
||||
}
|
||||
|
||||
m_commit->Push( _( "Position Relative" ) );
|
||||
|
|
|
@ -112,39 +112,37 @@ static bool TestForExistingItem( BOARD* aPcb, BOARD_ITEM* aItem )
|
|||
{
|
||||
for( PCB_TRACK* item : aPcb->Tracks() )
|
||||
{
|
||||
if( aItem == static_cast<BOARD_ITEM*>( item ) )
|
||||
if( aItem == item)
|
||||
return true;
|
||||
}
|
||||
|
||||
for( FOOTPRINT* item : aPcb->Footprints() )
|
||||
{
|
||||
if( aItem == static_cast<BOARD_ITEM*>( item ) )
|
||||
if( aItem == item )
|
||||
return true;
|
||||
}
|
||||
|
||||
for( BOARD_ITEM* item : aPcb->Drawings() )
|
||||
{
|
||||
if( aItem == static_cast<BOARD_ITEM*>( item ) )
|
||||
if( aItem == item )
|
||||
return true;
|
||||
}
|
||||
|
||||
for( ZONE* item : aPcb->Zones() )
|
||||
{
|
||||
if( aItem == static_cast<BOARD_ITEM*>( item ) )
|
||||
if( aItem == item )
|
||||
return true;
|
||||
}
|
||||
|
||||
NETINFO_LIST& netInfo = aPcb->GetNetInfo();
|
||||
|
||||
for( NETINFO_LIST::iterator i = netInfo.begin(); i != netInfo.end(); ++i )
|
||||
for( const NETINFO_ITEM* item : aPcb->GetNetInfo() )
|
||||
{
|
||||
if( aItem == static_cast<BOARD_ITEM*>( *i ) )
|
||||
if( aItem == item )
|
||||
return true;
|
||||
}
|
||||
|
||||
for( PCB_GROUP* item : aPcb->Groups() )
|
||||
{
|
||||
if( aItem == static_cast<BOARD_ITEM*>( item ) )
|
||||
if( aItem == item )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -536,14 +534,20 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
|
|||
|
||||
case UNDO_REDO::REGROUP:
|
||||
aList->SetPickedItemStatus( UNDO_REDO::UNGROUP, ii );
|
||||
static_cast<BOARD_ITEM*>( eda_item )->SetParentGroup( nullptr );
|
||||
|
||||
if( BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( eda_item ) )
|
||||
boardItem->SetParentGroup( nullptr );
|
||||
|
||||
break;
|
||||
|
||||
case UNDO_REDO::UNGROUP:
|
||||
aList->SetPickedItemStatus( UNDO_REDO::REGROUP, ii );
|
||||
|
||||
if( BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( eda_item ) )
|
||||
{
|
||||
if( group )
|
||||
group->AddItem( static_cast<BOARD_ITEM*>( eda_item ) );
|
||||
group->AddItem( boardItem );
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
@ -626,9 +630,12 @@ void PCB_BASE_EDIT_FRAME::ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aIt
|
|||
|
||||
void PCB_BASE_EDIT_FRAME::ClearListAndDeleteItems( PICKED_ITEMS_LIST* aList )
|
||||
{
|
||||
aList->ClearListAndDeleteItems( []( EDA_ITEM* item )
|
||||
aList->ClearListAndDeleteItems(
|
||||
[]( EDA_ITEM* item )
|
||||
{
|
||||
static_cast<BOARD_ITEM*>( item )->SetParentGroup( nullptr );
|
||||
if( BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item ) )
|
||||
boardItem->SetParentGroup( nullptr );
|
||||
|
||||
delete item;
|
||||
} );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue