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{
137
141
142#define GLOBALLABEL_MANDATORY_FIELDS { INTERSHEET_REFS }
143
144
146{
147public:
148 SCH_LABEL_BASE( const VECTOR2I& aPos, const wxString& aText, KICAD_T aType );
149
150 SCH_LABEL_BASE( const SCH_LABEL_BASE& aLabel );
151
152 SCH_LABEL_BASE& operator=( const SCH_LABEL_BASE& aLabel );
153
154 // Abstract class
155 virtual wxString GetClass() const override = 0;
156
157 bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override;
158
159 void SwapData( SCH_ITEM* aItem ) override;
160
161 bool CanConnect( const SCH_ITEM* aItem ) const override
162 {
163 switch( aItem->Type() )
164 {
165 case SCH_LINE_T:
166 return aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS;
167
169 return true;
170
171 case SCH_SYMBOL_T:
172 return true;
173
174 case SCH_LABEL_T:
176 case SCH_HIER_LABEL_T:
178 case SCH_SHEET_PIN_T:
179 return true;
180
181 default:
182 return false;
183 }
184 }
185
186 bool HasConnectivityChanges( const SCH_ITEM* aItem,
187 const SCH_SHEET_PATH* aInstance = nullptr ) const override;
188
190 void SetShape( LABEL_FLAG_SHAPE aShape ) { m_shape = aShape; }
191
192 // Type-specific versions for property manager
194 void SetLabelShape( LABEL_SHAPE aShape ) { m_shape = (LABEL_FLAG_SHAPE) aShape; }
195
196 COLOR4D GetLabelColor() const;
197
198 virtual void SetSpinStyle( SPIN_STYLE aSpinStyle );
199 SPIN_STYLE GetSpinStyle() const;
200
201 void SetLastResolvedState( const SCH_ITEM* aItem ) override
202 {
203 const SCH_LABEL_BASE* aLabel = dynamic_cast<const SCH_LABEL_BASE*>( aItem );
204
205 if( aLabel )
207 }
208
209 static const wxString GetDefaultFieldName( const wxString& aName, bool aUseDefaultName );
210
211 virtual int GetMandatoryFieldCount() { return 0; }
212
213 std::vector<SCH_FIELD>& GetFields() { return m_fields; }
214 const std::vector<SCH_FIELD>& GetFields() const { return m_fields; }
215
221 void SetFields( const std::vector<SCH_FIELD>& aFields )
222 {
223 m_fields = aFields; // vector copying, length is changed possibly
224 }
225
226 void AddFields( const std::vector<SCH_FIELD>& aFields )
227 {
228 m_fields.insert( m_fields.end(), aFields.begin(), aFields.end() );
229 }
230
231 void AddField( const SCH_FIELD& aField )
232 {
233 m_fields.push_back( aField );
234 }
235
241 bool IncrementLabel( int aIncrement );
242
243 void Move( const VECTOR2I& aMoveVector ) override;
244 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
245 void Rotate90( bool aClockwise ) override;
246
247 void MirrorSpinStyle( bool aLeftRight ) override;
248
249 void MirrorHorizontally( int aCenter ) override;
250 void MirrorVertically( int aCenter ) override;
251
252 void SetPosition( const VECTOR2I& aPosition ) override;
253
254 void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
255
261 void GetIntersheetRefs( const SCH_SHEET_PATH* aPath,
262 std::vector<std::pair<wxString, wxString>>* pages );
263
267 void GetContextualTextVars( wxArrayString* aVars ) const;
268
274 virtual bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth ) const;
275
276 wxString GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
277 int aDepth = 0 ) const override;
278
279 wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override
280 {
281 SCHEMATIC* schematic = Schematic();
282
283 if( schematic )
284 return GetShownText( &schematic->CurrentSheet(), aAllowExtraText, aDepth );
285 else
286 return GetText();
287 }
288
289 bool HasCachedDriverName() const override;
290 const wxString& GetCachedDriverName() const override;
291
292 void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override;
293
294 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
295 const std::vector<KICAD_T>& scanTypes ) override;
296
297 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
298 bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override;
299
300 VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
301
308 virtual void CreateGraphicShape( const RENDER_SETTINGS* aSettings,
309 std::vector<VECTOR2I>& aPoints, const VECTOR2I& Pos ) const
310 {
311 aPoints.clear();
312 }
313
314 int GetLabelBoxExpansion( const RENDER_SETTINGS* aSettings = nullptr ) const;
315
319 virtual const BOX2I GetBodyBoundingBox() const;
320
324 const BOX2I GetBoundingBox() const override;
325
326 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
327 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) 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 Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
345 const VECTOR2I& offset, bool aForceNoFill, bool aDimmed ) override;
346
347 void PrintBackground( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
348 const VECTOR2I& aOffset, bool aDimmed ) override {}
349
350 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
351 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
352
357 bool AutoRotateOnPlacement() const;
358
363 void SetAutoRotateOnPlacement( bool autoRotate = true );
364
369 virtual bool AutoRotateOnPlacementSupported() const = 0;
370
371 double Similarity( const SCH_ITEM& aItem ) const override;
372
373 bool operator==( const SCH_ITEM& aItem ) const override;
374
375protected:
376 void cacheShownText() override;
377
378protected:
379 std::vector<SCH_FIELD> m_fields;
380
382
386
388
390};
391
392
394{
395public:
396 SCH_LABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ), const wxString& aText = wxEmptyString );
397
398 // Do not create a copy constructor. The one generated by the compiler is adequate.
399
401
402 void Serialize( google::protobuf::Any &aContainer ) const override;
403 bool Deserialize( const google::protobuf::Any &aContainer ) override;
404
405 static inline bool ClassOf( const EDA_ITEM* aItem )
406 {
407 return aItem && SCH_LABEL_T == aItem->Type();
408 }
409
410 wxString GetClass() const override
411 {
412 return wxT( "SCH_LABEL" );
413 }
414
415 const BOX2I GetBodyBoundingBox() const override;
416
417 bool IsConnectable() const override { return true; }
418
419 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
420
421 BITMAPS GetMenuImage() const override;
422
423 bool IsReplaceable() const override { return true; }
424
425 EDA_ITEM* Clone() const override
426 {
427 return new SCH_LABEL( *this );
428 }
429
430 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
431 {
432 return m_isDangling && GetPosition() == aPos;
433 }
434
435 bool AutoRotateOnPlacementSupported() const override { return false; }
436
437private:
438 bool doIsConnected( const VECTOR2I& aPosition ) const override
439 {
440 return EDA_TEXT::GetTextPos() == aPosition;
441 }
442};
443
444
446{
447public:
448 SCH_DIRECTIVE_LABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ) );
449
450 SCH_DIRECTIVE_LABEL( const SCH_DIRECTIVE_LABEL& aClassLabel );
451
453
454 void Serialize( google::protobuf::Any &aContainer ) const override;
455 bool Deserialize( const google::protobuf::Any &aContainer ) override;
456
457 static inline bool ClassOf( const EDA_ITEM* aItem )
458 {
459 return aItem && SCH_DIRECTIVE_LABEL_T == aItem->Type();
460 }
461
462 wxString GetClass() const override
463 {
464 return wxT( "SCH_DIRECTIVE_LABEL" );
465 }
466
467 EDA_ITEM* Clone() const override
468 {
469 return new SCH_DIRECTIVE_LABEL( *this );
470 }
471
472 void SwapData( SCH_ITEM* aItem ) override;
473
475 void SetFlagShape( FLAG_SHAPE aShape ) { m_shape = (LABEL_FLAG_SHAPE) aShape; }
476
477 int GetPinLength() const { return m_pinLength; }
478 void SetPinLength( int aLength ) { m_pinLength = aLength; }
479
480 int GetPenWidth() const override;
481
482 void CreateGraphicShape( const RENDER_SETTINGS* aSettings,
483 std::vector<VECTOR2I>& aPoints,
484 const VECTOR2I& aPos ) const override;
485
486 void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
487
488 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
489
490 bool IsConnectable() const override { return true; }
491
492 bool AutoRotateOnPlacementSupported() const override { return false; }
493
494 void MirrorSpinStyle( bool aLeftRight ) override;
495
496 void MirrorHorizontally( int aCenter ) override;
497 void MirrorVertically( int aCenter ) override;
498
500 void AddConnectedRuleArea( SCH_RULE_AREA* aRuleArea );
501
504
506 void RemoveConnectedRuleArea( SCH_RULE_AREA* aRuleArea );
507
509 virtual bool IsDangling() const override;
510
511private:
514
516 std::unordered_set<SCH_RULE_AREA*> m_connected_rule_areas;
517};
518
519
521{
522public:
523 SCH_GLOBALLABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ),
524 const wxString& aText = wxEmptyString );
525
526 SCH_GLOBALLABEL( const SCH_GLOBALLABEL& aGlobalLabel );
527
529
530 void Serialize( google::protobuf::Any &aContainer ) const override;
531 bool Deserialize( const google::protobuf::Any &aContainer ) override;
532
533 static inline bool ClassOf( const EDA_ITEM* aItem )
534 {
535 return aItem && SCH_GLOBAL_LABEL_T == aItem->Type();
536 }
537
538 wxString GetClass() const override
539 {
540 return wxT( "SCH_GLOBALLABEL" );
541 }
542
543 EDA_ITEM* Clone() const override
544 {
545 return new SCH_GLOBALLABEL( *this );
546 }
547
548 int GetMandatoryFieldCount() override { return 1; }
549
550 void SetSpinStyle( SPIN_STYLE aSpinStyle ) override;
551
552 VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
553
554 void CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings,
555 std::vector<VECTOR2I>& aPoints,
556 const VECTOR2I& aPos ) const override;
557
558 bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth ) const override;
559
560 bool IsConnectable() const override { return true; }
561
562 std::vector<int> ViewGetLayers() const override;
563
564 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
565
566 BITMAPS GetMenuImage() const override;
567
568 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
569 {
570 return m_isDangling && GetPosition() == aPos;
571 }
572
573 bool AutoRotateOnPlacementSupported() const override { return true; }
574
575private:
576 bool doIsConnected( const VECTOR2I& aPosition ) const override
577 {
578 return EDA_TEXT::GetTextPos() == aPosition;
579 }
580};
581
582
584{
585public:
586 SCH_HIERLABEL( const VECTOR2I& aPos = VECTOR2I( 0, 0 ), const wxString& aText = wxEmptyString,
587 KICAD_T aType = SCH_HIER_LABEL_T );
588
589 // Do not create a copy constructor. The one generated by the compiler is adequate.
590
592
593 void Serialize( google::protobuf::Any &aContainer ) const override;
594 bool Deserialize( const google::protobuf::Any &aContainer ) override;
595
596 static inline bool ClassOf( const EDA_ITEM* aItem )
597 {
598 return aItem && SCH_HIER_LABEL_T == aItem->Type();
599 }
600
601 wxString GetClass() const override
602 {
603 return wxT( "SCH_HIERLABEL" );
604 }
605
606 void SetSpinStyle( SPIN_STYLE aSpinStyle ) override;
607
608 VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
609
610 void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector<VECTOR2I>& aPoints,
611 const VECTOR2I& aPos ) const override;
612 void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector<VECTOR2I>& aPoints,
613 const VECTOR2I& aPos, LABEL_FLAG_SHAPE aShape ) const;
614
615 const BOX2I GetBodyBoundingBox() const override;
616
617 bool IsConnectable() const override { return true; }
618
619 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
620
621 BITMAPS GetMenuImage() const override;
622
623 EDA_ITEM* Clone() const override
624 {
625 return new SCH_HIERLABEL( *this );
626 }
627
628 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
629 {
630 return m_isDangling && GetPosition() == aPos;
631 }
632
633 bool AutoRotateOnPlacementSupported() const override { return true; }
634
635private:
636 bool doIsConnected( const VECTOR2I& aPosition ) const override
637 {
638 return EDA_TEXT::GetTextPos() == aPosition;
639 }
640};
641
642#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:89
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:260
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:98
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:105
Holds all the data relating to one schematic.
Definition: schematic.h:83
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:162
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: sch_label.cpp:1528
void MirrorSpinStyle(bool aLeftRight) override
Definition: sch_label.cpp:1552
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_label.cpp:1509
void RemoveConnectedRuleArea(SCH_RULE_AREA *aRuleArea)
Removes a specific rule area from the cache.
Definition: sch_label.cpp:1785
void ClearConnectedRuleAreas()
Removes all rule areas from the cache.
Definition: sch_label.cpp:1779
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_label.cpp:1611
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_label.cpp:1583
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: sch_label.cpp:1757
bool IsConnectable() const override
Definition: sch_label.h:490
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_label.h:457
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: sch_label.cpp:1534
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:1633
FLAG_SHAPE GetFlagShape() const
Definition: sch_label.h:474
int GetPenWidth() const override
Definition: sch_label.cpp:1541
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:516
bool AutoRotateOnPlacementSupported() const override
Definition: sch_label.h:492
wxString GetClass() const override
Return the class name.
Definition: sch_label.h:462
void SetPinLength(int aLength)
Definition: sch_label.h:478
virtual bool IsDangling() const override
Determines dangling state from connectivity and cached connected rule areas.
Definition: sch_label.cpp:1791
void AddConnectedRuleArea(SCH_RULE_AREA *aRuleArea)
Adds an entry to the connected rule area cache.
Definition: sch_label.cpp:1773
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_label.h:467
void SetFlagShape(FLAG_SHAPE aShape)
Definition: sch_label.h:475
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
Definition: sch_label.cpp:1703
int GetPinLength() const
Definition: sch_label.h:477
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:53
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:1931
bool IsConnectable() const override
Definition: sch_label.h:560
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:1938
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:1872
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_label.h:533
int GetMandatoryFieldCount() override
Definition: sch_label.h:548
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
Definition: sch_label.h:576
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:1833
void SetSpinStyle(SPIN_STYLE aSpinStyle) override
Definition: sch_label.cpp:1865
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: sch_label.cpp:1826
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: sch_label.cpp:1820
bool AutoRotateOnPlacementSupported() const override
Definition: sch_label.h:573
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_label.h:543
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
Definition: sch_label.h:568
wxString GetClass() const override
Return the class name.
Definition: sch_label.h:538
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_label.cpp:2013
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: sch_label.cpp:2006
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
Definition: sch_label.h:636
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_label.h:596
wxString GetClass() const override
Return the class name.
Definition: sch_label.h:601
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: sch_label.cpp:2034
const BOX2I GetBodyBoundingBox() const override
Return the bounding box of the label only, without taking in account its fields.
Definition: sch_label.cpp:2080
void SetSpinStyle(SPIN_STYLE aSpinStyle) override
Definition: sch_label.cpp:2041
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:2048
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_label.h:623
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_label.cpp:2160
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: sch_label.cpp:2028
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
Definition: sch_label.h:628
bool IsConnectable() const override
Definition: sch_label.h:617
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: sch_label.cpp:2153
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:2133
bool AutoRotateOnPlacementSupported() const override
Definition: sch_label.h:633
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:150
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:288
bool operator==(const SCH_ITEM &aItem) const override
Definition: sch_label.cpp:497
void SetLastResolvedState(const SCH_ITEM *aItem) override
Definition: sch_label.h:201
const wxString & GetCachedDriverName() const override
Definition: sch_label.cpp:804
COLOR4D m_lastResolvedColor
Definition: sch_label.h:387
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const override
Definition: sch_label.cpp:819
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_label.cpp:377
void AddFields(const std::vector< SCH_FIELD > &aFields)
Definition: sch_label.h:226
void SetFields(const std::vector< SCH_FIELD > &aFields)
Set multiple schematic fields.
Definition: sch_label.h:221
void SetIsDangling(bool aIsDangling)
Definition: sch_label.h:338
void Print(const SCH_RENDER_SETTINGS *aSettings, int aUnit, int aBodyStyle, const VECTOR2I &offset, bool aForceNoFill, bool aDimmed) override
Print an item.
Definition: sch_label.cpp:1364
bool m_isDangling
Definition: sch_label.h:384
void AddField(const SCH_FIELD &aField)
Definition: sch_label.h:231
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...
Definition: sch_label.cpp:867
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: sch_label.cpp:851
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:905
bool HasCachedDriverName() const override
Definition: sch_label.cpp:798
const std::vector< SCH_FIELD > & GetFields() const
Definition: sch_label.h:214
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:970
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:892
bool AutoRotateOnPlacement() const
autoRotateOnPlacement
Definition: sch_label.cpp:1410
SCH_LABEL_BASE & operator=(const SCH_LABEL_BASE &aLabel)
Definition: sch_label.cpp:192
std::vector< SCH_FIELD > m_fields
Definition: sch_label.h:379
CONNECTION_TYPE m_connectionType
Definition: sch_label.h:383
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_label.cpp:445
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:1234
void SetLabelShape(LABEL_SHAPE aShape)
Definition: sch_label.h:194
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:1139
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: sch_label.h:279
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_label.cpp:263
SPIN_STYLE GetSpinStyle() const
Definition: sch_label.cpp:331
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:632
void MirrorSpinStyle(bool aLeftRight) override
Definition: sch_label.cpp:417
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
Definition: sch_label.cpp:899
COLOR4D GetLabelColor() const
Definition: sch_label.cpp:285
void SetShape(LABEL_FLAG_SHAPE aShape)
Definition: sch_label.h:190
LABEL_FLAG_SHAPE GetShape() const
Definition: sch_label.h:189
const BOX2I GetBoundingBox() const override
Return the bounding box of the label including its fields.
Definition: sch_label.cpp:945
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: sch_label.cpp:215
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_label.cpp:464
virtual bool AutoRotateOnPlacementSupported() const =0
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_label.cpp:370
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:687
bool CanConnect(const SCH_ITEM *aItem) const override
Definition: sch_label.h:161
LABEL_SHAPE GetLabelShape() const
Definition: sch_label.h:193
bool m_autoRotateOnPlacement
Definition: sch_label.h:385
wxString m_cached_driver_name
Definition: sch_label.h:389
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_label.cpp:386
int GetLabelBoxExpansion(const RENDER_SETTINGS *aSettings=nullptr) const
Definition: sch_label.cpp:912
bool IncrementLabel(int aIncrement)
Increment the label text if it ends with a number.
Definition: sch_label.cpp:483
void SetAutoRotateOnPlacement(bool autoRotate=true)
Definition: sch_label.cpp:1416
void PrintBackground(const SCH_RENDER_SETTINGS *aSettings, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Print just the background fills.
Definition: sch_label.h:347
void cacheShownText() override
Definition: sch_label.cpp:810
void Rotate90(bool aClockwise) override
Definition: sch_label.cpp:401
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:1176
static const wxString GetDefaultFieldName(const wxString &aName, bool aUseDefaultName)
Definition: sch_label.cpp:202
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction) override
Definition: sch_label.cpp:844
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
Definition: sch_label.cpp:560
virtual int GetMandatoryFieldCount()
Definition: sch_label.h:211
LABEL_FLAG_SHAPE m_shape
Definition: sch_label.h:381
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this label.
Definition: sch_label.cpp:669
virtual const BOX2I GetBodyBoundingBox() const
Return the bounding box of the label only, without taking in account its fields.
Definition: sch_label.cpp:927
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:308
std::vector< SCH_FIELD > & GetFields()
Definition: sch_label.h:213
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:1031
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:350
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
Definition: sch_label.cpp:296
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:857
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:523
bool AutoRotateOnPlacementSupported() const override
Definition: sch_label.h:435
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: sch_label.cpp:1442
wxString GetClass() const override
Return the class name.
Definition: sch_label.h:410
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
Definition: sch_label.h:438
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_label.h:425
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
Definition: sch_label.h:430
const BOX2I GetBodyBoundingBox() const override
Return the bounding box of the label only, without taking in account its fields.
Definition: sch_label.cpp:1456
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_label.cpp:1492
~SCH_LABEL()
Definition: sch_label.h:400
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: sch_label.cpp:1485
bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
Definition: sch_label.h:423
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_label.h:405
bool IsConnectable() const override
Definition: sch_label.h:417
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: sch_label.cpp:1431
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:123
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:139
unsigned CCWRotationsTo(const SPIN_STYLE &aOther) const
Get CCW rotation needed to get to the given spin style.
Definition: sch_label.cpp:155
SPIN_STYLE RotateCCW()
Definition: sch_label.cpp:107
INSPECT_RESULT
Definition: eda_item.h:43
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition: eda_item.h:82
@ LAYER_WIRE
Definition: layer_ids.h:441
@ LAYER_BUS
Definition: layer_ids.h:442
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
GLOBALLABEL_FIELD_T
Definition: sch_label.h:135
@ INTERSHEET_REFS
Definition: sch_label.h:136
@ GLOBALLABEL_MANDATORY_FIELD_COUNT
The first 2 are mandatory, and must be instantiated in SCH_SHEET.
Definition: sch_label.h:139
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_LINE_T
Definition: typeinfo.h:163
@ SCH_SYMBOL_T
Definition: typeinfo.h:172
@ SCH_DIRECTIVE_LABEL_T
Definition: typeinfo.h:171
@ SCH_LABEL_T
Definition: typeinfo.h:167
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:169
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:173
@ SCH_BUS_WIRE_ENTRY_T
Definition: typeinfo.h:161
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:168
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695