KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_label.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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright The 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#ifndef SCH_LABEL_H
22#define SCH_LABEL_H
23
24#include <sch_text.h>
25#include <sch_item.h>
26#include <sch_field.h>
27#include <sch_connection.h> // for CONNECTION_TYPE
28
29class SCH_RULE_AREA;
30
31
32/*
33 * Spin style for labels of all kinds on schematics.
34 *
35 * Basically a higher level abstraction of rotation and justification of text.
36 */
38{
39public:
40 enum SPIN : int
41 {
42 LEFT = 0,
43 UP = 1,
44 RIGHT = 2,
46 };
47
48
49 SPIN_STYLE() = default;
50 constexpr SPIN_STYLE( SPIN aSpin ) : m_spin( aSpin )
51 {
52 }
53
54 constexpr bool operator==( SPIN a ) const
55 {
56 return m_spin == a;
57 }
58
59 constexpr bool operator!=( SPIN a ) const
60 {
61 return m_spin != a;
62 }
63
64 operator int() const
65 {
66 return static_cast<int>( m_spin );
67 }
68
69 SPIN Spin() const { return m_spin; }
70
72
77
82
86 unsigned CCWRotationsTo( const SPIN_STYLE& aOther ) const;
87
88private:
90};
91
92
93/*
94 * Label and flag shapes used with text objects.
95 */
110
111/*
112 * Specific enums for property manager (not used elsewhere)
113 */
122
130
131
133{
134public:
135 SCH_LABEL_BASE( const VECTOR2I& aPos, const wxString& aText, KICAD_T aType );
136
137 SCH_LABEL_BASE( const SCH_LABEL_BASE& aLabel );
138
139 SCH_LABEL_BASE& operator=( const SCH_LABEL_BASE& aLabel );
140
141 // Abstract class
142 virtual wxString GetClass() const override = 0;
143
144 bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override;
145
146 bool CanConnect( const SCH_ITEM* aItem ) const override
147 {
148 switch( aItem->Type() )
149 {
150 case SCH_LINE_T:
151 return aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS;
152
154 return true;
155
156 case SCH_SYMBOL_T:
157 return true;
158
159 case SCH_LABEL_T:
161 case SCH_HIER_LABEL_T:
163 case SCH_SHEET_PIN_T:
164 return true;
165
166 default:
167 return false;
168 }
169 }
170
171 bool HasConnectivityChanges( const SCH_ITEM* aItem,
172 const SCH_SHEET_PATH* aInstance = nullptr ) const override;
173
174 // Type-specific versions for property manager
176 void SetLabelShape( LABEL_SHAPE aShape );
177
180 {
181 // Set flags directly if a flag shape
182 if( aShape >= F_FIRST )
183 m_shape = aShape;
184 else
185 SetLabelShape( (LABEL_SHAPE) aShape );
186 }
187
188 COLOR4D GetLabelColor() const;
189
190 virtual void SetSpinStyle( SPIN_STYLE aSpinStyle );
191 SPIN_STYLE GetSpinStyle() const;
192
193 void SetLastResolvedState( const SCH_ITEM* aItem ) override
194 {
195 const SCH_LABEL_BASE* aLabel = dynamic_cast<const SCH_LABEL_BASE*>( aItem );
196
197 if( aLabel )
199 }
200
201 static const wxString GetDefaultFieldName( const wxString& aName, bool aUseDefaultName );
202
206 int GetNextFieldOrdinal() const;
207
208 virtual int GetMandatoryFieldCount() { return 0; }
209
210 std::vector<SCH_FIELD>& GetFields() { return m_fields; }
211 const std::vector<SCH_FIELD>& GetFields() const { return m_fields; }
212
218 void SetFields( const std::vector<SCH_FIELD>& aFields )
219 {
220 m_fields = aFields; // vector copying, length is changed possibly
221 }
222
223 void AddFields( const std::vector<SCH_FIELD>& aFields )
224 {
225 m_fields.insert( m_fields.end(), aFields.begin(), aFields.end() );
226 }
227
228 void AddField( const SCH_FIELD& aField )
229 {
230 m_fields.push_back( aField );
231 }
232
238 virtual bool IncrementLabel( int aIncrement );
239
240 void Move( const VECTOR2I& aMoveVector ) override;
241 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
242 void Rotate90( bool aClockwise ) override;
243
244 void MirrorSpinStyle( bool aLeftRight ) override;
245
246 void MirrorHorizontally( int aCenter ) override;
247 void MirrorVertically( int aCenter ) override;
248
249 void SetPosition( const VECTOR2I& aPosition ) override;
250
251 void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
252
258 void GetIntersheetRefs( const SCH_SHEET_PATH* aPath,
259 std::vector<std::pair<wxString, wxString>>* pages );
260
264 void GetContextualTextVars( wxArrayString* aVars ) const;
265
271 virtual bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth ) const;
272
273 wxString GetShownText( const SCH_SHEET_PATH* aPath, RESOLUTION_CONTEXT aContext, int aDepth = 0 ) const override;
274
275 wxString GetShownText( RESOLUTION_CONTEXT aContext, int aDepth = 0 ) const override
276 {
277 if( SCHEMATIC* schematic = Schematic() )
278 return GetShownText( &schematic->CurrentSheet(), aContext, aDepth );
279 else
280 return GetText();
281 }
282
283 bool HasCachedDriverName() const override;
284 const wxString& GetCachedDriverName() const override;
285
286 void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction, RECURSE_MODE aMode ) override;
287
288 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
289 const std::vector<KICAD_T>& scanTypes ) override;
290
291 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
292 bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override;
293
294 VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
295
302 virtual void CreateGraphicShape( const RENDER_SETTINGS* aSettings,
303 std::vector<VECTOR2I>& aPoints, const VECTOR2I& Pos ) const
304 {
305 aPoints.clear();
306 }
307
308 int GetLabelBoxExpansion( const RENDER_SETTINGS* aSettings = nullptr ) const;
309
313 virtual const BOX2I GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const;
314
318 const BOX2I GetBoundingBox() const override;
319
320 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
321 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
322 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
323
324 std::vector<VECTOR2I> GetConnectionPoints() const override;
325
326 void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
327
328 bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
329 std::vector<DANGLING_END_ITEM>& aItemListByPos,
330 const SCH_SHEET_PATH* aPath = nullptr ) override;
331
332 bool IsDangling() const override { return m_isDangling; }
333 void SetIsDangling( bool aIsDangling ) { m_isDangling = aIsDangling; }
334
335 std::vector<int> ViewGetLayers() const override;
336
337 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
338
339 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
340 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
341
346 bool AutoRotateOnPlacement() const;
347
352 void SetAutoRotateOnPlacement( bool autoRotate = true );
353
358 virtual bool AutoRotateOnPlacementSupported() const = 0;
359
360 double Similarity( const SCH_ITEM& aItem ) const override;
361
362 bool operator==( const SCH_ITEM& aItem ) const override;
363
364protected:
365 void swapData( SCH_ITEM* aItem ) override;
366
367 void cacheShownText() override;
368
369protected:
370 std::vector<SCH_FIELD> m_fields;
371
373
377
379
381};
382
383
385{
386public:
387 SCH_LABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ), const wxString& aText = wxEmptyString );
388
389 // Do not create a copy constructor. The one generated by the compiler is adequate.
390
392
393 void Serialize( google::protobuf::Any &aContainer ) const override;
394 bool Deserialize( const google::protobuf::Any &aContainer ) override;
395
396 static inline bool ClassOf( const EDA_ITEM* aItem )
397 {
398 return aItem && SCH_LABEL_T == aItem->Type();
399 }
400
401 wxString GetClass() const override
402 {
403 return wxT( "SCH_LABEL" );
404 }
405
406 wxString GetFriendlyName() const override
407 {
408 return _( "Label" );
409 }
410
411 const BOX2I GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const override;
412
413 bool IsConnectable() const override { return true; }
414
415 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
416
417 BITMAPS GetMenuImage() const override;
418
419 bool IsReplaceable() const override { return true; }
420
421 EDA_ITEM* Clone() const override
422 {
423 return new SCH_LABEL( *this );
424 }
425
426 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
427 {
428 return m_isDangling && GetPosition() == aPos;
429 }
430
431 bool AutoRotateOnPlacementSupported() const override { return false; }
432
433private:
434 bool doIsConnected( const VECTOR2I& aPosition ) const override
435 {
436 return EDA_TEXT::GetTextPos() == aPosition;
437 }
438};
439
440
442{
443public:
444 SCH_DIRECTIVE_LABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ) );
445
446 SCH_DIRECTIVE_LABEL( const SCH_DIRECTIVE_LABEL& aClassLabel );
447
448 ~SCH_DIRECTIVE_LABEL() override;
449
450 void Serialize( google::protobuf::Any &aContainer ) const override;
451 bool Deserialize( const google::protobuf::Any &aContainer ) override;
452
453 static inline bool ClassOf( const EDA_ITEM* aItem )
454 {
455 return aItem && SCH_DIRECTIVE_LABEL_T == aItem->Type();
456 }
457
458 wxString GetClass() const override
459 {
460 return wxT( "SCH_DIRECTIVE_LABEL" );
461 }
462
463 wxString GetFriendlyName() const override
464 {
465 return _( "Directive Label" );
466 }
467
468 EDA_ITEM* Clone() const override
469 {
470 return new SCH_DIRECTIVE_LABEL( *this );
471 }
472
473 void swapData( SCH_ITEM* aItem ) override;
474
476 void SetFlagShape( FLAG_SHAPE aShape ) { m_shape = (LABEL_FLAG_SHAPE) aShape; }
477
478 int GetPinLength() const { return m_pinLength; }
479 void SetPinLength( int aLength ) { m_pinLength = aLength; }
480
481 int GetPenWidth() const override;
482
483 void CreateGraphicShape( const RENDER_SETTINGS* aSettings,
484 std::vector<VECTOR2I>& aPoints,
485 const VECTOR2I& aPos ) const override;
486
487 void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
488
489 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
490
491 bool IsConnectable() const override { return true; }
492
493 bool AutoRotateOnPlacementSupported() const override { return false; }
494
495 void MirrorSpinStyle( bool aLeftRight ) override;
496
497 void MirrorHorizontally( int aCenter ) override;
498 void MirrorVertically( int aCenter ) override;
499
501 void AddConnectedRuleArea( SCH_RULE_AREA* aRuleArea );
502
505
507 void RemoveConnectedRuleArea( SCH_RULE_AREA* aRuleArea );
508
509 const std::unordered_set<SCH_RULE_AREA*> GetConnectedRuleAreas() const;
510
512 virtual bool IsDangling() const override;
513
515 bool IncrementLabel( int aIncrement ) override;
516
517 bool operator==( const SCH_ITEM& aOther ) const override;
518
519private:
522
524 std::unordered_set<SCH_RULE_AREA*> m_connected_rule_areas;
525};
526
527
529{
530public:
531 SCH_GLOBALLABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ),
532 const wxString& aText = wxEmptyString );
533
534 SCH_GLOBALLABEL( const SCH_GLOBALLABEL& aGlobalLabel );
535
537
538 void Serialize( google::protobuf::Any &aContainer ) const override;
539 bool Deserialize( const google::protobuf::Any &aContainer ) override;
540
541 static inline bool ClassOf( const EDA_ITEM* aItem )
542 {
543 return aItem && SCH_GLOBAL_LABEL_T == aItem->Type();
544 }
545
546 wxString GetClass() const override
547 {
548 return wxT( "SCH_GLOBALLABEL" );
549 }
550
551 wxString GetFriendlyName() const override
552 {
553 return _( "Global Label" );
554 }
555
556 EDA_ITEM* Clone() const override
557 {
558 return new SCH_GLOBALLABEL( *this );
559 }
560
561 int GetMandatoryFieldCount() override { return 1; }
562
567 SCH_FIELD* GetField( FIELD_T aFieldType );
568 const SCH_FIELD* GetField( FIELD_T aFieldNdx ) const;
569
570 void SetSpinStyle( SPIN_STYLE aSpinStyle ) override;
571
572 VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
573
574 void CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings,
575 std::vector<VECTOR2I>& aPoints,
576 const VECTOR2I& aPos ) const override;
577
578 bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth ) const override;
579
580 bool IsConnectable() const override { return true; }
581
582 std::vector<int> ViewGetLayers() const override;
583
584 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
585
586 BITMAPS GetMenuImage() const override;
587
588 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
589 {
590 return m_isDangling && GetPosition() == aPos;
591 }
592
593 bool AutoRotateOnPlacementSupported() const override { return true; }
594
595private:
596 bool doIsConnected( const VECTOR2I& aPosition ) const override
597 {
598 return EDA_TEXT::GetTextPos() == aPosition;
599 }
600};
601
602
604{
605public:
606 SCH_HIERLABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ), const wxString& aText = wxEmptyString,
607 KICAD_T aType = SCH_HIER_LABEL_T );
608
609 // Do not create a copy constructor. The one generated by the compiler is adequate.
610
611 ~SCH_HIERLABEL() override = default;
612
613 void Serialize( google::protobuf::Any &aContainer ) const override;
614 bool Deserialize( const google::protobuf::Any &aContainer ) override;
615
616 static inline bool ClassOf( const EDA_ITEM* aItem )
617 {
618 return aItem && SCH_HIER_LABEL_T == aItem->Type();
619 }
620
621 wxString GetFriendlyName() const override
622 {
623 return _( "Hierarchical Label" );
624 }
625
626 wxString GetClass() const override
627 {
628 return wxT( "SCH_HIERLABEL" );
629 }
630
631 void SetSpinStyle( SPIN_STYLE aSpinStyle ) override;
632
633 VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
634
635 void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector<VECTOR2I>& aPoints,
636 const VECTOR2I& aPos ) const override;
637 void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector<VECTOR2I>& aPoints,
638 const VECTOR2I& aPos, LABEL_FLAG_SHAPE aShape ) const;
639
640 const BOX2I GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const override;
641
642 bool IsConnectable() const override { return true; }
643
644 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
645
646 BITMAPS GetMenuImage() const override;
647
648 EDA_ITEM* Clone() const override
649 {
650 return new SCH_HIERLABEL( *this );
651 }
652
653 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
654 {
655 return m_isDangling && GetPosition() == aPos;
656 }
657
658 bool AutoRotateOnPlacementSupported() const override { return true; }
659
660private:
661 bool doIsConnected( const VECTOR2I& aPosition ) const override
662 {
663 return EDA_TEXT::GetTextPos() == aPosition;
664 }
665};
666
667#endif /* SCH_LABEL_H */
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:927
The base class for create windows for drawing purpose.
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 VECTOR2I GetTextPos() const
Definition eda_text.h:313
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:118
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
Base plotter engine class.
Definition plotter.h:136
Holds all the data relating to one schematic.
Definition schematic.h:148
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void MirrorSpinStyle(bool aLeftRight) override
wxString GetFriendlyName() const override
Definition sch_label.h:463
void RemoveConnectedRuleArea(SCH_RULE_AREA *aRuleArea)
Removes a specific rule area from the cache.
void ClearConnectedRuleAreas()
Removes all rule areas from the cache.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
SCH_DIRECTIVE_LABEL(const VECTOR2I &aPos=VECTOR2I(0, 0))
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool IsConnectable() const override
Definition sch_label.h:491
static bool ClassOf(const EDA_ITEM *aItem)
Definition sch_label.h:453
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void CreateGraphicShape(const RENDER_SETTINGS *aSettings, std::vector< VECTOR2I > &aPoints, const VECTOR2I &aPos) const override
Calculate the graphic shape (a polygon) associated to the text.
FLAG_SHAPE GetFlagShape() const
Definition sch_label.h:475
int GetPenWidth() const override
std::unordered_set< SCH_RULE_AREA * > m_connected_rule_areas
Cache of any rule areas with borders which this label connects to.
Definition sch_label.h:524
~SCH_DIRECTIVE_LABEL() override
bool operator==(const SCH_ITEM &aOther) const override
bool AutoRotateOnPlacementSupported() const override
Definition sch_label.h:493
wxString GetClass() const override
Return the class name.
Definition sch_label.h:458
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
void SetPinLength(int aLength)
Definition sch_label.h:479
virtual bool IsDangling() const override
Determines dangling state from connectivity and cached connected rule areas.
void AddConnectedRuleArea(SCH_RULE_AREA *aRuleArea)
Adds an entry to the connected rule area cache.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition sch_label.h:468
void SetFlagShape(FLAG_SHAPE aShape)
Definition sch_label.h:476
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
bool IncrementLabel(int aIncrement) override
Increment the netclass and component class labels if possible.
const std::unordered_set< SCH_RULE_AREA * > GetConnectedRuleAreas() const
int GetPinLength() const
Definition sch_label.h:478
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this label.
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
bool IsConnectable() const override
Definition sch_label.h:580
void CreateGraphicShape(const RENDER_SETTINGS *aRenderSettings, std::vector< VECTOR2I > &aPoints, const VECTOR2I &aPos) const override
Calculate the graphic shape (a polygon) associated to the text.
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth) const override
Resolve any references to system tokens supported by the label.
static bool ClassOf(const EDA_ITEM *aItem)
Definition sch_label.h:541
int GetMandatoryFieldCount() override
Definition sch_label.h:561
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
Definition sch_label.h:596
VECTOR2I GetSchematicTextOffset(const RENDER_SETTINGS *aSettings) const override
This offset depends on the orientation, the type of text, and the area required to draw the associate...
void SetSpinStyle(SPIN_STYLE aSpinStyle) override
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
wxString GetFriendlyName() const override
Definition sch_label.h:551
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
SCH_GLOBALLABEL(const VECTOR2I &aPos=VECTOR2I(0, 0), const wxString &aText=wxEmptyString)
bool AutoRotateOnPlacementSupported() const override
Definition sch_label.h:593
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition sch_label.h:556
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
Definition sch_label.h:588
wxString GetClass() const override
Return the class name.
Definition sch_label.h:546
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
~SCH_HIERLABEL() override=default
const BOX2I GetBodyBoundingBox(const RENDER_SETTINGS *aSettings) const override
Return the bounding box of the label only, without taking in account its fields.
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
Definition sch_label.h:661
static bool ClassOf(const EDA_ITEM *aItem)
Definition sch_label.h:616
wxString GetClass() const override
Return the class name.
Definition sch_label.h:626
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void SetSpinStyle(SPIN_STYLE aSpinStyle) override
void CreateGraphicShape(const RENDER_SETTINGS *aSettings, std::vector< VECTOR2I > &aPoints, const VECTOR2I &aPos) const override
Calculate the graphic shape (a polygon) associated to the text.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition sch_label.h:648
SCH_HIERLABEL(const VECTOR2I &aPos=VECTOR2I(0, 0), const wxString &aText=wxEmptyString, KICAD_T aType=SCH_HIER_LABEL_T)
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
Definition sch_label.h:653
bool IsConnectable() const override
Definition sch_label.h:642
wxString GetFriendlyName() const override
Definition sch_label.h:621
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
VECTOR2I GetSchematicTextOffset(const RENDER_SETTINGS *aSettings) const override
This offset depends on the orientation, the type of text, and the area required to draw the associate...
bool AutoRotateOnPlacementSupported() const override
Definition sch_label.h:658
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:165
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:281
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition sch_item.h:345
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:52
bool operator==(const SCH_ITEM &aItem) const override
void SetLastResolvedState(const SCH_ITEM *aItem) override
Definition sch_label.h:193
const wxString & GetCachedDriverName() const override
SCH_LABEL_BASE(const VECTOR2I &aPos, const wxString &aText, KICAD_T aType)
COLOR4D m_lastResolvedColor
Definition sch_label.h:378
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
void AddFields(const std::vector< SCH_FIELD > &aFields)
Definition sch_label.h:223
void SetFields(const std::vector< SCH_FIELD > &aFields)
Set multiple schematic fields.
Definition sch_label.h:218
void SetIsDangling(bool aIsDangling)
Definition sch_label.h:333
void AddField(const SCH_FIELD &aField)
Definition sch_label.h:228
bool IsDangling() const override
Definition sch_label.h:332
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &scanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
bool HasCachedDriverName() const override
const std::vector< SCH_FIELD > & GetFields() const
Definition sch_label.h:211
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
bool AutoRotateOnPlacement() const
autoRotateOnPlacement
SCH_LABEL_BASE & operator=(const SCH_LABEL_BASE &aLabel)
std::vector< SCH_FIELD > m_fields
Definition sch_label.h:370
CONNECTION_TYPE m_connectionType
Definition sch_label.h:374
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
int GetNextFieldOrdinal() const
Return the next ordinal for a user field for this label.
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
void SetLabelShape(LABEL_SHAPE aShape)
bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const override
Check if aItem has connectivity changes against this object.
SPIN_STYLE GetSpinStyle() const
void GetIntersheetRefs(const SCH_SHEET_PATH *aPath, std::vector< std::pair< wxString, wxString > > *pages)
Build an array of { pageNumber, pageName } pairs.
void MirrorSpinStyle(bool aLeftRight) override
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
COLOR4D GetLabelColor() const
void SetShape(LABEL_FLAG_SHAPE aShape)
Definition sch_label.h:179
LABEL_FLAG_SHAPE GetShape() const
Definition sch_label.h:178
const BOX2I GetBoundingBox() const override
Return the bounding box of the label including its fields.
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
virtual bool AutoRotateOnPlacementSupported() const =0
void SetPosition(const VECTOR2I &aPosition) override
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
virtual bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth) const
Resolve any references to system tokens supported by the label.
bool CanConnect(const SCH_ITEM *aItem) const override
Definition sch_label.h:146
LABEL_SHAPE GetLabelShape() const
Definition sch_label.h:175
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode) override
bool m_autoRotateOnPlacement
Definition sch_label.h:376
wxString m_cached_driver_name
Definition sch_label.h:380
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
int GetLabelBoxExpansion(const RENDER_SETTINGS *aSettings=nullptr) const
virtual bool IncrementLabel(int aIncrement)
Increment the label text if it ends with a number.
void SetAutoRotateOnPlacement(bool autoRotate=true)
void cacheShownText() override
void Rotate90(bool aClockwise) override
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
static const wxString GetDefaultFieldName(const wxString &aName, bool aUseDefaultName)
wxString GetShownText(const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, int aDepth=0) const override
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
wxString GetShownText(RESOLUTION_CONTEXT aContext, int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition sch_label.h:275
virtual int GetMandatoryFieldCount()
Definition sch_label.h:208
LABEL_FLAG_SHAPE m_shape
Definition sch_label.h:372
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this label.
virtual const BOX2I GetBodyBoundingBox(const RENDER_SETTINGS *aSettings) const
Return the bounding box of the label only, without taking in account its fields.
virtual void CreateGraphicShape(const RENDER_SETTINGS *aSettings, std::vector< VECTOR2I > &aPoints, const VECTOR2I &Pos) const
Calculate the graphic shape (a polygon) associated to the text.
Definition sch_label.h:302
std::vector< SCH_FIELD > & GetFields()
Definition sch_label.h:210
virtual wxString GetClass() const override=0
Return the class name.
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemListByType, std::vector< DANGLING_END_ITEM > &aItemListByPos, const SCH_SHEET_PATH *aPath=nullptr) override
Test the schematic item to aItemList to check if it's dangling state has changed.
VECTOR2I GetSchematicTextOffset(const RENDER_SETTINGS *aSettings) const override
This offset depends on the orientation, the type of text, and the area required to draw the associate...
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
bool Replace(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) override
Perform a text replace using the find and replace criteria in aSearchData on items that support text ...
double Similarity(const SCH_ITEM &aItem) const override
Return a measure of how likely the other object is to represent the same object.
bool AutoRotateOnPlacementSupported() const override
Definition sch_label.h:431
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
wxString GetClass() const override
Return the class name.
Definition sch_label.h:401
const BOX2I GetBodyBoundingBox(const RENDER_SETTINGS *aSettings) const override
Return the bounding box of the label only, without taking in account its fields.
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
Definition sch_label.h:434
SCH_LABEL(const VECTOR2I &aPos=VECTOR2I(0, 0), const wxString &aText=wxEmptyString)
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition sch_label.h:421
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
Definition sch_label.h:426
wxString GetFriendlyName() const override
Definition sch_label.h:406
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
Definition sch_label.h:419
static bool ClassOf(const EDA_ITEM *aItem)
Definition sch_label.h:396
bool IsConnectable() const override
Definition sch_label.h:413
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
VECTOR2I GetPosition() const override
Definition sch_text.h:143
SCH_TEXT(const VECTOR2I &aPos={ 0, 0 }, const wxString &aText=wxEmptyString, SCH_LAYER_ID aLayer=LAYER_NOTES, KICAD_T aType=SCH_TEXT_T)
Definition sch_text.cpp:55
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
constexpr SPIN_STYLE(SPIN aSpin)
Definition sch_label.h:50
SPIN_STYLE MirrorX()
Mirror the label spin style across the X axis or simply swaps up and bottom.
SPIN Spin() const
Definition sch_label.h:69
SPIN m_spin
Definition sch_label.h:89
SPIN_STYLE()=default
constexpr bool operator!=(SPIN a) const
Definition sch_label.h:59
constexpr bool operator==(SPIN a) const
Definition sch_label.h:54
SPIN_STYLE MirrorY()
Mirror the label spin style across the Y axis or simply swaps left and right.
unsigned CCWRotationsTo(const SPIN_STYLE &aOther) const
Get CCW rotation needed to get to the given spin style.
SPIN_STYLE RotateCCW()
RESOLUTION_CONTEXT
Definition common.h:87
#define _(s)
RECURSE_MODE
Definition eda_item.h:50
INSPECT_RESULT
Definition eda_item.h:44
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition eda_item.h:91
@ LAYER_WIRE
Definition layer_ids.h:474
@ LAYER_BUS
Definition layer_ids.h:475
CONNECTION_TYPE
AUTOPLACE_ALGO
Definition sch_item.h:68
FLAG_SHAPE
Definition sch_label.h:124
@ FLAG_CIRCLE
Definition sch_label.h:126
@ FLAG_RECTANGLE
Definition sch_label.h:128
@ FLAG_DOT
Definition sch_label.h:125
@ FLAG_DIAMOND
Definition sch_label.h:127
LABEL_FLAG_SHAPE
Definition sch_label.h:97
@ L_BIDI
Definition sch_label.h:100
@ L_TRISTATE
Definition sch_label.h:101
@ L_UNSPECIFIED
Definition sch_label.h:102
@ F_DOT
Definition sch_label.h:105
@ F_ROUND
Definition sch_label.h:106
@ F_FIRST
Definition sch_label.h:104
@ L_OUTPUT
Definition sch_label.h:99
@ F_DIAMOND
Definition sch_label.h:107
@ L_INPUT
Definition sch_label.h:98
@ F_RECTANGLE
Definition sch_label.h:108
LABEL_SHAPE
Definition sch_label.h:115
@ LABEL_BIDI
Definition sch_label.h:118
@ LABEL_INPUT
Definition sch_label.h:116
@ LABEL_OUTPUT
Definition sch_label.h:117
@ LABEL_PASSIVE
Definition sch_label.h:120
@ LABEL_TRISTATE
Definition sch_label.h:119
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:70
@ SCH_LINE_T
Definition typeinfo.h:159
@ SCH_SYMBOL_T
Definition typeinfo.h:168
@ SCH_DIRECTIVE_LABEL_T
Definition typeinfo.h:167
@ SCH_LABEL_T
Definition typeinfo.h:163
@ SCH_HIER_LABEL_T
Definition typeinfo.h:165
@ SCH_SHEET_PIN_T
Definition typeinfo.h:170
@ SCH_BUS_WIRE_ENTRY_T
Definition typeinfo.h:157
@ SCH_GLOBAL_LABEL_T
Definition typeinfo.h:164
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683