mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 15:10:22 -05:00
#1044 Contour maps in 3d views: extend part manager to drape map surface and lines on 3d geometry
Add RivContourMapElevationProvider and extend RivContourMapProjectionPartMgr so the contour map surface and contour lines can be projected onto the terrain/grid geometry of the 3d view instead of only being drawn as a flat map.
This commit is contained in:
1 parent
4587ad4c98
commit
b22fb02aa5
5 files changed
+494
-79
No files matched your search
@@ -21,17 +21,22 @@
|
||||
#include "ContourMap/RigContourPolygonsTools.h"
|
||||
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
#include "cafFontTools.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPointer.h"
|
||||
#include "cafPdmUiNumberFormat.h"
|
||||
|
||||
#include "cvfColor3.h"
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfDrawableText.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector2.h"
|
||||
#include "cvfVector4.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
class RigContourMapGrid;
|
||||
class RivContourMapElevationProvider;
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
@@ -42,17 +47,47 @@ class ModelBasicList;
|
||||
class Part;
|
||||
} // namespace cvf
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
/// How the contour lines are drawn.
|
||||
///
|
||||
/// The defaults reproduce the appearance used by the 2d contour map views: one hairline per contour
|
||||
/// level, coloured to contrast the level colour of the map underneath it.
|
||||
///
|
||||
//==================================================================================================
|
||||
struct RivContourLineAppearance
|
||||
{
|
||||
// When not set, every contour level gets a colour contrasting its own level colour
|
||||
std::optional<cvf::Color3f> color;
|
||||
float lineWidth = 1.0f;
|
||||
|
||||
caf::FontTools::FontSize labelFontSize = caf::FontTools::FontSize::FONT_SIZE_10;
|
||||
|
||||
// Labels are drawn along the contour segment they belong to. The direction is a screen space one,
|
||||
// which only lines up with the segment while the camera looks straight down at the map, so in a 3d
|
||||
// view the text ends up rotated arbitrarily. Set this to keep the labels upright on screen instead.
|
||||
bool alignLabelsWithCamera = false;
|
||||
|
||||
// The colour to draw a contour level in. Shared by the lines and their labels so the two cannot
|
||||
// drift apart. levelColor is the map colour of the level, used when no explicit colour is set.
|
||||
cvf::Color3f colorForLevel( const cvf::Color3f& levelColor ) const;
|
||||
};
|
||||
|
||||
class RivContourMapProjectionPartMgr : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RivContourMapProjectionPartMgr( caf::PdmObject* contourMapProjection );
|
||||
|
||||
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;
|
||||
// elevationProvider controls where the geometry is placed vertically. When null, the geometry is
|
||||
// placed on the horizontal plane at RigContourMapGrid::origin3d(), which is the behaviour used by
|
||||
// the 2d contour map views.
|
||||
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 RivContourMapElevationProvider* elevationProvider = nullptr ) const;
|
||||
|
||||
void appendContourLinesToModel( const cvf::Camera* camera,
|
||||
cvf::ModelBasicList* model,
|
||||
@@ -63,7 +98,9 @@ public:
|
||||
bool showContourLines,
|
||||
bool showContourLabels,
|
||||
caf::NumberFormatType numberFormat,
|
||||
int precision );
|
||||
int precision,
|
||||
const RivContourMapElevationProvider* elevationProvider = nullptr,
|
||||
const RivContourLineAppearance& lineAppearance = {} );
|
||||
|
||||
void appendPickPointVisToModel( cvf::ModelBasicList* model,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
@@ -73,28 +110,53 @@ public:
|
||||
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<cvf::Vec4d>& vertices,
|
||||
const RigContourMapGrid& contourMapGrid,
|
||||
const cvf::Color3f& backgroundColor,
|
||||
cvf::ScalarMapper* scalarMapper ) const;
|
||||
// Convert a contour map local vertex to domain coordinates. Without an elevation provider this is
|
||||
// the vertex offset by RigContourMapGrid::origin3d(). With one, the z component is replaced by the
|
||||
// elevation reported for the vertex position, and nothing is returned where the provider has no
|
||||
// elevation to offer.
|
||||
static std::optional<cvf::Vec3d> toDomainCoord( const cvf::Vec3d& localVertex,
|
||||
const RigContourMapGrid& contourMapGrid,
|
||||
const RivContourMapElevationProvider* elevationProvider );
|
||||
|
||||
static std::optional<cvf::Vec3d> toDisplayCoord( const cvf::Vec3d& localVertex,
|
||||
const RigContourMapGrid& contourMapGrid,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
const RivContourMapElevationProvider* elevationProvider );
|
||||
|
||||
// The segments of a closed contour polygon in display coordinates, sampled densely enough to follow
|
||||
// the elevation reported by the provider. Segments where no elevation is defined are left out.
|
||||
static std::vector<std::pair<cvf::Vec3d, cvf::Vec3d>> resampledDisplaySegments( const std::vector<cvf::Vec3d>& localVertices,
|
||||
const RigContourMapGrid& contourMapGrid,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
const RivContourMapElevationProvider* elevationProvider );
|
||||
|
||||
static cvf::ref<cvf::DrawableText>
|
||||
createTextLabel( const cvf::Color3f& textColor, const cvf::Color3f& backgroundColor, caf::FontTools::FontSize fontSize );
|
||||
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 RivContourMapElevationProvider* elevationProvider ) 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;
|
||||
const RigContourMapGrid& contourMapGrid,
|
||||
const RivContourMapElevationProvider* elevationProvider ) 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,
|
||||
caf::NumberFormatType numberFormat,
|
||||
int precision ) const;
|
||||
const RigContourMapGrid& contourMapGrid,
|
||||
const cvf::ScalarMapper* scalarMapper,
|
||||
caf::NumberFormatType numberFormat,
|
||||
int precision,
|
||||
const RivContourMapElevationProvider* elevationProvider,
|
||||
const RivContourLineAppearance& lineAppearance ) const;
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> createPickPointVisDrawable( const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
const cvf::Vec2d& pickPoint,
|
||||
|
||||
Reference in new issue
Block a user