#3806 Measurement. Display text label at last clicked position

This commit is contained in:
Bjørn Erik Jensen
2018-12-20 12:34:17 +01:00
parent deec4c16e9
commit d6f4962ed7
7 changed files with 126 additions and 45 deletions

View File

@@ -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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -33,6 +33,23 @@ class RimMeasurement : public caf::PdmObject
using Vec3d = cvf::Vec3d;
public:
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;
@@ -42,7 +59,12 @@ public:
void addPointInDomain(const Vec3d& pointInDomain);
std::vector<Vec3d> pointsInDomain() const;
QString label() const;
private:
Lengths calculateLenghts() const;
void updateView() const;
bool m_isInMeasurementMode;