diff --git a/ComponentBasic/ComponentBasic.vcxproj b/ComponentBasic/ComponentBasic.vcxproj index 5ede4b3..579a290 100644 --- a/ComponentBasic/ComponentBasic.vcxproj +++ b/ComponentBasic/ComponentBasic.vcxproj @@ -101,9 +101,12 @@ + + - + + diff --git a/ComponentBasic/ComponentBasic.vcxproj.filters b/ComponentBasic/ComponentBasic.vcxproj.filters index 71afe92..ef3a263 100644 --- a/ComponentBasic/ComponentBasic.vcxproj.filters +++ b/ComponentBasic/ComponentBasic.vcxproj.filters @@ -26,11 +26,22 @@ Header Files - - Source Files - Header Files + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + \ No newline at end of file diff --git a/ComponentBasic/MapRoute.cpp b/ComponentBasic/MapRoute.cpp new file mode 100644 index 0000000..8e5ec34 --- /dev/null +++ b/ComponentBasic/MapRoute.cpp @@ -0,0 +1 @@ +#include "MapRoute.h" diff --git a/ComponentBasic/MapRoute.h b/ComponentBasic/MapRoute.h new file mode 100644 index 0000000..9ddda31 --- /dev/null +++ b/ComponentBasic/MapRoute.h @@ -0,0 +1,5 @@ +#pragma once +class MapRoute +{ +}; + diff --git a/ComponentBasic/VisibleBox.cpp b/ComponentBasic/VisibleBox.cpp new file mode 100644 index 0000000..1e394f0 --- /dev/null +++ b/ComponentBasic/VisibleBox.cpp @@ -0,0 +1,60 @@ +#include "VisibleBox.h" + + +// 通过 ProcList 继承 +std::shared_ptr Visible3DPlugin::execute(std::shared_ptr in) { + auto ins = std::make_shared(); + ins->setPosition(_self_lla); + ins->setPosture(_self_posture); + ins->setTarget(_bind_entity, in->sourceEntity()); + ins->setVolume(_self_d3); + return ins; +} + +void Visible3DPlugin::recoveryFrom(const QJsonObject& obj) { + this->_bind_entity = obj["_bind_entity"].toVariant().toULongLong(); + DBL_PEAK(_self_d3._length_m); + DBL_PEAK(_self_d3._width_m); + DBL_PEAK(_self_d3._height_m); + + DBL_PEAK(_self_lla._lon_deg); + DBL_PEAK(_self_lla._lat_deg); + DBL_PEAK(_self_lla._alt_m); + + DBL_PEAK(_self_posture._azimuth_deg); + DBL_PEAK(_self_posture._pitch_deg); + DBL_PEAK(_self_posture._roll_deg); +} + +void Visible3DPlugin::saveTo(QJsonObject& obj) const { + obj["_bind_entity"] = QJsonValue::fromVariant(QVariant::fromValue(this->_bind_entity)); + + DBL_SAVE(_self_d3._length_m); + DBL_SAVE(_self_d3._width_m); + DBL_SAVE(_self_d3._height_m); + + DBL_SAVE(_self_lla._lon_deg); + DBL_SAVE(_self_lla._lat_deg); + DBL_SAVE(_self_lla._alt_m); + + DBL_SAVE(_self_posture._azimuth_deg); + DBL_SAVE(_self_posture._pitch_deg); + DBL_SAVE(_self_posture._roll_deg); +} + +std::shared_ptr Visible3DPlugin::defaultNew() const { + auto copy = std::make_shared(); + copy->_bind_entity = _bind_entity; + copy->_self_d3 = _self_d3; + copy->_self_lla = _self_lla; + copy->_self_posture = _self_posture; + return copy; +} + +void Visible3DPlugin::bindEntity(uint64_t entity_id) { + this->_bind_entity = entity_id; +} + +QString Visible3DPlugin::name() const { + return NAME(Visible3DPlugin); +} diff --git a/ComponentBasic/VisibleBox.h b/ComponentBasic/VisibleBox.h new file mode 100644 index 0000000..73c2a4b --- /dev/null +++ b/ComponentBasic/VisibleBox.h @@ -0,0 +1,31 @@ +#pragma once +#include "componentbasic.h" +#include +#include + +/// +/// 可视化3d体积盒 +/// +class COMPONENTBASIC_EXPORT Visible3DPlugin : public ProcList< + WsRespond +> +{ +private: + uint64_t _bind_entity = 0; + D3Data _self_d3; + LLAPos _self_lla; + Posture _self_posture; + +public: + explicit Visible3DPlugin() = default; + + // 通过 ProcList 继承 + void bindEntity(uint64_t entity_id) override; + QString name() const override; + + std::shared_ptr execute(std::shared_ptr in) override; + + std::shared_ptr defaultNew() const override; + void recoveryFrom(const QJsonObject& obj) override; + void saveTo(QJsonObject& obj) const override; +}; \ No newline at end of file diff --git a/ComponentBasic/componentbasic.cpp b/ComponentBasic/componentbasic.cpp deleted file mode 100644 index e658e37..0000000 --- a/ComponentBasic/componentbasic.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "componentbasic.h" diff --git a/ComponentBasic/componentbasic.h b/ComponentBasic/componentbasic.h index 133ac23..90716cc 100644 --- a/ComponentBasic/componentbasic.h +++ b/ComponentBasic/componentbasic.h @@ -88,25 +88,3 @@ struct ProcList : public _ProcRoute_, public WsComponent return list; } }; - -#include -class COMPONENTBASIC_EXPORT Visible3DPlugin : public ProcList< - WsRespond -> -{ -public: - - // 通过 ProcList 继承 - std::shared_ptr execute(std::shared_ptr in) override; - - void recoveryFrom(const QJsonObject& obj) override; - - void saveTo(QJsonObject& obj) const override; - - std::shared_ptr defaultNew() const override; - - void bindEntity(uint64_t entity_id) override; - - QString name() const override; - -}; \ No newline at end of file diff --git a/MessageBasic/messagebasic.cpp b/MessageBasic/messagebasic.cpp index 2ee2434..79c54e4 100644 --- a/MessageBasic/messagebasic.cpp +++ b/MessageBasic/messagebasic.cpp @@ -119,84 +119,112 @@ uint64_t RespondDefault::sourceEntity() const return _from_id; } -Get3DVolume::Get3DVolume() +Get3DBox::Get3DBox() { } -void Get3DVolume::reset(uint64_t from, uint64_t to) +void Get3DBox::reset(uint64_t from, uint64_t to) { _from_id = from; _to_id = to; } -void Get3DVolume::recoveryFrom(const QJsonObject& obj) +void Get3DBox::recoveryFrom(const QJsonObject& obj) { from_to_recovery(_from_id, _to_id, obj); } -void Get3DVolume::saveTo(QJsonObject& obj) const +void Get3DBox::saveTo(QJsonObject& obj) const { from_to_save(_from_id, _to_id, obj); } -QString Get3DVolume::topicString() const +QString Get3DBox::topicString() const { - return NAME(Get3DVolume); + return NAME(Get3DBox); } -uint64_t Get3DVolume::targetEntity() const +uint64_t Get3DBox::targetEntity() const { return _to_id; } -uint64_t Get3DVolume::sourceEntity() const +uint64_t Get3DBox::sourceEntity() const { return _from_id; } -Volume3DDesc::Volume3DDesc() +Box3DDesc::Box3DDesc() { } -void Volume3DDesc::reset(uint64_t from, uint64_t to, double l, double w, double h, double azi) -{ +void Box3DDesc::setTarget(uint64_t from, uint64_t to) { _from_id = from; _to_id = to; - _length = l; - _width = w; - _height = h; - _azimuth_deg = azi; } -void Volume3DDesc::recoveryFrom(const QJsonObject& obj) +void Box3DDesc::setVolume(const D3Data& d) { + this->_d3_data = d; +} + +D3Data Box3DDesc::volume() const { return this->_d3_data; } + +void Box3DDesc::setPosture(const Posture& p) { + _posture_d3 = p; +} + +Posture Box3DDesc::posture() const { return this->_posture_d3; } + +void Box3DDesc::setPosition(const LLAPos& lla) { + _lla_pos = lla; +} + +LLAPos Box3DDesc::position() const { return this->_lla_pos; } + +void Box3DDesc::recoveryFrom(const QJsonObject& obj) { from_to_recovery(_from_id, _to_id, obj); - _length = obj["length"].toDouble(); - _width = obj["width"].toDouble(); - _height = obj["height"].toDouble(); - _azimuth_deg = obj["azimuth_deg"].toDouble(); + DBL_PEAK(this->_d3_data._height_m); + DBL_PEAK(this->_d3_data._length_m); + DBL_PEAK(this->_d3_data._width_m); + + DBL_PEAK(this->_lla_pos._lon_deg); + DBL_PEAK(this->_lla_pos._lat_deg); + DBL_PEAK(this->_lla_pos._alt_m); + + DBL_PEAK(this->_posture_d3._azimuth_deg); + DBL_PEAK(this->_posture_d3._pitch_deg); + DBL_PEAK(this->_posture_d3._roll_deg); } -void Volume3DDesc::saveTo(QJsonObject& obj) const +void Box3DDesc::saveTo(QJsonObject& obj) const { from_to_save(_from_id, _to_id, obj); - obj["length"] = _length; - obj["width"] = _width; - obj["height"] = _height; - obj["azimuth_deg"] = _azimuth_deg; + + DBL_SAVE(this->_d3_data._height_m); + DBL_SAVE(this->_d3_data._length_m); + DBL_SAVE(this->_d3_data._width_m); + + DBL_SAVE(this->_lla_pos._lon_deg); + DBL_SAVE(this->_lla_pos._lat_deg); + DBL_SAVE(this->_lla_pos._alt_m); + + DBL_SAVE(this->_posture_d3._azimuth_deg); + DBL_SAVE(this->_posture_d3._pitch_deg); + DBL_SAVE(this->_posture_d3._roll_deg); } -QString Volume3DDesc::topicString() const +QString Box3DDesc::topicString() const { - return NAME(Volume3DDesc); + return NAME(Box3DDesc); } -uint64_t Volume3DDesc::targetEntity() const +uint64_t Box3DDesc::targetEntity() const { return _to_id; } -uint64_t Volume3DDesc::sourceEntity() const +uint64_t Box3DDesc::sourceEntity() const { return _from_id; } diff --git a/MessageBasic/messagebasic.h b/MessageBasic/messagebasic.h index 4aaca90..4fc65f3 100644 --- a/MessageBasic/messagebasic.h +++ b/MessageBasic/messagebasic.h @@ -4,13 +4,15 @@ #include "simsbasic.h" #define NAME(v) #v +#define DBL_SAVE(u) obj[NAME(u)] = u +#define DBL_PEAK(u) u = obj[NAME(u)].toDouble() /// /// 推演请求 /// class MESSAGEBASIC_EXPORT DeduceRequest : public WsMessage { private: - uint64_t _from_id, _to_id; + uint64_t _from_id = 0, _to_id = 0; public: DeduceRequest(); @@ -30,7 +32,7 @@ public: /// class MESSAGEBASIC_EXPORT RespondDefault : public WsMessage { private: - uint64_t _from_id, _to_id; + uint64_t _from_id = 0, _to_id = 0; double _time_consume; public: @@ -53,7 +55,7 @@ public: /// class MESSAGEBASIC_EXPORT SyncRequest : public WsMessage { private: - uint64_t _from_id, _to_id; + uint64_t _from_id = 0, _to_id = 0; double _time_current; public: @@ -69,12 +71,16 @@ public: uint64_t sourceEntity() const override; }; -class MESSAGEBASIC_EXPORT Get3DVolume : public WsMessage { +// 体积盒可视化插件定义消息 ======================================================= +/// +/// 获取体积盒详细数据 +/// +class MESSAGEBASIC_EXPORT Get3DBox : public WsMessage { private: uint64_t _from_id = 0, _to_id = 0; public: - Get3DVolume(); + Get3DBox(); void reset(uint64_t from, uint64_t to); @@ -86,16 +92,52 @@ public: uint64_t sourceEntity() const override; }; -class MESSAGEBASIC_EXPORT Volume3DDesc : public WsMessage { +/// +/// WGS84坐标系坐标类型 +/// +struct LLAPos { + double _lon_deg = 0; + double _lat_deg = 0; + double _alt_m = 0; +}; +/// +/// 姿态数据结构定义 +/// +struct Posture { + double _azimuth_deg = 0; + double _pitch_deg = 0; + double _roll_deg = 0; +}; +/// +/// 三维数据结构定义 +/// +struct D3Data{ + double _length_m = 0; + double _width_m = 0; + double _height_m = 0; +}; + +/// +/// 体积盒详细数据定义 +/// +class MESSAGEBASIC_EXPORT Box3DDesc : public WsMessage { private: - uint64_t _from_id, _to_id; - double _length, _width, _height; - double _azimuth_deg; + uint64_t _from_id = 0, _to_id = 0; + D3Data _d3_data; + Posture _posture_d3; + LLAPos _lla_pos; public: - Volume3DDesc(); + Box3DDesc(); + + void setTarget(uint64_t from, uint64_t to); + void setVolume(const D3Data &d); + D3Data volume() const; + void setPosture(const Posture &p); + Posture posture() const; + void setPosition(const LLAPos &lla); + LLAPos position() const; - void reset(uint64_t from, uint64_t to, double l, double w, double h, double azi); // 通过 WsMessage 继承 void recoveryFrom(const QJsonObject& obj) override; @@ -103,4 +145,4 @@ public: QString topicString() const override; uint64_t targetEntity() const override; uint64_t sourceEntity() const override; -}; \ No newline at end of file +};