2019-03-04 08:35:48 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2019- Equinor ASA
|
|
|
|
//
|
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "RiuGridCrossQwtPlot.h"
|
|
|
|
|
2019-04-10 09:13:40 -05:00
|
|
|
#include "RiaFontCache.h"
|
|
|
|
|
2019-03-04 08:35:48 -06:00
|
|
|
#include "RiuCvfOverlayItemWidget.h"
|
2019-03-26 05:33:55 -05:00
|
|
|
#include "RiuRimQwtPlotCurve.h"
|
|
|
|
#include "RiuQwtCurvePointTracker.h"
|
2019-03-04 08:35:48 -06:00
|
|
|
#include "RiuWidgetDragger.h"
|
|
|
|
|
|
|
|
#include "RimGridCrossPlot.h"
|
2019-03-29 07:17:39 -05:00
|
|
|
#include "RimGridCrossPlotDataSet.h"
|
2019-03-26 05:33:55 -05:00
|
|
|
#include "RimGridCrossPlotCurve.h"
|
2019-03-04 08:35:48 -06:00
|
|
|
#include "RimRegularLegendConfig.h"
|
|
|
|
|
2019-03-11 05:39:23 -05:00
|
|
|
#include "cafCmdFeatureMenuBuilder.h"
|
2019-04-10 09:13:40 -05:00
|
|
|
#include "cafFixedAtlasFont.h"
|
2019-03-11 05:39:23 -05:00
|
|
|
#include "cafSelectionManager.h"
|
2019-03-04 08:35:48 -06:00
|
|
|
#include "cafTitledOverlayFrame.h"
|
|
|
|
|
2019-03-12 10:05:58 -05:00
|
|
|
#include "RimPlotAxisAnnotation.h"
|
2019-03-22 09:11:56 -05:00
|
|
|
#include "RimPlotAxisProperties.h"
|
2019-03-12 10:05:58 -05:00
|
|
|
#include "RiuPlotAnnotationTool.h"
|
|
|
|
|
2019-03-26 05:33:55 -05:00
|
|
|
#include "qwt_text.h"
|
|
|
|
#include "qwt_text_engine.h"
|
|
|
|
|
2019-03-25 08:47:55 -05:00
|
|
|
#include <QLabel>
|
2019-03-11 05:39:23 -05:00
|
|
|
#include <QMenu>
|
2019-03-07 12:00:38 -06:00
|
|
|
#include <QResizeEvent>
|
2019-03-25 08:47:55 -05:00
|
|
|
#include <QVBoxLayout>
|
2019-03-07 12:00:38 -06:00
|
|
|
|
2019-03-04 08:35:48 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RiuGridCrossQwtPlot::RiuGridCrossQwtPlot(RimViewWindow* ownerViewWindow, QWidget* parent /*= nullptr*/)
|
|
|
|
: RiuQwtPlot(ownerViewWindow, parent)
|
2019-03-12 10:05:58 -05:00
|
|
|
{
|
|
|
|
m_annotationTool = std::unique_ptr<RiuPlotAnnotationTool>(new RiuPlotAnnotationTool());
|
2019-03-25 08:47:55 -05:00
|
|
|
m_infoBox = new RiuDraggableOverlayFrame(this, canvas());
|
2019-03-26 05:33:55 -05:00
|
|
|
|
|
|
|
m_selectedPointMarker = new QwtPlotMarker;
|
|
|
|
|
|
|
|
// QwtPlotMarker takes ownership of the symbol, it is deleted in destructor of QwtPlotMarker
|
|
|
|
QwtSymbol* mySymbol = new QwtSymbol(QwtSymbol::Ellipse, QBrush(QColor(255, 255, 255, 50)), QPen(Qt::black, 2.0), QSize(10, 10));
|
|
|
|
m_selectedPointMarker->setSymbol(mySymbol);
|
|
|
|
m_selectedPointMarker->setLabelAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
|
|
|
m_selectedPointMarker->setSpacing(3);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RiuGridCrossQwtPlot::~RiuGridCrossQwtPlot()
|
|
|
|
{
|
|
|
|
if (m_selectedPointMarker->plot())
|
|
|
|
{
|
|
|
|
m_selectedPointMarker->detach();
|
|
|
|
}
|
|
|
|
delete m_selectedPointMarker;
|
2019-03-04 08:35:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-29 07:17:39 -05:00
|
|
|
void RiuGridCrossQwtPlot::addOrUpdateDataSetLegend(RimGridCrossPlotDataSet* dataSet)
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
|
|
|
RiuCvfOverlayItemWidget* overlayWidget = nullptr;
|
|
|
|
|
2019-03-29 07:17:39 -05:00
|
|
|
auto it = m_legendWidgets.find(dataSet);
|
2019-03-04 08:35:48 -06:00
|
|
|
if (it == m_legendWidgets.end() || it->second == nullptr)
|
|
|
|
{
|
2019-03-25 08:47:55 -05:00
|
|
|
overlayWidget = new RiuCvfOverlayItemWidget(this, canvas());
|
2019-03-29 07:17:39 -05:00
|
|
|
m_legendWidgets[dataSet] = overlayWidget;
|
2019-03-04 08:35:48 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
overlayWidget = it->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (overlayWidget)
|
|
|
|
{
|
2019-03-29 07:17:39 -05:00
|
|
|
caf::TitledOverlayFrame* overlayItem = dataSet->legendConfig()->titledOverlayFrame();
|
2019-04-10 09:13:40 -05:00
|
|
|
applyFontSizeToOverlayItem(overlayItem);
|
2019-03-07 12:00:38 -06:00
|
|
|
resizeOverlayItemToFitPlot(overlayItem);
|
|
|
|
overlayWidget->updateFromOverlayItem(overlayItem);
|
2019-03-04 08:35:48 -06:00
|
|
|
}
|
|
|
|
this->updateLegendLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-29 07:17:39 -05:00
|
|
|
void RiuGridCrossQwtPlot::removeDataSetLegend(RimGridCrossPlotDataSet* dataSetToShowLegendFor)
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
2019-03-29 07:17:39 -05:00
|
|
|
auto it = m_legendWidgets.find(dataSetToShowLegendFor);
|
2019-03-04 08:35:48 -06:00
|
|
|
if (it != m_legendWidgets.end())
|
|
|
|
{
|
2019-04-15 03:38:29 -05:00
|
|
|
if (it->second != nullptr)
|
|
|
|
{
|
|
|
|
it->second->hide();
|
|
|
|
it->second->deleteLater();
|
|
|
|
}
|
2019-03-04 08:35:48 -06:00
|
|
|
|
|
|
|
m_legendWidgets.erase(it);
|
|
|
|
}
|
|
|
|
|
|
|
|
this->updateLegendLayout();
|
|
|
|
}
|
|
|
|
|
2019-04-15 03:38:29 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuGridCrossQwtPlot::removeDanglingDataSetLegends()
|
|
|
|
{
|
|
|
|
for (auto it = m_legendWidgets.begin(); it != m_legendWidgets.end();)
|
|
|
|
{
|
|
|
|
if (it->first.isNull())
|
|
|
|
{
|
|
|
|
if (it->second != nullptr)
|
|
|
|
{
|
|
|
|
it->second->hide();
|
|
|
|
it->second->deleteLater();
|
|
|
|
}
|
|
|
|
m_legendWidgets.erase(it++);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-08 02:59:29 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuGridCrossQwtPlot::updateLegendSizesToMatchPlot()
|
|
|
|
{
|
|
|
|
RimGridCrossPlot* crossPlot = dynamic_cast<RimGridCrossPlot*>(ownerPlotDefinition());
|
|
|
|
if (!crossPlot) return;
|
|
|
|
|
|
|
|
bool anyLegendResized = false;
|
|
|
|
|
2019-03-29 07:17:39 -05:00
|
|
|
for (RimGridCrossPlotDataSet* dataSet : crossPlot->dataSets())
|
2019-03-08 02:59:29 -06:00
|
|
|
{
|
2019-03-29 07:17:39 -05:00
|
|
|
if (!dataSet->isChecked() || !dataSet->legendConfig()->showLegend()) continue;
|
2019-03-08 02:59:29 -06:00
|
|
|
|
2019-03-29 07:17:39 -05:00
|
|
|
auto pairIt = m_legendWidgets.find(dataSet);
|
2019-03-08 02:59:29 -06:00
|
|
|
if (pairIt != m_legendWidgets.end())
|
|
|
|
{
|
|
|
|
RiuCvfOverlayItemWidget* overlayWidget = pairIt->second;
|
2019-03-29 07:17:39 -05:00
|
|
|
caf::TitledOverlayFrame* overlayItem = dataSet->legendConfig()->titledOverlayFrame();
|
2019-04-10 09:13:40 -05:00
|
|
|
applyFontSizeToOverlayItem(overlayItem);
|
2019-03-27 09:02:12 -05:00
|
|
|
if (resizeOverlayItemToFitPlot(overlayItem))
|
2019-03-08 02:59:29 -06:00
|
|
|
{
|
2019-03-27 09:02:12 -05:00
|
|
|
anyLegendResized = true;
|
|
|
|
overlayWidget->updateFromOverlayItem(overlayItem);
|
2019-03-08 02:59:29 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (anyLegendResized)
|
|
|
|
{
|
|
|
|
updateLegendLayout();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-12 10:05:58 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuGridCrossQwtPlot::updateAnnotationObjects(RimPlotAxisProperties* axisProperties)
|
|
|
|
{
|
2019-03-22 09:11:56 -05:00
|
|
|
m_annotationTool->detachAllAnnotations();
|
2019-03-12 10:05:58 -05:00
|
|
|
|
2019-03-22 09:11:56 -05:00
|
|
|
for (auto annotation : axisProperties->annotations())
|
2019-03-12 10:05:58 -05:00
|
|
|
{
|
2019-03-22 09:11:56 -05:00
|
|
|
m_annotationTool->attachAnnotationLine(this, annotation->color(), annotation->name(), annotation->value());
|
2019-03-12 10:05:58 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-04 08:35:48 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuGridCrossQwtPlot::updateLayout()
|
|
|
|
{
|
|
|
|
QwtPlot::updateLayout();
|
2019-03-25 08:47:55 -05:00
|
|
|
updateInfoBoxLayout();
|
2019-03-04 08:35:48 -06:00
|
|
|
updateLegendLayout();
|
|
|
|
}
|
|
|
|
|
2019-03-25 08:47:55 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuGridCrossQwtPlot::updateInfoBoxLayout()
|
|
|
|
{
|
|
|
|
RimGridCrossPlot* crossPlot = dynamic_cast<RimGridCrossPlot*>(ownerPlotDefinition());
|
|
|
|
if (!crossPlot) return;
|
|
|
|
|
|
|
|
bool showInfo = false;
|
|
|
|
if (crossPlot->showInfoBox())
|
|
|
|
{
|
|
|
|
QStringList curveInfoTexts;
|
2019-03-29 07:17:39 -05:00
|
|
|
for (auto dataSet : crossPlot->dataSets())
|
2019-03-25 08:47:55 -05:00
|
|
|
{
|
2019-03-29 07:17:39 -05:00
|
|
|
QString curveInfoText = dataSet->infoText();
|
|
|
|
if (dataSet->isChecked() && !curveInfoText.isEmpty())
|
2019-03-25 08:47:55 -05:00
|
|
|
{
|
|
|
|
curveInfoTexts += curveInfoText;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
QStringList infoText;
|
|
|
|
if (curveInfoTexts.size() > 1)
|
|
|
|
{
|
|
|
|
infoText += QString("<ol style=\"margin-top: 0px; margin-left: 15px; -qt-list-indent:0;\">");
|
|
|
|
for (QString curveInfoText : curveInfoTexts)
|
|
|
|
{
|
|
|
|
infoText += QString("<li>%1</li>").arg(curveInfoText);
|
|
|
|
}
|
|
|
|
infoText += QString("</ol>");
|
|
|
|
}
|
|
|
|
else if (curveInfoTexts.size() > 0)
|
|
|
|
{
|
|
|
|
infoText += curveInfoTexts.front();
|
|
|
|
}
|
|
|
|
if (!infoText.empty())
|
|
|
|
{
|
|
|
|
m_infoBox->label()->setText(infoText.join("\n"));
|
2019-04-10 09:13:40 -05:00
|
|
|
QFont font = m_infoBox->font();
|
|
|
|
font.setPointSize(crossPlot->legendFontSize());
|
|
|
|
m_infoBox->setFont(font);
|
2019-03-25 08:47:55 -05:00
|
|
|
m_infoBox->adjustSize();
|
|
|
|
QRect infoRect = m_infoBox->frameGeometry();
|
|
|
|
QRect canvasRect = canvas()->frameGeometry();
|
|
|
|
infoRect.moveTop(canvasRect.top() + 4);
|
|
|
|
infoRect.moveRight(canvasRect.right() - 4);
|
|
|
|
m_infoBox->move(infoRect.topLeft());
|
|
|
|
showInfo = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (showInfo)
|
|
|
|
{
|
|
|
|
m_infoBox->show();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_infoBox->hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-04 08:35:48 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuGridCrossQwtPlot::updateLegendLayout()
|
|
|
|
{
|
|
|
|
const int spacing = 5;
|
|
|
|
int startMarginX = this->canvas()->pos().x() + spacing;
|
|
|
|
int startMarginY = this->canvas()->pos().y() + spacing;
|
|
|
|
|
|
|
|
int xpos = startMarginX;
|
|
|
|
int ypos = startMarginY;
|
|
|
|
int maxColumnWidth = 0;
|
|
|
|
|
2019-04-15 03:38:29 -05:00
|
|
|
removeDanglingDataSetLegends();
|
|
|
|
|
2019-03-04 08:35:48 -06:00
|
|
|
RimGridCrossPlot* crossPlot = dynamic_cast<RimGridCrossPlot*>(ownerPlotDefinition());
|
|
|
|
|
|
|
|
if (!crossPlot) return;
|
|
|
|
|
|
|
|
std::set<QString> legendTypes;
|
|
|
|
|
2019-03-29 07:17:39 -05:00
|
|
|
for (RimGridCrossPlotDataSet* dataSet : crossPlot->dataSets())
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
2019-04-12 11:31:57 -05:00
|
|
|
if (dataSet->isChecked() && dataSet->groupingEnabled() && dataSet->legendConfig()->showLegend())
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
2019-03-27 09:02:12 -05:00
|
|
|
|
2019-04-12 11:31:57 -05:00
|
|
|
auto pairIt = m_legendWidgets.find(dataSet);
|
|
|
|
if (pairIt != m_legendWidgets.end())
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
2019-04-12 11:31:57 -05:00
|
|
|
RiuCvfOverlayItemWidget* overlayWidget = pairIt->second;
|
|
|
|
|
|
|
|
// Show only one copy of each legend type
|
|
|
|
if (!legendTypes.count(dataSet->groupParameter()))
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
2019-04-12 11:31:57 -05:00
|
|
|
if (ypos + overlayWidget->height() + spacing > this->canvas()->height())
|
|
|
|
{
|
|
|
|
xpos += spacing + maxColumnWidth;
|
|
|
|
ypos = startMarginY;
|
|
|
|
maxColumnWidth = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
overlayWidget->show();
|
|
|
|
overlayWidget->move(xpos, ypos);
|
|
|
|
|
|
|
|
ypos += pairIt->second->height() + spacing;
|
|
|
|
maxColumnWidth = std::max(maxColumnWidth, pairIt->second->width());
|
|
|
|
legendTypes.insert(dataSet->groupParameter());
|
2019-03-04 08:35:48 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-03-07 12:00:38 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuGridCrossQwtPlot::resizeEvent(QResizeEvent* e)
|
|
|
|
{
|
|
|
|
QwtPlot::resizeEvent(e);
|
2019-03-08 02:59:29 -06:00
|
|
|
updateLegendSizesToMatchPlot();
|
2019-03-07 12:00:38 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RiuGridCrossQwtPlot::resizeOverlayItemToFitPlot(caf::TitledOverlayFrame* overlayItem)
|
|
|
|
{
|
|
|
|
QSize plotSize = this->canvas()->contentsRect().size();
|
2019-03-27 09:02:12 -05:00
|
|
|
cvf::Vec2ui existingRenderSize = overlayItem->renderSize();
|
2019-03-07 12:00:38 -06:00
|
|
|
cvf::Vec2ui legendSize = overlayItem->preferredSize();
|
|
|
|
|
|
|
|
bool sizeAltered = false;
|
|
|
|
|
2019-03-12 10:05:58 -05:00
|
|
|
if (plotSize.width() > 0 && (double)legendSize.x() > 0.9 * plotSize.width())
|
2019-03-07 12:00:38 -06:00
|
|
|
{
|
|
|
|
legendSize.x() = (plotSize.width() * 9) / 10;
|
2019-03-12 10:05:58 -05:00
|
|
|
sizeAltered = true;
|
2019-03-07 12:00:38 -06:00
|
|
|
}
|
2019-03-12 10:05:58 -05:00
|
|
|
if (plotSize.height() > 0 && (double)legendSize.y() > 0.9 * plotSize.height())
|
2019-03-07 12:00:38 -06:00
|
|
|
{
|
|
|
|
legendSize.y() = (plotSize.height() * 9) / 10;
|
2019-03-12 10:05:58 -05:00
|
|
|
sizeAltered = true;
|
2019-03-07 12:00:38 -06:00
|
|
|
}
|
|
|
|
overlayItem->setRenderSize(legendSize);
|
2019-03-27 09:02:12 -05:00
|
|
|
|
|
|
|
if (legendSize.x() != existingRenderSize.x() || legendSize.y() != existingRenderSize.y())
|
|
|
|
{
|
|
|
|
sizeAltered = true;
|
|
|
|
}
|
|
|
|
|
2019-03-07 12:00:38 -06:00
|
|
|
return sizeAltered;
|
|
|
|
}
|
2019-03-11 05:39:23 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuGridCrossQwtPlot::contextMenuEvent(QContextMenuEvent* event)
|
|
|
|
{
|
|
|
|
QMenu menu;
|
|
|
|
caf::CmdFeatureMenuBuilder menuBuilder;
|
|
|
|
|
|
|
|
caf::SelectionManager::instance()->setSelectedItem(ownerViewWindow());
|
|
|
|
|
2019-03-29 07:17:39 -05:00
|
|
|
menuBuilder << "RicSwapGridCrossPlotDataSetAxesFeature";
|
2019-03-12 07:48:51 -05:00
|
|
|
menuBuilder << "Separator";
|
2019-03-11 05:39:23 -05:00
|
|
|
menuBuilder << "RicShowPlotDataFeature";
|
|
|
|
|
|
|
|
menuBuilder.appendToMenu(&menu);
|
|
|
|
|
|
|
|
if (menu.actions().size() > 0)
|
|
|
|
{
|
|
|
|
menu.exec(event->globalPos());
|
|
|
|
}
|
|
|
|
}
|
2019-03-26 05:33:55 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuGridCrossQwtPlot::selectSample(QwtPlotCurve* curve, int sampleNumber)
|
|
|
|
{
|
|
|
|
QPointF sample = curve->sample(sampleNumber);
|
|
|
|
m_selectedPointMarker->setValue(sample);
|
|
|
|
m_selectedPointMarker->setAxes(QwtPlot::xBottom, QwtPlot::yLeft);
|
|
|
|
m_selectedPointMarker->attach(this);
|
2019-03-27 09:17:52 -05:00
|
|
|
QString curveName, xAxisName, yAxisName;
|
|
|
|
if (curveText(curve, &curveName, &xAxisName, &yAxisName))
|
|
|
|
{
|
|
|
|
QString labelFormat("<div style=\"margin: 4px;\"><b>%1:</b><br/>%2 = %3, %4 = %5</div>");
|
|
|
|
QString labelString = labelFormat.arg(curveName).arg(xAxisName).arg(sample.x()).arg(yAxisName).arg(sample.y());
|
|
|
|
QwtText curveLabel(labelString, QwtText::RichText);
|
|
|
|
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);
|
|
|
|
}
|
2019-03-26 05:33:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuGridCrossQwtPlot::clearSampleSelection()
|
|
|
|
{
|
|
|
|
m_selectedPointMarker->detach();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-27 09:17:52 -05:00
|
|
|
bool RiuGridCrossQwtPlot::curveText(const QwtPlotCurve* curve,
|
|
|
|
QString* curveTitle,
|
|
|
|
QString* xParamName,
|
|
|
|
QString* yParamName) const
|
2019-03-26 05:33:55 -05:00
|
|
|
{
|
2019-03-27 09:17:52 -05:00
|
|
|
CVF_ASSERT(curveTitle && xParamName && yParamName);
|
|
|
|
|
2019-03-26 05:33:55 -05:00
|
|
|
auto riuCurve = dynamic_cast<const RiuRimQwtPlotCurve*>(curve);
|
|
|
|
if (riuCurve)
|
|
|
|
{
|
|
|
|
auto crossPlotCurve = dynamic_cast<const RimGridCrossPlotCurve*>(riuCurve->ownerRimCurve());
|
|
|
|
if (crossPlotCurve)
|
|
|
|
{
|
2019-03-27 09:17:52 -05:00
|
|
|
*curveTitle = crossPlotCurve->curveName();
|
|
|
|
|
2019-03-29 07:17:39 -05:00
|
|
|
RimGridCrossPlotDataSet* dataSet = nullptr;
|
|
|
|
crossPlotCurve->firstAncestorOrThisOfType(dataSet);
|
|
|
|
if (dataSet)
|
2019-03-27 09:17:52 -05:00
|
|
|
{
|
2019-03-29 07:17:39 -05:00
|
|
|
*xParamName = dataSet->xAxisName();
|
|
|
|
*yParamName = dataSet->yAxisName();
|
2019-03-27 09:17:52 -05:00
|
|
|
return true;
|
|
|
|
}
|
2019-03-26 05:33:55 -05:00
|
|
|
}
|
|
|
|
}
|
2019-03-27 09:17:52 -05:00
|
|
|
return false;
|
2019-03-26 05:33:55 -05:00
|
|
|
}
|
2019-04-10 09:13:40 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuGridCrossQwtPlot::applyFontSizeToOverlayItem(caf::TitledOverlayFrame* overlayItem)
|
|
|
|
{
|
|
|
|
RimGridCrossPlot* crossPlot = static_cast<RimGridCrossPlot*>(ownerViewWindow());
|
|
|
|
int fontSize = crossPlot->legendFontSize();
|
|
|
|
cvf::ref<cvf::Font> cafFont = RiaFontCache::getFont(RiaFontCache::fontSizeEnumFromPointSize(fontSize));
|
|
|
|
overlayItem->setFont(cafFont.p());
|
|
|
|
}
|