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.

585 lines
19 KiB

8 years ago
5 years ago
14 years ago
14 years ago
18 years ago
4 years ago
4 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
Introduction of Graphics Abstraction Layer based rendering for pcbnew. New classes: - VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.) - VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes). - EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL). - GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries. - WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc. - PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods. - STROKE_FONT - Implements stroke font drawing using GAL methods. Most important changes to Kicad original code: * EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects. * EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime. * There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew) * Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom. * Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime. * Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods. * Removed tools/class_painter.h, as now it is extended and included in source code. Build changes: * GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL. * When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required. * GAL-related code is compiled into a static library (common/libgal). * Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS). More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
13 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 (C) 1992-2022 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. /**
  25. * @brief A single base class (PCB_TRACK) represents both tracks and vias, with subclasses
  26. * for curved tracks (PCB_ARC) and vias (PCB_VIA). All told there are three KICAD_Ts:
  27. * PCB_TRACK_T, PCB_ARC_T, and PCB_VIA_T.
  28. *
  29. * For vias there is a further VIATYPE which indicates THROUGH, BLIND_BURIED, or
  30. * MICROVIA, which are supported by the synthetic KICAD_Ts PCB_LOCATE_STDVIA_T,
  31. * PCB_LOCATE_BBVIA_T, and PCB_LOCATE_UVIA_T.
  32. */
  33. #ifndef CLASS_TRACK_H
  34. #define CLASS_TRACK_H
  35. #include <board_connected_item.h>
  36. #include <base_units.h>
  37. #include <geometry/shape_segment.h>
  38. #include <core/minoptmax.h>
  39. #include <core/arraydim.h>
  40. class PCB_TRACK;
  41. class PCB_VIA;
  42. class PAD;
  43. class MSG_PANEL_ITEM;
  44. class SHAPE_POLY_SET;
  45. class SHAPE_ARC;
  46. // Flag used in locate routines (from which endpoint work)
  47. enum ENDPOINT_T : int
  48. {
  49. ENDPOINT_START = 0,
  50. ENDPOINT_END = 1
  51. };
  52. // Via types
  53. // Note that this enum must be synchronized to GAL_LAYER_ID
  54. enum class VIATYPE : int
  55. {
  56. THROUGH = 3, /* Always a through hole via */
  57. BLIND_BURIED = 2, /* this via can be on internal layers */
  58. MICROVIA = 1, /* this via which connect from an external layer
  59. * to the near neighbor internal layer */
  60. NOT_DEFINED = 0 /* not yet used */
  61. };
  62. #define UNDEFINED_DRILL_DIAMETER -1 //< Undefined via drill diameter.
  63. // Used for tracks and vias for algorithmic safety, not to enforce constraints
  64. #define GEOMETRY_MIN_SIZE (int) ( 0.001 * pcbIUScale.IU_PER_MM )
  65. class PCB_TRACK : public BOARD_CONNECTED_ITEM
  66. {
  67. public:
  68. static inline bool ClassOf( const EDA_ITEM* aItem )
  69. {
  70. return aItem && PCB_TRACE_T == aItem->Type();
  71. }
  72. PCB_TRACK( BOARD_ITEM* aParent, KICAD_T idtype = PCB_TRACE_T );
  73. // Do not create a copy constructor. The one generated by the compiler is adequate.
  74. void Move( const VECTOR2I& aMoveVector ) override
  75. {
  76. m_Start += aMoveVector;
  77. m_End += aMoveVector;
  78. }
  79. void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
  80. virtual void Mirror( const VECTOR2I& aCentre, bool aMirrorAroundXAxis );
  81. void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
  82. void SetPosition( const VECTOR2I& aPos ) override { m_Start = aPos; }
  83. VECTOR2I GetPosition() const override { return m_Start; }
  84. const VECTOR2I GetFocusPosition() const override { return ( m_Start + m_End ) / 2; }
  85. void SetWidth( int aWidth ) { m_Width = aWidth; }
  86. int GetWidth() const { return m_Width; }
  87. void SetEnd( const VECTOR2I& aEnd ) { m_End = aEnd; }
  88. const VECTOR2I& GetEnd() const { return m_End; }
  89. void SetStart( const VECTOR2I& aStart ) { m_Start = aStart; }
  90. const VECTOR2I& GetStart() const { return m_Start; }
  91. void SetEndX( int aX ) { m_End.x = aX; }
  92. void SetEndY( int aY ) { m_End.y = aY; }
  93. int GetEndX() const { return m_End.x; }
  94. int GetEndY() const { return m_End.y; }
  95. /// Return the selected endpoint (start or end)
  96. const VECTOR2I& GetEndPoint( ENDPOINT_T aEndPoint ) const
  97. {
  98. if( aEndPoint == ENDPOINT_START )
  99. return m_Start;
  100. else
  101. return m_End;
  102. }
  103. // Virtual function
  104. const BOX2I GetBoundingBox() const override;
  105. /**
  106. * Function GetLength
  107. * returns the length of the track using the hypotenuse calculation.
  108. * @return double - the length of the track
  109. */
  110. virtual double GetLength() const;
  111. /**
  112. * Function TransformShapeToPolygon
  113. * Convert the track shape to a closed polygon
  114. * Used in filling zones calculations
  115. * Circles (vias) and arcs (ends of tracks) are approximated by segments
  116. * @param aBuffer = a buffer to store the polygon
  117. * @param aClearance = the clearance around the pad
  118. * @param aError = the maximum deviation from true circle
  119. * @param ignoreLineWidth = used for edge cut items where the line width is only for
  120. * visualization
  121. */
  122. void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
  123. int aError, ERROR_LOC aErrorLoc,
  124. bool ignoreLineWidth = false ) const override;
  125. // @copydoc BOARD_ITEM::GetEffectiveShape
  126. std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
  127. FLASHING aFlash = FLASHING::DEFAULT ) const override;
  128. /**
  129. * Function IsPointOnEnds
  130. * returns STARTPOINT if point if near (dist = min_dist) start point, ENDPOINT if
  131. * point if near (dist = min_dist) end point,STARTPOINT|ENDPOINT if point if near
  132. * (dist = min_dist) both ends, or 0 if none of the above.
  133. * if min_dist < 0: min_dist = track_width/2
  134. */
  135. EDA_ITEM_FLAGS IsPointOnEnds( const VECTOR2I& point, int min_dist = 0 ) const;
  136. /**
  137. * Function IsNull
  138. * returns true if segment length is zero.
  139. */
  140. bool IsNull() const
  141. {
  142. return ( Type() == PCB_VIA_T ) || ( m_Start == m_End );
  143. }
  144. void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
  145. INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
  146. const std::vector<KICAD_T>& aScanTypes ) override;
  147. bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
  148. bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
  149. bool ApproxCollinear( const PCB_TRACK& aTrack );
  150. wxString GetClass() const override
  151. {
  152. return wxT( "PCB_TRACK" );
  153. }
  154. /**
  155. * Function GetLocalClearance
  156. * returns any local clearance overrides set in the "classic" (ie: pre-rule) system.
  157. * @param aSource [out] optionally reports the source as a user-readable string
  158. * @return int - the clearance in internal units.
  159. */
  160. int GetLocalClearance( wxString* aSource ) const override;
  161. MINOPTMAX<int> GetWidthConstraint( wxString* aSource ) const;
  162. wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override;
  163. BITMAPS GetMenuImage() const override;
  164. virtual EDA_ITEM* Clone() const override;
  165. virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
  166. double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
  167. const BOX2I ViewBBox() const override;
  168. /**
  169. * @return true because a track or a via is always on a copper layer.
  170. */
  171. bool IsOnCopperLayer() const override
  172. {
  173. return true;
  174. }
  175. /**
  176. * Get last used LOD for the track net name
  177. * @return LOD from ViewGetLOD()
  178. */
  179. double GetCachedLOD()
  180. {
  181. return m_CachedLOD;
  182. }
  183. /**
  184. * Set the cached LOD
  185. * @param aLOD value from ViewGetLOD() or 0.0 to always display
  186. */
  187. void SetCachedLOD( double aLOD )
  188. {
  189. m_CachedLOD = aLOD;
  190. }
  191. /**
  192. * Get last used zoom scale for the track net name
  193. * @return scale from GetScale()
  194. */
  195. double GetCachedScale()
  196. {
  197. return m_CachedScale;
  198. }
  199. /**
  200. * Set the cached scale
  201. * @param aScale value from GetScale()
  202. */
  203. void SetCachedScale( double aScale )
  204. {
  205. m_CachedScale = aScale;
  206. }
  207. struct cmp_tracks
  208. {
  209. bool operator()( const PCB_TRACK* aFirst, const PCB_TRACK* aSecond ) const;
  210. };
  211. #if defined (DEBUG)
  212. virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
  213. #endif
  214. protected:
  215. virtual void swapData( BOARD_ITEM* aImage ) override;
  216. void GetMsgPanelInfoBase_Common( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) const;
  217. protected:
  218. int m_Width; ///< Thickness of track, or via diameter
  219. VECTOR2I m_Start; ///< Line start point
  220. VECTOR2I m_End; ///< Line end point
  221. double m_CachedLOD; ///< Last LOD used to draw this track's net
  222. double m_CachedScale; ///< Last zoom scale used to draw this track's net (we want to redraw when changing zoom)
  223. };
  224. class PCB_ARC : public PCB_TRACK
  225. {
  226. public:
  227. PCB_ARC( BOARD_ITEM* aParent ) :
  228. PCB_TRACK( aParent, PCB_ARC_T )
  229. {
  230. };
  231. PCB_ARC( BOARD_ITEM* aParent, const SHAPE_ARC* aArc );
  232. static inline bool ClassOf( const EDA_ITEM *aItem )
  233. {
  234. return aItem && PCB_ARC_T == aItem->Type();
  235. }
  236. virtual void Move( const VECTOR2I& aMoveVector ) override
  237. {
  238. m_Start += aMoveVector;
  239. m_Mid += aMoveVector;
  240. m_End += aMoveVector;
  241. }
  242. void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
  243. void Mirror( const VECTOR2I& aCentre, bool aMirrorAroundXAxis ) override;
  244. void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
  245. void SetMid( const VECTOR2I& aMid ) { m_Mid = aMid; }
  246. const VECTOR2I& GetMid() const { return m_Mid; }
  247. void SetPosition( const VECTOR2I& aPos ) override
  248. {
  249. m_Start = aPos;
  250. }
  251. virtual VECTOR2I GetPosition() const override;
  252. virtual VECTOR2I GetCenter() const override { return GetPosition(); }
  253. double GetRadius() const;
  254. EDA_ANGLE GetAngle() const;
  255. EDA_ANGLE GetArcAngleStart() const;
  256. EDA_ANGLE GetArcAngleEnd() const;
  257. virtual bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
  258. virtual bool HitTest( const BOX2I& aRect, bool aContained = true, int aAccuracy = 0 ) const override;
  259. bool IsCCW() const;
  260. wxString GetClass() const override
  261. {
  262. return wxT( "PCB_ARC" );
  263. }
  264. // @copydoc BOARD_ITEM::GetEffectiveShape
  265. std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
  266. FLASHING aFlash = FLASHING::DEFAULT ) const override;
  267. /**
  268. * Function GetLength
  269. * returns the length of the arc track
  270. * @return double - the length of the track
  271. */
  272. virtual double GetLength() const override
  273. {
  274. return GetRadius() * std::abs( GetAngle().AsRadians() );
  275. }
  276. EDA_ITEM* Clone() const override;
  277. protected:
  278. virtual void swapData( BOARD_ITEM* aImage ) override;
  279. private:
  280. VECTOR2I m_Mid; ///< Arc mid point, halfway between start and end
  281. };
  282. class PCB_VIA : public PCB_TRACK
  283. {
  284. public:
  285. PCB_VIA( BOARD_ITEM* aParent );
  286. static inline bool ClassOf( const EDA_ITEM *aItem )
  287. {
  288. return aItem && PCB_VIA_T == aItem->Type();
  289. }
  290. // Do not create a copy constructor. The one generated by the compiler is adequate.
  291. bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override
  292. {
  293. if( BOARD_CONNECTED_ITEM::IsType( aScanTypes ) )
  294. return true;
  295. for( KICAD_T scanType : aScanTypes )
  296. {
  297. if( scanType == PCB_LOCATE_STDVIA_T && m_viaType == VIATYPE::THROUGH )
  298. return true;
  299. else if( scanType == PCB_LOCATE_UVIA_T && m_viaType == VIATYPE::MICROVIA )
  300. return true;
  301. else if( scanType == PCB_LOCATE_BBVIA_T && m_viaType == VIATYPE::BLIND_BURIED )
  302. return true;
  303. }
  304. return false;
  305. }
  306. VIATYPE GetViaType() const { return m_viaType; }
  307. void SetViaType( VIATYPE aViaType ) { m_viaType = aViaType; }
  308. bool HasHole() const override
  309. {
  310. return true;
  311. }
  312. std::shared_ptr<SHAPE_SEGMENT> GetEffectiveHoleShape() const override;
  313. bool IsTented() const override;
  314. int GetSolderMaskExpansion() const;
  315. bool IsOnLayer( PCB_LAYER_ID aLayer ) const override;
  316. virtual LSET GetLayerSet() const override;
  317. virtual void SetLayerSet( LSET aLayers ) override;
  318. /**
  319. * Function SetLayerPair
  320. * For a via m_layer contains the top layer, the other layer is in m_bottomLayer
  321. * @param aTopLayer = first layer connected by the via
  322. * @param aBottomLayer = last layer connected by the via
  323. */
  324. void SetLayerPair( PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer );
  325. void SetBottomLayer( PCB_LAYER_ID aLayer );
  326. void SetTopLayer( PCB_LAYER_ID aLayer );
  327. /**
  328. * Function LayerPair
  329. * Return the 2 layers used by the via (the via actually uses
  330. * all layers between these 2 layers)
  331. * @param top_layer = pointer to the first layer (can be null)
  332. * @param bottom_layer = pointer to the last layer (can be null)
  333. */
  334. void LayerPair( PCB_LAYER_ID* top_layer, PCB_LAYER_ID* bottom_layer ) const;
  335. PCB_LAYER_ID TopLayer() const;
  336. PCB_LAYER_ID BottomLayer() const;
  337. /**
  338. * Function SanitizeLayers
  339. * Check so that the layers are correct dependin on the type of via, and
  340. * so that the top actually is on top.
  341. */
  342. void SanitizeLayers();
  343. VECTOR2I GetPosition() const override { return m_Start; }
  344. void SetPosition( const VECTOR2I& aPoint ) override { m_Start = aPoint; m_End = aPoint; }
  345. void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
  346. bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
  347. bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
  348. wxString GetClass() const override
  349. {
  350. return wxT( "PCB_VIA" );
  351. }
  352. wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override;
  353. BITMAPS GetMenuImage() const override;
  354. EDA_ITEM* Clone() const override;
  355. void ViewGetLayers( int aLayers[], int& aCount ) const override;
  356. double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
  357. void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
  358. #if defined (DEBUG)
  359. void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
  360. #endif
  361. int GetMinAnnulus( PCB_LAYER_ID aLayer, wxString* aSource ) const;
  362. /**
  363. * Sets the unconnected removal property. If true, the copper is removed on zone fill
  364. * or when specifically requested when the via is not connected on a layer.
  365. */
  366. void SetRemoveUnconnected( bool aSet ) { m_removeUnconnectedLayer = aSet; }
  367. bool GetRemoveUnconnected() const { return m_removeUnconnectedLayer; }
  368. /**
  369. * Sets whether we keep the start and end annular rings even if they are not connected
  370. */
  371. void SetKeepStartEnd( bool aSet ) { m_keepStartEndLayer = aSet; }
  372. bool GetKeepStartEnd() const { return m_keepStartEndLayer; }
  373. bool ConditionallyFlashed( PCB_LAYER_ID aLayer ) const
  374. {
  375. if( !m_removeUnconnectedLayer )
  376. return false;
  377. if( m_keepStartEndLayer && ( aLayer == m_layer || aLayer == m_bottomLayer ) )
  378. return false;
  379. return true;
  380. }
  381. /**
  382. * Checks to see whether the via should have a pad on the specific layer
  383. * @param aLayer Layer to check for connectivity
  384. * @return true if connected by pad or track (or optionally zone)
  385. */
  386. bool FlashLayer( int aLayer ) const;
  387. /**
  388. * Checks to see if the via is present on any of the layers in the set
  389. * @param aLayers set of layers to check the via against
  390. * @return true if connected by pad or track (or optionally zone) on any of the associated layers
  391. */
  392. bool FlashLayer( LSET aLayers ) const;
  393. /**
  394. * Function SetDrill
  395. * sets the drill value for vias.
  396. * @param aDrill is the new drill diameter
  397. */
  398. void SetDrill( int aDrill ) { m_drill = aDrill; }
  399. /**
  400. * Function GetDrill
  401. * returns the local drill setting for this PCB_VIA. If you want the calculated value,
  402. * use GetDrillValue() instead.
  403. */
  404. int GetDrill() const { return m_drill; }
  405. /**
  406. * Function GetDrillValue
  407. * "calculates" the drill value for vias (m-Drill if > 0, or default
  408. * drill value for the board.
  409. * @return real drill_value
  410. */
  411. int GetDrillValue() const;
  412. /**
  413. * Function SetDrillDefault
  414. * sets the drill value for vias to the default value #UNDEFINED_DRILL_DIAMETER.
  415. */
  416. void SetDrillDefault() { m_drill = UNDEFINED_DRILL_DIAMETER; }
  417. /**
  418. * Checks if the via is a free via (as opposed to one created on a track by the router).
  419. * Free vias don't have their nets automatically updated by the connectivity algorithm.
  420. * @return true if the via is a free via
  421. */
  422. bool GetIsFree() const { return m_isFree; }
  423. void SetIsFree( bool aFree = true ) { m_isFree = aFree; }
  424. /**
  425. * Function IsDrillDefault
  426. * @return true if the drill value is default value (-1)
  427. */
  428. bool IsDrillDefault() const { return m_drill <= 0; }
  429. // @copydoc BOARD_ITEM::GetEffectiveShape
  430. std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
  431. FLASHING aFlash = FLASHING::DEFAULT ) const override;
  432. void ClearZoneConnectionCache()
  433. {
  434. for( size_t ii = 0; ii < arrayDim( m_zoneLayerConnections ); ++ii )
  435. m_zoneLayerConnections[ ii ] = ZLC_UNRESOLVED;
  436. }
  437. ZONE_LAYER_CONNECTION& ZoneConnectionCache( PCB_LAYER_ID aLayer ) const
  438. {
  439. return m_zoneLayerConnections[ aLayer ];
  440. }
  441. protected:
  442. void swapData( BOARD_ITEM* aImage ) override;
  443. wxString layerMaskDescribe() const override;
  444. private:
  445. /// The bottom layer of the via (the top layer is in m_layer)
  446. PCB_LAYER_ID m_bottomLayer;
  447. VIATYPE m_viaType; ///< through, blind/buried or micro
  448. int m_drill; ///< for vias: via drill (- 1 for default value)
  449. bool m_removeUnconnectedLayer; ///< Remove annular rings on unconnected layers
  450. bool m_keepStartEndLayer; ///< Keep the start and end annular rings
  451. bool m_isFree; ///< "Free" vias don't get their nets auto-updated
  452. mutable ZONE_LAYER_CONNECTION m_zoneLayerConnections[B_Cu + 1];
  453. };
  454. #endif // CLASS_TRACK_H