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.

102 lines
2.6 KiB

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