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, see <https://www.gnu.org/licenses/>.
19 */
20
34
35#include <trigo.h>
36#include <eda_shape.h>
38#include <plotters/plotter.h>
41#include <bezier_curves.h>
42#include <callback_gal.h>
43#include <math/util.h> // for KiROUND
45
46PLOTTER::PLOTTER( const PROJECT* aProject ) :
47 m_project( aProject )
48{
49 m_plotScale = 1;
50 m_currentPenWidth = -1; // To-be-set marker
51 m_penState = 'Z'; // End-of-path idle
52 m_plotMirror = false; // Plot mirror option flag
54 m_yaxisReversed = false;
55 m_outputFile = nullptr;
56 m_colorMode = false; // Starts as a BW plot
57 m_negativeMode = false;
58
59 // Temporary init to avoid not initialized vars, will be set later
60 m_IUsPerDecimil = 1; // will be set later to the actual value
61 m_iuPerDeviceUnit = 1; // will be set later to the actual value
62 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
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 // This is the fallback plotter implementation for plotting an image as a rectangle.
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 const int radius = diametre / 2;
367
368 for( const DRILL_MARKERS::MARKER_PART& part : DRILL_MARKERS::BuildMarker( position, radius, aShapeId ) )
369 {
370 switch( part.m_Type )
371 {
373 MoveTo( part.m_Points.front() );
374 FinishTo( part.m_Points.back() );
375 break;
376
378 PlotPoly( part.m_Points, FILL_T::NO_FILL, GetCurrentLineWidth(), nullptr );
379 break;
380
382 Circle( position, part.m_Radius * 2, FILL_T::NO_FILL, GetCurrentLineWidth() );
383 break;
384 }
385 }
386}
387
388
389void PLOTTER::ThickOval( const VECTOR2I& aPos, const VECTOR2I& aSize, const EDA_ANGLE& aOrient,
390 int aWidth, void* aData )
391{
392 SetCurrentLineWidth( aWidth, aData );
393
394 EDA_ANGLE orient( aOrient );
395 VECTOR2I size( aSize );
396
397 if( size.x > size.y )
398 {
399 std::swap( size.x, size.y );
400 orient += ANGLE_90;
401 }
402
403 int deltaxy = size.y - size.x; /* distance between centers of the oval */
404 int radius = size.x / 2;
405
406 // Build a vertical oval shape giving the start and end points of arcs and edges,
407 // and the middle point of arcs
408 std::vector<VECTOR2I> corners;
409 corners.reserve( 6 );
410 // Shape is (x = corner and arc ends, c = arc centre)
411 // xcx
412 //
413 // xcx
414 int half_height = deltaxy / 2;
415 corners.emplace_back( -radius, -half_height );
416 corners.emplace_back( -radius, half_height );
417 corners.emplace_back( 0, half_height );
418 corners.emplace_back( radius, half_height );
419 corners.emplace_back( radius, -half_height );
420 corners.emplace_back( 0, -half_height );
421
422 // Rotate and move to the actual position
423 for( VECTOR2I& corner : corners )
424 {
425 RotatePoint( corner, orient );
426 corner += aPos;
427 }
428
429 // Gen shape (2 lines and 2 180 deg arcs):
430 MoveTo( corners[0] );
431 FinishTo( corners[1] );
432
433 Arc( corners[2], -orient, ANGLE_180, radius, FILL_T::NO_FILL, aWidth );
434
435 MoveTo( corners[3] );
436 FinishTo( corners[4] );
437
438 Arc( corners[5], -orient, -ANGLE_180, radius, FILL_T::NO_FILL, aWidth );
439}
440
441
442void PLOTTER::ThickSegment( const VECTOR2I& start, const VECTOR2I& end, int width, void* aData )
443{
444 if( start == end )
445 {
446 // The width parameter doubles as a sentinel. DO_NOT_SET_LINE_WIDTH means the
447 // caller already configured the pen so we use the live pen width as the diameter.
448 // USE_DEFAULT_LINE_WIDTH must be resolved through SetCurrentLineWidth so the pen
449 // is also set to the default value, otherwise we would emit whatever the prior
450 // pen width happened to be.
451 int diameter = width;
452
453 if( width == USE_DEFAULT_LINE_WIDTH )
454 {
455 SetCurrentLineWidth( width, aData );
456 diameter = GetCurrentLineWidth();
457 }
458 else if( width == DO_NOT_SET_LINE_WIDTH )
459 {
460 diameter = GetCurrentLineWidth();
461 }
462
463 wxCHECK2_MSG( diameter >= 0, return,
464 wxT( "Plotter called with unresolved line width sentinel" ) );
465
466 Circle( start, diameter, FILL_T::FILLED_SHAPE, 0 );
467 }
468 else
469 {
470 SetCurrentLineWidth( width );
471 MoveTo( start );
472 FinishTo( end );
473 }
474}
475
476
477void PLOTTER::ThickArc( const VECTOR2D& centre, const EDA_ANGLE& aStartAngle,
478 const EDA_ANGLE& aAngle, double aRadius, int aWidth, void* aData )
479{
480 Arc( centre, aStartAngle, aAngle, aRadius, FILL_T::NO_FILL, aWidth );
481}
482
483
484void PLOTTER::ThickArc( const EDA_SHAPE& aArcShape, void* aData, int aWidth )
485{
486 VECTOR2D center = aArcShape.getCenter();
487 VECTOR2D mid = aArcShape.GetArcMid();
488 VECTOR2D start = aArcShape.GetStart();
489 VECTOR2D end = aArcShape.GetEnd();
490
491 EDA_ANGLE startAngle( start - center );
492 EDA_ANGLE endAngle( end - center );
493 EDA_ANGLE angle = endAngle - startAngle;
494
495 // < 0: left, 0 : on the line, > 0 : right
496 double det = ( end - start ).Cross( mid - start );
497
498 if( det <= 0 ) // cw
499 angle.Normalize();
500 else
501 angle.NormalizeNegative();
502
503 double radius = ( start - center ).EuclideanNorm();
504
505 ThickArc( center, startAngle, angle, radius, aWidth, aData );
506}
507
508
509void PLOTTER::ThickRect( const VECTOR2I& p1, const VECTOR2I& p2, int width, void* aData )
510{
511 Rect( p1, p2, FILL_T::NO_FILL, width, 0 );
512}
513
514
515void PLOTTER::ThickCircle( const VECTOR2I& pos, int diametre, int width, void* aData )
516{
517 Circle( pos, diametre, FILL_T::NO_FILL, width );
518}
519
520
521void PLOTTER::FilledCircle( const VECTOR2I& pos, int diametre, void* aData )
522{
523 Circle( pos, diametre, FILL_T::FILLED_SHAPE, 0 );
524}
525
526
527void PLOTTER::ThickPoly( const SHAPE_POLY_SET& aPoly, int aWidth, void* aData )
528{
529 PlotPoly( aPoly.COutline( 0 ), FILL_T::NO_FILL, aWidth, aData );
530}
531
532
533void PLOTTER::PlotPoly( const SHAPE_LINE_CHAIN& aLineChain, FILL_T aFill, int aWidth, void* aData )
534{
535 std::vector<VECTOR2I> cornerList;
536 cornerList.reserve( aLineChain.PointCount() );
537
538 for( int ii = 0; ii < aLineChain.PointCount(); ii++ )
539 cornerList.emplace_back( aLineChain.CPoint( ii ) );
540
541 if( aLineChain.IsClosed() && cornerList.front() != cornerList.back() )
542 cornerList.emplace_back( aLineChain.CPoint( 0 ) );
543
544 PlotPoly( cornerList, aFill, aWidth, aData );
545}
546
547
548void PLOTTER::Text( const VECTOR2I& aPos,
549 const COLOR4D& aColor,
550 const wxString& aText,
551 const EDA_ANGLE& aOrient,
552 const VECTOR2I& aSize,
553 enum GR_TEXT_H_ALIGN_T aH_justify,
554 enum GR_TEXT_V_ALIGN_T aV_justify,
555 int aPenWidth,
556 bool aItalic,
557 bool aBold,
558 bool aMultilineAllowed,
559 KIFONT::FONT* aFont,
560 const KIFONT::METRICS& aFontMetrics,
561 void* aData )
562{
564 wxString text( aText );
565
566 if( text.Contains( wxS( "@{" ) ) )
567 {
568 EXPRESSION_EVALUATOR evaluator;
569 text = evaluator.Evaluate( text );
570 }
571
572 SetColor( aColor );
573
574 if( aPenWidth == 0 && aBold ) // Use default values if aPenWidth == 0
575 aPenWidth = GetPenSizeForBold( std::min( aSize.x, aSize.y ) );
576
577 if( aPenWidth < 0 )
578 aPenWidth = -aPenWidth;
579
580 CALLBACK_GAL callback_gal( empty_opts,
581 // Stroke callback
582 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
583 {
584 SetCurrentLineWidth( aPenWidth );
585 MoveTo( aPt1 );
586 LineTo( aPt2 );
587 PenFinish();
588 },
589 // Polygon callback
590 [&]( const SHAPE_LINE_CHAIN& aPoly )
591 {
592 PlotPoly( aPoly, FILL_T::FILLED_SHAPE, 0, aData );
593 } );
594
595 TEXT_ATTRIBUTES attributes;
596 attributes.m_Angle = aOrient;
597 attributes.m_StrokeWidth = aPenWidth;
598 attributes.m_Italic = aItalic;
599 attributes.m_Bold = aBold;
600 attributes.m_Halign = aH_justify;
601 attributes.m_Valign = aV_justify;
602 attributes.m_Size = aSize;
603
604 // if Size.x is < 0, the text is mirrored (we have no other param to know a text is mirrored)
605 if( attributes.m_Size.x < 0 )
606 {
607 attributes.m_Size.x = -attributes.m_Size.x;
608 attributes.m_Mirrored = true;
609 }
610
611 if( !aFont )
612 aFont = KIFONT::FONT::GetFont( m_renderSettings->GetDefaultFont() );
613
614 aFont->Draw( &callback_gal, text, aPos, attributes, aFontMetrics );
615}
616
617
618void PLOTTER::PlotText( const VECTOR2I& aPos,
619 const COLOR4D& aColor,
620 const wxString& aText,
621 const TEXT_ATTRIBUTES& aAttributes,
622 KIFONT::FONT* aFont,
623 const KIFONT::METRICS& aFontMetrics,
624 void* aData )
625{
627 wxString text( aText );
628
629 if( text.Contains( wxS( "@{" ) ) )
630 {
631 EXPRESSION_EVALUATOR evaluator;
632 text = evaluator.Evaluate( text );
633 }
634
635 TEXT_ATTRIBUTES attributes = aAttributes;
636 int penWidth = attributes.m_StrokeWidth;
637
638 SetColor( aColor );
639 SetCurrentLineWidth( penWidth, aData );
640
641 if( penWidth == 0 && attributes.m_Bold ) // Use default values if aPenWidth == 0
642 penWidth = GetPenSizeForBold( std::min( attributes.m_Size.x, attributes.m_Size.y ) );
643
644 if( penWidth < 0 )
645 penWidth = -penWidth;
646
647 attributes.m_StrokeWidth = penWidth;
648
649 CALLBACK_GAL callback_gal( empty_opts,
650 // Stroke callback
651 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
652 {
653 MoveTo( aPt1 );
654 LineTo( aPt2 );
655 PenFinish();
656 },
657 // Polygon callback
658 [&]( const SHAPE_LINE_CHAIN& aPoly )
659 {
660 PlotPoly( aPoly, FILL_T::FILLED_SHAPE, 0, aData );
661 } );
662
663 if( !aFont )
664 aFont = KIFONT::FONT::GetFont( m_renderSettings->GetDefaultFont() );
665
666 aFont->Draw( &callback_gal, text, aPos, attributes, aFontMetrics );
667}
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:982
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:228
EDA_ANGLE NormalizeNegative()
Definition eda_angle.h:247
double Sin() const
Definition eda_angle.h:177
double Cos() const
Definition eda_angle.h:196
VECTOR2I getCenter() const
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition eda_shape.h:333
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition eda_shape.h:283
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:94
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:144
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttributes, const METRICS &aFontMetrics, std::optional< VECTOR2I > aMousePos=std::nullopt, wxString *aActiveUrl=nullptr) const
Draw a string.
Definition font.cpp:243
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
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
double GetDashGapLenIU(int aLineWidth) const
Definition plotter.cpp:144
const PROJECT * m_project
Definition plotter.h:763
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:738
void Marker(const VECTOR2I &aPosition, int aDiameter, unsigned aShapeId)
Draw a pattern shape number aShapeId, to coord position.
Definition plotter.cpp:364
virtual void ThickPoly(const SHAPE_POLY_SET &aPoly, int aWidth, void *aData)
Definition plotter.cpp:527
bool m_plotMirror
Definition plotter.h:736
static const int USE_DEFAULT_LINE_WIDTH
Definition plotter.h:142
virtual void FilledCircle(const VECTOR2I &pos, int diametre, void *aData)
Definition plotter.cpp:521
void MoveTo(const VECTOR2I &pos)
Definition plotter.h:325
virtual void ThickOval(const VECTOR2I &aPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, int aWidth, void *aData)
Definition plotter.cpp:389
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:335
bool m_yaxisReversed
Definition plotter.h:739
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:733
PCB_LAYER_ID m_layer
Definition plotter.h:766
VECTOR2I m_plotOffset
Definition plotter.h:735
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:757
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:484
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width, int aCornerRadius=0)=0
char m_penState
Definition plotter.h:748
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:336
int m_currentPenWidth
Definition plotter.h:747
double m_plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition plotter.h:725
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:46
FILE * m_outputFile
Output file.
Definition plotter.h:742
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:330
void PenFinish()
Definition plotter.h:341
static const int DO_NOT_SET_LINE_WIDTH
Definition plotter.h:141
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, void *aData)
Definition plotter.cpp:442
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:618
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:509
RENDER_SETTINGS * m_renderSettings
Definition plotter.h:761
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:548
void markerBackSlash(const VECTOR2I &pos, int radius)
Plot a \ bar centered on the position.
Definition plotter.cpp:350
bool m_negativeMode
Definition plotter.h:746
double m_IUsPerDecimil
Definition plotter.h:731
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:515
virtual int GetCurrentLineWidth() const
Definition plotter.h:184
bool m_colorMode
Definition plotter.h:745
double GetDashMarkLenIU(int aLineWidth) const
Definition plotter.cpp:138
virtual void SetColor(const COLOR4D &color)=0
wxString m_filename
Definition plotter.h:752
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:63
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
EDA_ORIENTATION m_Angle
static constexpr EDA_ANGLE ANGLE_0
Definition eda_angle.h:448
static constexpr EDA_ANGLE ANGLE_90
Definition eda_angle.h:450
@ DEGREES_T
Definition eda_angle.h:30
static constexpr EDA_ANGLE ANGLE_180
Definition eda_angle.h:452
FILL_T
Definition eda_fill.h:29
@ NO_FILL
Definition eda_fill.h:30
@ FILLED_SHAPE
Fill with object color.
Definition eda_fill.h:31
int GetPenSizeForBold(int aTextSize)
Definition gr_text.cpp:34
@ UNDEFINED_LAYER
Definition layer_ids.h:57
std::vector< MARKER_PART > BuildMarker(const VECTOR2I &aPosition, int aRadius, unsigned aShapeId)
Decompose one mark, in the order the parts must be drawn.
One stroke of a mark.
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:227
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:540
constexpr int sign(T val)
Definition util.h:167
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707