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.

540 lines
19 KiB

8 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 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
8 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-2017 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. * @file class_track.h
  26. * @brief Definitions for tracks, vias and zones.
  27. */
  28. #ifndef CLASS_TRACK_H
  29. #define CLASS_TRACK_H
  30. #include <pcbnew.h>
  31. #include <class_board_item.h>
  32. #include <board_connected_item.h>
  33. #include <pcb_display_options.h>
  34. #include <trigo.h>
  35. class TRACK;
  36. class VIA;
  37. class D_PAD;
  38. class MSG_PANEL_ITEM;
  39. class SHAPE_POLY_SET;
  40. // Via types
  41. // Note that this enum must be synchronized to GAL_LAYER_ID
  42. enum VIATYPE_T
  43. {
  44. VIA_THROUGH = 3, /* Always a through hole via */
  45. VIA_BLIND_BURIED = 2, /* this via can be on internal layers */
  46. VIA_MICROVIA = 1, /* this via which connect from an external layer
  47. * to the near neighbor internal layer */
  48. VIA_NOT_DEFINED = 0 /* not yet used */
  49. };
  50. #define UNDEFINED_DRILL_DIAMETER -1 //< Undefined via drill diameter.
  51. #define MIN_VIA_DRAW_SIZE 4 /// Minimum size in pixel for full drawing
  52. // Used for tracks and vias for algorithmic safety, not to enforce constraints
  53. #define GEOMETRY_MIN_SIZE ( int )( 0.001 * IU_PER_MM )
  54. /**
  55. * Function GetTrack
  56. * is a helper function to locate a trace segment having an end point at \a aPosition
  57. * on \a aLayerMask starting at \a aStartTrace and end at \a aEndTrace.
  58. * <p>
  59. * The segments of track that are flagged as deleted or busy are ignored. Layer
  60. * visibility is also ignored.
  61. * </p>
  62. * @param aStartTrace A pointer to the TRACK object to begin searching.
  63. * @param aEndTrace A pointer to the TRACK object to stop the search. A NULL value
  64. * searches to the end of the list.
  65. * @param aPosition A wxPoint object containing the position to test.
  66. * @param aLayerMask A layer or layers to mask the hit test. Use -1 to ignore
  67. * layer mask.
  68. * @return A TRACK object pointer if found otherwise NULL.
  69. */
  70. TRACK* GetTrack( TRACK* aStartTrace, const TRACK* aEndTrace,
  71. const wxPoint& aPosition, LSET aLayerMask );
  72. class TRACK : public BOARD_CONNECTED_ITEM
  73. {
  74. public:
  75. static inline bool ClassOf( const EDA_ITEM* aItem )
  76. {
  77. return aItem && PCB_TRACE_T == aItem->Type();
  78. }
  79. BOARD_CONNECTED_ITEM* start; // pointers to a connected item (pad or track)
  80. BOARD_CONNECTED_ITEM* end;
  81. double m_Param; // Auxiliary variable ( used in some computations )
  82. TRACK( BOARD_ITEM* aParent, KICAD_T idtype = PCB_TRACE_T );
  83. // Do not create a copy constructor. The one generated by the compiler is adequate.
  84. TRACK* Next() const { return static_cast<TRACK*>( Pnext ); }
  85. TRACK* Back() const { return static_cast<TRACK*>( Pback ); }
  86. virtual void Move( const wxPoint& aMoveVector ) override
  87. {
  88. m_Start += aMoveVector;
  89. m_End += aMoveVector;
  90. }
  91. virtual void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
  92. virtual void Flip( const wxPoint& aCentre ) override;
  93. void SetPosition( const wxPoint& aPos ) override { m_Start = aPos; }
  94. const wxPoint GetPosition() const override { return m_Start; }
  95. void SetWidth( int aWidth ) { m_Width = aWidth; }
  96. int GetWidth() const { return m_Width; }
  97. void SetEnd( const wxPoint& aEnd ) { m_End = aEnd; }
  98. const wxPoint& GetEnd() const { return m_End; }
  99. void SetStart( const wxPoint& aStart ) { m_Start = aStart; }
  100. const wxPoint& GetStart() const { return m_Start; }
  101. /// Return the selected endpoint (start or end)
  102. const wxPoint& GetEndPoint( ENDPOINT_T aEndPoint ) const
  103. {
  104. if( aEndPoint == ENDPOINT_START )
  105. return m_Start;
  106. else
  107. return m_End;
  108. }
  109. // Virtual function
  110. const EDA_RECT GetBoundingBox() const override;
  111. bool IsLocked() const override
  112. {
  113. return GetState( TRACK_LOCKED );
  114. }
  115. void SetLocked( bool aLocked ) override
  116. {
  117. return SetState( TRACK_LOCKED, aLocked );
  118. }
  119. /**
  120. * Function GetBestInsertPoint
  121. * searches the "best" insertion point within the track linked list.
  122. * The best point is currently the end of the corresponding net code section.
  123. * (The BOARD::m_Track and BOARD::m_Zone lists are sorted by netcode.)
  124. * @param aPcb The BOARD to search for the insertion point.
  125. * @return TRACK* - the insertion point in the linked list.
  126. * this is the next item after the last item having my net code.
  127. * therefore the track to insert must be inserted before the insertion point.
  128. * if the best insertion point is the end of list, the returned value is NULL
  129. */
  130. TRACK* GetBestInsertPoint( BOARD* aPcb );
  131. /* Search (within the track linked list) the first segment matching the netcode
  132. * ( the linked list is always sorted by net codes )
  133. */
  134. TRACK* GetStartNetCode( int NetCode );
  135. /* Search (within the track linked list) the last segment matching the netcode
  136. * ( the linked list is always sorted by net codes )
  137. */
  138. TRACK* GetEndNetCode( int NetCode );
  139. /**
  140. * Function GetLength
  141. * returns the length of the track using the hypotenuse calculation.
  142. * @return double - the length of the track
  143. */
  144. double GetLength() const
  145. {
  146. return GetLineLength( m_Start, m_End );
  147. }
  148. /* Display on screen: */
  149. void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
  150. GR_DRAWMODE aDrawMode, const wxPoint& aOffset = ZeroOffset ) override;
  151. /**
  152. * Function TransformShapeWithClearanceToPolygon
  153. * Convert the track shape to a closed polygon
  154. * Used in filling zones calculations
  155. * Circles (vias) and arcs (ends of tracks) are approximated by segments
  156. * @param aCornerBuffer = a buffer to store the polygon
  157. * @param aClearanceValue = the clearance around the pad
  158. * @param aCircleToSegmentsCount = the number of segments to approximate a circle
  159. * @param aCorrectionFactor = the correction to apply to circles radius to keep
  160. * clearance when the circle is approximated by segment bigger or equal
  161. * to the real clearance value (usually near from 1.0)
  162. * @param ignoreLineWidth = used for edge cut items where the line width is only
  163. * for visualization
  164. */
  165. void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
  166. int aClearanceValue,
  167. int aCircleToSegmentsCount,
  168. double aCorrectionFactor,
  169. bool ignoreLineWidth = false ) const override;
  170. /**
  171. * Function IsPointOnEnds
  172. * returns STARTPOINT if point if near (dist = min_dist) start point, ENDPOINT if
  173. * point if near (dist = min_dist) end point,STARTPOINT|ENDPOINT if point if near
  174. * (dist = min_dist) both ends, or 0 if none of the above.
  175. * if min_dist < 0: min_dist = track_width/2
  176. */
  177. STATUS_FLAGS IsPointOnEnds( const wxPoint& point, int min_dist = 0 );
  178. /**
  179. * Function IsNull
  180. * returns true if segment length is zero.
  181. */
  182. bool IsNull();
  183. void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override;
  184. SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
  185. virtual bool HitTest( const wxPoint& aPosition ) const override;
  186. virtual bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const override;
  187. /**
  188. * Function GetVia
  189. * finds the first VIA object at \a aPosition on \a aLayer starting at the trace.
  190. *
  191. * @param aPosition The wxPoint to HitTest() against.
  192. * @param aLayer The layer to match, pass -1 for a don't care.
  193. * @return A pointer to a VIA object if found, else NULL.
  194. */
  195. VIA* GetVia( const wxPoint& aPosition, PCB_LAYER_ID aLayer = UNDEFINED_LAYER );
  196. /**
  197. * Function GetVia
  198. * finds the first VIA object at \a aPosition on \a aLayer starting at the trace
  199. * and ending at \a aEndTrace.
  200. *
  201. * @param aEndTrace Pointer to the last TRACK object to end search.
  202. * @param aPosition The wxPoint to HitTest() against.
  203. * @param aLayerMask The layers to match, pass -1 for a don't care.
  204. * @return A pointer to a VIA object if found, else NULL.
  205. */
  206. VIA* GetVia( TRACK* aEndTrace, const wxPoint& aPosition, LSET aLayerMask );
  207. /**
  208. * Function GetTrack
  209. * returns the trace segment connected to the segment at \a aEndPoint from \a
  210. * aStartTrace to \a aEndTrace.
  211. *
  212. * @param aStartTrace A pointer to the TRACK object to begin searching.
  213. * @param aEndTrace A pointer to the TRACK object to stop the search. A NULL value
  214. * searches to the end of the list.
  215. * @param aEndPoint The start or end point of the segment to test against.
  216. * @param aSameNetOnly if true stop searching when the netcode changes
  217. * @param aSequential If true, forces a forward sequential search,
  218. * which is restartable; the default search can be faster but the
  219. * position of the returned track in the list is unpredictable
  220. * @return A TRACK object pointer if found otherwise NULL.
  221. */
  222. TRACK* GetTrack( TRACK* aStartTrace, TRACK* aEndTrace, ENDPOINT_T aEndPoint,
  223. bool aSameNetOnly, bool aSequential );
  224. /**
  225. * Function GetEndSegments
  226. * get the segments connected to the end point of the track.
  227. * return 1 if OK, 0 when a track is a closed loop
  228. * and the beginning and the end of the track in *StartTrack and *EndTrack
  229. * Modify *StartTrack en *EndTrack :
  230. * (*StartTrack)->m_Start coordinate is the beginning of the track
  231. * (*EndTrack)->m_End coordinate is the end of the track
  232. * Segments connected must be consecutive in list
  233. */
  234. int GetEndSegments( int NbSegm, TRACK** StartTrack, TRACK** EndTrack );
  235. wxString GetClass() const override
  236. {
  237. return wxT( "TRACK" );
  238. }
  239. /**
  240. * Function GetClearance
  241. * returns the clearance in internal units. If \a aItem is not NULL then the
  242. * returned clearance is the greater of this object's clearance and
  243. * aItem's clearance. If \a aItem is NULL, then this objects clearance
  244. * is returned.
  245. * @param aItem is another BOARD_CONNECTED_ITEM or NULL
  246. * @return int - the clearance in internal units.
  247. */
  248. virtual int GetClearance( BOARD_CONNECTED_ITEM* aItem = NULL ) const override;
  249. virtual wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
  250. BITMAP_DEF GetMenuImage() const override;
  251. virtual EDA_ITEM* Clone() const override;
  252. virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
  253. virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
  254. const BOX2I ViewBBox() const override;
  255. virtual void SwapData( BOARD_ITEM* aImage ) override;
  256. #if defined (DEBUG)
  257. virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
  258. /**
  259. * Function ShowState
  260. * converts a set of state bits to a wxString
  261. * @param stateBits Is an OR-ed together set of bits like BUSY, EDIT, etc.
  262. */
  263. static wxString ShowState( int stateBits );
  264. #endif
  265. protected:
  266. /**
  267. * Function GetMsgPanelInfoBase
  268. * Display info about the track segment only, and does not calculate the full track length
  269. * @param aList A list of #MSG_PANEL_ITEM objects to add status information.
  270. */
  271. virtual void GetMsgPanelInfoBase( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList );
  272. /**
  273. * Helper function for the common panel info */
  274. void GetMsgPanelInfoBase_Common( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList );
  275. /**
  276. * Helper for drawing the short netname in tracks */
  277. void DrawShortNetname( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
  278. COLOR4D aBgColor );
  279. int m_Width; ///< Thickness of track, or via diameter
  280. wxPoint m_Start; ///< Line start point
  281. wxPoint m_End; ///< Line end point
  282. private:
  283. // make SetNext() and SetBack() private so that they may not be called from anywhere.
  284. // list management is done on TRACKs using DLIST<TRACK> only.
  285. void SetNext( EDA_ITEM* aNext ) { Pnext = aNext; }
  286. void SetBack( EDA_ITEM* aBack ) { Pback = aBack; }
  287. };
  288. class SEGZONE : public TRACK
  289. {
  290. public:
  291. SEGZONE( BOARD_ITEM* aParent );
  292. // Do not create a copy constructor. The one generated by the compiler is adequate.
  293. wxString GetClass() const override
  294. {
  295. return wxT( "ZONE" );
  296. }
  297. SEGZONE* Next() const { return static_cast<SEGZONE*>( Pnext ); }
  298. wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
  299. void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
  300. GR_DRAWMODE aDrawMode, const wxPoint& aOffset = ZeroOffset ) override;
  301. BITMAP_DEF GetMenuImage() const override;
  302. EDA_ITEM* Clone() const override;
  303. protected:
  304. void GetMsgPanelInfoBase( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override;
  305. };
  306. class VIA : public TRACK
  307. {
  308. public:
  309. VIA( BOARD_ITEM* aParent );
  310. static inline bool ClassOf( const EDA_ITEM *aItem )
  311. {
  312. return aItem && PCB_VIA_T == aItem->Type();
  313. }
  314. // Do not create a copy constructor. The one generated by the compiler is adequate.
  315. void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
  316. GR_DRAWMODE aDrawMode, const wxPoint& aOffset = ZeroOffset ) override;
  317. bool IsOnLayer( PCB_LAYER_ID aLayer ) const override;
  318. virtual LSET GetLayerSet() const override;
  319. /**
  320. * Function SetLayerPair
  321. * For a via m_Layer contains the top layer, the other layer is in
  322. * m_BottomLayer
  323. * @param aTopLayer = first layer connected by the via
  324. * @param aBottomLayer = last layer connected by the via
  325. */
  326. void SetLayerPair( PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer );
  327. void SetBottomLayer( PCB_LAYER_ID aLayer );
  328. void SetTopLayer( PCB_LAYER_ID aLayer );
  329. /**
  330. * Function LayerPair
  331. * Return the 2 layers used by the via (the via actually uses
  332. * all layers between these 2 layers)
  333. * @param top_layer = pointer to the first layer (can be null)
  334. * @param bottom_layer = pointer to the last layer (can be null)
  335. */
  336. void LayerPair( PCB_LAYER_ID* top_layer, PCB_LAYER_ID* bottom_layer ) const;
  337. PCB_LAYER_ID TopLayer() const;
  338. PCB_LAYER_ID BottomLayer() const;
  339. /**
  340. * Function SanitizeLayers
  341. * Check so that the layers are correct dependin on the type of via, and
  342. * so that the top actually is on top.
  343. */
  344. void SanitizeLayers();
  345. const wxPoint GetPosition() const override { return m_Start; }
  346. void SetPosition( const wxPoint& aPoint ) override { m_Start = aPoint; m_End = aPoint; }
  347. virtual bool HitTest( const wxPoint& aPosition ) const override;
  348. virtual bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const override;
  349. wxString GetClass() const override
  350. {
  351. return wxT( "VIA" );
  352. }
  353. wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
  354. BITMAP_DEF GetMenuImage() const override;
  355. EDA_ITEM* Clone() const override;
  356. virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
  357. virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
  358. virtual void Flip( const wxPoint& aCentre ) override;
  359. #if defined (DEBUG)
  360. virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
  361. #endif
  362. VIATYPE_T GetViaType() const { return m_ViaType; }
  363. void SetViaType( VIATYPE_T aViaType ) { m_ViaType = aViaType; }
  364. /**
  365. * Function SetDrill
  366. * sets the drill value for vias.
  367. * @param aDrill is the new drill diameter
  368. */
  369. void SetDrill( int aDrill ) { m_Drill = aDrill; }
  370. /**
  371. * Function GetDrill
  372. * returns the local drill setting for this VIA. If you want the calculated value,
  373. * use GetDrillValue() instead.
  374. */
  375. int GetDrill() const { return m_Drill; }
  376. /**
  377. * Function GetDrillValue
  378. * "calculates" the drill value for vias (m-Drill if > 0, or default
  379. * drill value for the board.
  380. * @return real drill_value
  381. */
  382. int GetDrillValue() const;
  383. /**
  384. * Function SetDrillDefault
  385. * sets the drill value for vias to the default value #UNDEFINED_DRILL_DIAMETER.
  386. */
  387. void SetDrillDefault() { m_Drill = UNDEFINED_DRILL_DIAMETER; }
  388. /**
  389. * Function IsDrillDefault
  390. * @return true if the drill value is default value (-1)
  391. */
  392. bool IsDrillDefault() const { return m_Drill <= 0; }
  393. virtual void SwapData( BOARD_ITEM* aImage ) override;
  394. protected:
  395. void GetMsgPanelInfoBase( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override;
  396. private:
  397. /// The bottom layer of the via (the top layer is in m_Layer)
  398. PCB_LAYER_ID m_BottomLayer;
  399. VIATYPE_T m_ViaType; // Type of via
  400. int m_Drill; // for vias: via drill (- 1 for default value)
  401. };
  402. /// Scan a track list for the first VIA o NULL if not found (or NULL passed)
  403. inline VIA* GetFirstVia( TRACK* aTrk, const TRACK* aStopPoint = NULL )
  404. {
  405. while( aTrk && (aTrk != aStopPoint) && (aTrk->Type() != PCB_VIA_T) )
  406. aTrk = aTrk->Next();
  407. // It could stop because of the stop point, not on a via
  408. if( aTrk && (aTrk->Type() == PCB_VIA_T) )
  409. return static_cast<VIA*>( aTrk );
  410. else
  411. return NULL;
  412. }
  413. /// Scan a track list for the first TRACK object. Returns NULL if not found (or NULL passed)
  414. inline TRACK* GetFirstTrack( TRACK* aTrk, const TRACK* aStopPoint = NULL )
  415. {
  416. while( aTrk && ( aTrk != aStopPoint ) && ( aTrk->Type() != PCB_TRACE_T ) )
  417. aTrk = aTrk->Next();
  418. // It could stop because of the stop point, not on a via
  419. if( aTrk && ( aTrk->Type() == PCB_TRACE_T ) )
  420. return static_cast<TRACK*>( aTrk );
  421. else
  422. return NULL;
  423. }
  424. #endif // CLASS_TRACK_H