KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_board_outline.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) 2023 Ethan Chien <[email protected]>
5 * Copyright (C) 2023 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 "pcb_board_outline.h"
26#include <eda_item_flags.h>
27#include <eda_item.h>
28#include <layer_ids.h>
29#include <memory>
31
33{
34 aCopyTo.m_outlines = aCopyFrom.m_outlines;
35 aCopyTo.m_parent = aCopyFrom.m_parent;
36}
37
38
41{
43}
44
46 PCB_BOARD_OUTLINE( aOther.GetParent() )
47{
48 CopyPros( aOther, *this );
49}
50
52{
53 CopyPros( aOther, *this );
54 return *this;
55}
56
58{
59}
60
61
62std::vector<int> PCB_BOARD_OUTLINE::ViewGetLayers() const
63{
64 std::vector<int> layers { LAYER_BOARD_OUTLINE_AREA };
65 return layers;
66}
67
68
70{
71 return m_outlines.BBox();
72}
73
74
76{
77 return UNDEFINED_LAYER;
78}
79
80
82{
83 return {};
84}
85
87{
88 WXUNUSED( aLayer )
89 return {};
90}
91
92double PCB_BOARD_OUTLINE::Similarity( const BOARD_ITEM& aItem ) const
93{
94 if( aItem.Type() == KICAD_T::PCB_BOARD_OUTLINE_T )
95 {
96 if( m_parent == aItem.GetParent() )
97 return 1.0;
98
99 return 0.5;
100 }
101
102 return 0.0;
103}
104
106{
107 if( const PCB_BOARD_OUTLINE* outline = dynamic_cast<const PCB_BOARD_OUTLINE*>( &aItem ) )
108 {
109 return outline->m_parent == m_parent;
110 }
111
112 return {};
113}
114
116{
117 return new PCB_BOARD_OUTLINE( *this );
118}
119
121{
122 return "PCB_BOARD_OUTLINE";
123}
124
125
126#if defined( DEBUG )
127
128void PCB_BOARD_OUTLINE::Show( int nestLevel, std::ostream& os ) const
129{
130 NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n";
131}
132
133#endif
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:79
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:210
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:97
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:141
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:109
EDA_ITEM * m_parent
Owner.
Definition: eda_item.h:514
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:37
SHAPE_POLY_SET m_outlines
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
double Similarity(const BOARD_ITEM &aItem) const override
Return a measure of how likely the other object is to represent the same object.
PCB_BOARD_OUTLINE(BOARD_ITEM *aParent)
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
wxString GetClass() const override
Return the class name.
bool operator==(const BOARD_ITEM &aItem) const override
PCB_BOARD_OUTLINE & operator=(const PCB_BOARD_OUTLINE &aOther)
static void CopyPros(const PCB_BOARD_OUTLINE &aCopyFrom, PCB_BOARD_OUTLINE &aCopyTo)
~PCB_BOARD_OUTLINE() override
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
#define SKIP_STRUCT
flag indicating that the structure should be ignored
@ LAYER_BOARD_OUTLINE_AREA
PCB board outline.
Definition: layer_ids.h:317
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ Edge_Cuts
Definition: layer_ids.h:112
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ PCB_BOARD_OUTLINE_T
class PCB_BOARD_OUTLINE_T, a pcb board outline item
Definition: typeinfo.h:111