KiCad PCB EDA Suite
Loading...
Searching...
No Matches
eda_item_flags.h
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) 2013-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2008-2015 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6 * Copyright (C) 2008 Wayne Stambaugh <[email protected]>
7 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, you may find one here:
21 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22 * or you may search the http://www.gnu.org website for the version 2 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
27#ifndef EDA_ITEM_FLAGS_H
28#define EDA_ITEM_FLAGS_H
29
30#include <cstdint>
31
32// These define are used for the .m_flags member of the class EDA_ITEM
33//
34// NB: DO NOT ADD FLAGS ANYWHERE BUT AT THE END: THE FLAG-SET IS STORED AS AN INTEGER IN FILES.
35//
36#define IS_CHANGED (1UL << 0)
37#define IS_LINKED (1UL << 1)
38#define IN_EDIT (1UL << 2)
39#define IS_MOVING (1UL << 3)
40#define IS_NEW (1UL << 4)
41#define IS_BROKEN (1UL << 5)
42
43#define IS_DELETED (1UL << 7)
44
45#define STARTPOINT (1UL << 9)
46#define ENDPOINT (1UL << 10)
47#define SELECTED (1UL << 11)
48#define SELECTED_BY_DRAG (1UL << 12)
49#define STRUCT_DELETED (1UL << 13)
50#define CANDIDATE (1UL << 14)
51#define SKIP_STRUCT (1UL << 15)
52
53#define IS_PASTED (1UL << 17)
54#define IS_SHOWN_AS_BITMAP (1UL << 18)
55#define COURTYARD_CONFLICT (1UL << 19)
57#define MALFORMED_F_COURTYARD (1UL << 20)
58#define MALFORMED_B_COURTYARD (1UL << 21)
59#define MALFORMED_COURTYARDS ( MALFORMED_F_COURTYARD | MALFORMED_B_COURTYARD )
60
61#define ROUTER_TRANSIENT (1UL << 22)
62
63#define CONNECTIVITY_CANDIDATE (1UL << 23)
64
65#define HOLE_PROXY (1UL << 24)
66#define SHOW_ELEC_TYPE (1UL << 25)
67#define BRIGHTENED (1UL << 26)
68
69#define MCT_SKIP_STRUCT (1 << 27)
70
71#define UR_TRANSIENT (1UL << 28)
72
73#define IS_DANGLING (1UL << 29)
74#define ENTERED (1UL << 30)
75#define SELECTION_CANDIDATE (1UL << 31)
76
77// WARNING: if you add flags, you'll probably need to adjust the masks in GetEditFlags() and
78// ClearTempFlags().
79
80#define EDA_ITEM_ALL_FLAGS UINT32_MAX
81
82typedef std::uint32_t EDA_ITEM_FLAGS;
83
84// Helper function to convert flags to string descriptions
85#include <string>
86#include <vector>
87#include <sstream>
88
89inline std::string EDAItemFlagsToString( EDA_ITEM_FLAGS flags )
90{
91 struct FlagDesc
92 {
93 EDA_ITEM_FLAGS value;
94 const char* name;
95 };
96
97 static const FlagDesc flagDescs[] = { { IS_CHANGED, "IS_CHANGED" },
98 { IS_LINKED, "IS_LINKED" },
99 { IN_EDIT, "IN_EDIT" },
100 { IS_MOVING, "IS_MOVING" },
101 { IS_NEW, "IS_NEW" },
102 { IS_BROKEN, "IS_BROKEN" },
103 { IS_DELETED, "IS_DELETED" },
104 { STARTPOINT, "STARTPOINT" },
105 { ENDPOINT, "ENDPOINT" },
106 { SELECTED, "SELECTED" },
107 { SELECTED_BY_DRAG, "SELECTED_BY_DRAG" },
108 { STRUCT_DELETED, "STRUCT_DELETED" },
109 { CANDIDATE, "CANDIDATE" },
110 { SKIP_STRUCT, "SKIP_STRUCT" },
111 { IS_PASTED, "IS_PASTED" },
112 { IS_SHOWN_AS_BITMAP, "IS_SHOWN_AS_BITMAP" },
113 { COURTYARD_CONFLICT, "COURTYARD_CONFLICT" },
114 { MALFORMED_F_COURTYARD, "MALFORMED_F_COURTYARD" },
115 { MALFORMED_B_COURTYARD, "MALFORMED_B_COURTYARD" },
116 { ROUTER_TRANSIENT, "ROUTER_TRANSIENT" },
117 { CONNECTIVITY_CANDIDATE, "CONNECTIVITY_CANDIDATE" },
118 { HOLE_PROXY, "HOLE_PROXY" },
119 { SHOW_ELEC_TYPE, "SHOW_ELEC_TYPE" },
120 { BRIGHTENED, "BRIGHTENED" },
121 { UR_TRANSIENT, "UR_TRANSIENT" },
122 { IS_DANGLING, "IS_DANGLING" },
123 { ENTERED, "ENTERED" },
124 { SELECTION_CANDIDATE, "SELECTION_CANDIDATE" } };
125
126 std::vector<std::string> setFlags;
127 for( const auto& desc : flagDescs )
128 {
129 if( flags & desc.value )
130 setFlags.push_back( desc.name );
131 }
132
133 std::ostringstream oss;
134 for( size_t i = 0; i < setFlags.size(); ++i )
135 {
136 if( i > 0 )
137 oss << " | ";
138 oss << setFlags[i];
139 }
140 if( setFlags.empty() )
141 return "0";
142 return oss.str();
143}
144
145
146#endif
const char * name
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
#define IS_CHANGED
Item was edited, and modified.
#define BRIGHTENED
item is drawn with a bright contour
#define IS_SHOWN_AS_BITMAP
#define IS_NEW
New item, just created.
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
#define SELECTED
Item was manually selected by the user.
#define SELECTED_BY_DRAG
Item was algorithmically selected as a dragged item.
#define SELECTION_CANDIDATE
indicates an item is a candidate for selection
std::string EDAItemFlagsToString(EDA_ITEM_FLAGS flags)
#define CONNECTIVITY_CANDIDATE
flag indicating that the structure is connected for connectivity
#define COURTYARD_CONFLICT
temporary set when moving footprints having courtyard overlapping
#define IS_DELETED
#define MALFORMED_F_COURTYARD
#define MALFORMED_B_COURTYARD
#define ROUTER_TRANSIENT
transient items that should NOT be cached
#define IS_BROKEN
Is a segment just broken by BreakSegment.
#define HOLE_PROXY
Indicates the BOARD_ITEM is a proxy for its hole.
#define ENTERED
indicates a group has been entered
#define STRUCT_DELETED
flag indication structures to be erased
#define ENDPOINT
ends. (Used to support dragging.)
#define IN_EDIT
Item currently edited.
#define SKIP_STRUCT
flag indicating that the structure should be ignored
std::uint32_t EDA_ITEM_FLAGS
#define CANDIDATE
flag indicating that the structure is connected
#define IS_MOVING
Item being moved.
#define UR_TRANSIENT
indicates the item is owned by the undo/redo stack
#define SHOW_ELEC_TYPE
Show pin electrical type.
#define IS_DANGLING
indicates a pin is dangling
#define STARTPOINT
When a line is selected, these flags indicate which.