Selection center is center of visible items.
Fixes https://gitlab.com/kicad/code/kicad/issues/6188
This commit is contained in:
parent
a551a500bb
commit
de013ee60a
|
@ -23,8 +23,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <tools/ee_selection.h>
|
#include <tools/ee_selection.h>
|
||||||
|
|
||||||
#include <sch_item.h>
|
#include <sch_item.h>
|
||||||
|
#include <sch_component.h>
|
||||||
|
#include <sch_sheet.h>
|
||||||
|
|
||||||
|
|
||||||
EE_SELECTION::EE_SELECTION( SCH_SCREEN* aScreen ) :
|
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
|
bool EE_SELECTION::AllItemsHaveLineStroke() const
|
||||||
{
|
{
|
||||||
for( const EDA_ITEM* item : m_items )
|
for( const EDA_ITEM* item : m_items )
|
||||||
|
|
|
@ -43,6 +43,8 @@ public:
|
||||||
|
|
||||||
EDA_ITEM* GetTopLeftItem( bool onlyModules = false ) const override;
|
EDA_ITEM* GetTopLeftItem( bool onlyModules = false ) const override;
|
||||||
|
|
||||||
|
EDA_RECT GetBoundingBox() const override;
|
||||||
|
|
||||||
void SetScreen( SCH_SCREEN* aScreen ) { m_screen = aScreen; }
|
void SetScreen( SCH_SCREEN* aScreen ) { m_screen = aScreen; }
|
||||||
SCH_SCREEN* GetScreen() { return m_screen; }
|
SCH_SCREEN* GetScreen() { return m_screen; }
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
#include <eda_item.h>
|
#include <eda_item.h>
|
||||||
#include <view/view_group.h>
|
#include <view/view_group.h>
|
||||||
|
|
||||||
|
|
||||||
class SELECTION : public KIGFX::VIEW_GROUP
|
class SELECTION : public KIGFX::VIEW_GROUP
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -153,17 +152,12 @@ public:
|
||||||
return static_cast<VECTOR2I>( GetBoundingBox().GetPosition() );
|
return static_cast<VECTOR2I>( GetBoundingBox().GetPosition() );
|
||||||
}
|
}
|
||||||
|
|
||||||
EDA_RECT GetBoundingBox() const
|
virtual EDA_RECT GetBoundingBox() const
|
||||||
{
|
{
|
||||||
EDA_RECT bbox;
|
EDA_RECT bbox;
|
||||||
|
|
||||||
if( Front() )
|
for( EDA_ITEM* item : m_items )
|
||||||
{
|
bbox.Merge( item->GetBoundingBox() );
|
||||||
bbox = Front()->GetBoundingBox();
|
|
||||||
|
|
||||||
for( auto i = m_items.begin() + 1; i != m_items.end(); ++i )
|
|
||||||
bbox.Merge( (*i)->GetBoundingBox() );
|
|
||||||
}
|
|
||||||
|
|
||||||
return bbox;
|
return bbox;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue