mirror of
https://github.com/OPM/ResInsight.git
synced 2026-11-07 23:05:29 -06:00
Optionally show polygon geometry info as text label
This commit is contained in:
1 parent
118ecf941a
commit
e492685070
13 files changed
+241
-120
No files matched your search
@@ -20,15 +20,17 @@
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RigPolygonTools.h"
|
||||
|
||||
#include "Rim3dView.h"
|
||||
#include "RimGridView.h"
|
||||
|
||||
#include "MeasurementCommands/RicMeasurementPickEventHandler.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuMeasurementEventFilter.h"
|
||||
#include "RiuViewerCommands.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
#include "cvfGeometryTools.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimMeasurement, "RimMeasurement" );
|
||||
@@ -127,63 +129,8 @@ void RimMeasurement::removeAllPoints()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimMeasurement::label() const
|
||||
{
|
||||
auto lengths = calculateLengths();
|
||||
|
||||
QString text;
|
||||
|
||||
if ( m_pointsInDomainCoords.size() > 2 )
|
||||
{
|
||||
text = QString( "Segment Length: %1\nSegment Horizontal Length: %2\n" ).arg( lengths.lastSegmentLength ).arg( lengths.lastSegmentHorisontalLength );
|
||||
|
||||
text += QString( "Total Length: %1\nTotal Horizontal Length: %2\n" ).arg( lengths.totalLength ).arg( lengths.totalHorizontalLength );
|
||||
|
||||
text += QString( "\nHorizontal Area : %1" ).arg( lengths.area );
|
||||
}
|
||||
else
|
||||
{
|
||||
text = QString( "Length: %1\nHorizontal Length: %2\n" ).arg( lengths.lastSegmentLength ).arg( lengths.lastSegmentHorisontalLength );
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimMeasurement::Lengths RimMeasurement::calculateLengths() const
|
||||
{
|
||||
Lengths lengths;
|
||||
|
||||
for ( size_t p = 1; p < m_pointsInDomainCoords.size(); p++ )
|
||||
{
|
||||
const auto& p0 = m_pointsInDomainCoords[p - 1];
|
||||
const auto& p1 = m_pointsInDomainCoords[p];
|
||||
|
||||
lengths.lastSegmentLength = ( p1 - p0 ).length();
|
||||
|
||||
const auto& p1_horiz = cvf::Vec3d( p1.x(), p1.y(), p0.z() );
|
||||
|
||||
lengths.lastSegmentHorisontalLength = ( p1_horiz - p0 ).length();
|
||||
|
||||
lengths.totalLength += lengths.lastSegmentLength;
|
||||
lengths.totalHorizontalLength += lengths.lastSegmentHorisontalLength;
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<Vec3d> pointsProjectedInZPlane;
|
||||
for ( const auto& p : m_pointsInDomainCoords )
|
||||
{
|
||||
auto pointInZ = p;
|
||||
pointInZ.z() = 0.0;
|
||||
pointsProjectedInZPlane.push_back( pointInZ );
|
||||
}
|
||||
|
||||
Vec3d area = cvf::GeometryTools::polygonAreaNormal3D( pointsProjectedInZPlane );
|
||||
|
||||
lengths.area = cvf::Math::abs( area.z() );
|
||||
}
|
||||
|
||||
return lengths;
|
||||
bool includeLastSegmentInfo = true;
|
||||
return RigPolygonTools::geometryDataAsText( m_pointsInDomainCoords, includeLastSegmentInfo );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -45,25 +45,6 @@ public:
|
||||
MEASURE_POLYLINE
|
||||
};
|
||||
|
||||
class Lengths
|
||||
{
|
||||
public:
|
||||
Lengths()
|
||||
: totalLength( 0 )
|
||||
, lastSegmentLength( 0 )
|
||||
, totalHorizontalLength( 0 )
|
||||
, lastSegmentHorisontalLength( 0 )
|
||||
, area( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
double totalLength;
|
||||
double lastSegmentLength;
|
||||
double totalHorizontalLength;
|
||||
double lastSegmentHorisontalLength;
|
||||
double area;
|
||||
};
|
||||
|
||||
RimMeasurement();
|
||||
~RimMeasurement() override;
|
||||
|
||||
@@ -78,8 +59,6 @@ public:
|
||||
QString label() const;
|
||||
|
||||
private:
|
||||
Lengths calculateLengths() const;
|
||||
|
||||
void updateView() const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "RiaColorTools.h"
|
||||
|
||||
#include "RigPolyLinesData.h"
|
||||
#include "RigPolygonTools.h"
|
||||
|
||||
#include "Rim3dView.h"
|
||||
#include "RimPolygon.h"
|
||||
@@ -65,6 +66,8 @@ RimPolygonInView::RimPolygonInView()
|
||||
CAF_PDM_InitField( &m_selectPolygon, "SelectPolygon", false, "" );
|
||||
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_selectPolygon );
|
||||
|
||||
CAF_PDM_InitField( &m_showLabel, "ShowLabel", false, "Show Label" );
|
||||
|
||||
CAF_PDM_InitField( &m_handleScalingFactor, "HandleScalingFactor", 2.0, "Handle Scaling Factor" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_targets, "Targets", "Targets" );
|
||||
@@ -305,6 +308,8 @@ void RimPolygonInView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
|
||||
uiOrdering.add( &m_handleScalingFactor );
|
||||
}
|
||||
|
||||
uiOrdering.add( &m_showLabel );
|
||||
|
||||
if ( m_polygon() )
|
||||
{
|
||||
uiOrdering.add( &m_selectPolygon );
|
||||
@@ -388,6 +393,23 @@ void RimPolygonInView::uiOrderingForLocalPolygon( QString uiConfigName, caf::Pdm
|
||||
uiOrdering.add( &m_handleScalingFactor );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimPolygonInView::label() const
|
||||
{
|
||||
if ( m_showLabel() && m_polygon() )
|
||||
{
|
||||
bool includeLastSegmentInfo = false;
|
||||
QString label = m_polygon->name();
|
||||
label += "\n" + RigPolygonTools::geometryDataAsText( m_polygon->pointsInDomainCoords(), includeLastSegmentInfo );
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -74,6 +74,8 @@ public:
|
||||
|
||||
void uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
|
||||
|
||||
QString label() const override;
|
||||
|
||||
protected:
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
@@ -100,6 +102,8 @@ private:
|
||||
caf::PdmField<double> m_handleScalingFactor;
|
||||
caf::PdmChildArrayField<RimPolylineTarget*> m_targets;
|
||||
|
||||
caf::PdmField<bool> m_showLabel;
|
||||
|
||||
cvf::ref<RivPolylinePartMgr> m_polylinePartMgr;
|
||||
std::shared_ptr<RicPolylineTargetsPickEventHandler> m_pickTargetsEventHandler;
|
||||
};
|
||||
@@ -425,6 +425,8 @@ void RimGridView::appendPolygonPartsToModel( caf::DisplayCoordTransform* scaleTr
|
||||
}
|
||||
|
||||
nativeOrOverrideViewer()->addStaticModelOnce( m_polygonVizModel.p(), isUsingOverrideViewer() );
|
||||
|
||||
m_polygonVizModel->updateBoundingBoxesRecursive();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -26,4 +26,5 @@ class RimPolylinesDataInterface
|
||||
{
|
||||
public:
|
||||
virtual cvf::ref<RigPolyLinesData> polyLinesData() const = 0;
|
||||
virtual QString label() const { return {}; };
|
||||
};
|
||||
Reference in new issue
Block a user