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,
49 BOTTOM = 3
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 */
98enum LABEL_FLAG_SHAPE : unsigned int
99{
105
112
113/*
114 * Specific enums for property manager (not used elsewhere)
115 */
116enum LABEL_SHAPE : unsigned int
117{
124
125enum FLAG_SHAPE : unsigned int
126{
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
177 void SetShape( LABEL_FLAG_SHAPE aShape ) { m_shape = aShape; }
178
179 // Type-specific versions for property manager
181 void SetLabelShape( LABEL_SHAPE aShape ) { m_shape = (LABEL_FLAG_SHAPE) aShape; }
182
183 COLOR4D GetLabelColor() const;
184
185 virtual void SetSpinStyle( SPIN_STYLE aSpinStyle );
186 SPIN_STYLE GetSpinStyle() const;
187
188 void SetLastResolvedState( const SCH_ITEM* aItem ) override
189 {
190 const SCH_LABEL_BASE* aLabel = dynamic_cast<const SCH_LABEL_BASE*>( aItem );
191
192 if( aLabel )
194 }
195
196 static const wxString GetDefaultFieldName( const wxString& aName, bool aUseDefaultName );
197
201 int GetNextFieldOrdinal() const;
202
203 virtual int GetMandatoryFieldCount() { return 0; }
204
205 std::vector<SCH_FIELD>& GetFields() { return m_fields; }
206 const std::vector<SCH_FIELD>& GetFields() const { return m_fields; }
207
213 void SetFields( const std::vector<SCH_FIELD>& aFields )
214 {
215 m_fields = aFields; // vector copying, length is changed possibly
216 }
217
218 void AddFields( const std::vector<SCH_FIELD>& aFields )
219 {
220 m_fields.insert( m_fields.end(), aFields.begin(), aFields.end() );
221 }
222
223 void AddField( const SCH_FIELD& aField )
224 {
225 m_fields.push_back( aField );
226 }
227
233 bool IncrementLabel( int aIncrement );
234
235 void Move( const VECTOR2I& aMoveVector ) override;
236 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
237 void Rotate90( bool aClockwise ) override;
238
239 void MirrorSpinStyle( bool aLeftRight ) override;
240
241 void MirrorHorizontally( int aCenter ) override;
242 void MirrorVertically( int aCenter ) override;
243
244 void SetPosition( const VECTOR2I& aPosition ) override;
245
246 void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
247
253 void GetIntersheetRefs( const SCH_SHEET_PATH* aPath,
254 std::vector<std::pair<wxString, wxString>>* pages );
255
259 void GetContextualTextVars( wxArrayString* aVars ) const;
260
266 virtual bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth ) const;
267
268 wxString GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
269 int aDepth = 0 ) const override;
270
271 wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override
272 {
273 SCHEMATIC* schematic = Schematic();
274
275 if( schematic )
276 return GetShownText( &schematic->CurrentSheet(), aAllowExtraText, aDepth );
277 else
278 return GetText();
279 }
280
281 bool HasCachedDriverName() const override;
282 const wxString& GetCachedDriverName() const override;
283
284 void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction, RECURSE_MODE aMode ) override;
285
286 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
287 const std::vector<KICAD_T>& scanTypes ) override;
288
289 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
290 bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override;
291
292 VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
293
300 virtual void CreateGraphicShape( const RENDER_SETTINGS* aSettings,
301 std::vector<VECTOR2I>& aPoints, const VECTOR2I& Pos ) const
302 {
303 aPoints.clear();
304 }
305
306 int GetLabelBoxExpansion( const RENDER_SETTINGS* aSettings = nullptr ) const;
307
311 virtual const BOX2I GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const;
312
316 const BOX2I GetBoundingBox() const override;
317
318 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
319 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
320
321 std::vector<VECTOR2I> GetConnectionPoints() const override;
322
323 void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
324
325 bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
326 std::vector<DANGLING_END_ITEM>& aItemListByPos,
327 const SCH_SHEET_PATH* aPath = nullptr ) override;
328
329 bool IsDangling() const override { return m_isDangling; }
330 void SetIsDangling( bool aIsDangling ) { m_isDangling = aIsDangling; }
331
332 std::vector<int> ViewGetLayers() const override;
333
334 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
335
336 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
337 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
338
343 bool AutoRotateOnPlacement() const;
344
349 void SetAutoRotateOnPlacement( bool autoRotate = true );
350
355 virtual bool AutoRotateOnPlacementSupported() const = 0;
356
357 double Similarity( const SCH_ITEM& aItem ) const override;
358
359 bool operator==( const SCH_ITEM& aItem ) const override;
360
361protected:
362 void swapData( SCH_ITEM* aItem ) override;
363
364 void cacheShownText() override;
365
366protected:
367 std::vector<SCH_FIELD> m_fields;
368
370
374
376
378};
379
380
382{
383public:
384 SCH_LABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ), const wxString& aText = wxEmptyString );
385
386 // Do not create a copy constructor. The one generated by the compiler is adequate.
387
389
390 void Serialize( google::protobuf::Any &aContainer ) const override;
391 bool Deserialize( const google::protobuf::Any &aContainer ) override;
392
393 static inline bool ClassOf( const EDA_ITEM* aItem )
394 {
395 return aItem && SCH_LABEL_T == aItem->Type();
396 }
397
398 wxString GetClass() const override
399 {
400 return wxT( "SCH_LABEL" );
401 }
402
403 const BOX2I GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const override;
404
405 bool IsConnectable() const override { return true; }
406
407 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
408
409 BITMAPS GetMenuImage() const override;
410
411 bool IsReplaceable() const override { return true; }
412
413 EDA_ITEM* Clone() const override
414 {
415 return new SCH_LABEL( *this );
416 }
417
418 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
419 {
420 return m_isDangling && GetPosition() == aPos;
421 }
422
423 bool AutoRotateOnPlacementSupported() const override { return false; }
424
425private:
426 bool doIsConnected( const VECTOR2I& aPosition ) const override
427 {
428 return EDA_TEXT::GetTextPos() == aPosition;
429 }
430};
431
432
434{
435public:
436 SCH_DIRECTIVE_LABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ) );
437
438 SCH_DIRECTIVE_LABEL( const SCH_DIRECTIVE_LABEL& aClassLabel );
439
441
442 void Serialize( google::protobuf::Any &aContainer ) const override;
443 bool Deserialize( const google::protobuf::Any &aContainer ) override;
444
445 static inline bool ClassOf( const EDA_ITEM* aItem )
446 {
447 return aItem && SCH_DIRECTIVE_LABEL_T == aItem->Type();
448 }
449
450 wxString GetClass() const override
451 {
452 return wxT( "SCH_DIRECTIVE_LABEL" );
453 }
454
455 EDA_ITEM* Clone() const override
456 {
457 return new SCH_DIRECTIVE_LABEL( *this );
458 }
459
460 void swapData( SCH_ITEM* aItem ) override;
461
463 void SetFlagShape( FLAG_SHAPE aShape ) { m_shape = (LABEL_FLAG_SHAPE) aShape; }
464
465 int GetPinLength() const { return m_pinLength; }
466 void SetPinLength( int aLength ) { m_pinLength = aLength; }
467
468 int GetPenWidth() const override;
469
470 void CreateGraphicShape( const RENDER_SETTINGS* aSettings,
471 std::vector<VECTOR2I>& aPoints,
472 const VECTOR2I& aPos ) const override;
473
474 void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
475
476 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
477
478 bool IsConnectable() const override { return true; }
479
480 bool AutoRotateOnPlacementSupported() const override { return false; }
481
482 void MirrorSpinStyle( bool aLeftRight ) override;
483
484 void MirrorHorizontally( int aCenter ) override;
485 void MirrorVertically( int aCenter ) override;
486
488 void AddConnectedRuleArea( SCH_RULE_AREA* aRuleArea );
489
492
494 void RemoveConnectedRuleArea( SCH_RULE_AREA* aRuleArea );
495
496 const std::unordered_set<SCH_RULE_AREA*> GetConnectedRuleAreas() const;
497
499 virtual bool IsDangling() const override;
500
501private:
504
506 std::unordered_set<SCH_RULE_AREA*> m_connected_rule_areas;
507};
508
509
511{
512public:
513 SCH_GLOBALLABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ),
514 const wxString& aText = wxEmptyString );
515
516 SCH_GLOBALLABEL( const SCH_GLOBALLABEL& aGlobalLabel );
517
519
520 void Serialize( google::protobuf::Any &aContainer ) const override;
521 bool Deserialize( const google::protobuf::Any &aContainer ) override;
522
523 static inline bool ClassOf( const EDA_ITEM* aItem )
524 {
525 return aItem && SCH_GLOBAL_LABEL_T == aItem->Type();
526 }
527
528 wxString GetClass() const override
529 {
530 return wxT( "SCH_GLOBALLABEL" );
531 }
532
533 EDA_ITEM* Clone() const override
534 {
535 return new SCH_GLOBALLABEL( *this );
536 }
537
538 int GetMandatoryFieldCount() override { return 1; }
539
544 SCH_FIELD* GetField( FIELD_T aFieldType );
545 const SCH_FIELD* GetField( FIELD_T aFieldNdx ) const;
546
547 void SetSpinStyle( SPIN_STYLE aSpinStyle ) override;
548
549 VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
550
551 void CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings,
552 std::vector<VECTOR2I>& aPoints,
553 const VECTOR2I& aPos ) const override;
554
555 bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth ) const override;
556
557 bool IsConnectable() const override { return true; }
558
559 std::vector<int> ViewGetLayers() const override;
560
561 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
562
563 BITMAPS GetMenuImage() const override;
564
565 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
566 {
567 return m_isDangling && GetPosition() == aPos;
568 }
569
570 bool AutoRotateOnPlacementSupported() const override { return true; }
571
572private:
573 bool doIsConnected( const VECTOR2I& aPosition ) const override
574 {
575 return EDA_TEXT::GetTextPos() == aPosition;
576 }
577};
578
579
581{
582public:
583 SCH_HIERLABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ), const wxString& aText = wxEmptyString,
584 KICAD_T aType = SCH_HIER_LABEL_T );
585
586 // Do not create a copy constructor. The one generated by the compiler is adequate.
587
588 ~SCH_HIERLABEL() override = default;
589
590 void Serialize( google::protobuf::Any &aContainer ) const override;
591 bool Deserialize( const google::protobuf::Any &aContainer ) override;
592
593 static inline bool ClassOf( const EDA_ITEM* aItem )
594 {
595 return aItem && SCH_HIER_LABEL_T == aItem->Type();
596 }
597
598 wxString GetClass() const override
599 {
600 return wxT( "SCH_HIERLABEL" );
601 }
602
603 void SetSpinStyle( SPIN_STYLE aSpinStyle ) override;
604
605 VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
606
607 void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector<VECTOR2I>& aPoints,
608 const VECTOR2I& aPos ) const override;
609 void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector<VECTOR2I>& aPoints,
610 const VECTOR2I& aPos, LABEL_FLAG_SHAPE aShape ) const;
611
612 const BOX2I GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const override;
613
614 bool IsConnectable() const override { return true; }
615
616 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
617
618 BITMAPS GetMenuImage() const override;
619
620 EDA_ITEM* Clone() const override
621 {
622 return new SCH_HIERLABEL( *this );
623 }
624
625 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
626 {
627 return m_isDangling && GetPosition() == aPos;
628 }
629
630 bool AutoRotateOnPlacementSupported() const override { return true; }
631
632private:
633 bool doIsConnected( const VECTOR2I& aPosition ) const override
634 {
635 return EDA_TEXT::GetTextPos() == aPosition;
636 }
637};
638
639#endif /* SCH_LABEL_H */
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
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:270
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.
Definition: sch_label.cpp:1590
void MirrorSpinStyle(bool aLeftRight) override
Definition: sch_label.cpp:1614
void RemoveConnectedRuleArea(SCH_RULE_AREA *aRuleArea)
Removes a specific rule area from the cache.
Definition: sch_label.cpp:1847
void ClearConnectedRuleAreas()
Removes all rule areas from the cache.
Definition: sch_label.cpp:1841
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_label.cpp:1673
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_label.cpp:1645
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: sch_label.cpp:1819
bool IsConnectable() const override
Definition: sch_label.h:478
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_label.h:445
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: sch_label.cpp:1596
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.
Definition: sch_label.cpp:1695
FLAG_SHAPE GetFlagShape() const
Definition: sch_label.h:462
int GetPenWidth() const override
Definition: sch_label.cpp:1603
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:506
bool AutoRotateOnPlacementSupported() const override
Definition: sch_label.h:480
wxString GetClass() const override
Return the class name.
Definition: sch_label.h:450
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_label.cpp:1571
void SetPinLength(int aLength)
Definition: sch_label.h:466
virtual bool IsDangling() const override
Determines dangling state from connectivity and cached connected rule areas.
Definition: sch_label.cpp:1859
void AddConnectedRuleArea(SCH_RULE_AREA *aRuleArea)
Adds an entry to the connected rule area cache.
Definition: sch_label.cpp:1835
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_label.h:455
void SetFlagShape(FLAG_SHAPE aShape)
Definition: sch_label.h:463
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
Definition: sch_label.cpp:1765
const std::unordered_set< SCH_RULE_AREA * > GetConnectedRuleAreas() const
Definition: sch_label.cpp:1853
int GetPinLength() const
Definition: sch_label.h:465
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this label.
Definition: sch_label.cpp:1902
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
Definition: sch_label.cpp:2016
bool IsConnectable() const override
Definition: sch_label.h:557
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.
Definition: sch_label.cpp:2028
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth) const override
Resolve any references to system tokens supported by the label.
Definition: sch_label.cpp:1957
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_label.h:523
int GetMandatoryFieldCount() override
Definition: sch_label.h:538
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
Definition: sch_label.h:573
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...
Definition: sch_label.cpp:1918
void SetSpinStyle(SPIN_STYLE aSpinStyle) override
Definition: sch_label.cpp:1950
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: sch_label.cpp:1895
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: sch_label.cpp:1889
bool AutoRotateOnPlacementSupported() const override
Definition: sch_label.h:570
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_label.h:533
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
Definition: sch_label.h:565
wxString GetClass() const override
Return the class name.
Definition: sch_label.h:528
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_label.cpp:2103
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: sch_label.cpp:2096
~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.
Definition: sch_label.cpp:2170
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
Definition: sch_label.h:633
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_label.h:593
wxString GetClass() const override
Return the class name.
Definition: sch_label.h:598
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: sch_label.cpp:2124
void SetSpinStyle(SPIN_STYLE aSpinStyle) override
Definition: sch_label.cpp:2131
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.
Definition: sch_label.cpp:2138
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_label.h:620
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_label.cpp:2250
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: sch_label.cpp:2118
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
Definition: sch_label.h:625
bool IsConnectable() const override
Definition: sch_label.h:614
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: sch_label.cpp:2243
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...
Definition: sch_label.cpp:2223
bool AutoRotateOnPlacementSupported() const override
Definition: sch_label.h:630
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:246
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:313
bool operator==(const SCH_ITEM &aItem) const override
Definition: sch_label.cpp:517
void SetLastResolvedState(const SCH_ITEM *aItem) override
Definition: sch_label.h:188
const wxString & GetCachedDriverName() const override
Definition: sch_label.cpp:876
COLOR4D m_lastResolvedColor
Definition: sch_label.h:375
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const override
Definition: sch_label.cpp:891
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_label.cpp:397
void AddFields(const std::vector< SCH_FIELD > &aFields)
Definition: sch_label.h:218
void SetFields(const std::vector< SCH_FIELD > &aFields)
Set multiple schematic fields.
Definition: sch_label.h:213
void SetIsDangling(bool aIsDangling)
Definition: sch_label.h:330
bool m_isDangling
Definition: sch_label.h:372
void AddField(const SCH_FIELD &aField)
Definition: sch_label.h:223
bool IsDangling() const override
Definition: sch_label.h:329
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...
Definition: sch_label.cpp:971
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: sch_label.cpp:919
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
Definition: sch_label.cpp:1009
bool HasCachedDriverName() const override
Definition: sch_label.cpp:870
const std::vector< SCH_FIELD > & GetFields() const
Definition: sch_label.h:206
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: sch_label.cpp:1077
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
Definition: sch_label.cpp:996
bool AutoRotateOnPlacement() const
autoRotateOnPlacement
Definition: sch_label.cpp:1472
SCH_LABEL_BASE & operator=(const SCH_LABEL_BASE &aLabel)
Definition: sch_label.cpp:196
std::vector< SCH_FIELD > m_fields
Definition: sch_label.h:367
CONNECTION_TYPE m_connectionType
Definition: sch_label.h:371
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_label.cpp:465
int GetNextFieldOrdinal() const
Return the next ordinal for a user field for this label.
Definition: sch_label.cpp:229
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.
Definition: sch_label.cpp:1341
void SetLabelShape(LABEL_SHAPE aShape)
Definition: sch_label.h:181
bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const override
Check if aItem has connectivity changes against this object.
Definition: sch_label.cpp:1246
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: sch_label.h:271
SPIN_STYLE GetSpinStyle() const
Definition: sch_label.cpp:351
void GetIntersheetRefs(const SCH_SHEET_PATH *aPath, std::vector< std::pair< wxString, wxString > > *pages)
Build an array of { pageNumber, pageName } pairs.
Definition: sch_label.cpp:652
void MirrorSpinStyle(bool aLeftRight) override
Definition: sch_label.cpp:437
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
Definition: sch_label.cpp:1003
COLOR4D GetLabelColor() const
Definition: sch_label.cpp:305
void SetShape(LABEL_FLAG_SHAPE aShape)
Definition: sch_label.h:177
LABEL_FLAG_SHAPE GetShape() const
Definition: sch_label.h:176
const BOX2I GetBoundingBox() const override
Return the bounding box of the label including its fields.
Definition: sch_label.cpp:1052
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: sch_label.cpp:235
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_label.cpp:484
virtual bool AutoRotateOnPlacementSupported() const =0
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_label.cpp:390
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_label.cpp:283
virtual bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth) const
Resolve any references to system tokens supported by the label.
Definition: sch_label.cpp:707
bool CanConnect(const SCH_ITEM *aItem) const override
Definition: sch_label.h:148
LABEL_SHAPE GetLabelShape() const
Definition: sch_label.h:180
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode) override
Definition: sch_label.cpp:912
bool m_autoRotateOnPlacement
Definition: sch_label.h:373
wxString m_cached_driver_name
Definition: sch_label.h:377
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_label.cpp:406
int GetLabelBoxExpansion(const RENDER_SETTINGS *aSettings=nullptr) const
Definition: sch_label.cpp:1019
bool IncrementLabel(int aIncrement)
Increment the label text if it ends with a number.
Definition: sch_label.cpp:503
void SetAutoRotateOnPlacement(bool autoRotate=true)
Definition: sch_label.cpp:1478
void cacheShownText() override
Definition: sch_label.cpp:882
void Rotate90(bool aClockwise) override
Definition: sch_label.cpp:421
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.
Definition: sch_label.cpp:1283
static const wxString GetDefaultFieldName(const wxString &aName, bool aUseDefaultName)
Definition: sch_label.cpp:216
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
Definition: sch_label.cpp:580
virtual int GetMandatoryFieldCount()
Definition: sch_label.h:203
LABEL_FLAG_SHAPE m_shape
Definition: sch_label.h:369
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this label.
Definition: sch_label.cpp:689
virtual const BOX2I GetBodyBoundingBox(const RENDER_SETTINGS *aSettings) const
Return the bounding box of the label only, without taking in account its fields.
Definition: sch_label.cpp:1034
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:300
std::vector< SCH_FIELD > & GetFields()
Definition: sch_label.h:205
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.
Definition: sch_label.cpp:1138
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...
Definition: sch_label.cpp:370
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
Definition: sch_label.cpp:316
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 ...
Definition: sch_label.cpp:961
double Similarity(const SCH_ITEM &aItem) const override
Return a measure of how likely the other object is to represent the same object.
Definition: sch_label.cpp:543
bool AutoRotateOnPlacementSupported() const override
Definition: sch_label.h:423
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: sch_label.cpp:1504
wxString GetClass() const override
Return the class name.
Definition: sch_label.h:398
const BOX2I GetBodyBoundingBox(const RENDER_SETTINGS *aSettings) const override
Return the bounding box of the label only, without taking in account its fields.
Definition: sch_label.cpp:1518
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
Definition: sch_label.h:426
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_label.h:413
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
Definition: sch_label.h:418
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_label.cpp:1554
~SCH_LABEL()
Definition: sch_label.h:388
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: sch_label.cpp:1547
bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
Definition: sch_label.h:411
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_label.h:393
bool IsConnectable() const override
Definition: sch_label.h:405
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: sch_label.cpp:1493
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
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.
Definition: sch_label.cpp:125
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.
Definition: sch_label.cpp:141
unsigned CCWRotationsTo(const SPIN_STYLE &aOther) const
Get CCW rotation needed to get to the given spin style.
Definition: sch_label.cpp:157
SPIN_STYLE RotateCCW()
Definition: sch_label.cpp:109
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:442
@ LAYER_BUS
Definition: layer_ids.h:443
CONNECTION_TYPE
AUTOPLACE_ALGO
Definition: sch_item.h:69
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: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:695