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, bool aAllowExtraText,
274 int aDepth = 0 ) const override;
275
276 wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override
277 {
278 SCHEMATIC* schematic = Schematic();
279
280 if( schematic )
281 return GetShownText( &schematic->CurrentSheet(), aAllowExtraText, aDepth );
282 else
283 return GetText();
284 }
285
286 bool HasCachedDriverName() const override;
287 const wxString& GetCachedDriverName() const override;
288
289 void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction, RECURSE_MODE aMode ) override;
290
291 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
292 const std::vector<KICAD_T>& scanTypes ) override;
293
294 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
295 bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override;
296
297 VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
298
305 virtual void CreateGraphicShape( const RENDER_SETTINGS* aSettings,
306 std::vector<VECTOR2I>& aPoints, const VECTOR2I& Pos ) const
307 {
308 aPoints.clear();
309 }
310
311 int GetLabelBoxExpansion( const RENDER_SETTINGS* aSettings = nullptr ) const;
312
316 virtual const BOX2I GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const;
317
321 const BOX2I GetBoundingBox() const override;
322
323 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
324 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
325 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
326
327 std::vector<VECTOR2I> GetConnectionPoints() const override;
328
329 void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
330
331 bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
332 std::vector<DANGLING_END_ITEM>& aItemListByPos,
333 const SCH_SHEET_PATH* aPath = nullptr ) override;
334
335 bool IsDangling() const override { return m_isDangling; }
336 void SetIsDangling( bool aIsDangling ) { m_isDangling = aIsDangling; }
337
338 std::vector<int> ViewGetLayers() const override;
339
340 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
341
342 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
343 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
344
349 bool AutoRotateOnPlacement() const;
350
355 void SetAutoRotateOnPlacement( bool autoRotate = true );
356
361 virtual bool AutoRotateOnPlacementSupported() const = 0;
362
363 double Similarity( const SCH_ITEM& aItem ) const override;
364
365 bool operator==( const SCH_ITEM& aItem ) const override;
366
367protected:
368 void swapData( SCH_ITEM* aItem ) override;
369
370 void cacheShownText() override;
371
372protected:
373 std::vector<SCH_FIELD> m_fields;
374
376
380
382
384};
385
386
388{
389public:
390 SCH_LABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ), const wxString& aText = wxEmptyString );
391
392 // Do not create a copy constructor. The one generated by the compiler is adequate.
393
395
396 void Serialize( google::protobuf::Any &aContainer ) const override;
397 bool Deserialize( const google::protobuf::Any &aContainer ) override;
398
399 static inline bool ClassOf( const EDA_ITEM* aItem )
400 {
401 return aItem && SCH_LABEL_T == aItem->Type();
402 }
403
404 wxString GetClass() const override
405 {
406 return wxT( "SCH_LABEL" );
407 }
408
409 wxString GetFriendlyName() const override
410 {
411 return _( "Label" );
412 }
413
414 const BOX2I GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const override;
415
416 bool IsConnectable() const override { return true; }
417
418 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
419
420 BITMAPS GetMenuImage() const override;
421
422 bool IsReplaceable() const override { return true; }
423
424 EDA_ITEM* Clone() const override
425 {
426 return new SCH_LABEL( *this );
427 }
428
429 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
430 {
431 return m_isDangling && GetPosition() == aPos;
432 }
433
434 bool AutoRotateOnPlacementSupported() const override { return false; }
435
436private:
437 bool doIsConnected( const VECTOR2I& aPosition ) const override
438 {
439 return EDA_TEXT::GetTextPos() == aPosition;
440 }
441};
442
443
445{
446public:
447 SCH_DIRECTIVE_LABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ) );
448
449 SCH_DIRECTIVE_LABEL( const SCH_DIRECTIVE_LABEL& aClassLabel );
450
451 ~SCH_DIRECTIVE_LABEL() override;
452
453 void Serialize( google::protobuf::Any &aContainer ) const override;
454 bool Deserialize( const google::protobuf::Any &aContainer ) override;
455
456 static inline bool ClassOf( const EDA_ITEM* aItem )
457 {
458 return aItem && SCH_DIRECTIVE_LABEL_T == aItem->Type();
459 }
460
461 wxString GetClass() const override
462 {
463 return wxT( "SCH_DIRECTIVE_LABEL" );
464 }
465
466 wxString GetFriendlyName() const override
467 {
468 return _( "Directive Label" );
469 }
470
471 EDA_ITEM* Clone() const override
472 {
473 return new SCH_DIRECTIVE_LABEL( *this );
474 }
475
476 void swapData( SCH_ITEM* aItem ) override;
477
479 void SetFlagShape( FLAG_SHAPE aShape ) { m_shape = (LABEL_FLAG_SHAPE) aShape; }
480
481 int GetPinLength() const { return m_pinLength; }
482 void SetPinLength( int aLength ) { m_pinLength = aLength; }
483
484 int GetPenWidth() const override;
485
486 void CreateGraphicShape( const RENDER_SETTINGS* aSettings,
487 std::vector<VECTOR2I>& aPoints,
488 const VECTOR2I& aPos ) const override;
489
490 void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
491
492 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
493
494 bool IsConnectable() const override { return true; }
495
496 bool AutoRotateOnPlacementSupported() const override { return false; }
497
498 void MirrorSpinStyle( bool aLeftRight ) override;
499
500 void MirrorHorizontally( int aCenter ) override;
501 void MirrorVertically( int aCenter ) override;
502
504 void AddConnectedRuleArea( SCH_RULE_AREA* aRuleArea );
505
508
510 void RemoveConnectedRuleArea( SCH_RULE_AREA* aRuleArea );
511
512 const std::unordered_set<SCH_RULE_AREA*> GetConnectedRuleAreas() const;
513
515 virtual bool IsDangling() const override;
516
518 bool IncrementLabel( int aIncrement ) override;
519
520 bool operator==( const SCH_ITEM& aOther ) const override;
521
522private:
525
527 std::unordered_set<SCH_RULE_AREA*> m_connected_rule_areas;
528};
529
530
532{
533public:
534 SCH_GLOBALLABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ),
535 const wxString& aText = wxEmptyString );
536
537 SCH_GLOBALLABEL( const SCH_GLOBALLABEL& aGlobalLabel );
538
540
541 void Serialize( google::protobuf::Any &aContainer ) const override;
542 bool Deserialize( const google::protobuf::Any &aContainer ) override;
543
544 static inline bool ClassOf( const EDA_ITEM* aItem )
545 {
546 return aItem && SCH_GLOBAL_LABEL_T == aItem->Type();
547 }
548
549 wxString GetClass() const override
550 {
551 return wxT( "SCH_GLOBALLABEL" );
552 }
553
554 wxString GetFriendlyName() const override
555 {
556 return _( "Global Label" );
557 }
558
559 EDA_ITEM* Clone() const override
560 {
561 return new SCH_GLOBALLABEL( *this );
562 }
563
564 int GetMandatoryFieldCount() override { return 1; }
565
570 SCH_FIELD* GetField( FIELD_T aFieldType );
571 const SCH_FIELD* GetField( FIELD_T aFieldNdx ) const;
572
573 void SetSpinStyle( SPIN_STYLE aSpinStyle ) override;
574
575 VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
576
577 void CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings,
578 std::vector<VECTOR2I>& aPoints,
579 const VECTOR2I& aPos ) const override;
580
581 bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth ) const override;
582
583 bool IsConnectable() const override { return true; }
584
585 std::vector<int> ViewGetLayers() const override;
586
587 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
588
589 BITMAPS GetMenuImage() const override;
590
591 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
592 {
593 return m_isDangling && GetPosition() == aPos;
594 }
595
596 bool AutoRotateOnPlacementSupported() const override { return true; }
597
598private:
599 bool doIsConnected( const VECTOR2I& aPosition ) const override
600 {
601 return EDA_TEXT::GetTextPos() == aPosition;
602 }
603};
604
605
607{
608public:
609 SCH_HIERLABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ), const wxString& aText = wxEmptyString,
610 KICAD_T aType = SCH_HIER_LABEL_T );
611
612 // Do not create a copy constructor. The one generated by the compiler is adequate.
613
614 ~SCH_HIERLABEL() override = default;
615
616 void Serialize( google::protobuf::Any &aContainer ) const override;
617 bool Deserialize( const google::protobuf::Any &aContainer ) override;
618
619 static inline bool ClassOf( const EDA_ITEM* aItem )
620 {
621 return aItem && SCH_HIER_LABEL_T == aItem->Type();
622 }
623
624 wxString GetFriendlyName() const override
625 {
626 return _( "Hierarchical Label" );
627 }
628
629 wxString GetClass() const override
630 {
631 return wxT( "SCH_HIERLABEL" );
632 }
633
634 void SetSpinStyle( SPIN_STYLE aSpinStyle ) override;
635
636 VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
637
638 void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector<VECTOR2I>& aPoints,
639 const VECTOR2I& aPos ) const override;
640 void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector<VECTOR2I>& aPoints,
641 const VECTOR2I& aPos, LABEL_FLAG_SHAPE aShape ) const;
642
643 const BOX2I GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const override;
644
645 bool IsConnectable() const override { return true; }
646
647 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
648
649 BITMAPS GetMenuImage() const override;
650
651 EDA_ITEM* Clone() const override
652 {
653 return new SCH_HIERLABEL( *this );
654 }
655
656 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
657 {
658 return m_isDangling && GetPosition() == aPos;
659 }
660
661 bool AutoRotateOnPlacementSupported() const override { return true; }
662
663private:
664 bool doIsConnected( const VECTOR2I& aPosition ) const override
665 {
666 return EDA_TEXT::GetTextPos() == aPosition;
667 }
668};
669
670#endif /* SCH_LABEL_H */
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
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:96
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:108
virtual VECTOR2I GetTextPos() const
Definition eda_text.h:294
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:110
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:133
Holds all the data relating to one schematic.
Definition schematic.h:90
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:466
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:494
static bool ClassOf(const EDA_ITEM *aItem)
Definition sch_label.h:456
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:478
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:527
~SCH_DIRECTIVE_LABEL() override
bool operator==(const SCH_ITEM &aOther) const override
bool AutoRotateOnPlacementSupported() const override
Definition sch_label.h:496
wxString GetClass() const override
Return the class name.
Definition sch_label.h:461
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
void SetPinLength(int aLength)
Definition sch_label.h:482
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:471
void SetFlagShape(FLAG_SHAPE aShape)
Definition sch_label.h:479
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:481
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:583
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:544
int GetMandatoryFieldCount() override
Definition sch_label.h:564
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
Definition sch_label.h:599
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:554
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:596
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition sch_label.h:559
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
Definition sch_label.h:591
wxString GetClass() const override
Return the class name.
Definition sch_label.h:549
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:664
static bool ClassOf(const EDA_ITEM *aItem)
Definition sch_label.h:619
wxString GetClass() const override
Return the class name.
Definition sch_label.h:629
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:651
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:656
bool IsConnectable() const override
Definition sch_label.h:645
wxString GetFriendlyName() const override
Definition sch_label.h:624
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:661
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:162
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:268
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition sch_item.h:338
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:381
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const override
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:336
void AddField(const SCH_FIELD &aField)
Definition sch_label.h:228
bool IsDangling() const override
Definition sch_label.h:335
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:373
CONNECTION_TYPE m_connectionType
Definition sch_label.h:377
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.
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition sch_label.h:276
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:379
wxString m_cached_driver_name
Definition sch_label.h:383
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)
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
virtual int GetMandatoryFieldCount()
Definition sch_label.h:208
LABEL_FLAG_SHAPE m_shape
Definition sch_label.h:375
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:305
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:434
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:404
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:437
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:424
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
Definition sch_label.h:429
wxString GetFriendlyName() const override
Definition sch_label.h:409
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:422
static bool ClassOf(const EDA_ITEM *aItem)
Definition sch_label.h:399
bool IsConnectable() const override
Definition sch_label.h:416
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:146
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()
#define _(s)
RECURSE_MODE
Definition eda_item.h:48
INSPECT_RESULT
Definition eda_item.h:42
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition eda_item.h:89
@ LAYER_WIRE
Definition layer_ids.h:450
@ LAYER_BUS
Definition layer_ids.h:451
CONNECTION_TYPE
AUTOPLACE_ALGO
Definition sch_item.h:65
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:71
@ SCH_LINE_T
Definition typeinfo.h:160
@ SCH_SYMBOL_T
Definition typeinfo.h:169
@ SCH_DIRECTIVE_LABEL_T
Definition typeinfo.h:168
@ SCH_LABEL_T
Definition typeinfo.h:164
@ SCH_HIER_LABEL_T
Definition typeinfo.h:166
@ SCH_SHEET_PIN_T
Definition typeinfo.h:171
@ SCH_BUS_WIRE_ENTRY_T
Definition typeinfo.h:158
@ SCH_GLOBAL_LABEL_T
Definition typeinfo.h:165
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683