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.

101 lines
3.5 KiB

Horizontal/vertical zoom for Simulator plots ADDED: Horizontal/vertical zoom for simulator plots, via mouse wheel, toolbar buttons, menu commands, and hotkeys. ADDED: Simulator preferences panel, populated with mouse wheel and trackpad settings that control pan and zoom of simulator plots. ADDED: Zoom In/Out Horizontally/Vertically commands that can be bound to hotkeys. CHANGED: Simulator plot scroll wheel gestures are no longer hard-coded and can now be configured via the new Simulator preferences panel. Fixes https://gitlab.com/kicad/code/kicad/-/issues/16597 Other unreported bugs that were fixed: - Fixed wierd, jumpy simulator plot view limiting behavior. - Fixed Zoom In Center and Zoom Out Center commands not preserving the simulator plot center point. - Fixed simulator plot nudging when exported as PNGs. - Fixed rectangular selection zoom being able to exceed simulator plot view limits. Notes: - Provided new SIM_PREFERENCES struct to be used for future simulator preferences set via the simulator preferences dialog. - Bundled pre-existing EESCHEMA_SETTINGS::SIMULATOR settings into EESCHEMA_SETTINGS::SIMULATOR::VIEW. - Replaced mpWindow::EnableMouseWheelPan with more general SetMouseWheelActions. - Refactored and tidied up wxMathPlot's mpWindow code involved with fitting, zooming, and panning. - Consolidated long lists of duplicated member variable initializers to a new mpWindow private delegated constructor. - Provided provisional Zoom In/Out Horizontally/Vertically toolbar icons that need improvement by a graphics designer. - Provided gitignore entries for the Qt Creator IDE
2 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2024 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 3
  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. * https://www.gnu.org/licenses/gpl-3.0.html
  19. * or you may search the http://www.gnu.org website for the version 3 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. #ifndef __SIM_PREFERENCES__
  24. #define __SIM_PREFERENCES__
  25. /**
  26. * @file sim_preferences.h
  27. *
  28. * Contains preferences pertaining to the simulator.
  29. */
  30. /**
  31. * Enumerates the possible mouse wheel actions that can be performed on simulator plots.
  32. */
  33. enum class SIM_MOUSE_WHEEL_ACTION
  34. {
  35. // Directly using mpWindow::MouseWheelAction would leak wxMathPlot via the eeschema_settings.h
  36. // header, so we duplicate it here in this miminal header.
  37. NONE,
  38. PAN_LEFT_RIGHT,
  39. PAN_RIGHT_LEFT,
  40. PAN_UP_DOWN,
  41. ZOOM,
  42. ZOOM_HORIZONTALLY,
  43. ZOOM_VERTICALLY,
  44. COUNT // Internal use only
  45. };
  46. /**
  47. * Contains the set of modified mouse wheel actions that can be performed on a simulator plot.
  48. */
  49. struct SIM_MOUSE_WHEEL_ACTION_SET
  50. {
  51. // Directly using mpWindow::MouseWheelActionSet would leak wxMathPlot via the
  52. // eeschema_settings.h header, so we duplicate it here in this miminal header.
  53. SIM_MOUSE_WHEEL_ACTION vertical_unmodified;
  54. SIM_MOUSE_WHEEL_ACTION vertical_with_ctrl;
  55. SIM_MOUSE_WHEEL_ACTION vertical_with_shift;
  56. SIM_MOUSE_WHEEL_ACTION vertical_with_alt;
  57. SIM_MOUSE_WHEEL_ACTION horizontal;
  58. static SIM_MOUSE_WHEEL_ACTION_SET GetMouseDefaults()
  59. {
  60. // Returns defaults equivalent to the global Mouse and Touchpad default settings
  61. SIM_MOUSE_WHEEL_ACTION_SET actions;
  62. actions.vertical_unmodified = SIM_MOUSE_WHEEL_ACTION::ZOOM;
  63. actions.vertical_with_ctrl = SIM_MOUSE_WHEEL_ACTION::PAN_LEFT_RIGHT;
  64. actions.vertical_with_shift = SIM_MOUSE_WHEEL_ACTION::PAN_UP_DOWN;
  65. actions.vertical_with_alt = SIM_MOUSE_WHEEL_ACTION::NONE;
  66. actions.horizontal = SIM_MOUSE_WHEEL_ACTION::NONE;
  67. return actions;
  68. }
  69. static SIM_MOUSE_WHEEL_ACTION_SET GetTrackpadDefaults()
  70. {
  71. // Returns defaults equivalent to the global Mouse and Touchpad default settings
  72. SIM_MOUSE_WHEEL_ACTION_SET actions;
  73. actions.vertical_unmodified = SIM_MOUSE_WHEEL_ACTION::PAN_UP_DOWN;
  74. actions.vertical_with_ctrl = SIM_MOUSE_WHEEL_ACTION::ZOOM;
  75. actions.vertical_with_shift = SIM_MOUSE_WHEEL_ACTION::PAN_LEFT_RIGHT;
  76. actions.vertical_with_alt = SIM_MOUSE_WHEEL_ACTION::NONE;
  77. actions.horizontal = SIM_MOUSE_WHEEL_ACTION::PAN_LEFT_RIGHT;
  78. return actions;
  79. }
  80. };
  81. /**
  82. * Contains preferences pertaining to the simulator.
  83. */
  84. struct SIM_PREFERENCES
  85. {
  86. SIM_MOUSE_WHEEL_ACTION_SET mouse_wheel_actions;
  87. };
  88. #endif // __SIM_PREFERENCES__