Tulip  5.0.0
Large graphs analysis and drawing
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, bool gradient = true);
49 
50 protected :
51 
52  void resizeEvent(QResizeEvent * event);
53  void showEvent(QShowEvent * event);
54 
55 private slots :
56 
57  void accept();
58  void pressButtonBrowse();
59  void nbColorsValueChanged(int value);
60  void colorTableItemDoubleClicked(QTableWidgetItem *item);
61  void displaySavedGradientPreview();
62  void displayUserGradientPreview();
63  void saveCurrentColorScale();
64  void deleteSavedColorScale();
65  void reeditSaveColorScale(QListWidgetItem *savedColorScaleItem);
66  void importColorScaleFromImageFile();
67  void importColorScaleFromColorScaleFile();
68  void invertEditedColorScale();
69  void applyGlobalAlphaToColorScale();
70 
71 private :
72  Ui::ColorScaleDialog *_ui;
73 
74  void setColorScaleFromImage(const QString &imageFilePath);
75 
76  void loadUserSavedColorScales();
77  void displayGradientPreview(const QList<QColor> &colorsVector, bool gradient, 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 std::vector<Color> getColorScaleFromImageFile(const QString &imageFilePath);
87 };
88 
89 }
90 
91 #endif /* COLORSCALECONFIGDIALOG_H_ */
92 ///@endcond