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.

501 lines
19 KiB

19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
18 years ago
18 years ago
19 years ago
19 years ago
19 years ago
19 years ago
18 years ago
19 years ago
18 years ago
19 years ago
18 years ago
19 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
19 years ago
19 years ago
18 years ago
18 years ago
18 years ago
18 years ago
19 years ago
19 years ago
19 years ago
19 years ago
18 years ago
19 years ago
19 years ago
18 years ago
19 years ago
19 years ago
19 years ago
19 years ago
18 years ago
19 years ago
19 years ago
19 years ago
18 years ago
19 years ago
19 years ago
19 years ago
19 years ago
18 years ago
  1. /**************************************************************/
  2. /* pcbstruct.h : definition des structures de donnees type PCB */
  3. /**************************************************************/
  4. #ifndef PCBSTRUCT_H
  5. #define PCBSTRUCT_H
  6. #include "base_struct.h"
  7. // Definitions relatives aux libariries
  8. #define ENTETE_LIBRAIRIE "PCBNEW-LibModule-V1"
  9. #define ENTETE_LIBDOC "PCBNEW-LibDoc----V1"
  10. #define L_ENTETE_LIB 18
  11. #define EXT_CMP wxT( ".emp" )
  12. #define EXT_CMP_MASK wxT( "*.emp" )
  13. #define EXT_DOC wxT( ".mdc" )
  14. /* Bits indicateurs du membre .Status, pour pistes, modules... */
  15. #define FLAG1 0x2000 /* flag libre pour calculs locaux */
  16. #define FLAG0 0x1000 /* flag libre pour calculs locaux */
  17. #define BEGIN_ONPAD 0x800 /* flag indiquant un debut de segment sur pad */
  18. #define END_ONPAD 0x400 /* flag indiquant une fin de segment sur pad */
  19. #define BUSY 0x0200 /* flag indiquant que la structure a deja
  20. * ete examinee, dans certaines routines */
  21. #define DELETED 0x0100 /* Bit flag de Status pour structures effacee
  22. * et mises en chaine "DELETED" */
  23. #define NO_TRACE 0x80 /* l'element ne doit pas etre affiche */
  24. #define SURBRILL 0x20 /* element en surbrillance */
  25. #define DRAG 0x10 /* segment en mode drag */
  26. #define EDIT 0x8 /* element en cours d'edition */
  27. #define SEGM_FIXE 0x04 /* segment FIXE ( pas d'effacement global ) */
  28. #define SEGM_AR 0x02 /* segment Auto_Route */
  29. #define CHAIN 0x01 /* segment marque */
  30. /* Flags pour les couches cuivres */
  31. /* numero des couches particulieres */
  32. #define LAYER_CUIVRE_N 0
  33. #define CUIVRE_N 0
  34. #define LAYER_N_2 1 /* Numero layer 2 */
  35. #define LAYER_N_3 2 /* Numero layer 3 */
  36. #define LAYER_N_4 3 /* Numero layer 4 */
  37. #define LAYER_N_5 4 /* Numero layer 5 */
  38. #define LAYER_N_6 5 /* Numero layer 6 */
  39. #define LAYER_N_7 6 /* Numero layer 7 */
  40. #define LAYER_N_8 7 /* Numero layer 8 */
  41. #define LAYER_N_9 8 /* Numero layer 9 */
  42. #define LAYER_N_10 9 /* Numero layer 10 */
  43. #define LAYER_N_11 10 /* Numero layer 11 */
  44. #define LAYER_N_12 11 /* Numero layer 12 */
  45. #define LAYER_N_13 12 /* Numero layer 13 */
  46. #define LAYER_N_14 13 /* Numero layer 14 */
  47. #define LAYER_N_15 14 /* Numero layer 15 */
  48. #define LAYER_CMP_N 15
  49. #define CMP_N 15
  50. #define NB_COPPER_LAYERS (CMP_N + 1)
  51. #define FIRST_NO_COPPER_LAYER 16
  52. #define ADHESIVE_N_CU 16
  53. #define ADHESIVE_N_CMP 17
  54. #define SOLDERPASTE_N_CU 18
  55. #define SOLDERPASTE_N_CMP 19
  56. #define SILKSCREEN_N_CU 20
  57. #define SILKSCREEN_N_CMP 21
  58. #define SOLDERMASK_N_CU 22
  59. #define SOLDERMASK_N_CMP 23
  60. #define DRAW_N 24
  61. #define COMMENT_N 25
  62. #define ECO1_N 26
  63. #define ECO2_N 27
  64. #define EDGE_N 28
  65. #define LAST_NO_COPPER_LAYER 28
  66. #define NB_LAYERS (EDGE_N + 1)
  67. #define LAYER_COUNT 32
  68. /*************************************/
  69. /* constantes de gestion des couches */
  70. /*************************************/
  71. #define CUIVRE_LAYER (1<<LAYER_CUIVRE_N) ///< bit mask for copper layer
  72. #define LAYER_2 (1<<LAYER_N_2) ///< bit mask for layer 2
  73. #define LAYER_3 (1<<LAYER_N_3) ///< bit mask for layer 3
  74. #define LAYER_4 (1<<LAYER_N_4) ///< bit mask for layer 4
  75. #define LAYER_5 (1<<LAYER_N_5) ///< bit mask for layer 5
  76. #define LAYER_6 (1<<LAYER_N_6) ///< bit mask for layer 6
  77. #define LAYER_7 (1<<LAYER_N_7) ///< bit mask for layer 7
  78. #define LAYER_8 (1<<LAYER_N_8) ///< bit mask for layer 8
  79. #define LAYER_9 (1<<LAYER_N_9) ///< bit mask for layer 9
  80. #define LAYER_10 (1<<LAYER_N_10) ///< bit mask for layer 10
  81. #define LAYER_11 (1<<LAYER_N_11) ///< bit mask for layer 11
  82. #define LAYER_12 (1<<LAYER_N_12) ///< bit mask for layer 12
  83. #define LAYER_13 (1<<LAYER_N_13) ///< bit mask for layer 13
  84. #define LAYER_14 (1<<LAYER_N_14) ///< bit mask for layer 14
  85. #define LAYER_15 (1<<LAYER_N_15) ///< bit mask for layer 15
  86. #define CMP_LAYER (1<<LAYER_CMP_N) ///< bit mask for component layer
  87. #define ADHESIVE_LAYER_CU (1<<ADHESIVE_N_CU)
  88. #define ADHESIVE_LAYER_CMP (1<<ADHESIVE_N_CMP)
  89. #define SOLDERPASTE_LAYER_CU (1<<SOLDERPASTE_N_CU)
  90. #define SOLDERPASTE_LAYER_CMP (1<<SOLDERPASTE_N_CMP)
  91. #define SILKSCREEN_LAYER_CU (1<<SILKSCREEN_N_CU)
  92. #define SILKSCREEN_LAYER_CMP (1<<SILKSCREEN_N_CMP)
  93. #define SOLDERMASK_LAYER_CU (1<<SOLDERMASK_N_CU)
  94. #define SOLDERMASK_LAYER_CMP (1<<SOLDERMASK_N_CMP)
  95. #define DRAW_LAYER (1<<DRAW_N)
  96. #define COMMENT_LAYER (1<<COMMENT_N)
  97. #define ECO1_LAYER (1<<ECO1_N)
  98. #define ECO2_LAYER (1<<ECO2_N)
  99. #define EDGE_LAYER (1<<EDGE_N)
  100. // extra bits 0xE0000000
  101. /* masques generaux : */
  102. #define ALL_LAYERS 0x1FFFFFFF
  103. #define ALL_NO_CU_LAYERS 0x1FFF0000
  104. #define ALL_CU_LAYERS 0x0000FFFF
  105. #define INTERNAL_LAYERS 0x00007FFE /* Bits layers internes */
  106. #define EXTERNAL_LAYERS 0x00008001
  107. /* Forme des segments (pistes, contours ..) ( parametre .shape ) */
  108. enum Track_Shapes {
  109. S_SEGMENT = 0, /* segment rectiligne */
  110. S_RECT, /* segment forme rect (i.e. bouts non arrondis) */
  111. S_ARC, /* segment en arc de cercle (bouts arrondis)*/
  112. S_CIRCLE, /* segment en cercle (anneau)*/
  113. S_ARC_RECT, /* segment en arc de cercle (bouts droits) (GERBER)*/
  114. S_SPOT_OVALE, /* spot ovale (for GERBER)*/
  115. S_SPOT_CIRCLE, /* spot rond (for GERBER)*/
  116. S_SPOT_RECT, /* spot rect (for GERBER)*/
  117. S_POLYGON /* polygon shape */
  118. };
  119. /* Forward declaration */
  120. class MODULE;
  121. class EQUIPOT;
  122. class MARQUEUR;
  123. class TRACK;
  124. class D_PAD;
  125. struct CHEVELU;
  126. class Ki_PageDescr;
  127. class DrawBlockStruct;
  128. // Class for handle current printed board design settings
  129. #define HIST0RY_NUMBER 8
  130. class EDA_BoardDesignSettings
  131. {
  132. public:
  133. int m_CopperLayerCount; // Number of copper layers for this design
  134. int m_ViaDrill; // via drill (for the entire board)
  135. int m_CurrentViaSize; // Current via size
  136. int m_ViaSizeHistory[HIST0RY_NUMBER]; // Last HIST0RY_NUMBER used via sizes
  137. int m_CurrentViaType; // via type (BLIND, TROUGHT ...), bits 1 and 2 (not 0 and 1)
  138. int m_CurrentTrackWidth; // current track width
  139. int m_TrackWidhtHistory[HIST0RY_NUMBER]; // Last HIST0RY_NUMBER used track widths
  140. int m_DrawSegmentWidth; // current graphic line width (not EDGE layer)
  141. int m_EdgeSegmentWidth; // current graphic line width (EDGE layer only)
  142. int m_PcbTextWidth; // current Pcb (not module) Text width
  143. wxSize m_PcbTextSize; // current Pcb (not module) Text size
  144. int m_TrackClearence; // track to track and track to pads clearance
  145. int m_ZoneClearence; // zone to track and zone to pads clearance
  146. int m_MaskMargin; // Solder mask margin
  147. // Color options for screen display of the Printed Board:
  148. int m_PcbGridColor; // Grid color
  149. int m_LayerColor[32]; // Layer colors (tracks and graphic items)
  150. int m_ViaColor[4]; // Via color (depending on is type)
  151. int m_ModuleTextCMPColor; // Text module color for modules on the COMPONENT layer
  152. int m_ModuleTextCUColor; // Text module color for modules on the COPPER layer
  153. int m_ModuleTextNOVColor; // Text module color for "invisible" texts (must be BLACK if really not displayed)
  154. int m_AnchorColor; // Anchor color for modules and texts
  155. int m_PadCUColor; // Pad color for the COPPER side of the pad
  156. int m_PadCMPColor; // Pad color for the COMPONENT side of the pad
  157. // Pad color for the pads of both sides is m_PadCUColor OR m_PadCMPColor (in terms of colors)
  158. int m_RatsnestColor; // Ratsnest color
  159. public:
  160. EDA_BoardDesignSettings();
  161. /**
  162. * Function GetVisibleLayers
  163. * returns a bit-map of all the layers that are visible.
  164. * @return int - the visible layers in bit-mapped form.
  165. */
  166. int GetVisibleLayers() const;
  167. };
  168. // Values for m_DisplayViaMode member:
  169. enum DisplayViaMode {
  170. VIA_HOLE_NOT_SHOW = 0,
  171. VIA_SPECIAL_HOLE_SHOW,
  172. ALL_VIA_HOLE_SHOW,
  173. OPT_VIA_HOLE_END
  174. };
  175. class BOARD : public BOARD_ITEM
  176. {
  177. public:
  178. WinEDA_BasePcbFrame* m_PcbFrame; // Window de visualisation
  179. EDA_Rect m_BoundaryBox; // Limites d'encadrement du PCB
  180. int m_Unused;
  181. int m_Status_Pcb; // Mot d'etat: Bit 1 = Chevelu calcule
  182. EDA_BoardDesignSettings* m_BoardSettings; // Link to current design settings
  183. int m_NbNets; // Nombre de nets (equipotentielles)
  184. int m_NbNodes; // nombre de pads connectes
  185. int m_NbLinks; // nombre de chevelus
  186. int m_NbLoclinks; // nombre de chevelus dans Local ratsnest
  187. // minimal de pistes a tracer
  188. int m_NbNoconnect; // nombre de chevelus actifs
  189. int m_NbSegmTrack; // nombre d'elements de type segments de piste
  190. int m_NbSegmZone; // nombre d'elements de type segments de zone
  191. BOARD_ITEM* m_Drawings; // linked list of lines & texts
  192. MODULE* m_Modules; // linked list of MODULEs
  193. EQUIPOT* m_Equipots; // linked list of nets
  194. TRACK* m_Track; // linked list of TRACKs and SEGVIAs
  195. SEGZONE* m_Zone; // linked list of SEGZONEs
  196. D_PAD** m_Pads; // pointeur liste d'acces aux pads
  197. int m_NbPads; // nombre total de pads
  198. CHEVELU* m_Ratsnest; // pointeur liste des chevelus
  199. CHEVELU* m_LocalRatsnest; // pointeur liste des chevelus d'un module
  200. EDGE_ZONE* m_CurrentLimitZone; /* pointeur sur la liste des segments
  201. * de delimitation de la zone en cours de trace */
  202. BOARD( EDA_BaseStruct* StructFather, WinEDA_BasePcbFrame* frame );
  203. ~BOARD();
  204. /* supprime du chainage la structure Struct */
  205. void UnLink();
  206. /* Routines de calcul des nombres de segments pistes et zones */
  207. int GetNumSegmTrack();
  208. int GetNumSegmZone();
  209. int GetNumNoconnect(); // retourne le nombre de connexions manquantes
  210. int GetNumRatsnests(); // retourne le nombre de chevelus
  211. int GetNumNodes(); // retourne le nombre de pads a netcode > 0
  212. // Calcul du rectangle d'encadrement:
  213. bool ComputeBoundaryBox();
  214. /**
  215. * Function Display_Infos
  216. * has knowledge about the frame and how and where to put status information
  217. * about this object into the frame's message panel.
  218. * Is virtual from EDA_BaseStruct.
  219. * @param frame A WinEDA_DrawFrame in which to print status information.
  220. */
  221. void Display_Infos( WinEDA_DrawFrame* frame );
  222. /**
  223. * Function Visit
  224. * may be re-implemented for each derived class in order to handle
  225. * all the types given by its member data. Implementations should call
  226. * inspector->Inspect() on types in scanTypes[], and may use IterateForward()
  227. * to do so on lists of such data.
  228. * @param inspector An INSPECTOR instance to use in the inspection.
  229. * @param testData Arbitrary data used by the inspector.
  230. * @param scanTypes Which KICAD_T types are of interest and the order
  231. * is significant too, terminated by EOT.
  232. * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
  233. * else SCAN_CONTINUE, and determined by the inspector.
  234. */
  235. SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData,
  236. const KICAD_T scanTypes[] );
  237. /**
  238. * Function FindPadOrModule
  239. * searches for either a pad or module, giving precedence to pads.
  240. * Any Pad or Module on the desired layer that HitTest()s true will be
  241. * returned, otherwise any visible Pad or Module on any other layer.
  242. * The provided layer must be visible.
  243. * @param refPos The wxPoint to hit-test.
  244. * @return BOARD_ITEM* - if a direct hit, else NULL.
  245. */
  246. // BOARD_ITEM* FindPadOrModule( const wxPoint& refPos, int layer );
  247. /**
  248. * Function FindNet
  249. * searches for a net with the given netcode.
  250. * @param aNetcode A netcode to search for.
  251. * @return EQUIPOT* - the net or NULL if not found.
  252. */
  253. EQUIPOT* FindNet( int aNetcode ) const;
  254. /**
  255. * Function GetClass
  256. * returns the class name.
  257. * @return wxString
  258. */
  259. wxString GetClass() const
  260. {
  261. return wxT( "BOARD" );
  262. }
  263. #if defined(DEBUG)
  264. /**
  265. * Function Show
  266. * is used to output the object tree, currently for debugging only.
  267. * @param nestLevel An aid to prettier tree indenting, and is the level
  268. * of nesting of this object within the overall tree.
  269. * @param os The ostream& to output to.
  270. */
  271. void Show( int nestLevel, std::ostream& os );
  272. #endif
  273. };
  274. /* Description d'un ecran */
  275. class PCB_SCREEN : public BASE_SCREEN
  276. {
  277. public:
  278. int m_Active_Layer; /* ref couche active */
  279. int m_Route_Layer_TOP; /* ref couches actives */
  280. int m_Route_Layer_BOTTOM; /* pour placement vias et routage 2 couches */
  281. public:
  282. PCB_SCREEN( int idscreen );
  283. ~PCB_SCREEN();
  284. PCB_SCREEN* Next() { return (PCB_SCREEN*) Pnext; }
  285. void Init();
  286. void SetNextZoom();
  287. void SetPreviousZoom();
  288. void SetLastZoom();
  289. /**
  290. * Function GetCurItem
  291. * returns the currently selected BOARD_ITEM, overriding BASE_SCREEN::GetCurItem().
  292. * @return BOARD_ITEM* - the one selected, or NULL.
  293. */
  294. BOARD_ITEM* GetCurItem() const { return (BOARD_ITEM*) BASE_SCREEN::GetCurItem(); }
  295. };
  296. /***************************/
  297. /* Description des Modules */
  298. /***************************/
  299. #include "class_pad.h" /* Description des Pastilles :*/
  300. #include "class_edge_mod.h"
  301. #include "class_text_mod.h"
  302. #include "class_module.h"
  303. #include "class_equipot.h"
  304. /***********************************/
  305. /* Description des elements du PCB */
  306. /***********************************/
  307. class DRAWSEGMENT : public BOARD_ITEM
  308. {
  309. public:
  310. int m_Width; // 0 = line, > 0 = tracks, bus ...
  311. wxPoint m_Start; // Line start point
  312. wxPoint m_End; // Line end point
  313. int m_Shape; // forme: Segment , Cercle..
  314. int m_Type; // numero de sous type ( cotation.. )
  315. int m_Angle; // pour les arcs: "longueur" de l'arc en 1/10 deg
  316. public:
  317. DRAWSEGMENT( BOARD_ITEM* StructFather, KICAD_T idtype = TYPEDRAWSEGMENT );
  318. ~DRAWSEGMENT();
  319. // Read/write data
  320. bool WriteDrawSegmentDescr( FILE* File );
  321. bool ReadDrawSegmentDescr( FILE* File, int* LineNum );
  322. /* supprime du chainage la structure Struct */
  323. void UnLink();
  324. void Copy( DRAWSEGMENT* source );
  325. /**
  326. * Function Display_Infos
  327. * has knowledge about the frame and how and where to put status information
  328. * about this object into the frame's message panel.
  329. * Is virtual from EDA_BaseStruct.
  330. * @param frame A WinEDA_BasePcbFrame in which to print status information.
  331. */
  332. void Display_Infos( WinEDA_DrawFrame* frame );
  333. /**
  334. * Function HitTest
  335. * tests if the given wxPoint is within the bounds of this object.
  336. * @param ref_pos A wxPoint to test
  337. * @return bool - true if a hit, else false
  338. */
  339. bool HitTest( const wxPoint& ref_pos );
  340. /**
  341. * Function GetClass
  342. * returns the class name.
  343. * @return wxString
  344. */
  345. wxString GetClass() const
  346. {
  347. return wxT("DRAWSEGMENT");
  348. }
  349. };
  350. #include "class_pcb_text.h"
  351. #include "class_cotation.h"
  352. #include "class_mire.h"
  353. #include "class_track.h"
  354. /*******************/
  355. /* class EDGE_ZONE */
  356. /*******************/
  357. class EDGE_ZONE : public DRAWSEGMENT
  358. {
  359. public:
  360. EDGE_ZONE( BOARD_ITEM* StructFather );
  361. EDGE_ZONE( const EDGE_ZONE& edgezone );
  362. ~EDGE_ZONE();
  363. };
  364. /************************************/
  365. /* Gestion des marqueurs sur le PCB */
  366. /************************************/
  367. class MARQUEUR : public BOARD_ITEM
  368. {
  369. /* Description d'un marqueur */
  370. public:
  371. wxPoint m_Pos;
  372. char* m_Bitmap; /* Shape (bitmap) */
  373. int m_Type;
  374. int m_Color; /* couleur */
  375. wxString m_Diag; /* Associated text (comment) */
  376. public:
  377. MARQUEUR( BOARD_ITEM* StructFather );
  378. ~MARQUEUR();
  379. void UnLink();
  380. void Draw( WinEDA_DrawPanel* panel, wxDC* DC, int DrawMode );
  381. /**
  382. * Function Display_Infos
  383. * has knowledge about the frame and how and where to put status information
  384. * about this object into the frame's message panel.
  385. * @param frame A WinEDA_DrawFrame in which to print status information.
  386. */
  387. void Display_Infos( WinEDA_DrawFrame* frame );
  388. /**
  389. * Function HitTest
  390. * tests if the given wxPoint is within the bounds of this object.
  391. * @param ref_pos A wxPoint to test
  392. * @return bool - true if a hit, else false
  393. */
  394. bool HitTest( const wxPoint& ref_pos );
  395. };
  396. class DISPLAY_OPTIONS
  397. {
  398. public:
  399. bool DisplayPadFill;
  400. bool DisplayPadNum;
  401. bool DisplayPadNoConn;
  402. bool DisplayPadIsol;
  403. int DisplayModEdge;
  404. int DisplayModText;
  405. bool DisplayPcbTrackFill; /* FALSE = sketch , TRUE = filled */
  406. bool DisplayTrackIsol;
  407. int m_DisplayViaMode; /* 0 do not show via hole,
  408. * 1 show via hole for non default value
  409. * 2 show all via hole */
  410. bool DisplayPolarCood;
  411. bool DisplayZones;
  412. bool Show_Modules_Cmp;
  413. bool Show_Modules_Cu;
  414. int DisplayDrawItems;
  415. bool ContrastModeDisplay;
  416. public:
  417. DISPLAY_OPTIONS();
  418. };
  419. #endif /* PCBSTRUCT_H */