mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3948 HoloLens : Support for export of text labels. Also added more detailed debug information.
This commit is contained in:
parent
64395e8aa3
commit
ccff90b1d5
@ -272,10 +272,10 @@ void RicHoloLensRestClient::slotSendMetaDataFinished()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RicHoloLensRestClient::sendBinaryData(const QByteArray& binaryDataArr)
|
void RicHoloLensRestClient::sendBinaryData(const QByteArray& binaryDataArr, QByteArray dbgTagString)
|
||||||
{
|
{
|
||||||
const QString url = m_serverUrl + "/sessions/" + m_sessionName + "/data";
|
const QString url = m_serverUrl + "/sessions/" + m_sessionName + "/data";
|
||||||
cvf::Trace::show("sendBinaryData: POST on url: %s", url.toLatin1().constData());
|
cvf::Trace::show("sendBinaryData(%s): POST on url: %s", dbgTagString.constData(), url.toLatin1().constData());
|
||||||
|
|
||||||
const qint64 sendStartTimeStamp_ms = getCurrentTimeStamp_ms();
|
const qint64 sendStartTimeStamp_ms = getCurrentTimeStamp_ms();
|
||||||
|
|
||||||
@ -285,6 +285,7 @@ void RicHoloLensRestClient::sendBinaryData(const QByteArray& binaryDataArr)
|
|||||||
|
|
||||||
QNetworkReply* reply = m_accessManager.post(request, binaryDataArr);
|
QNetworkReply* reply = m_accessManager.post(request, binaryDataArr);
|
||||||
reply->setProperty("holo_sendStartTimeStamp_ms", QVariant(sendStartTimeStamp_ms));
|
reply->setProperty("holo_sendStartTimeStamp_ms", QVariant(sendStartTimeStamp_ms));
|
||||||
|
reply->setProperty("holo_dbgTagString", QVariant(dbgTagString));
|
||||||
|
|
||||||
connect(reply, SIGNAL(finished()), SLOT(slotSendBinaryDataFinished()));
|
connect(reply, SIGNAL(finished()), SLOT(slotSendBinaryDataFinished()));
|
||||||
|
|
||||||
@ -323,9 +324,18 @@ void RicHoloLensRestClient::slotSendBinaryDataFinished()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QByteArray dbgTagString;
|
||||||
|
{
|
||||||
|
QVariant var = reply->property("holo_dbgTagString");
|
||||||
|
if (var.type() == QVariant::ByteArray)
|
||||||
|
{
|
||||||
|
dbgTagString = var.toByteArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
|
||||||
cvf::Trace::show("sendBinaryData OK, elapsedTime=%.2fs", elapsedTime_s);
|
cvf::Trace::show("sendBinaryData(%s) OK, elapsedTime=%.2fs", dbgTagString.constData(), elapsedTime_s);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -343,18 +353,28 @@ void RicHoloLensRestClient::slotDbgUploadProgress(qint64 bytesSent, qint64 bytes
|
|||||||
if (pct % 10 == 0 && pct != sl_lastPct)
|
if (pct % 10 == 0 && pct != sl_lastPct)
|
||||||
{
|
{
|
||||||
double elapsedTime_s = -1;
|
double elapsedTime_s = -1;
|
||||||
|
QByteArray dbgTagString;
|
||||||
QNetworkReply* reply = dynamic_cast<QNetworkReply*>(sender());
|
QNetworkReply* reply = dynamic_cast<QNetworkReply*>(sender());
|
||||||
if (reply)
|
if (reply)
|
||||||
{
|
{
|
||||||
QVariant var = reply->property("holo_sendStartTimeStamp_ms");
|
|
||||||
if (var.type() == QVariant::LongLong)
|
|
||||||
{
|
{
|
||||||
const qint64 startTimeStamp_ms = var.toLongLong();
|
QVariant var = reply->property("holo_sendStartTimeStamp_ms");
|
||||||
elapsedTime_s = (getCurrentTimeStamp_ms() - startTimeStamp_ms)/1000.0;
|
if (var.type() == QVariant::LongLong)
|
||||||
|
{
|
||||||
|
const qint64 startTimeStamp_ms = var.toLongLong();
|
||||||
|
elapsedTime_s = (getCurrentTimeStamp_ms() - startTimeStamp_ms)/1000.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
QVariant var = reply->property("holo_dbgTagString");
|
||||||
|
if (var.type() == QVariant::ByteArray)
|
||||||
|
{
|
||||||
|
dbgTagString = var.toByteArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cvf::Trace::show("Sending progress: %3d%%, %.2f/%.2fMB (elapsedTime=%.2fs)", pct, bytesSent/(1024.0*1024.0), bytesTotal/(1024.0*1024.0), elapsedTime_s);
|
cvf::Trace::show("Progress sendBinaryData(%s): %3d%%, %.2f/%.2fMB (elapsedTime=%.2fs)", dbgTagString.constData(), pct, bytesSent/(1024.0*1024.0), bytesTotal/(1024.0*1024.0), elapsedTime_s);
|
||||||
sl_lastPct = pct;
|
sl_lastPct = pct;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public:
|
|||||||
void createSession(const QByteArray& sessionPinCode);
|
void createSession(const QByteArray& sessionPinCode);
|
||||||
void deleteSession();
|
void deleteSession();
|
||||||
void sendMetaData(int metaDataSequenceNumber, const QString& jsonMetaDataString);
|
void sendMetaData(int metaDataSequenceNumber, const QString& jsonMetaDataString);
|
||||||
void sendBinaryData(const QByteArray& binaryDataArr);
|
void sendBinaryData(const QByteArray& binaryDataArr, QByteArray dbgTagString);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addBearerAuthenticationHeaderToRequest(QNetworkRequest* request) const;
|
void addBearerAuthenticationHeaderToRequest(QNetworkRequest* request) const;
|
||||||
|
@ -295,7 +295,7 @@ void RicHoloLensSession::handleSuccessfulSendMetaData(int metaDataSequenceNumber
|
|||||||
|
|
||||||
RiaLogging::info(QString("HoloLens: sending array id: %1, %2KB (%3 bytes)").arg(arrayId).arg(packetByteArr.size()/1024.0, 0, 'f', 2).arg(packetByteArr.size()));
|
RiaLogging::info(QString("HoloLens: sending array id: %1, %2KB (%3 bytes)").arg(arrayId).arg(packetByteArr.size()/1024.0, 0, 'f', 2).arg(packetByteArr.size()));
|
||||||
|
|
||||||
m_restClient->sendBinaryData(packetByteArr);
|
m_restClient->sendBinaryData(packetByteArr, "arrId" + QByteArray::number(arrayId));
|
||||||
|
|
||||||
totalNumArraysSent++;
|
totalNumArraysSent++;
|
||||||
totalBytesSent += packetByteArr.size();
|
totalBytesSent += packetByteArr.size();
|
||||||
@ -316,7 +316,7 @@ void RicHoloLensSession::handleSuccessfulSendMetaData(int metaDataSequenceNumber
|
|||||||
|
|
||||||
RiaLogging::info(QString("HoloLens: Sending data to server (%1 arrays combined), %2KB (%3 bytes)").arg(totalNumArraysSent).arg(totalBytesSent/1024.0, 0, 'f', 2).arg(totalBytesSent));
|
RiaLogging::info(QString("HoloLens: Sending data to server (%1 arrays combined), %2KB (%3 bytes)").arg(totalNumArraysSent).arg(totalBytesSent/1024.0, 0, 'f', 2).arg(totalBytesSent));
|
||||||
|
|
||||||
m_restClient->sendBinaryData(combinedPacketArr);
|
m_restClient->sendBinaryData(combinedPacketArr, "metaSeqNum" + QByteArray::number(metaDataSequenceNumber));
|
||||||
}
|
}
|
||||||
|
|
||||||
const double totalMb = totalBytesSent/(1024.0*1024.0);
|
const double totalMb = totalBytesSent/(1024.0*1024.0);
|
||||||
|
@ -63,9 +63,6 @@ void VdeVizDataExtractor::extractViewContents(QString* modelMetaJsonStr, std::ve
|
|||||||
// First extract the parts (cvfPart + info) to be exported from from the ResInsight view
|
// First extract the parts (cvfPart + info) to be exported from from the ResInsight view
|
||||||
const std::vector<VdeExportPart> exportPartsArr = RicHoloLensExportImpl::partsForExport(m_view);
|
const std::vector<VdeExportPart> exportPartsArr = RicHoloLensExportImpl::partsForExport(m_view);
|
||||||
|
|
||||||
// TODO: Convert this into JSON data
|
|
||||||
const std::vector<std::pair<cvf::Vec3f, cvf::String>> labelAndPositions = RicHoloLensExportImpl::labelsForExport(m_view);
|
|
||||||
|
|
||||||
// Convert this to an array of export ready meshes
|
// Convert this to an array of export ready meshes
|
||||||
const std::vector<std::unique_ptr<VdeMesh> > meshArr = buildMeshArray(exportPartsArr);
|
const std::vector<std::unique_ptr<VdeMesh> > meshArr = buildMeshArray(exportPartsArr);
|
||||||
const int buildMeshes_ms = static_cast<int>(tim.lapTime()*1000);
|
const int buildMeshes_ms = static_cast<int>(tim.lapTime()*1000);
|
||||||
@ -160,7 +157,11 @@ void VdeVizDataExtractor::extractViewContents(QString* modelMetaJsonStr, std::ve
|
|||||||
const int fillPacketDir_ms = static_cast<int>(tim.lapTime()*1000);
|
const int fillPacketDir_ms = static_cast<int>(tim.lapTime()*1000);
|
||||||
|
|
||||||
|
|
||||||
*modelMetaJsonStr = createModelMetaJsonString(meshArr, allMeshesArrayIdsArr);
|
// Extract any exportable labels present in the view
|
||||||
|
const std::vector<std::pair<cvf::Vec3f, cvf::String>> labelAndPositionsArr = RicHoloLensExportImpl::labelsForExport(m_view);
|
||||||
|
|
||||||
|
// Actually create the JSON containing model meta data
|
||||||
|
*modelMetaJsonStr = createModelMetaJsonString(meshArr, allMeshesArrayIdsArr, labelAndPositionsArr);
|
||||||
|
|
||||||
// Find all unique packet array IDs referenced
|
// Find all unique packet array IDs referenced
|
||||||
std::set<int> referencedIdsSet;
|
std::set<int> referencedIdsSet;
|
||||||
@ -318,10 +319,9 @@ std::unique_ptr<VdeMesh> VdeVizDataExtractor::createMeshFromExportPart(const Vde
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QString VdeVizDataExtractor::createModelMetaJsonString(const std::vector<std::unique_ptr<VdeMesh> >& meshArr, const std::vector<VdeMeshArrayIds>& meshContentIdsArr)
|
QString VdeVizDataExtractor::createModelMetaJsonString(const std::vector<std::unique_ptr<VdeMesh> >& meshArr, const std::vector<VdeMeshArrayIds>& meshContentIdsArr, const std::vector<std::pair<cvf::Vec3f, cvf::String> >& labelAndPositionsArr)
|
||||||
{
|
{
|
||||||
QVariantList jsonMeshMetaList;
|
QVariantList jsonMeshMetaList;
|
||||||
|
|
||||||
for (size_t i = 0; i < meshArr.size(); i++)
|
for (size_t i = 0; i < meshArr.size(); i++)
|
||||||
{
|
{
|
||||||
const VdeMesh* mesh = meshArr[i].get();
|
const VdeMesh* mesh = meshArr[i].get();
|
||||||
@ -360,9 +360,30 @@ QString VdeVizDataExtractor::createModelMetaJsonString(const std::vector<std::un
|
|||||||
jsonMeshMetaList.push_back(jsonMeshMeta);
|
jsonMeshMetaList.push_back(jsonMeshMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantList jsonLabelList;
|
||||||
|
for (size_t i = 0; i < labelAndPositionsArr.size(); i++)
|
||||||
|
{
|
||||||
|
const cvf::Vec3f& pos = labelAndPositionsArr[i].first;
|
||||||
|
const cvf::String& txt = labelAndPositionsArr[i].second;
|
||||||
|
|
||||||
|
QMap<QString, QVariant> jsonPos;
|
||||||
|
jsonPos["x"] = pos.x();
|
||||||
|
jsonPos["y"] = pos.y();
|
||||||
|
jsonPos["z"] = pos.z();
|
||||||
|
|
||||||
|
QMap<QString, QVariant> jsonLabelEntry;
|
||||||
|
jsonLabelEntry["position"] = jsonPos;
|
||||||
|
jsonLabelEntry["text"] = txt.toAscii().ptr();
|
||||||
|
|
||||||
|
jsonLabelList.push_back(jsonLabelEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QMap<QString, QVariant> jsonModelMeta;
|
QMap<QString, QVariant> jsonModelMeta;
|
||||||
jsonModelMeta["modelName"] = "ResInsightExport";
|
jsonModelMeta["modelName"] = "ResInsightExport";
|
||||||
jsonModelMeta["meshArr"] = jsonMeshMetaList;
|
jsonModelMeta["meshArr"] = jsonMeshMetaList;
|
||||||
|
jsonModelMeta["labelsArr"] = jsonLabelList;
|
||||||
|
|
||||||
ResInsightInternalJson::Json jsonCodec;
|
ResInsightInternalJson::Json jsonCodec;
|
||||||
const bool prettifyJson = true;
|
const bool prettifyJson = true;
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#include "cvfBase.h"
|
#include "cvfBase.h"
|
||||||
#include "cvfColor3.h"
|
#include "cvfColor3.h"
|
||||||
#include "cvfArray.h"
|
#include "cvfArray.h"
|
||||||
|
#include "cvfVector3.h"
|
||||||
|
#include "cvfString.h"
|
||||||
#include "cvfTextureImage.h"
|
#include "cvfTextureImage.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@ -100,7 +102,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
static std::vector<std::unique_ptr<VdeMesh> > buildMeshArray(const std::vector<VdeExportPart>& exportPartsArr);
|
static std::vector<std::unique_ptr<VdeMesh> > buildMeshArray(const std::vector<VdeExportPart>& exportPartsArr);
|
||||||
static std::unique_ptr<VdeMesh> createMeshFromExportPart(const VdeExportPart& exportPart);
|
static std::unique_ptr<VdeMesh> createMeshFromExportPart(const VdeExportPart& exportPart);
|
||||||
static QString createModelMetaJsonString(const std::vector<std::unique_ptr<VdeMesh> >& meshArr, const std::vector<VdeMeshArrayIds>& meshContentIdsArr);
|
static QString createModelMetaJsonString(const std::vector<std::unique_ptr<VdeMesh> >& meshArr, const std::vector<VdeMeshArrayIds>& meshContentIdsArr, const std::vector<std::pair<cvf::Vec3f, cvf::String> >& labelAndPositionsArr);
|
||||||
static void debugComparePackets(const VdeArrayDataPacket& packetA, const VdeArrayDataPacket& packetB);
|
static void debugComparePackets(const VdeArrayDataPacket& packetA, const VdeArrayDataPacket& packetB);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user