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.

77 lines
3.3 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2022 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_FootprintViewerAutoZoomOnSelect( true ),
  32. m_FilterFlags( 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_FilterFlags, 0 ) );
  42. m_params.emplace_back( new PARAM<wxString>( "filter_footprint_text", &m_FilterString, "" ) );
  43. m_params.emplace_back( new PARAM<int>( "libraries_pane_width", &m_LibrariesWidth, 0 ) );
  44. m_params.emplace_back( new PARAM<int>( "footprints_pane_width", &m_FootprintsWidth, 0 ) );
  45. addParamsForWindow( &m_FootprintViewer, "footprint_viewer" );
  46. m_params.emplace_back( new PARAM<double>( "footprint_viewer.zoom", &m_FootprintViewerZoom, 1.0 ) );
  47. m_params.emplace_back( new PARAM<bool>( "footprint_viewer.autozoom",
  48. &m_FootprintViewerAutoZoomOnSelect, true ) );
  49. }
  50. bool CVPCB_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
  51. {
  52. bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
  53. ret &= fromLegacy<int>( aCfg, "FilterFootprint", "filter_footprint" );
  54. ret &= migrateWindowConfig( aCfg, "FootprintViewerFrame", "footprint_viewer" );
  55. ret &= fromLegacy<bool>( aCfg, "FootprintViewerFrameDiPadFi", "footprint_viewer.pad_fill" );
  56. ret &= fromLegacy<bool>( aCfg, "FootprintViewerFrameDiPadNu", "footprint_viewer.pad_numbers" );
  57. ret &= fromLegacy<bool>(
  58. aCfg, "FootprintViewerFrameDiModTx", "footprint_viewer.footprint_text_fill" );
  59. ret &= fromLegacy<bool>( aCfg, "FootprintViewerFrameAutoZoom", "footprint_viewer.auto_zoom" );
  60. ret &= fromLegacy<double>( aCfg, "FootprintViewerFrameZoom", "footprint_viewer.zoom" );
  61. return ret;
  62. }