File indexing completed on 2024-05-05 03:48:22

0001 /*
0002     File                 : ColorMapsManager.h
0003     Project              : LabPlot
0004     Description          : color maps manager
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2021 Alexander Semke <alexander.semke@web.de>
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #ifndef COLORMAPSMANAGER_H
0011 #define COLORMAPSMANAGER_H
0012 
0013 #include <QColor>
0014 #include <QMap>
0015 #include <QVector>
0016 
0017 class QPixmap;
0018 
0019 class ColorMapsManager {
0020 public:
0021     static ColorMapsManager* instance();
0022     QStringList collectionNames() const;
0023     QString collectionInfo(const QString& collectionName) const;
0024     QStringList colorMapNames(const QString& collectionName);
0025     QVector<QColor> colors() const;
0026     void render(QPixmap&, const QString& name);
0027 
0028 private:
0029     ColorMapsManager();
0030     ~ColorMapsManager();
0031 
0032     void loadCollections();
0033 
0034     static ColorMapsManager* m_instance;
0035 
0036     QMap<QString, QString> m_collections; // collections (key = collection name, value = description)
0037     QMap<QString, QStringList> m_colorMaps; // color maps in a collection (key = collection name, value = list of color map names)
0038     QMap<QString, QStringList> m_colors; // colors (key = color map name, value = list of colors in the string representation)
0039     QString m_jsonDir;
0040     QVector<QColor> m_colormap;
0041 };
0042 
0043 #endif // COLORMAPSMANAGER_H