mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3187 symbols and labels for well path attributes, initial work.
This commit is contained in:
@@ -243,8 +243,7 @@ void RiuLineSegmentQwtPlotCurve::drawSymbols(QPainter *painter, const QwtSymbol
|
||||
{
|
||||
for (auto& pt : pointsToDisplay)
|
||||
{
|
||||
int width = painter->fontMetrics().width(sym->label());
|
||||
painter->drawText(pt.x() - width / 2, pt.y() - 5, sym->label());
|
||||
sym->renderSymbolLabel(painter, pt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -358,7 +357,8 @@ std::vector<double> RiuLineSegmentQwtPlotCurve::fromTime_t(const std::vector<tim
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Internal class to support labels on symbols
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuCurveQwtSymbol::RiuCurveQwtSymbol(QwtSymbol::Style style, const QString& label) : QwtSymbol(style), m_label(label)
|
||||
RiuCurveQwtSymbol::RiuCurveQwtSymbol(QwtSymbol::Style style, const QString& label, LabelPosition labelPosition)
|
||||
: QwtSymbol(style), m_label(label), m_labelPosition(labelPosition)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -370,9 +370,33 @@ void RiuCurveQwtSymbol::renderSymbols(QPainter *painter, const QPointF *points,
|
||||
{
|
||||
for (int i = 0; i < numPoints; i++)
|
||||
{
|
||||
auto pt = points[i];
|
||||
int width = painter->fontMetrics().width(m_label);
|
||||
painter->drawText(pt.x() - width / 2, pt.y() - 5, m_label);
|
||||
auto position = points[i];
|
||||
renderSymbolLabel(painter, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuCurveQwtSymbol::renderSymbolLabel(QPainter *painter, const QPointF& position) const
|
||||
{
|
||||
int symbolWidth = this->size().width();
|
||||
int labelWidth = painter->fontMetrics().width(m_label);
|
||||
if (m_labelPosition == LabelAboveSymbol)
|
||||
{
|
||||
painter->drawText(position.x() - labelWidth / 2, position.y() - 5, m_label);
|
||||
}
|
||||
else if (m_labelPosition == LabelRightOfSymbol)
|
||||
{
|
||||
painter->drawText(position.x() + symbolWidth / 2 + 1, position.y(), m_label);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuCurveQwtSymbol::setLabelPosition(LabelPosition labelPosition)
|
||||
{
|
||||
m_labelPosition = labelPosition;
|
||||
}
|
||||
|
||||
@@ -118,12 +118,20 @@ private:
|
||||
class RiuCurveQwtSymbol : public QwtSymbol
|
||||
{
|
||||
public:
|
||||
RiuCurveQwtSymbol(QwtSymbol::Style style, const QString& label);
|
||||
enum LabelPosition
|
||||
{
|
||||
LabelAboveSymbol,
|
||||
LabelRightOfSymbol
|
||||
};
|
||||
RiuCurveQwtSymbol(QwtSymbol::Style style, const QString& label, LabelPosition labelPosition = LabelAboveSymbol);
|
||||
|
||||
virtual void renderSymbols(QPainter *painter, const QPointF *points, int numPoints) const override;
|
||||
|
||||
void renderSymbolLabel(QPainter *painter, const QPointF& position) const;
|
||||
QString label() const { return m_label; }
|
||||
|
||||
void setLabelPosition(LabelPosition labelPosition);
|
||||
|
||||
private:
|
||||
QString m_label;
|
||||
QString m_label;
|
||||
LabelPosition m_labelPosition;
|
||||
};
|
||||
|
||||
@@ -106,10 +106,9 @@ void RiuWellLogTrack::setDepthZoom(double minDepth, double maxDepth)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogTrack::setXRange(double min, double max)
|
||||
void RiuWellLogTrack::setXRange(double min, double max, QwtPlot::Axis axis)
|
||||
{
|
||||
setAxisScale(QwtPlot::xTop, min, max);
|
||||
setAxisScale(QwtPlot::xBottom, min, max);
|
||||
setAxisScale(axis, min, max);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
void setDepthTitle(const QString& title);
|
||||
void setXTitle(const QString& title);
|
||||
|
||||
void setXRange(double min, double max);
|
||||
void setXRange(double min, double max, QwtPlot::Axis axis = QwtPlot::xTop);
|
||||
|
||||
bool isRimTrackVisible();
|
||||
void enableDepthAxisLabelsAndTitle(bool enable);
|
||||
|
||||
Reference in New Issue
Block a user