JKQTPlotter trunk/v5.0.0
an extensive Qt5+Qt6 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
Loading...
Searching...
No Matches
jkqtpimagetools.h
1/*
2 Copyright (c) 2008-2024 Jan W. Krieger (<jan@jkrieger.de>)
3
4
5
6 This software is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License (LGPL) as published by
8 the Free Software Foundation, either version 2.1 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License (LGPL) for more details.
15
16 You should have received a copy of the GNU Lesser General Public License (LGPL)
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20
21#ifndef JKQTPIMAGETOOLS_H
22#define JKQTPIMAGETOOLS_H
23#include <QIcon>
24#include <QDebug>
25#include <QImage>
26#include <QStringList>
27#include "jkqtplotter/jkqtplotter_imexport.h"
28#include "jkqtcommon/jkqtpbasicimagetools.h"
29#include "jkqtplotter/jkqtplotter_configmacros.h"
30#include <cmath>
31#include <cfloat>
32#include <stdint.h>
33#include <QColor>
34#include "jkqtplotter/jkqtptools.h"
35
36class JKQTPVerticalIndependentAxis; // forward
37class JKQTPHorizontalIndependentAxis; // forward
38class JKQTBasePlotter; // forward
39
40
41/*! \brief if a class is derived from this class, it may use color bars
42 \ingroup jkqtplotter_imagelots_tools
43 */
45#ifndef JKQTPLOTTER_WORKAROUND_QGADGET_BUG
46 Q_GADGET
47#endif
48 public:
49
52
53 /** \brief get list with all available palettes */
54 static QStringList getPalettes() ;
55 /** \brief get list with all available palettes */
56 static int getPalettesCount() ;
57 /** \brief get QIcon representing the given palette */
58 static QIcon getPaletteIcon(int i) ;
59 /** \brief get QIcon representing the given palette */
61 /** \brief get QIcon representing the given palette */
62 static QImage getPaletteImage(int i, size_t width) ;
63 /** \brief get QIcon representing the given palette */
64 static QImage getPaletteImage(JKQTPMathImageColorPalette palette, size_t width) ;
65
66 /** \brief get QIcon representing the given palette */
67 static QIcon getPaletteKeyIcon(int i) ;
68 /** \brief get QIcon representing the given palette */
70 /** \brief get QIcon representing the given palette */
71 static QImage getPaletteKeyImage(int i, size_t width, size_t height) ;
72 /** \brief get QIcon representing the given palette */
73 static QImage getPaletteKeyImage(JKQTPMathImageColorPalette palette, size_t width, size_t height) ;
74
75
76
77
78 /*! \brief if the graph plots outside the actual plot field of view (e.g. color bars, scale bars, ...)
79
80 \note If you want to draw outside, then you'll also have to implement drawOutside()
81 */
82 virtual void cbGetOutsideSize(JKQTPEnhancedPainter& painter, int& leftSpace, int& rightSpace, int& topSpace, int& bottomSpace);
83
84 /*! \brief plots outside the actual plot field of view (e.g. color bars, scale bars, ...)
85
86 \note If you want to draw outside, then you'll also have to implement getOutsideSize(), so enough space is reserved
87
88 The four value supplied tell the method where to draw (inside one of the rectangles).
89 */
90 virtual void cbDrawOutside(JKQTPEnhancedPainter& painter, QRect leftSpace, QRect rightSpace, QRect topSpace, QRect bottomSpace);
91
92
93 /** \brief set the parent class for internal objects (e.g. color bars) */
94 virtual void cbSetParent(JKQTBasePlotter* parent);
95
96
97 /** \brief determine min/max data value of the image */
98 virtual void cbGetDataMinMax(double& imin, double& imax)=0;
99
100
101
102
103 /** \copydoc palette */
104 void setColorPalette(int pal);
105 /** \copydoc palette */
107 /** \copydoc palette */
109
110 /** \copydoc rangeMinFailAction */
112 /** \copydoc rangeMinFailAction */
114 /** \copydoc rangeMaxFailAction */
116 /** \copydoc rangeMaxFailAction */
118 /** \copydoc rangeMinFailColor */
119 void setRangeMinFailColor(const QColor & __value);
120 /** \copydoc rangeMinFailColor */
121 QColor getRangeMinFailColor() const;
122 /** \copydoc rangeMaxFailColor */
123 void setRangeMaxFailColor(const QColor & __value);
124 /** \copydoc rangeMaxFailColor */
125 QColor getRangeMaxFailColor() const;
126 /** \copydoc nanColor */
127 void setNanColor(const QColor & __value);
128 /** \copydoc nanColor */
129 QColor getNanColor() const;
130 /** \copydoc infColor */
131 void setInfColor(const QColor & __value);
132 /** \copydoc infColor */
133 QColor getInfColor() const;
134 /** \copydoc showColorBar */
135 void setShowColorBar(bool __value);
136 /** \copydoc showColorBar */
137 bool getShowColorBar() const;
138 /** \copydoc colorBarWidth */
139 void setColorBarWidth(int __value);
140 /** \copydoc colorBarWidth */
141 int getColorBarWidth() const;
142 /** \copydoc colorBarOffset */
143 void setColorBarOffset(int __value);
144 /** \copydoc colorBarOffset */
145 int getColorBarOffset() const;
146 /** \copydoc colorBarRelativeHeight */
147 void setColorBarRelativeHeight(double __value);
148 /** \copydoc colorBarRelativeHeight */
150 /** \copydoc imageMin */
151 void setImageMin(double __value);
152 /** \copydoc imageMin */
153 double getImageMin() const;
154 /** \copydoc imageMax */
155 void setImageMax(double __value);
156 /** \copydoc imageMax */
157 double getImageMax() const;
158 /** \copydoc autoImageRange */
159 void setAutoImageRange(bool __value);
160 /** \copydoc autoImageRange */
161 bool getAutoImageRange() const;
162 /** \copydoc imageName */
163 void setImageName(const QString & __value);
164 /** \copydoc imageName */
165 QString getImageName() const;
166 /** \copydoc imageNameFontName */
167 void setImageNameFontName(const QString & __value);
168 /** \copydoc imageNameFontName */
169 QString getImageNameFontName() const;
170 /** \copydoc imageNameFontSize */
171 void setImageNameFontSize(double __value);
172 /** \copydoc imageNameFontSize */
173 double getImageNameFontSize() const;
174 /** \copydoc colorBarRightAxis */
176 /** \copydoc colorBarTopAxis */
178 /** \copydoc colorBarRightAxis */
180 /** \copydoc colorBarTopAxis */
182 /** \copydoc colorBarTopVisible */
183 void setColorBarTopVisible(bool __value);
184 /** \copydoc colorBarTopVisible */
186 /** \copydoc colorBarRightVisible */
187 void setColorBarRightVisible(bool __value);
188 /** \copydoc colorBarRightVisible */
190
191
192 protected:
194
195
196 /** \brief top color bar visible */
198 /** \brief right color bar visible */
200 /** \brief name of the image displayed above color bar (may contain LaTeX markup!) */
201 QString imageName;
202 /** \brief font name when displaying imageName */
204 /** \brief font size in points when displaying imageName */
206 /** \brief palette for plotting an image */
208 /** \brief indicate whether to display a color bar */
210 /** \brief width of the color bar */
212 /** \brief height of the color bar, as multiple of plotHeight */
214 /** \brief indicates whether to estimate min/max of the image automatically */
216 /** \brief image value range minimum */
217 double imageMin;
218 /** \brief image value range maximum */
219 double imageMax;
220 /** \brief offset between outside space border and color bar */
222 /** \brief which action to take if a color is below \a imageMin and \a autoImageRange \c ==false */
224 /** \brief which action to take if a color is above \a imageMax and \a autoImageRange \c ==false */
226 /** \brief color to use for some settings of \a rangeMinFailAction */
228 /** \brief color to use for some settings of \a rangeMaxFailAction */
230 /** \brief color to use for a not-a-number value */
231 QColor nanColor;
232 /** \brief color to use for an infinity value */
233 QColor infColor;
234
235
236 /** \brief object used for color bar axes at the right
237 *
238 * \note this axis has some kind of a special role. It is used to format color bar axes
239 */
241 /** \brief object used for color bar axes at the top
242 *
243 * \note this axis has some kind of a special role. It is used to format color bar axes
244 */
246
247
248
249};
250
251
252
253/*! \brief if a class is derived from this class, it may use color bars that have 2 axes (one "data"/color axis and one "modifier" axis)
254 \ingroup jkqtplotter_imagelots_tools
255 */
257#ifndef JKQTPLOTTER_WORKAROUND_QGADGET_BUG
258 Q_GADGET
259#endif
260 public:
261
262
263
266
267 /*! \brief if the graph plots outside the actual plot field of view (e.g. color bars, scale bars, ...)
268
269 \note If you want to draw outside, then you'll also have to implement drawOutside()
270 */
271 virtual void cbGetOutsideSize(JKQTPEnhancedPainter& painter, int& leftSpace, int& rightSpace, int& topSpace, int& bottomSpace) override;
272
273 /*! \brief plots outside the actual plot field of view (e.g. color bars, scale bars, ...)
274
275 \note If you want to draw outside, then you'll also have to implement getOutsideSize(), so enough space is reserved
276
277 The four value supplied tell the method where to draw (inside one of the rectangles).
278 */
279 virtual void cbDrawOutside(JKQTPEnhancedPainter& painter, QRect leftSpace, QRect rightSpace, QRect topSpace, QRect bottomSpace) override;
280
281
282 /** \brief set the parent class for internal objects (e.g. color bars) */
283 virtual void cbSetParent(JKQTBasePlotter* parent) override;
284
285
286 /** \brief determine min/max data value of the modifier image */
287 virtual void cbGetModifierDataMinMax(double& imin, double& imax)=0;
288
289
290 /** \copydoc modifierMode */
292 /** \copydoc modifierMode */
294
295 /** \copydoc colorBarModifiedWidth */
296 void setColorBarModifiedWidth(double __value);
297 /** \copydoc colorBarModifiedWidth */
299 /** \copydoc modifierColorBarTopAxis */
301 /** \copydoc modifierColorBarRightAxis */
303 /** \copydoc modifierColorBarTopAxis */
305 /** \copydoc modifierColorBarRightAxis */
307 /** \copydoc autoModifierRange */
308 void setAutoModifierRange(bool __value);
309 /** \copydoc autoModifierRange */
311 /** \copydoc modifierMin */
312 void setModifierMin(double __value);
313 /** \copydoc modifierMin */
314 double getModifierMin() const;
315 /** \copydoc modifierMax */
316 void setModifierMax(double __value);
317 /** \copydoc modifierMax */
318 double getModifierMax() const;
319
320
321 /** \brief modify the given image \a img, using modifier image \a dataModifier (of type \a datatypeModifier and size \a Nx * \a Ny), using values in the range \a internalModifierMin ... \a internalModifierMax
322 */
323 void modifyImage(QImage& img, const void* dataModifier, JKQTPMathImageDataType datatypeModifier, int Nx, int Ny, double internalModifierMin, double internalModifierMax);
324
325 protected:
326
327 /** \brief indicates whether to estimate min/max of the modifier automatically */
329 /** \brief modifier value range minimum */
331 /** \brief modifier value range maximum */
333 /** \brief width of the color bar when modifier is on */
335 /** \brief how to apply the modifier column dataModifier
336 * \see ModifierMode
337 */
339
340
341 /** \brief object used for color bar axes (right border, modifier image data)
342 *
343 * \note this axis has some kind of a special role. It is used to format color bar axes
344 */
346 /** \brief object used for color bar axes (top border, modifier image data)
347 *
348 * \note this axis has some kind of a special role. It is used to format color bar axes
349 */
351};
352
353
354
355
356#endif // JKQTPIMAGETOOLS_H
base class for 2D plotter classes (used by the plotter widget JKQTPlotter)
Definition jkqtpbaseplotter.h:394
if a class is derived from this class, it may use color bars
Definition jkqtpimagetools.h:44
void setColorBarTopVisible(bool __value)
top color bar visible
JKQTPMathImageColorRangeFailAction rangeMinFailAction
which action to take if a color is below imageMin and autoImageRange ==false
Definition jkqtpimagetools.h:223
bool getShowColorBar() const
indicate whether to display a color bar
static QImage getPaletteKeyImage(JKQTPMathImageColorPalette palette, size_t width, size_t height)
get QIcon representing the given palette
JKQTBasePlotter * cbParent
Definition jkqtpimagetools.h:193
bool showColorBar
indicate whether to display a color bar
Definition jkqtpimagetools.h:209
void setRangeMaxFailColor(const QColor &__value)
color to use for some settings of rangeMaxFailAction
void setShowColorBar(bool __value)
indicate whether to display a color bar
void setInfColor(const QColor &__value)
color to use for an infinity value
JKQTPMathImageColorRangeFailAction getActionRangeMinFail() const
which action to take if a color is below imageMin and autoImageRange ==false
double imageMax
image value range maximum
Definition jkqtpimagetools.h:219
double imageNameFontSize
font size in points when displaying imageName
Definition jkqtpimagetools.h:205
void setImageName(const QString &__value)
name of the image displayed above color bar (may contain LaTeX markup!)
static int getPalettesCount()
get list with all available palettes
bool colorBarTopVisible
top color bar visible
Definition jkqtpimagetools.h:197
JKQTPVerticalIndependentAxis * colorBarRightAxis
object used for color bar axes at the right
Definition jkqtpimagetools.h:240
bool autoImageRange
indicates whether to estimate min/max of the image automatically
Definition jkqtpimagetools.h:215
QString getImageName() const
name of the image displayed above color bar (may contain LaTeX markup!)
QColor getInfColor() const
color to use for an infinity value
QColor getNanColor() const
color to use for a not-a-number value
double getColorBarRelativeHeight() const
height of the color bar, as multiple of plotHeight
static QIcon getPaletteKeyIcon(JKQTPMathImageColorPalette palette)
get QIcon representing the given palette
static QImage getPaletteImage(JKQTPMathImageColorPalette palette, size_t width)
get QIcon representing the given palette
JKQTPMathImageColorPalette getColorPalette() const
palette for plotting an image
int getColorBarWidth() const
width of the color bar
JKQTPMathImageColorRangeFailAction rangeMaxFailAction
which action to take if a color is above imageMax and autoImageRange ==false
Definition jkqtpimagetools.h:225
QColor getRangeMaxFailColor() const
color to use for some settings of rangeMaxFailAction
static QIcon getPaletteIcon(int i)
get QIcon representing the given palette
static QImage getPaletteImage(int i, size_t width)
get QIcon representing the given palette
virtual void cbDrawOutside(JKQTPEnhancedPainter &painter, QRect leftSpace, QRect rightSpace, QRect topSpace, QRect bottomSpace)
plots outside the actual plot field of view (e.g. color bars, scale bars, ...)
int colorBarOffset
offset between outside space border and color bar
Definition jkqtpimagetools.h:221
void setImageNameFontSize(double __value)
font size in points when displaying imageName
bool getColorBarTopVisible() const
top color bar visible
static QStringList getPalettes()
get list with all available palettes
JKQTPMathImageColorPalette palette
palette for plotting an image
Definition jkqtpimagetools.h:207
void setRangeMaxFailAction(const JKQTPMathImageColorRangeFailAction &__value)
which action to take if a color is above imageMax and autoImageRange ==false
QColor getRangeMinFailColor() const
color to use for some settings of rangeMinFailAction
void setImageMin(double __value)
image value range minimum
QString imageName
name of the image displayed above color bar (may contain LaTeX markup!)
Definition jkqtpimagetools.h:201
bool getColorBarRightVisible() const
right color bar visible
const JKQTPHorizontalIndependentAxis * getColorBarTopAxis() const
object used for color bar axes at the top
JKQTPColorPaletteStyleAndToolsMixin(JKQTBasePlotter *parent)
JKQTPHorizontalIndependentAxis * colorBarTopAxis
object used for color bar axes at the top
Definition jkqtpimagetools.h:245
JKQTPVerticalIndependentAxis * getColorBarRightAxis()
object used for color bar axes at the right
JKQTPHorizontalIndependentAxis * getColorBarTopAxis()
object used for color bar axes at the top
double getImageMax() const
image value range maximum
void setRangeMinFailAction(const JKQTPMathImageColorRangeFailAction &__value)
which action to take if a color is below imageMin and autoImageRange ==false
int colorBarWidth
width of the color bar
Definition jkqtpimagetools.h:211
void setNanColor(const QColor &__value)
color to use for a not-a-number value
JKQTPMathImageColorRangeFailAction getActionRangeMaxFail() const
which action to take if a color is above imageMax and autoImageRange ==false
double imageMin
image value range minimum
Definition jkqtpimagetools.h:217
static QIcon getPaletteKeyIcon(int i)
get QIcon representing the given palette
virtual void cbGetDataMinMax(double &imin, double &imax)=0
determine min/max data value of the image
QColor rangeMaxFailColor
color to use for some settings of rangeMaxFailAction
Definition jkqtpimagetools.h:229
virtual void cbGetOutsideSize(JKQTPEnhancedPainter &painter, int &leftSpace, int &rightSpace, int &topSpace, int &bottomSpace)
if the graph plots outside the actual plot field of view (e.g. color bars, scale bars,...
double getImageNameFontSize() const
font size in points when displaying imageName
void setImageNameFontName(const QString &__value)
font name when displaying imageName
void setColorBarOffset(int __value)
offset between outside space border and color bar
void setImageMax(double __value)
image value range maximum
QString imageNameFontName
font name when displaying imageName
Definition jkqtpimagetools.h:203
int getColorBarOffset() const
offset between outside space border and color bar
bool colorBarRightVisible
right color bar visible
Definition jkqtpimagetools.h:199
static QImage getPaletteKeyImage(int i, size_t width, size_t height)
get QIcon representing the given palette
void setColorBarRelativeHeight(double __value)
height of the color bar, as multiple of plotHeight
virtual void cbSetParent(JKQTBasePlotter *parent)
set the parent class for internal objects (e.g. color bars)
QColor infColor
color to use for an infinity value
Definition jkqtpimagetools.h:233
void setColorPalette(const JKQTPMathImageColorPalette &__value)
palette for plotting an image
const JKQTPVerticalIndependentAxis * getColorBarRightAxis() const
object used for color bar axes at the right
QColor nanColor
color to use for a not-a-number value
Definition jkqtpimagetools.h:231
QColor rangeMinFailColor
color to use for some settings of rangeMinFailAction
Definition jkqtpimagetools.h:227
QString getImageNameFontName() const
font name when displaying imageName
static QIcon getPaletteIcon(JKQTPMathImageColorPalette palette)
get QIcon representing the given palette
void setRangeMinFailColor(const QColor &__value)
color to use for some settings of rangeMinFailAction
void setColorPalette(int pal)
palette for plotting an image
double getImageMin() const
image value range minimum
void setAutoImageRange(bool __value)
indicates whether to estimate min/max of the image automatically
void setColorBarWidth(int __value)
width of the color bar
void setColorBarRightVisible(bool __value)
right color bar visible
double colorBarRelativeHeight
height of the color bar, as multiple of plotHeight
Definition jkqtpimagetools.h:213
bool getAutoImageRange() const
indicates whether to estimate min/max of the image automatically
if a class is derived from this class, it may use color bars that have 2 axes (one "data"/color axis ...
Definition jkqtpimagetools.h:256
void setModifierMode(const JKQTPMathImageModifierMode &__value)
how to apply the modifier column dataModifier
JKQTPMathImageModifierMode modifierMode
how to apply the modifier column dataModifier
Definition jkqtpimagetools.h:338
double getColorBarModifiedWidth() const
width of the color bar when modifier is on
virtual void cbGetModifierDataMinMax(double &imin, double &imax)=0
determine min/max data value of the modifier image
void setModifierMin(double __value)
modifier value range minimum
void setColorBarModifiedWidth(double __value)
width of the color bar when modifier is on
double colorBarModifiedWidth
width of the color bar when modifier is on
Definition jkqtpimagetools.h:334
JKQTPVerticalIndependentAxis * getModifierColorBarTopAxis()
object used for color bar axes (right border, modifier image data)
JKQTPHorizontalIndependentAxis * modifierColorBarRightAxis
object used for color bar axes (top border, modifier image data)
Definition jkqtpimagetools.h:350
JKQTPHorizontalIndependentAxis * getModifierColorBarRightAxis()
object used for color bar axes (top border, modifier image data)
const JKQTPHorizontalIndependentAxis * getModifierColorBarRightAxis() const
object used for color bar axes (top border, modifier image data)
double getModifierMin() const
modifier value range minimum
JKQTPMathImageModifierMode getModifierMode() const
how to apply the modifier column dataModifier
double modifierMin
modifier value range minimum
Definition jkqtpimagetools.h:330
virtual void cbSetParent(JKQTBasePlotter *parent) override
set the parent class for internal objects (e.g. color bars)
JKQTPVerticalIndependentAxis * modifierColorBarTopAxis
object used for color bar axes (right border, modifier image data)
Definition jkqtpimagetools.h:345
JKQTPColorPaletteWithModifierStyleAndToolsMixin(JKQTBasePlotter *parent)
virtual void cbDrawOutside(JKQTPEnhancedPainter &painter, QRect leftSpace, QRect rightSpace, QRect topSpace, QRect bottomSpace) override
plots outside the actual plot field of view (e.g. color bars, scale bars, ...)
double modifierMax
modifier value range maximum
Definition jkqtpimagetools.h:332
virtual void cbGetOutsideSize(JKQTPEnhancedPainter &painter, int &leftSpace, int &rightSpace, int &topSpace, int &bottomSpace) override
if the graph plots outside the actual plot field of view (e.g. color bars, scale bars,...
virtual ~JKQTPColorPaletteWithModifierStyleAndToolsMixin()=default
bool autoModifierRange
indicates whether to estimate min/max of the modifier automatically
Definition jkqtpimagetools.h:328
bool getAutoModifierRange() const
indicates whether to estimate min/max of the modifier automatically
void setAutoModifierRange(bool __value)
indicates whether to estimate min/max of the modifier automatically
const JKQTPVerticalIndependentAxis * getModifierColorBarTopAxis() const
object used for color bar axes (right border, modifier image data)
void modifyImage(QImage &img, const void *dataModifier, JKQTPMathImageDataType datatypeModifier, int Nx, int Ny, double internalModifierMin, double internalModifierMax)
modify the given image img, using modifier image dataModifier (of type datatypeModifier and size Nx *...
void setModifierMax(double __value)
modifier value range maximum
double getModifierMax() const
modifier value range maximum
this class extends the QPainter
Definition jkqtpenhancedpainter.h:33
implements a position-indipendent horizontal axis, based on JKQTPCoordinateAxis (for most of document...
Definition jkqtpcoordinateaxes.h:1240
implements a position-indipendent vertical axis, based on JKQTPCoordinateAxis (for most of documentat...
Definition jkqtpcoordinateaxes.h:1053
JKQTPMathImageDataType
possible datatypes of the data array, plotted by this class.
Definition jkqtpbasicimagetools.h:41
JKQTPMathImageColorPalette
available palettes for coloring an image
Definition jkqtpbasicimagetools.h:84
JKQTPMathImageModifierMode
describes how to modify a rendered image with a second data array
Definition jkqtpbasicimagetools.h:1445
JKQTPMathImageColorRangeFailAction
modes available for image pixels that are above/below the pixel value range
Definition jkqtpbasicimagetools.h:363
#define JKQTPLOTTER_LIB_EXPORT
Definition jkqtplotter_imexport.h:89