diff --git a/ApplicationCode/Application/RIApplication.cpp b/ApplicationCode/Application/RIApplication.cpp index 8f5795f521..bb4da7d3ea 100644 --- a/ApplicationCode/Application/RIApplication.cpp +++ b/ApplicationCode/Application/RIApplication.cpp @@ -111,6 +111,14 @@ RIApplication::RIApplication(int& argc, char** argv) m_socketServer = new RiaSocketServer( this); m_workerProcess = NULL; + + + m_startupDefaultDirectory = QDir::homePath(); + +#ifdef WIN32 + //m_startupDefaultDirectory += "/My Documents/"; +#endif + } @@ -119,6 +127,7 @@ RIApplication::RIApplication(int& argc, char** argv) //-------------------------------------------------------------------------------------------------- RIApplication::~RIApplication() { + delete m_preferences; } @@ -282,6 +291,8 @@ bool RIApplication::saveProjectPromptForFileName() { //if (m_project.isNull()) return true; + RIApplication* app = RIApplication::instance(); + QString startPath; if (!m_project->fileName().isEmpty()) { @@ -290,7 +301,7 @@ bool RIApplication::saveProjectPromptForFileName() } else { - startPath = QDir::currentPath(); + startPath = app->defaultFileDialogDirectory("BINARY_GRID"); } startPath += "/ResInsightProject.rip"; @@ -301,6 +312,9 @@ bool RIApplication::saveProjectPromptForFileName() return false; } + // Remember the directory to next time + app->setDefaultFileDialogDirectory("BINARY_GRID", QFileInfo(fileName).absolutePath()); + bool bSaveOk = saveProjectAs(fileName); setWindowCaptionFromAppState(); @@ -591,38 +605,52 @@ bool RIApplication::parseArguments() bool isParsingProjectFile = false; bool isParsingCaseNames = false; + bool isParsingStartDir = false; bool showHelp = false; int i; for (i = 1; i < arguments.size(); i++) { QString arg = arguments[i]; - bool argParsedAsFlag = false; + bool foundKnownOption = false; if (arg.toLower() == "-help" || arg.toLower() == "-?") { showHelp = true; + foundKnownOption = true; } if (arg.toLower() == "-last") { openLatestProject = true; - argParsedAsFlag = true; + foundKnownOption = true; } else if (arg.toLower() == "-project") { isParsingCaseNames = false; isParsingProjectFile = true; - argParsedAsFlag = true; + isParsingStartDir = false; + + foundKnownOption = true; } else if (arg.toLower() == "-case") { isParsingCaseNames = true; isParsingProjectFile = false; - argParsedAsFlag = true; + isParsingStartDir = false; + + foundKnownOption = true; + } + else if (arg.toLower() == "-startdir") + { + isParsingCaseNames = false; + isParsingProjectFile = false; + isParsingStartDir = true; + + foundKnownOption = true; } - if (!argParsedAsFlag) + if (!foundKnownOption) { if (isParsingProjectFile && QFile::exists(arg)) { @@ -633,6 +661,11 @@ bool RIApplication::parseArguments() { caseNames.append(arg); } + + if (isParsingStartDir) + { + m_startupDefaultDirectory = arg; + } } } @@ -648,6 +681,8 @@ bool RIApplication::parseArguments() "-project Open project file \n" "-case Open Eclipse case \n" " (do not include .GRID/.EGRID)\n" + "-startdir The default directory for open/save commands\n" + "-help \n" "-? Displays help text\n" "-----------------------------------------------------------------"; @@ -883,3 +918,28 @@ void RIApplication::terminateProcess() m_workerProcess = NULL; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RIApplication::defaultFileDialogDirectory(const QString& dialogName) +{ + QString defaultDirectory = m_startupDefaultDirectory; + std::map::iterator it; + it = m_fileDialogDefaultDirectories.find(dialogName); + + if ( it != m_fileDialogDefaultDirectories.end()) + { + defaultDirectory = it->second; + } + + return defaultDirectory; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RIApplication::setDefaultFileDialogDirectory(const QString& dialogName, const QString& defaultDirectory) +{ + m_fileDialogDefaultDirectories[dialogName] = defaultDirectory; +} diff --git a/ApplicationCode/Application/RIApplication.h b/ApplicationCode/Application/RIApplication.h index c0c9fe5b03..722d103f7d 100644 --- a/ApplicationCode/Application/RIApplication.h +++ b/ApplicationCode/Application/RIApplication.h @@ -75,6 +75,9 @@ public: void createLargeResultsMockModel(); void createInputMockModel(); + QString defaultFileDialogDirectory(const QString& dialogName); + void setDefaultFileDialogDirectory(const QString& dialogName, const QString& defaultDirectory); + bool openEclipseCaseFromFile(const QString& fileName); bool openEclipseCase(const QString& caseName, const QString& caseFileName); bool openInputEclipseCase(const QString& caseName, const QStringList& caseFileNames); @@ -129,4 +132,7 @@ private: caf::UiProcess* m_workerProcess; RIPreferences* m_preferences; + + std::map m_fileDialogDefaultDirectories; + QString m_startupDefaultDirectory; }; diff --git a/ApplicationCode/Application/RIPreferences.cpp b/ApplicationCode/Application/RIPreferences.cpp index f78417c979..57aeee9a06 100644 --- a/ApplicationCode/Application/RIPreferences.cpp +++ b/ApplicationCode/Application/RIPreferences.cpp @@ -37,13 +37,17 @@ RIPreferences::RIPreferences(void) CAF_PDM_InitField(&octaveExecutable, "octaveExecutable", QString("octave"), "Octave", "", "", ""); octaveExecutable.setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); + CAF_PDM_InitField(&defaultGridLines, "defaultGridLines", true, "Gridlines", "", "", ""); + CAF_PDM_InitField(&defaultScaleFactorZ, "defaultScaleFactorZ", 5, "Z scale factor", "", "", ""); + CAF_PDM_InitField(&useShaders, "useShaders", true, "Use Shaders", "", "", ""); - CAF_PDM_InitField(&showHud, "showHud", true, "Show 3D Information", "", "", ""); + CAF_PDM_InitField(&showHud, "showHud", false, "Show 3D Information", "", "", ""); CAF_PDM_InitFieldNoDefault(&lastUsedProjectFileName,"lastUsedProjectFileName", "Last Used Project File", "", "", ""); lastUsedProjectFileName.setUiHidden(true); - CAF_PDM_InitField(&autocomputeSOIL, "autocomputeSOIL", true, "Compute SOIL if not on disk", "", "", ""); + CAF_PDM_InitField(&autocomputeSOIL, "autocomputeSOIL", true, "SOIL", "", "SOIL = 1.0 - SGAS - SWAT", ""); + CAF_PDM_InitField(&autocomputeDepthRelatedProperties,"autocomputeDepth", true, "DEPTH related properties", "", "DEPTH, DX, DY, DZ, TOP, BOTTOM", ""); } //-------------------------------------------------------------------------------------------------- @@ -69,3 +73,24 @@ void RIPreferences::defineEditorAttribute(const caf::PdmFieldHandle* field, QStr } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RIPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const +{ + uiOrdering.add(&navigationPolicy); + + caf::PdmUiGroup* scriptGroup = uiOrdering.addNewGroup("Script configuration"); + scriptGroup->add(&scriptDirectory); + scriptGroup->add(&scriptEditorExecutable); + scriptGroup->add(&octaveExecutable); + + caf::PdmUiGroup* defaultSettingsGroup = uiOrdering.addNewGroup("Default settings"); + defaultSettingsGroup->add(&defaultScaleFactorZ); + defaultSettingsGroup->add(&defaultGridLines); + + caf::PdmUiGroup* autoComputeGroup = uiOrdering.addNewGroup("Compute when loading new case"); + autoComputeGroup->add(&autocomputeSOIL); + autoComputeGroup->add(&autocomputeDepthRelatedProperties); +} + diff --git a/ApplicationCode/Application/RIPreferences.h b/ApplicationCode/Application/RIPreferences.h index 16183a8e0d..a35ba41997 100644 --- a/ApplicationCode/Application/RIPreferences.h +++ b/ApplicationCode/Application/RIPreferences.h @@ -36,14 +36,20 @@ public: // Pdm Fields caf::PdmField scriptEditorExecutable; caf::PdmField octaveExecutable; + caf::PdmField defaultScaleFactorZ; + caf::PdmField defaultGridLines; + caf::PdmField useShaders; caf::PdmField showHud; caf::PdmField lastUsedProjectFileName; caf::PdmField autocomputeSOIL; + caf::PdmField autocomputeDepthRelatedProperties; protected: virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); + + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const; }; diff --git a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp index 599cdd3d4c..b58021cbf8 100644 --- a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp @@ -29,6 +29,7 @@ #include #include +#include #ifdef USE_ECL_LIB #include "ecl_grid.h" @@ -38,6 +39,8 @@ #include + + //-------------------------------------------------------------------------------------------------- /// Constructor //-------------------------------------------------------------------------------------------------- @@ -63,6 +66,20 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigReservoi { CVF_ASSERT(reservoir); + qint64 coordPos = -1; + qint64 zcornPos = -1; + qint64 specgridPos = -1; + qint64 actnumPos = -1; + qint64 mapaxesPos = -1; + + findGridKeywordPositions(fileName, &coordPos, &zcornPos, &specgridPos, &actnumPos, &mapaxesPos); + + if (coordPos < 0 || zcornPos < 0 || specgridPos < 0) + { + return false; + } + + FILE* gridFilePointer = util_fopen(fileName.toLatin1().data(), "r"); if (!gridFilePointer) return false; @@ -74,6 +91,8 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigReservoi //ecl_kw_type * ecl_kw_fscanf_alloc_grdecl_dynamic__( FILE * stream , const char * kw , bool strict , ecl_type_enum ecl_type); //ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz , const ecl_kw_type * zcorn_kw , const ecl_kw_type * coord_kw , const ecl_kw_type * actnum_kw , const ecl_kw_type * mapaxes_kw ); + + ecl_kw_type* specGridKw = NULL; ecl_kw_type* zCornKw = NULL; ecl_kw_type* coordKw = NULL; @@ -82,19 +101,38 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigReservoi // Try to read all the needed keywords. Early exit if some are not found caf::ProgressInfo progress(7, "Read Grid from Eclipse Input file"); - bool allKwReadOk = true; - allKwReadOk = allKwReadOk && NULL != (specGridKw = ecl_kw_fscanf_alloc_grdecl_dynamic__( gridFilePointer , "SPECGRID" , false , ECL_INT_TYPE)); + + + bool allKwReadOk = true; + bool continueReading = true; + + fseek(gridFilePointer, specgridPos, SEEK_SET); + allKwReadOk = allKwReadOk && NULL != (specGridKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ECL_INT_TYPE)); progress.setProgress(1); - allKwReadOk = allKwReadOk && NULL != (zCornKw = ecl_kw_fscanf_alloc_grdecl_dynamic__( gridFilePointer , "ZCORN" , false , ECL_FLOAT_TYPE)); + + fseek(gridFilePointer, zcornPos, SEEK_SET); + allKwReadOk = allKwReadOk && NULL != (zCornKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ECL_FLOAT_TYPE)); progress.setProgress(2); - allKwReadOk = allKwReadOk && NULL != (coordKw = ecl_kw_fscanf_alloc_grdecl_dynamic__( gridFilePointer , "COORD" , false , ECL_FLOAT_TYPE)); + + fseek(gridFilePointer, coordPos, SEEK_SET); + allKwReadOk = allKwReadOk && NULL != (coordKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ECL_FLOAT_TYPE)); progress.setProgress(3); - allKwReadOk = allKwReadOk && NULL != (actNumKw = ecl_kw_fscanf_alloc_grdecl_dynamic__( gridFilePointer , "ACTNUM" , false , ECL_INT_TYPE)); - progress.setProgress(4); + + // If ACTNUM is not defined, this pointer will be NULL, which is a valid condition + if (actnumPos >= 0) + { + fseek(gridFilePointer, actnumPos, SEEK_SET); + allKwReadOk = allKwReadOk && NULL != (actNumKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ECL_INT_TYPE)); + progress.setProgress(4); + } // If MAPAXES is not defined, this pointer will be NULL, which is a valid condition - mapAxesKw = ecl_kw_fscanf_alloc_grdecl_dynamic__( gridFilePointer , "MAPAXES" , false , ECL_FLOAT_TYPE); + if (mapaxesPos >= 0) + { + fseek(gridFilePointer, mapaxesPos, SEEK_SET); + mapAxesKw = ecl_kw_fscanf_alloc_current_grdecl__( gridFilePointer, false , ECL_FLOAT_TYPE); + } if (!allKwReadOk) { @@ -125,7 +163,7 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigReservoi ecl_kw_free(specGridKw); ecl_kw_free(zCornKw); ecl_kw_free(coordKw); - ecl_kw_free(actNumKw); + if (actNumKw) ecl_kw_free(actNumKw); if (mapAxesKw) ecl_kw_free(mapAxesKw); ecl_grid_free(inputGrid); @@ -152,7 +190,7 @@ std::map RifEclipseInputFileTools::readProperties(const QStri caf::ProgressInfo mainProgress(2, "Reading Eclipse Input properties"); caf::ProgressInfo startProgress(knownKeywordSet.size(), "Scanning for known properties"); - std::vector fileKeywords = RifEclipseInputFileTools::findKeywordsOnFile(fileName); + std::vector fileKeywords = RifEclipseInputFileTools::findKeywordsOnFile(fileName); mainProgress.setProgress(1); caf::ProgressInfo progress(fileKeywords.size(), "Reading properties"); @@ -168,13 +206,14 @@ std::map RifEclipseInputFileTools::readProperties(const QStri std::map newResults; for (size_t i = 0; i < fileKeywords.size(); ++i) { - std::cout << fileKeywords[i].toLatin1().data() << std::endl; - if (knownKeywordSet.count(fileKeywords[i])) + //std::cout << fileKeywords[i].keyword.toLatin1().data() << std::endl; + if (knownKeywordSet.count(fileKeywords[i].keyword)) { - ecl_kw_type* eclKeyWordData = ecl_kw_fscanf_alloc_grdecl_dynamic__( gridFilePointer , fileKeywords[i].toLatin1().data() , false , ECL_FLOAT_TYPE); + fseek(gridFilePointer, fileKeywords[i].filePos, SEEK_SET); + ecl_kw_type* eclKeyWordData = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ECL_FLOAT_TYPE); if (eclKeyWordData) { - QString newResultName = reservoir->mainGrid()->results()->makeResultNameUnique(fileKeywords[i]); + QString newResultName = reservoir->mainGrid()->results()->makeResultNameUnique(fileKeywords[i].keyword); size_t resultIndex = reservoir->mainGrid()->results()->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName); // Should really merge with inputProperty object information because we need to use PropertyName, and not keyword @@ -184,7 +223,7 @@ std::map RifEclipseInputFileTools::readProperties(const QStri ecl_kw_get_data_as_double(eclKeyWordData, newPropertyData[0].data()); ecl_kw_free(eclKeyWordData); - newResults[newResultName] = fileKeywords[i]; + newResults[newResultName] = fileKeywords[i].keyword; } } progress.setProgress(i); @@ -196,45 +235,47 @@ std::map RifEclipseInputFileTools::readProperties(const QStri //-------------------------------------------------------------------------------------------------- /// Read all the keywords from a file +// +// This code was originally written using QTextStream, but due to a bug in Qt version up to 4.8.0 +// we had to implement the reading using QFile and QFile::readLine +// +// See: +// https://bugreports.qt-project.org/browse/QTBUG-9814 +// //-------------------------------------------------------------------------------------------------- -std::vector RifEclipseInputFileTools::findKeywordsOnFile(const QString &fileName) +std::vector< RifKeywordAndFilePos > RifEclipseInputFileTools::findKeywordsOnFile(const QString &fileName) { - std::vector keywords; + std::vector< RifKeywordAndFilePos > keywords; - std::ifstream is(fileName.toLatin1().data()); + char buf[1024]; - while (is) + QFile data(fileName); + data.open(QFile::ReadOnly); + + QString line; + qint64 filepos = -1; + qint64 lineLength = -1; + + do { - std::string word; - is >> word; - if (word.size() && isalpha(word[0])) + lineLength = data.readLine(buf, sizeof(buf)); + if (lineLength > 0) { - keywords.push_back(word.c_str()); + line = QString::fromAscii(buf); + if (line.size() && line[0].isLetter()) + { + RifKeywordAndFilePos keyPos; + + filepos = data.pos() - lineLength; + keyPos.filePos = filepos; + keyPos.keyword = line.left(8).trimmed(); + keywords.push_back(keyPos); + //qDebug() << keyPos.keyword << " - " << keyPos.filePos; + } } - - is.ignore(20000, '\n'); } + while (lineLength != -1); - is.close(); - - /* - FILE* gridFilePointer = util_fopen(fileName.toLatin1().data(), "r"); - - if (!gridFilePointer) return keywords; - - char * keyWordString = NULL; - - keyWordString = ecl_kw_grdecl_alloc_next_header(gridFilePointer); - - while(keyWordString) - { - keywords.push_back(keyWordString); - util_realloc(keyWordString, 0, "RifEclipseInputFileTools::findKeywordsOnFile"); - keyWordString = ecl_kw_grdecl_alloc_next_header(gridFilePointer); - } - - util_fclose(gridFilePointer); - */ return keywords; } @@ -434,3 +475,73 @@ void RifEclipseInputFileTools::writeDataToTextFile(QFile* file, const QString& e out << "\n" << "/" << "\n"; } + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifEclipseInputFileTools::findGridKeywordPositions(const QString& filename, qint64* coordPos, qint64* zcornPos, qint64* specgridPos, qint64* actnumPos, qint64* mapaxesPos) +{ + CVF_ASSERT(coordPos && zcornPos && specgridPos && actnumPos && mapaxesPos); + + + std::vector< RifKeywordAndFilePos > keywordsAndFilePos = findKeywordsOnFile(filename); + size_t i; + for (i = 0; i < keywordsAndFilePos.size(); i++) + { + if (keywordsAndFilePos[i].keyword == "COORD") + { + *coordPos = keywordsAndFilePos[i].filePos; + } + else if (keywordsAndFilePos[i].keyword == "ZCORN") + { + *zcornPos = keywordsAndFilePos[i].filePos; + } + else if (keywordsAndFilePos[i].keyword == "SPECGRID") + { + *specgridPos = keywordsAndFilePos[i].filePos; + } + else if (keywordsAndFilePos[i].keyword == "ACTNUM") + { + *actnumPos = keywordsAndFilePos[i].filePos; + } + else if (keywordsAndFilePos[i].keyword == "MAPAXES") + { + *mapaxesPos = keywordsAndFilePos[i].filePos; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifEclipseInputFileTools::readPropertyAtFilePosition(const QString& fileName, RigReservoir* reservoir, const QString& eclipseKeyWord, qint64 filePos, const QString& resultName) +{ + CVF_ASSERT(reservoir); + + FILE* filePointer = util_fopen(fileName.toLatin1().data(), "r"); + if (!filePointer) return false; + + fseek(filePointer, filePos, SEEK_SET); + ecl_kw_type* eclKeyWordData = ecl_kw_fscanf_alloc_current_grdecl__(filePointer, false , ECL_FLOAT_TYPE); + bool isOk = false; + if (eclKeyWordData) + { + QString newResultName = resultName; + size_t resultIndex = reservoir->mainGrid()->results()->findScalarResultIndex(newResultName); + if (resultIndex == cvf::UNDEFINED_SIZE_T) + { + resultIndex = reservoir->mainGrid()->results()->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName); + } + + std::vector< std::vector >& newPropertyData = reservoir->mainGrid()->results()->cellScalarResults(resultIndex); + newPropertyData.resize(1); + newPropertyData[0].resize(ecl_kw_get_size(eclKeyWordData), HUGE_VAL); + ecl_kw_get_data_as_double(eclKeyWordData, newPropertyData[0].data()); + isOk = true; + ecl_kw_free(eclKeyWordData); + } + + util_fclose(filePointer); + return isOk; +} diff --git a/ApplicationCode/FileInterface/RifEclipseInputFileTools.h b/ApplicationCode/FileInterface/RifEclipseInputFileTools.h index 4767358f7c..d0c264b28c 100644 --- a/ApplicationCode/FileInterface/RifEclipseInputFileTools.h +++ b/ApplicationCode/FileInterface/RifEclipseInputFileTools.h @@ -23,10 +23,23 @@ #include "cvfLibCore.h" #include +#include + + class RigReservoir; -class QString; class QFile; + +//-------------------------------------------------------------------------------------------------- +/// Structure used to cache file position of keywords +//-------------------------------------------------------------------------------------------------- +struct RifKeywordAndFilePos +{ + QString keyword; + qint64 filePos; +}; + + //================================================================================================== // // Class for access to Eclipse "keyword" files using libecl @@ -43,7 +56,9 @@ public: // Returns map of assigned resultName and Eclipse Keyword. static std::map readProperties(const QString& fileName, RigReservoir* reservoir); static bool readProperty (const QString& fileName, RigReservoir* reservoir, const QString& eclipseKeyWord, const QString& resultName ); - static std::vector findKeywordsOnFile(const QString &fileName); + static bool readPropertyAtFilePosition (const QString& fileName, RigReservoir* reservoir, const QString& eclipseKeyWord, qint64 filePos, const QString& resultName ); + + static std::vector< RifKeywordAndFilePos > findKeywordsOnFile(const QString &fileName); static const std::vector& knownPropertyKeywords(); @@ -52,4 +67,5 @@ public: private: static void writeDataToTextFile(QFile* file, const QString& eclipseKeyWord, const std::vector& resultData); + static void findGridKeywordPositions(const QString& filename, qint64* coordPos, qint64* zcornPos, qint64* specgridPos, qint64* actnumPos, qint64* mapaxesPos); }; diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index cd99f7713b..51ed1398d3 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -99,7 +99,7 @@ void Rim3dOverlayInfoConfig::update3DInfo() QString infoText = QString( "

