mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
3D Cross Plot: Improve colors and symbols in legend
This commit is contained in:
@@ -43,18 +43,30 @@ CAF_PDM_SOURCE_INIT(RimGridCrossPlotCurve, "GridCrossPlotCurve");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlotCurve::determineColorAndSymbol(int curveSetIndex, int categoryIndex, bool contrastColors)
|
||||
void RimGridCrossPlotCurve::determineColorAndSymbol(int curveSetIndex, int categoryIndex, int nCategories, bool contrastColors)
|
||||
{
|
||||
const caf::ColorTable& colors = RiaColorTables::contrastCategoryPaletteColors();
|
||||
int colorIndex = categoryIndex + curveSetIndex; // Offset cycle for each curve set
|
||||
setColor(colors.cycledColor3f(colorIndex));
|
||||
int numColors = (int) colors.size();
|
||||
if (contrastColors)
|
||||
{
|
||||
const caf::ColorTable& colors = RiaColorTables::contrastCategoryPaletteColors();
|
||||
int colorIndex = categoryIndex + 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 = categoryIndex / numColors;
|
||||
|
||||
RiuQwtSymbol::PointSymbolEnum symbol = RiuQwtSymbol::cycledSymbolStyle(curveSetIndex, symbolIndex);
|
||||
setSymbol(symbol);
|
||||
// Retain same symbol until we've gone full cycle in colors
|
||||
int symbolIndex = categoryIndex / numColors;
|
||||
|
||||
RiuQwtSymbol::PointSymbolEnum symbol = RiuQwtSymbol::cycledSymbolStyle(curveSetIndex, symbolIndex);
|
||||
setSymbol(symbol);
|
||||
}
|
||||
else
|
||||
{
|
||||
const caf::ColorTable& colors = RiaColorTables::contrastCategoryPaletteColors();
|
||||
cvf::Color3ub cycledBaseColor = colors.cycledColor3ub(curveSetIndex);
|
||||
caf::ColorTable hueConstColTable = RiaColorTables::createBrightnessBasedColorTable(cycledBaseColor, nCategories);
|
||||
setColor(hueConstColTable.cycledColor3f(categoryIndex));
|
||||
RiuQwtSymbol::PointSymbolEnum symbol = RiuQwtSymbol::cycledFilledSymbolStyle(curveSetIndex);
|
||||
setSymbol(symbol);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -65,6 +77,8 @@ RimGridCrossPlotCurve::RimGridCrossPlotCurve()
|
||||
CAF_PDM_InitObject("Cross Plot Points", ":/WellLogCurve16x16.png", "", "");
|
||||
|
||||
setLineStyle(RiuQwtPlotCurve::STYLE_NONE);
|
||||
setLineThickness(0);
|
||||
setSymbol(RiuQwtSymbol::SYMBOL_NONE);
|
||||
setSymbolSize(6);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class RimGridCrossPlotCurve : public RimPlotCurve
|
||||
public:
|
||||
RimGridCrossPlotCurve();
|
||||
~RimGridCrossPlotCurve() override = default;
|
||||
void determineColorAndSymbol(int curveSetIndex, int categoryIndex, bool contrastColors = false);
|
||||
void determineColorAndSymbol(int curveSetIndex, int categoryIndex, int nCategories, bool contrastColors = false);
|
||||
void setSamples(const QVector<QPointF>& samples);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -154,6 +154,17 @@ QString RimGridCrossPlotCurveSet::createAutoName() const
|
||||
return nameTags.join(", ");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlotCurveSet::detachAllCurves()
|
||||
{
|
||||
for (auto curve : m_crossPlotCurves())
|
||||
{
|
||||
curve->detachQwtCurve();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -173,7 +184,8 @@ void RimGridCrossPlotCurveSet::initAfterRead()
|
||||
void RimGridCrossPlotCurveSet::onLoadDataAndUpdate(bool updateParentPlot)
|
||||
{
|
||||
performAutoNameUpdate();
|
||||
|
||||
|
||||
detachAllCurves();
|
||||
m_crossPlotCurves.deleteAllChildObjects();
|
||||
|
||||
std::map<int, QVector<QPointF>> samples;
|
||||
@@ -269,7 +281,7 @@ void RimGridCrossPlotCurveSet::onLoadDataAndUpdate(bool updateParentPlot)
|
||||
{
|
||||
curve->setCustomName(QString("%1 : %2").arg(createAutoName()).arg(timeStepName));
|
||||
}
|
||||
curve->determineColorAndSymbol(curveSetIndex, sampleCategory.first);
|
||||
curve->determineColorAndSymbol(curveSetIndex, sampleCategory.first, (int) samples.size(), false);
|
||||
curve->setSamples(sampleCategory.second);
|
||||
curve->updateCurveAppearance();
|
||||
curve->updateCurveNameAndUpdatePlotLegendAndTitle();
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
|
||||
int indexInPlot() const;
|
||||
QString createAutoName() const override;
|
||||
|
||||
void detachAllCurves();
|
||||
protected:
|
||||
void initAfterRead() override;
|
||||
void onLoadDataAndUpdate(bool updateParentPlot);
|
||||
|
||||
Reference in New Issue
Block a user