#1573 Created own unit system class

This commit is contained in:
Bjørnar Grip Fjær 2017-06-06 14:57:32 +02:00
parent 7628719620
commit f1b4b735ff
6 changed files with 79 additions and 29 deletions

View File

@ -14,6 +14,7 @@ ${CEE_CURRENT_LIST_DIR}RimEclipsePropertyFilterCollection.h
${CEE_CURRENT_LIST_DIR}RimCellRangeFilter.h
${CEE_CURRENT_LIST_DIR}RimCellRangeFilterCollection.h
${CEE_CURRENT_LIST_DIR}RimDefines.h
${CEE_CURRENT_LIST_DIR}RimUnitSystem.h
${CEE_CURRENT_LIST_DIR}RimLegendConfig.h
${CEE_CURRENT_LIST_DIR}RimOilField.h
${CEE_CURRENT_LIST_DIR}RimProject.h
@ -102,6 +103,7 @@ ${CEE_CURRENT_LIST_DIR}RimEclipsePropertyFilterCollection.cpp
${CEE_CURRENT_LIST_DIR}RimCellRangeFilter.cpp
${CEE_CURRENT_LIST_DIR}RimCellRangeFilterCollection.cpp
${CEE_CURRENT_LIST_DIR}RimDefines.cpp
${CEE_CURRENT_LIST_DIR}RimUnitSystem.cpp
${CEE_CURRENT_LIST_DIR}RimLegendConfig.cpp
${CEE_CURRENT_LIST_DIR}RimOilField.cpp
${CEE_CURRENT_LIST_DIR}RimProject.cpp

View File

@ -56,16 +56,6 @@ namespace caf
setDefault(RimDefines::UNIT_METER);
}
template<>
void caf::AppEnum< RimDefines::UnitSystem >::setUp()
{
addItem(RimDefines::UNITS_METRIC, "UNITS_METRIC", "Metric");
addItem(RimDefines::UNITS_FIELD, "UNITS_FIELD", "Field");
setDefault(RimDefines::UNITS_METRIC);
}
template<>
void caf::AppEnum< RimDefines::PlotAxis >::setUp()
{

View File

@ -92,23 +92,6 @@ public:
};
enum UnitSystem
{
UNITS_METRIC,
UNITS_FIELD
//UNITS_LAB
};
static double feetPerMeter() { return 3.2808399; }
static double meterPerFeet() { return 0.3048000; }
static double meterToFeet(double meter) { return meter*feetPerMeter(); }
static double feetToMeter(double feet) { return feet*meterPerFeet();}
static double meterToInch(double meter) { return meter*feetPerMeter()*12; }
static double inchToMeter(double inch) { return (inch / 12)*meterPerFeet(); }
// Defines relate to plotting
enum PlotAxis

View File

@ -0,0 +1,33 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- 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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimUnitSystem.h"
#include "cafAppEnum.h"
namespace caf
{
template<>
void caf::AppEnum< RimUnitSystem::UnitSystem >::setUp()
{
addItem(RimUnitSystem::UNITS_METRIC, "UNITS_METRIC", "Metric");
addItem(RimUnitSystem::UNITS_FIELD, "UNITS_FIELD", "Field");
setDefault(RimUnitSystem::UNITS_METRIC);
}
}

View File

@ -0,0 +1,40 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- 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
class RimUnitSystem
{
public:
enum UnitSystem
{
UNITS_METRIC,
UNITS_FIELD
//UNITS_LAB
};
static double feetPerMeter() { return 3.2808399; }
static double meterPerFeet() { return 0.3048000; }
static double meterToFeet(double meter) { return meter*feetPerMeter(); }
static double feetToMeter(double feet) { return feet*meterPerFeet();}
static double meterToInch(double meter) { return meter*feetPerMeter()*12; }
static double inchToMeter(double inch) { return (inch / 12)*meterPerFeet(); }
};

View File

@ -21,6 +21,8 @@
#include "RigCurveDataTools.h"
#include "RimUnitSystem.h"
#include "cvfMath.h"
#include "cvfAssert.h"
@ -366,7 +368,7 @@ std::vector<double> RigWellLogCurveData::convertFromMeterToFeet(const std::vecto
for (size_t i = 0; i < valuesInMeter.size(); i++)
{
valuesInFeet[i] = valuesInMeter[i] * RimDefines::feetPerMeter();
valuesInFeet[i] = valuesInMeter[i] * RimUnitSystem::feetPerMeter();
}
return valuesInFeet;
@ -381,7 +383,7 @@ std::vector<double> RigWellLogCurveData::convertFromFeetToMeter(const std::vecto
for (size_t i = 0; i < valuesInFeet.size(); i++)
{
valuesInMeter[i] = valuesInFeet[i] / RimDefines::feetPerMeter();
valuesInMeter[i] = valuesInFeet[i] / RimUnitSystem::feetPerMeter();
}
return valuesInMeter;