#7324 Export well path: Remove problematic characters in file name

This commit is contained in:
Magne Sjaastad 2021-02-16 15:46:26 +01:00
parent 4666c45f66
commit b93be2f73b
3 changed files with 12 additions and 9 deletions

View File

@ -36,13 +36,12 @@
#include "cafPdmUiPropertyViewDialog.h" #include "cafPdmUiPropertyViewDialog.h"
#include "cafSelectionManagerTools.h" #include "cafSelectionManagerTools.h"
#include "cafUtils.h"
#include <QAction> #include <QAction>
#include <QDir> #include <QDir>
#include <QFileInfo> #include <QFileInfo>
#include <cafUtils.h>
#include <memory> #include <memory>
CAF_CMD_SOURCE_INIT( RicExportSelectedWellPathsFeature, "RicExportSelectedWellPathsFeature" ); CAF_CMD_SOURCE_INIT( RicExportSelectedWellPathsFeature, "RicExportSelectedWellPathsFeature" );
@ -55,7 +54,9 @@ void RicExportSelectedWellPathsFeature::exportWellPath( gsl::not_null<const RimW
const QString& folder, const QString& folder,
bool writeProjectInfo ) bool writeProjectInfo )
{ {
auto fileName = wellPath->name() + ".dev"; auto fileName = caf::Utils::makeValidFileBasename( wellPath->name() );
fileName += ".dev";
auto filePtr = openFileForExport( folder, fileName ); auto filePtr = openFileForExport( folder, fileName );
auto stream = createOutputFileStream( *filePtr ); auto stream = createOutputFileStream( *filePtr );
@ -69,6 +70,8 @@ void RicExportSelectedWellPathsFeature::exportWellPath( gsl::not_null<const RimW
writeWellPathGeometryToStream( *stream, wellPath->name(), xValues, yValues, tvdValues, mdValues, useMdRkb, writeProjectInfo ); writeWellPathGeometryToStream( *stream, wellPath->name(), xValues, yValues, tvdValues, mdValues, useMdRkb, writeProjectInfo );
filePtr->close(); filePtr->close();
RiaLogging::info( QString( "Exported well geometry to %1" ).arg( filePtr->fileName() ) );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -172,7 +175,7 @@ QTextStreamPtr RicExportSelectedWellPathsFeature::createOutputFileStream( QFile&
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicExportSelectedWellPathsFeature::handleAction( const std::vector<RimWellPath*>& wellPaths ) void RicExportSelectedWellPathsFeature::exportWellPathsToFile( const std::vector<RimWellPath*>& wellPaths )
{ {
if ( !wellPaths.empty() ) if ( !wellPaths.empty() )
{ {
@ -211,7 +214,7 @@ void RicExportSelectedWellPathsFeature::onActionTriggered( bool isChecked )
{ {
std::vector<RimWellPath*> wellPaths = caf::selectedObjectsByTypeStrict<RimWellPath*>(); std::vector<RimWellPath*> wellPaths = caf::selectedObjectsByTypeStrict<RimWellPath*>();
handleAction( wellPaths ); exportWellPathsToFile( wellPaths );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -45,7 +45,7 @@ class RicExportSelectedWellPathsFeature : public caf::CmdFeature
{ {
CAF_CMD_HEADER_INIT; CAF_CMD_HEADER_INIT;
static void handleAction( const std::vector<RimWellPath*>& wellPaths ); static void exportWellPathsToFile( const std::vector<RimWellPath*>& wellPaths );
static void exportWellPath( gsl::not_null<const RimWellPath*> wellPath, static void exportWellPath( gsl::not_null<const RimWellPath*> wellPath,
double mdStepSize, double mdStepSize,
const QString& folder, const QString& folder,

View File

@ -58,7 +58,7 @@ void RicExportVisibleWellPathsFeature::onActionTriggered( bool isChecked )
{ {
std::vector<RimWellPath*> wellPaths = RicExportCompletionsForVisibleWellPathsFeature::visibleWellPaths(); std::vector<RimWellPath*> wellPaths = RicExportCompletionsForVisibleWellPathsFeature::visibleWellPaths();
RicExportSelectedWellPathsFeature::handleAction( wellPaths ); RicExportSelectedWellPathsFeature::exportWellPathsToFile( wellPaths );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------