kicad/gerbview/tools/gerbview_selection.cpp

66 lines
1.6 KiB
C++
Raw Normal View History

/*
* 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
* 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/>.
*/
#include <eda_item.h>
#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 )
{
centre = Front()->GetPosition();
}
else
{
2022-08-31 09:15:42 +00:00
BOX2I bbox;
2022-08-31 09:15:42 +00:00
for( EDA_ITEM* item : m_items )
bbox.Merge( item->GetBoundingBox() );
centre = bbox.Centre();
}
return centre;
}
const BOX2I GERBVIEW_SELECTION::ViewBBox() const
{
2022-08-31 09:15:42 +00:00
BOX2I bbox;
if( Size() == 1 )
{
2022-08-31 09:15:42 +00:00
bbox = Front()->GetBoundingBox();
}
else if( Size() > 1 )
{
2022-08-31 09:15:42 +00:00
for( EDA_ITEM* item : m_items )
bbox.Merge( item->GetBoundingBox() );
}
2022-08-31 09:15:42 +00:00
return bbox;
}