Tulip  4.8.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
ColorScaleConfigDialog.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
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 
22 #ifndef COLORSCALECONFIGDIALOG_H_
23 #define COLORSCALECONFIGDIALOG_H_
24 
25 #include <tulip/ColorScale.h>
26 
27 #include <QDialog>
28 
29 namespace Ui {
30 class ColorScaleDialog;
31 }
32 
33 class QTableWidgetItem;
34 class QListWidgetItem;
35 class QLabel;
36 
37 namespace tlp {
38 
39 class TLP_QT_SCOPE ColorScaleConfigDialog : public QDialog {
40 
41  Q_OBJECT
42 
43 public :
44  ColorScaleConfigDialog(const ColorScale &colorScale = ColorScale(), QWidget *parent = NULL);
45  ~ColorScaleConfigDialog();
46  void setColorScale(const ColorScale &colorScale);
47  const ColorScale& getColorScale() const;
48  static ColorScale getColorScaleFromImageFile(const std::string& imageFilePath,
49  bool gradient = true);
50 
51 protected :
52 
53  void resizeEvent(QResizeEvent * event);
54  void showEvent(QShowEvent * event);
55 
56 private slots :
57 
58  void accept();
59  void pressButtonBrowse();
60  void nbColorsValueChanged(int value);
61  void colorTableItemDoubleClicked(QTableWidgetItem *item);
62  void displaySavedGradientPreview();
63  void displayUserGradientPreview();
64  void saveCurrentColorScale();
65  void deleteSavedColorScale();
66  void reeditSaveColorScale(QListWidgetItem *savedColorScaleItem);
67  void importColorScaleFromImageFile();
68  void invertEditedColorScale();
69 
70 private :
71  Ui::ColorScaleDialog *_ui;
72 
73  void setColorScaleFromImage(const QString &imageFilePath);
74 
75  void loadUserSavedColorScales();
76  void displayGradientPreview(const QList<QColor> &colorsVector, bool gradient, QLabel *displayLabel);
77 
78  ColorScale colorScale;
79  std::string gradientsImageDirectory;
80 
81  static std::map<QString, std::vector<Color> > tulipImageColorScales;
82  static void loadTulipImageColorScales();
83  static std::vector<Color> getColorScaleFromImageFile(const QString &imageFilePath);
84 };
85 
86 }
87 
88 #endif /* COLORSCALECONFIGDIALOG_H_ */
89 ///@endcond