mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5832 Add color legend data with import from LYR file.
This commit is contained in:
committed by
Kristian Bendiksen
parent
3e5c77e79e
commit
6cb86d4792
@@ -164,6 +164,7 @@ list( APPEND REFERENCED_CMAKE_FILES
|
||||
Commands/AnalysisPlotCommands/CMakeLists_files.cmake
|
||||
Commands/ApplicationCommands/CMakeLists_files.cmake
|
||||
Commands/AnnotationCommands/CMakeLists_files.cmake
|
||||
Commands/ColorLegendCommands/CMakeLists_files.cmake
|
||||
Commands/CompletionCommands/CMakeLists_files.cmake
|
||||
Commands/CompletionExportCommands/CMakeLists_files.cmake
|
||||
Commands/CorrelationPlotCommands/CMakeLists_files.cmake
|
||||
|
@@ -0,0 +1,22 @@
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportColorCategories.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportColorCategories.cpp
|
||||
)
|
||||
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
${SOURCE_GROUP_HEADER_FILES}
|
||||
)
|
||||
|
||||
list(APPEND CODE_SOURCE_FILES
|
||||
${SOURCE_GROUP_SOURCE_FILES}
|
||||
)
|
||||
|
||||
source_group( "CommandFeature\\ColorLegend" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake )
|
||||
|
||||
# cotire
|
||||
caf_cotire_start_unity_at_first_item(SOURCE_GROUP_SOURCE_FILES)
|
@@ -0,0 +1,100 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicImportColorCategories.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RigFormationNames.h"
|
||||
#include "RimColorLegend.h"
|
||||
#include "RimColorLegendCollection.h"
|
||||
#include "RimColorLegendItem.h"
|
||||
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "RifColorLegendData.h"
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QFileDialog>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicImportColorCategories, "RicImportColorCategories" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicImportColorCategories::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicImportColorCategories::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString defaultDir = app->lastUsedDialogDirectory( "BINARY_GRID" );
|
||||
|
||||
QString filterText = QString( "Formation Names description File (*.lyr);;All Files (*.*)" );
|
||||
|
||||
QString fileName = QFileDialog::getOpenFileName( Riu3DMainWindowTools::mainWindowWidget(),
|
||||
"Import Formation File",
|
||||
defaultDir,
|
||||
filterText );
|
||||
|
||||
if ( fileName.isEmpty() ) return;
|
||||
|
||||
// Remember the path to next time
|
||||
app->setLastUsedDialogDirectory( "BINARY_GRID", QFileInfo( fileName ).absolutePath() );
|
||||
|
||||
QString errormessage;
|
||||
cvf::ref<RigFormationNames> formations = RifColorLegendData::readFormationNamesFile( fileName, &errormessage );
|
||||
|
||||
const std::vector<QString>& formationNames = formations->formationNames();
|
||||
const std::vector<cvf::Color3f>& formationColors = formations->formationColors();
|
||||
|
||||
RimColorLegend* colorLegend = new RimColorLegend;
|
||||
colorLegend->setColorLegendName( "LYR imported color legend" );
|
||||
|
||||
for ( size_t i = 0; i < formationColors.size(); i++ )
|
||||
{
|
||||
RimColorLegendItem* colorLegendItem = new RimColorLegendItem;
|
||||
|
||||
colorLegendItem->setValues( formationNames[i], i, formationColors[i] );
|
||||
|
||||
colorLegend->appendColorLegendItem( colorLegendItem );
|
||||
}
|
||||
|
||||
RimProject* proj = RimProject::current();
|
||||
|
||||
RimColorLegendCollection* colorLegendCollection = proj->colorLegendCollection;
|
||||
|
||||
colorLegendCollection->appendColorLegend( colorLegend );
|
||||
|
||||
colorLegendCollection->updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicImportColorCategories::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setIcon( QIcon( ":/Formations16x16.png" ) );
|
||||
actionToSetup->setText( "Import Color Legend from LYR Formation File" );
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020 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 "cafCmdFeature.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicImportColorCategories : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
@@ -52,6 +52,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RifCsvDataTableFormatter.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifEclipseInputPropertyLoader.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifSurfaceReader.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifRoffReader.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifColorLegendData.h
|
||||
|
||||
# HDF5 file reader is directly included in ResInsight main CmakeList.txt
|
||||
#${CMAKE_CURRENT_LIST_DIR}/RifHdf5Reader.h
|
||||
@@ -108,6 +109,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RifReaderEnsembleStatisticsRft.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifEclipseInputPropertyLoader.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifSurfaceReader.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifRoffReader.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifColorLegendData.cpp
|
||||
|
||||
# HDF5 file reader is directly included in ResInsight main CmakeList.txt
|
||||
#${CMAKE_CURRENT_LIST_DIR}/RifHdf5Reader.cpp
|
||||
|
264
ApplicationCode/FileInterface/RifColorLegendData.cpp
Normal file
264
ApplicationCode/FileInterface/RifColorLegendData.cpp
Normal file
@@ -0,0 +1,264 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RifColorLegendData.h"
|
||||
|
||||
#include "RigFormationNames.h"
|
||||
|
||||
#include "cafAssert.h"
|
||||
#include "cafPdmUiFilePathEditor.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "cvfColor3.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<RigFormationNames> RifColorLegendData::readFormationNamesFile( const QString& fileName, QString* errorMessage )
|
||||
{
|
||||
QFileInfo fileInfo( fileName );
|
||||
|
||||
if ( fileInfo.fileName() == "layer_zone_table.txt" )
|
||||
{
|
||||
return RifColorLegendData::readFmuFormationNameFile( fileName, errorMessage );
|
||||
}
|
||||
else
|
||||
{
|
||||
return RifColorLegendData::readLyrFormationNameFile( fileName, errorMessage );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<RigFormationNames> RifColorLegendData::readLyrFormationNameFile( const QString& fileName, QString* errorMessage )
|
||||
{
|
||||
cvf::ref<RigFormationNames> formationNames = new RigFormationNames;
|
||||
|
||||
QFile dataFile( fileName );
|
||||
|
||||
if ( !dataFile.open( QFile::ReadOnly ) )
|
||||
{
|
||||
if ( errorMessage ) ( *errorMessage ) += "Could not open file: " + fileName + "\n";
|
||||
return formationNames;
|
||||
}
|
||||
|
||||
QTextStream stream( &dataFile );
|
||||
|
||||
int lineNumber = 1;
|
||||
while ( !stream.atEnd() )
|
||||
{
|
||||
QString line = stream.readLine();
|
||||
QStringList lineSegs = line.split( "'", QString::KeepEmptyParts );
|
||||
|
||||
if ( lineSegs.size() == 0 ) continue; // Empty line
|
||||
if ( lineSegs.size() == 1 ) continue; // No name present. Comment line ?
|
||||
if ( lineSegs.size() == 2 )
|
||||
{
|
||||
if ( errorMessage ) ( *errorMessage ) += "Missing quote on line : " + QString::number( lineNumber ) + "\n";
|
||||
continue; // One quote present
|
||||
}
|
||||
|
||||
if ( lineSegs.size() == 3 ) // Normal case
|
||||
{
|
||||
if ( lineSegs[0].contains( "--" ) ) continue; // Comment line
|
||||
QString formationName = lineSegs[1];
|
||||
int commentMarkPos = lineSegs[2].indexOf( "--" );
|
||||
QString numberString = lineSegs[2];
|
||||
if ( commentMarkPos >= 0 ) numberString.truncate( commentMarkPos );
|
||||
|
||||
QString colorWord = numberString.split( " ", QString::SkipEmptyParts ).last(); // extract last word which may
|
||||
// contain formation color
|
||||
|
||||
if ( QColor::isValidColor( colorWord ) )
|
||||
numberString.remove( colorWord ); // remove color if present as last word on line
|
||||
|
||||
QStringList numberWords =
|
||||
numberString.split( QRegExp( "-" ), QString::SkipEmptyParts ); // extract words containing formation
|
||||
// number(s)
|
||||
|
||||
if ( numberWords.size() == 2 ) // formation range with or without color at end of line
|
||||
{
|
||||
bool isNumber1 = false;
|
||||
bool isNumber2 = false;
|
||||
int startK = numberWords[0].toInt( &isNumber1 );
|
||||
int endK = numberWords[1].toInt( &isNumber2 );
|
||||
|
||||
if ( !( isNumber2 && isNumber1 ) )
|
||||
{
|
||||
if ( errorMessage )
|
||||
( *errorMessage ) += "Format error on line: " + QString::number( lineNumber ) + "\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
int tmp = startK;
|
||||
startK = tmp < endK ? tmp : endK;
|
||||
endK = tmp > endK ? tmp : endK;
|
||||
|
||||
if ( QColor::isValidColor( colorWord ) ) // formation color present at end of line
|
||||
{
|
||||
cvf::Color3f formationColor;
|
||||
|
||||
convertStringToColor( colorWord, &formationColor );
|
||||
formationNames->appendFormationRange( formationName, formationColor, startK - 1, endK - 1 );
|
||||
}
|
||||
else // no color present
|
||||
{
|
||||
formationNames->appendFormationRange( formationName, startK - 1, endK - 1 );
|
||||
}
|
||||
}
|
||||
else if ( numberWords.size() == 1 )
|
||||
{
|
||||
bool isNumber1 = false;
|
||||
int kLayerCount = numberWords[0].toInt( &isNumber1 );
|
||||
|
||||
if ( !isNumber1 )
|
||||
{
|
||||
if ( errorMessage )
|
||||
( *errorMessage ) += "Format error on line: " + QString::number( lineNumber ) + "\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( QColor::isValidColor( colorWord ) ) // formation color present at end of line
|
||||
{
|
||||
cvf::Color3f formationColor;
|
||||
|
||||
convertStringToColor( colorWord, &formationColor );
|
||||
formationNames->appendFormationRangeHeight( formationName, formationColor, kLayerCount );
|
||||
}
|
||||
else // no color present
|
||||
{
|
||||
formationNames->appendFormationRangeHeight( formationName, kLayerCount );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( errorMessage )
|
||||
( *errorMessage ) += "Format error on line: " + QString::number( lineNumber ) + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
++lineNumber;
|
||||
}
|
||||
|
||||
return formationNames;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<RigFormationNames> RifColorLegendData::readFmuFormationNameFile( const QString& fileName, QString* errorMessage )
|
||||
{
|
||||
cvf::ref<RigFormationNames> formationNames = new RigFormationNames;
|
||||
|
||||
QFile dataFile( fileName );
|
||||
|
||||
if ( !dataFile.open( QFile::ReadOnly ) )
|
||||
{
|
||||
if ( errorMessage ) ( *errorMessage ) += "Could not open file: " + fileName + "\n";
|
||||
return formationNames;
|
||||
}
|
||||
|
||||
QTextStream stream( &dataFile );
|
||||
|
||||
int lineNumber = 1;
|
||||
|
||||
QString currentFormationName;
|
||||
int startK = -1;
|
||||
int endK = -1;
|
||||
|
||||
while ( !stream.atEnd() )
|
||||
{
|
||||
QString line = stream.readLine();
|
||||
if ( line.isNull() )
|
||||
{
|
||||
// Make sure we append the last formation
|
||||
if ( !currentFormationName.isEmpty() )
|
||||
{
|
||||
formationNames->appendFormationRange( currentFormationName, startK - 1, endK - 1 );
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
QTextStream lineStream( &line );
|
||||
|
||||
double kLayer;
|
||||
QString formationName;
|
||||
|
||||
lineStream >> kLayer >> formationName;
|
||||
|
||||
if ( lineStream.status() != QTextStream::Ok )
|
||||
{
|
||||
*errorMessage = QString( "Failed to parse line %1 of '%2'" ).arg( lineNumber ).arg( fileName );
|
||||
return formationNames;
|
||||
}
|
||||
|
||||
if ( formationName != currentFormationName )
|
||||
{
|
||||
// Append previous formation
|
||||
if ( !currentFormationName.isEmpty() )
|
||||
{
|
||||
formationNames->appendFormationRange( currentFormationName, startK - 1, endK - 1 );
|
||||
}
|
||||
|
||||
// Start new formation
|
||||
currentFormationName = formationName;
|
||||
startK = kLayer;
|
||||
endK = kLayer;
|
||||
}
|
||||
else
|
||||
{
|
||||
endK = kLayer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Append previous formation at the end of the stream
|
||||
if ( !currentFormationName.isEmpty() )
|
||||
{
|
||||
formationNames->appendFormationRange( currentFormationName, startK - 1, endK - 1 );
|
||||
}
|
||||
|
||||
return formationNames;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Conversion of a color specification from string representation to Color3f.
|
||||
/// String can be in various formats according to QColor capabilities, notably
|
||||
/// SVG color keyword names, c.f. https://www.w3.org/TR/SVG11/types.html#ColorKeywords,
|
||||
/// or #RRGGBB used on a LYR formation data file.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifColorLegendData::convertStringToColor( const QString& word, cvf::Color3f* color )
|
||||
{
|
||||
if ( word.isEmpty() ) return false;
|
||||
|
||||
QColor colorQ( word );
|
||||
|
||||
if ( colorQ.isValid() )
|
||||
{
|
||||
*color = cvf::Color3f::fromByteColor( colorQ.red(), colorQ.green(), colorQ.blue() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
45
ApplicationCode/FileInterface/RifColorLegendData.h
Normal file
45
ApplicationCode/FileInterface/RifColorLegendData.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 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"
|
||||
#include "cvfObject.h"
|
||||
|
||||
class RigFormationNames;
|
||||
class QString;
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class Color3f;
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RifColorLegendData
|
||||
{
|
||||
public:
|
||||
static cvf::ref<RigFormationNames> readFormationNamesFile( const QString& fileName, QString* errorMessage );
|
||||
|
||||
private:
|
||||
static cvf::ref<RigFormationNames> readLyrFormationNameFile( const QString& fileName, QString* errorMessage );
|
||||
static cvf::ref<RigFormationNames> readFmuFormationNameFile( const QString& fileName, QString* errorMessage );
|
||||
|
||||
static bool convertStringToColor( const QString& word, cvf::Color3f* color );
|
||||
};
|
@@ -153,6 +153,10 @@ ${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementInViewCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementInView.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellDiskConfig.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimElementVectorResult.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimColorLegendCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimColorLegend.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimColorLegendItem.h
|
||||
|
||||
)
|
||||
|
||||
|
||||
@@ -310,6 +314,9 @@ ${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementInViewCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementInView.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellDiskConfig.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimElementVectorResult.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimColorLegendCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimColorLegend.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimColorLegendItem.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
75
ApplicationCode/ProjectDataModel/RimColorLegend.cpp
Normal file
75
ApplicationCode/ProjectDataModel/RimColorLegend.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimColorLegend.h"
|
||||
#include "RimColorLegendItem.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimColorLegend, "ColorLegend" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimColorLegend::RimColorLegend()
|
||||
{
|
||||
CAF_PDM_InitObject( "ColorLegend", ":/Legend.png", "", "" );
|
||||
|
||||
CAF_PDM_InitField( &m_colorLegendName, "ColorLegendName", QString( "" ), "Color Legend Name", "", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_colorLegendItems, "ColorLegendItems", "", "", "", "" );
|
||||
m_colorLegendItems.uiCapability()->setUiHidden( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimColorLegend::~RimColorLegend()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimColorLegend::userDescriptionField()
|
||||
{
|
||||
return &m_colorLegendName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimColorLegend::setColorLegendName( const QString& colorLegendName )
|
||||
{
|
||||
m_colorLegendName = colorLegendName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimColorLegend::appendColorLegendItem( RimColorLegendItem* colorLegendItem )
|
||||
{
|
||||
m_colorLegendItems.push_back( colorLegendItem );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimColorLegend::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
}
|
56
ApplicationCode/ProjectDataModel/RimColorLegend.h
Normal file
56
ApplicationCode/ProjectDataModel/RimColorLegend.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020 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 "cafPdmChildArrayField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
class RimColorLegendItem;
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PdmUiEditorAttribute;
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimColorLegend : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimColorLegend();
|
||||
~RimColorLegend() override;
|
||||
|
||||
public:
|
||||
void setColorLegendName( const QString& colorLegendName );
|
||||
void appendColorLegendItem( RimColorLegendItem* colorLegendItem );
|
||||
|
||||
public:
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
|
||||
private:
|
||||
caf::PdmField<QString> m_colorLegendName;
|
||||
caf::PdmChildArrayField<RimColorLegendItem*> m_colorLegendItems;
|
||||
};
|
@@ -0,0 +1,57 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimColorLegendCollection.h"
|
||||
#include "RimColorLegend.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimColorLegendCollection, "ColorLegendCollection" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimColorLegendCollection::RimColorLegendCollection()
|
||||
{
|
||||
CAF_PDM_InitObject( "ColorLegendCollection", ":/Formations16x16.png", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_colorLegends, "ColorLegends", "", "", "", "" );
|
||||
m_colorLegends.uiCapability()->setUiHidden( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimColorLegendCollection::~RimColorLegendCollection()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimColorLegendCollection::appendColorLegend( RimColorLegend* colorLegend )
|
||||
{
|
||||
m_colorLegends.push_back( colorLegend );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimColorLegendCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
}
|
51
ApplicationCode/ProjectDataModel/RimColorLegendCollection.h
Normal file
51
ApplicationCode/ProjectDataModel/RimColorLegendCollection.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020 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 "cafPdmChildArrayField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
class RimColorLegend;
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PdmUiEditorAttribute;
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimColorLegendCollection : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimColorLegendCollection();
|
||||
~RimColorLegendCollection() override;
|
||||
|
||||
public:
|
||||
void appendColorLegend( RimColorLegend* colorLegend );
|
||||
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
|
||||
private:
|
||||
caf::PdmChildArrayField<RimColorLegend*> m_colorLegends;
|
||||
};
|
86
ApplicationCode/ProjectDataModel/RimColorLegendItem.cpp
Normal file
86
ApplicationCode/ProjectDataModel/RimColorLegendItem.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimColorLegendItem.h"
|
||||
|
||||
#include "cvfColor3.h"
|
||||
|
||||
#include <QColor>
|
||||
#include <QString>
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimColorLegendItem, "ColorLegendItem" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimColorLegendItem::RimColorLegendItem()
|
||||
{
|
||||
CAF_PDM_InitObject( "ColorLegendItem", "", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_color, "Color", "Color", "", "", "" );
|
||||
|
||||
CAF_PDM_InitField( &m_categoryValue, "CategoryValue", 0, "Category Value", "", "", "" );
|
||||
CAF_PDM_InitField( &m_categoryName, "CategoryName", QString( "" ), "Category Name", "", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_nameProxy, "NameProxy", "Name Proxy", "", "", "" );
|
||||
m_nameProxy.registerGetMethod( this, &RimColorLegendItem::extractColorItemName );
|
||||
m_nameProxy.uiCapability()->setUiHidden( true );
|
||||
m_nameProxy.xmlCapability()->disableIO();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimColorLegendItem::~RimColorLegendItem()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimColorLegendItem::setValues( const QString& categoryName, int categoryValue, const cvf::Color3f& color )
|
||||
{
|
||||
m_categoryName = categoryName;
|
||||
m_categoryValue = categoryValue;
|
||||
m_color = color;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimColorLegendItem::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimColorLegendItem::userDescriptionField()
|
||||
{
|
||||
return &m_nameProxy;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// "stringify" category value and name; category value with leading zeros presupposing max 2 digits
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimColorLegendItem::extractColorItemName() const
|
||||
{
|
||||
return QString( "%1" ).arg( m_categoryValue, 2, 10, QChar( '0' ) ) + " " + m_categoryName;
|
||||
}
|
59
ApplicationCode/ProjectDataModel/RimColorLegendItem.h
Normal file
59
ApplicationCode/ProjectDataModel/RimColorLegendItem.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020 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 "cafPdmChildArrayField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmProxyValueField.h"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PdmUiEditorAttribute;
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimColorLegendItem : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimColorLegendItem();
|
||||
~RimColorLegendItem() override;
|
||||
|
||||
void setValues( const QString& categoryName, int categoryValue, const cvf::Color3f& color );
|
||||
|
||||
public:
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
|
||||
private:
|
||||
QString extractColorItemName() const;
|
||||
|
||||
private:
|
||||
caf::PdmField<cvf::Color3f> m_color;
|
||||
caf::PdmField<int> m_categoryValue;
|
||||
caf::PdmField<QString> m_categoryName;
|
||||
|
||||
caf::PdmProxyValueField<QString> m_nameProxy;
|
||||
};
|
@@ -39,6 +39,7 @@
|
||||
#include "RimCellEdgeColors.h"
|
||||
#include "RimCellRangeFilter.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimColorLegendCollection.h"
|
||||
#include "RimCorrelationMatrixPlot.h"
|
||||
#include "RimCorrelationPlot.h"
|
||||
#include "RimCorrelationPlotCollection.h"
|
||||
@@ -782,6 +783,10 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
{
|
||||
menuBuilder << "RicExportCompletionsForVisibleSimWellsFeature";
|
||||
}
|
||||
else if ( dynamic_cast<RimColorLegendCollection*>( firstUiItem ) )
|
||||
{
|
||||
menuBuilder << "RicImportColorCategories";
|
||||
}
|
||||
else if ( dynamic_cast<RimFormationNames*>( firstUiItem ) )
|
||||
{
|
||||
menuBuilder << "RicImportFormationNamesFeature";
|
||||
|
@@ -39,6 +39,7 @@
|
||||
#include "RimCalcScript.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimColorLegendCollection.h"
|
||||
#include "RimCommandObject.h"
|
||||
#include "RimCompletionTemplateCollection.h"
|
||||
#include "RimContextCommandBuilder.h"
|
||||
@@ -129,6 +130,9 @@ RimProject::RimProject( void )
|
||||
CAF_PDM_InitFieldNoDefault( &oilFields, "OilFields", "Oil Fields", "", "", "" );
|
||||
oilFields.uiCapability()->setUiHidden( true );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &colorLegendCollection, "ColorLegendCollection", "Color Legend Collection", "", "", "" );
|
||||
colorLegendCollection = new RimColorLegendCollection();
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &scriptCollection, "ScriptCollection", "Octave Scripts", ":/octave.png", "", "" );
|
||||
scriptCollection.uiCapability()->setUiHidden( true );
|
||||
scriptCollection.xmlCapability()->disableIO();
|
||||
@@ -1457,6 +1461,7 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q
|
||||
if ( oilField->annotationCollection() ) uiTreeOrdering.add( oilField->annotationCollection() );
|
||||
}
|
||||
|
||||
uiTreeOrdering.add( colorLegendCollection() );
|
||||
uiTreeOrdering.add( scriptCollection() );
|
||||
}
|
||||
|
||||
|
@@ -52,6 +52,7 @@ class RimMeasurement;
|
||||
class RimAdvancedSnapshotExportDefinition;
|
||||
class RimObservedSummaryData;
|
||||
class RimOilField;
|
||||
class RimColorLegendCollection;
|
||||
class RimScriptCollection;
|
||||
class RimSummaryCase;
|
||||
class RimSummaryCaseCollection;
|
||||
@@ -93,6 +94,7 @@ public:
|
||||
static RimProject* current();
|
||||
|
||||
caf::PdmChildArrayField<RimOilField*> oilFields;
|
||||
caf::PdmChildField<RimColorLegendCollection*> colorLegendCollection;
|
||||
caf::PdmChildField<RimScriptCollection*> scriptCollection;
|
||||
caf::PdmChildField<RimWellPathImport*> wellPathImport;
|
||||
caf::PdmChildField<RimMainPlotCollection*> mainPlotCollection;
|
||||
|
@@ -44,10 +44,80 @@ QString RigFormationNames::formationNameFromKLayerIdx( size_t Kidx )
|
||||
return m_formationNames[idx];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigFormationNames::formationColorFromKLayerIdx( size_t Kidx, cvf::Color3f* formationColor )
|
||||
{
|
||||
int idx = formationIndexFromKLayerIdx( Kidx );
|
||||
|
||||
if ( idx == -1 || idx >= static_cast<int>( m_formationColors.size() ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( m_formationColors[idx] == undefinedColor() ) return false;
|
||||
|
||||
*formationColor = m_formationColors[idx];
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigFormationNames::appendFormationRange( const QString& name, int kStartIdx, int kEndIdx )
|
||||
{
|
||||
appendFormationRangeWithColor( name, undefinedColor(), kStartIdx, kEndIdx );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigFormationNames::appendFormationRange( const QString& name, cvf::Color3f color, int kStartIdx, int kEndIdx )
|
||||
{
|
||||
appendFormationRangeWithColor( name, color, kStartIdx, kEndIdx );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigFormationNames::appendFormationRangeHeight( const QString& name, int kLayerCount )
|
||||
{
|
||||
if ( kLayerCount < 1 ) return;
|
||||
|
||||
int kStartIdx = static_cast<int>( m_nameIndexPrKLayer.size() );
|
||||
int kEndIdx = kStartIdx + kLayerCount;
|
||||
|
||||
appendFormationRangeWithColor( name, undefinedColor(), kStartIdx, kEndIdx );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigFormationNames::appendFormationRangeHeight( const QString& name, cvf::Color3f color, int kLayerCount )
|
||||
{
|
||||
if ( kLayerCount < 1 ) return;
|
||||
|
||||
int kStartIdx = static_cast<int>( m_nameIndexPrKLayer.size() );
|
||||
int kEndIdx = kStartIdx + kLayerCount;
|
||||
|
||||
appendFormationRangeWithColor( name, color, kStartIdx, kEndIdx );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Color3f RigFormationNames::undefinedColor()
|
||||
{
|
||||
static cvf::Color3f noColor( -1.0f, -1.0f, -1.0f );
|
||||
|
||||
return noColor;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigFormationNames::appendFormationRangeWithColor( const QString& name, cvf::Color3f color, int kStartIdx, int kEndIdx )
|
||||
{
|
||||
CVF_ASSERT( kStartIdx <= kEndIdx );
|
||||
|
||||
@@ -64,25 +134,6 @@ void RigFormationNames::appendFormationRange( const QString& name, int kStartIdx
|
||||
{
|
||||
m_nameIndexPrKLayer[kIdx] = nameIdx;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigFormationNames::appendFormationRangeHeight( const QString& name, int kLayerCount )
|
||||
{
|
||||
if ( kLayerCount < 1 ) return;
|
||||
|
||||
int nameIdx = static_cast<int>( m_formationNames.size() );
|
||||
|
||||
m_formationNames.push_back( name );
|
||||
|
||||
int kStartIdx = static_cast<int>( m_nameIndexPrKLayer.size() );
|
||||
|
||||
m_nameIndexPrKLayer.resize( kStartIdx + kLayerCount, -1 );
|
||||
|
||||
for ( int kIdx = kStartIdx; kIdx < kStartIdx + kLayerCount; ++kIdx )
|
||||
{
|
||||
m_nameIndexPrKLayer[kIdx] = nameIdx;
|
||||
}
|
||||
|
||||
m_formationColors.push_back( color );
|
||||
}
|
||||
|
@@ -23,6 +23,8 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "cvfColor3.h"
|
||||
|
||||
class RigFormationNames : public cvf::Object
|
||||
{
|
||||
public:
|
||||
@@ -37,12 +39,23 @@ public:
|
||||
|
||||
QString formationNameFromKLayerIdx( size_t Kidx );
|
||||
|
||||
const std::vector<QString>& formationNames() const { return m_formationNames; }
|
||||
bool formationColorFromKLayerIdx( size_t Kidx, cvf::Color3f* formationColor );
|
||||
|
||||
const std::vector<QString>& formationNames() const { return m_formationNames; }
|
||||
const std::vector<cvf::Color3f>& formationColors() const { return m_formationColors; }
|
||||
|
||||
void appendFormationRange( const QString& name, int kStartIdx, int kEndIdx );
|
||||
void appendFormationRangeHeight( const QString& name, int kLayerCount );
|
||||
|
||||
void appendFormationRange( const QString& name, cvf::Color3f color, int kStartIdx, int kEndIdx );
|
||||
void appendFormationRangeHeight( const QString& name, cvf::Color3f color, int kLayerCount );
|
||||
|
||||
private:
|
||||
std::vector<int> m_nameIndexPrKLayer;
|
||||
std::vector<QString> m_formationNames;
|
||||
static cvf::Color3f undefinedColor();
|
||||
void appendFormationRangeWithColor( const QString& name, cvf::Color3f color, int kStartIdx, int kEndIdx );
|
||||
|
||||
private:
|
||||
std::vector<int> m_nameIndexPrKLayer;
|
||||
std::vector<QString> m_formationNames;
|
||||
std::vector<cvf::Color3f> m_formationColors; // optional color per formation
|
||||
};
|
||||
|
@@ -66,6 +66,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RifWellMeasurementReader-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaDateStringParser-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigHexGradientTools-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifSurfaceReader-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifColorLegendData-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifRoffReader-Test.cpp
|
||||
)
|
||||
|
||||
|
85
ApplicationCode/UnitTests/RifColorLegendData-Test.cpp
Normal file
85
ApplicationCode/UnitTests/RifColorLegendData-Test.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "RifColorLegendData.h"
|
||||
#include "RigFormationNames.h"
|
||||
|
||||
#include "QDir"
|
||||
#include "RiaTestDataDirectory.h"
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "cvfColor3.h"
|
||||
|
||||
TEST( RifColorLegendData, ReadLYRFileWithoutColor )
|
||||
{
|
||||
QDir baseFolder( TEST_DATA_DIR );
|
||||
|
||||
const QString filename( "RifColorLegendData/Norne_ATW2013.lyr" );
|
||||
const QString filePath = baseFolder.absoluteFilePath( filename );
|
||||
EXPECT_TRUE( QFile::exists( filePath ) );
|
||||
|
||||
QString errormessage;
|
||||
|
||||
cvf::ref<RigFormationNames> fm = RifColorLegendData::readFormationNamesFile( filePath, &errormessage );
|
||||
EXPECT_TRUE( errormessage.isEmpty() );
|
||||
|
||||
QString formationName_K1 = fm->formationNameFromKLayerIdx( 0 );
|
||||
int formationIndex = fm->formationIndexFromKLayerIdx( 1 );
|
||||
|
||||
EXPECT_TRUE( formationName_K1 == "Garn 3" );
|
||||
EXPECT_EQ( 1, formationIndex );
|
||||
}
|
||||
|
||||
TEST( RifColorLegendData, ReadLYRFileWithColorName )
|
||||
{
|
||||
QDir baseFolder( TEST_DATA_DIR );
|
||||
|
||||
const QString filename( "RifColorLegendData/Norne_ATW2013ColorName.lyr" );
|
||||
const QString filePath = baseFolder.absoluteFilePath( filename );
|
||||
EXPECT_TRUE( QFile::exists( filePath ) );
|
||||
|
||||
QString errormessage;
|
||||
|
||||
cvf::ref<RigFormationNames> fm = RifColorLegendData::readFormationNamesFile( filePath, &errormessage );
|
||||
EXPECT_TRUE( errormessage.isEmpty() );
|
||||
|
||||
QString formationName_K1 = fm->formationNameFromKLayerIdx( 1 );
|
||||
int formationIndex = fm->formationIndexFromKLayerIdx( 1 );
|
||||
|
||||
cvf::Color3f formationColor;
|
||||
bool colorPresent = fm->formationColorFromKLayerIdx( 1, &formationColor );
|
||||
EXPECT_TRUE( colorPresent );
|
||||
|
||||
EXPECT_TRUE( formationName_K1 == "Garn 2" );
|
||||
EXPECT_EQ( 1, formationIndex );
|
||||
EXPECT_EQ( 1.0f, formationColor.r() );
|
||||
EXPECT_EQ( 0.0f, formationColor.g() );
|
||||
EXPECT_EQ( 0.0f, formationColor.b() );
|
||||
}
|
||||
|
||||
TEST( RifColorLegendData, ReadLYRFileWithColorHTML )
|
||||
{
|
||||
QDir baseFolder( TEST_DATA_DIR );
|
||||
|
||||
const QString filename( "RifColorLegendData/Norne_ATW2013ColorHTML.lyr" );
|
||||
const QString filePath = baseFolder.absoluteFilePath( filename );
|
||||
EXPECT_TRUE( QFile::exists( filePath ) );
|
||||
|
||||
QString errormessage;
|
||||
|
||||
cvf::ref<RigFormationNames> fm = RifColorLegendData::readFormationNamesFile( filePath, &errormessage );
|
||||
EXPECT_TRUE( errormessage.isEmpty() );
|
||||
|
||||
QString formationName_K1 = fm->formationNameFromKLayerIdx( 1 );
|
||||
int formationIndex = fm->formationIndexFromKLayerIdx( 1 );
|
||||
|
||||
cvf::Color3f formationColor;
|
||||
bool colorPresent = fm->formationColorFromKLayerIdx( 1, &formationColor );
|
||||
EXPECT_TRUE( colorPresent );
|
||||
|
||||
EXPECT_TRUE( formationName_K1 == "Garn 2" );
|
||||
EXPECT_EQ( 1, formationIndex );
|
||||
EXPECT_EQ( 1.0f, formationColor.r() );
|
||||
EXPECT_EQ( 0.0f, formationColor.g() );
|
||||
EXPECT_EQ( 0.0f, formationColor.b() );
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
-- Formations - Norne FFM ATW2013
|
||||
'Garn 3' 1 - 1
|
||||
'Garn 2' 2 - 2
|
||||
'Garn 1' 3 - 3
|
||||
'Not' 4 - 4
|
||||
'Ile 2.2' 5 - 5
|
||||
'Ile 2.1.3' 6 - 6
|
||||
'Ile 2.1.2' 7 - 7
|
||||
'Ile 2.1.1' 8 - 8
|
||||
'Ile 1.3' 9 - 9
|
||||
'Ile 1.2' 10 - 10
|
||||
'Ile 1.1' 11 - 11
|
||||
'Tofte 2.2' 12 - 12
|
||||
'Tofte 2.1.3' 13 - 13
|
||||
'Tofte 2.1.2' 14 - 14
|
||||
'Tofte 2.1.1' 15 - 15
|
||||
'Tofte 1.2.2' 16 - 16
|
||||
'Tofte 1.2.1' 17 - 17
|
||||
'Tofte 1.1' 18 - 18
|
||||
'Tilje 4' 19 - 19
|
||||
'Tilje 3' 20 - 20
|
||||
'Tilje 2' 21 - 21
|
||||
'Tilje 1' 22 - 22
|
@@ -0,0 +1,23 @@
|
||||
-- Formations - Norne FFM ATW2013
|
||||
'Garn 3' 1 - 1 #000000
|
||||
'Garn 2' 2 - 2 #FF0000
|
||||
'Garn 1' 3 - 3 #00FF00
|
||||
'Not' 4 - 4 #0000FF
|
||||
'Ile 2.2' 5 - 5 #000000
|
||||
'Ile 2.1.3' 6 - 6 #FF0000
|
||||
'Ile 2.1.2' 7 - 7 #00FF00
|
||||
'Ile 2.1.1' 8 - 8 #0000FF
|
||||
'Ile 1.3' 9 - 9 #000000
|
||||
'Ile 1.2' 10 - 10 #FF0000
|
||||
'Ile 1.1' 11 - 11 #00FF00
|
||||
'Tofte 2.2' 12 - 12 #0000FF
|
||||
'Tofte 2.1.3' 13 - 13 #000000
|
||||
'Tofte 2.1.2' 14 - 14 #FF0000
|
||||
'Tofte 2.1.1' 15 - 15 #00FF00
|
||||
'Tofte 1.2.2' 16 - 16 #0000FF
|
||||
'Tofte 1.2.1' 17 - 17 #000000
|
||||
'Tofte 1.1' 18 - 18 #FF0000
|
||||
'Tilje 4' 19 - 19 #00FF00
|
||||
'Tilje 3' 20 - 20 #0000FF
|
||||
'Tilje 2' 21 - 21 #000000
|
||||
'Tilje 1' 22 - 22 #FF0000
|
@@ -0,0 +1,23 @@
|
||||
-- Formations - Norne FFM ATW2013
|
||||
'Garn 3' 1 - 1 black
|
||||
'Garn 2' 2 - 2 red
|
||||
'Garn 1' 3 - 3 green
|
||||
'Not' 4 - 4 black
|
||||
'Ile 2.2' 5 - 5 red
|
||||
'Ile 2.1.3' 6 - 6 green
|
||||
'Ile 2.1.2' 7 - 7 black
|
||||
'Ile 2.1.1' 8 - 8 red
|
||||
'Ile 1.3' 9 - 9 green
|
||||
'Ile 1.2' 10 - 10 black
|
||||
'Ile 1.1' 11 - 11 red
|
||||
'Tofte 2.2' 12 - 12 green
|
||||
'Tofte 2.1.3' 13 - 13 black
|
||||
'Tofte 2.1.2' 14 - 14 red
|
||||
'Tofte 2.1.1' 15 - 15 green
|
||||
'Tofte 1.2.2' 16 - 16 black
|
||||
'Tofte 1.2.1' 17 - 17 red
|
||||
'Tofte 1.1' 18 - 18 green
|
||||
'Tilje 4' 19 - 19 black
|
||||
'Tilje 3' 20 - 20 red
|
||||
'Tilje 2' 21 - 21 green
|
||||
'Tilje 1' 22 - 22 red
|
Reference in New Issue
Block a user