Warning, file /office/calligra/libs/pigment/KoColorDisplayRendererInterface.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * Copyright (c) 2014 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Lesser General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2.1 of the License, or (at your option) any later version. 0008 * 0009 * This library is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 * Lesser General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Lesser General Public License 0015 * along with this library; see the file COPYING.LIB. If not, write to 0016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef __KO_COLOR_DISPLAY_RENDERER_INTERFACE_H 0021 #define __KO_COLOR_DISPLAY_RENDERER_INTERFACE_H 0022 0023 #include <QObject> 0024 #include <QColor> 0025 #include <QSharedPointer> 0026 0027 #include "KoColor.h" 0028 0029 class KoChannelInfo; 0030 0031 /** 0032 * A special interface class provided by pigment to let widgets render 0033 * a KoColor on screen using custom profiling provided by the user. 0034 * 0035 * If you want to provide your own rendering of the KoColor on screen, 0036 * reimplement this class and provide its instance to a supporting 0037 * widget. 0038 */ 0039 class PIGMENTCMS_EXPORT KoColorDisplayRendererInterface : public QObject 0040 { 0041 Q_OBJECT 0042 0043 public: 0044 KoColorDisplayRendererInterface(); 0045 ~KoColorDisplayRendererInterface() override; 0046 0047 /** 0048 * Convert the color \p c to a custom QColor that will be 0049 * displayed by the widget on screen. Please note, that the 0050 * reverse conversion may simply not exist. 0051 */ 0052 virtual QColor toQColor(const KoColor &c) const = 0; 0053 0054 /** 0055 * This tries to approximate a rendered QColor into the KoColor 0056 * of the painting color space. Please note, that in most of the 0057 * cases the exact reverse transformation does not exist, so the 0058 * resulting color will be only a rough approximation. Never try 0059 * to do a round trip like that: 0060 * 0061 * // r will never be equal to c! 0062 * r = approximateFromRenderedQColor(toQColor(c)); 0063 */ 0064 virtual KoColor approximateFromRenderedQColor(const QColor &c) const = 0; 0065 0066 virtual KoColor fromHsv(int h, int s, int v, int a = 255) const = 0; 0067 virtual void getHsv(const KoColor &srcColor, int *h, int *s, int *v, int *a = 0) const = 0; 0068 0069 0070 /** 0071 * \return the minimum value of a floating point channel that can 0072 * be seen on screen 0073 */ 0074 virtual qreal minVisibleFloatValue(const KoChannelInfo *chaninfo) const = 0; 0075 0076 /** 0077 * \return the maximum value of a floating point channel that can 0078 * be seen on screen. In normal situation it is 1.0. When 0079 * the user changes exposure the value varies. 0080 */ 0081 virtual qreal maxVisibleFloatValue(const KoChannelInfo *chaninfo) const = 0; 0082 0083 Q_SIGNALS: 0084 void displayConfigurationChanged(); 0085 0086 private: 0087 Q_DISABLE_COPY(KoColorDisplayRendererInterface) 0088 }; 0089 0090 /** 0091 * The default conversion class that just calls KoColor::toQColor() 0092 * conversion implementation which effectively renders the color into 0093 * sRGB color space. 0094 */ 0095 class PIGMENTCMS_EXPORT KoDumbColorDisplayRenderer : public KoColorDisplayRendererInterface 0096 { 0097 Q_OBJECT 0098 public: 0099 QColor toQColor(const KoColor &c) const override; 0100 KoColor approximateFromRenderedQColor(const QColor &c) const override; 0101 KoColor fromHsv(int h, int s, int v, int a = 255) const override; 0102 void getHsv(const KoColor &srcColor, int *h, int *s, int *v, int *a = 0) const override; 0103 0104 qreal minVisibleFloatValue(const KoChannelInfo *chaninfo) const override; 0105 qreal maxVisibleFloatValue(const KoChannelInfo *chaninfo) const override; 0106 0107 static KoColorDisplayRendererInterface* instance(); 0108 }; 0109 0110 #endif /* __KO_COLOR_DISPLAY_RENDERER_INTERFACE_H */