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

tool structure that summarizes several static properties of JKQTPlotters palette system, also provides functions to work with palettes and register user-defined palettes. More...

#include <jkqtpbasicimagetools.h>

Classes

struct  LUTData
 internal datatype, representing a lookup-table and its metadata inside global_jkqtpimagetools_lutstore More...
 

Public Types

typedef QVector< QRgb > LUTType
 Datatype to store lookup-tables used to map data values (scales to 0..size-1) onto RGB-colors.
 

Static Public Member Functions

template<class T >
static void array2image (const T *dbl_in, int width, int height, QImage &img, const LUTType &lutUser, double minColor, double maxColor, JKQTPMathImageColorRangeFailAction paletteMinFail=JKQTPMathImageLastPaletteColor, JKQTPMathImageColorRangeFailAction paletteMaxFail=JKQTPMathImageLastPaletteColor, QColor minFailColor=QColor("black"), QColor maxFailColor=QColor("black"), QColor nanColor=QColor("black"), QColor infColor=QColor("black"), bool logScale=false, double logBase=10.0)
 convert a 2D image (as 1D array) into a QImage with given palette (see JKQTFPColorPalette)
 
template<class T >
static void array2image (const T *dbl_in, int width, int height, QImage &img, JKQTPMathImageColorPalette palette, double minColor, double maxColor, JKQTPMathImageColorRangeFailAction paletteMinFail=JKQTPMathImageLastPaletteColor, JKQTPMathImageColorRangeFailAction paletteMaxFail=JKQTPMathImageLastPaletteColor, QColor minFailColor=QColor("black"), QColor maxFailColor=QColor("black"), QColor nanColor=QColor("black"), QColor infColor=QColor("black"), bool logScale=false, double logBase=10.0, const LUTType &lutUser=LUTType())
 convert a 2D image (as 1D array) into a QImage with given palette (see JKQTFPColorPalette)
 
static JKQTCOMMON_LIB_EXPORT QVector< QColor > getColorsforPalette (JKQTPMathImageColorPalette palette)
 return the list of QColors making up a JKQTPMathImageColorPalette, stored it in lutstore and return it
 
static JKQTCOMMON_LIB_EXPORT const LUTTypegetLUTforPalette (JKQTPMathImageColorPalette palette)
 create a LUT for a given JKQTPMathImageColorPalette, stored it in lutstore and return it
 
static JKQTCOMMON_LIB_EXPORT QIcon GetPaletteIcon (int i)
 generates a QIcon for the i-th color palette (i is based on the list returned by JKQTPImagePlot_getPredefinedPalettes() )

 
static JKQTCOMMON_LIB_EXPORT QIcon GetPaletteIcon (JKQTPMathImageColorPalette palette)
 generates a QIcon for a specific JKQTPMathImageColorPalette

 
static JKQTCOMMON_LIB_EXPORT QImage GetPaletteImage (const LUTType &lut, int width)
 generates a QImage with width width and height 1 for a lookup-table lut

 
static JKQTCOMMON_LIB_EXPORT QImage GetPaletteImage (int i, int width)
 generates a QImage with width width and height 1 for the i-th color palette (i is based on the list returned by JKQTPImagePlot_getPredefinedPalettes() )

 
static JKQTCOMMON_LIB_EXPORT QImage GetPaletteImage (int i, int width, int height)
 generates a QImage with width width and height height for the i-th color palette (i is based on the list returned by JKQTPImagePlot_getPredefinedPalettes() )

 
static JKQTCOMMON_LIB_EXPORT QImage GetPaletteImage (JKQTPMathImageColorPalette palette, int width)
 generates a QImage with width width and height 1 for a specific JKQTPMathImageColorPalette

 
static JKQTCOMMON_LIB_EXPORT QImage GetPaletteImage (JKQTPMathImageColorPalette palette, int width, int height)
 generates a QImage with width width and height height for a specific JKQTPMathImageColorPalette

 
static QStringList JKQTCOMMON_LIB_EXPORT getPredefinedPalettes ()
 return a list of all globally available LUTs, human-readable/localized form

 
static QStringList JKQTCOMMON_LIB_EXPORT getPredefinedPalettesMachineReadable ()
 return a list of all globally available LUTs, machine-readable form

 
static JKQTCOMMON_LIB_EXPORT QString JKQTPMathImageColorPalette2String (JKQTPMathImageColorPalette p)
 convert the palette p to a machine-readable string
 
static JKQTCOMMON_LIB_EXPORT QString JKQTPMathImageColorPalette2StringHumanReadable (JKQTPMathImageColorPalette p)
 convert the palette p to a human-readable (localized) string
 
