Commit 830d7dee authored by Don Gagne's avatar Don Gagne

Merge pull request #1860 from DonLakeFlyer/MissionWork

Mission work
parents 00b393ba faa7500c
...@@ -28,25 +28,49 @@ ...@@ -28,25 +28,49 @@
#include <QtQml> #include <QtQml>
Fact::Fact(void) : Fact::Fact(QObject* parent)
_componentId(-1), : QObject(parent)
_value(0), , _componentId(-1)
_type(FactMetaData::valueTypeInt32), , _value(0)
_metaData(NULL) , _type(FactMetaData::valueTypeInt32)
, _metaData(NULL)
{ {
FactMetaData* metaData = new FactMetaData(_type, this); FactMetaData* metaData = new FactMetaData(_type, this);
setMetaData(metaData); setMetaData(metaData);
} }
Fact::Fact(int componentId, QString name, FactMetaData::ValueType_t type, QObject* parent) : Fact::Fact(int componentId, QString name, FactMetaData::ValueType_t type, QObject* parent)
QObject(parent), : QObject(parent)
_name(name), , _name(name)
_componentId(componentId), , _componentId(componentId)
_value(0), , _value(0)
_type(type), , _type(type)
_metaData(NULL) , _metaData(NULL)
{ {
FactMetaData* metaData = new FactMetaData(_type, this);
setMetaData(metaData);
}
Fact::Fact(const Fact& other, QObject* parent)
: QObject(parent)
{
*this = other;
}
const Fact& Fact::operator=(const Fact& other)
{
_name = other._name;
_componentId = other._componentId;
_value = other._value;
_type = other._type;
if (_metaData && other._metaData) {
*_metaData = *other._metaData;
} else {
_metaData = NULL;
}
return *this;
} }
void Fact::forceSetValue(const QVariant& value) void Fact::forceSetValue(const QVariant& value)
......
...@@ -40,9 +40,12 @@ class Fact : public QObject ...@@ -40,9 +40,12 @@ class Fact : public QObject
Q_OBJECT Q_OBJECT
public: public:
Fact(void); Fact(QObject* parent = NULL);
Fact(int componentId, QString name, FactMetaData::ValueType_t type, QObject* parent = NULL); Fact(int componentId, QString name, FactMetaData::ValueType_t type, QObject* parent = NULL);
Fact(const Fact& other, QObject* parent = NULL);
const Fact& operator=(const Fact& other);
Q_PROPERTY(int componentId READ componentId CONSTANT) Q_PROPERTY(int componentId READ componentId CONSTANT)
Q_PROPERTY(QString name READ name CONSTANT) Q_PROPERTY(QString name READ name CONSTANT)
Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged USER true) Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged USER true)
......
...@@ -32,6 +32,20 @@ ...@@ -32,6 +32,20 @@
#include <limits> #include <limits>
FactMetaData::FactMetaData(QObject* parent) :
QObject(parent),
_group("*Default Group"),
_type(valueTypeInt32),
_defaultValue(0),
_defaultValueAvailable(false),
_min(_minForType()),
_max(_maxForType()),
_minIsDefaultForType(true),
_maxIsDefaultForType(true)
{
}
FactMetaData::FactMetaData(ValueType_t type, QObject* parent) : FactMetaData::FactMetaData(ValueType_t type, QObject* parent) :
QObject(parent), QObject(parent),
_group("*Default Group"), _group("*Default Group"),
...@@ -46,6 +60,26 @@ FactMetaData::FactMetaData(ValueType_t type, QObject* parent) : ...@@ -46,6 +60,26 @@ FactMetaData::FactMetaData(ValueType_t type, QObject* parent) :
} }
FactMetaData::FactMetaData(const FactMetaData& other, QObject* parent)
: QObject(parent)
{
*this = other;
}
const FactMetaData& FactMetaData::operator=(const FactMetaData& other)
{
_group = other._group;
_type = other._type;
_defaultValue = other._defaultValue;
_defaultValueAvailable = other._defaultValueAvailable;
_min = other._min;
_max = other._max;
_minIsDefaultForType = other._minIsDefaultForType;
_maxIsDefaultForType = other._maxIsDefaultForType;
return *this;
}
QVariant FactMetaData::defaultValue(void) QVariant FactMetaData::defaultValue(void)
{ {
if (_defaultValueAvailable) { if (_defaultValueAvailable) {
......
...@@ -52,7 +52,11 @@ public: ...@@ -52,7 +52,11 @@ public:
valueTypeDouble valueTypeDouble
} ValueType_t; } ValueType_t;
FactMetaData(QObject* parent = NULL);
FactMetaData(ValueType_t type, QObject* parent = NULL); FactMetaData(ValueType_t type, QObject* parent = NULL);
FactMetaData(const FactMetaData& other, QObject* parent = NULL);
const FactMetaData& operator=(const FactMetaData& other);
// Property accessors // Property accessors
QString name(void) { return _name; } QString name(void) { return _name; }
......
This diff is collapsed.
...@@ -53,7 +53,7 @@ public: ...@@ -53,7 +53,7 @@ public:
int frame = MAV_FRAME_GLOBAL, int frame = MAV_FRAME_GLOBAL,
int action = MAV_CMD_NAV_WAYPOINT); int action = MAV_CMD_NAV_WAYPOINT);
MissionItem(const MissionItem& other); MissionItem(const MissionItem& other, QObject* parent = NULL);
~MissionItem(); ~MissionItem();
const MissionItem& operator=(const MissionItem& other); const MissionItem& operator=(const MissionItem& other);
...@@ -125,23 +125,23 @@ public: ...@@ -125,23 +125,23 @@ public:
bool getAutoContinue() const { bool getAutoContinue() const {
return _autocontinue; return _autocontinue;
} }
double getLoiterOrbit() const { double loiterOrbitRadius() const {
return _orbit; return _loiterOrbitRadiusFact->value().toDouble();
} }
double getAcceptanceRadius() const { double getAcceptanceRadius() const {
return _param2; return getParam2();
} }
double getHoldTime() const { double getHoldTime() const {
return _param1; return getParam1();
} }
double getParam1() const { double getParam1() const {
return _param1; return _param1Fact->value().toDouble();
} }
double getParam2() const { double getParam2() const {
return _param2; return _param2Fact->value().toDouble();
} }
double getParam3() const { double getParam3() const {
return _orbit; return loiterOrbitRadius();
} }
double getParam4() const { double getParam4() const {
return yawRadians(); return yawRadians();
...@@ -195,7 +195,7 @@ public: ...@@ -195,7 +195,7 @@ public:
void setFrame (int _frame); void setFrame (int _frame);
void setAutocontinue(bool autoContinue); void setAutocontinue(bool autoContinue);
void setCurrent (bool _current); void setCurrent (bool _current);
void setLoiterOrbit (double _orbit); void setLoiterOrbitRadius (double radius);
void setParam1 (double _param1); void setParam1 (double _param1);
void setParam2 (double _param2); void setParam2 (double _param2);
void setParam3 (double param3); void setParam3 (double param3);
...@@ -226,27 +226,20 @@ private: ...@@ -226,27 +226,20 @@ private:
int _sequenceNumber; int _sequenceNumber;
QGeoCoordinate _coordinate; QGeoCoordinate _coordinate;
double _yawRadians;
int _frame; int _frame;
int _action; int _action;
bool _autocontinue; bool _autocontinue;
bool _isCurrentItem; bool _isCurrentItem;
double _orbit;
double _param1;
double _param2;
quint64 _reachedTime; quint64 _reachedTime;
Fact* _yawFact; Fact* _yawRadiansFact;
Fact* _pitchFact; Fact* _loiterOrbitRadiusFact;
Fact* _loiterRadiusFact;
Fact* _param1Fact; Fact* _param1Fact;
Fact* _param2Fact; Fact* _param2Fact;
FactMetaData* _yawMetaData;
FactMetaData* _pitchMetaData; FactMetaData* _pitchMetaData;
FactMetaData* _acceptanceRadiusMetaData; FactMetaData* _acceptanceRadiusMetaData;
FactMetaData* _holdTimeMetaData; FactMetaData* _holdTimeMetaData;
FactMetaData* _loiterRadiusMetaData;
FactMetaData* _loiterTurnsMetaData; FactMetaData* _loiterTurnsMetaData;
FactMetaData* _loiterSecondsMetaData; FactMetaData* _loiterSecondsMetaData;
FactMetaData* _delaySecondsMetaData; FactMetaData* _delaySecondsMetaData;
......
...@@ -104,7 +104,7 @@ QRectF Waypoint2DIcon::boundingRect() const ...@@ -104,7 +104,7 @@ QRectF Waypoint2DIcon::boundingRect() const
} }
if (((waypoint->getAction() == (int)MAV_CMD_NAV_LOITER_UNLIM) || (waypoint->getAction() == (int)MAV_CMD_NAV_LOITER_TIME) || (waypoint->getAction() == (int)MAV_CMD_NAV_LOITER_TURNS))) if (((waypoint->getAction() == (int)MAV_CMD_NAV_LOITER_UNLIM) || (waypoint->getAction() == (int)MAV_CMD_NAV_LOITER_TIME) || (waypoint->getAction() == (int)MAV_CMD_NAV_LOITER_TURNS)))
{ {
loiter = map->metersToPixels(waypoint->getLoiterOrbit(), coord); loiter = map->metersToPixels(waypoint->loiterOrbitRadius(), coord);
} }
} }
...@@ -306,7 +306,7 @@ void Waypoint2DIcon::paint(QPainter *painter, const QStyleOptionGraphicsItem *op ...@@ -306,7 +306,7 @@ void Waypoint2DIcon::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
penDash.setWidth(1); penDash.setWidth(1);
//penDash.setStyle(Qt::DotLine); //penDash.setStyle(Qt::DotLine);
// A negative radius indicates counter-clockwise rotation, but we still want to draw it positive // A negative radius indicates counter-clockwise rotation, but we still want to draw it positive
const int loiter = map->metersToPixels(fabs(waypoint->getLoiterOrbit()), Coord()); const int loiter = map->metersToPixels(fabs(waypoint->loiterOrbitRadius()), Coord());
if (loiter > picture.width()/2) if (loiter > picture.width()/2)
{ {
painter->setPen(penBlack); painter->setPen(penBlack);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment