Warning, file /office/calligra/libs/pigment/KoColorConversionSystem.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) 2007-2008 Cyrille Berger <cberger@cberger.net> 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_CONVERSION_SYSTEM_H_ 0021 #define _KO_COLOR_CONVERSION_SYSTEM_H_ 0022 0023 class KoColorProfile; 0024 class KoColorSpace; 0025 class KoColorSpaceFactory; 0026 class KoColorSpaceEngine; 0027 class KoID; 0028 0029 #include "KoColorConversionTransformation.h" 0030 0031 #include <QList> 0032 #include <QPair> 0033 0034 #include "pigment_export.h" 0035 0036 /** 0037 * This class hold the logic related to pigment's Color Conversion System. It's 0038 * basically a graph containing all the possible color transformation between 0039 * the color spaces. The most useful functions are createColorConverter to create 0040 * a color conversion between two color spaces, and insertColorSpace which is called 0041 * by KoColorSpaceRegistry each time a new color space is added to the registry. 0042 * 0043 * This class is not part of public API, and can be changed without notice. 0044 */ 0045 class PIGMENTCMS_EXPORT KoColorConversionSystem 0046 { 0047 public: 0048 struct Node; 0049 struct Vertex; 0050 struct NodeKey; 0051 friend uint qHash(const KoColorConversionSystem::NodeKey &key); 0052 struct Path; 0053 /** 0054 * Construct a Color Conversion System, leave to the KoColorSpaceRegistry to 0055 * create it. 0056 */ 0057 KoColorConversionSystem(); 0058 ~KoColorConversionSystem(); 0059 /** 0060 * This function is called by the KoColorSpaceRegistry to add a new color space 0061 * to the graph of transformation. 0062 */ 0063 void insertColorSpace(const KoColorSpaceFactory*); 0064 0065 void insertColorProfile(const KoColorProfile*); 0066 /** 0067 * This function is called by the color space to create a color conversion 0068 * between two color space. This function search in the graph of transformations 0069 * the best possible path between the two color space. 0070 */ 0071 KoColorConversionTransformation* createColorConverter(const KoColorSpace * srcColorSpace, const KoColorSpace * dstColorSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) const; 0072 0073 /** 0074 * This function creates two transformations, one from the color space and one to the 0075 * color space. The destination color space is picked from a list of color space, such 0076 * as the conversion between the two color space is of the best quality. 0077 * 0078 * The typical use case of this function is for KoColorTransformationFactory which 0079 * doesn't support all color spaces, so unsupported color space have to find an 0080 * acceptable conversion in order to use that KoColorTransformationFactory. 0081 * 0082 * @param colorSpace the source color space 0083 * @param possibilities a list of color space among which we need to find the best 0084 * conversion 0085 * @param fromCS the conversion from the source color space will be affected to this 0086 * variable 0087 * @param toCS the revert conversion to the source color space will be affected to this 0088 * variable 0089 */ 0090 void createColorConverters(const KoColorSpace* colorSpace, const QList< QPair<KoID, KoID> >& possibilities, KoColorConversionTransformation*& fromCS, KoColorConversionTransformation*& toCS) const; 0091 public: 0092 /** 0093 * This function return a text that can be compiled using dot to display 0094 * the graph of color conversion connection. 0095 */ 0096 QString toDot() const; 0097 /** 0098 * This function return a text that can be compiled using dot to display 0099 * the graph of color conversion connection, with a red link to show the 0100 * path of the best color conversion. 0101 */ 0102 QString bestPathToDot(const QString& srcKey, const QString& dstKey) const; 0103 public: 0104 /** 0105 * @return true if there is a path between two color spaces 0106 */ 0107 bool existsPath(const QString& srcModelId, const QString& srcDepthId, const QString& srcProfileName, const QString& dstModelId, const QString& dstDepthId, const QString& dstProfileName) const; 0108 /** 0109 * @return true if there is a good path between two color spaces 0110 */ 0111 bool existsGoodPath(const QString& srcModelId, const QString& srcDepthId, const QString& srcProfileName, const QString& dstModelId, const QString& dstDepthId, const QString& dstProfileName) const; 0112 private: 0113 QString vertexToDot(Vertex* v, const QString &options) const; 0114 private: 0115 /** 0116 * Insert an engine. 0117 */ 0118 Node* insertEngine(const KoColorSpaceEngine* engine); 0119 KoColorConversionTransformation* createTransformationFromPath(const KoColorConversionSystem::Path& path, const KoColorSpace* srcColorSpace, const KoColorSpace* dstColorSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) const; 0120 /** 0121 * Query the registry to get the color space associated with this 0122 * node. (default profile) 0123 */ 0124 const KoColorSpace* defaultColorSpaceForNode(const Node* node) const; 0125 /** 0126 * Create a new node 0127 */ 0128 Node* createNode(const QString& _modelId, const QString& _depthId, const QString& _profileName); 0129 /** 0130 * Initialise a node for ICC color spaces 0131 */ 0132 void connectToEngine(Node* _node, Node* _engine); 0133 const Node* nodeFor(const KoColorSpace*) const; 0134 /** 0135 * @return the node corresponding to that key, or create it if needed 0136 */ 0137 Node* nodeFor(const NodeKey& key); 0138 const Node* nodeFor(const NodeKey& key) const; 0139 /** 0140 * @return the list of nodes that correspond to a given model and depth. 0141 */ 0142 QList<Node*> nodesFor(const QString& _modelId, const QString& _depthId); 0143 /** 0144 * @return the node associated with that key, and create it if needed 0145 */ 0146 Node* nodeFor(const QString& colorModelId, const QString& colorDepthId, const QString& _profileName); 0147 const Node* nodeFor(const QString& colorModelId, const QString& colorDepthId, const QString& _profileName) const; 0148 /** 0149 * @return the vertex between two nodes, or null if the vertex doesn't exist 0150 */ 0151 Vertex* vertexBetween(Node* srcNode, Node* dstNode); 0152 /** 0153 * create a vertex between two nodes and return it. 0154 */ 0155 Vertex* createVertex(Node* srcNode, Node* dstNode); 0156 /** 0157 * looks for the best path between two nodes 0158 */ 0159 Path findBestPath(const Node* srcNode, const Node* dstNode) const; 0160 /** 0161 * Delete all the paths of the list given in argument. 0162 */ 0163 void deletePaths(QList<KoColorConversionSystem::Path*> paths) const; 0164 /** 0165 * Don't call that function, but raher findBestPath 0166 * @internal 0167 */ 0168 inline Path findBestPathImpl2(const Node* srcNode, const Node* dstNode, bool ignoreHdr, bool ignoreColorCorrectness) const; 0169 /** 0170 * Don't call that function, but raher findBestPath 0171 * @internal 0172 */ 0173 inline Path findBestPathImpl(const Node* srcNode, const Node* dstNode, bool ignoreHdr) const; 0174 0175 private: 0176 struct Private; 0177 Private* const d; 0178 }; 0179 0180 #endif