From 847bd0736aa0fcd916a2e4704de69f271cfeb22b Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 21 Oct 2019 23:31:39 +0200 Subject: [PATCH] #4819 Write contour map metadata header. --- .../RicExportContourMapToAsciiFeature.cpp | 26 +++++++++++++++++++ .../RicExportContourMapToAsciiFeature.h | 5 ++++ 2 files changed, 31 insertions(+) diff --git a/ApplicationCode/Commands/RicExportContourMapToAsciiFeature.cpp b/ApplicationCode/Commands/RicExportContourMapToAsciiFeature.cpp index 9bf06b927a..223b5783af 100644 --- a/ApplicationCode/Commands/RicExportContourMapToAsciiFeature.cpp +++ b/ApplicationCode/Commands/RicExportContourMapToAsciiFeature.cpp @@ -34,6 +34,7 @@ #include "cafUtils.h" #include +#include #include #include @@ -136,6 +137,28 @@ void RicExportContourMapToAsciiFeature::onActionTriggered( bool isChecked ) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportContourMapToAsciiFeature::writeMetaDataToStream( QTextStream& stream, + const RimContourMapProjection* contourMapProjection, + const QString& caseName, + bool exportLocalCoordinates ) +{ + cvf::Vec2ui numVerticesIJ = contourMapProjection->numberOfVerticesIJ(); + stream << "# case name : " << caseName << "\n"; + stream << "# sampling points : nx=" << numVerticesIJ.x() << " ny=" << numVerticesIJ.y() << "\n"; + QDateTime now = QDateTime::currentDateTime(); + stream << "# time and date : " << now.toString( Qt::ISODate ) << "\n"; + stream << "# property name : " << contourMapProjection->resultDescriptionText() << "\n"; + if ( exportLocalCoordinates ) + { + stream << "# UTM offset : x=" << contourMapProjection->origin3d().x() + << " y=" << contourMapProjection->origin3d().y() << "\n"; + } + stream << "\n\n"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -217,10 +240,12 @@ RicfCommandResponse RicExportContourMapToAsciiFeature::execute() if ( existingEclipseContourMap ) { contourMapProjection = existingEclipseContourMap->contourMapProjection(); + contourMapName = existingEclipseContourMap->createAutoName(); } else if ( existingGeoMechContourMap ) { contourMapProjection = existingGeoMechContourMap->contourMapProjection(); + contourMapName = existingGeoMechContourMap->createAutoName(); } CAF_ASSERT( contourMapProjection ); @@ -234,6 +259,7 @@ RicfCommandResponse RicExportContourMapToAsciiFeature::execute() { QString tableText; QTextStream stream( &exportFile ); + writeMetaDataToStream( stream, contourMapProjection, contourMapName, m_exportLocalCoordinates.value() ); writeContourMapToStream( stream, contourMapProjection, m_exportLocalCoordinates.value(), diff --git a/ApplicationCode/Commands/RicExportContourMapToAsciiFeature.h b/ApplicationCode/Commands/RicExportContourMapToAsciiFeature.h index 21fb79886c..2a7d7ba448 100644 --- a/ApplicationCode/Commands/RicExportContourMapToAsciiFeature.h +++ b/ApplicationCode/Commands/RicExportContourMapToAsciiFeature.h @@ -41,6 +41,11 @@ protected: bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; + static void writeMetaDataToStream( QTextStream& stream, + const RimContourMapProjection* contourMapProjection, + const QString& caseName, + bool exportLocalCoordinates ); + static void writeContourMapToStream( QTextStream& stream, const RimContourMapProjection* contourMapProjection, bool exportLocalCoordinates,