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.

204 lines
6.0 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
  5. * Copyright (C) 2023 CERN
  6. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  7. *
  8. * This program is free software: you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation, either version 3 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef EDA_3D_VIEWER_SETTINGS_H_
  22. #define EDA_3D_VIEWER_SETTINGS_H_
  23. #include <3d_enums.h>
  24. #include <plugins/3dapi/xv3d_types.h>
  25. #include <settings/app_settings.h>
  26. #include <settings/parameters.h>
  27. #include <project/board_project_settings.h>
  28. #include "render_settings.h"
  29. #define FOLLOW_PCB wxT( "follow_pcb_editor" )
  30. #define FOLLOW_PLOT_SETTINGS wxT( "follow_plot_settings" )
  31. #define LEGACY_PRESET_FLAG wxT( "legacy_preset_flag" )
  32. enum class ANTIALIASING_MODE;
  33. struct LAYER_PRESET_3D
  34. {
  35. LAYER_PRESET_3D( const wxString& aName = wxEmptyString );
  36. LAYER_PRESET_3D( const wxString& aName, const std::bitset<LAYER_3D_END>& aLayers,
  37. const std::map<int, KIGFX::COLOR4D>& aColors ) :
  38. name( aName ),
  39. layers( aLayers ),
  40. colors( aColors )
  41. {
  42. }
  43. wxString name; ///< A name for this layer set
  44. std::bitset<LAYER_3D_END> layers;
  45. std::map<int, KIGFX::COLOR4D> colors;
  46. };
  47. class PARAM_LAYER_PRESET_3D : public PARAM_LAMBDA<nlohmann::json>
  48. {
  49. public:
  50. PARAM_LAYER_PRESET_3D( const std::string& aPath, std::vector<LAYER_PRESET_3D>* aPresetList );
  51. private:
  52. nlohmann::json presetsToJson();
  53. void jsonToPresets( const nlohmann::json& aJson );
  54. private:
  55. std::vector<LAYER_PRESET_3D>* m_presets;
  56. std::map<int, wxString> m_layerToLayerNameMap;
  57. std::map<wxString, int> m_layerNameToLayerMap;
  58. };
  59. class EDA_3D_VIEWER_SETTINGS : public APP_SETTINGS_BASE
  60. {
  61. public:
  62. struct AUI_PANELS
  63. {
  64. int right_panel_width;
  65. bool show_layer_manager;
  66. };
  67. struct RENDER_SETTINGS
  68. {
  69. RENDER_ENGINE engine;
  70. GRID3D_TYPE grid_type;
  71. ANTIALIASING_MODE opengl_AA_mode;
  72. MATERIAL_MODE material_mode;
  73. bool opengl_AA_disableOnMove;
  74. bool opengl_thickness_disableOnMove;
  75. bool opengl_vias_disableOnMove;
  76. bool opengl_holes_disableOnMove;
  77. bool opengl_render_bbox_only_OnMove;
  78. bool opengl_copper_thickness;
  79. bool show_model_bbox;
  80. bool show_off_board_silk;
  81. bool highlight_on_rollover;
  82. KIGFX::COLOR4D opengl_selection_color;
  83. bool raytrace_anti_aliasing;
  84. bool raytrace_backfloor;
  85. bool raytrace_post_processing;
  86. bool raytrace_procedural_textures;
  87. bool raytrace_reflections;
  88. bool raytrace_refractions;
  89. bool raytrace_shadows;
  90. int raytrace_nrsamples_shadows;
  91. int raytrace_nrsamples_reflections;
  92. int raytrace_nrsamples_refractions;
  93. float raytrace_spread_shadows;
  94. float raytrace_spread_reflections;
  95. float raytrace_spread_refractions;
  96. int raytrace_recursivelevel_reflections;
  97. int raytrace_recursivelevel_refractions;
  98. KIGFX::COLOR4D raytrace_lightColorCamera;
  99. KIGFX::COLOR4D raytrace_lightColorTop;
  100. KIGFX::COLOR4D raytrace_lightColorBottom;
  101. std::vector<KIGFX::COLOR4D> raytrace_lightColor;
  102. std::vector<int> raytrace_lightElevation; // -90 .. 90
  103. std::vector<int> raytrace_lightAzimuth; // 0 .. 359
  104. bool show_adhesive;
  105. bool show_axis;
  106. bool show_board_body;
  107. bool show_comments;
  108. bool show_drawings;
  109. bool show_eco1;
  110. bool show_eco2;
  111. bool show_user[45];
  112. bool show_footprints_insert;
  113. bool show_footprints_normal;
  114. bool show_footprints_virtual;
  115. bool show_footprints_not_in_posfile;
  116. bool show_footprints_dnp;
  117. bool show_silkscreen_top;
  118. bool show_silkscreen_bottom;
  119. bool show_soldermask_top;
  120. bool show_soldermask_bottom;
  121. bool show_solderpaste;
  122. bool show_copper_top;
  123. bool show_copper_bottom;
  124. bool show_zones;
  125. bool show_fp_references;
  126. bool show_fp_values;
  127. bool show_fp_text;
  128. bool subtract_mask_from_silk;
  129. bool clip_silk_on_via_annuli;
  130. bool differentiate_plated_copper;
  131. bool use_board_editor_copper_colors; // OpenGL only
  132. bool preview_show_board_body;
  133. /**
  134. * return true if platted copper aeras and non platted copper areas must be drawn
  135. * using a different color
  136. */
  137. bool DifferentiatePlatedCopper()
  138. {
  139. if( engine == RENDER_ENGINE::OPENGL && use_board_editor_copper_colors )
  140. return false;
  141. return differentiate_plated_copper;
  142. }
  143. };
  144. struct CAMERA_SETTINGS
  145. {
  146. bool animation_enabled;
  147. int moving_speed_multiplier;
  148. double rotation_increment;
  149. int projection_mode;
  150. };
  151. EDA_3D_VIEWER_SETTINGS();
  152. virtual ~EDA_3D_VIEWER_SETTINGS() {}
  153. LAYER_PRESET_3D* FindPreset( const wxString& aName );
  154. virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override;
  155. public:
  156. AUI_PANELS m_AuiPanels;
  157. RENDER_SETTINGS m_Render;
  158. CAMERA_SETTINGS m_Camera;
  159. bool m_UseStackupColors;
  160. std::vector<LAYER_PRESET_3D> m_LayerPresets;
  161. wxString m_CurrentPreset;
  162. protected:
  163. virtual std::string getLegacyFrameName() const override { return "Viewer3DFrameName"; }
  164. private:
  165. bool migrateSchema0to1();
  166. };
  167. #endif