Tulip 5.7.1
Large graphs analysis and drawing
Loading...
Searching...
No Matches
ColorScaleConfigDialog.h
1/*
2 *
3 * This file is part of Tulip (https://tulip.labri.fr)
4 *
5 * Authors: David Auber and the Tulip development Team
6 * from LaBRI, University of Bordeaux
7 *
8 * Tulip is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation, either version 3
11 * of the License, or (at your option) any later version.
12 *
13 * Tulip is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
17 *
18 */
19///@cond DOXYGEN_HIDDEN
20
21#ifndef COLORSCALECONFIGDIALOG_H_
22#define COLORSCALECONFIGDIALOG_H_
23
24#include <tulip/ColorScale.h>
25
26#include <QDialog>
27
28namespace Ui {
29class ColorScaleDialog;
30}
31
32class QTableWidgetItem;
33class QListWidgetItem;
34class QLabel;
35
36namespace tlp {
37
38class TLP_QT_SCOPE ColorScaleConfigDialog : public QDialog {
39
40 Q_OBJECT
41
42public:
43 ColorScaleConfigDialog(const ColorScale &colorScale = ColorScale(), QWidget *parent = nullptr);
44 ~ColorScaleConfigDialog() override;
45 void setColorScale(const ColorScale &colorScale);
46 const ColorScale &getColorScale() const;
47 static ColorScale getColorScaleFromImageFile(const std::string &imageFilePath,
48 bool gradient = true);
49
50protected:
51 void resizeEvent(QResizeEvent *event) override;
52 void showEvent(QShowEvent *event) override;
53
54private slots:
55
56 void accept() override;
57 void pressButtonBrowse();
58 void nbColorsValueChanged(int value);
59 void colorTableItemDoubleClicked(QTableWidgetItem *item);
60 void displaySavedGradientPreview();
61 void displayUserGradientPreview();
62 void saveCurrentColorScale();
63 void deleteSavedColorScale();
64 void reeditSaveColorScale(QListWidgetItem *savedColorScaleItem);
65 void importColorScaleFromImageFile();
66 void importColorScaleFromColorScaleFile();
67 void invertEditedColorScale();
68 void applyGlobalAlphaToColorScale();
69
70private:
71 Ui::ColorScaleDialog *_ui;
72
73 void setColorScaleFromImage(const QString &imageFilePath);
74
75 void loadUserSavedColorScales();
76 void displayGradientPreview(const QList<QColor> &colorsVector, bool gradient,
77 QLabel *displayLabel);
78 void importColorScaleFromFile(const QString &currentDir);
79
80 ColorScale colorScale;
81 ColorScale latestColorScale;
82 std::string gradientsImageDirectory;
83
84 static std::map<QString, std::vector<Color>> tulipImageColorScales;
85 static void loadTulipImageColorScales();
86 static void loadImageColorScalesFromDir(const QString &colorScalesDir);
87 static std::vector<Color> getColorScaleFromImageFile(const QString &imageFilePath);
88};
89} // namespace tlp
90
91#endif /* COLORSCALECONFIGDIALOG_H_ */
92///@endcond