You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

705 lines
26 KiB

10 months ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2016 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. #ifndef PLOT_COMMON_H_
  25. #define PLOT_COMMON_H_
  26. #include <eda_shape.h>
  27. #include <vector>
  28. #include <math/box2.h>
  29. #include <gr_text.h>
  30. #include <page_info.h>
  31. #include <outline_mode.h>
  32. #include <gal/color4d.h>
  33. #include <stroke_params.h>
  34. #include <render_settings.h>
  35. #include <font/font.h>
  36. class COLOR_SETTINGS;
  37. class SHAPE_ARC;
  38. class SHAPE_POLY_SET;
  39. class SHAPE_LINE_CHAIN;
  40. class GBR_NETLIST_METADATA;
  41. class PROJECT;
  42. using KIGFX::RENDER_SETTINGS;
  43. // Must be in the same order as the drop-down list in the plot dialog inside pcbnew
  44. // Units (inch/mm for DXF plotter
  45. enum class DXF_UNITS
  46. {
  47. INCH = 0, // Do not use MM: it conficts with a Windows header
  48. MM = 1
  49. };
  50. /**
  51. * The set of supported output plot formats.
  52. *
  53. They should be kept in order of the radio buttons in the plot panel/windows.
  54. */
  55. enum class PLOT_FORMAT
  56. {
  57. UNDEFINED = -1,
  58. FIRST_FORMAT = 0,
  59. HPGL = FIRST_FORMAT,
  60. GERBER,
  61. POST,
  62. DXF,
  63. PDF,
  64. SVG,
  65. LAST_FORMAT = SVG
  66. };
  67. /**
  68. * Which kind of text to output with the PSLIKE plotters.
  69. *
  70. * You can:
  71. * 1) only use the internal vector font
  72. * 2) only use native postscript fonts
  73. * 3) use the internal vector font and add 'phantom' text to aid
  74. * searching
  75. * 4) keep the default for the plot driver
  76. *
  77. * This is recognized by the DXF driver too, where NATIVE emits
  78. * TEXT entities instead of stroking the text
  79. */
  80. enum class PLOT_TEXT_MODE
  81. {
  82. STROKE,
  83. NATIVE,
  84. PHANTOM,
  85. DEFAULT
  86. };
  87. /**
  88. * Base plotter engine class. General rule: all the interface with the caller
  89. * is done in IU, the IU size is specified with SetViewport. Internal and
  90. * output processing is usually done in decimils (or whatever unit the
  91. * effective engine class need to use)
  92. */
  93. class PLOTTER
  94. {
  95. public:
  96. // These values are used as flag for pen or aperture selection
  97. static const int DO_NOT_SET_LINE_WIDTH = -2; // Skip selection
  98. static const int USE_DEFAULT_LINE_WIDTH = -1; // use the default pen
  99. PLOTTER( const PROJECT* aProject = nullptr );
  100. virtual ~PLOTTER();
  101. /**
  102. * Return the effective plot engine in use. It's not very OO but for
  103. * now is required since some things are only done with some output devices
  104. * (like drill marks, emitted only for postscript
  105. */
  106. virtual PLOT_FORMAT GetPlotterType() const = 0;
  107. virtual bool StartPlot( const wxString& aPageNumber ) = 0;
  108. virtual bool EndPlot() = 0;
  109. virtual void SetNegative( bool aNegative ) { m_negativeMode = aNegative; }
  110. /**
  111. * Plot in B/W or color.
  112. *
  113. * @param aColorMode use true to plot in color, false to plot in black and white.
  114. */
  115. virtual void SetColorMode( bool aColorMode ) { m_colorMode = aColorMode; }
  116. bool GetColorMode() const { return m_colorMode; }
  117. void SetRenderSettings( RENDER_SETTINGS* aSettings ) { m_renderSettings = aSettings; }
  118. RENDER_SETTINGS* RenderSettings() { return m_renderSettings; }
  119. virtual void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_pageInfo = aPageSettings; }
  120. PAGE_INFO& PageSettings() { return m_pageInfo; }
  121. void SetPlotMirrored( bool aMirror ) { m_plotMirror = aMirror; };
  122. bool GetPlotMirrored() const { return m_plotMirror; }
  123. /**
  124. * Set the line width for the next drawing.
  125. *
  126. * @param width is specified in IUs.
  127. * @param aData is an auxiliary parameter, mainly used in gerber plotter.
  128. */
  129. virtual void SetCurrentLineWidth( int width, void* aData = nullptr ) = 0;
  130. virtual int GetCurrentLineWidth() const { return m_currentPenWidth; }
  131. virtual void SetColor( const COLOR4D& color ) = 0;
  132. virtual void SetDash( int aLineWidth, LINE_STYLE aLineStyle ) = 0;
  133. virtual void SetCreator( const wxString& aCreator ) { m_creator = aCreator; }
  134. virtual void SetTitle( const wxString& aTitle ) { m_title = aTitle; }
  135. virtual void SetAuthor( const wxString& aAuthor ) { m_author = aAuthor; }
  136. virtual void SetSubject( const wxString& aSubject ) { m_subject = aSubject; }
  137. /**
  138. * Add a line to the list of free lines to print at the beginning of the file.
  139. *
  140. * @param aExtraString is the string to print
  141. */
  142. void AddLineToHeader( const wxString& aExtraString )
  143. {
  144. m_headerExtraLines.Add( aExtraString );
  145. }
  146. /**
  147. * Remove all lines from the list of free lines to print at the beginning of the file
  148. */
  149. void ClearHeaderLinesList()
  150. {
  151. m_headerExtraLines.Clear();
  152. }
  153. /**
  154. * Set the plot offset and scaling for the current plot
  155. *
  156. * @param aOffset is the plot offset.
  157. * @param aIusPerDecimil gives the scaling factor from IUs to device units
  158. * @param aScale is the user set plot scaling factor (either explicitly
  159. * or using 'fit to A4').
  160. * @param aMirror flips the plot in the Y direction (useful for toner
  161. * transfers or some kind of film).
  162. */
  163. virtual void SetViewport( const VECTOR2I& aOffset, double aIusPerDecimil,
  164. double aScale, bool aMirror ) = 0;
  165. /**
  166. * Open or create the plot file \a aFullFilename.
  167. *
  168. * @param aFullFilename is the full file name of the file to create.
  169. * @return true if success, false if the file cannot be created/opened.
  170. *
  171. * Virtual because some plotters use ascii files, some others binary files (PDF)
  172. * The base class open the file in text mode
  173. */
  174. virtual bool OpenFile( const wxString& aFullFilename );
  175. /**
  176. * The IUs per decimil are an essential scaling factor when
  177. * plotting; they are set and saved when establishing the viewport.
  178. * Here they can be get back again
  179. */
  180. double GetIUsPerDecimil() const { return m_IUsPerDecimil; }
  181. int GetPlotterArcLowDef() const { return m_IUsPerDecimil * 8; }
  182. int GetPlotterArcHighDef() const { return m_IUsPerDecimil * 2; }
  183. // Low level primitives
  184. virtual void Rect( const VECTOR2I& p1, const VECTOR2I& p2, FILL_T fill, int width ) = 0;
  185. virtual void Circle( const VECTOR2I& pos, int diametre, FILL_T fill, int width ) = 0;
  186. virtual void Arc( const VECTOR2D& aStart, const VECTOR2D& aMid, const VECTOR2D& aEnd,
  187. FILL_T aFill, int aWidth );
  188. virtual void Arc( const VECTOR2D& aCenter, const EDA_ANGLE& aStartAngle,
  189. const EDA_ANGLE& aAngle, double aRadius, FILL_T aFill,
  190. int aWidth );
  191. /**
  192. * Generic fallback: Cubic Bezier curve rendered as a polyline.
  193. *
  194. * In KiCad the bezier curves have 4 control points: start ctrl1 ctrl2 end
  195. */
  196. virtual void BezierCurve( const VECTOR2I& aStart, const VECTOR2I& aControl1,
  197. const VECTOR2I& aControl2, const VECTOR2I& aEnd,
  198. int aTolerance, int aLineThickness );
  199. /**
  200. * Moveto/lineto primitive, moves the 'pen' to the specified direction.
  201. *
  202. * @param pos is the target position.
  203. * @param plume specifies the kind of motion: 'U' only moves the pen,
  204. * 'D' draw a line from the current position and 'Z' finish
  205. * the drawing and returns the 'pen' to rest (flushes the trace).
  206. */
  207. virtual void PenTo( const VECTOR2I& pos, char plume ) = 0;
  208. // Convenience functions for PenTo
  209. void MoveTo( const VECTOR2I& pos )
  210. {
  211. PenTo( pos, 'U' );
  212. }
  213. void LineTo( const VECTOR2I& pos )
  214. {
  215. PenTo( pos, 'D' );
  216. }
  217. void FinishTo( const VECTOR2I& pos )
  218. {
  219. PenTo( pos, 'D' );
  220. PenTo( pos, 'Z' );
  221. }
  222. void PenFinish()
  223. {
  224. // The point is not important with Z motion
  225. PenTo( VECTOR2I( 0, 0 ), 'Z' );
  226. }
  227. /**
  228. * Draw a polygon ( filled or not ).
  229. *
  230. * @param aCornerList is the corners list (a std::vector< VECTOR2I >).
  231. * @param aFill is the type of fill.
  232. * @param aWidth is the line width.
  233. * @param aData is an auxiliary info (mainly for gerber format).
  234. */
  235. virtual void PlotPoly( const std::vector<VECTOR2I>& aCornerList, FILL_T aFill,
  236. int aWidth = USE_DEFAULT_LINE_WIDTH, void* aData = nullptr ) = 0;
  237. /**
  238. * Draw a polygon ( filled or not ).
  239. *
  240. * @param aCornerList is the corners list (a SHAPE_LINE_CHAIN).
  241. * must be closed (IsClosed() == true) for a polygon. Otherwise this is a polyline.
  242. * @param aFill is the type of fill.
  243. * @param aWidth is the line width.
  244. * @param aData is an auxiliary info (mainly for gerber format).
  245. */
  246. virtual void PlotPoly( const SHAPE_LINE_CHAIN& aCornerList, FILL_T aFill,
  247. int aWidth = USE_DEFAULT_LINE_WIDTH, void* aData = nullptr );
  248. /**
  249. * Only PostScript plotters can plot bitmaps.
  250. *
  251. * A rectangle is plotted for plotters that cannot plot a bitmap.
  252. *
  253. * @param aImage is the bitmap.
  254. * @param aPos is position of the center of the bitmap.
  255. * @param aScaleFactor is the scale factor to apply to the bitmap size
  256. * (this is not the plot scale factor).
  257. */
  258. virtual void PlotImage( const wxImage& aImage, const VECTOR2I& aPos, double aScaleFactor );
  259. // Higher level primitives -- can be drawn as line, sketch or 'filled'
  260. virtual void ThickSegment( const VECTOR2I& start, const VECTOR2I& end, int width,
  261. OUTLINE_MODE tracemode, void* aData );
  262. virtual void ThickArc( const EDA_SHAPE& aArcShape, OUTLINE_MODE aTraceMode, void* aData,
  263. int aWidth );
  264. virtual void ThickArc( const VECTOR2D& aCentre, const EDA_ANGLE& aStAngle,
  265. const EDA_ANGLE& aAngle, double aRadius, int aWidth,
  266. OUTLINE_MODE aTraceMode, void* aData );
  267. virtual void ThickRect( const VECTOR2I& p1, const VECTOR2I& p2, int width,
  268. OUTLINE_MODE tracemode, void* aData );
  269. virtual void ThickCircle( const VECTOR2I& pos, int diametre, int width, OUTLINE_MODE tracemode,
  270. void* aData );
  271. virtual void FilledCircle( const VECTOR2I& pos, int diametre, OUTLINE_MODE tracemode,
  272. void* aData );
  273. // Flash primitives
  274. /**
  275. * @param aPadPos Position of the shape (center of the rectangle.
  276. * @param aDiameter is the diameter of round pad.
  277. * @param aTraceMode is the drawing mode, FILLED or SKETCH.
  278. * @param aData is an auxiliary info (mainly for gerber format attributes).
  279. */
  280. virtual void FlashPadCircle( const VECTOR2I& aPadPos, int aDiameter, OUTLINE_MODE aTraceMode,
  281. void* aData ) = 0;
  282. /**
  283. * @param aPadPos Position of the shape (center of the rectangle.
  284. * @param aSize is the size of oblong shape.
  285. * @param aPadOrient The rotation of the shape.
  286. * @param aTraceMode is the drawing mode, FILLED or SKETCH.
  287. * @param aData an auxiliary info (mainly for gerber format attributes).
  288. */
  289. virtual void FlashPadOval( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
  290. const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
  291. void* aData ) = 0;
  292. /**
  293. * @param aPadPos Position of the shape (center of the rectangle).
  294. * @param aSize is the size of rounded rect.
  295. * @param aPadOrient The rotation of the shape.
  296. * @param aTraceMode is the drawing mode, FILLED or SKETCH.
  297. * @param aData an auxiliary info (mainly for gerber format attributes).
  298. */
  299. virtual void FlashPadRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
  300. const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
  301. void* aData ) = 0;
  302. /**
  303. * @param aPadPos Position of the shape (center of the rectangle.
  304. * @param aSize is the size of rounded rect.
  305. * @param aCornerRadius Radius of the rounded corners.
  306. * @param aOrient The rotation of the shape.
  307. * @param aTraceMode is the drawing mode, FILLED or SKETCH.
  308. * @param aData an auxiliary info (mainly for gerber format attributes).
  309. */
  310. virtual void FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
  311. int aCornerRadius, const EDA_ANGLE& aOrient,
  312. OUTLINE_MODE aTraceMode, void* aData ) = 0;
  313. /**
  314. * @param aPadPos Position of the shape.
  315. * @param aSize is the size of round reference pad.
  316. * @param aPadOrient is the pad rotation, used only with aperture macros (Gerber plotter).
  317. * @param aPolygons the shape as polygon set.
  318. * @param aTraceMode is the drawing mode, FILLED or SKETCH.
  319. * @param aData an auxiliary info (mainly for gerber format attributes).
  320. */
  321. virtual void FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
  322. const EDA_ANGLE& aPadOrient, SHAPE_POLY_SET* aPolygons,
  323. OUTLINE_MODE aTraceMode, void* aData ) = 0;
  324. /**
  325. * Flash a trapezoidal pad.
  326. *
  327. * @param aPadPos is the the position of the shape.
  328. * @param aCorners is the list of 4 corners positions, relative to the shape position,
  329. * pad orientation 0.
  330. * @param aPadOrient is the rotation of the shape.
  331. * @param aTraceMode is the drawing mode, FILLED or SKETCH.
  332. * @param aData an auxiliary info (mainly for gerber format attributes).
  333. */
  334. virtual void FlashPadTrapez( const VECTOR2I& aPadPos, const VECTOR2I* aCorners,
  335. const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
  336. void* aData ) = 0;
  337. /**
  338. * Flash a regular polygon. Useful only in Gerber files to flash a regular polygon.
  339. *
  340. * @param aShapePos is the center of the circle containing the polygon.
  341. * @param aRadius is the radius of the circle containing the polygon.
  342. * @param aCornerCount is the number of vertices.
  343. * @param aOrient is the polygon rotation.
  344. * @param aData is a auxiliary parameter used (if needed) to handle extra info
  345. * specific to the plotter.
  346. */
  347. virtual void FlashRegularPolygon( const VECTOR2I& aShapePos, int aDiameter, int aCornerCount,
  348. const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode,
  349. void* aData ) = 0;
  350. /**
  351. * Draw text with the plotter.
  352. *
  353. * For convenience it accept the color to use for specific plotters
  354. * aData is used to pass extra parameters (GERBER).
  355. *
  356. * @param aPos is the text position (according to aH_justify, aV_justify).
  357. * @param aColor is the text color.
  358. * @param aText is the text to draw.
  359. * @param aOrient is the angle.
  360. * @param aSize is the text size (size.x or size.y can be < 0 for mirrored texts).
  361. * @param aH_justify is the horizontal justification (Left, center, right).
  362. * @param aV_justify is the vertical justification (bottom, center, top).
  363. * @param aPenWidth is the line width (if = 0, use plot default line width).
  364. * @param aItalic is the true to simulate an italic font.
  365. * @param aBold use true to use a bold font Useful only with default width value
  366. * (aPenWidth = 0).
  367. * @param aMultilineAllowed use true to plot text as multiline, otherwise single line.
  368. * @param aData is a parameter used by some plotters in SetCurrentLineWidth(),
  369. * not directly used here.
  370. */
  371. virtual void Text( const VECTOR2I& aPos,
  372. const COLOR4D& aColor,
  373. const wxString& aText,
  374. const EDA_ANGLE& aOrient,
  375. const VECTOR2I& aSize,
  376. enum GR_TEXT_H_ALIGN_T aH_justify,
  377. enum GR_TEXT_V_ALIGN_T aV_justify,
  378. int aPenWidth,
  379. bool aItalic,
  380. bool aBold,
  381. bool aMultilineAllowed,
  382. KIFONT::FONT* aFont,
  383. const KIFONT::METRICS& aFontMetrics,
  384. void* aData = nullptr );
  385. virtual void PlotText( const VECTOR2I& aPos,
  386. const COLOR4D& aColor,
  387. const wxString& aText,
  388. const TEXT_ATTRIBUTES& aAttributes,
  389. KIFONT::FONT* aFont = nullptr,
  390. const KIFONT::METRICS& aFontMetrics = KIFONT::METRICS::Default(),
  391. void* aData = nullptr );
  392. /**
  393. * Create a clickable hyperlink with a rectangular click area
  394. *
  395. * @param aBox is the rectangular click target
  396. * @param aDestinationURL is the target URL
  397. */
  398. virtual void HyperlinkBox( const BOX2I& aBox, const wxString& aDestinationURL )
  399. {
  400. // NOP for most plotters.
  401. }
  402. /**
  403. * Create a clickable hyperlink menu with a rectangular click area
  404. *
  405. * @param aBox is the rectangular click target
  406. * @param aDestURLs is the target URL
  407. */
  408. virtual void HyperlinkMenu( const BOX2I& aBox, const std::vector<wxString>& aDestURLs )
  409. {
  410. // NOP for most plotters.
  411. }
  412. /**
  413. * Create a bookmark to a symbol
  414. *
  415. * @param aBox is the rectangular click target
  416. * @param aSymbolReference is the symbol schematic ref
  417. */
  418. virtual void Bookmark( const BOX2I& aBox, const wxString& aName,
  419. const wxString& aGroupName = wxEmptyString )
  420. {
  421. // NOP for most plotters.
  422. }
  423. /**
  424. * Draw a marker (used for the drill map).
  425. */
  426. static const unsigned MARKER_COUNT = 58;
  427. /**
  428. * Draw a pattern shape number aShapeId, to coord position.
  429. *
  430. * @param aPosition is the position of the marker.
  431. * @param aDiameter is the diameter of the marker.
  432. * @param aShapeId is the index (used to generate forms characters).
  433. */
  434. void Marker( const VECTOR2I& position, int diametre, unsigned aShapeId );
  435. /**
  436. * Set the current Gerber layer polarity to positive or negative
  437. * by writing \%LPD*\% or \%LPC*\% to the Gerber file, respectively.
  438. * (obviously starts a new Gerber layer, too)
  439. *
  440. * @param aPositive is the layer polarity and true for positive.
  441. * It's not useful with most other plotter since they can't 'scratch'
  442. * the film like photoplotter imagers do
  443. */
  444. virtual void SetLayerPolarity( bool aPositive )
  445. {
  446. // NOP for most plotters
  447. }
  448. /**
  449. * Change the current text mode.
  450. *
  451. * See the PlotTextMode explanation at the beginning of the file.
  452. */
  453. virtual void SetTextMode( PLOT_TEXT_MODE mode )
  454. {
  455. // NOP for most plotters.
  456. }
  457. virtual void SetGerberCoordinatesFormat( int aResolution, bool aUseInches = false )
  458. {
  459. // NOP for most plotters. Only for Gerber plotter
  460. }
  461. /// Set the number of digits for mantissa in coordinates in mm for SVG plotter
  462. virtual void SetSvgCoordinatesFormat( unsigned aPrecision )
  463. {
  464. // NOP for most plotters. Only for SVG plotter
  465. }
  466. /**
  467. * calling this function allows one to define the beginning of a group
  468. * of drawing items, for instance in SVG or Gerber format.
  469. * (example: group all segments of a letter or a text)
  470. * @param aData can define any parameter
  471. * for most of plotters: do nothing
  472. */
  473. virtual void StartBlock( void* aData ) {}
  474. /**
  475. * calling this function allows one to define the end of a group of drawing
  476. * items for instance in SVG or Gerber format.
  477. * the group is started by StartBlock()
  478. * @param aData can define any parameter
  479. * for most of plotters: do nothing
  480. */
  481. virtual void EndBlock( void* aData ) {}
  482. /**
  483. * @return the plot offset in IUs, set by SetViewport() and used to plot items.
  484. */
  485. VECTOR2I GetPlotOffsetUserUnits() {return m_plotOffset; }
  486. protected:
  487. /**
  488. * Generic fallback: arc rendered as a polyline.
  489. * Note also aCentre and aRadius are double to avoid creating rounding issues due
  490. * to the fact a arc is defined in Kicad by a start point, a end point and third point
  491. * not angles and radius.
  492. * In some plotters (i.e. dxf) whe need a good precision when calculating an arc
  493. * without error introduced by rounding, to avoid moving the end points,
  494. * usually important in outlines when plotting an arc given by center, radius and angles.
  495. * Winding direction: counter-clockwise in right-down coordinate system.
  496. */
  497. virtual void polyArc( const VECTOR2D& aCentre, const EDA_ANGLE& aStartAngle,
  498. const EDA_ANGLE& aAngle, double aRadius, FILL_T aFill,
  499. int aWidth = USE_DEFAULT_LINE_WIDTH );
  500. // These are marker subcomponents
  501. /**
  502. * Plot a circle centered on the position. Building block for markers
  503. */
  504. void markerCircle( const VECTOR2I& pos, int radius );
  505. /**
  506. * Plot a - bar centered on the position. Building block for markers
  507. */
  508. void markerHBar( const VECTOR2I& pos, int radius );
  509. /**
  510. * Plot a / bar centered on the position. Building block for markers
  511. */
  512. void markerSlash( const VECTOR2I& pos, int radius );
  513. /**
  514. * Plot a \ bar centered on the position. Building block for markers
  515. */
  516. void markerBackSlash( const VECTOR2I& pos, int radius );
  517. /**
  518. * Plot a | bar centered on the position. Building block for markers
  519. */
  520. void markerVBar( const VECTOR2I& pos, int radius );
  521. /**
  522. * Plot a square centered on the position. Building block for markers
  523. */
  524. void markerSquare( const VECTOR2I& position, int radius );
  525. /**
  526. * Plot a lozenge centered on the position. Building block for markers
  527. */
  528. void markerLozenge( const VECTOR2I& position, int radius );
  529. // Helper function for sketched filler segment
  530. /**
  531. * Convert a thick segment and plot it as an oval
  532. */
  533. void segmentAsOval( const VECTOR2I& start, const VECTOR2I& end, int width,
  534. OUTLINE_MODE tracemode );
  535. void sketchOval( const VECTOR2I& aPos, const VECTOR2I& aSize, const EDA_ANGLE& aOrient,
  536. int aWidth );
  537. // Coordinate and scaling conversion functions
  538. /**
  539. * Modify coordinates according to the orientation, scale factor, and offsets trace. Also
  540. * convert from a VECTOR2I to VECTOR2D, since some output engines needs floating point
  541. * coordinates.
  542. */
  543. virtual VECTOR2D userToDeviceCoordinates( const VECTOR2I& aCoordinate );
  544. /**
  545. * Modify size according to the plotter scale factors (VECTOR2I version, returns a VECTOR2D).
  546. */
  547. virtual VECTOR2D userToDeviceSize( const VECTOR2I& size );
  548. /**
  549. * Modify size according to the plotter scale factors (simple double version).
  550. */
  551. virtual double userToDeviceSize( double size ) const;
  552. double GetDotMarkLenIU( int aLineWidth ) const;
  553. double GetDashMarkLenIU( int aLineWidth ) const;
  554. double GetDashGapLenIU( int aLineWidth ) const;
  555. protected: // variables used in most of plotters:
  556. /// Plot scale - chosen by the user (even implicitly with 'fit in a4')
  557. double m_plotScale;
  558. /* Caller scale (how many IUs in a decimil - always); it's a double
  559. * because in Eeschema there are 0.1 IUs in a decimil (Eeschema
  560. * always works in mils internally) while PcbNew can work in decimil
  561. * or nanometers, so this value would be >= 1 */
  562. double m_IUsPerDecimil;
  563. double m_iuPerDeviceUnit; // Device scale (from IUs to plotter device units;
  564. // usually decimils)
  565. VECTOR2I m_plotOffset; // Plot offset (in IUs)
  566. bool m_plotMirror; // X axis orientation (SVG)
  567. // and plot mirrored (only for PS, PDF and SVG)
  568. bool m_mirrorIsHorizontal; // true to mirror horizontally (else vertically)
  569. bool m_yaxisReversed; // true if the Y axis is top to bottom (SVG)
  570. /// Output file
  571. FILE* m_outputFile;
  572. // Pen handling
  573. bool m_colorMode; // true to plot in color, otherwise black & white
  574. bool m_negativeMode; // true to generate a negative image (PS mode mainly)
  575. int m_currentPenWidth;
  576. char m_penState; // current pen state: 'U', 'D' or 'Z' (see PenTo)
  577. VECTOR2I m_penLastpos; // last pen position; -1,-1 when pen is at rest
  578. wxString m_creator;
  579. wxString m_filename;
  580. wxString m_title;
  581. wxString m_author;
  582. wxString m_subject;
  583. PAGE_INFO m_pageInfo;
  584. VECTOR2I m_paperSize; // Paper size in IU - not in mils
  585. wxArrayString m_headerExtraLines; // a set of string to print in header file
  586. RENDER_SETTINGS* m_renderSettings;
  587. const PROJECT* m_project;
  588. };
  589. class TITLE_BLOCK;
  590. void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BLOCK& aTitleBlock,
  591. const PAGE_INFO& aPageInfo, const std::map<wxString, wxString>*aProperties,
  592. const wxString& aSheetNumber, int aSheetCount, const wxString& aSheetName,
  593. const wxString& aSheetPath, const wxString& aFilename,
  594. COLOR4D aColor = COLOR4D::UNSPECIFIED, bool aIsFirstPage = true );
  595. /**
  596. * Return the default plot extension for a format.
  597. */
  598. wxString GetDefaultPlotExtension( PLOT_FORMAT aFormat );
  599. #endif // PLOT_COMMON_H_