#pragma once #include #include #include #include "cameraviewposition.h" namespace VCtrl { class ViewWidget; } namespace BuildingViewer { class ViewWidgetState { public: explicit ViewWidgetState(VCtrl::ViewWidget *pView); explicit ViewWidgetState(const QJsonObject &jsonObj) { m_featureID = jsonObj[QStringLiteral("featureID")].toString().toStdString(); m_usedTransparencyValue = jsonObj[QStringLiteral("usedTransparencyValue")].toDouble(); m_posCamera.m_top = jsonObj[QStringLiteral("posCameraTop")].toDouble(); m_posCamera.m_left = jsonObj[QStringLiteral("posCameraLeft")].toDouble(); m_posCamera.m_bottom = jsonObj[QStringLiteral("posCameraBottom")].toDouble(); m_posCamera.m_right = jsonObj[QStringLiteral("posCameraRight")].toDouble(); m_windowWidth = jsonObj[QStringLiteral("windowWidth")].toInt(); m_windowHeight = jsonObj[QStringLiteral("windowHeight")].toInt(); m_usesExactPos = jsonObj[QStringLiteral("usesExactPos")].toBool(); m_lockActive = jsonObj[QStringLiteral("lockActive")].toBool(); m_dotsActive = jsonObj[QStringLiteral("dotsActive")].toBool(); m_isMaximized = jsonObj[QStringLiteral("isMaximized")].toBool(); m_namesActive = jsonObj[QStringLiteral("namesActive")].toBool(); m_usesOrtho = jsonObj[QStringLiteral("usesOrtho")].toBool(); } QJsonObject toJson() const { return { {QStringLiteral("featureID"), QString::fromStdString(m_featureID)}, {QStringLiteral("usedTransparencyValue"), m_usedTransparencyValue}, {QStringLiteral("posCameraTop"), m_posCamera.m_top}, {QStringLiteral("posCameraLeft"), m_posCamera.m_left}, {QStringLiteral("posCameraBottom"), m_posCamera.m_bottom}, {QStringLiteral("posCameraRight"), m_posCamera.m_right}, {QStringLiteral("windowWidth"), m_windowWidth}, {QStringLiteral("windowHeight"), m_windowHeight}, {QStringLiteral("usesExactPos"), m_usesExactPos}, {QStringLiteral("lockActive"), m_lockActive}, {QStringLiteral("dotsActive"), m_dotsActive}, {QStringLiteral("namesActive"), m_namesActive}, {QStringLiteral("isMaximized"), m_isMaximized}, {QStringLiteral("usesOrtho"), m_usesOrtho}, }; } std::string m_featureID; // We use featureID (manual string description of a building) since contextID may differ/change depending on implementation double m_usedTransparencyValue = 0.0; BuildingViewer::CameraViewPosition m_posCamera; int m_windowWidth = -1, m_windowHeight = -1; bool m_lockActive = false; bool m_dotsActive = false; bool m_isMaximized = false; bool m_namesActive = false; bool m_usesOrtho = false; bool m_usesExactPos = false; }; }