static JKQTCOMMON_LIB_EXPORT int registerPalette (const QString &name, const LUTType &paletteLut, const QString &nameT=QString())
 registers a new LUT defined by paletteLut and with the given name (computer-readable) for later use, optionally stores also the human-readable and localized name nameT and assigns a new LUT-ID >=JKQTPMathImageFIRST_REGISTERED_USER_PALETTE to the palette and returns it
 
static JKQTCOMMON_LIB_EXPORT QVector< int > registerPalettesFromFile (const QString &filename, bool interpolatePalette=false)
 loads all palettes defined in the given palette files filename into global_jkqtpimagetools_userluts and assigns a new LUT-ID >=JKQTPMathImageFIRST_REGISTERED_USER_PALETTE to each palette All new IDs are returned as a list
 
static JKQTCOMMON_LIB_EXPORT JKQTPMathImageColorPalette String2JKQTPMathImageColorPalette (const QString &p)
 convert the palette name p to JKQTPMathImageColorPalette (compatible with JKQTPImageTools::String2JKQTPMathImageColorPalette() )
 

Static Public Attributes

static JKQTCOMMON_LIB_EXPORT const int LUTSIZE
 size of the lookup tables used by JKQTFPimagePlot_array2image()
 
static JKQTCOMMON_LIB_EXPORT const int NDEFAULTSTEPS
 number of entries in an auto-generated steps-palette
 
static JKQTCOMMON_LIB_EXPORT const int PALETTE_ICON_WIDTH
 Width of the Palette-Icons, generated e.g. by JKQTPImageTools::GetPaletteIcon()
 
static JKQTCOMMON_LIB_EXPORT const int PALETTE_IMAGEICON_HEIGHT
 Height of the Palette-Icons, generated e.g. by JKQTPImageTools::GetPaletteIcon()
 

Static Private Member Functions

static JKQTCOMMON_LIB_EXPORT QMap< int, LUTDatagetDefaultLUTs ()
 returns data of the default LUTs, used to initialize global_jkqtpimagetools_lutstore
 
static JKQTCOMMON_LIB_EXPORT const LUTTypegetLUTforPalette (const QMap< int, LUTData > &lutcache, JKQTPMathImageColorPalette palette)
 create a LUT for a given JKQTPMathImageColorPalette, store it in lutstore and return it
 

Static Private Attributes

static JKQTCOMMON_LIB_EXPORT QStringList getPredefinedPalettesGlobalList
 storage for the palette names in getPredefinedPalettes()
 
static JKQTCOMMON_LIB_EXPORT QStringList getPredefinedPalettesMachineReadableGlobalList
 storage for the palette names in etPredefinedPalettesMachineReadable()
 
static JKQTCOMMON_LIB_EXPORT QMap< int, LUTDataglobal_jkqtpimagetools_lutstore
 internal global storage object for lookup-tables
 
static JKQTCOMMON_LIB_EXPORT int global_next_userpalette
 storage for the next ID to assign to a user-defined palette, registered with registerPalette() or registerPalettesFromFile()
 
static JKQTCOMMON_LIB_EXPORT QReadWriteLock lutMutex
 Mutex to protect global_jkqtpimagetools_lutstore, getPredefinedPalettesGlobalList, getPredefinedPalettesMachineReadableGlobalList and global_next_userpalette.
 

Detailed Description

tool structure that summarizes several static properties of JKQTPlotters palette system, also provides functions to work with palettes and register user-defined palettes.

See also
Example (JKQTPlotter): Simple math image plot

Member Typedef Documentation

◆ LUTType

typedef QVector<QRgb> JKQTPImageTools::LUTType

Datatype to store lookup-tables used to map data values (scales to 0..size-1) onto RGB-colors.

Member Function Documentation

◆ array2image() [1/2]

template<class T >
static void JKQTPImageTools::array2image ( const T *  dbl_in,
int  width,
int  height,
QImage &  img,
const LUTType lutUser,
double  minColor,
double  maxColor,
JKQTPMathImageColorRangeFailAction  paletteMinFail = JKQTPMathImageLastPaletteColor,
JKQTPMathImageColorRangeFailAction  paletteMaxFail = JKQTPMathImageLastPaletteColor,
QColor  minFailColor = QColor("black"),
QColor  maxFailColor = QColor("black"),
QColor  nanColor = QColor("black"),
QColor  infColor = QColor("black"),
bool  logScale = false,
double  logBase = 10.0 
)
inlinestatic

