From cdda4d74dfcd9ea61b2cbcab9b7dde1b52a238e6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 22 Oct 2018 12:00:02 +0200 Subject: [PATCH] #3541 HoloLens : Create dummy file backed feature --- .../Application/RiaApplication.cpp | 1 + .../HoloLensCommands/CMakeLists_files.cmake | 4 +- ...ensCreateDummyFileBackedSessionFeature.cpp | 59 +++++++++++++++++++ ...oLensCreateDummyFileBackedSessionFeature.h | 34 +++++++++++ .../HoloLensCommands/RicHoloLensSession.cpp | 16 +++-- .../HoloLensCommands/RicHoloLensSession.h | 3 +- .../UserInterface/RiuMainWindow.cpp | 1 + 7 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 ApplicationCode/Commands/HoloLensCommands/RicHoloLensCreateDummyFileBackedSessionFeature.cpp create mode 100644 ApplicationCode/Commands/HoloLensCommands/RicHoloLensCreateDummyFileBackedSessionFeature.h diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index d6c9174c57..ebd1b5a469 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -997,6 +997,7 @@ bool RiaApplication::saveProjectAs(const QString& fileName) void RiaApplication::closeProject() { RicHoloLensSession::instance()->terminateSession(); + RicHoloLensSession::refreshToolbarState(); RiuMainWindow* mainWnd = RiuMainWindow::instance(); diff --git a/ApplicationCode/Commands/HoloLensCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/HoloLensCommands/CMakeLists_files.cmake index aeb3d9d40a..2ad79354d6 100644 --- a/ApplicationCode/Commands/HoloLensCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/HoloLensCommands/CMakeLists_files.cmake @@ -9,8 +9,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicHoloLensTerminateSessionFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicHoloLensServerSettings.h ${CMAKE_CURRENT_LIST_DIR}/RicHoloLensCreateSessionUi.h ${CMAKE_CURRENT_LIST_DIR}/RicHoloLensSession.h - - +${CMAKE_CURRENT_LIST_DIR}/RicHoloLensCreateDummyFileBackedSessionFeature.h ${CMAKE_CURRENT_LIST_DIR}/VdeArrayDataPacket.h ${CMAKE_CURRENT_LIST_DIR}/VdeExportPart.h @@ -27,6 +26,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicHoloLensTerminateSessionFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicHoloLensServerSettings.cpp ${CMAKE_CURRENT_LIST_DIR}/RicHoloLensCreateSessionUi.cpp ${CMAKE_CURRENT_LIST_DIR}/RicHoloLensSession.cpp +${CMAKE_CURRENT_LIST_DIR}/RicHoloLensCreateDummyFileBackedSessionFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/VdeArrayDataPacket.cpp ${CMAKE_CURRENT_LIST_DIR}/VdeExportPart.cpp diff --git a/ApplicationCode/Commands/HoloLensCommands/RicHoloLensCreateDummyFileBackedSessionFeature.cpp b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensCreateDummyFileBackedSessionFeature.cpp new file mode 100644 index 0000000000..c427514a64 --- /dev/null +++ b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensCreateDummyFileBackedSessionFeature.cpp @@ -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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicHoloLensCreateDummyFileBackedSessionFeature.h" + +#include "RicHoloLensSession.h" + +#include "RiaQIconTools.h" + +#include + +CAF_CMD_SOURCE_INIT(RicHoloLensCreateDummyFiledBackedSessionFeature, "RicHoloLensCreateDummyFiledBackedSessionFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicHoloLensCreateDummyFiledBackedSessionFeature::isCommandEnabled() +{ + return !RicHoloLensSession::instance()->isSessionValid(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicHoloLensCreateDummyFiledBackedSessionFeature::onActionTriggered(bool isChecked) +{ + RicHoloLensSession::instance()->createDummyFileBackedSession(); + + RicHoloLensSession::refreshToolbarState(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicHoloLensCreateDummyFiledBackedSessionFeature::setupActionLook(QAction* actionToSetup) +{ + QPixmap pixmap(":/hololens.png"); + QPixmap overlayPixmap(":/plus-sign-green.png"); + + QPixmap combinedPixmap = RiaQIconTools::appendPixmapUpperLeft(pixmap, overlayPixmap); + actionToSetup->setIcon(QIcon(combinedPixmap)); + + actionToSetup->setText("Create Dummy File Backed Session"); +} diff --git a/ApplicationCode/Commands/HoloLensCommands/RicHoloLensCreateDummyFileBackedSessionFeature.h b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensCreateDummyFileBackedSessionFeature.h new file mode 100644 index 0000000000..9518596fea --- /dev/null +++ b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensCreateDummyFileBackedSessionFeature.h @@ -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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicHoloLensCreateDummyFiledBackedSessionFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +private: + bool isCommandEnabled() override; + void onActionTriggered(bool isChecked) override; + void setupActionLook(QAction* actionToSetup) override; +}; diff --git a/ApplicationCode/Commands/HoloLensCommands/RicHoloLensSession.cpp b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensSession.cpp index 7a3100eec7..8ad80166ca 100644 --- a/ApplicationCode/Commands/HoloLensCommands/RicHoloLensSession.cpp +++ b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensSession.cpp @@ -27,7 +27,7 @@ //-------------------------------------------------------------------------------------------------- RicHoloLensSession::RicHoloLensSession() : m_isSessionValid(false) - , m_isDummySession(false) + , m_isIsFileBackedSessionValid(false) { } @@ -72,7 +72,7 @@ bool RicHoloLensSession::createDummyFileBackedSession() return false; } - m_isDummySession = true; + m_isIsFileBackedSessionValid = true; return true; } @@ -82,11 +82,19 @@ bool RicHoloLensSession::createDummyFileBackedSession() //-------------------------------------------------------------------------------------------------- bool RicHoloLensSession::isSessionValid() const { - if (m_isDummySession) return true; + if (m_isIsFileBackedSessionValid) return true; return m_isSessionValid; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicHoloLensSession::isFileBackedSessionValid() const +{ + return m_isIsFileBackedSessionValid; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -104,7 +112,7 @@ void RicHoloLensSession::terminateSession() RiaLogging::info("Terminating HoloLens Session"); - m_isDummySession = false; + m_isIsFileBackedSessionValid = false; m_isSessionValid = false; } diff --git a/ApplicationCode/Commands/HoloLensCommands/RicHoloLensSession.h b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensSession.h index da6be570fa..5eb6e838e1 100644 --- a/ApplicationCode/Commands/HoloLensCommands/RicHoloLensSession.h +++ b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensSession.h @@ -36,6 +36,7 @@ public: bool createDummyFileBackedSession(); bool isSessionValid() const; + bool isFileBackedSessionValid() const; void updateSessionDataFromView(RimGridView* activeView); void terminateSession(); @@ -44,5 +45,5 @@ public: private: bool m_isSessionValid; - bool m_isDummySession; + bool m_isIsFileBackedSessionValid; }; diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index f1f845c598..bff4e38677 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -499,6 +499,7 @@ void RiuMainWindow::createMenus() testMenu->addSeparator(); testMenu->addAction(cmdFeatureMgr->action("RicHoloLensExportToFolderFeature")); + testMenu->addAction(cmdFeatureMgr->action("RicHoloLensCreateDummyFiledBackedSessionFeature")); // Windows menu m_windowMenu = menuBar()->addMenu("&Windows");