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
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
110
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() const { 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 void AddFields( const std::vector<SCH_FIELD>& aFields );
220 void AddField( const SCH_FIELD& aField );
221
227 virtual bool IncrementLabel( int aIncrement );
228
229 void Move( const VECTOR2I& aMoveVector ) override;
230 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
231 void Rotate90( bool aClockwise ) override;
232
233 void MirrorSpinStyle( bool aLeftRight ) override;
234
235 void MirrorHorizontally( int aCenter ) override;
236 void MirrorVertically( int aCenter ) override;
237
238 void SetPosition( const VECTOR2I& aPosition ) override;
239
240 void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
241
248 void GetIntersheetRefs( const SCH_SHEET_PATH* aPath,
249 std::vector<std::pair<wxString, wxString>>* pages );
250
254 void GetContextualTextVars( wxArrayString* aVars ) const;
255
263 virtual bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth ) const;
264
265 wxString GetShownText( const SCH_SHEET_PATH* aPath, RESOLUTION_CONTEXT aContext, int aDepth = 0 ) const override;
266
267 wxString GetShownText( RESOLUTION_CONTEXT aContext, int aDepth = 0 ) const override
268 {
269 if( SCHEMATIC* schematic = Schematic() )
270 return GetShownText( &schematic->CurrentSheet(), aContext, aDepth );
271 else
272 return GetText();
273 }
274
275 bool HasCachedDriverName() const override;
276 const wxString& GetCachedDriverName() const override;
277
278 void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction, RECURSE_MODE aMode ) override;
279
280 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
281 const std::vector<KICAD_T>& scanTypes ) override;
282
283 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
284 bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override;
285
286 VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
287
295 virtual void CreateGraphicShape( const RENDER_SETTINGS* aSettings,
296 std::vector<VECTOR2I>& aPoints, const VECTOR2I& Pos ) const
297 {
298 aPoints.clear();
299 }
300
301 int GetLabelBoxExpansion( const RENDER_SETTINGS* aSettings = nullptr ) const;
302
306 virtual const BOX2I GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const;
307
311 const BOX2I GetBoundingBox() const override;
312
313 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
314 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
315 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
316
317 std::vector<VECTOR2I> GetConnectionPoints() const override;
318
319 void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
320
321 bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
322 std::vector<DANGLING_END_ITEM>& aItemListByPos,
323 const SCH_SHEET_PATH* aPath = nullptr ) override;
324
325 bool IsDangling() const override { return m_isDangling; }
326 void SetIsDangling( bool aIsDangling ) { m_isDangling = aIsDangling; }
327
328 std::vector<int> ViewGetLayers() const override;
329
330 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
331
332 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
333 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
334
339 bool AutoRotateOnPlacement() const;
340
345 void SetAutoRotateOnPlacement( bool autoRotate = true );
346
351 virtual bool AutoRotateOnPlacementSupported() const = 0;
352
353 double Similarity( const SCH_ITEM& aItem ) const override;
354
355 bool operator==( const SCH_ITEM& aItem ) const override;
356
357protected:
358 void swapData( SCH_ITEM* aItem ) override;
359
360 void cacheShownText() override;
361
362protected:
363 std::vector<SCH_FIELD> m_fields;
364
366
370
372
374};
375
376
378{
379public:
380 SCH_LABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ), const wxString& aText = wxEmptyString );
381
382 // Do not create a copy constructor. The one generated by the compiler is adequate.
383
385
386 void Serialize( google::protobuf::Any &aContainer ) const override;
387 bool Deserialize( const google::protobuf::Any &aContainer ) override;
388
389 static inline bool ClassOf( const EDA_ITEM* aItem )
390 {
391 return aItem && SCH_LABEL_T == aItem->Type();
392 }
393
394 wxString GetClass() const override
395 {
396 return wxT( "SCH_LABEL" );
397 }
398
399 wxString GetFriendlyName() const override
400 {
401 return _( "Label" );
402 }
403
404 const BOX2I GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const override;
405
406 bool IsConnectable() const override { return true; }
407
408 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
409
410 BITMAPS GetMenuImage() const override;
411
412 bool IsReplaceable() const override { return true; }
413
414 EDA_ITEM* Clone() const override
415 {
416 return new SCH_LABEL( *this );
417 }
418
419 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
420 {
421 return m_isDangling && GetPosition() == aPos;
422 }
423
424 bool AutoRotateOnPlacementSupported() const override { return false; }
425
426private:
427 bool doIsConnected( const VECTOR2I& aPosition ) const override
428 {
429 return EDA_TEXT::GetTextPos() == aPosition;
430 }
431};
432
433
435{
436public:
437 SCH_DIRECTIVE_LABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ) );
438
439 SCH_DIRECTIVE_LABEL( const SCH_DIRECTIVE_LABEL& aClassLabel );
440
441 ~SCH_DIRECTIVE_LABEL() override;
442
443 void Serialize( google::protobuf::Any &aContainer ) const override;
444 bool Deserialize( const google::protobuf::Any &aContainer ) override;
445
446 static inline bool ClassOf( const EDA_ITEM* aItem )
447 {
448 return aItem && SCH_DIRECTIVE_LABEL_T == aItem->Type();
449 }
450
451 wxString GetClass() const override
452 {
453 return wxT( "SCH_DIRECTIVE_LABEL" );
454 }
455
456 wxString GetFriendlyName() const override
457 {
458 return _( "Directive Label" );
459 }
460
461 EDA_ITEM* Clone() const override
462 {
463 return new SCH_DIRECTIVE_LABEL( *this );
464 }
465
466 void swapData( SCH_ITEM* aItem ) override;
467
469 void SetFlagShape( FLAG_SHAPE aShape ) { m_shape = (LABEL_FLAG_SHAPE) aShape; }
470
471 int GetPinLength() const { return m_pinLength; }
472 void SetPinLength( int aLength ) { m_pinLength = aLength; }
473
474 int GetPenWidth() const override;
475
476 void CreateGraphicShape( const RENDER_SETTINGS* aSettings,
477 std::vector<VECTOR2I>& aPoints,
478 const VECTOR2I& aPos ) const override;
479
480 void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
481
482 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
483
484 bool IsConnectable() const override { return true; }
485
486 bool AutoRotateOnPlacementSupported() const override { return false; }
487
488 void MirrorSpinStyle( bool aLeftRight ) override;
489
490 void MirrorHorizontally( int aCenter ) override;
491 void MirrorVertically( int aCenter ) override;
492
494 void AddConnectedRuleArea( SCH_RULE_AREA* aRuleArea );
495
498
500 void RemoveConnectedRuleArea( SCH_RULE_AREA* aRuleArea );
501
502 const std::unordered_set<SCH_RULE_AREA*> GetConnectedRuleAreas() const;
503
505 virtual bool IsDangling() const override;
506
508 bool IncrementLabel( int aIncrement ) override;
509
510 bool operator==( const SCH_ITEM& aOther ) const override;
511
512private:
515
517 std::unordered_set<SCH_RULE_AREA*> m_connected_rule_areas;
518};
519
520
522{
523public:
524 SCH_GLOBALLABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ),
525 const wxString& aText = wxEmptyString );
526
527 SCH_GLOBALLABEL( const SCH_GLOBALLABEL& aGlobalLabel );
528
530
531 void Serialize( google::protobuf::Any &aContainer ) const override;
532 bool Deserialize( const google::protobuf::Any &aContainer ) override;
533
534 static inline bool ClassOf( const EDA_ITEM* aItem )
535 {
536 return aItem && SCH_GLOBAL_LABEL_T == aItem->Type();
537 }
538
539 wxString GetClass() const override
540 {
541 return wxT( "SCH_GLOBALLABEL" );
542 }
543
544 wxString GetFriendlyName() const override
545 {
546 return _( "Global Label" );
547 }
548
549 EDA_ITEM* Clone() const override
550 {
551 return new SCH_GLOBALLABEL( *this );
552 }
553
554 int GetMandatoryFieldCount() const override { return 1; }
555
560 SCH_FIELD* GetField( FIELD_T aFieldType );
561 const SCH_FIELD* GetField( FIELD_T aFieldNdx ) const;
562
563 void SetSpinStyle( SPIN_STYLE aSpinStyle ) override;
564
565 VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
566
567 void CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings,
568 std::vector<VECTOR2I>& aPoints,
569 const VECTOR2I& aPos ) const override;
570
571 bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth ) const override;
572
573 bool IsConnectable() const override { return true; }
574
575 std::vector<int> ViewGetLayers() const override;
576
577 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
578
579 BITMAPS GetMenuImage() const override;
580
581 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
582 {
583 return m_isDangling && GetPosition() == aPos;
584 }
585
586 bool AutoRotateOnPlacementSupported() const override { return true; }
587
588private:
589 bool doIsConnected( const VECTOR2I& aPosition ) const override
590 {
591 return EDA_TEXT::GetTextPos() == aPosition;
592 }
593};
594
595
597{
598public:
599 SCH_HIERLABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ), const wxString& aText = wxEmptyString,
600 KICAD_T aType = SCH_HIER_LABEL_T );
601
602 // Do not create a copy constructor. The one generated by the compiler is adequate.
603
604 ~SCH_HIERLABEL() override = default;
605
606 void Serialize( google::protobuf::Any &aContainer ) const override;
607 bool Deserialize( const google::protobuf::Any &aContainer ) override;
608
609 static inline bool ClassOf( const EDA_ITEM* aItem )
610 {
611 return aItem && SCH_HIER_LABEL_T == aItem->Type();
612 }
613
614 wxString GetFriendlyName() const override
615 {
616 return _( "Hierarchical Label" );
617 }
618
619 wxString GetClass() const override
620 {
621 return wxT( "SCH_HIERLABEL" );
622 }
623
624 void SetSpinStyle( SPIN_STYLE aSpinStyle ) override;
625
626 VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
627
628 void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector<VECTOR2I>& aPoints,
629 const VECTOR2I& aPos ) const override;
630 void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector<VECTOR2I>& aPoints,
631 const VECTOR2I& aPos, LABEL_FLAG_SHAPE aShape ) const;
632
633 const BOX2I GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const override;
634
635 bool IsConnectable() const override { return true; }
636
637 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
638
639 BITMAPS GetMenuImage() const override;
640
641 EDA_ITEM* Clone() const override
642 {
643 return new SCH_HIERLABEL( *this );
644 }
645
646 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
647 {
648 return m_isDangling && GetPosition() == aPos;
649 }
650
651 bool AutoRotateOnPlacementSupported() const override { return true; }
652
653private:
654 bool doIsConnected( const VECTOR2I& aPosition ) const override
655 {
656 return EDA_TEXT::GetTextPos() == aPosition;
657 }
658};
659
660#endif /* SCH_LABEL_H */
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
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:149
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:456
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:484
static bool ClassOf(const EDA_ITEM *aItem)
Definition sch_label.h:446
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:468
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:517
~SCH_DIRECTIVE_LABEL() override
bool operator==(const SCH_ITEM &aOther) const override
bool AutoRotateOnPlacementSupported() const override
Definition sch_label.h:486
wxString GetClass() const override
Return the class name.
Definition sch_label.h:451
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
void SetPinLength(int aLength)
Definition sch_label.h:472
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:461
void SetFlagShape(FLAG_SHAPE aShape)
Definition sch_label.h:469
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:471
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:573
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:534
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
Definition sch_label.h:589
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
int GetMandatoryFieldCount() const override
Definition sch_label.h:554
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
wxString GetFriendlyName() const override
Definition sch_label.h:544
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:586
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition sch_label.h:549
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
Definition sch_label.h:581
wxString GetClass() const override
Return the class name.
Definition sch_label.h:539
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:654
static bool ClassOf(const EDA_ITEM *aItem)
Definition sch_label.h:609
wxString GetClass() const override
Return the class name.
Definition sch_label.h:619
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:641
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:646
bool IsConnectable() const override
Definition sch_label.h:635
wxString GetFriendlyName() const override
Definition sch_label.h:614
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:651
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:170
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:302
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition sch_item.h:353
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:65
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:371
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
void AddFields(const std::vector< SCH_FIELD > &aFields)
void SetFields(const std::vector< SCH_FIELD > &aFields)
Set multiple schematic fields.
void SetIsDangling(bool aIsDangling)
Definition sch_label.h:326
void AddField(const SCH_FIELD &aField)
bool IsDangling() const override
Definition sch_label.h:325
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:363
CONNECTION_TYPE m_connectionType
Definition sch_label.h:367
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:369
wxString m_cached_driver_name
Definition sch_label.h:373
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:267
LABEL_FLAG_SHAPE m_shape
Definition sch_label.h:365
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:295
virtual int GetMandatoryFieldCount() const
Definition sch_label.h:208
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:424
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:394
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:427
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:414
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
Definition sch_label.h:419
wxString GetFriendlyName() const override
Definition sch_label.h:399
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:412
static bool ClassOf(const EDA_ITEM *aItem)
Definition sch_label.h:389
bool IsConnectable() const override
Definition sch_label.h:406
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:56
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Spin style for labels of all kinds on schematics.
Definition sch_label.h:38
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:89
#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:73
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
Label and flag shapes used with text objects.
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
Specific enums for property manager (not used elsewhere)
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:708