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.

725 lines
22 KiB

14 years ago
14 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
  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 PCB_DIMENSION_H
  25. #define PCB_DIMENSION_H
  26. #include <board_item.h>
  27. #include <pcb_text.h>
  28. #include <geometry/shape.h>
  29. #include <geometry/circle.h>
  30. class LINE_READER;
  31. class MSG_PANEL_ITEM;
  32. /// How to display the units in a dimension's text
  33. enum class DIM_UNITS_FORMAT
  34. {
  35. NO_SUFFIX, // 1234.0
  36. BARE_SUFFIX, // 1234.0 mm
  37. PAREN_SUFFIX // 1234.0 (mm)
  38. };
  39. enum class DIM_PRECISION
  40. {
  41. X = 0, // 0
  42. X_X, // 0.0
  43. X_XX, // 0.00
  44. X_XXX, // 0.000
  45. X_XXXX, // 0.0000
  46. X_XXXXX, // 0.00000
  47. V_VV, // 0.00 / 0 / 0.0
  48. V_VVV, // 0.000 / 0 / 0.00
  49. V_VVVV, // 0.0000 / 0.0 / 0.000
  50. V_VVVVV // 0.00000 / 0.00 / 0.0000
  51. };
  52. /// Where to place the text on a dimension
  53. enum class DIM_TEXT_POSITION
  54. {
  55. OUTSIDE, ///< Text appears outside the dimension line (default)
  56. INLINE, ///< Text appears in line with the dimension line
  57. MANUAL ///< Text placement is manually set by the user
  58. };
  59. /**
  60. * Used for storing the units selection in the file because EDA_UNITS alone doesn't cut it
  61. */
  62. enum class DIM_UNITS_MODE
  63. {
  64. INCH, // Do not use IN: it conflicts with a Windows header
  65. MILS,
  66. MM,
  67. AUTOMATIC
  68. };
  69. /**
  70. * Used for dimension's arrow.
  71. */
  72. enum class DIM_ARROW_DIRECTION
  73. {
  74. INWARD, ///< >-----<
  75. OUTWARD, ///< <----->
  76. };
  77. /**
  78. * Frame to show around dimension text
  79. */
  80. enum class DIM_TEXT_BORDER
  81. {
  82. NONE,
  83. RECTANGLE,
  84. CIRCLE,
  85. ROUNDRECT
  86. };
  87. /**
  88. * Abstract dimension API
  89. *
  90. * Some notes about dimension nomenclature:
  91. *
  92. * - "feature points" are the points being measured by the dimension. For an example, the start
  93. * and end points of a line to be measured. These are the first points picked when drawing a
  94. * new dimension. Dimensions can have one or more feature points: linear dimensions (the only
  95. * type supported in KiCad 5 and earlier) have two feature points; leader dimensions have one;
  96. * and ordinate dimensions can have in theory an unlimited number of feature points.
  97. *
  98. * - "feature lines" are lines that coincide with feature points. Not all dimension types have
  99. * feature lines. The actual start and end of feature lines is calculated from dimension style
  100. * properties (offset from feature point to start of feature line, height of crossbar, and height
  101. * of feature line past crossbar, for example in linear dimensions)
  102. *
  103. * - "crossbar" refers to the perpendicular line (usually with arrows at each end) between feature
  104. * lines on linear dimensions
  105. */
  106. class PCB_DIMENSION_BASE : public PCB_TEXT
  107. {
  108. public:
  109. PCB_DIMENSION_BASE( BOARD_ITEM* aParent, KICAD_T aType = PCB_DIMENSION_T );
  110. void Serialize( google::protobuf::Any &aContainer ) const override;
  111. bool Deserialize( const google::protobuf::Any &aContainer ) override;
  112. /**
  113. * The dimension's origin is the first feature point for the dimension. Every dimension has
  114. * one or more feature points, so every dimension has at least an origin.
  115. * @return the origin point of this dimension
  116. */
  117. virtual const VECTOR2I& GetStart() const { return m_start; }
  118. virtual void SetStart( const VECTOR2I& aPoint ) { m_start = aPoint; }
  119. virtual const VECTOR2I& GetEnd() const { return m_end; }
  120. virtual void SetEnd( const VECTOR2I& aPoint ) { m_end = aPoint; }
  121. VECTOR2I GetPosition() const override { return m_start; }
  122. void SetPosition( const VECTOR2I& aPos ) override { m_start = aPos; }
  123. bool GetOverrideTextEnabled() const { return m_overrideTextEnabled; }
  124. void SetOverrideTextEnabled( bool aOverride ) { m_overrideTextEnabled = aOverride; }
  125. wxString GetOverrideText() const { return m_valueString; }
  126. void SetOverrideText( const wxString& aValue ) { m_valueString = aValue; }
  127. void ChangeOverrideText( const wxString& aValue )
  128. {
  129. SetOverrideTextEnabled( true );
  130. SetOverrideText( aValue );
  131. Update();
  132. }
  133. int GetMeasuredValue() const { return m_measuredValue; }
  134. // KiCad normally calculates the measured value but some importers need to set it.
  135. void SetMeasuredValue( int aValue ) { m_measuredValue = aValue; }
  136. /**
  137. * @return the dimension value, rendered with precision / zero suppression but no units, etc
  138. */
  139. wxString GetValueText() const;
  140. /**
  141. * Update the dimension's cached text and geometry.
  142. *
  143. * Call this whenever you change something in the geometry
  144. * definition, or the text (which can affect geometry, e.g. by
  145. * a knockout of a crossbar line or similar)
  146. */
  147. void Update()
  148. {
  149. // Calls updateText internally
  150. updateGeometry();
  151. }
  152. void UpdateUnits()
  153. {
  154. SetUnitsMode( GetUnitsMode() );
  155. Update();
  156. }
  157. wxString GetPrefix() const { return m_prefix; }
  158. void SetPrefix( const wxString& aPrefix );
  159. void ChangePrefix( const wxString& aPrefix )
  160. {
  161. SetPrefix( aPrefix );
  162. Update();
  163. }
  164. wxString GetSuffix() const { return m_suffix; }
  165. void SetSuffix( const wxString& aSuffix );
  166. void ChangeSuffix( const wxString& aSuffix )
  167. {
  168. SetSuffix( aSuffix );
  169. Update();
  170. }
  171. DIM_ARROW_DIRECTION GetArrowDirection() const { return m_arrowDirection; }
  172. void SetArrowDirection( const DIM_ARROW_DIRECTION& aDirection )
  173. {
  174. m_arrowDirection = aDirection;
  175. }
  176. void ChangeArrowDirection( const DIM_ARROW_DIRECTION& aDirection )
  177. {
  178. SetArrowDirection( aDirection );
  179. updateText();
  180. updateGeometry();
  181. }
  182. EDA_UNITS GetUnits() const { return m_units; }
  183. void SetUnits( EDA_UNITS aUnits );
  184. DIM_UNITS_MODE GetUnitsMode() const;
  185. void SetUnitsMode( DIM_UNITS_MODE aMode );
  186. void ChangeUnitsMode( DIM_UNITS_MODE aMode )
  187. {
  188. SetUnitsMode( aMode );
  189. Update();
  190. }
  191. void SetAutoUnits( bool aAuto = true ) { m_autoUnits = aAuto; }
  192. DIM_UNITS_FORMAT GetUnitsFormat() const { return m_unitsFormat; }
  193. void SetUnitsFormat( const DIM_UNITS_FORMAT aFormat ) { m_unitsFormat = aFormat; }
  194. void ChangeUnitsFormat( const DIM_UNITS_FORMAT aFormat )
  195. {
  196. SetUnitsFormat( aFormat );
  197. Update();
  198. }
  199. DIM_PRECISION GetPrecision() const { return m_precision; }
  200. void SetPrecision( DIM_PRECISION aPrecision ) { m_precision = aPrecision; }
  201. void ChangePrecision( DIM_PRECISION aPrecision )
  202. {
  203. SetPrecision( aPrecision );
  204. Update();
  205. }
  206. bool GetSuppressZeroes() const { return m_suppressZeroes; }
  207. void SetSuppressZeroes( bool aSuppress ) { m_suppressZeroes = aSuppress; }
  208. void ChangeSuppressZeroes( bool aSuppress )
  209. {
  210. SetSuppressZeroes( aSuppress );
  211. Update();
  212. }
  213. bool GetKeepTextAligned() const { return m_keepTextAligned; }
  214. void SetKeepTextAligned( bool aKeepAligned ) { m_keepTextAligned = aKeepAligned; }
  215. double GetTextAngleDegreesProp() const { return GetTextAngleDegrees(); }
  216. void ChangeTextAngleDegrees( double aDegrees );
  217. void ChangeKeepTextAligned( bool aKeepAligned );
  218. void SetTextPositionMode( DIM_TEXT_POSITION aMode ) { m_textPosition = aMode; }
  219. DIM_TEXT_POSITION GetTextPositionMode() const { return m_textPosition; }
  220. int GetArrowLength() const { return m_arrowLength; }
  221. void SetArrowLength( int aLength ) { m_arrowLength = aLength; }
  222. void SetExtensionOffset( int aOffset ) { m_extensionOffset = aOffset; }
  223. int GetExtensionOffset() const { return m_extensionOffset; }
  224. int GetLineThickness() const { return m_lineThickness; }
  225. void SetLineThickness( int aWidth ) { m_lineThickness = aWidth; }
  226. /**
  227. * @return a list of line segments that make up this dimension (for drawing, plotting, etc).
  228. */
  229. const std::vector<std::shared_ptr<SHAPE>>& GetShapes() const { return m_shapes; }
  230. // BOARD_ITEM overrides
  231. void Move( const VECTOR2I& offset ) override;
  232. void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
  233. void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
  234. /**
  235. * Mirror the dimension relative to a given horizontal axis.
  236. *
  237. * The text is not mirrored. Only its position (and angle) is mirrored. The layer is not
  238. * changed.
  239. *
  240. * @param axis_pos is the vertical axis position to mirror around.
  241. */
  242. virtual void Mirror( const VECTOR2I& axis_pos, FLIP_DIRECTION aFlipDirection ) override;
  243. void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
  244. bool HitTest( const VECTOR2I& aPosition, int aAccuracy ) const override;
  245. bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
  246. const BOX2I GetBoundingBox() const override;
  247. std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer,
  248. FLASHING aFlash = FLASHING::DEFAULT ) const override;
  249. wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
  250. const BOX2I ViewBBox() const override;
  251. void ClearRenderCache() override;
  252. void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
  253. int aError, ERROR_LOC aErrorLoc,
  254. bool aIgnoreLineWidth = false ) const override;
  255. double Similarity( const BOARD_ITEM& aOther ) const override;
  256. bool operator==( const PCB_DIMENSION_BASE& aOther ) const;
  257. bool operator==( const BOARD_ITEM& aBoardItem ) const override;
  258. #if defined(DEBUG)
  259. virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
  260. #endif
  261. protected:
  262. /**
  263. * Update the cached geometry of the dimension after changing any of its properties.
  264. */
  265. virtual void updateGeometry() = 0;
  266. /**
  267. * Update the text field value from the current geometry (called by updateGeometry normally).
  268. *
  269. * If you change the text, you should call updateGeometry which will call this,
  270. * and also handle any text-dependent geoemtry handling (like a knockout)
  271. */
  272. virtual void updateText();
  273. template<typename ShapeType>
  274. void addShape( const ShapeType& aShape );
  275. /**
  276. * Draws an arrow and updates the shape container.
  277. * example arrow 0Deg tail:4 (---->)
  278. *
  279. * @param startPoint arrow point.
  280. * @param anAngle arrow angle.
  281. * @param aLength arrow tail length.
  282. */
  283. void drawAnArrow( VECTOR2I aStartPoint, EDA_ANGLE anAngle, int aLength );
  284. // Value format
  285. bool m_overrideTextEnabled; ///< Manually specify the displayed measurement value
  286. wxString m_valueString; ///< Displayed value when m_overrideValue = true
  287. wxString m_prefix; ///< String prepended to the value
  288. wxString m_suffix; ///< String appended to the value
  289. EDA_UNITS m_units; ///< 0 = inches, 1 = mm
  290. bool m_autoUnits; ///< If true, follow the currently selected UI units
  291. DIM_UNITS_FORMAT m_unitsFormat; ///< How to render the units suffix
  292. DIM_ARROW_DIRECTION m_arrowDirection; ///< direction of dimension arrow.
  293. DIM_PRECISION m_precision; ///< Number of digits to display after decimal
  294. bool m_suppressZeroes; ///< Suppress trailing zeroes
  295. // Geometry
  296. int m_lineThickness; ///< Thickness used for all graphics in the dimension
  297. int m_arrowLength; ///< Length of arrow shapes
  298. int m_extensionOffset; ///< Distance from feature points to extension line start
  299. DIM_TEXT_POSITION m_textPosition; ///< How to position the text
  300. bool m_keepTextAligned; ///< Calculate text orientation to match dimension
  301. // Internal
  302. int m_measuredValue; ///< value of PCB dimensions
  303. VECTOR2I m_start;
  304. VECTOR2I m_end;
  305. ///< Internal cache of drawn shapes
  306. std::vector<std::shared_ptr<SHAPE>> m_shapes;
  307. bool m_inClearRenderCache; ///< re-entrancy guard
  308. // a flag to protect against reentrance
  309. bool m_busy;
  310. };
  311. /**
  312. * For better understanding of the points that make a dimension:
  313. *
  314. * Note: historically KiCad called extension lines "feature lines", and also note that what we
  315. * call the "crossbar line" here is more commonly called the "dimension line"
  316. *
  317. * Start (feature point 1) End (feature point 2)
  318. * | |
  319. * | <-- extension lines --> |
  320. * | |
  321. * | m_arrowG2F m_arrowD2F |
  322. * | / \ |
  323. * Crossbar start |/_______crossbar line________\| Crossbar end
  324. * |\ m_text /|
  325. * | \ / |
  326. * | m_arrowG1F m_arrowD1F |
  327. * | |
  328. * m_featureLineGF m_featureLineDF
  329. */
  330. /**
  331. * An aligned dimension measures the distance between two feature points. It has a crossbar
  332. * (dimension line) that stays parallel with the vector between the feature points.
  333. *
  334. * The height (distance from features to crossbar) can be set directly, or set by manipulating the
  335. * crossbar start or end point (with the point editor).
  336. */
  337. class PCB_DIM_ALIGNED : public PCB_DIMENSION_BASE
  338. {
  339. public:
  340. PCB_DIM_ALIGNED( BOARD_ITEM* aParent, KICAD_T aType = PCB_DIM_ALIGNED_T );
  341. // Do not create a copy constructor & operator=.
  342. // The ones generated by the compiler are adequate.
  343. ~PCB_DIM_ALIGNED() = default;
  344. void Serialize( google::protobuf::Any &aContainer ) const override;
  345. bool Deserialize( const google::protobuf::Any &aContainer ) override;
  346. static inline bool ClassOf( const EDA_ITEM* aItem )
  347. {
  348. return aItem && aItem->Type() == PCB_DIM_ALIGNED_T;
  349. }
  350. EDA_ITEM* Clone() const override;
  351. void Mirror( const VECTOR2I& axis_pos, FLIP_DIRECTION aFlipDirection ) override;
  352. BITMAPS GetMenuImage() const override;
  353. const VECTOR2I& GetCrossbarStart() const { return m_crossBarStart; }
  354. const VECTOR2I& GetCrossbarEnd() const { return m_crossBarEnd; }
  355. /**
  356. * Set the distance from the feature points to the crossbar line.
  357. *
  358. * @param aHeight is the new height.
  359. */
  360. void SetHeight( int aHeight ) { m_height = aHeight; }
  361. int GetHeight() const { return m_height; }
  362. void ChangeHeight( int aHeight )
  363. {
  364. SetHeight( aHeight );
  365. Update();
  366. }
  367. /**
  368. * Update the stored height basing on points coordinates.
  369. *
  370. * @param aCrossbarStart is the start point of the crossbar.
  371. */
  372. void UpdateHeight( const VECTOR2I& aCrossbarStart, const VECTOR2I& aCrossbarEnd );
  373. void SetExtensionHeight( int aHeight ) { m_extensionHeight = aHeight; }
  374. int GetExtensionHeight() const { return m_extensionHeight; }
  375. void ChangeExtensionHeight( int aHeight )
  376. {
  377. SetExtensionHeight( aHeight );
  378. Update();
  379. }
  380. /**
  381. * Return the angle of the crossbar.
  382. *
  383. * @return Angle of the crossbar line expressed in radians.
  384. */
  385. double GetAngle() const
  386. {
  387. VECTOR2I delta( m_end - m_start );
  388. return atan2( (double)delta.y, (double)delta.x );
  389. }
  390. wxString GetClass() const override
  391. {
  392. return wxT( "PCB_DIM_ALIGNED" );
  393. }
  394. void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
  395. protected:
  396. virtual void swapData( BOARD_ITEM* aImage ) override;
  397. void updateGeometry() override;
  398. void updateText() override;
  399. // Geometry
  400. int m_height; ///< Perpendicular distance from features to crossbar
  401. int m_extensionHeight; ///< Length of extension lines past the crossbar
  402. VECTOR2I m_crossBarStart; ///< Crossbar start control point
  403. VECTOR2I m_crossBarEnd; ///< Crossbar end control point
  404. };
  405. /**
  406. * An orthogonal dimension is like an aligned dimension, but the extension lines are locked to the
  407. * X or Y axes, and the measurement is only taken in the X or Y direction.
  408. */
  409. class PCB_DIM_ORTHOGONAL : public PCB_DIM_ALIGNED
  410. {
  411. public:
  412. enum class DIR
  413. {
  414. HORIZONTAL, // Aligned with x-axis
  415. VERTICAL // Aligned with y-axis
  416. };
  417. PCB_DIM_ORTHOGONAL( BOARD_ITEM* aParent );
  418. ~PCB_DIM_ORTHOGONAL() = default;
  419. void Serialize( google::protobuf::Any &aContainer ) const override;
  420. bool Deserialize( const google::protobuf::Any &aContainer ) override;
  421. static inline bool ClassOf( const EDA_ITEM* aItem )
  422. {
  423. return aItem && aItem->Type() == PCB_DIM_ORTHOGONAL_T;
  424. }
  425. EDA_ITEM* Clone() const override;
  426. void Mirror( const VECTOR2I& axis_pos, FLIP_DIRECTION aFlipDirection ) override;
  427. BITMAPS GetMenuImage() const override;
  428. /**
  429. * Set the orientation of the dimension line (so, perpendicular to the feature lines).
  430. *
  431. * @param aOrientation is the orientation the dimension should take.
  432. */
  433. void SetOrientation( DIR aOrientation ) { m_orientation = aOrientation; }
  434. DIR GetOrientation() const { return m_orientation; }
  435. wxString GetClass() const override
  436. {
  437. return wxT( "PCB_DIM_ORTHOGONAL" );
  438. }
  439. void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
  440. protected:
  441. void swapData( BOARD_ITEM* aImage ) override;
  442. void updateGeometry() override;
  443. void updateText() override;
  444. private:
  445. // Geometry
  446. DIR m_orientation; ///< What axis to lock the dimension line to.
  447. };
  448. /**
  449. * A radial dimension indicates either the radius or diameter of an arc or circle.
  450. *
  451. * A guide to the geometry of a circle dimension:
  452. *
  453. * |
  454. * --a--
  455. * |
  456. *
  457. *
  458. * b_
  459. * |\
  460. * \
  461. * c---d TEXT
  462. *
  463. * Point a (the center of the arc or circle) is m_start, point b (a point on the arc or circle)
  464. * is m_end, point c is m_leaderLength away from b on the a-b vector, and point d is the end of
  465. * the "text line". The c-d line is drawn from c to the text center, and clipped on the text
  466. * bounding box.
  467. */
  468. class PCB_DIM_RADIAL : public PCB_DIMENSION_BASE
  469. {
  470. public:
  471. PCB_DIM_RADIAL( BOARD_ITEM* aParent );
  472. void Serialize( google::protobuf::Any &aContainer ) const override;
  473. bool Deserialize( const google::protobuf::Any &aContainer ) override;
  474. static inline bool ClassOf( const EDA_ITEM* aItem )
  475. {
  476. return aItem && aItem->Type() == PCB_DIM_RADIAL_T;
  477. }
  478. EDA_ITEM* Clone() const override;
  479. void SetLeaderLength( int aLength ) { m_leaderLength = aLength; }
  480. int GetLeaderLength() const { return m_leaderLength; }
  481. void ChangeLeaderLength( int aLength )
  482. {
  483. SetLeaderLength( aLength );
  484. Update();
  485. }
  486. // Returns the point (c).
  487. VECTOR2I GetKnee() const;
  488. BITMAPS GetMenuImage() const override;
  489. wxString GetClass() const override
  490. {
  491. return wxT( "PCB_DIM_RADIAL" );
  492. }
  493. protected:
  494. virtual void swapData( BOARD_ITEM* aImage ) override;
  495. void updateText() override;
  496. void updateGeometry() override;
  497. private:
  498. int m_leaderLength;
  499. };
  500. /**
  501. * A leader is a dimension-like object pointing to a specific point.
  502. *
  503. * A guide to the geometry of a leader:
  504. *
  505. * a_
  506. * |\
  507. * \
  508. * b---c TEXT
  509. *
  510. * Point (a) is m_start, point (b) is m_end, point (c) is the end of the "text line"
  511. * The b-c line is drawn from b to the text center, and clipped on the text bounding box.
  512. */
  513. class PCB_DIM_LEADER : public PCB_DIMENSION_BASE
  514. {
  515. public:
  516. PCB_DIM_LEADER( BOARD_ITEM* aParent );
  517. void Serialize( google::protobuf::Any &aContainer ) const override;
  518. bool Deserialize( const google::protobuf::Any &aContainer ) override;
  519. static inline bool ClassOf( const EDA_ITEM* aItem )
  520. {
  521. return aItem && aItem->Type() == PCB_DIM_LEADER_T;
  522. }
  523. EDA_ITEM* Clone() const override;
  524. BITMAPS GetMenuImage() const override;
  525. wxString GetClass() const override
  526. {
  527. return wxT( "PCB_DIM_LEADER" );
  528. }
  529. void SetTextBorder( DIM_TEXT_BORDER aBorder ) { m_textBorder = aBorder; }
  530. DIM_TEXT_BORDER GetTextBorder() const { return m_textBorder; }
  531. void ChangeTextBorder( DIM_TEXT_BORDER aBorder )
  532. {
  533. SetTextBorder( aBorder );
  534. Update();
  535. }
  536. void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
  537. protected:
  538. virtual void swapData( BOARD_ITEM* aImage ) override;
  539. void updateText() override;
  540. void updateGeometry() override;
  541. private:
  542. DIM_TEXT_BORDER m_textBorder;
  543. };
  544. /**
  545. * Mark the center of a circle or arc with a cross shape.
  546. *
  547. * The size and orientation of the cross is adjustable.
  548. * m_start always marks the center being measured; m_end marks the end of one leg of the cross.
  549. */
  550. class PCB_DIM_CENTER : public PCB_DIMENSION_BASE
  551. {
  552. public:
  553. PCB_DIM_CENTER( BOARD_ITEM* aParent );
  554. void Serialize( google::protobuf::Any &aContainer ) const override;
  555. bool Deserialize( const google::protobuf::Any &aContainer ) override;
  556. static inline bool ClassOf( const EDA_ITEM* aItem )
  557. {
  558. return aItem && aItem->Type() == PCB_DIM_CENTER_T;
  559. }
  560. EDA_ITEM* Clone() const override;
  561. BITMAPS GetMenuImage() const override;
  562. wxString GetClass() const override
  563. {
  564. return wxT( "PCB_DIM_CENTER" );
  565. }
  566. const BOX2I GetBoundingBox() const override;
  567. const BOX2I ViewBBox() const override;
  568. protected:
  569. virtual void swapData( BOARD_ITEM* aImage ) override;
  570. void updateGeometry() override;
  571. };
  572. #endif // DIMENSION_H