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 "RicHoloLensServerSettings.h"
|
||||
#include "RicHoloLensSession.h"
|
||||
|
||||
#include "cafPdmSettings.h"
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QPushButton>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicHoloLensCreateSessionFeature, "RicHoloLensCreateSessionFeature");
|
||||
|
||||
@ -35,7 +37,7 @@ CAF_CMD_SOURCE_INIT(RicHoloLensCreateSessionFeature, "RicHoloLensCreateSessionFe
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicHoloLensCreateSessionFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
return !RicHoloLensSession::instance()->isSessionValid();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -45,10 +47,24 @@ void RicHoloLensCreateSessionFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RicHoloLensCreateSessionUi createSessionUi;
|
||||
|
||||
caf::PdmUiPropertyViewDialog propertyDialog(
|
||||
nullptr, &createSessionUi, "HoloLens - Export Data Folder", "", QDialogButtonBox::Close);
|
||||
propertyDialog.resize(QSize(400, 400));
|
||||
caf::PdmUiPropertyViewDialog propertyDialog(nullptr, &createSessionUi, "HoloLens - Create Session", "");
|
||||
propertyDialog.resize(QSize(400, 330));
|
||||
|
||||
{
|
||||
QDialogButtonBox* dialogButtonBox = propertyDialog.dialogButtonBox();
|
||||
dialogButtonBox->clear();
|
||||
|
||||
QPushButton* pushButton = dialogButtonBox->addButton("Create Session", QDialogButtonBox::ActionRole);
|
||||
connect(pushButton, SIGNAL(clicked()), &propertyDialog, SLOT(close()));
|
||||
}
|
||||
|
||||
propertyDialog.exec();
|
||||
|
||||
RicHoloLensSession::instance()->createSession(
|
||||
createSessionUi.serverUrl(), createSessionUi.sessionName(), createSessionUi.sessionPinCode());
|
||||
|
||||
RicHoloLensSession::refreshToolbarState();
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -25,10 +25,7 @@
|
||||
#include "RicHoloLensServerSettings.h"
|
||||
|
||||
#include "cafPdmSettings.h"
|
||||
#include "cafPdmUiFilePathEditor.h"
|
||||
#include "cafPdmUiOrdering.h"
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
#include "cafPdmUiTextEditor.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RicHoloLensCreateSessionUi, "RicHoloLensCreateSessionUi");
|
||||
|
||||
@ -39,23 +36,13 @@ 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";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -67,24 +54,30 @@ RicHoloLensCreateSessionUi::~RicHoloLensCreateSessionUi()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicHoloLensCreateSessionUi::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue)
|
||||
QString RicHoloLensCreateSessionUi::serverUrl() const
|
||||
{
|
||||
if (changedField == &m_createSession)
|
||||
{
|
||||
if (m_createSession)
|
||||
{
|
||||
QString msg = "Created Session : " + m_sessionName;
|
||||
setStatusText(msg);
|
||||
CVF_ASSERT(m_serverSettings());
|
||||
|
||||
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_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 "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmProxyValueField.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
class RicHoloLensServerSettings;
|
||||
@ -37,24 +36,16 @@ 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;
|
||||
QString serverUrl() const;
|
||||
QString sessionName() const;
|
||||
QString sessionPinCode() const;
|
||||
|
||||
private:
|
||||
QString getStatusText() const;
|
||||
void setStatusText(const QString& statusText);
|
||||
protected:
|
||||
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
|
||||
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;
|
||||
caf::PdmField<QString> m_sessionName;
|
||||
caf::PdmField<QString> m_sessionPinCode;
|
||||
};
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#include "RicHoloLensExportToSharingServerFeature.h"
|
||||
|
||||
#include "RicHoloLensSession.h"
|
||||
|
||||
#include "VdeFileExporter.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
@ -34,9 +36,7 @@ CAF_CMD_SOURCE_INIT(RicHoloLensExportToSharingServerFeature, "RicHoloLensExportT
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicHoloLensExportToSharingServerFeature::isCommandEnabled()
|
||||
{
|
||||
// Return true if a valid session is active
|
||||
|
||||
return true;
|
||||
return RicHoloLensSession::instance()->isSessionValid();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -31,3 +31,11 @@ RicHoloLensServerSettings::RicHoloLensServerSettings()
|
||||
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:
|
||||
RicHoloLensServerSettings();
|
||||
|
||||
QString serverUrl() const;
|
||||
|
||||
private:
|
||||
caf::PdmField<QString> m_serverAddress;
|
||||
};
|
||||
|
@ -18,6 +18,10 @@
|
||||
|
||||
#include "RicHoloLensSession.h"
|
||||
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "cafCmdFeatureManager.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -44,9 +48,15 @@ bool RicHoloLensSession::createSession(const QString& serverUrl, const QString&
|
||||
{
|
||||
if (isSessionValid())
|
||||
{
|
||||
RiaLogging::error("Terminate existing session before creating a new session");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
RiaLogging::info("url : " + serverUrl + " name : " + sessionName + " pinCode : " + sessionPinCode);
|
||||
|
||||
m_isSessionValid = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -57,6 +67,8 @@ bool RicHoloLensSession::createDummyFileBackedSession()
|
||||
{
|
||||
if (isSessionValid())
|
||||
{
|
||||
RiaLogging::error("Terminate existing session before creating a new session");
|
||||
|
||||
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()
|
||||
{
|
||||
if (!isSessionValid()) return;
|
||||
|
||||
RiaLogging::info("Terminating HoloLens Session");
|
||||
|
||||
m_isDummySession = 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 terminateSession();
|
||||
|
||||
static void refreshToolbarState();
|
||||
|
||||
private:
|
||||
bool m_isSessionValid;
|
||||
bool m_isDummySession;
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#include "RicHoloLensTerminateSessionFeature.h"
|
||||
|
||||
#include "RicHoloLensSession.h"
|
||||
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaQIconTools.h"
|
||||
|
||||
@ -30,7 +32,7 @@ CAF_CMD_SOURCE_INIT(RicHoloLensTerminateSessionFeature, "RicHoloLensTerminateSes
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicHoloLensTerminateSessionFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
return RicHoloLensSession::instance()->isSessionValid();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -38,9 +40,9 @@ bool RicHoloLensTerminateSessionFeature::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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