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.

908 lines
23 KiB

15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
14 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) 2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  5. * Copyright (C) 2010 KiCad Developers, see change_log.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. #ifndef SCH_PART_H_
  25. #define SCH_PART_H_
  26. #include <sch_lib.h>
  27. #include <sch_lib_table.h>
  28. #include <sch_lpid.h>
  29. //#include <boost/ptr_container/ptr_vector.hpp>
  30. #include <boost/ptr_container/ptr_map.hpp>
  31. #define INTERNAL_PER_LOGICAL 10000 ///< no. internal units per logical unit
  32. /**
  33. * Function InternalToLogical
  34. * converts an internal coordinate to a logical coordinate. Logical coordinates
  35. * are defined as the standard distance between pins being equal to one.
  36. * Internal coordinates are currently INTERNAL_PER_LOGICAL times that.
  37. */
  38. static inline double InternalToLogical( int aCoord )
  39. {
  40. return double( aCoord ) / INTERNAL_PER_LOGICAL;
  41. }
  42. /**
  43. * Function LogicalToInternal
  44. * converts a logical coordinate to an internal coordinate. Logical coordinates
  45. * are defined as the standard distance between pins being equal to one.
  46. * Internal coordinates are currently INTERNAL_PER_LOGICAL times that.
  47. */
  48. static inline int LogicalToInternal( double aCoord )
  49. {
  50. return int( aCoord * INTERNAL_PER_LOGICAL );
  51. }
  52. static inline int WidthToInternal( double aWidth )
  53. {
  54. // sweet line widths are a "percent of a logical unit"
  55. return LogicalToInternal( aWidth ) / 100;
  56. }
  57. static inline double InternalToWidth( int aWidth )
  58. {
  59. // sweet line widths are a "percent of a logical unit"
  60. return InternalToLogical( aWidth ) * 100;
  61. }
  62. static inline int FontzToInternal( double aFontSize )
  63. {
  64. // sweet font sizes are deci-pins
  65. return LogicalToInternal( aFontSize ) / 10;
  66. }
  67. static inline double InternalToFontz( int aFontSize )
  68. {
  69. // sweet font sizes are deci-pins
  70. return InternalToLogical( aFontSize ) * 10;
  71. }
  72. //-----<temporary home for PART sub objects, move after stable>------------------
  73. #include <wx/gdicmn.h>
  74. #include <deque>
  75. #include <vector>
  76. #include <set>
  77. #include <sweet_lexer.h>
  78. class OUTPUTFORMATTER;
  79. /// Control Bits for Format() functions
  80. #define CTL_OMIT_NL (1<<0) ///< omit new line in Format()s.
  81. namespace SCH {
  82. class PART;
  83. class SWEET_PARSER;
  84. class PROPERTY;
  85. class POINT : public wxPoint
  86. {
  87. public:
  88. POINT( int x, int y ) :
  89. wxPoint( x, y )
  90. {}
  91. POINT( const POINT& r ) :
  92. wxPoint( r )
  93. {}
  94. POINT() :
  95. wxPoint()
  96. {}
  97. // assume assignment operator is inherited.
  98. };
  99. };
  100. /// a set of pin padnames that are electrically equivalent for a PART.
  101. typedef std::set< wxString > MERGE_SET;
  102. /// The key is the VISIBLE_PIN from
  103. /// (pin_merge VISIBLE_PIN (hide HIDDEN_PIN1 HIDDEN_PIN2...))
  104. typedef boost::ptr_map< wxString, MERGE_SET > MERGE_SETS;
  105. /**
  106. * Class FONTZ
  107. * is the size of a font, and comes with a constructor which initializes
  108. * height and width to special values which defer font size decision to
  109. * a higher control.
  110. */
  111. class FONTZ
  112. {
  113. public:
  114. #define FONTZ_DEFAULT -1 ///< when size defers to higher control
  115. FONTZ() :
  116. height( FONTZ_DEFAULT ),
  117. width( FONTZ_DEFAULT )
  118. {}
  119. int height;
  120. int width;
  121. };
  122. typedef float ANGLE;
  123. typedef int STROKE; ///< will be a class someday, currently only line width
  124. namespace SCH {
  125. class FONT
  126. {
  127. friend class PART;
  128. friend class SWEET_PARSER;
  129. protected:
  130. wxString name; ///< name or other id such as number, TBD
  131. FONTZ size;
  132. bool italic;
  133. bool bold;
  134. public:
  135. FONT() :
  136. italic( false ),
  137. bold( false )
  138. {}
  139. void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
  140. throw( IO_ERROR );
  141. // trust compiler to write its own assignment operator for this class OK.
  142. };
  143. struct TEXT_EFFECTS
  144. {
  145. POINT pos;
  146. ANGLE angle;
  147. FONT font;
  148. bool isVisible;
  149. PROPERTY* property; ///< only used from a COMPONENT, specifies PROPERTY in PART
  150. wxString propName; ///< only used from a COMPONENT, specifies PROPERTY in PART
  151. TEXT_EFFECTS() :
  152. angle( 0 ),
  153. isVisible( false ),
  154. property( 0 )
  155. {}
  156. void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
  157. throw( IO_ERROR );
  158. // trust compiler to write its own assignment operator for this class OK.
  159. };
  160. #define STROKE_DEFAULT -1 ///< defer line width decision to higher control
  161. #define FILL_TYPE_DEFAULT PR::T_none ///< fillType defaut
  162. class BASE_GRAPHIC
  163. {
  164. friend class PART;
  165. friend class SWEET_PARSER;
  166. protected:
  167. PART* owner;
  168. PART* birthplace; ///< at which PART in inheritance chain was 'this' added
  169. public:
  170. BASE_GRAPHIC( PART* aOwner ) :
  171. owner( aOwner ),
  172. birthplace( aOwner )
  173. {}
  174. virtual ~BASE_GRAPHIC() {}
  175. /**
  176. * Function Clone
  177. * invokes the copy constructor on a heap allocated object of this same
  178. * type and creates a deep copy of 'this' into it
  179. * @param aOwner is the owner of the returned, new object.
  180. */
  181. virtual BASE_GRAPHIC* Clone( PART* aOwner ) const = 0;
  182. static const char* ShowFill( int aFillType )
  183. {
  184. return SWEET_LEXER::TokenName( PR::T( aFillType ) );
  185. }
  186. /**
  187. * Function Format
  188. * outputs this object to @a aFormatter in s-expression form.
  189. */
  190. virtual void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
  191. throw( IO_ERROR )
  192. {}
  193. };
  194. typedef std::deque<POINT> POINTS;
  195. class POLY_LINE : public BASE_GRAPHIC
  196. {
  197. friend class PART;
  198. friend class SWEET_PARSER;
  199. protected:
  200. STROKE stroke;
  201. int fillType; // T_none, T_filled, or T_transparent
  202. POINTS pts;
  203. void formatContents( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
  204. throw( IO_ERROR );
  205. public:
  206. POLY_LINE( PART* aOwner ) :
  207. BASE_GRAPHIC( aOwner ),
  208. stroke( STROKE_DEFAULT ),
  209. fillType( PR::T_none )
  210. {
  211. }
  212. void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
  213. throw( IO_ERROR );
  214. BASE_GRAPHIC* Clone( PART* aOwner ) const
  215. {
  216. POLY_LINE* n = new POLY_LINE( *this );
  217. n->owner = aOwner;
  218. return n;
  219. }
  220. };
  221. class BEZIER : public POLY_LINE
  222. {
  223. friend class PART;
  224. friend class SWEET_PARSER;
  225. public:
  226. BEZIER( PART* aOwner ) :
  227. POLY_LINE( aOwner )
  228. {
  229. stroke = STROKE_DEFAULT;
  230. fillType = PR::T_none;
  231. }
  232. void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
  233. throw( IO_ERROR );
  234. BASE_GRAPHIC* Clone( PART* aOwner ) const
  235. {
  236. BEZIER* n = new BEZIER( *this );
  237. n->owner = aOwner;
  238. return n;
  239. }
  240. };
  241. class RECTANGLE : public BASE_GRAPHIC
  242. {
  243. friend class PART;
  244. friend class SWEET_PARSER;
  245. protected:
  246. STROKE stroke;
  247. int fillType; // T_none, T_filled, or T_transparent
  248. POINT start;
  249. POINT end;
  250. public:
  251. RECTANGLE( PART* aOwner ) :
  252. BASE_GRAPHIC( aOwner ),
  253. stroke( STROKE_DEFAULT ),
  254. fillType( FILL_TYPE_DEFAULT )
  255. {
  256. }
  257. void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
  258. throw( IO_ERROR );
  259. BASE_GRAPHIC* Clone( PART* aOwner ) const
  260. {
  261. RECTANGLE* n = new RECTANGLE( *this );
  262. n->owner = aOwner;
  263. return n;
  264. }
  265. };
  266. class CIRCLE : public BASE_GRAPHIC
  267. {
  268. friend class PART;
  269. friend class SWEET_PARSER;
  270. protected:
  271. POINT center;
  272. int radius;
  273. STROKE stroke;
  274. int fillType; // T_none, T_filled, or T_transparent
  275. public:
  276. CIRCLE( PART* aOwner ) :
  277. BASE_GRAPHIC( aOwner ),
  278. radius( LogicalToInternal( 0.5 ) ),
  279. stroke( STROKE_DEFAULT ),
  280. fillType( FILL_TYPE_DEFAULT )
  281. {
  282. }
  283. void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
  284. throw( IO_ERROR );
  285. BASE_GRAPHIC* Clone( PART* aOwner ) const
  286. {
  287. CIRCLE* n = new CIRCLE( *this );
  288. n->owner = aOwner;
  289. return n;
  290. }
  291. };
  292. class ARC : public BASE_GRAPHIC
  293. {
  294. friend class PART;
  295. friend class SWEET_PARSER;
  296. protected:
  297. POINT pos;
  298. STROKE stroke;
  299. int fillType; // T_none, T_filled, or T_transparent
  300. int radius;
  301. POINT start;
  302. POINT end;
  303. public:
  304. ARC( PART* aOwner ) :
  305. BASE_GRAPHIC( aOwner ),
  306. stroke( STROKE_DEFAULT ),
  307. fillType( FILL_TYPE_DEFAULT ),
  308. radius( LogicalToInternal( 0.5 ) )
  309. {
  310. }
  311. void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
  312. throw( IO_ERROR );
  313. BASE_GRAPHIC* Clone( PART* aOwner ) const
  314. {
  315. ARC* n = new ARC( *this );
  316. n->owner = aOwner;
  317. return n;
  318. }
  319. };
  320. class GR_TEXT : public BASE_GRAPHIC
  321. {
  322. friend class PART;
  323. friend class SWEET_PARSER;
  324. protected:
  325. POINT pos;
  326. ANGLE angle;
  327. int fillType; ///< T_none, T_filled, or T_transparent
  328. int hjustify; ///< T_center, T_right, or T_left
  329. int vjustify; ///< T_center, T_top, or T_bottom
  330. bool isVisible;
  331. wxString text;
  332. FONT font;
  333. public:
  334. GR_TEXT( PART* aOwner ) :
  335. BASE_GRAPHIC( aOwner ),
  336. angle( 0 ),
  337. fillType( PR::T_filled ),
  338. hjustify( PR::T_left ),
  339. vjustify( PR::T_bottom ),
  340. isVisible( true )
  341. {}
  342. static const char* ShowJustify( int aJustify )
  343. {
  344. return SWEET_LEXER::TokenName( PR::T( aJustify ) );
  345. }
  346. void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
  347. throw( IO_ERROR );
  348. BASE_GRAPHIC* Clone( PART* aOwner ) const
  349. {
  350. GR_TEXT* n = new GR_TEXT( *this );
  351. n->owner = aOwner;
  352. return n;
  353. }
  354. };
  355. class PROPERTY : public BASE_GRAPHIC
  356. {
  357. friend class PART;
  358. friend class SWEET_PARSER;
  359. protected:
  360. wxString name;
  361. wxString text;
  362. TEXT_EFFECTS* effects;
  363. void clear()
  364. {
  365. delete effects;
  366. effects = 0;
  367. name = wxEmptyString;
  368. text = wxEmptyString;
  369. }
  370. public:
  371. PROPERTY( PART* aOwner, const wxChar* aName = wxT( "" ) ) :
  372. BASE_GRAPHIC( aOwner ),
  373. name( aName ),
  374. effects( 0 )
  375. {}
  376. PROPERTY( const PROPERTY& r ) :
  377. BASE_GRAPHIC( NULL ),
  378. effects( 0 )
  379. {
  380. // use assignment operator
  381. *this = r;
  382. }
  383. PROPERTY& operator = ( const PROPERTY& r ); // @todo
  384. ~PROPERTY()
  385. {
  386. clear();
  387. }
  388. /**
  389. * Function Effects
  390. * returns a pointer to the TEXT_EFFECTS object for this PROPERTY, and optionally
  391. * will lazily allocate one if it did not exist previously.
  392. * @param doAlloc if true, means do an allocation of a new TEXT_EFFECTS if one
  393. * currently does not exist, otherwise return NULL if non-existent.
  394. */
  395. TEXT_EFFECTS* EffectsLookup();
  396. TEXT_EFFECTS* Effects() const
  397. {
  398. return effects;
  399. }
  400. void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
  401. throw( IO_ERROR );
  402. BASE_GRAPHIC* Clone( PART* aOwner ) const
  403. {
  404. PROPERTY* n = new PROPERTY( *this );
  405. n->owner = aOwner;
  406. return n;
  407. }
  408. };
  409. struct PINTEXT
  410. {
  411. wxString text;
  412. FONT font;
  413. bool isVisible;
  414. PINTEXT() :
  415. isVisible( true )
  416. {}
  417. void Format( OUTPUTFORMATTER* aFormatter, const char* aElement, int aNestLevel, int aControlBits ) const
  418. throw( IO_ERROR );
  419. };
  420. #define PIN_LEN_DEFAULT -1 ///< use standard pin length for given type
  421. #define PIN_SHAPE_DEFAULT PR::T_line ///< use standard pin shape
  422. #define PIN_CONN_DEFAULT PR::T_in ///< use standard pin connection type
  423. class PIN : public BASE_GRAPHIC
  424. {
  425. friend class PART;
  426. friend class SWEET_PARSER;
  427. public:
  428. PIN( PART* aOwner ) :
  429. BASE_GRAPHIC( aOwner ),
  430. angle( 0 ),
  431. connectionType( PIN_CONN_DEFAULT ),
  432. shape( PIN_SHAPE_DEFAULT ),
  433. length( PIN_LEN_DEFAULT ),
  434. isVisible( true )
  435. {}
  436. ~PIN();
  437. const char* ShowType() const
  438. {
  439. return SWEET_LEXER::TokenName( PR::T( connectionType ) );
  440. }
  441. const char* ShowShape() const
  442. {
  443. return SWEET_LEXER::TokenName( PR::T( shape ) );
  444. }
  445. void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
  446. throw( IO_ERROR );
  447. BASE_GRAPHIC* Clone( PART* aOwner ) const
  448. {
  449. PIN* n = new PIN( *this );
  450. n->owner = aOwner;
  451. return n;
  452. }
  453. protected:
  454. POINT pos;
  455. ANGLE angle;
  456. PINTEXT pad;
  457. PINTEXT signal;
  458. int connectionType; ///< T_in, T_out, T_inout, T_tristate, T_passive, T_unspecified,
  459. ///< T_power_in, T_power_out, T_open_collector, T_open_emitter, or T_unconnected.
  460. int shape; ///< T_none, T_line, T_inverted, T_clock, T_inverted_clk, T_input_low, T_clock_low,
  461. ///< T_falling_edge, T_non_logic.
  462. int length; ///< length of pin in internal units
  463. bool isVisible; ///< pin is visible
  464. wxString pin_merge; ///< pad of (pin_merge ...) that I am a member of, else empty if none
  465. };
  466. /**
  467. * Class PART_REF
  468. * is an LPID with a pointer to the "looked up" PART, which is looked up lazily.
  469. */
  470. class PART_REF : public LPID
  471. {
  472. public:
  473. PART_REF() :
  474. LPID(),
  475. part(0)
  476. {}
  477. /**
  478. * Constructor LPID
  479. * takes aLPID string and parses it. A typical LPID string uses a logical
  480. * library name followed by a part name.
  481. * e.g.: "kicad:passives/R/rev2", or
  482. * e.g.: "mylib:R33"
  483. */
  484. PART_REF( const STRING& aLPID ) throw( PARSE_ERROR ) :
  485. LPID( aLPID ),
  486. part(0)
  487. {
  488. }
  489. /**
  490. * Function Lookup
  491. * returns the PART that this LPID refers to. Never returns NULL, because
  492. * instead an exception would be thrown.
  493. * @throw IO_ERROR if any problem occurs or if the part cannot be found.
  494. */
  495. PART* Lookup( LIB_TABLE* aLibTable, LIB* aFallBackLib ) throw( IO_ERROR )
  496. {
  497. if( !part )
  498. {
  499. part = aLibTable->LookupPart( *this, aFallBackLib );
  500. }
  501. return part;
  502. }
  503. protected:
  504. PART* part; ///< The looked-up PART,
  505. ///< no ownership (duh, PARTs are always owned by a LIB)
  506. };
  507. typedef std::vector<PART_REF> PART_REFS;
  508. } // namespace SCH
  509. //-----</temporary home for PART sub objects, move after stable>-----------------
  510. typedef std::set< wxString > KEYWORDS;
  511. namespace SCH {
  512. typedef std::vector< BASE_GRAPHIC* > GRAPHICS;
  513. typedef std::vector< PROPERTY* > PROPERTIES;
  514. typedef std::vector< PIN* > PINS;
  515. typedef std::vector< PIN* > PIN_LIST; ///< no ownership, used for searches
  516. class LPID;
  517. class SWEET_PARSER;
  518. /**
  519. * Class PART
  520. * will have to be unified with what Wayne is doing. I want a separate copy
  521. * here until I can get the state management correct. Since a PART only lives
  522. * within a cache called a LIB, its constructor is private (only a LIB
  523. * can instantiate one), and it exists in various states of freshness and
  524. * completeness relative to the LIB_SOURCE within the LIB.
  525. */
  526. class PART
  527. {
  528. friend class LIB; // is the owner of all PARTS, afterall
  529. friend class SWEET_PARSER;
  530. public:
  531. /**
  532. * Enum PROP_ID
  533. * is the set of "mandatory" properties within a PART. These are used by
  534. * class PART as array indices into PART::mandatory[].
  535. */
  536. enum PROP_ID
  537. {
  538. REFERENCE, ///< reference prefix, a template for instantiation at COMPONENT level
  539. VALUE, ///< value, e.g. "3.3K"
  540. FOOTPRINT, ///< name of PCB module, e.g. "16DIP300"
  541. DATASHEET, ///< URI of datasheet
  542. MODEL, ///< spice model name
  543. END ///< array sentinel, not a valid index
  544. };
  545. virtual ~PART();
  546. PART& operator = ( const PART& other );
  547. /**
  548. * Function Owner
  549. * returns the LIB* owner of this part.
  550. */
  551. LIB* Owner() { return owner; }
  552. /**
  553. * Function Parse
  554. * translates a Sweet string into a binary form that is represented
  555. * by the normal fields of this class. Parse is expected to call Inherit()
  556. * if this part extends any other.
  557. *
  558. * @param aParser is an instance of SWEET_PARSER, rewound at the first line.
  559. *
  560. * @param aLibTable is the LIB_TABLE "view" that is in effect for inheritance,
  561. * and comes from the big containing SCHEMATIC object.
  562. */
  563. void Parse( SWEET_PARSER* aParser, LIB_TABLE* aLibTable ) throw( IO_ERROR, PARSE_ERROR );
  564. /**
  565. * Function Format
  566. * outputs this PART in UTF8 encoded s-expression format to @a aFormatter.
  567. * @param aFormatter is the output sink to write to.
  568. * @param aNestLevel is the initial indent level
  569. * @param aControlBits are bit flags ORed together which control how the output
  570. * is done.
  571. */
  572. void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits = 0 ) const
  573. throw( IO_ERROR );
  574. /**
  575. * Function PropDelete
  576. * deletes the property with aPropertyName if found and returns true, else false
  577. * if not found.
  578. */
  579. bool PropDelete( const wxString& aPropertyName );
  580. /**
  581. * Function Field
  582. * returns a pointer to one of the mandatory properties, or NULL
  583. * if non-existent. Use FieldLookup() to potentially allocate it.
  584. */
  585. PROPERTY* Field( PROP_ID aPropertyId ) const
  586. {
  587. wxASSERT( unsigned(aPropertyId) < unsigned(END) );
  588. return mandatory[aPropertyId];
  589. }
  590. /**
  591. * Function FieldLookup
  592. * returns a pointer to one of the mandatory properties, which is lazily
  593. * constructed by this function if need be.
  594. * @param aPropertyId tells which field.
  595. */
  596. PROPERTY* FieldLookup( PROP_ID aPropertyId );
  597. /**
  598. * Function PinFindByPad
  599. * finds a PIN based on aPad or returns NULL if not found.
  600. * @param aPad is the pin to find
  601. * @return PIN* - the found PIN or NULL if not found.
  602. */
  603. PIN* PinFindByPad( const wxString& aPad )
  604. {
  605. PINS::iterator it = pinFindByPad( aPad );
  606. return it != pins.end() ? *it : NULL;
  607. }
  608. /**
  609. * Function PinsFindBySignal
  610. * fetches all the pins matching aSignal into aResults.
  611. */
  612. void PinsFindBySignal( PIN_LIST* aResults, const wxString& aSignal );
  613. /**
  614. * Function PinDelete
  615. * deletes the pin with aPad if found and returns true, else false
  616. * if not found.
  617. */
  618. bool PinDelete( const wxString& aPad );
  619. /*
  620. void SetValue( const wxString& aValue )
  621. {
  622. value = aValue;
  623. }
  624. const wxString& GetValue()
  625. {
  626. return value;
  627. }
  628. void SetFootprint( const wxString& aFootprint )
  629. {
  630. footprint = aFootprint;
  631. }
  632. const wxString& GetFootprint()
  633. {
  634. return footprint;
  635. }
  636. void SetModel( const wxString& aModel )
  637. {
  638. model = aModel;
  639. }
  640. const wxString& GetModel()
  641. {
  642. return model;
  643. }
  644. */
  645. /*
  646. void SetBody( const STR_UTF& aSExpression )
  647. {
  648. body = aSExpression;
  649. }
  650. */
  651. protected: // not likely to have C++ descendants, but protected none-the-less.
  652. /// a protected constructor, only a LIB can instantiate a PART.
  653. PART( LIB* aOwner, const STRING& aPartNameAndRev );
  654. /**
  655. * Function destroy
  656. * clears out this object, deleting everything that this PART owns and
  657. * initializing values back to a state as if the object was just constructed
  658. * empty.
  659. */
  660. void clear();
  661. /**
  662. * Function inherit
  663. * is a specialized assignment function that copies a specific subset, enough
  664. * to fulfill the requirements of the Sweet s-expression language.
  665. */
  666. void inherit( const PART& aBasePart );
  667. /**
  668. * Function propertyFind
  669. * searches for aPropertyName and returns a PROPERTIES::iterator which
  670. * is the found item or properties.end() if not found.
  671. */
  672. PROPERTIES::iterator propertyFind( const wxString& aPropertyName );
  673. /**
  674. * Function pinFindByPad
  675. * searches for a PIN with aPad and returns a PROPERTIES::iterator which
  676. * is the found item or pins.end() if not found.
  677. */
  678. PINS::iterator pinFindByPad( const wxString& aPad );
  679. LIB* owner; ///< which LIB am I a part of (pun if you want)
  680. int contains; ///< has bits from Enum PartParts
  681. STRING partNameAndRev; ///< example "passives/R[/revN..]", immutable.
  682. LPID* extends; ///< of base part, NULL if none, otherwise I own it.
  683. const PART* base; ///< which PART am I extending, if any. no ownership.
  684. POINT anchor;
  685. /// encapsulate the old version deletion, take ownership of @a aLPID
  686. void setExtends( LPID* aLPID );
  687. /// s-expression text for the part, initially empty, and read in as this part
  688. /// actually becomes cached in RAM.
  689. STRING body;
  690. /// mandatory properties, aka fields. Index into mandatory[] is PROP_ID.
  691. PROPERTY* mandatory[END];
  692. /**
  693. * Member properties
  694. * holds the non-mandatory properties.
  695. */
  696. PROPERTIES properties;
  697. /**
  698. * Member graphics
  699. * owns : POLY_LINE, RECTANGLE, CIRCLE, ARC, BEZIER, and GR_TEXT objects.
  700. */
  701. GRAPHICS graphics;
  702. /**
  703. * Member pins
  704. * owns all the PINs in pins.
  705. */
  706. PINS pins;
  707. /// Alternate body forms.
  708. PART_REFS alternates;
  709. /// searching aids
  710. KEYWORDS keywords;
  711. /**
  712. * A pin_merge set is a set of pins that are all electrically equivalent
  713. * and whose anchor pin is the only one visible. The visible pin is the
  714. * key in the MERGE_SETS boost::ptr_map::map
  715. */
  716. MERGE_SETS pin_merges;
  717. };
  718. } // namespace PART
  719. #endif // SCH_PART_