KiCad PCB EDA Suite
Loading...
Searching...
No Matches
plotter.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) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
39#include <trigo.h>
40#include <plotters/plotter.h>
42#include <bezier_curves.h>
43#include <callback_gal.h>
44#include <math/util.h> // for KiROUND
46
47PLOTTER::PLOTTER( const PROJECT* aProject ) :
48 m_project( aProject )
49{
50 m_plotScale = 1;
51 m_currentPenWidth = -1; // To-be-set marker
52 m_penState = 'Z'; // End-of-path idle
53 m_plotMirror = false; // Plot mirror option flag
55 m_yaxisReversed = false;
56 m_outputFile = nullptr;
57 m_colorMode = false; // Starts as a BW plot
58 m_negativeMode = false;
59
60 // Temporary init to avoid not initialized vars, will be set later
61 m_IUsPerDecimil = 1; // will be set later to the actual value
62 m_iuPerDeviceUnit = 1; // will be set later to the actual value
63 m_renderSettings = nullptr;
64}
65
66
68{
69 // Emergency cleanup, but closing the file is usually made in EndPlot().
70 if( m_outputFile )
71 fclose( m_outputFile );
72}
73
74
75bool PLOTTER::OpenFile( const wxString& aFullFilename )
76{
77 m_filename = aFullFilename;
78
79 wxASSERT( !m_outputFile );
80
81 // Open the file in text mode (not suitable for all plotters but only for most of them.
82 m_outputFile = wxFopen( m_filename, wxT( "wt" ) );
83
84 if( m_outputFile == nullptr )
85 return false ;
86
87 return true;
88}
89
90
92{
93 VECTOR2I pos = aCoordinate - m_plotOffset;
94
95 double x = pos.x * m_plotScale;
96 double y = ( m_paperSize.y - pos.y * m_plotScale );
97
98 if( m_plotMirror )
99 {
101 x = ( m_paperSize.x - pos.x * m_plotScale );
102 else
103 y = pos.y * m_plotScale;
104 }
105
106 if( m_yaxisReversed )
107 y = m_paperSize.y - y;
108
111
112 return VECTOR2D( x, y );
113}
114
115
117{
118 return VECTOR2D( size.x * m_plotScale * m_iuPerDeviceUnit,
120}
121
122
123double PLOTTER::userToDeviceSize( double size ) const
124{
125 return size * m_plotScale * m_iuPerDeviceUnit;
126}
127
128
129#define IU_PER_MILS ( m_IUsPerDecimil * 10 )
130
131
132double PLOTTER::GetDotMarkLenIU( int aLineWidth ) const
133{
134 return userToDeviceSize( m_renderSettings->GetDotLength( aLineWidth ) );
135}
136
137
138double PLOTTER::GetDashMarkLenIU( int aLineWidth ) const
139{
140 return userToDeviceSize( m_renderSettings->GetDashLength( aLineWidth ) );
141}
142
143
144double PLOTTER::GetDashGapLenIU( int aLineWidth ) const
145{
146 return userToDeviceSize( m_renderSettings->GetGapLength( aLineWidth ) );
147}
148
149
150void PLOTTER::Arc( const VECTOR2D& aStart, const VECTOR2D& aMid, const VECTOR2D& aEnd, FILL_T aFill,
151 int aWidth )
152{
153 VECTOR2D aCenter = CalcArcCenter( aStart, aMid, aEnd );
154
155 EDA_ANGLE startAngle( aStart - aCenter );
156 EDA_ANGLE endAngle( aEnd - aCenter );
157
158 // < 0: left, 0 : on the line, > 0 : right
159 double det = ( aEnd - aStart ).Cross( aMid - aStart );
160
161 int cw = det <= 0;
162 EDA_ANGLE angle = endAngle - startAngle;
163
164 if( cw )
165 angle.Normalize();
166 else
167 angle.NormalizeNegative();
168
169 double radius = ( aStart - aCenter ).EuclideanNorm();
170 Arc( aCenter, startAngle, angle, radius, aFill, aWidth );
171}
172
173
174void PLOTTER::Arc( const VECTOR2D& aCenter, const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aAngle,
175 double aRadius, FILL_T aFill, int aWidth )
176{
177 polyArc( aCenter, aStartAngle, aAngle, aRadius, aFill, aWidth );
178}
179
180
181void PLOTTER::polyArc( const VECTOR2D& aCenter, const EDA_ANGLE& aStartAngle,
182 const EDA_ANGLE& aAngle, double aRadius, FILL_T aFill, int aWidth )
183{
184 EDA_ANGLE startAngle = aStartAngle;
185 EDA_ANGLE endAngle = startAngle + aAngle;
186 const EDA_ANGLE delta( 5.0, DEGREES_T ); // increment to draw arc
187 VECTOR2I start, end;
188 const int sign = 1;
189
190 if( aAngle < ANGLE_0 )
191 std::swap( startAngle, endAngle );
192
193 SetCurrentLineWidth( aWidth );
194
195 start.x = KiROUND( aCenter.x + aRadius * startAngle.Cos() );
196 start.y = KiROUND( aCenter.y + sign * aRadius * startAngle.Sin() );
197
198 if( aFill != FILL_T::NO_FILL )
199 {
200 MoveTo( aCenter );
201 LineTo( start );
202 }
203 else
204 {
205 MoveTo( start );
206 }
207
208 for( EDA_ANGLE ii = startAngle + delta; ii < endAngle; ii += delta )
209 {
210 end.x = KiROUND( aCenter.x + aRadius * ii.Cos() );
211 end.y = KiROUND( aCenter.y + sign * aRadius * ii.Sin() );
212 LineTo( end );
213 }
214
215 end.x = KiROUND( aCenter.x + aRadius * endAngle.Cos() );
216 end.y = KiROUND( aCenter.y + sign * aRadius * endAngle.Sin() );
217
218 if( aFill != FILL_T::NO_FILL )
219 {
220 LineTo( end );
221 FinishTo( aCenter );
222 }
223 else
224 {
225 FinishTo( end );
226 }
227}
228
229
230void PLOTTER::BezierCurve( const VECTOR2I& aStart, const VECTOR2I& aControl1,
231 const VECTOR2I& aControl2, const VECTOR2I& aEnd,
232 int aTolerance, int aLineThickness )
233{
234 // Generic fallback: Quadratic Bezier curve plotted as a polyline
235 std::vector<VECTOR2I> ctrlPoints;
236 ctrlPoints.reserve( 4 );
237
238 ctrlPoints.push_back( aStart );
239 ctrlPoints.push_back( aControl1 );
240 ctrlPoints.push_back( aControl2 );
241 ctrlPoints.push_back( aEnd );
242
243 BEZIER_POLY bezier_converter( ctrlPoints );
244
245 std::vector<VECTOR2I> approxPoints;
246 bezier_converter.GetPoly( approxPoints, aTolerance );
247
248 SetCurrentLineWidth( aLineThickness );
249 MoveTo( aStart );
250
251 for( unsigned ii = 1; ii < approxPoints.size()-1; ii++ )
252 LineTo( approxPoints[ii] );
253
254 FinishTo( aEnd );
255}
256
257
258void PLOTTER::PlotImage( const wxImage& aImage, const VECTOR2I& aPos, double aScaleFactor )
259{
260 VECTOR2I size( aImage.GetWidth() * aScaleFactor, aImage.GetHeight() * aScaleFactor );
261
262 VECTOR2I start = aPos;
263 start.x -= size.x / 2;
264 start.y -= size.y / 2;
265
266 VECTOR2I end = start;
267 end.x += size.x;
268 end.y += size.y;
269
270 Rect( start, end, FILL_T::NO_FILL, USE_DEFAULT_LINE_WIDTH );
271}
272
273
274void PLOTTER::markerSquare( const VECTOR2I& position, int radius )
275{
276 double r = KiROUND( radius / 1.4142 );
277 std::vector<VECTOR2I> corner_list;
278 VECTOR2I corner;
279
280 corner_list.reserve( 4 );
281
282 corner.x = position.x + r;
283 corner.y = position.y + r;
284 corner_list.push_back( corner );
285 corner.x = position.x + r;
286 corner.y = position.y - r;
287 corner_list.push_back( corner );
288 corner.x = position.x - r;
289 corner.y = position.y - r;
290 corner_list.push_back( corner );
291 corner.x = position.x - r;
292 corner.y = position.y + r;
293 corner_list.push_back( corner );
294 corner.x = position.x + r;
295 corner.y = position.y + r;
296 corner_list.push_back( corner );
297
298 PlotPoly( corner_list, FILL_T::NO_FILL, GetCurrentLineWidth(), nullptr );
299}
300
301
302void PLOTTER::markerCircle( const VECTOR2I& position, int radius )
303{
304 Circle( position, radius * 2, FILL_T::NO_FILL, GetCurrentLineWidth() );
305}
306
307
308void PLOTTER::markerLozenge( const VECTOR2I& position, int radius )
309{
310 std::vector<VECTOR2I> corner_list;
311 VECTOR2I corner;
312
313 corner_list.reserve( 4 );
314
315 corner.x = position.x;
316 corner.y = position.y + radius;
317 corner_list.push_back( corner );
318 corner.x = position.x + radius;
319 corner.y = position.y,
320 corner_list.push_back( corner );
321 corner.x = position.x;
322 corner.y = position.y - radius;
323 corner_list.push_back( corner );
324 corner.x = position.x - radius;
325 corner.y = position.y;
326 corner_list.push_back( corner );
327 corner.x = position.x;
328 corner.y = position.y + radius;
329 corner_list.push_back( corner );
330
331 PlotPoly( corner_list, FILL_T::NO_FILL, GetCurrentLineWidth(), nullptr );
332}
333
334
335void PLOTTER::markerHBar( const VECTOR2I& pos, int radius )
336{
337 MoveTo( VECTOR2I( pos.x - radius, pos.y ) );
338 FinishTo( VECTOR2I( pos.x + radius, pos.y ) );
339}
340
341
342void PLOTTER::markerSlash( const VECTOR2I& pos, int radius )
343{
344 MoveTo( VECTOR2I( pos.x - radius, pos.y - radius ) );
345 FinishTo( VECTOR2I( pos.x + radius, pos.y + radius ) );
346}
347
348
350{
351 MoveTo( VECTOR2I( pos.x + radius, pos.y - radius ) );
352 FinishTo( VECTOR2I( pos.x - radius, pos.y + radius ) );
353}
354
355
356void PLOTTER::markerVBar( const VECTOR2I& pos, int radius )
357{
358 MoveTo( VECTOR2I( pos.x, pos.y - radius ) );
359 FinishTo( VECTOR2I( pos.x, pos.y + radius ) );
360}
361
362
363void PLOTTER::Marker( const VECTOR2I& position, int diametre, unsigned aShapeId )
364{
365 int radius = diametre / 2;
366
367 /* Marker are composed by a series of 'parts' superimposed; not every
368 combination make sense, obviously. Since they are used in order I
369 tried to keep the uglier/more complex constructions at the end.
370 Also I avoided the |/ |\ -/ -\ construction because they're *very*
371 ugly... if needed they could be added anyway... I'd like to see
372 a board with more than 58 drilling/slotting tools!
373 If Visual C++ supported the 0b literals they would be optimally
374 and easily encoded as an integer array. We have to do with octal */
375 static const unsigned char marker_patterns[MARKER_COUNT] = {
376
377 // Bit order: O Square Lozenge - | \ /
378 // First choice: simple shapes
379 0003, // X
380 0100, // O
381 0014, // +
382 0040, // Sq
383 0020, // Lz
384
385 // Two simple shapes
386 0103, // X O
387 0017, // X +
388 0043, // X Sq
389 0023, // X Lz
390 0114, // O +
391 0140, // O Sq
392 0120, // O Lz
393 0054, // + Sq
394 0034, // + Lz
395 0060, // Sq Lz
396
397 // Three simple shapes
398 0117, // X O +
399 0143, // X O Sq
400 0123, // X O Lz
401 0057, // X + Sq
402 0037, // X + Lz
403 0063, // X Sq Lz
404 0154, // O + Sq
405 0134, // O + Lz
406 0074, // + Sq Lz
407
408 // Four simple shapes
409 0174, // O Sq Lz +
410 0163, // X O Sq Lz
411 0157, // X O Sq +
412 0137, // X O Lz +
413 0077, // X Sq Lz +
414
415 // This draws *everything *
416 0177, // X O Sq Lz +
417
418 // Here we use the single bars... so the cross is forbidden
419 0110, // O -
420 0104, // O |
421 0101, // O /
422 0050, // Sq -
423 0044, // Sq |
424 0041, // Sq /
425 0030, // Lz -
426 0024, // Lz |
427 0021, // Lz /
428 0150, // O Sq -
429 0144, // O Sq |
430 0141, // O Sq /
431 0130, // O Lz -
432 0124, // O Lz |
433 0121, // O Lz /
434 0070, // Sq Lz -
435 0064, // Sq Lz |
436 0061, // Sq Lz /
437 0170, // O Sq Lz -
438 0164, // O Sq Lz |
439 0161, // O Sq Lz /
440
441 // Last resort: the backlash component (easy to confound)
442 0102, // \ O
443 0042, // \ Sq
444 0022, // \ Lz
445 0142, // \ O Sq
446 0122, // \ O Lz
447 0062, // \ Sq Lz
448 0162 // \ O Sq Lz
449 };
450
451 if( aShapeId >= MARKER_COUNT )
452 {
453 // Fallback shape
454 markerCircle( position, radius );
455 }
456 else
457 {
458 // Decode the pattern and draw the corresponding parts
459 unsigned char pat = marker_patterns[aShapeId];
460
461 if( pat & 0001 )
462 markerSlash( position, radius );
463
464 if( pat & 0002 )
465 markerBackSlash( position, radius );
466
467 if( pat & 0004 )
468 markerVBar( position, radius );
469
470 if( pat & 0010 )
471 markerHBar( position, radius );
472
473 if( pat & 0020 )
474 markerLozenge( position, radius );
475
476 if( pat & 0040 )
477 markerSquare( position, radius );
478
479 if( pat & 0100 )
480 markerCircle( position, radius );
481 }
482}
483
484
485void PLOTTER::ThickOval( const VECTOR2I& aPos, const VECTOR2I& aSize, const EDA_ANGLE& aOrient,
486 int aWidth, void* aData )
487{
488 SetCurrentLineWidth( aWidth, aData );
489
490 EDA_ANGLE orient( aOrient );
491 VECTOR2I size( aSize );
492
493 if( size.x > size.y )
494 {
495 std::swap( size.x, size.y );
496 orient += ANGLE_90;
497 }
498
499 int deltaxy = size.y - size.x; /* distance between centers of the oval */
500 int radius = size.x / 2;
501
502 // Build a vertical oval shape giving the start and end points of arcs and edges,
503 // and the middle point of arcs
504 std::vector<VECTOR2I> corners;
505 corners.reserve( 6 );
506 // Shape is (x = corner and arc ends, c = arc centre)
507 // xcx
508 //
509 // xcx
510 int half_height = deltaxy / 2;
511 corners.emplace_back( -radius, -half_height );
512 corners.emplace_back( -radius, half_height );
513 corners.emplace_back( 0, half_height );
514 corners.emplace_back( radius, half_height );
515 corners.emplace_back( radius, -half_height );
516 corners.emplace_back( 0, -half_height );
517
518 // Rotate and move to the actual position
519 for( VECTOR2I& corner : corners )
520 {
521 RotatePoint( corner, orient );
522 corner += aPos;
523 }
524
525 // Gen shape (2 lines and 2 180 deg arcs):
526 MoveTo( corners[0] );
527 FinishTo( corners[1] );
528
529 Arc( corners[2], -orient, ANGLE_180, radius, FILL_T::NO_FILL, aWidth );
530
531 MoveTo( corners[3] );
532 FinishTo( corners[4] );
533
534 Arc( corners[5], -orient, -ANGLE_180, radius, FILL_T::NO_FILL, aWidth );
535}
536
537
538void PLOTTER::ThickSegment( const VECTOR2I& start, const VECTOR2I& end, int width, void* aData )
539{
540 if( start == end )
541 {
542 Circle( start, width, FILL_T::FILLED_SHAPE, 0 );
543 }
544 else
545 {
546 SetCurrentLineWidth( width );
547 MoveTo( start );
548 FinishTo( end );
549 }
550}
551
552
553void PLOTTER::ThickArc( const VECTOR2D& centre, const EDA_ANGLE& aStartAngle,
554 const EDA_ANGLE& aAngle, double aRadius, int aWidth, void* aData )
555{
556 Arc( centre, aStartAngle, aAngle, aRadius, FILL_T::NO_FILL, aWidth );
557}
558
559
560void PLOTTER::ThickArc( const EDA_SHAPE& aArcShape, void* aData, int aWidth )
561{
562 VECTOR2D center = aArcShape.getCenter();
563 VECTOR2D mid = aArcShape.GetArcMid();
564 VECTOR2D start = aArcShape.GetStart();
565 VECTOR2D end = aArcShape.GetEnd();
566
567 EDA_ANGLE startAngle( start - center );
568 EDA_ANGLE endAngle( end - center );
569 EDA_ANGLE angle = endAngle - startAngle;
570
571 // < 0: left, 0 : on the line, > 0 : right
572 double det = ( end - start ).Cross( mid - start );
573
574 if( det <= 0 ) // cw
575 angle.Normalize();
576 else
577 angle.NormalizeNegative();
578
579 double radius = ( start - center ).EuclideanNorm();
580
581 ThickArc( center, startAngle, angle, radius, aWidth, aData );
582}
583
584
585void PLOTTER::ThickRect( const VECTOR2I& p1, const VECTOR2I& p2, int width, void* aData )
586{
587 Rect( p1, p2, FILL_T::NO_FILL, width );
588}
589
590
591void PLOTTER::ThickCircle( const VECTOR2I& pos, int diametre, int width, void* aData )
592{
593 Circle( pos, diametre, FILL_T::NO_FILL, width );
594}
595
596
597void PLOTTER::FilledCircle( const VECTOR2I& pos, int diametre, void* aData )
598{
599 Circle( pos, diametre, FILL_T::FILLED_SHAPE, 0 );
600}
601
602
603void PLOTTER::ThickPoly( const SHAPE_POLY_SET& aPoly, int aWidth, void* aData )
604{
605 PlotPoly( aPoly.COutline( 0 ), FILL_T::NO_FILL, aWidth, aData );
606}
607
608
609void PLOTTER::PlotPoly( const SHAPE_LINE_CHAIN& aCornerList, FILL_T aFill, int aWidth, void* aData )
610{
611 std::vector<VECTOR2I> cornerList;
612 cornerList.reserve( aCornerList.PointCount() );
613
614 for( int ii = 0; ii < aCornerList.PointCount(); ii++ )
615 cornerList.emplace_back( aCornerList.CPoint( ii ) );
616
617 if( aCornerList.IsClosed() && cornerList.front() != cornerList.back() )
618 cornerList.emplace_back( aCornerList.CPoint( 0 ) );
619
620 PlotPoly( cornerList, aFill, aWidth, aData );
621}
622
623
624void PLOTTER::Text( const VECTOR2I& aPos,
625 const COLOR4D& aColor,
626 const wxString& aText,
627 const EDA_ANGLE& aOrient,
628 const VECTOR2I& aSize,
629 enum GR_TEXT_H_ALIGN_T aH_justify,
630 enum GR_TEXT_V_ALIGN_T aV_justify,
631 int aPenWidth,
632 bool aItalic,
633 bool aBold,
634 bool aMultilineAllowed,
635 KIFONT::FONT* aFont,
636 const KIFONT::METRICS& aFontMetrics,
637 void* aData )
638{
640
641 SetColor( aColor );
642
643 if( aPenWidth == 0 && aBold ) // Use default values if aPenWidth == 0
644 aPenWidth = GetPenSizeForBold( std::min( aSize.x, aSize.y ) );
645
646 if( aPenWidth < 0 )
647 aPenWidth = -aPenWidth;
648
649 CALLBACK_GAL callback_gal( empty_opts,
650 // Stroke callback
651 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
652 {
653 SetCurrentLineWidth( aPenWidth );
654 MoveTo( aPt1 );
655 LineTo( aPt2 );
656 PenFinish();
657 },
658 // Polygon callback
659 [&]( const SHAPE_LINE_CHAIN& aPoly )
660 {
661 PlotPoly( aPoly, FILL_T::FILLED_SHAPE, 0, aData );
662 } );
663
664 TEXT_ATTRIBUTES attributes;
665 attributes.m_Angle = aOrient;
666 attributes.m_StrokeWidth = aPenWidth;
667 attributes.m_Italic = aItalic;
668 attributes.m_Bold = aBold;
669 attributes.m_Halign = aH_justify;
670 attributes.m_Valign = aV_justify;
671 attributes.m_Size = aSize;
672
673 // if Size.x is < 0, the text is mirrored (we have no other param to know a text is mirrored)
674 if( attributes.m_Size.x < 0 )
675 {
676 attributes.m_Size.x = -attributes.m_Size.x;
677 attributes.m_Mirrored = true;
678 }
679
680 if( !aFont )
681 aFont = KIFONT::FONT::GetFont();
682
683 aFont->Draw( &callback_gal, aText, aPos, attributes, aFontMetrics );
684}
685
686
687void PLOTTER::PlotText( const VECTOR2I& aPos,
688 const COLOR4D& aColor,
689 const wxString& aText,
690 const TEXT_ATTRIBUTES& aAttributes,
691 KIFONT::FONT* aFont,
692 const KIFONT::METRICS& aFontMetrics,
693 void* aData )
694{
696
697 TEXT_ATTRIBUTES attributes = aAttributes;
698 int penWidth = attributes.m_StrokeWidth;
699
700 SetColor( aColor );
701 SetCurrentLineWidth( penWidth, aData );
702
703 if( penWidth == 0 && attributes.m_Bold ) // Use default values if aPenWidth == 0
704 penWidth = GetPenSizeForBold( std::min( attributes.m_Size.x, attributes.m_Size.y ) );
705
706 if( penWidth < 0 )
707 penWidth = -penWidth;
708
709 attributes.m_StrokeWidth = penWidth;
710
711 CALLBACK_GAL callback_gal( empty_opts,
712 // Stroke callback
713 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
714 {
715 MoveTo( aPt1 );
716 LineTo( aPt2 );
717 PenFinish();
718 },
719 // Polygon callback
720 [&]( const SHAPE_LINE_CHAIN& aPoly )
721 {
722 PlotPoly( aPoly, FILL_T::FILLED_SHAPE, 0, aData );
723 } );
724
725 if( !aFont )
726 aFont = KIFONT::FONT::GetFont();
727
728 aFont->Draw( &callback_gal, aText, aPos, attributes, aFontMetrics );
729}
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition: box2.h:990
Bezier curves to polygon converter.
Definition: bezier_curves.h:38
void GetPoly(std::vector< VECTOR2I > &aOutput, int aMaxError=10)
Convert a Bezier curve to a polygon.
EDA_ANGLE Normalize()
Definition: eda_angle.h:224
EDA_ANGLE NormalizeNegative()
Definition: eda_angle.h:241
double Sin() const
Definition: eda_angle.h:173
double Cos() const
Definition: eda_angle.h:192
VECTOR2I getCenter() const
Definition: eda_shape.cpp:929
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:215
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:173
VECTOR2I GetArcMid() const
Definition: eda_shape.cpp:974
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:131
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false, const std::vector< wxString > *aEmbeddedFiles=nullptr, bool aForDrawingSheet=false)
Definition: font.cpp:147
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:250
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
double GetGapLength(int aLineWidth) const
double GetDotLength(int aLineWidth) const
double GetDashLength(int aLineWidth) const
double GetDotMarkLenIU(int aLineWidth) const
Definition: plotter.cpp:132
virtual void PlotImage(const wxImage &aImage, const VECTOR2I &aPos, double aScaleFactor)
Only PostScript plotters can plot bitmaps.
Definition: plotter.cpp:258
static const unsigned MARKER_COUNT
Draw a marker (used for the drill map).
Definition: plotter.h:491
double GetDashGapLenIU(int aLineWidth) const
Definition: plotter.cpp:144
virtual void Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width)=0
virtual bool OpenFile(const wxString &aFullFilename)
Open or create the plot file aFullFilename.
Definition: plotter.cpp:75
bool m_mirrorIsHorizontal
Definition: plotter.h:656
virtual void ThickPoly(const SHAPE_POLY_SET &aPoly, int aWidth, void *aData)
Definition: plotter.cpp:603
bool m_plotMirror
Definition: plotter.h:654
static const int USE_DEFAULT_LINE_WIDTH
Definition: plotter.h:125
virtual void FilledCircle(const VECTOR2I &pos, int diametre, void *aData)
Definition: plotter.cpp:597
void MoveTo(const VECTOR2I &pos)
Definition: plotter.h:261
virtual void ThickOval(const VECTOR2I &aPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, int aWidth, void *aData)
Definition: plotter.cpp:485
void markerSlash(const VECTOR2I &pos, int radius)
Plot a / bar centered on the position.
Definition: plotter.cpp:342
void FinishTo(const VECTOR2I &pos)
Definition: plotter.h:271
bool m_yaxisReversed
Definition: plotter.h:657
virtual void polyArc(const VECTOR2D &aCentre, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle, double aRadius, FILL_T aFill, int aWidth)
Generic fallback: arc rendered as a polyline.
Definition: plotter.cpp:181
double m_iuPerDeviceUnit
Definition: plotter.h:651
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width)=0
VECTOR2I m_plotOffset
Definition: plotter.h:653
virtual VECTOR2D userToDeviceCoordinates(const VECTOR2I &aCoordinate)
Modify coordinates according to the orientation, scale factor, and offsets trace.
Definition: plotter.cpp:91
virtual ~PLOTTER()
Definition: plotter.cpp:67
VECTOR2I m_paperSize
Definition: plotter.h:675
virtual VECTOR2D userToDeviceSize(const VECTOR2I &size)
Modify size according to the plotter scale factors (VECTOR2I version, returns a VECTOR2D).
Definition: plotter.cpp:116
virtual void ThickArc(const EDA_SHAPE &aArcShape, void *aData, int aWidth)
Definition: plotter.cpp:560
char m_penState
Definition: plotter.h:666
void Marker(const VECTOR2I &position, int diametre, unsigned aShapeId)
Draw a pattern shape number aShapeId, to coord position.
Definition: plotter.cpp:363
virtual void BezierCurve(const VECTOR2I &aStart, const VECTOR2I &aControl1, const VECTOR2I &aControl2, const VECTOR2I &aEnd, int aTolerance, int aLineThickness)
Generic fallback: Cubic Bezier curve rendered as a polyline.
Definition: plotter.cpp:230
void markerHBar(const VECTOR2I &pos, int radius)
Plot a - bar centered on the position.
Definition: plotter.cpp:335
int m_currentPenWidth
Definition: plotter.h:665
double m_plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plotter.h:643
void markerCircle(const VECTOR2I &pos, int radius)
Plot a circle centered on the position.
Definition: plotter.cpp:302
PLOTTER(const PROJECT *aProject=nullptr)
Definition: plotter.cpp:47
FILE * m_outputFile
Output file.
Definition: plotter.h:660
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
void LineTo(const VECTOR2I &pos)
Definition: plotter.h:266
void PenFinish()
Definition: plotter.h:277
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, void *aData)
Definition: plotter.cpp:538
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont=nullptr, const KIFONT::METRICS &aFontMetrics=KIFONT::METRICS::Default(), void *aData=nullptr)
Definition: plotter.cpp:687
void markerLozenge(const VECTOR2I &position, int radius)
Plot a lozenge centered on the position.
Definition: plotter.cpp:308
virtual void PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth, void *aData)=0
Draw a polygon ( filled or not ).
virtual void ThickRect(const VECTOR2I &p1, const VECTOR2I &p2, int width, void *aData)
Definition: plotter.cpp:585
RENDER_SETTINGS * m_renderSettings
Definition: plotter.h:679
virtual void Text(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aPenWidth, bool aItalic, bool aBold, bool aMultilineAllowed, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr)
Draw text with the plotter.
Definition: plotter.cpp:624
void markerBackSlash(const VECTOR2I &pos, int radius)
Plot a \ bar centered on the position.
Definition: plotter.cpp:349
bool m_negativeMode
Definition: plotter.h:664
double m_IUsPerDecimil
Definition: plotter.h:649
void markerVBar(const VECTOR2I &pos, int radius)
Plot a | bar centered on the position.
Definition: plotter.cpp:356
void markerSquare(const VECTOR2I &position, int radius)
Plot a square centered on the position.
Definition: plotter.cpp:274
virtual void ThickCircle(const VECTOR2I &pos, int diametre, int width, void *aData)
Definition: plotter.cpp:591
virtual int GetCurrentLineWidth() const
Definition: plotter.h:167
bool m_colorMode
Definition: plotter.h:663
double GetDashMarkLenIU(int aLineWidth) const
Definition: plotter.cpp:138
virtual void SetColor(const COLOR4D &color)=0
wxString m_filename
Definition: plotter.h:670
virtual void Arc(const VECTOR2D &aStart, const VECTOR2D &aMid, const VECTOR2D &aEnd, FILL_T aFill, int aWidth)
Definition: plotter.cpp:150
Container for project specific data.
Definition: project.h:65
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
bool IsClosed() const override
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.
Represent a set of closed polygons.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
static constexpr EDA_ANGLE ANGLE_0
Definition: eda_angle.h:404
static constexpr EDA_ANGLE ANGLE_90
Definition: eda_angle.h:406
@ DEGREES_T
Definition: eda_angle.h:31
static constexpr EDA_ANGLE ANGLE_180
Definition: eda_angle.h:408
FILL_T
Definition: eda_shape.h:56
int GetPenSizeForBold(int aTextSize)
Definition: gr_text.cpp:36
bool cw
VECTOR2I center
int radius
VECTOR2I end
constexpr int delta
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
GR_TEXT_V_ALIGN_T
This is API surface mapped to common.types.VertialAlignment.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
Definition: trigo.cpp:229
const VECTOR2I CalcArcCenter(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Determine the center of an arc or circle given three points on its circumference.
Definition: trigo.cpp:521
constexpr int sign(T val)
Definition: util.h:159
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695
VECTOR2< double > VECTOR2D
Definition: vector2d.h:694