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.

107 lines
3.6 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2019 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. #ifndef __BOARD_STATISTICS_TOOL_H
  24. #define __BOARD_STATISTICS_TOOL_H
  25. #include <dialogs/dialog_board_statistics.h>
  26. #include <pcb_edit_frame.h>
  27. #include <tools/pcb_actions.h>
  28. #include <tools/pcb_tool_base.h>
  29. /**
  30. * Class PCB_INSPECTION_TOOL
  31. *
  32. * Tool for pcb inspection.
  33. */
  34. class PCB_INSPECTION_TOOL : public wxEvtHandler, public PCB_TOOL_BASE
  35. {
  36. public:
  37. PCB_INSPECTION_TOOL();
  38. /// @copydoc TOOL_INTERACTIVE::Init()
  39. bool Init() override;
  40. /// @copydoc TOOL_INTERACTIVE::Reset()
  41. void Reset( RESET_REASON aReason ) override;
  42. /**
  43. * Function ShowStatisticDialog()
  44. *
  45. * Shows dialog with board statistics
  46. */
  47. int ShowStatisticsDialog( const TOOL_EVENT& aEvent );
  48. ///> Notifies eeschema about the selected item.
  49. int CrossProbePcbToSch( const TOOL_EVENT& aEvent );
  50. ///> Highlights net belonging to the item under the cursor.
  51. int HighlightNet( const TOOL_EVENT& aEvent );
  52. ///> Clears all board highlights
  53. int ClearHighlight( const TOOL_EVENT& aEvent );
  54. ///> Launches a tool to pick the item whose net is going to be highlighted.
  55. int HighlightNetTool( const TOOL_EVENT& aEvent );
  56. ///> Performs the appropriate action in response to an eeschema cross-probe.
  57. int HighlightItem( const TOOL_EVENT& aEvent );
  58. ///> Updates ratsnest for selected items.
  59. int UpdateSelectionRatsnest( const TOOL_EVENT& aEvent );
  60. ///> Hides ratsnest for selected items. Called when there are no items selected.
  61. int HideDynamicRatsnest( const TOOL_EVENT& aEvent );
  62. ///> Shows local ratsnest of a component
  63. int LocalRatsnestTool( const TOOL_EVENT& aEvent );
  64. int FlipPcbView( const TOOL_EVENT& aEvent );
  65. int ListNets( const TOOL_EVENT& aEvent );
  66. private:
  67. ///> Event handler to recalculate dynamic ratsnest
  68. void ratsnestTimer( wxTimerEvent& aEvent );
  69. ///> Recalculates dynamic ratsnest for the current selection
  70. void calculateSelectionRatsnest();
  71. bool highlightNet( const VECTOR2D& aPosition, bool aUseSelection );
  72. ///> Bind handlers to corresponding TOOL_ACTIONs
  73. void setTransitions() override;
  74. private:
  75. PCB_EDIT_FRAME* m_frame; // Pointer to the currently used edit frame.
  76. bool m_probingSchToPcb; // Recursion guard when cross-probing to EESchema
  77. int m_lastNetcode; // Used for toggling between last two highlighted nets
  78. bool m_slowRatsnest; // Indicates current selection ratsnest will be slow to calculate
  79. wxTimer m_ratsnestTimer; // Timer to initiate lazy ratsnest calculation (ie: when slow)
  80. };
  81. #endif //__BOARD_STATISTICS_TOOL_H