-- %1 --

" - "Cell count: Total: %2 Active: %3
" + "Cell count. Total: %2 Active: %3
" "Main Grid I,J,K: %4, %5, %6
").arg(caseName, totCellCount, activeCellCount, iSize, jSize, kSize); if (m_reservoirView->animationMode() && m_reservoirView->cellResult()->hasResult()) @@ -108,11 +108,16 @@ void Rim3dOverlayInfoConfig::update3DInfo() double min, max; double p10, p90; + double mean; size_t scalarIndex = m_reservoirView->cellResult()->gridScalarIndex(); m_reservoirView->gridCellResults()->minMaxCellScalarValues(scalarIndex, min, max); m_reservoirView->gridCellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); + m_reservoirView->gridCellResults()->meanCellScalarValues(scalarIndex, mean); - infoText += QString("

Min: %1 P10: %2 P90: %3 Max: %4
").arg(min).arg(p10).arg(p90).arg(max); + //infoText += QString("
Min: %1 P10: %2 Mean: %3 P90: %4 Max: %5
").arg(min).arg(p10).arg(mean).arg(p90).arg(max); + //infoText += QString("
Min: %1   P10: %2   Mean: %3 \n  P90: %4   Max: %5 
").arg(min).arg(p10).arg(mean).arg(p90).arg(max); + infoText += QString("" + "
MinP10 Mean P90 Max
%1 %2 %3 %4 %5
").arg(min).arg(p10).arg(mean).arg(p90).arg(max); } @@ -142,13 +147,16 @@ void Rim3dOverlayInfoConfig::update3DInfo() { double min, max; double p10, p90; + double mean; + size_t scalarIndex = m_reservoirView->cellResult()->gridScalarIndex(); m_reservoirView->gridCellResults()->minMaxCellScalarValues(scalarIndex, min, max); m_reservoirView->gridCellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); + m_reservoirView->gridCellResults()->meanCellScalarValues(scalarIndex, mean); m_reservoirView->viewer()->showHistogram(true); m_reservoirView->viewer()->setHistogram(min, max, m_reservoirView->gridCellResults()->cellScalarValuesHistogram(scalarIndex)); - m_reservoirView->viewer()->setHistogramPercentiles(p10, p90); + m_reservoirView->viewer()->setHistogramPercentiles(p10, p90, mean); } } } diff --git a/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp b/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp index 89297ae102..00c2b06d67 100644 --- a/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp @@ -299,8 +299,6 @@ void RimCellEdgeResultSlot::updateIgnoredScalarValue() //-------------------------------------------------------------------------------------------------- void RimCellEdgeResultSlot::minMaxCellEdgeValues(double& min, double& max) { - CVF_ASSERT(min && max); - double globalMin, globalMax; globalMin = HUGE_VAL; globalMax = -HUGE_VAL; diff --git a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp b/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp index 3cc8822740..d4c887a866 100644 --- a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp @@ -24,6 +24,7 @@ #include "RigGridBase.h" #include "RigReservoirCellResults.h" +#include "cafPdmUiDoubleSliderEditor.h" @@ -65,9 +66,15 @@ RimCellPropertyFilter::RimCellPropertyFilter() resultDefinition.setUiHidden(true); CAF_PDM_InitField(&lowerBound, "LowerBound", 0.0, "Min", "", "", ""); + lowerBound.setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); + CAF_PDM_InitField(&upperBound, "UpperBound", 0.0, "Max", "", "", ""); + upperBound.setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); updateIconState(); + + m_minimumResultValue = cvf::UNDEFINED_DOUBLE; + m_maximumResultValue = cvf::UNDEFINED_DOUBLE; } //-------------------------------------------------------------------------------------------------- @@ -148,6 +155,9 @@ void RimCellPropertyFilter::setDefaultValues() upperBound = max; upperBound.setUiName(QString("Max (%1)").arg(max)); + + m_maximumResultValue = max; + m_minimumResultValue = min; } //-------------------------------------------------------------------------------------------------- @@ -173,3 +183,26 @@ void RimCellPropertyFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrd uiOrdering.add(&filterMode); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCellPropertyFilter::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +{ + if (m_minimumResultValue == cvf::UNDEFINED_DOUBLE || m_maximumResultValue == cvf::UNDEFINED_DOUBLE) + { + return; + } + + if (field == &lowerBound || field == &upperBound) + { + caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast(attribute); + if (!myAttr) + { + return; + } + + myAttr->m_minimum = m_minimumResultValue; + myAttr->m_maximum = m_maximumResultValue; + } +} + diff --git a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.h b/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.h index b0de0712ff..228826cb6b 100644 --- a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.h +++ b/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.h @@ -72,10 +72,12 @@ public: virtual QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly ); protected: - virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const; + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const; + virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); private: RimCellPropertyFilterCollection* m_parentContainer; + double m_minimumResultValue, m_maximumResultValue; }; diff --git a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp index 9d3e3ee924..5c974cb175 100644 --- a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp @@ -34,6 +34,10 @@ #include "RifEclipseInputFileTools.h" #include "cafProgressInfo.h" +#include "RIApplication.h" +#include "RIPreferences.h" + + CAF_PDM_SOURCE_INIT(RimInputReservoir, "RimInputReservoir"); //-------------------------------------------------------------------------------------------------- /// @@ -150,34 +154,42 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames) bool RimInputReservoir::openEclipseGridFile() { // Early exit if reservoir data is created - if (m_rigReservoir.notNull()) return true; - - cvf::ref readerInterface; - - if (caseName().contains("Input Mock Debug Model")) + if (m_rigReservoir.isNull()) { - readerInterface = this->createMockModel(this->caseName()); - } - else - { - RigReservoir* reservoir = new RigReservoir; - readerInterface = new RifReaderEclipseInput; - if (!readerInterface->open(m_gridFileName, reservoir)) + cvf::ref readerInterface; + + if (caseName().contains("Input Mock Debug Model")) { - delete reservoir; - return false; + readerInterface = this->createMockModel(this->caseName()); + } + else + { + RigReservoir* reservoir = new RigReservoir; + readerInterface = new RifReaderEclipseInput; + if (!readerInterface->open(m_gridFileName, reservoir)) + { + delete reservoir; + return false; + } + + m_rigReservoir = reservoir; + loadAndSyncronizeInputProperties(); } - m_rigReservoir = reservoir; - loadAndSyncronizeInputProperties(); + CVF_ASSERT(m_rigReservoir.notNull()); + CVF_ASSERT(readerInterface.notNull()); + + m_rigReservoir->mainGrid()->results()->setReaderInterface(readerInterface.p()); + m_rigReservoir->computeFaults(); + m_rigReservoir->mainGrid()->computeCachedData(); } - CVF_ASSERT(m_rigReservoir.notNull()); - CVF_ASSERT(readerInterface.notNull()); - - m_rigReservoir->mainGrid()->results()->setReaderInterface(readerInterface.p()); - m_rigReservoir->computeFaults(); - m_rigReservoir->mainGrid()->computeCachedData(); + RigReservoirCellResults* results = m_rigReservoir->mainGrid()->results(); + RIApplication* app = RIApplication::instance(); + if (app->preferences()->autocomputeDepthRelatedProperties) + { + results->computeDepthRelatedResults(); + } return true; } @@ -220,8 +232,8 @@ void RimInputReservoir::loadAndSyncronizeInputProperties() if (isExistingFile) { - std::vector fileKeywords = RifEclipseInputFileTools::findKeywordsOnFile(filenames[i]); - for_all(fileKeywords, fkIt) fileKeywordSet.insert(fileKeywords[fkIt]); + std::vector< RifKeywordAndFilePos > fileKeywords = RifEclipseInputFileTools::findKeywordsOnFile(filenames[i]); + for_all(fileKeywords, fkIt) fileKeywordSet.insert(fileKeywords[fkIt].keyword); } // Find the input property objects referring to the file diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index f774bc0829..3f681fcd18 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -49,8 +49,9 @@ namespace caf { template<> void caf::AppEnum< RimReservoirView::MeshModeType >::setUp() { - addItem(RimReservoirView::FULL_MESH, "FULL_MESH", "All"); - addItem(RimReservoirView::NO_MESH, "NO_MESH", "None"); + addItem(RimReservoirView::FULL_MESH, "FULL_MESH", "All"); + addItem(RimReservoirView::FAULTS_MESH, "FAULTS_MESH", "Faults only"); + addItem(RimReservoirView::NO_MESH, "NO_MESH", "None"); setDefault(RimReservoirView::FULL_MESH); } @@ -58,7 +59,7 @@ template<> void caf::AppEnum< RimReservoirView::SurfaceModeType >::setUp() { addItem(RimReservoirView::SURFACE, "SURFACE", "All"); - addItem(RimReservoirView::FAULTS, "FAULTS", "Faults"); + addItem(RimReservoirView::FAULTS, "FAULTS", "Faults only"); addItem(RimReservoirView::NO_SURFACE, "NO_SURFACE", "None"); setDefault(RimReservoirView::SURFACE); } @@ -80,6 +81,10 @@ CAF_PDM_SOURCE_INIT(RimReservoirView, "ReservoirView"); //-------------------------------------------------------------------------------------------------- RimReservoirView::RimReservoirView() { + RIApplication* app = RIApplication::instance(); + RIPreferences* preferences = app->preferences(); + CVF_ASSERT(preferences); + CAF_PDM_InitObject("Reservoir View", ":/ReservoirView.png", "", ""); CAF_PDM_InitFieldNoDefault(&cellResult, "GridCellResult", "Cell Result", ":/CellResult.png", "", ""); @@ -93,7 +98,11 @@ RimReservoirView::RimReservoirView() overlayInfoConfig->setReservoirView(this); CAF_PDM_InitField(&name, "UserDescription", QString(""), "Name", "", "", ""); - CAF_PDM_InitField(&scaleZ, "GridZScale", 1.0, "Z Scale", "", "Scales the scene in the Z direction", ""); + + double defaultScaleFactor = 1.0; + if (preferences) defaultScaleFactor = preferences->defaultScaleFactorZ; + CAF_PDM_InitField(&scaleZ, "GridZScale", defaultScaleFactor, "Z Scale", "", "Scales the scene in the Z direction", ""); + CAF_PDM_InitField(&showWindow, "ShowWindow", true, "Show 3D viewer", "", "", ""); showWindow.setUiHidden(true); @@ -114,7 +123,9 @@ RimReservoirView::RimReservoirView() propertyFilterCollection = new RimCellPropertyFilterCollection(); propertyFilterCollection->setReservoirView(this); - CAF_PDM_InitFieldNoDefault(&meshMode, "MeshMode", "Grid lines", "", "", ""); + caf::AppEnum defaultMeshType = NO_MESH; + if (preferences->defaultGridLines) defaultMeshType = FULL_MESH; + CAF_PDM_InitField(&meshMode, "MeshMode", defaultMeshType, "Grid lines", "", "", ""); CAF_PDM_InitFieldNoDefault(&surfaceMode, "SurfaceMode", "Grid surface", "", "", ""); CAF_PDM_InitField(&maximumFrameRate, "MaximumFrameRate", 10, "Maximum frame rate","", "", ""); @@ -153,6 +164,7 @@ RimReservoirView::~RimReservoirView() delete rangeFilterCollection(); delete propertyFilterCollection(); + delete wellCollection(); if (m_viewer) { @@ -870,35 +882,30 @@ void RimReservoirView::appendCellResultInfo(size_t gridIndex, size_t cellIndex, void RimReservoirView::updateDisplayModelVisibility() { if (m_viewer.isNull()) return; + + // Initialize the mask to show everything except the the bits controlled here + unsigned int mask = 0xffffffff & ~surfaceBit & ~faultBit & ~meshSurfaceBit & ~meshFaultBit ; - bool surfaceVisible = false; - bool faultVisible = false; + // Then turn the appropriate bits on according to the user settings if (surfaceMode == SURFACE) { - surfaceVisible = true; - faultVisible = true; + mask |= surfaceBit; + mask |= faultBit; } else if (surfaceMode == FAULTS) { - faultVisible = true; + mask |= faultBit; } - unsigned int mask = 0; if (meshMode == FULL_MESH) { - if (surfaceVisible) mask |= meshSurfaceBit; - if (faultVisible) mask |= meshFaultBit; + mask |= meshSurfaceBit; + mask |= meshFaultBit; } - - if (surfaceVisible) + else if (meshMode == FAULTS_MESH) { - mask |= surfaceBit; - } - - if (faultVisible) - { - mask |= faultBit; + mask |= meshFaultBit; } m_viewer->setEnableMask(mask); diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.h b/ApplicationCode/ProjectDataModel/RimReservoirView.h index 918536910b..5446d15d30 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.h @@ -73,6 +73,7 @@ public: enum MeshModeType { FULL_MESH, + FAULTS_MESH, NO_MESH }; diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 8352be54b4..bb2c9d5611 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -201,6 +201,28 @@ bool RimUiTreeModelPdm::deleteReservoirView(const QModelIndex& itemIndex) return true; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUiTreeModelPdm::deleteReservoir(const QModelIndex& itemIndex) +{ + CVF_ASSERT(itemIndex.isValid()); + + caf::PdmUiTreeItem* uiItem = getTreeItemFromIndex(itemIndex); + CVF_ASSERT(uiItem); + + RimReservoir* reservoir = dynamic_cast(uiItem->dataObject().p()); + CVF_ASSERT(reservoir); + + // Remove Ui items pointing at the pdm object to delete + removeRow(itemIndex.row(), itemIndex.parent()); + + RimProject* proj = RIApplication::instance()->project(); + proj->reservoirs().removeChildObject(reservoir); + + delete reservoir; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -419,3 +441,4 @@ void RimUiTreeModelPdm::deleteInputProperty(const QModelIndex& itemIndex) delete inputProperty; } + diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h index b49a915631..1e41d090a3 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h @@ -48,6 +48,7 @@ public: bool deletePropertyFilter(const QModelIndex& itemIndex); bool deleteReservoirView(const QModelIndex& itemIndex); void deleteInputProperty(const QModelIndex& itemIndex); + void deleteReservoir(const QModelIndex& itemIndex); RimCellPropertyFilter* addPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); RimCellRangeFilter* addRangeFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 0bc659a768..a309bb7522 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -133,13 +133,19 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) { QMenu menu; menu.addAction(QString("Delete"), this, SLOT(slotDeleteObjectFromContainer())); - menu.addAction(QString("Write"), this, SLOT(slotWriteInputProperty())); + menu.addAction(QString("Save Property To File"), this, SLOT(slotWriteInputProperty())); menu.exec(event->globalPos()); } else if (dynamic_cast(uiItem->dataObject().p())) { QMenu menu; - menu.addAction(QString("Write"), this, SLOT(slotWriteBinaryResultAsInputProperty())); + menu.addAction(QString("Save Property To File"), this, SLOT(slotWriteBinaryResultAsInputProperty())); + menu.exec(event->globalPos()); + } + else if (dynamic_cast(uiItem->dataObject().p())) + { + QMenu menu; + menu.addAction(QString("Close"), this, SLOT(slotCloseCase())); menu.exec(event->globalPos()); } } @@ -452,7 +458,26 @@ void RimUiTreeView::slotExecuteScript() QString octavePath = app->octavePath(); if (!octavePath.isEmpty()) { + // http://www.gnu.org/software/octave/doc/interpreter/Command-Line-Options.html#Command-Line-Options + + // -p path + // Add path to the head of the search path for function files. The value of path specified on the command line + // will override any value of OCTAVE_PATH found in the environment, but not any commands in the system or + // user startup files that set the internal load path through one of the path functions. + + // -q + // Don't print the usual greeting and version message at startup. + + + // TODO: Must rename RimCalcScript::absolutePath to absoluteFileName, as the code below is confusing + // absolutePath() is a function in QFileInfo + QFileInfo fi(calcScript->absolutePath()); + QString octaveFunctionSearchPath = fi.absolutePath(); + QStringList arguments; + arguments.append("--path"); + arguments << octaveFunctionSearchPath; + arguments.append("-q"); arguments << calcScript->absolutePath(); @@ -539,9 +564,17 @@ void RimUiTreeView::setModel(QAbstractItemModel* model) //-------------------------------------------------------------------------------------------------- void RimUiTreeView::slotAddInputProperty() { - QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Eclipse Input Property Files", NULL, "All Files (*.* *)"); + RIApplication* app = RIApplication::instance(); + QString defaultDir = app->defaultFileDialogDirectory("INPUT_FILES"); + QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Eclipse Input Property Files", defaultDir, "All Files (*.* *)"); + if (fileNames.isEmpty()) return; + // Remember the directory to next time + defaultDir = QFileInfo(fileNames.last()).absolutePath(); + app->setDefaultFileDialogDirectory("INPUT_FILES", defaultDir); + + QModelIndex index = currentIndex(); RimUiTreeModelPdm* myModel = dynamic_cast(model()); caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex()); @@ -702,3 +735,15 @@ void RimUiTreeView::slotWriteBinaryResultAsInputProperty() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUiTreeView::slotCloseCase() +{ + RimUiTreeModelPdm* myModel = dynamic_cast(model()); + if (myModel) + { + myModel->deleteReservoir(currentIndex()); + } +} + diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.h b/ApplicationCode/ProjectDataModel/RimUiTreeView.h index b694faaf7f..30c4723e76 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.h @@ -67,6 +67,8 @@ private slots: void slotWriteInputProperty(); void slotWriteBinaryResultAsInputProperty(); + void slotCloseCase(); + void slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected); signals: diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp index 6aa4f5c3d5..f8104b2f95 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp @@ -106,6 +106,11 @@ void RigReservoirCellResults::minMaxCellScalarValues(size_t scalarResultIndex, s size_t i; for (i = 0; i < values.size(); i++) { + if (values[i] == HUGE_VAL) + { + continue; + } + if (values[i] < min) { min = values[i]; @@ -172,6 +177,42 @@ void RigReservoirCellResults::p10p90CellScalarValues(size_t scalarResultIndex, d p90 = m_p10p90[scalarResultIndex].second; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigReservoirCellResults::meanCellScalarValues(size_t scalarResultIndex, double& meanValue) +{ + CVF_ASSERT(scalarResultIndex < resultCount()); + + // Extend array and cache vars + + if (scalarResultIndex >= m_meanValues.size() ) + { + m_meanValues.resize(scalarResultIndex+1, HUGE_VAL); + } + + if (m_meanValues[scalarResultIndex] != HUGE_VAL) + { + meanValue = m_meanValues[scalarResultIndex]; + return; + } + + double valueSum = 0.0; + size_t count = 0; + for (size_t tIdx = 0; tIdx < timeStepCount(scalarResultIndex); tIdx++) + { + std::vector& values = m_cellScalarResults[scalarResultIndex][tIdx]; + for (size_t cIdx = 0; cIdx < values.size(); ++cIdx) + { + valueSum += values[cIdx]; + } + count += values.size(); + } + + m_meanValues[scalarResultIndex] = valueSum/count; + meanValue = m_meanValues[scalarResultIndex]; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -335,40 +376,190 @@ size_t RigReservoirCellResults::findScalarResultIndex(const QString& resultName) //-------------------------------------------------------------------------------------------------- void RigReservoirCellResults::loadOrComputeSOIL() { - size_t resultGridIndex = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL"); + size_t soilResultGridIndex = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL"); - if (resultGridIndex == cvf::UNDEFINED_SIZE_T) + if (soilResultGridIndex == cvf::UNDEFINED_SIZE_T) { + const std::vector< std::vector >* swat = NULL; + const std::vector< std::vector >* sgas = NULL; + size_t scalarIndexSWAT = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SWAT"); - size_t scalarIndexSGAS = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SGAS"); - - if (scalarIndexSGAS != cvf::UNDEFINED_SIZE_T && scalarIndexSWAT != cvf::UNDEFINED_SIZE_T) + if (scalarIndexSWAT != cvf::UNDEFINED_SIZE_T) { - size_t timeStepCount = m_resultInfos[scalarIndexSWAT].m_timeStepDates.size(); - resultGridIndex = addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL"); - m_cellScalarResults[resultGridIndex].resize(timeStepCount); + swat = &(cellScalarResults(scalarIndexSWAT)); + } - const std::vector< std::vector >& sgas = cellScalarResults(scalarIndexSGAS); - const std::vector< std::vector >& swat = cellScalarResults(scalarIndexSWAT); - std::vector< std::vector >& soil = cellScalarResults(resultGridIndex); + size_t scalarIndexSGAS = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SGAS"); + if (scalarIndexSGAS != cvf::UNDEFINED_SIZE_T) + { + sgas = &(cellScalarResults(scalarIndexSGAS)); + } - size_t resultValueCount = sgas[0].size(); + // Early exit if none of SWAT or SGAS is present + if (scalarIndexSWAT == cvf::UNDEFINED_SIZE_T && scalarIndexSGAS == cvf::UNDEFINED_SIZE_T) + { + return; + } - int timeStepIdx = 0; - for (timeStepIdx = 0; timeStepIdx < static_cast(timeStepCount); timeStepIdx++) - { - soil[timeStepIdx].resize(resultValueCount); - int idx = 0; + size_t soilResultValueCount = 0; + size_t soilTimeStepCount = 0; + if (swat) + { + soilResultValueCount = swat->at(0).size(); + soilTimeStepCount = m_resultInfos[scalarIndexSWAT].m_timeStepDates.size(); + } + + if (sgas) + { + soilResultValueCount = qMax(soilResultValueCount, sgas->at(0).size()); + + size_t sgasTimeStepCount = m_resultInfos[scalarIndexSGAS].m_timeStepDates.size(); + soilTimeStepCount = qMax(soilTimeStepCount, sgasTimeStepCount); + } + + soilResultGridIndex = addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL"); + m_cellScalarResults[soilResultGridIndex].resize(soilTimeStepCount); + + std::vector< std::vector >& soil = cellScalarResults(soilResultGridIndex); + + int timeStepIdx = 0; + for (timeStepIdx = 0; timeStepIdx < static_cast(soilTimeStepCount); timeStepIdx++) + { + soil[timeStepIdx].resize(soilResultValueCount); + + int idx = 0; #pragma omp parallel for - for (idx = 0; idx < static_cast(resultValueCount); idx++) + for (idx = 0; idx < static_cast(soilResultValueCount); idx++) + { + double soilValue = 1.0; + if (sgas) { - soil[timeStepIdx][idx] = 1.0 - sgas[timeStepIdx][idx] - swat[timeStepIdx][idx]; + soilValue -= sgas->at(timeStepIdx)[idx]; } + + if (swat) + { + soilValue -= swat->at(timeStepIdx)[idx]; + } + + soil[timeStepIdx][idx] = soilValue; } } } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigReservoirCellResults::computeDepthRelatedResults() +{ + size_t depthResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DEPTH"); + size_t dxResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DX"); + size_t dyResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DY"); + size_t dzResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DZ"); + size_t topsResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "TOPS"); + size_t bottomResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "BOTTOM"); + + bool computeDepth = false; + bool computeDx = false; + bool computeDy = false; + bool computeDz = false; + bool computeTops = false; + bool computeBottom = false; + + size_t resultValueCount = m_ownerMainGrid->cells().size(); + + if (depthResultGridIndex == cvf::UNDEFINED_SIZE_T) + { + depthResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "DEPTH", resultValueCount); + computeDepth = true; + } + + if (dxResultGridIndex == cvf::UNDEFINED_SIZE_T) + { + dxResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "DX", resultValueCount); + computeDx = true; + } + + if (dyResultGridIndex == cvf::UNDEFINED_SIZE_T) + { + dyResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "DY", resultValueCount); + computeDy = true; + } + + if (dzResultGridIndex == cvf::UNDEFINED_SIZE_T) + { + dzResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "DZ", resultValueCount); + computeDz = true; + } + + if (topsResultGridIndex == cvf::UNDEFINED_SIZE_T) + { + topsResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "TOPS", resultValueCount); + computeTops = true; + } + + if (bottomResultGridIndex == cvf::UNDEFINED_SIZE_T) + { + bottomResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "BOTTOM", resultValueCount); + computeBottom = true; + } + + std::vector< std::vector >& depth = cellScalarResults(depthResultGridIndex); + std::vector< std::vector >& dx = cellScalarResults(dxResultGridIndex); + std::vector< std::vector >& dy = cellScalarResults(dyResultGridIndex); + std::vector< std::vector >& dz = cellScalarResults(dzResultGridIndex); + std::vector< std::vector >& tops = cellScalarResults(topsResultGridIndex); + std::vector< std::vector >& bottom = cellScalarResults(bottomResultGridIndex); + + bool computeValuesForActiveCellsOnly = m_ownerMainGrid->numActiveCells() > 0; + + size_t cellIdx = 0; + for (cellIdx = 0; cellIdx < m_ownerMainGrid->cells().size(); cellIdx++) + { + const RigCell& cell = m_ownerMainGrid->cells()[cellIdx]; + + if (computeValuesForActiveCellsOnly && !cell.active()) + { + continue; + } + + if (computeDepth) + { + depth[0][cellIdx] = cvf::Math::abs(cell.center().z()); + } + + if (computeDx) + { + cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_I) - cell.faceCenter(cvf::StructGridInterface::POS_I); + dx[0][cellIdx] = cellWidth.length(); + } + + if (computeDy) + { + cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_J) - cell.faceCenter(cvf::StructGridInterface::POS_J); + dy[0][cellIdx] = cellWidth.length(); + } + + if (computeDz) + { + cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_K) - cell.faceCenter(cvf::StructGridInterface::POS_K); + dz[0][cellIdx] = cellWidth.length(); + } + + if (computeTops) + { + tops[0][cellIdx] = cvf::Math::abs(cell.faceCenter(cvf::StructGridInterface::NEG_K).z()); + } + + if (computeBottom) + { + bottom[0][cellIdx] = cvf::Math::abs(cell.faceCenter(cvf::StructGridInterface::POS_K).z()); + } + } +} + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -558,3 +749,17 @@ void RigReservoirCellResults::clearAllResults() m_cellScalarResults[i].clear(); } } + +//-------------------------------------------------------------------------------------------------- +/// Add a result with given type and name, and allocate one result vector for the static result values +//-------------------------------------------------------------------------------------------------- +size_t RigReservoirCellResults::addStaticScalarResult(RimDefines::ResultCatType type, const QString& resultName, size_t resultValueCount) +{ + size_t resultIdx = addEmptyScalarResult(type, resultName); + + m_cellScalarResults[resultIdx].push_back(std::vector()); + m_cellScalarResults[resultIdx][0].resize(resultValueCount, HUGE_VAL); + + return resultIdx; +} + diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h index 5101f4f417..251a9e7da2 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h @@ -42,6 +42,7 @@ public: void minMaxCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& min, double& max); const std::vector& cellScalarValuesHistogram(size_t scalarResultIndex); void p10p90CellScalarValues(size_t scalarResultIndex, double& p10, double& p90); + void meanCellScalarValues(size_t scalarResultIndex, double& meanValue); // Access meta-information about the results size_t resultCount() const; @@ -66,16 +67,21 @@ public: void clearAllResults(); void loadOrComputeSOIL(); + void computeDepthRelatedResults(); // Access the results data std::vector< std::vector > & cellScalarResults(size_t scalarResultIndex); double cellScalarResult(size_t timeStepIndex, size_t scalarResultIndex, size_t resultValueIndex); +private: + size_t addStaticScalarResult(RimDefines::ResultCatType type, const QString& resultName, size_t resultValueCount); + private: std::vector< std::vector< std::vector > > m_cellScalarResults; ///< Scalar results for each timestep for each Result index (ResultVariable) std::vector< std::pair > m_maxMinValues; ///< Max min values for each Result index std::vector< std::vector > m_histograms; ///< Histogram for each Result Index std::vector< std::pair > m_p10p90; ///< P10 and p90 values for each Result Index + std::vector< double > m_meanValues; ///< Mean value for each Result Index std::vector< std::vector< std::pair > > m_maxMinValuesPrTs; ///< Max min values for each timestep and Result index @@ -125,6 +131,11 @@ public: CVF_ASSERT(m_histogram); for (size_t i = 0; i < data.size(); ++i) { + if (data[i] == HUGE_VAL) + { + continue; + } + size_t index = 0; if (maxIndex > 0) index = (size_t)(maxIndex*(data[i] - m_min)/m_range); diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index 6c95df0b28..b411db795b 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -29,7 +29,6 @@ #include "RimReservoir.h" #include "RigReservoir.h" #include "RigReservoirCellResults.h" -#include #include "RimInputProperty.h" #include "RimInputReservoir.h" #include "RimUiTreeModelPdm.h" @@ -46,7 +45,8 @@ RiaSocketServer::RiaSocketServer(QObject* parent) m_currentTimeStepToRead(0), m_currentReservoir(NULL), m_currentScalarIndex(cvf::UNDEFINED_SIZE_T), - m_invalidActiveCellCountDetected(false) + m_invalidActiveCellCountDetected(false), + m_readState(ReadingCommand) { m_errorMessageDialog = new QErrorMessage(RIMainWindow::instance()); @@ -67,7 +67,7 @@ RiaSocketServer::RiaSocketServer(QObject* parent) return; } - connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(onNewClientConnection())); + connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(slotNewClientConnection())); } //-------------------------------------------------------------------------------------------------- @@ -90,16 +90,31 @@ unsigned short RiaSocketServer::serverPort() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaSocketServer::onNewClientConnection() +void RiaSocketServer::slotNewClientConnection() { // If we are currently handling a connection, just ignore the new one until the queue is empty. - if (m_currentClient != NULL) return; + if (m_currentClient != NULL) + { + if (m_currentClient->state() == QAbstractSocket::ConnectedState) + { + return; + } + else + { + if (m_readState == ReadingPropertyData) + { + readPropertyDataFromOctave(); + } + + terminateCurrentConnection(); + } + } + // Get the first pending connection, and set it as the current Client to handle QTcpSocket *newClient = m_tcpServer->nextPendingConnection(); - this->handleClientConnection(newClient); } @@ -124,13 +139,14 @@ void RiaSocketServer::handleClientConnection(QTcpSocket* clientToHandle) m_currentPropertyName = ""; connect(m_currentClient, SIGNAL(disconnected()), this, SLOT(slotCurrentClientDisconnected())); + m_readState = ReadingCommand; if (m_currentClient->bytesAvailable()) { - this->slotReadCommand(); + this->readCommandFromOctave(); } - connect(m_currentClient, SIGNAL(readyRead()), this, SLOT(slotReadCommand())); + connect(m_currentClient, SIGNAL(readyRead()), this, SLOT(slotReadyRead())); } //-------------------------------------------------------------------------------------------------- @@ -178,7 +194,7 @@ RimReservoir* RiaSocketServer::findReservoir(const QString& caseName) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaSocketServer::slotReadCommand() +void RiaSocketServer::readCommandFromOctave() { QDataStream socketStream(m_currentClient); socketStream.setVersion(QDataStream::Qt_4_0); @@ -210,16 +226,17 @@ void RiaSocketServer::slotReadCommand() CVF_ASSERT(args.size() > 0); - // qDebug() << args; bool isGetProperty = args[0] == "GetProperty"; // GetProperty [casename/index] PropertyName bool isSetProperty = args[0] == "SetProperty"; // SetProperty [casename/index] PropertyName bool isGetCellInfo = args[0] == "GetActiveCellInfo"; // GetActiveCellInfo [casename/index] bool isGetGridDim = args[0] == "GetMainGridDimensions"; // GetMainGridDimensions [casename/index] + if (!(isGetProperty || isSetProperty || isGetCellInfo || isGetGridDim)) { m_errorMessageDialog->showMessage(tr("ResInsight SocketServer: \n") + tr("Unknown command: %1").arg(args[0].data())); + terminateCurrentConnection(); return; } @@ -307,8 +324,6 @@ void RiaSocketServer::slotReadCommand() quint64 timestepByteCount = (quint64)(timestepResultCount*sizeof(double)); socketStream << timestepByteCount ; - // qDebug() << "Trying to read " << (quint64)(scalarResultFrames->front().size()*sizeof(double)) << "bytes of data"; - // Then write the data. for (size_t tIdx = 0; tIdx < scalarResultFrames->size(); ++tIdx) @@ -326,8 +341,9 @@ void RiaSocketServer::slotReadCommand() } else // Set property { + m_readState = ReadingPropertyData; + // Disconnect the socket from calling this slot again. - m_currentClient->disconnect(SIGNAL(readyRead())); m_currentReservoir = reservoir; if ( scalarResultFrames != NULL) @@ -335,10 +351,8 @@ void RiaSocketServer::slotReadCommand() m_scalarResultsToAdd = scalarResultFrames; if (m_currentClient->bytesAvailable()) { - this->slotReadPropertyData(); + this->readPropertyDataFromOctave(); } - - connect(m_currentClient, SIGNAL(readyRead()), this, SLOT(slotReadPropertyData())); } } } @@ -402,7 +416,7 @@ void RiaSocketServer::slotReadCommand() //-------------------------------------------------------------------------------------------------- /// This method reads data from octave and puts it into the resInsight Structures //-------------------------------------------------------------------------------------------------- -void RiaSocketServer::slotReadPropertyData() +void RiaSocketServer::readPropertyDataFromOctave() { QDataStream socketStream(m_currentClient); socketStream.setVersion(QDataStream::Qt_4_0); @@ -530,24 +544,10 @@ void RiaSocketServer::slotCurrentClientDisconnected() && m_currentClient->bytesAvailable() && !m_invalidActiveCellCountDetected) { - this->slotReadPropertyData(); + this->readPropertyDataFromOctave(); } - m_currentClient->deleteLater(); - m_currentClient = NULL; - - // Clean up more state: - - m_currentCommandSize = 0; - m_scalarResultsToAdd = NULL; - - m_timeStepCountToRead = 0; - m_bytesPerTimeStepToRead = 0; - m_currentTimeStepToRead = 0; - m_currentReservoir = NULL; - m_currentScalarIndex = cvf::UNDEFINED_SIZE_T; - m_currentPropertyName = ""; - m_invalidActiveCellCountDetected = false; + terminateCurrentConnection(); QTcpSocket *newClient = m_tcpServer->nextPendingConnection(); @@ -556,3 +556,58 @@ void RiaSocketServer::slotCurrentClientDisconnected() this->handleClientConnection(newClient); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSocketServer::terminateCurrentConnection() +{ + if (m_currentClient) + { + m_currentClient->disconnect(SIGNAL(disconnected())); + m_currentClient->disconnect(SIGNAL(readyRead())); + m_currentClient->deleteLater(); + m_currentClient = NULL; + } + + // Clean up more state: + + m_currentCommandSize = 0; + m_timeStepCountToRead = 0; + m_bytesPerTimeStepToRead = 0; + m_currentTimeStepToRead = 0; + m_scalarResultsToAdd = NULL; + m_currentReservoir = NULL; + m_currentScalarIndex = cvf::UNDEFINED_SIZE_T; + m_currentPropertyName = ""; + m_invalidActiveCellCountDetected = false; + + m_readState = ReadingCommand; + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSocketServer::slotReadyRead() +{ + switch (m_readState) + { + case ReadingCommand : + { + readCommandFromOctave(); + break; + } + + case ReadingPropertyData : + { + readPropertyDataFromOctave(); + break; + } + + default: + CVF_ASSERT(false); + break; + } +} + diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.h b/ApplicationCode/SocketInterface/RiaSocketServer.h index 86519b94c9..e6e0d54553 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.h +++ b/ApplicationCode/SocketInterface/RiaSocketServer.h @@ -19,6 +19,7 @@ #pragma once #include +#include class QLabel; class QPushButton; @@ -28,24 +29,32 @@ class QNetworkSession; class QErrorMessage; class RimReservoir; + class RiaSocketServer : public QObject { Q_OBJECT +public: + enum ReadState {ReadingCommand, ReadingPropertyData}; + public: RiaSocketServer(QObject *parent = 0); ~RiaSocketServer(); unsigned short serverPort(); private slots: - void onNewClientConnection(); - void slotReadCommand(); - void slotReadPropertyData(); + void slotNewClientConnection(); void slotCurrentClientDisconnected(); + void slotReadyRead(); private: + void readCommandFromOctave(); + void readPropertyDataFromOctave(); + + void handleClientConnection( QTcpSocket* clientToHandle); RimReservoir* findReservoir(const QString &casename); + void terminateCurrentConnection(); private: QTcpServer* m_tcpServer; @@ -56,6 +65,7 @@ private: // Vars used for reading data from octave and adding them to the available results + ReadState m_readState; quint64 m_timeStepCountToRead; quint64 m_bytesPerTimeStepToRead; size_t m_currentTimeStepToRead; diff --git a/ApplicationCode/UserInterface/RIMainWindow.cpp b/ApplicationCode/UserInterface/RIMainWindow.cpp index 475aa50fbf..0934800e08 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.cpp +++ b/ApplicationCode/UserInterface/RIMainWindow.cpp @@ -291,6 +291,8 @@ void RIMainWindow::createMenus() viewMenu->addAction(m_viewFromEast); viewMenu->addAction(m_viewFromBelow); viewMenu->addAction(m_viewFromAbove); + viewMenu->addSeparator(); + viewMenu->addAction(m_newPropertyView); connect(viewMenu, SIGNAL(aboutToShow()), SLOT(slotRefreshViewActions())); @@ -300,8 +302,6 @@ void RIMainWindow::createMenus() debugMenu->addAction(m_mockResultsModelAction); debugMenu->addAction(m_mockLargeResultsModelAction); debugMenu->addAction(m_mockInputModelAction); - debugMenu->addSeparator(); - debugMenu->addAction(m_newPropertyView); connect(debugMenu, SIGNAL(aboutToShow()), SLOT(slotRefreshDebugActions())); @@ -595,13 +595,19 @@ void RIMainWindow::slotOpenBinaryGridFiles() { if (checkForDocumentModifications()) { + RIApplication* app = RIApplication::instance(); + #ifdef USE_ECL_LIB - QStringList fileNames = QFileDialog::getOpenFileNames(this, "Open Eclipse File", NULL, "Eclipse Grid Files (*.GRID *.EGRID)"); + + QString defaultDir = app->defaultFileDialogDirectory("BINARY_GRID"); + QStringList fileNames = QFileDialog::getOpenFileNames(this, "Open Eclipse File", defaultDir, "Eclipse Grid Files (*.GRID *.EGRID)"); + if (fileNames.size()) defaultDir = QFileInfo(fileNames.last()).absolutePath(); + app->setDefaultFileDialogDirectory("BINARY_GRID", defaultDir); + #else QStringList fileNames; fileNames << "dummy"; #endif - RIApplication* app = RIApplication::instance(); int i; for (i = 0; i < fileNames.size(); i++) @@ -624,11 +630,15 @@ void RIMainWindow::slotOpenInputFiles() { if (checkForDocumentModifications()) { - QStringList fileNames = QFileDialog::getOpenFileNames(this, "Open Eclipse Input Files", NULL, "Eclipse Input Files and Input Properties (*.GRDECL *)"); + RIApplication* app = RIApplication::instance(); + QString defaultDir = app->defaultFileDialogDirectory("INPUT_FILES"); + QStringList fileNames = QFileDialog::getOpenFileNames(this, "Open Eclipse Input Files", defaultDir, "Eclipse Input Files and Input Properties (*.GRDECL *)"); if (fileNames.isEmpty()) return; - RIApplication* app = RIApplication::instance(); + // Remember the path to next time + app->setDefaultFileDialogDirectory("INPUT_FILES", QFileInfo(fileNames.last()).absolutePath()); + app->openInputEclipseCase("Eclipse Input Files", fileNames); } } @@ -641,10 +651,15 @@ void RIMainWindow::slotOpenProject() { if (checkForDocumentModifications()) { - QString fileName = QFileDialog::getOpenFileName(this, "Open ResInsight Project", NULL, "ResInsight project (*.rip)"); + RIApplication* app = RIApplication::instance(); + QString defaultDir = app->defaultFileDialogDirectory("BINARY_GRID"); + QString fileName = QFileDialog::getOpenFileName(this, "Open ResInsight Project", defaultDir, "ResInsight project (*.rip)"); + if (fileName.isEmpty()) return; - RIApplication* app = RIApplication::instance(); + // Remember the path to next time + app->setDefaultFileDialogDirectory("BINARY_GRID", QFileInfo(fileName).absolutePath()); + app->loadProject(fileName); } diff --git a/ApplicationCode/UserInterface/RIViewer.cpp b/ApplicationCode/UserInterface/RIViewer.cpp index 8fe91e5a3f..d82c33b554 100644 --- a/ApplicationCode/UserInterface/RIViewer.cpp +++ b/ApplicationCode/UserInterface/RIViewer.cpp @@ -96,7 +96,9 @@ RIViewer::RIViewer(const QGLFormat& format, QWidget* parent) m_animationProgress->setPalette(p); m_animationProgress->setFormat("Time Step: %v/%m"); m_animationProgress->setTextVisible(true); - m_animationProgress->setStyle(new QCDEStyle()); + + m_progressBarStyle = new QCDEStyle(); + m_animationProgress->setStyle(m_progressBarStyle); m_showAnimProgress = false; // Histogram @@ -114,6 +116,11 @@ RIViewer::~RIViewer() { m_reservoirView->showWindow = false; m_reservoirView->cameraPosition = m_mainCamera->viewMatrix(); + + delete m_InfoLabel; + delete m_animationProgress; + delete m_histogramWidget; + delete m_progressBarStyle; } @@ -405,6 +412,12 @@ cvf::Part* RIViewer::pickPointAndFace(int winPosX, int winPosY, uint* faceHit, c //-------------------------------------------------------------------------------------------------- void RIViewer::paintOverlayItems(QPainter* painter) { + // No support for overlay items using SW rendering yet. + if (!isShadersSupported()) + { + return; + } + int columnWidth = 200; int margin = 5; int yPos = margin; @@ -471,9 +484,10 @@ void RIViewer::setHistogram(double min, double max, const std::vector& h //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIViewer::setHistogramPercentiles(double pmin, double pmax) +void RIViewer::setHistogramPercentiles(double pmin, double pmax, double mean) { m_histogramWidget->setPercentiles(pmin, pmax); + m_histogramWidget->setMean(mean); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RIViewer.h b/ApplicationCode/UserInterface/RIViewer.h index f3551332c1..b09ce90448 100644 --- a/ApplicationCode/UserInterface/RIViewer.h +++ b/ApplicationCode/UserInterface/RIViewer.h @@ -29,6 +29,7 @@ class RimReservoirView; class QLabel; class QProgressBar; class RiuSimpleHistogramWidget; +class QCDEStyle; namespace cvf { @@ -60,7 +61,7 @@ public: void setInfoText(QString text); void showHistogram(bool enable); void setHistogram(double min, double max, const std::vector& histogram); - void setHistogramPercentiles(double pmin, double pmax); + void setHistogramPercentiles(double pmin, double pmax, double mean); void showAnimationProgress(bool enable); @@ -88,6 +89,7 @@ private: RiuSimpleHistogramWidget* m_histogramWidget; bool m_showHistogram; + QCDEStyle* m_progressBarStyle; cvf::ref m_legend1; diff --git a/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.cpp b/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.cpp index 2495f94ab4..f5384166de 100644 --- a/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.cpp +++ b/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.cpp @@ -10,6 +10,8 @@ QWidget(parent, f) { m_minPercentile = HUGE_VAL; m_maxPercentile = HUGE_VAL; + m_mean = HUGE_VAL; + } //-------------------------------------------------------------------------------------------------- @@ -78,6 +80,14 @@ void RiuSimpleHistogramWidget::draw(QPainter *painter,int x, int y, int width, i painter->setPen(QColor(255, 0, 0, 200)); painter->drawLine(xpos, y+1, xpos, y + height -1); } + + // Vertical lines for percentiles + if (m_mean != HUGE_VAL) + { + int xpos = xPosFromDomainValue(m_mean); + painter->setPen(QColor(0, 0, 255, 200)); + painter->drawLine(xpos, y+1, xpos, y + height -1); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.h b/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.h index d3b0e1b24b..5ced51fa8e 100644 --- a/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.h +++ b/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.h @@ -11,6 +11,7 @@ public: void setHistogramData(double min, double max, const std::vector& histogram); void setPercentiles(double pmin, double pmax) {m_minPercentile = pmin; m_maxPercentile = pmax;} + void setMean(double mean) {m_mean = mean;} protected: virtual void paintEvent(QPaintEvent* event); @@ -28,6 +29,7 @@ private: double m_min; double m_minPercentile; double m_maxPercentile; + double m_mean; size_t m_maxHistogramCount; double m_width; diff --git a/CMakeLists.txt b/CMakeLists.txt index 6dc57526b6..a4061be8f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,8 +33,8 @@ ENDIF() ################################################################################ set(CMAKE_MAJOR_VERSION 0) -set(CMAKE_MINOR_VERSION 8) -set(CMAKE_PATCH_VERSION 7) +set(CMAKE_MINOR_VERSION 9) +set(CMAKE_PATCH_VERSION 0) set(PRODUCTVER ${CMAKE_MAJOR_VERSION},${CMAKE_MINOR_VERSION},0,${CMAKE_PATCH_VERSION}) set(STRPRODUCTVER ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}) diff --git a/ThirdParty/Ert-windows-x64/include/buffer.h b/ThirdParty/Ert-windows-x64/include/buffer.h index b52a3b653d..7df53ca7d7 100644 --- a/ThirdParty/Ert-windows-x64/include/buffer.h +++ b/ThirdParty/Ert-windows-x64/include/buffer.h @@ -92,7 +92,7 @@ extern "C" { buffer_type * buffer_fread_alloc(const char * filename); void buffer_fread_realloc(buffer_type * buffer , const char * filename); -#ifdef HAVE_ZLIB +#ifdef WITH_ZLIB size_t buffer_fwrite_compressed(buffer_type * buffer, const void * ptr , size_t byte_size); size_t buffer_fread_compressed(buffer_type * buffer , size_t compressed_size , void * target_ptr , size_t target_size); #endif diff --git a/ThirdParty/Ert-windows-x64/include/ecl_grid.h b/ThirdParty/Ert-windows-x64/include/ecl_grid.h index c2a4cb358a..1405fbda00 100644 --- a/ThirdParty/Ert-windows-x64/include/ecl_grid.h +++ b/ThirdParty/Ert-windows-x64/include/ecl_grid.h @@ -61,11 +61,15 @@ extern "C" { bool ecl_grid_ijk_valid(const ecl_grid_type * , int , int , int ); int ecl_grid_get_global_index3(const ecl_grid_type * , int , int , int ); int ecl_grid_get_global_index1A(const ecl_grid_type * ecl_grid , int active_index); + ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz , const ecl_kw_type * zcorn_kw , const ecl_kw_type * coord_kw , const ecl_kw_type * actnum_kw , const ecl_kw_type * mapaxes_kw ); ecl_grid_type * ecl_grid_alloc_GRDECL_data(int , int , int , const float * , const float * , const int * , const float * mapaxes); ecl_grid_type * ecl_grid_alloc_GRID_data(int num_coords , int nx, int ny , int nz , int coords_size , int ** coords , float ** corners , const float * mapaxes); ecl_grid_type * ecl_grid_alloc(const char * ); ecl_grid_type * ecl_grid_load_case( const char * case_input ); + ecl_grid_type * ecl_grid_alloc_rectangular( int nx , int ny , int nz , double dx , double dy , double dz , const int * actnum); + ecl_grid_type * ecl_grid_alloc_regular( int nx, int ny , int nz , const double * ivec, const double * jvec , const double * kvec , const int * actnum); + bool ecl_grid_exists( const char * case_input ); char * ecl_grid_alloc_case_filename( const char * case_input ); @@ -148,6 +152,9 @@ extern "C" { ecl_kw_type * ecl_grid_alloc_hostnum_kw( const ecl_grid_type * grid ); ecl_kw_type * ecl_grid_alloc_gridhead_kw( int nx, int ny , int nz , int grid_nr); + void ecl_grid_ri_export( const ecl_grid_type * ecl_grid , double * ri_points); + void ecl_grid_cell_ri_export( const ecl_grid_type * ecl_grid , int global_index , double * ri_points); + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert-windows-x64/include/ecl_kw.h b/ThirdParty/Ert-windows-x64/include/ecl_kw.h index f27ee05c40..986ff5eb38 100644 --- a/ThirdParty/Ert-windows-x64/include/ecl_kw.h +++ b/ThirdParty/Ert-windows-x64/include/ecl_kw.h @@ -103,9 +103,6 @@ extern "C" { bool ecl_kw_is_grdecl_file(FILE * ); bool ecl_kw_is_kw_file(FILE * , bool ); - void ecl_kw_inplace_sub(ecl_kw_type * , const ecl_kw_type * ); - void ecl_kw_inplace_mul(ecl_kw_type * , const ecl_kw_type * ); - void ecl_kw_inplace_div(ecl_kw_type * , const ecl_kw_type * ); double ecl_kw_element_sum_float( const ecl_kw_type * ecl_kw ); void ecl_kw_inplace_inv(ecl_kw_type * my_kw); @@ -113,8 +110,6 @@ extern "C" { void ecl_kw_max_min(const ecl_kw_type * , void * , void *); void * ecl_kw_get_void_ptr(const ecl_kw_type * ecl_kw); - double ecl_kw_iget_as_double(const ecl_kw_type * , int ); - ecl_kw_type * ecl_kw_buffer_alloc(buffer_type * buffer); void ecl_kw_buffer_store(const ecl_kw_type * ecl_kw , buffer_type * buffer); @@ -149,29 +144,29 @@ extern "C" { void ecl_kw_copy_indexed( ecl_kw_type * target_kw , const int_vector_type * index_set , const ecl_kw_type * src_kw); bool ecl_kw_assert_binary_numeric( const ecl_kw_type * kw1, const ecl_kw_type * kw2); -#define ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( ctype ) bool ecl_kw_assert_binary_ ## ctype( const ecl_kw_type * kw1 , const ecl_kw_type * kw2); - ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( int ) - ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( float ) - ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( double ) +#define ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( ctype ) bool ecl_kw_assert_binary_ ## ctype( const ecl_kw_type * kw1 , const ecl_kw_type * kw2) + ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( int ); + ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( float ); + ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( double ); #undef ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER -#define ECL_KW_SCALE_TYPED_HEADER( ctype ) void ecl_kw_scale_ ## ctype (ecl_kw_type * ecl_kw , ctype scale_factor); - ECL_KW_SCALE_TYPED_HEADER( int ) - ECL_KW_SCALE_TYPED_HEADER( float ) - ECL_KW_SCALE_TYPED_HEADER( double ) +#define ECL_KW_SCALE_TYPED_HEADER( ctype ) void ecl_kw_scale_ ## ctype (ecl_kw_type * ecl_kw , ctype scale_factor) + ECL_KW_SCALE_TYPED_HEADER( int ); + ECL_KW_SCALE_TYPED_HEADER( float ); + ECL_KW_SCALE_TYPED_HEADER( double ); #undef ECL_KW_SCALE_TYPED_HEADER void ecl_kw_scale_float_or_double( ecl_kw_type * ecl_kw , double scale_factor ); -#define ECL_KW_SHIFT_TYPED_HEADER( ctype ) void ecl_kw_shift_ ## ctype (ecl_kw_type * ecl_kw , ctype shift_factor); - ECL_KW_SHIFT_TYPED_HEADER( int ) - ECL_KW_SHIFT_TYPED_HEADER( float ) - ECL_KW_SHIFT_TYPED_HEADER( double ) +#define ECL_KW_SHIFT_TYPED_HEADER( ctype ) void ecl_kw_shift_ ## ctype (ecl_kw_type * ecl_kw , ctype shift_factor) + ECL_KW_SHIFT_TYPED_HEADER( int ); + ECL_KW_SHIFT_TYPED_HEADER( float ); + ECL_KW_SHIFT_TYPED_HEADER( double ); #undef ECL_KW_SHIFT_TYPED_HEADER void ecl_kw_shift_float_or_double( ecl_kw_type * ecl_kw , double shift_value ); -#define ECL_KW_IGET_TYPED_HEADER(type) type ecl_kw_iget_ ## type(const ecl_kw_type * , int); +#define ECL_KW_IGET_TYPED_HEADER(type) type ecl_kw_iget_ ## type(const ecl_kw_type * , int) ECL_KW_IGET_TYPED_HEADER(double); ECL_KW_IGET_TYPED_HEADER(float); ECL_KW_IGET_TYPED_HEADER(int); @@ -179,7 +174,7 @@ extern "C" { bool ecl_kw_iget_bool( const ecl_kw_type * ecl_kw , int i ); -#define ECL_KW_ISET_TYPED_HEADER(type) void ecl_kw_iset_ ## type(ecl_kw_type * , int , type ); +#define ECL_KW_ISET_TYPED_HEADER(type) void ecl_kw_iset_ ## type(ecl_kw_type * , int , type ) ECL_KW_ISET_TYPED_HEADER(double); ECL_KW_ISET_TYPED_HEADER(float); ECL_KW_ISET_TYPED_HEADER(int); @@ -187,7 +182,7 @@ extern "C" { void ecl_kw_iset_bool( ecl_kw_type * ecl_kw , int i , bool bool_value); -#define ECL_KW_GET_TYPED_PTR_HEADER(type) type * ecl_kw_get_ ## type ## _ptr(const ecl_kw_type *); +#define ECL_KW_GET_TYPED_PTR_HEADER(type) type * ecl_kw_get_ ## type ## _ptr(const ecl_kw_type *) ECL_KW_GET_TYPED_PTR_HEADER(double); ECL_KW_GET_TYPED_PTR_HEADER(float); ECL_KW_GET_TYPED_PTR_HEADER(int); @@ -195,31 +190,31 @@ extern "C" { #undef ECL_KW_GET_TYPED_PTR_HEADER -#define ECL_KW_SET_INDEXED_HEADER(ctype ) void ecl_kw_set_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype value); +#define ECL_KW_SET_INDEXED_HEADER(ctype ) void ecl_kw_set_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype value) ECL_KW_SET_INDEXED_HEADER( double ); ECL_KW_SET_INDEXED_HEADER( float ); ECL_KW_SET_INDEXED_HEADER( int ); #undef ECL_KW_SET_INDEXED_HEADER -#define ECL_KW_SHIFT_INDEXED_HEADER(ctype) void ecl_kw_shift_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype shift); - ECL_KW_SHIFT_INDEXED_HEADER( int ) - ECL_KW_SHIFT_INDEXED_HEADER( float ) - ECL_KW_SHIFT_INDEXED_HEADER( double ) +#define ECL_KW_SHIFT_INDEXED_HEADER(ctype) void ecl_kw_shift_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype shift) + ECL_KW_SHIFT_INDEXED_HEADER( int ); + ECL_KW_SHIFT_INDEXED_HEADER( float ); + ECL_KW_SHIFT_INDEXED_HEADER( double ); #undef ECL_KW_SHIFT_INDEXED_HEADER -#define ECL_KW_SCALE_INDEXED_HEADER(ctype) void ecl_kw_scale_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype scale); - ECL_KW_SCALE_INDEXED_HEADER( int ) - ECL_KW_SCALE_INDEXED_HEADER( float ) - ECL_KW_SCALE_INDEXED_HEADER( double ) +#define ECL_KW_SCALE_INDEXED_HEADER(ctype) void ecl_kw_scale_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype scale) + ECL_KW_SCALE_INDEXED_HEADER( int ); + ECL_KW_SCALE_INDEXED_HEADER( float ); + ECL_KW_SCALE_INDEXED_HEADER( double ); #undef ECL_KW_SCALE_INDEXED_HEADER -#define ECL_KW_MAX_MIN_HEADER( ctype ) void ecl_kw_max_min_ ## ctype( const ecl_kw_type * ecl_kw , ctype * _max , ctype * _min); - ECL_KW_MAX_MIN_HEADER( int ) - ECL_KW_MAX_MIN_HEADER( float ) - ECL_KW_MAX_MIN_HEADER( double ) +#define ECL_KW_MAX_MIN_HEADER( ctype ) void ecl_kw_max_min_ ## ctype( const ecl_kw_type * ecl_kw , ctype * _max , ctype * _min) + ECL_KW_MAX_MIN_HEADER( int ); + ECL_KW_MAX_MIN_HEADER( float ); + ECL_KW_MAX_MIN_HEADER( double ); #undef ECL_KW_MAX_MIN_HEADER #include diff --git a/ThirdParty/Ert-windows-x64/include/ecl_kw_magic.h b/ThirdParty/Ert-windows-x64/include/ecl_kw_magic.h index d6453617b0..d47790820e 100644 --- a/ThirdParty/Ert-windows-x64/include/ecl_kw_magic.h +++ b/ThirdParty/Ert-windows-x64/include/ecl_kw_magic.h @@ -255,6 +255,9 @@ extern "C" { /* Common keywords */ #define SPECGRID_KW "SPECGRID" +#define SPECGRID_NX_INDEX 0 +#define SPECGRID_NY_INDEX 1 +#define SPECGRID_NZ_INDEX 2 #define MAPAXES_KW "MAPAXES" /* Keyword used to transform from grid coordinates to world coordinates. */ #define LGR_KW "LGR" /* Name of LGR; for GRID files it can contain two elements, diff --git a/ThirdParty/Ert-windows-x64/include/ecl_smspec.h b/ThirdParty/Ert-windows-x64/include/ecl_smspec.h index 1c122094e5..20046b3595 100644 --- a/ThirdParty/Ert-windows-x64/include/ecl_smspec.h +++ b/ThirdParty/Ert-windows-x64/include/ecl_smspec.h @@ -44,8 +44,9 @@ typedef struct ecl_smspec_struct ecl_smspec_type; ecl_smspec_install_gen_key() must be updated. */ const int_vector_type * ecl_smspec_get_index_map( const ecl_smspec_type * smspec ); - - void ecl_smspec_add_node(ecl_smspec_type * ecl_smspec, smspec_node_type * smspec_node); + void ecl_smspec_index_node( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node); + void ecl_smspec_insert_node(ecl_smspec_type * ecl_smspec, smspec_node_type * smspec_node); + void ecl_smspec_add_node( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node ); ecl_smspec_var_type ecl_smspec_iget_var_type( const ecl_smspec_type * smspec , int index ); bool ecl_smspec_needs_num( ecl_smspec_var_type var_type ); bool ecl_smspec_needs_wgname( ecl_smspec_var_type var_type ); @@ -112,7 +113,7 @@ typedef struct ecl_smspec_struct ecl_smspec_type; - + void ecl_smspec_init_var( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node , const char * keyword , const char * wgname , int num, const char * unit ); void ecl_smspec_select_matching_general_var_list( const ecl_smspec_type * smspec , const char * pattern , stringlist_type * keys); stringlist_type * ecl_smspec_alloc_matching_general_var_list(const ecl_smspec_type * smspec , const char * pattern); diff --git a/ThirdParty/Ert-windows-x64/include/ecl_sum.h b/ThirdParty/Ert-windows-x64/include/ecl_sum.h index f336ceb3db..c575b85ae7 100644 --- a/ThirdParty/Ert-windows-x64/include/ecl_sum.h +++ b/ThirdParty/Ert-windows-x64/include/ecl_sum.h @@ -173,6 +173,8 @@ typedef struct ecl_sum_struct ecl_sum_type; void ecl_sum_fwrite( const ecl_sum_type * ecl_sum ); void ecl_sum_fwrite_smspec( const ecl_sum_type * ecl_sum ); smspec_node_type * ecl_sum_add_var( ecl_sum_type * ecl_sum , const char * keyword , const char * wgname , int num , const char * unit , float default_value); + smspec_node_type * ecl_sum_add_blank_var( ecl_sum_type * ecl_sum , float default_value); + void ecl_sum_init_var( ecl_sum_type * ecl_sum , smspec_node_type * smspec_node , const char * keyword , const char * wgname , int num , const char * unit); ecl_sum_tstep_type * ecl_sum_add_tstep( ecl_sum_type * ecl_sum , int report_step , double sim_days); void ecl_sum_update_wgname( ecl_sum_type * ecl_sum , smspec_node_type * node , const char * wgname ); diff --git a/ThirdParty/Ert-windows-x64/include/matrix.h b/ThirdParty/Ert-windows-x64/include/matrix.h index f71c1cec86..a44fd96866 100644 --- a/ThirdParty/Ert-windows-x64/include/matrix.h +++ b/ThirdParty/Ert-windows-x64/include/matrix.h @@ -131,6 +131,7 @@ typedef struct matrix_struct matrix_type; double matrix_trace(const matrix_type *matrix); double matrix_diag_std(const matrix_type * Sk,double mean); double matrix_det3( const matrix_type * A); + double matrix_det4( const matrix_type * A); #ifdef HAVE_ISFINITE bool matrix_is_finite(const matrix_type * matrix); diff --git a/ThirdParty/Ert-windows-x64/include/path_fmt.h b/ThirdParty/Ert-windows-x64/include/path_fmt.h index 6440e49268..fc913fef86 100644 --- a/ThirdParty/Ert-windows-x64/include/path_fmt.h +++ b/ThirdParty/Ert-windows-x64/include/path_fmt.h @@ -25,22 +25,21 @@ extern "C" { #include #include -typedef struct path_fmt_struct path_fmt_type; - - -path_fmt_type * path_fmt_safe_cast(const void * arg); -path_fmt_type * path_fmt_alloc_directory_fmt(const char * ); -path_fmt_type * path_fmt_alloc_path_fmt(const char * ); -path_fmt_type * path_fmt_copyc(const path_fmt_type *); -path_fmt_type * path_fmt_scanf_alloc(const char * , int , const node_ctype * , bool ); -char * path_fmt_alloc_path(const path_fmt_type * , bool , ...); -char * path_fmt_alloc_file(const path_fmt_type * , bool , ...); -void path_fmt_free(path_fmt_type * ); -const char * path_fmt_get_fmt(const path_fmt_type * ); -void path_fmt_reset_fmt(path_fmt_type * , const char * ); -void path_fmt_make_path(const path_fmt_type * ); -path_fmt_type * path_fmt_realloc_path_fmt( path_fmt_type * path_fmt, const char * fmt ); - + typedef struct path_fmt_struct path_fmt_type; + + path_fmt_type * path_fmt_alloc_directory_fmt(const char * ); + path_fmt_type * path_fmt_alloc_path_fmt(const char * ); + path_fmt_type * path_fmt_copyc(const path_fmt_type *); + path_fmt_type * path_fmt_scanf_alloc(const char * , int , const node_ctype * , bool ); + char * path_fmt_alloc_path(const path_fmt_type * , bool , ...); + char * path_fmt_alloc_file(const path_fmt_type * , bool , ...); + void path_fmt_free(path_fmt_type * ); + void path_fmt_free__( void * arg ); + const char * path_fmt_get_fmt(const path_fmt_type * ); + void path_fmt_reset_fmt(path_fmt_type * , const char * ); + void path_fmt_make_path(const path_fmt_type * ); + path_fmt_type * path_fmt_realloc_path_fmt( path_fmt_type * path_fmt, const char * fmt ); + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert-windows-x64/include/smspec_node.h b/ThirdParty/Ert-windows-x64/include/smspec_node.h index f5c498fce3..cd5ec9a3b1 100644 --- a/ThirdParty/Ert-windows-x64/include/smspec_node.h +++ b/ThirdParty/Ert-windows-x64/include/smspec_node.h @@ -68,6 +68,15 @@ typedef enum {ECL_SMSPEC_INVALID_VAR = 0 , char * smspec_alloc_local_completion_key( const char * join_string, const char * keyword , const char * lgr_name , const char * wgname , int i , int j , int k); + bool smspec_node_init( smspec_node_type * smspec_node, + ecl_smspec_var_type var_type , + const char * wgname , + const char * keyword , + const char * unit , + const char * key_join_string , + const int grid_dims[3] , + int num); + smspec_node_type * smspec_node_alloc( ecl_smspec_var_type var_type , const char * wgname , @@ -87,6 +96,7 @@ typedef enum {ECL_SMSPEC_INVALID_VAR = 0 , int param_index, float default_value); + smspec_node_type * smspec_node_alloc_new(int params_index, float default_value); void smspec_node_free( smspec_node_type * index ); void smspec_node_free__(void * arg); @@ -100,11 +110,15 @@ typedef enum {ECL_SMSPEC_INVALID_VAR = 0 , void smspec_node_update_wgname( smspec_node_type * index , const char * wgname , const char * key_join_string); const char * smspec_node_get_keyword( const smspec_node_type * smspec_node); const char * smspec_node_get_unit( const smspec_node_type * smspec_node); + void smspec_node_set_unit( smspec_node_type * smspec_node , const char * unit ); bool smspec_node_is_rate( const smspec_node_type * smspec_node ); bool smspec_node_is_total( const smspec_node_type * smspec_node ); bool smspec_node_need_nums( const smspec_node_type * smspec_node ); - float smspec_node_get_default_value( const smspec_node_type * smspec_node ); void smspec_node_fprintf( const smspec_node_type * smspec_node , FILE * stream); + + void smspec_node_set_default( smspec_node_type * smspec_node , float default_value); + float smspec_node_get_default( const smspec_node_type * smspec_node); + #ifdef __cplusplus } diff --git a/ThirdParty/Ert-windows-x64/include/thread_pool.h b/ThirdParty/Ert-windows-x64/include/thread_pool.h index 0aa675360a..0f4fbe4e0a 100644 --- a/ThirdParty/Ert-windows-x64/include/thread_pool.h +++ b/ThirdParty/Ert-windows-x64/include/thread_pool.h @@ -18,8 +18,8 @@ #ifndef __THREAD_POOL_H__ #define __THREAD_POOL_H__ -#ifdef HAVE_PTHREAD -#define HAVE_THREAD_POOL +#ifdef WITH_PTHREAD +#define WITH_THREAD_POOL #include "thread_pool_posix.h" #endif diff --git a/ThirdParty/Ert-windows-x64/include/util.h b/ThirdParty/Ert-windows-x64/include/util.h index 671e99fd1e..063f8807dc 100644 --- a/ThirdParty/Ert-windows-x64/include/util.h +++ b/ThirdParty/Ert-windows-x64/include/util.h @@ -405,7 +405,7 @@ const char * util_enum_iget( int index , int size , const util_enum_element_type /*****************************************************************/ /* Conditional section below here */ -#ifdef HAVE_ZLIB +#ifdef WITH_ZLIB void util_compress_buffer(const void * , int , void * , unsigned long * ); int util_fread_sizeof_compressed(FILE * stream); void util_fread_compressed(void * , FILE * ); diff --git a/ThirdParty/Ert-windows-x64/include/vector.h b/ThirdParty/Ert-windows-x64/include/vector.h index 6a405858de..48394de0ea 100644 --- a/ThirdParty/Ert-windows-x64/include/vector.h +++ b/ThirdParty/Ert-windows-x64/include/vector.h @@ -23,60 +23,62 @@ extern "C" { #endif #include +#include -typedef void ( vector_func_type ) (void * , void *); -typedef int ( vector_cmp_ftype) (const void * , const void *); - -typedef struct vector_struct vector_type; + typedef void ( vector_func_type ) (void * , void *); + typedef int ( vector_cmp_ftype) (const void * , const void *); + + typedef struct vector_struct vector_type; + vector_type * vector_alloc_new(); + void vector_grow_NULL( vector_type * vector , int new_size ); + vector_type * vector_alloc_NULL_initialized( int size ); -vector_type * vector_alloc_new(); -vector_type * vector_alloc_NULL_initialized( int size ); - -int vector_append_ref( vector_type * , const void *); -int vector_append_owned_ref( vector_type * , const void * , free_ftype * del); -int vector_append_copy(vector_type * , const void *, copyc_ftype *, free_ftype *); - -void vector_iset_ref( vector_type * , int , const void *); -void vector_iset_owned_ref( vector_type * , int , const void * , free_ftype * del); -void vector_iset_copy(vector_type * , int , const void *, copyc_ftype *, free_ftype *); - -void vector_safe_iset_copy(vector_type * vector , int index , const void * data, copyc_ftype * copyc , free_ftype * del); -void vector_safe_iset_owned_ref(vector_type * vector , int index , const void * data, free_ftype * del); -void vector_safe_iset_ref(vector_type * vector , int index , const void * data); - -void vector_insert_ref( vector_type * , int , const void *); -void vector_insert_owned_ref( vector_type * , int , const void * , free_ftype * del); -void vector_insert_copy(vector_type * , int , const void *, copyc_ftype *, free_ftype *); -void vector_insert_buffer(vector_type * vector , int index , const void * buffer, int buffer_size); - -void vector_push_ref( vector_type * , const void *); -void vector_push_owned_ref( vector_type * , const void * , free_ftype * del); -void vector_push_copy(vector_type * , const void *, copyc_ftype *, free_ftype *); - - -void vector_clear(vector_type * vector); -void vector_free(vector_type * ); -void vector_free__( void * arg ); -void vector_append_buffer(vector_type * , const void * , int); -void vector_push_buffer(vector_type * , const void * , int); -int vector_get_size(const vector_type * ); -void * vector_safe_iget(const vector_type * vector, int index); -const void * vector_safe_iget_const(const vector_type * vector, int index); -const void * vector_iget_const(const vector_type * , int ); -void * vector_iget(const vector_type * , int ); -void vector_idel(vector_type * vector , int index); -void vector_shrink( vector_type * vector , int new_size ); -void * vector_get_last(const vector_type * ); -const void * vector_get_last_const(const vector_type * ); -int vector_get_size( const vector_type * ); -void * vector_pop(vector_type * ); -void vector_sort(vector_type * vector , vector_cmp_ftype * cmp); -vector_type * vector_alloc_copy(const vector_type * src , bool deep_copy); - -void vector_iset_buffer(vector_type * vector , int index , const void * buffer, int buffer_size); - + int vector_append_ref( vector_type * , const void *); + int vector_append_owned_ref( vector_type * , const void * , free_ftype * del); + int vector_append_copy(vector_type * , const void *, copyc_ftype *, free_ftype *); + + void vector_iset_ref( vector_type * , int , const void *); + void vector_iset_owned_ref( vector_type * , int , const void * , free_ftype * del); + void vector_iset_copy(vector_type * , int , const void *, copyc_ftype *, free_ftype *); + + void vector_safe_iset_copy(vector_type * vector , int index , const void * data, copyc_ftype * copyc , free_ftype * del); + void vector_safe_iset_owned_ref(vector_type * vector , int index , const void * data, free_ftype * del); + void vector_safe_iset_ref(vector_type * vector , int index , const void * data); + + void vector_insert_ref( vector_type * , int , const void *); + void vector_insert_owned_ref( vector_type * , int , const void * , free_ftype * del); + void vector_insert_copy(vector_type * , int , const void *, copyc_ftype *, free_ftype *); + void vector_insert_buffer(vector_type * vector , int index , const void * buffer, int buffer_size); + + void vector_push_ref( vector_type * , const void *); + void vector_push_owned_ref( vector_type * , const void * , free_ftype * del); + void vector_push_copy(vector_type * , const void *, copyc_ftype *, free_ftype *); + + + void vector_clear(vector_type * vector); + void vector_free(vector_type * ); + void vector_free__( void * arg ); + void vector_append_buffer(vector_type * , const void * , int); + void vector_push_buffer(vector_type * , const void * , int); + int vector_get_size(const vector_type * ); + void * vector_safe_iget(const vector_type * vector, int index); + const void * vector_safe_iget_const(const vector_type * vector, int index); + const void * vector_iget_const(const vector_type * , int ); + void * vector_iget(const vector_type * , int ); + void vector_idel(vector_type * vector , int index); + void vector_shrink( vector_type * vector , int new_size ); + void * vector_get_last(const vector_type * ); + const void * vector_get_last_const(const vector_type * ); + int vector_get_size( const vector_type * ); + void * vector_pop(vector_type * ); + void vector_sort(vector_type * vector , vector_cmp_ftype * cmp); + vector_type * vector_alloc_copy(const vector_type * src , bool deep_copy); + + void vector_iset_buffer(vector_type * vector , int index , const void * buffer, int buffer_size); + + UTIL_IS_INSTANCE_HEADER( vector ); #ifdef __cplusplus } diff --git a/ThirdParty/Ert-windows-x64/lib/ecl.lib b/ThirdParty/Ert-windows-x64/lib/ecl.lib index cbd318d178..47b329b824 100644 Binary files a/ThirdParty/Ert-windows-x64/lib/ecl.lib and b/ThirdParty/Ert-windows-x64/lib/ecl.lib differ diff --git a/ThirdParty/Ert-windows-x64/lib/ert_util.lib b/ThirdParty/Ert-windows-x64/lib/ert_util.lib index 3a853ecdc8..463b28f9e2 100644 Binary files a/ThirdParty/Ert-windows-x64/lib/ert_util.lib and b/ThirdParty/Ert-windows-x64/lib/ert_util.lib differ diff --git a/ThirdParty/Ert-windows-x64/lib/geometry.lib b/ThirdParty/Ert-windows-x64/lib/geometry.lib index 2d324fc3f1..30f0197115 100644 Binary files a/ThirdParty/Ert-windows-x64/lib/geometry.lib and b/ThirdParty/Ert-windows-x64/lib/geometry.lib differ diff --git a/ThirdParty/Ert-windows-x64/lib/well.lib b/ThirdParty/Ert-windows-x64/lib/well.lib index c124e27fea..bc9e0535a6 100644 Binary files a/ThirdParty/Ert-windows-x64/lib/well.lib and b/ThirdParty/Ert-windows-x64/lib/well.lib differ diff --git a/ThirdParty/Ert-windows/include/buffer.h b/ThirdParty/Ert-windows/include/buffer.h index b52a3b653d..7df53ca7d7 100644 --- a/ThirdParty/Ert-windows/include/buffer.h +++ b/ThirdParty/Ert-windows/include/buffer.h @@ -92,7 +92,7 @@ extern "C" { buffer_type * buffer_fread_alloc(const char * filename); void buffer_fread_realloc(buffer_type * buffer , const char * filename); -#ifdef HAVE_ZLIB +#ifdef WITH_ZLIB size_t buffer_fwrite_compressed(buffer_type * buffer, const void * ptr , size_t byte_size); size_t buffer_fread_compressed(buffer_type * buffer , size_t compressed_size , void * target_ptr , size_t target_size); #endif diff --git a/ThirdParty/Ert-windows/include/ecl_grid.h b/ThirdParty/Ert-windows/include/ecl_grid.h index c2a4cb358a..1405fbda00 100644 --- a/ThirdParty/Ert-windows/include/ecl_grid.h +++ b/ThirdParty/Ert-windows/include/ecl_grid.h @@ -61,11 +61,15 @@ extern "C" { bool ecl_grid_ijk_valid(const ecl_grid_type * , int , int , int ); int ecl_grid_get_global_index3(const ecl_grid_type * , int , int , int ); int ecl_grid_get_global_index1A(const ecl_grid_type * ecl_grid , int active_index); + ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz , const ecl_kw_type * zcorn_kw , const ecl_kw_type * coord_kw , const ecl_kw_type * actnum_kw , const ecl_kw_type * mapaxes_kw ); ecl_grid_type * ecl_grid_alloc_GRDECL_data(int , int , int , const float * , const float * , const int * , const float * mapaxes); ecl_grid_type * ecl_grid_alloc_GRID_data(int num_coords , int nx, int ny , int nz , int coords_size , int ** coords , float ** corners , const float * mapaxes); ecl_grid_type * ecl_grid_alloc(const char * ); ecl_grid_type * ecl_grid_load_case( const char * case_input ); + ecl_grid_type * ecl_grid_alloc_rectangular( int nx , int ny , int nz , double dx , double dy , double dz , const int * actnum); + ecl_grid_type * ecl_grid_alloc_regular( int nx, int ny , int nz , const double * ivec, const double * jvec , const double * kvec , const int * actnum); + bool ecl_grid_exists( const char * case_input ); char * ecl_grid_alloc_case_filename( const char * case_input ); @@ -148,6 +152,9 @@ extern "C" { ecl_kw_type * ecl_grid_alloc_hostnum_kw( const ecl_grid_type * grid ); ecl_kw_type * ecl_grid_alloc_gridhead_kw( int nx, int ny , int nz , int grid_nr); + void ecl_grid_ri_export( const ecl_grid_type * ecl_grid , double * ri_points); + void ecl_grid_cell_ri_export( const ecl_grid_type * ecl_grid , int global_index , double * ri_points); + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert-windows/include/ecl_kw.h b/ThirdParty/Ert-windows/include/ecl_kw.h index f27ee05c40..986ff5eb38 100644 --- a/ThirdParty/Ert-windows/include/ecl_kw.h +++ b/ThirdParty/Ert-windows/include/ecl_kw.h @@ -103,9 +103,6 @@ extern "C" { bool ecl_kw_is_grdecl_file(FILE * ); bool ecl_kw_is_kw_file(FILE * , bool ); - void ecl_kw_inplace_sub(ecl_kw_type * , const ecl_kw_type * ); - void ecl_kw_inplace_mul(ecl_kw_type * , const ecl_kw_type * ); - void ecl_kw_inplace_div(ecl_kw_type * , const ecl_kw_type * ); double ecl_kw_element_sum_float( const ecl_kw_type * ecl_kw ); void ecl_kw_inplace_inv(ecl_kw_type * my_kw); @@ -113,8 +110,6 @@ extern "C" { void ecl_kw_max_min(const ecl_kw_type * , void * , void *); void * ecl_kw_get_void_ptr(const ecl_kw_type * ecl_kw); - double ecl_kw_iget_as_double(const ecl_kw_type * , int ); - ecl_kw_type * ecl_kw_buffer_alloc(buffer_type * buffer); void ecl_kw_buffer_store(const ecl_kw_type * ecl_kw , buffer_type * buffer); @@ -149,29 +144,29 @@ extern "C" { void ecl_kw_copy_indexed( ecl_kw_type * target_kw , const int_vector_type * index_set , const ecl_kw_type * src_kw); bool ecl_kw_assert_binary_numeric( const ecl_kw_type * kw1, const ecl_kw_type * kw2); -#define ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( ctype ) bool ecl_kw_assert_binary_ ## ctype( const ecl_kw_type * kw1 , const ecl_kw_type * kw2); - ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( int ) - ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( float ) - ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( double ) +#define ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( ctype ) bool ecl_kw_assert_binary_ ## ctype( const ecl_kw_type * kw1 , const ecl_kw_type * kw2) + ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( int ); + ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( float ); + ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( double ); #undef ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER -#define ECL_KW_SCALE_TYPED_HEADER( ctype ) void ecl_kw_scale_ ## ctype (ecl_kw_type * ecl_kw , ctype scale_factor); - ECL_KW_SCALE_TYPED_HEADER( int ) - ECL_KW_SCALE_TYPED_HEADER( float ) - ECL_KW_SCALE_TYPED_HEADER( double ) +#define ECL_KW_SCALE_TYPED_HEADER( ctype ) void ecl_kw_scale_ ## ctype (ecl_kw_type * ecl_kw , ctype scale_factor) + ECL_KW_SCALE_TYPED_HEADER( int ); + ECL_KW_SCALE_TYPED_HEADER( float ); + ECL_KW_SCALE_TYPED_HEADER( double ); #undef ECL_KW_SCALE_TYPED_HEADER void ecl_kw_scale_float_or_double( ecl_kw_type * ecl_kw , double scale_factor ); -#define ECL_KW_SHIFT_TYPED_HEADER( ctype ) void ecl_kw_shift_ ## ctype (ecl_kw_type * ecl_kw , ctype shift_factor); - ECL_KW_SHIFT_TYPED_HEADER( int ) - ECL_KW_SHIFT_TYPED_HEADER( float ) - ECL_KW_SHIFT_TYPED_HEADER( double ) +#define ECL_KW_SHIFT_TYPED_HEADER( ctype ) void ecl_kw_shift_ ## ctype (ecl_kw_type * ecl_kw , ctype shift_factor) + ECL_KW_SHIFT_TYPED_HEADER( int ); + ECL_KW_SHIFT_TYPED_HEADER( float ); + ECL_KW_SHIFT_TYPED_HEADER( double ); #undef ECL_KW_SHIFT_TYPED_HEADER void ecl_kw_shift_float_or_double( ecl_kw_type * ecl_kw , double shift_value ); -#define ECL_KW_IGET_TYPED_HEADER(type) type ecl_kw_iget_ ## type(const ecl_kw_type * , int); +#define ECL_KW_IGET_TYPED_HEADER(type) type ecl_kw_iget_ ## type(const ecl_kw_type * , int) ECL_KW_IGET_TYPED_HEADER(double); ECL_KW_IGET_TYPED_HEADER(float); ECL_KW_IGET_TYPED_HEADER(int); @@ -179,7 +174,7 @@ extern "C" { bool ecl_kw_iget_bool( const ecl_kw_type * ecl_kw , int i ); -#define ECL_KW_ISET_TYPED_HEADER(type) void ecl_kw_iset_ ## type(ecl_kw_type * , int , type ); +#define ECL_KW_ISET_TYPED_HEADER(type) void ecl_kw_iset_ ## type(ecl_kw_type * , int , type ) ECL_KW_ISET_TYPED_HEADER(double); ECL_KW_ISET_TYPED_HEADER(float); ECL_KW_ISET_TYPED_HEADER(int); @@ -187,7 +182,7 @@ extern "C" { void ecl_kw_iset_bool( ecl_kw_type * ecl_kw , int i , bool bool_value); -#define ECL_KW_GET_TYPED_PTR_HEADER(type) type * ecl_kw_get_ ## type ## _ptr(const ecl_kw_type *); +#define ECL_KW_GET_TYPED_PTR_HEADER(type) type * ecl_kw_get_ ## type ## _ptr(const ecl_kw_type *) ECL_KW_GET_TYPED_PTR_HEADER(double); ECL_KW_GET_TYPED_PTR_HEADER(float); ECL_KW_GET_TYPED_PTR_HEADER(int); @@ -195,31 +190,31 @@ extern "C" { #undef ECL_KW_GET_TYPED_PTR_HEADER -#define ECL_KW_SET_INDEXED_HEADER(ctype ) void ecl_kw_set_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype value); +#define ECL_KW_SET_INDEXED_HEADER(ctype ) void ecl_kw_set_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype value) ECL_KW_SET_INDEXED_HEADER( double ); ECL_KW_SET_INDEXED_HEADER( float ); ECL_KW_SET_INDEXED_HEADER( int ); #undef ECL_KW_SET_INDEXED_HEADER -#define ECL_KW_SHIFT_INDEXED_HEADER(ctype) void ecl_kw_shift_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype shift); - ECL_KW_SHIFT_INDEXED_HEADER( int ) - ECL_KW_SHIFT_INDEXED_HEADER( float ) - ECL_KW_SHIFT_INDEXED_HEADER( double ) +#define ECL_KW_SHIFT_INDEXED_HEADER(ctype) void ecl_kw_shift_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype shift) + ECL_KW_SHIFT_INDEXED_HEADER( int ); + ECL_KW_SHIFT_INDEXED_HEADER( float ); + ECL_KW_SHIFT_INDEXED_HEADER( double ); #undef ECL_KW_SHIFT_INDEXED_HEADER -#define ECL_KW_SCALE_INDEXED_HEADER(ctype) void ecl_kw_scale_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype scale); - ECL_KW_SCALE_INDEXED_HEADER( int ) - ECL_KW_SCALE_INDEXED_HEADER( float ) - ECL_KW_SCALE_INDEXED_HEADER( double ) +#define ECL_KW_SCALE_INDEXED_HEADER(ctype) void ecl_kw_scale_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype scale) + ECL_KW_SCALE_INDEXED_HEADER( int ); + ECL_KW_SCALE_INDEXED_HEADER( float ); + ECL_KW_SCALE_INDEXED_HEADER( double ); #undef ECL_KW_SCALE_INDEXED_HEADER -#define ECL_KW_MAX_MIN_HEADER( ctype ) void ecl_kw_max_min_ ## ctype( const ecl_kw_type * ecl_kw , ctype * _max , ctype * _min); - ECL_KW_MAX_MIN_HEADER( int ) - ECL_KW_MAX_MIN_HEADER( float ) - ECL_KW_MAX_MIN_HEADER( double ) +#define ECL_KW_MAX_MIN_HEADER( ctype ) void ecl_kw_max_min_ ## ctype( const ecl_kw_type * ecl_kw , ctype * _max , ctype * _min) + ECL_KW_MAX_MIN_HEADER( int ); + ECL_KW_MAX_MIN_HEADER( float ); + ECL_KW_MAX_MIN_HEADER( double ); #undef ECL_KW_MAX_MIN_HEADER #include diff --git a/ThirdParty/Ert-windows/include/ecl_kw_magic.h b/ThirdParty/Ert-windows/include/ecl_kw_magic.h index d6453617b0..d47790820e 100644 --- a/ThirdParty/Ert-windows/include/ecl_kw_magic.h +++ b/ThirdParty/Ert-windows/include/ecl_kw_magic.h @@ -255,6 +255,9 @@ extern "C" { /* Common keywords */ #define SPECGRID_KW "SPECGRID" +#define SPECGRID_NX_INDEX 0 +#define SPECGRID_NY_INDEX 1 +#define SPECGRID_NZ_INDEX 2 #define MAPAXES_KW "MAPAXES" /* Keyword used to transform from grid coordinates to world coordinates. */ #define LGR_KW "LGR" /* Name of LGR; for GRID files it can contain two elements, diff --git a/ThirdParty/Ert-windows/include/ecl_smspec.h b/ThirdParty/Ert-windows/include/ecl_smspec.h index 1c122094e5..20046b3595 100644 --- a/ThirdParty/Ert-windows/include/ecl_smspec.h +++ b/ThirdParty/Ert-windows/include/ecl_smspec.h @@ -44,8 +44,9 @@ typedef struct ecl_smspec_struct ecl_smspec_type; ecl_smspec_install_gen_key() must be updated. */ const int_vector_type * ecl_smspec_get_index_map( const ecl_smspec_type * smspec ); - - void ecl_smspec_add_node(ecl_smspec_type * ecl_smspec, smspec_node_type * smspec_node); + void ecl_smspec_index_node( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node); + void ecl_smspec_insert_node(ecl_smspec_type * ecl_smspec, smspec_node_type * smspec_node); + void ecl_smspec_add_node( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node ); ecl_smspec_var_type ecl_smspec_iget_var_type( const ecl_smspec_type * smspec , int index ); bool ecl_smspec_needs_num( ecl_smspec_var_type var_type ); bool ecl_smspec_needs_wgname( ecl_smspec_var_type var_type ); @@ -112,7 +113,7 @@ typedef struct ecl_smspec_struct ecl_smspec_type; - + void ecl_smspec_init_var( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node , const char * keyword , const char * wgname , int num, const char * unit ); void ecl_smspec_select_matching_general_var_list( const ecl_smspec_type * smspec , const char * pattern , stringlist_type * keys); stringlist_type * ecl_smspec_alloc_matching_general_var_list(const ecl_smspec_type * smspec , const char * pattern); diff --git a/ThirdParty/Ert-windows/include/ecl_sum.h b/ThirdParty/Ert-windows/include/ecl_sum.h index f336ceb3db..c575b85ae7 100644 --- a/ThirdParty/Ert-windows/include/ecl_sum.h +++ b/ThirdParty/Ert-windows/include/ecl_sum.h @@ -173,6 +173,8 @@ typedef struct ecl_sum_struct ecl_sum_type; void ecl_sum_fwrite( const ecl_sum_type * ecl_sum ); void ecl_sum_fwrite_smspec( const ecl_sum_type * ecl_sum ); smspec_node_type * ecl_sum_add_var( ecl_sum_type * ecl_sum , const char * keyword , const char * wgname , int num , const char * unit , float default_value); + smspec_node_type * ecl_sum_add_blank_var( ecl_sum_type * ecl_sum , float default_value); + void ecl_sum_init_var( ecl_sum_type * ecl_sum , smspec_node_type * smspec_node , const char * keyword , const char * wgname , int num , const char * unit); ecl_sum_tstep_type * ecl_sum_add_tstep( ecl_sum_type * ecl_sum , int report_step , double sim_days); void ecl_sum_update_wgname( ecl_sum_type * ecl_sum , smspec_node_type * node , const char * wgname ); diff --git a/ThirdParty/Ert-windows/include/matrix.h b/ThirdParty/Ert-windows/include/matrix.h index f71c1cec86..a44fd96866 100644 --- a/ThirdParty/Ert-windows/include/matrix.h +++ b/ThirdParty/Ert-windows/include/matrix.h @@ -131,6 +131,7 @@ typedef struct matrix_struct matrix_type; double matrix_trace(const matrix_type *matrix); double matrix_diag_std(const matrix_type * Sk,double mean); double matrix_det3( const matrix_type * A); + double matrix_det4( const matrix_type * A); #ifdef HAVE_ISFINITE bool matrix_is_finite(const matrix_type * matrix); diff --git a/ThirdParty/Ert-windows/include/path_fmt.h b/ThirdParty/Ert-windows/include/path_fmt.h index 6440e49268..fc913fef86 100644 --- a/ThirdParty/Ert-windows/include/path_fmt.h +++ b/ThirdParty/Ert-windows/include/path_fmt.h @@ -25,22 +25,21 @@ extern "C" { #include #include -typedef struct path_fmt_struct path_fmt_type; - - -path_fmt_type * path_fmt_safe_cast(const void * arg); -path_fmt_type * path_fmt_alloc_directory_fmt(const char * ); -path_fmt_type * path_fmt_alloc_path_fmt(const char * ); -path_fmt_type * path_fmt_copyc(const path_fmt_type *); -path_fmt_type * path_fmt_scanf_alloc(const char * , int , const node_ctype * , bool ); -char * path_fmt_alloc_path(const path_fmt_type * , bool , ...); -char * path_fmt_alloc_file(const path_fmt_type * , bool , ...); -void path_fmt_free(path_fmt_type * ); -const char * path_fmt_get_fmt(const path_fmt_type * ); -void path_fmt_reset_fmt(path_fmt_type * , const char * ); -void path_fmt_make_path(const path_fmt_type * ); -path_fmt_type * path_fmt_realloc_path_fmt( path_fmt_type * path_fmt, const char * fmt ); - + typedef struct path_fmt_struct path_fmt_type; + + path_fmt_type * path_fmt_alloc_directory_fmt(const char * ); + path_fmt_type * path_fmt_alloc_path_fmt(const char * ); + path_fmt_type * path_fmt_copyc(const path_fmt_type *); + path_fmt_type * path_fmt_scanf_alloc(const char * , int , const node_ctype * , bool ); + char * path_fmt_alloc_path(const path_fmt_type * , bool , ...); + char * path_fmt_alloc_file(const path_fmt_type * , bool , ...); + void path_fmt_free(path_fmt_type * ); + void path_fmt_free__( void * arg ); + const char * path_fmt_get_fmt(const path_fmt_type * ); + void path_fmt_reset_fmt(path_fmt_type * , const char * ); + void path_fmt_make_path(const path_fmt_type * ); + path_fmt_type * path_fmt_realloc_path_fmt( path_fmt_type * path_fmt, const char * fmt ); + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert-windows/include/smspec_node.h b/ThirdParty/Ert-windows/include/smspec_node.h index f5c498fce3..cd5ec9a3b1 100644 --- a/ThirdParty/Ert-windows/include/smspec_node.h +++ b/ThirdParty/Ert-windows/include/smspec_node.h @@ -68,6 +68,15 @@ typedef enum {ECL_SMSPEC_INVALID_VAR = 0 , char * smspec_alloc_local_completion_key( const char * join_string, const char * keyword , const char * lgr_name , const char * wgname , int i , int j , int k); + bool smspec_node_init( smspec_node_type * smspec_node, + ecl_smspec_var_type var_type , + const char * wgname , + const char * keyword , + const char * unit , + const char * key_join_string , + const int grid_dims[3] , + int num); + smspec_node_type * smspec_node_alloc( ecl_smspec_var_type var_type , const char * wgname , @@ -87,6 +96,7 @@ typedef enum {ECL_SMSPEC_INVALID_VAR = 0 , int param_index, float default_value); + smspec_node_type * smspec_node_alloc_new(int params_index, float default_value); void smspec_node_free( smspec_node_type * index ); void smspec_node_free__(void * arg); @@ -100,11 +110,15 @@ typedef enum {ECL_SMSPEC_INVALID_VAR = 0 , void smspec_node_update_wgname( smspec_node_type * index , const char * wgname , const char * key_join_string); const char * smspec_node_get_keyword( const smspec_node_type * smspec_node); const char * smspec_node_get_unit( const smspec_node_type * smspec_node); + void smspec_node_set_unit( smspec_node_type * smspec_node , const char * unit ); bool smspec_node_is_rate( const smspec_node_type * smspec_node ); bool smspec_node_is_total( const smspec_node_type * smspec_node ); bool smspec_node_need_nums( const smspec_node_type * smspec_node ); - float smspec_node_get_default_value( const smspec_node_type * smspec_node ); void smspec_node_fprintf( const smspec_node_type * smspec_node , FILE * stream); + + void smspec_node_set_default( smspec_node_type * smspec_node , float default_value); + float smspec_node_get_default( const smspec_node_type * smspec_node); + #ifdef __cplusplus } diff --git a/ThirdParty/Ert-windows/include/thread_pool.h b/ThirdParty/Ert-windows/include/thread_pool.h index 0aa675360a..0f4fbe4e0a 100644 --- a/ThirdParty/Ert-windows/include/thread_pool.h +++ b/ThirdParty/Ert-windows/include/thread_pool.h @@ -18,8 +18,8 @@ #ifndef __THREAD_POOL_H__ #define __THREAD_POOL_H__ -#ifdef HAVE_PTHREAD -#define HAVE_THREAD_POOL +#ifdef WITH_PTHREAD +#define WITH_THREAD_POOL #include "thread_pool_posix.h" #endif diff --git a/ThirdParty/Ert-windows/include/util.h b/ThirdParty/Ert-windows/include/util.h index 671e99fd1e..063f8807dc 100644 --- a/ThirdParty/Ert-windows/include/util.h +++ b/ThirdParty/Ert-windows/include/util.h @@ -405,7 +405,7 @@ const char * util_enum_iget( int index , int size , const util_enum_element_type /*****************************************************************/ /* Conditional section below here */ -#ifdef HAVE_ZLIB +#ifdef WITH_ZLIB void util_compress_buffer(const void * , int , void * , unsigned long * ); int util_fread_sizeof_compressed(FILE * stream); void util_fread_compressed(void * , FILE * ); diff --git a/ThirdParty/Ert-windows/include/vector.h b/ThirdParty/Ert-windows/include/vector.h index 6a405858de..48394de0ea 100644 --- a/ThirdParty/Ert-windows/include/vector.h +++ b/ThirdParty/Ert-windows/include/vector.h @@ -23,60 +23,62 @@ extern "C" { #endif #include +#include -typedef void ( vector_func_type ) (void * , void *); -typedef int ( vector_cmp_ftype) (const void * , const void *); - -typedef struct vector_struct vector_type; + typedef void ( vector_func_type ) (void * , void *); + typedef int ( vector_cmp_ftype) (const void * , const void *); + + typedef struct vector_struct vector_type; + vector_type * vector_alloc_new(); + void vector_grow_NULL( vector_type * vector , int new_size ); + vector_type * vector_alloc_NULL_initialized( int size ); -vector_type * vector_alloc_new(); -vector_type * vector_alloc_NULL_initialized( int size ); - -int vector_append_ref( vector_type * , const void *); -int vector_append_owned_ref( vector_type * , const void * , free_ftype * del); -int vector_append_copy(vector_type * , const void *, copyc_ftype *, free_ftype *); - -void vector_iset_ref( vector_type * , int , const void *); -void vector_iset_owned_ref( vector_type * , int , const void * , free_ftype * del); -void vector_iset_copy(vector_type * , int , const void *, copyc_ftype *, free_ftype *); - -void vector_safe_iset_copy(vector_type * vector , int index , const void * data, copyc_ftype * copyc , free_ftype * del); -void vector_safe_iset_owned_ref(vector_type * vector , int index , const void * data, free_ftype * del); -void vector_safe_iset_ref(vector_type * vector , int index , const void * data); - -void vector_insert_ref( vector_type * , int , const void *); -void vector_insert_owned_ref( vector_type * , int , const void * , free_ftype * del); -void vector_insert_copy(vector_type * , int , const void *, copyc_ftype *, free_ftype *); -void vector_insert_buffer(vector_type * vector , int index , const void * buffer, int buffer_size); - -void vector_push_ref( vector_type * , const void *); -void vector_push_owned_ref( vector_type * , const void * , free_ftype * del); -void vector_push_copy(vector_type * , const void *, copyc_ftype *, free_ftype *); - - -void vector_clear(vector_type * vector); -void vector_free(vector_type * ); -void vector_free__( void * arg ); -void vector_append_buffer(vector_type * , const void * , int); -void vector_push_buffer(vector_type * , const void * , int); -int vector_get_size(const vector_type * ); -void * vector_safe_iget(const vector_type * vector, int index); -const void * vector_safe_iget_const(const vector_type * vector, int index); -const void * vector_iget_const(const vector_type * , int ); -void * vector_iget(const vector_type * , int ); -void vector_idel(vector_type * vector , int index); -void vector_shrink( vector_type * vector , int new_size ); -void * vector_get_last(const vector_type * ); -const void * vector_get_last_const(const vector_type * ); -int vector_get_size( const vector_type * ); -void * vector_pop(vector_type * ); -void vector_sort(vector_type * vector , vector_cmp_ftype * cmp); -vector_type * vector_alloc_copy(const vector_type * src , bool deep_copy); - -void vector_iset_buffer(vector_type * vector , int index , const void * buffer, int buffer_size); - + int vector_append_ref( vector_type * , const void *); + int vector_append_owned_ref( vector_type * , const void * , free_ftype * del); + int vector_append_copy(vector_type * , const void *, copyc_ftype *, free_ftype *); + + void vector_iset_ref( vector_type * , int , const void *); + void vector_iset_owned_ref( vector_type * , int , const void * , free_ftype * del); + void vector_iset_copy(vector_type * , int , const void *, copyc_ftype *, free_ftype *); + + void vector_safe_iset_copy(vector_type * vector , int index , const void * data, copyc_ftype * copyc , free_ftype * del); + void vector_safe_iset_owned_ref(vector_type * vector , int index , const void * data, free_ftype * del); + void vector_safe_iset_ref(vector_type * vector , int index , const void * data); + + void vector_insert_ref( vector_type * , int , const void *); + void vector_insert_owned_ref( vector_type * , int , const void * , free_ftype * del); + void vector_insert_copy(vector_type * , int , const void *, copyc_ftype *, free_ftype *); + void vector_insert_buffer(vector_type * vector , int index , const void * buffer, int buffer_size); + + void vector_push_ref( vector_type * , const void *); + void vector_push_owned_ref( vector_type * , const void * , free_ftype * del); + void vector_push_copy(vector_type * , const void *, copyc_ftype *, free_ftype *); + + + void vector_clear(vector_type * vector); + void vector_free(vector_type * ); + void vector_free__( void * arg ); + void vector_append_buffer(vector_type * , const void * , int); + void vector_push_buffer(vector_type * , const void * , int); + int vector_get_size(const vector_type * ); + void * vector_safe_iget(const vector_type * vector, int index); + const void * vector_safe_iget_const(const vector_type * vector, int index); + const void * vector_iget_const(const vector_type * , int ); + void * vector_iget(const vector_type * , int ); + void vector_idel(vector_type * vector , int index); + void vector_shrink( vector_type * vector , int new_size ); + void * vector_get_last(const vector_type * ); + const void * vector_get_last_const(const vector_type * ); + int vector_get_size( const vector_type * ); + void * vector_pop(vector_type * ); + void vector_sort(vector_type * vector , vector_cmp_ftype * cmp); + vector_type * vector_alloc_copy(const vector_type * src , bool deep_copy); + + void vector_iset_buffer(vector_type * vector , int index , const void * buffer, int buffer_size); + + UTIL_IS_INSTANCE_HEADER( vector ); #ifdef __cplusplus } diff --git a/ThirdParty/Ert-windows/lib/ecl.lib b/ThirdParty/Ert-windows/lib/ecl.lib index c28d666bb6..9eb1f76365 100644 Binary files a/ThirdParty/Ert-windows/lib/ecl.lib and b/ThirdParty/Ert-windows/lib/ecl.lib differ diff --git a/ThirdParty/Ert-windows/lib/ert_util.lib b/ThirdParty/Ert-windows/lib/ert_util.lib index 10c5ec611f..4d1c52646b 100644 Binary files a/ThirdParty/Ert-windows/lib/ert_util.lib and b/ThirdParty/Ert-windows/lib/ert_util.lib differ diff --git a/ThirdParty/Ert-windows/lib/geometry.lib b/ThirdParty/Ert-windows/lib/geometry.lib index 2345114eb3..482b2389af 100644 Binary files a/ThirdParty/Ert-windows/lib/geometry.lib and b/ThirdParty/Ert-windows/lib/geometry.lib differ diff --git a/ThirdParty/Ert-windows/lib/well.lib b/ThirdParty/Ert-windows/lib/well.lib index 3221c8ec64..cf9b2beb47 100644 Binary files a/ThirdParty/Ert-windows/lib/well.lib and b/ThirdParty/Ert-windows/lib/well.lib differ diff --git a/ThirdParty/Ert/include/buffer.h b/ThirdParty/Ert/include/buffer.h index b52a3b653d..7df53ca7d7 100644 --- a/ThirdParty/Ert/include/buffer.h +++ b/ThirdParty/Ert/include/buffer.h @@ -92,7 +92,7 @@ extern "C" { buffer_type * buffer_fread_alloc(const char * filename); void buffer_fread_realloc(buffer_type * buffer , const char * filename); -#ifdef HAVE_ZLIB +#ifdef WITH_ZLIB size_t buffer_fwrite_compressed(buffer_type * buffer, const void * ptr , size_t byte_size); size_t buffer_fread_compressed(buffer_type * buffer , size_t compressed_size , void * target_ptr , size_t target_size); #endif diff --git a/ThirdParty/Ert/include/ecl_grid.h b/ThirdParty/Ert/include/ecl_grid.h index c2a4cb358a..1405fbda00 100644 --- a/ThirdParty/Ert/include/ecl_grid.h +++ b/ThirdParty/Ert/include/ecl_grid.h @@ -61,11 +61,15 @@ extern "C" { bool ecl_grid_ijk_valid(const ecl_grid_type * , int , int , int ); int ecl_grid_get_global_index3(const ecl_grid_type * , int , int , int ); int ecl_grid_get_global_index1A(const ecl_grid_type * ecl_grid , int active_index); + ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz , const ecl_kw_type * zcorn_kw , const ecl_kw_type * coord_kw , const ecl_kw_type * actnum_kw , const ecl_kw_type * mapaxes_kw ); ecl_grid_type * ecl_grid_alloc_GRDECL_data(int , int , int , const float * , const float * , const int * , const float * mapaxes); ecl_grid_type * ecl_grid_alloc_GRID_data(int num_coords , int nx, int ny , int nz , int coords_size , int ** coords , float ** corners , const float * mapaxes); ecl_grid_type * ecl_grid_alloc(const char * ); ecl_grid_type * ecl_grid_load_case( const char * case_input ); + ecl_grid_type * ecl_grid_alloc_rectangular( int nx , int ny , int nz , double dx , double dy , double dz , const int * actnum); + ecl_grid_type * ecl_grid_alloc_regular( int nx, int ny , int nz , const double * ivec, const double * jvec , const double * kvec , const int * actnum); + bool ecl_grid_exists( const char * case_input ); char * ecl_grid_alloc_case_filename( const char * case_input ); @@ -148,6 +152,9 @@ extern "C" { ecl_kw_type * ecl_grid_alloc_hostnum_kw( const ecl_grid_type * grid ); ecl_kw_type * ecl_grid_alloc_gridhead_kw( int nx, int ny , int nz , int grid_nr); + void ecl_grid_ri_export( const ecl_grid_type * ecl_grid , double * ri_points); + void ecl_grid_cell_ri_export( const ecl_grid_type * ecl_grid , int global_index , double * ri_points); + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/include/ecl_kw.h b/ThirdParty/Ert/include/ecl_kw.h index f27ee05c40..986ff5eb38 100644 --- a/ThirdParty/Ert/include/ecl_kw.h +++ b/ThirdParty/Ert/include/ecl_kw.h @@ -103,9 +103,6 @@ extern "C" { bool ecl_kw_is_grdecl_file(FILE * ); bool ecl_kw_is_kw_file(FILE * , bool ); - void ecl_kw_inplace_sub(ecl_kw_type * , const ecl_kw_type * ); - void ecl_kw_inplace_mul(ecl_kw_type * , const ecl_kw_type * ); - void ecl_kw_inplace_div(ecl_kw_type * , const ecl_kw_type * ); double ecl_kw_element_sum_float( const ecl_kw_type * ecl_kw ); void ecl_kw_inplace_inv(ecl_kw_type * my_kw); @@ -113,8 +110,6 @@ extern "C" { void ecl_kw_max_min(const ecl_kw_type * , void * , void *); void * ecl_kw_get_void_ptr(const ecl_kw_type * ecl_kw); - double ecl_kw_iget_as_double(const ecl_kw_type * , int ); - ecl_kw_type * ecl_kw_buffer_alloc(buffer_type * buffer); void ecl_kw_buffer_store(const ecl_kw_type * ecl_kw , buffer_type * buffer); @@ -149,29 +144,29 @@ extern "C" { void ecl_kw_copy_indexed( ecl_kw_type * target_kw , const int_vector_type * index_set , const ecl_kw_type * src_kw); bool ecl_kw_assert_binary_numeric( const ecl_kw_type * kw1, const ecl_kw_type * kw2); -#define ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( ctype ) bool ecl_kw_assert_binary_ ## ctype( const ecl_kw_type * kw1 , const ecl_kw_type * kw2); - ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( int ) - ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( float ) - ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( double ) +#define ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( ctype ) bool ecl_kw_assert_binary_ ## ctype( const ecl_kw_type * kw1 , const ecl_kw_type * kw2) + ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( int ); + ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( float ); + ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( double ); #undef ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER -#define ECL_KW_SCALE_TYPED_HEADER( ctype ) void ecl_kw_scale_ ## ctype (ecl_kw_type * ecl_kw , ctype scale_factor); - ECL_KW_SCALE_TYPED_HEADER( int ) - ECL_KW_SCALE_TYPED_HEADER( float ) - ECL_KW_SCALE_TYPED_HEADER( double ) +#define ECL_KW_SCALE_TYPED_HEADER( ctype ) void ecl_kw_scale_ ## ctype (ecl_kw_type * ecl_kw , ctype scale_factor) + ECL_KW_SCALE_TYPED_HEADER( int ); + ECL_KW_SCALE_TYPED_HEADER( float ); + ECL_KW_SCALE_TYPED_HEADER( double ); #undef ECL_KW_SCALE_TYPED_HEADER void ecl_kw_scale_float_or_double( ecl_kw_type * ecl_kw , double scale_factor ); -#define ECL_KW_SHIFT_TYPED_HEADER( ctype ) void ecl_kw_shift_ ## ctype (ecl_kw_type * ecl_kw , ctype shift_factor); - ECL_KW_SHIFT_TYPED_HEADER( int ) - ECL_KW_SHIFT_TYPED_HEADER( float ) - ECL_KW_SHIFT_TYPED_HEADER( double ) +#define ECL_KW_SHIFT_TYPED_HEADER( ctype ) void ecl_kw_shift_ ## ctype (ecl_kw_type * ecl_kw , ctype shift_factor) + ECL_KW_SHIFT_TYPED_HEADER( int ); + ECL_KW_SHIFT_TYPED_HEADER( float ); + ECL_KW_SHIFT_TYPED_HEADER( double ); #undef ECL_KW_SHIFT_TYPED_HEADER void ecl_kw_shift_float_or_double( ecl_kw_type * ecl_kw , double shift_value ); -#define ECL_KW_IGET_TYPED_HEADER(type) type ecl_kw_iget_ ## type(const ecl_kw_type * , int); +#define ECL_KW_IGET_TYPED_HEADER(type) type ecl_kw_iget_ ## type(const ecl_kw_type * , int) ECL_KW_IGET_TYPED_HEADER(double); ECL_KW_IGET_TYPED_HEADER(float); ECL_KW_IGET_TYPED_HEADER(int); @@ -179,7 +174,7 @@ extern "C" { bool ecl_kw_iget_bool( const ecl_kw_type * ecl_kw , int i ); -#define ECL_KW_ISET_TYPED_HEADER(type) void ecl_kw_iset_ ## type(ecl_kw_type * , int , type ); +#define ECL_KW_ISET_TYPED_HEADER(type) void ecl_kw_iset_ ## type(ecl_kw_type * , int , type ) ECL_KW_ISET_TYPED_HEADER(double); ECL_KW_ISET_TYPED_HEADER(float); ECL_KW_ISET_TYPED_HEADER(int); @@ -187,7 +182,7 @@ extern "C" { void ecl_kw_iset_bool( ecl_kw_type * ecl_kw , int i , bool bool_value); -#define ECL_KW_GET_TYPED_PTR_HEADER(type) type * ecl_kw_get_ ## type ## _ptr(const ecl_kw_type *); +#define ECL_KW_GET_TYPED_PTR_HEADER(type) type * ecl_kw_get_ ## type ## _ptr(const ecl_kw_type *) ECL_KW_GET_TYPED_PTR_HEADER(double); ECL_KW_GET_TYPED_PTR_HEADER(float); ECL_KW_GET_TYPED_PTR_HEADER(int); @@ -195,31 +190,31 @@ extern "C" { #undef ECL_KW_GET_TYPED_PTR_HEADER -#define ECL_KW_SET_INDEXED_HEADER(ctype ) void ecl_kw_set_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype value); +#define ECL_KW_SET_INDEXED_HEADER(ctype ) void ecl_kw_set_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype value) ECL_KW_SET_INDEXED_HEADER( double ); ECL_KW_SET_INDEXED_HEADER( float ); ECL_KW_SET_INDEXED_HEADER( int ); #undef ECL_KW_SET_INDEXED_HEADER -#define ECL_KW_SHIFT_INDEXED_HEADER(ctype) void ecl_kw_shift_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype shift); - ECL_KW_SHIFT_INDEXED_HEADER( int ) - ECL_KW_SHIFT_INDEXED_HEADER( float ) - ECL_KW_SHIFT_INDEXED_HEADER( double ) +#define ECL_KW_SHIFT_INDEXED_HEADER(ctype) void ecl_kw_shift_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype shift) + ECL_KW_SHIFT_INDEXED_HEADER( int ); + ECL_KW_SHIFT_INDEXED_HEADER( float ); + ECL_KW_SHIFT_INDEXED_HEADER( double ); #undef ECL_KW_SHIFT_INDEXED_HEADER -#define ECL_KW_SCALE_INDEXED_HEADER(ctype) void ecl_kw_scale_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype scale); - ECL_KW_SCALE_INDEXED_HEADER( int ) - ECL_KW_SCALE_INDEXED_HEADER( float ) - ECL_KW_SCALE_INDEXED_HEADER( double ) +#define ECL_KW_SCALE_INDEXED_HEADER(ctype) void ecl_kw_scale_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype scale) + ECL_KW_SCALE_INDEXED_HEADER( int ); + ECL_KW_SCALE_INDEXED_HEADER( float ); + ECL_KW_SCALE_INDEXED_HEADER( double ); #undef ECL_KW_SCALE_INDEXED_HEADER -#define ECL_KW_MAX_MIN_HEADER( ctype ) void ecl_kw_max_min_ ## ctype( const ecl_kw_type * ecl_kw , ctype * _max , ctype * _min); - ECL_KW_MAX_MIN_HEADER( int ) - ECL_KW_MAX_MIN_HEADER( float ) - ECL_KW_MAX_MIN_HEADER( double ) +#define ECL_KW_MAX_MIN_HEADER( ctype ) void ecl_kw_max_min_ ## ctype( const ecl_kw_type * ecl_kw , ctype * _max , ctype * _min) + ECL_KW_MAX_MIN_HEADER( int ); + ECL_KW_MAX_MIN_HEADER( float ); + ECL_KW_MAX_MIN_HEADER( double ); #undef ECL_KW_MAX_MIN_HEADER #include diff --git a/ThirdParty/Ert/include/ecl_kw_magic.h b/ThirdParty/Ert/include/ecl_kw_magic.h index d6453617b0..d47790820e 100644 --- a/ThirdParty/Ert/include/ecl_kw_magic.h +++ b/ThirdParty/Ert/include/ecl_kw_magic.h @@ -255,6 +255,9 @@ extern "C" { /* Common keywords */ #define SPECGRID_KW "SPECGRID" +#define SPECGRID_NX_INDEX 0 +#define SPECGRID_NY_INDEX 1 +#define SPECGRID_NZ_INDEX 2 #define MAPAXES_KW "MAPAXES" /* Keyword used to transform from grid coordinates to world coordinates. */ #define LGR_KW "LGR" /* Name of LGR; for GRID files it can contain two elements, diff --git a/ThirdParty/Ert/include/ecl_smspec.h b/ThirdParty/Ert/include/ecl_smspec.h index 1c122094e5..20046b3595 100644 --- a/ThirdParty/Ert/include/ecl_smspec.h +++ b/ThirdParty/Ert/include/ecl_smspec.h @@ -44,8 +44,9 @@ typedef struct ecl_smspec_struct ecl_smspec_type; ecl_smspec_install_gen_key() must be updated. */ const int_vector_type * ecl_smspec_get_index_map( const ecl_smspec_type * smspec ); - - void ecl_smspec_add_node(ecl_smspec_type * ecl_smspec, smspec_node_type * smspec_node); + void ecl_smspec_index_node( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node); + void ecl_smspec_insert_node(ecl_smspec_type * ecl_smspec, smspec_node_type * smspec_node); + void ecl_smspec_add_node( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node ); ecl_smspec_var_type ecl_smspec_iget_var_type( const ecl_smspec_type * smspec , int index ); bool ecl_smspec_needs_num( ecl_smspec_var_type var_type ); bool ecl_smspec_needs_wgname( ecl_smspec_var_type var_type ); @@ -112,7 +113,7 @@ typedef struct ecl_smspec_struct ecl_smspec_type; - + void ecl_smspec_init_var( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node , const char * keyword , const char * wgname , int num, const char * unit ); void ecl_smspec_select_matching_general_var_list( const ecl_smspec_type * smspec , const char * pattern , stringlist_type * keys); stringlist_type * ecl_smspec_alloc_matching_general_var_list(const ecl_smspec_type * smspec , const char * pattern); diff --git a/ThirdParty/Ert/include/ecl_sum.h b/ThirdParty/Ert/include/ecl_sum.h index f336ceb3db..c575b85ae7 100644 --- a/ThirdParty/Ert/include/ecl_sum.h +++ b/ThirdParty/Ert/include/ecl_sum.h @@ -173,6 +173,8 @@ typedef struct ecl_sum_struct ecl_sum_type; void ecl_sum_fwrite( const ecl_sum_type * ecl_sum ); void ecl_sum_fwrite_smspec( const ecl_sum_type * ecl_sum ); smspec_node_type * ecl_sum_add_var( ecl_sum_type * ecl_sum , const char * keyword , const char * wgname , int num , const char * unit , float default_value); + smspec_node_type * ecl_sum_add_blank_var( ecl_sum_type * ecl_sum , float default_value); + void ecl_sum_init_var( ecl_sum_type * ecl_sum , smspec_node_type * smspec_node , const char * keyword , const char * wgname , int num , const char * unit); ecl_sum_tstep_type * ecl_sum_add_tstep( ecl_sum_type * ecl_sum , int report_step , double sim_days); void ecl_sum_update_wgname( ecl_sum_type * ecl_sum , smspec_node_type * node , const char * wgname ); diff --git a/ThirdParty/Ert/include/matrix.h b/ThirdParty/Ert/include/matrix.h index f71c1cec86..a44fd96866 100644 --- a/ThirdParty/Ert/include/matrix.h +++ b/ThirdParty/Ert/include/matrix.h @@ -131,6 +131,7 @@ typedef struct matrix_struct matrix_type; double matrix_trace(const matrix_type *matrix); double matrix_diag_std(const matrix_type * Sk,double mean); double matrix_det3( const matrix_type * A); + double matrix_det4( const matrix_type * A); #ifdef HAVE_ISFINITE bool matrix_is_finite(const matrix_type * matrix); diff --git a/ThirdParty/Ert/include/path_fmt.h b/ThirdParty/Ert/include/path_fmt.h index 6440e49268..fc913fef86 100644 --- a/ThirdParty/Ert/include/path_fmt.h +++ b/ThirdParty/Ert/include/path_fmt.h @@ -25,22 +25,21 @@ extern "C" { #include #include -typedef struct path_fmt_struct path_fmt_type; - - -path_fmt_type * path_fmt_safe_cast(const void * arg); -path_fmt_type * path_fmt_alloc_directory_fmt(const char * ); -path_fmt_type * path_fmt_alloc_path_fmt(const char * ); -path_fmt_type * path_fmt_copyc(const path_fmt_type *); -path_fmt_type * path_fmt_scanf_alloc(const char * , int , const node_ctype * , bool ); -char * path_fmt_alloc_path(const path_fmt_type * , bool , ...); -char * path_fmt_alloc_file(const path_fmt_type * , bool , ...); -void path_fmt_free(path_fmt_type * ); -const char * path_fmt_get_fmt(const path_fmt_type * ); -void path_fmt_reset_fmt(path_fmt_type * , const char * ); -void path_fmt_make_path(const path_fmt_type * ); -path_fmt_type * path_fmt_realloc_path_fmt( path_fmt_type * path_fmt, const char * fmt ); - + typedef struct path_fmt_struct path_fmt_type; + + path_fmt_type * path_fmt_alloc_directory_fmt(const char * ); + path_fmt_type * path_fmt_alloc_path_fmt(const char * ); + path_fmt_type * path_fmt_copyc(const path_fmt_type *); + path_fmt_type * path_fmt_scanf_alloc(const char * , int , const node_ctype * , bool ); + char * path_fmt_alloc_path(const path_fmt_type * , bool , ...); + char * path_fmt_alloc_file(const path_fmt_type * , bool , ...); + void path_fmt_free(path_fmt_type * ); + void path_fmt_free__( void * arg ); + const char * path_fmt_get_fmt(const path_fmt_type * ); + void path_fmt_reset_fmt(path_fmt_type * , const char * ); + void path_fmt_make_path(const path_fmt_type * ); + path_fmt_type * path_fmt_realloc_path_fmt( path_fmt_type * path_fmt, const char * fmt ); + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/include/smspec_node.h b/ThirdParty/Ert/include/smspec_node.h index f5c498fce3..cd5ec9a3b1 100644 --- a/ThirdParty/Ert/include/smspec_node.h +++ b/ThirdParty/Ert/include/smspec_node.h @@ -68,6 +68,15 @@ typedef enum {ECL_SMSPEC_INVALID_VAR = 0 , char * smspec_alloc_local_completion_key( const char * join_string, const char * keyword , const char * lgr_name , const char * wgname , int i , int j , int k); + bool smspec_node_init( smspec_node_type * smspec_node, + ecl_smspec_var_type var_type , + const char * wgname , + const char * keyword , + const char * unit , + const char * key_join_string , + const int grid_dims[3] , + int num); + smspec_node_type * smspec_node_alloc( ecl_smspec_var_type var_type , const char * wgname , @@ -87,6 +96,7 @@ typedef enum {ECL_SMSPEC_INVALID_VAR = 0 , int param_index, float default_value); + smspec_node_type * smspec_node_alloc_new(int params_index, float default_value); void smspec_node_free( smspec_node_type * index ); void smspec_node_free__(void * arg); @@ -100,11 +110,15 @@ typedef enum {ECL_SMSPEC_INVALID_VAR = 0 , void smspec_node_update_wgname( smspec_node_type * index , const char * wgname , const char * key_join_string); const char * smspec_node_get_keyword( const smspec_node_type * smspec_node); const char * smspec_node_get_unit( const smspec_node_type * smspec_node); + void smspec_node_set_unit( smspec_node_type * smspec_node , const char * unit ); bool smspec_node_is_rate( const smspec_node_type * smspec_node ); bool smspec_node_is_total( const smspec_node_type * smspec_node ); bool smspec_node_need_nums( const smspec_node_type * smspec_node ); - float smspec_node_get_default_value( const smspec_node_type * smspec_node ); void smspec_node_fprintf( const smspec_node_type * smspec_node , FILE * stream); + + void smspec_node_set_default( smspec_node_type * smspec_node , float default_value); + float smspec_node_get_default( const smspec_node_type * smspec_node); + #ifdef __cplusplus } diff --git a/ThirdParty/Ert/include/thread_pool.h b/ThirdParty/Ert/include/thread_pool.h index 0aa675360a..0f4fbe4e0a 100644 --- a/ThirdParty/Ert/include/thread_pool.h +++ b/ThirdParty/Ert/include/thread_pool.h @@ -18,8 +18,8 @@ #ifndef __THREAD_POOL_H__ #define __THREAD_POOL_H__ -#ifdef HAVE_PTHREAD -#define HAVE_THREAD_POOL +#ifdef WITH_PTHREAD +#define WITH_THREAD_POOL #include "thread_pool_posix.h" #endif diff --git a/ThirdParty/Ert/include/util.h b/ThirdParty/Ert/include/util.h index 671e99fd1e..063f8807dc 100644 --- a/ThirdParty/Ert/include/util.h +++ b/ThirdParty/Ert/include/util.h @@ -405,7 +405,7 @@ const char * util_enum_iget( int index , int size , const util_enum_element_type /*****************************************************************/ /* Conditional section below here */ -#ifdef HAVE_ZLIB +#ifdef WITH_ZLIB void util_compress_buffer(const void * , int , void * , unsigned long * ); int util_fread_sizeof_compressed(FILE * stream); void util_fread_compressed(void * , FILE * ); diff --git a/ThirdParty/Ert/include/vector.h b/ThirdParty/Ert/include/vector.h index 6a405858de..48394de0ea 100644 --- a/ThirdParty/Ert/include/vector.h +++ b/ThirdParty/Ert/include/vector.h @@ -23,60 +23,62 @@ extern "C" { #endif #include +#include -typedef void ( vector_func_type ) (void * , void *); -typedef int ( vector_cmp_ftype) (const void * , const void *); - -typedef struct vector_struct vector_type; + typedef void ( vector_func_type ) (void * , void *); + typedef int ( vector_cmp_ftype) (const void * , const void *); + + typedef struct vector_struct vector_type; + vector_type * vector_alloc_new(); + void vector_grow_NULL( vector_type * vector , int new_size ); + vector_type * vector_alloc_NULL_initialized( int size ); -vector_type * vector_alloc_new(); -vector_type * vector_alloc_NULL_initialized( int size ); - -int vector_append_ref( vector_type * , const void *); -int vector_append_owned_ref( vector_type * , const void * , free_ftype * del); -int vector_append_copy(vector_type * , const void *, copyc_ftype *, free_ftype *); - -void vector_iset_ref( vector_type * , int , const void *); -void vector_iset_owned_ref( vector_type * , int , const void * , free_ftype * del); -void vector_iset_copy(vector_type * , int , const void *, copyc_ftype *, free_ftype *); - -void vector_safe_iset_copy(vector_type * vector , int index , const void * data, copyc_ftype * copyc , free_ftype * del); -void vector_safe_iset_owned_ref(vector_type * vector , int index , const void * data, free_ftype * del); -void vector_safe_iset_ref(vector_type * vector , int index , const void * data); - -void vector_insert_ref( vector_type * , int , const void *); -void vector_insert_owned_ref( vector_type * , int , const void * , free_ftype * del); -void vector_insert_copy(vector_type * , int , const void *, copyc_ftype *, free_ftype *); -void vector_insert_buffer(vector_type * vector , int index , const void * buffer, int buffer_size); - -void vector_push_ref( vector_type * , const void *); -void vector_push_owned_ref( vector_type * , const void * , free_ftype * del); -void vector_push_copy(vector_type * , const void *, copyc_ftype *, free_ftype *); - - -void vector_clear(vector_type * vector); -void vector_free(vector_type * ); -void vector_free__( void * arg ); -void vector_append_buffer(vector_type * , const void * , int); -void vector_push_buffer(vector_type * , const void * , int); -int vector_get_size(const vector_type * ); -void * vector_safe_iget(const vector_type * vector, int index); -const void * vector_safe_iget_const(const vector_type * vector, int index); -const void * vector_iget_const(const vector_type * , int ); -void * vector_iget(const vector_type * , int ); -void vector_idel(vector_type * vector , int index); -void vector_shrink( vector_type * vector , int new_size ); -void * vector_get_last(const vector_type * ); -const void * vector_get_last_const(const vector_type * ); -int vector_get_size( const vector_type * ); -void * vector_pop(vector_type * ); -void vector_sort(vector_type * vector , vector_cmp_ftype * cmp); -vector_type * vector_alloc_copy(const vector_type * src , bool deep_copy); - -void vector_iset_buffer(vector_type * vector , int index , const void * buffer, int buffer_size); - + int vector_append_ref( vector_type * , const void *); + int vector_append_owned_ref( vector_type * , const void * , free_ftype * del); + int vector_append_copy(vector_type * , const void *, copyc_ftype *, free_ftype *); + + void vector_iset_ref( vector_type * , int , const void *); + void vector_iset_owned_ref( vector_type * , int , const void * , free_ftype * del); + void vector_iset_copy(vector_type * , int , const void *, copyc_ftype *, free_ftype *); + + void vector_safe_iset_copy(vector_type * vector , int index , const void * data, copyc_ftype * copyc , free_ftype * del); + void vector_safe_iset_owned_ref(vector_type * vector , int index , const void * data, free_ftype * del); + void vector_safe_iset_ref(vector_type * vector , int index , const void * data); + + void vector_insert_ref( vector_type * , int , const void *); + void vector_insert_owned_ref( vector_type * , int , const void * , free_ftype * del); + void vector_insert_copy(vector_type * , int , const void *, copyc_ftype *, free_ftype *); + void vector_insert_buffer(vector_type * vector , int index , const void * buffer, int buffer_size); + + void vector_push_ref( vector_type * , const void *); + void vector_push_owned_ref( vector_type * , const void * , free_ftype * del); + void vector_push_copy(vector_type * , const void *, copyc_ftype *, free_ftype *); + + + void vector_clear(vector_type * vector); + void vector_free(vector_type * ); + void vector_free__( void * arg ); + void vector_append_buffer(vector_type * , const void * , int); + void vector_push_buffer(vector_type * , const void * , int); + int vector_get_size(const vector_type * ); + void * vector_safe_iget(const vector_type * vector, int index); + const void * vector_safe_iget_const(const vector_type * vector, int index); + const void * vector_iget_const(const vector_type * , int ); + void * vector_iget(const vector_type * , int ); + void vector_idel(vector_type * vector , int index); + void vector_shrink( vector_type * vector , int new_size ); + void * vector_get_last(const vector_type * ); + const void * vector_get_last_const(const vector_type * ); + int vector_get_size( const vector_type * ); + void * vector_pop(vector_type * ); + void vector_sort(vector_type * vector , vector_cmp_ftype * cmp); + vector_type * vector_alloc_copy(const vector_type * src , bool deep_copy); + + void vector_iset_buffer(vector_type * vector , int index , const void * buffer, int buffer_size); + + UTIL_IS_INSTANCE_HEADER( vector ); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/lib/libecl.a b/ThirdParty/Ert/lib/libecl.a index 87bd0c00dd..1281acdf57 100644 Binary files a/ThirdParty/Ert/lib/libecl.a and b/ThirdParty/Ert/lib/libecl.a differ diff --git a/ThirdParty/Ert/lib/libert_util.a b/ThirdParty/Ert/lib/libert_util.a index de743cbf4f..580d10de7e 100644 Binary files a/ThirdParty/Ert/lib/libert_util.a and b/ThirdParty/Ert/lib/libert_util.a differ diff --git a/ThirdParty/Ert/lib/libgeometry.a b/ThirdParty/Ert/lib/libgeometry.a index fa6a75847e..16a07a98cb 100644 Binary files a/ThirdParty/Ert/lib/libgeometry.a and b/ThirdParty/Ert/lib/libgeometry.a differ diff --git a/ThirdParty/Ert/lib/libwell.a b/ThirdParty/Ert/lib/libwell.a index 790c7ee565..a9c3f210c0 100644 Binary files a/ThirdParty/Ert/lib/libwell.a and b/ThirdParty/Ert/lib/libwell.a differ diff --git a/VisualizationModules/LibRender/cvfScalarMapperRangeBased.cpp b/VisualizationModules/LibRender/cvfScalarMapperRangeBased.cpp index 890a19112c..5110300155 100644 --- a/VisualizationModules/LibRender/cvfScalarMapperRangeBased.cpp +++ b/VisualizationModules/LibRender/cvfScalarMapperRangeBased.cpp @@ -37,7 +37,8 @@ ScalarMapperRangeBased::ScalarMapperRangeBased() m_rangeMax(cvf::UNDEFINED_DOUBLE), m_decadeLevelCount(1), m_levelCount(8), - m_textureSize(2048) // Large enough, I guess and a power of two + m_textureSize(2048), // Large enough, I guess and a power of two + m_adjustLevels(true) { m_colors.resize(m_textureSize); m_colors.setAll(Color3ub::WHITE); diff --git a/cafAnimControl/cafAnimationToolBar.cpp b/cafAnimControl/cafAnimationToolBar.cpp index 8133354dfa..299995d501 100644 --- a/cafAnimControl/cafAnimationToolBar.cpp +++ b/cafAnimControl/cafAnimationToolBar.cpp @@ -99,7 +99,7 @@ void AnimationToolBar::init() addAction(m_animSkipToStartAction); addAction(m_animStepBackwardAction); addAction(m_animPlayBwdAction ); - addAction(m_animStopAction); + //addAction(m_animStopAction); addAction(m_animPauseAction); addAction(m_animPlayAction); addAction(m_animStepForwardAction); diff --git a/cafUserInterface/CMakeLists.txt b/cafUserInterface/CMakeLists.txt index 3b31a74508..b35796a516 100644 --- a/cafUserInterface/CMakeLists.txt +++ b/cafUserInterface/CMakeLists.txt @@ -19,6 +19,8 @@ set( QOBJECT_HEADERS cafPdmUiFilePathEditor.h cafPdmUiListEditor.h cafPdmUiSliderEditor.h + cafPdmUiDoubleSliderEditor.h + cafPdmUiColorEditor.h cafPdmUiPropertyView.h @@ -43,6 +45,7 @@ add_library( ${PROJECT_NAME} cafPdmUiFilePathEditor.cpp cafPdmUiListEditor.cpp cafPdmUiSliderEditor.cpp + cafPdmUiDoubleSliderEditor.cpp cafPdmUiColorEditor.cpp cafPdmUiPropertyView.cpp diff --git a/cafUserInterface/cafPdmUiCheckBoxEditor.cpp b/cafUserInterface/cafPdmUiCheckBoxEditor.cpp index 755ec4842b..50447083da 100644 --- a/cafUserInterface/cafPdmUiCheckBoxEditor.cpp +++ b/cafUserInterface/cafPdmUiCheckBoxEditor.cpp @@ -57,6 +57,7 @@ void PdmUiCheckBoxEditor::configureAndUpdateUi(const QString& uiConfigName) m_label->setVisible(!field()->isUiHidden(uiConfigName)); m_label->setEnabled(!field()->isUiReadOnly(uiConfigName)); + m_label->setToolTip(field()->uiToolTip(uiConfigName)); m_checkBox->setEnabled(!field()->isUiReadOnly(uiConfigName)); diff --git a/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp b/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp new file mode 100644 index 0000000000..15b632237b --- /dev/null +++ b/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp @@ -0,0 +1,218 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2012 Ceetron AS +// +// This library 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. +// +// This library 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 <> +// for more details. +// +//################################################################################################## + +#include "cafPdmUiDoubleSliderEditor.h" + +#include "cafPdmUiDefaultObjectEditor.h" +#include "cafPdmObject.h" +#include "cafPdmUiFieldEditorHandle.h" +#include "cafPdmField.h" + +#include "cafFactory.h" + +#include +#include +#include +#include + +#include + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class PdmDoubleValidator : public QDoubleValidator +{ +public: + PdmDoubleValidator(QObject * parent = 0) : QDoubleValidator(parent) + { + } + + PdmDoubleValidator(double bottom, double top, int decimals, QObject * parent) + : QDoubleValidator(bottom, top, decimals, parent) + { + } + + ~PdmDoubleValidator() + { + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + virtual void fixup(QString& stringValue) const + { + double doubleValue = stringValue.toDouble(); + doubleValue = qBound(bottom(), doubleValue, top()); + + stringValue = QString::number(doubleValue, 'g', decimals()); + } +}; + +namespace caf +{ + +CAF_PDM_UI_FIELD_EDITOR_SOURCE_INIT(PdmUiDoubleSliderEditor); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiDoubleSliderEditor::configureAndUpdateUi(const QString& uiConfigName) +{ + assert(!m_lineEdit.isNull()); + + QIcon ic = field()->uiIcon(uiConfigName); + if (!ic.isNull()) + { + m_label->setPixmap(ic.pixmap(ic.actualSize(QSize(64, 64)))); + } + else + { + m_label->setText(field()->uiName(uiConfigName)); + } + + m_label->setVisible(!field()->isUiHidden(uiConfigName)); + m_label->setEnabled(!field()->isUiReadOnly(uiConfigName)); + + m_lineEdit->setEnabled(!field()->isUiReadOnly(uiConfigName)); + m_slider->setEnabled(!field()->isUiReadOnly(uiConfigName)); + + field()->ownerObject()->editorAttribute(field(), uiConfigName, &m_attributes); + + PdmDoubleValidator* pdmValidator = new PdmDoubleValidator(m_attributes.m_minimum, m_attributes.m_maximum, m_attributes.m_decimals, this); + m_lineEdit->setValidator(pdmValidator); + + QString textValue = field()->uiValue().toString(); + pdmValidator->fixup(textValue); + + m_lineEdit->setText(textValue); + updateSliderPosition(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* PdmUiDoubleSliderEditor::createEditorWidget(QWidget * parent) +{ + QWidget* containerWidget = new QWidget(parent); + + QHBoxLayout* layout = new QHBoxLayout(); + layout->setMargin(0); + containerWidget->setLayout(layout); + + m_lineEdit = new QLineEdit(containerWidget); + m_lineEdit->setMaximumWidth(100); + connect(m_lineEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished())); + + m_slider = new QSlider(Qt::Horizontal, containerWidget); + layout->addWidget(m_lineEdit); + layout->addWidget(m_slider); + + connect(m_slider, SIGNAL(valueChanged(int)), this, SLOT(slotSliderValueChanged(int))); + + return containerWidget; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* PdmUiDoubleSliderEditor::createLabelWidget(QWidget * parent) +{ + m_label = new QLabel(parent); + return m_label; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiDoubleSliderEditor::slotEditingFinished() +{ + updateSliderPosition(); + + writeValueToField(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiDoubleSliderEditor::slotSliderValueChanged(int value) +{ + double newDoubleValue = convertFromSliderValue(value); + m_lineEdit->setText(QString::number(newDoubleValue)); + + writeValueToField(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiDoubleSliderEditor::updateSliderPosition() +{ + QString textValue = m_lineEdit->text(); + + bool convertOk = false; + double newSliderValue = textValue.toDouble(&convertOk); + + int newSliderPosition = convertToSliderValue(newSliderValue); + if (m_slider->value() != newSliderPosition) + { + m_slider->blockSignals(true); + m_slider->setValue(newSliderPosition); + m_slider->blockSignals(false); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiDoubleSliderEditor::writeValueToField() +{ + QString textValue = m_lineEdit->text(); + QVariant v; + v = textValue; + this->setValueToField(v); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int PdmUiDoubleSliderEditor::convertToSliderValue(double value) +{ + double exactSliderValue = m_slider->maximum() * (value - m_attributes.m_minimum) / (m_attributes.m_maximum - m_attributes.m_minimum); + + int sliderValue = static_cast(exactSliderValue); + sliderValue = qBound(m_slider->minimum(), sliderValue, m_slider->maximum()); + + return sliderValue; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double PdmUiDoubleSliderEditor::convertFromSliderValue(int sliderValue) +{ + double newDoubleValue = m_attributes.m_minimum + sliderValue * (m_attributes.m_maximum - m_attributes.m_minimum) / m_slider->maximum(); + newDoubleValue = qBound(m_attributes.m_minimum, newDoubleValue, m_attributes.m_maximum); + + return newDoubleValue; +} + + +} // end namespace caf diff --git a/cafUserInterface/cafPdmUiDoubleSliderEditor.h b/cafUserInterface/cafPdmUiDoubleSliderEditor.h new file mode 100644 index 0000000000..3e4d489e1a --- /dev/null +++ b/cafUserInterface/cafPdmUiDoubleSliderEditor.h @@ -0,0 +1,90 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2012 Ceetron AS +// +// This library 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. +// +// This library 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 <> +// for more details. +// +//################################################################################################## + +#pragma once +#include "cafPdmUiFieldEditorHandle.h" + +#include +#include +#include +#include +#include +#include +#include + + +namespace caf +{ + +//================================================================================================== +/// +//================================================================================================== + +class PdmUiDoubleSliderEditorAttribute : public PdmUiEditorAttribute +{ +public: + PdmUiDoubleSliderEditorAttribute() + { + m_minimum = 0; + m_maximum = 10; + m_decimals = 6; + } + +public: + double m_minimum; + double m_maximum; + int m_decimals; +}; + + +class PdmUiDoubleSliderEditor : public PdmUiFieldEditorHandle +{ + Q_OBJECT + CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT; + +public: + PdmUiDoubleSliderEditor() {} + virtual ~PdmUiDoubleSliderEditor() {} + +protected: + virtual void configureAndUpdateUi(const QString& uiConfigName); + virtual QWidget* createEditorWidget(QWidget * parent); + virtual QWidget* createLabelWidget(QWidget * parent); + +protected slots: + void slotEditingFinished(); + void slotSliderValueChanged(int value); + +private: + void updateSliderPosition(); + void writeValueToField(); + + int convertToSliderValue(double value); + double convertFromSliderValue(int sliderValue); + +private: + QPointer m_lineEdit; + QPointer m_slider; + QPointer m_label; + + PdmUiDoubleSliderEditorAttribute m_attributes; +}; + + +} // end namespace caf diff --git a/cafUserInterface/cafPdmUiFilePathEditor.cpp b/cafUserInterface/cafPdmUiFilePathEditor.cpp index 408fde660a..c6e581b718 100644 --- a/cafUserInterface/cafPdmUiFilePathEditor.cpp +++ b/cafUserInterface/cafPdmUiFilePathEditor.cpp @@ -122,11 +122,21 @@ void PdmUiFilePathEditor::slotEditingFinished() //-------------------------------------------------------------------------------------------------- void PdmUiFilePathEditor::fileSelectionClicked() { + QString defaultPath; + if ( m_lineEdit->text().isEmpty()) + { + defaultPath = QDir::homePath(); + } + else + { + defaultPath = m_lineEdit->text(); + } + if (m_attributes.m_selectDirectory) { QString directoryPath = QFileDialog::getExistingDirectory(m_lineEdit, tr("Get existing directory"), - m_lineEdit->text(), + defaultPath, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); if (!directoryPath.isEmpty()) @@ -140,11 +150,11 @@ void PdmUiFilePathEditor::fileSelectionClicked() QString filePath; if (m_attributes.m_selectSaveFileName) { - filePath = QFileDialog::getSaveFileName(m_lineEdit, tr("Save File"), m_lineEdit->text(), m_attributes.m_fileSelectionFilter); + filePath = QFileDialog::getSaveFileName(m_lineEdit, tr("Save File"), defaultPath, m_attributes.m_fileSelectionFilter); } else { - filePath = QFileDialog::getOpenFileName(m_lineEdit, tr("Choose a file"), m_lineEdit->text(), m_attributes.m_fileSelectionFilter); + filePath = QFileDialog::getOpenFileName(m_lineEdit, tr("Choose a file"), defaultPath, m_attributes.m_fileSelectionFilter); } if (!filePath.isEmpty()) diff --git a/cafUserInterface/cafProgressInfo.cpp b/cafUserInterface/cafProgressInfo.cpp index f5e966aa0b..19decafe5b 100644 --- a/cafUserInterface/cafProgressInfo.cpp +++ b/cafUserInterface/cafProgressInfo.cpp @@ -263,6 +263,8 @@ static bool isWrongThread() //-------------------------------------------------------------------------------------------------- void ProgressInfoStatic::start(int maxProgressValue, const QString& title) { + if (!qApp) return; + if (isWrongThread()) return; if (!maxProgressStack().size()) diff --git a/cafUserInterface/cafUiTreeModelPdm.cpp b/cafUserInterface/cafUiTreeModelPdm.cpp index a5b50632d0..f9bc0a315e 100644 --- a/cafUserInterface/cafUiTreeModelPdm.cpp +++ b/cafUserInterface/cafUiTreeModelPdm.cpp @@ -315,7 +315,17 @@ bool UiTreeModelPdm::removeRows(int position, int rows, const QModelIndex &paren { if (rows <= 0) return true; - PdmUiTreeItem* parentItem = getTreeItemFromIndex(parent); + PdmUiTreeItem* parentItem = NULL; + if (parent.isValid()) + { + parentItem = getTreeItemFromIndex(parent); + } + else + { + parentItem = m_root; + } + + if (!parentItem) return true; bool success = true;