1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
//
// C++ Interface: positionmodel
//
// Description:
//
//
// Author: Thibaut GRIDEL <tgridel@free.fr>
//
// Copyright (c) 2008-2011 Thibaut GRIDEL
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
//
#ifndef POSITIONMODEL_H
#define POSITIONMODEL_H
#include <QtGui>
class SituationModel;
/**
\class PositionModel
\brief The Model for a Position
The class represents the Model for a Position, according to an
Observer Pattern.
PositionModel contains data which represents an object with a position,
and a stacking order. It is inherited by BoatModel and PointModel.
\sa SituationModel, BoatModel, PointModel
*/
class PositionModel : public QObject {
Q_OBJECT
Q_PROPERTY(QPointF pos READ position WRITE setPosition)
Q_PROPERTY(qreal heading READ heading WRITE setHeading)
Q_PROPERTY(QString text READ text WRITE setText)
Q_PROPERTY(QPointF textPos READ textPosition WRITE setTextPosition)
Q_PROPERTY(bool laylines READ laylines() WRITE setLaylines)
Q_PROPERTY(qreal wind READ wind WRITE setWind)
public:
PositionModel(SituationModel* situation, QObject *parent = 0);
virtual ~PositionModel();
// Setters and Getters for Model Data
QPointF position() const { return m_position; }
virtual void setPosition(const QPointF& theValue);
int order() const { return m_order; }
void setOrder(const int theValue);
qreal heading() const { return m_heading; }
virtual void setHeading(const qreal& theValue);
QString text() const {return m_text; }
void setText(const QString theValue);
QPointF textPosition() const {return m_textPosition; }
void setTextPosition(const QPointF& theValue);
bool laylines() const {return m_laylines; }
void setLaylines(bool theValue);
// Setters and Getters for Non model Data
SituationModel* situation() const { return m_situation; }
virtual qreal wind() const;
QStringList discardedXml() const { return m_discardedXml; }
void appendDiscardedXml(const QString& theValue);
public slots:
virtual void setWind(qreal wind);
signals:
void positionChanged(QPointF position);
void orderChanged(int order);
void headingChanged(qreal heading);
void textChanged(QString text);
void textPositionChanged(QPointF textPosition);
void windChanged(qreal wind);
void laylinesChanged(bool laylines);
protected:
// Model Data
/// \a m_position holds the position of the object
QPointF m_position;
/// \a m_order holds the stacking order of the object. It starts at 1 for track boat
int m_order;
/// \a m_heading holds the heading of the object
qreal m_heading;
/// \a m_text holds the text to display
QString m_text;
/// \a m_textPosition holds the position of the text to display
QPointF m_textPosition;
/// \a m_laylines holds wether the object should display laylines
bool m_laylines;
// Non model Data
/// \a m_situation keeps a pointer to the SituationModel to which
/// it belongs
SituationModel *m_situation;
qreal m_wind;
/// \a m_discardedXml keeps all unparsed xml tags
QStringList m_discardedXml;
};
#endif
|