mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4819 Basic export and nearly completed UI.
This commit is contained in:
parent
b3dd2109ac
commit
dc9e064c9a
@ -82,6 +82,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicResampleDialog.h
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RicCreateTemporaryLgrFeature.h
|
${CMAKE_CURRENT_LIST_DIR}/RicCreateTemporaryLgrFeature.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteTemporaryLgrsFeature.h
|
${CMAKE_CURRENT_LIST_DIR}/RicDeleteTemporaryLgrsFeature.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicExportContourMapToAsciiFeature.h
|
${CMAKE_CURRENT_LIST_DIR}/RicExportContourMapToAsciiFeature.h
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RicExportContourMapToAsciiUi.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -162,6 +163,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicResampleDialog.cpp
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RicCreateTemporaryLgrFeature.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicCreateTemporaryLgrFeature.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteTemporaryLgrsFeature.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicDeleteTemporaryLgrsFeature.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicExportContourMapToAsciiFeature.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicExportContourMapToAsciiFeature.cpp
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RicExportContourMapToAsciiUi.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "RiaGuiApplication.h"
|
#include "RiaGuiApplication.h"
|
||||||
#include "RiaLogging.h"
|
#include "RiaLogging.h"
|
||||||
|
#include "RicExportContourMapToAsciiUi.h"
|
||||||
#include "RifTextDataTableFormatter.h"
|
#include "RifTextDataTableFormatter.h"
|
||||||
#include "RimContourMapProjection.h"
|
#include "RimContourMapProjection.h"
|
||||||
#include "RimEclipseContourMapProjection.h"
|
#include "RimEclipseContourMapProjection.h"
|
||||||
@ -26,6 +27,7 @@
|
|||||||
#include "RimGeoMechContourMapProjection.h"
|
#include "RimGeoMechContourMapProjection.h"
|
||||||
#include "RimGeoMechContourMapView.h"
|
#include "RimGeoMechContourMapView.h"
|
||||||
|
|
||||||
|
#include "cafPdmUiPropertyViewDialog.h"
|
||||||
#include "cafSelectionManager.h"
|
#include "cafSelectionManager.h"
|
||||||
#include "cafUtils.h"
|
#include "cafUtils.h"
|
||||||
|
|
||||||
@ -75,21 +77,25 @@ void RicExportContourMapToAsciiFeature::onActionTriggered( bool isChecked )
|
|||||||
|
|
||||||
RiaGuiApplication* app = RiaGuiApplication::instance();
|
RiaGuiApplication* app = RiaGuiApplication::instance();
|
||||||
CAF_ASSERT( app && "Must be gui mode" );
|
CAF_ASSERT( app && "Must be gui mode" );
|
||||||
|
|
||||||
QString startPath = app->lastUsedDialogDirectoryWithFallbackToProjectFolder( "CONTOUR_EXPORT" );
|
QString startPath = app->lastUsedDialogDirectoryWithFallbackToProjectFolder( "CONTOUR_EXPORT" );
|
||||||
|
|
||||||
QString fileBaseName = caf::Utils::makeValidFileBasename( contourMapName );
|
QString fileBaseName = caf::Utils::makeValidFileBasename( contourMapName );
|
||||||
|
|
||||||
startPath = startPath + "/" + fileBaseName + ".txt";
|
startPath = startPath + "/" + fileBaseName + ".txt";
|
||||||
|
|
||||||
QString fileName = QFileDialog::getSaveFileName( nullptr,
|
RicExportContourMapToAsciiUi featureUi;
|
||||||
tr( "Export Contour Map To Text File" ),
|
featureUi.setExportFileName( startPath );
|
||||||
startPath,
|
|
||||||
tr( "Text file (*.txt);;All files(*.*)" ) );
|
|
||||||
|
|
||||||
if ( fileName.isEmpty() )
|
caf::PdmUiPropertyViewDialog propertyDialog( nullptr,
|
||||||
|
&featureUi,
|
||||||
|
"Export Contour Map as Text",
|
||||||
|
"",
|
||||||
|
QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
|
||||||
|
QString fileName = featureUi.exportFileName();
|
||||||
|
if ( propertyDialog.exec() == QDialog::Accepted && !fileName.isEmpty() )
|
||||||
{
|
{
|
||||||
return;
|
app->setLastUsedDialogDirectory( "CONTOUR_EXPORT", fileName );
|
||||||
}
|
|
||||||
|
|
||||||
QFile exportFile( fileName );
|
QFile exportFile( fileName );
|
||||||
if ( !exportFile.open( QIODevice::WriteOnly | QIODevice::Text ) )
|
if ( !exportFile.open( QIODevice::WriteOnly | QIODevice::Text ) )
|
||||||
@ -98,10 +104,19 @@ void RicExportContourMapToAsciiFeature::onActionTriggered( bool isChecked )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cvf::Vec2ui numVerticesIJ = contourMapProjection->numberOfVerticesIJ();
|
|
||||||
|
|
||||||
QString tableText;
|
QString tableText;
|
||||||
QTextStream stream( &exportFile );
|
QTextStream stream( &exportFile );
|
||||||
|
|
||||||
|
writeContourMapToStream( stream, contourMapProjection );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicExportContourMapToAsciiFeature::writeContourMapToStream( QTextStream& stream,
|
||||||
|
const RimContourMapProjection* contourMapProjection )
|
||||||
|
{
|
||||||
RifTextDataTableFormatter formatter( stream );
|
RifTextDataTableFormatter formatter( stream );
|
||||||
formatter.setTableRowLineAppendText( "" );
|
formatter.setTableRowLineAppendText( "" );
|
||||||
formatter.setTableRowPrependText( "" );
|
formatter.setTableRowPrependText( "" );
|
||||||
@ -116,6 +131,7 @@ void RicExportContourMapToAsciiFeature::onActionTriggered( bool isChecked )
|
|||||||
|
|
||||||
formatter.header( header );
|
formatter.header( header );
|
||||||
|
|
||||||
|
cvf::Vec2ui numVerticesIJ = contourMapProjection->numberOfVerticesIJ();
|
||||||
for ( unsigned int j = 0; j < numVerticesIJ.y(); j++ )
|
for ( unsigned int j = 0; j < numVerticesIJ.y(); j++ )
|
||||||
{
|
{
|
||||||
for ( unsigned int i = 0; i < numVerticesIJ.x(); i++ )
|
for ( unsigned int i = 0; i < numVerticesIJ.x(); i++ )
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
#include "cafCmdFeature.h"
|
#include "cafCmdFeature.h"
|
||||||
|
|
||||||
|
class RimContourMapProjection;
|
||||||
|
class QTextStream;
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
@ -30,5 +33,8 @@ protected:
|
|||||||
// Overrides
|
// Overrides
|
||||||
bool isCommandEnabled() override;
|
bool isCommandEnabled() override;
|
||||||
void onActionTriggered( bool isChecked ) override;
|
void onActionTriggered( bool isChecked ) override;
|
||||||
|
|
||||||
|
static void writeContourMapToStream( QTextStream& stream, const RimContourMapProjection* contourMapProjection );
|
||||||
|
|
||||||
void setupActionLook( QAction* actionToSetup ) override;
|
void setupActionLook( QAction* actionToSetup ) override;
|
||||||
};
|
};
|
||||||
|
67
ApplicationCode/Commands/RicExportContourMapToAsciiUi.cpp
Normal file
67
ApplicationCode/Commands/RicExportContourMapToAsciiUi.cpp
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
#include "RicExportContourMapToAsciiUi.h"
|
||||||
|
|
||||||
|
#include "RiaApplication.h"
|
||||||
|
|
||||||
|
#include "cafPdmUiFilePathEditor.h"
|
||||||
|
|
||||||
|
CAF_PDM_SOURCE_INIT( RicExportContourMapToAsciiUi, "RicExportContourMapToAsciiUi" );
|
||||||
|
|
||||||
|
RicExportContourMapToAsciiUi::RicExportContourMapToAsciiUi()
|
||||||
|
{
|
||||||
|
CAF_PDM_InitObject( "Export Contour Map to Text", "", "", "" );
|
||||||
|
|
||||||
|
CAF_PDM_InitField( &m_exportFileName, "ExportFileName", QString(), "Export File Name", "", "", "" );
|
||||||
|
m_exportFileName.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() );
|
||||||
|
|
||||||
|
CAF_PDM_InitField( &m_exportLocalCoordinates, "ExportLocalCoordinates", false, "Export Local Coordinates", "", "", "" );
|
||||||
|
CAF_PDM_InitField( &m_undefinedValueLabel, "UndefinedValueLabel", QString( "NaN" ), "Undefined Value Label", "", "", "" );
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QString RicExportContourMapToAsciiUi::exportFileName() const
|
||||||
|
{
|
||||||
|
return m_exportFileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicExportContourMapToAsciiUi::setExportFileName( const QString& exportFileName )
|
||||||
|
{
|
||||||
|
m_exportFileName = exportFileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicExportContourMapToAsciiUi::exportLocalCoordinates() const
|
||||||
|
{
|
||||||
|
return m_exportLocalCoordinates;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QString RicExportContourMapToAsciiUi::undefinedValueLabel() const
|
||||||
|
{
|
||||||
|
return m_undefinedValueLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicExportContourMapToAsciiUi::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||||
|
QString uiConfigName,
|
||||||
|
caf::PdmUiEditorAttribute* attribute )
|
||||||
|
{
|
||||||
|
if ( field == &m_exportFileName )
|
||||||
|
{
|
||||||
|
caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>( attribute );
|
||||||
|
if ( myAttr )
|
||||||
|
{
|
||||||
|
myAttr->m_selectSaveFileName = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
48
ApplicationCode/Commands/RicExportContourMapToAsciiUi.h
Normal file
48
ApplicationCode/Commands/RicExportContourMapToAsciiUi.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2019- Equinor 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 RicExportContourMapToAsciiUi : public caf::PdmObject
|
||||||
|
{
|
||||||
|
CAF_PDM_HEADER_INIT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
RicExportContourMapToAsciiUi();
|
||||||
|
|
||||||
|
QString exportFileName() const;
|
||||||
|
void setExportFileName( const QString& exportFileName );
|
||||||
|
bool exportLocalCoordinates() const;
|
||||||
|
QString undefinedValueLabel() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||||
|
QString uiConfigName,
|
||||||
|
caf::PdmUiEditorAttribute* attribute ) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
caf::PdmField<QString> m_exportFileName;
|
||||||
|
caf::PdmField<bool> m_exportLocalCoordinates;
|
||||||
|
caf::PdmField<QString> m_undefinedValueLabel;
|
||||||
|
};
|
@ -1606,7 +1606,7 @@ cvf::Vec2d RimContourMapProjection::origin2d() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
/// Vertex positions in local coordinates (add origin2d.x() for UTM x)
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
std::vector<double> RimContourMapProjection::xVertexPositions() const
|
std::vector<double> RimContourMapProjection::xVertexPositions() const
|
||||||
{
|
{
|
||||||
@ -1624,7 +1624,7 @@ std::vector<double> RimContourMapProjection::xVertexPositions() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
/// Vertex positions in local coordinates (add origin2d.y() for UTM y)
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
std::vector<double> RimContourMapProjection::yVertexPositions() const
|
std::vector<double> RimContourMapProjection::yVertexPositions() const
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user