| 1 | // This file is part of Dust Racing 2D. |
| 2 | // Copyright (C) 2015 Jussi Lind <[email protected]> |
| 3 | // |
| 4 | // Dust Racing 2D is free software: you can redistribute it and/or modify |
| 5 | // it under the terms of the GNU General Public License as published by |
| 6 | // the Free Software Foundation, either version 3 of the License, or |
| 7 | // (at your option) any later version. |
| 8 | // Dust Racing 2D is distributed in the hope that it will be useful, |
| 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | // GNU General Public License for more details. |
| 12 | // |
| 13 | // You should have received a copy of the GNU General Public License |
| 14 | // along with Dust Racing 2D. If not, see <http://www.gnu.org/licenses/>. |
| 15 | |
| 16 | #ifndef TARGETNODEBASE_HPP |
| 17 | #define TARGETNODEBASE_HPP |
| 18 | |
| 19 | #include <QPointF> |
| 20 | #include <QSizeF> |
| 21 | #include <QString> |
| 22 | |
| 23 | #include <memory> |
| 24 | |
| 25 | //! Base class for freely placeable target nodes in the editor. |
| 26 | class TargetNodeBase |
| 27 | { |
| 28 | public: |
| 29 | typedef std::shared_ptr<TargetNodeBase> TargetNodeBasePtr; |
| 30 | |
| 31 | //! Constructor. |
| 32 | TargetNodeBase(); |
| 33 | |
| 34 | TargetNodeBase(TargetNodeBase & other) = delete; |
| 35 | |
| 36 | TargetNodeBase(TargetNodeBase && other) = delete; |
| 37 | |
| 38 | TargetNodeBase & operator=(TargetNodeBase & other) = delete; |
| 39 | |
| 40 | //! Destructor. |
| 41 | virtual ~TargetNodeBase() = default; |
| 42 | |
| 43 | //! Get location in world / scene. |
| 44 | virtual QPointF location() const; |
| 45 | |
| 46 | //! Set coordinates in the world. |
| 47 | virtual void setLocation(QPointF newLocation); |
| 48 | |
| 49 | virtual int index() const; |
| 50 | |
| 51 | virtual void setIndex(int index); |
| 52 | |
| 53 | virtual void setNext(TargetNodeBasePtr nextNnode); |
| 54 | |
| 55 | virtual TargetNodeBasePtr next() const; |
| 56 | |
| 57 | virtual void setPrev(TargetNodeBasePtr prevNode); |
| 58 | |
| 59 | virtual TargetNodeBasePtr prev() const; |
| 60 | |
| 61 | virtual void setSize(QSizeF size); |
| 62 | |
| 63 | virtual QSizeF size() const; |
| 64 | |
| 65 | private: |
| 66 | //! Coordinates in the world. |
| 67 | QPointF m_location; |
| 68 | |
| 69 | //! Original size in pixels. |
| 70 | QSizeF m_size; |
| 71 | |
| 72 | //! Index in the route. |
| 73 | int m_index; |
| 74 | |
| 75 | TargetNodeBasePtr m_next; |
| 76 | |
| 77 | TargetNodeBasePtr m_prev; |
| 78 | }; |
| 79 | |
| 80 | using TargetNodeBasePtr = std::shared_ptr<TargetNodeBase>; |
| 81 | |
| 82 | #endif // TARGETNODEBASE_HPP |