convert a 2D image (as 1D array) into a QImage with given palette (see JKQTFPColorPalette)

Parameters
dbl_inpointer to a 1D array of template type T representing the image to plot. This array has to be of size width * height
widthwidth of the array in dbl
heightheight of the array in dbl
[out]imgthe QImage object to draw to (should be initialized as QImage::Format_ARGB32 )
lutUseruser-defined lookup-table
minColorlower boundary of color range in dbl pixels, if minColor == maxColor then this function will extract the image min and image max.
maxColorupper boundary of color range in dbl pixels, if minColor == maxColor then this function will extract the image min and image max.
paletteMinFailspecifies what shell happen, when a value in dbl is below minColor
paletteMaxFailspecifies what shell happen, when a value in dbl is above maxColor
minFailColorcolor to use for pixels that are below minColor for some settings of paletteMinFail
maxFailColorcolor to use for pixels that are below maxColor for some settings of paletteMaxFail
nanColorcolor to use for pixels that are not-a-number
infColorcolor to use for pixels that are infinity
logScalecreate a log-scaled image
logBasebase for the logarithm used when logScale==true

◆ array2image() [2/2]

template<class T >
static void JKQTPImageTools::array2image ( const T *  dbl_in,
int  width,
int  height,
QImage &  img,
JKQTPMathImageColorPalette  palette,
double  minColor,
double  maxColor,
JKQTPMathImageColorRangeFailAction  paletteMinFail = JKQTPMathImageLastPaletteColor,
JKQTPMathImageColorRangeFailAction  paletteMaxFail = JKQTPMathImageLastPaletteColor,
QColor  minFailColor = QColor("black"),
QColor  maxFailColor = QColor("black"),
QColor  nanColor = QColor("black"),
QColor  infColor = QColor("black"),
bool  logScale = false,
double  logBase = 10.0,
const LUTType lutUser = LUTType() 
)
inlinestatic

convert a 2D image (as 1D array) into a QImage with given palette (see JKQTFPColorPalette)

Parameters
dbl_inpointer to a 1D array of template type T representing the image to plot. This array has to be of size width * height
widthwidth of the array in dbl
heightheight of the array in dbl
[out]imgthe QImage object to draw to (should be initialized as QImage::Format_ARGB32 )
palettethe color palette to use for the display
minColorlower boundary of color range in dbl pixels, if minColor == maxColor then this function will extract the image min and image max.
maxColorupper boundary of color range in dbl pixels, if minColor == maxColor then this function will extract the image min and image max.
paletteMinFailspecifies what shell happen, when a value in dbl is below minColor
paletteMaxFailspecifies what shell happen, when a value in dbl is above maxColor
minFailColorcolor to use for pixels that are below minColor for some settings of paletteMinFail
maxFailColorcolor to use for pixels that are below maxColor for some settings of paletteMaxFail
nanColorcolor to use for pixels that are not-a-number
infColorcolor to use for pixels that are infinity
logScalecreate a log-scaled image
logBasebase for the logarithm used when logScale==true
lutUseruser define LUT, used if palette ==JKQTPMathImageUSER_PALETTE
Note
There is a variant of this function that is called with a userLUT directly, instead of palette

◆ getColorsforPalette()

static JKQTCOMMON_LIB_EXPORT QVector< QColor > JKQTPImageTools::getColorsforPalette ( JKQTPMathImageColorPalette  palette)
static

return the list of QColors making up a JKQTPMathImageColorPalette, stored it in lutstore and return it

◆ getDefaultLUTs()

static JKQTCOMMON_LIB_EXPORT QMap< int, LUTData > JKQTPImageTools::getDefaultLUTs ( )
staticprivate

returns data of the default LUTs, used to initialize global_jkqtpimagetools_lutstore

◆ getLUTforPalette() [1/2]

static JKQTCOMMON_LIB_EXPORT const LUTType & JKQTPImageTools::getLUTforPalette ( const QMap< int, LUTData > &  lutcache,
JKQTPMathImageColorPalette  palette 
)
staticprivate

create a LUT for a given JKQTPMathImageColorPalette, store it in lutstore and return it

◆ getLUTforPalette() [2/2]

static JKQTCOMMON_LIB_EXPORT const LUTType & JKQTPImageTools::getLUTforPalette ( JKQTPMathImageColorPalette  palette)
static

create a LUT for a given JKQTPMathImageColorPalette, stored it in lutstore and return it

◆ GetPaletteIcon() [1/2]

static JKQTCOMMON_LIB_EXPORT QIcon JKQTPImageTools::GetPaletteIcon ( int  i)
static

