#821 Added export dialog with resampling support

This commit is contained in:
Magne Sjaastad
2016-09-19 11:17:36 +02:00
parent cb6d9d714b
commit 7de4f8f175
8 changed files with 200 additions and 13 deletions

View File

@@ -50,6 +50,7 @@ ${CEE_CURRENT_LIST_DIR}RicTilePlotWindowsFeature.h
${CEE_CURRENT_LIST_DIR}RicShowPlotWindowFeature.h
${CEE_CURRENT_LIST_DIR}RicLaunchUnitTestsFeature.h
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.h
${CEE_CURRENT_LIST_DIR}RicExportToLasFileResampleUi.h
${CEE_CURRENT_LIST_DIR}RicImportInputEclipseCaseOpmFeature.h
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.h
${CEE_CURRENT_LIST_DIR}RicAddOpmInputPropertyFeature.h
@@ -105,6 +106,7 @@ ${CEE_CURRENT_LIST_DIR}RicTilePlotWindowsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicShowPlotWindowFeature.cpp
${CEE_CURRENT_LIST_DIR}RicLaunchUnitTestsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.cpp
${CEE_CURRENT_LIST_DIR}RicExportToLasFileResampleUi.cpp
${CEE_CURRENT_LIST_DIR}RicImportInputEclipseCaseOpmFeature.cpp
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.cpp
${CEE_CURRENT_LIST_DIR}RicAddOpmInputPropertyFeature.cpp

View File

@@ -20,9 +20,11 @@
#include "RicExportToLasFileFeature.h"
#include "RiaApplication.h"
#include "RicExportToLasFileResampleUi.h"
#include "RigLasFileExporter.h"
#include "RimWellLogCurve.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cafSelectionManager.h"
#include <QAction>
@@ -49,14 +51,25 @@ void RicExportToLasFileFeature::onActionTriggered(bool isChecked)
if (curves.size() == 0) return;
QString defaultDir = RiaApplication::instance()->defaultFileDialogDirectory("WELL_LOGS_DIR");
QString exportFolder = QFileDialog::getExistingDirectory(NULL, "Select destination folder for LAS export");
if (!exportFolder.isEmpty())
RicExportToLasFileResampleUi featureUi;
featureUi.exportFolder = defaultDir;
caf::PdmUiPropertyViewDialog propertyDialog(NULL, &featureUi, "Export Curve Data to LAS file(s)", "", QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
if (propertyDialog.exec() == QDialog::Accepted &&
!featureUi.exportFolder().isEmpty())
{
RigLasFileExporter lasExporter(curves);
lasExporter.writeToFolder(exportFolder);
if (featureUi.activateResample)
{
lasExporter.setResamplingInterval(featureUi.resampleInterval());
}
lasExporter.writeToFolder(featureUi.exportFolder());
// Remember the path to next time
RiaApplication::instance()->setDefaultFileDialogDirectory("WELL_LOGS_DIR", exportFolder);
RiaApplication::instance()->setDefaultFileDialogDirectory("WELL_LOGS_DIR", featureUi.exportFolder());
}
}

View File

@@ -0,0 +1,76 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- 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 "RicExportToLasFileResampleUi.h"
#include "cafPdmUiFilePathEditor.h"
CAF_PDM_SOURCE_INIT(RicExportToLasFileResampleUi, "RicExportToLasFileResampleUi");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicExportToLasFileResampleUi::RicExportToLasFileResampleUi(void)
{
CAF_PDM_InitObject("Resample LAS curves for export", "", "", "");
CAF_PDM_InitField(&exportFolder, "ExportFolder", QString(), "Export Folder", "", "", "");
exportFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitField(&activateResample, "ActivateResample", false, "Resample Curve Data for Export", "", "", "");
CAF_PDM_InitField(&resampleInterval, "ResampleInterval", 1.0, "Resample Interval [m]", "", "", "");
updateFieldVisibility();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportToLasFileResampleUi::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
updateFieldVisibility();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportToLasFileResampleUi::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
{
if (field == &exportFolder)
{
caf::PdmUiFilePathEditorAttribute* myAttr = static_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
if (myAttr)
{
myAttr->m_selectDirectory = true;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportToLasFileResampleUi::updateFieldVisibility()
{
if (activateResample)
{
resampleInterval.uiCapability()->setUiReadOnly(false);
}
else
{
resampleInterval.uiCapability()->setUiReadOnly(true);
}
}

View File

@@ -0,0 +1,44 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- 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"
//==================================================================================================
///
//==================================================================================================
class RicExportToLasFileResampleUi : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RicExportToLasFileResampleUi(void);
caf::PdmField<bool> activateResample;
caf::PdmField<double> resampleInterval;
caf::PdmField<QString> exportFolder;
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
private:
void updateFieldVisibility();
};