KiCad PCB EDA Suite
Loading...
Searching...
No Matches
gerbview_selection.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2019 CERN
5 * Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <eda_item.h>
22#include <view/view_group.h>
23#include <gerber_draw_item.h>
25
27{
28 VECTOR2I centre;
29
30 if( Size() == 1 )
31 {
32 centre = Front()->GetPosition();
33 }
34 else
35 {
36 BOX2I bbox;
37
38 for( EDA_ITEM* item : m_items )
39 bbox.Merge( item->GetBoundingBox() );
40
41 centre = bbox.Centre();
42 }
43
44 return centre;
45}
46
47
49{
50 BOX2I bbox;
51
52 if( Size() == 1 )
53 {
54 bbox = Front()->GetBoundingBox();
55 }
56 else if( Size() > 1 )
57 {
58 for( EDA_ITEM* item : m_items )
59 bbox.Merge( item->GetBoundingBox() );
60 }
61
62 return bbox;
63}
64
65
Vec Centre() const
Definition: box2.h:71
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: box2.h:589
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:239
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition: eda_item.cpp:74
VECTOR2I GetCenter() const override
Returns the center point of the selection area bounding box.
const BOX2I ViewBBox() const override
Return the bounding box for all stored items covering all its layers.
std::deque< EDA_ITEM * > m_items
Definition: selection.h:271
EDA_ITEM * Front() const
Definition: selection.h:208
int Size() const
Returns the number of selected parts.
Definition: selection.h:115