mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3810 HoloLens : Tool bar button and scheduler for auto sent to server
This commit is contained in:
parent
af0c169bca
commit
22e8eb485f
@ -13,6 +13,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RicHoloLensSession.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensSessionObserver.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensSessionManager.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensCreateDummyFileBackedSessionFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensAutoExportToSharingServerFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicExportToSharingServerScheduler.h
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/VdeArrayDataPacket.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/VdeCachingHashedIdFactory.h
|
||||
@ -35,6 +37,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RicHoloLensCreateSessionUi.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensSession.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensSessionManager.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensCreateDummyFileBackedSessionFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensAutoExportToSharingServerFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicExportToSharingServerScheduler.cpp
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/VdeArrayDataPacket.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/VdeCachingHashedIdFactory.cpp
|
||||
@ -56,6 +60,7 @@ ${SOURCE_GROUP_SOURCE_FILES}
|
||||
set (QT_MOC_HEADERS
|
||||
${QT_MOC_HEADERS}
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicHoloLensRestClient.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicExportToSharingServerScheduler.h
|
||||
)
|
||||
|
||||
|
||||
|
@ -0,0 +1,98 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- Equinor 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 "RicExportToSharingServerScheduler.h"
|
||||
|
||||
#include "RicHoloLensAutoExportToSharingServerFeature.h"
|
||||
|
||||
#include "cafCmdFeatureManager.h"
|
||||
#include "cafProgressState.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QTimer>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicExportToSharingServerScheduler* RicExportToSharingServerScheduler::instance()
|
||||
{
|
||||
static RicExportToSharingServerScheduler theInstance;
|
||||
|
||||
return &theInstance;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExportToSharingServerScheduler::scheduleUpdateSession()
|
||||
{
|
||||
startTimer(0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExportToSharingServerScheduler::startTimer(int msecs)
|
||||
{
|
||||
if (!m_timer)
|
||||
{
|
||||
m_timer = new QTimer(this);
|
||||
connect(m_timer, SIGNAL(timeout()), this, SLOT(slotTriggerUpdateSessionWhenReady()));
|
||||
}
|
||||
|
||||
if (!m_timer->isActive())
|
||||
{
|
||||
m_timer->setSingleShot(true);
|
||||
m_timer->start(msecs);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExportToSharingServerScheduler::triggerUpdateSession()
|
||||
{
|
||||
auto* cmdFeature = dynamic_cast<RicHoloLensAutoExportToSharingServerFeature*>(
|
||||
caf::CmdFeatureManager::instance()->getCommandFeature("RicHoloLensAutoExportToSharingServerFeature"));
|
||||
if (cmdFeature)
|
||||
{
|
||||
cmdFeature->triggerUpdateSession();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExportToSharingServerScheduler::slotTriggerUpdateSessionWhenReady()
|
||||
{
|
||||
if (caf::ProgressState::isActive())
|
||||
{
|
||||
startTimer(100);
|
||||
return;
|
||||
}
|
||||
|
||||
triggerUpdateSession();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicExportToSharingServerScheduler::~RicExportToSharingServerScheduler()
|
||||
{
|
||||
delete m_timer;
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- Equinor 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 <QObject>
|
||||
|
||||
class QTimer;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RicExportToSharingServerScheduler : public QObject
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
static RicExportToSharingServerScheduler* instance();
|
||||
void scheduleUpdateSession();
|
||||
|
||||
private slots:
|
||||
void slotTriggerUpdateSessionWhenReady();
|
||||
|
||||
private:
|
||||
RicExportToSharingServerScheduler()
|
||||
: m_timer(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
~RicExportToSharingServerScheduler() override;
|
||||
|
||||
RicExportToSharingServerScheduler(const RicExportToSharingServerScheduler& o) = delete;
|
||||
void operator=(const RicExportToSharingServerScheduler& o) = delete;
|
||||
|
||||
void startTimer(int msecs);
|
||||
void triggerUpdateSession();
|
||||
|
||||
private:
|
||||
QTimer* m_timer;
|
||||
};
|
@ -0,0 +1,151 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- Equinor 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 "RicHoloLensAutoExportToSharingServerFeature.h"
|
||||
#include "RicHoloLensSession.h"
|
||||
#include "RicHoloLensSessionManager.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaQIconTools.h"
|
||||
|
||||
#include "RimGridView.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicHoloLensAutoExportToSharingServerFeature, "RicHoloLensAutoExportToSharingServerFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicHoloLensAutoExportToSharingServerFeature::RicHoloLensAutoExportToSharingServerFeature()
|
||||
: m_isActive(false)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicHoloLensAutoExportToSharingServerFeature::setActive(bool enable)
|
||||
{
|
||||
m_isActive = enable;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicHoloLensAutoExportToSharingServerFeature::isActive() const
|
||||
{
|
||||
if (isSessionValid())
|
||||
{
|
||||
return m_isActive;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicHoloLensAutoExportToSharingServerFeature::triggerUpdateSession()
|
||||
{
|
||||
if (m_isActive && isSessionValid())
|
||||
{
|
||||
RimGridView* activeView = RiaApplication::instance()->activeGridView();
|
||||
if (!activeView)
|
||||
{
|
||||
RiaLogging::error("No active view");
|
||||
return;
|
||||
}
|
||||
|
||||
RicHoloLensSession* session = RicHoloLensSessionManager::instance()->session();
|
||||
|
||||
session->updateSessionDataFromView(*activeView);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicHoloLensAutoExportToSharingServerFeature::isCommandEnabled()
|
||||
{
|
||||
return isSessionValid();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicHoloLensAutoExportToSharingServerFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
if (!isSessionValid())
|
||||
{
|
||||
RiaLogging::error("No valid HoloLens session present");
|
||||
return;
|
||||
}
|
||||
|
||||
RimGridView* activeView = RiaApplication::instance()->activeGridView();
|
||||
if (!activeView)
|
||||
{
|
||||
RiaLogging::error("No active view");
|
||||
return;
|
||||
}
|
||||
|
||||
m_isActive = isChecked;
|
||||
if (m_isActive)
|
||||
{
|
||||
triggerUpdateSession();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicHoloLensAutoExportToSharingServerFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
QPixmap pixmap(":/hololens.png");
|
||||
QPixmap overlayPixmap(":/arrow-right-green.png");
|
||||
|
||||
QPixmap combinedPixmap = RiaQIconTools::appendPixmapUpperLeft(pixmap, overlayPixmap);
|
||||
actionToSetup->setIcon(QIcon(combinedPixmap));
|
||||
|
||||
actionToSetup->setText("Automatically Export to Sharing Server");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicHoloLensAutoExportToSharingServerFeature::isCommandChecked()
|
||||
{
|
||||
return isActive();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicHoloLensAutoExportToSharingServerFeature::isSessionValid() const
|
||||
{
|
||||
RicHoloLensSession* session = RicHoloLensSessionManager::instance()->session();
|
||||
if (session && session->isSessionValid())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- Equinor 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 RicHoloLensAutoExportToSharingServerFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RicHoloLensAutoExportToSharingServerFeature();
|
||||
|
||||
void setActive(bool enable);
|
||||
bool isActive() const;
|
||||
|
||||
void triggerUpdateSession();
|
||||
|
||||
private:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered(bool isChecked) override;
|
||||
void setupActionLook(QAction* actionToSetup) override;
|
||||
bool isCommandChecked() override;
|
||||
|
||||
bool isSessionValid() const;
|
||||
|
||||
private:
|
||||
bool m_isActive;
|
||||
};
|
@ -18,11 +18,14 @@
|
||||
|
||||
#include "RicHoloLensTerminateSessionFeature.h"
|
||||
|
||||
#include "RicHoloLensAutoExportToSharingServerFeature.h"
|
||||
#include "RicHoloLensSessionManager.h"
|
||||
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaQIconTools.h"
|
||||
|
||||
#include "cafCmdFeatureManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicHoloLensTerminateSessionFeature, "RicHoloLensTerminateSessionFeature");
|
||||
@ -40,6 +43,13 @@ bool RicHoloLensTerminateSessionFeature::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicHoloLensTerminateSessionFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
auto* cmdFeature = dynamic_cast<RicHoloLensAutoExportToSharingServerFeature*>(
|
||||
caf::CmdFeatureManager::instance()->getCommandFeature("RicHoloLensAutoExportToSharingServerFeature"));
|
||||
if (cmdFeature)
|
||||
{
|
||||
cmdFeature->setActive(false);
|
||||
}
|
||||
|
||||
RicHoloLensSessionManager::instance()->terminateSession();
|
||||
|
||||
RicHoloLensSessionManager::refreshToolbarState();
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "RiaFieldHandleTools.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "HoloLensCommands/RicExportToSharingServerScheduler.h"
|
||||
|
||||
#include "RigActiveCellInfo.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigEclipseCaseData.h"
|
||||
@ -568,6 +570,8 @@ void RimEclipseView::createDisplayModel()
|
||||
plot->viewGeometryUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
RicExportToSharingServerScheduler::instance()->scheduleUpdateSession();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -588,6 +592,8 @@ void RimEclipseView::updateCurrentTimeStep()
|
||||
// Invisible Wells are marked as read only when "show wells intersecting visible cells" is enabled
|
||||
// Visibility of wells differ betweeen time steps, so trigger a rebuild of tree state items
|
||||
wellCollection()->updateConnectedEditors();
|
||||
|
||||
RicExportToSharingServerScheduler::instance()->scheduleUpdateSession();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -595,6 +595,7 @@ void RiuMainWindow::createToolBars()
|
||||
|
||||
m_holoLensToolBar->addAction(cmdFeatureMgr->action("RicHoloLensCreateSessionFeature"));
|
||||
m_holoLensToolBar->addAction(cmdFeatureMgr->action("RicHoloLensTerminateSessionFeature"));
|
||||
m_holoLensToolBar->addAction(cmdFeatureMgr->action("RicHoloLensAutoExportToSharingServerFeature"));
|
||||
m_holoLensToolBar->addAction(cmdFeatureMgr->action("RicHoloLensExportToSharingServerFeature"));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user