2020-09-26 21:58:58 +08:00
|
|
|
#include "jkqtpgraphsbasestyle.h"
|
|
|
|
#include <QPalette>
|
|
|
|
#include <QApplication>
|
|
|
|
#include "jkqtplotter/jkqtptools.h"
|
|
|
|
#include "jkqtplotter/jkqtpbaseplotterstyle.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JKQTGraphsSpecificStyleProperties::JKQTGraphsSpecificStyleProperties(JKQTPPlotStyleType type, const JKQTBasePlotterStyle &/*parent*/):
|
|
|
|
defaultLineWidth(2),
|
|
|
|
defaultSymbolSize(10),
|
2020-09-27 22:11:58 +08:00
|
|
|
defaultSymbolLineWidth(1),
|
2020-09-26 21:58:58 +08:00
|
|
|
defaultErrorIndicatorWidth(1),
|
|
|
|
defaultHeadDecoratorStyle(JKQTPLineDecoratorStyle::JKQTPDefaultLineDecorator),
|
|
|
|
defaultHeadDecoratorSizeFactor(8.0),
|
2020-09-27 22:11:58 +08:00
|
|
|
errorFillStyle(Qt::SolidPattern),
|
2022-06-03 03:21:17 +08:00
|
|
|
graphColorDerivationMode(JKQTPColorDerivationMode::JKQTPFFCMSameColor),
|
|
|
|
fillColorDerivationMode(JKQTPColorDerivationMode::JKQTPFFCMLighterColor),
|
|
|
|
errorColorDerivationMode(JKQTPColorDerivationMode::JKQTPFFCMDarkerColor),
|
|
|
|
errorFillColorDerivationMode(JKQTPColorDerivationMode::JKQTPFFCMLighterAndTransparentColor),
|
|
|
|
symbolFillColorDerivationMode(JKQTPColorDerivationMode::JKQTPFFCMLighterColor)
|
2020-09-27 22:11:58 +08:00
|
|
|
{
|
|
|
|
modifyForDefaultStyle(type);
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTGraphsSpecificStyleProperties::JKQTGraphsSpecificStyleProperties(JKQTPPlotStyleType type, const JKQTGraphsSpecificStyleProperties &other):
|
|
|
|
JKQTGraphsSpecificStyleProperties(other)
|
|
|
|
{
|
|
|
|
modifyForDefaultStyle(type);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void JKQTGraphsSpecificStyleProperties::modifyForDefaultStyle(JKQTPPlotStyleType type)
|
2020-09-26 21:58:58 +08:00
|
|
|
{
|
|
|
|
switch(type) {
|
|
|
|
case JKQTPPlotStyleType::Default:
|
|
|
|
break;
|
|
|
|
case JKQTPPlotStyleType::Filled:
|
2022-06-03 03:21:17 +08:00
|
|
|
fillColorDerivationMode=JKQTPColorDerivationMode::JKQTPFFCMLighterAndTransparentColor;
|
2020-09-26 21:58:58 +08:00
|
|
|
break;
|
|
|
|
case JKQTPPlotStyleType::Impulses:
|
|
|
|
defaultLineWidth=3;
|
|
|
|
break;
|
|
|
|
case JKQTPPlotStyleType::Barchart:
|
|
|
|
defaultLineWidth=0;
|
2022-06-03 03:21:17 +08:00
|
|
|
graphColorDerivationMode=JKQTPColorDerivationMode::JKQTPFFCMLighterColor;
|
|
|
|
fillColorDerivationMode=JKQTPColorDerivationMode::JKQTPFFCMLighterColor;
|
2020-09-26 21:58:58 +08:00
|
|
|
break;
|
|
|
|
case JKQTPPlotStyleType::Boxplot:
|
|
|
|
defaultLineWidth=1;
|
2022-06-03 03:21:17 +08:00
|
|
|
fillColorDerivationMode=JKQTPColorDerivationMode::JKQTPFFCMWhite;
|
|
|
|
graphColorDerivationMode=JKQTPColorDerivationMode::JKQTPFFCMSameNonTransparentColor;
|
2020-09-26 21:58:58 +08:00
|
|
|
break;
|
|
|
|
case JKQTPPlotStyleType::Annotation:
|
2022-06-03 03:21:17 +08:00
|
|
|
graphColorDerivationMode=JKQTPColorDerivationMode::JKQTPFFCMSameNonTransparentColor;
|
2020-09-26 21:58:58 +08:00
|
|
|
defaultSymbolSize=16;
|
|
|
|
break;
|
|
|
|
case JKQTPPlotStyleType::Geometric:
|
2022-06-03 03:21:17 +08:00
|
|
|
graphColorDerivationMode=JKQTPColorDerivationMode::JKQTPFFCMSameNonTransparentColor;
|
|
|
|
fillColorDerivationMode=JKQTPColorDerivationMode::JKQTPFFCMFullyTransparentColor;
|
2020-09-26 21:58:58 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTGraphsSpecificStyleProperties::loadSettings(const QSettings &settings, const QString &group, const JKQTGraphsSpecificStyleProperties &defaultStyle)
|
|
|
|
{
|
|
|
|
defaultLineWidth=settings.value(group+"linewidth", defaultStyle.defaultLineWidth).toDouble();
|
|
|
|
defaultSymbolSize=settings.value(group+"symbol_size", defaultStyle.defaultSymbolSize).toDouble();
|
2020-09-27 22:11:58 +08:00
|
|
|
defaultSymbolLineWidth=settings.value(group+"symbol_line_width", defaultStyle.defaultSymbolLineWidth).toDouble();
|
|
|
|
defaultErrorIndicatorWidth=settings.value(group+"error_indicator_width", defaultStyle.defaultErrorIndicatorWidth).toDouble();
|
2020-09-26 21:58:58 +08:00
|
|
|
defaultHeadDecoratorStyle=String2JKQTPLineDecoratorStyle(settings.value(group+"head_decorator_type", JKQTPLineDecoratorStyle2String(defaultStyle.defaultHeadDecoratorStyle)).toString());
|
|
|
|
defaultHeadDecoratorSizeFactor=settings.value(group+"head_decorator_size_factor", defaultStyle.defaultHeadDecoratorSizeFactor).toDouble();
|
2020-09-27 22:11:58 +08:00
|
|
|
errorFillStyle=jkqtp_String2QBrushStyle(settings.value(group+"error_fill_style", jkqtp_QBrushStyle2String(errorFillStyle)).toString());
|
2020-09-26 21:58:58 +08:00
|
|
|
|
|
|
|
graphColorDerivationMode=String2JKQTPColorDerivationMode(settings.value(group+"graph_color_mode", JKQTPColorDerivationMode2String(defaultStyle.graphColorDerivationMode)).toString());
|
|
|
|
fillColorDerivationMode=String2JKQTPColorDerivationMode(settings.value(group+"fill_color_mode", JKQTPColorDerivationMode2String(defaultStyle.fillColorDerivationMode)).toString());
|
|
|
|
errorColorDerivationMode=String2JKQTPColorDerivationMode(settings.value(group+"error_color_mode", JKQTPColorDerivationMode2String(defaultStyle.errorColorDerivationMode)).toString());
|
|
|
|
errorFillColorDerivationMode=String2JKQTPColorDerivationMode(settings.value(group+"error_fill_color_mode", JKQTPColorDerivationMode2String(defaultStyle.errorFillColorDerivationMode)).toString());
|
|
|
|
symbolFillColorDerivationMode=String2JKQTPColorDerivationMode(settings.value(group+"symbol_fill_color_mode", JKQTPColorDerivationMode2String(defaultStyle.symbolFillColorDerivationMode)).toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTGraphsSpecificStyleProperties::saveSettings(QSettings &settings, const QString &group) const
|
|
|
|
{
|
|
|
|
settings.setValue(group+"linewidth", defaultLineWidth);
|
|
|
|
settings.setValue(group+"symbol_size", defaultSymbolSize);
|
2020-09-27 22:11:58 +08:00
|
|
|
settings.setValue(group+"symbol_line_width", defaultSymbolLineWidth);
|
2020-09-26 21:58:58 +08:00
|
|
|
settings.setValue(group+"error_indicator_width", defaultErrorIndicatorWidth);
|
|
|
|
settings.setValue(group+"head_decorator_size_factor", defaultHeadDecoratorSizeFactor);
|
|
|
|
settings.setValue(group+"head_decorator_type", JKQTPLineDecoratorStyle2String(defaultHeadDecoratorStyle));
|
2020-09-27 22:11:58 +08:00
|
|
|
settings.setValue(group+"error_fill_style", jkqtp_QBrushStyle2String(errorFillStyle));
|
2020-09-26 21:58:58 +08:00
|
|
|
|
|
|
|
settings.setValue(group+"graph_color_mode", JKQTPColorDerivationMode2String(graphColorDerivationMode));
|
|
|
|
settings.setValue(group+"fill_color_mode", JKQTPColorDerivationMode2String(fillColorDerivationMode));
|
|
|
|
settings.setValue(group+"error_color_mode", JKQTPColorDerivationMode2String(errorColorDerivationMode));
|
|
|
|
settings.setValue(group+"error_fill_color_mode", JKQTPColorDerivationMode2String(errorFillColorDerivationMode));
|
|
|
|
settings.setValue(group+"symbol_fill_color_mode", JKQTPColorDerivationMode2String(symbolFillColorDerivationMode));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-27 22:11:58 +08:00
|
|
|
|
2020-09-26 21:58:58 +08:00
|
|
|
JKQTGeometricSpecificStyleProperties::JKQTGeometricSpecificStyleProperties(const JKQTBasePlotterStyle& parent):
|
|
|
|
JKQTGraphsSpecificStyleProperties(JKQTPPlotStyleType::Geometric, parent),
|
|
|
|
defaultColor(parent.defaultTextColor),
|
|
|
|
defaultLineStyle(Qt::SolidLine),
|
|
|
|
defaultSymbol(JKQTPGraphSymbols::JKQTPCross),
|
|
|
|
defaultFillStyle(Qt::SolidPattern)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTGeometricSpecificStyleProperties::JKQTGeometricSpecificStyleProperties(const JKQTBasePlotterStyle& parent, const JKQTGraphsSpecificStyleProperties &other):
|
2020-09-27 22:11:58 +08:00
|
|
|
JKQTGraphsSpecificStyleProperties(JKQTPPlotStyleType::Geometric, other),
|
2020-09-26 21:58:58 +08:00
|
|
|
defaultColor(parent.defaultTextColor),
|
|
|
|
defaultLineStyle(Qt::SolidLine),
|
|
|
|
defaultSymbol(JKQTPGraphSymbols::JKQTPCross),
|
|
|
|
defaultFillStyle(Qt::SolidPattern)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTGeometricSpecificStyleProperties::JKQTGeometricSpecificStyleProperties(JKQTPPlotStyleType type, const JKQTBasePlotterStyle &parent):
|
|
|
|
JKQTGraphsSpecificStyleProperties(type, parent),
|
|
|
|
defaultColor(parent.defaultTextColor),
|
|
|
|
defaultLineStyle(Qt::SolidLine),
|
|
|
|
defaultSymbol(JKQTPGraphSymbols::JKQTPCross),
|
|
|
|
defaultFillStyle(Qt::SolidPattern)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-09-27 22:11:58 +08:00
|
|
|
JKQTGeometricSpecificStyleProperties::JKQTGeometricSpecificStyleProperties(JKQTPPlotStyleType type, const JKQTGraphsSpecificStyleProperties &other, const JKQTBasePlotterStyle &parent):
|
|
|
|
JKQTGraphsSpecificStyleProperties(type, other),
|
|
|
|
defaultColor(parent.defaultTextColor),
|
|
|
|
defaultLineStyle(Qt::SolidLine),
|
|
|
|
defaultSymbol(JKQTPGraphSymbols::JKQTPCross),
|
|
|
|
defaultFillStyle(Qt::SolidPattern)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-09-26 21:58:58 +08:00
|
|
|
|
2020-09-27 22:11:58 +08:00
|
|
|
void JKQTGeometricSpecificStyleProperties::loadSettings(const QSettings &settings, const QString &group, const JKQTGeometricSpecificStyleProperties &defaultStyle)
|
2020-09-26 21:58:58 +08:00
|
|
|
{
|
|
|
|
JKQTGraphsSpecificStyleProperties::loadSettings(settings, group, defaultStyle);
|
|
|
|
defaultColor=jkqtp_String2QColor(settings.value(group+"color", jkqtp_QColor2String(defaultColor)).toString());
|
|
|
|
defaultLineStyle=jkqtp_String2QPenStyle(settings.value(group+"line_style", jkqtp_QPenStyle2String(defaultLineStyle)).toString());
|
|
|
|
defaultSymbol=String2JKQTPGraphSymbols(settings.value(group+"symbol", JKQTPGraphSymbols2String(defaultSymbol)).toString());
|
2024-01-23 04:31:09 +08:00
|
|
|
defaultFillStyle=JKQTFillStyleSummmary::fromString(settings.value(group+"fill_style", defaultFillStyle.toCSSString()).toString());
|
2020-09-26 21:58:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTGeometricSpecificStyleProperties::saveSettings(QSettings &settings, const QString &group) const
|
|
|
|
{
|
|
|
|
JKQTGraphsSpecificStyleProperties::saveSettings(settings, group);
|
|
|
|
settings.setValue(group+"color", jkqtp_QColor2String(defaultColor));
|
|
|
|
settings.setValue(group+"line_style", jkqtp_QPenStyle2String(defaultLineStyle));
|
|
|
|
settings.setValue(group+"symbol", JKQTPGraphSymbols2String(defaultSymbol));
|
2024-01-23 04:31:09 +08:00
|
|
|
settings.setValue(group+"fill_style", defaultFillStyle.toCSSString());
|
2020-09-26 21:58:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
JKQTAnnotationsSpecificStyleProperties::JKQTAnnotationsSpecificStyleProperties(const JKQTBasePlotterStyle& parent):
|
2020-09-27 22:11:58 +08:00
|
|
|
JKQTGeometricSpecificStyleProperties(JKQTPPlotStyleType::Annotation, parent),
|
2020-09-26 21:58:58 +08:00
|
|
|
defaultTextColor(parent.defaultTextColor),
|
|
|
|
defaultFontSize(12),
|
|
|
|
defaultFontName(parent.defaultFontName)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTAnnotationsSpecificStyleProperties::JKQTAnnotationsSpecificStyleProperties(const JKQTBasePlotterStyle& parent, const JKQTGraphsSpecificStyleProperties &other):
|
2020-09-27 22:11:58 +08:00
|
|
|
JKQTGeometricSpecificStyleProperties(JKQTPPlotStyleType::Annotation, other, parent),
|
2020-09-26 21:58:58 +08:00
|
|
|
defaultTextColor(parent.defaultTextColor),
|
|
|
|
defaultFontSize(12),
|
|
|
|
defaultFontName(parent.defaultFontName)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTAnnotationsSpecificStyleProperties::loadSettings(const QSettings &settings, const QString &group, const JKQTAnnotationsSpecificStyleProperties &defaultStyle)
|
|
|
|
{
|
|
|
|
JKQTGeometricSpecificStyleProperties::loadSettings(settings, group, defaultStyle);
|
|
|
|
defaultTextColor=jkqtp_String2QColor(settings.value(group+"text_color", jkqtp_QColor2String(defaultStyle.defaultTextColor)).toString());
|
|
|
|
defaultFontSize=settings.value(group+"font_size", defaultStyle.defaultFontSize).toDouble();
|
|
|
|
defaultFontName=settings.value(group+"font_name", defaultStyle.defaultFontName).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTAnnotationsSpecificStyleProperties::saveSettings(QSettings &settings, const QString &group) const
|
|
|
|
{
|
|
|
|
JKQTGeometricSpecificStyleProperties::saveSettings(settings, group);
|
|
|
|
settings.setValue(group+"text_color", jkqtp_QColor2String(defaultTextColor));
|
|
|
|
settings.setValue(group+"font_size", defaultFontSize);
|
|
|
|
settings.setValue(group+"font_name", defaultFontName);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-09-27 07:42:54 +08:00
|
|
|
|
2020-09-26 21:58:58 +08:00
|
|
|
JKQTGraphsBaseStyle::JKQTGraphsBaseStyle(const JKQTBasePlotterStyle& parent):
|
|
|
|
useAntiAliasingForGraphs(true),
|
|
|
|
defaultGraphStyle(JKQTPPlotStyleType::Default, parent),
|
2022-09-27 07:42:54 +08:00
|
|
|
barchartStyle(parent),
|
2020-09-26 21:58:58 +08:00
|
|
|
boxplotStyle(JKQTPPlotStyleType::Boxplot, parent),
|
|
|
|
filledStyle(JKQTPPlotStyleType::Filled, parent),
|
2022-11-01 03:34:01 +08:00
|
|
|
impulseStyle(parent),
|
2020-09-26 21:58:58 +08:00
|
|
|
geometricStyle(parent),
|
|
|
|
annotationStyle(parent),
|
2023-07-26 04:20:00 +08:00
|
|
|
defaultPalette(JKQTPMathImageColorPalette::JKQTPMathImageMATLAB),
|
|
|
|
defaultGraphColors(getDefaultGraphColors()),
|
|
|
|
defaultGraphPenStyles(getDefaultGraphPenStyles()),
|
|
|
|
defaultGraphSymbols(getDefaultGraphSymbols()),
|
|
|
|
defaultGraphFillStyles(getDefaultGraphFillStyles())
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QVector<QColor> JKQTGraphsBaseStyle::getDefaultGraphColors()
|
2020-09-26 21:58:58 +08:00
|
|
|
{
|
2023-07-31 04:30:09 +08:00
|
|
|
QVector<QColor> cols;
|
|
|
|
const auto& lut=JKQTPImageTools::getLUTforPalette(JKQTPMathImageDefault_STEP);
|
|
|
|
for (const auto& c: lut) {
|
|
|
|
cols.push_back(QColor(c));
|
|
|
|
}
|
|
|
|
return cols;
|
2023-07-26 04:20:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
QVector<Qt::PenStyle> JKQTGraphsBaseStyle::getDefaultGraphPenStyles()
|
|
|
|
{
|
|
|
|
return QVector<Qt::PenStyle>()<<Qt::SolidLine<<Qt::DashLine<<Qt::DotLine<<Qt::DashDotLine<<Qt::DashDotDotLine;
|
|
|
|
}
|
2020-09-26 21:58:58 +08:00
|
|
|
|
2023-07-26 04:20:00 +08:00
|
|
|
QVector<JKQTPGraphSymbols> JKQTGraphsBaseStyle::getDefaultGraphSymbols()
|
|
|
|
{
|
|
|
|
QVector<JKQTPGraphSymbols> syms;
|
2024-01-23 20:09:37 +08:00
|
|
|
for (int i=2; i<=static_cast<int>(JKQTPMaxSymbolID); i++) syms.push_back(static_cast<JKQTPGraphSymbols>(i));
|
2023-07-26 04:20:00 +08:00
|
|
|
return syms;
|
|
|
|
}
|
|
|
|
|
2024-01-22 05:20:33 +08:00
|
|
|
QVector<JKQTFillStyleSummmary> JKQTGraphsBaseStyle::getDefaultGraphFillStyles()
|
2023-07-26 04:20:00 +08:00
|
|
|
{
|
2024-01-22 05:20:33 +08:00
|
|
|
return QVector<JKQTFillStyleSummmary>()<<JKQTFillStyleSummmary(Qt::SolidPattern);
|
2020-09-26 21:58:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTGraphsBaseStyle::loadSettings(const QSettings &settings, const QString &group, const JKQTGraphsBaseStyle &defaultStyle, const JKQTBasePlotterStyle& parent)
|
|
|
|
{
|
|
|
|
useAntiAliasingForGraphs=settings.value(group+"antialiase", defaultStyle.useAntiAliasingForGraphs).toBool();
|
|
|
|
defaultPalette=JKQTPImageTools::String2JKQTPMathImageColorPalette(settings.value(group+"palette", JKQTPImageTools::JKQTPMathImageColorPalette2String(defaultStyle.defaultPalette)).toString());
|
|
|
|
|
|
|
|
auto readID=[](const QString& k, const QString& start) {
|
|
|
|
if (k.startsWith(start)) {
|
|
|
|
QString kk=k;
|
|
|
|
kk.remove(0, start.size());
|
|
|
|
QString num="";
|
|
|
|
while (!kk.isEmpty() && kk.at(0).isDigit()) {
|
|
|
|
num+=kk.at(0);
|
|
|
|
kk.remove(0, 1);
|
|
|
|
}
|
|
|
|
bool ok=false;
|
|
|
|
int id=num.toInt(&ok);
|
|
|
|
if (ok) {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
};
|
|
|
|
|
2023-07-26 04:20:00 +08:00
|
|
|
|
2020-09-26 21:58:58 +08:00
|
|
|
defaultGraphColors.clear();
|
|
|
|
defaultGraphPenStyles.clear();
|
|
|
|
defaultGraphSymbols.clear();
|
|
|
|
defaultGraphFillStyles.clear();
|
2023-07-26 04:20:00 +08:00
|
|
|
bool loadColors=true;
|
|
|
|
if (settings.value("auto_styles/use_default_colors", false).toBool()) {
|
|
|
|
loadColors=false;
|
|
|
|
defaultGraphColors=defaultStyle.defaultGraphColors;
|
|
|
|
}
|
2023-07-31 04:30:09 +08:00
|
|
|
const QString ini_colors_fromm_palettes=settings.value(group+"auto_styles/use_color_from_palette", "").toString();
|
2023-07-26 04:20:00 +08:00
|
|
|
if (JKQTPImageTools::getPredefinedPalettesMachineReadable().contains(ini_colors_fromm_palettes)) {
|
|
|
|
loadColors=false;
|
|
|
|
const auto& lut=JKQTPImageTools::getLUTforPalette(JKQTPImageTools::String2JKQTPMathImageColorPalette(ini_colors_fromm_palettes));
|
|
|
|
for (const auto& c: lut) {
|
|
|
|
defaultGraphColors.push_back(QColor(c));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const QStringList allk=settings.allKeys();
|
2020-09-26 21:58:58 +08:00
|
|
|
for (auto& k: allk) {
|
2023-07-26 04:20:00 +08:00
|
|
|
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()));
|
|
|
|
}
|
2020-09-26 21:58:58 +08:00
|
|
|
}
|
|
|
|
|
2023-07-26 04:20:00 +08:00
|
|
|
int id=readID(k, group+"auto_styles/line_style");
|
2020-09-26 21:58:58 +08:00
|
|
|
if (id>=0) {
|
|
|
|
defaultGraphPenStyles.push_back(jkqtp_String2QPenStyle(settings.value(group+"auto_styles/line_style"+QString::number(id), jkqtp_QPenStyle2String(Qt::SolidLine)).toString()));
|
|
|
|
}
|
|
|
|
|
|
|
|
id=readID(k, group+"auto_styles/symbol");
|
|
|
|
if (id>=0) {
|
|
|
|
defaultGraphSymbols.push_back(String2JKQTPGraphSymbols(settings.value(group+"auto_styles/symbol"+QString::number(id), JKQTPGraphSymbols2String(JKQTPCross)).toString()));
|
|
|
|
}
|
|
|
|
id=readID(k, group+"auto_styles/fill_style");
|
|
|
|
if (id>=0) {
|
2024-01-22 05:20:33 +08:00
|
|
|
defaultGraphFillStyles.push_back(JKQTFillStyleSummmary::fromString(settings.value(group+"auto_styles/fill_style"+QString::number(id), jkqtp_QBrushStyle2String(Qt::SolidPattern)).toString()));
|
2020-09-26 21:58:58 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (defaultGraphColors.size()==0) {
|
2023-07-26 04:20:00 +08:00
|
|
|
for (int i=0; i<defaultStyle.defaultGraphColors.size(); i++) {
|
2020-09-26 21:58:58 +08:00
|
|
|
defaultGraphColors.push_back(defaultStyle.defaultGraphColors[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (defaultGraphPenStyles.size()==0) {
|
2023-07-26 04:20:00 +08:00
|
|
|
for (int i=0; i<defaultStyle.defaultGraphPenStyles.size(); i++) {
|
2020-09-26 21:58:58 +08:00
|
|
|
defaultGraphPenStyles.push_back(defaultStyle.defaultGraphPenStyles[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (defaultGraphSymbols.size()==0) {
|
2023-07-26 04:20:00 +08:00
|
|
|
for (int i=0; i<defaultStyle.defaultGraphSymbols.size(); i++) {
|
2020-09-26 21:58:58 +08:00
|
|
|
defaultGraphSymbols.push_back(defaultStyle.defaultGraphSymbols[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (defaultGraphFillStyles.size()==0) {
|
2023-07-26 04:20:00 +08:00
|
|
|
for (int i=0; i<defaultStyle.defaultGraphFillStyles.size(); i++) {
|
2020-09-26 21:58:58 +08:00
|
|
|
defaultGraphFillStyles.push_back(defaultStyle.defaultGraphFillStyles[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
defaultGraphStyle.loadSettings(settings, group+"graphs_base/", JKQTGraphsSpecificStyleProperties(JKQTPPlotStyleType::Default, parent));
|
2022-09-27 07:42:54 +08:00
|
|
|
barchartStyle.loadSettings(settings, group+"graphs_barchart/", JKQTBarchartSpecificStyleProperties(parent, defaultGraphStyle));
|
2020-09-27 22:11:58 +08:00
|
|
|
boxplotStyle.loadSettings(settings, group+"graphs_boxplot/", JKQTGraphsSpecificStyleProperties(JKQTPPlotStyleType::Boxplot, defaultGraphStyle));
|
|
|
|
filledStyle.loadSettings(settings, group+"graphs_filled/", JKQTGraphsSpecificStyleProperties(JKQTPPlotStyleType::Filled, defaultGraphStyle));
|
2022-11-01 03:34:01 +08:00
|
|
|
impulseStyle.loadSettings(settings, group+"graphs_impulses/", JKQTImpulseSpecificStyleProperties(parent, defaultGraphStyle));
|
2020-09-26 21:58:58 +08:00
|
|
|
geometricStyle.loadSettings(settings, group+"graphs_geometric/", JKQTGeometricSpecificStyleProperties(parent, defaultGraphStyle));
|
|
|
|
annotationStyle.loadSettings(settings, group+"graphs_annotation/", JKQTAnnotationsSpecificStyleProperties(parent, defaultGraphStyle));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTGraphsBaseStyle::saveSettings(QSettings &settings, const QString &group) const
|
|
|
|
{
|
|
|
|
|
|
|
|
settings.setValue(group+"antialiase", useAntiAliasingForGraphs);
|
|
|
|
settings.setValue(group+"palette", JKQTPImageTools::JKQTPMathImageColorPalette2String(defaultPalette));
|
|
|
|
|
|
|
|
|
2023-07-26 04:20:00 +08:00
|
|
|
bool saveSingleColors=true;
|
|
|
|
for (int pali=0; pali<static_cast<int>(JKQTPMathImagePREDEFINED_PALETTES_COUNT); pali++ ) {
|
|
|
|
const JKQTPMathImageColorPalette pal=static_cast<JKQTPMathImageColorPalette>(pali);
|
|
|
|
if (defaultGraphColors==JKQTPImageTools::getColorsforPalette(pal)) {
|
|
|
|
settings.setValue(group+"auto_styles/use_color_from_palette", JKQTPImageTools::JKQTPMathImageColorPalette2String(pal));
|
|
|
|
saveSingleColors=false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (saveSingleColors && defaultGraphColors==getDefaultGraphColors()) {
|
|
|
|
settings.setValue(group+"auto_styles/use_default_colors", true);
|
|
|
|
saveSingleColors=false;
|
2020-09-26 21:58:58 +08:00
|
|
|
}
|
2023-07-26 04:20:00 +08:00
|
|
|
if (saveSingleColors) {
|
|
|
|
const QString maxnum=QString::number(defaultGraphColors.size());
|
|
|
|
int cnt=0;
|
|
|
|
for (auto& gs: defaultGraphColors) {
|
|
|
|
QString num=QString::number(cnt);
|
|
|
|
while (num.size()<maxnum.size()) num.prepend('0');
|
|
|
|
settings.setValue(group+"auto_styles/color"+num, jkqtp_QColor2String(gs));
|
|
|
|
cnt++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
const QString maxnum=QString::number(defaultGraphPenStyles.size());
|
|
|
|
int cnt=0;
|
|
|
|
for (auto& gs: defaultGraphPenStyles) {
|
|
|
|
QString num=QString::number(cnt);
|
|
|
|
while (num.size()<maxnum.size()) num.prepend('0');
|
|
|
|
settings.setValue(group+"auto_styles/line_style"+num, jkqtp_QPenStyle2String(gs));
|
|
|
|
cnt++;
|
|
|
|
}
|
2020-09-26 21:58:58 +08:00
|
|
|
}
|
2023-07-26 04:20:00 +08:00
|
|
|
bool saveSingleSymbols=true;
|
|
|
|
if (defaultGraphSymbols==getDefaultGraphSymbols()) {
|
|
|
|
settings.setValue(group+"auto_styles/use_default_symbols", true);
|
|
|
|
saveSingleSymbols=false;
|
2020-09-26 21:58:58 +08:00
|
|
|
}
|
2023-07-26 04:20:00 +08:00
|
|
|
if (saveSingleSymbols) {
|
|
|
|
int cnt=0;
|
|
|
|
const QString maxnum=QString::number(defaultGraphSymbols.size());
|
|
|
|
for (auto& gs: defaultGraphSymbols) {
|
|
|
|
QString num=QString::number(cnt);
|
|
|
|
while (num.size()<maxnum.size()) num.prepend('0');
|
|
|
|
settings.setValue(group+"auto_styles/symbol"+num, JKQTPGraphSymbols2String(gs));
|
|
|
|
cnt++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
const QString maxnum=QString::number(defaultGraphFillStyles.size());
|
|
|
|
int cnt=0;
|
|
|
|
for (auto& gs: defaultGraphFillStyles) {
|
|
|
|
QString num=QString::number(cnt);
|
|
|
|
while (num.size()<maxnum.size()) num.prepend('0');
|
2024-01-22 05:20:33 +08:00
|
|
|
settings.setValue(group+"auto_styles/fill_style"+num, jkqtp_QBrushStyle2String(gs.brushStyle));
|
2023-07-26 04:20:00 +08:00
|
|
|
cnt++;
|
|
|
|
}
|
2020-09-26 21:58:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
defaultGraphStyle.saveSettings(settings, group+"graphs_base/");
|
|
|
|
barchartStyle.saveSettings(settings, group+"graphs_barchart/");
|
|
|
|
boxplotStyle.saveSettings(settings, group+"graphs_boxplot/");
|
|
|
|
filledStyle.saveSettings(settings, group+"graphs_filled/");
|
|
|
|
impulseStyle.saveSettings(settings, group+"graphs_impulses/");
|
|
|
|
geometricStyle.saveSettings(settings, group+"graphs_geometric/");
|
|
|
|
annotationStyle.saveSettings(settings, group+"graphs_annotation/");
|
|
|
|
}
|
|
|
|
|
|
|
|
const JKQTGraphsSpecificStyleProperties &JKQTGraphsBaseStyle::getGraphStyleByType(JKQTPPlotStyleType type) const
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case JKQTPPlotStyleType::Default:
|
|
|
|
return defaultGraphStyle;
|
|
|
|
case JKQTPPlotStyleType::Barchart:
|
|
|
|
return barchartStyle;
|
|
|
|
case JKQTPPlotStyleType::Boxplot:
|
|
|
|
return boxplotStyle;
|
|
|
|
case JKQTPPlotStyleType::Filled:
|
|
|
|
return filledStyle;
|
|
|
|
case JKQTPPlotStyleType::Impulses:
|
|
|
|
return impulseStyle;
|
|
|
|
case JKQTPPlotStyleType::Geometric:
|
|
|
|
return geometricStyle;
|
|
|
|
case JKQTPPlotStyleType::Annotation:
|
|
|
|
return annotationStyle;
|
|
|
|
}
|
|
|
|
return defaultGraphStyle;
|
|
|
|
}
|
2022-09-27 07:42:54 +08:00
|
|
|
|
|
|
|
|
2023-07-26 04:20:00 +08:00
|
|
|
|
2022-09-27 07:42:54 +08:00
|
|
|
JKQTBarchartSpecificStyleProperties::JKQTBarchartSpecificStyleProperties(const JKQTBasePlotterStyle& parent):
|
|
|
|
JKQTGraphsSpecificStyleProperties(JKQTPPlotStyleType::Barchart, parent),
|
|
|
|
defaultRectRadiusAtValue(0),
|
2022-11-01 03:34:01 +08:00
|
|
|
defaultRectRadiusAtBaseline(0),
|
|
|
|
drawBaseline(false)
|
2022-09-27 07:42:54 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-01-23 20:09:37 +08:00
|
|
|
JKQTBarchartSpecificStyleProperties::JKQTBarchartSpecificStyleProperties(const JKQTBasePlotterStyle& /*parent*/, const JKQTGraphsSpecificStyleProperties &other):
|
2022-09-27 07:42:54 +08:00
|
|
|
JKQTGraphsSpecificStyleProperties(JKQTPPlotStyleType::Barchart, other),
|
|
|
|
defaultRectRadiusAtValue(0),
|
2022-11-01 03:34:01 +08:00
|
|
|
defaultRectRadiusAtBaseline(0),
|
|
|
|
drawBaseline(false)
|
2022-09-27 07:42:54 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTBarchartSpecificStyleProperties::loadSettings(const QSettings &settings, const QString &group, const JKQTBarchartSpecificStyleProperties &defaultStyle)
|
|
|
|
{
|
|
|
|
JKQTGraphsSpecificStyleProperties::loadSettings(settings, group, defaultStyle);
|
|
|
|
defaultRectRadiusAtValue=settings.value(group+"radius_at_value", defaultStyle.defaultRectRadiusAtValue).toDouble();
|
|
|
|
defaultRectRadiusAtBaseline=settings.value(group+"radius_at_baseline", defaultStyle.defaultRectRadiusAtBaseline).toDouble();
|
2022-11-01 03:34:01 +08:00
|
|
|
drawBaseline=settings.value(group+"draw_baseline", defaultStyle.drawBaseline).toBool();
|
2022-09-27 07:42:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTBarchartSpecificStyleProperties::saveSettings(QSettings &settings, const QString &group) const
|
|
|
|
{
|
|
|
|
JKQTGraphsSpecificStyleProperties::saveSettings(settings, group);
|
|
|
|
settings.setValue(group+"radius_at_value", defaultRectRadiusAtValue);
|
|
|
|
settings.setValue(group+"radius_at_baseline", defaultRectRadiusAtBaseline);
|
2022-11-01 03:34:01 +08:00
|
|
|
settings.setValue(group+"draw_baseline", drawBaseline);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
JKQTImpulseSpecificStyleProperties::JKQTImpulseSpecificStyleProperties(const JKQTBasePlotterStyle& parent):
|
|
|
|
JKQTGraphsSpecificStyleProperties(JKQTPPlotStyleType::Impulses, parent),
|
|
|
|
drawBaseline(false)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-01-23 20:09:37 +08:00
|
|
|
JKQTImpulseSpecificStyleProperties::JKQTImpulseSpecificStyleProperties(const JKQTBasePlotterStyle& /*parent*/, const JKQTGraphsSpecificStyleProperties &other):
|
2022-11-01 03:34:01 +08:00
|
|
|
JKQTGraphsSpecificStyleProperties(JKQTPPlotStyleType::Impulses, other),
|
|
|
|
drawBaseline(false)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTImpulseSpecificStyleProperties::loadSettings(const QSettings &settings, const QString &group, const JKQTImpulseSpecificStyleProperties &defaultStyle)
|
|
|
|
{
|
|
|
|
JKQTGraphsSpecificStyleProperties::loadSettings(settings, group, defaultStyle);
|
|
|
|
drawBaseline=settings.value(group+"draw_baseline", defaultStyle.drawBaseline).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTImpulseSpecificStyleProperties::saveSettings(QSettings &settings, const QString &group) const
|
|
|
|
{
|
|
|
|
JKQTGraphsSpecificStyleProperties::saveSettings(settings, group);
|
|
|
|
settings.setValue(group+"draw_baseline", drawBaseline);
|
2022-09-27 07:42:54 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-01-22 05:20:33 +08:00
|
|
|
|
2024-01-23 20:09:37 +08:00
|
|
|
JKQTFillStyleSummmary::JKQTFillStyleSummmary(Qt::BrushStyle style, const QGradient& grad):
|
|
|
|
brushStyle(style), gradient(grad)
|
2024-01-22 05:20:33 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
QBrush JKQTFillStyleSummmary::brush(const QColor &color) const
|
|
|
|
{
|
|
|
|
QBrush b;
|
|
|
|
b.setColor(color);
|
|
|
|
if (brushStyle==Qt::LinearGradientPattern || brushStyle==Qt::RadialGradientPattern || brushStyle==Qt::ConicalGradientPattern) {
|
|
|
|
QGradient g=gradient;
|
2024-01-23 04:31:09 +08:00
|
|
|
JKQTPReplaceCurrentColor(g, color);
|
2024-01-22 05:20:33 +08:00
|
|
|
g.setCoordinateMode(QGradient::ObjectMode);
|
|
|
|
b=QBrush(g);
|
|
|
|
} else {
|
|
|
|
b.setStyle(brushStyle);
|
|
|
|
}
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTFillStyleSummmary JKQTFillStyleSummmary::fromString(const QString &style)
|
|
|
|
{
|
|
|
|
JKQTFillStyleSummmary res;
|
2024-01-23 20:09:37 +08:00
|
|
|
res.brushStyle=jkqtp_String2QBrushStyleExt(style, &(res.gradient), &(res.texture));
|
2024-01-22 05:20:33 +08:00
|
|
|
return res;
|
|
|
|
}
|
2024-01-23 04:31:09 +08:00
|
|
|
|
|
|
|
QString JKQTFillStyleSummmary::toCSSString() const
|
|
|
|
{
|
|
|
|
return jkqtp_QBrushStyle2String(brushStyle);
|
|
|
|
}
|