mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3402 HoloLens : Add visibleParts to RiuViewer
This commit is contained in:
@@ -45,7 +45,6 @@
|
|||||||
#include "cvfRenderState.h"
|
#include "cvfRenderState.h"
|
||||||
#include "cvfRenderStateTextureBindings.h"
|
#include "cvfRenderStateTextureBindings.h"
|
||||||
#include "cvfRenderState_FF.h"
|
#include "cvfRenderState_FF.h"
|
||||||
#include "cvfScene.h"
|
|
||||||
#include "cvfTexture.h"
|
#include "cvfTexture.h"
|
||||||
#include "cvfTexture2D_FF.h"
|
#include "cvfTexture2D_FF.h"
|
||||||
|
|
||||||
@@ -63,145 +62,140 @@ std::vector<VdeExportPart> RicHoloLensExportImpl::partsForExport(const RimGridVi
|
|||||||
|
|
||||||
if (view.viewer())
|
if (view.viewer())
|
||||||
{
|
{
|
||||||
cvf::Scene* scene = view.viewer()->currentScene();
|
auto visibleParts = view.viewer()->visibleParts();
|
||||||
if (scene)
|
|
||||||
|
for (auto& scenePart : visibleParts)
|
||||||
{
|
{
|
||||||
cvf::Collection<cvf::Part> sceneParts;
|
if (RicHoloLensExportImpl::isGrid(scenePart.p()))
|
||||||
scene->allParts(&sceneParts);
|
|
||||||
|
|
||||||
for (auto& scenePart : sceneParts)
|
|
||||||
{
|
{
|
||||||
if (RicHoloLensExportImpl::isGrid(scenePart.p()))
|
VdeExportPart partForExport(scenePart.p());
|
||||||
|
partForExport.setSourceObjectType(VdeExportPart::OBJ_TYPE_GRID);
|
||||||
|
|
||||||
|
if (rimEclipseCase && rimEclipseCase->mainGrid())
|
||||||
{
|
{
|
||||||
VdeExportPart partForExport(scenePart.p());
|
if (rimEclipseCase->mainGrid()->isFaceNormalsOutwards())
|
||||||
partForExport.setSourceObjectType(VdeExportPart::OBJ_TYPE_GRID);
|
|
||||||
|
|
||||||
if (rimEclipseCase && rimEclipseCase->mainGrid())
|
|
||||||
{
|
{
|
||||||
if (rimEclipseCase->mainGrid()->isFaceNormalsOutwards())
|
partForExport.setWinding(VdeExportPart::COUNTERCLOCKWISE);
|
||||||
{
|
|
||||||
partForExport.setWinding(VdeExportPart::COUNTERCLOCKWISE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
partForExport.setWinding(VdeExportPart::CLOCKWISE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
auto* si = dynamic_cast<RivSourceInfo*>(scenePart->sourceInfo());
|
|
||||||
if (si)
|
|
||||||
{
|
{
|
||||||
RimFaultInView* faultInView = dynamic_cast<RimFaultInView*>(si->object());
|
partForExport.setWinding(VdeExportPart::CLOCKWISE);
|
||||||
if (faultInView)
|
|
||||||
{
|
|
||||||
partForExport.setSourceObjectName(faultInView->name());
|
|
||||||
partForExport.setColor(faultInView->faultColor());
|
|
||||||
}
|
|
||||||
|
|
||||||
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(si->object());
|
|
||||||
if (eclipseCase)
|
|
||||||
{
|
|
||||||
QString nameOfObject = rimEclipseCase->gridFileName();
|
|
||||||
auto gridSourceInfo = dynamic_cast<const RivSourceInfo*>(scenePart->sourceInfo());
|
|
||||||
if (gridSourceInfo)
|
|
||||||
{
|
|
||||||
size_t gridIndex = gridSourceInfo->gridIndex();
|
|
||||||
|
|
||||||
nameOfObject += " Grid " + QString::number(gridIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
const RimEclipseView* eclipseView = dynamic_cast<const RimEclipseView*>(&view);
|
|
||||||
if (eclipseView)
|
|
||||||
{
|
|
||||||
cvf::Color4f color = eclipseView->colorFromCellCategory(si->cellSetType());
|
|
||||||
partForExport.setColor(color.toColor3f());
|
|
||||||
partForExport.setOpacity(color.a());
|
|
||||||
|
|
||||||
QString text = RicHoloLensExportImpl::gridCellSetTypeText(si->cellSetType());
|
|
||||||
partForExport.setSourceObjectCellSetType(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
partForExport.setSourceObjectName(nameOfObject);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if texture image is present
|
|
||||||
if (scenePart->effect())
|
|
||||||
{
|
|
||||||
{
|
|
||||||
auto textureBindings = dynamic_cast<cvf::RenderStateTextureBindings*>(
|
|
||||||
scenePart->effect()->renderStateOfType(cvf::RenderState::TEXTURE_BINDINGS));
|
|
||||||
|
|
||||||
if (textureBindings && textureBindings->bindingCount() > 0)
|
|
||||||
{
|
|
||||||
cvf::Texture* textureBinding = textureBindings->texture(0);
|
|
||||||
partForExport.setTextureImage(textureBinding->image());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
auto textureMappingFF = dynamic_cast<cvf::RenderStateTextureMapping_FF*>(
|
|
||||||
scenePart->effect()->renderStateOfType(cvf::RenderState::TEXTURE_MAPPING_FF));
|
|
||||||
|
|
||||||
if (textureMappingFF && textureMappingFF->texture())
|
|
||||||
{
|
|
||||||
auto* texture = textureMappingFF->texture();
|
|
||||||
partForExport.setTextureImage(texture->image());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exportParts.push_back(partForExport);
|
|
||||||
}
|
}
|
||||||
else if (RicHoloLensExportImpl::isPipe(scenePart.p()))
|
|
||||||
|
auto* si = dynamic_cast<RivSourceInfo*>(scenePart->sourceInfo());
|
||||||
|
if (si)
|
||||||
{
|
{
|
||||||
VdeExportPart partForExport(scenePart.p());
|
RimFaultInView* faultInView = dynamic_cast<RimFaultInView*>(si->object());
|
||||||
partForExport.setSourceObjectType(VdeExportPart::OBJ_TYPE_PIPE);
|
if (faultInView)
|
||||||
|
|
||||||
auto simWellSourceInfo = dynamic_cast<const RivSimWellPipeSourceInfo*>(scenePart->sourceInfo());
|
|
||||||
if (simWellSourceInfo)
|
|
||||||
{
|
{
|
||||||
auto simWell = simWellSourceInfo->well();
|
partForExport.setSourceObjectName(faultInView->name());
|
||||||
if (simWell)
|
partForExport.setColor(faultInView->faultColor());
|
||||||
{
|
|
||||||
partForExport.setSourceObjectName(simWell->name());
|
|
||||||
partForExport.setColor(simWell->wellPipeColor());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>(scenePart->sourceInfo());
|
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(si->object());
|
||||||
if (wellPathSourceInfo)
|
if (eclipseCase)
|
||||||
{
|
{
|
||||||
RimWellPath* wellPath = wellPathSourceInfo->wellPath();
|
QString nameOfObject = rimEclipseCase->gridFileName();
|
||||||
if (wellPath)
|
auto gridSourceInfo = dynamic_cast<const RivSourceInfo*>(scenePart->sourceInfo());
|
||||||
|
if (gridSourceInfo)
|
||||||
{
|
{
|
||||||
partForExport.setSourceObjectName(wellPath->name());
|
size_t gridIndex = gridSourceInfo->gridIndex();
|
||||||
partForExport.setColor(wellPath->wellPathColor());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exportParts.push_back(partForExport);
|
nameOfObject += " Grid " + QString::number(gridIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
const RimEclipseView* eclipseView = dynamic_cast<const RimEclipseView*>(&view);
|
||||||
|
if (eclipseView)
|
||||||
|
{
|
||||||
|
cvf::Color4f color = eclipseView->colorFromCellCategory(si->cellSetType());
|
||||||
|
partForExport.setColor(color.toColor3f());
|
||||||
|
partForExport.setOpacity(color.a());
|
||||||
|
|
||||||
|
QString text = RicHoloLensExportImpl::gridCellSetTypeText(si->cellSetType());
|
||||||
|
partForExport.setSourceObjectCellSetType(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
partForExport.setSourceObjectName(nameOfObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (RicHoloLensExportImpl::isMeshLines(scenePart.p()))
|
|
||||||
|
// Check if texture image is present
|
||||||
|
if (scenePart->effect())
|
||||||
{
|
{
|
||||||
VdeExportPart partForExport(scenePart.p());
|
|
||||||
partForExport.setSourceObjectType(VdeExportPart::OBJ_TYPE_GRID_MESH);
|
|
||||||
|
|
||||||
cvf::Color3f lineColor = RiaApplication::instance()->preferences()->defaultGridLineColors();
|
|
||||||
|
|
||||||
auto linesSourceInfo = dynamic_cast<const RivMeshLinesSourceInfo*>(scenePart->sourceInfo());
|
|
||||||
if (linesSourceInfo)
|
|
||||||
{
|
{
|
||||||
if (dynamic_cast<RimFaultInView*>(linesSourceInfo->object()))
|
auto textureBindings = dynamic_cast<cvf::RenderStateTextureBindings*>(
|
||||||
|
scenePart->effect()->renderStateOfType(cvf::RenderState::TEXTURE_BINDINGS));
|
||||||
|
|
||||||
|
if (textureBindings && textureBindings->bindingCount() > 0)
|
||||||
{
|
{
|
||||||
lineColor = RiaApplication::instance()->preferences()->defaultFaultGridLineColors();
|
cvf::Texture* textureBinding = textureBindings->texture(0);
|
||||||
|
partForExport.setTextureImage(textureBinding->image());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
partForExport.setColor(lineColor);
|
{
|
||||||
|
auto textureMappingFF = dynamic_cast<cvf::RenderStateTextureMapping_FF*>(
|
||||||
|
scenePart->effect()->renderStateOfType(cvf::RenderState::TEXTURE_MAPPING_FF));
|
||||||
|
|
||||||
exportParts.push_back(partForExport);
|
if (textureMappingFF && textureMappingFF->texture())
|
||||||
|
{
|
||||||
|
auto* texture = textureMappingFF->texture();
|
||||||
|
partForExport.setTextureImage(texture->image());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exportParts.push_back(partForExport);
|
||||||
|
}
|
||||||
|
else if (RicHoloLensExportImpl::isPipe(scenePart.p()))
|
||||||
|
{
|
||||||
|
VdeExportPart partForExport(scenePart.p());
|
||||||
|
partForExport.setSourceObjectType(VdeExportPart::OBJ_TYPE_PIPE);
|
||||||
|
|
||||||
|
auto simWellSourceInfo = dynamic_cast<const RivSimWellPipeSourceInfo*>(scenePart->sourceInfo());
|
||||||
|
if (simWellSourceInfo)
|
||||||
|
{
|
||||||
|
auto simWell = simWellSourceInfo->well();
|
||||||
|
if (simWell)
|
||||||
|
{
|
||||||
|
partForExport.setSourceObjectName(simWell->name());
|
||||||
|
partForExport.setColor(simWell->wellPipeColor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>(scenePart->sourceInfo());
|
||||||
|
if (wellPathSourceInfo)
|
||||||
|
{
|
||||||
|
RimWellPath* wellPath = wellPathSourceInfo->wellPath();
|
||||||
|
if (wellPath)
|
||||||
|
{
|
||||||
|
partForExport.setSourceObjectName(wellPath->name());
|
||||||
|
partForExport.setColor(wellPath->wellPathColor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exportParts.push_back(partForExport);
|
||||||
|
}
|
||||||
|
else if (RicHoloLensExportImpl::isMeshLines(scenePart.p()))
|
||||||
|
{
|
||||||
|
VdeExportPart partForExport(scenePart.p());
|
||||||
|
partForExport.setSourceObjectType(VdeExportPart::OBJ_TYPE_GRID_MESH);
|
||||||
|
|
||||||
|
cvf::Color3f lineColor = RiaApplication::instance()->preferences()->defaultGridLineColors();
|
||||||
|
|
||||||
|
auto linesSourceInfo = dynamic_cast<const RivMeshLinesSourceInfo*>(scenePart->sourceInfo());
|
||||||
|
if (linesSourceInfo)
|
||||||
|
{
|
||||||
|
if (dynamic_cast<RimFaultInView*>(linesSourceInfo->object()))
|
||||||
|
{
|
||||||
|
lineColor = RiaApplication::instance()->preferences()->defaultFaultGridLineColors();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
partForExport.setColor(lineColor);
|
||||||
|
|
||||||
|
exportParts.push_back(partForExport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
#include "cvfFont.h"
|
#include "cvfFont.h"
|
||||||
#include "cvfOpenGLResourceManager.h"
|
#include "cvfOpenGLResourceManager.h"
|
||||||
#include "cvfOverlayAxisCross.h"
|
#include "cvfOverlayAxisCross.h"
|
||||||
|
#include "cvfPartRenderHintCollection.h"
|
||||||
#include "cvfRenderQueueSorter.h"
|
#include "cvfRenderQueueSorter.h"
|
||||||
#include "cvfRenderSequence.h"
|
#include "cvfRenderSequence.h"
|
||||||
#include "cvfRendering.h"
|
#include "cvfRendering.h"
|
||||||
@@ -921,6 +922,40 @@ void RiuViewer::setCursorPosition(const cvf::Vec3d& domainCoord)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::vector<cvf::ref<cvf::Part>> RiuViewer::visibleParts()
|
||||||
|
{
|
||||||
|
std::vector<cvf::ref<cvf::Part>> partsMatchingEnableMask;
|
||||||
|
|
||||||
|
if (m_mainRendering.notNull())
|
||||||
|
{
|
||||||
|
auto enableMask = m_mainRendering->enableMask();
|
||||||
|
cvf::Scene* scene = currentScene();
|
||||||
|
|
||||||
|
for (cvf::uint i = 0; i < scene->modelCount(); i++)
|
||||||
|
{
|
||||||
|
cvf::Model* model = scene->model(i);
|
||||||
|
if (enableMask & model->partEnableMask())
|
||||||
|
{
|
||||||
|
cvf::Collection<cvf::Part> partCollection;
|
||||||
|
model->allParts(&partCollection);
|
||||||
|
|
||||||
|
for (const auto& p : partCollection)
|
||||||
|
{
|
||||||
|
if (enableMask & p->enableMask())
|
||||||
|
{
|
||||||
|
partsMatchingEnableMask.push_back(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return partsMatchingEnableMask;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -116,6 +116,8 @@ public:
|
|||||||
|
|
||||||
void setCursorPosition(const cvf::Vec3d& domainCoord);
|
void setCursorPosition(const cvf::Vec3d& domainCoord);
|
||||||
|
|
||||||
|
std::vector<cvf::ref<cvf::Part>> visibleParts();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void slotSetCurrentFrame(int frameIndex) override;
|
void slotSetCurrentFrame(int frameIndex) override;
|
||||||
void slotEndAnimation() override;
|
void slotEndAnimation() override;
|
||||||
|
|||||||
Reference in New Issue
Block a user