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.

1274 lines
49 KiB

  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) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
  6. * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. /**
  26. * @file wxEeschemaStruct.h
  27. */
  28. #ifndef WX_EESCHEMA_STRUCT_H
  29. #define WX_EESCHEMA_STRUCT_H
  30. #include <sch_base_frame.h>
  31. #include <param_config.h>
  32. #include <class_undoredo_container.h>
  33. #include <template_fieldnames.h>
  34. #include <block_commande.h>
  35. #include <class_sch_screen.h>
  36. #include <sch_collectors.h>
  37. class LIB_EDIT_FRAME;
  38. class LIB_VIEW_FRAME;
  39. class DRAWSEGMENT;
  40. class SCH_ITEM;
  41. class SCH_NO_CONNECT;
  42. class CMP_LIBRARY;
  43. class LIB_COMPONENT;
  44. class LIB_DRAW_ITEM;
  45. class EDA_ITEM;
  46. class SCH_BUS_ENTRY_BASE;
  47. class SCH_BUS_WIRE_ENTRY;
  48. class SCH_BUS_BUS_ENTRY;
  49. class SCH_GLOBALLABEL;
  50. class SCH_TEXT;
  51. class SCH_BITMAP;
  52. class SCH_SHEET;
  53. class SCH_SHEET_PATH;
  54. class SCH_SHEET_PIN;
  55. class SCH_COMPONENT;
  56. class SCH_FIELD;
  57. class LIB_PIN;
  58. class SCH_JUNCTION;
  59. class DIALOG_SCH_FIND;
  60. class wxFindDialogEvent;
  61. class wxFindReplaceData;
  62. /* enum used in RotationMiroir() */
  63. enum COMPONENT_ORIENTATION_T {
  64. CMP_NORMAL, // Normal orientation, no rotation or mirror
  65. CMP_ROTATE_CLOCKWISE, // Rotate -90
  66. CMP_ROTATE_COUNTERCLOCKWISE, // Rotate +90
  67. CMP_ORIENT_0, // No rotation and no mirror id CMP_NORMAL
  68. CMP_ORIENT_90, // Rotate 90, no mirror
  69. CMP_ORIENT_180, // Rotate 180, no mirror
  70. CMP_ORIENT_270, // Rotate -90, no mirror
  71. CMP_MIRROR_X = 0x100, // Mirror around X axis
  72. CMP_MIRROR_Y = 0x200 // Mirror around Y axis
  73. };
  74. /** Schematic annotation order options. */
  75. enum ANNOTATE_ORDER_T {
  76. SORT_BY_X_POSITION, ///< Annotate by X position from left to right.
  77. SORT_BY_Y_POSITION, ///< Annotate by Y position from top to bottom.
  78. UNSORTED, ///< Annotate by position of component in the schematic sheet
  79. ///< object list.
  80. };
  81. /** Schematic annotation type options. */
  82. enum ANNOTATE_OPTION_T {
  83. INCREMENTAL_BY_REF, ///< Annotate incrementally using the first free reference number.
  84. SHEET_NUMBER_X_100, ///< Annotate using the first free reference number starting at
  85. ///< the sheet number * 100.
  86. SHEET_NUMBER_X_1000, ///< Annotate using the first free reference number starting at
  87. ///< the sheet number * 1000.
  88. };
  89. /// Schematic search type used by the socket link with Pcbnew
  90. enum SCH_SEARCH_T {
  91. FIND_COMPONENT_ONLY, ///< Find a component in the schematic.
  92. FIND_PIN, ///< Find a component pin in the schematic.
  93. FIND_REFERENCE, ///< Find an item by it's reference designator.
  94. FIND_VALUE, ///< Find an item by it's value field.
  95. FIND_FIELD ///< Find a component field.
  96. };
  97. /**
  98. * Schematic editor (Eeschema) main window.
  99. */
  100. class SCH_EDIT_FRAME : public SCH_BASE_FRAME
  101. {
  102. private:
  103. SCH_SHEET_PATH* m_CurrentSheet; ///< which sheet we are presently working on.
  104. wxString m_DefaultSchematicFileName;
  105. int m_TextFieldSize;
  106. PARAM_CFG_ARRAY m_projectFileParams;
  107. PARAM_CFG_ARRAY m_configSettings;
  108. wxPageSetupDialogData m_pageSetupData;
  109. wxFindReplaceData* m_findReplaceData;
  110. wxPoint m_previewPosition;
  111. wxSize m_previewSize;
  112. wxPoint m_printDialogPosition;
  113. wxSize m_printDialogSize;
  114. bool m_printMonochrome; ///< Print monochrome instead of grey scale.
  115. bool m_printSheetReference;
  116. DIALOG_SCH_FIND* m_dlgFindReplace;
  117. wxPoint m_findDialogPosition;
  118. wxSize m_findDialogSize;
  119. wxArrayString m_findStringHistoryList;
  120. wxArrayString m_replaceStringHistoryList;
  121. BLOCK_SELECTOR m_blockItems; ///< List of selected items.
  122. SCH_ITEM* m_item_to_repeat; ///< Last item to insert by the repeat command.
  123. int m_repeatLabelDelta; ///< Repeat label number increment step.
  124. SCH_COLLECTOR m_collectedItems; ///< List of collected items.
  125. SCH_FIND_COLLECTOR m_foundItems; ///< List of find/replace items.
  126. SCH_ITEM* m_undoItem; ///< Copy of the current item being edited.
  127. wxString m_simulatorCommand; ///< Command line used to call the circuit
  128. ///< simulator (gnucap, spice, ...)
  129. wxString m_netListerCommand; ///< Command line to call a custom net list
  130. ///< generator.
  131. bool m_forceHVLines; ///< force H or V directions for wires, bus, line
  132. int m_defaultLabelSize; ///< size of a new label
  133. /// An index to the last find item in the found items list #m_foundItems.
  134. int m_foundItemIndex;
  135. /// Flag to indicate show hidden pins.
  136. bool m_showAllPins;
  137. /// The name of the format to use when generating a net list.
  138. wxString m_netListFormat;
  139. /// Add X prefix to component references when generating spice net lists.
  140. bool m_addReferencPrefix;
  141. wxString m_userLibraryPath;
  142. wxArrayString m_componentLibFiles;
  143. static int m_lastSheetPinType; ///< Last sheet pin type.
  144. static wxSize m_lastSheetPinTextSize; ///< Last sheet pin text size.
  145. static wxPoint m_lastSheetPinPosition; ///< Last sheet pin position.
  146. protected:
  147. TEMPLATES m_TemplateFieldNames;
  148. /**
  149. * Function doAutoSave
  150. * saves the schematic files that have been modified and not yet saved.
  151. *
  152. * @return true if the auto save was successful otherwise false.
  153. */
  154. virtual bool doAutoSave();
  155. /**
  156. * Function autoSaveRequired
  157. * returns true if the schematic has been modified.
  158. */
  159. virtual bool isAutoSaveRequired() const;
  160. /**
  161. * Function addCurrentItemToList
  162. * adds the item currently being edited to the schematic and adds the changes to
  163. * the undo/redo container.
  164. *
  165. * @param aDC A pointer the device context to draw on when not NULL.
  166. */
  167. void addCurrentItemToList( wxDC* aDC );
  168. public:
  169. SCH_EDIT_FRAME( wxWindow* aParent, const wxString& aTitle,
  170. const wxPoint& aPosition, const wxSize& aSize,
  171. long aStyle = KICAD_DEFAULT_DRAWFRAME_STYLE );
  172. ~SCH_EDIT_FRAME();
  173. SCH_SCREEN* GetScreen() const; // overload SCH_BASE_FRAME
  174. void OnCloseWindow( wxCloseEvent& Event );
  175. int GetDefaultLabelSize() const { return m_defaultLabelSize; }
  176. void SetDefaultLabelSize( int aLabelSize ) { m_defaultLabelSize = aLabelSize; }
  177. bool GetForceHVLines() const { return m_forceHVLines; }
  178. void SetForceHVLines( bool aForceHVdirection ) { m_forceHVLines = aForceHVdirection; }
  179. bool GetShowAllPins() const { return m_showAllPins; }
  180. void SetShowAllPins( bool aEnable ) { m_showAllPins = aEnable; }
  181. const wxString GetNetListFormatName() const { return m_netListFormat; }
  182. void SetNetListFormatName( const wxString& aFormat ) { m_netListFormat = aFormat; }
  183. bool GetAddReferencePrefix() const { return m_addReferencPrefix; }
  184. void SetAddReferencePrefix( bool aEnable ) { m_addReferencPrefix = aEnable; }
  185. wxString GetUserLibraryPath() const { return m_userLibraryPath; }
  186. void SetUserLibraryPath( const wxString& aPath ) { m_userLibraryPath = aPath; }
  187. const wxArrayString& GetComponentLibraries() const { return m_componentLibFiles; }
  188. void SetComponentLibraries( const wxArrayString& aList ) { m_componentLibFiles = aList; }
  189. void Process_Special_Functions( wxCommandEvent& event );
  190. void OnColorConfig( wxCommandEvent& aEvent );
  191. void Process_Config( wxCommandEvent& event );
  192. void OnSelectTool( wxCommandEvent& aEvent );
  193. void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 );
  194. /**
  195. * Function GetProjectFileParametersList
  196. * returns the project file parameter list for Eeschema.
  197. *
  198. *<p?
  199. * Populate the project file parameter array specific to Eeschema if it hasn't
  200. * already been populated and return a reference to the array to the caller.
  201. * Creating the parameter list at run time has the advantage of being able to
  202. * define local variables. The old method of statically building the array at
  203. * compile time required global variable definitions.
  204. * </p>
  205. */
  206. PARAM_CFG_ARRAY& GetProjectFileParametersList( void );
  207. /**
  208. * Function SaveProjectSettings
  209. * saves changes to the project settings to the project (.pro) file.
  210. * @param aAskForSave = true to open a dialog before saving the settings
  211. */
  212. void SaveProjectSettings( bool aAskForSave );
  213. /**
  214. * Function LoadProjectFile
  215. * loads the KiCad project file (*.pro) settings specific to Eeschema.
  216. *
  217. * @param aFileName The project file name to load.
  218. * @param aForceReread Force the project file to be reread if true.
  219. * @return True if the project file was loaded correctly.
  220. */
  221. bool LoadProjectFile( const wxString& aFileName, bool aForceReread );
  222. /**
  223. * Function GetDefaultFieldName
  224. * returns a default symbol field name for field \a aFieldNdx for all components.
  225. * These field names are not modifiable, but template field names are.
  226. * @param aFieldNdx The field number index
  227. */
  228. static wxString GetDefaultFieldName( int aFieldNdx );
  229. /**
  230. * Function AddTemplateFieldName
  231. * inserts or appends a wanted symbol field name into the field names
  232. * template. Should be used for any symbol property editor. If the name
  233. * already exists, it overwrites the same name.
  234. *
  235. * @param aFieldName is a full description of the wanted field, and it must not match
  236. * any of the default field names.
  237. * @return int - the index within the config container at which aFieldName was
  238. * added, or -1 if the name is illegal because it matches a default field name.
  239. */
  240. int AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName )
  241. {
  242. return m_TemplateFieldNames.AddTemplateFieldName( aFieldName );
  243. }
  244. /**
  245. * Function GetTemplateFieldName
  246. * returns a template field names list for read only access.
  247. */
  248. const TEMPLATE_FIELDNAMES& GetTemplateFieldNames()
  249. {
  250. return m_TemplateFieldNames.GetTemplateFieldNames();
  251. }
  252. /**
  253. * Function GetTemplates
  254. * returns the field names template for read only access.
  255. */
  256. const TEMPLATES& GetTemplates()
  257. {
  258. return m_TemplateFieldNames;
  259. }
  260. /**
  261. * Function DeleteAllTemplateFieldNames
  262. * removes all template field names.
  263. */
  264. void DeleteAllTemplateFieldNames()
  265. {
  266. m_TemplateFieldNames.DeleteAllTemplateFieldNames();
  267. }
  268. /**
  269. * Function GetConfigurationSettings
  270. * returns the Eeschema applications settings.
  271. * <p>
  272. * This replaces the old statically define list that had the project file settings and
  273. * the application settings mixed together. This was confusing and caused some settings
  274. * to get saved and loaded incorrectly. Currently, only the settings that are needed at
  275. * start up by the main window are defined here. There are other locally used settings
  276. * scattered throughout the Eeschema source code. If you need to define a configuration
  277. * setting that need to be loaded at run time, this is the place to define it.
  278. * </p>
  279. */
  280. PARAM_CFG_ARRAY& GetConfigurationSettings( void );
  281. void LoadSettings();
  282. void SaveSettings();
  283. void RedrawActiveWindow( wxDC* DC, bool EraseBg );
  284. void CreateScreens();
  285. void ReCreateHToolbar();
  286. void ReCreateVToolbar();
  287. void ReCreateOptToolbar();
  288. void ReCreateMenuBar();
  289. void OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem = NULL );
  290. /**
  291. * Function OnModify
  292. * Must be called after a schematic change
  293. * in order to set the "modify" flag of the current screen
  294. * and update the date in frame reference
  295. */
  296. void OnModify();
  297. virtual wxString GetScreenDesc();
  298. void InstallConfigFrame( wxCommandEvent& event );
  299. void OnLeftClick( wxDC* aDC, const wxPoint& aPosition );
  300. void OnLeftDClick( wxDC* aDC, const wxPoint& aPosition );
  301. bool OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu );
  302. void OnSelectOptionToolbar( wxCommandEvent& event );
  303. double BestZoom();
  304. /**
  305. * Function LocateAndShowItem
  306. * checks the schematic at \a aPosition in logical (drawing) units for a item
  307. * matching the types in \a aFilterList.
  308. * <p>
  309. * The search is first performed at the nearest grid position to \a aPosition. If no
  310. * item if found on grid, then \a aPosition is tested for any items. If the item found
  311. * can be cross probed, a message is send to Pcbnew and the selected item is highlighted
  312. * in PCB editor.
  313. * </p>
  314. * @param aPosition The wxPoint on the schematic to search.
  315. * @param aFilterList A list of #KICAD_T types to to filter.
  316. * @param aHotKeyCommandId A hot key command ID for performing additional tests when
  317. * multiple items are found at \a aPosition.
  318. * @return A SCH_ITEM pointer of the item found or NULL if no item found
  319. */
  320. SCH_ITEM* LocateAndShowItem( const wxPoint& aPosition,
  321. const KICAD_T aFilterList[] = SCH_COLLECTOR::AllItems,
  322. int aHotKeyCommandId = 0 );
  323. /**
  324. * Function LocateItem
  325. * checks for items at \a aPosition matching the types in \a aFilterList.
  326. * <p>
  327. * If multiple items are located at \a aPosition, a context menu is displayed to clarify
  328. * which item the user intended to select. If the user aborts the context menu, NULL is
  329. * returned and the abort request flag will be set to true. Make sure to clear this flag
  330. * before attempting to display any other context menus.
  331. * </p>
  332. *
  333. * @param aPosition The wxPoint location where to search.
  334. * @param aFilterList A list of #KICAD_T types to to filter.
  335. * @param aHotKeyCommandId A hot key command ID for performing additional tests when
  336. * multiple items are found at \a aPosition.
  337. * @return The SCH_ITEM pointer of the item found or NULL if no item found.
  338. */
  339. SCH_ITEM* LocateItem( const wxPoint& aPosition,
  340. const KICAD_T aFilterList[] = SCH_COLLECTOR::AllItems,
  341. int aHotKeyCommandId = 0 );
  342. /**
  343. * Function DeleteItemAtCrossHair
  344. * delete the item found under the cross hair. If multiple items are found at the
  345. * cross hair position, a context menu is displayed to clarify which item to delete.
  346. * See LocateItem() for more information on locating multiple items.
  347. *
  348. * @param aDC The device context to update if and item is deleted.
  349. * @return True if an item was deleted.
  350. */
  351. bool DeleteItemAtCrossHair( wxDC* aDC );
  352. /**
  353. * Function FindComponentAndItem
  354. * finds a component in the schematic and an item in this component.
  355. * @param aReference The component reference designator to find.
  356. * @param aSearchHierarchy If false, search the current sheet only. Otherwise,
  357. * the entire hierarchy
  358. * @param aSearchType A #SCH_SEARCH_T value used to determine what to search for.
  359. * @param aSearchText The text to search for, either in value, reference or elsewhere.
  360. * @param aWarpMouse If true, then move the mouse cursor to the item.
  361. */
  362. SCH_ITEM* FindComponentAndItem( const wxString& aReference,
  363. bool aSearchHierarchy,
  364. SCH_SEARCH_T aSearchType,
  365. const wxString& aSearchText,
  366. bool aWarpMouse );
  367. /**
  368. * Function SendMessageToPcbnew
  369. * send a remote to Pcbnew via a socket connection.
  370. * @param objectToSync Item to be located on board (footprint, pad or text)
  371. * @param LibItem Component in library if objectToSync is a sub item of a component
  372. * <p>
  373. * Commands are
  374. * $PART: reference put cursor on footprint anchor
  375. * $PIN: number $PART: reference put cursor on the footprint pad
  376. * </p>
  377. */
  378. void SendMessageToPCBNEW( EDA_ITEM* objectToSync, SCH_COMPONENT* LibItem );
  379. /**
  380. * BuildNetListBase
  381. * netlist generation:
  382. * Creates a flat list which stores all connected objects, and mainly
  383. * pins and labels.
  384. * @return a pointer to the list
  385. */
  386. NETLIST_OBJECT_LIST * BuildNetListBase();
  387. /**
  388. * Function CreateNetlist
  389. * <ul>
  390. * <li> test for some issues (missing or duplicate references and sheet names)
  391. * <li> build netlist info
  392. * <li> create the netlist file (different formats)
  393. * </ul>
  394. * @param aFormat = netlist format (NET_TYPE_PCBNEW ...)
  395. * @param aFullFileName = full netlist file name
  396. * @param aNetlistOptions = netlist options using OR'ed bits.
  397. * <p>
  398. * For SPICE netlist only:
  399. * if NET_USE_NETNAMES is set, use net names from labels in schematic
  400. * else use net numbers (net codes)
  401. * if NET_USE_X_PREFIX is set : change "U" and "IC" refernce prefix to "X"
  402. * </p>
  403. * @return true if success.
  404. */
  405. bool CreateNetlist( int aFormat,
  406. const wxString& aFullFileName,
  407. unsigned aNetlistOptions );
  408. /**
  409. * Function WriteNetListFile
  410. * Create the netlist file. Netlist info must be existing
  411. * (BuildNetListBase() creates this info)
  412. * @param aConnectedItemsList = the initialized list of connected items
  413. * @param aFormat = netlist format (NET_TYPE_PCBNEW ...)
  414. * @param aFullFileName = full netlist file name
  415. * @param aNetlistOptions = netlist options using OR'ed bits.
  416. * <p>
  417. * For SPICE netlist only:
  418. * if NET_USE_NETNAMES is set, use net names from labels in schematic
  419. * else use net numbers (net codes)
  420. * if NET_USE_X_PREFIX is set : change "U" and "IC" refernce prefix to "X"
  421. * </p>
  422. * @return true if success.
  423. */
  424. bool WriteNetListFile( NETLIST_OBJECT_LIST * aConnectedItemsList,
  425. int aFormat,
  426. const wxString& aFullFileName,
  427. unsigned aNetlistOptions );
  428. /**
  429. * Function DeleteAnnotation
  430. * clears the current component annotation.
  431. * @param aCurrentSheetOnly Clear the entire schematic annotation if true. Otherwise
  432. * only clear the annotation for the current sheet.
  433. */
  434. void DeleteAnnotation( bool aCurrentSheetOnly );
  435. /**
  436. * Function AnnotateComponents
  437. *
  438. * annotates the components in the schematic that are not currently annotated.
  439. *
  440. * @param aAnnotateSchematic Annotate the entire schematic if true. Otherwise annotate
  441. * the current sheet only.
  442. * @param aSortOption Define the annotation order. See #ANNOTATE_ORDER_T.
  443. * @param aAlgoOption Define the annotation style. See #ANNOTATE_OPTION_T.
  444. * @param aResetAnnotation Clear any previous annotation if true. Otherwise, keep the
  445. * existing component annotation.
  446. * @param aRepairTimestamps Test for and repair any duplicate time stamps if true.
  447. * Otherwise, keep the existing time stamps. This option
  448. * could change previous annotation because time stamps are
  449. * used to handle annotation in complex hierarchies.
  450. *
  451. * When the sheet number is used in annotation, each sheet annotation starts from sheet
  452. * number * 100. In other words the first sheet uses 100 to 199, the second sheet uses
  453. * 200 to 299, and so on.
  454. */
  455. void AnnotateComponents( bool aAnnotateSchematic, ANNOTATE_ORDER_T aSortOption,
  456. ANNOTATE_OPTION_T aAlgoOption, bool aResetAnnotation,
  457. bool aRepairTimestamps );
  458. /**
  459. * Function CheckAnnotate
  460. * checks for annotation errors.
  461. *
  462. * <p>
  463. * The following list of items are checked:
  464. * <ul>
  465. * <li> Components that are not annotated.
  466. * <li> Duplicate component references.
  467. * <li> Multiple part per package components where the part\n
  468. * number is greater number of parts in the package.
  469. * <li> Multiple part per package components where the reference\n
  470. * designator is different between parts.
  471. * </ul>
  472. * </p>
  473. *
  474. * @return Number of annotation errors found.
  475. * @param aMessageList A wxArrayString to store error messages.
  476. * @param aOneSheetOnly Check the current sheet only if true. Otherwise check
  477. * the entire schematic.
  478. */
  479. int CheckAnnotate( wxArrayString* aMessageList, bool aOneSheetOnly );
  480. // Functions used for hierarchy handling
  481. SCH_SHEET_PATH& GetCurrentSheet();
  482. void SetCurrentSheet( const SCH_SHEET_PATH& aSheet );
  483. /**
  484. * Function DisplayCurrentSheet
  485. * draws the current sheet on the display.
  486. */
  487. void DisplayCurrentSheet();
  488. /**
  489. * Function GetUniqueFilenameForCurrentSheet
  490. * @return a filename that can be used in plot and print functions
  491. * for the current screen and sheet path.
  492. * This filename is unique and must be used instead of the screen filename
  493. * (or screen filename) when one must creates file for each sheet in the
  494. * hierarchy. because in complex hierarchies a sheet and a SCH_SCREEN is
  495. * used more than once
  496. * Name is &ltroot sheet filename&gt-&ltsheet path&gt and has no extension.
  497. * However if filename is too long name is &ltsheet filename&gt-&ltsheet number&gt
  498. */
  499. wxString GetUniqueFilenameForCurrentSheet();
  500. /**
  501. * Function SetSheetNumberAndCount
  502. * Set the m_ScreenNumber and m_NumberOfScreens members for screens
  503. * must be called after a delete or add sheet command, and when entering
  504. * a sheet
  505. */
  506. void SetSheetNumberAndCount();
  507. /**
  508. * Show the print dialog
  509. */
  510. void OnPrint( wxCommandEvent& event );
  511. wxPageSetupDialogData& GetPageSetupData() { return m_pageSetupData; }
  512. void SetPreviewPosition( const wxPoint& aPoint ) { m_previewPosition = aPoint; }
  513. void SetPreviewSize( const wxSize& aSize ) { m_previewSize = aSize; }
  514. const wxPoint& GetPreviewPosition() { return m_previewPosition; }
  515. const wxSize& GetPreviewSize() { return m_previewSize; }
  516. void SetPrintDialogPosition( const wxPoint& aPoint )
  517. {
  518. m_printDialogPosition = aPoint;
  519. }
  520. void SetPrintDialogSize( const wxSize& aSize ) { m_printDialogSize = aSize; }
  521. const wxPoint& GetPrintDialogPosition() { return m_printDialogPosition; }
  522. const wxSize& GetPrintDialogSize() { return m_printDialogSize; }
  523. bool GetPrintMonochrome() { return m_printMonochrome; }
  524. void SetPrintMonochrome( bool aMonochrome ) { m_printMonochrome = aMonochrome; }
  525. bool GetPrintSheetReference() { return m_printSheetReference; }
  526. void SetPrintSheetReference( bool aShow ) { m_printSheetReference = aShow; }
  527. // Plot functions:
  528. // void ToPostProcess( wxCommandEvent& event );
  529. void PlotSchematic( wxCommandEvent& event );
  530. // read and save files
  531. void Save_File( wxCommandEvent& event );
  532. /**
  533. * Function OnSaveProject
  534. * is the command event handler to save the entire project and create a component library
  535. * archive.
  536. *
  537. * The component library archive name is &ltroot_name&gt-cache.lib
  538. */
  539. void OnSaveProject( wxCommandEvent& aEvent );
  540. /**
  541. * Function LoadOneEEProject
  542. * load an entire project into the schematic editor.
  543. *
  544. * This function loads schematic root file and it's subhierarchies, the project
  545. * configuration, and the component libraries which are not already loaded.
  546. *
  547. * @param aFileName The full path an file name to load.
  548. * @param aIsNew True indicates that this is a new project and the default project
  549. * template is loaded.
  550. * @return True if the project loaded properly.
  551. */
  552. bool LoadOneEEProject( const wxString& aFileName, bool aIsNew );
  553. /**
  554. * Function AppendOneEEProject
  555. * read an entire project and loads it into the schematic editor *whitout* replacing the
  556. * existing contents.
  557. * @return True if the project was imported properly.
  558. */
  559. bool AppendOneEEProject();
  560. /**
  561. * Function LoadOneEEFile
  562. * loads the schematic (.sch) file \a aFullFileName into \a aScreen.
  563. *
  564. * @param aScreen Pointer to the associated SCH_SCREEN object in which to load
  565. * \a aFullFileName.
  566. * @param aFullFileName A reference to a wxString object containing the absolute path
  567. * and file name to load.
  568. * @param append True if loaded file is being appended to the currently open file instead
  569. * of replacing it.
  570. * @return True if \a aFullFileName has been loaded (at least partially.)
  571. */
  572. bool LoadOneEEFile( SCH_SCREEN* aScreen, const wxString& aFullFileName, bool append = false );
  573. /**
  574. * Function ReadCmpToFootprintLinkFile
  575. * Loads a .cmp file from CvPcb and update the footprin field
  576. * of components
  577. * Prepares parameters and calls ProcessCmpToFootprintLinkFile
  578. * to actually read the file and update Fp fields
  579. */
  580. bool LoadCmpToFootprintLinkFile();
  581. /**
  582. * Function ProcessStuffFile
  583. * gets footprint info from each line in the Stuff File by Ref Desg
  584. *
  585. * Read a Cmp To Footprint Link file created by CvPcb (the .cmp file).
  586. * That file has lines like:
  587. * BeginCmp
  588. * TimeStamp = /32307DE2/AA450F67;
  589. * Reference = C1;
  590. * ValeurCmp = 47uF;
  591. * IdModule = CP6;
  592. * EndCmp
  593. *
  594. * @param aFullFilename = the full filename to read
  595. * @param aForceFieldsVisibleAttribute = true to change the footprint field flag
  596. * visible or invisible
  597. * false = keep old state.
  598. * @param aFieldsVisibleAttributeState = footprint field flag visible new state
  599. * @return bool = true if success.
  600. */
  601. bool ProcessCmpToFootprintLinkFile( wxString& aFullFilename,
  602. bool aForceFieldsVisibleAttribute,
  603. bool aFieldsVisibleAttributeState );
  604. /**
  605. * Function SaveEEFile
  606. * saves \a aScreen to a schematic file.
  607. *
  608. * @param aScreen A pointer to the SCH_SCREEN object to save. A NULL pointer saves
  609. * the current screen.
  610. * @param aSaveUnderNewName Controls how the file is to be saved;: using previous name
  611. * or under a new name .
  612. * @param aCreateBackupFile Creates a back of the file associated with \a aScreen
  613. * if true.
  614. * Helper definitions #CREATE_BACKUP_FILE and
  615. * #NO_BACKUP_FILE are defined for improved code readability.
  616. * @return True if the file has been saved.
  617. */
  618. bool SaveEEFile( SCH_SCREEN* aScreen,
  619. bool aSaveUnderNewName = false,
  620. bool aCreateBackupFile = CREATE_BACKUP_FILE );
  621. // General search:
  622. private:
  623. /**
  624. * Function OnMoveItem
  625. * handles the #ID_SCH_MOVE_ITEM event used to move schematic itams.
  626. */
  627. void OnMoveItem( wxCommandEvent& aEvent );
  628. /**
  629. * Function OnRotate
  630. * handles the #ID_SCH_ROTATE_CLOCKWISE and #ID_SCH_ROTATE_COUNTERCLOCKWISE events
  631. * used to rotate schematic itams and blocks.
  632. */
  633. void OnRotate( wxCommandEvent& aEvent );
  634. /**
  635. * Function OnEditItem
  636. * handles the #ID_SCH_EDIT_ITEM event used to edit schematic itams.
  637. */
  638. void OnEditItem( wxCommandEvent& aEvent );
  639. /**
  640. * Function OnDragItem
  641. * handles the #ID_SCH_DRAG_ITEM event used to drag schematic itams.
  642. */
  643. void OnDragItem( wxCommandEvent& aEvent );
  644. /**
  645. * Function OnOrient
  646. * handles the #ID_SCH_MIRROR_X, #ID_SCH_MIRROR_Y, and #ID_SCH_ORIENT_NORMAL events
  647. * used to orient schematic itams and blocks.
  648. */
  649. void OnOrient( wxCommandEvent& aEvent );
  650. void OnExit( wxCommandEvent& event );
  651. void OnAnnotate( wxCommandEvent& event );
  652. void OnErc( wxCommandEvent& event );
  653. void OnCreateNetlist( wxCommandEvent& event );
  654. void OnCreateBillOfMaterials( wxCommandEvent& event );
  655. void OnFindItems( wxCommandEvent& event );
  656. void OnFindDialogClose( wxFindDialogEvent& event );
  657. void OnFindDrcMarker( wxFindDialogEvent& event );
  658. void OnFindCompnentInLib( wxFindDialogEvent& event );
  659. /**
  660. * Function OnFindSchematicItem
  661. * finds an item in the schematic matching the search criteria in \a aEvent.
  662. *
  663. * @param aEvent - Find dialog event containing the find parameters.
  664. */
  665. void OnFindSchematicItem( wxFindDialogEvent& aEvent );
  666. /**
  667. * Function OnReplace
  668. * performs a search and replace of text in an item in the schematic matching the
  669. * search and replace criteria in \a aEvent.
  670. *
  671. * @param aEvent - Find dialog event containing the search and replace parameters.
  672. */
  673. void OnFindReplace( wxFindDialogEvent& aEvent );
  674. void OnLoadFile( wxCommandEvent& event );
  675. void OnLoadCmpToFootprintLinkFile( wxCommandEvent& event );
  676. void OnNewProject( wxCommandEvent& event );
  677. void OnLoadProject( wxCommandEvent& event );
  678. void OnAppendProject( wxCommandEvent& event );
  679. void OnOpenPcbnew( wxCommandEvent& event );
  680. void OnOpenCvpcb( wxCommandEvent& event );
  681. void OnOpenLibraryEditor( wxCommandEvent& event );
  682. void OnSetOptions( wxCommandEvent& event );
  683. void OnCancelCurrentCommand( wxCommandEvent& aEvent );
  684. void OnSelectItem( wxCommandEvent& aEvent );
  685. /**
  686. * Function OnCopySchematicItemRequest
  687. * is the command event handler for duplicating the item at the current location.
  688. */
  689. void OnCopySchematicItemRequest( wxCommandEvent& event );
  690. /* User interface update event handlers. */
  691. void OnUpdateBlockSelected( wxUpdateUIEvent& event );
  692. void OnUpdatePaste( wxUpdateUIEvent& event );
  693. void OnUpdateHiddenPins( wxUpdateUIEvent& event );
  694. void OnUpdateBusOrientation( wxUpdateUIEvent& event );
  695. void OnUpdateSelectTool( wxUpdateUIEvent& aEvent );
  696. /**
  697. * Function SetLanguage
  698. * called on a language menu selection
  699. */
  700. void SetLanguage( wxCommandEvent& event );
  701. /**
  702. * Function UpdateTitle
  703. * sets the main window title bar text.
  704. * <p>
  705. * If file name defined by SCH_SCREEN::m_FileName is not set, the title is set to the
  706. * application name appended with no file.
  707. * Otherwise, the title is set to the hierarchical sheet path and the full file name,
  708. * and read only is appended to the title if the user does not have write
  709. * access to the file.
  710. * </p>
  711. */
  712. void UpdateTitle();
  713. // Bus Entry
  714. SCH_BUS_WIRE_ENTRY* CreateBusWireEntry( wxDC* DC );
  715. SCH_BUS_BUS_ENTRY* CreateBusBusEntry( wxDC* DC );
  716. void SetBusEntryShape( wxDC* DC, SCH_BUS_ENTRY_BASE* BusEntry, char entry_shape );
  717. /**
  718. * Function AddNoConnect
  719. * add a no connect item to the current schematic sheet at \a aPosition.
  720. * @param aDC The device context to draw the no connect to.
  721. * @param aPosition The position in logical (drawing) units to add the no connect.
  722. * @return The no connect item added.
  723. */
  724. SCH_NO_CONNECT* AddNoConnect( wxDC* aDC, const wxPoint& aPosition );
  725. /**
  726. * Function AddJunction
  727. * adds a new junction at \a aPosition.
  728. */
  729. SCH_JUNCTION* AddJunction( wxDC* aDC, const wxPoint& aPosition, bool aPutInUndoList = false );
  730. /**
  731. * Function MoveItem
  732. * start moving \a aItem using the mouse.
  733. *
  734. * @param aItem A pointer to an SCH_ITEM to move.
  735. * @param aDC The device context to draw \a aItem.
  736. */
  737. void MoveItem( SCH_ITEM* aItem, wxDC* aDC );
  738. // Text, label, glabel
  739. SCH_TEXT* CreateNewText( wxDC* aDC, int aType );
  740. void EditSchematicText( SCH_TEXT* TextStruct );
  741. void ChangeTextOrient( SCH_TEXT* aTextItem, wxDC* aDC );
  742. /**
  743. * Function OnCovertTextType
  744. * is a command event handler to change a text type to an other one. The new text,
  745. * label, hierarchical label, or global label is created from the old text and the
  746. * old text is deleted.
  747. */
  748. void OnConvertTextType( wxCommandEvent& aEvent );
  749. /**
  750. * Function BeginSegment
  751. * creates a new segment ( WIRE, BUS ) or terminates the current segment in progress.
  752. *
  753. * If the end of the current segment is on an other segment, place a junction if needed
  754. * and terminates the command. If the end of the current segment is on a pin, terminate
  755. * the command. In all other cases starts a new segment.
  756. */
  757. void BeginSegment( wxDC* DC, int type );
  758. /**
  759. * Function EndSegment
  760. * called to terminate a bus, wire, or line creation
  761. */
  762. void EndSegment( wxDC* DC );
  763. /**
  764. * Function DeleteCurrentSegment
  765. * erases the last segment at the current mouse position.
  766. */
  767. void DeleteCurrentSegment( wxDC* DC );
  768. void DeleteConnection( bool DeleteFullConnection );
  769. // graphic lines
  770. void Edge( DRAWSEGMENT* Segment, wxDC* DC );
  771. void SetNewWidth( DRAWSEGMENT* DrawSegm, wxDC* DC );
  772. void Layer( DRAWSEGMENT* Segment, wxDC* DC );
  773. DRAWSEGMENT* Begin_Edge( DRAWSEGMENT* Segment, wxDC* DC );
  774. // Images:
  775. SCH_BITMAP* CreateNewImage( wxDC* aDC );
  776. void MoveImage( SCH_BITMAP* aItem, wxDC* aDC );
  777. void RotateImage( SCH_BITMAP* aItem );
  778. /**
  779. * Function MirrorImage
  780. * Mirror a bitmap
  781. * @param aItem = the SCH_BITMAP item to mirror
  782. * @param Is_X_axis = true to mirror relative to Horizontal axis
  783. * false to mirror relative to vertical axis
  784. */
  785. void MirrorImage( SCH_BITMAP* aItem, bool Is_X_axis );
  786. void EditImage( SCH_BITMAP* aItem );
  787. // Hierarchical Sheet & PinSheet
  788. void InstallHierarchyFrame( wxDC* DC, wxPoint& pos );
  789. SCH_SHEET* CreateSheet( wxDC* DC );
  790. void ReSizeSheet( SCH_SHEET* Sheet, wxDC* DC );
  791. /// Loads the cache library associated to the aFileName
  792. bool LoadCacheLibrary( const wxString& aFileName );
  793. public:
  794. /**
  795. * Function EditSheet
  796. * is used to edit an existing sheet or add a new sheet to the schematic.
  797. * <p>
  798. * When \a aSheet is a new sheet:
  799. * <ul>
  800. * <li>and the file name already exists in the schematic hierarchy, the screen associated
  801. * with the sheet found in the hierarchy is associated with \a aSheet.</li>
  802. * <li>and the file name already exists on the system, then \a aSheet is loaded with the
  803. * existing file.</li>
  804. * <li>and the file name does not exist in the schematic hierarchy or on the file system,
  805. * then a new screen is created and associated with \a aSheet.</li>
  806. * </ul> </p> <p>
  807. * When \a aSheet is an existing sheet:
  808. * <ul>
  809. * <li>and the file name already exists in the schematic hierarchy, the current associated
  810. * screen is replace by the one found in the hierarchy.</li>
  811. * <li>and the file name already exists on the system, the current associated screen file
  812. * name is changed and the file is loaded.</li>
  813. * <li>and the file name does not exist in the schematic hierarchy or on the file system,
  814. * the current associated screen file name is changed and saved to disk.</li>
  815. * </ul> </p>
  816. */
  817. bool EditSheet( SCH_SHEET* aSheet, wxDC* aDC );
  818. wxPoint GetLastSheetPinPosition() const { return m_lastSheetPinPosition; }
  819. private:
  820. void StartMoveSheet( SCH_SHEET* sheet, wxDC* DC );
  821. /**
  822. * Function CreateSheetPin
  823. * creates a new SCH_SHEET_PIN object and add it to \a aSheet at the current cursor position.
  824. * @param aSheet The sheet to add the new sheet pin to.
  825. * @param aDC The device context to draw on.
  826. * @return The new sheet pin object created or NULL if the task was aborted by the user.
  827. */
  828. SCH_SHEET_PIN* CreateSheetPin( SCH_SHEET* aSheet, wxDC* aDC );
  829. /**
  830. * Function EditSheetPin
  831. * displays the dialog for editing the parameters of \a aSheetPin.
  832. * @param aSheetPin The sheet pin item to edit.
  833. * @param aDC The device context to draw on.
  834. * @return The user response from the edit dialog.
  835. */
  836. int EditSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC );
  837. /**
  838. * Function ImportSheetPin
  839. * automatically creates a sheet pin from the hierarchical labels in the schematic
  840. * referenced by \a aSheet.
  841. * @param aSheet The sheet to import the new sheet pin to.
  842. * @param aDC The device context to draw on.
  843. * @return The new sheet pin object importd or NULL if the task was aborted by the user.
  844. */
  845. SCH_SHEET_PIN* ImportSheetPin( SCH_SHEET* aSheet, wxDC* aDC );
  846. public:
  847. /**
  848. * Function DeleteItem
  849. * removes \a aItem from the current screen and saves it in the undo list.
  850. * @param aItem The item to remove from the current screen.
  851. */
  852. void DeleteItem( SCH_ITEM* aItem );
  853. int GetLabelIncrement() const { return m_repeatLabelDelta; }
  854. private:
  855. /**
  856. * Function Load_Component
  857. * loads from a library and places a component.
  858. * if libname != "", search in lib "libname"
  859. * else search in all loaded libs
  860. */
  861. SCH_COMPONENT* Load_Component( wxDC* DC,
  862. const wxString& libname,
  863. wxArrayString& List,
  864. bool UseLibBrowser );
  865. /**
  866. * Function EditComponent
  867. * displays the edit component dialog to edit the parameters of \a aComponent.
  868. *
  869. * @param aComponent is a pointer to the SCH_COMPONENT object to be edited.
  870. */
  871. void EditComponent( SCH_COMPONENT* aComponent );
  872. public:
  873. /**
  874. * Function OrientComponent
  875. * rotates and mirrors a component.
  876. */
  877. void OrientComponent( COMPONENT_ORIENTATION_T aOrientation = CMP_NORMAL );
  878. private:
  879. void OnSelectUnit( wxCommandEvent& aEvent );
  880. void ConvertPart( SCH_COMPONENT* DrawComponent, wxDC* DC );
  881. void SetInitCmp( SCH_COMPONENT* DrawComponent, wxDC* DC );
  882. /**
  883. * Function EditComponentFieldText
  884. * displays the edit field dialog to edit the parameters of \a aField.
  885. *
  886. * @param aField is a pointer to the SCH_FIELD object to be edited.
  887. */
  888. void EditComponentFieldText( SCH_FIELD* aField );
  889. void RotateField( SCH_FIELD* aField, wxDC* aDC );
  890. /**
  891. * Function PastListOfItems
  892. * pastes a list of items from the block stack.
  893. */
  894. void PasteListOfItems( wxDC* DC );
  895. /* Undo - redo */
  896. public:
  897. /**
  898. * Function SaveCopyInUndoList.
  899. * Create a copy of the current schematic item, and put it in the undo list.
  900. *
  901. * flag_type_command =
  902. * UR_CHANGED
  903. * UR_NEW
  904. * UR_DELETED
  905. * UR_WIRE_IMAGE
  906. * UR_MOVED
  907. *
  908. * If it is a delete command, items are put on list with the .Flags member
  909. * set to UR_DELETED. When it will be really deleted, the GetDrawItems() and the
  910. * sub-hierarchy will be deleted. If it is only a copy, the GetDrawItems() and the
  911. * sub-hierarchy must NOT be deleted.
  912. *
  913. * @note
  914. * Edit wires and buses is a bit complex.
  915. * because when a new wire is added, a lot of modifications in wire list is made
  916. * (wire concatenation): modified items, deleted items and new items
  917. * so flag_type_command is UR_WIRE_IMAGE: the struct ItemToCopy is a list of
  918. * wires saved in Undo List (for Undo or Redo commands, saved wires will be
  919. * exchanged with current wire list
  920. * @param aItemToCopy = the schematic item modified by the command to undo
  921. * @param aTypeCommand = command type (see enum UNDO_REDO_T)
  922. * @param aTransformPoint = the reference point of the transformation,
  923. * for commands like move
  924. */
  925. void SaveCopyInUndoList( SCH_ITEM* aItemToCopy,
  926. UNDO_REDO_T aTypeCommand,
  927. const wxPoint& aTransformPoint = wxPoint( 0, 0 ) );
  928. /**
  929. * Function SaveCopyInUndoList (overloaded).
  930. * Creates a new entry in undo list of commands.
  931. * add a list of pickers to handle a list of items
  932. * @param aItemsList = the list of items modified by the command to undo
  933. * @param aTypeCommand = command type (see enum UNDO_REDO_T)
  934. * @param aTransformPoint = the reference point of the transformation,
  935. * for commands like move
  936. */
  937. void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
  938. UNDO_REDO_T aTypeCommand,
  939. const wxPoint& aTransformPoint = wxPoint( 0, 0 ) );
  940. private:
  941. /**
  942. * Function PutDataInPreviousState
  943. * is used in undo or redo command to put data pointed by List in the previous state, i.e.
  944. * the state stored in \a aList
  945. * @param aList a PICKED_ITEMS_LIST pointer to the list of items to undo/redo
  946. * @param aRedoCommand a bool: true for redo, false for undo
  947. */
  948. void PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRedoCommand );
  949. /**
  950. * Function GetSchematicFromRedoList
  951. * Redo the last edition:
  952. * - Save the current schematic in Undo list
  953. * - Get an old version of the schematic from Redo list
  954. * @return none
  955. */
  956. void GetSchematicFromRedoList( wxCommandEvent& event );
  957. /**
  958. * Function GetSchematicFromUndoList
  959. * performs an undo the last edition:
  960. * - Save the current schematic in Redo list
  961. * - Get an old version of the schematic from Undo list
  962. */
  963. void GetSchematicFromUndoList( wxCommandEvent& event );
  964. /**
  965. * Function copyBlockItems
  966. * copies the list of block item.
  967. * @sa m_blockItems
  968. * @param aItemsList List to copy the block select items into.
  969. */
  970. void copyBlockItems( PICKED_ITEMS_LIST& aItemsList );
  971. /**
  972. * Function addJunctionMenuEntries
  973. * adds the context menu items to \a aMenu for \a aJunction.
  974. * @param aMenu The menu to add the items to.
  975. * @param aJunction The SCH_JUNCTION object selected.
  976. */
  977. void addJunctionMenuEntries( wxMenu* aMenu, SCH_JUNCTION* aJunction );
  978. public:
  979. void Key( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct );
  980. /**
  981. * Function InitBlockPasteInfos
  982. * initializes the parameters used by the block paste command.
  983. */
  984. void InitBlockPasteInfos();
  985. /* Function HandleBlockEndByPopUp
  986. * performs an end block command from context menu.
  987. *
  988. * This can be called only after HandleBlockEnd and the current command is block
  989. * move. Execute a command other than block move from the current block move
  990. * selected items list. Due to (minor) problems in undo/redo or/and display block,
  991. * a mirror/rotate command is immediately executed and multiple block commands are
  992. * not allowed (multiple commands are tricky to undo/redo in one time)
  993. */
  994. void HandleBlockEndByPopUp( int Command, wxDC* DC );
  995. /**
  996. * Function ReturnBlockCommand
  997. * Returns the block command internat code (BLOCK_MOVE, BLOCK_COPY...)
  998. * corresponding to the keys pressed (ALT, SHIFT, SHIFT ALT ..) when
  999. * block command is started by dragging the mouse.
  1000. * @param aKey = the key modifiers (Alt, Shift ...)
  1001. * @return the block command id (BLOCK_MOVE, BLOCK_COPY...)
  1002. */
  1003. virtual int ReturnBlockCommand( int aKey );
  1004. /**
  1005. * Function HandleBlockPlace
  1006. * Called after HandleBlockEnd, when a block command needs to be
  1007. * executed after the block is moved to its new place
  1008. * (bloc move, drag, copy .. )
  1009. * Parameters must be initialized in GetScreen()->m_BlockLocate
  1010. */
  1011. virtual void HandleBlockPlace( wxDC* DC );
  1012. /**
  1013. * Function HandleBlockEnd
  1014. * Handle the "end" of a block command,
  1015. * i.e. is called at the end of the definition of the area of a block.
  1016. * depending on the current block command, this command is executed
  1017. * or parameters are initialized to prepare a call to HandleBlockPlace
  1018. * in GetScreen()->m_BlockLocate
  1019. * @return false if no item selected, or command finished,
  1020. * true if some items found and HandleBlockPlace must be called later
  1021. */
  1022. virtual bool HandleBlockEnd( wxDC* DC );
  1023. /**
  1024. * Function RepeatDrawItem
  1025. * repeats the last item placement if the last item was a bus, bus entry,
  1026. * label, or component.
  1027. *
  1028. * Labels that end with a number will be incremented.
  1029. */
  1030. void RepeatDrawItem( wxDC* DC );
  1031. /**
  1032. * Function SetRepeatItem
  1033. * clones aItem and owns that clone in this container.
  1034. */
  1035. void SetRepeatItem( SCH_ITEM* aItem );
  1036. /**
  1037. * Function GetRepeatItem
  1038. * returns the item which is to be repeated with the insert key. Such object
  1039. * is owned by this container, and must be cloned.
  1040. */
  1041. SCH_ITEM* GetRepeatItem() const { return m_item_to_repeat; }
  1042. /**
  1043. * Function SetUndoItem
  1044. * clones \a aItem which can be used to restore the state of the item being edited
  1045. * when the user cancels the editing in progress.
  1046. *
  1047. * @param aItem The item to make a clone of for undoing the last change. Set to
  1048. * NULL to free the current undo item.
  1049. */
  1050. void SetUndoItem( const SCH_ITEM* aItem );
  1051. SCH_ITEM* GetUndoItem() const { return m_undoItem; }
  1052. /**
  1053. * Function SaveUndoItemInUndoList
  1054. * swaps the cloned item in member variable m_undoItem with \a aItem and saves it to
  1055. * the undo list then swap the data back. This swaps the internal structure of the
  1056. * item with the cloned item. It does not swap the actual item pointers themselves.
  1057. *
  1058. * @param aItem The item to swap with the current undo item.
  1059. */
  1060. void SaveUndoItemInUndoList( SCH_ITEM* aItem );
  1061. /**
  1062. * Function LoadLibraries
  1063. *
  1064. * Clear all libraries currently loaded and load all of the project libraries.
  1065. */
  1066. void LoadLibraries( void );
  1067. /**
  1068. * Function CreateArchiveLibraryCacheFile
  1069. * creates a library file with the name of the root document plus the '-cache' suffix,
  1070. * That file will contain all components used in the current schematic.
  1071. *
  1072. * @param aUseCurrentSheetFilename = false to use the root shhet filename
  1073. * (default) or true to use the currently opened sheet.
  1074. * @return true if the file was written successfully.
  1075. */
  1076. bool CreateArchiveLibraryCacheFile( bool aUseCurrentSheetFilename = false );
  1077. /**
  1078. * Function CreateArchiveLibrary
  1079. * creates a library \a aFileName that contains all components used in the current schematic.
  1080. *
  1081. * @param aFileName The full path and file name of the archive library.
  1082. * @return True if \a aFileName was written successfully.
  1083. */
  1084. bool CreateArchiveLibrary( const wxString& aFileName );
  1085. /**
  1086. * Function PrintPage
  1087. * plots or prints the current sheet to the clipboard.
  1088. * @param aDC = wxDC given by the calling print function
  1089. * @param aPrintMask = not used here
  1090. * @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
  1091. * @param aData = a pointer on an auxiliary data (not always used, NULL if not used)
  1092. */
  1093. virtual void PrintPage( wxDC* aDC, LAYER_MSK aPrintMask,
  1094. bool aPrintMirrorMode, void* aData = NULL );
  1095. void SetSimulatorCommand( const wxString& aCommand ) { m_simulatorCommand = aCommand; }
  1096. wxString GetSimulatorCommand() const { return m_simulatorCommand; }
  1097. void SetNetListerCommand( const wxString& aCommand ) { m_netListerCommand = aCommand; }
  1098. wxString GetNetListerCommand() const { return m_netListerCommand; }
  1099. DECLARE_EVENT_TABLE()
  1100. };
  1101. #endif // WX_EESCHEMA_STRUCT_H