2019-06-08 21:48:22 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2019-08-14 08:28:07 +00:00
|
|
|
* Copyright (C) 2019 CERN
|
2019-06-08 21:48:22 +00:00
|
|
|
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-10-14 01:06:53 +00:00
|
|
|
#include <eda_item.h>
|
2019-06-08 21:48:22 +00:00
|
|
|
#include <view/view_group.h>
|
|
|
|
#include <gerber_draw_item.h>
|
|
|
|
#include <tools/gerbview_selection.h>
|
|
|
|
|
|
|
|
VECTOR2I GERBVIEW_SELECTION::GetCenter() const
|
|
|
|
{
|
|
|
|
VECTOR2I centre;
|
|
|
|
|
|
|
|
if( Size() == 1 )
|
|
|
|
{
|
2020-04-24 13:36:10 +00:00
|
|
|
centre = Front()->GetPosition();
|
2019-06-08 21:48:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-08-31 09:15:42 +00:00
|
|
|
BOX2I bbox;
|
2019-06-08 21:48:22 +00:00
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
for( EDA_ITEM* item : m_items )
|
|
|
|
bbox.Merge( item->GetBoundingBox() );
|
2019-06-08 21:48:22 +00:00
|
|
|
|
|
|
|
centre = bbox.Centre();
|
|
|
|
}
|
|
|
|
|
|
|
|
return centre;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const BOX2I GERBVIEW_SELECTION::ViewBBox() const
|
|
|
|
{
|
2022-08-31 09:15:42 +00:00
|
|
|
BOX2I bbox;
|
2019-06-08 21:48:22 +00:00
|
|
|
|
|
|
|
if( Size() == 1 )
|
|
|
|
{
|
2022-08-31 09:15:42 +00:00
|
|
|
bbox = Front()->GetBoundingBox();
|
2019-06-08 21:48:22 +00:00
|
|
|
}
|
|
|
|
else if( Size() > 1 )
|
|
|
|
{
|
2022-08-31 09:15:42 +00:00
|
|
|
for( EDA_ITEM* item : m_items )
|
|
|
|
bbox.Merge( item->GetBoundingBox() );
|
2019-06-08 21:48:22 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
return bbox;
|
2019-06-08 21:48:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|