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.

168 lines
4.3 KiB

  1. /***********************************/
  2. /** pcbcfg() : configuration **/
  3. /***********************************/
  4. /* lit ou met a jour la configuration de PCBNEW */
  5. #include "fctsys.h"
  6. #include "common.h"
  7. #include "pcbnew.h"
  8. #include "pcbplot.h"
  9. #include "pcbcfg.h"
  10. #include "worksheet.h"
  11. #include "id.h"
  12. #include "protos.h"
  13. /* Routines Locales */
  14. /* Variables locales */
  15. /***********************************************************/
  16. void WinEDA_PcbFrame::Process_Config(wxCommandEvent& event)
  17. /***********************************************************/
  18. {
  19. int id = event.GetId();
  20. wxPoint pos;
  21. wxClientDC dc(DrawPanel);
  22. DrawPanel->PrepareGraphicContext(&dc);
  23. pos = GetPosition();
  24. pos.x += 20; pos.y += 20;
  25. switch( id )
  26. {
  27. case ID_COLORS_SETUP :
  28. DisplayColorSetupFrame(this, pos);
  29. break;
  30. case ID_CONFIG_REQ : // Creation de la fenetre de configuration
  31. {
  32. InstallConfigFrame(pos);
  33. break;
  34. }
  35. case ID_PCB_TRACK_SIZE_SETUP:
  36. case ID_PCB_LOOK_SETUP:
  37. case ID_OPTIONS_SETUP:
  38. case ID_PCB_DRAWINGS_WIDTHS_SETUP:
  39. InstallPcbOptionsFrame(pos, &dc, id);
  40. break;
  41. case ID_PCB_PAD_SETUP:
  42. InstallPadOptionsFrame( NULL, NULL, pos);
  43. break;
  44. case ID_CONFIG_SAVE:
  45. Update_config(this);
  46. break;
  47. case ID_CONFIG_READ:
  48. {
  49. wxString FullFileName = GetScreen()->m_FileName.AfterLast('/');
  50. ChangeFileNameExt(FullFileName, g_Prj_Config_Filename_ext);
  51. FullFileName = EDA_FileSelector(_("Read config file"),
  52. wxPathOnly(GetScreen()->m_FileName),/* Chemin par defaut */
  53. FullFileName, /* nom fichier par defaut */
  54. g_Prj_Config_Filename_ext, /* extension par defaut */
  55. FullFileName, /* Masque d'affichage */
  56. this,
  57. wxFD_OPEN,
  58. TRUE /* ne change pas de repertoire courant */
  59. );
  60. if ( FullFileName.IsEmpty()) break;
  61. if ( ! wxFileExists(FullFileName) )
  62. {
  63. wxString msg;
  64. msg.Printf(_("File %s not found"), FullFileName.GetData());
  65. DisplayError(this, msg); break;
  66. }
  67. Read_Config(FullFileName );
  68. }
  69. break;
  70. default:
  71. DisplayError(this, wxT("WinEDA_PcbFrame::Process_Config internal error"));
  72. }
  73. }
  74. /**************************************************************************/
  75. bool Read_Config(const wxString & project_name)
  76. /*************************************************************************/
  77. /* lit la configuration, si elle n'a pas deja ete lue
  78. 1 - lit <nom fichier brd>.pro
  79. 2 - si non trouve lit <chemin de *.exe>/kicad.pro
  80. 3 - si non trouve: init des variables aux valeurs par defaut
  81. Retourne TRUE si lu, FALSE si config non lue ou non modifie
  82. */
  83. {
  84. wxString FullFileName;
  85. int ii;
  86. g_Prj_Config_Filename_ext = wxT(".pro");
  87. FullFileName = project_name;
  88. ChangeFileNameExt(FullFileName, g_Prj_Config_Filename_ext);
  89. /* Init des valeurs par defaut */
  90. g_LibName_List.Clear();
  91. EDA_Appl->ReadProjectConfig( FullFileName,
  92. GROUP, ParamCfgList, FALSE);
  93. /* Traitement des variables particulieres: */
  94. SetRealLibraryPath( wxT("modules") );
  95. if (ScreenPcb)
  96. {
  97. ScreenPcb->m_Diviseur_Grille = Pcbdiv_grille;
  98. ScreenPcb->m_UserGrid = g_UserGrid;
  99. ScreenPcb->m_UserGridUnit = g_UserGrid_Unit;
  100. }
  101. g_DesignSettings.m_TrackWidhtHistory[0] = g_DesignSettings.m_CurrentTrackWidth;
  102. g_DesignSettings.m_ViaSizeHistory[0] = g_DesignSettings.m_CurrentViaSize;
  103. for ( ii = 1; ii < HIST0RY_NUMBER; ii++)
  104. {
  105. g_DesignSettings.m_TrackWidhtHistory[ii] = 0;
  106. g_DesignSettings.m_ViaSizeHistory[ii] = 0;
  107. }
  108. return TRUE;
  109. }
  110. /**********************************************************/
  111. void WinEDA_PcbFrame::Update_config(wxWindow * displayframe)
  112. /***********************************************************/
  113. /* enregistrement de la config */
  114. {
  115. wxString FullFileName;
  116. wxString mask;
  117. mask = wxT("*") + g_Prj_Config_Filename_ext;
  118. FullFileName = GetScreen()->m_FileName.AfterLast('/');
  119. ChangeFileNameExt(FullFileName, g_Prj_Config_Filename_ext);
  120. FullFileName = EDA_FileSelector(_("Save config file"),
  121. wxPathOnly(GetScreen()->m_FileName), /* Chemin par defaut */
  122. FullFileName, /* nom fichier par defaut */
  123. g_Prj_Config_Filename_ext, /* extension par defaut */
  124. mask, /* Masque d'affichage */
  125. displayframe,
  126. wxFD_SAVE,
  127. TRUE
  128. );
  129. if ( FullFileName.IsEmpty() ) return;
  130. Pcbdiv_grille = GetScreen()->m_Diviseur_Grille;
  131. /* ecriture de la configuration */
  132. EDA_Appl->WriteProjectConfig(FullFileName, wxT("/pcbnew"), ParamCfgList);
  133. }