generates a QIcon for the i-th color palette (i is based on the list returned by JKQTPImagePlot_getPredefinedPalettes() )

◆ GetPaletteIcon() [2/2]

static JKQTCOMMON_LIB_EXPORT QIcon JKQTPImageTools::GetPaletteIcon ( JKQTPMathImageColorPalette  palette)
static

generates a QIcon for a specific JKQTPMathImageColorPalette

◆ GetPaletteImage() [1/5]

static JKQTCOMMON_LIB_EXPORT QImage JKQTPImageTools::GetPaletteImage ( const LUTType lut,
int  width 
)
static

generates a QImage with width width and height 1 for a lookup-table lut

◆ GetPaletteImage() [2/5]

static JKQTCOMMON_LIB_EXPORT QImage JKQTPImageTools::GetPaletteImage ( int  i,
int  width 
)
static

generates a QImage with width width and height 1 for the i-th color palette (i is based on the list returned by JKQTPImagePlot_getPredefinedPalettes() )

◆ GetPaletteImage() [3/5]

static JKQTCOMMON_LIB_EXPORT QImage JKQTPImageTools::GetPaletteImage ( int  i,
int  width,
int  height 
)
static

generates a QImage with width width and height height for the i-th color palette (i is based on the list returned by JKQTPImagePlot_getPredefinedPalettes() )

◆ GetPaletteImage() [4/5]

static JKQTCOMMON_LIB_EXPORT QImage JKQTPImageTools::GetPaletteImage ( JKQTPMathImageColorPalette  palette,
int  width 
)
static

generates a QImage with width width and height 1 for a specific JKQTPMathImageColorPalette

◆ GetPaletteImage() [5/5]

static JKQTCOMMON_LIB_EXPORT QImage JKQTPImageTools::GetPaletteImage ( JKQTPMathImageColorPalette  palette,
int  width,
int  height 
)
static

generates a QImage with width width and height height for a specific JKQTPMathImageColorPalette

◆ getPredefinedPalettes()

static QStringList JKQTCOMMON_LIB_EXPORT JKQTPImageTools::getPredefinedPalettes ( )
static

return a list of all globally available LUTs, human-readable/localized form

◆ getPredefinedPalettesMachineReadable()

static QStringList JKQTCOMMON_LIB_EXPORT JKQTPImageTools::getPredefinedPalettesMachineReadable ( )
static

return a list of all globally available LUTs, machine-readable form

◆ JKQTPMathImageColorPalette2String()

static JKQTCOMMON_LIB_EXPORT QString JKQTPImageTools::JKQTPMathImageColorPalette2String ( JKQTPMathImageColorPalette  p)
static

convert the palette p to a machine-readable string

See also
JKQTPImageTools::String2JKQTPMathImageColorPalette()

◆ JKQTPMathImageColorPalette2StringHumanReadable()

static JKQTCOMMON_LIB_EXPORT QString JKQTPImageTools::JKQTPMathImageColorPalette2StringHumanReadable ( JKQTPMathImageColorPalette  p)
static

convert the palette p to a human-readable (localized) string

See also
JKQTPImageTools::String2JKQTPMathImageColorPalette()

◆ registerPalette()

static JKQTCOMMON_LIB_EXPORT int JKQTPImageTools::registerPalette ( const QString &  name,
const LUTType paletteLut,
const QString &  nameT = QString() 
)
static

registers a new LUT defined by paletteLut and with the given name (computer-readable) for later use, optionally stores also the human-readable and localized name nameT and assigns a new LUT-ID >=JKQTPMathImageFIRST_REGISTERED_USER_PALETTE to the palette and returns it

See also
Example (JKQTPlotter): Simple math image plot, JKQTPBuildColorPaletteLUTLinInterpolate(), JKQTPBuildColorPaletteLUT(), JKQTPBuildColorPaletteLUTLinInterpolateSorted(), JKQTPBuildColorPaletteLUTSorted(), JKQTPBuildColorPaletteLUTLinInterpolate(), JKQTPBuildColorPaletteLUT()

◆ registerPalettesFromFile()

static JKQTCOMMON_LIB_EXPORT QVector< int > JKQTPImageTools::registerPalettesFromFile ( const QString &  filename,
bool  interpolatePalette = false 
)
static

loads all palettes defined in the given palette files filename into global_jkqtpimagetools_userluts and assigns a new LUT-ID >=JKQTPMathImageFIRST_REGISTERED_USER_PALETTE to each palette All new IDs are returned as a list

