KiCad PCB EDA Suite
Loading...
Searching...
No Matches
match_properties.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
21
22#include <board.h>
23#include <eda_item.h>
24#include <footprint.h>
25#include <i18n_utility.h>
26#include <pad.h>
27#include <pcb_barcode.h>
28#include <pcb_dimension.h>
29#include <pcb_reference_image.h>
30#include <pcb_shape.h>
31#include <pcb_generated_table.h>
32#include <pcb_table.h>
33#include <pcb_tablecell.h>
34#include <pcb_target.h>
35#include <pcb_text.h>
36#include <pcb_textbox.h>
37#include <pcb_track.h>
38#include <properties/property.h>
41#include <zone.h>
42
43#include <map>
44
45
46struct FAMILY
47{
50 wxString m_Label;
51};
52
53
55static const std::map<wxString, FAMILY>& families()
56{
57 // clang-format off
58 static const std::map<wxString, FAMILY> families = {
59 { wxS( "route" ), { TYPE_HASH( PCB_TRACK ), _HKI( "Tracks and Arcs" ) } },
60 { wxS( "via" ), { TYPE_HASH( PCB_VIA ), _HKI( "Vias" ) } },
61 { wxS( "pad" ), { TYPE_HASH( PAD ), _HKI( "Pads" ) } },
62 { wxS( "shape" ), { TYPE_HASH( PCB_SHAPE ), _HKI( "Graphics" ) } },
63 { wxS( "text" ), { TYPE_HASH( PCB_TEXT ), _HKI( "Text" ) } },
64 { wxS( "textbox" ), { TYPE_HASH( PCB_TEXTBOX ), _HKI( "Text Boxes" ) } },
65 { wxS( "dimension" ), { TYPE_HASH( PCB_DIM_ALIGNED ), _HKI( "Dimensions" ) } },
66 { wxS( "zone" ), { TYPE_HASH( ZONE ), _HKI( "Zones" ) } },
67 { wxS( "rule_area" ), { TYPE_HASH( ZONE ), _HKI( "Rule Areas" ) } },
68 { wxS( "footprint" ), { TYPE_HASH( FOOTPRINT ), _HKI( "Footprints" ) } },
69 { wxS( "table" ), { TYPE_HASH( PCB_TABLE ), _HKI( "Tables" ) } },
70 { wxS( "generated_table" ), { TYPE_HASH( PCB_GENERATED_TABLE ), _HKI( "Generated Tables" ) } },
71 { wxS( "table_cell" ), { TYPE_HASH( PCB_TABLECELL ), _HKI( "Table Cells" ) } },
72 { wxS( "target" ), { TYPE_HASH( PCB_TARGET ), _HKI( "Targets" ) } },
73 { wxS( "reference_image" ), { TYPE_HASH( PCB_REFERENCE_IMAGE ), _HKI( "Reference Images" ) } },
74 { wxS( "barcode" ), { TYPE_HASH( PCB_BARCODE ), _HKI( "Barcodes" ) } }
75 };
76 // clang-format on
77
78 return families;
79}
80
81
85{
86 wxString m_Label;
87 std::map<wxString, wxString> m_Names;
88};
89
90
92static const wxString COMMON_FAMILY = wxS( "common" );
93
94
97static const std::map<wxString, COMMON_PROPERTY>& commonProperties()
98{
99 // clang-format off
100 static const std::map<wxString, COMMON_PROPERTY> common = {
101 { wxS( "Layer" ), { _HKI( "Layer" ), {
102 { wxS( "barcode" ), wxS( "Layer" ) },
103 { wxS( "dimension" ), wxS( "Layer" ) },
104 { wxS( "shape" ), wxS( "Layer" ) },
105 { wxS( "table" ), wxS( "Layer" ) },
106 { wxS( "generated_table" ), wxS( "Layer" ) },
107 { wxS( "target" ), wxS( "Layer" ) },
108 { wxS( "text" ), wxS( "Layer" ) },
109 { wxS( "textbox" ), wxS( "Layer" ) },
110 { wxS( "reference_image" ), wxS( "Associated Layer" ) } } } },
111
112 { wxS( "Line Width" ), { _HKI( "Line Width" ), {
113 { wxS( "route" ), wxS( "Width" ) },
114 { wxS( "shape" ), wxS( "Line Width" ) },
115 { wxS( "table" ), wxS( "Border Width" ) },
116 { wxS( "generated_table" ), wxS( "Border Width" ) },
117 { wxS( "target" ), wxS( "Width" ) } } } },
118
119 { wxS( "Soldermask" ), { _HKI( "Soldermask" ), {
120 { wxS( "route" ), wxS( "Soldermask" ) },
121 { wxS( "shape" ), wxS( "Soldermask" ) } } } },
122
123 { wxS( "Soldermask Margin Override" ), { _HKI( "Soldermask Margin Override" ), {
124 { wxS( "pad" ), wxS( "Soldermask Margin Override" ) },
125 { wxS( "route" ), wxS( "Soldermask Margin Override" ) },
126 { wxS( "shape" ), wxS( "Soldermask Margin Override" ) } } } },
127
128 // Fill is registered on text boxes and table cells but its availability func refuses
129 // both, so claiming it here would pair kinds over something that can never apply.
130
131 { wxS( "Font" ), { _HKI( "Font" ), {
132 { wxS( "dimension" ), wxS( "Font" ) },
133 { wxS( "table_cell" ), wxS( "Font" ) },
134 { wxS( "text" ), wxS( "Font" ) },
135 { wxS( "textbox" ), wxS( "Font" ) } } } },
136
137 { wxS( "Text Width" ), { _HKI( "Text Width" ), {
138 { wxS( "dimension" ), wxS( "Width" ) },
139 { wxS( "table_cell" ), wxS( "Width" ) },
140 { wxS( "text" ), wxS( "Width" ) },
141 { wxS( "textbox" ), wxS( "Width" ) } } } },
142
143 { wxS( "Text Height" ), { _HKI( "Text Height" ), {
144 { wxS( "dimension" ), wxS( "Height" ) },
145 { wxS( "table_cell" ), wxS( "Height" ) },
146 { wxS( "text" ), wxS( "Height" ) },
147 { wxS( "textbox" ), wxS( "Height" ) } } } },
148
149 { wxS( "Text Thickness" ), { _HKI( "Text Thickness" ), {
150 { wxS( "dimension" ), wxS( "Thickness" ) },
151 { wxS( "table_cell" ), wxS( "Thickness" ) },
152 { wxS( "text" ), wxS( "Thickness" ) },
153 { wxS( "textbox" ), wxS( "Thickness" ) } } } },
154
155 { wxS( "Bold" ), { _HKI( "Bold" ), {
156 { wxS( "dimension" ), wxS( "Bold" ) },
157 { wxS( "table_cell" ), wxS( "Bold" ) },
158 { wxS( "text" ), wxS( "Bold" ) },
159 { wxS( "textbox" ), wxS( "Bold" ) } } } },
160
161 { wxS( "Italic" ), { _HKI( "Italic" ), {
162 { wxS( "dimension" ), wxS( "Italic" ) },
163 { wxS( "table_cell" ), wxS( "Italic" ) },
164 { wxS( "text" ), wxS( "Italic" ) },
165 { wxS( "textbox" ), wxS( "Italic" ) } } } },
166
167 { wxS( "Horizontal Justification" ), { _HKI( "Horizontal Justification" ), {
168 { wxS( "dimension" ), wxS( "Horizontal Justification" ) },
169 { wxS( "table_cell" ), wxS( "Horizontal Justification" ) },
170 { wxS( "text" ), wxS( "Horizontal Justification" ) },
171 { wxS( "textbox" ), wxS( "Horizontal Justification" ) } } } },
172
173 { wxS( "Vertical Justification" ), { _HKI( "Vertical Justification" ), {
174 { wxS( "dimension" ), wxS( "Vertical Justification" ) },
175 { wxS( "table_cell" ), wxS( "Vertical Justification" ) },
176 { wxS( "text" ), wxS( "Vertical Justification" ) },
177 { wxS( "textbox" ), wxS( "Vertical Justification" ) } } } },
178
179 { wxS( "Knockout" ), { _HKI( "Knockout" ), {
180 { wxS( "barcode" ), wxS( "Knockout" ) },
181 { wxS( "dimension" ), wxS( "Knockout" ) },
182 { wxS( "table_cell" ), wxS( "Knockout" ) },
183 { wxS( "text" ), wxS( "Knockout" ) },
184 { wxS( "textbox" ), wxS( "Knockout" ) } } } }
185 };
186 // clang-format on
187
188 return common;
189}
190
191
193static const std::map<wxString, std::map<wxString, wxString>>& commonReach();
194
195
203
204
206static wxString familyPrefix( const EDA_ITEM& aItem )
207{
208 const wxString family = MATCH_PROPERTIES_CATALOG::Family( aItem );
209
210 return family.IsEmpty() ? wxString() : family + wxS( "/" );
211}
212
213
215{
216 switch( aItem.Type() )
217 {
218 case PCB_TRACE_T:
219 case PCB_ARC_T: return wxS( "route" );
220 case PCB_VIA_T: return wxS( "via" );
221 case PCB_PAD_T: return wxS( "pad" );
222 case PCB_SHAPE_T: return wxS( "shape" );
223 case PCB_TEXT_T:
224 case PCB_FIELD_T: return wxS( "text" );
225 case PCB_TEXTBOX_T: return wxS( "textbox" );
227 case PCB_DIM_LEADER_T:
228 case PCB_DIM_CENTER_T:
229 case PCB_DIM_RADIAL_T:
230 case PCB_DIM_ORTHOGONAL_T: return wxS( "dimension" );
231 case PCB_FOOTPRINT_T: return wxS( "footprint" );
232 case PCB_TABLE_T: return wxS( "table" );
233 // Their own family, since plain tables advertise colors and Cell Separators they mask and
234 // lack the Row Height and Font they add
236 case PCB_STACKUP_TABLE_T: return wxS( "generated_table" );
237 case PCB_TABLECELL_T: return wxS( "table_cell" );
238 case PCB_TARGET_T: return wxS( "target" );
239 case PCB_REFERENCE_IMAGE_T: return wxS( "reference_image" );
240 case PCB_BARCODE_T: return wxS( "barcode" );
241 case PCB_ZONE_T: return static_cast<const ZONE&>( aItem ).GetIsRuleArea() ? wxS( "rule_area" ) : wxS( "zone" );
242 default: return wxEmptyString;
243 }
244}
245
246
247wxString MATCH_PROPERTIES_CATALOG::FamilyLabel( const wxString& aFamily )
248{
249 if( aFamily == COMMON_FAMILY )
250 return _( "Common to Several Kinds" );
251
252 auto entry = families().find( aFamily );
253
254 return entry == families().end() ? aFamily : wxGetTranslation( entry->second.m_Label );
255}
256
257
258std::set<wxString> MATCH_PROPERTIES_CATALOG::FamiliesFor( const wxString& aKey )
259{
260 const wxString family = aKey.BeforeFirst( '/' );
261
262 if( family != COMMON_FAMILY )
263 return { family };
264
265 auto entry = commonReach().find( aKey.AfterFirst( '/' ) );
266
267 if( entry == commonReach().end() )
268 return {};
269
270 std::set<wxString> families;
271
272 for( const auto& [name, property] : entry->second )
273 families.insert( name );
274
275 return families;
276}
277
278
279bool MATCH_PROPERTIES_CATALOG::PropertyIsRegistered( const wxString& aFamily, const wxString& aName )
280{
281 auto entry = families().find( aFamily );
282
283 if( entry == families().end() )
284 return false;
285
286 return PROPERTY_MANAGER::Instance().GetProperty( entry->second.m_Type, aName ) != nullptr;
287}
288
289
290wxString MATCH_PROPERTIES_CATALOG::PropertyLabel( const wxString& aKey )
291{
292 if( aKey.BeforeFirst( '/' ) == COMMON_FAMILY )
293 {
294 auto entry = commonProperties().find( aKey.AfterFirst( '/' ) );
295
296 if( entry != commonProperties().end() )
297 return wxGetTranslation( entry->second.m_Label );
298 }
299
300 // wxGetTranslation() returns its own argument for a missing msgid, so the name it is given
301 // has to outlive the call.
302 const wxString name = aKey.AfterFirst( '/' );
303
304 return wxGetTranslation( name );
305}
306
307
308wxString MATCH_PROPERTIES_CATALOG::DisplayLabel( const wxString& aKey )
309{
310 return wxString::Format( wxS( "%s — %s" ), FamilyLabel( aKey.BeforeFirst( '/' ) ), PropertyLabel( aKey ) );
311}
312
313
314bool MATCH_PROPERTIES_CATALOG::Compatible( const EDA_ITEM& aSource, const EDA_ITEM& aTarget )
315{
316 const wxString source = Family( aSource );
317 const wxString target = Family( aTarget );
318
319 if( source.IsEmpty() || target.IsEmpty() )
320 return false;
321
322 if( source == target )
323 return true;
324
325 // Different kinds still meet over anything they both understand.
326 for( const auto& [key, families] : commonReach() )
327 {
328 if( families.contains( source ) && families.contains( target ) )
329 return true;
330 }
331
332 return false;
333}
334
335
336std::vector<EDA_ITEM*> MATCH_PROPERTIES_CATALOG::CompatibleTargets( const EDA_ITEM& aSource,
337 const std::vector<EDA_ITEM*>& aCandidates )
338{
339 std::vector<EDA_ITEM*> targets;
340
341 for( EDA_ITEM* candidate : aCandidates )
342 {
343 if( candidate && candidate != &aSource && Compatible( aSource, *candidate ) )
344 targets.push_back( candidate );
345 }
346
347 return targets;
348}
349
350
351bool MATCH_PROPERTIES_CATALOG::AnyEnabledFor( const EDA_ITEM& aItem, const std::set<wxString>& aEnabledKeys )
352{
353 const wxString prefix = familyPrefix( aItem );
354
355 if( prefix.IsEmpty() )
356 return false;
357
358 auto it = aEnabledKeys.lower_bound( prefix );
359
360 if( it != aEnabledKeys.end() && it->StartsWith( prefix ) )
361 return true;
362
363 const wxString family = Family( aItem );
364
365 for( const auto& [key, families] : commonReach() )
366 {
367 if( families.contains( family ) && aEnabledKeys.contains( COMMON_FAMILY + wxS( "/" ) + key ) )
368 return true;
369 }
370
371 return false;
372}
373
374
376static std::vector<PENDING_PROPERTY> plan( const EDA_ITEM& aSource, const EDA_ITEM& aTarget,
377 const std::set<wxString>& aEnabledKeys )
378{
379 std::vector<PENDING_PROPERTY> pending;
380 const wxString prefix = familyPrefix( aSource );
381 const wxString sourceFamily = MATCH_PROPERTIES_CATALOG::Family( aSource );
382 const wxString targetFamily = MATCH_PROPERTIES_CATALOG::Family( aTarget );
383 const bool acrossKinds = sourceFamily != targetFamily;
385 EDA_ITEM* source = const_cast<EDA_ITEM*>( &aSource );
386 const TYPE_ID sourceType = TYPE_HASH( aSource );
387 const TYPE_ID targetType = TYPE_HASH( aTarget );
388
389 auto stage =
390 [&]( const wxString& aSourceName, const wxString& aTargetName, bool aOptional )
391 {
392 PROPERTY_BASE* sourceProperty = mgr.GetProperty( sourceType, aSourceName );
393 PROPERTY_BASE* targetProperty = mgr.GetProperty( targetType, aTargetName );
394
395 if( !sourceProperty || !targetProperty )
396 return;
397
398 // The enabled set is persisted and hand-editable. It can name a stale property.
399 if( !sourceProperty->IsCopyable() || sourceProperty->IsHiddenFromPropertiesManager()
400 || !mgr.IsAvailableFor( sourceType, sourceProperty, source )
401 || !mgr.IsWriteableFor( sourceType, sourceProperty, source ) )
402 {
403 return;
404 }
405
406 // A mixed value has no single value to copy, only whichever part the getter reads
407 if( sourceProperty->IsIndeterminate( source ) )
408 return;
409
410 pending.push_back( { targetProperty, aSource.Get( sourceProperty ), aOptional } );
411 };
412
413 // Enabled keys are the short list. Walk their prefix range, not every property of the type.
414 // GetProperty() is a linear scan, so one lookup per property is quadratic.
415 if( !acrossKinds )
416 {
417 for( auto it = aEnabledKeys.lower_bound( prefix ); it != aEnabledKeys.end() && it->StartsWith( prefix );
418 ++it )
419 {
420 const wxString name = it->Mid( prefix.length() );
421
422 stage( name, name, false );
423 }
424 }
425
426 // A common property is registered under a different name in each family, and crossing kinds
427 // it may simply not fit. Those are dropped rather than reported.
428 for( const auto& [key, families] : commonReach() )
429 {
430 auto sourceName = families.find( sourceFamily );
431 auto targetName = families.find( targetFamily );
432
433 if( sourceName == families.end() || targetName == families.end() )
434 continue;
435
436 if( !aEnabledKeys.contains( COMMON_FAMILY + wxS( "/" ) + key ) )
437 continue;
438
439 stage( sourceName->second, targetName->second, acrossKinds );
440 }
441
442 return pending;
443}
444
445
447 const std::set<wxString>& aEnabledKeys )
448{
450
451 if( !Compatible( aSource, aTarget ) )
452 {
453 result.m_Error = _( "The source and target have no properties in common." );
454 return result;
455 }
456
458 const TYPE_ID targetType = TYPE_HASH( aTarget );
459 std::unique_ptr<EDA_ITEM> staged( aTarget.Clone() );
460 std::vector<PENDING_PROPERTY> pending = plan( aSource, aTarget, aEnabledKeys );
461 std::vector<std::pair<PROPERTY_BASE*, bool>> stagedProperties;
462
463 // Setting one property can make another writeable. Sweep until nothing moves. What is
464 // still pending does not apply to this target. Drop it.
465 for( bool madeProgress = true; madeProgress; )
466 {
467 madeProgress = false;
468
469 for( auto it = pending.begin(); it != pending.end(); )
470 {
471 PROPERTY_BASE* targetProperty = it->m_Property;
472
473 if( !mgr.IsAvailableFor( targetType, targetProperty, staged.get() )
474 || !mgr.IsWriteableFor( targetType, targetProperty, staged.get() ) )
475 {
476 ++it;
477 continue;
478 }
479
480 if( !staged->Set( targetProperty, it->m_Value, false ) )
481 {
482 // Between two kinds of item the same idea can still be held differently. That
483 // is a property this target does not take, not a failure of the copy.
484 if( it->m_Optional )
485 {
486 it = pending.erase( it );
487 madeProgress = true;
488 continue;
489 }
490
491 result.m_Error = wxString::Format( _( "Could not apply property '%s' to the target item." ),
492 wxGetTranslation( targetProperty->Name() ) );
493 return result;
494 }
495
496 stagedProperties.push_back( { targetProperty, it->m_Optional } );
497 it = pending.erase( it );
498 madeProgress = true;
499 }
500 }
501
502 // A later property can turn a staged one read-only again. A validator means nothing until
503 // the item is finished. Re-check both before touching the real item.
504 std::vector<std::pair<PROPERTY_BASE*, wxAny>> apply;
505
506 for( const auto& [targetProperty, optional] : stagedProperties )
507 {
508 if( !mgr.IsAvailableFor( targetType, targetProperty, staged.get() )
509 || !mgr.IsWriteableFor( targetType, targetProperty, staged.get() ) )
510 {
511 continue;
512 }
513
514 wxAny stagedValue = staged->Get( targetProperty );
515
516 if( targetProperty->Validate( wxAny( stagedValue ), staged.get() ) )
517 {
518 // Across kinds a value that does not suit the target is nothing to report, the
519 // same as one that would not stage.
520 if( optional )
521 continue;
522
523 result.m_Error = wxString::Format( _( "The value for property '%s' is not valid for the target item." ),
524 wxGetTranslation( targetProperty->Name() ) );
525 return result;
526 }
527
528 apply.emplace_back( targetProperty, std::move( stagedValue ) );
529 }
530
531 for( auto& [targetProperty, value] : apply )
532 {
533 if( !KiWxAnyEquals( aTarget.Get( targetProperty ), value, targetProperty )
534 && aTarget.Set( targetProperty, value ) )
535 {
536 ++result.m_Changed;
537 }
538 }
539
540 return result;
541}
542
543
544const std::set<wxString>& MATCH_PROPERTIES_CATALOG::AllSafeKeys()
545{
546 // PROPERTY_MANAGER registrations are static. The answer cannot change after the first ask.
547 static const std::set<wxString> keys = []
548 {
549 std::set<wxString> result;
551
552 // Zones and rule areas are one item type, told apart by a flag. Ask a rule area which
553 // properties it offers.
554 BOARD board;
555 ZONE ruleArea( &board );
556 ruleArea.SetIsRuleArea( true );
557
558 for( const auto& [family, entry] : families() )
559 {
560 const TYPE_ID type = entry.m_Type;
561 const bool ruleAreaFamily = family == wxS( "rule_area" );
562
563 for( PROPERTY_BASE* property : mgr.GetProperties( type ) )
564 {
565 if( !property->IsCopyable() || property->IsHiddenFromPropertiesManager() )
566 continue;
567
568 if( type == TYPE_HASH( ZONE )
569 && mgr.IsAvailableFor( type, property, &ruleArea ) != ruleAreaFamily )
570 {
571 continue;
572 }
573
574 result.insert( family + wxS( "/" ) + property->Name() );
575 }
576 }
577
578 // A common property stands in for the per-family entries it covers, so the same idea is
579 // not offered twice under different names.
580 for( const auto& [key, common] : commonProperties() )
581 {
582 std::vector<wxString> covered;
583
584 for( const auto& [family, name] : common.m_Names )
585 {
586 const wxString familyKey = family + wxS( "/" ) + name;
587
588 if( result.contains( familyKey ) )
589 covered.push_back( familyKey );
590 }
591
592 // One family is not something in common; leave it where it was.
593 if( covered.size() < 2 )
594 continue;
595
596 for( const wxString& familyKey : covered )
597 result.erase( familyKey );
598
599 result.insert( COMMON_FAMILY + wxS( "/" ) + key );
600 }
601
602 return result;
603 }();
604
605 return keys;
606}
607
608
609const std::map<wxString, std::map<wxString, wxString>>& commonReach()
610{
611 static const std::map<wxString, std::map<wxString, wxString>> reach = []
612 {
613 std::map<wxString, std::map<wxString, wxString>> result;
614
615 // AllSafeKeys() decided which families a common key really covers. Rebuild that same
616 // decision here so the two cannot drift.
617 for( const auto& [key, common] : commonProperties() )
618 {
619 if( !MATCH_PROPERTIES_CATALOG::AllSafeKeys().contains( COMMON_FAMILY + wxS( "/" ) + key ) )
620 continue;
621
622 for( const auto& [family, name] : common.m_Names )
623 {
625 result[key][family] = name;
626 }
627 }
628
629 return result;
630 }();
631
632 return reach;
633}
634
635
636const std::set<wxString>& MATCH_PROPERTIES_CATALOG::DefaultKeys()
637{
638 static const std::set<wxString> keys = {
639 wxS( "common/Layer" ), wxS( "common/Line Width" ), wxS( "shape/Fill" ),
640 wxS( "common/Soldermask" ), wxS( "common/Soldermask Margin Override" ),
641 wxS( "common/Font" ), wxS( "common/Text Width" ), wxS( "common/Text Height" ),
642 wxS( "common/Text Thickness" ), wxS( "common/Bold" ), wxS( "common/Italic" ),
643 wxS( "shape/Line Style" ), wxS( "via/Diameter" ), wxS( "via/Hole" ),
644 wxS( "zone/Fill Mode" ), wxS( "table/Border Style" )
645 };
646
647 return keys;
648}
const char * name
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition eda_item.cpp:288
wxAny Get(PROPERTY_BASE *aProperty) const
bool Set(PROPERTY_BASE *aProperty, wxAny &aValue, bool aNotify=true)
Definition pad.h:61
For better understanding of the points that make a dimension:
A table whose cell text is derived from the board and rebuilt whenever it goes stale.
Object to handle a bitmap image that can be inserted in a PCB.
bool IsHiddenFromPropertiesManager() const
Definition property.h:353
bool IsCopyable() const
True for a property that says how an item looks, not what or where it is.
Definition property.h:387
bool IsIndeterminate(INSPECTABLE *aObject) const
Return true if aObject holds several values for this property, so it has no single value to show.
Definition property.h:314
const wxString & Name() const
Definition property.h:221
Provide class metadata.
const std::vector< PROPERTY_BASE * > & GetProperties(TYPE_ID aType) const
Return all properties for a specific type.
bool IsWriteableFor(TYPE_ID aItemClass, PROPERTY_BASE *aProp, INSPECTABLE *aItem)
Checks overriden availability and original availability of a property, returns false if the property ...
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Return a property for a specific type.
bool IsAvailableFor(TYPE_ID aItemClass, PROPERTY_BASE *aProp, INSPECTABLE *aItem)
Checks overriden availability and original availability of a property, returns false if the property ...
Handle a list of polygons defining a copper zone.
Definition zone.h:70
void SetIsRuleArea(bool aEnable)
Definition zone.h:835
#define _(s)
Some functions to handle hotkeys in KiCad.
std::string source
static std::vector< PENDING_PROPERTY > plan(const EDA_ITEM &aSource, const EDA_ITEM &aTarget, const std::set< wxString > &aEnabledKeys)
Target properties to write, paired with values read off the source.
static wxString familyPrefix(const EDA_ITEM &aItem)
Empty if the item has no family. Never matches a key.
static const std::map< wxString, COMMON_PROPERTY > & commonProperties()
Keyed by the name the settings use after the prefix.
static const wxString COMMON_FAMILY
The prefix common keys carry in the enabled set, in place of a family.
static const std::map< wxString, std::map< wxString, wxString > > & commonReach()
The families a common property actually reaches, once the unregistered ones are dropped.
static const std::map< wxString, FAMILY > & families()
Keyed by the names Family() returns. Every family there must appear here.
MATCH_PROPERTIES_RESULT Copy(const EDA_ITEM &aSource, EDA_ITEM &aTarget, const std::set< wxString > &aEnabledKeys)
bool Compatible(const EDA_ITEM &aSource, const EDA_ITEM &aTarget)
const std::set< wxString > & AllSafeKeys()
Every property Match Properties may copy, keyed as "family/Property Name".
bool PropertyIsRegistered(const wxString &aFamily, const wxString &aName)
Whether aFamily registers a property of that name. Used to prune the common table.
wxString PropertyLabel(const wxString &aKey)
The translated property name alone, without the family it belongs to.
const std::set< wxString > & DefaultKeys()
The subset enabled until the user says otherwise.
bool AnyEnabledFor(const EDA_ITEM &aItem, const std::set< wxString > &aEnabledKeys)
True if any enabled key names a property of this item's family.
std::vector< EDA_ITEM * > CompatibleTargets(const EDA_ITEM &aSource, const std::vector< EDA_ITEM * > &aCandidates)
wxString FamilyLabel(const wxString &aFamily)
The translated name of a family, for the heading of its group.
std::set< wxString > FamiliesFor(const wxString &aKey)
The families a key reaches. One for a family key, several for a common one.
wxString Family(const EDA_ITEM &aItem)
wxString DisplayLabel(const wxString &aKey)
#define _HKI(x)
Definition page_info.cpp:40
BARCODE class definition.
#define TYPE_HASH(x)
Macro to generate unique identifier for a type.
Definition property.h:74
size_t TYPE_ID
Unique type identifier.
A property that means the same thing in more than one family.
std::map< wxString, wxString > m_Names
family -> the name it is registered under there
TYPE_ID m_Type
One item type carrying every property the family advertises.
wxString m_Label
One value staged for the target. Optional entries are dropped if they will not go.
PROPERTY_BASE * m_Property
VECTOR2I end
wxString result
Test unit parsing edge cases and error handling.
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition typeinfo.h:80
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition typeinfo.h:98
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition typeinfo.h:95
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:89
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition typeinfo.h:96
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition typeinfo.h:85
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition typeinfo.h:100
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition typeinfo.h:84
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
Definition typeinfo.h:81
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
Definition typeinfo.h:82
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
Definition typeinfo.h:93
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition typeinfo.h:99
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
Definition typeinfo.h:87
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition typeinfo.h:78
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition typeinfo.h:94
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:79
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition typeinfo.h:90
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
Definition typeinfo.h:86
@ PCB_STACKUP_TABLE_T
class PCB_STACKUP_TABLE, a live stackup table derived from PCB_TABLE
Definition typeinfo.h:242
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:88
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition typeinfo.h:97
@ PCB_DRILL_CHART_T
class PCB_DRILL_CHART, a live drill chart derived from PCB_TABLE
Definition typeinfo.h:239
bool KiWxAnyEquals(const wxAny &aA, const wxAny &aB, const PROPERTY_BASE *aProperty)
Compare two wxAny values for equality across the KiCad property type set.