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.

87 lines
3.6 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_FootprintViewerZoom( 1.0 ),
  31. m_FilterFootprint( 0 ),
  32. m_LibrariesWidth( 0 ),
  33. m_FootprintsWidth( 0 )
  34. {
  35. // We always snap and don't let the user configure it
  36. m_FootprintViewerMagneticSettings.pads = MAGNETIC_OPTIONS::CAPTURE_ALWAYS;
  37. m_FootprintViewerMagneticSettings.tracks = MAGNETIC_OPTIONS::CAPTURE_ALWAYS;
  38. m_FootprintViewerMagneticSettings.graphics = true;
  39. // Init settings:
  40. m_params.emplace_back( new PARAM<int>( "filter_footprint", &m_FilterFootprint, 0 ) );
  41. m_params.emplace_back( new PARAM<int>( "libraries_pane_width", &m_LibrariesWidth, 0 ) );
  42. m_params.emplace_back( new PARAM<int>( "footprints_pane_width", &m_FootprintsWidth, 0 ) );
  43. addParamsForWindow( &m_FootprintViewer, "footprint_viewer" );
  44. m_params.emplace_back( new PARAM<bool>( "footprint_viewer.pad_fill",
  45. &m_FootprintViewerDisplayOptions.m_DisplayPadFill, true ) );
  46. m_params.emplace_back( new PARAM<bool>( "footprint_viewer.pad_numbers",
  47. &m_FootprintViewerDisplayOptions.m_DisplayPadNum, true ) );
  48. m_params.emplace_back( new PARAM<bool>( "footprint_viewer.footprint_text_fill",
  49. &m_FootprintViewerDisplayOptions.m_DisplayTextFill, true ) );
  50. m_params.emplace_back( new PARAM<bool>( "footprint_viewer.graphic_items_fill",
  51. &m_FootprintViewerDisplayOptions.m_DisplayGraphicsFill, true ) );
  52. m_params.emplace_back( new PARAM<double>( "footprint_viewer.zoom",
  53. &m_FootprintViewerZoom, 1.0 ) );
  54. }
  55. bool CVPCB_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
  56. {
  57. bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
  58. ret &= fromLegacy<int>( aCfg, "FilterFootprint", "filter_footprint" );
  59. ret &= migrateWindowConfig( aCfg, "FootprintViewerFrame", "footprint_viewer" );
  60. ret &= fromLegacy<bool>( aCfg, "FootprintViewerFrameDiPadFi", "footprint_viewer.pad_fill" );
  61. ret &= fromLegacy<bool>( aCfg, "FootprintViewerFrameDiPadNu", "footprint_viewer.pad_numbers" );
  62. ret &= fromLegacy<bool>(
  63. aCfg, "FootprintViewerFrameDiModTx", "footprint_viewer.footprint_text_fill" );
  64. ret &= fromLegacy<bool>( aCfg, "FootprintViewerFrameAutoZoom", "footprint_viewer.auto_zoom" );
  65. ret &= fromLegacy<double>( aCfg, "FootprintViewerFrameZoom", "footprint_viewer.zoom" );
  66. return ret;
  67. }