mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Impoved result info text presentation
Display Cell result, Fault result, NNC result, and Cell edge result as a section with a linefeed above Always show value for intersection point at top with details below.
This commit is contained in:
@@ -44,6 +44,34 @@ RiuResultTextBuilder::RiuResultTextBuilder(RimReservoirView* reservoirView, size
|
||||
m_gridIndex = gridIndex;
|
||||
m_cellIndex = cellIndex;
|
||||
m_timeStepIndex = timeStepIndex;
|
||||
|
||||
m_nncIndex = cvf::UNDEFINED_SIZE_T;
|
||||
m_intersectionPoint = cvf::Vec3d::UNDEFINED;
|
||||
m_face = cvf::StructGridInterface::NO_FACE;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuResultTextBuilder::setNncIndex(size_t nncIndex)
|
||||
{
|
||||
m_nncIndex = nncIndex;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuResultTextBuilder::setIntersectionPoint(cvf::Vec3d intersectionPoint)
|
||||
{
|
||||
m_intersectionPoint = intersectionPoint;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuResultTextBuilder::setFace(cvf::StructGridInterface::FaceType face)
|
||||
{
|
||||
m_face = face;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -51,21 +79,97 @@ RiuResultTextBuilder::RiuResultTextBuilder(RimReservoirView* reservoirView, size
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiuResultTextBuilder::mainResultText()
|
||||
{
|
||||
QString text;
|
||||
QString text;
|
||||
|
||||
QString nncText = nncResultText();
|
||||
if (!nncText.isEmpty())
|
||||
{
|
||||
text = nncText;
|
||||
}
|
||||
else
|
||||
{
|
||||
text = gridResultText();
|
||||
}
|
||||
// Produce result text for all variants
|
||||
// Priority defined as follows : NNC, Fault, Grid
|
||||
{
|
||||
QString nncText = nncResultText();
|
||||
QString faultText = faultResultText();
|
||||
|
||||
if (!nncText.isEmpty())
|
||||
{
|
||||
text = "NNC : " + nncText;
|
||||
}
|
||||
else if (!faultResultText().isEmpty())
|
||||
{
|
||||
text = "Fault : " + faultText;
|
||||
}
|
||||
else
|
||||
{
|
||||
text = "Grid cell : " + gridResultText();
|
||||
}
|
||||
|
||||
text += "\n";
|
||||
}
|
||||
|
||||
QString topoText = this->topologyText("\n");
|
||||
text += topoText;
|
||||
text += "\n";
|
||||
|
||||
appendDetails(text, nncDetails());
|
||||
|
||||
if (nncDetails().isEmpty())
|
||||
{
|
||||
appendDetails(text, faultResultDetails());
|
||||
}
|
||||
|
||||
appendDetails(text, cellEdgeResultDetails());
|
||||
|
||||
bool isCustomFaultResultVisible = m_reservoirView->faultResultSettings()->showCustomFaultResult() && m_reservoirView->faultResultSettings()->hasValidCustomResult();
|
||||
if (isCustomFaultResultVisible)
|
||||
{
|
||||
appendDetails(text, gridResultDetails());
|
||||
}
|
||||
|
||||
appendDetails(text, wellResultText());
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiuResultTextBuilder::topologyText(QString itemSeparator)
|
||||
{
|
||||
QString text;
|
||||
|
||||
if (m_reservoirView->eclipseCase())
|
||||
{
|
||||
const RigCaseData* eclipseCase = m_reservoirView->eclipseCase()->reservoirData();
|
||||
if (eclipseCase)
|
||||
{
|
||||
size_t i = 0;
|
||||
size_t j = 0;
|
||||
size_t k = 0;
|
||||
if (eclipseCase->grid(m_gridIndex)->ijkFromCellIndex(m_cellIndex, &i, &j, &k))
|
||||
{
|
||||
// Adjust to 1-based Eclipse indexing
|
||||
i++;
|
||||
j++;
|
||||
k++;
|
||||
|
||||
cvf::Vec3d domainCoord = m_intersectionPoint + eclipseCase->grid(m_gridIndex)->displayModelOffset();
|
||||
|
||||
cvf::StructGridInterface::FaceEnum faceEnum(m_face);
|
||||
|
||||
QString faceText = faceEnum.text();
|
||||
|
||||
text += QString("Face : %1").arg(faceText) + itemSeparator;
|
||||
text += QString("Hit grid %1").arg(m_gridIndex) + itemSeparator;
|
||||
text += QString("Cell : [%1, %2, %3]").arg(i).arg(j).arg(k) + itemSeparator;
|
||||
|
||||
QString formattedText;
|
||||
formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z());
|
||||
|
||||
text += formattedText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -79,6 +183,11 @@ QString RiuResultTextBuilder::gridResultDetails()
|
||||
RigGridBase* grid = eclipseCaseData->grid(m_gridIndex);
|
||||
|
||||
this->appendTextFromResultSlot(eclipseCaseData, m_gridIndex, m_cellIndex, m_timeStepIndex, m_reservoirView->cellResult(), &text);
|
||||
|
||||
if (!text.isEmpty())
|
||||
{
|
||||
text.prepend("-- Grid cell result details --\n");
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
@@ -100,14 +209,16 @@ QString RiuResultTextBuilder::faultResultDetails()
|
||||
const RigFault* fault = mainGrid->findFaultFromCellIndexAndCellFace(m_cellIndex, m_face);
|
||||
if (fault)
|
||||
{
|
||||
text.append(QString("Fault Name: %1\n").arg(fault->name()));
|
||||
text += "-- Fault result details --\n";
|
||||
|
||||
text += QString("Fault Name: %1\n").arg(fault->name());
|
||||
|
||||
cvf::StructGridInterface::FaceEnum faceHelper(m_face);
|
||||
text.append("Fault Face : " + faceHelper.text() + "\n");
|
||||
text += "Fault Face : " + faceHelper.text() + "\n";
|
||||
|
||||
if (m_reservoirView->faultResultSettings()->hasValidCustomResult())
|
||||
{
|
||||
text.append("Fault result data:\n");
|
||||
text += "Fault result data:\n";
|
||||
this->appendTextFromResultSlot(eclipseCaseData, m_gridIndex, m_cellIndex, m_timeStepIndex, m_reservoirView->currentFaultResultSlot(), &text);
|
||||
}
|
||||
}
|
||||
@@ -116,16 +227,46 @@ QString RiuResultTextBuilder::faultResultDetails()
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiuResultTextBuilder::gridResultText()
|
||||
{
|
||||
QString text;
|
||||
QString text = cellResultText(m_reservoirView->cellResult());
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiuResultTextBuilder::faultResultText()
|
||||
{
|
||||
QString text;
|
||||
|
||||
if (m_reservoirView->eclipseCase() && m_reservoirView->eclipseCase()->reservoirData())
|
||||
{
|
||||
RigCaseData* eclipseCaseData = m_reservoirView->eclipseCase()->reservoirData();
|
||||
RigGridBase* grid = eclipseCaseData->grid(m_gridIndex);
|
||||
RigMainGrid* mainGrid = grid->mainGrid();
|
||||
|
||||
const RigFault* fault = mainGrid->findFaultFromCellIndexAndCellFace(m_cellIndex, m_face);
|
||||
if (fault)
|
||||
{
|
||||
cvf::StructGridInterface::FaceEnum faceHelper(m_face);
|
||||
if (m_reservoirView->faultResultSettings()->hasValidCustomResult())
|
||||
{
|
||||
text = cellResultText(m_reservoirView->currentFaultResultSlot());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -133,8 +274,40 @@ QString RiuResultTextBuilder::nncResultText()
|
||||
{
|
||||
QString text;
|
||||
|
||||
return text;
|
||||
if (m_nncIndex != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
if (m_reservoirView.notNull() && m_reservoirView->eclipseCase())
|
||||
{
|
||||
RigCaseData* eclipseCase = m_reservoirView->eclipseCase()->reservoirData();
|
||||
|
||||
RigMainGrid* grid = eclipseCase->mainGrid();
|
||||
CVF_ASSERT(grid);
|
||||
|
||||
RigNNCData* nncData = grid->nncData();
|
||||
CVF_ASSERT(nncData);
|
||||
|
||||
if (nncData)
|
||||
{
|
||||
const RigConnection& conn = nncData->connections()[m_nncIndex];
|
||||
cvf::StructGridInterface::FaceEnum face(conn.m_c1Face);
|
||||
|
||||
if (m_reservoirView->currentFaultResultSlot())
|
||||
{
|
||||
size_t scalarResultIdx = m_reservoirView->currentFaultResultSlot()->scalarResultIndex();
|
||||
const std::vector<double>* nncValues = nncData->connectionScalarResult(scalarResultIdx);
|
||||
if (nncValues)
|
||||
{
|
||||
QString resultVar = m_reservoirView->currentFaultResultSlot()->resultVariable();
|
||||
double scalarValue = (*nncValues)[m_nncIndex];
|
||||
|
||||
text = QString("%1 : %2").arg(resultVar).arg(scalarValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -274,11 +447,11 @@ void RiuResultTextBuilder::appendTextFromResultSlot(RigCaseData* eclipseCase, si
|
||||
if (resultAccessor.notNull())
|
||||
{
|
||||
double scalarValue = resultAccessor->cellScalar(cellIndex);
|
||||
resultInfoText->append(resultSlot->resultVariable());
|
||||
resultInfoText->append("Cell result : ");
|
||||
resultInfoText->append(resultSlot->resultVariable());
|
||||
resultInfoText->append(QString(" : %1\n").arg(scalarValue));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -288,7 +461,6 @@ QString RiuResultTextBuilder::cellEdgeResultDetails()
|
||||
{
|
||||
QString text;
|
||||
|
||||
//if (m_reservoirView->eclipseCase() && m_reservoirView->eclipseCase()->reservoirData())
|
||||
if (m_reservoirView->cellEdgeResult()->hasResult())
|
||||
{
|
||||
size_t resultIndices[6];
|
||||
@@ -296,7 +468,7 @@ QString RiuResultTextBuilder::cellEdgeResultDetails()
|
||||
m_reservoirView->cellEdgeResult()->gridScalarIndices(resultIndices);
|
||||
m_reservoirView->cellEdgeResult()->gridScalarResultNames(&resultNames);
|
||||
|
||||
text.push_back("\nCell edge result data:\n");
|
||||
text += "-- Cell edge result data --\n";
|
||||
for (int idx = 0; idx < 6; idx++)
|
||||
{
|
||||
if (resultIndices[idx] == cvf::UNDEFINED_SIZE_T) continue;
|
||||
@@ -314,3 +486,184 @@ QString RiuResultTextBuilder::cellEdgeResultDetails()
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiuResultTextBuilder::nncDetails()
|
||||
{
|
||||
QString text;
|
||||
|
||||
if (m_nncIndex != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
if (m_reservoirView.notNull() && m_reservoirView->eclipseCase())
|
||||
{
|
||||
RigCaseData* eclipseCase = m_reservoirView->eclipseCase()->reservoirData();
|
||||
|
||||
RigMainGrid* grid = eclipseCase->mainGrid();
|
||||
CVF_ASSERT(grid);
|
||||
|
||||
RigNNCData* nncData = grid->nncData();
|
||||
CVF_ASSERT(nncData);
|
||||
|
||||
if (nncData)
|
||||
{
|
||||
text += "-- NNC details --\n";
|
||||
{
|
||||
const RigConnection& conn = nncData->connections()[m_nncIndex];
|
||||
cvf::StructGridInterface::FaceEnum face(conn.m_c1Face);
|
||||
|
||||
// First cell of NNC
|
||||
{
|
||||
CVF_ASSERT(conn.m_c1GlobIdx < grid->cells().size());
|
||||
const RigCell& cell = grid->cells()[conn.m_c1GlobIdx];
|
||||
|
||||
RigGridBase* hostGrid = cell.hostGrid();
|
||||
size_t gridLocalCellIndex = cell.gridLocalCellIndex();
|
||||
|
||||
size_t i, j, k;
|
||||
if (hostGrid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k))
|
||||
{
|
||||
// Adjust to 1-based Eclipse indexing
|
||||
i++;
|
||||
j++;
|
||||
k++;
|
||||
|
||||
QString gridName = QString::fromStdString(hostGrid->gridName());
|
||||
text.append(QString("NNC 1 : cell [%1, %2, %3] face %4 (%5)\n").arg(i).arg(j).arg(k).arg(face.text()).arg(gridName));
|
||||
}
|
||||
}
|
||||
|
||||
// Second cell of NNC
|
||||
{
|
||||
CVF_ASSERT(conn.m_c2GlobIdx < grid->cells().size());
|
||||
const RigCell& cell = grid->cells()[conn.m_c2GlobIdx];
|
||||
|
||||
RigGridBase* hostGrid = cell.hostGrid();
|
||||
size_t gridLocalCellIndex = cell.gridLocalCellIndex();
|
||||
|
||||
size_t i, j, k;
|
||||
if (hostGrid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k))
|
||||
{
|
||||
// Adjust to 1-based Eclipse indexing
|
||||
i++;
|
||||
j++;
|
||||
k++;
|
||||
|
||||
QString gridName = QString::fromStdString(hostGrid->gridName());
|
||||
cvf::StructGridInterface::FaceEnum oppositeFaceEnum(cvf::StructGridInterface::oppositeFace(face));
|
||||
QString faceText = oppositeFaceEnum.text();
|
||||
|
||||
text.append(QString("NNC 2 : cell [%1, %2, %3] face %4 (%5)\n").arg(i).arg(j).arg(k).arg(faceText).arg(gridName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuResultTextBuilder::appendDetails(QString& text, const QString& details)
|
||||
{
|
||||
if (!details.isEmpty())
|
||||
{
|
||||
text += "\n";
|
||||
text += details;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiuResultTextBuilder::cellResultText(RimResultSlot* resultSlot)
|
||||
{
|
||||
QString text;
|
||||
|
||||
if (m_reservoirView->eclipseCase() && m_reservoirView->eclipseCase()->reservoirData())
|
||||
{
|
||||
RigCaseData* eclipseCaseData = m_reservoirView->eclipseCase()->reservoirData();
|
||||
RigGridBase* grid = eclipseCaseData->grid(m_gridIndex);
|
||||
|
||||
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(resultSlot->porosityModel());
|
||||
|
||||
QString resultVar = resultSlot->resultVariable();
|
||||
|
||||
if (resultSlot->isTernarySaturationSelected())
|
||||
{
|
||||
RimReservoirCellResultsStorage* gridCellResults = m_reservoirView->cellResult()->currentGridCellResults();
|
||||
if (gridCellResults)
|
||||
{
|
||||
size_t soilScalarSetIndex = gridCellResults->findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL");
|
||||
size_t sgasScalarSetIndex = gridCellResults->findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SGAS");
|
||||
size_t swatScalarSetIndex = gridCellResults->findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SWAT");
|
||||
|
||||
cvf::ref<RigResultAccessor> dataAccessObjectX = RigResultAccessorFactory::createResultAccessor(eclipseCaseData, m_gridIndex, porosityModel, m_timeStepIndex, soilScalarSetIndex);
|
||||
cvf::ref<RigResultAccessor> dataAccessObjectY = RigResultAccessorFactory::createResultAccessor(eclipseCaseData, m_gridIndex, porosityModel, m_timeStepIndex, sgasScalarSetIndex);
|
||||
cvf::ref<RigResultAccessor> dataAccessObjectZ = RigResultAccessorFactory::createResultAccessor(eclipseCaseData, m_gridIndex, porosityModel, m_timeStepIndex, swatScalarSetIndex);
|
||||
|
||||
double scalarValue = 0.0;
|
||||
|
||||
if (dataAccessObjectX.notNull()) scalarValue = dataAccessObjectX->cellScalar(m_cellIndex);
|
||||
else scalarValue = 0.0;
|
||||
text += QString("SOIL : %1 ").arg(scalarValue);
|
||||
|
||||
if (dataAccessObjectY.notNull()) scalarValue = dataAccessObjectY->cellScalar(m_cellIndex);
|
||||
else scalarValue = 0.0;
|
||||
text += QString("SGAS : %1 ").arg(scalarValue);
|
||||
|
||||
if (dataAccessObjectZ.notNull()) scalarValue = dataAccessObjectZ->cellScalar(m_cellIndex);
|
||||
else scalarValue = 0.0;
|
||||
text += QString("SWAT : %1 ").arg(scalarValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cvf::ref<RigResultAccessor> resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCaseData, m_gridIndex, porosityModel, m_timeStepIndex, resultVar);
|
||||
if (resultAccessor.notNull())
|
||||
{
|
||||
double scalarValue = resultAccessor->cellFaceScalar(m_cellIndex, m_face);
|
||||
text = QString("%1 : %2").arg(resultVar).arg(scalarValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiuResultTextBuilder::wellResultText()
|
||||
{
|
||||
QString text;
|
||||
|
||||
if (m_reservoirView->eclipseCase() &&
|
||||
m_reservoirView->eclipseCase()->reservoirData() )
|
||||
{
|
||||
cvf::Collection<RigSingleWellResultsData> wellResults = m_reservoirView->eclipseCase()->reservoirData()->wellResults();
|
||||
for (size_t i = 0; i < wellResults.size(); i++)
|
||||
{
|
||||
RigSingleWellResultsData* singleWellResultData = wellResults.at(i);
|
||||
|
||||
if (m_timeStepIndex < static_cast<int>(singleWellResultData->firstResultTimeStep()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const RigWellResultFrame& wellResultFrame = singleWellResultData->wellResultFrame(m_timeStepIndex);
|
||||
const RigWellResultPoint* wellResultCell = wellResultFrame.findResultCell(m_gridIndex, m_cellIndex);
|
||||
if (wellResultCell)
|
||||
{
|
||||
text += QString("-- Well-cell connection info --\n Well Name: %1\n Branch Id: %2\n Segment Id: %3\n").arg(singleWellResultData->m_wellName).arg(wellResultCell->m_ertBranchId).arg(wellResultCell->m_ertSegmentId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,17 +40,28 @@ class RiuResultTextBuilder
|
||||
{
|
||||
public:
|
||||
RiuResultTextBuilder(RimReservoirView* reservoirView, size_t gridIndex, size_t cellIndex, size_t timeStepIndex);
|
||||
void setPickInfo(cvf::Part* part, cvf::uint partFaceHit, cvf::Part* nncPart, cvf::uint nncFaceHit, cvf::Vec3d intersectionPoint);
|
||||
void setFace(cvf::StructGridInterface::FaceType face);
|
||||
void setNncIndex(size_t nncIndex);
|
||||
void setIntersectionPoint(cvf::Vec3d intersectionPoint);
|
||||
|
||||
QString mainResultText();
|
||||
|
||||
QString gridResultDetails();
|
||||
QString faultResultDetails();
|
||||
QString cellEdgeResultDetails();
|
||||
|
||||
QString topologyText(QString itemSeparator);
|
||||
|
||||
private:
|
||||
QString gridResultText();
|
||||
QString nncResultText();
|
||||
void appendDetails(QString& text, const QString& details);
|
||||
|
||||
QString gridResultDetails();
|
||||
QString faultResultDetails();
|
||||
QString cellEdgeResultDetails();
|
||||
QString nncDetails();
|
||||
|
||||
QString gridResultText();
|
||||
QString faultResultText();
|
||||
QString nncResultText();
|
||||
QString wellResultText();
|
||||
|
||||
QString cellResultText(RimResultSlot* resultSlot);
|
||||
|
||||
void appendTextFromResultSlot(RigCaseData* eclipseCase, size_t gridIndex, size_t cellIndex, size_t timeStepIndex, RimResultSlot* resultSlot, QString* resultInfoText);
|
||||
|
||||
@@ -63,11 +74,7 @@ private:
|
||||
|
||||
cvf::StructGridInterface::FaceType m_face;
|
||||
|
||||
cvf::Part* m_part;
|
||||
uint m_partFaceIndex;
|
||||
|
||||
cvf::Part* m_nncPart;
|
||||
uint m_nncPartFaceIndex;
|
||||
size_t m_nncIndex;
|
||||
|
||||
cvf::Vec3d m_intersectionPoint;
|
||||
};
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "RivSourceInfo.h"
|
||||
#include "RiuResultTextBuilder.h"
|
||||
|
||||
using cvf::ManipulatorTrackball;
|
||||
|
||||
@@ -215,8 +216,9 @@ void RiuViewer::mouseReleaseEvent(QMouseEvent* event)
|
||||
uint faceIndex = cvf::UNDEFINED_UINT;
|
||||
cvf::Vec3d localIntersectionPoint(cvf::Vec3d::ZERO);
|
||||
|
||||
cvf::Part * firstHitPart = NULL;
|
||||
firstHitPart = pickPointAndFace(winPosX, winPosY, &faceIndex, &localIntersectionPoint);
|
||||
cvf::Part* firstHitPart = NULL;
|
||||
cvf::Part* nncFirstHitPart = NULL;
|
||||
pickPointAndFace(winPosX, winPosY, &localIntersectionPoint, &firstHitPart, &faceIndex, &nncFirstHitPart, NULL);
|
||||
if (firstHitPart)
|
||||
{
|
||||
if (faceIndex != cvf::UNDEFINED_UINT)
|
||||
@@ -375,7 +377,6 @@ void RiuViewer::keyPressEvent(QKeyEvent* event)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -386,22 +387,24 @@ void RiuViewer::handlePickAction(int winPosX, int winPosY)
|
||||
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
||||
if (!mainWnd) return;
|
||||
|
||||
QString pickInfo = "No hits";
|
||||
QString resultInfo = "";
|
||||
|
||||
uint faceIndex = cvf::UNDEFINED_UINT;
|
||||
size_t gridIndex = cvf::UNDEFINED_SIZE_T;
|
||||
size_t cellIndex = cvf::UNDEFINED_SIZE_T;
|
||||
size_t nncIndex = cvf::UNDEFINED_SIZE_T;
|
||||
cvf::StructGridInterface::FaceType face = cvf::StructGridInterface::NO_FACE;
|
||||
cvf::Vec3d localIntersectionPoint(cvf::Vec3d::ZERO);
|
||||
|
||||
cvf::Part * firstHitPart = NULL;
|
||||
firstHitPart = pickPointAndFace(winPosX, winPosY, &faceIndex, &localIntersectionPoint);
|
||||
if (firstHitPart)
|
||||
{
|
||||
// If a drawable geometry was hit, get info about the picked geometry
|
||||
// and possibly the picked scalar value, if any
|
||||
if (faceIndex != cvf::UNDEFINED_UINT)
|
||||
{
|
||||
size_t gridIndex = firstHitPart->id();
|
||||
cvf::Part* firstHitPart = NULL;
|
||||
uint firstPartFaceIndex = cvf::UNDEFINED_UINT;
|
||||
|
||||
cvf::Part* firstNncHitPart = NULL;
|
||||
uint nncPartFaceIndex = cvf::UNDEFINED_UINT;
|
||||
|
||||
pickPointAndFace(winPosX, winPosY, &localIntersectionPoint, &firstHitPart, &firstPartFaceIndex, &firstNncHitPart, &nncPartFaceIndex);
|
||||
|
||||
if (firstHitPart)
|
||||
{
|
||||
gridIndex = firstHitPart->id();
|
||||
if (firstHitPart->sourceInfo())
|
||||
{
|
||||
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(firstHitPart->sourceInfo());
|
||||
@@ -411,41 +414,40 @@ void RiuViewer::handlePickAction(int winPosX, int winPosY)
|
||||
{
|
||||
CVF_ASSERT(rivSourceInfo->m_cellFaceFromTriangleMapper.notNull());
|
||||
|
||||
size_t cellIndex = cvf::UNDEFINED_SIZE_T;
|
||||
cellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex(faceIndex);
|
||||
|
||||
cvf::StructGridInterface::FaceType face = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace(faceIndex);
|
||||
|
||||
m_reservoirView->pickInfo(gridIndex, cellIndex, face, localIntersectionPoint, ", ", &pickInfo);
|
||||
|
||||
// Build up result from from both pick info and result values
|
||||
m_reservoirView->pickInfo(gridIndex, cellIndex, face, localIntersectionPoint, "\n", &resultInfo);
|
||||
resultInfo += "\n";
|
||||
m_reservoirView->appendCellResultInfo(gridIndex, cellIndex, face, &resultInfo);
|
||||
#if 0
|
||||
const RigCaseData* reservoir = m_reservoirView->eclipseCase()->reservoirData();
|
||||
const RigGridBase* grid = reservoir->grid(gridIndex);
|
||||
const RigCell& cell = grid->cell(cellIndex);
|
||||
const caf::SizeTArray8& cellNodeIndices = cell.cornerIndices();
|
||||
const std::vector<cvf::Vec3d>& nodes = reservoir->mainGrid()->nodes();
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
resultInfo += QString::number(i) + " : ";
|
||||
for (int j = 0; j < 3; ++j)
|
||||
resultInfo += QString::number(nodes[cellNodeIndices[i]][j], 'g', 10) + " ";
|
||||
resultInfo += "\n";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (rivSourceInfo->m_NNCIndices.notNull())
|
||||
{
|
||||
size_t nncIndex = rivSourceInfo->m_NNCIndices->get(faceIndex);
|
||||
|
||||
m_reservoirView->appendNNCResultInfo(nncIndex, &resultInfo);
|
||||
cellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex(firstPartFaceIndex);
|
||||
face = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace(firstPartFaceIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (firstNncHitPart && firstNncHitPart->sourceInfo())
|
||||
{
|
||||
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(firstNncHitPart->sourceInfo());
|
||||
if (rivSourceInfo)
|
||||
{
|
||||
if (nncPartFaceIndex < rivSourceInfo->m_NNCIndices->size())
|
||||
{
|
||||
nncIndex = rivSourceInfo->m_NNCIndices->get(nncPartFaceIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString pickInfo = "No hits";
|
||||
QString resultInfo = "";
|
||||
|
||||
if (cellIndex != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
RiuResultTextBuilder textBuilder(m_reservoirView, gridIndex, cellIndex, m_reservoirView->currentTimeStep());
|
||||
textBuilder.setFace(face);
|
||||
textBuilder.setNncIndex(nncIndex);
|
||||
textBuilder.setIntersectionPoint(localIntersectionPoint);
|
||||
|
||||
resultInfo = textBuilder.mainResultText();
|
||||
|
||||
pickInfo = textBuilder.topologyText(", ");
|
||||
}
|
||||
|
||||
mainWnd->statusBar()->showMessage(pickInfo);
|
||||
@@ -516,10 +518,8 @@ void RiuViewer::setEnableMask(unsigned int mask)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Perform picking and return the index of the face that was hit, if a drawable geo was hit
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Part* RiuViewer::pickPointAndFace(int winPosX, int winPosY, uint* faceHit, cvf::Vec3d* localIntersectionPoint)
|
||||
void RiuViewer::pickPointAndFace(int winPosX, int winPosY, cvf::Vec3d* localIntersectionPoint, cvf::Part** firstPart, uint* firstPartFaceHit, cvf::Part** nncPart, uint* nncPartFaceHit)
|
||||
{
|
||||
CVF_ASSERT(faceHit);
|
||||
|
||||
cvf::HitItemCollection hitItems;
|
||||
bool isSomethingHit = rayPick(winPosX, winPosY, &hitItems);
|
||||
|
||||
@@ -531,8 +531,8 @@ cvf::Part* RiuViewer::pickPointAndFace(int winPosX, int winPosY, uint* faceHit,
|
||||
double pickDepthThresholdSquared = characteristicCellSize / 100.0;
|
||||
pickDepthThresholdSquared = pickDepthThresholdSquared * pickDepthThresholdSquared;
|
||||
|
||||
cvf::HitItem* hitItem = hitItems.firstItem();
|
||||
cvf::Vec3d firstItemIntersectionPoint = hitItem->intersectionPoint();
|
||||
cvf::HitItem* firstNonNncHitItem = NULL;
|
||||
cvf::Vec3d firstItemIntersectionPoint = hitItems.item(0)->intersectionPoint();
|
||||
|
||||
// Check if we have a close hit item with NNC data
|
||||
for (size_t i = 0; i < hitItems.count(); i++)
|
||||
@@ -540,26 +540,47 @@ cvf::Part* RiuViewer::pickPointAndFace(int winPosX, int winPosY, uint* faceHit,
|
||||
cvf::HitItem* hitItemCandidate = hitItems.item(i);
|
||||
cvf::Vec3d diff = firstItemIntersectionPoint - hitItemCandidate->intersectionPoint();
|
||||
|
||||
// Hit items are ordered by distance from eye
|
||||
if (diff.lengthSquared() > pickDepthThresholdSquared) break;
|
||||
|
||||
const cvf::Part* pickedPartCandidate = hitItemCandidate->part();
|
||||
bool isNncpart = false;
|
||||
if (pickedPartCandidate && pickedPartCandidate->sourceInfo())
|
||||
{
|
||||
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(pickedPartCandidate->sourceInfo());
|
||||
if (rivSourceInfo && rivSourceInfo->hasNNCIndices())
|
||||
// Hit items are ordered by distance from eye
|
||||
if (diff.lengthSquared() < pickDepthThresholdSquared)
|
||||
{
|
||||
hitItem = hitItemCandidate;
|
||||
break;
|
||||
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(pickedPartCandidate->sourceInfo());
|
||||
if (rivSourceInfo && rivSourceInfo->hasNNCIndices())
|
||||
{
|
||||
*nncPart = const_cast<cvf::Part*>(pickedPartCandidate);
|
||||
|
||||
const cvf::HitDetailDrawableGeo* detail = dynamic_cast<const cvf::HitDetailDrawableGeo*>(hitItemCandidate->detail());
|
||||
if (detail && nncPartFaceHit)
|
||||
{
|
||||
*nncPartFaceHit = detail->faceIndex();
|
||||
}
|
||||
|
||||
isNncpart = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isNncpart && !firstNonNncHitItem)
|
||||
{
|
||||
firstNonNncHitItem = hitItemCandidate;
|
||||
firstItemIntersectionPoint = firstNonNncHitItem->intersectionPoint();
|
||||
}
|
||||
|
||||
if (firstNonNncHitItem && *nncPart)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const cvf::Part* pickedPart = hitItem->part();
|
||||
const cvf::Part* pickedPart = firstNonNncHitItem->part();
|
||||
CVF_ASSERT(pickedPart);
|
||||
*firstPart = const_cast<cvf::Part*>(pickedPart);
|
||||
|
||||
const cvf::Transform* xf = pickedPart->transform();
|
||||
cvf::Vec3d globalPickedPoint = hitItem->intersectionPoint();
|
||||
cvf::Vec3d globalPickedPoint = firstNonNncHitItem->intersectionPoint();
|
||||
|
||||
if(localIntersectionPoint)
|
||||
{
|
||||
@@ -573,21 +594,14 @@ cvf::Part* RiuViewer::pickPointAndFace(int winPosX, int winPosY, uint* faceHit,
|
||||
}
|
||||
}
|
||||
|
||||
if (faceHit)
|
||||
if (firstPartFaceHit)
|
||||
{
|
||||
|
||||
const cvf::HitDetailDrawableGeo* detail = dynamic_cast<const cvf::HitDetailDrawableGeo*>(hitItem->detail());
|
||||
const cvf::HitDetailDrawableGeo* detail = dynamic_cast<const cvf::HitDetailDrawableGeo*>(firstNonNncHitItem->detail());
|
||||
if (detail)
|
||||
{
|
||||
*faceHit = detail->faceIndex();
|
||||
*firstPartFaceHit = detail->faceIndex();
|
||||
}
|
||||
}
|
||||
|
||||
return const_cast<cvf::Part*>(pickedPart); // Hack. The const'ness of HitItem will probably change to non-const
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ protected:
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
|
||||
void handlePickAction(int winPosX, int winPosY);
|
||||
cvf::Part* pickPointAndFace(int winPosX, int winPosY, uint* faceHit, cvf::Vec3d* localIntersectionPoint);
|
||||
void pickPointAndFace(int winPosX, int winPosY, cvf::Vec3d* localIntersectionPoint, cvf::Part** firstPart, uint* firstPartFaceHit, cvf::Part** nncPart, uint* nncPartFaceHit);
|
||||
|
||||
private slots:
|
||||
void slotRangeFilterI();
|
||||
|
||||
Reference in New Issue
Block a user