mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Refactor: Decouple RivContourMapProjectionPartMgr and RimContourMapProjection
This commit is contained in:
parent
eb6467c599
commit
8da0690096
@ -1,28 +1,41 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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 "RivContourMapProjectionPartMgr.h"
|
||||
|
||||
#include "RiaColorTools.h"
|
||||
#include "RiaFontCache.h"
|
||||
#include "RiaWeightedMeanCalculator.h"
|
||||
#include "RigCellGeometryTools.h"
|
||||
|
||||
#include "RigContourMapGrid.h"
|
||||
#include "RigContourPolygonsTools.h"
|
||||
|
||||
#include "RivMeshLinesSourceInfo.h"
|
||||
#include "RivPartPriority.h"
|
||||
#include "RivScalarMapperUtils.h"
|
||||
|
||||
#include "RimContourMapProjection.h"
|
||||
#include "RimGridView.h"
|
||||
#include "RimRegularLegendConfig.h"
|
||||
|
||||
#include "cafCategoryMapper.h"
|
||||
#include "cafEffectGenerator.h"
|
||||
#include "cafFixedAtlasFont.h"
|
||||
|
||||
#include "cvfCamera.h"
|
||||
#include "cvfColor3.h"
|
||||
#include "cvfDrawableText.h"
|
||||
#include "cvfGeometryBuilderFaceList.h"
|
||||
#include "cvfGeometryTools.h"
|
||||
#include "cvfGeometryUtils.h"
|
||||
#include "cvfMeshEdgeExtractor.h"
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
#include "cvfPrimitiveSetIndexedUInt.h"
|
||||
#include "cvfRay.h"
|
||||
@ -34,35 +47,28 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivContourMapProjectionPartMgr::RivContourMapProjectionPartMgr( RimContourMapProjection* contourMapProjection, RimGridView* contourMap )
|
||||
RivContourMapProjectionPartMgr::RivContourMapProjectionPartMgr( caf::PdmObject* pdmObject )
|
||||
{
|
||||
m_contourMapProjection = contourMapProjection;
|
||||
m_parentContourMap = contourMap;
|
||||
m_pdmObject = pdmObject;
|
||||
|
||||
m_labelEffect = new cvf::Effect;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivContourMapProjectionPartMgr::createProjectionGeometry()
|
||||
{
|
||||
m_contourMapProjection->generateGeometryIfNecessary();
|
||||
|
||||
m_contourLinePolygons = m_contourMapProjection->contourPolygons();
|
||||
m_contourMapTriangles = m_contourMapProjection->trianglesWithVertexValues();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivContourMapProjectionPartMgr::appendProjectionToModel( cvf::ModelBasicList* model,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform ) const
|
||||
const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
const std::vector<cvf::Vec4d>& vertices,
|
||||
const RigContourMapGrid& contourMapGrid,
|
||||
const cvf::Color3f& backgroundColor,
|
||||
cvf::ScalarMapper* scalarMapper ) const
|
||||
{
|
||||
cvf::ref<cvf::Part> mapPart = createProjectionMapPart( displayCoordTransform );
|
||||
cvf::ref<cvf::Part> mapPart = createProjectionMapPart( displayCoordTransform, vertices, contourMapGrid, backgroundColor, scalarMapper );
|
||||
if ( mapPart.notNull() )
|
||||
{
|
||||
model->addPart( mapPart.p() );
|
||||
@ -73,9 +79,12 @@ void RivContourMapProjectionPartMgr::appendProjectionToModel( cvf::ModelBasicLis
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivContourMapProjectionPartMgr::appendPickPointVisToModel( cvf::ModelBasicList* model,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform ) const
|
||||
const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
const cvf::Vec2d& pickPoint,
|
||||
const RigContourMapGrid& contourMapGrid ) const
|
||||
|
||||
{
|
||||
cvf::ref<cvf::DrawableGeo> drawable = createPickPointVisDrawable( displayCoordTransform );
|
||||
cvf::ref<cvf::DrawableGeo> drawable = createPickPointVisDrawable( displayCoordTransform, pickPoint, contourMapGrid );
|
||||
if ( drawable.notNull() && drawable->boundingBox().isValid() )
|
||||
{
|
||||
caf::MeshEffectGenerator meshEffectGen( cvf::Color3::MAGENTA );
|
||||
@ -87,7 +96,7 @@ void RivContourMapProjectionPartMgr::appendPickPointVisToModel( cvf::ModelBasicL
|
||||
part->setName( "RivContourMapProjectionPartMgr::appendPickPointVisToModel" );
|
||||
part->setDrawable( drawable.p() );
|
||||
part->setEffect( effect.p() );
|
||||
part->setSourceInfo( new RivMeshLinesSourceInfo( m_contourMapProjection.p() ) );
|
||||
part->setSourceInfo( new RivMeshLinesSourceInfo( m_pdmObject.p() ) );
|
||||
|
||||
model->addPart( part.p() );
|
||||
}
|
||||
@ -96,7 +105,8 @@ void RivContourMapProjectionPartMgr::appendPickPointVisToModel( cvf::ModelBasicL
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::Vec2fArray> RivContourMapProjectionPartMgr::createTextureCoords( const std::vector<double>& values ) const
|
||||
cvf::ref<cvf::Vec2fArray> RivContourMapProjectionPartMgr::createTextureCoords( const std::vector<double>& values,
|
||||
cvf::ScalarMapper* scalarMapper ) const
|
||||
{
|
||||
cvf::ref<cvf::Vec2fArray> textureCoords = new cvf::Vec2fArray( values.size() );
|
||||
|
||||
@ -105,7 +115,7 @@ cvf::ref<cvf::Vec2fArray> RivContourMapProjectionPartMgr::createTextureCoords( c
|
||||
{
|
||||
if ( values[i] != std::numeric_limits<double>::infinity() )
|
||||
{
|
||||
cvf::Vec2f textureCoord = m_contourMapProjection->legendConfig()->scalarMapper()->mapToTextureCoord( values[i] );
|
||||
cvf::Vec2f textureCoord = scalarMapper->mapToTextureCoord( values[i] );
|
||||
textureCoord.y() = 0.0;
|
||||
( *textureCoords )[i] = textureCoord;
|
||||
}
|
||||
@ -122,22 +132,28 @@ cvf::ref<cvf::Vec2fArray> RivContourMapProjectionPartMgr::createTextureCoords( c
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivContourMapProjectionPartMgr::appendContourLinesToModel( const cvf::Camera* camera,
|
||||
cvf::ModelBasicList* model,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform )
|
||||
const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
const std::vector<RigContourPolygonsTools::ContourPolygons>& contourLinePolygons,
|
||||
const RigContourMapGrid& contourMapGrid,
|
||||
cvf::ScalarMapper* mapper,
|
||||
bool showContourLines,
|
||||
bool showContourLabels,
|
||||
RiaNumberFormat::NumberFormatType numberFormat,
|
||||
int precision )
|
||||
{
|
||||
if ( m_contourMapProjection->showContourLines() )
|
||||
if ( showContourLines )
|
||||
{
|
||||
cvf::ScalarMapper* mapper = m_contourMapProjection->legendConfig()->scalarMapper();
|
||||
|
||||
std::vector<std::vector<cvf::BoundingBox>> labelBBoxes;
|
||||
std::vector<cvf::ref<cvf::Drawable>> labelDrawables;
|
||||
|
||||
if ( m_contourMapProjection->showContourLabels() )
|
||||
if ( showContourLabels )
|
||||
{
|
||||
labelDrawables = createContourLabels( camera, displayCoordTransform, &labelBBoxes );
|
||||
labelDrawables =
|
||||
createContourLabels( camera, displayCoordTransform, &labelBBoxes, contourLinePolygons, contourMapGrid, mapper, numberFormat, precision );
|
||||
}
|
||||
|
||||
std::vector<std::vector<cvf::ref<cvf::Drawable>>> contourDrawablesForAllLevels =
|
||||
createContourPolygons( displayCoordTransform, labelBBoxes );
|
||||
createContourPolygons( displayCoordTransform, labelBBoxes, contourLinePolygons, mapper, contourMapGrid );
|
||||
|
||||
std::vector<double> tickValues;
|
||||
mapper->majorTickValues( &tickValues );
|
||||
@ -164,14 +180,14 @@ void RivContourMapProjectionPartMgr::appendContourLinesToModel( const cvf::Camer
|
||||
part->setDrawable( contourDrawable.p() );
|
||||
part->setEffect( effect.p() );
|
||||
part->setPriority( RivPartPriority::MeshLines );
|
||||
part->setSourceInfo( new RivMeshLinesSourceInfo( m_contourMapProjection.p() ) );
|
||||
part->setSourceInfo( new RivMeshLinesSourceInfo( m_pdmObject.p() ) );
|
||||
|
||||
model->addPart( part.p() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_contourMapProjection->showContourLabels() )
|
||||
if ( showContourLabels )
|
||||
{
|
||||
for ( auto labelDrawableRef : labelDrawables )
|
||||
{
|
||||
@ -180,7 +196,7 @@ void RivContourMapProjectionPartMgr::appendContourLinesToModel( const cvf::Camer
|
||||
part->setDrawable( labelDrawableRef.p() );
|
||||
part->setEffect( m_labelEffect.p() );
|
||||
part->setPriority( RivPartPriority::Text );
|
||||
part->setSourceInfo( new RivMeshLinesSourceInfo( m_contourMapProjection.p() ) );
|
||||
part->setSourceInfo( new RivMeshLinesSourceInfo( m_pdmObject.p() ) );
|
||||
model->addPart( part.p() );
|
||||
}
|
||||
}
|
||||
@ -211,9 +227,12 @@ cvf::ref<cvf::DrawableText> RivContourMapProjectionPartMgr::createTextLabel( con
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::Part> RivContourMapProjectionPartMgr::createProjectionMapPart( const caf::DisplayCoordTransform* displayCoordTransform ) const
|
||||
cvf::ref<cvf::Part> RivContourMapProjectionPartMgr::createProjectionMapPart( const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
const std::vector<cvf::Vec4d>& vertices,
|
||||
const RigContourMapGrid& contourMapGrid,
|
||||
const cvf::Color3f& backgroundColor,
|
||||
cvf::ScalarMapper* scalarMapper ) const
|
||||
{
|
||||
const std::vector<cvf::Vec4d>& vertices = m_contourMapTriangles;
|
||||
if ( vertices.size() < 3u )
|
||||
{
|
||||
return cvf::ref<cvf::Part>();
|
||||
@ -223,7 +242,7 @@ cvf::ref<cvf::Part> RivContourMapProjectionPartMgr::createProjectionMapPart( con
|
||||
std::vector<double> values( vertices.size() );
|
||||
for ( uint i = 0; i < vertices.size(); ++i )
|
||||
{
|
||||
cvf::Vec3d globalVertex = cvf::Vec3d( vertices[i].x(), vertices[i].y(), vertices[i].z() ) + m_contourMapProjection->origin3d();
|
||||
cvf::Vec3d globalVertex = cvf::Vec3d( vertices[i].x(), vertices[i].y(), vertices[i].z() ) + contourMapGrid.origin3d();
|
||||
cvf::Vec3f displayVertexPos( displayCoordTransform->transformToDisplayCoord( globalVertex ) );
|
||||
( *vertexArray )[i] = displayVertexPos;
|
||||
( *faceList )[i] = i;
|
||||
@ -240,18 +259,10 @@ cvf::ref<cvf::Part> RivContourMapProjectionPartMgr::createProjectionMapPart( con
|
||||
part->setName( "RivContourMapProjectionPartMgr::createProjectionMapPart" );
|
||||
part->setDrawable( geo.p() );
|
||||
|
||||
cvf::ScalarMapper* mapper = m_contourMapProjection->legendConfig()->scalarMapper();
|
||||
cvf::ref<cvf::Vec2fArray> textureCoords = createTextureCoords( values, scalarMapper );
|
||||
RivScalarMapperUtils::applyTextureResultsToPart( part.p(), textureCoords.p(), scalarMapper, 1.0f, caf::FC_NONE, true, backgroundColor );
|
||||
|
||||
cvf::ref<cvf::Vec2fArray> textureCoords = createTextureCoords( values );
|
||||
RivScalarMapperUtils::applyTextureResultsToPart( part.p(),
|
||||
textureCoords.p(),
|
||||
mapper,
|
||||
1.0f,
|
||||
caf::FC_NONE,
|
||||
true,
|
||||
m_parentContourMap->backgroundColor() );
|
||||
|
||||
part->setSourceInfo( new RivObjectSourceInfo( m_contourMapProjection.p() ) );
|
||||
part->setSourceInfo( new RivObjectSourceInfo( m_pdmObject.p() ) );
|
||||
part->setPriority( RivPartPriority::BaseLevel );
|
||||
return part;
|
||||
}
|
||||
@ -261,41 +272,43 @@ cvf::ref<cvf::Part> RivContourMapProjectionPartMgr::createProjectionMapPart( con
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::vector<cvf::ref<cvf::Drawable>>>
|
||||
RivContourMapProjectionPartMgr::createContourPolygons( const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
const std::vector<std::vector<cvf::BoundingBox>>& labelBBoxes ) const
|
||||
const std::vector<std::vector<cvf::BoundingBox>>& labelBBoxes,
|
||||
const std::vector<RigContourPolygonsTools::ContourPolygons>& contourLinePolygons,
|
||||
cvf::ScalarMapper* scalarMapper,
|
||||
const RigContourMapGrid& contourMapGrid ) const
|
||||
{
|
||||
const cvf::ScalarMapper* mapper = m_contourMapProjection->legendConfig()->scalarMapper();
|
||||
std::vector<double> tickValues;
|
||||
mapper->majorTickValues( &tickValues );
|
||||
std::vector<double> tickValues;
|
||||
scalarMapper->majorTickValues( &tickValues );
|
||||
|
||||
std::vector<std::vector<cvf::ref<cvf::Drawable>>> contourDrawablesForAllLevels;
|
||||
contourDrawablesForAllLevels.resize( tickValues.size() );
|
||||
|
||||
for ( size_t i = 1; i < m_contourLinePolygons.size(); ++i )
|
||||
for ( size_t i = 1; i < contourLinePolygons.size(); ++i )
|
||||
{
|
||||
std::vector<cvf::ref<cvf::Drawable>> contourDrawables;
|
||||
|
||||
for ( size_t j = 0; j < m_contourLinePolygons[i].size(); ++j )
|
||||
for ( size_t j = 0; j < contourLinePolygons[i].size(); ++j )
|
||||
{
|
||||
if ( m_contourLinePolygons[i][j].vertices.empty() ) continue;
|
||||
if ( contourLinePolygons[i][j].vertices.empty() ) continue;
|
||||
|
||||
// cvf::String::number does not allow precision on 'g' formats, so use Qt.
|
||||
QString qLabelText = QString::number( m_contourLinePolygons[i][j].value, 'g', 2 );
|
||||
QString qLabelText = QString::number( contourLinePolygons[i][j].value, 'g', 2 );
|
||||
cvf::String labelText = cvfqt::Utils::toString( qLabelText );
|
||||
|
||||
size_t nVertices = m_contourLinePolygons[i][j].vertices.size();
|
||||
size_t nVertices = contourLinePolygons[i][j].vertices.size();
|
||||
|
||||
std::vector<cvf::Vec3f> displayLines;
|
||||
displayLines.reserve( nVertices * 2 );
|
||||
for ( size_t v = 0; v < nVertices; ++v )
|
||||
{
|
||||
cvf::Vec3d globalVertex1 = m_contourLinePolygons[i][j].vertices[v] + m_contourMapProjection->origin3d();
|
||||
cvf::Vec3d globalVertex1 = contourLinePolygons[i][j].vertices[v] + contourMapGrid.origin3d();
|
||||
cvf::Vec3d displayVertex1 = displayCoordTransform->transformToDisplayCoord( globalVertex1 );
|
||||
|
||||
cvf::Vec3d globalVertex2;
|
||||
if ( v < nVertices - 1 )
|
||||
globalVertex2 = m_contourLinePolygons[i][j].vertices[v + 1] + m_contourMapProjection->origin3d();
|
||||
globalVertex2 = contourLinePolygons[i][j].vertices[v + 1] + contourMapGrid.origin3d();
|
||||
else
|
||||
globalVertex2 = m_contourLinePolygons[i][j].vertices[0] + m_contourMapProjection->origin3d();
|
||||
globalVertex2 = contourLinePolygons[i][j].vertices[0] + contourMapGrid.origin3d();
|
||||
|
||||
cvf::Vec3d displayVertex2 = displayCoordTransform->transformToDisplayCoord( globalVertex2 );
|
||||
|
||||
@ -390,41 +403,45 @@ std::vector<std::vector<cvf::ref<cvf::Drawable>>>
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<cvf::ref<cvf::Drawable>>
|
||||
RivContourMapProjectionPartMgr::createContourLabels( const cvf::Camera* camera,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
std::vector<std::vector<cvf::BoundingBox>>* labelBBoxes ) const
|
||||
RivContourMapProjectionPartMgr::createContourLabels( const cvf::Camera* camera,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
std::vector<std::vector<cvf::BoundingBox>>* labelBBoxes,
|
||||
const std::vector<RigContourPolygonsTools::ContourPolygons>& contourLinePolygons,
|
||||
const RigContourMapGrid& contourMapGrid,
|
||||
const cvf::ScalarMapper* scalarMapper,
|
||||
RiaNumberFormat::NumberFormatType numberFormat,
|
||||
int precision ) const
|
||||
{
|
||||
CVF_ASSERT( camera && displayCoordTransform && labelBBoxes );
|
||||
|
||||
std::vector<cvf::ref<cvf::Drawable>> labelDrawables;
|
||||
labelBBoxes->clear();
|
||||
labelBBoxes->resize( m_contourLinePolygons.size() );
|
||||
labelBBoxes->resize( contourLinePolygons.size() );
|
||||
|
||||
if ( !camera->viewport() || camera->viewport()->width() == 0 ) return labelDrawables;
|
||||
|
||||
const cvf::ScalarMapper* mapper = m_contourMapProjection->legendConfig()->scalarMapper();
|
||||
if ( mapper == nullptr ) return labelDrawables;
|
||||
if ( scalarMapper == nullptr ) return labelDrawables;
|
||||
|
||||
if ( dynamic_cast<const caf::CategoryMapper*>( mapper ) != nullptr ) return labelDrawables;
|
||||
if ( dynamic_cast<const caf::CategoryMapper*>( scalarMapper ) != nullptr ) return labelDrawables;
|
||||
|
||||
std::vector<double> tickValues;
|
||||
mapper->majorTickValues( &tickValues );
|
||||
scalarMapper->majorTickValues( &tickValues );
|
||||
|
||||
const RigContourPolygonsTools::ContourPolygons* previousLevel = nullptr;
|
||||
for ( int64_t i = (int64_t)m_contourLinePolygons.size() - 1; i > 0; --i )
|
||||
for ( int64_t i = (int64_t)contourLinePolygons.size() - 1; i > 0; --i )
|
||||
{
|
||||
cvf::Color3f backgroundColor( mapper->mapToColor( tickValues[i] ) );
|
||||
cvf::Color3f backgroundColor( scalarMapper->mapToColor( tickValues[i] ) );
|
||||
cvf::Color3f textColor = RiaColorTools::contrastColor( backgroundColor );
|
||||
cvf::ref<cvf::DrawableText> label = createTextLabel( textColor, backgroundColor );
|
||||
|
||||
for ( size_t j = 0; j < m_contourLinePolygons[i].size(); ++j )
|
||||
for ( size_t j = 0; j < contourLinePolygons[i].size(); ++j )
|
||||
{
|
||||
if ( m_contourLinePolygons[i][j].vertices.empty() ) continue;
|
||||
if ( contourLinePolygons[i][j].vertices.empty() ) continue;
|
||||
|
||||
QString qLabelText = m_contourMapProjection->legendConfig()->valueToText( m_contourLinePolygons[i][j].value );
|
||||
QString qLabelText = RiaNumberFormat::valueToText( contourLinePolygons[i][j].value, numberFormat, precision );
|
||||
cvf::String labelText = cvfqt::Utils::toString( qLabelText );
|
||||
|
||||
size_t nVertices = m_contourLinePolygons[i][j].vertices.size();
|
||||
size_t nVertices = contourLinePolygons[i][j].vertices.size();
|
||||
size_t nLabels = nVertices;
|
||||
double distanceSinceLastLabel = std::numeric_limits<double>::infinity();
|
||||
for ( size_t l = 0; l < nLabels; ++l )
|
||||
@ -432,19 +449,19 @@ std::vector<cvf::ref<cvf::Drawable>>
|
||||
size_t nVertex = ( nVertices * l ) / nLabels;
|
||||
size_t nextVertex = ( nVertex + 1 ) % nVertices;
|
||||
|
||||
const cvf::Vec3d& localVertex1 = m_contourLinePolygons[i][j].vertices[nVertex];
|
||||
const cvf::Vec3d& localVertex2 = m_contourLinePolygons[i][j].vertices[nextVertex];
|
||||
const cvf::Vec3d& localVertex1 = contourLinePolygons[i][j].vertices[nVertex];
|
||||
const cvf::Vec3d& localVertex2 = contourLinePolygons[i][j].vertices[nextVertex];
|
||||
|
||||
cvf::Vec3d lineCenter = ( localVertex1 + localVertex2 ) * 0.5;
|
||||
double tolerance = 1.0e-2 * m_contourMapProjection->sampleSpacing();
|
||||
double tolerance = 1.0e-2 * contourMapGrid.sampleSpacing();
|
||||
|
||||
if ( previousLevel && lineOverlapsWithPreviousContourLevel( lineCenter, *previousLevel, tolerance ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
cvf::Vec3d globalVertex1 = localVertex1 + m_contourMapProjection->origin3d();
|
||||
cvf::Vec3d globalVertex2 = localVertex2 + m_contourMapProjection->origin3d();
|
||||
cvf::Vec3d globalVertex1 = localVertex1 + contourMapGrid.origin3d();
|
||||
cvf::Vec3d globalVertex2 = localVertex2 + contourMapGrid.origin3d();
|
||||
|
||||
cvf::Vec3d globalVertex = 0.5 * ( globalVertex1 + globalVertex2 );
|
||||
|
||||
@ -510,7 +527,7 @@ std::vector<cvf::ref<cvf::Drawable>>
|
||||
labelDrawables.push_back( label );
|
||||
}
|
||||
|
||||
previousLevel = &m_contourLinePolygons[i];
|
||||
previousLevel = &contourLinePolygons[i];
|
||||
}
|
||||
return labelDrawables;
|
||||
}
|
||||
@ -518,10 +535,12 @@ std::vector<cvf::ref<cvf::Drawable>>
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo>
|
||||
RivContourMapProjectionPartMgr::createPickPointVisDrawable( const caf::DisplayCoordTransform* displayCoordTransform ) const
|
||||
cvf::ref<cvf::DrawableGeo> RivContourMapProjectionPartMgr::createPickPointVisDrawable( const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
const cvf::Vec2d& pickPoint,
|
||||
const RigContourMapGrid& contourMapGrid ) const
|
||||
{
|
||||
std::vector<cvf::Vec3d> pickPointPolygon = m_contourMapProjection->generatePickPointPolygon();
|
||||
std::vector<cvf::Vec3d> pickPointPolygon = RigContourPolygonsTools::generatePickPointPolygon( pickPoint, contourMapGrid );
|
||||
|
||||
if ( pickPointPolygon.empty() )
|
||||
{
|
||||
return nullptr;
|
||||
@ -530,7 +549,7 @@ cvf::ref<cvf::DrawableGeo>
|
||||
|
||||
for ( size_t i = 0; i < pickPointPolygon.size(); ++i )
|
||||
{
|
||||
cvf::Vec3d globalPoint = pickPointPolygon[i] + m_contourMapProjection->origin3d();
|
||||
cvf::Vec3d globalPoint = pickPointPolygon[i] + contourMapGrid.origin3d();
|
||||
cvf::Vec3f displayPoint( displayCoordTransform->transformToDisplayCoord( globalPoint ) );
|
||||
( *vertexArray )[i] = displayPoint;
|
||||
}
|
||||
|
@ -18,57 +18,96 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RimContourMapProjection.h"
|
||||
#include "RigContourPolygonsTools.h"
|
||||
|
||||
#include "RiaNumberFormat.h"
|
||||
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfDrawableText.h"
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector2.h"
|
||||
#include "cvfVector4.h"
|
||||
|
||||
class RimEclipseContourMapView;
|
||||
class RigContourMapGrid;
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class Effect;
|
||||
}
|
||||
class ScalarMapper;
|
||||
class Color3f;
|
||||
class ModelBasicList;
|
||||
class Part;
|
||||
} // namespace cvf
|
||||
|
||||
class RivContourMapProjectionPartMgr : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RivContourMapProjectionPartMgr( RimContourMapProjection* contourMapProjection, RimGridView* contourMap );
|
||||
RivContourMapProjectionPartMgr( caf::PdmObject* contourMapProjection );
|
||||
|
||||
void createProjectionGeometry();
|
||||
void appendProjectionToModel( cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform ) const;
|
||||
void appendContourLinesToModel( const cvf::Camera* camera,
|
||||
cvf::ModelBasicList* model,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform );
|
||||
void appendPickPointVisToModel( cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform ) const;
|
||||
void appendProjectionToModel( cvf::ModelBasicList* model,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
const std::vector<cvf::Vec4d>& vertices,
|
||||
const RigContourMapGrid& contourMapGrid,
|
||||
const cvf::Color3f& backgroundColor,
|
||||
cvf::ScalarMapper* scalarMapper ) const;
|
||||
|
||||
cvf::ref<cvf::Vec2fArray> createTextureCoords( const std::vector<double>& values ) const;
|
||||
void appendContourLinesToModel( const cvf::Camera* camera,
|
||||
cvf::ModelBasicList* model,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
const std::vector<RigContourPolygonsTools::ContourPolygons>& contourLinePolygons,
|
||||
const RigContourMapGrid& contourMapGrid,
|
||||
cvf::ScalarMapper* mapper,
|
||||
bool showContourLines,
|
||||
bool showContourLabels,
|
||||
RiaNumberFormat::NumberFormatType numberFormat,
|
||||
int precision );
|
||||
|
||||
void appendPickPointVisToModel( cvf::ModelBasicList* model,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
const cvf::Vec2d& pickPoint,
|
||||
const RigContourMapGrid& contourMapGrid ) const;
|
||||
|
||||
cvf::ref<cvf::Vec2fArray> createTextureCoords( const std::vector<double>& values, cvf::ScalarMapper* scalarMapper ) const;
|
||||
|
||||
private:
|
||||
static cvf::ref<cvf::DrawableText> createTextLabel( const cvf::Color3f& textColor, const cvf::Color3f& backgroundColor );
|
||||
cvf::ref<cvf::Part> createProjectionMapPart( const caf::DisplayCoordTransform* displayCoordTransform ) const;
|
||||
std::vector<std::vector<cvf::ref<cvf::Drawable>>> createContourPolygons( const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
const std::vector<std::vector<cvf::BoundingBox>>& labelBBoxes ) const;
|
||||
std::vector<cvf::ref<cvf::Drawable>> createContourLabels( const cvf::Camera* camera,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
std::vector<std::vector<cvf::BoundingBox>>* labelBBoxes ) const;
|
||||
cvf::ref<cvf::DrawableGeo> createPickPointVisDrawable( const caf::DisplayCoordTransform* displayCoordTransform ) const;
|
||||
static bool lineOverlapsWithPreviousContourLevel( const cvf::Vec3d& lineCenter,
|
||||
const RimContourMapProjection::ContourPolygons& previousLevel,
|
||||
double tolerance );
|
||||
cvf::ref<cvf::Part> createProjectionMapPart( const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
const std::vector<cvf::Vec4d>& vertices,
|
||||
const RigContourMapGrid& contourMapGrid,
|
||||
const cvf::Color3f& backgroundColor,
|
||||
cvf::ScalarMapper* scalarMapper ) const;
|
||||
|
||||
std::vector<std::vector<cvf::ref<cvf::Drawable>>>
|
||||
createContourPolygons( const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
const std::vector<std::vector<cvf::BoundingBox>>& labelBBoxes,
|
||||
const std::vector<RigContourPolygonsTools::ContourPolygons>& contourLinePolygons,
|
||||
cvf::ScalarMapper* scalarMapper,
|
||||
const RigContourMapGrid& contourMapGrid ) const;
|
||||
|
||||
std::vector<cvf::ref<cvf::Drawable>> createContourLabels( const cvf::Camera* camera,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
std::vector<std::vector<cvf::BoundingBox>>* labelBBoxes,
|
||||
const std::vector<RigContourPolygonsTools::ContourPolygons>& contourLinePolygons,
|
||||
const RigContourMapGrid& contourMapGrid,
|
||||
const cvf::ScalarMapper* scalarMapper,
|
||||
RiaNumberFormat::NumberFormatType numberFormat,
|
||||
int precision ) const;
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> createPickPointVisDrawable( const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
const cvf::Vec2d& pickPoint,
|
||||
const RigContourMapGrid& contourMapGrid ) const;
|
||||
|
||||
static bool lineOverlapsWithPreviousContourLevel( const cvf::Vec3d& lineCenter,
|
||||
const RigContourPolygonsTools::ContourPolygons& previousLevel,
|
||||
double tolerance );
|
||||
|
||||
private:
|
||||
caf::PdmPointer<RimContourMapProjection> m_contourMapProjection;
|
||||
caf::PdmPointer<RimGridView> m_parentContourMap;
|
||||
caf::PdmPointer<caf::PdmObject> m_pdmObject;
|
||||
|
||||
std::vector<RimContourMapProjection::ContourPolygons> m_contourLinePolygons;
|
||||
std::vector<cvf::Vec4d> m_contourMapTriangles;
|
||||
std::vector<std::vector<cvf::BoundingBox>> m_labelBoundingBoxes;
|
||||
cvf::ref<cvf::Effect> m_labelEffect;
|
||||
std::vector<std::vector<cvf::BoundingBox>> m_labelBoundingBoxes;
|
||||
cvf::ref<cvf::Effect> m_labelEffect;
|
||||
};
|
||||
|
@ -67,7 +67,7 @@ RimGeoMechContourMapView::RimGeoMechContourMapView()
|
||||
|
||||
setDefaultCustomName();
|
||||
|
||||
m_contourMapProjectionPartMgr = new RivContourMapProjectionPartMgr( contourMapProjection(), this );
|
||||
m_contourMapProjectionPartMgr = new RivContourMapProjectionPartMgr( contourMapProjection() );
|
||||
|
||||
( (RiuViewerToViewInterface*)this )->setCameraPosition( sm_defaultViewMatrix );
|
||||
|
||||
@ -283,7 +283,7 @@ void RimGeoMechContourMapView::createContourMapGeometry()
|
||||
{
|
||||
if ( nativeOrOverrideViewer() && m_contourMapProjection->isChecked() )
|
||||
{
|
||||
m_contourMapProjectionPartMgr->createProjectionGeometry();
|
||||
m_contourMapProjection->generateGeometryIfNecessary();
|
||||
}
|
||||
}
|
||||
|
||||
@ -305,7 +305,13 @@ void RimGeoMechContourMapView::appendContourMapProjectionToModel()
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = displayCoordTransform();
|
||||
|
||||
m_contourMapProjectionPartMgr->appendProjectionToModel( contourMapProjectionModelBasicList.p(), transForm.p() );
|
||||
m_contourMapProjectionPartMgr->appendProjectionToModel( contourMapProjectionModelBasicList.p(),
|
||||
transForm.p(),
|
||||
m_contourMapProjection->trianglesWithVertexValues(),
|
||||
*m_contourMapProjection->mapGrid(),
|
||||
backgroundColor(),
|
||||
m_contourMapProjection->legendConfig()->scalarMapper() );
|
||||
|
||||
contourMapProjectionModelBasicList->updateBoundingBoxesRecursive();
|
||||
frameScene->addModel( contourMapProjectionModelBasicList.p() );
|
||||
}
|
||||
@ -330,7 +336,17 @@ void RimGeoMechContourMapView::appendContourLinesToModel()
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = displayCoordTransform();
|
||||
|
||||
m_contourMapProjectionPartMgr->appendContourLinesToModel( viewer()->mainCamera(), contourMapLabelModelBasicList.p(), transForm.p() );
|
||||
m_contourMapProjectionPartMgr->appendContourLinesToModel( viewer()->mainCamera(),
|
||||
contourMapLabelModelBasicList.p(),
|
||||
transForm.p(),
|
||||
m_contourMapProjection->contourPolygons(),
|
||||
*m_contourMapProjection->mapGrid(),
|
||||
m_contourMapProjection->legendConfig()->scalarMapper(),
|
||||
m_contourMapProjection->showContourLines(),
|
||||
m_contourMapProjection->showContourLabels(),
|
||||
m_contourMapProjection->legendConfig()->tickNumberFormat(),
|
||||
m_contourMapProjection->legendConfig()->significantDigitsInData() );
|
||||
|
||||
contourMapLabelModelBasicList->updateBoundingBoxesRecursive();
|
||||
frameScene->addModel( contourMapLabelModelBasicList.p() );
|
||||
}
|
||||
@ -355,7 +371,11 @@ void RimGeoMechContourMapView::appendPickPointVisToModel()
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = displayCoordTransform();
|
||||
|
||||
m_contourMapProjectionPartMgr->appendPickPointVisToModel( contourMapProjectionModelBasicList.p(), transForm.p() );
|
||||
m_contourMapProjectionPartMgr->appendPickPointVisToModel( contourMapProjectionModelBasicList.p(),
|
||||
transForm.p(),
|
||||
m_contourMapProjection->pickPoint(),
|
||||
*m_contourMapProjection->mapGrid() );
|
||||
|
||||
contourMapProjectionModelBasicList->updateBoundingBoxesRecursive();
|
||||
frameScene->addModel( contourMapProjectionModelBasicList.p() );
|
||||
}
|
||||
|
@ -188,37 +188,6 @@ void RimContourMapProjection::generateGeometryIfNecessary()
|
||||
progress.setProgress( 100 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<cvf::Vec3d> RimContourMapProjection::generatePickPointPolygon()
|
||||
{
|
||||
std::vector<cvf::Vec3d> points;
|
||||
|
||||
if ( !m_pickPoint.isUndefined() )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
cvf::Vec2d cellDiagonal( sampleSpacing() * 0.5, sampleSpacing() * 0.5 );
|
||||
cvf::Vec2ui pickedCell = m_contourMapGrid->ijFromLocalPos( m_pickPoint );
|
||||
cvf::Vec2d cellCenter = m_contourMapGrid->cellCenterPosition( pickedCell.x(), pickedCell.y() );
|
||||
cvf::Vec2d cellCorner = cellCenter - cellDiagonal;
|
||||
points.push_back( cvf::Vec3d( cellCorner, 0.0 ) );
|
||||
points.push_back( cvf::Vec3d( cellCorner + cvf::Vec2d( sampleSpacing(), 0.0 ), 0.0 ) );
|
||||
points.push_back( cvf::Vec3d( cellCorner + cvf::Vec2d( sampleSpacing(), 0.0 ), 0.0 ) );
|
||||
points.push_back( cvf::Vec3d( cellCorner + cvf::Vec2d( sampleSpacing(), sampleSpacing() ), 0.0 ) );
|
||||
points.push_back( cvf::Vec3d( cellCorner + cvf::Vec2d( sampleSpacing(), sampleSpacing() ), 0.0 ) );
|
||||
points.push_back( cvf::Vec3d( cellCorner + cvf::Vec2d( 0.0, sampleSpacing() ), 0.0 ) );
|
||||
points.push_back( cvf::Vec3d( cellCorner + cvf::Vec2d( 0.0, sampleSpacing() ), 0.0 ) );
|
||||
points.push_back( cvf::Vec3d( cellCorner, 0.0 ) );
|
||||
#endif
|
||||
points.push_back( cvf::Vec3d( m_pickPoint - cvf::Vec2d( 0.5 * sampleSpacing(), 0.0 ), 0.0 ) );
|
||||
points.push_back( cvf::Vec3d( m_pickPoint + cvf::Vec2d( 0.5 * sampleSpacing(), 0.0 ), 0.0 ) );
|
||||
points.push_back( cvf::Vec3d( m_pickPoint - cvf::Vec2d( 0.0, 0.5 * sampleSpacing() ), 0.0 ) );
|
||||
points.push_back( cvf::Vec3d( m_pickPoint + cvf::Vec2d( 0.0, 0.5 * sampleSpacing() ), 0.0 ) );
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -314,6 +283,14 @@ const RigContourMapProjection* RimContourMapProjection::mapProjection() const
|
||||
return m_contourMapProjection.get();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const RigContourMapGrid* RimContourMapProjection::mapGrid() const
|
||||
{
|
||||
return m_contourMapGrid.get();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -330,12 +307,20 @@ void RimContourMapProjection::setPickPoint( cvf::Vec2d globalPickPoint )
|
||||
m_pickPoint = globalPickPoint - m_contourMapGrid->origin2d();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec2d RimContourMapProjection::pickPoint() const
|
||||
{
|
||||
return m_pickPoint;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec3d RimContourMapProjection::origin3d() const
|
||||
{
|
||||
return m_contourMapGrid->expandedBoundingBox().min();
|
||||
return m_contourMapGrid->origin3d();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -53,8 +53,6 @@ public:
|
||||
void generateGeometryIfNecessary();
|
||||
void clearGeometry();
|
||||
|
||||
std::vector<cvf::Vec3d> generatePickPointPolygon();
|
||||
|
||||
const std::vector<ContourPolygons>& contourPolygons() const;
|
||||
const std::vector<cvf::Vec4d>& trianglesWithVertexValues();
|
||||
|
||||
@ -75,6 +73,8 @@ public:
|
||||
bool isStraightSummationResult() const;
|
||||
|
||||
void setPickPoint( cvf::Vec2d globalPickPoint );
|
||||
cvf::Vec2d pickPoint() const;
|
||||
|
||||
cvf::Vec3d origin3d() const;
|
||||
|
||||
// Pure-virtual public methods which should be overridden by Eclipse and Geo-mechanical contour map implementations
|
||||
@ -90,6 +90,7 @@ public:
|
||||
virtual cvf::ref<cvf::UByteArray> getCellVisibility() const;
|
||||
|
||||
const RigContourMapProjection* mapProjection() const;
|
||||
const RigContourMapGrid* mapGrid() const;
|
||||
|
||||
protected:
|
||||
// Protected virtual methods to be overridden by Eclipse and Geo-mechanical contour map implementations
|
||||
|
@ -77,7 +77,7 @@ RimEclipseContourMapView::RimEclipseContourMapView()
|
||||
|
||||
setDefaultCustomName();
|
||||
|
||||
m_contourMapProjectionPartMgr = new RivContourMapProjectionPartMgr( contourMapProjection(), this );
|
||||
m_contourMapProjectionPartMgr = new RivContourMapProjectionPartMgr( contourMapProjection() );
|
||||
|
||||
setCameraPosition( sm_defaultViewMatrix );
|
||||
|
||||
@ -314,7 +314,7 @@ void RimEclipseContourMapView::createContourMapGeometry()
|
||||
{
|
||||
if ( nativeOrOverrideViewer() && m_contourMapProjection->isChecked() )
|
||||
{
|
||||
m_contourMapProjectionPartMgr->createProjectionGeometry();
|
||||
m_contourMapProjection->generateGeometryIfNecessary();
|
||||
}
|
||||
}
|
||||
|
||||
@ -336,7 +336,13 @@ void RimEclipseContourMapView::appendContourMapProjectionToModel()
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = displayCoordTransform();
|
||||
|
||||
m_contourMapProjectionPartMgr->appendProjectionToModel( contourMapProjectionModelBasicList.p(), transForm.p() );
|
||||
m_contourMapProjectionPartMgr->appendProjectionToModel( contourMapProjectionModelBasicList.p(),
|
||||
transForm.p(),
|
||||
m_contourMapProjection->trianglesWithVertexValues(),
|
||||
*m_contourMapProjection->mapGrid(),
|
||||
backgroundColor(),
|
||||
m_contourMapProjection->legendConfig()->scalarMapper() );
|
||||
|
||||
contourMapProjectionModelBasicList->updateBoundingBoxesRecursive();
|
||||
frameScene->addModel( contourMapProjectionModelBasicList.p() );
|
||||
}
|
||||
@ -361,7 +367,17 @@ void RimEclipseContourMapView::appendContourLinesToModel()
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = displayCoordTransform();
|
||||
|
||||
m_contourMapProjectionPartMgr->appendContourLinesToModel( viewer()->mainCamera(), contourMapLabelModelBasicList.p(), transForm.p() );
|
||||
m_contourMapProjectionPartMgr->appendContourLinesToModel( viewer()->mainCamera(),
|
||||
contourMapLabelModelBasicList.p(),
|
||||
transForm.p(),
|
||||
m_contourMapProjection->contourPolygons(),
|
||||
*m_contourMapProjection->mapGrid(),
|
||||
m_contourMapProjection->legendConfig()->scalarMapper(),
|
||||
m_contourMapProjection->showContourLines(),
|
||||
m_contourMapProjection->showContourLabels(),
|
||||
m_contourMapProjection->legendConfig()->tickNumberFormat(),
|
||||
m_contourMapProjection->legendConfig()->significantDigitsInData() );
|
||||
|
||||
contourMapLabelModelBasicList->updateBoundingBoxesRecursive();
|
||||
frameScene->addModel( contourMapLabelModelBasicList.p() );
|
||||
}
|
||||
@ -386,7 +402,10 @@ void RimEclipseContourMapView::appendPickPointVisToModel()
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = displayCoordTransform();
|
||||
|
||||
m_contourMapProjectionPartMgr->appendPickPointVisToModel( contourMapProjectionModelBasicList.p(), transForm.p() );
|
||||
m_contourMapProjectionPartMgr->appendPickPointVisToModel( contourMapProjectionModelBasicList.p(),
|
||||
transForm.p(),
|
||||
m_contourMapProjection->pickPoint(),
|
||||
*m_contourMapProjection->mapGrid() );
|
||||
contourMapProjectionModelBasicList->updateBoundingBoxesRecursive();
|
||||
frameScene->addModel( contourMapProjectionModelBasicList.p() );
|
||||
}
|
||||
|
@ -1161,6 +1161,22 @@ QString RimRegularLegendConfig::valueToText( double value ) const
|
||||
return RiaNumberFormat::valueToText( value, m_tickNumberFormat(), m_significantDigitsInData );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaNumberFormat::NumberFormatType RimRegularLegendConfig::tickNumberFormat() const
|
||||
{
|
||||
return m_tickNumberFormat();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimRegularLegendConfig::significantDigitsInData() const
|
||||
{
|
||||
return m_significantDigitsInData;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -127,10 +127,16 @@ public:
|
||||
RimColorLegend* colorLegend() const;
|
||||
void setMappingMode( MappingType mappingType );
|
||||
MappingType mappingMode() { return m_mappingMode(); }
|
||||
void setTickNumberFormat( RiaNumberFormat::NumberFormatType numberFormat );
|
||||
void resetUserDefinedValues();
|
||||
void setCenterLegendAroundZero( bool enable );
|
||||
void setUserDefinedRange( double minVal, double maxVal );
|
||||
|
||||
void setTickNumberFormat( RiaNumberFormat::NumberFormatType numberFormat );
|
||||
|
||||
RiaNumberFormat::NumberFormatType tickNumberFormat() const;
|
||||
|
||||
int significantDigitsInData() const;
|
||||
|
||||
void resetUserDefinedValues();
|
||||
void setCenterLegendAroundZero( bool enable );
|
||||
void setUserDefinedRange( double minVal, double maxVal );
|
||||
|
||||
void disableAllTimeStepsRange( bool doDisable );
|
||||
|
||||
|
@ -19,13 +19,12 @@
|
||||
#include "RigContourPolygonsTools.h"
|
||||
|
||||
#include "RigCellGeometryTools.h"
|
||||
#include "RigContourMapGrid.h"
|
||||
|
||||
#include "cafContourLines.h"
|
||||
|
||||
#include "cvfGeometryTools.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -186,3 +185,35 @@ bool RigContourPolygonsTools::lineOverlapsWithContourPolygons( const cvf::Vec3d&
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<cvf::Vec3d> RigContourPolygonsTools::generatePickPointPolygon( const cvf::Vec2d& pickPoint, const RigContourMapGrid& contourMapGrid )
|
||||
{
|
||||
std::vector<cvf::Vec3d> points;
|
||||
|
||||
if ( !pickPoint.isUndefined() )
|
||||
{
|
||||
double sampleSpacing = contourMapGrid.sampleSpacing();
|
||||
#ifndef NDEBUG
|
||||
cvf::Vec2d cellDiagonal( sampleSpacing * 0.5, sampleSpacing * 0.5 );
|
||||
cvf::Vec2ui pickedCell = contourMapGrid.ijFromLocalPos( pickPoint );
|
||||
cvf::Vec2d cellCenter = contourMapGrid.cellCenterPosition( pickedCell.x(), pickedCell.y() );
|
||||
cvf::Vec2d cellCorner = cellCenter - cellDiagonal;
|
||||
points.push_back( cvf::Vec3d( cellCorner, 0.0 ) );
|
||||
points.push_back( cvf::Vec3d( cellCorner + cvf::Vec2d( sampleSpacing, 0.0 ), 0.0 ) );
|
||||
points.push_back( cvf::Vec3d( cellCorner + cvf::Vec2d( sampleSpacing, 0.0 ), 0.0 ) );
|
||||
points.push_back( cvf::Vec3d( cellCorner + cvf::Vec2d( sampleSpacing, sampleSpacing ), 0.0 ) );
|
||||
points.push_back( cvf::Vec3d( cellCorner + cvf::Vec2d( sampleSpacing, sampleSpacing ), 0.0 ) );
|
||||
points.push_back( cvf::Vec3d( cellCorner + cvf::Vec2d( 0.0, sampleSpacing ), 0.0 ) );
|
||||
points.push_back( cvf::Vec3d( cellCorner + cvf::Vec2d( 0.0, sampleSpacing ), 0.0 ) );
|
||||
points.push_back( cvf::Vec3d( cellCorner, 0.0 ) );
|
||||
#endif
|
||||
points.push_back( cvf::Vec3d( pickPoint - cvf::Vec2d( 0.5 * sampleSpacing, 0.0 ), 0.0 ) );
|
||||
points.push_back( cvf::Vec3d( pickPoint + cvf::Vec2d( 0.5 * sampleSpacing, 0.0 ), 0.0 ) );
|
||||
points.push_back( cvf::Vec3d( pickPoint - cvf::Vec2d( 0.0, 0.5 * sampleSpacing ), 0.0 ) );
|
||||
points.push_back( cvf::Vec3d( pickPoint + cvf::Vec2d( 0.0, 0.5 * sampleSpacing ), 0.0 ) );
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
@ -23,8 +23,6 @@
|
||||
#include "cvfBoundingBox.h"
|
||||
|
||||
class RigContourMapGrid;
|
||||
class RimGridView;
|
||||
class RimRegularLegendConfig;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -50,4 +48,6 @@ public:
|
||||
static void clipContourPolygons( ContourPolygons& contourPolygons, const ContourPolygons& clipBy );
|
||||
static double sumPolygonArea( const ContourPolygons& contourPolygons );
|
||||
static bool lineOverlapsWithContourPolygons( const cvf::Vec3d& lineCenter, const ContourPolygons& contourPolygons, double tolerance );
|
||||
|
||||
static std::vector<cvf::Vec3d> generatePickPointPolygon( const cvf::Vec2d& pickPoint, const RigContourMapGrid& contourMapGrid );
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user