KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 <core/ignore.h>
39
40
44 m_borderEnabled( true )
45{
48 SetMultilineAllowed( true );
49}
50
51
53{
54}
55
56
58{
59 return KiROUND( GetStroke().GetWidth() / 2.0 ) + KiROUND( GetTextSize().y * 0.75 );
60}
61
62
64{
65 EDA_ANGLE rotation = GetDrawRotation();
66
67 if( rotation == ANGLE_90 )
68 return VECTOR2I( GetStartX(), GetEndY() );
69 else if( rotation == ANGLE_180 )
70 return GetEnd();
71 else if( rotation == ANGLE_270 )
72 return VECTOR2I( GetEndX(), GetStartY() );
73 else
74 return GetStart();
75}
76
77
79{
80 EDA_ANGLE rotation = GetDrawRotation();
81
82 if( rotation == ANGLE_90 )
83 return VECTOR2I( GetEndX(), GetStartY() );
84 else if( rotation == ANGLE_180 )
85 return GetStart();
86 else if( rotation == ANGLE_270 )
87 return VECTOR2I( GetStartX(), GetEndY() );
88 else
89 return GetEnd();
90}
91
92
93void PCB_TEXTBOX::SetTop( int aVal )
94{
95 EDA_ANGLE rotation = GetDrawRotation();
96
97 if( rotation == ANGLE_90 || rotation == ANGLE_180 )
98 SetEndY( aVal );
99 else
100 SetStartY( aVal );
101}
102
103
105{
106 EDA_ANGLE rotation = GetDrawRotation();
107
108 if( rotation == ANGLE_90 || rotation == ANGLE_180 )
109 SetStartY( aVal );
110 else
111 SetEndY( aVal );
112}
113
114
115void PCB_TEXTBOX::SetLeft( int aVal )
116{
117 EDA_ANGLE rotation = GetDrawRotation();
118
119 if( rotation == ANGLE_180 || rotation == ANGLE_270 )
120 SetEndX( aVal );
121 else
122 SetStartX( aVal );
123}
124
125
126void PCB_TEXTBOX::SetRight( int aVal )
127{
128 EDA_ANGLE rotation = GetDrawRotation();
129
130 if( rotation == ANGLE_180 || rotation == ANGLE_270 )
131 SetStartX( aVal );
132 else
133 SetEndX( aVal );
134}
135
136
138{
139 EDA_ANGLE delta = aAngle.Normalized() - GetTextAngle();
141}
142
143
144std::vector<VECTOR2I> PCB_TEXTBOX::GetAnchorAndOppositeCorner() const
145{
146 std::vector<VECTOR2I> pts;
147 std::vector<VECTOR2I> corners = GetCorners();
148 EDA_ANGLE textAngle( GetDrawRotation() );
149
150 textAngle.Normalize();
151
152 pts.emplace_back( corners[0] );
153
154 if( textAngle < ANGLE_90 )
155 {
156 if( corners[1].y <= corners[0].y )
157 pts.emplace_back( corners[1] );
158 else
159 pts.emplace_back( corners[3] );
160 }
161 else if( textAngle < ANGLE_180 )
162 {
163 if( corners[1].x <= corners[0].x )
164 pts.emplace_back( corners[1] );
165 else
166 pts.emplace_back( corners[3] );
167 }
168 else if( textAngle < ANGLE_270 )
169 {
170 if( corners[1].y >= corners[0].y )
171 pts.emplace_back( corners[1] );
172 else
173 pts.emplace_back( corners[3] );
174 }
175 else
176 {
177 if( corners[1].x >= corners[0].x )
178 pts.emplace_back( corners[1] );
179 else
180 pts.emplace_back( corners[3] );
181 }
182
183 return pts;
184}
185
186
188{
189 std::vector<VECTOR2I> corners = GetAnchorAndOppositeCorner();
190 GR_TEXT_H_ALIGN_T effectiveAlignment = GetHorizJustify();
191 VECTOR2I textAnchor;
192 VECTOR2I offset;
193
194 if( IsBackLayer( GetLayer() ) )
195 std::swap( corners[0], corners[1] );
196
197 if( IsMirrored() )
198 {
199 switch( GetHorizJustify() )
200 {
201 case GR_TEXT_H_ALIGN_LEFT: effectiveAlignment = GR_TEXT_H_ALIGN_RIGHT; break;
202 case GR_TEXT_H_ALIGN_CENTER: effectiveAlignment = GR_TEXT_H_ALIGN_CENTER; break;
203 case GR_TEXT_H_ALIGN_RIGHT: effectiveAlignment = GR_TEXT_H_ALIGN_LEFT; break;
204 }
205 }
206
207 switch( effectiveAlignment )
208 {
210 textAnchor = corners[0];
211 offset = VECTOR2I( GetTextMargin(), GetTextMargin() );
212 break;
214 textAnchor = ( corners[0] + corners[1] ) / 2;
215 offset = VECTOR2I( 0, GetTextMargin() );
216 break;
218 textAnchor = corners[1];
219 offset = VECTOR2I( -GetTextMargin(), GetTextMargin() );
220 break;
221 }
222
223 RotatePoint( offset, GetDrawRotation() );
224 return textAnchor + offset;
225}
226
227
228double PCB_TEXTBOX::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
229{
230 constexpr double HIDE = std::numeric_limits<double>::max();
231
232 KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( aView->GetPainter() );
233 KIGFX::PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
234
235 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
236 {
237 // Hide shadow if the main layer is not shown
238 if( !aView->IsLayerVisible( m_layer ) )
239 return HIDE;
240
241 // Hide shadow on dimmed tracks
242 if( renderSettings->GetHighContrast() )
243 {
244 if( m_layer != renderSettings->GetPrimaryHighContrastLayer() )
245 return HIDE;
246 }
247 }
248
249 return 0.0;
250}
251
252
253void PCB_TEXTBOX::ViewGetLayers( int aLayers[], int& aCount ) const
254{
255 aLayers[0] = GetLayer();
256 aCount = 1;
257
258 if( IsLocked() )
259 aLayers[ aCount++ ] = LAYER_LOCKED_ITEM_SHADOW;
260}
261
262
263wxString PCB_TEXTBOX::GetShownText( bool aAllowExtraText, int aDepth ) const
264{
265 BOARD* board = dynamic_cast<BOARD*>( GetParent() );
266
267 std::function<bool( wxString* )> pcbTextResolver =
268 [&]( wxString* token ) -> bool
269 {
270 if( token->IsSameAs( wxT( "LAYER" ) ) )
271 {
272 *token = GetLayerName();
273 return true;
274 }
275
276 if( board->ResolveTextVar( token, aDepth + 1 ) )
277 {
278 return true;
279 }
280
281 return false;
282 };
283
284 wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth );
285
286 if( board && HasTextVars() && aDepth < 10 )
287 text = ExpandTextVars( text, &pcbTextResolver );
288
289 KIFONT::FONT* font = getDrawFont();
290 std::vector<VECTOR2I> corners = GetAnchorAndOppositeCorner();
291 int colWidth = ( corners[1] - corners[0] ).EuclideanNorm();
292
293 colWidth -= GetTextMargin() * 2;
294 font->LinebreakText( text, colWidth, GetTextSize(), GetTextThickness(), IsBold(), IsItalic() );
295
296 return text;
297}
298
299
300bool PCB_TEXTBOX::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
301{
302 return BOARD_ITEM::Matches( UnescapeString( GetText() ), aSearchData );
303}
304
305
306void PCB_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
307{
308 // Don't use GetShownText() here; we want to show the user the variable references
309 aList.emplace_back( _( "Text Box" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
310
311 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
312 aList.emplace_back( _( "Status" ), _( "Locked" ) );
313
314 aList.emplace_back( _( "Layer" ), GetLayerName() );
315 aList.emplace_back( _( "Mirror" ), IsMirrored() ? _( "Yes" ) : _( "No" ) );
316 aList.emplace_back( _( "Angle" ), wxString::Format( "%g", GetTextAngle().AsDegrees() ) );
317
318 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
319 aList.emplace_back( _( "Text Thickness" ), aFrame->MessageTextFromValue( GetTextThickness() ) );
320 aList.emplace_back( _( "Text Width" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
321 aList.emplace_back( _( "Text Height" ), aFrame->MessageTextFromValue( GetTextHeight() ) );
322
323 aList.emplace_back( _( "Box Width" ),
324 aFrame->MessageTextFromValue( std::abs( GetEnd().x - GetStart().x ) ) );
325
326 aList.emplace_back( _( "Box Height" ),
327 aFrame->MessageTextFromValue( std::abs( GetEnd().y - GetStart().y ) ));
328
329 m_stroke.GetMsgPanelInfo( aFrame, aList );
330}
331
332
333void PCB_TEXTBOX::Move( const VECTOR2I& aMoveVector )
334{
335 PCB_SHAPE::Move( aMoveVector );
336 EDA_TEXT::Offset( aMoveVector );
337}
338
339
340void PCB_TEXTBOX::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
341{
342 PCB_SHAPE::Rotate( aRotCentre, aAngle );
343 EDA_TEXT::SetTextAngle( ( GetTextAngle() + aAngle ).Normalized() );
344
345 if( GetTextAngle().IsCardinal() && GetShape() != SHAPE_T::RECTANGLE )
346 {
347 std::vector<VECTOR2I> corners = GetCorners();
348 VECTOR2I diag = corners[2] - corners[0];
349 EDA_ANGLE angle = GetTextAngle();
350
351 SetShape( SHAPE_T::RECTANGLE );
352 SetStart( corners[0] );
353
354 angle.Normalize();
355
356 if( angle == ANGLE_90 )
357 SetEnd( VECTOR2I( corners[0].x + abs( diag.x ), corners[0].y - abs( diag.y ) ) );
358 else if( angle == ANGLE_180 )
359 SetEnd( VECTOR2I( corners[0].x - abs( diag.x ), corners[0].y - abs( diag.y ) ) );
360 else if( angle == ANGLE_270 )
361 SetEnd( VECTOR2I( corners[0].x - abs( diag.x ), corners[0].y + abs( diag.y ) ) );
362 else
363 SetEnd( VECTOR2I( corners[0].x + abs( diag.x ), corners[0].y + abs( diag.y ) ) );
364 }
365}
366
367
368void PCB_TEXTBOX::Mirror( const VECTOR2I& aCentre, bool aMirrorAroundXAxis )
369{
370 // the position is mirrored, but not the text (or its justification)
371 PCB_SHAPE::Mirror( aCentre, aMirrorAroundXAxis );
372
373 BOX2I rect( m_start, m_end - m_start );
374 rect.Normalize();
375 m_start = VECTOR2I( rect.GetLeft(), rect.GetTop() );
376 m_end = VECTOR2I( rect.GetRight(), rect.GetBottom() );
377}
378
379
380void PCB_TEXTBOX::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
381{
382 if( aFlipLeftRight )
383 {
384 m_start.x = aCentre.x - ( m_start.x - aCentre.x );
385 m_end.x = aCentre.x - ( m_end.x - aCentre.x );
387 }
388 else
389 {
390 m_start.y = aCentre.y - ( m_start.y - aCentre.y );
391 m_end.y = aCentre.y - ( m_end.y - aCentre.y );
393 }
394
395 SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) );
396
397 if( ( GetLayerSet() & LSET::SideSpecificMask() ).any() )
399}
400
401
402bool PCB_TEXTBOX::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
403{
404 BOX2I rect = GetBoundingBox();
405
406 rect.Inflate( aAccuracy );
407
408 return rect.Contains( aPosition );
409}
410
411
412bool PCB_TEXTBOX::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
413{
414 BOX2I rect = aRect;
415
416 rect.Inflate( aAccuracy );
417
418 if( aContained )
419 return rect.Contains( GetBoundingBox() );
420
421 return rect.Intersects( GetBoundingBox() );
422}
423
424
425wxString PCB_TEXTBOX::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
426{
427 return wxString::Format( _( "PCB Text Box on %s" ), GetLayerName() );
428}
429
430
432{
433 return BITMAPS::add_textbox;
434}
435
436
438{
439 return new PCB_TEXTBOX( *this );
440}
441
442
444{
445 assert( aImage->Type() == PCB_TEXTBOX_T );
446
447 std::swap( *((PCB_TEXTBOX*) this), *((PCB_TEXTBOX*) aImage) );
448}
449
450
451std::shared_ptr<SHAPE> PCB_TEXTBOX::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
452{
453 std::shared_ptr<SHAPE_COMPOUND> shape = GetEffectiveTextShape();
454
455 if( PCB_SHAPE::GetStroke().GetWidth() >= 0 )
456 shape->AddShape( PCB_SHAPE::GetEffectiveShape( aLayer, aFlash ) );
457
458 return shape;
459}
460
461
462void PCB_TEXTBOX::TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, int aClearance, int aMaxError,
463 ERROR_LOC aErrorLoc ) const
464{
466 KIFONT::FONT* font = getDrawFont();
467 int penWidth = GetEffectiveTextPenWidth();
468
469 // Note: this function is mainly used in 3D viewer.
470 // the polygonal shape of a text can have many basic shapes,
471 // so combining these shapes can be very useful to create a final shape
472 // swith a lot less vertices to speedup calculations using this final shape
473 // Simplify shapes is not usually always efficient, but in this case it is.
474 SHAPE_POLY_SET buffer;
475
476 CALLBACK_GAL callback_gal( empty_opts,
477 // Stroke callback
478 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
479 {
480 TransformOvalToPolygon( buffer, aPt1, aPt2, penWidth, aMaxError, aErrorLoc );
481 },
482 // Triangulation callback
483 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2, const VECTOR2I& aPt3 )
484 {
485 buffer.NewOutline();
486
487 for( const VECTOR2I& point : { aPt1, aPt2, aPt3 } )
488 buffer.Append( point.x, point.y );
489 } );
490
491 font->Draw( &callback_gal, GetShownText( true ), GetDrawPos(), GetAttributes(), GetFontMetrics() );
492
493 if( aClearance > 0 || aErrorLoc == ERROR_OUTSIDE )
494 {
495 if( aErrorLoc == ERROR_OUTSIDE )
496 aClearance += aMaxError;
497
498 buffer.Inflate( aClearance, SHAPE_POLY_SET::ROUND_ALL_CORNERS, aMaxError, true );
499 }
500 else
501 {
503 }
504
505 aBuffer.Append( buffer );
506}
507
508
510 int aClearance, int aMaxError, ERROR_LOC aErrorLoc,
511 bool aIgnoreLineWidth ) const
512{
513 // Don't use PCB_SHAPE::TransformShapeToPolygon. We want to treat the textbox as filled even
514 // if there's no background colour.
515
516 int width = GetWidth() + ( 2 * aClearance );
517
518 if( GetShape() == SHAPE_T::RECTANGLE )
519 {
520 std::vector<VECTOR2I> pts = GetRectCorners();
521
522 aBuffer.NewOutline();
523
524 for( const VECTOR2I& pt : pts )
525 aBuffer.Append( pt );
526
527 if( m_borderEnabled && width > 0 )
528 {
529 // Add in segments
530 TransformOvalToPolygon( aBuffer, pts[0], pts[1], width, aMaxError, aErrorLoc );
531 TransformOvalToPolygon( aBuffer, pts[1], pts[2], width, aMaxError, aErrorLoc );
532 TransformOvalToPolygon( aBuffer, pts[2], pts[3], width, aMaxError, aErrorLoc );
533 TransformOvalToPolygon( aBuffer, pts[3], pts[0], width, aMaxError, aErrorLoc );
534 }
535 }
536 else if( GetShape() == SHAPE_T::POLY ) // Non-cardinally-rotated rect
537 {
538 aBuffer.NewOutline();
539
540 const SHAPE_LINE_CHAIN& poly = m_poly.Outline( 0 );
541
542 for( int ii = 0; ii < poly.PointCount(); ++ii )
543 aBuffer.Append( poly.GetPoint( ii ) );
544
545 if( m_borderEnabled && width > 0 )
546 {
547 for( int ii = 0; ii < poly.SegmentCount(); ++ii )
548 {
549 const SEG& seg = poly.GetSegment( ii );
550 TransformOvalToPolygon( aBuffer, seg.A, seg.B, width, aMaxError, aErrorLoc );
551 }
552 }
553 }
554}
555
556
558{
559 return m_borderEnabled;
560}
561
562
564{
565 m_borderEnabled = enabled;
566}
567
568
569void PCB_TEXTBOX::SetBorderWidth( const int aSize )
570{
571 m_stroke.SetWidth( aSize );
572}
573
574
575static struct PCB_TEXTBOX_DESC
576{
578 {
580
581 if( plotDashTypeEnum.Choices().GetCount() == 0 )
582 {
583 plotDashTypeEnum.Map( PLOT_DASH_TYPE::DEFAULT, _HKI( "Default" ) )
584 .Map( PLOT_DASH_TYPE::SOLID, _HKI( "Solid" ) )
585 .Map( PLOT_DASH_TYPE::DASH, _HKI( "Dashed" ) )
586 .Map( PLOT_DASH_TYPE::DOT, _HKI( "Dotted" ) )
587 .Map( PLOT_DASH_TYPE::DASHDOT, _HKI( "Dash-Dot" ) )
588 .Map( PLOT_DASH_TYPE::DASHDOTDOT, _HKI( "Dash-Dot-Dot" ) );
589 }
590
597
598 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Shape" ) );
599 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Start X" ) );
600 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Start Y" ) );
601 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "End X" ) );
602 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "End Y" ) );
603 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Line Width" ) );
604 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Line Style" ) );
605 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Visible" ) );
606
607 const wxString borderProps = _( "Border Properties" );
608
609 void ( PCB_TEXTBOX::*lineStyleSetter )( PLOT_DASH_TYPE ) = &PCB_TEXTBOX::SetLineStyle;
610 PLOT_DASH_TYPE ( PCB_TEXTBOX::*lineStyleGetter )() const = &PCB_TEXTBOX::GetLineStyle;
611
612 propMgr.AddProperty( new PROPERTY<PCB_TEXTBOX, bool>( _HKI( "Border" ),
615 borderProps );
616
617 propMgr.AddProperty( new PROPERTY_ENUM<PCB_TEXTBOX, PLOT_DASH_TYPE>( _HKI( "Border Style" ),
618 lineStyleSetter,
619 lineStyleGetter ),
620 borderProps );
621
622 propMgr.AddProperty( new PROPERTY<PCB_TEXTBOX, int>( _HKI( "Border Width" ),
625 PROPERTY_DISPLAY::PT_SIZE ),
626 borderProps );
627 }
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:77
PCB_LAYER_ID m_layer
Definition: board_item.h:361
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:45
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:209
const KIFONT::METRICS & GetFontMetrics() const
Definition: board_item.cpp:96
virtual bool IsLocked() const
Definition: board_item.cpp:73
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:182
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Definition: board_item.cpp:102
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:271
bool ResolveTextVar(wxString *token, int aDepth) const
Definition: board.cpp:376
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:120
bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:270
coord_type GetTop() const
Definition: box2.h:195
bool Contains(const Vec &aPoint) const
Definition: box2.h:142
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:507
coord_type GetRight() const
Definition: box2.h:190
coord_type GetLeft() const
Definition: box2.h:194
coord_type GetBottom() const
Definition: box2.h:191
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
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:372
void SetStartX(int x)
Definition: eda_shape.h:140
int GetStartY() const
Definition: eda_shape.h:125
void SetEndY(int y)
Definition: eda_shape.h:159
PLOT_DASH_TYPE GetLineStyle() const
Definition: eda_shape.cpp:1715
int GetEndX() const
Definition: eda_shape.h:151
void SetStartY(int y)
Definition: eda_shape.h:134
void SetLineStyle(const PLOT_DASH_TYPE aStyle)
Definition: eda_shape.cpp:1709
SHAPE_T GetShape() const
Definition: eda_shape.h:117
int GetEndY() const
Definition: eda_shape.h:150
void SetEndX(int x)
Definition: eda_shape.h:165
VECTOR2I m_start
Definition: eda_shape.h:387
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:149
void SetStart(const VECTOR2I &aStart)
Definition: eda_shape.h:128
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:124
void SetShape(SHAPE_T aShape)
Definition: eda_shape.h:116
std::vector< VECTOR2I > GetRectCorners() const
Definition: eda_shape.cpp:1105
void SetEnd(const VECTOR2I &aEnd)
Definition: eda_shape.h:153
int GetStartX() const
Definition: eda_shape.h:126
VECTOR2I m_end
Definition: eda_shape.h:388
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:397
STROKE_PARAMS m_stroke
Definition: eda_shape.h:377
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:80
int GetTextHeight() const
Definition: eda_text.h:213
bool IsItalic() const
Definition: eda_text.h:141
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:131
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:95
KIFONT::FONT * GetFont() const
Definition: eda_text.h:199
void SetMirrored(bool isMirrored)
Definition: eda_text.cpp:233
virtual EDA_ANGLE GetDrawRotation() const
Definition: eda_text.h:315
int GetTextWidth() const
Definition: eda_text.h:210
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:257
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:416
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:160
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
Definition: eda_text.h:114
virtual KIFONT::FONT * getDrawFont() const
Definition: eda_text.cpp:461
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:183
bool IsMirrored() const
Definition: eda_text.h:150
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:305
bool IsBold() const
Definition: eda_text.h:144
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:908
virtual wxString GetShownText(bool aAllowExtraText, int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:106
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:202
int GetTextThickness() const
Definition: eda_text.h:123
void SetMultilineAllowed(bool aAllow)
Definition: eda_text.cpp:241
VECTOR2I GetTextSize() const
Definition: eda_text.h:207
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:249
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition: property.h:646
static ENUM_MAP< T > & Instance()
Definition: property.h:640
wxPGChoices & Choices()
Definition: property.h:689
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:131
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttributes, const METRICS &aFontMetrics) const
Draw a string.
Definition: font.cpp:251
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:582
Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:163
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:168
PCB specific render settings.
Definition: pcb_painter.h:76
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:68
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:409
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:212
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:112
virtual void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pcb_shape.cpp:306
int GetWidth() const override
Definition: pcb_shape.cpp:149
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:522
virtual std::vector< VECTOR2I > GetCorners() const
Return 4 corners for a rectangle or rotated rectangle (stored as a poly).
Definition: pcb_shape.cpp:207
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition: pcb_shape.cpp:97
STROKE_PARAMS GetStroke() const override
Definition: pcb_shape.h:82
virtual void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: pcb_shape.cpp:235
virtual void Mirror(const VECTOR2I &aCentre, bool aMirrorAroundXAxis)
Definition: pcb_shape.cpp:320
VECTOR2I GetPosition() const override
Definition: pcb_shape.h:70
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: pcb_shape.h:67
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
void SetBorderWidth(const int aSize)
bool IsBorderEnabled() const
Disables the border, this is done by changing the stroke internally.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth=false) const override
Convert the shape to a closed polygon.
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
bool m_borderEnabled
Controls drawing the border (as defined by the stroke members)
Definition: pcb_textbox.h:151
int GetTextMargin() const
Definition: pcb_textbox.cpp:57
void SetBorderEnabled(bool enabled)
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc) const
Function TransformTextToPolySet Convert the text to a polygonSet describing the actual character stro...
std::vector< VECTOR2I > GetAnchorAndOppositeCorner() const
EDA_ITEM * Clone() const override
Tests whether the border is disabled, as configured by the stroke.
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.
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
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:93
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
void SetTextAngle(const EDA_ANGLE &aAngle) override
PCB_TEXTBOX(BOARD_ITEM *parent)
Definition: pcb_textbox.cpp:41
void Move(const VECTOR2I &aMoveVector) override
Move this object.
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:63
VECTOR2I GetBotRight() const override
Definition: pcb_textbox.cpp:78
int GetBorderWidth() const
Definition: pcb_textbox.h:148
void ViewGetLayers(int aLayers[], int &aCount) const override
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
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
Definition: seg.h:42
VECTOR2I A
Definition: seg.h:49
VECTOR2I B
Definition: seg.h:50
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
virtual const VECTOR2I GetPoint(int aIndex) const override
int PointCount() const
Return the number of points (vertices) in this line chain.
virtual const SEG GetSegment(int aIndex) const override
int SegmentCount() const
Return the number of segments in this line chain.
Represent a set of closed polygons.
@ ROUND_ALL_CORNERS
All angles are rounded.
void Inflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, bool aSimplify=false)
Perform outline inflation/deflation.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
void Simplify(POLYGON_MODE aFastMode)
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFastMo...
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int NewOutline()
Creates a new empty polygon in the set and returns its index.
void SetWidth(int aWidth)
Definition: stroke_params.h:92
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:441
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:439
static constexpr EDA_ANGLE & ANGLE_270
Definition: eda_angle.h:442
#define PCB_EDIT_FRAME_NAME
SHAPE_T
Definition: eda_shape.h:42
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
@ ERROR_OUTSIDE
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:148
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
Definition: layer_ids.h:944
@ LAYER_LOCKED_ITEM_SHADOW
shadow layer for locked items
Definition: layer_ids.h:240
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
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:201
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:426
static struct PCB_TEXTBOX_DESC _PCB_TEXTBOX_DESC
#define TYPE_HASH(x)
Definition: property.h:64
#define REGISTER_TYPE(x)
Definition: property_mgr.h:356
wxString UnescapeString(const wxString &aSource)
PLOT_DASH_TYPE
Dashed line types.
Definition: stroke_params.h:48
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:92
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:588