mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3541 HoloLens : Use RicHoloLensSession to control state of toolbar buttons
This commit is contained in:
parent
24a075499e
commit
3f7d85e2e1
@ -22,11 +22,13 @@
|
|||||||
|
|
||||||
#include "RicHoloLensCreateSessionUi.h"
|
#include "RicHoloLensCreateSessionUi.h"
|
||||||
#include "RicHoloLensServerSettings.h"
|
#include "RicHoloLensServerSettings.h"
|
||||||
|
#include "RicHoloLensSession.h"
|
||||||
|
|
||||||
#include "cafPdmSettings.h"
|
#include "cafPdmSettings.h"
|
||||||
#include "cafPdmUiPropertyViewDialog.h"
|
#include "cafPdmUiPropertyViewDialog.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
CAF_CMD_SOURCE_INIT(RicHoloLensCreateSessionFeature, "RicHoloLensCreateSessionFeature");
|
CAF_CMD_SOURCE_INIT(RicHoloLensCreateSessionFeature, "RicHoloLensCreateSessionFeature");
|
||||||
|
|
||||||
@ -35,7 +37,7 @@ CAF_CMD_SOURCE_INIT(RicHoloLensCreateSessionFeature, "RicHoloLensCreateSessionFe
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool RicHoloLensCreateSessionFeature::isCommandEnabled()
|
bool RicHoloLensCreateSessionFeature::isCommandEnabled()
|
||||||
{
|
{
|
||||||
return true;
|
return !RicHoloLensSession::instance()->isSessionValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -45,10 +47,24 @@ void RicHoloLensCreateSessionFeature::onActionTriggered(bool isChecked)
|
|||||||
{
|
{
|
||||||
RicHoloLensCreateSessionUi createSessionUi;
|
RicHoloLensCreateSessionUi createSessionUi;
|
||||||
|
|
||||||
caf::PdmUiPropertyViewDialog propertyDialog(
|
caf::PdmUiPropertyViewDialog propertyDialog(nullptr, &createSessionUi, "HoloLens - Create Session", "");
|
||||||
nullptr, &createSessionUi, "HoloLens - Export Data Folder", "", QDialogButtonBox::Close);
|
propertyDialog.resize(QSize(400, 330));
|
||||||
propertyDialog.resize(QSize(400, 400));
|
|
||||||
|
{
|
||||||
|
QDialogButtonBox* dialogButtonBox = propertyDialog.dialogButtonBox();
|
||||||
|
dialogButtonBox->clear();
|
||||||
|
|
||||||
|
QPushButton* pushButton = dialogButtonBox->addButton("Create Session", QDialogButtonBox::ActionRole);
|
||||||
|
connect(pushButton, SIGNAL(clicked()), &propertyDialog, SLOT(close()));
|
||||||
|
}
|
||||||
|
|
||||||
propertyDialog.exec();
|
propertyDialog.exec();
|
||||||
|
|
||||||
|
RicHoloLensSession::instance()->createSession(
|
||||||
|
createSessionUi.serverUrl(), createSessionUi.sessionName(), createSessionUi.sessionPinCode());
|
||||||
|
|
||||||
|
RicHoloLensSession::refreshToolbarState();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -25,10 +25,7 @@
|
|||||||
#include "RicHoloLensServerSettings.h"
|
#include "RicHoloLensServerSettings.h"
|
||||||
|
|
||||||
#include "cafPdmSettings.h"
|
#include "cafPdmSettings.h"
|
||||||
#include "cafPdmUiFilePathEditor.h"
|
|
||||||
#include "cafPdmUiOrdering.h"
|
#include "cafPdmUiOrdering.h"
|
||||||
#include "cafPdmUiPushButtonEditor.h"
|
|
||||||
#include "cafPdmUiTextEditor.h"
|
|
||||||
|
|
||||||
CAF_PDM_SOURCE_INIT(RicHoloLensCreateSessionUi, "RicHoloLensCreateSessionUi");
|
CAF_PDM_SOURCE_INIT(RicHoloLensCreateSessionUi, "RicHoloLensCreateSessionUi");
|
||||||
|
|
||||||
@ -39,23 +36,13 @@ RicHoloLensCreateSessionUi::RicHoloLensCreateSessionUi()
|
|||||||
{
|
{
|
||||||
CAF_PDM_InitObject("HoloLens Create Session", "", "", "");
|
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_sessionName, "SessionName", QString("DummySessionName"), "Session Name", "", "", "");
|
||||||
CAF_PDM_InitField(&m_sessionPinCode, "SessionPinCode", QString("1234"), "Session Pin Code", "", "", "");
|
CAF_PDM_InitField(&m_sessionPinCode, "SessionPinCode", QString("1234"), "Session Pin Code", "", "", "");
|
||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault(&m_serverSettings, "ServerSettings", "Server Settings", "", "", "");
|
CAF_PDM_InitFieldNoDefault(&m_serverSettings, "ServerSettings", "Server Settings", "", "", "");
|
||||||
m_serverSettings = new RicHoloLensServerSettings;
|
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);
|
caf::PdmSettings::readFieldsFromApplicationStore(m_serverSettings);
|
||||||
|
|
||||||
m_statusText = "Server Status Unknown";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -67,24 +54,30 @@ RicHoloLensCreateSessionUi::~RicHoloLensCreateSessionUi()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RicHoloLensCreateSessionUi::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
|
QString RicHoloLensCreateSessionUi::serverUrl() const
|
||||||
const QVariant& oldValue,
|
|
||||||
const QVariant& newValue)
|
|
||||||
{
|
{
|
||||||
if (changedField == &m_createSession)
|
CVF_ASSERT(m_serverSettings());
|
||||||
{
|
|
||||||
if (m_createSession)
|
|
||||||
{
|
|
||||||
QString msg = "Created Session : " + m_sessionName;
|
|
||||||
setStatusText(msg);
|
|
||||||
|
|
||||||
RiaLogging::info(msg);
|
return m_serverSettings->serverUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_createSession = false;
|
//--------------------------------------------------------------------------------------------------
|
||||||
}
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QString RicHoloLensCreateSessionUi::sessionName() const
|
||||||
|
{
|
||||||
|
return m_sessionName;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QString RicHoloLensCreateSessionUi::sessionPinCode() const
|
||||||
|
{
|
||||||
|
return m_sessionPinCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -103,39 +96,5 @@ void RicHoloLensCreateSessionUi::defineUiOrdering(QString uiConfigName, caf::Pdm
|
|||||||
|
|
||||||
group->add(&m_sessionName);
|
group->add(&m_sessionName);
|
||||||
group->add(&m_sessionPinCode);
|
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;
|
|
||||||
}
|
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#include "cafPdmChildField.h"
|
#include "cafPdmChildField.h"
|
||||||
#include "cafPdmField.h"
|
#include "cafPdmField.h"
|
||||||
#include "cafPdmObject.h"
|
#include "cafPdmObject.h"
|
||||||
#include "cafPdmProxyValueField.h"
|
|
||||||
#include "cafPdmPtrField.h"
|
#include "cafPdmPtrField.h"
|
||||||
|
|
||||||
class RicHoloLensServerSettings;
|
class RicHoloLensServerSettings;
|
||||||
@ -37,24 +36,16 @@ public:
|
|||||||
RicHoloLensCreateSessionUi();
|
RicHoloLensCreateSessionUi();
|
||||||
~RicHoloLensCreateSessionUi() override;
|
~RicHoloLensCreateSessionUi() override;
|
||||||
|
|
||||||
protected:
|
QString serverUrl() const;
|
||||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
QString sessionName() const;
|
||||||
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
QString sessionPinCode() const;
|
||||||
void defineEditorAttribute(const caf::PdmFieldHandle* field,
|
|
||||||
QString uiConfigName,
|
|
||||||
caf::PdmUiEditorAttribute* attribute) override;
|
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
QString getStatusText() const;
|
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||||
void setStatusText(const QString& statusText);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
caf::PdmChildField<RicHoloLensServerSettings*> m_serverSettings;
|
caf::PdmChildField<RicHoloLensServerSettings*> m_serverSettings;
|
||||||
caf::PdmField<bool> m_createSession;
|
|
||||||
|
|
||||||
caf::PdmField<QString> m_sessionName;
|
caf::PdmField<QString> m_sessionName;
|
||||||
caf::PdmField<QString> m_sessionPinCode;
|
caf::PdmField<QString> m_sessionPinCode;
|
||||||
caf::PdmProxyValueField<QString> m_statusTextProxy;
|
|
||||||
|
|
||||||
QString m_statusText;
|
|
||||||
};
|
};
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include "RicHoloLensExportToSharingServerFeature.h"
|
#include "RicHoloLensExportToSharingServerFeature.h"
|
||||||
|
|
||||||
|
#include "RicHoloLensSession.h"
|
||||||
|
|
||||||
#include "VdeFileExporter.h"
|
#include "VdeFileExporter.h"
|
||||||
|
|
||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
@ -34,9 +36,7 @@ CAF_CMD_SOURCE_INIT(RicHoloLensExportToSharingServerFeature, "RicHoloLensExportT
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool RicHoloLensExportToSharingServerFeature::isCommandEnabled()
|
bool RicHoloLensExportToSharingServerFeature::isCommandEnabled()
|
||||||
{
|
{
|
||||||
// Return true if a valid session is active
|
return RicHoloLensSession::instance()->isSessionValid();
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -31,3 +31,11 @@ RicHoloLensServerSettings::RicHoloLensServerSettings()
|
|||||||
CAF_PDM_InitField(&m_serverAddress, "ServerAddress", QString(), "Server Address", "", "", "");
|
CAF_PDM_InitField(&m_serverAddress, "ServerAddress", QString(), "Server Address", "", "", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QString RicHoloLensServerSettings::serverUrl() const
|
||||||
|
{
|
||||||
|
return m_serverAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,8 @@ class RicHoloLensServerSettings : public caf::PdmObject
|
|||||||
public:
|
public:
|
||||||
RicHoloLensServerSettings();
|
RicHoloLensServerSettings();
|
||||||
|
|
||||||
|
QString serverUrl() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
caf::PdmField<QString> m_serverAddress;
|
caf::PdmField<QString> m_serverAddress;
|
||||||
};
|
};
|
||||||
|
@ -18,6 +18,10 @@
|
|||||||
|
|
||||||
#include "RicHoloLensSession.h"
|
#include "RicHoloLensSession.h"
|
||||||
|
|
||||||
|
#include "RiaLogging.h"
|
||||||
|
|
||||||
|
#include "cafCmdFeatureManager.h"
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -44,9 +48,15 @@ bool RicHoloLensSession::createSession(const QString& serverUrl, const QString&
|
|||||||
{
|
{
|
||||||
if (isSessionValid())
|
if (isSessionValid())
|
||||||
{
|
{
|
||||||
|
RiaLogging::error("Terminate existing session before creating a new session");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RiaLogging::info("url : " + serverUrl + " name : " + sessionName + " pinCode : " + sessionPinCode);
|
||||||
|
|
||||||
|
m_isSessionValid = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,6 +67,8 @@ bool RicHoloLensSession::createDummyFileBackedSession()
|
|||||||
{
|
{
|
||||||
if (isSessionValid())
|
if (isSessionValid())
|
||||||
{
|
{
|
||||||
|
RiaLogging::error("Terminate existing session before creating a new session");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,13 +90,34 @@ bool RicHoloLensSession::isSessionValid() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RicHoloLensSession::updateSessionDataFromView(RimGridView* activeView) {}
|
void RicHoloLensSession::updateSessionDataFromView(RimGridView* activeView)
|
||||||
|
{
|
||||||
|
RiaLogging::info("HoloLens : updateSessionDataFromView");
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RicHoloLensSession::terminateSession()
|
void RicHoloLensSession::terminateSession()
|
||||||
{
|
{
|
||||||
|
if (!isSessionValid()) return;
|
||||||
|
|
||||||
|
RiaLogging::info("Terminating HoloLens Session");
|
||||||
|
|
||||||
m_isDummySession = false;
|
m_isDummySession = false;
|
||||||
m_isSessionValid = false;
|
m_isSessionValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicHoloLensSession::refreshToolbarState()
|
||||||
|
{
|
||||||
|
QStringList commandIds;
|
||||||
|
|
||||||
|
commandIds << "RicHoloLensCreateSessionFeature";
|
||||||
|
commandIds << "RicHoloLensExportToSharingServerFeature";
|
||||||
|
commandIds << "RicHoloLensTerminateSessionFeature";
|
||||||
|
|
||||||
|
caf::CmdFeatureManager::instance()->refreshEnabledState(commandIds);
|
||||||
|
}
|
||||||
|
@ -40,6 +40,8 @@ public:
|
|||||||
void updateSessionDataFromView(RimGridView* activeView);
|
void updateSessionDataFromView(RimGridView* activeView);
|
||||||
void terminateSession();
|
void terminateSession();
|
||||||
|
|
||||||
|
static void refreshToolbarState();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_isSessionValid;
|
bool m_isSessionValid;
|
||||||
bool m_isDummySession;
|
bool m_isDummySession;
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include "RicHoloLensTerminateSessionFeature.h"
|
#include "RicHoloLensTerminateSessionFeature.h"
|
||||||
|
|
||||||
|
#include "RicHoloLensSession.h"
|
||||||
|
|
||||||
#include "RiaLogging.h"
|
#include "RiaLogging.h"
|
||||||
#include "RiaQIconTools.h"
|
#include "RiaQIconTools.h"
|
||||||
|
|
||||||
@ -30,7 +32,7 @@ CAF_CMD_SOURCE_INIT(RicHoloLensTerminateSessionFeature, "RicHoloLensTerminateSes
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool RicHoloLensTerminateSessionFeature::isCommandEnabled()
|
bool RicHoloLensTerminateSessionFeature::isCommandEnabled()
|
||||||
{
|
{
|
||||||
return true;
|
return RicHoloLensSession::instance()->isSessionValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -38,9 +40,9 @@ bool RicHoloLensTerminateSessionFeature::isCommandEnabled()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RicHoloLensTerminateSessionFeature::onActionTriggered(bool isChecked)
|
void RicHoloLensTerminateSessionFeature::onActionTriggered(bool isChecked)
|
||||||
{
|
{
|
||||||
QString text = "HoloLens : Terminated Session 'MyName'";
|
RicHoloLensSession::instance()->terminateSession();
|
||||||
|
|
||||||
RiaLogging::info(text);
|
RicHoloLensSession::refreshToolbarState();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user