mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3806 Measurement. Display text label at last clicked position
This commit is contained in:
@@ -90,6 +90,44 @@ std::vector<cvf::Vec3d> RimMeasurement::pointsInDomain() const
|
||||
return m_pointsInDomain;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimMeasurement::label() const
|
||||
{
|
||||
auto lengths = calculateLenghts();
|
||||
return QString("Total length: \t%1\nLast length: \t%2\nTotal horizontal length: \t%3\nLast horizontal length: \t%4")
|
||||
.arg(lengths.totalLength)
|
||||
.arg(lengths.lastSegmentLength)
|
||||
.arg(lengths.totalHorizontalLength)
|
||||
.arg(lengths.lastSegmentHorisontalLength);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimMeasurement::Lengths RimMeasurement::calculateLenghts() const
|
||||
{
|
||||
Lengths lengths;
|
||||
|
||||
for (size_t p = 1; p < m_pointsInDomain.size(); p++)
|
||||
{
|
||||
const auto& p0 = m_pointsInDomain[p - 1];
|
||||
const auto& p1 = m_pointsInDomain[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;
|
||||
}
|
||||
|
||||
return lengths;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user