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 (C) 1992-2022 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, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <gerbview_frame.h>
26#include <gbr_layout.h>
27#include <gerber_file_image.h>
29
31 EDA_ITEM( nullptr, GERBER_LAYOUT_T )
32{
33}
34
35
37{
38}
39
40// Accessor to the list of Gerber files (and drill files) images
42{
44}
45
46
48{
49 BOX2I bbox; // Start with a fresh BOX2I so the Merge algorithm works
50
51 for( unsigned layer = 0; layer < GetImagesList()->ImagesMaxCount(); ++layer )
52 {
53 GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( layer );
54
55 if( gerber == nullptr ) // Graphic layer not yet used
56 continue;
57
58 for( GERBER_DRAW_ITEM* item : gerber->GetItems() )
59 bbox.Merge( item->GetBoundingBox() );
60 }
61
62 bbox.Normalize();
63
64 m_BoundingBox = bbox;
65 return bbox;
66}
67
68
69INSPECT_RESULT GBR_LAYOUT::Visit( INSPECTOR inspector, void* testData,
70 const std::vector<KICAD_T>& aScanTypes )
71{
72#if 0 && defined(DEBUG)
73 std::cout << GetClass().mb_str() << ' ';
74#endif
75
76 for( KICAD_T scanType : aScanTypes )
77 {
78 if( scanType == GERBER_LAYOUT_T )
79 {
80 for( unsigned layer = 0; layer < GetImagesList()->ImagesMaxCount(); ++layer )
81 {
82 GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( layer );
83
84 if( gerber == nullptr ) // Graphic layer not yet used
85 continue;
86
87 if( gerber->Visit( inspector, testData, aScanTypes ) == INSPECT_RESULT::QUIT )
88 return INSPECT_RESULT::QUIT;
89 }
90 }
91 }
92
93 return INSPECT_RESULT::CONTINUE;
94}
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:136
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: box2.h:623
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:88
BOX2I ComputeBoundingBox() const
Calculate the bounding box containing all Gerber items.
Definition: gbr_layout.cpp:47
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Definition: gbr_layout.cpp:41
BOX2I m_BoundingBox
Definition: gbr_layout.h:89
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...
Definition: gbr_layout.cpp:69
wxString GetClass() const override
Return the class name.
Definition: gbr_layout.h:51
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:43
const INSPECTOR_FUNC & INSPECTOR
Definition: eda_item.h:81
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:78
@ GERBER_LAYOUT_T
Definition: typeinfo.h:207