#1983 RFT Plot. Apply colors and symbols to curves

This commit is contained in:
Bjørn Erik Jensen 2017-10-09 10:51:07 +02:00
parent d5d3646bb5
commit 0cb97b9c74
2 changed files with 106 additions and 1 deletions

View File

@ -132,6 +132,103 @@ void RimWellRftPlot::deleteViewWidget()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellRftPlot::applyCurveAppearance(RimWellLogCurve* newCurve)
{
const std::pair<RimWellRftAddress, QDateTime>& newCurveDef = curveDefFromCurve(newCurve);
std::vector<cvf::Color3f> colorTable;
RiaColorTables::summaryCurveDefaultPaletteColors().color3fArray().toStdVector(&colorTable);
std::vector<RimPlotCurve::PointSymbolEnum> symbolTable =
{
RimPlotCurve::SYMBOL_NONE,
RimPlotCurve::SYMBOL_ELLIPSE,
RimPlotCurve::SYMBOL_RECT,
RimPlotCurve::SYMBOL_DIAMOND,
RimPlotCurve::SYMBOL_TRIANGLE,
RimPlotCurve::SYMBOL_CROSS,
RimPlotCurve::SYMBOL_XCROSS
};
cvf::Color3f currentColor;
RimPlotCurve::PointSymbolEnum currentSymbol = RimPlotCurve::SYMBOL_NONE;
RimPlotCurve::LineStyleEnum currentLineStyle = RimPlotCurve::STYLE_SOLID;
bool isCurrentColorSet = false;
bool isCurrentSymbolSet = false;
std::set<cvf::Color3f> assignedColors;
std::set<RimPlotCurve::PointSymbolEnum> assignedSymbols;
// Used colors and symbols
for (const auto& curve : m_wellLogPlot->trackByIndex(0)->curvesVector())
{
if (curve == newCurve) continue;
auto cDef = curveDefFromCurve(curve);
if (cDef.first == newCurveDef.first)
{
currentColor = curve->color();
isCurrentColorSet = true;
}
if (cDef.second == newCurveDef.second)
{
currentSymbol = curve->symbol();
isCurrentSymbolSet = true;
}
assignedColors.insert(curve->color());
assignedSymbols.insert(curve->symbol());
}
// Assign color
if (!isCurrentColorSet)
{
for(const auto& color : colorTable)
{
if (assignedColors.count(color) == 0)
{
currentColor = color;
isCurrentColorSet = true;
break;
}
}
if (!isCurrentColorSet)
{
currentColor = colorTable.front();
}
}
// Assign symbol
if (!isCurrentSymbolSet)
{
for (const auto& symbol : symbolTable)
{
if (symbol == RimPlotCurve::SYMBOL_NONE) continue;
if (assignedSymbols.count(symbol) == 0)
{
currentSymbol = symbol;
isCurrentSymbolSet = true;
break;
}
}
if (!isCurrentSymbolSet)
{
currentSymbol = symbolTable.front();
}
}
// Observed data
currentLineStyle = newCurveDef.first.sourceType() == RftSourceType::OBSERVED
? RimPlotCurve::STYLE_NONE : RimPlotCurve::STYLE_SOLID;
newCurve->setColor(currentColor);
newCurve->setSymbol(currentSymbol);
newCurve->setLineStyle(currentLineStyle);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -515,6 +612,8 @@ void RimWellRftPlot::updateCurvesInPlot(const std::set<std::pair<RimWellRftAddre
RifEclipseRftAddress address(m_wellName, curveDefToAdd.second, RifEclipseRftAddress::PRESSURE);
curve->setRftAddress(address);
applyCurveAppearance(curve);
curve->loadDataAndUpdate(true);
}
else if (curveDefToAdd.first.sourceType() == RftSourceType::GRID)
@ -543,6 +642,8 @@ void RimWellRftPlot::updateCurvesInPlot(const std::set<std::pair<RimWellRftAddre
auto currentTimeStepIt = std::find(timeSteps.begin(), timeSteps.end(), curveDefToAdd.second);
auto currentTimeStep = std::distance(timeSteps.begin(), currentTimeStepIt);
curve->setCurrentTimeStep(currentTimeStep);
applyCurveAppearance(curve);
curve->loadDataAndUpdate(false);
}
}
@ -557,6 +658,8 @@ void RimWellRftPlot::updateCurvesInPlot(const std::set<std::pair<RimWellRftAddre
plotTrack->addCurve(curve);
curve->setWellPath(wellPath);
curve->setWellLogChannelName(pressureChannels.front()->name());
applyCurveAppearance(curve);
curve->loadDataAndUpdate(true);
}
}

View File

@ -25,7 +25,7 @@
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include "RimWellRftAddress.h"
#include "RimPlotCurve.h"
#include <QPointer>
#include <QDate>
#include <QMetaType>
@ -129,6 +129,8 @@ private:
virtual QWidget* createViewWidget(QWidget* mainWindowParent) override;
virtual void deleteViewWidget() override;
void applyCurveAppearance(RimWellLogCurve* newCurve);
private:
caf::PdmField<bool> m_showPlotTitle;
caf::PdmField<QString> m_userName;