#3523 Holo Lens : Add features for communication with web server

This commit is contained in:
Magne Sjaastad 2018-10-18 22:11:11 +02:00
parent e3b7cc0558
commit a87eca531c
12 changed files with 567 additions and 0 deletions

View File

@ -3,6 +3,12 @@ set (SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensExportToFolderFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensExportToFolderUi.h
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensExportImpl.h
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensExportToSharingServerFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensCreateSessionFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensTerminateSessionFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensServerSettings.h
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensCreateSessionUi.h
${CMAKE_CURRENT_LIST_DIR}/VdeArrayDataPacket.h
${CMAKE_CURRENT_LIST_DIR}/VdeExportPart.h
@ -13,6 +19,11 @@ set (SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensExportToFolderFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensExportImpl.cpp
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensExportToFolderUi.cpp
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensExportToSharingServerFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensCreateSessionFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensTerminateSessionFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensServerSettings.cpp
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensCreateSessionUi.cpp
${CMAKE_CURRENT_LIST_DIR}/VdeArrayDataPacket.cpp
${CMAKE_CURRENT_LIST_DIR}/VdeExportPart.cpp

View File

@ -0,0 +1,59 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 Statoil ASA
//
// ResInsight 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.
//
// ResInsight 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 at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicHoloLensCreateSessionFeature.h"
#include "RicHoloLensCreateSessionUi.h"
#include "RicHoloLensServerSettings.h"
#include "cafPdmSettings.h"
#include "cafPdmUiPropertyViewDialog.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicHoloLensCreateSessionFeature, "RicHoloLensCreateSessionFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicHoloLensCreateSessionFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicHoloLensCreateSessionFeature::onActionTriggered(bool isChecked)
{
RicHoloLensCreateSessionUi createSessionUi;
caf::PdmUiPropertyViewDialog propertyDialog(
nullptr, &createSessionUi, "HoloLens - Export Data Folder", "", QDialogButtonBox::Close);
propertyDialog.resize(QSize(400, 400));
propertyDialog.exec();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicHoloLensCreateSessionFeature::setupActionLook(QAction* actionToSetup)
{
// actionToSetup->setIcon(QIcon(":/Save.png"));
actionToSetup->setText("HoloLens : Create Session");
}

View File

@ -0,0 +1,34 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 Statoil ASA
//
// ResInsight 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.
//
// ResInsight 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 at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicHoloLensCreateSessionFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
private:
bool isCommandEnabled() override;
void onActionTriggered(bool isChecked) override;
void setupActionLook(QAction* actionToSetup) override;
};

View File

@ -0,0 +1,141 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 Statoil ASA
//
// ResInsight 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.
//
// ResInsight 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 at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicHoloLensCreateSessionUi.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RiaOptionItemFactory.h"
#include "RicHoloLensServerSettings.h"
#include "cafPdmSettings.h"
#include "cafPdmUiFilePathEditor.h"
#include "cafPdmUiOrdering.h"
#include "cafPdmUiPushButtonEditor.h"
#include "cafPdmUiTextEditor.h"
CAF_PDM_SOURCE_INIT(RicHoloLensCreateSessionUi, "RicHoloLensCreateSessionUi");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicHoloLensCreateSessionUi::RicHoloLensCreateSessionUi()
{
CAF_PDM_InitObject("HoloLens Create Session", "", "", "");
CAF_PDM_InitField(&m_createSession, "CreateSession", false, "", "", "", "");
caf::PdmUiPushButtonEditor::configureEditorForField(&m_createSession);
CAF_PDM_InitField(&m_sessionName, "SessionName", QString("DummySessionName"), "Session Name", "", "", "");
CAF_PDM_InitField(&m_sessionPinCode, "SessionPinCode", QString("1234"), "Session Pin Code", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_serverSettings, "ServerSettings", "Server Settings", "", "", "");
m_serverSettings = new RicHoloLensServerSettings;
CAF_PDM_InitFieldNoDefault(&m_statusTextProxy, "StatusText", "Status Text", "", "", "");
m_statusTextProxy.registerGetMethod(this, &RicHoloLensCreateSessionUi::getStatusText);
m_statusTextProxy.uiCapability()->setUiEditorTypeName(caf::PdmUiTextEditor::uiEditorTypeName());
m_statusTextProxy.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);
caf::PdmSettings::readFieldsFromApplicationStore(m_serverSettings);
m_statusText = "Server Status Unknown";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicHoloLensCreateSessionUi::~RicHoloLensCreateSessionUi()
{
caf::PdmSettings::writeFieldsToApplicationStore(m_serverSettings);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicHoloLensCreateSessionUi::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue)
{
if (changedField == &m_createSession)
{
if (m_createSession)
{
QString msg = "Created Session : " + m_sessionName;
setStatusText(msg);
RiaLogging::info(msg);
}
m_createSession = false;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicHoloLensCreateSessionUi::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
{
caf::PdmUiGroup* group = uiOrdering.addNewGroup("Server Configuration");
m_serverSettings->uiOrdering(uiConfigName, *group);
}
{
caf::PdmUiGroup* group = uiOrdering.addNewGroup("Create Session");
group->add(&m_sessionName);
group->add(&m_sessionPinCode);
group->add(&m_createSession);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicHoloLensCreateSessionUi::defineEditorAttribute(const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute)
{
if (field == &m_createSession)
{
caf::PdmUiPushButtonEditorAttribute* pbAttribute = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>(attribute);
if (pbAttribute)
{
pbAttribute->m_buttonText = "Create Session";
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicHoloLensCreateSessionUi::getStatusText() const
{
return m_statusText;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicHoloLensCreateSessionUi::setStatusText(const QString& statusText)
{
m_statusText = statusText;
}

View File

@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 Statoil ASA
//
// ResInsight 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.
//
// ResInsight 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 at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmChildField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmProxyValueField.h"
#include "cafPdmPtrField.h"
class RicHoloLensServerSettings;
//==================================================================================================
///
//==================================================================================================
class RicHoloLensCreateSessionUi : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RicHoloLensCreateSessionUi();
~RicHoloLensCreateSessionUi() override;
protected:
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
void defineEditorAttribute(const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute) override;
private:
QString getStatusText() const;
void setStatusText(const QString& statusText);
private:
caf::PdmChildField<RicHoloLensServerSettings*> m_serverSettings;
caf::PdmField<bool> m_createSession;
caf::PdmField<QString> m_sessionName;
caf::PdmField<QString> m_sessionPinCode;
caf::PdmProxyValueField<QString> m_statusTextProxy;
QString m_statusText;
};

View File

@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 Statoil ASA
//
// ResInsight 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.
//
// ResInsight 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 at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicHoloLensExportToSharingServerFeature.h"
#include "VdeFileExporter.h"
#include "RiaApplication.h"
#include "RimGridView.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicHoloLensExportToSharingServerFeature, "RicHoloLensExportToSharingServerFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicHoloLensExportToSharingServerFeature::isCommandEnabled()
{
// Return true if a valid session is active
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicHoloLensExportToSharingServerFeature::onActionTriggered(bool isChecked)
{
RimGridView* activeView = RiaApplication::instance()->activeGridView();
if (!activeView) return;
VdeFileExporter exporter("dummypath");
exporter.exportViewContents(*activeView);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicHoloLensExportToSharingServerFeature::setupActionLook(QAction* actionToSetup)
{
//actionToSetup->setIcon(QIcon(":/Save.png"));
actionToSetup->setText("HoloLens : Export to Sharing Server");
}

View File

@ -0,0 +1,34 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 Statoil ASA
//
// ResInsight 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.
//
// ResInsight 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 at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicHoloLensExportToSharingServerFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
private:
bool isCommandEnabled() override;
void onActionTriggered(bool isChecked) override;
void setupActionLook(QAction* actionToSetup) override;
};

View File

@ -0,0 +1,33 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 Statoil ASA
//
// ResInsight 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.
//
// ResInsight 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 at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicHoloLensServerSettings.h"
CAF_PDM_SOURCE_INIT(RicHoloLensServerSettings, "RicHoloLensServerSettings");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicHoloLensServerSettings::RicHoloLensServerSettings()
{
CAF_PDM_InitObject("HoloLens Server Settings", "", "", "");
CAF_PDM_InitField(&m_serverAddress, "ServerAddress", QString(), "Server Address", "", "", "");
}

View File

@ -0,0 +1,38 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 Statoil ASA
//
// ResInsight 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.
//
// ResInsight 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 at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmField.h"
#include "cafPdmObject.h"
class RimGridView;
//==================================================================================================
///
//==================================================================================================
class RicHoloLensServerSettings : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RicHoloLensServerSettings();
private:
caf::PdmField<QString> m_serverAddress;
};

View File

@ -0,0 +1,52 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 Statoil ASA
//
// ResInsight 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.
//
// ResInsight 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 at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicHoloLensTerminateSessionFeature.h"
#include "RiaLogging.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicHoloLensTerminateSessionFeature, "RicHoloLensTerminateSessionFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicHoloLensTerminateSessionFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicHoloLensTerminateSessionFeature::onActionTriggered(bool isChecked)
{
QString text = "HoloLens : Terminated Session 'MyName'";
RiaLogging::info(text);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicHoloLensTerminateSessionFeature::setupActionLook(QAction* actionToSetup)
{
//actionToSetup->setIcon(QIcon(":/Save.png"));
actionToSetup->setText("HoloLens : Terminate Session");
}

View File

@ -0,0 +1,34 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 Statoil ASA
//
// ResInsight 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.
//
// ResInsight 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 at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicHoloLensTerminateSessionFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
private:
bool isCommandEnabled() override;
void onActionTriggered(bool isChecked) override;
void setupActionLook(QAction* actionToSetup) override;
};

View File

@ -581,6 +581,17 @@ void RiuMainWindow::createToolBars()
dsToolBar->addAction(m_drawStyleHideGridCellsAction);
dsToolBar->addAction(m_toggleFaultsLabelAction);
dsToolBar->addAction(m_showWellCellsAction);
dsToolBar->hide();
}
{
QToolBar* toolbar = addToolBar(tr("HoloLens"));
toolbar->setObjectName(toolbar->windowTitle());
toolbar->addAction(cmdFeatureMgr->action("RicHoloLensCreateSessionFeature"));
toolbar->addAction(cmdFeatureMgr->action("RicHoloLensTerminateSessionFeature"));
toolbar->addAction(cmdFeatureMgr->action("RicHoloLensExportToSharingServerFeature"));
toolbar->hide();
}
RiaApplication* app = RiaApplication::instance();