2019-02-21 05:52:23 -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 "RimGridCrossPlotCurve.h"
|
|
|
|
|
|
|
|
#include "RiaColorTables.h"
|
|
|
|
|
|
|
|
#include "RigCaseCellResultCalculator.h"
|
2019-02-22 04:08:21 -06:00
|
|
|
#include "RiuQwtSymbol.h"
|
2019-02-21 05:52:23 -06:00
|
|
|
|
|
|
|
#include "RimCase.h"
|
|
|
|
#include "RimEclipseCase.h"
|
|
|
|
#include "RimEclipseResultDefinition.h"
|
|
|
|
#include "RimGridCrossPlot.h"
|
|
|
|
#include "RimTools.h"
|
|
|
|
|
|
|
|
#include "cafPdmUiComboBoxEditor.h"
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QPointF>
|
|
|
|
#include <QVector>
|
|
|
|
|
|
|
|
#include "qwt_plot.h"
|
|
|
|
#include "qwt_plot_curve.h"
|
2019-02-22 04:08:21 -06:00
|
|
|
#include "qwt_graphic.h"
|
2019-02-21 05:52:23 -06:00
|
|
|
|
|
|
|
#include <random>
|
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT(RimGridCrossPlotCurve, "GridCrossPlotCurve");
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-02-28 11:30:07 -06:00
|
|
|
RimGridCrossPlotCurve::RimGridCrossPlotCurve()
|
|
|
|
: m_curveSetIndex(0)
|
|
|
|
, m_categoryIndex(0)
|
|
|
|
, m_categoryCount(0)
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-02-28 11:30:07 -06:00
|
|
|
CAF_PDM_InitObject("Cross Plot Points", ":/WellLogCurve16x16.png", "", "");
|
|
|
|
|
|
|
|
setLineStyle(RiuQwtPlotCurve::STYLE_NONE);
|
|
|
|
setSymbol(RiuQwtSymbol::SYMBOL_NONE);
|
|
|
|
setSymbolSize(6);
|
|
|
|
}
|
2019-02-21 08:42:02 -06:00
|
|
|
|
2019-02-28 11:30:07 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlotCurve::setCategoryInformation(int curveSetIndex, int categoryIndex, int categoryCount)
|
|
|
|
{
|
|
|
|
m_curveSetIndex = curveSetIndex;
|
|
|
|
m_categoryIndex = categoryIndex;
|
|
|
|
m_categoryCount = categoryCount;
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-02-28 11:30:07 -06:00
|
|
|
void RimGridCrossPlotCurve::setUseContrastColors(bool useContrastColors)
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-02-28 11:30:07 -06:00
|
|
|
m_useContrastColors = useContrastColors;
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-02-27 03:57:17 -06:00
|
|
|
void RimGridCrossPlotCurve::setSamples(const std::vector<double>& xValues, const std::vector<double>& yValues)
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-02-27 03:57:17 -06:00
|
|
|
CVF_ASSERT(xValues.size() == yValues.size());
|
|
|
|
|
|
|
|
m_qwtPlotCurve->setSamples(&xValues[0], &yValues[0], static_cast<int>(xValues.size()));
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-02-28 11:30:07 -06:00
|
|
|
void RimGridCrossPlotCurve::updateCurveAppearance()
|
|
|
|
{
|
|
|
|
determineColorAndSymbol();
|
|
|
|
RimPlotCurve::updateCurveAppearance();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
int RimGridCrossPlotCurve::categoryIndex() const
|
|
|
|
{
|
|
|
|
return m_categoryIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlotCurve::determineColorAndSymbol()
|
|
|
|
{
|
|
|
|
if (m_useContrastColors)
|
|
|
|
{
|
|
|
|
const caf::ColorTable& colors = RiaColorTables::categoryPaletteColors();
|
|
|
|
int colorIndex = m_categoryIndex + m_curveSetIndex; // Offset cycle for each curve set
|
|
|
|
setColor(colors.cycledColor3f(colorIndex));
|
|
|
|
int numColors = (int)colors.size();
|
|
|
|
|
|
|
|
// Retain same symbol until we've gone full cycle in colors
|
|
|
|
int symbolIndex = m_categoryIndex / numColors;
|
|
|
|
|
|
|
|
RiuQwtSymbol::PointSymbolEnum symbol = RiuQwtSymbol::cycledSymbolStyle(m_curveSetIndex, symbolIndex);
|
|
|
|
setSymbol(symbol);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const caf::ColorTable& colors = RiaColorTables::contrastCategoryPaletteColors();
|
|
|
|
cvf::Color3ub cycledBaseColor = colors.cycledColor3ub(m_curveSetIndex);
|
|
|
|
caf::ColorTable hueConstColTable = RiaColorTables::createBrightnessBasedColorTable(cycledBaseColor, m_categoryCount);
|
|
|
|
setColor(hueConstColTable.cycledColor3f(m_categoryIndex));
|
|
|
|
RiuQwtSymbol::PointSymbolEnum symbol = RiuQwtSymbol::cycledFilledSymbolStyle(m_curveSetIndex);
|
|
|
|
setSymbol(symbol);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-02-21 05:52:23 -06:00
|
|
|
void RimGridCrossPlotCurve::updateZoomInParentPlot()
|
|
|
|
{
|
|
|
|
RimGridCrossPlot* plot;
|
|
|
|
this->firstAncestorOrThisOfTypeAsserted(plot);
|
|
|
|
plot->calculateZoomRangeAndUpdateQwt();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlotCurve::updateLegendsInPlot()
|
|
|
|
{
|
2019-02-26 08:42:58 -06:00
|
|
|
RimGridCrossPlot* plot = nullptr;
|
|
|
|
this->firstAncestorOrThisOfType(plot);
|
|
|
|
if (plot)
|
|
|
|
{
|
|
|
|
plot->reattachCurvesToQwtAndReplot();
|
|
|
|
}
|
|
|
|
RimPlotCurve::updateLegendsInPlot();
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RimGridCrossPlotCurve::createCurveAutoName()
|
|
|
|
{
|
|
|
|
return m_customCurveName;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlotCurve::onLoadDataAndUpdate(bool updateParentPlot)
|
|
|
|
{
|
|
|
|
if (updateParentPlot)
|
|
|
|
{
|
|
|
|
RimGridCrossPlot* crossPlot;
|
|
|
|
firstAncestorOrThisOfTypeAsserted(crossPlot);
|
|
|
|
crossPlot->reattachCurvesToQwtAndReplot();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlotCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
|
|
|
{
|
|
|
|
caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup("Appearance");
|
|
|
|
RimPlotCurve::appearanceUiOrdering(*appearanceGroup);
|
2019-02-26 08:42:58 -06:00
|
|
|
caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup("Curve Name");
|
|
|
|
nameGroup->add(&m_curveName);
|
|
|
|
nameGroup->add(&m_showLegend);
|
|
|
|
uiOrdering.skipRemainingFields(true);
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|