KiCad PCB EDA Suite
pcb_textbox.cpp
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) 2022-2023 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <pcb_edit_frame.h>
25#include <base_units.h>
26#include <bitmaps.h>
27#include <board.h>
29#include <footprint.h>
30#include <pcb_textbox.h>
31#include <pcb_painter.h>
32#include <trigo.h>
33#include <string_utils.h>
35#include <callback_gal.h>
37#include <macros.h>
38#include <ignore.h>
39
40
44{
47 SetMultilineAllowed( true );
48}
49
50
52{
53}
54
55
57{
58 return KiROUND( GetStroke().GetWidth() / 2.0 ) + KiROUND( GetTextSize().y * 0.75 );
59}
60
61
63{
64 EDA_ANGLE rotation = GetDrawRotation();
65
66 if( rotation == ANGLE_90 )
67 return VECTOR2I( GetStartX(), GetEndY() );
68 else if( rotation == ANGLE_180 )
69 return GetEnd();
70 else if( rotation == ANGLE_270 )
71 return VECTOR2I( GetEndX(), GetStartY() );
72 else
73 return GetStart();
74}
75
76
78{
79 EDA_ANGLE rotation = GetDrawRotation();
80
81 if( rotation == ANGLE_90 )
82 return VECTOR2I( GetEndX(), GetStartY() );
83 else if( rotation == ANGLE_180 )
84 return GetStart();
85 else if( rotation == ANGLE_270 )
86 return VECTOR2I( GetStartX(), GetEndY() );
87 else
88 return GetEnd();
89}
90
91
92void PCB_TEXTBOX::SetTop( int aVal )
93{
94 EDA_ANGLE rotation = GetDrawRotation();
95
96 if( rotation == ANGLE_90 || rotation == ANGLE_180 )
97 SetEndY( aVal );
98 else
99 SetStartY( aVal );
100}
101
102
104{
105 EDA_ANGLE rotation = GetDrawRotation();
106
107 if( rotation == ANGLE_90 || rotation == ANGLE_180 )
108 SetStartY( aVal );
109 else
110 SetEndY( aVal );
111}
112
113
114void PCB_TEXTBOX::SetLeft( int aVal )
115{
116 EDA_ANGLE rotation = GetDrawRotation();
117
118 if( rotation == ANGLE_180 || rotation == ANGLE_270 )
119 SetEndX( aVal );
120 else
121 SetStartX( aVal );
122}
123
124
125void PCB_TEXTBOX::SetRight( int aVal )
126{
127 EDA_ANGLE rotation = GetDrawRotation();
128
129 if( rotation == ANGLE_180 || rotation == ANGLE_270 )
130 SetStartX( aVal );
131 else
132 SetEndX( aVal );
133}
134
135
137{
138 EDA_ANGLE delta = aAngle.Normalized() - GetTextAngle();
140}
141
142
143std::vector<VECTOR2I> PCB_TEXTBOX::GetAnchorAndOppositeCorner() const
144{
145 std::vector<VECTOR2I> pts;
146 std::vector<VECTOR2I> corners = GetCorners();
147 EDA_ANGLE textAngle( GetDrawRotation() );
148
149 textAngle.Normalize();
150
151 pts.emplace_back( corners[0] );
152
153 if( textAngle < ANGLE_90 )
154 {
155 if( corners[1].y <= corners[0].y )
156 pts.emplace_back( corners[1] );
157 else
158 pts.emplace_back( corners[3] );
159 }
160 else if( textAngle < ANGLE_180 )
161 {
162 if( corners[1].x <= corners[0].x )
163 pts.emplace_back( corners[1] );
164 else
165 pts.emplace_back( corners[3] );
166 }
167 else if( textAngle < ANGLE_270 )
168 {
169 if( corners[1].y >= corners[0].y )
170 pts.emplace_back( corners[1] );
171 else
172 pts.emplace_back( corners[3] );
173 }
174 else
175 {
176 if( corners[1].x >= corners[0].x )
177 pts.emplace_back( corners[1] );
178 else
179 pts.emplace_back( corners[3] );
180 }
181
182 return pts;
183}
184
185
187{
188 std::vector<VECTOR2I> corners = GetAnchorAndOppositeCorner();
189 GR_TEXT_H_ALIGN_T effectiveAlignment = GetHorizJustify();
190 VECTOR2I textAnchor;
191 VECTOR2I offset;
192
193 if( IsMirrored() )
194 {
195 std::swap( corners[0], corners[1] );
196
197 switch( GetHorizJustify() )
198 {
199 case GR_TEXT_H_ALIGN_LEFT: effectiveAlignment = GR_TEXT_H_ALIGN_RIGHT; break;
200 case GR_TEXT_H_ALIGN_CENTER: effectiveAlignment = GR_TEXT_H_ALIGN_CENTER; break;
201 case GR_TEXT_H_ALIGN_RIGHT: effectiveAlignment = GR_TEXT_H_ALIGN_LEFT; break;
202 }
203 }
204
205 switch( effectiveAlignment )
206 {
208 textAnchor = corners[0];
209 offset = VECTOR2I( GetTextMargin(), GetTextMargin() );
210 break;
212 textAnchor = ( corners[0] + corners[1] ) / 2;
213 offset = VECTOR2I( 0, GetTextMargin() );
214 break;
216 textAnchor = corners[1];
217 offset = VECTOR2I( -GetTextMargin(), GetTextMargin() );
218 break;
219 }
220
221 RotatePoint( offset, GetDrawRotation() );
222 return textAnchor + offset;
223}
224
225
226double PCB_TEXTBOX::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
227{
228 constexpr double HIDE = std::numeric_limits<double>::max();
229
230 KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( aView->GetPainter() );
231 KIGFX::PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
232
233 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
234 {
235 // Hide shadow if the main layer is not shown
236 if( !aView->IsLayerVisible( m_layer ) )
237 return HIDE;
238
239 // Hide shadow on dimmed tracks
240 if( renderSettings->GetHighContrast() )
241 {
242 if( m_layer != renderSettings->GetPrimaryHighContrastLayer() )
243 return HIDE;
244 }
245 }
246
247 return 0.0;
248}
249
250
251wxString PCB_TEXTBOX::GetShownText( int aDepth, bool aAllowExtraText ) const
252{
253 BOARD* board = dynamic_cast<BOARD*>( GetParent() );
254
255 std::function<bool( wxString* )> pcbTextResolver =
256 [&]( wxString* token ) -> bool
257 {
258 if( token->IsSameAs( wxT( "LAYER" ) ) )
259 {
260 *token = GetLayerName();
261 return true;
262 }
263
264 if( board->ResolveTextVar( token, aDepth + 1 ) )
265 {
266 return true;
267 }
268
269 return false;
270 };
271
272 wxString text = EDA_TEXT::GetShownText();
273
274 if( board && HasTextVars() && aDepth < 10 )
275 text = ExpandTextVars( text, &pcbTextResolver );
276
277 KIFONT::FONT* font = getDrawFont();
278 std::vector<VECTOR2I> corners = GetAnchorAndOppositeCorner();
279 int colWidth = ( corners[1] - corners[0] ).EuclideanNorm();
280
281 colWidth -= GetTextMargin() * 2;
282 font->LinebreakText( text, colWidth, GetTextSize(), GetTextThickness(), IsBold(), IsItalic() );
283
284 return text;
285}
286
287
288void PCB_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
289{
290 // Don't use GetShownText() here; we want to show the user the variable references
291 aList.emplace_back( _( "Text Box" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
292
293 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
294 aList.emplace_back( _( "Status" ), _( "Locked" ) );
295
296 aList.emplace_back( _( "Layer" ), GetLayerName() );
297 aList.emplace_back( _( "Mirror" ), IsMirrored() ? _( "Yes" ) : _( "No" ) );
298 aList.emplace_back( _( "Angle" ), wxString::Format( "%g", GetTextAngle().AsDegrees() ) );
299
300 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
301 aList.emplace_back( _( "Text Thickness" ), aFrame->MessageTextFromValue( GetTextThickness() ) );
302 aList.emplace_back( _( "Text Width" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
303 aList.emplace_back( _( "Text Height" ), aFrame->MessageTextFromValue( GetTextHeight() ) );
304
305 aList.emplace_back( _( "Box Width" ),
306 aFrame->MessageTextFromValue( std::abs( GetEnd().x - GetStart().x ) ) );
307
308 aList.emplace_back( _( "Box Height" ),
309 aFrame->MessageTextFromValue( std::abs( GetEnd().y - GetStart().y ) ));
310
311 m_stroke.GetMsgPanelInfo( aFrame, aList );
312}
313
314
315void PCB_TEXTBOX::Move( const VECTOR2I& aMoveVector )
316{
317 PCB_SHAPE::Move( aMoveVector );
318 EDA_TEXT::Offset( aMoveVector );
319}
320
321
322void PCB_TEXTBOX::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
323{
324 PCB_SHAPE::Rotate( aRotCentre, aAngle );
325 EDA_TEXT::SetTextAngle( ( GetTextAngle() + aAngle ).Normalized() );
326
327 if( GetTextAngle().IsCardinal() && GetShape() != SHAPE_T::RECT )
328 {
329 std::vector<VECTOR2I> corners = GetCorners();
330 VECTOR2I diag = corners[2] - corners[0];
332
334 SetStart( corners[0] );
335
336 angle.Normalize();
337
338 if( angle == ANGLE_90 )
339 SetEnd( VECTOR2I( corners[0].x + abs( diag.x ), corners[0].y - abs( diag.y ) ) );
340 else if( angle == ANGLE_180 )
341 SetEnd( VECTOR2I( corners[0].x - abs( diag.x ), corners[0].y - abs( diag.y ) ) );
342 else if( angle == ANGLE_270 )
343 SetEnd( VECTOR2I( corners[0].x - abs( diag.x ), corners[0].y + abs( diag.y ) ) );
344 else
345 SetEnd( VECTOR2I( corners[0].x + abs( diag.x ), corners[0].y + abs( diag.y ) ) );
346 }
347}
348
349
350void PCB_TEXTBOX::Mirror( const VECTOR2I& aCentre, bool aMirrorAroundXAxis )
351{
352 // the position is mirrored, but not the text (or its justification)
353 PCB_SHAPE::Mirror( aCentre, aMirrorAroundXAxis );
354
355 BOX2I rect( m_start, m_end - m_start );
356 rect.Normalize();
357 m_start = VECTOR2I( rect.GetLeft(), rect.GetTop() );
358 m_end = VECTOR2I( rect.GetRight(), rect.GetBottom() );
359}
360
361
362void PCB_TEXTBOX::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
363{
364 if( aFlipLeftRight )
365 {
366 m_start.x = aCentre.x - ( m_start.x - aCentre.x );
367 m_end.x = aCentre.x - ( m_end.x - aCentre.x );
369 }
370 else
371 {
372 m_start.y = aCentre.y - ( m_start.y - aCentre.y );
373 m_end.y = aCentre.y - ( m_end.y - aCentre.y );
375 }
376
377 SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) );
378
379 if( ( GetLayerSet() & LSET::SideSpecificMask() ).any() )
381}
382
383
384bool PCB_TEXTBOX::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
385{
386 BOX2I rect = GetBoundingBox();
387
388 rect.Inflate( aAccuracy );
389
390 return rect.Contains( aPosition );
391}
392
393
394bool PCB_TEXTBOX::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
395{
396 BOX2I rect = aRect;
397
398 rect.Inflate( aAccuracy );
399
400 if( aContained )
401 return rect.Contains( GetBoundingBox() );
402
403 return rect.Intersects( GetBoundingBox() );
404}
405
406
407wxString PCB_TEXTBOX::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
408{
409 return wxString::Format( _( "PCB Text Box on %s"), GetLayerName() );
410}
411
412
414{
416}
417
418
420{
421 return new PCB_TEXTBOX( *this );
422}
423
424
426{
427 assert( aImage->Type() == PCB_TEXTBOX_T );
428
429 std::swap( *((PCB_TEXTBOX*) this), *((PCB_TEXTBOX*) aImage) );
430}
431
432
433std::shared_ptr<SHAPE> PCB_TEXTBOX::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
434{
435 std::shared_ptr<SHAPE_COMPOUND> shape = GetEffectiveTextShape();
436
437 if( PCB_SHAPE::GetStroke().GetWidth() >= 0 )
438 shape->AddShape( PCB_SHAPE::GetEffectiveShape( aLayer, aFlash ) );
439
440 return shape;
441}
442
443
445 int aClearance, int aError, ERROR_LOC aErrorLoc ) const
446{
448 KIFONT::FONT* font = getDrawFont();
449 int penWidth = GetEffectiveTextPenWidth();
450
451 // Note: this function is mainly used in 3D viewer.
452 // the polygonal shape of a text can have many basic shapes,
453 // so combining these shapes can be very useful to create a final shape
454 // swith a lot less vertices to speedup calculations using this final shape
455 // Simplify shapes is not usually always efficient, but in this case it is.
456 SHAPE_POLY_SET buffer;
457
458 CALLBACK_GAL callback_gal( empty_opts,
459 // Stroke callback
460 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
461 {
462 TransformOvalToPolygon( buffer, aPt1, aPt2, penWidth + ( 2 * aClearance ), aError,
463 ERROR_INSIDE );
464 },
465 // Triangulation callback
466 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2, const VECTOR2I& aPt3 )
467 {
468 buffer.NewOutline();
469
470 for( const VECTOR2I& point : { aPt1, aPt2, aPt3 } )
471 buffer.Append( point.x, point.y );
472 } );
473
474 font->Draw( &callback_gal, GetShownText(), GetDrawPos(), GetAttributes() );
475
477 aBuffer.Append( buffer );
478}
479
480
482 int aClearance, int aError, ERROR_LOC aErrorLoc,
483 bool aIgnoreLineWidth ) const
484{
485 // Don't use PCB_SHAPE::TransformShapeToPolygon. We want to treat the textbox as filled even
486 // if there's no background colour.
487
488 std::vector<VECTOR2I> pts = GetRectCorners();
489
490 aBuffer.NewOutline();
491
492 for( const VECTOR2I& pt : pts )
493 aBuffer.Append( pt );
494
495 int width = GetWidth() + ( 2 * aClearance );
496
497 if( width > 0 )
498 {
499 // Add in segments
500 TransformOvalToPolygon( aBuffer, pts[0], pts[1], width, aError, aErrorLoc );
501 TransformOvalToPolygon( aBuffer, pts[1], pts[2], width, aError, aErrorLoc );
502 TransformOvalToPolygon( aBuffer, pts[2], pts[3], width, aError, aErrorLoc );
503 TransformOvalToPolygon( aBuffer, pts[3], pts[0], width, aError, aErrorLoc );
504 }
505}
506
507
508static struct PCB_TEXTBOX_DESC
509{
511 {
518
519 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Shape" ) );
520 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Start X" ) );
521 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Start Y" ) );
522 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "End X" ) );
523 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "End Y" ) );
524 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Line Width" ) );
525 }
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:70
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:192
PCB_LAYER_ID m_layer
Definition: board_item.h:341
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:226
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:43
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:197
virtual bool IsLocked() const
Definition: board_item.cpp:71
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:175
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Definition: board_item.cpp:94
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:269
bool ResolveTextVar(wxString *token, int aDepth) const
Definition: board.cpp:350
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:119
bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:269
coord_type GetTop() const
Definition: box2.h:194
bool Contains(const Vec &aPoint) const
Definition: box2.h:141
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:506
coord_type GetRight() const
Definition: box2.h:189
coord_type GetLeft() const
Definition: box2.h:193
coord_type GetBottom() const
Definition: box2.h:190
EDA_ANGLE Normalize()
Definition: eda_angle.h:249
EDA_ANGLE Normalized() const
Definition: eda_angle.h:260
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:85
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
void SetStartX(int x)
Definition: eda_shape.h:136
int GetStartY() const
Definition: eda_shape.h:121
void SetEndY(int y)
Definition: eda_shape.h:155
int GetEndX() const
Definition: eda_shape.h:147
void SetStartY(int y)
Definition: eda_shape.h:130
SHAPE_T GetShape() const
Definition: eda_shape.h:113
int GetEndY() const
Definition: eda_shape.h:146
void SetEndX(int x)
Definition: eda_shape.h:161
VECTOR2I m_start
Definition: eda_shape.h:369
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:145
void SetStart(const VECTOR2I &aStart)
Definition: eda_shape.h:124
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:120
void SetShape(SHAPE_T aShape)
Definition: eda_shape.h:112
std::vector< VECTOR2I > GetRectCorners() const
Definition: eda_shape.cpp:1035
int GetWidth() const
Definition: eda_shape.h:109
void SetEnd(const VECTOR2I &aEnd)
Definition: eda_shape.h:149
int GetStartX() const
Definition: eda_shape.h:122
VECTOR2I m_end
Definition: eda_shape.h:370
STROKE_PARAMS m_stroke
Definition: eda_shape.h:365
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:72
int GetTextHeight() const
Definition: eda_text.h:202
bool IsItalic() const
Definition: eda_text.h:130
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:120
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
KIFONT::FONT * GetFont() const
Definition: eda_text.h:188
void SetMirrored(bool isMirrored)
Definition: eda_text.cpp:226
virtual EDA_ANGLE GetDrawRotation() const
Definition: eda_text.h:317
int GetTextWidth() const
Definition: eda_text.h:199
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:250
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:391
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:149
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
Definition: eda_text.h:103
virtual KIFONT::FONT * getDrawFont() const
Definition: eda_text.cpp:428
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:172
bool IsMirrored() const
Definition: eda_text.h:139
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:299
bool IsBold() const
Definition: eda_text.h:133
std::shared_ptr< SHAPE_COMPOUND > GetEffectiveTextShape(bool aTriangulate=true, bool aUseTextRotation=true) const
build a list of segments (SHAPE_SEGMENT) to describe a text shape.
Definition: eda_text.cpp:855
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:195
int GetTextThickness() const
Definition: eda_text.h:112
virtual wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:98
void SetMultilineAllowed(bool aAllow)
Definition: eda_text.cpp:234
VECTOR2I GetTextSize() const
Definition: eda_text.h:196
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:242
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:105
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttrs) const
Draw a string.
Definition: font.cpp:232
void LinebreakText(wxString &aText, int aColumnWidth, const VECTOR2I &aGlyphSize, int aThickness, bool aBold, bool aItalic) const
Insert characters into text to ensure that no lines are wider than aColumnWidth.
Definition: font.cpp:509
Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:158
virtual PCB_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
Definition: pcb_painter.h:163
PCB specific render settings.
Definition: pcb_painter.h:72
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
Return the board layer which is in high-contrast mode.
bool GetHighContrast() const
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:69
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:410
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:213
static LSET SideSpecificMask()
Definition: lset.cpp:908
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_shape.h:101
virtual void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pcb_shape.cpp:191
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Make a set of SHAPE objects representing the PCB_SHAPE.
Definition: pcb_shape.cpp:344
virtual std::vector< VECTOR2I > GetCorners() const
Return 4 corners for a rectangle or rotated rectangle (stored as a poly).
Definition: pcb_shape.cpp:133
STROKE_PARAMS GetStroke() const override
Definition: pcb_shape.h:71
virtual void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: pcb_shape.cpp:163
virtual void Mirror(const VECTOR2I &aCentre, bool aMirrorAroundXAxis)
Definition: pcb_shape.cpp:205
VECTOR2I GetPosition() const override
Definition: pcb_shape.h:65
bool HitTest(const VECTOR2I &aPosition, int aAccuracy) const override
Test if aPosition is inside or on the boundary of this item.
virtual void swapData(BOARD_ITEM *aImage) override
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
int GetTextMargin() const
Definition: pcb_textbox.cpp:56
std::vector< VECTOR2I > GetAnchorAndOppositeCorner() const
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc) const
Function TransformTextToPolySet Convert the text to a polygonSet describing the actual character stro...
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Make a set of SHAPE objects representing the PCB_SHAPE.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
VECTOR2I GetDrawPos() const 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.
void SetLeft(int aVal) override
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
void SetRight(int aVal) override
void SetTop(int aVal) override
Definition: pcb_textbox.cpp:92
void SetTextAngle(const EDA_ANGLE &aAngle) override
PCB_TEXTBOX(BOARD_ITEM *parent)
Definition: pcb_textbox.cpp:41
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth=false) const override
Convert the shape to a closed polygon.
void Move(const VECTOR2I &aMoveVector) override
Move this object.
wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
void SetBottom(int aVal) override
void Mirror(const VECTOR2I &aCentre, bool aMirrorAroundXAxis) override
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
VECTOR2I GetTopLeft() const override
Definition: pcb_textbox.cpp:62
VECTOR2I GetBotRight() const override
Definition: pcb_textbox.cpp:77
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:74
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
void Mask(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName)
Sets a base class property as masked in a derived class.
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:76
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
Represent a set of closed polygons.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
void Simplify(POLYGON_MODE aFastMode)
int NewOutline()
Creates a new hole in a given outline.
void GetMsgPanelInfo(UNITS_PROVIDER *aUnitsProvider, std::vector< MSG_PANEL_ITEM > &aList, bool aIncludeStyle=true, bool aIncludeWidth=true)
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
Definition: common.cpp:58
void TransformOvalToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a oblong shape to a polygon, using multiple segments.
#define _HKI(x)
#define _(s)
static constexpr EDA_ANGLE & ANGLE_180
Definition: eda_angle.h:433
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:431
static constexpr EDA_ANGLE & ANGLE_270
Definition: eda_angle.h:434
#define PCB_EDIT_FRAME_NAME
SHAPE_T
Definition: eda_shape.h:41
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
@ ERROR_INSIDE
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:147
@ LAYER_LOCKED_ITEM_SHADOW
shadow layer for locked items
Definition: layer_ids.h:239
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Definition: lset.cpp:544
This file contains miscellaneous commonly used macros and functions.
wxString EllipsizeStatusText(wxWindow *aWindow, const wxString &aString)
Ellipsize text (at the end) to be no more than 1/3 of the window width.
Definition: ui_common.cpp:197
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:418
static struct PCB_TEXTBOX_DESC _PCB_TEXTBOX_DESC
#define TYPE_HASH(x)
Definition: property.h:63
#define REGISTER_TYPE(x)
Definition: property_mgr.h:328
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
constexpr int delta
GR_TEXT_H_ALIGN_T
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_V_ALIGN_TOP
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183
double EuclideanNorm(const VECTOR2I &vector)
Definition: trigo.h:129
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:91
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590