The file might either be a palette XML-file or a CSV-file:

CSV-files need to have one of the following two formats (RED/GREEN/BLUE: 0..255):

scalar, red, green, blue
scalar, red, green, blue
...

or simply

red, green, blue
red, green, blue
...

The parser will also allow tabs and whitespaces as column separators.

CML-files need to have one of the following two formats (RED/GREEN/BLUE/OPACITY: 0..1):

    <ColorMap name="PALETTENAME" space="RGB">
      <Point x="scalar" r="RED" g="GREEN" b="BLUE"/>
      <Point x="scalar" r="RED" g="GREEN" b="BLUE"/>
      ...
    </ColorMap>

optionally several

<ColorMap>...</ColorMap>

definitions may be put below an arbitrarily named document node, e.g.:

    <ColorMaps>
        <ColorMap name="PALETTENAME" space="RGB">
          <Point x="scalar" r="RED" g="GREEN" b="BLUE"/>
          <Point x="scalar" r="RED" g="GREEN" b="BLUE"/>
          ...
        </ColorMap>
        <ColorMap name="PALETTENAME" space="RGB">
          <Point x="scalar" r="RED" g="GREEN" b="BLUE"/>
          <Point x="scalar" r="RED" g="GREEN" b="BLUE"/>
          ...
        </ColorMap>
        ...
    </ColorMaps>
Note
In both cases, the palette will be formed without interpolation, i.e. using JKQTPBuildColorPaletteLUT() . If in addition interpolatePalette is set to true, the function JKQTPBuildColorPaletteLUTLinInterpolate() is used instead.
See also
Example (JKQTPlotter): Simple math image plot , JKQTPBuildColorPaletteLUT()

◆ String2JKQTPMathImageColorPalette()

static JKQTCOMMON_LIB_EXPORT JKQTPMathImageColorPalette JKQTPImageTools::String2JKQTPMathImageColorPalette ( const QString &  p)
static

convert the palette name p to JKQTPMathImageColorPalette (compatible with JKQTPImageTools::String2JKQTPMathImageColorPalette() )

See also
JKQTPImageTools::JKQTPMathImageColorPalette2String()

Member Data Documentation

◆ getPredefinedPalettesGlobalList

JKQTCOMMON_LIB_EXPORT QStringList JKQTPImageTools::getPredefinedPalettesGlobalList
staticprivate

storage for the palette names in getPredefinedPalettes()


◆ getPredefinedPalettesMachineReadableGlobalList

JKQTCOMMON_LIB_EXPORT QStringList JKQTPImageTools::getPredefinedPalettesMachineReadableGlobalList
staticprivate

storage for the palette names in etPredefinedPalettesMachineReadable()


◆ global_jkqtpimagetools_lutstore

JKQTCOMMON_LIB_EXPORT QMap<int, LUTData > JKQTPImageTools::global_jkqtpimagetools_lutstore
staticprivate

internal global storage object for lookup-tables

◆ global_next_userpalette

JKQTCOMMON_LIB_EXPORT int JKQTPImageTools::global_next_userpalette
staticprivate

storage for the next ID to assign to a user-defined palette, registered with registerPalette() or registerPalettesFromFile()

See also
registerPalette() registerPalettesFromFile()

◆ lutMutex

JKQTCOMMON_LIB_EXPORT QReadWriteLock JKQTPImageTools::lutMutex
staticprivate

Mutex to protect global_jkqtpimagetools_lutstore, getPredefinedPalettesGlobalList, getPredefinedPalettesMachineReadableGlobalList and global_next_userpalette.

◆ LUTSIZE

JKQTCOMMON_LIB_EXPORT const int JKQTPImageTools::LUTSIZE
static

size of the lookup tables used by JKQTFPimagePlot_array2image()

◆ NDEFAULTSTEPS

JKQTCOMMON_LIB_EXPORT const int JKQTPImageTools::NDEFAULTSTEPS
static

number of entries in an auto-generated steps-palette

◆ PALETTE_ICON_WIDTH

JKQTCOMMON_LIB_EXPORT const int JKQTPImageTools::PALETTE_ICON_WIDTH
static

Width of the Palette-Icons, generated e.g. by JKQTPImageTools::GetPaletteIcon()

◆ PALETTE_IMAGEICON_HEIGHT

JKQTCOMMON_LIB_EXPORT const int JKQTPImageTools::PALETTE_IMAGEICON_HEIGHT
static

Height of the Palette-Icons, generated e.g. by JKQTPImageTools::GetPaletteIcon()


The documentation for this struct was generated from the following file: