Browse Source

Selection center is center of visible items.

Fixes https://gitlab.com/kicad/code/kicad/issues/6188
6.0.7
Jeff Young 5 years ago
parent
commit
de013ee60a
  1. 21
      eeschema/tools/ee_selection.cpp
  2. 2
      eeschema/tools/ee_selection.h
  3. 12
      include/tool/selection.h

21
eeschema/tools/ee_selection.cpp

@ -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 )

2
eeschema/tools/ee_selection.h

@ -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; }

12
include/tool/selection.h

@ -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;
}

Loading…
Cancel
Save