mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Added scalarMapperUtils for code sharing between grids/faults
This commit is contained in:
parent
c67b75e992
commit
eca4276adb
@ -28,6 +28,7 @@ ${CEE_CURRENT_LIST_DIR}RivTextureCoordsCreator.h
|
||||
${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapper.h
|
||||
${CEE_CURRENT_LIST_DIR}RivTernaryTextureCoordsCreator.h
|
||||
${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapperEffectGenerator.h
|
||||
${CEE_CURRENT_LIST_DIR}RivScalarMapperUtils.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@ -52,6 +53,7 @@ ${CEE_CURRENT_LIST_DIR}RivTextureCoordsCreator.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapper.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivTernaryTextureCoordsCreator.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapperEffectGenerator.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivScalarMapperUtils.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
86
ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp
Normal file
86
ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA, Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RivScalarMapperUtils.h"
|
||||
|
||||
#include "RivTernaryScalarMapperEffectGenerator.h"
|
||||
#include "RivTernaryScalarMapper.h"
|
||||
|
||||
#include "cafEffectGenerator.h"
|
||||
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfPart.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivScalarMapperUtils::applyTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const cvf::ScalarMapper* mapper, float opacityLevel)
|
||||
{
|
||||
CVF_ASSERT(part && textureCoords && mapper);
|
||||
|
||||
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(part->drawable());
|
||||
if (dg) dg->setTextureCoordArray(textureCoords);
|
||||
|
||||
cvf::ref<cvf::Effect> scalarEffect = RivScalarMapperUtils::createScalarMapperEffect(mapper, opacityLevel);
|
||||
part->setEffect(scalarEffect.p());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivScalarMapperUtils::applyTernaryTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const RivTernaryScalarMapper* mapper, float opacityLevel)
|
||||
{
|
||||
CVF_ASSERT(part && textureCoords && mapper);
|
||||
|
||||
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(part->drawable());
|
||||
if (dg) dg->setTextureCoordArray(textureCoords);
|
||||
|
||||
cvf::ref<cvf::Effect> scalarEffect = RivScalarMapperUtils::createTernaryScalarMapperEffect(mapper, opacityLevel);
|
||||
part->setEffect(scalarEffect.p());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::Effect> RivScalarMapperUtils::createScalarMapperEffect(const cvf::ScalarMapper* mapper, float opacityLevel)
|
||||
{
|
||||
CVF_ASSERT(mapper);
|
||||
|
||||
caf::PolygonOffset polygonOffset = caf::PO_1;
|
||||
caf::ScalarMapperEffectGenerator scalarEffgen(mapper, polygonOffset);
|
||||
scalarEffgen.setOpacityLevel(opacityLevel);
|
||||
cvf::ref<cvf::Effect> scalarEffect = scalarEffgen.generateEffect();
|
||||
|
||||
return scalarEffect;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::Effect> RivScalarMapperUtils::createTernaryScalarMapperEffect(const RivTernaryScalarMapper* mapper, float opacityLevel)
|
||||
{
|
||||
CVF_ASSERT(mapper);
|
||||
|
||||
caf::PolygonOffset polygonOffset = caf::PO_1;
|
||||
RivTernaryScalarMapperEffectGenerator scalarEffgen(mapper, polygonOffset);
|
||||
scalarEffgen.setOpacityLevel(opacityLevel);
|
||||
cvf::ref<cvf::Effect> scalarEffect = scalarEffgen.generateEffect();
|
||||
|
||||
return scalarEffect;
|
||||
}
|
45
ApplicationCode/ModelVisualization/RivScalarMapperUtils.h
Normal file
45
ApplicationCode/ModelVisualization/RivScalarMapperUtils.h
Normal file
@ -0,0 +1,45 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA, Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cvfArray.h"
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class ScalarMapper;
|
||||
class Part;
|
||||
class Effect;
|
||||
}
|
||||
|
||||
class RivTernaryScalarMapper;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RivScalarMapperUtils
|
||||
{
|
||||
public:
|
||||
static void applyTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const cvf::ScalarMapper* mapper, float opacityLevel);
|
||||
static void applyTernaryTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const RivTernaryScalarMapper* mapper, float opacityLevel);
|
||||
|
||||
private:
|
||||
static cvf::ref<cvf::Effect> createScalarMapperEffect(const cvf::ScalarMapper* mapper, float opacityLevel);
|
||||
static cvf::ref<cvf::Effect> createTernaryScalarMapperEffect(const RivTernaryScalarMapper* mapper, float opacityLevel);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user