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
jkqtpimageoverlays.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 JKQTPGRAPHSIMAGEOVERLAYS_H
22#define JKQTPGRAPHSIMAGEOVERLAYS_H
23
24
25#include <QString>
26#include <QPainter>
27#include <QImage>
28#include <QIcon>
29#include "jkqtplotter/graphs/jkqtpscatter.h"
30#include "jkqtplotter/jkqtptools.h"
31#include "jkqtplotter/jkqtpbaseelements.h"
32#include "jkqtplotter/graphs/jkqtpimage.h"
33#include "jkqtplotter/jkqtplotter_imexport.h"
34#include "jkqtplotter/jkqtpimagetools.h"
35
36
37
38/*! \brief class to plot an image from an 2-dimensional array of boolean values: alle \c true values are plotted in a given color, while the \c false pixels are drawn in another (default: transparent)
39 \ingroup jkqtplotter_imagelots_overlays
40
41 \image html overlayimage.png
42
43 */
45 Q_OBJECT
46 public:
47
48 /** \brief class constructor */
49 JKQTPOverlayImage(double x, double y, double width, double height, const bool* data, int Nx, int Ny, QColor colTrue, JKQTBasePlotter* parent=nullptr);
51
52 /** \brief class constructor */
53 JKQTPOverlayImage(double x, double y, double width, double height, const bool* data, int Nx, int Ny, QColor colTrue, JKQTPlotter* parent);
55
56 /** \brief plots the graph to the plotter object specified as parent */
57 virtual void draw(JKQTPEnhancedPainter& painter) override;
58
59 /** \brief return the plotted image only as a QImage */
60 virtual QImage drawImage();
61
62 /** \brief plots a key marker inside the specified rectangle \a rect */
63 virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, const QRectF& rect) override;
64 /** \brief returns the color to be used for the key label */
65 virtual QColor getKeyLabelColor() const override;
66
67 /** \copydoc trueColor */
68 void setTrueColor(const QColor & __value);
69 /** \copydoc trueColor */
70 QColor getTrueColor() const;
71 /** \copydoc falseColor */
72 void setFalseColor(const QColor & __value);
73 /** \copydoc falseColor */
74 QColor getFalseColor() const;
75 /** \copydoc Nx */
76 void setNx(int __value);
77 /** \copydoc Nx */
78 void setNx(size_t __value);
79 /** \copydoc Nx */
80 int getNx() const;
81 /** \copydoc Ny */
82 void setNy(int __value);
83 /** \copydoc Ny */
84 void setNy(size_t __value);
85 /** \copydoc Ny */
86 int getNy() const;
87 /** \copydoc data */
88 virtual void setData(const bool* __value);
89 /** \copydoc data */
90 const bool *getData() const;
91
92 /** \brief set the plot-data to a given array \a data with size \a Nx * \a Ny in row-major ordering */
93 virtual void setData(const bool* data, int Nx, int Ny);
94
95 /** \brief return the data used for plotting as a QVector<double> in row-major data-ordering */
96 QVector<double> getDataAsDoubleVector() const;
97
98 protected:
99 /** \brief points to the data array, holding the image */
100 const bool* data;
101 /** \brief width of the data array data in pt */
102 int Nx;
103 /** \brief height of the data array data in pt */
104 int Ny;
105
106 /** \brief color for \c true pixels */
107 QColor trueColor;
108 /** \brief color for \c false pixels */
110
111 protected:
112 /** \brief action that calls saveImagePlotAsImage() */
113 QAction* actSaveImage;
114 /** \brief action that calls copyImagePlotAsImage() */
115 QAction* actCopyImage;
116 public:
117 /** \copydoc JKQTPImageBase::setTitle() */
118 virtual void setTitle(const QString& title) override;
119 /** \copydoc JKQTPImageBase::setParent() */
120 virtual void setParent(JKQTBasePlotter* parent) override;
121 public Q_SLOTS:
122 /** \brief save the plotted image as a file with \a filename and format \a outputFormat */
123 void saveImagePlotAsImage(const QString &filename=QString(""), const QByteArray &outputFormat=QByteArray());
124 /** \brief copy the plotted image as an image into the clipboard */
126
127};
128
129
130
131/*! \brief class to plot an image from an 2-dimensional array of boolean values: alle \c true values are plotted in a given color, while the \c false pixels are drawn in another (default: transparent)
132 \ingroup jkqtplotter_imagelots_overlays
133
134 In contrast to JKQTPOverlayImage this class draws ist contents as rectangles, not as semi-transparent image. This may lead to nicer results,but could be slower.
135 Also it is possible to draw other types of markers (cross, circles, ...)
136
137 \image html overlayimageenhanced.png
138 */
140 Q_OBJECT
141 public:
147
148 /** \brief class constructor */
149 JKQTPOverlayImageEnhanced(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTBasePlotter* parent=nullptr);
151 /** \brief class constructor */
152 JKQTPOverlayImageEnhanced(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTPlotter* parent);
154
155 /** \brief plots the graph to the plotter object specified as parent */
156 virtual void draw(JKQTPEnhancedPainter& painter) override;
157 /** \brief plots a key marker inside the specified rectangle \a rect */
158 virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, const QRectF& rect) override;
159
160 /** \copydoc symbol */
162 /** \copydoc symbol */
164 /** \copydoc symbolLineWidth */
165 void setSymbolLineWidth(double __value);
166 /** \copydoc symbolLineWidth */
167 double getSymbolLineWidth() const;
168 /** \copydoc drawMode */
170 /** \copydoc drawMode */
172 /** \copydoc symbolSizeFactor */
173 void setSymbolSizeFactor(double __value);
174 /** \copydoc symbolSizeFactor */
175 double getSymbolSizeFactor() const;
176 /** \brief set the font to be used for character symbols \c JKQTPCharacterSymbol+QChar('').unicode() */
177 void setSymbolFontName(const QString& __value);
178 /** \brief get the font to be used for character symbols \c JKQTPCharacterSymbol+QChar('').unicode() */
179 QString getSymbolFontName() const;
180
181 protected:
182 /** \brief which symbol to use for the datapoints */
184 /** \brief width (in pt) of the lines used to plot the symbol for the data points */
186
187 /** \brief indicates whether to draw filled rectangles, or symbols */
189
190 /** \brief a rescaling factor for the symbols */
192 /** \brief font to be used for character symbols \c JKQTPCharacterSymbol+QChar('').unicode() */
194
195
196};
197
198
199
200
201/*! \brief class to plot an image from an 2-dimensional array of boolean values: alle \c true values are plotted in a given color, while the \c false pixels are drawn in another (default: transparent)
202 \ingroup jkqtplotter_imagelots_overlays
203
204 In contrast to JKQTPOverlayImage this class draws ist contents as rectangles, not as semi-transparent image. This may lead to nicer results,but could be slower.
205 Also it is possible to draw other types of markers (cross, circles, ...)
206
207 \image html overlayimageenhanced.png
208
209 */
211 Q_OBJECT
212 public:
215
216 /** \copydoc imageColumn */
217 virtual void setImageColumn(int __value);
218 /** \copydoc imageColumn */
219 int getImageColumn() const;
220 /** \brief plots the graph to the plotter object specified as parent */
221 virtual void draw(JKQTPEnhancedPainter& painter) override;
222
223 /** \copydoc JKQTPGraph::usesColumn() */
224 virtual bool usesColumn(int c) const override;
225
226
227 protected:
228 /** \brief column to read overlay image from */
230};
231
232
233#endif // JKQTPGRAPHSIMAGEOVERLAYS_H
234
base class for 2D plotter classes (used by the plotter widget JKQTPlotter)
Definition jkqtpbaseplotter.h:394
class to plot an image from an 2-dimensional array of boolean values: alle true values are plotted in...
Definition jkqtpimageoverlays.h:210
virtual void draw(JKQTPEnhancedPainter &painter) override
plots the graph to the plotter object specified as parent
int getImageColumn() const
column to read overlay image from
virtual void setImageColumn(int __value)
column to read overlay image from
JKQTPColumnOverlayImageEnhanced(JKQTPlotter *parent)
virtual bool usesColumn(int c) const override
returns true if the given column is used by the graph
JKQTPColumnOverlayImageEnhanced(JKQTBasePlotter *parent=nullptr)
int imageColumn
column to read overlay image from
Definition jkqtpimageoverlays.h:229
this class extends the QPainter
Definition jkqtpenhancedpainter.h:33
base class for plotting an image
Definition jkqtpimage.h:40
class to plot an image from an 2-dimensional array of boolean values: alle true values are plotted in...
Definition jkqtpimageoverlays.h:139
void setDrawMode(OverlayImageEnhancedDrawMode __value)
indicates whether to draw filled rectangles, or symbols
OverlayImageEnhancedDrawMode
Definition jkqtpimageoverlays.h:142
@ DrawAsImage
Definition jkqtpimageoverlays.h:144
@ DrawAsRectangles
Definition jkqtpimageoverlays.h:143
void setSymbolLineWidth(double __value)
width (in pt) of the lines used to plot the symbol for the data points
double getSymbolLineWidth() const
width (in pt) of the lines used to plot the symbol for the data points
double symbolSizeFactor
a rescaling factor for the symbols
Definition jkqtpimageoverlays.h:191
double getSymbolSizeFactor() const
a rescaling factor for the symbols
double symbolLineWidth
width (in pt) of the lines used to plot the symbol for the data points
Definition jkqtpimageoverlays.h:185
JKQTPGraphSymbols symbol
which symbol to use for the datapoints
Definition jkqtpimageoverlays.h:183
JKQTPOverlayImageEnhanced(JKQTBasePlotter *parent=nullptr)
JKQTPOverlayImageEnhanced(JKQTPlotter *parent)
QString getSymbolFontName() const
get the font to be used for character symbols JKQTPCharacterSymbol+QChar('').unicode()
JKQTPGraphSymbols getSymbol() const
which symbol to use for the datapoints
virtual void drawKeyMarker(JKQTPEnhancedPainter &painter, const QRectF &rect) override
plots a key marker inside the specified rectangle rect
void setSymbolSizeFactor(double __value)
a rescaling factor for the symbols
JKQTPOverlayImageEnhanced(double x, double y, double width, double height, bool *data, int Nx, int Ny, QColor colTrue, JKQTPlotter *parent)
class constructor
void setSymbolFontName(const QString &__value)
set the font to be used for character symbols JKQTPCharacterSymbol+QChar('').unicode()
QString m_symbolFontName
font to be used for character symbols JKQTPCharacterSymbol+QChar('').unicode()
Definition jkqtpimageoverlays.h:193
JKQTPOverlayImageEnhanced(double x, double y, double width, double height, bool *data, int Nx, int Ny, QColor colTrue, JKQTBasePlotter *parent=nullptr)
class constructor
void setSymbolType(JKQTPGraphSymbols __value)
which symbol to use for the datapoints
OverlayImageEnhancedDrawMode drawMode
indicates whether to draw filled rectangles, or symbols
Definition jkqtpimageoverlays.h:188
virtual void draw(JKQTPEnhancedPainter &painter) override
plots the graph to the plotter object specified as parent
OverlayImageEnhancedDrawMode getDrawMode() const
indicates whether to draw filled rectangles, or symbols
class to plot an image from an 2-dimensional array of boolean values: alle true values are plotted in...
Definition jkqtpimageoverlays.h:44
JKQTPOverlayImage(double x, double y, double width, double height, const bool *data, int Nx, int Ny, QColor colTrue, JKQTPlotter *parent)
class constructor
void setFalseColor(const QColor &__value)
color for false pixels
const bool * getData() const
points to the data array, holding the image
void saveImagePlotAsImage(const QString &filename=QString(""), const QByteArray &outputFormat=QByteArray())
save the plotted image as a file with filename and format outputFormat
JKQTPOverlayImage(JKQTPlotter *parent)
void setTrueColor(const QColor &__value)
color for true pixels
JKQTPOverlayImage(double x, double y, double width, double height, const bool *data, int Nx, int Ny, QColor colTrue, JKQTBasePlotter *parent=nullptr)
class constructor
const bool * data
points to the data array, holding the image
Definition jkqtpimageoverlays.h:100
virtual void setParent(JKQTBasePlotter *parent) override
sets the parent painter class
int getNx() const
width of the data array data in pt
QAction * actSaveImage
action that calls saveImagePlotAsImage()
Definition jkqtpimageoverlays.h:113
virtual void setData(const bool *data, int Nx, int Ny)
set the plot-data to a given array data with size Nx * Ny in row-major ordering
QColor getFalseColor() const
color for false pixels
QColor getTrueColor() const
color for true pixels
void setNy(int __value)
height of the data array data in pt
void copyImagePlotAsImage()
copy the plotted image as an image into the clipboard
QVector< double > getDataAsDoubleVector() const
return the data used for plotting as a QVector<double> in row-major data-ordering
QAction * actCopyImage
action that calls copyImagePlotAsImage()
Definition jkqtpimageoverlays.h:115
virtual void draw(JKQTPEnhancedPainter &painter) override
plots the graph to the plotter object specified as parent
virtual QImage drawImage()
return the plotted image only as a QImage
void setNx(size_t __value)
width of the data array data in pt
int Nx
width of the data array data in pt
Definition jkqtpimageoverlays.h:102
void setNy(size_t __value)
height of the data array data in pt
QColor falseColor
color for false pixels
Definition jkqtpimageoverlays.h:109
int getNy() const
height of the data array data in pt
int Ny
height of the data array data in pt
Definition jkqtpimageoverlays.h:104
JKQTPOverlayImage(JKQTBasePlotter *parent=nullptr)
void setNx(int __value)
width of the data array data in pt
virtual void setTitle(const QString &title) override
sets the title of the plot (for display in key!).
QColor trueColor
color for true pixels
Definition jkqtpimageoverlays.h:107
virtual void drawKeyMarker(JKQTPEnhancedPainter &painter, const QRectF &rect) override
plots a key marker inside the specified rectangle rect
virtual QColor getKeyLabelColor() const override
returns the color to be used for the key label
virtual void setData(const bool *__value)
points to the data array, holding the image
plotter widget for scientific plots (uses JKQTBasePlotter to do the actual drawing)
Definition jkqtplotter.h:364
#define JKQTPLOTTER_LIB_EXPORT
Definition jkqtplotter_imexport.h:89
JKQTPGraphSymbols
symbols that can be used to plot a datapoint for a graph
Definition jkqtpdrawingtools.h:143