KiCad PCB EDA Suite
Loading...
Searching...
No Matches
gbr_layout.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) 2012-2018 Jean-Pierre Charras jp.charras at wanadoo.fr
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <gerbview_frame.h>
22#include <gbr_layout.h>
23#include <gerber_file_image.h>
25
30
31
35
36// Accessor to the list of Gerber files (and drill files) images
41
42
44{
45 BOX2I bbox; // Start with a fresh BOX2I so the Merge algorithm works
46
47 for( unsigned layer = 0; layer < GetImagesList()->ImagesMaxCount(); ++layer )
48 {
49 GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( layer );
50
51 if( gerber == nullptr ) // Graphic layer not yet used
52 continue;
53
54 for( GERBER_DRAW_ITEM* item : gerber->GetItems() )
55 bbox.Merge( item->GetBoundingBox() );
56 }
57
58 bbox.Normalize();
59
60 m_BoundingBox = bbox;
61 return bbox;
62}
63
64
65INSPECT_RESULT GBR_LAYOUT::Visit( INSPECTOR inspector, void* testData,
66 const std::vector<KICAD_T>& aScanTypes )
67{
68#if 0 && defined(DEBUG)
69 std::cout << GetClass().mb_str() << ' ';
70#endif
71
72 for( KICAD_T scanType : aScanTypes )
73 {
74 if( scanType == GERBER_LAYOUT_T )
75 {
76 for( unsigned layer = 0; layer < GetImagesList()->ImagesMaxCount(); ++layer )
77 {
78 GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( layer );
79
80 if( gerber == nullptr ) // Graphic layer not yet used
81 continue;
82
83 if( gerber->Visit( inspector, testData, aScanTypes ) == INSPECT_RESULT::QUIT )
85 }
86 }
87 }
88
90}
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition box2.h:142
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition box2.h:654
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:37
BOX2I ComputeBoundingBox() const
Calculate the bounding box containing all Gerber items.
GERBER_FILE_IMAGE_LIST * GetImagesList() const
BOX2I m_BoundingBox
Definition gbr_layout.h:85
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
wxString GetClass() const override
Return the class name.
Definition gbr_layout.h:47
GERBER_FILE_IMAGE_LIST is a helper class to handle a list of GERBER_FILE_IMAGE files which are loaded...
static GERBER_FILE_IMAGE_LIST & GetImagesList()
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
Hold the image data and parameters for one gerber file and layer parameters.
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
GERBER_DRAW_ITEMS & GetItems()
INSPECT_RESULT
Definition eda_item.h:42
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition eda_item.h:89
Class CLASS_GBR_LAYOUT to handle info to draw loaded Gerber images and page frame reference.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:71
@ GERBER_LAYOUT_T
Definition typeinfo.h:206