Selection center is center of visible items.

Fixes https://gitlab.com/kicad/code/kicad/issues/6188
This commit is contained in:
Jeff Young 2020-10-30 20:30:23 +00:00
parent a551a500bb
commit de013ee60a
3 changed files with 25 additions and 10 deletions

View File

@ -23,8 +23,9 @@
*/
#include <tools/ee_selection.h>
#include <sch_item.h>
#include <sch_component.h>
#include <sch_sheet.h>
EE_SELECTION::EE_SELECTION( SCH_SCREEN* aScreen ) :
@ -58,6 +59,24 @@ EDA_ITEM* EE_SELECTION::GetTopLeftItem( bool onlyModules ) const
}
EDA_RECT EE_SELECTION::GetBoundingBox() const
{
EDA_RECT bbox;
for( EDA_ITEM* item : m_items )
{
if( item->Type() == SCH_COMPONENT_T )
bbox.Merge( static_cast<SCH_COMPONENT*>( item )->GetBoundingBox( false ) );
else if( item->Type() == SCH_SHEET_T )
bbox.Merge( static_cast<SCH_SHEET*>( item )->GetBodyBoundingBox() );
else
bbox.Merge( item->GetBoundingBox() );
}
return bbox;
}
bool EE_SELECTION::AllItemsHaveLineStroke() const
{
for( const EDA_ITEM* item : m_items )

View File

@ -43,6 +43,8 @@ public:
EDA_ITEM* GetTopLeftItem( bool onlyModules = false ) const override;
EDA_RECT GetBoundingBox() const override;
void SetScreen( SCH_SCREEN* aScreen ) { m_screen = aScreen; }
SCH_SCREEN* GetScreen() { return m_screen; }

View File

@ -33,7 +33,6 @@
#include <eda_item.h>
#include <view/view_group.h>
class SELECTION : public KIGFX::VIEW_GROUP
{
public:
@ -153,17 +152,12 @@ public:
return static_cast<VECTOR2I>( GetBoundingBox().GetPosition() );
}
EDA_RECT GetBoundingBox() const
virtual EDA_RECT GetBoundingBox() const
{
EDA_RECT bbox;
if( Front() )
{
bbox = Front()->GetBoundingBox();
for( auto i = m_items.begin() + 1; i != m_items.end(); ++i )
bbox.Merge( (*i)->GetBoundingBox() );
}
for( EDA_ITEM* item : m_items )
bbox.Merge( item->GetBoundingBox() );
return bbox;
}