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 (C) 1992-2023 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, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26/*
27 * the class DS_DATA_ITEM (and DS_DATA_ITEM_TEXT) defines
28 * a basic shape of a drawing sheet (frame references and title block)
29 * Basic shapes are line, rect and texts
30 * the DS_DATA_ITEM coordinates units is the mm, and are relative to
31 * one of 4 page corners.
32 *
33 * These items cannot be drawn or plot "as this". they should be converted
34 * to a "draw list" (DS_DRAW_ITEM_BASE and derived items)
35
36 * The list of these items is stored in a DS_DATA_MODEL instance.
37 *
38 * When building the draw list:
39 * the DS_DATA_MODEL is used to create a DS_DRAW_ITEM_LIST
40 * coordinates are converted to draw/plot coordinates.
41 * texts are expanded if they contain format symbols.
42 * Items with m_RepeatCount > 1 are created m_RepeatCount times
43 *
44 * the DS_DATA_MODEL is created only once.
45 * the DS_DRAW_ITEM_LIST is created each time the drawing sheet is plotted/drawn
46 *
47 * the DS_DATA_MODEL instance is created from a S expression which
48 * describes the drawing sheet (can be the default drawing sheet or a custom file).
49 */
50
51#include <eda_draw_frame.h>
55#include <base_units.h>
56#include <page_info.h>
57#include <layer_ids.h>
58#include <gr_basic.h>
59#include <trigo.h>
60#include <render_settings.h>
61#include <font/font.h>
62
63
64// ============================ BASE CLASS ==============================
65
67{
69}
70
71
72std::vector<int> DS_DRAW_ITEM_BASE::ViewGetLayers() const
73{
74 std::vector<int> layers( 1 );
75
76 if( m_peer == nullptr )
77 {
78 layers[0] = LAYER_DRAWINGSHEET;
79 return layers;
80 }
81
83 layers[0] = LAYER_DRAWINGSHEET_PAGE1;
85 layers[0] = LAYER_DRAWINGSHEET_PAGEn;
86 else
87 layers[0] = LAYER_DRAWINGSHEET;
88
89 return layers;
90}
91
92
93// A generic HitTest that can be used by some, but not all, sub-classes.
94bool DS_DRAW_ITEM_BASE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
95{
96 BOX2I sel = aRect;
97
98 if ( aAccuracy )
99 sel.Inflate( aAccuracy );
100
101 if( aContained )
102 return sel.Contains( GetBoundingBox() );
103
104 return sel.Intersects( GetBoundingBox() );
105}
106
107
109 std::vector<MSG_PANEL_ITEM>& aList )
110{
111 wxString msg;
112 DS_DATA_ITEM* dataItem = GetPeer();
113
114 if( dataItem == nullptr ) // Is only a pure graphic item used in drawing sheet editor to
115 // handle the page limits
116 return;
117
118 switch( dataItem->GetType() )
119 {
121 aList.emplace_back( _( "Line" ), wxEmptyString );
122 break;
123
125 aList.emplace_back( _( "Rectangle" ), wxEmptyString );
126 break;
127
129 {
130 DS_DRAW_ITEM_TEXT* textItem = static_cast<DS_DRAW_ITEM_TEXT*>( this );
131 // Don't use GetShownText(); we want to see the variable references here
132 aList.emplace_back( _( "Text" ), KIUI::EllipsizeStatusText( aFrame, textItem->GetText() ) );
133 break;
134 }
135
137 aList.emplace_back( _( "Imported Shape" ), wxEmptyString );
138 break;
139
141 aList.emplace_back( _( "Image" ), wxEmptyString );
142 break;
143 }
144
145 switch( dataItem->GetPage1Option() )
146 {
147 case FIRST_PAGE_ONLY: msg = _( "First Page Only" ); break;
148 case SUBSEQUENT_PAGES: msg = _( "Subsequent Pages" ); break;
149 default: msg = _( "All Pages" ); break;
150 }
151
152 aList.emplace_back( _( "First Page Option" ), msg );
153
154 msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( unityScale, EDA_UNITS::UNSCALED,
155 dataItem->m_RepeatCount );
156 aList.emplace_back( _( "Repeat Count" ), msg );
157
158 msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( unityScale, EDA_UNITS::UNSCALED,
159 dataItem->m_IncrementLabel );
160 aList.emplace_back( _( "Repeat Label Increment" ), msg );
161
162 msg.Printf( wxT( "(%s, %s)" ),
163 aFrame->MessageTextFromValue( dataItem->m_IncrementVector.x ),
164 aFrame->MessageTextFromValue( dataItem->m_IncrementVector.y ) );
165
166 aList.emplace_back( _( "Repeat Position Increment" ), msg );
167
168 aList.emplace_back( _( "Comment" ), dataItem->m_Info );
169}
170
171
172// ============================ TEXT ==============================
173
174void DS_DRAW_ITEM_TEXT::PrintWsItem( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
175{
177
178 if( color == COLOR4D::UNSPECIFIED )
179 color = aSettings->GetLayerColor( LAYER_DRAWINGSHEET );
180
181 Print( aSettings, aOffset, color, FILLED );
182}
183
184
186{
187 // A really dumb over-approximation because doing it for real (even with the stroke font)
188 // shows up large in profiles.
189
190 const TEXT_ATTRIBUTES& attrs = GetAttributes();
191 const wxString text = GetShownText( true );
192 BOX2I bbox( GetTextPos() );
193
194 bbox.SetWidth( KiROUND( (int) text.length() * attrs.m_Size.x * 1.3 ) );
195 bbox.SetHeight( attrs.m_Size.y );
196
197 switch( attrs.m_Halign )
198 {
199 case GR_TEXT_H_ALIGN_LEFT: break;
200 case GR_TEXT_H_ALIGN_CENTER: bbox.Offset( - (int) bbox.GetWidth() / 2, 0 ); break;
201 case GR_TEXT_H_ALIGN_RIGHT: bbox.Offset( - (int) bbox.GetWidth(), 0 ); break;
203 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
204 break;
205 }
206
207 switch( GetAttributes().m_Valign )
208 {
209 case GR_TEXT_V_ALIGN_TOP: break;
210 case GR_TEXT_V_ALIGN_CENTER: bbox.Offset( 0, - (int) bbox.GetHeight() / 2 ); break;
211 case GR_TEXT_V_ALIGN_BOTTOM: bbox.Offset( 0, - (int) bbox.GetHeight() ); break;
213 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
214 break;
215 }
216
217 bbox.Inflate( attrs.m_Size.x, attrs.m_Size.y / 2 );
218 return bbox;
219}
220
221
223{
224 return EDA_TEXT::GetTextBox();
225}
226
227
228bool DS_DRAW_ITEM_TEXT::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
229{
230 return EDA_TEXT::TextHitTest( aPosition, aAccuracy );
231}
232
233
234bool DS_DRAW_ITEM_TEXT::HitTest( const BOX2I& aRect, bool aContains, int aAccuracy ) const
235{
236 return EDA_TEXT::TextHitTest( aRect, aContains, aAccuracy );
237}
238
239
240wxString DS_DRAW_ITEM_TEXT::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
241{
242 return wxString::Format( _( "Text '%s'" ),
243 aFull ? GetShownText( false ) : KIUI::EllipsizeMenuText( GetText() ) );
244}
245
246
247// ============================ POLYGON =================================
248
250 const VECTOR2I& aOffset )
251{
252 wxDC* DC = aSettings->GetPrintDC();
254 int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
255
256 std::vector<VECTOR2I> points_moved;
257
258 for( int idx = 0; idx < m_Polygons.OutlineCount(); ++idx )
259 {
260 points_moved.clear();
261 SHAPE_LINE_CHAIN& outline = m_Polygons.Outline( idx );
262
263 for( int ii = 0; ii < outline.PointCount(); ii++ )
264 {
265 points_moved.emplace_back( outline.CPoint( ii ).x + aOffset.x,
266 outline.CPoint( ii ).y + aOffset.y );
267 }
268
269 GRPoly( DC, (int) points_moved.size(), &points_moved[0], true, penWidth, color, color );
270 }
271}
272
273
275{
276 // Note: m_pos is the anchor point of the shape.
277 VECTOR2I move_vect = aPos - m_pos;
278 m_pos = aPos;
279
280 // Move polygon corners to the new position:
281 m_Polygons.Move( move_vect );
282}
283
284
286{
287 return m_Polygons.BBox();
288}
289
290
291bool DS_DRAW_ITEM_POLYPOLYGONS::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
292{
293 return m_Polygons.Collide( aPosition, aAccuracy );
294}
295
296
297bool DS_DRAW_ITEM_POLYPOLYGONS::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
298{
299 BOX2I sel = aRect;
300
301 if ( aAccuracy )
302 sel.Inflate( aAccuracy );
303
304 if( aContained )
305 return sel.Contains( GetBoundingBox() );
306
307 // Fast test: if rect is outside the polygon bounding box, then they cannot intersect
308 if( !sel.Intersects( GetBoundingBox() ) )
309 return false;
310
311 for( int idx = 0; idx < m_Polygons.OutlineCount(); ++idx )
312 {
313 const SHAPE_LINE_CHAIN& outline = m_Polygons.COutline( idx );
314
315 for( int ii = 0; ii < outline.PointCount(); ii++ )
316 {
317 VECTOR2I corner( outline.CPoint( ii ).x, outline.CPoint( ii ).y );
318
319 // Test if the point is within aRect
320 if( sel.Contains( corner ) )
321 return true;
322
323 // Test if this edge intersects aRect
324 int ii_next = (ii+1) % outline.PointCount();
325 VECTOR2I next_corner( outline.CPoint( ii_next ).x, outline.CPoint( ii_next ).y );
326
327 if( sel.Intersects( corner, next_corner ) )
328 return true;
329 }
330 }
331
332 return false;
333}
334
335
336wxString DS_DRAW_ITEM_POLYPOLYGONS::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
337{
338 return _( "Imported Shape" );
339}
340
341
342// ============================ RECT ==============================
343
344void DS_DRAW_ITEM_RECT::PrintWsItem( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
345{
346 wxDC* DC = aSettings->GetPrintDC();
348 int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
349
350 GRRect( DC, GetStart() + aOffset, GetEnd() + aOffset, penWidth, color );
351}
352
353
355{
356 return BOX2I( GetStart(), GetEnd() - GetStart() );
357}
358
359
360bool DS_DRAW_ITEM_RECT::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
361{
362 int dist = aAccuracy + ( GetPenWidth() / 2 );
363 VECTOR2I start = GetStart();
364 VECTOR2I end;
365 end.x = GetEnd().x;
366 end.y = start.y;
367
368 // Upper line
369 if( TestSegmentHit( aPosition, start, end, dist ) )
370 return true;
371
372 // Right line
373 start = end;
374 end.y = GetEnd().y;
375
376 if( TestSegmentHit( aPosition, start, end, dist ) )
377 return true;
378
379 // lower line
380 start = end;
381 end.x = GetStart().x;
382
383 if( TestSegmentHit( aPosition, start, end, dist ) )
384 return true;
385
386 // left line
387 start = end;
388 end = GetStart();
389
390 if( TestSegmentHit( aPosition, start, end, dist ) )
391 return true;
392
393 return false;
394}
395
396
397bool DS_DRAW_ITEM_RECT::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
398{
399 BOX2I sel = aRect;
400
401 if ( aAccuracy )
402 sel.Inflate( aAccuracy );
403
404 if( aContained )
405 return sel.Contains( GetBoundingBox() );
406
407 // For greedy we need to check each side of the rect as we're pretty much always inside the
408 // rect which defines the drawing-sheet frame.
409 BOX2I side = GetBoundingBox();
410 side.SetHeight( 0 );
411
412 if( sel.Intersects( side ) )
413 return true;
414
415 side.SetY( GetBoundingBox().GetBottom() );
416
417 if( sel.Intersects( side ) )
418 return true;
419
420 side = GetBoundingBox();
421 side.SetWidth( 0 );
422
423 if( sel.Intersects( side ) )
424 return true;
425
426 side.SetX( GetBoundingBox().GetRight() );
427
428 if( sel.Intersects( side ) )
429 return true;
430
431 return false;
432}
433
434
435wxString DS_DRAW_ITEM_RECT::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
436{
437 return wxString::Format( _( "Rectangle, width %s height %s" ),
438 aUnitsProvider->MessageTextFromValue( std::abs( GetStart().x - GetEnd().x ) ),
439 aUnitsProvider->MessageTextFromValue( std::abs( GetStart().y - GetEnd().y ) ) );
440}
441
442
443// ============================ LINE ==============================
444
445void DS_DRAW_ITEM_LINE::PrintWsItem( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
446{
447 wxDC* DC = aSettings->GetPrintDC();
449 int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
450
451 GRLine( DC, GetStart() + aOffset, GetEnd() + aOffset, penWidth, color );
452}
453
454
456{
457 return BOX2I( GetStart(), GetEnd() - GetStart() );
458}
459
460
461bool DS_DRAW_ITEM_LINE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
462{
463 int mindist = aAccuracy + ( GetPenWidth() / 2 ) + 1;
464 return TestSegmentHit( aPosition, GetStart(), GetEnd(), mindist );
465}
466
467
468wxString DS_DRAW_ITEM_LINE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
469{
470 return wxString::Format( _( "Line, length %s" ),
471 aUnitsProvider->MessageTextFromValue( GetStart().Distance( GetEnd() ) ) );
472}
473
474
475// ============== BITMAP ================
476
477void DS_DRAW_ITEM_BITMAP::PrintWsItem( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
478{
480
481 if( !bitmap->m_ImageBitmap )
482 return;
483
484 bitmap->m_ImageBitmap->DrawBitmap( aSettings->GetPrintDC(), m_pos + aOffset,
485 aSettings->GetBackgroundColor() );
486}
487
488
490{
491 const DS_DATA_ITEM_BITMAP* bitmap = static_cast<const DS_DATA_ITEM_BITMAP*>( m_peer );
492 BOX2I bbox;
493
494 if( bitmap && bitmap->m_ImageBitmap )
495 {
496 VECTOR2I bm_size = bitmap->m_ImageBitmap->GetSize();
497 bbox.SetSize( bm_size );
498 bbox.SetOrigin( m_pos.x - bm_size.x / 2, m_pos.y - bm_size.y / 2 );
499 }
500
501 return bbox;
502}
503
504
505bool DS_DRAW_ITEM_BITMAP::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
506{
507 BOX2I bbox = GetBoundingBox();
508 bbox.Inflate( aAccuracy );
509
510 return bbox.Contains( aPosition );
511}
512
513
514bool DS_DRAW_ITEM_BITMAP::HitTest( const BOX2I& aRect, bool aContains, int aAccuracy ) const
515{
516 return DS_DRAW_ITEM_BASE::HitTest( aRect, aContains, aAccuracy );
517}
518
519
520wxString DS_DRAW_ITEM_BITMAP::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
521{
522 return _( "Image" );
523}
524
525
526wxString DS_DRAW_ITEM_PAGE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
527{
528 return _( "Page Limits" );
529}
530
531
533{
534 BOX2I dummy;
535
536 // We want this graphic item always visible. So gives the max size to the
537 // bounding box to avoid any clamping:
538 dummy.SetMaximum();
539
540 return dummy;
541}
542
543
544// ====================== DS_DRAW_ITEM_LIST ==============================
545
547 const TITLE_BLOCK& aTitleBlock )
548{
550
551 m_titleBlock = &aTitleBlock;
552 m_paperFormat = aPageInfo.GetType();
553
554 // Build the basic layout shape, if the layout list is empty
555 if( model.GetCount() == 0 && !model.VoidListAllowed() )
556 model.LoadDrawingSheet( wxEmptyString, nullptr );
557
558 model.SetupDrawEnvironment( aPageInfo, GetMilsToIUfactor() );
559
560 for( DS_DATA_ITEM* wsItem : model.GetItems() )
561 {
562 // Generate it only if the page option allows this
563 if( wsItem->GetPage1Option() == FIRST_PAGE_ONLY && !m_isFirstPage )
564 continue;
565 else if( wsItem->GetPage1Option() == SUBSEQUENT_PAGES && m_isFirstPage )
566 continue;
567
568 wsItem->SyncDrawItems( this, nullptr );
569 }
570}
571
572
573/* Print the item list created by BuildDrawItemsList
574 * aDC = the current Device Context
575 * The not selected items are drawn first (most of items)
576 * The selected items are drawn after (usually 0 or 1)
577 * to be sure they are seen, even for overlapping items
578 */
580{
581 std::vector<DS_DRAW_ITEM_BASE*> second_items;
582
583 for( DS_DRAW_ITEM_BASE* item = GetFirst(); item; item = GetNext() )
584 {
585 if( item->Type() == WSG_BITMAP_T )
586 item->PrintWsItem( aSettings );
587 else
588 second_items.push_back( item );
589 }
590
591 for( DS_DRAW_ITEM_BASE* item : second_items )
592 item->PrintWsItem( aSettings );
593}
594
595
int color
Definition: DXF_plotter.cpp:58
constexpr EDA_IU_SCALE unityScale
Definition: base_units.h:111
BOX2< VECTOR2I > BOX2I
Definition: box2.h:922
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition: box2.h:990
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:558
constexpr void SetHeight(size_type val)
Definition: box2.h:292
constexpr void SetOrigin(const Vec &pos)
Definition: box2.h:237
constexpr size_type GetWidth() const
Definition: box2.h:214
constexpr void SetSize(const SizeVec &size)
Definition: box2.h:248
constexpr size_type GetHeight() const
Definition: box2.h:215
constexpr bool Contains(const Vec &aPoint) const
Definition: box2.h:168
constexpr void SetWidth(size_type val)
Definition: box2.h:287
constexpr void SetX(coord_type val)
Definition: box2.h:277
constexpr void SetY(coord_type val)
Definition: box2.h:282
constexpr void Offset(coord_type dx, coord_type dy)
Definition: box2.h:259
constexpr bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:311
BITMAP_BASE * m_ImageBitmap
Definition: ds_data_item.h:370
Drawing sheet structure type definitions.
Definition: ds_data_item.h:96
PAGE_OPTION GetPage1Option() const
Definition: ds_data_item.h:133
DS_ITEM_TYPE GetType() const
Definition: ds_data_item.h:128
VECTOR2D m_IncrementVector
Definition: ds_data_item.h:204
wxString m_Info
Definition: ds_data_item.h:199
int m_IncrementLabel
Definition: ds_data_item.h:205
Handle the graphic items list to draw/plot the frame and title block.
Definition: ds_data_model.h:39
bool LoadDrawingSheet(const wxString &aFullFileName, wxString *aMsg, bool aAppend=false)
Populates the list with a custom layout or the default layout if no custom layout is available.
void SetupDrawEnvironment(const PAGE_INFO &aPageInfo, double aMilsToIU)
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
unsigned GetCount() const
bool VoidListAllowed()
Definition: ds_data_model.h:88
std::vector< DS_DATA_ITEM * > & GetItems()
Base class to handle basic graphic items.
Definition: ds_draw_item.h:59
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: ds_draw_item.h:101
const BOX2I GetBoundingBox() const override=0
Return the orthogonal bounding box of this object for display purposes.
virtual int GetPenWidth() const
Definition: ds_draw_item.h:70
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
Definition: ds_draw_item.h:63
const KIFONT::METRICS & GetFontMetrics() const
DS_DATA_ITEM * m_peer
Definition: ds_draw_item.h:123
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
Definition: ds_draw_item.h:144
const VECTOR2I & GetEnd() const
Definition: ds_draw_item.h:146
DS_DRAW_ITEM_BASE * GetFirst()
Definition: ds_draw_item.h:511
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.
wxString m_paperFormat
Definition: ds_draw_item.h:574
const TITLE_BLOCK * m_titleBlock
Definition: ds_draw_item.h:573
bool m_isFirstPage
Is this the first page or not.
Definition: ds_draw_item.h:570
double GetMilsToIUfactor()
Get the scalar to convert pages units (mils) to draw/plot units.
Definition: ds_draw_item.h:475
DS_DRAW_ITEM_BASE * GetNext()
Definition: ds_draw_item.h:521
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.
Definition: ds_draw_item.h:206
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
Definition: ds_draw_item.h:233
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
const VECTOR2I & GetStart() const
Definition: ds_draw_item.h:231
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.
Definition: ds_draw_item.h:313
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.
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:253
COLOR4D GetTextColor() const
Definition: eda_text.h:250
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:94
BOX2I GetTextBox(int aLine=-1) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
Definition: eda_text.cpp:616
virtual bool TextHitTest(const VECTOR2I &aPoint, int aAccuracy=0) const
Test if aPoint is within the bounds of this object.
Definition: eda_text.cpp:750
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:214
virtual wxString GetShownText(bool aAllowExtraText, int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:105
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, const COLOR4D &aColor, OUTLINE_MODE aDisplay_mode=FILLED)
Print this text object to the device context aDC.
Definition: eda_text.cpp:769
static const METRICS & Default()
Definition: font.cpp:52
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.
int GetDefaultPenWidth() const
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.
wxDC * GetPrintDC() const
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:59
const wxString & GetType() const
Definition: page_info.h:99
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.
bool Collide(const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance,...
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int OutlineCount() const
Return the number of outlines in the set.
void Move(const VECTOR2I &aVector) override
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
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:41
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
Definition: ds_data_item.h:58
@ SUBSEQUENT_PAGES
Definition: ds_data_item.h:59
#define _(s)
void GRRect(wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor)
Definition: gr_basic.cpp:396
void GRLine(wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:171
static const bool FILLED
Definition: gr_basic.cpp:30
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:341
@ LAYER_DRAWINGSHEET_PAGEn
for drawingsheetEditor previewing
Definition: layer_ids.h:251
@ LAYER_DRAWINGSHEET
drawingsheet frame and titleblock
Definition: layer_ids.h:218
@ LAYER_DRAWINGSHEET_PAGE1
for drawingsheetEditor previewing
Definition: layer_ids.h:250
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.
Definition: eda_units.cpp:408
KICOMMON_API wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
Definition: ui_common.cpp:213
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.
Definition: ui_common.cpp:195
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:390
std::vector< FAB_LAYER_COLOR > dummy
@ 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:175
@ WSG_BITMAP_T
Definition: typeinfo.h:219