diff --git a/ApplicationCode/Commands/HoloLensCommands/RicHoloLensExportImpl.cpp b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensExportImpl.cpp index 4dfc521b99..e71f3d9b75 100644 --- a/ApplicationCode/Commands/HoloLensCommands/RicHoloLensExportImpl.cpp +++ b/ApplicationCode/Commands/HoloLensCommands/RicHoloLensExportImpl.cpp @@ -45,7 +45,6 @@ #include "cvfRenderState.h" #include "cvfRenderStateTextureBindings.h" #include "cvfRenderState_FF.h" -#include "cvfScene.h" #include "cvfTexture.h" #include "cvfTexture2D_FF.h" @@ -63,145 +62,140 @@ std::vector RicHoloLensExportImpl::partsForExport(const RimGridVi if (view.viewer()) { - cvf::Scene* scene = view.viewer()->currentScene(); - if (scene) + auto visibleParts = view.viewer()->visibleParts(); + + for (auto& scenePart : visibleParts) { - cvf::Collection sceneParts; - scene->allParts(&sceneParts); - - for (auto& scenePart : sceneParts) + if (RicHoloLensExportImpl::isGrid(scenePart.p())) { - if (RicHoloLensExportImpl::isGrid(scenePart.p())) + VdeExportPart partForExport(scenePart.p()); + partForExport.setSourceObjectType(VdeExportPart::OBJ_TYPE_GRID); + + if (rimEclipseCase && rimEclipseCase->mainGrid()) { - VdeExportPart partForExport(scenePart.p()); - partForExport.setSourceObjectType(VdeExportPart::OBJ_TYPE_GRID); - - if (rimEclipseCase && rimEclipseCase->mainGrid()) + if (rimEclipseCase->mainGrid()->isFaceNormalsOutwards()) { - if (rimEclipseCase->mainGrid()->isFaceNormalsOutwards()) - { - partForExport.setWinding(VdeExportPart::COUNTERCLOCKWISE); - } - else - { - partForExport.setWinding(VdeExportPart::CLOCKWISE); - } + partForExport.setWinding(VdeExportPart::COUNTERCLOCKWISE); } - - auto* si = dynamic_cast(scenePart->sourceInfo()); - if (si) + else { - RimFaultInView* faultInView = dynamic_cast(si->object()); - if (faultInView) - { - partForExport.setSourceObjectName(faultInView->name()); - partForExport.setColor(faultInView->faultColor()); - } - - RimEclipseCase* eclipseCase = dynamic_cast(si->object()); - if (eclipseCase) - { - QString nameOfObject = rimEclipseCase->gridFileName(); - auto gridSourceInfo = dynamic_cast(scenePart->sourceInfo()); - if (gridSourceInfo) - { - size_t gridIndex = gridSourceInfo->gridIndex(); - - nameOfObject += " Grid " + QString::number(gridIndex); - } - - const RimEclipseView* eclipseView = dynamic_cast(&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); - } + partForExport.setWinding(VdeExportPart::CLOCKWISE); } - - // Check if texture image is present - if (scenePart->effect()) - { - { - auto textureBindings = dynamic_cast( - 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( - 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(scenePart->sourceInfo()); + if (si) { - VdeExportPart partForExport(scenePart.p()); - partForExport.setSourceObjectType(VdeExportPart::OBJ_TYPE_PIPE); - - auto simWellSourceInfo = dynamic_cast(scenePart->sourceInfo()); - if (simWellSourceInfo) + RimFaultInView* faultInView = dynamic_cast(si->object()); + if (faultInView) { - auto simWell = simWellSourceInfo->well(); - if (simWell) - { - partForExport.setSourceObjectName(simWell->name()); - partForExport.setColor(simWell->wellPipeColor()); - } + partForExport.setSourceObjectName(faultInView->name()); + partForExport.setColor(faultInView->faultColor()); } - auto wellPathSourceInfo = dynamic_cast(scenePart->sourceInfo()); - if (wellPathSourceInfo) + RimEclipseCase* eclipseCase = dynamic_cast(si->object()); + if (eclipseCase) { - RimWellPath* wellPath = wellPathSourceInfo->wellPath(); - if (wellPath) + QString nameOfObject = rimEclipseCase->gridFileName(); + auto gridSourceInfo = dynamic_cast(scenePart->sourceInfo()); + if (gridSourceInfo) { - partForExport.setSourceObjectName(wellPath->name()); - partForExport.setColor(wellPath->wellPathColor()); - } - } + size_t gridIndex = gridSourceInfo->gridIndex(); - exportParts.push_back(partForExport); + nameOfObject += " Grid " + QString::number(gridIndex); + } + + const RimEclipseView* eclipseView = dynamic_cast(&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(scenePart->sourceInfo()); - if (linesSourceInfo) { - if (dynamic_cast(linesSourceInfo->object())) + auto textureBindings = dynamic_cast( + 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( + 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(scenePart->sourceInfo()); + if (simWellSourceInfo) + { + auto simWell = simWellSourceInfo->well(); + if (simWell) + { + partForExport.setSourceObjectName(simWell->name()); + partForExport.setColor(simWell->wellPipeColor()); + } + } + + auto wellPathSourceInfo = dynamic_cast(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(scenePart->sourceInfo()); + if (linesSourceInfo) + { + if (dynamic_cast(linesSourceInfo->object())) + { + lineColor = RiaApplication::instance()->preferences()->defaultFaultGridLineColors(); + } + } + + partForExport.setColor(lineColor); + + exportParts.push_back(partForExport); } } } diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index d4cad38af6..5c32072c58 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -53,6 +53,7 @@ #include "cvfFont.h" #include "cvfOpenGLResourceManager.h" #include "cvfOverlayAxisCross.h" +#include "cvfPartRenderHintCollection.h" #include "cvfRenderQueueSorter.h" #include "cvfRenderSequence.h" #include "cvfRendering.h" @@ -921,6 +922,40 @@ void RiuViewer::setCursorPosition(const cvf::Vec3d& domainCoord) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector> RiuViewer::visibleParts() +{ + std::vector> 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 partCollection; + model->allParts(&partCollection); + + for (const auto& p : partCollection) + { + if (enableMask & p->enableMask()) + { + partsMatchingEnableMask.push_back(p); + } + } + } + } + } + + return partsMatchingEnableMask; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuViewer.h b/ApplicationCode/UserInterface/RiuViewer.h index caaf5b9658..247ce36b45 100644 --- a/ApplicationCode/UserInterface/RiuViewer.h +++ b/ApplicationCode/UserInterface/RiuViewer.h @@ -116,6 +116,8 @@ public: void setCursorPosition(const cvf::Vec3d& domainCoord); + std::vector> visibleParts(); + public slots: void slotSetCurrentFrame(int frameIndex) override; void slotEndAnimation() override;