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