21#ifndef JKQTPGRAPHSCONTOUR_H
22#define JKQTPGRAPHSCONTOUR_H
30#include "jkqtplotter/graphs/jkqtpscatter.h"
31#include "jkqtplotter/jkqtptools.h"
32#include "jkqtplotter/jkqtpbaseelements.h"
33#include "jkqtplotter/graphs/jkqtpimage.h"
34#include "jkqtplotter/jkqtpgraphsbasestylingmixins.h"
35#include "jkqtplotter/jkqtplotter_imexport.h"
36#include "jkqtplotter/jkqtpimagetools.h"
113 template <
class TContainer>
114 void setContourLevels(
const TContainer &levels);
122 template <
class TContainer,
class TColorContainer>
123 void setContourLevels(
const TContainer &levels,
const TColorContainer& colors);
205 inline bool intersect(QLineF &line,
const QVector3D &vertex1,
const QVector3D &vertex2,
const QVector3D &vertex3,
double level)
const;
213 inline QPointF interpolatePoint(
const QVector3D &point1,
const QVector3D &point2,
double level)
const ;
220 inline int compare2level(
const QVector3D &vertex,
float level)
const ;
295template<
class TContainer,
class TColorContainer>
300 auto itc=colors.begin();
301 for (
auto it=levels.begin(); it!=levels.end(); ++it) {
313template<
class TContainer>
318 for (
auto it=levels.begin(); it!=levels.end(); ++it) {
350 static const int caseLUT[3][3][3] =
353 { { 0, 0, 8 }, { 0, 2, 5 }, { 7, 6, 9 } },
354 { { 0, 3, 4 }, { 1, 10, 1 }, { 4, 3, 0 } },
355 { { 9, 6, 7 }, { 5, 2, 0 }, { 8, 0, 0 } }
358 const int caseType = caseLUT[eq1+1][eq2+1][eq3+1];
363 line.setP1(vertex1.toPointF());
364 line.setP2(vertex2.toPointF());
368 line.setP1(vertex2.toPointF());
369 line.setP2(vertex3.toPointF());
373 line.setP1(vertex3.toPointF());
374 line.setP2(vertex1.toPointF());
378 line.setP1(vertex1.toPointF());
383 line.setP1(vertex2.toPointF());
388 line.setP1(vertex3.toPointF());
415 line.setP1(vertex3.toPointF());
416 line.setP2(vertex1.toPointF());
430 const double h1 = point1.z() - level;
431 const double h2 = point2.z() - level;
440 const double x = (h2 * point1.x() - h1 * point2.x()) / (h2 - h1);
441 const double y = (h2 * point1.y() - h1 * point2.y()) / (h2 - h1);
447 return QPointF(
x,
y);
452 if (vertex.z() > level) {
456 if (vertex.z() < level) {
base class for 2D plotter classes (used by the plotter widget JKQTPlotter)
Definition jkqtpbaseplotter.h:394
class for a contour plots (same as JKQTPContourPlot) of images stored in a JKQTPDatastore column
Definition jkqtpcontour.h:253
virtual bool usesColumn(int c) const override
returns true if the given column is used by the graph
virtual void ensureImageData() override
overwrite this to fill the data poiters before they are accessed (e.g. to load data from a column in ...
JKQTPColumnContourPlot(JKQTPlotter *parent)
class constructor
void setImageColumn(int __value)
column containing the displayed image
JKQTPColumnContourPlot(JKQTBasePlotter *parent=nullptr)
class constructor
int getImageColumn() const
column containing the displayed image
void setImageColumn(size_t __value)
column containing the displayed image
int imageColumn
column containing the displayed image
Definition jkqtpcontour.h:278
class for a contour plot
Definition jkqtpcontour.h:76
ContourColoringMode
options of how the colors for the contours are chosen (note that all images in the documentation show...
Definition jkqtpcontour.h:80
@ SingleColorContours
each contour line has the same color
Definition jkqtpcontour.h:81
@ ColorContoursFromPalette
the color for each contour line is chosen from the current color palette, distributing the contour li...
Definition jkqtpcontour.h:83
@ ColorContoursFromPaletteByValue
the color for each contour line is determined by the current color palette, image range and the value...
Definition jkqtpcontour.h:82
QVector< double > contourLevels
the list of contour levels
Definition jkqtpcontour.h:173
QList< QVector< QPolygonF > > contourLinesCache
For Caching: the contour lines as vector of single lines (one for each triangle). the list index refe...
Definition jkqtpcontour.h:233
ContourColoringMode contourColoringMode
defines how the colors for the contours are chosen
Definition jkqtpcontour.h:170
void clearContourLevel()
clear all currently defined contour levels
void setIgnoreOnPlane(bool __value)
if true, vertices that all lie on the contour plane will be ignored
void addContourLevel(double level, QColor overrideColor)
add another level for which to draw a contour and define an override color for this line
JKQTPContourPlot(JKQTPlotter *parent)
class constructor
QPointF interpolatePoint(const QVector3D &point1, const QVector3D &point2, double level) const
interpolatePoint linear interpolation of a line to the x-y plane using the z-value relative to level
Definition jkqtpcontour.h:428
ContourColoringMode getContourColoringMode() const
defines how the colors for the contours are chosen
void setContourColoringMode(ContourColoringMode __value)
defines how the colors for the contours are chosen
void clearCachedContours()
overrides the caching strategy and forces a recalculation of the contours
QColor getOverrideColor(int level) const
returns the override color for contour level level
JKQTPContourPlot(JKQTBasePlotter *parent=nullptr)
class constructor
void addContourLevel(double level)
add another level for which to draw a contour
void setRelativeLevels(bool __value)
indicates wether the contour levels are absolute values or relative to the maximum (max-min)
bool getIgnoreOnPlane() const
if true, vertices that all lie on the contour plane will be ignored
QMap< double, QColor > contourOverrideColor
override contour level colors for specific levels, when contourColoringMode==SingleColorContours
Definition jkqtpcontour.h:175
void createContourLevelsLog(int nLevels=3, int m=2)
creates at least nLevels contour levels with logarithmic spacing. FIXME: Has not been tested yet
int getNumberOfLevels() const
the list of contour levels
bool intersect(QLineF &line, const QVector3D &vertex1, const QVector3D &vertex2, const QVector3D &vertex3, double level) const
gives the intersection line of a plane defined by three vertices with a contour level in the x-y plan...
Definition jkqtpcontour.h:328
QVector< double > getContourLevels() const
the list of contour levels
virtual void draw(JKQTPEnhancedPainter &painter) override
plots the graph to the plotter object specified as parent
void setContourLevels(const TContainer &levels)
sets new contour levels from a container levels
Definition jkqtpcontour.h:314
bool hasOverrideColor(int level) const
returns the override color for contour level level
int compare2level(const QVector3D &vertex, float level) const
compare2level checks if the vertex lies above, under or on the contour plane level
Definition jkqtpcontour.h:451
int64_t contourLinesCachedForChecksum
if (>=0) checksum of the column for which contours were cached in contourLinesCache
Definition jkqtpcontour.h:238
void removeOverrideColor(int level)
removes the override color for contour level level
void setOverrideColor(double level, QColor overrideColor)
define an override color for the contour line at the given level
void calcContourLines(QList< QVector< QLineF > > &ContourLines)
calcContourLines calculates the contour lines using the CONREC algorithm
void createContourLevels(int nLevels=3)
creates at nLevels contour levels linearly spaced between the data's minimum and maximum values
bool getRelativeLevels() const
indicates wether the contour levels are absolute values or relative to the maximum (max-min)
bool relativeLevels
indicates wether the contour levels are absolute values or relative to the maximum (max-min)
Definition jkqtpcontour.h:177
bool ignoreOnPlane
if true, vertices that all lie on the contour plane will be ignored
Definition jkqtpcontour.h:168
this class extends the QPainter
Definition jkqtpenhancedpainter.h:33
This Mix-In class provides setter/getter methods, storage and other facilities for the graph line sty...
Definition jkqtpgraphsbasestylingmixins.h:49
double x
x coordinate of lower left corner
Definition jkqtpimage.h:104
double y
y coordinate of lower left corner
Definition jkqtpimage.h:106
virtual void setDatatypeModifier(JKQTPMathImageDataType __value)
datatype of the data array data
virtual const void * getDataModifier() const
points to the data array, holding the modifier image
virtual JKQTPMathImageDataType getDatatypeModifier() const
datatype of the data array data
virtual void setDataModifier(const void *__value)
points to the data array, holding the modifier image
QVector< double > getDataModifierAsDoubleVector() const
returns the contents of the internal modifier image as a QVector<double>
class to plot an image from an 2-dimensional array of values
Definition jkqtpimage.h:433
double getModifierValueAt(double x, double y)
return the value (raw data!) of the contained modifier image at the given coordinate
Definition jkqtpimage.h:677
double getModifierPixelValue(int xIdx, int yIdx) const
retrieve modifier image data at a given position as double
Definition jkqtpimage.h:700
int getModifierSampleSize() const
retrieve size of a single sample in the modifier image data (i.e. size of the datatype)
Definition jkqtpimage.h:732
virtual void getModifierMinMax(double &imin, double &imax) override
determine min/max data value of 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