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.

145 lines
4.1 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2020 CERN
  5. * @author Jon Evans <jon@craftyjon.com>
  6. *
  7. * This program is free software: you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation, either version 3 of the License, or (at your
  10. * option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along
  18. * with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef KICAD_PROJECT_LOCAL_SETTINGS_H
  21. #define KICAD_PROJECT_LOCAL_SETTINGS_H
  22. #include <layers_id_colors_and_visibility.h>
  23. #include <project/board_project_settings.h>
  24. #include <settings/json_settings.h>
  25. #include <wildcards_and_files_ext.h>
  26. #include <settings/app_settings.h>
  27. class PROJECT;
  28. struct PROJECT_FILE_STATE
  29. {
  30. wxString fileName;
  31. bool open;
  32. struct WINDOW_STATE window;
  33. };
  34. /**
  35. * The project local settings are things that are attached to a particular project, but also might
  36. * be particular to a certain user editing that project, or change quickly, and therefore may not
  37. * want to be checked in to version control or otherwise distributed with the main project.
  38. *
  39. * Examples include layer visibility, recently-used design entry settings, and so on.
  40. *
  41. * The backing store is a JSON file named <project>.kicad_prl
  42. *
  43. * This file doesn't need to exist for a project to be loaded. It will be created on-demand if
  44. * any of the things stored here are modified by the user.
  45. */
  46. class PROJECT_LOCAL_SETTINGS : public JSON_SETTINGS
  47. {
  48. public:
  49. PROJECT_LOCAL_SETTINGS( PROJECT* aProject, const wxString& aFilename );
  50. virtual ~PROJECT_LOCAL_SETTINGS() {}
  51. bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override;
  52. bool Migrate() override;
  53. bool SaveToFile( const wxString& aDirectory = "", bool aForce = false ) override;
  54. void SetProject( PROJECT* aProject )
  55. {
  56. m_project = aProject;
  57. }
  58. private:
  59. bool migrateSchema1to2();
  60. protected:
  61. wxString getFileExt() const override
  62. {
  63. return ProjectLocalSettingsFileExtension;
  64. }
  65. wxString getLegacyFileExt() const override
  66. {
  67. return wxT( "NO_SUCH_FILE_EXTENSION" );
  68. }
  69. private:
  70. /// A link to the owning project
  71. PROJECT* m_project;
  72. public:
  73. /**
  74. * Project scope
  75. */
  76. /// File based state
  77. std::vector<PROJECT_FILE_STATE> m_files;
  78. /**
  79. * Board settings
  80. */
  81. /// The board layers that are turned on for viewing (@see PCB_LAYER_ID)
  82. LSET m_VisibleLayers;
  83. /// The GAL layers (aka items) that are turned on for viewing (@see GAL_LAYER_ID)
  84. GAL_SET m_VisibleItems;
  85. /// The current (active) board layer for editing
  86. PCB_LAYER_ID m_ActiveLayer;
  87. /// The name of a LAYER_PRESET that is currently activated (or blank if none)
  88. wxString m_ActiveLayerPreset;
  89. /// The current contrast mode
  90. HIGH_CONTRAST_MODE m_ContrastModeDisplay;
  91. /// The current net color mode
  92. NET_COLOR_MODE m_NetColorMode;
  93. /// How zones are drawn (TODO: not yet used)
  94. ZONE_DISPLAY_MODE m_ZoneDisplayMode;
  95. double m_TrackOpacity; ///< Opacity override for all tracks
  96. double m_ViaOpacity; ///< Opacity override for all types of via
  97. double m_PadOpacity; ///< Opacity override for SMD pads and PTH
  98. double m_ZoneOpacity; ///< Opacity override for filled zones
  99. /**
  100. * A list of netnames that have been manually hidden in the board editor.
  101. * Currently, hiding nets means hiding the ratsnest for those nets.
  102. */
  103. std::vector<wxString> m_HiddenNets;
  104. /// State of the selection filter widget
  105. SELECTION_FILTER_OPTIONS m_SelectionFilter;
  106. void SaveFileState( const wxString& aFileName, const WINDOW_SETTINGS* aWindowCfg, bool aOpen );
  107. const PROJECT_FILE_STATE* GetFileState( const wxString& aFileName );
  108. void ClearFileState();
  109. };
  110. #endif