Holo Lens : Create menu and UI for export of data to folder

This commit is contained in:
Magne Sjaastad
2018-09-12 10:31:22 +02:00
parent b019c95ab9
commit f1dd707561
11 changed files with 543 additions and 1 deletions

View File

@@ -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

View File

@@ -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 )

View File

@@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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 <QString>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicHoloLensExportImpl::partsForExport(const RimGridView* view, cvf::Collection<cvf::Part>* partCollection)
{
CVF_ASSERT(partCollection);
if (!view) return;
if (view->viewer())
{
cvf::Scene* scene = view->viewer()->mainScene();
if (scene)
{
cvf::Collection<cvf::Part> 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<const RivSourceInfo*>(sourceInfo);
if (gridSourceInfo)
{
size_t gridIndex = gridSourceInfo->gridIndex();
nameOfObject = QString::number(gridIndex);
}
}
{
auto simWellSourceInfo = dynamic_cast<const RivSimWellPipeSourceInfo*>(sourceInfo);
if (simWellSourceInfo)
{
RimSimWellInView* simulationWell = simWellSourceInfo->well();
nameOfObject = simulationWell->name();
}
}
{
auto wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>(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<const RivSourceInfo*>(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<const RivSimWellPipeSourceInfo*>(sourceInfo);
if (simWellSourceInfo)
{
return true;
}
}
{
auto wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>(sourceInfo);
if (wellPathSourceInfo)
{
return true;
}
}
return false;
}

View File

@@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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<cvf::Part>* partCollection);
static QString nameFromPart(const cvf::Part* part);
static bool isGrid(const cvf::Part* part);
static bool isPipe(const cvf::Part* part);
};

View File

@@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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 <QAction>
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QTextStream>
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<cvf::Part> 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");
}

View File

@@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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;
};

View File

@@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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<caf::PdmOptionItemInfo> RicHoloLensExportToFolderUi::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly)
{
QList<caf::PdmOptionItemInfo> options;
if (fieldNeedingOptions == &m_viewForExport)
{
std::vector<RimGridView*> 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<caf::PdmUiFilePathEditorAttribute*>(attribute);
if (myAttr)
{
myAttr->m_selectDirectory = true;
}
}
}

View File

@@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly) override;
void defineEditorAttribute(const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute) override;
private:
caf::PdmPtrField<RimGridView*> m_viewForExport;
caf::PdmField<QString> m_exportFolder;
};

View File

@@ -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;
}

View File

@@ -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<RicExportCarfinUi*> m_exportCarfin;
caf::PdmChildField<RicExportCompletionDataSettingsUi*> m_exportCompletionData;
caf::PdmChildField<RiuCreateMultipleFractionsUi*> m_multipleFractionsData;
caf::PdmChildField<RicHoloLensExportToFolderUi*> m_holoLenseExportToFolderData;
};

View File

@@ -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");