mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Added label and label anchor line. Setting to control fault outside filter.
This commit is contained in:
@@ -39,6 +39,7 @@ RivFaultGeometryGenerator::RivFaultGeometryGenerator(const cvf::StructGridInterf
|
||||
{
|
||||
m_showNativeFaultFaces = true;
|
||||
m_showOppositeFaultFaces = true;
|
||||
m_limitFaultsToFilters = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -162,7 +163,11 @@ void RivFaultGeometryGenerator::computeArrays()
|
||||
for (size_t fIdx = 0; fIdx < faultFaces.size(); fIdx++)
|
||||
{
|
||||
size_t cellIndex = faultFaces[fIdx].m_globalCellIndex;
|
||||
if (!(*m_cellVisibility)[cellIndex]) continue;
|
||||
|
||||
if (m_limitFaultsToFilters)
|
||||
{
|
||||
if (!(*m_cellVisibility)[cellIndex]) continue;
|
||||
}
|
||||
|
||||
cvf::StructGridInterface::FaceType face = faultFaces[fIdx].m_face;
|
||||
|
||||
@@ -202,7 +207,10 @@ void RivFaultGeometryGenerator::computeArrays()
|
||||
|
||||
size_t cellIndex = m_grid->cellIndexFromIJK(ni, nj, nk);
|
||||
|
||||
if (!(*m_cellVisibility)[cellIndex]) continue;
|
||||
if (m_limitFaultsToFilters)
|
||||
{
|
||||
if (!(*m_cellVisibility)[cellIndex]) continue;
|
||||
}
|
||||
|
||||
cvf::Vec3d cornerVerts[8];
|
||||
m_grid->cellCornerVertices(cellIndex, cornerVerts);
|
||||
@@ -320,3 +328,11 @@ void RivFaultGeometryGenerator::setShowOppositeFaultFaces(bool showOppositeFault
|
||||
m_showOppositeFaultFaces = showOppositeFaultFaces;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFaultGeometryGenerator::setLimitFaultsToFilter(bool limitFaultsToFilter)
|
||||
{
|
||||
m_limitFaultsToFilters = limitFaultsToFilter;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ public:
|
||||
|
||||
void setShowNativeFaultFaces(bool showNativeFaultFaces);
|
||||
void setShowOppositeFaultFaces(bool showOppositeFaultFaces);
|
||||
void setLimitFaultsToFilter(bool limitFaultsToFilter);
|
||||
|
||||
void textureCoordinates(cvf::Vec2fArray* textureCoords,
|
||||
const cvf::StructGridScalarDataAccess* dataAccessObject,
|
||||
@@ -78,6 +79,7 @@ private:
|
||||
|
||||
bool m_showNativeFaultFaces;
|
||||
bool m_showOppositeFaultFaces;
|
||||
bool m_limitFaultsToFilters;
|
||||
|
||||
// Created arrays
|
||||
cvf::ref<cvf::Vec3fArray> m_vertices;
|
||||
|
||||
@@ -40,6 +40,10 @@
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
#include "cvfDrawableText.h"
|
||||
#include "cvfqtUtils.h"
|
||||
#include "cvfPrimitiveSetIndexedUInt.h"
|
||||
#include "cvfPrimitiveSetDirect.h"
|
||||
|
||||
|
||||
|
||||
@@ -66,6 +70,7 @@ RivFaultPart::RivFaultPart(const RigGridBase* grid, const RimFault* rimFault)
|
||||
|
||||
m_showNativeFaces = true;
|
||||
m_showOppositeFaces = true;
|
||||
m_showLabel = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -105,6 +110,25 @@ void RivFaultPart::setShowOppositeFaces(bool showOppositeFaces)
|
||||
m_showOppositeFaces = showOppositeFaces;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFaultPart::setShowLabel(bool showLabel)
|
||||
{
|
||||
m_showLabel = showLabel;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFaultPart::setLimitFaultToVisibleCells(bool limitFaultToVisibleCells)
|
||||
{
|
||||
m_nativeFaultGenerator.setLimitFaultsToFilter(limitFaultToVisibleCells);
|
||||
m_oppositeFaultGenerator.setLimitFaultsToFilter(limitFaultToVisibleCells);
|
||||
|
||||
generatePartGeometry();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -251,19 +275,25 @@ void RivFaultPart::appendPartsToModel(cvf::ModelBasicList* model)
|
||||
|
||||
if (!m_rimFault->showFault()) return;
|
||||
|
||||
if (m_showNativeFaces)
|
||||
if (m_showNativeFaces && m_nativeFaultFaces.notNull())
|
||||
{
|
||||
if(m_nativeFaultFaces.notNull() ) model->addPart(m_nativeFaultFaces.p() );
|
||||
model->addPart(m_nativeFaultFaces.p());
|
||||
}
|
||||
|
||||
if (m_showOppositeFaces)
|
||||
if (m_showOppositeFaces && m_oppositeFaultFaces.notNull())
|
||||
{
|
||||
if(m_oppositeFaultFaces.notNull() ) model->addPart(m_oppositeFaultFaces.p() );
|
||||
model->addPart(m_oppositeFaultFaces.p());
|
||||
}
|
||||
|
||||
// Always show gridlines for both native and opposite fault faces
|
||||
if(m_nativeFaultGridLines.notNull() ) model->addPart(m_nativeFaultGridLines.p() );
|
||||
if(m_oppositeFaultGridLines.notNull() ) model->addPart(m_oppositeFaultGridLines.p() );
|
||||
// Always show grid lines for both native and opposite fault faces
|
||||
if (m_nativeFaultGridLines.notNull()) model->addPart(m_nativeFaultGridLines.p());
|
||||
if (m_oppositeFaultGridLines.notNull()) model->addPart(m_oppositeFaultGridLines.p());
|
||||
|
||||
if (m_showLabel)
|
||||
{
|
||||
if (m_faultLabelPart.notNull()) model->addPart(m_faultLabelPart.p());
|
||||
if (m_faultLabelLinePart.notNull()) model->addPart(m_faultLabelLinePart.p());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -288,7 +318,6 @@ void RivFaultPart::generatePartGeometry()
|
||||
part->setName("Grid " + cvf::String(static_cast<int>(m_grid->gridIndex())));
|
||||
part->setId(m_grid->gridIndex()); // !! For now, use grid index as part ID (needed for pick info)
|
||||
part->setDrawable(geo.p());
|
||||
//part->setTransform(m_scaleTransform.p());
|
||||
|
||||
// Set mapping from triangle face index to cell index
|
||||
part->setSourceInfo(m_nativeFaultGenerator.triangleToSourceGridCellMap().p());
|
||||
@@ -314,7 +343,6 @@ void RivFaultPart::generatePartGeometry()
|
||||
part->setName("Grid mesh" + cvf::String(static_cast<int>(m_grid->gridIndex())));
|
||||
part->setDrawable(geoMesh.p());
|
||||
|
||||
//part->setTransform(m_scaleTransform.p());
|
||||
part->updateBoundingBox();
|
||||
part->setEnableMask(meshFaultBit);
|
||||
|
||||
@@ -339,7 +367,6 @@ void RivFaultPart::generatePartGeometry()
|
||||
part->setName("Grid " + cvf::String(static_cast<int>(m_grid->gridIndex())));
|
||||
part->setId(m_grid->gridIndex()); // !! For now, use grid index as part ID (needed for pick info)
|
||||
part->setDrawable(geo.p());
|
||||
//part->setTransform(m_scaleTransform.p());
|
||||
|
||||
// Set mapping from triangle face index to cell index
|
||||
part->setSourceInfo(m_oppositeFaultGenerator.triangleToSourceGridCellMap().p());
|
||||
@@ -365,7 +392,6 @@ void RivFaultPart::generatePartGeometry()
|
||||
part->setName("Grid mesh" + cvf::String(static_cast<int>(m_grid->gridIndex())));
|
||||
part->setDrawable(geoMesh.p());
|
||||
|
||||
//part->setTransform(m_scaleTransform.p());
|
||||
part->updateBoundingBox();
|
||||
part->setEnableMask(meshFaultBit);
|
||||
|
||||
@@ -373,6 +399,25 @@ void RivFaultPart::generatePartGeometry()
|
||||
}
|
||||
}
|
||||
|
||||
m_faultLabelPart = NULL;
|
||||
if (m_rimFault->showFaultLabel())
|
||||
{
|
||||
cvf::ref<cvf::Part> partToAttachLabelTo;
|
||||
if (m_nativeFaultFaces.notNull())
|
||||
{
|
||||
partToAttachLabelTo = m_nativeFaultFaces;
|
||||
}
|
||||
else if(m_oppositeFaultFaces.notNull())
|
||||
{
|
||||
partToAttachLabelTo = m_oppositeFaultFaces;
|
||||
}
|
||||
|
||||
if (partToAttachLabelTo.notNull())
|
||||
{
|
||||
createLabelWithAnchorLine(partToAttachLabelTo.p());
|
||||
}
|
||||
}
|
||||
|
||||
updatePartEffect();
|
||||
}
|
||||
|
||||
@@ -433,3 +478,121 @@ void RivFaultPart::updatePartEffect()
|
||||
m_oppositeFaultGridLines->setEffect(eff.p());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFaultPart::createLabelWithAnchorLine(const cvf::Part* part)
|
||||
{
|
||||
CVF_ASSERT(part);
|
||||
|
||||
cvf::BoundingBox bb = part->boundingBox();
|
||||
|
||||
cvf::Vec3d bbTopCenter = bb.center();
|
||||
bbTopCenter.z() = bb.max().z();
|
||||
|
||||
const cvf::DrawableGeo* geo = dynamic_cast<const cvf::DrawableGeo*>(part->drawable());
|
||||
|
||||
// Find closest vertex to top of bounding box.
|
||||
// Will be recomputed when filter changes, to make sure the label is always visible
|
||||
// for any filter combination
|
||||
cvf::Vec3f faultVertexToAttachLabel = findClosestVertex(cvf::Vec3f(bbTopCenter), geo->vertexArray());
|
||||
|
||||
cvf::Vec3f labelPosition = faultVertexToAttachLabel;
|
||||
labelPosition.z() += bb.extent().z() / 2;
|
||||
|
||||
// Fault label
|
||||
{
|
||||
cvf::Font* standardFont = RiaApplication::instance()->standardFont();
|
||||
|
||||
cvf::ref<cvf::DrawableText> drawableText = new cvf::DrawableText;
|
||||
drawableText->setFont(standardFont);
|
||||
drawableText->setCheckPosVisible(false);
|
||||
drawableText->setDrawBorder(false);
|
||||
drawableText->setDrawBackground(false);
|
||||
drawableText->setVerticalAlignment(cvf::TextDrawer::CENTER);
|
||||
drawableText->setTextColor(m_rimFault->faultColor());
|
||||
|
||||
cvf::String cvfString = cvfqt::Utils::toString(m_rimFault->name());
|
||||
|
||||
cvf::Vec3f textCoord(labelPosition);
|
||||
double characteristicCellSize = bb.extent().z() / 20;
|
||||
textCoord.z() += characteristicCellSize;
|
||||
|
||||
drawableText->addText(cvfString, textCoord);
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName("RivFaultPart : text " + cvfString);
|
||||
part->setDrawable(drawableText.p());
|
||||
|
||||
cvf::ref<cvf::Effect> eff = new cvf::Effect;
|
||||
|
||||
part->setEffect(eff.p());
|
||||
part->setPriority(1000);
|
||||
|
||||
m_faultLabelPart = part;
|
||||
}
|
||||
|
||||
|
||||
// Line from fault geometry to label
|
||||
{
|
||||
cvf::ref<cvf::Vec3fArray> vertices = new cvf::Vec3fArray;
|
||||
vertices->reserve(2);
|
||||
vertices->add(faultVertexToAttachLabel);
|
||||
vertices->add(labelPosition);
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
|
||||
geo->setVertexArray(vertices.p());
|
||||
|
||||
cvf::ref<cvf::PrimitiveSetDirect> primSet = new cvf::PrimitiveSetDirect(cvf::PT_LINES);
|
||||
primSet->setStartIndex(0);
|
||||
primSet->setIndexCount(vertices->size());
|
||||
geo->addPrimitiveSet(primSet.p());
|
||||
|
||||
m_faultLabelLinePart = new cvf::Part;
|
||||
m_faultLabelLinePart->setName("Anchor line for label" + cvf::String(static_cast<int>(m_grid->gridIndex())));
|
||||
m_faultLabelLinePart->setDrawable(geo.p());
|
||||
|
||||
m_faultLabelLinePart->updateBoundingBox();
|
||||
|
||||
caf::MeshEffectGenerator gen(m_rimFault->faultColor());
|
||||
cvf::ref<cvf::Effect> eff = gen.generateEffect();
|
||||
|
||||
m_faultLabelLinePart->setEffect(eff.p());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec3f RivFaultPart::findClosestVertex(const cvf::Vec3f& point, const cvf::Vec3fArray* vertices)
|
||||
{
|
||||
CVF_ASSERT(vertices);
|
||||
|
||||
if (!vertices) return cvf::Vec3f::UNDEFINED;
|
||||
|
||||
float closestDiff(HUGE_VAL);
|
||||
|
||||
size_t closestIndex = cvf::UNDEFINED_SIZE_T;
|
||||
|
||||
for (size_t i = 0; i < vertices->size(); i++)
|
||||
{
|
||||
float diff = point.pointDistance(vertices->get(i));
|
||||
|
||||
if (diff < closestDiff)
|
||||
{
|
||||
closestDiff = diff;
|
||||
closestIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (closestIndex != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
return vertices->get(closestIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
return cvf::Vec3f::UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,12 +55,18 @@ public:
|
||||
|
||||
void setShowNativeFaces(bool showNativeFaces);
|
||||
void setShowOppositeFaces(bool showOppositeFaces);
|
||||
void setShowLabel(bool showLabel);
|
||||
void setLimitFaultToVisibleCells(bool limitFaultToVisibleCells);
|
||||
|
||||
void appendPartsToModel(cvf::ModelBasicList* model);
|
||||
|
||||
private:
|
||||
void generatePartGeometry();
|
||||
void updatePartEffect();
|
||||
|
||||
void createLabelWithAnchorLine(const cvf::Part* part);
|
||||
|
||||
static cvf::Vec3f findClosestVertex(const cvf::Vec3f& point, const cvf::Vec3fArray* vertices);
|
||||
|
||||
private:
|
||||
cvf::cref<RigGridBase> m_grid;
|
||||
@@ -71,6 +77,7 @@ private:
|
||||
|
||||
bool m_showNativeFaces;
|
||||
bool m_showOppositeFaces;
|
||||
bool m_showLabel;
|
||||
|
||||
cvf::ref<cvf::UByteArray> m_cellVisibility;
|
||||
|
||||
@@ -83,4 +90,7 @@ private:
|
||||
cvf::ref<cvf::Part> m_oppositeFaultFaces;
|
||||
cvf::ref<cvf::Part> m_oppositeFaultGridLines;
|
||||
cvf::ref<cvf::Vec2fArray> m_oppositeFaultFacesTextureCoords;
|
||||
|
||||
cvf::ref<cvf::Part> m_faultLabelPart;
|
||||
cvf::ref<cvf::Part> m_faultLabelLinePart;
|
||||
};
|
||||
|
||||
@@ -103,9 +103,11 @@ void RivFaultPartMgr::appendPartsToModel(cvf::ModelBasicList* model)
|
||||
{
|
||||
cvf::ref<RivFaultPart> rivFaultPart = m_faultParts[i];
|
||||
|
||||
// Distribute fault settings from fault collection to fault parts
|
||||
// Propagate settings from RimFaultCollection to RivFaultPart
|
||||
rivFaultPart->setShowNativeFaces(m_faultCollection->showFaultFaces());
|
||||
rivFaultPart->setShowOppositeFaces(m_faultCollection->showOppositeFaultFaces());
|
||||
rivFaultPart->setShowLabel(m_faultCollection->showFaultLabel());
|
||||
rivFaultPart->setLimitFaultToVisibleCells(m_faultCollection->limitFaultsToFilter());
|
||||
|
||||
rivFaultPart->appendPartsToModel(&parts);
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ RimFaultCollection::RimFaultCollection()
|
||||
|
||||
CAF_PDM_InitField(&showFaultFaces, "ShowFaultFaces", true, "Show faults faces", "", "", "");
|
||||
CAF_PDM_InitField(&showOppositeFaultFaces, "ShowOppositeFaultFaces", true, "Show opposite fault faces", "", "", "");
|
||||
CAF_PDM_InitField(&limitFaultsToFilter, "LimitFaultsToFilter", true, "Hide fault outside filters", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&showFaultLabel, "ShowFaultLabel", true, "Show fault labels", "", "", "");
|
||||
cvf::Color3f defWellLabelColor = RiaApplication::instance()->preferences()->defaultWellLabelColor();
|
||||
@@ -83,23 +84,20 @@ void RimFaultCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedFiel
|
||||
if (&showFaultCollection == changedField)
|
||||
{
|
||||
this->updateUiIconFromState(showFaultCollection);
|
||||
|
||||
if (m_reservoirView)
|
||||
{
|
||||
m_reservoirView->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
if (&showGeometryDetectedFaults == changedField ||
|
||||
&showFaultFaces == changedField ||
|
||||
&showOppositeFaultFaces == changedField)
|
||||
&showOppositeFaultFaces == changedField ||
|
||||
&showFaultCollection == changedField ||
|
||||
&showFaultLabel == changedField ||
|
||||
&limitFaultsToFilter == changedField)
|
||||
{
|
||||
if (m_reservoirView)
|
||||
{
|
||||
m_reservoirView->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -51,6 +51,7 @@ public:
|
||||
|
||||
caf::PdmField<bool> showFaultFaces;
|
||||
caf::PdmField<bool> showOppositeFaultFaces;
|
||||
caf::PdmField<bool> limitFaultsToFilter;
|
||||
|
||||
caf::PdmField<bool> showFaultLabel;
|
||||
caf::PdmField<cvf::Color3f> faultLabelColor;
|
||||
|
||||
Reference in New Issue
Block a user