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.

99 lines
2.7 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2013 CERN
  5. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, you may find one here:
  21. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  22. * or you may search the http://www.gnu.org website for the version 2 license,
  23. * or you may write to the Free Software Foundation, Inc.,
  24. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  25. */
  26. #ifndef PREVIEW_ITEMS_SELECTION_AREA_H
  27. #define PREVIEW_ITEMS_SELECTION_AREA_H
  28. #include <preview_items/simple_overlay_item.h>
  29. namespace KIGFX
  30. {
  31. class GAL;
  32. namespace PREVIEW
  33. {
  34. /**
  35. * Represent a selection area (currently a rectangle) in a VIEW, drawn corner-to-corner between
  36. * two points.
  37. *
  38. * This is useful when selecting a rectangular area, for lasso-select or zooming, for example.
  39. */
  40. class SELECTION_AREA : public SIMPLE_OVERLAY_ITEM
  41. {
  42. public:
  43. static const int SelectionLayer = LAYER_GP_OVERLAY;
  44. SELECTION_AREA();
  45. const BOX2I ViewBBox() const override;
  46. ///< Set the origin of the rectangle (the fixed corner)
  47. void SetOrigin( const VECTOR2I& aOrigin )
  48. {
  49. m_origin = aOrigin;
  50. }
  51. /**
  52. * Set the current end of the rectangle (the corner that moves with the cursor.
  53. */
  54. void SetEnd( const VECTOR2I& aEnd )
  55. {
  56. m_end = aEnd;
  57. }
  58. /**
  59. * @return string "SELECTION_AREA"
  60. */
  61. wxString GetClass() const override
  62. {
  63. return wxT( "SELECTION_AREA" );
  64. }
  65. VECTOR2I GetOrigin() const { return m_origin; }
  66. VECTOR2I GetEnd() const { return m_end; }
  67. void SetAdditive( bool aAdditive ) { m_additive = aAdditive; }
  68. void SetSubtractive( bool aSubtractive ) { m_subtractive = aSubtractive; }
  69. void SetExclusiveOr( bool aExclusiveOr ) { m_exclusiveOr = aExclusiveOr; }
  70. void ViewDraw( int aLayer, KIGFX::VIEW* aView ) const override final;
  71. private:
  72. bool m_additive;
  73. bool m_subtractive;
  74. bool m_exclusiveOr;
  75. VECTOR2I m_origin, m_end;
  76. };
  77. } // PREVIEW
  78. } // KIGFX
  79. #endif // PREVIEW_ITEMS_SELECTION_AREA_H