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.

671 lines
22 KiB

* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
11 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2008-2014 Wayne Stambaugh <stambaughw@verizon.net>
  6. * Copyright (C) 2004-2014 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 libeditframe.h
  27. * @brief Definition of class LIB_EDIT_FRAME
  28. */
  29. #ifndef LIBEDITFRM_H_
  30. #define LIBEDITFRM_H_
  31. #include <sch_base_frame.h>
  32. #include <class_sch_screen.h>
  33. #include <lib_draw_item.h>
  34. #include <lib_collectors.h>
  35. class SCH_EDIT_FRAME;
  36. class PART_LIB;
  37. class LIB_PART;
  38. class LIB_ALIAS;
  39. class LIB_FIELD;
  40. class DIALOG_LIB_EDIT_TEXT;
  41. /**
  42. * The component library editor main window.
  43. */
  44. class LIB_EDIT_FRAME : public SCH_BASE_FRAME
  45. {
  46. LIB_PART* m_my_part; ///< a part I own, it is not in any library, but a copy could be.
  47. LIB_PART* m_tempCopyComponent; ///< temp copy of a part during edit, I own it here.
  48. LIB_COLLECTOR m_collectedItems; ///< Used for hit testing.
  49. wxComboBox* m_partSelectBox; ///< a Box to select a part to edit (if any)
  50. wxComboBox* m_aliasSelectBox; ///< a box to select the alias to edit (if any)
  51. wxString m_configPath;
  52. wxString m_lastLibImportPath;
  53. wxString m_lastLibExportPath;
  54. /** Convert of the item currently being drawn. */
  55. bool m_drawSpecificConvert;
  56. /**
  57. * Specify which component parts the current draw item applies to.
  58. *
  59. * If true, the item being drawn or edited applies only to the selected
  60. * part. Otherwise it applies to all parts in the component.
  61. */
  62. bool m_drawSpecificUnit;
  63. /**
  64. * Set to true to not synchronize pins at the same position when editing
  65. * components with multiple parts or multiple body styles. Setting this
  66. * to false allows editing each pin per part or body style individually.
  67. * This requires the user to open each part or body style to make changes
  68. * to the pin at the same location.
  69. */
  70. bool m_editPinsPerPartOrConvert;
  71. /** The current draw or edit graphic item fill style. */
  72. static FILL_T m_drawFillStyle;
  73. /** Default line width for drawing or editing graphic items. */
  74. static int m_drawLineWidth;
  75. static LIB_ITEM* m_lastDrawItem;
  76. static LIB_ITEM* m_drawItem;
  77. static wxString m_aliasName;
  78. // The unit number to edit and show
  79. static int m_unit;
  80. // Show the normal shape ( m_convert <= 1 ) or the converted shape
  81. // ( m_convert > 1 )
  82. static int m_convert;
  83. // true to force DeMorgan/normal tools selection enabled.
  84. // They are enabled when the loaded component has
  85. // Graphic items for converted shape
  86. // But under some circumstances (New component created)
  87. // these tools must left enabled
  88. static bool m_showDeMorgan;
  89. /// The current text size setting.
  90. static int m_textSize;
  91. /// Current text orientation setting.
  92. static int m_textOrientation;
  93. /// The default pin num text size setting.
  94. static int m_textPinNumDefaultSize;
  95. /// The default pin name text size setting.
  96. static int m_textPinNameDefaultSize;
  97. /// Default pin length
  98. static int m_defaultPinLength;
  99. static wxSize m_clientSize;
  100. friend class DIALOG_LIB_EDIT_TEXT;
  101. LIB_ITEM* locateItem( const wxPoint& aPosition, const KICAD_T aFilterList[] );
  102. public:
  103. LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent );
  104. ~LIB_EDIT_FRAME();
  105. /**
  106. * Function GetLibEditFrameName (static)
  107. * @return the frame name used when creating the frame
  108. * used to get a reference to this frame, if exists
  109. */
  110. static const wxChar* GetLibEditFrameName();
  111. /** The current library being edited, or NULL if none. */
  112. PART_LIB* GetCurLib();
  113. /** Sets the current library and return the old. */
  114. PART_LIB* SetCurLib( PART_LIB* aLib );
  115. /**
  116. * Function GetCurPart
  117. * returns the current part being edited, or NULL if none selected.
  118. * This is a LIB_PART that I own, it is at best a copy of one in a library.
  119. */
  120. LIB_PART* GetCurPart();
  121. /**
  122. * Function SetCurPart
  123. * takes ownership over aPart and notes that it is the one currently
  124. * being edited.
  125. */
  126. void SetCurPart( LIB_PART* aPart );
  127. /** @return the default pin num text size.
  128. */
  129. static int GetPinNumDefaultSize() { return m_textPinNumDefaultSize; }
  130. /** @return The default pin name text size setting.
  131. */
  132. static int GetPinNameDefaultSize() { return m_textPinNameDefaultSize; }
  133. /** @return The default pin len setting.
  134. */
  135. static int GetDefaultPinLength() { return m_defaultPinLength; }
  136. /** Set the default pin len.
  137. */
  138. static void SetDefaultPinLength( int aLength ) { m_defaultPinLength = aLength; }
  139. void ReCreateMenuBar();
  140. /**
  141. * Function EnsureActiveLibExists
  142. * must be called after the libraries are reloaded
  143. * (for instance after loading a schematic project)
  144. */
  145. static void EnsureActiveLibExists();
  146. void InstallConfigFrame( wxCommandEvent& event );
  147. void InstallDimensionsDialog( wxCommandEvent& event );
  148. void OnColorConfig( wxCommandEvent& aEvent );
  149. void OnPreferencesOptions( wxCommandEvent& event );
  150. void Process_Config( wxCommandEvent& event );
  151. /**
  152. * Function SycnronizePins
  153. * @return True if the edit pins per part or convert is false and the current
  154. * component has multiple parts or body styles. Otherwise false is
  155. * returned.
  156. */
  157. bool SynchronizePins();
  158. /**
  159. * Function OnPlotCurrentComponent
  160. * plot the current component in SVG or PNG format.
  161. */
  162. void OnPlotCurrentComponent( wxCommandEvent& event );
  163. void Process_Special_Functions( wxCommandEvent& event );
  164. void OnSelectTool( wxCommandEvent& aEvent );
  165. /**
  166. * Routine to read one part.
  167. * The format is that of libraries, but it loads only 1 component.
  168. * Or 1 component if there are several.
  169. * If the first component is an alias, it will load the corresponding root.
  170. */
  171. void OnImportPart( wxCommandEvent& event );
  172. /**
  173. * Function OnExportPart
  174. * creates a new library and backup the current component in this library or export
  175. * the component of the current library.
  176. */
  177. void OnExportPart( wxCommandEvent& event );
  178. void OnSelectAlias( wxCommandEvent& event );
  179. void OnSelectPart( wxCommandEvent& event );
  180. /**
  181. * Function DeleteOnePart
  182. * is the command event handler to delete an entry from the current library.
  183. *
  184. * The deleted entry can be an alias or a component. If the entry is an alias,
  185. * it is removed from the component and the list of alias is updated. If the
  186. * entry is a component and the list of aliases is empty, the component and all
  187. * it drawable items are deleted. Otherwise the first alias in the alias list
  188. * becomes the new component name and the other aliases become dependent on
  189. * renamed component.
  190. *
  191. * @note This only deletes the entry in memory. The file does not change.
  192. */
  193. void DeleteOnePart( wxCommandEvent& event );
  194. /**
  195. * Function CreateNewLibraryPart
  196. * is the command event handler to create a new library component.
  197. *
  198. * If an old component is currently in edit, it is deleted.
  199. */
  200. void CreateNewLibraryPart( wxCommandEvent& event );
  201. void OnCreateNewPartFromExisting( wxCommandEvent& event );
  202. void OnEditComponentProperties( wxCommandEvent& event );
  203. void InstallFieldsEditorDialog( wxCommandEvent& event );
  204. /**
  205. * Function LoadOneLibraryPart
  206. * loads a library component from the currently selected library.
  207. *
  208. * If a library is already selected, the user is prompted for the component name
  209. * to load. If there is no current selected library, the user is prompted to select
  210. * a library name and then select component to load.
  211. */
  212. void LoadOneLibraryPart( wxCommandEvent& event );
  213. void OnViewEntryDoc( wxCommandEvent& event );
  214. void OnCheckComponent( wxCommandEvent& event );
  215. void OnSelectBodyStyle( wxCommandEvent& event );
  216. void OnEditPin( wxCommandEvent& event );
  217. void OnSelectItem( wxCommandEvent& aEvent );
  218. void OnOpenPinTable( wxCommandEvent& aEvent );
  219. void OnUpdateSelectTool( wxUpdateUIEvent& aEvent );
  220. void OnUpdateEditingPart( wxUpdateUIEvent& event );
  221. void OnUpdateNotEditingPart( wxUpdateUIEvent& event );
  222. void OnUpdateUndo( wxUpdateUIEvent& event );
  223. void OnUpdateRedo( wxUpdateUIEvent& event );
  224. void OnUpdateSaveCurrentLib( wxUpdateUIEvent& event );
  225. void OnUpdateViewDoc( wxUpdateUIEvent& event );
  226. void OnUpdatePinByPin( wxUpdateUIEvent& event );
  227. void OnUpdatePinTable( wxUpdateUIEvent& event );
  228. void OnUpdatePartNumber( wxUpdateUIEvent& event );
  229. void OnUpdateDeMorganNormal( wxUpdateUIEvent& event );
  230. void OnUpdateDeMorganConvert( wxUpdateUIEvent& event );
  231. void OnUpdateSelectAlias( wxUpdateUIEvent& event );
  232. void UpdateAliasSelectList();
  233. void UpdatePartSelectList();
  234. /**
  235. * Function DisplayLibInfos
  236. * updates the main window title bar with the current library name and read only status
  237. * of the library.
  238. */
  239. void DisplayLibInfos();
  240. /**
  241. * Function RedrawComponent
  242. * Redraw the current component loaded in library editor
  243. * Display reference like in schematic (a reference U is shown U? or U?A)
  244. * accordint to the current selected unit and De Morgan selection
  245. * although it is stored without ? and part id.
  246. * @param aDC = the current device context
  247. * @param aOffset = a draw offset. usually 0,0 to draw on the screen, but
  248. * can be set to page size / 2 to draw or print in SVG format.
  249. */
  250. void RedrawComponent( wxDC* aDC, wxPoint aOffset );
  251. /**
  252. * Function RedrawActiveWindow
  253. * Redraw the current component loaded in library editor, an axes
  254. * Display reference like in schematic (a reference U is shown U? or U?A)
  255. * update status bar and info shown in the bottom of the window
  256. */
  257. void RedrawActiveWindow( wxDC* DC, bool EraseBg );
  258. void OnCloseWindow( wxCloseEvent& Event );
  259. void ReCreateHToolbar();
  260. void ReCreateVToolbar();
  261. void CreateOptionToolbar();
  262. void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
  263. bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
  264. double BestZoom(); // Returns the best zoom
  265. void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
  266. bool OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem = NULL );
  267. bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 );
  268. void LoadSettings( wxConfigBase* aCfg );
  269. void SaveSettings( wxConfigBase* aCfg );
  270. /**
  271. * Function CloseWindow
  272. * triggers the wxCloseEvent, which is handled by the function given
  273. * to EVT_CLOSE() macro:
  274. * <p>
  275. * EVT_CLOSE( LIB_EDIT_FRAME::OnCloseWindow )
  276. */
  277. void CloseWindow( wxCommandEvent& event )
  278. {
  279. // Generate a wxCloseEvent
  280. Close( false );
  281. }
  282. /**
  283. * Function OnModify
  284. * Must be called after a schematic change
  285. * in order to set the "modify" flag of the current screen
  286. */
  287. void OnModify()
  288. {
  289. GetScreen()->SetModify();
  290. }
  291. const wxString& GetAliasName() { return m_aliasName; }
  292. int GetUnit() { return m_unit; }
  293. void SetUnit( int unit )
  294. {
  295. wxASSERT( unit >= 1 );
  296. m_unit = unit;
  297. }
  298. int GetConvert() { return m_convert; }
  299. void SetConvert( int convert )
  300. {
  301. wxASSERT( convert >= 0 );
  302. m_convert = convert;
  303. }
  304. LIB_ITEM* GetLastDrawItem() { return m_lastDrawItem; }
  305. void SetLastDrawItem( LIB_ITEM* drawItem )
  306. {
  307. m_lastDrawItem = drawItem;
  308. }
  309. LIB_ITEM* GetDrawItem() { return m_drawItem; }
  310. void SetDrawItem( LIB_ITEM* drawItem );
  311. bool GetShowDeMorgan() { return m_showDeMorgan; }
  312. void SetShowDeMorgan( bool show ) { m_showDeMorgan = show; }
  313. FILL_T GetFillStyle() { return m_drawFillStyle; }
  314. /**
  315. * Function TempCopyComponent
  316. * create a temporary copy of the current edited component
  317. * Used to prepare an Undo ant/or abort command before editing the component
  318. */
  319. void TempCopyComponent();
  320. /**
  321. * Function RestoreComponent
  322. * Restore the current edited component from its temporary copy.
  323. * Used to abort a command
  324. */
  325. void RestoreComponent();
  326. /**
  327. * Function GetTempCopyComponent
  328. * @return the temporary copy of the current component.
  329. */
  330. LIB_PART* GetTempCopyComponent() { return m_tempCopyComponent; }
  331. /**
  332. * Function ClearTempCopyComponent
  333. * delete temporary copy of the current component and clear pointer
  334. */
  335. void ClearTempCopyComponent();
  336. bool IsEditingDrawItem() { return m_drawItem && m_drawItem->InEditMode(); }
  337. private:
  338. /**
  339. * Function OnActivate
  340. * is called when the frame is activated. Tests if the current library exists.
  341. * The library list can be changed by the schematic editor after reloading a new schematic
  342. * and the current library can point a non existent lib.
  343. */
  344. virtual void OnActivate( wxActivateEvent& event );
  345. // General:
  346. /**
  347. * Function SaveOnePart
  348. * saves the current LIB_PART into the provided PART_LIB.
  349. *
  350. * Any changes are updated in memory only and NOT to a file. The old component is
  351. * deleted from the library and/or any aliases before the edited component is updated
  352. * in the library.
  353. * @param aLib - the part library where the part must be saved.
  354. * @param aPromptUser true to ask for confirmation, when the part_lib is already existing
  355. * in memory, false to save silently
  356. * @return true if the part was saved, false if aborted by user
  357. */
  358. bool SaveOnePart( PART_LIB* aLib, bool aPromptUser = true );
  359. /**
  360. * Function SelectActiveLibrary
  361. * sets the current active library to \a aLibrary.
  362. *
  363. * @param aLibrary A pointer to the PART_LIB object to select. If NULL, then display
  364. * list of available libraries to select from.
  365. */
  366. void SelectActiveLibrary( PART_LIB* aLibrary = NULL );
  367. /**
  368. * Function OnSaveActiveLibrary
  369. * it the command event handler to save the changes to the current library.
  370. *
  371. * A backup file of the current library is saved with the .bak extension before the
  372. * changes made to the library are saved.
  373. */
  374. void OnSaveActiveLibrary( wxCommandEvent& event );
  375. /**
  376. * Function SaveActiveLibrary
  377. * saves the changes to the current library.
  378. *
  379. * A backup file of the current library is saved with the .bak extension before the
  380. * changes made to the library are saved.
  381. * @param newFile Ask for a new file name to save the library.
  382. * @return True if the library was successfully saved.
  383. */
  384. bool SaveActiveLibrary( bool newFile );
  385. /**
  386. * Function LoadComponentFromCurrentLib
  387. * loads a component from the current active library.
  388. * @param aLibEntry The component to load from \a aLibrary (can be an alias)
  389. * @return true if \a aLibEntry loaded correctly.
  390. */
  391. bool LoadComponentFromCurrentLib( LIB_ALIAS* aLibEntry );
  392. /**
  393. * Function LoadOneLibraryPartAux
  394. * loads a copy of \a aLibEntry from \a aLibrary into memory.
  395. *
  396. * @param aLibEntry A pointer to the LIB_ALIAS object to load.
  397. * @param aLibrary A pointer to the PART_LIB object to load \a aLibEntry from.
  398. * @return True if a copy of \a aLibEntry was successfully loaded from \a aLibrary.
  399. */
  400. bool LoadOneLibraryPartAux( LIB_ALIAS* aLibEntry, PART_LIB* aLibrary );
  401. /**
  402. * Function DisplayCmpDoc
  403. * displays the documentation of the selected component.
  404. */
  405. void DisplayCmpDoc();
  406. /**
  407. * Function OnRotateItem
  408. * rotates the current item.
  409. */
  410. void OnRotateItem( wxCommandEvent& aEvent );
  411. /**
  412. * Function deleteItem
  413. * deletes the currently selected draw item.
  414. * @param aDC The device context to draw upon when removing item.
  415. */
  416. void deleteItem( wxDC* aDC );
  417. // General editing
  418. public:
  419. /**
  420. * Function SaveCopyInUndoList.
  421. * Create a copy of the current component, and save it in the undo list.
  422. * Because a component in library editor does not a lot of primitives,
  423. * the full data is duplicated. It is not worth to try to optimize this save funtion
  424. */
  425. void SaveCopyInUndoList( EDA_ITEM* ItemToCopy );
  426. private:
  427. void GetComponentFromUndoList( wxCommandEvent& event );
  428. void GetComponentFromRedoList( wxCommandEvent& event );
  429. // Editing pins
  430. void CreatePin( wxDC* DC );
  431. void StartMovePin( wxDC* DC );
  432. /**
  433. * Function CreateImagePins
  434. * adds copies of \a aPin for \a aUnit in components with multiple parts and
  435. * \a aConvert for components that have multiple body styles.
  436. *
  437. * @param aPin The pin to copy.
  438. * @param aUnit The unit to add a copy of \a aPin to.
  439. * @param aConvert The alternate body style to add a copy of \a aPin to.
  440. * @param aDeMorgan Flag to indicate if \a aPin should be created for the
  441. * alternate body style.
  442. */
  443. void CreateImagePins( LIB_PIN* aPin, int aUnit, int aConvert, bool aDeMorgan );
  444. /**
  445. * Function PlaceAnchor
  446. * places an anchor reference coordinate for the current component.
  447. * <p>
  448. * All object coordinates are offset to the current cursor position.
  449. * </p>
  450. */
  451. void PlaceAnchor();
  452. // Editing graphic items
  453. LIB_ITEM* CreateGraphicItem( LIB_PART* LibEntry, wxDC* DC );
  454. void GraphicItemBeginDraw( wxDC* DC );
  455. void StartMoveDrawSymbol( wxDC* DC );
  456. void StartModifyDrawSymbol( wxDC* DC ); //<! Modify the item, adjust size etc.
  457. void EndDrawGraphicItem( wxDC* DC );
  458. /**
  459. * Function LoadOneSymbol
  460. * read a component symbol file (*.sym ) and add graphic items to the current component.
  461. * <p>
  462. * A symbol file *.sym has the same format as a library, and contains only
  463. * one symbol.
  464. * </p>
  465. */
  466. void LoadOneSymbol();
  467. /**
  468. * Function SaveOneSymbol
  469. * saves the current component to a symbol file.
  470. * <p>
  471. * The symbol file format is similar to the standard component library file format, but
  472. * there is only one symbol. Invisible pins are not saved.
  473. */
  474. void SaveOneSymbol();
  475. void EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem );
  476. void EditSymbolText( wxDC* DC, LIB_ITEM* DrawItem );
  477. LIB_ITEM* LocateItemUsingCursor( const wxPoint& aPosition,
  478. const KICAD_T aFilterList[] = LIB_COLLECTOR::AllItems );
  479. void EditField( LIB_FIELD* Field );
  480. public:
  481. /**
  482. * Function LoadComponentAndSelectLib
  483. * selects the current active library.
  484. *
  485. * @param aLibrary The PART_LIB to select
  486. * @param aLibEntry The component to load from aLibrary (can be an alias).
  487. * @return true if \a aLibEntry was loaded from \a aLibrary.
  488. */
  489. bool LoadComponentAndSelectLib( LIB_ALIAS* aLibEntry, PART_LIB* aLibrary );
  490. /* Block commands: */
  491. /**
  492. * Function BlockCommand
  493. * returns the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
  494. * the \a aKey (ALT, SHIFT ALT ..)
  495. */
  496. virtual int BlockCommand( int aKey );
  497. /**
  498. * Function HandleBlockPlace
  499. * handles the block place command.
  500. */
  501. virtual void HandleBlockPlace( wxDC* DC );
  502. /**
  503. * Function HandleBlockEnd
  504. * performs a block end command.
  505. * @return If command finished (zoom, delete ...) false is returned otherwise true
  506. * is returned indicating more processing is required.
  507. */
  508. virtual bool HandleBlockEnd( wxDC* DC );
  509. /**
  510. * Function PlacePin
  511. * Place at cursor location the pin currently moved (i.e. pin pointed by m_drawItem)
  512. * (and the linked pins, if any)
  513. */
  514. void PlacePin();
  515. /**
  516. * Function GlobalSetPins
  517. * @param aMasterPin is the "template" pin
  518. * @param aId is a param to select what should be mofified:
  519. * - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM:
  520. * Change pins text name size
  521. * - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM:
  522. * Change pins text num size
  523. * - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM:
  524. * Change pins length.
  525. *
  526. * If aMasterPin is selected ( .m_flag == IS_SELECTED ),
  527. * only the other selected pins are modified
  528. */
  529. void GlobalSetPins( LIB_PIN* aMasterPin, int aId );
  530. // Automatic placement of pins
  531. void RepeatPinItem( wxDC* DC, LIB_PIN* Pin );
  532. /**
  533. * Function CreatePNGorJPEGFile
  534. * creates an image (screenshot) of the current component in PNG or JPEG format.
  535. * @param aFileName = the full filename
  536. * @param aFmt_jpeg = true to use JPEG file format, false to use PNG file format
  537. */
  538. void CreatePNGorJPEGFile( const wxString& aFileName, bool aFmt_jpeg );
  539. /**
  540. * Virtual function PrintPage
  541. * used to print a page
  542. * @param aDC = wxDC given by the calling print function
  543. * @param aPrintMask = not used here
  544. * @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
  545. * @param aData = a pointer on an auxiliary data (not always used, NULL if not used)
  546. */
  547. virtual void PrintPage( wxDC* aDC, LSET aPrintMask,
  548. bool aPrintMirrorMode, void* aData = NULL );
  549. /**
  550. * Function SVG_PlotComponent
  551. * Creates the SVG print file for the current edited component.
  552. * @param aFullFileName = the full filename
  553. */
  554. void SVG_PlotComponent( const wxString& aFullFileName );
  555. DECLARE_EVENT_TABLE()
  556. };
  557. #endif // LIBEDITFRM_H_