|
| 1 | +/*************************************************************************** |
| 2 | + qgslayoutguidecollection.h |
| 3 | + -------------------------- |
| 4 | + begin : July 2017 |
| 5 | + copyright : (C) 2017 by Nyall Dawson |
| 6 | + email : nyall dot dawson at gmail dot com |
| 7 | + ***************************************************************************/ |
| 8 | +/*************************************************************************** |
| 9 | + * * |
| 10 | + * This program is free software; you can redistribute it and/or modify * |
| 11 | + * it under the terms of the GNU General Public License as published by * |
| 12 | + * the Free Software Foundation; either version 2 of the License, or * |
| 13 | + * (at your option) any later version. * |
| 14 | + * * |
| 15 | + ***************************************************************************/ |
| 16 | +#ifndef QGSLAYOUTGUIDECOLLECTION_H |
| 17 | +#define QGSLAYOUTGUIDECOLLECTION_H |
| 18 | + |
| 19 | +#include "qgis_core.h" |
| 20 | +#include "qgslayoutmeasurement.h" |
| 21 | +#include "qgslayoutpoint.h" |
| 22 | +#include <QPen> |
| 23 | +#include <memory> |
| 24 | + |
| 25 | +class QgsLayout; |
| 26 | +class QGraphicsLineItem; |
| 27 | + |
| 28 | +/** |
| 29 | + * \ingroup core |
| 30 | + * \class QgsLayoutGuide |
| 31 | + * \brief Contains the configuration for a single snap guide used by a layout. |
| 32 | + * \since QGIS 3.0 |
| 33 | + */ |
| 34 | +class CORE_EXPORT QgsLayoutGuide |
| 35 | +{ |
| 36 | + |
| 37 | + public: |
| 38 | + |
| 39 | + //! Guide orientation |
| 40 | + enum Orientation |
| 41 | + { |
| 42 | + Horizontal, //!< Horizontal guide |
| 43 | + Vertical, //!< Vertical guide |
| 44 | + }; |
| 45 | + |
| 46 | + QgsLayoutGuide( QgsLayout *layout, Orientation orientation, const QgsLayoutMeasurement &position ); |
| 47 | + |
| 48 | + /** |
| 49 | + * Returns the guide's orientation. |
| 50 | + */ |
| 51 | + Orientation orientation() const; |
| 52 | + |
| 53 | + /** |
| 54 | + * Returns the guide's position within the page. |
| 55 | + * |
| 56 | + * The position indicates either the horizontal or vertical position |
| 57 | + * of the guide, depending on the guide's orientation(). |
| 58 | + * |
| 59 | + * \see setPosition() |
| 60 | + */ |
| 61 | + QgsLayoutMeasurement position() const; |
| 62 | + |
| 63 | + /** |
| 64 | + * Sets the guide's \a position within the page. |
| 65 | + * |
| 66 | + * The \a position argument indicates either the horizontal or vertical position |
| 67 | + * of the guide, depending on the guide's orientation(). |
| 68 | + * |
| 69 | + * \see position() |
| 70 | + */ |
| 71 | + void setPosition( const QgsLayoutMeasurement &position ); |
| 72 | + |
| 73 | + /** |
| 74 | + * Returns the page number of the guide. |
| 75 | + * |
| 76 | + * Page numbering begins at 0. |
| 77 | + * |
| 78 | + * \see setPage() |
| 79 | + */ |
| 80 | + int page() const; |
| 81 | + |
| 82 | + /** |
| 83 | + * Sets the \a page number of the guide. |
| 84 | + * |
| 85 | + * Page numbering begins at 0. |
| 86 | + * |
| 87 | + * \see page() |
| 88 | + */ |
| 89 | + void setPage( int page ); |
| 90 | + |
| 91 | + /** |
| 92 | + * Updates the position of the guide's line item. |
| 93 | + */ |
| 94 | + void update(); |
| 95 | + |
| 96 | + /** |
| 97 | + * Returns the guide's line item. |
| 98 | + */ |
| 99 | + QGraphicsLineItem *item(); |
| 100 | + |
| 101 | + private: |
| 102 | + |
| 103 | + Orientation mOrientation = Vertical; |
| 104 | + |
| 105 | + //! Horizontal/vertical position of guide on page |
| 106 | + QgsLayoutMeasurement mPosition; |
| 107 | + |
| 108 | + //! Page number, 0 index based |
| 109 | + int mPage = 0; |
| 110 | + |
| 111 | + QgsLayout *mLayout = nullptr; |
| 112 | + |
| 113 | + //! Line item used in scene for guide |
| 114 | + std::shared_ptr< QGraphicsLineItem > mLineItem; |
| 115 | +}; |
| 116 | + |
| 117 | + |
| 118 | + |
| 119 | +#endif //QGSLAYOUTGUIDECOLLECTION_H |
0 commit comments