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.

75 lines
2.2 KiB

  1. #ifndef __PCB_TEST_SELECTION_TOOL_H
  2. #define __PCB_TEST_SELECTION_TOOL_H
  3. #include <tool/action_menu.h>
  4. #include <tool/selection_tool.h>
  5. #include <tool/tool_menu.h>
  6. #include <tools/pcb_selection_conditions.h>
  7. #include <tools/pcb_tool_base.h>
  8. #include <tools/pcb_selection.h>
  9. class PCB_TEST_FRAME_BASE;
  10. class PCB_TEST_SELECTION_TOOL : public SELECTION_TOOL
  11. {
  12. public:
  13. PCB_TEST_SELECTION_TOOL();
  14. virtual ~PCB_TEST_SELECTION_TOOL();
  15. /// @copydoc TOOL_BASE::Init()
  16. bool Init() override;
  17. /// @copydoc TOOL_BASE::Reset()
  18. void Reset( RESET_REASON aReason ) override;
  19. int Main( const TOOL_EVENT& aEvent );
  20. PCB_SELECTION& GetSelection() { return m_selection; }
  21. void ClearSelection();
  22. void SetSelectionHook( std::function<void(PCB_TEST_FRAME_BASE*, PCB_SELECTION*)> aHook )
  23. {
  24. m_selectionHook = aHook;
  25. }
  26. void SetSelectableItemTypes( const std::vector<KICAD_T> aTypes );
  27. protected:
  28. const GENERAL_COLLECTORS_GUIDE getCollectorsGuide() const;
  29. bool selectPoint( const VECTOR2I& aWhere );
  30. void setTransitions() override;
  31. KIGFX::PCB_VIEW* view() const { return static_cast<KIGFX::PCB_VIEW*>( getView() ); }
  32. KIGFX::VIEW_CONTROLS* controls() const { return getViewControls(); }
  33. PCB_TEST_FRAME_BASE* frame() const { return getEditFrame<PCB_TEST_FRAME_BASE>(); }
  34. BOARD* board() const { return getModel<BOARD>(); }
  35. PCB_DRAW_PANEL_GAL* canvas() const
  36. {
  37. return static_cast<PCB_DRAW_PANEL_GAL*>( frame()->GetPanel().get() );
  38. }
  39. SELECTION& selection() override { return m_selection; }
  40. void highlightInternal( EDA_ITEM* aItem, int aMode, bool aUsingOverlay );
  41. void unhighlight( EDA_ITEM* aItem, int aMode, SELECTION* aGroup ) override;
  42. void unhighlightInternal( EDA_ITEM* aItem, int aMode, bool aUsingOverlay );
  43. void highlight( EDA_ITEM* aItem, int aMode, SELECTION* aGroup ) override;
  44. void select( EDA_ITEM* aItem ) override;
  45. void unselect( EDA_ITEM* aItem ) override;
  46. private:
  47. std::function<void(PCB_TEST_FRAME_BASE*,PCB_SELECTION*)> m_selectionHook;
  48. PCB_SELECTION m_selection; // Current state of selection
  49. std::vector<KICAD_T> m_selectableTypes;
  50. };
  51. #endif