diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index e84f8e67c1..6fd14caec6 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -375,5 +375,12 @@ void RimPlotCurve::loadDataAndUpdate() this->onLoadDataAndUpdate(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::setLineStyle(LineStyleEnum lineStyle) +{ + m_lineStyle = lineStyle; +} diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.h b/ApplicationCode/ProjectDataModel/RimPlotCurve.h index 4fa080d9a9..92310d4d0d 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.h +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.h @@ -66,6 +66,7 @@ public: QwtPlotCurve* qwtPlotCurve() const; void setColor(const cvf::Color3f& color); + void setLineStyle(LineStyleEnum lineStyle); bool isCurveVisible() const; QString curveName() const { return m_curveName; } diff --git a/ApplicationCode/ProjectDataModel/RimSummaryCurveFilter.cpp b/ApplicationCode/ProjectDataModel/RimSummaryCurveFilter.cpp index d2fd6adb47..60308698f3 100644 --- a/ApplicationCode/ProjectDataModel/RimSummaryCurveFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimSummaryCurveFilter.cpp @@ -229,6 +229,37 @@ void RimSummaryCurveFilter::detachQwtCurves() } } +static const int RI_LOGPLOT_CURVECOLORSCOUNT = 15; +static const int RI_LOGPLOT_CURVECOLORS[] = +{ + Qt::black, + Qt::darkBlue, + Qt::darkRed, + Qt::darkGreen, + Qt::darkYellow, + Qt::darkMagenta, + Qt::darkCyan, + Qt::darkGray, + Qt::blue, + Qt::red, + Qt::green, + Qt::yellow, + Qt::magenta, + Qt::cyan, + Qt::gray +}; + +//-------------------------------------------------------------------------------------------------- +/// Pick default curve color from an index based palette +//-------------------------------------------------------------------------------------------------- +cvf::Color3f curveColorFromTable(int colorIndex) +{ + QColor color = QColor(Qt::GlobalColor(RI_LOGPLOT_CURVECOLORS[colorIndex % RI_LOGPLOT_CURVECOLORSCOUNT])); + ++colorIndex; + cvf::Color3f cvfColor(color.redF(), color.greenF(), color.blueF()); + return cvfColor; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -276,17 +307,41 @@ void RimSummaryCurveFilter::syncCurvesFromUiSelection() // Create all new curves that is missing + int colorIndex = 2; + int lineStyleIdx = -1; + + RimSummaryCase* prevCase = nullptr; + RimPlotCurve::LineStyleEnum lineStyle = RimPlotCurve::STYLE_SOLID; for (auto& caseAddrPair: newCurveDefinitions) { RimSummaryCase* currentCase = caseAddrPair.first; - RimSummaryCurve* curve = new RimSummaryCurve(); + + RimSummaryCurve* curve = new RimSummaryCurve(); curve->setParentQwtPlot(m_parentQwtPlot); curve->setSummaryCase(currentCase); curve->setSummaryAddress(caseAddrPair.second); - cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable(); + + if(currentCase != prevCase) + { + prevCase = currentCase; + colorIndex = 2; + lineStyleIdx ++; + lineStyle = caf::AppEnum::fromIndex(lineStyleIdx%caf::AppEnum::size()); + if(lineStyle == RimPlotCurve::STYLE_NONE) + { + lineStyle = RimPlotCurve::STYLE_SOLID; + lineStyleIdx++; + } + } + + cvf::Color3f curveColor = curveColorFromTable(colorIndex); + colorIndex++; + curve->setColor(curveColor); + curve->setLineStyle(lineStyle); + m_curves.push_back(curve); } }