mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-09 23:53:04 -06:00
#4222 Add axis labels to Grid Cross Plot pick info
This commit is contained in:
parent
a168f8a206
commit
337345a887
@ -347,13 +347,18 @@ void RiuGridCrossQwtPlot::selectSample(QwtPlotCurve* curve, int sampleNumber)
|
|||||||
m_selectedPointMarker->setValue(sample);
|
m_selectedPointMarker->setValue(sample);
|
||||||
m_selectedPointMarker->setAxes(QwtPlot::xBottom, QwtPlot::yLeft);
|
m_selectedPointMarker->setAxes(QwtPlot::xBottom, QwtPlot::yLeft);
|
||||||
m_selectedPointMarker->attach(this);
|
m_selectedPointMarker->attach(this);
|
||||||
QString curveName = curveText(curve);
|
QString curveName, xAxisName, yAxisName;
|
||||||
QwtText curveLabel(QString("<div style=\"margin: 4px;\"><b>%1:</b><br/>%2, %3</div>").arg(curveName).arg(sample.x()).arg(sample.y()), QwtText::RichText);
|
if (curveText(curve, &curveName, &xAxisName, &yAxisName))
|
||||||
curveLabel.setBackgroundBrush(QBrush(QColor(250, 250, 250, 220)));
|
{
|
||||||
curveLabel.setPaintAttribute(QwtText::PaintBackground);
|
QString labelFormat("<div style=\"margin: 4px;\"><b>%1:</b><br/>%2 = %3, %4 = %5</div>");
|
||||||
curveLabel.setBorderPen(QPen(Qt::black, 1.0));
|
QString labelString = labelFormat.arg(curveName).arg(xAxisName).arg(sample.x()).arg(yAxisName).arg(sample.y());
|
||||||
curveLabel.setBorderRadius(2.0);
|
QwtText curveLabel(labelString, QwtText::RichText);
|
||||||
m_selectedPointMarker->setLabel(curveLabel);
|
curveLabel.setBackgroundBrush(QBrush(QColor(250, 250, 250, 220)));
|
||||||
|
curveLabel.setPaintAttribute(QwtText::PaintBackground);
|
||||||
|
curveLabel.setBorderPen(QPen(Qt::black, 1.0));
|
||||||
|
curveLabel.setBorderRadius(2.0);
|
||||||
|
m_selectedPointMarker->setLabel(curveLabel);
|
||||||
|
}
|
||||||
replot();
|
replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,16 +374,30 @@ void RiuGridCrossQwtPlot::clearSampleSelection()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QString RiuGridCrossQwtPlot::curveText(const QwtPlotCurve* curve) const
|
bool RiuGridCrossQwtPlot::curveText(const QwtPlotCurve* curve,
|
||||||
|
QString* curveTitle,
|
||||||
|
QString* xParamName,
|
||||||
|
QString* yParamName) const
|
||||||
{
|
{
|
||||||
|
CVF_ASSERT(curveTitle && xParamName && yParamName);
|
||||||
|
|
||||||
auto riuCurve = dynamic_cast<const RiuRimQwtPlotCurve*>(curve);
|
auto riuCurve = dynamic_cast<const RiuRimQwtPlotCurve*>(curve);
|
||||||
if (riuCurve)
|
if (riuCurve)
|
||||||
{
|
{
|
||||||
auto crossPlotCurve = dynamic_cast<const RimGridCrossPlotCurve*>(riuCurve->ownerRimCurve());
|
auto crossPlotCurve = dynamic_cast<const RimGridCrossPlotCurve*>(riuCurve->ownerRimCurve());
|
||||||
if (crossPlotCurve)
|
if (crossPlotCurve)
|
||||||
{
|
{
|
||||||
return crossPlotCurve->curveName();
|
*curveTitle = crossPlotCurve->curveName();
|
||||||
|
|
||||||
|
RimGridCrossPlotCurveSet* curveSet = nullptr;
|
||||||
|
crossPlotCurve->firstAncestorOrThisOfType(curveSet);
|
||||||
|
if (curveSet)
|
||||||
|
{
|
||||||
|
*xParamName = curveSet->xAxisName();
|
||||||
|
*yParamName = curveSet->yAxisName();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -63,9 +63,9 @@ protected:
|
|||||||
bool resizeOverlayItemToFitPlot(caf::TitledOverlayFrame* overlayItem);
|
bool resizeOverlayItemToFitPlot(caf::TitledOverlayFrame* overlayItem);
|
||||||
void contextMenuEvent(QContextMenuEvent*) override;
|
void contextMenuEvent(QContextMenuEvent*) override;
|
||||||
|
|
||||||
void selectSample(QwtPlotCurve* curve, int sampleNumber) override;
|
void selectSample(QwtPlotCurve* curve, int sampleNumber) override;
|
||||||
void clearSampleSelection() override;
|
void clearSampleSelection() override;
|
||||||
QString curveText(const QwtPlotCurve* curves) const;
|
bool curveText(const QwtPlotCurve* curve, QString* curveTitle, QString* xParamName, QString* yParamName) const;
|
||||||
private:
|
private:
|
||||||
typedef caf::PdmPointer<RimGridCrossPlotCurveSet> CurveSetPtr;
|
typedef caf::PdmPointer<RimGridCrossPlotCurveSet> CurveSetPtr;
|
||||||
typedef QPointer<RiuCvfOverlayItemWidget> LegendPtr;
|
typedef QPointer<RiuCvfOverlayItemWidget> LegendPtr;
|
||||||
|
Loading…
Reference in New Issue
Block a user