From b89efbf73e9c320fa83eafccaead48f6b5ef0685 Mon Sep 17 00:00:00 2001 From: astridkbjorke Date: Thu, 9 Mar 2017 14:27:41 +0100 Subject: [PATCH] #1294 - Renaming and moving ascii export feature, now RicAsciiExportWellLogPlotFeature. Adding functionality for getting data to export (but formatting is still missing) --- .../FlowCommands/CMakeLists_files.cmake | 1 - .../WellLogCommands/CMakeLists_files.cmake | 2 + .../RicAsciiExportWellLogPlotFeature.cpp} | 31 +++++++-------- .../RicAsciiExportWellLogPlotFeature.h} | 6 +-- .../RimContextCommandBuilder.cpp | 2 +- .../ProjectDataModel/RimWellLogPlot.cpp | 38 +++++++++++++++++++ .../ProjectDataModel/RimWellLogPlot.h | 2 + .../ProjectDataModel/RimWellLogTrack.cpp | 24 ++++++++++++ .../ProjectDataModel/RimWellLogTrack.h | 5 +++ 9 files changed, 91 insertions(+), 20 deletions(-) rename ApplicationCode/Commands/{FlowCommands/RicAsciiExportWellAllocationPlotFeature.cpp => WellLogCommands/RicAsciiExportWellLogPlotFeature.cpp} (74%) rename ApplicationCode/Commands/{FlowCommands/RicAsciiExportWellAllocationPlotFeature.h => WellLogCommands/RicAsciiExportWellLogPlotFeature.h} (84%) diff --git a/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake index ab9a79354b..4c8c480711 100644 --- a/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake @@ -26,7 +26,6 @@ ${CEE_CURRENT_LIST_DIR}RicAsciiExportWellAllocationPlotFeature.cpp ${CEE_CURRENT_LIST_DIR}RicSelectViewUI.cpp ) - list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES} ) diff --git a/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake index 3baf857dbe..b97443fe3e 100644 --- a/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake @@ -20,6 +20,7 @@ ${CEE_CURRENT_LIST_DIR}RicPasteWellLogTrackFeature.h ${CEE_CURRENT_LIST_DIR}RicPasteWellLogPlotFeature.h ${CEE_CURRENT_LIST_DIR}RicChangeDataSourceFeature.h ${CEE_CURRENT_LIST_DIR}RicChangeDataSourceFeatureUi.h +${CEE_CURRENT_LIST_DIR}RicAsciiExportWellLogPlotFeature.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -38,6 +39,7 @@ ${CEE_CURRENT_LIST_DIR}RicPasteWellLogTrackFeature.cpp ${CEE_CURRENT_LIST_DIR}RicPasteWellLogPlotFeature.cpp ${CEE_CURRENT_LIST_DIR}RicChangeDataSourceFeature.cpp ${CEE_CURRENT_LIST_DIR}RicChangeDataSourceFeatureUi.cpp +${CEE_CURRENT_LIST_DIR}RicAsciiExportWellLogPlotFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/FlowCommands/RicAsciiExportWellAllocationPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicAsciiExportWellLogPlotFeature.cpp similarity index 74% rename from ApplicationCode/Commands/FlowCommands/RicAsciiExportWellAllocationPlotFeature.cpp rename to ApplicationCode/Commands/WellLogCommands/RicAsciiExportWellLogPlotFeature.cpp index 2a2c8aa241..7b1c6ceb6f 100644 --- a/ApplicationCode/Commands/FlowCommands/RicAsciiExportWellAllocationPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicAsciiExportWellLogPlotFeature.cpp @@ -16,12 +16,12 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RicAsciiExportWellAllocationPlotFeature.h" +#include "RicAsciiExportWellLogPlotFeature.h" #include "RiaApplication.h" #include "RiaLogging.h" -#include "RimWellAllocationPlot.h" +#include "RimWellLogPlot.h" #include "RiuMainWindow.h" @@ -39,12 +39,12 @@ -CAF_CMD_SOURCE_INIT(RicAsciiExportWellAllocationPlotFeature, "RicAsciiExportWellAllocationPlotFeature"); +CAF_CMD_SOURCE_INIT(RicAsciiExportWellLogPlotFeature, "RicAsciiExportWellLogPlotFeature"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicAsciiExportWellAllocationPlotFeature::isCommandEnabled() +bool RicAsciiExportWellLogPlotFeature::isCommandEnabled() { return true; } @@ -52,7 +52,7 @@ bool RicAsciiExportWellAllocationPlotFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicAsciiExportWellAllocationPlotFeature::onActionTriggered(bool isChecked) +void RicAsciiExportWellLogPlotFeature::onActionTriggered(bool isChecked) { RiaApplication* app = RiaApplication::instance(); QString projectFolder = app->currentProjectPath(); @@ -60,15 +60,15 @@ void RicAsciiExportWellAllocationPlotFeature::onActionTriggered(bool isChecked) RimProject* project = RiaApplication::instance()->project(); CVF_ASSERT(project); - std::vector selectedWellAllocPlots; - caf::SelectionManager::instance()->objectsByType(&selectedWellAllocPlots); + std::vector selectedWellLogPlots; + caf::SelectionManager::instance()->objectsByType(&selectedWellLogPlots); QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("PLOT_ASCIIEXPORT_DIR", projectFolder); QString defaultFileName = defaultDir + "/" + QString("WellAllocationPlotExport"); - QString fileName = QFileDialog::getSaveFileName(NULL, "Select file for Well Allocation Plot Export", defaultFileName, "All files(*.*)"); + QString fileName = QFileDialog::getSaveFileName(NULL, "Select file for Well Log Plot Export", defaultFileName, "All files(*.*)"); if (fileName.isEmpty()) return; - bool isOk = writeAsciiExportForWellAllocPlots(fileName, selectedWellAllocPlots); + bool isOk = writeAsciiExportForWellLogPlots(fileName, selectedWellLogPlots); if (!isOk) { @@ -80,7 +80,7 @@ void RicAsciiExportWellAllocationPlotFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicAsciiExportWellAllocationPlotFeature::setupActionLook(QAction* actionToSetup) +void RicAsciiExportWellLogPlotFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("Export Well Allocation Plot Data"); } @@ -88,7 +88,7 @@ void RicAsciiExportWellAllocationPlotFeature::setupActionLook(QAction* actionToS //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicAsciiExportWellAllocationPlotFeature::writeAsciiExportForWellAllocPlots(const QString& fileName, const std::vector& selectedWellAllocPlots) +bool RicAsciiExportWellLogPlotFeature::writeAsciiExportForWellLogPlots(const QString& fileName, const std::vector& selectedWellLogPlots) { RiaLogging::info(QString("Writing ascii values for well allocation plot(s) to file: %1").arg(fileName)); @@ -98,14 +98,15 @@ bool RicAsciiExportWellAllocationPlotFeature::writeAsciiExportForWellAllocPlots( return false; } - caf::ProgressInfo pi(selectedWellAllocPlots.size(), QString("Writing data to file %1").arg(fileName)); + caf::ProgressInfo pi(selectedWellLogPlots.size(), QString("Writing data to file %1").arg(fileName)); size_t progress = 0; QTextStream out(&file); - for (RimWellAllocationPlot* wellAllocPlot : selectedWellAllocPlots) + for (RimWellLogPlot* wellLogPlot : selectedWellLogPlots) { - out << wellAllocPlot->description(); -/* out << summaryPlot->asciiDataForPlotExport();*/ + out << wellLogPlot->description(); + out << "\n"; + out << wellLogPlot->asciiDataForPlotExport(); out << "\n\n"; progress++; diff --git a/ApplicationCode/Commands/FlowCommands/RicAsciiExportWellAllocationPlotFeature.h b/ApplicationCode/Commands/WellLogCommands/RicAsciiExportWellLogPlotFeature.h similarity index 84% rename from ApplicationCode/Commands/FlowCommands/RicAsciiExportWellAllocationPlotFeature.h rename to ApplicationCode/Commands/WellLogCommands/RicAsciiExportWellLogPlotFeature.h index 6024307dc1..7c81f5939e 100644 --- a/ApplicationCode/Commands/FlowCommands/RicAsciiExportWellAllocationPlotFeature.h +++ b/ApplicationCode/Commands/WellLogCommands/RicAsciiExportWellLogPlotFeature.h @@ -21,12 +21,12 @@ #include "cafCmdFeature.h" #include "cafPdmField.h" -class RimWellAllocationPlot; +class RimWellLogPlot; //================================================================================================== /// //================================================================================================== -class RicAsciiExportWellAllocationPlotFeature : public caf::CmdFeature +class RicAsciiExportWellLogPlotFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; @@ -38,5 +38,5 @@ protected: virtual void setupActionLook(QAction* actionToSetup) override; private: - bool writeAsciiExportForWellAllocPlots(const QString& fileName, const std::vector& selectedSummaryPlots); + bool writeAsciiExportForWellLogPlots(const QString& fileName, const std::vector& selectedSummaryPlots); }; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index c05eb19a6c..84caf68e55 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -257,6 +257,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection() commandIds << "RicPasteWellLogTrackFeature"; commandIds << "Separator"; commandIds << "RicNewWellLogPlotTrackFeature"; + commandIds << "RicAsciiExportWellLogPlotFeature"; } else if (dynamic_cast(uiItem)) { @@ -355,7 +356,6 @@ QStringList RimContextCommandBuilder::commandsFromSelection() else if (dynamic_cast(uiItem)) { commandIds << "RicAddStoredWellAllocationPlotFeature"; - commandIds << "RicAsciiExportWellAllocationPlotFeature"; } diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp index 3c001c3a12..29e2e0b4a3 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp @@ -31,6 +31,8 @@ #include #include "RimWellAllocationPlot.h" +#include "RimWellLogCurve.h" +#include "RigWellLogCurveData.h" #define RI_LOGPLOT_MINDEPTH_DEFAULT 0.0 #define RI_LOGPLOT_MAXDEPTH_DEFAULT 1000.0 @@ -383,6 +385,42 @@ QWidget* RimWellLogPlot::viewWidget() return m_viewer; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimWellLogPlot::asciiDataForPlotExport() +{ + QString out; + + for (RimWellLogTrack* track : m_tracks) + { + out += "\n" + track->description() + "\n"; + + std::vector curves = track->curvesVector(); + for (RimWellLogCurve* curve : curves) + { + out += curve->curveName() + "\n"; + const RigWellLogCurveData* curveData = curve->curveData(); + std::vector xPlotValues = curveData->xPlotValues(); + + std::vector depths; + depths = curveData->measuredDepthPlotValues(RimDefines::UNIT_NONE); + + if (!(depths.size() == xPlotValues.size())) return out; + + for (int i = xPlotValues.size()-1; i >= 0; i--) + { + out += QString::number(depths[i]) + " " + QString::number(xPlotValues[i]) + " \n"; + } + + + } + + } + + return out; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.h b/ApplicationCode/ProjectDataModel/RimWellLogPlot.h index 8f87fa520e..4e1da689ef 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.h @@ -99,6 +99,8 @@ public: virtual void zoomAll() override; virtual QWidget* viewWidget() override; + QString asciiDataForPlotExport(); + protected: // Overridden PDM methods diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp index 8c131e0084..e7a889c531 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp @@ -491,3 +491,27 @@ std::vector RimWellLogTrack::visibleStackedCurves() return stackedCurves; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimWellLogTrack::description() +{ + return m_userName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimWellLogTrack::curvesVector() +{ + std::vector curvesVector; + + for (RimWellLogCurve* curve : curves) + { + curvesVector.push_back(curve); + } + + return curvesVector; +} + diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.h b/ApplicationCode/ProjectDataModel/RimWellLogTrack.h index aa159e9116..dbcfc96321 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.h @@ -69,6 +69,11 @@ public: void setLogarithmicScale(bool enable); std::vector visibleStackedCurves(); + + QString description(); + std::vector curvesVector(); + + protected: // Overridden PDM methods virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);