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, see <https://www.gnu.org/licenses/>.
19 */
20
21#include "pcb_board_outline.h"
22#include <eda_item_flags.h>
23#include <eda_item.h>
24#include <layer_ids.h>
25#include <memory>
27
29{
30 aCopyTo.m_outlines = aCopyFrom.m_outlines;
31 aCopyTo.m_parent = aCopyFrom.m_parent;
32}
33
34
40
43{
44 CopyPros( aOther, *this );
45}
46
48{
49 CopyPros( aOther, *this );
50 return *this;
51}
52
56
57
58std::vector<int> PCB_BOARD_OUTLINE::ViewGetLayers() const
59{
60 std::vector<int> layers { LAYER_BOARD_OUTLINE_AREA };
61 return layers;
62}
63
64
66{
67 return m_outlines.BBox();
68}
69
70
75
76
78{
79 return {};
80}
81
83{
84 WXUNUSED( aLayer )
85 return {};
86}
87
88double PCB_BOARD_OUTLINE::Similarity( const BOARD_ITEM& aItem ) const
89{
90 if( aItem.Type() == KICAD_T::PCB_BOARD_OUTLINE_T )
91 {
92 if( m_parent == aItem.GetParent() )
93 return 1.0;
94
95 return 0.5;
96 }
97
98 return 0.0;
99}
100
102{
103 if( const PCB_BOARD_OUTLINE* outline = dynamic_cast<const PCB_BOARD_OUTLINE*>( &aItem ) )
104 {
105 return outline->m_parent == m_parent;
106 }
107
108 return {};
109}
110
112{
113 return new PCB_BOARD_OUTLINE( *this );
114}
115
117{
118 return "PCB_BOARD_OUTLINE";
119}
120
121
122#if defined( DEBUG )
123
124void PCB_BOARD_OUTLINE::Show( int nestLevel, std::ostream& os ) const
125{
126 NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n";
127}
128
129#endif
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:83
BOARD_ITEM_CONTAINER * GetParent() const
Definition board_item.h:231
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition eda_item.h:152
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:108
EDA_ITEM * m_parent
Owner.
Definition eda_item.h:543
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:37
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)
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.
#define SKIP_STRUCT
flag indicating that the structure should be ignored
@ LAYER_BOARD_OUTLINE_AREA
PCB board outline.
Definition layer_ids.h:314
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ Edge_Cuts
Definition layer_ids.h:108
@ UNDEFINED_LAYER
Definition layer_ids.h:57
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:71
@ PCB_BOARD_OUTLINE_T
class PCB_BOARD_OUTLINE_T, a pcb board outline item
Definition typeinfo.h:105