File indexing completed on 2023-09-24 03:52:08
0001 /* 0002 SPDX-FileCopyrightText: 2010 Etienne Rebetez <etienne.rebetez@oberwallis.ch> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KALZIUMELEMENTPROPERTY_H 0008 #define KALZIUMELEMENTPROPERTY_H 0009 0010 #include <QObject> 0011 #include <QBrush> 0012 0013 #include "kalziumgradienttype.h" 0014 #include "kalziumschemetype.h" 0015 0016 /** 0017 * The logic of the scheme and the gradients is merged in this class. It provides 0018 * an API to set the gradient and scheme without worrying about the real id's. 0019 * Elements can then get their properties with the element functions. 0020 * Here is also the place where the gradientslider is evaluated. (see gradientwidget) 0021 * @short This class holds the logic of the appearance from the periodic table 0022 * @author Etienne Rebetez 0023 */ 0024 0025 class KalziumElementProperty : public QObject 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 /** 0031 * Get the instance of this factory. 0032 */ 0033 static KalziumElementProperty *instance(); 0034 0035 enum ELEMENTTEXTINFORMATIONMODE { 0036 NORMAL = 0, // Only Symbol Number 0037 ELNUMBER, 0038 GRADIENTVALUE 0039 }; 0040 0041 enum SPECIALGRADIENTYPDEF { NOGRADIENT = 0, SOMGradientType = 1, DISCOVERYDATE = 9 }; 0042 0043 /** 0044 * all available schemes. Can be used to populate menus. 0045 */ 0046 QStringList schemeList() const; 0047 /** 0048 * all available gradients. Can be used to populate menus. 0049 */ 0050 QStringList gradientList() const; 0051 0052 /** 0053 * Returns the current scheme id as int. Equivalent to the scheme list. 0054 */ 0055 int schemeId() const; 0056 /** 0057 * Returns the current gradient id as int. Equivalent to the gradient list. 0058 */ 0059 int gradientId() const; 0060 0061 /** 0062 * Returns the current real KalziumSchemeType class 0063 */ 0064 KalziumSchemeType *scheme() const; 0065 /** 0066 * Returns the current real KalziumGradientType class 0067 */ 0068 KalziumGradientType *gradient() const; 0069 0070 /** 0071 * This is an element function. 0072 * It returns the Brush (Background) for the given element. 0073 * It uses the color form getElementColor. 0074 * @param el Number of the element. 0075 */ 0076 QBrush getElementBrush(int el); 0077 /** 0078 * This is an element function. 0079 * It returns the Color (Background) for the given element. 0080 * @param el Number of the element. 0081 */ 0082 QColor getElementColor(int el); 0083 /** 0084 * This is an element function. 0085 * It returns the Text color for the given element. 0086 * @param el Number of the element. 0087 */ 0088 QColor getTextColor(int el) const; 0089 /** 0090 * This is an element function. 0091 * It returns the border color of the for the given element. 0092 * @param el Number of the element. 0093 */ 0094 QColor getBorderColor(int el) const; 0095 0096 /** 0097 * This is an element function. 0098 * It returns the value from the current gradient type for the given element. 0099 * @param el Number of the element. 0100 */ 0101 double getValue(int el) const; 0102 0103 /** 0104 * This is an element function. 0105 * The mode returns the enum ELEMENTTEXTINFORMATIONMODE. 0106 * The mode is used to differ different layouts in the elementitem. 0107 */ 0108 int getMode() const; 0109 0110 Q_SIGNALS: 0111 /** 0112 * Is emitted every time a property (scheme, gradient, ...) is changed. 0113 * all elements will be redrawn. 0114 */ 0115 void propertyChanged(); 0116 0117 public Q_SLOTS: 0118 /** 0119 * gets the value from the gradientwidget. The value which is used to 0120 * determine if an element is active or not. 0121 * @param slide value of the current gradient 0122 */ 0123 void setSliderValue(double slide); 0124 /** 0125 * sets the new scheme 0126 */ 0127 void setScheme(int newScheme); 0128 /** 0129 * sets the new gradient 0130 */ 0131 void setGradient(int newGradient); 0132 0133 private: 0134 KalziumElementProperty(); 0135 ~KalziumElementProperty() override; 0136 0137 bool isGradient(); 0138 0139 QColor gradientBrushLogic(int el) const; 0140 0141 int m_currentScheme; 0142 int m_currentGradient; 0143 0144 double m_slider; 0145 int m_mode; 0146 }; 0147 0148 #endif // KALZIUMELEMENTPROPERTY_H