diff --git a/doc/dox/whatsnew.dox b/doc/dox/whatsnew.dox
index f254ef0ce1..88dd7f8472 100644
--- a/doc/dox/whatsnew.dox
+++ b/doc/dox/whatsnew.dox
@@ -25,6 +25,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
BREAKING/REWORKED: Updated default styling of graphs. They are now more modern!
BREAKING/REWORKED: Implement better/more access functions to the graphs (inlcuding sorting, moving up/down, appending/prepending, graphs-iterators ...), solves issue #97, thanks to user:sim186 for bringing this up
BREAKING/FIXED: fixed issue #96: JKQTPlotter::saveAsPixelImage() does not add a border around the image any longer (can be reacivated by a new optional function parameter), thanks to user:nmielcarek for reporting
+ FIXED/BREAKING: graph symbols were not properly applied when reading styles (in fact they were shuffled under some circumstances)
FIXED issue described in #62: Fix custom labels draw, because giving exactly two label-strings did not display all of them, thanks to user:FalsinSoft
FIXED issue #70: Typo in jkqtplotter/CMakeLists.txt, thanks to user:tedlinlab
FIXED issue #80: Bug with multiple inheritance with Q_GDAGET with CLANG, thanks to user:igormironchik, caused by QTBUG-104874
@@ -85,6 +86,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
NEW: several new color palettes (especially stepped/categorial palettes), e.g. JKQTPMathImageColorPalette::JKQTPMathImageOkabeIto_STEP, JKQTPMathImageColorPalette::JKQTPMathImageIBMColorBlindSafe, JKQTPMathImageColorPalette::JKQTPMathImageIBMColorBlindSafe_STEP, ...
NEW: add color palettes from Green's HELIX method, see https://arxiv.org/abs/1108.5083, also see https://jiffyclub.github.io/palettable/cubehelix/, see JKQTPCreateGreensCubeHelixLUT() and e.g. JKQTPMathImageCubeHelixClassic, JKQTPMathImageCubeHelix1, ...
NEW: Using Q_SIGNALS/Q_SLOTS instead of signals/slots MOC-keywords ... this allows for interoperability with other signals/slots frameworks, thanks to user:nickmontini for the proposal
+ NEW: you can use any (preferably stepped/categorial) JKQTPMathImageColorPalette as default graph colors list in a style.ini file, by setting auto_styles/use_color_from_palette=PALETTE_NAME
JKQTMathText:
diff --git a/lib/jkqtcommon/jkqtpbasicimagetools.cpp b/lib/jkqtcommon/jkqtpbasicimagetools.cpp
index 4635e5f318..d4a48cc82b 100644
--- a/lib/jkqtcommon/jkqtpbasicimagetools.cpp
+++ b/lib/jkqtcommon/jkqtpbasicimagetools.cpp
@@ -64,8 +64,8 @@ QMap JKQTPImageTools::getDefaultLUTs() {
lutstore[palette]=JKQTPImageTools::LUTData(palN, palNT);
JKQTPPaletteList lst;
lst< lock(JKQTPImageTools::lutMutex);
+ auto it=JKQTPImageTools::global_jkqtpimagetools_lutstore.find(p);
+ if (it==JKQTPImageTools::global_jkqtpimagetools_lutstore.end()) return QString::number(static_cast(p));
+ else {
+ if (it.value().nameT.size()>0) return it.value().nameT;
+ else if (it.value().name.size()>0) return it.value().name;
+ else return QString::number(static_cast(p));
+ }
+}
+
JKQTPMathImageColorPalette JKQTPImageTools::String2JKQTPMathImageColorPalette(const QString &p)
{
std::lock_guard lock(JKQTPImageTools::lutMutex);
@@ -2848,7 +2860,7 @@ JKQTPMathImageColorPalette JKQTPImageTools::String2JKQTPMathImageColorPalette(co
-const JKQTPImageTools::LUTType& JKQTPImageTools::getLUTforPalette(QMap& lutstore, JKQTPMathImageColorPalette palette) {
+const JKQTPImageTools::LUTType& JKQTPImageTools::getLUTforPalette(const QMap& lutstore, JKQTPMathImageColorPalette palette) {
static JKQTPImageTools::LUTType empty(JKQTPImageTools::LUTSIZE, 0);
auto it=lutstore.find(static_cast(palette));
@@ -2919,6 +2931,20 @@ QIcon JKQTPImageTools::GetPaletteIcon(JKQTPMathImageColorPalette palette) {
return JKQTPImageTools::GetPaletteIcon(static_cast(palette));
}
+const JKQTPImageTools::LUTType &JKQTPImageTools::getLUTforPalette(JKQTPMathImageColorPalette palette)
+{
+ return getLUTforPalette(JKQTPImageTools::global_jkqtpimagetools_lutstore, palette);
+}
+
+QVector JKQTPImageTools::getColorsforPalette(JKQTPMathImageColorPalette palette)
+{
+ QVector cols;
+ const auto& lut=JKQTPImageTools::getLUTforPalette(palette);
+ cols.reserve(lut.size());
+ std::for_each(lut.begin(), lut.end(), [&](QRgb c) { cols.push_back(c); });
+ return cols;
+}
+
diff --git a/lib/jkqtcommon/jkqtpbasicimagetools.h b/lib/jkqtcommon/jkqtpbasicimagetools.h
index 551d1769f2..4560779a26 100644
--- a/lib/jkqtcommon/jkqtpbasicimagetools.h
+++ b/lib/jkqtcommon/jkqtpbasicimagetools.h
@@ -507,10 +507,14 @@ struct JKQTPImageTools {
/** \brief return a list of all globally available LUTs, machine-readable form */
static QStringList JKQTCOMMON_LIB_EXPORT getPredefinedPalettesMachineReadable();
- /*! \brief convert the palette \a p to a string
+ /*! \brief convert the palette \a p to a machine-readable string
\see JKQTPImageTools::String2JKQTPMathImageColorPalette()
*/
static JKQTCOMMON_LIB_EXPORT QString JKQTPMathImageColorPalette2String(JKQTPMathImageColorPalette p);
+ /*! \brief convert the palette \a p to a human-readable (localized) string
+ \see JKQTPImageTools::String2JKQTPMathImageColorPalette()
+ */
+ static JKQTCOMMON_LIB_EXPORT QString JKQTPMathImageColorPalette2StringHumanReadable(JKQTPMathImageColorPalette p);
/*! \brief convert the palette name \a p to JKQTPMathImageColorPalette (compatible with JKQTPImageTools::String2JKQTPMathImageColorPalette() )
\see JKQTPImageTools::JKQTPMathImageColorPalette2String()
@@ -535,6 +539,10 @@ struct JKQTPImageTools {
/** \brief generates a QIcon for a specific JKQTPMathImageColorPalette */
static QIcon JKQTCOMMON_LIB_EXPORT GetPaletteIcon(JKQTPMathImageColorPalette palette) ;
+ /*! \brief create a LUT for a given JKQTPMathImageColorPalette, stored it in \a lutstore and return it */
+ static const LUTType& JKQTCOMMON_LIB_EXPORT getLUTforPalette(JKQTPMathImageColorPalette palette);
+ /*! \brief return the list of QColors making up a JKQTPMathImageColorPalette, stored it in \a lutstore and return it */
+ static QVector JKQTCOMMON_LIB_EXPORT getColorsforPalette(JKQTPMathImageColorPalette palette);
private:
@@ -577,7 +585,7 @@ struct JKQTPImageTools {
/*! \brief create a LUT for a given JKQTPMathImageColorPalette, store it in \a lutstore and return it
\internal
*/
- static JKQTCOMMON_LIB_EXPORT const LUTType& getLUTforPalette(QMap &lutcache, JKQTPMathImageColorPalette palette);
+ static JKQTCOMMON_LIB_EXPORT const LUTType& getLUTforPalette(const QMap &lutcache, JKQTPMathImageColorPalette palette);
};
diff --git a/lib/jkqtplotter/jkqtpgraphsbasestyle.cpp b/lib/jkqtplotter/jkqtpgraphsbasestyle.cpp
index 04d1bb4176..fe36b73c7e 100644
--- a/lib/jkqtplotter/jkqtpgraphsbasestyle.cpp
+++ b/lib/jkqtplotter/jkqtpgraphsbasestyle.cpp
@@ -204,7 +204,17 @@ JKQTGraphsBaseStyle::JKQTGraphsBaseStyle(const JKQTBasePlotterStyle& parent):
impulseStyle(parent),
geometricStyle(parent),
annotationStyle(parent),
- defaultPalette(JKQTPMathImageColorPalette::JKQTPMathImageMATLAB)
+ defaultPalette(JKQTPMathImageColorPalette::JKQTPMathImageMATLAB),
+ defaultGraphColors(getDefaultGraphColors()),
+ defaultGraphPenStyles(getDefaultGraphPenStyles()),
+ defaultGraphSymbols(getDefaultGraphSymbols()),
+ defaultGraphFillStyles(getDefaultGraphFillStyles())
+{
+
+}
+
+
+QVector JKQTGraphsBaseStyle::getDefaultGraphColors()
{
// color scale by Okabe & Ito:
// M. Okabe and K. Ito, “How to make figures and presentations that are friendly to color blind people,” University of Tokyo, 2002.
@@ -212,11 +222,24 @@ JKQTGraphsBaseStyle::JKQTGraphsBaseStyle(const JKQTBasePlotterStyle& parent):
//defaultGraphColors<(i));
- defaultGraphFillStyles<()< JKQTGraphsBaseStyle::getDefaultGraphPenStyles()
+{
+ return QVector()< JKQTGraphsBaseStyle::getDefaultGraphSymbols()
+{
+ QVector syms;
+ for (int i=2; i<=JKQTPMaxSymbolID; i++) syms.push_back(static_cast(i));
+ return syms;
+}
+
+QVector JKQTGraphsBaseStyle::getDefaultGraphFillStyles()
+{
+ return QVector()<=0) {
- defaultGraphColors.push_back(jkqtp_String2QColor(settings.value(group+"auto_styles/color"+QString::number(id), jkqtp_QColor2String(QColor("red"))).toString()));
+ if (loadColors) {
+ int id=readID(k, group+"auto_styles/color");
+ if (id>=0) {
+ defaultGraphColors.push_back(jkqtp_String2QColor(settings.value(group+"auto_styles/color"+QString::number(id), jkqtp_QColor2String(QColor("red"))).toString()));
+ }
}
- id=readID(k, group+"auto_styles/line_style");
+ int id=readID(k, group+"auto_styles/line_style");
if (id>=0) {
defaultGraphPenStyles.push_back(jkqtp_String2QPenStyle(settings.value(group+"auto_styles/line_style"+QString::number(id), jkqtp_QPenStyle2String(Qt::SolidLine)).toString()));
}
@@ -268,22 +307,22 @@ void JKQTGraphsBaseStyle::loadSettings(const QSettings &settings, const QString
}
}
if (defaultGraphColors.size()==0) {
- for (int i=defaultGraphColors.size(); i(JKQTPMathImagePREDEFINED_PALETTES_COUNT); pali++ ) {
+ const JKQTPMathImageColorPalette pal=static_cast(pali);
+ if (defaultGraphColors==JKQTPImageTools::getColorsforPalette(pal)) {
+ settings.setValue(group+"auto_styles/use_color_from_palette", JKQTPImageTools::JKQTPMathImageColorPalette2String(pal));
+ saveSingleColors=false;
+ break;
+ }
}
- cnt=0;
- for (auto& gs: defaultGraphPenStyles) {
- settings.setValue(group+"auto_styles/line_style"+QString::number(cnt), jkqtp_QPenStyle2String(gs));
- cnt++;
+ if (saveSingleColors && defaultGraphColors==getDefaultGraphColors()) {
+ settings.setValue(group+"auto_styles/use_default_colors", true);
+ saveSingleColors=false;
}
- cnt=0;
- for (auto& gs: defaultGraphSymbols) {
- settings.setValue(group+"auto_styles/symbol"+QString::number(cnt), JKQTPGraphSymbols2String(gs));
- cnt++;
+ if (saveSingleColors) {
+ const QString maxnum=QString::number(defaultGraphColors.size());
+ int cnt=0;
+ for (auto& gs: defaultGraphColors) {
+ QString num=QString::number(cnt);
+ while (num.size() defaultGraphFillStyles;
+ /** \brief standard color palette for the default style */
+ static QVector getDefaultGraphColors();
+ /** \brief a list of Qt::PenStyles used to automatically style different graphs differently in the default style */
+ static QVector getDefaultGraphPenStyles();
+ /** \brief list of JKQTPGraphSymbols used to automatically assign to different graphs in the default style */
+ static QVector getDefaultGraphSymbols();
+ /** \brief list of Qt::BrushStyle used to automatically style different graphs differently in the default style */
+ static QVector getDefaultGraphFillStyles();
+
};
#endif // JKQTPGRAPHSBASESTYLE_H