Skip to content

Commit 27d8808

Browse files
author
Magne Sjaastad
committed
Version 0.8.6
1 parent 651d908 commit 27d8808

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+621
-174
lines changed

ApplicationCode/Application/RIApplication.cpp

+50-20
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ bool RIApplication::closeProject(bool askToSaveIfDirty)
331331
{
332332
RIMainWindow* mainWnd = RIMainWindow::instance();
333333

334+
terminateProcess();
335+
334336
if (false)
335337
{
336338
QMessageBox msgBox(mainWnd);
@@ -353,7 +355,7 @@ bool RIApplication::closeProject(bool askToSaveIfDirty)
353355

354356
mainWnd->cleanupGuiBeforeProjectClose();
355357

356-
caf::EffectCache::instance()->clear();
358+
caf::EffectGenerator::clearEffectCache();
357359
m_project->close();
358360

359361
onProjectOpenedOrClosed();
@@ -417,16 +419,19 @@ bool RIApplication::openEclipseCase(const QString& caseName, const QString& case
417419

418420
RimReservoirView* riv = rimResultReservoir->createAndAddReservoirView();
419421

420-
// Select SOIL as default result variable
421-
riv->cellResult()->resultType = RimDefines::DYNAMIC_NATIVE;
422-
riv->cellResult()->resultVariable = "SOIL";
423-
riv->animationMode = true;
422+
if (m_preferences->autocomputeSOIL)
423+
{
424+
// Select SOIL as default result variable
425+
riv->cellResult()->resultType = RimDefines::DYNAMIC_NATIVE;
426+
riv->cellResult()->resultVariable = "SOIL";
427+
riv->animationMode = true;
428+
}
424429

425430
riv->loadDataAndUpdate();
426431

427432
if (!riv->cellResult()->hasResult())
428433
{
429-
riv->cellResult()->resultVariable = RimDefines::nonSelectedResultName();
434+
riv->cellResult()->resultVariable = RimDefines::undefinedResultName();
430435
}
431436

432437
onProjectOpenedOrClosed();
@@ -455,7 +460,7 @@ bool RIApplication::openInputEclipseCase(const QString& caseName, const QStringL
455460

456461
if (!riv->cellResult()->hasResult())
457462
{
458-
riv->cellResult()->resultVariable = RimDefines::nonSelectedResultName();
463+
riv->cellResult()->resultVariable = RimDefines::undefinedResultName();
459464
}
460465

461466
onProjectOpenedOrClosed();
@@ -536,10 +541,12 @@ void RIApplication::setUseShaders(bool enable)
536541
//--------------------------------------------------------------------------------------------------
537542
bool RIApplication::useShaders() const
538543
{
544+
if (!m_preferences->useShaders) return false;
545+
539546
bool isShadersSupported = caf::Viewer::isShadersSupported();
540547
if (!isShadersSupported) return false;
541548

542-
return m_preferences->useShaders;
549+
return true;
543550
}
544551

545552

@@ -721,7 +728,7 @@ void RIApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus
721728
// get a chance to run before we delete the object
722729
if (m_workerProcess)
723730
{
724-
m_workerProcess->deleteLater();
731+
m_workerProcess->close();
725732
}
726733
m_workerProcess = NULL;
727734

@@ -749,23 +756,33 @@ void RIApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus
749756
//--------------------------------------------------------------------------------------------------
750757
bool RIApplication::launchProcess(const QString& program, const QStringList& arguments)
751758
{
752-
m_workerProcess = new caf::UiProcess(this);
753-
connect(m_workerProcess, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(slotWorkerProcessFinished(int, QProcess::ExitStatus)));
759+
if (m_workerProcess == NULL)
760+
{
761+
m_workerProcess = new caf::UiProcess(this);
762+
connect(m_workerProcess, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(slotWorkerProcessFinished(int, QProcess::ExitStatus)));
754763

755-
RIMainWindow::instance()->processMonitor()->startMonitorWorkProcess(m_workerProcess);
764+
RIMainWindow::instance()->processMonitor()->startMonitorWorkProcess(m_workerProcess);
756765

757-
m_workerProcess->start(program, arguments);
758-
if (!m_workerProcess->waitForStarted(1000))
759-
{
760-
m_workerProcess->deleteLater();
761-
m_workerProcess = NULL;
766+
m_workerProcess->start(program, arguments);
767+
if (!m_workerProcess->waitForStarted(1000))
768+
{
769+
m_workerProcess->close();
770+
m_workerProcess = NULL;
771+
772+
RIMainWindow::instance()->processMonitor()->stopMonitorWorkProcess();
762773

763-
RIMainWindow::instance()->processMonitor()->stopMonitorWorkProcess();
774+
QMessageBox::warning(RIMainWindow::instance(), "Script execution", "Failed to start script executable located at\n" + program);
764775

776+
return false;
777+
}
778+
779+
return true;
780+
}
781+
else
782+
{
783+
QMessageBox::warning(NULL, "Script execution", "An Octave process is still running. Please stop this process before executing a new script.");
765784
return false;
766785
}
767-
768-
return true;
769786
}
770787

771788
//--------------------------------------------------------------------------------------------------
@@ -853,3 +870,16 @@ void RIApplication::applyPreferences()
853870
}
854871

855872
}
873+
874+
//--------------------------------------------------------------------------------------------------
875+
///
876+
//--------------------------------------------------------------------------------------------------
877+
void RIApplication::terminateProcess()
878+
{
879+
if (m_workerProcess)
880+
{
881+
m_workerProcess->close();
882+
}
883+
884+
m_workerProcess = NULL;
885+
}

ApplicationCode/Application/RIApplication.h

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class RIApplication : public QApplication
103103
QString octavePath() const;
104104

105105
bool launchProcess(const QString& program, const QStringList& arguments);
106+
void terminateProcess();
106107

107108
RIPreferences* preferences();
108109
void readPreferences();

ApplicationCode/Application/RIPreferences.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ RIPreferences::RIPreferences(void)
4242

4343
CAF_PDM_InitFieldNoDefault(&lastUsedProjectFileName,"lastUsedProjectFileName", "Last Used Project File", "", "", "");
4444
lastUsedProjectFileName.setUiHidden(true);
45+
46+
CAF_PDM_InitField(&autocomputeSOIL, "autocomputeSOIL", true, "Compute SOIL if not on disk", "", "", "");
4547
}
4648

4749
//--------------------------------------------------------------------------------------------------

ApplicationCode/Application/RIPreferences.h

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ class RIPreferences : public caf::PdmObject
4141

4242
caf::PdmField<QString> lastUsedProjectFileName;
4343

44+
caf::PdmField<bool> autocomputeSOIL;
45+
46+
4447
protected:
4548
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
4649
};

ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigReservoi
6666
FILE* gridFilePointer = util_fopen(fileName.toLatin1().data(), "r");
6767
if (!gridFilePointer) return false;
6868

69-
// Main grid Dimentions
69+
// Main grid dimensions
7070
// SPECGRID - This is whats normally available, but not really the input to Eclipse.
7171
// DIMENS - Is what Eclipse expects and uses, but is not defined in the GRID section and is not (?) available normally
7272
// ZCORN, COORD, ACTNUM, MAPAXES

ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#endif //USE_ECL_LIB
2626

2727
#include <QFileInfo>
28+
#include "cafProgressInfo.h"
2829

2930
//--------------------------------------------------------------------------------------------------
3031
/// Constructor
@@ -105,7 +106,11 @@ bool RifEclipseOutputFileTools::keywordsOnFile(QStringList* keywords, size_t num
105106
CVF_ASSERT(keywords);
106107
keywords->clear();
107108

109+
108110
size_t numKeywords = ecl_file_get_num_distinct_kw(m_file);
111+
112+
caf::ProgressInfo info(numKeywords, "Reading Keywords on file");
113+
109114
size_t i;
110115
for (i = 0; i < numKeywords; i++)
111116
{
@@ -148,6 +153,8 @@ bool RifEclipseOutputFileTools::keywordsOnFile(QStringList* keywords, size_t num
148153
{
149154
keywords->append(QString(kw));
150155
}
156+
157+
info.setProgress(i);
151158
}
152159

153160
return true;

ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,15 @@ QStringList RifEclipseRestartFilesetAccess::resultNames()
142142
bool RifEclipseRestartFilesetAccess::results(const QString& resultName, size_t timeStep, std::vector<double>* values)
143143
{
144144
size_t numOccurrences = m_files[timeStep]->numOccurrences(resultName);
145-
CVF_ASSERT(m_numGrids == numOccurrences);
145+
146+
// No results for this result variable for current time step found
147+
if (numOccurrences == 0) return true;
148+
149+
// Result handling depends on presens of result values for all grids
150+
if (m_numGrids != numOccurrences)
151+
{
152+
return false;
153+
}
146154

147155
size_t i;
148156
for (i = 0; i < numOccurrences; i++)

ApplicationCode/FileInterface/RifReaderEclipseInput.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ bool RifReaderEclipseInput::open(const QString& fileName, RigReservoir* reservoi
6767
close();
6868

6969
// Should we handle gridless properties ?
70-
// If so, they must match dimentions, and a grid afterwards must match dimension
70+
// If so, they must match dimensions, and a grid afterwards must match dimension
7171

7272
// Add file:
7373
// Open file

ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,11 @@ bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir)
381381
QStringList staticResultNames = staticResults;
382382

383383
QList<QDateTime> staticDate;
384-
staticDate.push_back(m_timeSteps.front());
384+
if (m_timeSteps.size() > 0)
385+
{
386+
staticDate.push_back(m_timeSteps.front());
387+
}
388+
385389
for (size_t i = 0; i < static_cast<size_t>(staticResultNames.size()); ++i)
386390
{
387391
size_t resIndex = resCellResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, staticResultNames[i]);

ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp

+43-35
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "cvfTexture.h"
4545
#include "cvfSampler.h"
4646
#include "cvfScalarMapper.h"
47+
#include "cafEffectGenerator.h"
4748

4849

4950
//--------------------------------------------------------------------------------------------------
@@ -87,22 +88,16 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
8788
const RigGridBase* grid = dynamic_cast<const RigGridBase*>(generator->activeGrid());
8889

8990
CVF_ASSERT(grid != NULL);
90-
const std::vector< double >* cellScalarResults = NULL;
91-
bool cellScalarResultUseGlobalActiveIndex = true;
9291

93-
const std::vector< double >* edgeScalarResults[6] = {NULL, NULL, NULL, NULL, NULL, NULL};
92+
bool cellScalarResultUseGlobalActiveIndex = true;
9493
bool edgeScalarResultUseGlobalActiveIndex[6];
9594

9695
if (cellResultSlot->hasResult())
9796
{
98-
const std::vector< std::vector<double> >& scalarResultTimeSteps = grid->mainGrid()->results()->cellScalarResults(cellResultSlot->gridScalarIndex());
99-
if (cellResultSlot->hasDynamicResult())
100-
{
101-
cellScalarResults = &scalarResultTimeSteps[timeStepIndex];
102-
}
103-
else
97+
if (!cellResultSlot->hasDynamicResult())
10498
{
105-
cellScalarResults = &scalarResultTimeSteps[0];
99+
// Static result values are located at time step 0
100+
timeStepIndex = 0;
106101
}
107102

108103
cellScalarResultUseGlobalActiveIndex = grid->mainGrid()->results()->isUsingGlobalActiveIndex(cellResultSlot->gridScalarIndex());
@@ -118,8 +113,6 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
118113
{
119114
if (resultIndices[cubeFaceIdx] != cvf::UNDEFINED_SIZE_T)
120115
{
121-
const std::vector< std::vector<double> >& scalarResultTimeSteps = grid->mainGrid()->results()->cellScalarResults(resultIndices[cubeFaceIdx]);
122-
edgeScalarResults[cubeFaceIdx] = &scalarResultTimeSteps[0]; // Assuming only static edge results
123116
edgeScalarResultUseGlobalActiveIndex[cubeFaceIdx] = grid->mainGrid()->results()->isUsingGlobalActiveIndex(resultIndices[cubeFaceIdx]);
124117
}
125118
}
@@ -143,18 +136,16 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
143136
float cellColorTextureCoord = 0.5f; // If no results exists, the texture will have a special color
144137
size_t cellIndex = quadToCell[quadIdx];
145138

146-
size_t resultIndex = cellIndex;
139+
size_t resultValueIndex = cellIndex;
147140
if (cellScalarResultUseGlobalActiveIndex)
148141
{
149-
resultIndex = grid->cell(cellIndex).globalActiveIndex();
142+
resultValueIndex = grid->cell(cellIndex).globalActiveIndex();
150143
}
151144

152-
if (cellScalarResults )
153145
{
154-
if (resultIndex != cvf::UNDEFINED_SIZE_T)
146+
double scalarValue = grid->mainGrid()->results()->cellScalarResult(timeStepIndex, cellResultSlot->gridScalarIndex(), resultValueIndex);
147+
if (scalarValue != HUGE_VAL)
155148
{
156-
double scalarValue = (*cellScalarResults)[resultIndex];
157-
158149
cellColorTextureCoord = cellResultScalarMapper->mapToTextureCoord(scalarValue)[0];
159150
}
160151
else
@@ -174,19 +165,17 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
174165
{
175166
edgeColor = -1.0f; // Undefined texture coord. Shader handles this.
176167

177-
resultIndex = cellIndex;
168+
resultValueIndex = cellIndex;
178169
if (edgeScalarResultUseGlobalActiveIndex[cubeFaceIdx])
179170
{
180-
resultIndex = grid->cell(cellIndex).globalActiveIndex();
171+
resultValueIndex = grid->cell(cellIndex).globalActiveIndex();
181172
}
182173

183-
if (resultIndices[cubeFaceIdx] != cvf::UNDEFINED_SIZE_T && resultIndex != cvf::UNDEFINED_SIZE_T)
174+
// Assuming static values to be mapped onto cell edge, always using time step zero
175+
double scalarValue = grid->mainGrid()->results()->cellScalarResult(0, resultIndices[cubeFaceIdx], resultValueIndex);
176+
if (scalarValue != HUGE_VAL && scalarValue != ignoredScalarValue)
184177
{
185-
double scalarValue = (*(edgeScalarResults[cubeFaceIdx]))[resultIndex];
186-
if(scalarValue != ignoredScalarValue)
187-
{
188-
edgeColor = edgeResultScalarMapper->mapToTextureCoord(scalarValue)[0];
189-
}
178+
edgeColor = edgeResultScalarMapper->mapToTextureCoord(scalarValue)[0];
190179
}
191180

192181
cvf::FloatArray* colArr = cellEdgeColorTextureCoordsArrays.at(cubeFaceIdx);
@@ -250,6 +239,20 @@ bool CellEdgeEffectGenerator::isEqual(const EffectGenerator* other) const
250239
&& m_defaultCellColor == otherCellFaceEffectGenerator->m_defaultCellColor
251240
)
252241
{
242+
cvf::ref<cvf::TextureImage> texImg2 = new cvf::TextureImage;
243+
244+
if (otherCellFaceEffectGenerator->m_edgeScalarMapper.notNull())
245+
{
246+
otherCellFaceEffectGenerator->m_edgeScalarMapper->updateTexture(texImg2.p());
247+
if (!caf::ScalarMapperEffectGenerator::isImagesEqual(m_edgeTextureImage.p(), texImg2.p())) return false;
248+
}
249+
250+
if (otherCellFaceEffectGenerator->m_cellScalarMapper.notNull())
251+
{
252+
otherCellFaceEffectGenerator->m_cellScalarMapper->updateTexture(texImg2.p());
253+
if (!caf::ScalarMapperEffectGenerator::isImagesEqual(m_cellTextureImage.p(), texImg2.p())) return false;
254+
}
255+
253256
return true;
254257
}
255258
else
@@ -264,6 +267,9 @@ bool CellEdgeEffectGenerator::isEqual(const EffectGenerator* other) const
264267
caf::EffectGenerator* CellEdgeEffectGenerator::copy() const
265268
{
266269
CellEdgeEffectGenerator * newEffect = new CellEdgeEffectGenerator(m_edgeScalarMapper.p(), m_cellScalarMapper.p());
270+
newEffect->m_edgeTextureImage = m_edgeTextureImage;
271+
newEffect->m_cellTextureImage = m_cellTextureImage;
272+
267273
newEffect->setOpacityLevel(m_opacityLevel);
268274
newEffect->setCullBackfaces(m_cullBackfaces);
269275
newEffect->setUndefinedColor(m_undefinedColor);
@@ -316,23 +322,25 @@ void CellEdgeEffectGenerator::updateForShaderBasedRendering(cvf::Effect* effect)
316322

317323
// Set up textures
318324

319-
cvf::ref<cvf::TextureImage> edgeTexImg = new cvf::TextureImage;
320-
cvf::ref<cvf::TextureImage> cellTexImg = new cvf::TextureImage;
325+
m_edgeTextureImage = new cvf::TextureImage;
326+
m_cellTextureImage = new cvf::TextureImage;
321327

322-
m_edgeScalarMapper->updateTexture(edgeTexImg.p());
328+
cvf::ref<cvf::TextureImage> modifiedCellTextImage;
329+
m_edgeScalarMapper->updateTexture(m_edgeTextureImage.p());
323330
if (m_cellScalarMapper.notNull())
324331
{
325-
m_cellScalarMapper->updateTexture(cellTexImg.p());
326-
cellTexImg = caf::ScalarMapperEffectGenerator::addAlphaAndUndefStripes(cellTexImg.p(), m_undefinedColor, m_opacityLevel);
332+
m_cellScalarMapper->updateTexture(m_cellTextureImage.p());
333+
modifiedCellTextImage = caf::ScalarMapperEffectGenerator::addAlphaAndUndefStripes(m_cellTextureImage.p(), m_undefinedColor, m_opacityLevel);
327334
}
328335
else
329336
{
330-
cellTexImg->allocate(2,1);
331-
cellTexImg->fill(cvf::Color4ub(cvf::Color4f(m_defaultCellColor, m_opacityLevel)));
337+
modifiedCellTextImage = new cvf::TextureImage;
338+
modifiedCellTextImage->allocate(2,1);
339+
modifiedCellTextImage->fill(cvf::Color4ub(cvf::Color4f(m_defaultCellColor, m_opacityLevel)));
332340
}
333341

334-
cvf::ref<cvf::Texture> edgeTexture = new cvf::Texture(edgeTexImg.p());
335-
cvf::ref<cvf::Texture> cellTexture = new cvf::Texture(cellTexImg.p());
342+
cvf::ref<cvf::Texture> edgeTexture = new cvf::Texture(m_edgeTextureImage.p());
343+
cvf::ref<cvf::Texture> cellTexture = new cvf::Texture(modifiedCellTextImage.p());
336344

337345
cvf::ref<cvf::Sampler> sampler = new cvf::Sampler;
338346
sampler->setWrapMode(cvf::Sampler::CLAMP_TO_EDGE);

0 commit comments

Comments
 (0)