pcbnew: Clean up group move
SetPosition() only changes the base position of tracks, we need to use Move() to move the whole element. This also cleans up white space and group handling in ratsnest Fixes https://gitlab.com/kicad/code/kicad/issues/5188
This commit is contained in:
parent
275e810573
commit
a0c54951db
|
@ -37,26 +37,27 @@ bool PCB_GROUP::AddItem( BOARD_ITEM* item )
|
|||
return m_items.insert( item ).second;
|
||||
}
|
||||
|
||||
|
||||
bool PCB_GROUP::RemoveItem( const BOARD_ITEM* item )
|
||||
{
|
||||
return m_items.erase( const_cast<BOARD_ITEM*>( item ) ) == 1;
|
||||
}
|
||||
|
||||
|
||||
wxPoint PCB_GROUP::GetPosition() const
|
||||
{
|
||||
return GetBoundingBox().Centre();
|
||||
}
|
||||
|
||||
|
||||
void PCB_GROUP::SetPosition( const wxPoint& newpos )
|
||||
{
|
||||
wxPoint delta = newpos - GetPosition();
|
||||
|
||||
for( auto member : m_items )
|
||||
{
|
||||
member->SetPosition( member->GetPosition() + delta );
|
||||
}
|
||||
Move( delta );
|
||||
}
|
||||
|
||||
|
||||
EDA_ITEM* PCB_GROUP::Clone() const
|
||||
{
|
||||
// Use copy constructor to get the same uuid and other fields
|
||||
|
@ -64,6 +65,7 @@ EDA_ITEM* PCB_GROUP::Clone() const
|
|||
return newGroup;
|
||||
}
|
||||
|
||||
|
||||
PCB_GROUP* PCB_GROUP::DeepClone() const
|
||||
{
|
||||
// Use copy constructor to get the same uuid and other fields
|
||||
|
@ -114,19 +116,6 @@ void PCB_GROUP::SwapData( BOARD_ITEM* aImage )
|
|||
std::swap( *( (PCB_GROUP*) this ), *( (PCB_GROUP*) aImage ) );
|
||||
}
|
||||
|
||||
#if 0
|
||||
void PCB_GROUP::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
|
||||
PCB_LAYER_ID aLayer, int aClearanceValue,
|
||||
int aError = ARC_LOW_DEF,
|
||||
bool ignoreLineWidth = false ) const
|
||||
{
|
||||
}
|
||||
const BOX2I PCB_GROUP::ViewBBox() const
|
||||
{
|
||||
return GetBoundingBox();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool PCB_GROUP::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
||||
{
|
||||
|
@ -134,6 +123,7 @@ bool PCB_GROUP::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
|||
return rect.Inflate( aAccuracy ).Contains( aPosition );
|
||||
}
|
||||
|
||||
|
||||
bool PCB_GROUP::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
|
||||
{
|
||||
EDA_RECT arect = aRect;
|
||||
|
@ -160,6 +150,7 @@ bool PCB_GROUP::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
const EDA_RECT PCB_GROUP::GetBoundingBox() const
|
||||
{
|
||||
EDA_RECT area;
|
||||
|
@ -182,6 +173,7 @@ const EDA_RECT PCB_GROUP::GetBoundingBox() const
|
|||
return area;
|
||||
}
|
||||
|
||||
|
||||
SEARCH_RESULT PCB_GROUP::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
|
||||
{
|
||||
for( const KICAD_T* stype = scanTypes; *stype != EOT; ++stype )
|
||||
|
@ -197,6 +189,7 @@ SEARCH_RESULT PCB_GROUP::Visit( INSPECTOR inspector, void* testData, const KICAD
|
|||
return SEARCH_RESULT::CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
LSET PCB_GROUP::GetLayerSet() const
|
||||
{
|
||||
LSET aSet;
|
||||
|
@ -208,6 +201,7 @@ LSET PCB_GROUP::GetLayerSet() const
|
|||
return aSet;
|
||||
}
|
||||
|
||||
|
||||
void PCB_GROUP::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
{
|
||||
// What layer to put bounding box on? change in class_pcb_group.cpp
|
||||
|
@ -229,6 +223,7 @@ void PCB_GROUP::ViewGetLayers( int aLayers[], int& aCount ) const
|
|||
aLayers[i++] = layer;
|
||||
}
|
||||
|
||||
|
||||
unsigned int PCB_GROUP::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
|
||||
{
|
||||
if( aView->IsLayerVisible( LAYER_ANCHOR ) )
|
||||
|
@ -237,12 +232,16 @@ unsigned int PCB_GROUP::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
|
|||
return std::numeric_limits<unsigned int>::max();
|
||||
}
|
||||
|
||||
|
||||
void PCB_GROUP::Move( const wxPoint& aMoveVector )
|
||||
{
|
||||
wxPoint newpos = GetPosition() + aMoveVector;
|
||||
SetPosition( newpos );
|
||||
for( auto member : m_items )
|
||||
{
|
||||
member->Move( aMoveVector );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PCB_GROUP::Rotate( const wxPoint& aRotCentre, double aAngle )
|
||||
{
|
||||
for( BOARD_ITEM* item : m_items )
|
||||
|
@ -251,6 +250,7 @@ void PCB_GROUP::Rotate( const wxPoint& aRotCentre, double aAngle )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void PCB_GROUP::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
|
||||
{
|
||||
for( BOARD_ITEM* item : m_items )
|
||||
|
@ -259,6 +259,7 @@ void PCB_GROUP::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
wxString PCB_GROUP::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||
{
|
||||
if( m_name.empty() )
|
||||
|
@ -268,11 +269,13 @@ wxString PCB_GROUP::GetSelectMenuText( EDA_UNITS aUnits ) const
|
|||
return wxString::Format( _( "Group \"%s\" with %ld members" ), m_name, m_items.size() );
|
||||
}
|
||||
|
||||
|
||||
BITMAP_DEF PCB_GROUP::GetMenuImage() const
|
||||
{
|
||||
return module_xpm;
|
||||
}
|
||||
|
||||
|
||||
void PCB_GROUP::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
|
||||
{
|
||||
aList.emplace_back( _( "Group" ), m_name.empty() ? _( "Anonymous" ) :
|
||||
|
@ -280,6 +283,7 @@ void PCB_GROUP::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I
|
|||
aList.emplace_back( _( "Members" ), wxString::Format( _( "%ld" ), m_items.size() ), BROWN );
|
||||
}
|
||||
|
||||
|
||||
void PCB_GROUP::RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction )
|
||||
{
|
||||
try
|
||||
|
@ -293,6 +297,7 @@ void PCB_GROUP::RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFuncti
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void PCB_GROUP::RunOnDescendants( const std::function<void( BOARD_ITEM* )>& aFunction )
|
||||
{
|
||||
try
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
*/
|
||||
|
||||
#include <bitmaps.h>
|
||||
#include <class_pcb_group.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/selection_tool.h>
|
||||
#include <tools/pcbnew_picker_tool.h>
|
||||
|
@ -462,9 +463,12 @@ void PCB_INSPECTION_TOOL::calculateSelectionRatsnest( const VECTOR2I& aDelta )
|
|||
SELECTION& selection = selectionTool->GetSelection();
|
||||
std::shared_ptr<CONNECTIVITY_DATA> connectivity = board()->GetConnectivity();
|
||||
std::vector<BOARD_ITEM*> items;
|
||||
std::deque<EDA_ITEM*> queued_items( selection.begin(), selection.end() );
|
||||
|
||||
for( EDA_ITEM* item : selection )
|
||||
for( std::size_t i = 0; i < queued_items.size(); ++i )
|
||||
{
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( queued_items[i] );
|
||||
|
||||
if( item->Type() == PCB_MODULE_T )
|
||||
{
|
||||
for( auto pad : static_cast<MODULE*>( item )->Pads() )
|
||||
|
@ -473,6 +477,12 @@ void PCB_INSPECTION_TOOL::calculateSelectionRatsnest( const VECTOR2I& aDelta )
|
|||
items.push_back( pad );
|
||||
}
|
||||
}
|
||||
else if( item->Type() == PCB_GROUP_T )
|
||||
{
|
||||
PCB_GROUP *group = static_cast<PCB_GROUP*>( item );
|
||||
group->RunOnDescendants( [ &queued_items ]( BOARD_ITEM *aItem )
|
||||
{ queued_items.push_back( aItem );} );
|
||||
}
|
||||
else if( BOARD_CONNECTED_ITEM* boardItem = dyn_cast<BOARD_CONNECTED_ITEM*>( item ) )
|
||||
{
|
||||
if( boardItem->GetLocalRatsnestVisible() || displayOptions().m_ShowModuleRatsnest )
|
||||
|
|
Loading…
Reference in New Issue