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.

679 lines
28 KiB

18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
16 years ago
16 years ago
++PCBNew * Removed Pcb_Frame argument from BOARD() constructor, since it precludes having a BOARD being edited by more than one editor, it was a bad design. And this meant removing m_PcbFrame from BOARD. * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed, such as dialog_mask_clearance, dialog_drc, etc. * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it with build_version.h's #define BOARD_FILE_VERSION, although there may be a better place for this constant. * Made the public functions in PARAM_CFG_ARRAY be type const. void SaveParam(..) const and void ReadParam(..) const * PARAM_CFG_BASE now has virtual destructor since we have various way of destroying the derived class and boost::ptr_vector must be told about this. * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use an automatic PARAM_CFG_ARRAY which is on the stack.\ * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array, since it has to access the current BOARD and the BOARD can change. Remember BOARD_DESIGN_SETTINGS are now in the BOARD. * Made the m_BoundingBox member private, this was a brutally hard task, and indicative of the lack of commitment to accessors and object oriented design on the part of KiCad developers. We must do better. Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox(). * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
14 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
15 years ago
  1. /**
  2. * @file eeschema_config.cpp
  3. */
  4. #include "fctsys.h"
  5. #include "appl_wxstruct.h"
  6. #include "class_drawpanel.h"
  7. #include "confirm.h"
  8. #include "gestfich.h"
  9. #include "wxEeschemaStruct.h"
  10. #include "eeschema_id.h"
  11. #include "general.h"
  12. #include "netlist_control.h"
  13. #include "protos.h"
  14. #include "libeditframe.h"
  15. #include "eeschema_config.h"
  16. #include "worksheet.h"
  17. #include "hotkeys.h"
  18. #include "sch_sheet.h"
  19. #include "dialog_hotkeys_editor.h"
  20. #include "dialogs/dialog_color_config.h"
  21. #include "dialogs/dialog_eeschema_config.h"
  22. #include "dialogs/dialog_eeschema_options.h"
  23. #include <wx/fdrepdlg.h>
  24. #define HOTKEY_FILENAME wxT( "eeschema" )
  25. #define FR_HISTORY_LIST_CNT 10 ///< Maximum number of find and replace strings.
  26. void LIB_EDIT_FRAME::InstallConfigFrame( wxCommandEvent& event )
  27. {
  28. DIALOG_EESCHEMA_CONFIG CfgFrame( (SCH_EDIT_FRAME *)GetParent(), this );
  29. CfgFrame.ShowModal();
  30. }
  31. void LIB_EDIT_FRAME::OnColorConfig( wxCommandEvent& aEvent )
  32. {
  33. DIALOG_COLOR_CONFIG dlg( this );
  34. dlg.ShowModal();
  35. }
  36. void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
  37. {
  38. int id = event.GetId();
  39. wxFileName fn;
  40. SCH_EDIT_FRAME* schFrame = ( SCH_EDIT_FRAME* ) GetParent();
  41. switch( id )
  42. {
  43. case ID_CONFIG_SAVE:
  44. schFrame->SaveProjectFile();
  45. break;
  46. case ID_CONFIG_READ:
  47. {
  48. fn = g_RootSheet->GetScreen()->GetFileName();
  49. fn.SetExt( ProjectFileExtension );
  50. wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(),
  51. fn.GetFullName(), ProjectFileWildcard,
  52. wxFD_OPEN | wxFD_FILE_MUST_EXIST );
  53. if( dlg.ShowModal() == wxID_CANCEL )
  54. break;
  55. schFrame->LoadProjectFile( dlg.GetPath(), true );
  56. }
  57. break;
  58. /* Hotkey IDs */
  59. case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
  60. InstallHotkeyFrame( this, s_Eeschema_Hokeys_Descr );
  61. break;
  62. case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG:
  63. ExportHotkeyConfigToFile( s_Eeschema_Hokeys_Descr );
  64. break;
  65. case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG:
  66. ImportHotkeyConfigFromFile( s_Eeschema_Hokeys_Descr );
  67. break;
  68. case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
  69. // Display current hotkey list for LibEdit.
  70. DisplayHotkeyList( this, s_Libedit_Hokeys_Descr );
  71. break;
  72. default:
  73. DisplayError( this, wxT( "LIB_EDIT_FRAME::Process_Config error" ) );
  74. }
  75. }
  76. void SCH_EDIT_FRAME::OnColorConfig( wxCommandEvent& aEvent )
  77. {
  78. DIALOG_COLOR_CONFIG dlg( this );
  79. dlg.ShowModal();
  80. }
  81. void SCH_EDIT_FRAME::InstallConfigFrame( wxCommandEvent& event )
  82. {
  83. DIALOG_EESCHEMA_CONFIG CfgFrame( this, this );
  84. CfgFrame.ShowModal();
  85. }
  86. void SCH_EDIT_FRAME::Process_Config( wxCommandEvent& event )
  87. {
  88. int id = event.GetId();
  89. wxFileName fn;
  90. switch( id )
  91. {
  92. case ID_CONFIG_SAVE:
  93. SaveProjectFile();
  94. break;
  95. case ID_CONFIG_READ:
  96. {
  97. fn = g_RootSheet->GetScreen()->GetFileName();
  98. fn.SetExt( ProjectFileExtension );
  99. wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(),
  100. fn.GetFullName(), ProjectFileWildcard,
  101. wxFD_OPEN | wxFD_FILE_MUST_EXIST );
  102. if( dlg.ShowModal() == wxID_CANCEL )
  103. break;
  104. LoadProjectFile( dlg.GetPath(), true );
  105. }
  106. break;
  107. /* Hotkey IDs */
  108. case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG:
  109. ExportHotkeyConfigToFile( s_Eeschema_Hokeys_Descr );
  110. break;
  111. case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG:
  112. ImportHotkeyConfigFromFile( s_Eeschema_Hokeys_Descr );
  113. break;
  114. case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
  115. InstallHotkeyFrame( this, s_Eeschema_Hokeys_Descr );
  116. break;
  117. case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
  118. // Display current hotkey list for eeschema.
  119. DisplayHotkeyList( this, s_Schematic_Hokeys_Descr );
  120. break;
  121. default:
  122. DisplayError( this, wxT( "SCH_EDIT_FRAME::Process_Config error" ) );
  123. }
  124. }
  125. void SCH_EDIT_FRAME::OnSetOptions( wxCommandEvent& event )
  126. {
  127. wxArrayString units;
  128. GRIDS grid_list;
  129. GetScreen()->GetGrids( grid_list );
  130. DIALOG_EESCHEMA_OPTIONS dlg( this );
  131. units.Add( GetUnitsLabel( INCHES ) );
  132. units.Add( GetUnitsLabel( MILLIMETRES ) );
  133. dlg.SetUnits( units, g_UserUnit );
  134. dlg.SetGridSizes( grid_list, GetScreen()->GetGridId() );
  135. dlg.SetLineWidth( g_DrawDefaultLineThickness );
  136. dlg.SetTextSize( g_DefaultTextLabelSize );
  137. dlg.SetRepeatHorizontal( g_RepeatStep.x );
  138. dlg.SetRepeatVertical( g_RepeatStep.y );
  139. dlg.SetRepeatLabel( g_RepeatDeltaLabel );
  140. dlg.SetAutoSaveInterval( GetAutoSaveInterval() / 60 );
  141. dlg.SetShowGrid( IsGridVisible() );
  142. dlg.SetShowHiddenPins( m_ShowAllPins );
  143. dlg.SetEnableAutoPan( DrawPanel->m_AutoPAN_Enable );
  144. dlg.SetEnableHVBusOrientation( g_HVLines );
  145. dlg.SetShowPageLimits( g_ShowPageLimits );
  146. dlg.Layout();
  147. dlg.Fit();
  148. dlg.SetMinSize( dlg.GetSize() );
  149. const TEMPLATE_FIELDNAMES& tfnames = m_TemplateFieldNames.GetTemplateFieldNames();
  150. for( unsigned i=0; i<tfnames.size(); ++i )
  151. {
  152. D(printf("dlg.SetFieldName(%d, '%s')\n", i, TO_UTF8( tfnames[i].m_Name) );)
  153. dlg.SetFieldName( i, tfnames[i].m_Name );
  154. }
  155. if( dlg.ShowModal() == wxID_CANCEL )
  156. return;
  157. g_UserUnit = (EDA_UNITS_T)dlg.GetUnitsSelection();
  158. GetScreen()->SetGrid( grid_list[ (size_t) dlg.GetGridSelection() ].m_Size );
  159. g_DrawDefaultLineThickness = dlg.GetLineWidth();
  160. g_DefaultTextLabelSize = dlg.GetTextSize();
  161. g_RepeatStep.x = dlg.GetRepeatHorizontal();
  162. g_RepeatStep.y = dlg.GetRepeatVertical();
  163. g_RepeatDeltaLabel = dlg.GetRepeatLabel();
  164. SetAutoSaveInterval( dlg.GetAutoSaveInterval() * 60 );
  165. SetGridVisibility( dlg.GetShowGrid() );
  166. m_ShowAllPins = dlg.GetShowHiddenPins();
  167. DrawPanel->m_AutoPAN_Enable = dlg.GetEnableAutoPan();
  168. g_HVLines = dlg.GetEnableHVBusOrientation();
  169. g_ShowPageLimits = dlg.GetShowPageLimits();
  170. wxString templateFieldName;
  171. // @todo this will change when the template field editor is redone to
  172. // look like the component field property editor, showing visibility and value also
  173. DeleteAllTemplateFieldNames();
  174. for( int i=0; i<8; ++i ) // no. fields in this dialog window
  175. {
  176. templateFieldName = dlg.GetFieldName( i );
  177. if( !templateFieldName.IsEmpty() )
  178. {
  179. TEMPLATE_FIELDNAME fld( dlg.GetFieldName( i ) );
  180. // @todo set visibility and value also from a better editor
  181. AddTemplateFieldName( fld );
  182. }
  183. }
  184. DrawPanel->Refresh( true );
  185. }
  186. PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetProjectFileParameters()
  187. {
  188. if( !m_projectFileParams.empty() )
  189. return m_projectFileParams;
  190. m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LibDir" ),
  191. &m_UserLibraryPath ) );
  192. m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ),
  193. &m_ComponentLibFiles,
  194. GROUPLIB ) );
  195. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "NetFmt" ),
  196. &m_NetlistFormat,
  197. NET_TYPE_PCBNEW,
  198. NET_TYPE_PCBNEW,
  199. NET_TYPE_CUSTOM_MAX ) );
  200. /* NOTE: Left as global until supporting code can be fixed. */
  201. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "HPGLSpd" ),
  202. &g_HPGL_Pen_Descr.m_Pen_Speed,
  203. 20, 2, 45 ) );
  204. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "HPGLDm" ),
  205. &g_HPGL_Pen_Descr.m_Pen_Diam,
  206. 15, 1, 150 ) );
  207. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "HPGLNum" ),
  208. &g_HPGL_Pen_Descr.m_Pen_Num,
  209. 1, 1, 8 ) );
  210. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offX_A4" ),
  211. &g_Sheet_A4.m_Offset.x ) );
  212. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offY_A4" ),
  213. &g_Sheet_A4.m_Offset.y ) );
  214. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offX_A3" ),
  215. &g_Sheet_A3.m_Offset.x ) );
  216. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offY_A3" ),
  217. &g_Sheet_A3.m_Offset.y ) );
  218. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offX_A2" ),
  219. &g_Sheet_A2.m_Offset.x ) );
  220. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offY_A2" ),
  221. &g_Sheet_A2.m_Offset.y ) );
  222. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offX_A1" ),
  223. &g_Sheet_A1.m_Offset.x ) );
  224. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offY_A1" ),
  225. &g_Sheet_A1.m_Offset.y ) );
  226. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offX_A0" ),
  227. &g_Sheet_A0.m_Offset.x ) );
  228. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offY_A0" ),
  229. &g_Sheet_A0.m_Offset.y ) );
  230. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offX_A" ),
  231. &g_Sheet_A.m_Offset.x ) );
  232. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offY_A" ),
  233. &g_Sheet_A.m_Offset.y ) );
  234. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offX_B" ),
  235. &g_Sheet_B.m_Offset.x ) );
  236. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offY_B" ),
  237. &g_Sheet_B.m_Offset.y ) );
  238. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offX_C" ),
  239. &g_Sheet_C.m_Offset.x ) );
  240. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offY_C" ),
  241. &g_Sheet_C.m_Offset.y ) );
  242. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offX_D" ),
  243. &g_Sheet_D.m_Offset.x ) );
  244. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offY_D" ),
  245. &g_Sheet_D.m_Offset.y ) );
  246. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offX_E" ),
  247. &g_Sheet_E.m_Offset.x ) );
  248. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offY_E" ),
  249. &g_Sheet_E.m_Offset.y ) );
  250. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "RptD_X" ),
  251. &g_RepeatStep.x,
  252. 0, -1000, +1000 ) );
  253. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "RptD_Y" ),
  254. &g_RepeatStep.y,
  255. 100, -1000, +1000 ) );
  256. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "RptLab" ),
  257. &g_RepeatDeltaLabel,
  258. 1, -10, +10 ) );
  259. m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "LabSize" ),
  260. &g_DefaultTextLabelSize,
  261. DEFAULT_SIZE_TEXT, 0,
  262. 1000 ) );
  263. return m_projectFileParams;
  264. }
  265. bool SCH_EDIT_FRAME::LoadProjectFile( const wxString& aFileName, bool aForceReread )
  266. {
  267. wxFileName fn;
  268. bool IsRead = true;
  269. wxArrayString liblist_tmp = m_ComponentLibFiles;
  270. if( aFileName.IsEmpty() )
  271. fn = g_RootSheet->GetScreen()->GetFileName();
  272. else
  273. fn = aFileName;
  274. m_ComponentLibFiles.Clear();
  275. /* Change the schematic file extension (.sch) to the project file
  276. * extension (.pro). */
  277. fn.SetExt( ProjectFileExtension );
  278. wxGetApp().RemoveLibraryPath( m_UserLibraryPath );
  279. if( !wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP,
  280. GetProjectFileParameters(),
  281. !aForceReread ) )
  282. {
  283. m_ComponentLibFiles = liblist_tmp;
  284. IsRead = false;
  285. }
  286. /* User library path takes precedent over default library search paths. */
  287. wxGetApp().InsertLibraryPath( m_UserLibraryPath, 1 );
  288. /* If the list is void, force loading the library "power.lib" that is
  289. * the "standard" library for power symbols.
  290. */
  291. if( m_ComponentLibFiles.GetCount() == 0 )
  292. m_ComponentLibFiles.Add( wxT( "power" ) );
  293. LoadLibraries();
  294. GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
  295. return IsRead;
  296. }
  297. void SCH_EDIT_FRAME::SaveProjectFile()
  298. {
  299. wxFileName fn;
  300. fn = g_RootSheet->GetScreen()->GetFileName(); /*ConfigFileName*/
  301. fn.SetExt( ProjectFileExtension );
  302. if( !IsWritable( fn ) )
  303. return;
  304. wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters() );
  305. }
  306. static const wxString DefaultDrawLineWidthEntry( wxT( "DefaultDrawLineWidth" ) );
  307. static const wxString ShowHiddenPinsEntry( wxT( "ShowHiddenPins" ) );
  308. static const wxString HorzVertLinesOnlyEntry( wxT( "HorizVertLinesOnly" ) );
  309. static const wxString PreviewFramePositionXEntry( wxT( "PreviewFramePositionX" ) );
  310. static const wxString PreviewFramePositionYEntry( wxT( "PreviewFramePositionY" ) );
  311. static const wxString PreviewFrameWidthEntry( wxT( "PreviewFrameWidth" ) );
  312. static const wxString PreviewFrameHeightEntry( wxT( "PreviewFrameHeight" ) );
  313. static const wxString PrintDialogPositionXEntry( wxT( "PrintDialogPositionX" ) );
  314. static const wxString PrintDialogPositionYEntry( wxT( "PrintDialogPositionY" ) );
  315. static const wxString PrintDialogWidthEntry( wxT( "PrintDialogWidth" ) );
  316. static const wxString PrintDialogHeightEntry( wxT( "PrintDialogHeight" ) );
  317. static const wxString FindDialogPositionXEntry( wxT( "FindDialogPositionX" ) );
  318. static const wxString FindDialogPositionYEntry( wxT( "FindDialogPositionY" ) );
  319. static const wxString FindDialogWidthEntry( wxT( "FindDialogWidth" ) );
  320. static const wxString FindDialogHeightEntry( wxT( "FindDialogHeight" ) );
  321. static const wxString FindReplaceFlagsEntry( wxT( "LastFindReplaceFlags" ) );
  322. static const wxString FindStringEntry( wxT( "LastFindString" ) );
  323. static const wxString ReplaceStringEntry( wxT( "LastReplaceString" ) );
  324. static const wxString FindStringHistoryEntry( wxT( "FindStringHistoryList%d" ) );
  325. static const wxString ReplaceStringHistoryEntry( wxT( "ReplaceStringHistoryList%d" ) );
  326. static const wxString FieldNamesEntry( wxT( "FieldNames" ) );
  327. static const wxString SpiceNetNamesEntry( wxT( "SpiceUseNetNames" ) );
  328. static const wxString SimulatorCommandEntry( wxT( "SimCmdLine" ) );
  329. PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetConfigurationSettings( void )
  330. {
  331. if( !m_configSettings.empty() )
  332. return m_configSettings;
  333. m_configSettings.push_back( new PARAM_CFG_INT( wxT( "Unite" ),
  334. (int*)&g_UserUnit, 0 ) );
  335. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColWire" ),
  336. &g_LayerDescr.LayerColor[LAYER_WIRE],
  337. GREEN ) );
  338. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBus" ),
  339. &g_LayerDescr.LayerColor[LAYER_BUS],
  340. BLUE ) );
  341. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorConn" ),
  342. &g_LayerDescr.LayerColor[LAYER_JUNCTION],
  343. GREEN ) );
  344. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLlab" ),
  345. &g_LayerDescr.LayerColor[LAYER_LOCLABEL],
  346. BLACK ) );
  347. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorHlab" ),
  348. &g_LayerDescr.LayerColor[LAYER_HIERLABEL],
  349. BROWN ) );
  350. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorGbllab" ),
  351. &g_LayerDescr.LayerColor[LAYER_GLOBLABEL],
  352. RED ) );
  353. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPinF" ),
  354. &g_LayerDescr.LayerColor[LAYER_PINFUN],
  355. MAGENTA ) );
  356. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColPinN" ),
  357. &g_LayerDescr.LayerColor[LAYER_PINNUM],
  358. RED ) );
  359. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPNam" ),
  360. &g_LayerDescr.LayerColor[LAYER_PINNAM],
  361. CYAN ) );
  362. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorField" ),
  363. &g_LayerDescr.LayerColor[LAYER_FIELDS],
  364. MAGENTA ) );
  365. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorRef" ),
  366. &g_LayerDescr.LayerColor[LAYER_REFERENCEPART],
  367. CYAN ) );
  368. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorValue" ),
  369. &g_LayerDescr.LayerColor[LAYER_VALUEPART],
  370. CYAN ) );
  371. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNote" ),
  372. &g_LayerDescr.LayerColor[LAYER_NOTES],
  373. LIGHTBLUE ) );
  374. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBody" ),
  375. &g_LayerDescr.LayerColor[LAYER_DEVICE],
  376. RED ) );
  377. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBodyBg" ),
  378. &g_LayerDescr.LayerColor[LAYER_DEVICE_BACKGROUND],
  379. LIGHTYELLOW ) );
  380. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNetN" ),
  381. &g_LayerDescr.LayerColor[LAYER_NETNAM],
  382. DARKGRAY ) );
  383. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPin" ),
  384. &g_LayerDescr.LayerColor[LAYER_PIN],
  385. RED ) );
  386. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheet" ),
  387. &g_LayerDescr.LayerColor[LAYER_SHEET],
  388. MAGENTA ) );
  389. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true,
  390. wxT( "ColorSheetFileName" ),
  391. &g_LayerDescr.LayerColor[LAYER_SHEETFILENAME],
  392. BROWN ) );
  393. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheetName" ),
  394. &g_LayerDescr.LayerColor[LAYER_SHEETNAME],
  395. CYAN ) );
  396. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheetLab" ),
  397. &g_LayerDescr.LayerColor[LAYER_SHEETLABEL],
  398. BROWN ) );
  399. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNoCo" ),
  400. &g_LayerDescr.LayerColor[LAYER_NOCONNECT],
  401. BLUE ) );
  402. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorErcW" ),
  403. &g_LayerDescr.LayerColor[LAYER_ERC_WARN],
  404. GREEN ) );
  405. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorErcE" ),
  406. &g_LayerDescr.LayerColor[LAYER_ERC_ERR],
  407. RED ) );
  408. m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorGrid" ),
  409. &g_LayerDescr.LayerColor[LAYER_GRID],
  410. DARKGRAY ) );
  411. m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "PrintMonochrome" ),
  412. &m_printMonochrome, true ) );
  413. m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "PrintSheetReferenceAndTitleBlock" ),
  414. &m_printSheetReference, true ) );
  415. return m_configSettings;
  416. }
  417. void SCH_EDIT_FRAME::LoadSettings()
  418. {
  419. wxASSERT( wxGetApp().m_EDA_Config != NULL );
  420. long tmp;
  421. wxConfig* cfg = wxGetApp().m_EDA_Config;
  422. EDA_DRAW_FRAME::LoadSettings();
  423. wxGetApp().ReadCurrentSetupValues( GetConfigurationSettings() );
  424. // This is required until someone gets rid of the global variable g_LayerDescription().
  425. m_GridColor = g_LayerDescr.LayerColor[LAYER_GRID];
  426. g_DrawDefaultLineThickness = cfg->Read( DefaultDrawLineWidthEntry,(long) 6 );
  427. cfg->Read( ShowHiddenPinsEntry, &m_ShowAllPins, false );
  428. cfg->Read( HorzVertLinesOnlyEntry, &g_HVLines, true );
  429. /* Load print preview window session settings. */
  430. cfg->Read( PreviewFramePositionXEntry, &tmp, -1 );
  431. m_previewPosition.x = (int) tmp;
  432. cfg->Read( PreviewFramePositionYEntry, &tmp, -1 );
  433. m_previewPosition.y = (int) tmp;
  434. cfg->Read( PreviewFrameWidthEntry, &tmp, -1 );
  435. m_previewSize.SetWidth( (int) tmp );
  436. cfg->Read( PreviewFrameHeightEntry, &tmp, -1 );
  437. m_previewSize.SetHeight( (int) tmp );
  438. /* Load print dialog session settings. */
  439. cfg->Read( PrintDialogPositionXEntry, &tmp, -1 );
  440. m_printDialogPosition.x = (int) tmp;
  441. cfg->Read( PrintDialogPositionYEntry, &tmp, -1 );
  442. m_printDialogPosition.y = (int) tmp;
  443. cfg->Read( PrintDialogWidthEntry, &tmp, -1 );
  444. m_printDialogSize.SetWidth( (int) tmp );
  445. cfg->Read( PrintDialogHeightEntry, &tmp, -1 );
  446. m_printDialogSize.SetHeight( (int) tmp );
  447. // Load netlists options:
  448. cfg->Read( SpiceNetNamesEntry, &g_OptNetListUseNames, false );
  449. cfg->Read( SimulatorCommandEntry, &m_simulatorCommand );
  450. /* Load find dialog session setting. */
  451. cfg->Read( FindDialogPositionXEntry, &tmp, -1 );
  452. m_findDialogPosition.x = (int) tmp;
  453. cfg->Read( FindDialogPositionYEntry, &tmp, -1 );
  454. m_findDialogPosition.y = (int) tmp;
  455. cfg->Read( FindDialogWidthEntry, &tmp, -1 );
  456. m_findDialogSize.SetWidth( (int) tmp );
  457. cfg->Read( FindDialogHeightEntry, &tmp, -1 );
  458. m_findDialogSize.SetHeight( (int) tmp );
  459. wxASSERT_MSG( m_findReplaceData,
  460. wxT( "Find dialog data settings object not created. Bad programmer!" ) );
  461. cfg->Read( FindReplaceFlagsEntry, &tmp, (long) wxFR_DOWN );
  462. m_findReplaceData->SetFlags( (wxUint32) tmp );
  463. m_findReplaceData->SetFindString( cfg->Read( FindStringEntry, wxEmptyString ) );
  464. m_findReplaceData->SetReplaceString( cfg->Read( ReplaceStringEntry, wxEmptyString ) );
  465. /* Load the find and replace string history list. */
  466. for ( size_t i = 0; i < FR_HISTORY_LIST_CNT; i++ )
  467. {
  468. wxString tmpHistory;
  469. wxString entry;
  470. entry.Printf( FindStringHistoryEntry, i );
  471. tmpHistory = cfg->Read( entry, wxEmptyString );
  472. if( !tmpHistory.IsEmpty() )
  473. m_findStringHistoryList.Add( tmpHistory );
  474. entry.Printf( ReplaceStringHistoryEntry, i );
  475. tmpHistory = cfg->Read( entry, wxEmptyString );
  476. if( !tmpHistory.IsEmpty() )
  477. m_replaceStringHistoryList.Add( tmpHistory );
  478. }
  479. wxString templateFieldNames = cfg->Read( FieldNamesEntry, wxEmptyString );
  480. if( !templateFieldNames.IsEmpty() )
  481. {
  482. TEMPLATE_FIELDNAMES_LEXER lexer( TO_UTF8( templateFieldNames ) );
  483. try
  484. {
  485. m_TemplateFieldNames.Parse( &lexer );
  486. }
  487. catch( IO_ERROR& e )
  488. {
  489. // @todo show error msg
  490. D( printf( "templatefieldnames parsing error: '%s'\n",
  491. TO_UTF8( e.errorText ) ); )
  492. }
  493. }
  494. }
  495. void SCH_EDIT_FRAME::SaveSettings()
  496. {
  497. wxASSERT( wxGetApp().m_EDA_Config != NULL );
  498. wxConfig* cfg = wxGetApp().m_EDA_Config;
  499. EDA_DRAW_FRAME::SaveSettings();
  500. wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() );
  501. cfg->Write( DefaultDrawLineWidthEntry, (long) g_DrawDefaultLineThickness );
  502. cfg->Write( ShowHiddenPinsEntry, m_ShowAllPins );
  503. cfg->Write( HorzVertLinesOnlyEntry, g_HVLines );
  504. /* Save print preview window session settings. */
  505. cfg->Write( PreviewFramePositionXEntry, m_previewPosition.x );
  506. cfg->Write( PreviewFramePositionYEntry, m_previewPosition.y );
  507. cfg->Write( PreviewFrameWidthEntry, m_previewSize.GetWidth() );
  508. cfg->Write( PreviewFrameHeightEntry, m_previewSize.GetHeight() );
  509. /* Save print dialog session settings. */
  510. cfg->Write( PrintDialogPositionXEntry, m_printDialogPosition.x );
  511. cfg->Write( PrintDialogPositionYEntry, m_printDialogPosition.y );
  512. cfg->Write( PrintDialogWidthEntry, m_printDialogSize.GetWidth() );
  513. cfg->Write( PrintDialogHeightEntry, m_printDialogSize.GetHeight() );
  514. // Save netlists options:
  515. cfg->Write( SpiceNetNamesEntry, g_OptNetListUseNames );
  516. cfg->Write( SimulatorCommandEntry, m_simulatorCommand );
  517. /* Save find dialog session setting. */
  518. cfg->Write( FindDialogPositionXEntry, m_findDialogPosition.x );
  519. cfg->Write( FindDialogPositionYEntry, m_findDialogPosition.y );
  520. cfg->Write( FindDialogWidthEntry, m_findDialogSize.GetWidth() );
  521. cfg->Write( FindDialogHeightEntry, m_findDialogSize.GetHeight() );
  522. wxASSERT_MSG( m_findReplaceData,
  523. wxT( "Find dialog data settings object not created. Bad programmer!" ) );
  524. cfg->Write( FindReplaceFlagsEntry, (long) m_findReplaceData->GetFlags() );
  525. cfg->Write( FindStringEntry, m_findReplaceData->GetFindString() );
  526. cfg->Write( ReplaceStringEntry, m_findReplaceData->GetReplaceString() );
  527. /* Save the find and replace string history list. */
  528. size_t i;
  529. wxString tmpHistory;
  530. wxString entry; // invoke constructor outside of any loops
  531. for ( i = 0; i < m_findStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ )
  532. {
  533. entry.Printf( FindStringHistoryEntry, i );
  534. cfg->Write( entry, m_findStringHistoryList[ i ] );
  535. }
  536. for ( i = 0; i < m_replaceStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ )
  537. {
  538. entry.Printf( ReplaceStringHistoryEntry, i );
  539. cfg->Write( entry, m_replaceStringHistoryList[ i ] );
  540. }
  541. // Save template fieldnames
  542. STRING_FORMATTER sf;
  543. m_TemplateFieldNames.Format( &sf, 0 );
  544. D(printf("saving formatted template fieldnames:'%s'\n", sf.GetString().c_str() );)
  545. wxString record = FROM_UTF8( sf.GetString().c_str() );
  546. record.Replace( wxT("\n"), wxT(""), true ); // strip all newlines
  547. record.Replace( wxT(" "), wxT(" "), true ); // double space to single
  548. cfg->Write( FieldNamesEntry, record );
  549. }