Files
ResInsight/ApplicationLibCode/ProjectDataModel/RimColorLegendCollection.h
T
Kristian Bendiksen d78d7cf430 #14192 Update color legend in place on roff property re-import
Reuse RimColorLegendCollection::updateColorLegend in the two roff import
sites that previously deleted and recreated the legend bound to a result,
so views referencing the legend keep their binding on re-import.

Extract the rock color matching from createColorLegendMatchDefaultRockColors
into matchDefaultRockColors so the facies branch can pass matched colors to
updateColorLegend. Remove the now-unused
RimColorLegendCollection::createColorLegend.
2026-06-10 18:02:07 +02:00

88 lines
3.6 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cvfColor3.h"
class RimCase;
class RimColorLegend;
class RimColorLegendItem;
class RimFormationNames;
namespace caf
{
class PdmUiEditorAttribute;
}
//==================================================================================================
///
///
//==================================================================================================
class RimColorLegendCollection : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimColorLegendCollection();
~RimColorLegendCollection() override;
void createStandardColorLegends();
void appendCustomColorLegend( RimColorLegend* customColorLegend );
bool isStandardColorLegend( RimColorLegend* colorLegend );
void deleteCustomColorLegends();
RimColorLegend* updateColorLegend( const RimCase* rimCase,
const QString& resultName,
const QString& colorLegendName,
const std::vector<int>& categoryValues,
const std::vector<QString>& categoryNames,
const std::vector<cvf::Color3f>& colors );
RimColorLegend* updateColorLegend( const RimCase* rimCase,
const QString& resultName,
const QString& colorLegendName,
const std::map<int, QString>& valuesAndNames,
const std::vector<cvf::Color3f>& colors = {} );
void createColorLegendFromFormationNames( RimFormationNames* rimFormationNames );
void deleteColorLegend( const RimCase* rimCase, const QString& resultName );
void setDefaultColorLegendForResult( const RimCase* rimCase, const QString& resultName, RimColorLegend* colorLegend );
std::vector<RimColorLegend*> allColorLegends() const;
RimColorLegend* findByName( const QString& name ) const;
RimColorLegend* findDefaultLegendForResult( const RimCase* rimCase, const QString& resultName ) const;
protected:
void initAfterRead() override;
private:
RimColorLegendItem* createColorLegendItem( const QString& name, int r, int g, int b ) const;
RimColorLegend* createRockTypeColorLegend() const;
static QString createLookupKey( const RimCase* rimCase, const QString& resultName );
caf::PdmChildArrayField<RimColorLegend*> m_standardColorLegends; // ResInsight standard (built-in) legends
caf::PdmChildArrayField<RimColorLegend*> m_customColorLegends; // user specified legends
std::map<QString, caf::PdmPointer<RimColorLegend>> m_defaultColorLegendNameForResult;
};