diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 26b870bfe1..fee8ca387c 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -107,6 +107,7 @@ list( APPEND REFERENCED_CMAKE_FILES Commands/EclipseCommands/EclipseWell/CMakeLists_files.cmake Commands/ExportCommands/CMakeLists_files.cmake Commands/FlowCommands/CMakeLists_files.cmake + Commands/HoloLensCommands/CMakeLists_files.cmake Commands/IntersectionBoxCommands/CMakeLists_files.cmake Commands/IntersectionViewCommands/CMakeLists_files.cmake Commands/OctaveScriptCommands/CMakeLists_files.cmake diff --git a/ApplicationCode/Commands/HoloLensCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/HoloLensCommands/CMakeLists_files.cmake new file mode 100644 index 0000000000..96849775d9 --- /dev/null +++ b/ApplicationCode/Commands/HoloLensCommands/CMakeLists_files.cmake @@ -0,0 +1,23 @@ + +set (SOURCE_GROUP_HEADER_FILES +${CMAKE_CURRENT_LIST_DIR}/RicHoloLensExportToFolderFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicHoloLensExportToFolderUi.h +${CMAKE_CURRENT_LIST_DIR}/RicHoloLensExportImpl.h +) + +set (SOURCE_GROUP_SOURCE_FILES +${CMAKE_CURRENT_LIST_DIR}/RicHoloLensExportToFolderFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicHoloLensExportImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicHoloLensExportToFolderUi.cpp +) + + +list(APPEND CODE_HEADER_FILES +${SOURCE_GROUP_HEADER_FILES} +) + +list(APPEND CODE_SOURCE_FILES +${SOURCE_GROUP_SOURCE_FILES} +) + +source_group( "CommandFeature\\HoloLens" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/HoloLensCommands/RicHoloLensExportImpl.cpp b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensExportImpl.cpp new file mode 100644 index 0000000000..6a6cd7456b --- /dev/null +++ b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensExportImpl.cpp @@ -0,0 +1,154 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RicHoloLensExportImpl.h" + +#include "RimGridView.h" +#include "RimSimWellInView.h" +#include "RimWellPath.h" + +#include "RivSimWellPipeSourceInfo.h" +#include "RivSourceInfo.h" +#include "RivWellPathSourceInfo.h" + +#include "RiuViewer.h" + +#include "cvfPart.h" +#include "cvfScene.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicHoloLensExportImpl::partsForExport(const RimGridView* view, cvf::Collection* partCollection) +{ + CVF_ASSERT(partCollection); + + if (!view) return; + + if (view->viewer()) + { + cvf::Scene* scene = view->viewer()->mainScene(); + if (scene) + { + cvf::Collection sceneParts; + scene->allParts(&sceneParts); + + for (auto& scenePart : sceneParts) + { + if (RicHoloLensExportImpl::isGrid(scenePart.p()) || RicHoloLensExportImpl::isPipe(scenePart.p())) + { + partCollection->push_back(scenePart.p()); + } + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicHoloLensExportImpl::nameFromPart(const cvf::Part* part) +{ + if (!part) return ""; + + QString nameOfObject; + + auto sourceInfo = part->sourceInfo(); + + { + auto gridSourceInfo = dynamic_cast(sourceInfo); + if (gridSourceInfo) + { + size_t gridIndex = gridSourceInfo->gridIndex(); + + nameOfObject = QString::number(gridIndex); + } + } + + { + auto simWellSourceInfo = dynamic_cast(sourceInfo); + if (simWellSourceInfo) + { + RimSimWellInView* simulationWell = simWellSourceInfo->well(); + nameOfObject = simulationWell->name(); + } + } + + { + auto wellPathSourceInfo = dynamic_cast(sourceInfo); + if (wellPathSourceInfo) + { + RimWellPath* wellPath = wellPathSourceInfo->wellPath(); + nameOfObject = wellPath->name(); + } + } + + return nameOfObject; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicHoloLensExportImpl::isGrid(const cvf::Part* part) +{ + if (!part) return false; + + auto sourceInfo = part->sourceInfo(); + + { + auto gridSourceInfo = dynamic_cast(sourceInfo); + if (gridSourceInfo) + { + return true; + } + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicHoloLensExportImpl::isPipe(const cvf::Part* part) +{ + if (!part) return ""; + + QString nameOfObject; + + auto sourceInfo = part->sourceInfo(); + + { + auto simWellSourceInfo = dynamic_cast(sourceInfo); + if (simWellSourceInfo) + { + return true; + } + } + + { + auto wellPathSourceInfo = dynamic_cast(sourceInfo); + if (wellPathSourceInfo) + { + return true; + } + } + + return false; +} diff --git a/ApplicationCode/Commands/HoloLensCommands/RicHoloLensExportImpl.h b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensExportImpl.h new file mode 100644 index 0000000000..6af43f0843 --- /dev/null +++ b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensExportImpl.h @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "cvfBase.h" +#include "cvfCollection.h" + +class QString; +class RimGridView; + +namespace cvf +{ +class Part; +} // namespace cvf + +//================================================================================================== +/// +//================================================================================================== +class RicHoloLensExportImpl +{ +public: + static void partsForExport(const RimGridView* view, cvf::Collection* partCollection); + + static QString nameFromPart(const cvf::Part* part); + + static bool isGrid(const cvf::Part* part); + static bool isPipe(const cvf::Part* part); +}; diff --git a/ApplicationCode/Commands/HoloLensCommands/RicHoloLensExportToFolderFeature.cpp b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensExportToFolderFeature.cpp new file mode 100644 index 0000000000..5bf2e6529f --- /dev/null +++ b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensExportToFolderFeature.cpp @@ -0,0 +1,102 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RicHoloLensExportToFolderFeature.h" +#include "RicHoloLensExportImpl.h" +#include "RicHoloLensExportToFolderUi.h" + +#include "RiaApplication.h" +#include "RimDialogData.h" +#include "RimGridView.h" +#include "RimProject.h" + +#include "cafPdmUiPropertyViewDialog.h" + +#include "cvfCollection.h" +#include "cvfPart.h" + +#include +#include +#include +#include +#include + +CAF_CMD_SOURCE_INIT(RicHoloLensExportToFolderFeature, "RicHoloLensExportToFolderFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicHoloLensExportToFolderFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicHoloLensExportToFolderFeature::onActionTriggered(bool isChecked) +{ + RimGridView* activeView = RiaApplication::instance()->activeGridView(); + + RicHoloLensExportToFolderUi* featureUi = RiaApplication::instance()->project()->dialogData()->holoLensExportToFolderData(); + featureUi->setViewForExport(activeView); + + caf::PdmUiPropertyViewDialog propertyDialog( + nullptr, featureUi, "HoloLens - Export Data Folder", "", QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + propertyDialog.resize(QSize(400, 330)); + + if (propertyDialog.exec() == QDialog::Accepted && !featureUi->exportFolder().isEmpty()) + { + cvf::Collection allPartsColl; + + RimGridView* viewForExport = featureUi->viewForExport(); + + RicHoloLensExportImpl::partsForExport(viewForExport, &allPartsColl); + + QDir dir(featureUi->exportFolder()); + + for (size_t i = 0; i < allPartsColl.size(); i++) + { + cvf::Part* part = allPartsColl.at(i); + + if (part) + { + QString nameOfObject = RicHoloLensExportImpl::nameFromPart(part); + // bool isGrid = RicHoloLensExportImpl::isGrid(part); + + QString absolutePath = dir.absoluteFilePath(nameOfObject); + QFile outputFile(absolutePath); + if (outputFile.open(QIODevice::WriteOnly)) + { + QTextStream stream(&outputFile); + + stream << nameOfObject; + } + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicHoloLensExportToFolderFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/Save.png")); + actionToSetup->setText("HoloLens : Export to Folder"); +} diff --git a/ApplicationCode/Commands/HoloLensCommands/RicHoloLensExportToFolderFeature.h b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensExportToFolderFeature.h new file mode 100644 index 0000000000..1b8eeaa0f7 --- /dev/null +++ b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensExportToFolderFeature.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 RicHoloLensExportToFolderFeature : 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/RicHoloLensExportToFolderUi.cpp b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensExportToFolderUi.cpp new file mode 100644 index 0000000000..bb40850ef7 --- /dev/null +++ b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensExportToFolderUi.cpp @@ -0,0 +1,115 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RicHoloLensExportToFolderUi.h" + +#include "RiaApplication.h" + +#include "RimCase.h" +#include "RimGridView.h" +#include "RimProject.h" + +#include "cafPdmUiFilePathEditor.h" +#include "cafPdmUiOrdering.h" + +CAF_PDM_SOURCE_INIT(RicHoloLensExportToFolderUi, "RicHoloLensExportToFolderUi"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicHoloLensExportToFolderUi::RicHoloLensExportToFolderUi() +{ + CAF_PDM_InitObject("Resample LAS curves for export", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_viewForExport, "ViewForExport", "View", "", "", ""); + + CAF_PDM_InitField(&m_exportFolder, "ExportFolder", QString(), "Export Folder", "", "", ""); + m_exportFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicHoloLensExportToFolderUi::setViewForExport(RimGridView* view) +{ + m_viewForExport = view; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicHoloLensExportToFolderUi::exportFolder() const +{ + return m_exportFolder; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGridView* RicHoloLensExportToFolderUi::viewForExport() const +{ + return m_viewForExport; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RicHoloLensExportToFolderUi::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) +{ + QList options; + + if (fieldNeedingOptions == &m_viewForExport) + { + std::vector visibleViews; + RiaApplication::instance()->project()->allVisibleGridViews(visibleViews); + + for (RimGridView* v : visibleViews) + { + RimCase* rimCase = nullptr; + v->firstAncestorOrThisOfType(rimCase); + + QIcon icon; + if (rimCase) + { + icon = rimCase->uiCapability()->uiIcon(); + } + + options.push_back(caf::PdmOptionItemInfo(v->name(), v, false, icon)); + } + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicHoloLensExportToFolderUi::defineEditorAttribute(const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute) +{ + if (field == &m_exportFolder) + { + caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast(attribute); + if (myAttr) + { + myAttr->m_selectDirectory = true; + } + } +} diff --git a/ApplicationCode/Commands/HoloLensCommands/RicHoloLensExportToFolderUi.h b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensExportToFolderUi.h new file mode 100644 index 0000000000..8e3089bd1f --- /dev/null +++ b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensExportToFolderUi.h @@ -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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmPtrField.h" + +class RimGridView; + +//================================================================================================== +/// +//================================================================================================== +class RicHoloLensExportToFolderUi : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RicHoloLensExportToFolderUi(); + + void setViewForExport(RimGridView* view); + + QString exportFolder() const; + RimGridView* viewForExport() const; + +private: + QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) override; + void defineEditorAttribute(const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute) override; + +private: + caf::PdmPtrField m_viewForExport; + caf::PdmField m_exportFolder; +}; diff --git a/ApplicationCode/ProjectDataModel/RimDialogData.cpp b/ApplicationCode/ProjectDataModel/RimDialogData.cpp index be8211bbcf..77e46c4043 100644 --- a/ApplicationCode/ProjectDataModel/RimDialogData.cpp +++ b/ApplicationCode/ProjectDataModel/RimDialogData.cpp @@ -21,6 +21,7 @@ #include "ExportCommands/RicExportCarfinUi.h" #include "CompletionExportCommands/RicExportCompletionDataSettingsUi.h" #include "FractureCommands/RicCreateMultipleFracturesUi.h" +#include "HoloLensCommands/RicHoloLensExportToFolderUi.h" CAF_PDM_SOURCE_INIT(RimDialogData, "RimDialogData"); @@ -39,6 +40,9 @@ RimDialogData::RimDialogData() CAF_PDM_InitFieldNoDefault(&m_multipleFractionsData, "MultipleFractionsData", "Multiple Fractures Data", "", "", ""); m_multipleFractionsData = new RiuCreateMultipleFractionsUi(); + + CAF_PDM_InitFieldNoDefault(&m_holoLenseExportToFolderData, "HoloLenseExportToFolderData", "Holo Lens Export To Folder Data", "", "", ""); + m_holoLenseExportToFolderData = new RicHoloLensExportToFolderUi(); } //-------------------------------------------------------------------------------------------------- @@ -90,3 +94,11 @@ RiuCreateMultipleFractionsUi* RimDialogData::multipleFractionsData() const return m_multipleFractionsData; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicHoloLensExportToFolderUi* RimDialogData::holoLensExportToFolderData() const +{ + return m_holoLenseExportToFolderData; +} + diff --git a/ApplicationCode/ProjectDataModel/RimDialogData.h b/ApplicationCode/ProjectDataModel/RimDialogData.h index 737a67c839..b86bcfde4c 100644 --- a/ApplicationCode/ProjectDataModel/RimDialogData.h +++ b/ApplicationCode/ProjectDataModel/RimDialogData.h @@ -24,6 +24,7 @@ class RicExportCarfinUi; class RicExportCompletionDataSettingsUi; class RiuCreateMultipleFractionsUi; +class RicHoloLensExportToFolderUi; //================================================================================================== /// @@ -51,10 +52,11 @@ public: RicExportCompletionDataSettingsUi* exportCompletionData() const; RiuCreateMultipleFractionsUi* multipleFractionsData() const; - + RicHoloLensExportToFolderUi* holoLensExportToFolderData() const; private: caf::PdmChildField m_exportCarfin; caf::PdmChildField m_exportCompletionData; caf::PdmChildField m_multipleFractionsData; + caf::PdmChildField m_holoLenseExportToFolderData; }; diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 8a42fe478d..a319a639cd 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -494,6 +494,9 @@ void RiuMainWindow::createMenus() testMenu->addAction(m_executePaintEventPerformanceTest); testMenu->addAction(cmdFeatureMgr->action("RicLaunchUnitTestsFeature")); testMenu->addAction(cmdFeatureMgr->action("RicRunCommandFileFeature")); + testMenu->addSeparator(); + + testMenu->addAction(cmdFeatureMgr->action("RicHoloLensExportToFolderFeature")); // Windows menu m_windowMenu = menuBar()->addMenu("&Windows");