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.

687 lines
26 KiB

14 years ago
14 years ago
14 years ago
11 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
* 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
11 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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 1992-2016 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_module.h
  26. * @brief Module description (excepted pads)
  27. */
  28. #ifndef MODULE_H_
  29. #define MODULE_H_
  30. #include <list>
  31. #include <dlist.h>
  32. #include <layers_id_colors_and_visibility.h> // ALL_LAYERS definition.
  33. #include <class_board_item.h>
  34. #include <board_item_container.h>
  35. #include <lib_id.h>
  36. #include <class_text_mod.h>
  37. #include <PolyLine.h>
  38. #include "zones.h"
  39. #include <3d_cache/3d_info.h>
  40. #include <functional>
  41. class LINE_READER;
  42. class EDA_3D_CANVAS;
  43. class EDA_DRAW_PANEL;
  44. class D_PAD;
  45. class BOARD;
  46. class MSG_PANEL_ITEM;
  47. namespace KIGFX
  48. {
  49. class VIEW;
  50. };
  51. enum INCLUDE_NPTH_T
  52. {
  53. DO_NOT_INCLUDE_NPTH = false,
  54. INCLUDE_NPTH = true
  55. };
  56. /**
  57. * Enum MODULE_ATTR_T
  58. * is the set of attributes allowed within a MODULE, using MODULE::SetAttributes()
  59. * and MODULE::GetAttributes(). These are to be ORed together when calling
  60. * MODULE::SetAttributes()
  61. */
  62. enum MODULE_ATTR_T
  63. {
  64. MOD_DEFAULT = 0, ///< default
  65. MOD_CMS = 1, ///< Set for modules listed in the automatic insertion list
  66. ///< (usually SMD footprints)
  67. MOD_VIRTUAL = 2 ///< Virtual component: when created by copper shapes on
  68. ///< board (Like edge card connectors, mounting hole...)
  69. };
  70. class MODULE : public BOARD_ITEM_CONTAINER
  71. {
  72. public:
  73. MODULE( BOARD* parent );
  74. MODULE( const MODULE& aModule );
  75. ~MODULE();
  76. MODULE& operator=( const MODULE& aOther );
  77. static inline bool ClassOf( const EDA_ITEM* aItem )
  78. {
  79. return PCB_MODULE_T == aItem->Type();
  80. }
  81. MODULE* Next() const { return static_cast<MODULE*>( Pnext ); }
  82. MODULE* Back() const { return static_cast<MODULE*>( Pback ); }
  83. ///> @copydoc BOARD_ITEM_CONTAINER::Add()
  84. void Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode = ADD_INSERT ) override;
  85. ///> @copydoc BOARD_ITEM_CONTAINER::Remove()
  86. void Remove( BOARD_ITEM* aBoardItem ) override;
  87. /**
  88. * Function ClearAllNets
  89. * Clear (i.e. force the ORPHANED dummy net info) the net info which
  90. * depends on a given board for all pads of the footprint.
  91. * This is needed when a footprint is copied between the fp editor and
  92. * the board editor for instance, because net info become fully broken
  93. */
  94. void ClearAllNets();
  95. /**
  96. * Function CalculateBoundingBox
  97. * calculates the bounding box in board coordinates.
  98. */
  99. void CalculateBoundingBox();
  100. /**
  101. * Function GetFootprintRect()
  102. * Returns the area of the module footprint excluding any text.
  103. * @return EDA_RECT - The rectangle containing the footprint.
  104. */
  105. EDA_RECT GetFootprintRect() const;
  106. // Virtual function
  107. const EDA_RECT GetBoundingBox() const override;
  108. DLIST<D_PAD>& Pads() { return m_Pads; }
  109. const DLIST<D_PAD>& Pads() const { return m_Pads; }
  110. DLIST<BOARD_ITEM>& GraphicalItems() { return m_Drawings; }
  111. const DLIST<BOARD_ITEM>& GraphicalItems() const { return m_Drawings; }
  112. std::list<S3D_INFO>& Models() { return m_3D_Drawings; }
  113. const std::list<S3D_INFO>& Models() const { return m_3D_Drawings; }
  114. void SetPosition( const wxPoint& aPos ) override;
  115. const wxPoint& GetPosition() const override { return m_Pos; }
  116. void SetOrientation( double newangle );
  117. void SetOrientationDegrees( double aOrientation ) { SetOrientation( aOrientation*10.0 ); }
  118. double GetOrientation() const { return m_Orient; }
  119. double GetOrientationDegrees() const { return m_Orient/10.0; }
  120. double GetOrientationRadians() const { return m_Orient*M_PI/1800; }
  121. const LIB_ID& GetFPID() const { return m_fpid; }
  122. void SetFPID( const LIB_ID& aFPID ) { m_fpid = aFPID; }
  123. const wxString& GetDescription() const { return m_Doc; }
  124. void SetDescription( const wxString& aDoc ) { m_Doc = aDoc; }
  125. const wxString& GetKeywords() const { return m_KeyWord; }
  126. void SetKeywords( const wxString& aKeywords ) { m_KeyWord = aKeywords; }
  127. const wxString& GetPath() const { return m_Path; }
  128. void SetPath( const wxString& aPath ) { m_Path = aPath; }
  129. int GetLocalSolderMaskMargin() const { return m_LocalSolderMaskMargin; }
  130. void SetLocalSolderMaskMargin( int aMargin ) { m_LocalSolderMaskMargin = aMargin; }
  131. int GetLocalClearance() const { return m_LocalClearance; }
  132. void SetLocalClearance( int aClearance ) { m_LocalClearance = aClearance; }
  133. int GetLocalSolderPasteMargin() const { return m_LocalSolderPasteMargin; }
  134. void SetLocalSolderPasteMargin( int aMargin ) { m_LocalSolderPasteMargin = aMargin; }
  135. double GetLocalSolderPasteMarginRatio() const { return m_LocalSolderPasteMarginRatio; }
  136. void SetLocalSolderPasteMarginRatio( double aRatio ) { m_LocalSolderPasteMarginRatio = aRatio; }
  137. void SetZoneConnection( ZoneConnection aType ) { m_ZoneConnection = aType; }
  138. ZoneConnection GetZoneConnection() const { return m_ZoneConnection; }
  139. void SetThermalWidth( int aWidth ) { m_ThermalWidth = aWidth; }
  140. int GetThermalWidth() const { return m_ThermalWidth; }
  141. void SetThermalGap( int aGap ) { m_ThermalGap = aGap; }
  142. int GetThermalGap() const { return m_ThermalGap; }
  143. int GetAttributes() const { return m_Attributs; }
  144. void SetAttributes( int aAttributes ) { m_Attributs = aAttributes; }
  145. void SetFlag( int aFlag ) { m_arflag = aFlag; }
  146. void IncrementFlag() { m_arflag += 1; }
  147. int GetFlag() const { return m_arflag; }
  148. void Move( const wxPoint& aMoveVector ) override;
  149. void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
  150. void Flip( const wxPoint& aCentre ) override;
  151. /**
  152. * Function MoveAnchorPosition
  153. * Move the reference point of the footprint
  154. * It looks like a move footprint:
  155. * the footprints elements (pads, outlines, edges .. ) are moved
  156. * However:
  157. * - the footprint position is not modified.
  158. * - the relative (local) coordinates of these items are modified
  159. * (a move footprint does not change these local coordinates,
  160. * but changes the footprint position)
  161. */
  162. void MoveAnchorPosition( const wxPoint& aMoveVector );
  163. /**
  164. * function IsFlipped
  165. * @return true if the module is flipped, i.e. on the back side of the board
  166. */
  167. bool IsFlipped() const {return GetLayer() == B_Cu; }
  168. // m_ModuleStatus bits:
  169. #define MODULE_is_LOCKED 0x01 ///< module LOCKED: no autoplace allowed
  170. #define MODULE_is_PLACED 0x02 ///< In autoplace: module automatically placed
  171. #define MODULE_to_PLACE 0x04 ///< In autoplace: module waiting for autoplace
  172. #define MODULE_PADS_LOCKED 0x08 ///< In autoplace: module waiting for autoplace
  173. bool IsLocked() const override
  174. {
  175. return ( m_ModuleStatus & MODULE_is_LOCKED ) != 0;
  176. }
  177. /**
  178. * Function SetLocked
  179. * sets the MODULE_is_LOCKED bit in the m_ModuleStatus
  180. * @param isLocked When true means turn on locked status, else unlock
  181. */
  182. void SetLocked( bool isLocked ) override
  183. {
  184. if( isLocked )
  185. m_ModuleStatus |= MODULE_is_LOCKED;
  186. else
  187. m_ModuleStatus &= ~MODULE_is_LOCKED;
  188. }
  189. bool IsPlaced() const { return (m_ModuleStatus & MODULE_is_PLACED); }
  190. void SetIsPlaced( bool isPlaced )
  191. {
  192. if( isPlaced )
  193. m_ModuleStatus |= MODULE_is_PLACED;
  194. else
  195. m_ModuleStatus &= ~MODULE_is_PLACED;
  196. }
  197. bool NeedsPlaced() const { return (m_ModuleStatus & MODULE_to_PLACE); }
  198. void SetNeedsPlaced( bool needsPlaced )
  199. {
  200. if( needsPlaced )
  201. m_ModuleStatus |= MODULE_to_PLACE;
  202. else
  203. m_ModuleStatus &= ~MODULE_to_PLACE;
  204. }
  205. bool PadsLocked() const { return ( m_ModuleStatus & MODULE_PADS_LOCKED ); }
  206. void SetPadsLocked( bool aPadsLocked )
  207. {
  208. if( aPadsLocked )
  209. m_ModuleStatus |= MODULE_PADS_LOCKED;
  210. else
  211. m_ModuleStatus &= ~MODULE_PADS_LOCKED;
  212. }
  213. void SetLastEditTime( time_t aTime ) { m_LastEditTime = aTime; }
  214. void SetLastEditTime( ) { m_LastEditTime = time( NULL ); }
  215. time_t GetLastEditTime() const { return m_LastEditTime; }
  216. /* drawing functions */
  217. /**
  218. * Function Draw
  219. * draws the footprint to the \a aDC.
  220. * @param aPanel = draw panel, Used to know the clip box
  221. * @param aDC = Current Device Context
  222. * @param aDrawMode = GR_OR, GR_XOR..
  223. * @param aOffset = draw offset (usually wxPoint(0,0)
  224. */
  225. void Draw( EDA_DRAW_PANEL* aPanel,
  226. wxDC* aDC,
  227. GR_DRAWMODE aDrawMode,
  228. const wxPoint& aOffset = ZeroOffset ) override;
  229. /**
  230. * Function DrawOutlinesWhenMoving
  231. * draws in XOR mode the footprint when moving it to the \a aDC.
  232. * To speed up the drawing, only a simplified shape is drawn
  233. * @param aPanel = draw panel, Used to know the clip box
  234. * @param aDC = Current Device Context
  235. * @param aMoveVector = the offset between the curr position and
  236. * the draw position.
  237. */
  238. void DrawOutlinesWhenMoving( EDA_DRAW_PANEL* aPanel,
  239. wxDC* aDC, const wxPoint& aMoveVector );
  240. /**
  241. * function TransformPadsShapesWithClearanceToPolygon
  242. * generate pads shapes on layer aLayer as polygons,
  243. * and adds these polygons to aCornerBuffer
  244. * Useful to generate a polygonal representation of a footprint
  245. * in 3D view and plot functions, when a full polygonal approach is needed
  246. * @param aLayer = the current layer: pads on this layer are considered
  247. * @param aCornerBuffer = the buffer to store polygons
  248. * @param aInflateValue = an additionnal size to add to pad shapes
  249. * aInflateValue = 0 to have the exact pad size
  250. * @param aCircleToSegmentsCount = number of segments to generate a circle
  251. * @param aCorrectionFactor = the correction to apply to a circle radius
  252. * to approximate a circle by the polygon.
  253. * if aCorrectionFactor = 1.0, the polygon is inside the circle
  254. * the radius of circle approximated by segments is
  255. * initial radius * aCorrectionFactor
  256. * @param aSkipNPTHPadsWihNoCopper = if true, do not add a NPTH pad shape,
  257. * if the shape has same size and position as the hole. Usually, these
  258. * pads are not drawn on copper layers, because there is actually no copper
  259. * Due to diff between layers and holes, these pads must be skipped to be sure
  260. * there is no copper left on the board (for instance when creating Gerber Files or 3D shapes)
  261. * default = false
  262. */
  263. void TransformPadsShapesWithClearanceToPolygon( LAYER_ID aLayer,
  264. SHAPE_POLY_SET& aCornerBuffer,
  265. int aInflateValue,
  266. int aCircleToSegmentsCount,
  267. double aCorrectionFactor,
  268. bool aSkipNPTHPadsWihNoCopper = false ) const;
  269. /**
  270. * function TransformGraphicShapesWithClearanceToPolygonSet
  271. * generate shapes of graphic items (outlines) on layer aLayer as polygons,
  272. * and adds these polygons to aCornerBuffer
  273. * Useful to generate a polygonal representation of a footprint
  274. * in 3D view and plot functions, when a full polygonal approach is needed
  275. * @param aLayer = the current layer: items on this layer are considered
  276. * @param aCornerBuffer = the buffer to store polygons
  277. * @param aInflateValue = a value to inflate shapes
  278. * aInflateValue = 0 to have the exact shape size
  279. * @param aCircleToSegmentsCount = number of segments to generate a circle
  280. * @param aCorrectionFactor = the correction to apply to a circle radius
  281. * to approximate a circle by the polygon.
  282. * if aCorrectionFactor = 1.0, the polygon is inside the circle
  283. * the radius of circle approximated by segments is
  284. * initial radius * aCorrectionFactor
  285. * @param aCircleToSegmentsCountForTexts = number of segments to generate
  286. * a circle when building the texts polygonal shapes of the stroke font
  287. * if 0, use the aCircleToSegmentsCount value
  288. */
  289. void TransformGraphicShapesWithClearanceToPolygonSet(
  290. LAYER_ID aLayer,
  291. SHAPE_POLY_SET& aCornerBuffer,
  292. int aInflateValue,
  293. int aCircleToSegmentsCount,
  294. double aCorrectionFactor,
  295. int aCircleToSegmentsCountForTexts = 0 ) const;
  296. /**
  297. * @brief TransformGraphicTextWithClearanceToPolygonSet
  298. * This function is the same as TransformGraphicShapesWithClearanceToPolygonSet
  299. * but only generate text
  300. * @param aLayer
  301. * @param aCornerBuffer
  302. * @param aInflateValue
  303. * @param aCircleToSegmentsCount
  304. * @param aCorrectionFactor
  305. * @param aCircleToSegmentsCountForTexts
  306. */
  307. void TransformGraphicTextWithClearanceToPolygonSet(
  308. LAYER_ID aLayer,
  309. SHAPE_POLY_SET& aCornerBuffer,
  310. int aInflateValue,
  311. int aCircleToSegmentsCount,
  312. double aCorrectionFactor,
  313. int aCircleToSegmentsCountForTexts = 0 ) const;
  314. /**
  315. * Function DrawEdgesOnly
  316. * Draws the footprint edges only to the current Device Context
  317. * @param panel = The active Draw Panel (used to know the clip box)
  318. * @param DC = current Device Context
  319. * @param offset = draw offset (usually wxPoint(0,0)
  320. * @param draw_mode = GR_OR, GR_XOR, GR_AND
  321. */
  322. void DrawEdgesOnly( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
  323. GR_DRAWMODE draw_mode );
  324. /**
  325. * Function DrawAncre
  326. * Draw the anchor cross (vertical)
  327. * Must be done after the pads, because drawing the hole will erase overwrite
  328. * every thing already drawn.
  329. */
  330. void DrawAncre( EDA_DRAW_PANEL* panel, wxDC* DC,
  331. const wxPoint& offset, int dim_ancre, GR_DRAWMODE draw_mode );
  332. ///> @copydoc EDA_ITEM::GetMsgPanelInfo
  333. void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override;
  334. bool HitTest( const wxPoint& aPosition ) const override;
  335. /** @copydoc BOARD_ITEM::HitTest(const EDA_RECT& aRect,
  336. * bool aContained = true, int aAccuracy ) const
  337. */
  338. bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const override;
  339. /**
  340. * Function GetReference
  341. * @return const wxString& - the reference designator text.
  342. */
  343. const wxString& GetReference() const
  344. {
  345. return m_Reference->GetText();
  346. }
  347. /**
  348. * Function SetReference
  349. * @param aReference A reference to a wxString object containing the reference designator
  350. * text.
  351. */
  352. void SetReference( const wxString& aReference )
  353. {
  354. m_Reference->SetText( aReference );
  355. }
  356. /**
  357. * Function GetReference prefix
  358. * Gets the alphabetic prefix of the module reference - e.g.
  359. * R1 -> R
  360. * IC34 -> IC
  361. * @return the reference prefix (may be empty)
  362. */
  363. wxString GetReferencePrefix() const;
  364. /**
  365. * Function GetValue
  366. * @return const wxString& - the value text.
  367. */
  368. const wxString& GetValue() const
  369. {
  370. return m_Value->GetText();
  371. }
  372. /**
  373. * Function SetValue
  374. * @param aValue A reference to a wxString object containing the value text.
  375. */
  376. void SetValue( const wxString& aValue )
  377. {
  378. m_Value->SetText( aValue );
  379. }
  380. /// read/write accessors:
  381. TEXTE_MODULE& Value() { return *m_Value; }
  382. TEXTE_MODULE& Reference() { return *m_Reference; }
  383. /// The const versions to keep the compiler happy.
  384. TEXTE_MODULE& Value() const { return *m_Value; }
  385. TEXTE_MODULE& Reference() const { return *m_Reference; }
  386. /**
  387. * Function FindPadByName
  388. * returns a D_PAD* with a matching name. Note that names may not be
  389. * unique, depending on how the foot print was created.
  390. * @param aPadName the pad name to find
  391. * @return D_PAD* - The first matching name is returned, or NULL if not
  392. * found.
  393. */
  394. D_PAD* FindPadByName( const wxString& aPadName ) const;
  395. /**
  396. * Function GetPad
  397. * get a pad at \a aPosition on \a aLayerMask in the footprint.
  398. *
  399. * @param aPosition A wxPoint object containing the position to hit test.
  400. * @param aLayerMask A layer or layers to mask the hit test.
  401. * @return A pointer to a D_PAD object if found otherwise NULL.
  402. */
  403. D_PAD* GetPad( const wxPoint& aPosition, LSET aLayerMask = LSET::AllLayersMask() );
  404. /**
  405. * GetPadCount
  406. * returns the number of pads.
  407. *
  408. * @param aIncludeNPTH includes non-plated through holes when true. Does not include
  409. * non-plated through holes when false.
  410. * @return the number of pads according to \a aIncludeNPTH.
  411. */
  412. unsigned GetPadCount( INCLUDE_NPTH_T aIncludeNPTH = INCLUDE_NPTH_T( INCLUDE_NPTH ) ) const;
  413. /**
  414. * GetUniquePadCount
  415. * returns the number of unique pads.
  416. * A complex pad can be built with many pads having the same pad name
  417. * to create a complex shape or fragmented solder paste areas.
  418. *
  419. * GetUniquePadCount calculate the count of not blank pad names
  420. *
  421. * @param aIncludeNPTH includes non-plated through holes when true. Does not include
  422. * non-plated through holes when false.
  423. * @return the number of unique pads according to \a aIncludeNPTH.
  424. */
  425. unsigned GetUniquePadCount( INCLUDE_NPTH_T aIncludeNPTH = INCLUDE_NPTH_T( INCLUDE_NPTH ) ) const;
  426. /**
  427. * Function GetNextPadName
  428. * returns the next available pad name in the module
  429. *
  430. * @param aFillSequenceGaps true if the numbering should "fill in" gaps in
  431. * the sequence, else return the highest value + 1
  432. * @return the next available pad name
  433. */
  434. wxString GetNextPadName( bool aFillSequenceGaps ) const;
  435. double GetArea() const { return m_Surface; }
  436. time_t GetLink() const { return m_Link; }
  437. void SetLink( time_t aLink ) { m_Link = aLink; }
  438. int GetPlacementCost180() const { return m_CntRot180; }
  439. void SetPlacementCost180( int aCost ) { m_CntRot180 = aCost; }
  440. int GetPlacementCost90() const { return m_CntRot90; }
  441. void SetPlacementCost90( int aCost ) { m_CntRot90 = aCost; }
  442. /**
  443. * Function Duplicate
  444. * Duplicate a given item within the module, without adding to the board
  445. * @return the new item, or NULL if the item could not be duplicated
  446. */
  447. BOARD_ITEM* Duplicate( const BOARD_ITEM* aItem,
  448. bool aIncrementPadNumbers,
  449. bool aAddToModule = false );
  450. /**
  451. * Function Add3DModel
  452. * adds \a a3DModel definition to the end of the 3D model list.
  453. *
  454. * @param a3DModel A pointer to a #S3D_INFO to add to the list.
  455. */
  456. void Add3DModel( S3D_INFO* a3DModel );
  457. SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
  458. wxString GetClass() const override
  459. {
  460. return wxT( "MODULE" );
  461. }
  462. wxString GetSelectMenuText() const override;
  463. BITMAP_DEF GetMenuImage() const override;
  464. EDA_ITEM* Clone() const override;
  465. /**
  466. * Function RunOnChildren
  467. *
  468. * Invokes a function on all BOARD_ITEMs that belong to the module (pads, drawings, texts).
  469. * @param aFunction is the function to be invoked.
  470. */
  471. void RunOnChildren( std::function<void (BOARD_ITEM*)> aFunction );
  472. /// @copydoc VIEW_ITEM::ViewGetLayers()
  473. virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
  474. /// @copydoc VIEW_ITEM::ViewGetLOD()
  475. virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
  476. /// @copydoc VIEW_ITEM::ViewBBox()
  477. virtual const BOX2I ViewBBox() const override;
  478. /**
  479. * Function CopyNetlistSettings
  480. * copies the netlist settings to \a aModule.
  481. * Used to copy some footprint parameters when replacing a footprint by an other
  482. * footprint when reading a netlist, or in exchange footprint dialog
  483. *
  484. * The netlist settings are all of the #MODULE settings not define by a #MODULE in
  485. * a netlist. These setting include placement prms (position, orientation, side)
  486. * and optionally local prms( clearances, zone connection type, etc).
  487. * The reference designator, value, path, and physical geometry settings are not
  488. * copied.
  489. *
  490. * @param aModule is the #MODULE to copy the settings to.
  491. * @param aCopyLocalSettings = false to copy only module placement
  492. * true to also copy local prms
  493. */
  494. void CopyNetlistSettings( MODULE* aModule, bool aCopyLocalSettings );
  495. /**
  496. * static function IsLibNameValid
  497. * Test for validity of a name of a footprint to be used in a footprint library
  498. * ( no spaces, dir separators ... )
  499. * @param aName = the name in library to validate
  500. * @return true if the given name is valid
  501. */
  502. static bool IsLibNameValid( const wxString & aName );
  503. /**
  504. * static function StringLibNameInvalidChars
  505. * Test for validity of the name in a library of the footprint
  506. * ( no spaces, dir separators ... )
  507. * @param aUserReadable = false to get the list of invalid chars
  508. * true to get a readable form (i.e ' ' = 'space' '\\t'= 'tab')
  509. * @return a constant std::string giving the list of invalid chars in lib name
  510. */
  511. static const wxChar* StringLibNameInvalidChars( bool aUserReadable );
  512. /**
  513. * Function SetInitialComments
  514. * takes ownership of caller's heap allocated aInitialComments block. The comments
  515. * are single line strings already containing the s-expression comments with
  516. * optional leading whitespace and then a '#' character followed by optional
  517. * single line text (text with no line endings, not even one).
  518. * This block of single line comments will be output upfront of any generated
  519. * s-expression text in the PCBIO::Format() function.
  520. * <p>
  521. * Note that a block of single line comments constitutes a multiline block of
  522. * single line comments. That is, the block is made of consecutive single line
  523. * comments.
  524. * @param aInitialComments is a heap allocated wxArrayString or NULL, which the caller
  525. * gives up ownership of over to this MODULE.
  526. */
  527. void SetInitialComments( wxArrayString* aInitialComments )
  528. {
  529. delete m_initial_comments;
  530. m_initial_comments = aInitialComments;
  531. }
  532. /**
  533. * Function PadCoverageRatio
  534. * Calculates the ratio of total area of the footprint pads to the area of the
  535. * footprint. Used by selection tool heuristics.
  536. * @return the ratio
  537. */
  538. double PadCoverageRatio() const;
  539. /// Return the initial comments block or NULL if none, without transfer of ownership.
  540. const wxArrayString* GetInitialComments() const { return m_initial_comments; }
  541. #if defined(DEBUG)
  542. virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
  543. #endif
  544. private:
  545. DLIST<D_PAD> m_Pads; ///< Linked list of pads.
  546. DLIST<BOARD_ITEM> m_Drawings; ///< Linked list of graphical items.
  547. std::list<S3D_INFO> m_3D_Drawings; ///< Linked list of 3D models.
  548. double m_Orient; ///< Orientation in tenths of a degree, 900=90.0 degrees.
  549. wxPoint m_Pos; ///< Position of module on the board in internal units.
  550. TEXTE_MODULE* m_Reference; ///< Component reference designator value (U34, R18..)
  551. TEXTE_MODULE* m_Value; ///< Component value (74LS00, 22K..)
  552. LIB_ID m_fpid; ///< The #LIB_ID of the MODULE.
  553. int m_Attributs; ///< Flag bits ( see Mod_Attribut )
  554. int m_ModuleStatus; ///< For autoplace: flags (LOCKED, AUTOPLACED)
  555. EDA_RECT m_BoundaryBox; ///< Bounding box : coordinates on board, real orientation.
  556. // The final margin is the sum of these 2 values
  557. int m_ThermalWidth;
  558. int m_ThermalGap;
  559. wxString m_Doc; ///< File name and path for documentation file.
  560. wxString m_KeyWord; ///< Search keywords to find module in library.
  561. wxString m_Path;
  562. ZoneConnection m_ZoneConnection;
  563. time_t m_LastEditTime;
  564. int m_arflag; ///< Use to trace ratsnest and auto routing.
  565. double m_Surface; ///< Bounding box area
  566. time_t m_Link; ///< Temporary logical link used in edition
  567. int m_CntRot90; ///< Horizontal automatic placement cost ( 0..10 ).
  568. int m_CntRot180; ///< Vertical automatic placement cost ( 0..10 ).
  569. // Local tolerances. When zero, this means the corresponding netclass value
  570. // is used. Usually theses local tolerances zero, in deference to the
  571. // corresponding netclass values.
  572. int m_LocalClearance;
  573. int m_LocalSolderMaskMargin; ///< Solder mask margin
  574. int m_LocalSolderPasteMargin; ///< Solder paste margin absolute value
  575. double m_LocalSolderPasteMarginRatio; ///< Solder mask margin ratio
  576. ///< value of pad size
  577. wxArrayString* m_initial_comments; ///< leading s-expression comments in the module,
  578. ///< lazily allocated only if needed for speed
  579. };
  580. #endif // MODULE_H_