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.

91 lines
3.7 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, you may find one here:
  18. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. * or you may search the http://www.gnu.org website for the version 2 license,
  20. * or you may write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. #include <cvpcb_settings.h>
  24. #include <settings/parameters.h>
  25. #include <wx/config.h>
  26. ///! Update the schema version whenever a migration is required
  27. const int cvpcbSchemaVersion = 0;
  28. CVPCB_SETTINGS::CVPCB_SETTINGS() :
  29. APP_SETTINGS_BASE( "cvpcb", cvpcbSchemaVersion ),
  30. m_FootprintViewerAutoZoom( false ),
  31. m_FootprintViewerZoom( 1.0 ),
  32. m_FilterFootprint( 0 ),
  33. m_LibrariesWidth( 0 ),
  34. m_FootprintsWidth( 0 )
  35. {
  36. // We always snap and don't let the user configure it
  37. m_FootprintViewerMagneticSettings.pads = MAGNETIC_OPTIONS::CAPTURE_ALWAYS;
  38. m_FootprintViewerMagneticSettings.tracks = MAGNETIC_OPTIONS::CAPTURE_ALWAYS;
  39. m_FootprintViewerMagneticSettings.graphics = true;
  40. // Init settings:
  41. m_params.emplace_back( new PARAM<int>( "filter_footprint", &m_FilterFootprint, 0 ) );
  42. m_params.emplace_back( new PARAM<int>( "libraries_pane_width", &m_LibrariesWidth, 0 ) );
  43. m_params.emplace_back( new PARAM<int>( "footprints_pane_width", &m_FootprintsWidth, 0 ) );
  44. addParamsForWindow( &m_FootprintViewer, "footprint_viewer" );
  45. m_params.emplace_back( new PARAM<bool>( "footprint_viewer.pad_fill",
  46. &m_FootprintViewerDisplayOptions.m_DisplayPadFill, true ) );
  47. m_params.emplace_back( new PARAM<bool>( "footprint_viewer.pad_numbers",
  48. &m_FootprintViewerDisplayOptions.m_DisplayPadNum, true ) );
  49. m_params.emplace_back( new PARAM<bool>( "footprint_viewer.footprint_text_fill",
  50. &m_FootprintViewerDisplayOptions.m_DisplayTextFill, true ) );
  51. m_params.emplace_back( new PARAM<bool>( "footprint_viewer.graphic_items_fill",
  52. &m_FootprintViewerDisplayOptions.m_DisplayGraphicsFill, true ) );
  53. m_params.emplace_back( new PARAM<bool>( "footprint_viewer.auto_zoom",
  54. &m_FootprintViewerAutoZoom, false ) );
  55. m_params.emplace_back( new PARAM<double>( "footprint_viewer.zoom",
  56. &m_FootprintViewerZoom, 1.0 ) );
  57. }
  58. bool CVPCB_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
  59. {
  60. bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
  61. ret &= fromLegacy<int>( aCfg, "FilterFootprint", "filter_footprint" );
  62. ret &= migrateWindowConfig( aCfg, "FootprintViewerFrame", "footprint_viewer" );
  63. ret &= fromLegacy<bool>( aCfg, "FootprintViewerFrameDiPadFi", "footprint_viewer.pad_fill" );
  64. ret &= fromLegacy<bool>( aCfg, "FootprintViewerFrameDiPadNu", "footprint_viewer.pad_numbers" );
  65. ret &= fromLegacy<bool>(
  66. aCfg, "FootprintViewerFrameDiModTx", "footprint_viewer.footprint_text_fill" );
  67. ret &= fromLegacy<bool>( aCfg, "FootprintViewerFrameAutoZoom", "footprint_viewer.auto_zoom" );
  68. ret &= fromLegacy<double>( aCfg, "FootprintViewerFrameZoom", "footprint_viewer.zoom" );
  69. return ret;
  70. }