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
74
79
84
88 unsigned CCWRotationsTo( const SPIN_STYLE& aOther ) const;
89
90private:
92};
93
94
95/*
96 * Label and flag shapes used with text objects.
97 */
112
113/*
114 * Specific enums for property manager (not used elsewhere)
115 */
124
132
133
135{
136public:
137 SCH_LABEL_BASE( const VECTOR2I& aPos, const wxString& aText, KICAD_T aType );
138
139 SCH_LABEL_BASE( const SCH_LABEL_BASE& aLabel );
140
141 SCH_LABEL_BASE& operator=( const SCH_LABEL_BASE& aLabel );
142
143 // Abstract class
144 virtual wxString GetClass() const override = 0;
145
146 bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override;
147
148 bool CanConnect( const SCH_ITEM* aItem ) const override
149 {
150 switch( aItem->Type() )
151 {
152 case SCH_LINE_T:
153 return aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS;
154
156 return true;
157
158 case SCH_SYMBOL_T:
159 return true;
160
161 case SCH_LABEL_T:
163 case SCH_HIER_LABEL_T:
165 case SCH_SHEET_PIN_T:
166 return true;
167
168 default:
169 return false;
170 }
171 }
172
173 bool HasConnectivityChanges( const SCH_ITEM* aItem,
174 const SCH_SHEET_PATH* aInstance = nullptr ) const override;
175
176 // Type-specific versions for property manager
178 void SetLabelShape( LABEL_SHAPE aShape );
179
182 {
183 // Set flags directly if a flag shape
184 if( aShape >= F_FIRST )
185 m_shape = aShape;
186 else
187 SetLabelShape( (LABEL_SHAPE) aShape );
188 }
189
190 COLOR4D GetLabelColor() const;
191
192 virtual void SetSpinStyle( SPIN_STYLE aSpinStyle );
193 SPIN_STYLE GetSpinStyle() const;
194
195 void SetLastResolvedState( const SCH_ITEM* aItem ) override
196 {
197 const SCH_LABEL_BASE* aLabel = dynamic_cast<const SCH_LABEL_BASE*>( aItem );
198
199 if( aLabel )
201 }
202
203 static const wxString GetDefaultFieldName( const wxString& aName, bool aUseDefaultName );
204
208 int GetNextFieldOrdinal() const;
209
210 virtual int GetMandatoryFieldCount() { return 0; }
211
212 std::vector<SCH_FIELD>& GetFields() { return m_fields; }
213 const std::vector<SCH_FIELD>& GetFields() const { return m_fields; }
214
220 void SetFields( const std::vector<SCH_FIELD>& aFields )
221 {
222 m_fields = aFields; // vector copying, length is changed possibly
223 }
224
225 void AddFields( const std::vector<SCH_FIELD>& aFields )
226 {
227 m_fields.insert( m_fields.end(), aFields.begin(), aFields.end() );
228 }
229
230 void AddField( const SCH_FIELD& aField )
231 {
232 m_fields.push_back( aField );
233 }
234
240 bool IncrementLabel( int aIncrement );
241
242 void Move( const VECTOR2I& aMoveVector ) override;
243 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
244 void Rotate90( bool aClockwise ) override;
245
246 void MirrorSpinStyle( bool aLeftRight ) override;
247
248 void MirrorHorizontally( int aCenter ) override;
249 void MirrorVertically( int aCenter ) override;
250
251 void SetPosition( const VECTOR2I& aPosition ) override;
252
253 void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
254
260 void GetIntersheetRefs( const SCH_SHEET_PATH* aPath,
261 std::vector<std::pair<wxString, wxString>>* pages );
262
266 void GetContextualTextVars( wxArrayString* aVars ) const;
267
273 virtual bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth ) const;
274
275 wxString GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
276 int aDepth = 0 ) const override;
277
278 wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override
279 {
280 SCHEMATIC* schematic = Schematic();
281
282 if( schematic )
283 return GetShownText( &schematic->CurrentSheet(), aAllowExtraText, aDepth );
284 else
285 return GetText();
286 }
287
288 bool HasCachedDriverName() const override;
289 const wxString& GetCachedDriverName() const override;
290
291 void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction, RECURSE_MODE aMode ) override;
292
293 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
294 const std::vector<KICAD_T>& scanTypes ) override;
295
296 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
297 bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override;
298
299 VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
300
307 virtual void CreateGraphicShape( const RENDER_SETTINGS* aSettings,
308 std::vector<VECTOR2I>& aPoints, const VECTOR2I& Pos ) const
309 {
310 aPoints.clear();
311 }
312
313 int GetLabelBoxExpansion( const RENDER_SETTINGS* aSettings = nullptr ) const;
314
318 virtual const BOX2I GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const;
319
323 const BOX2I GetBoundingBox() const override;
324
325 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
326 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
327 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
328
329 std::vector<VECTOR2I> GetConnectionPoints() const override;
330
331 void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
332
333 bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
334 std::vector<DANGLING_END_ITEM>& aItemListByPos,
335 const SCH_SHEET_PATH* aPath = nullptr ) override;
336
337 bool IsDangling() const override { return m_isDangling; }
338 void SetIsDangling( bool aIsDangling ) { m_isDangling = aIsDangling; }
339
340 std::vector<int> ViewGetLayers() const override;
341
342 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
343
344 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
345 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
346
351 bool AutoRotateOnPlacement() const;
352
357 void SetAutoRotateOnPlacement( bool autoRotate = true );
358
363 virtual bool AutoRotateOnPlacementSupported() const = 0;
364
365 double Similarity( const SCH_ITEM& aItem ) const override;
366
367 bool operator==( const SCH_ITEM& aItem ) const override;
368
369protected:
370 void swapData( SCH_ITEM* aItem ) override;
371
372 void cacheShownText() override;
373
374protected:
375 std::vector<SCH_FIELD> m_fields;
376
378
382
384
386};
387
388
390{
391public:
392 SCH_LABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ), const wxString& aText = wxEmptyString );
393
394 // Do not create a copy constructor. The one generated by the compiler is adequate.
395
397
398 void Serialize( google::protobuf::Any &aContainer ) const override;
399 bool Deserialize( const google::protobuf::Any &aContainer ) override;
400
401 static inline bool ClassOf( const EDA_ITEM* aItem )
402 {
403 return aItem && SCH_LABEL_T == aItem->Type();
404 }
405
406 wxString GetClass() const override
407 {
408 return wxT( "SCH_LABEL" );
409 }
410
411 const BOX2I GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const override;
412
413 bool IsConnectable() const override { return true; }
414
415 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
416
417 BITMAPS GetMenuImage() const override;
418
419 bool IsReplaceable() const override { return true; }
420
421 EDA_ITEM* Clone() const override
422 {
423 return new SCH_LABEL( *this );
424 }
425
426 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
427 {
428 return m_isDangling && GetPosition() == aPos;
429 }
430
431 bool AutoRotateOnPlacementSupported() const override { return false; }
432
433private:
434 bool doIsConnected( const VECTOR2I& aPosition ) const override
435 {
436 return EDA_TEXT::GetTextPos() == aPosition;
437 }
438};
439
440
442{
443public:
444 SCH_DIRECTIVE_LABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ) );
445
446 SCH_DIRECTIVE_LABEL( const SCH_DIRECTIVE_LABEL& aClassLabel );
447
449
450 void Serialize( google::protobuf::Any &aContainer ) const override;
451 bool Deserialize( const google::protobuf::Any &aContainer ) override;
452
453 static inline bool ClassOf( const EDA_ITEM* aItem )
454 {
455 return aItem && SCH_DIRECTIVE_LABEL_T == aItem->Type();
456 }
457
458 wxString GetClass() const override
459 {
460 return wxT( "SCH_DIRECTIVE_LABEL" );
461 }
462
463 EDA_ITEM* Clone() const override
464 {
465 return new SCH_DIRECTIVE_LABEL( *this );
466 }
467
468 void swapData( SCH_ITEM* aItem ) override;
469
471 void SetFlagShape( FLAG_SHAPE aShape ) { m_shape = (LABEL_FLAG_SHAPE) aShape; }
472
473 int GetPinLength() const { return m_pinLength; }
474 void SetPinLength( int aLength ) { m_pinLength = aLength; }
475
476 int GetPenWidth() const override;
477
478 void CreateGraphicShape( const RENDER_SETTINGS* aSettings,
479 std::vector<VECTOR2I>& aPoints,
480 const VECTOR2I& aPos ) const override;
481
482 void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
483
484 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
485
486 bool IsConnectable() const override { return true; }
487
488 bool AutoRotateOnPlacementSupported() const override { return false; }
489
490 void MirrorSpinStyle( bool aLeftRight ) override;
491
492 void MirrorHorizontally( int aCenter ) override;
493 void MirrorVertically( int aCenter ) override;
494
496 void AddConnectedRuleArea( SCH_RULE_AREA* aRuleArea );
497
500
502 void RemoveConnectedRuleArea( SCH_RULE_AREA* aRuleArea );
503
504 const std::unordered_set<SCH_RULE_AREA*> GetConnectedRuleAreas() const;
505
507 virtual bool IsDangling() const override;
508
509private:
512
514 std::unordered_set<SCH_RULE_AREA*> m_connected_rule_areas;
515};
516
517
519{
520public:
521 SCH_GLOBALLABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ),
522 const wxString& aText = wxEmptyString );
523
524 SCH_GLOBALLABEL( const SCH_GLOBALLABEL& aGlobalLabel );
525
527
528 void Serialize( google::protobuf::Any &aContainer ) const override;
529 bool Deserialize( const google::protobuf::Any &aContainer ) override;
530
531 static inline bool ClassOf( const EDA_ITEM* aItem )
532 {
533 return aItem && SCH_GLOBAL_LABEL_T == aItem->Type();
534 }
535
536 wxString GetClass() const override
537 {
538 return wxT( "SCH_GLOBALLABEL" );
539 }
540
541 EDA_ITEM* Clone() const override
542 {
543 return new SCH_GLOBALLABEL( *this );
544 }
545
546 int GetMandatoryFieldCount() override { return 1; }
547
552 SCH_FIELD* GetField( FIELD_T aFieldType );
553 const SCH_FIELD* GetField( FIELD_T aFieldNdx ) const;
554
555 void SetSpinStyle( SPIN_STYLE aSpinStyle ) override;
556
557 VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
558
559 void CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings,
560 std::vector<VECTOR2I>& aPoints,
561 const VECTOR2I& aPos ) const override;
562
563 bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth ) const override;
564
565 bool IsConnectable() const override { return true; }
566
567 std::vector<int> ViewGetLayers() const override;
568
569 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
570
571 BITMAPS GetMenuImage() const override;
572
573 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
574 {
575 return m_isDangling && GetPosition() == aPos;
576 }
577
578 bool AutoRotateOnPlacementSupported() const override { return true; }
579
580private:
581 bool doIsConnected( const VECTOR2I& aPosition ) const override
582 {
583 return EDA_TEXT::GetTextPos() == aPosition;
584 }
585};
586
587
589{
590public:
591 SCH_HIERLABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ), const wxString& aText = wxEmptyString,
592 KICAD_T aType = SCH_HIER_LABEL_T );
593
594 // Do not create a copy constructor. The one generated by the compiler is adequate.
595
596 ~SCH_HIERLABEL() override = default;
597
598 void Serialize( google::protobuf::Any &aContainer ) const override;
599 bool Deserialize( const google::protobuf::Any &aContainer ) override;
600
601 static inline bool ClassOf( const EDA_ITEM* aItem )
602 {
603 return aItem && SCH_HIER_LABEL_T == aItem->Type();
604 }
605
606 wxString GetClass() const override
607 {
608 return wxT( "SCH_HIERLABEL" );
609 }
610
611 void SetSpinStyle( SPIN_STYLE aSpinStyle ) override;
612
613 VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
614
615 void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector<VECTOR2I>& aPoints,
616 const VECTOR2I& aPos ) const override;
617 void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector<VECTOR2I>& aPoints,
618 const VECTOR2I& aPos, LABEL_FLAG_SHAPE aShape ) const;
619
620 const BOX2I GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const override;
621
622 bool IsConnectable() const override { return true; }
623
624 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
625
626 BITMAPS GetMenuImage() const override;
627
628 EDA_ITEM* Clone() const override
629 {
630 return new SCH_HIERLABEL( *this );
631 }
632
633 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
634 {
635 return m_isDangling && GetPosition() == aPos;
636 }
637
638 bool AutoRotateOnPlacementSupported() const override { return true; }
639
640private:
641 bool doIsConnected( const VECTOR2I& aPosition ) const override
642 {
643 return EDA_TEXT::GetTextPos() == aPosition;
644 }
645};
646
647#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:98
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
const VECTOR2I & GetTextPos() const
Definition eda_text.h:272
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:97
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:104
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
Base plotter engine class.
Definition plotter.h:121
Holds all the data relating to one schematic.
Definition schematic.h:88
SCH_SHEET_PATH & CurrentSheet() const
Definition schematic.h:171
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void MirrorSpinStyle(bool aLeftRight) override
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:486
static bool ClassOf(const EDA_ITEM *aItem)
Definition sch_label.h:453
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void CreateGraphicShape(const RENDER_SETTINGS *aSettings, std::vector< VECTOR2I > &aPoints, const VECTOR2I &aPos) const override
Calculate the graphic shape (a polygon) associated to the text.
FLAG_SHAPE GetFlagShape() const
Definition sch_label.h:470
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:514
bool AutoRotateOnPlacementSupported() const override
Definition sch_label.h:488
wxString GetClass() const override
Return the class name.
Definition sch_label.h:458
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
void SetPinLength(int aLength)
Definition sch_label.h:474
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:463
void SetFlagShape(FLAG_SHAPE aShape)
Definition sch_label.h:471
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
const std::unordered_set< SCH_RULE_AREA * > GetConnectedRuleAreas() const
int GetPinLength() const
Definition sch_label.h:473
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:565
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:531
int GetMandatoryFieldCount() override
Definition sch_label.h:546
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
Definition sch_label.h:581
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.
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:578
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition sch_label.h:541
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
Definition sch_label.h:573
wxString GetClass() const override
Return the class name.
Definition sch_label.h:536
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:641
static bool ClassOf(const EDA_ITEM *aItem)
Definition sch_label.h:601
wxString GetClass() const override
Return the class name.
Definition sch_label.h:606
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:628
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:633
bool IsConnectable() const override
Definition sch_label.h:622
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:638
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:167
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:217
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition sch_item.h:309
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:51
bool operator==(const SCH_ITEM &aItem) const override
void SetLastResolvedState(const SCH_ITEM *aItem) override
Definition sch_label.h:195
const wxString & GetCachedDriverName() const override
SCH_LABEL_BASE(const VECTOR2I &aPos, const wxString &aText, KICAD_T aType)
COLOR4D m_lastResolvedColor
Definition sch_label.h:383
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:225
void SetFields(const std::vector< SCH_FIELD > &aFields)
Set multiple schematic fields.
Definition sch_label.h:220
void SetIsDangling(bool aIsDangling)
Definition sch_label.h:338
void AddField(const SCH_FIELD &aField)
Definition sch_label.h:230
bool IsDangling() const override
Definition sch_label.h:337
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:213
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:375
CONNECTION_TYPE m_connectionType
Definition sch_label.h:379
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:278
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:181
LABEL_FLAG_SHAPE GetShape() const
Definition sch_label.h:180
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:148
LABEL_SHAPE GetLabelShape() const
Definition sch_label.h:177
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode) override
bool m_autoRotateOnPlacement
Definition sch_label.h:381
wxString m_cached_driver_name
Definition sch_label.h:385
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
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:210
LABEL_FLAG_SHAPE m_shape
Definition sch_label.h:377
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:307
std::vector< SCH_FIELD > & GetFields()
Definition sch_label.h:212
virtual wxString GetClass() const override=0
Return the class name.
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemListByType, std::vector< DANGLING_END_ITEM > &aItemListByPos, const SCH_SHEET_PATH *aPath=nullptr) override
Test the schematic item to aItemList to check if it's dangling state has changed.
VECTOR2I GetSchematicTextOffset(const RENDER_SETTINGS *aSettings) const override
This offset depends on the orientation, the type of text, and the area required to draw the associate...
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
bool Replace(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) override
Perform a text replace using the find and replace criteria in aSearchData on items that support text ...
double Similarity(const SCH_ITEM &aItem) const override
Return a measure of how likely the other object is to represent the same object.
bool AutoRotateOnPlacementSupported() const override
Definition sch_label.h:431
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
wxString GetClass() const override
Return the class name.
Definition sch_label.h:406
const BOX2I GetBodyBoundingBox(const RENDER_SETTINGS *aSettings) const override
Return the bounding box of the label only, without taking in account its fields.
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
Definition sch_label.h:434
SCH_LABEL(const VECTOR2I &aPos=VECTOR2I(0, 0), const wxString &aText=wxEmptyString)
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition sch_label.h:421
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
Definition sch_label.h:426
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
Definition sch_label.h:419
static bool ClassOf(const EDA_ITEM *aItem)
Definition sch_label.h:401
bool IsConnectable() const override
Definition sch_label.h:413
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
VECTOR2I GetPosition() const override
Definition sch_text.h:141
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:51
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 m_spin
Definition sch_label.h:91
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()
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:451
@ LAYER_BUS
Definition layer_ids.h:452
CONNECTION_TYPE
AUTOPLACE_ALGO
Definition sch_item.h:68
FLAG_SHAPE
Definition sch_label.h:126
@ FLAG_CIRCLE
Definition sch_label.h:128
@ FLAG_RECTANGLE
Definition sch_label.h:130
@ FLAG_DOT
Definition sch_label.h:127
@ FLAG_DIAMOND
Definition sch_label.h:129
LABEL_FLAG_SHAPE
Definition sch_label.h:99
@ L_BIDI
Definition sch_label.h:102
@ L_TRISTATE
Definition sch_label.h:103
@ L_UNSPECIFIED
Definition sch_label.h:104
@ F_DOT
Definition sch_label.h:107
@ F_ROUND
Definition sch_label.h:108
@ F_FIRST
Definition sch_label.h:106
@ L_OUTPUT
Definition sch_label.h:101
@ F_DIAMOND
Definition sch_label.h:109
@ L_INPUT
Definition sch_label.h:100
@ F_RECTANGLE
Definition sch_label.h:110
LABEL_SHAPE
Definition sch_label.h:117
@ LABEL_BIDI
Definition sch_label.h:120
@ LABEL_INPUT
Definition sch_label.h:118
@ LABEL_OUTPUT
Definition sch_label.h:119
@ LABEL_PASSIVE
Definition sch_label.h:122
@ LABEL_TRISTATE
Definition sch_label.h:121
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:78
@ SCH_LINE_T
Definition typeinfo.h:165
@ SCH_SYMBOL_T
Definition typeinfo.h:174
@ SCH_DIRECTIVE_LABEL_T
Definition typeinfo.h:173
@ SCH_LABEL_T
Definition typeinfo.h:169
@ SCH_HIER_LABEL_T
Definition typeinfo.h:171
@ SCH_SHEET_PIN_T
Definition typeinfo.h:176
@ SCH_BUS_WIRE_ENTRY_T
Definition typeinfo.h:163
@ SCH_GLOBAL_LABEL_T
Definition typeinfo.h:170
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695