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, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef SCH_LABEL_H
26#define SCH_LABEL_H
27
28#include <sch_text.h>
29#include <sch_item.h>
30#include <sch_field.h>
31#include <sch_connection.h> // for CONNECTION_TYPE
32
33class SCH_RULE_AREA;
34
35
36/*
37 * Spin style for labels of all kinds on schematics.
38 *
39 * Basically a higher level abstraction of rotation and justification of text.
40 */
42{
43public:
44 enum SPIN : int
45 {
46 LEFT = 0,
47 UP = 1,
48 RIGHT = 2,
50 };
51
52
53 SPIN_STYLE() = default;
54 constexpr SPIN_STYLE( SPIN aSpin ) : m_spin( aSpin )
55 {
56 }
57
58 constexpr bool operator==( SPIN a ) const
59 {
60 return m_spin == a;
61 }
62
63 constexpr bool operator!=( SPIN a ) const
64 {
65 return m_spin != a;
66 }
67
68 operator int() const
69 {
70 return static_cast<int>( m_spin );
71 }
72
73 SPIN Spin() const { return m_spin; }
74
76
81
86
90 unsigned CCWRotationsTo( const SPIN_STYLE& aOther ) const;
91
92private:
94};
95
96
97/*
98 * Label and flag shapes used with text objects.
99 */
114
115/*
116 * Specific enums for property manager (not used elsewhere)
117 */
126
134
135
137{
138public:
139 SCH_LABEL_BASE( const VECTOR2I& aPos, const wxString& aText, KICAD_T aType );
140
141 SCH_LABEL_BASE( const SCH_LABEL_BASE& aLabel );
142
143 SCH_LABEL_BASE& operator=( const SCH_LABEL_BASE& aLabel );
144
145 // Abstract class
146 virtual wxString GetClass() const override = 0;
147
148 bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override;
149
150 bool CanConnect( const SCH_ITEM* aItem ) const override
151 {
152 switch( aItem->Type() )
153 {
154 case SCH_LINE_T:
155 return aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS;
156
158 return true;
159
160 case SCH_SYMBOL_T:
161 return true;
162
163 case SCH_LABEL_T:
165 case SCH_HIER_LABEL_T:
167 case SCH_SHEET_PIN_T:
168 return true;
169
170 default:
171 return false;
172 }
173 }
174
175 bool HasConnectivityChanges( const SCH_ITEM* aItem,
176 const SCH_SHEET_PATH* aInstance = nullptr ) const override;
177
178 // Type-specific versions for property manager
180 void SetLabelShape( LABEL_SHAPE aShape );
181
184 {
185 // Set flags directly if a flag shape
186 if( aShape >= F_FIRST )
187 m_shape = aShape;
188 else
189 SetLabelShape( (LABEL_SHAPE) aShape );
190 }
191
192 COLOR4D GetLabelColor() const;
193
194 virtual void SetSpinStyle( SPIN_STYLE aSpinStyle );
195 SPIN_STYLE GetSpinStyle() const;
196
197 void SetLastResolvedState( const SCH_ITEM* aItem ) override
198 {
199 const SCH_LABEL_BASE* aLabel = dynamic_cast<const SCH_LABEL_BASE*>( aItem );
200
201 if( aLabel )
203 }
204
205 static const wxString GetDefaultFieldName( const wxString& aName, bool aUseDefaultName );
206
210 int GetNextFieldOrdinal() const;
211
212 virtual int GetMandatoryFieldCount() { return 0; }
213
214 std::vector<SCH_FIELD>& GetFields() { return m_fields; }
215 const std::vector<SCH_FIELD>& GetFields() const { return m_fields; }
216
222 void SetFields( const std::vector<SCH_FIELD>& aFields )
223 {
224 m_fields = aFields; // vector copying, length is changed possibly
225 }
226
227 void AddFields( const std::vector<SCH_FIELD>& aFields )
228 {
229 m_fields.insert( m_fields.end(), aFields.begin(), aFields.end() );
230 }
231
232 void AddField( const SCH_FIELD& aField )
233 {
234 m_fields.push_back( aField );
235 }
236
242 virtual bool IncrementLabel( int aIncrement );
243
244 void Move( const VECTOR2I& aMoveVector ) override;
245 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
246 void Rotate90( bool aClockwise ) override;
247
248 void MirrorSpinStyle( bool aLeftRight ) override;
249
250 void MirrorHorizontally( int aCenter ) override;
251 void MirrorVertically( int aCenter ) override;
252
253 void SetPosition( const VECTOR2I& aPosition ) override;
254
255 void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
256
262 void GetIntersheetRefs( const SCH_SHEET_PATH* aPath,
263 std::vector<std::pair<wxString, wxString>>* pages );
264
268 void GetContextualTextVars( wxArrayString* aVars ) const;
269
275 virtual bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth ) const;
276
277 wxString GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
278 int aDepth = 0 ) const override;
279
280 wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override
281 {
282 SCHEMATIC* schematic = Schematic();
283
284 if( schematic )
285 return GetShownText( &schematic->CurrentSheet(), aAllowExtraText, aDepth );
286 else
287 return GetText();
288 }
289
290 bool HasCachedDriverName() const override;
291 const wxString& GetCachedDriverName() const override;
292
293 void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction, RECURSE_MODE aMode ) override;
294
295 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
296 const std::vector<KICAD_T>& scanTypes ) override;
297
298 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
299 bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override;
300
301 VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
302
309 virtual void CreateGraphicShape( const RENDER_SETTINGS* aSettings,
310 std::vector<VECTOR2I>& aPoints, const VECTOR2I& Pos ) const
311 {
312 aPoints.clear();
313 }
314
315 int GetLabelBoxExpansion( const RENDER_SETTINGS* aSettings = nullptr ) const;
316
320 virtual const BOX2I GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const;
321
325 const BOX2I GetBoundingBox() const override;
326
327 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
328 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
329 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
330
331 std::vector<VECTOR2I> GetConnectionPoints() const override;
332
333 void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
334
335 bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
336 std::vector<DANGLING_END_ITEM>& aItemListByPos,
337 const SCH_SHEET_PATH* aPath = nullptr ) override;
338
339 bool IsDangling() const override { return m_isDangling; }
340 void SetIsDangling( bool aIsDangling ) { m_isDangling = aIsDangling; }
341
342 std::vector<int> ViewGetLayers() const override;
343
344 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
345
346 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
347 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
348
353 bool AutoRotateOnPlacement() const;
354
359 void SetAutoRotateOnPlacement( bool autoRotate = true );
360
365 virtual bool AutoRotateOnPlacementSupported() const = 0;
366
367 double Similarity( const SCH_ITEM& aItem ) const override;
368
369 bool operator==( const SCH_ITEM& aItem ) const override;
370
371protected:
372 void swapData( SCH_ITEM* aItem ) override;
373
374 void cacheShownText() override;
375
376protected:
377 std::vector<SCH_FIELD> m_fields;
378
380
384
386
388};
389
390
392{
393public:
394 SCH_LABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ), const wxString& aText = wxEmptyString );
395
396 // Do not create a copy constructor. The one generated by the compiler is adequate.
397
399
400 void Serialize( google::protobuf::Any &aContainer ) const override;
401 bool Deserialize( const google::protobuf::Any &aContainer ) override;
402
403 static inline bool ClassOf( const EDA_ITEM* aItem )
404 {
405 return aItem && SCH_LABEL_T == aItem->Type();
406 }
407
408 wxString GetClass() const override
409 {
410 return wxT( "SCH_LABEL" );
411 }
412
413 wxString GetFriendlyName() const override
414 {
415 return _( "Label" );
416 }
417
418 const BOX2I GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const override;
419
420 bool IsConnectable() const override { return true; }
421
422 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
423
424 BITMAPS GetMenuImage() const override;
425
426 bool IsReplaceable() const override { return true; }
427
428 EDA_ITEM* Clone() const override
429 {
430 return new SCH_LABEL( *this );
431 }
432
433 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
434 {
435 return m_isDangling && GetPosition() == aPos;
436 }
437
438 bool AutoRotateOnPlacementSupported() const override { return false; }
439
440private:
441 bool doIsConnected( const VECTOR2I& aPosition ) const override
442 {
443 return EDA_TEXT::GetTextPos() == aPosition;
444 }
445};
446
447
449{
450public:
451 SCH_DIRECTIVE_LABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ) );
452
453 SCH_DIRECTIVE_LABEL( const SCH_DIRECTIVE_LABEL& aClassLabel );
454
455 ~SCH_DIRECTIVE_LABEL() override;
456
457 void Serialize( google::protobuf::Any &aContainer ) const override;
458 bool Deserialize( const google::protobuf::Any &aContainer ) override;
459
460 static inline bool ClassOf( const EDA_ITEM* aItem )
461 {
462 return aItem && SCH_DIRECTIVE_LABEL_T == aItem->Type();
463 }
464
465 wxString GetClass() const override
466 {
467 return wxT( "SCH_DIRECTIVE_LABEL" );
468 }
469
470 wxString GetFriendlyName() const override
471 {
472 return _( "Directive Label" );
473 }
474
475 EDA_ITEM* Clone() const override
476 {
477 return new SCH_DIRECTIVE_LABEL( *this );
478 }
479
480 void swapData( SCH_ITEM* aItem ) override;
481
483 void SetFlagShape( FLAG_SHAPE aShape ) { m_shape = (LABEL_FLAG_SHAPE) aShape; }
484
485 int GetPinLength() const { return m_pinLength; }
486 void SetPinLength( int aLength ) { m_pinLength = aLength; }
487
488 int GetPenWidth() const override;
489
490 void CreateGraphicShape( const RENDER_SETTINGS* aSettings,
491 std::vector<VECTOR2I>& aPoints,
492 const VECTOR2I& aPos ) const override;
493
494 void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
495
496 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
497
498 bool IsConnectable() const override { return true; }
499
500 bool AutoRotateOnPlacementSupported() const override { return false; }
501
502 void MirrorSpinStyle( bool aLeftRight ) override;
503
504 void MirrorHorizontally( int aCenter ) override;
505 void MirrorVertically( int aCenter ) override;
506
508 void AddConnectedRuleArea( SCH_RULE_AREA* aRuleArea );
509
512
514 void RemoveConnectedRuleArea( SCH_RULE_AREA* aRuleArea );
515
516 const std::unordered_set<SCH_RULE_AREA*> GetConnectedRuleAreas() const;
517
519 virtual bool IsDangling() const override;
520
522 bool IncrementLabel( int aIncrement ) override;
523
524 bool operator==( const SCH_ITEM& aOther ) const override;
525
526private:
529
531 std::unordered_set<SCH_RULE_AREA*> m_connected_rule_areas;
532};
533
534
536{
537public:
538 SCH_GLOBALLABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ),
539 const wxString& aText = wxEmptyString );
540
541 SCH_GLOBALLABEL( const SCH_GLOBALLABEL& aGlobalLabel );
542
544
545 void Serialize( google::protobuf::Any &aContainer ) const override;
546 bool Deserialize( const google::protobuf::Any &aContainer ) override;
547
548 static inline bool ClassOf( const EDA_ITEM* aItem )
549 {
550 return aItem && SCH_GLOBAL_LABEL_T == aItem->Type();
551 }
552
553 wxString GetClass() const override
554 {
555 return wxT( "SCH_GLOBALLABEL" );
556 }
557
558 wxString GetFriendlyName() const override
559 {
560 return _( "Global Label" );
561 }
562
563 EDA_ITEM* Clone() const override
564 {
565 return new SCH_GLOBALLABEL( *this );
566 }
567
568 int GetMandatoryFieldCount() override { return 1; }
569
574 SCH_FIELD* GetField( FIELD_T aFieldType );
575 const SCH_FIELD* GetField( FIELD_T aFieldNdx ) const;
576
577 void SetSpinStyle( SPIN_STYLE aSpinStyle ) override;
578
579 VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
580
581 void CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings,
582 std::vector<VECTOR2I>& aPoints,
583 const VECTOR2I& aPos ) const override;
584
585 bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth ) const override;
586
587 bool IsConnectable() const override { return true; }
588
589 std::vector<int> ViewGetLayers() const override;
590
591 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
592
593 BITMAPS GetMenuImage() const override;
594
595 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
596 {
597 return m_isDangling && GetPosition() == aPos;
598 }
599
600 bool AutoRotateOnPlacementSupported() const override { return true; }
601
602private:
603 bool doIsConnected( const VECTOR2I& aPosition ) const override
604 {
605 return EDA_TEXT::GetTextPos() == aPosition;
606 }
607};
608
609
611{
612public:
613 SCH_HIERLABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ), const wxString& aText = wxEmptyString,
614 KICAD_T aType = SCH_HIER_LABEL_T );
615
616 // Do not create a copy constructor. The one generated by the compiler is adequate.
617
618 ~SCH_HIERLABEL() override = default;
619
620 void Serialize( google::protobuf::Any &aContainer ) const override;
621 bool Deserialize( const google::protobuf::Any &aContainer ) override;
622
623 static inline bool ClassOf( const EDA_ITEM* aItem )
624 {
625 return aItem && SCH_HIER_LABEL_T == aItem->Type();
626 }
627
628 wxString GetFriendlyName() const override
629 {
630 return _( "Hierarchical Label" );
631 }
632
633 wxString GetClass() const override
634 {
635 return wxT( "SCH_HIERLABEL" );
636 }
637
638 void SetSpinStyle( SPIN_STYLE aSpinStyle ) override;
639
640 VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
641
642 void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector<VECTOR2I>& aPoints,
643 const VECTOR2I& aPos ) const override;
644 void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector<VECTOR2I>& aPoints,
645 const VECTOR2I& aPos, LABEL_FLAG_SHAPE aShape ) const;
646
647 const BOX2I GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const override;
648
649 bool IsConnectable() const override { return true; }
650
651 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
652
653 BITMAPS GetMenuImage() const override;
654
655 EDA_ITEM* Clone() const override
656 {
657 return new SCH_HIERLABEL( *this );
658 }
659
660 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
661 {
662 return m_isDangling && GetPosition() == aPos;
663 }
664
665 bool AutoRotateOnPlacementSupported() const override { return true; }
666
667private:
668 bool doIsConnected( const VECTOR2I& aPosition ) const override
669 {
670 return EDA_TEXT::GetTextPos() == aPosition;
671 }
672};
673
674#endif /* SCH_LABEL_H */
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
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:100
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:112
const VECTOR2I & GetTextPos() const
Definition eda_text.h:298
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:114
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:105
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:89
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:470
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:498
static bool ClassOf(const EDA_ITEM *aItem)
Definition sch_label.h:460
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:482
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:531
~SCH_DIRECTIVE_LABEL() override
bool operator==(const SCH_ITEM &aOther) const override
bool AutoRotateOnPlacementSupported() const override
Definition sch_label.h:500
wxString GetClass() const override
Return the class name.
Definition sch_label.h:465
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
void SetPinLength(int aLength)
Definition sch_label.h:486
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:475
void SetFlagShape(FLAG_SHAPE aShape)
Definition sch_label.h:483
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:485
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:587
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:548
int GetMandatoryFieldCount() override
Definition sch_label.h:568
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
Definition sch_label.h:603
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:558
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:600
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition sch_label.h:563
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
Definition sch_label.h:595
wxString GetClass() const override
Return the class name.
Definition sch_label.h:553
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:668
static bool ClassOf(const EDA_ITEM *aItem)
Definition sch_label.h:623
wxString GetClass() const override
Return the class name.
Definition sch_label.h:633
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:655
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:660
bool IsConnectable() const override
Definition sch_label.h:649
wxString GetFriendlyName() const override
Definition sch_label.h:628
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:665
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:168
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:272
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition sch_item.h:344
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:56
bool operator==(const SCH_ITEM &aItem) const override
void SetLastResolvedState(const SCH_ITEM *aItem) override
Definition sch_label.h:197
const wxString & GetCachedDriverName() const override
SCH_LABEL_BASE(const VECTOR2I &aPos, const wxString &aText, KICAD_T aType)
COLOR4D m_lastResolvedColor
Definition sch_label.h:385
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:227
void SetFields(const std::vector< SCH_FIELD > &aFields)
Set multiple schematic fields.
Definition sch_label.h:222
void SetIsDangling(bool aIsDangling)
Definition sch_label.h:340
void AddField(const SCH_FIELD &aField)
Definition sch_label.h:232
bool IsDangling() const override
Definition sch_label.h:339
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:215
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:377
CONNECTION_TYPE m_connectionType
Definition sch_label.h:381
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:280
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:183
LABEL_FLAG_SHAPE GetShape() const
Definition sch_label.h:182
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:150
LABEL_SHAPE GetLabelShape() const
Definition sch_label.h:179
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode) override
bool m_autoRotateOnPlacement
Definition sch_label.h:383
wxString m_cached_driver_name
Definition sch_label.h:387
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:212
LABEL_FLAG_SHAPE m_shape
Definition sch_label.h:379
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:309
std::vector< SCH_FIELD > & GetFields()
Definition sch_label.h:214
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:438
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:408
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:441
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:428
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
Definition sch_label.h:433
wxString GetFriendlyName() const override
Definition sch_label.h:413
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:426
static bool ClassOf(const EDA_ITEM *aItem)
Definition sch_label.h:403
bool IsConnectable() const override
Definition sch_label.h:420
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:150
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:59
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:54
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:73
SPIN m_spin
Definition sch_label.h:93
SPIN_STYLE()=default
constexpr bool operator!=(SPIN a) const
Definition sch_label.h:63
constexpr bool operator==(SPIN a) const
Definition sch_label.h:58
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:52
INSPECT_RESULT
Definition eda_item.h:46
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition eda_item.h:93
@ LAYER_WIRE
Definition layer_ids.h:454
@ LAYER_BUS
Definition layer_ids.h:455
CONNECTION_TYPE
AUTOPLACE_ALGO
Definition sch_item.h:69
FLAG_SHAPE
Definition sch_label.h:128
@ FLAG_CIRCLE
Definition sch_label.h:130
@ FLAG_RECTANGLE
Definition sch_label.h:132
@ FLAG_DOT
Definition sch_label.h:129
@ FLAG_DIAMOND
Definition sch_label.h:131
LABEL_FLAG_SHAPE
Definition sch_label.h:101
@ L_BIDI
Definition sch_label.h:104
@ L_TRISTATE
Definition sch_label.h:105
@ L_UNSPECIFIED
Definition sch_label.h:106
@ F_DOT
Definition sch_label.h:109
@ F_ROUND
Definition sch_label.h:110
@ F_FIRST
Definition sch_label.h:108
@ L_OUTPUT
Definition sch_label.h:103
@ F_DIAMOND
Definition sch_label.h:111
@ L_INPUT
Definition sch_label.h:102
@ F_RECTANGLE
Definition sch_label.h:112
LABEL_SHAPE
Definition sch_label.h:119
@ LABEL_BIDI
Definition sch_label.h:122
@ LABEL_INPUT
Definition sch_label.h:120
@ LABEL_OUTPUT
Definition sch_label.h:121
@ LABEL_PASSIVE
Definition sch_label.h:124
@ LABEL_TRISTATE
Definition sch_label.h:123
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:75
@ SCH_LINE_T
Definition typeinfo.h:164
@ SCH_SYMBOL_T
Definition typeinfo.h:173
@ SCH_DIRECTIVE_LABEL_T
Definition typeinfo.h:172
@ SCH_LABEL_T
Definition typeinfo.h:168
@ SCH_HIER_LABEL_T
Definition typeinfo.h:170
@ SCH_SHEET_PIN_T
Definition typeinfo.h:175
@ SCH_BUS_WIRE_ENTRY_T
Definition typeinfo.h:162
@ SCH_GLOBAL_LABEL_T
Definition typeinfo.h:169
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687