KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ds_draw_item.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) 1992-2013 Jean-Pierre Charras <jp.charras at wanadoo.fr>.
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22/*
23 * the class DS_DATA_ITEM (and DS_DATA_ITEM_TEXT) defines
24 * a basic shape of a drawing sheet (frame references and title block)
25 * Basic shapes are line, rect and texts
26 * the DS_DATA_ITEM coordinates units is the mm, and are relative to
27 * one of 4 page corners.
28 *
29 * These items cannot be drawn or plot "as this". they should be converted
30 * to a "draw list" (DS_DRAW_ITEM_BASE and derived items)
31
32 * The list of these items is stored in a DS_DATA_MODEL instance.
33 *
34 * When building the draw list:
35 * the DS_DATA_MODEL is used to create a DS_DRAW_ITEM_LIST
36 * coordinates are converted to draw/plot coordinates.
37 * texts are expanded if they contain format symbols.
38 * Items with m_RepeatCount > 1 are created m_RepeatCount times
39 *
40 * the DS_DATA_MODEL is created only once.
41 * the DS_DRAW_ITEM_LIST is created each time the drawing sheet is plotted/drawn
42 *
43 * the DS_DATA_MODEL instance is created from a S expression which
44 * describes the drawing sheet (can be the default drawing sheet or a custom file).
45 */
46
47#include <eda_draw_frame.h>
51#include <base_units.h>
52#include <page_info.h>
53#include <layer_ids.h>
54#include <gr_basic.h>
55#include <trigo.h>
56#include <render_settings.h>
57#include <font/font.h>
58
59
60// ============================ BASE CLASS ==============================
61
66
67
68std::vector<int> DS_DRAW_ITEM_BASE::ViewGetLayers() const
69{
70 std::vector<int> layers( 1 );
71
72 if( m_peer == nullptr )
73 {
74 layers[0] = LAYER_DRAWINGSHEET;
75 return layers;
76 }
77
78 if( m_peer->GetPage1Option() == FIRST_PAGE_ONLY )
79 layers[0] = LAYER_DRAWINGSHEET_PAGE1;
80 else if( m_peer->GetPage1Option() == SUBSEQUENT_PAGES )
81 layers[0] = LAYER_DRAWINGSHEET_PAGEn;
82 else
83 layers[0] = LAYER_DRAWINGSHEET;
84
85 return layers;
86}
87
88
89bool DS_DRAW_ITEM_BASE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
90{
91 BOX2I sel = aRect;
92
93 if ( aAccuracy )
94 sel.Inflate( aAccuracy );
95
96 if( aContained )
97 return sel.Contains( GetBoundingBox() );
98
99 return sel.Intersects( GetBoundingBox() );
100}
101
102
104 std::vector<MSG_PANEL_ITEM>& aList )
105{
106 wxString msg;
107 DS_DATA_ITEM* dataItem = GetPeer();
108
109 if( dataItem == nullptr ) // Is only a pure graphic item used in drawing sheet editor to
110 // handle the page limits
111 return;
112
113 switch( dataItem->GetType() )
114 {
116 aList.emplace_back( _( "Line" ), wxEmptyString );
117 break;
118
120 aList.emplace_back( _( "Rectangle" ), wxEmptyString );
121 break;
122
124 {
125 DS_DRAW_ITEM_TEXT* textItem = static_cast<DS_DRAW_ITEM_TEXT*>( this );
126
127 // Don't use GetShownText(); we want to see the variable references here
128 aList.emplace_back( _( "Text" ), KIUI::EllipsizeStatusText( aFrame, textItem->GetText() ) );
129 break;
130 }
131
133 aList.emplace_back( _( "Imported Shape" ), wxEmptyString );
134 break;
135
137 aList.emplace_back( _( "Image" ), wxEmptyString );
138 break;
139 }
140
141 switch( dataItem->GetPage1Option() )
142 {
143 case FIRST_PAGE_ONLY: msg = _( "First Page Only" ); break;
144 case SUBSEQUENT_PAGES: msg = _( "Subsequent Pages" ); break;
145 default: msg = _( "All Pages" ); break;
146 }
147
148 aList.emplace_back( _( "First Page Option" ), msg );
149
151 dataItem->m_RepeatCount );
152 aList.emplace_back( _( "Repeat Count" ), msg );
153
155 dataItem->m_IncrementLabel );
156 aList.emplace_back( _( "Repeat Label Increment" ), msg );
157
158 msg.Printf( wxT( "(%s, %s)" ),
159 aFrame->MessageTextFromValue( dataItem->m_IncrementVector.x ),
160 aFrame->MessageTextFromValue( dataItem->m_IncrementVector.y ) );
161
162 aList.emplace_back( _( "Repeat Position Increment" ), msg );
163
164 aList.emplace_back( _( "Comment" ), dataItem->m_Info );
165}
166
167
168// ============================ TEXT ==============================
169
170void DS_DRAW_ITEM_TEXT::PrintWsItem( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
171{
172 COLOR4D color = GetTextColor();
173
174 if( color == COLOR4D::UNSPECIFIED )
175 color = aSettings->GetLayerColor( LAYER_DRAWINGSHEET );
176
177 Print( aSettings, aOffset, color );
178}
179
180
182{
183 // A really dumb over-approximation because doing it for real (even with the stroke font)
184 // shows up large in profiles.
185
186 const TEXT_ATTRIBUTES& attrs = GetAttributes();
187 const wxString text = GetShownText( true );
188 BOX2I bbox( GetTextPos() );
189
190 bbox.SetWidth( KiROUND( (int) text.length() * attrs.m_Size.x * 1.3 ) );
191 bbox.SetHeight( attrs.m_Size.y );
192
193 switch( attrs.m_Halign )
194 {
195 case GR_TEXT_H_ALIGN_LEFT: break;
196 case GR_TEXT_H_ALIGN_CENTER: bbox.Offset( - (int) bbox.GetWidth() / 2, 0 ); break;
197 case GR_TEXT_H_ALIGN_RIGHT: bbox.Offset( - (int) bbox.GetWidth(), 0 ); break;
199 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
200 break;
201 }
202
203 switch( GetAttributes().m_Valign )
204 {
205 case GR_TEXT_V_ALIGN_TOP: break;
206 case GR_TEXT_V_ALIGN_CENTER: bbox.Offset( 0, - (int) bbox.GetHeight() / 2 ); break;
207 case GR_TEXT_V_ALIGN_BOTTOM: bbox.Offset( 0, - (int) bbox.GetHeight() ); break;
209 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
210 break;
211 }
212
213 bbox.Inflate( attrs.m_Size.x, attrs.m_Size.y / 2 );
214 return bbox;
215}
216
217
219{
220 return EDA_TEXT::GetTextBox( nullptr );
221}
222
223
224bool DS_DRAW_ITEM_TEXT::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
225{
226 return EDA_TEXT::TextHitTest( aPosition, aAccuracy );
227}
228
229
230bool DS_DRAW_ITEM_TEXT::HitTest( const BOX2I& aRect, bool aContains, int aAccuracy ) const
231{
232 return EDA_TEXT::TextHitTest( aRect, aContains, aAccuracy );
233}
234
235
236wxString DS_DRAW_ITEM_TEXT::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
237{
238 return wxString::Format( _( "Text '%s'" ),
239 aFull ? GetShownText( false ) : KIUI::EllipsizeMenuText( GetText() ) );
240}
241
242
243// ============================ POLYGON =================================
244
246 const VECTOR2I& aOffset )
247{
248 wxDC* DC = aSettings->GetPrintDC();
249 COLOR4D color = aSettings->GetLayerColor( LAYER_DRAWINGSHEET );
250 int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
251
252 std::vector<VECTOR2I> points_moved;
253
254 for( int idx = 0; idx < m_Polygons.OutlineCount(); ++idx )
255 {
256 points_moved.clear();
257 SHAPE_LINE_CHAIN& outline = m_Polygons.Outline( idx );
258
259 for( int ii = 0; ii < outline.PointCount(); ii++ )
260 {
261 points_moved.emplace_back( outline.CPoint( ii ).x + aOffset.x,
262 outline.CPoint( ii ).y + aOffset.y );
263 }
264
265 GRPoly( DC, (int) points_moved.size(), &points_moved[0], true, penWidth, color, color );
266 }
267}
268
269
271{
272 // Note: m_pos is the anchor point of the shape.
273 VECTOR2I move_vect = aPos - m_pos;
274 m_pos = aPos;
275
276 // Move polygon corners to the new position:
277 m_Polygons.Move( move_vect );
278}
279
280
282{
283 return m_Polygons.BBox();
284}
285
286
287bool DS_DRAW_ITEM_POLYPOLYGONS::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
288{
289 return m_Polygons.Collide( aPosition, aAccuracy );
290}
291
292
293bool DS_DRAW_ITEM_POLYPOLYGONS::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
294{
295 BOX2I sel = aRect;
296
297 if ( aAccuracy )
298 sel.Inflate( aAccuracy );
299
300 if( aContained )
301 return sel.Contains( GetBoundingBox() );
302
303 // Fast test: if rect is outside the polygon bounding box, then they cannot intersect
304 if( !sel.Intersects( GetBoundingBox() ) )
305 return false;
306
307 for( int idx = 0; idx < m_Polygons.OutlineCount(); ++idx )
308 {
309 const SHAPE_LINE_CHAIN& outline = m_Polygons.COutline( idx );
310
311 for( int ii = 0; ii < outline.PointCount(); ii++ )
312 {
313 VECTOR2I corner( outline.CPoint( ii ).x, outline.CPoint( ii ).y );
314
315 // Test if the point is within aRect
316 if( sel.Contains( corner ) )
317 return true;
318
319 // Test if this edge intersects aRect
320 int ii_next = (ii+1) % outline.PointCount();
321 VECTOR2I next_corner( outline.CPoint( ii_next ).x, outline.CPoint( ii_next ).y );
322
323 if( sel.Intersects( corner, next_corner ) )
324 return true;
325 }
326 }
327
328 return false;
329}
330
331
332wxString DS_DRAW_ITEM_POLYPOLYGONS::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
333{
334 return _( "Imported shape" );
335}
336
337
338// ============================ RECT ==============================
339
340void DS_DRAW_ITEM_RECT::PrintWsItem( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
341{
342 wxDC* DC = aSettings->GetPrintDC();
343 COLOR4D color = aSettings->GetLayerColor( LAYER_DRAWINGSHEET );
344 int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
345
346 GRRect( DC, GetStart() + aOffset, GetEnd() + aOffset, penWidth, color );
347}
348
349
351{
352 return BOX2I( GetStart(), GetEnd() - GetStart() );
353}
354
355
356bool DS_DRAW_ITEM_RECT::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
357{
358 int dist = aAccuracy + ( GetPenWidth() / 2 );
359 VECTOR2I start = GetStart();
361 end.x = GetEnd().x;
362 end.y = start.y;
363
364 // Upper line
365 if( TestSegmentHit( aPosition, start, end, dist ) )
366 return true;
367
368 // Right line
369 start = end;
370 end.y = GetEnd().y;
371
372 if( TestSegmentHit( aPosition, start, end, dist ) )
373 return true;
374
375 // lower line
376 start = end;
377 end.x = GetStart().x;
378
379 if( TestSegmentHit( aPosition, start, end, dist ) )
380 return true;
381
382 // left line
383 start = end;
384 end = GetStart();
385
386 if( TestSegmentHit( aPosition, start, end, dist ) )
387 return true;
388
389 return false;
390}
391
392
393bool DS_DRAW_ITEM_RECT::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
394{
395 BOX2I sel = aRect;
396
397 if ( aAccuracy )
398 sel.Inflate( aAccuracy );
399
400 if( aContained )
401 return sel.Contains( GetBoundingBox() );
402
403 // For greedy we need to check each side of the rect as we're pretty much always inside the
404 // rect which defines the drawing-sheet frame.
405 BOX2I side = GetBoundingBox();
406 side.SetHeight( 0 );
407
408 if( sel.Intersects( side ) )
409 return true;
410
411 side.SetY( GetBoundingBox().GetBottom() );
412
413 if( sel.Intersects( side ) )
414 return true;
415
416 side = GetBoundingBox();
417 side.SetWidth( 0 );
418
419 if( sel.Intersects( side ) )
420 return true;
421
422 side.SetX( GetBoundingBox().GetRight() );
423
424 if( sel.Intersects( side ) )
425 return true;
426
427 return false;
428}
429
430
431wxString DS_DRAW_ITEM_RECT::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
432{
433 return wxString::Format( _( "Rectangle, width %s height %s" ),
434 aUnitsProvider->MessageTextFromValue( std::abs( GetStart().x - GetEnd().x ) ),
435 aUnitsProvider->MessageTextFromValue( std::abs( GetStart().y - GetEnd().y ) ) );
436}
437
438
439// ============================ LINE ==============================
440
441void DS_DRAW_ITEM_LINE::PrintWsItem( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
442{
443 wxDC* DC = aSettings->GetPrintDC();
444 COLOR4D color = aSettings->GetLayerColor( LAYER_DRAWINGSHEET );
445 int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
446
447 GRLine( DC, GetStart() + aOffset, GetEnd() + aOffset, penWidth, color );
448}
449
450
452{
453 return BOX2I( GetStart(), GetEnd() - GetStart() );
454}
455
456
457bool DS_DRAW_ITEM_LINE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
458{
459 int mindist = aAccuracy + ( GetPenWidth() / 2 ) + 1;
460 return TestSegmentHit( aPosition, GetStart(), GetEnd(), mindist );
461}
462
463
464wxString DS_DRAW_ITEM_LINE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
465{
466 return wxString::Format( _( "Line, length %s" ),
467 aUnitsProvider->MessageTextFromValue( GetStart().Distance( GetEnd() ) ) );
468}
469
470
471// ============== BITMAP ================
472
473void DS_DRAW_ITEM_BITMAP::PrintWsItem( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
474{
476
477 if( !bitmap->m_ImageBitmap )
478 return;
479
480 bitmap->m_ImageBitmap->DrawBitmap( aSettings->GetPrintDC(), m_pos + aOffset,
481 aSettings->GetBackgroundColor() );
482}
483
484
486{
487 const DS_DATA_ITEM_BITMAP* bitmap = static_cast<const DS_DATA_ITEM_BITMAP*>( m_peer );
488 BOX2I bbox;
489
490 if( bitmap && bitmap->m_ImageBitmap )
491 {
492 VECTOR2I bm_size = bitmap->m_ImageBitmap->GetSize();
493 bbox.SetSize( bm_size );
494 bbox.SetOrigin( m_pos.x - bm_size.x / 2, m_pos.y - bm_size.y / 2 );
495 }
496
497 return bbox;
498}
499
500
501bool DS_DRAW_ITEM_BITMAP::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
502{
503 BOX2I bbox = GetBoundingBox();
504 bbox.Inflate( aAccuracy );
505
506 return bbox.Contains( aPosition );
507}
508
509
510bool DS_DRAW_ITEM_BITMAP::HitTest( const BOX2I& aRect, bool aContains, int aAccuracy ) const
511{
512 return DS_DRAW_ITEM_BASE::HitTest( aRect, aContains, aAccuracy );
513}
514
515
516wxString DS_DRAW_ITEM_BITMAP::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
517{
518 return _( "Image" );
519}
520
521
522wxString DS_DRAW_ITEM_PAGE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
523{
524 return _( "Page limits" );
525}
526
527
529{
530 BOX2I dummy;
531
532 // We want this graphic item always visible. So gives the max size to the
533 // bounding box to avoid any clamping:
534 dummy.SetMaximum();
535
536 return dummy;
537}
538
539
540// ====================== DS_DRAW_ITEM_LIST ==============================
541
543 const TITLE_BLOCK& aTitleBlock )
544{
546
547 m_titleBlock = &aTitleBlock;
548 m_paperFormat = aPageInfo.GetTypeAsString();
549
550 // Build the basic layout shape, if the layout list is empty
551 if( model.GetCount() == 0 && !model.VoidListAllowed() )
552 model.LoadDrawingSheet( wxEmptyString, nullptr );
553
554 model.SetupDrawEnvironment( aPageInfo, GetMilsToIUfactor() );
555
556 for( DS_DATA_ITEM* wsItem : model.GetItems() )
557 {
558 // Generate it only if the page option allows this
559 if( wsItem->GetPage1Option() == FIRST_PAGE_ONLY && !m_isFirstPage )
560 continue;
561 else if( wsItem->GetPage1Option() == SUBSEQUENT_PAGES && m_isFirstPage )
562 continue;
563
564 wsItem->SyncDrawItems( this, nullptr );
565 }
566}
567
568
570{
571 std::vector<DS_DRAW_ITEM_BASE*> second_items;
572
573 for( DS_DRAW_ITEM_BASE* item = GetFirst(); item; item = GetNext() )
574 {
575 if( item->Type() == WSG_BITMAP_T )
576 item->PrintWsItem( aSettings );
577 else
578 second_items.push_back( item );
579 }
580
581 for( DS_DRAW_ITEM_BASE* item : second_items )
582 item->PrintWsItem( aSettings );
583}
584
585
constexpr EDA_IU_SCALE unityScale
Definition base_units.h:124
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:986
void DrawBitmap(wxDC *aDC, const VECTOR2I &aPos, const KIGFX::COLOR4D &aBackgroundColor=KIGFX::COLOR4D::UNSPECIFIED) const
VECTOR2I GetSize() const
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition box2.h:554
constexpr void SetHeight(size_type val)
Definition box2.h:288
constexpr void SetOrigin(const Vec &pos)
Definition box2.h:233
constexpr size_type GetWidth() const
Definition box2.h:210
constexpr void SetSize(const SizeVec &size)
Definition box2.h:244
constexpr size_type GetHeight() const
Definition box2.h:211
constexpr bool Contains(const Vec &aPoint) const
Definition box2.h:164
constexpr void SetWidth(size_type val)
Definition box2.h:283
constexpr void SetX(coord_type val)
Definition box2.h:273
constexpr void SetY(coord_type val)
Definition box2.h:278
constexpr void Offset(coord_type dx, coord_type dy)
Definition box2.h:255
constexpr bool Intersects(const BOX2< Vec > &aRect) const
Definition box2.h:307
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:398
BITMAP_BASE * m_ImageBitmap
Drawing sheet structure type definitions.
PAGE_OPTION GetPage1Option() const
DS_ITEM_TYPE GetType() const
VECTOR2D m_IncrementVector
wxString m_Info
Handle the graphic items list to draw/plot the frame and title block.
static DS_DATA_MODEL & GetTheInstance()
Return the instance of DS_DATA_MODEL used in the application.
Base class to handle basic graphic items.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
const BOX2I GetBoundingBox() const override=0
Return the orthogonal bounding box of this object for display purposes.
virtual int GetPenWidth() const
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.
DS_DATA_ITEM * GetPeer() const
const KIFONT::METRICS & GetFontMetrics() const
DS_DATA_ITEM * m_peer
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
void PrintWsItem(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void PrintWsItem(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
DS_DRAW_ITEM_BASE * GetFirst()
void BuildDrawItemsList(const PAGE_INFO &aPageInfo, const TITLE_BLOCK &aTitleBlock)
Drawing or plot the drawing sheet.
void Print(const RENDER_SETTINGS *aSettings)
Draws the item list created by BuildDrawItemsList.
const TITLE_BLOCK * m_titleBlock
bool m_isFirstPage
Is this the first page or not.
double GetMilsToIUfactor()
Get the scalar to convert pages units (mils) to draw/plot units.
DS_DRAW_ITEM_BASE * GetNext()
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
SHAPE_POLY_SET m_Polygons
The list of polygons.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void SetPosition(const VECTOR2I &aPos) override
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
void PrintWsItem(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
const VECTOR2I & GetEnd() const
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
const VECTOR2I & GetStart() const
void PrintWsItem(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
A graphic text.
void PrintWsItem(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
virtual const BOX2I GetApproxBBox() override
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
The base class for create windows for drawing purpose.
COLOR4D GetTextColor() const
Definition eda_text.h:291
virtual VECTOR2I GetTextPos() const
Definition eda_text.h:294
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:110
BOX2I GetTextBox(const RENDER_SETTINGS *aSettings, int aLine=-1) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
Definition eda_text.cpp:773
virtual bool TextHitTest(const VECTOR2I &aPoint, int aAccuracy=0) const
Test if aPoint is within the bounds of this object.
Definition eda_text.cpp:902
const TEXT_ATTRIBUTES & GetAttributes() const
Definition eda_text.h:252
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, const COLOR4D &aColor)
Print this text object to the device context aDC.
Definition eda_text.cpp:921
virtual wxString GetShownText(bool aAllowExtraText, int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition eda_text.h:121
static const METRICS & Default()
Definition font.cpp:48
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
virtual const COLOR4D & GetBackgroundColor() const =0
Return current background color settings.
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition page_info.h:75
wxString GetTypeAsString() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
int PointCount() const
Return the number of points (vertices) in this line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
GR_TEXT_H_ALIGN_T m_Halign
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition title_block.h:37
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
@ FIRST_PAGE_ONLY
@ SUBSEQUENT_PAGES
#define _(s)
void GRRect(wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor)
Definition gr_basic.cpp:397
void GRLine(wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, wxPenStyle aStyle)
Definition gr_basic.cpp:171
void GRPoly(wxDC *DC, int n, const VECTOR2I *Points, bool Fill, int width, const COLOR4D &Color, const COLOR4D &BgColor)
Draw a new polyline and fill it if Fill, in drawing space.
Definition gr_basic.cpp:342
@ LAYER_DRAWINGSHEET_PAGEn
Sheet Editor previewing pages after first page.
Definition layer_ids.h:323
@ LAYER_DRAWINGSHEET
Sheet frame and title block.
Definition layer_ids.h:274
@ LAYER_DRAWINGSHEET_PAGE1
Sheet Editor previewing first page.
Definition layer_ids.h:322
KICOMMON_API wxString MessageTextFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A helper to convert the double length aValue to a string in inches, millimeters, or unscaled units.
KICOMMON_API wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
KICOMMON_API wxString EllipsizeStatusText(wxWindow *aWindow, const wxString &aString)
Ellipsize text (at the end) to be no more than 1/3 of the window width.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition eda_angle.h:400
std::vector< FAB_LAYER_COLOR > dummy
KIBIS_MODEL * model
VECTOR2I end
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_H_ALIGN_INDETERMINATE
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_INDETERMINATE
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP
bool TestSegmentHit(const VECTOR2I &aRefPoint, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
Definition trigo.cpp:171
@ WSG_BITMAP_T
Definition typeinfo.h:217
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683