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.

505 lines
18 KiB

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