#include "jkqtpgraphsbasestyle.h" #include #include #include "jkqtplotter/jkqtptools.h" #include "jkqtplotter/jkqtpbaseplotterstyle.h" JKQTGraphsSpecificStyleProperties::JKQTGraphsSpecificStyleProperties(JKQTPPlotStyleType type, const JKQTBasePlotterStyle &/*parent*/): defaultLineWidth(2), defaultSymbolSize(10), defaultSymbolLineWidth(1), defaultErrorIndicatorWidth(1), defaultHeadDecoratorStyle(JKQTPLineDecoratorStyle::JKQTPDefaultLineDecorator), defaultHeadDecoratorSizeFactor(8.0), errorFillStyle(Qt::SolidPattern), graphColorDerivationMode(JKQTPColorDerivationMode::JKQTPFFCMSameColor), fillColorDerivationMode(JKQTPColorDerivationMode::JKQTPFFCMLighterColor), errorColorDerivationMode(JKQTPColorDerivationMode::JKQTPFFCMDarkerColor), errorFillColorDerivationMode(JKQTPColorDerivationMode::JKQTPFFCMLighterAndTransparentColor), symbolFillColorDerivationMode(JKQTPColorDerivationMode::JKQTPFFCMLighterColor) { modifyForDefaultStyle(type); } JKQTGraphsSpecificStyleProperties::JKQTGraphsSpecificStyleProperties(JKQTPPlotStyleType type, const JKQTGraphsSpecificStyleProperties &other): JKQTGraphsSpecificStyleProperties(other) { modifyForDefaultStyle(type); } void JKQTGraphsSpecificStyleProperties::modifyForDefaultStyle(JKQTPPlotStyleType type) { switch(type) { case JKQTPPlotStyleType::Default: break; case JKQTPPlotStyleType::Filled: fillColorDerivationMode=JKQTPColorDerivationMode::JKQTPFFCMLighterAndTransparentColor; break; case JKQTPPlotStyleType::Impulses: defaultLineWidth=3; break; case JKQTPPlotStyleType::Barchart: defaultLineWidth=0; graphColorDerivationMode=JKQTPColorDerivationMode::JKQTPFFCMLighterColor; fillColorDerivationMode=JKQTPColorDerivationMode::JKQTPFFCMLighterColor; break; case JKQTPPlotStyleType::Boxplot: defaultLineWidth=1; fillColorDerivationMode=JKQTPColorDerivationMode::JKQTPFFCMWhite; graphColorDerivationMode=JKQTPColorDerivationMode::JKQTPFFCMSameNonTransparentColor; break; case JKQTPPlotStyleType::Annotation: graphColorDerivationMode=JKQTPColorDerivationMode::JKQTPFFCMSameNonTransparentColor; defaultSymbolSize=16; break; case JKQTPPlotStyleType::Geometric: graphColorDerivationMode=JKQTPColorDerivationMode::JKQTPFFCMSameNonTransparentColor; fillColorDerivationMode=JKQTPColorDerivationMode::JKQTPFFCMFullyTransparentColor; 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(); defaultSymbolLineWidth=settings.value(group+"symbol_line_width", defaultStyle.defaultSymbolLineWidth).toDouble(); defaultErrorIndicatorWidth=settings.value(group+"error_indicator_width", defaultStyle.defaultErrorIndicatorWidth).toDouble(); defaultHeadDecoratorStyle=String2JKQTPLineDecoratorStyle(settings.value(group+"head_decorator_type", JKQTPLineDecoratorStyle2String(defaultStyle.defaultHeadDecoratorStyle)).toString()); defaultHeadDecoratorSizeFactor=settings.value(group+"head_decorator_size_factor", defaultStyle.defaultHeadDecoratorSizeFactor).toDouble(); errorFillStyle=jkqtp_String2QBrushStyle(settings.value(group+"error_fill_style", jkqtp_QBrushStyle2String(errorFillStyle)).toString()); 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); settings.setValue(group+"symbol_line_width", defaultSymbolLineWidth); settings.setValue(group+"error_indicator_width", defaultErrorIndicatorWidth); settings.setValue(group+"head_decorator_size_factor", defaultHeadDecoratorSizeFactor); settings.setValue(group+"head_decorator_type", JKQTPLineDecoratorStyle2String(defaultHeadDecoratorStyle)); settings.setValue(group+"error_fill_style", jkqtp_QBrushStyle2String(errorFillStyle)); 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)); } 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): JKQTGraphsSpecificStyleProperties(JKQTPPlotStyleType::Geometric, other), 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) { } 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) { } void JKQTGeometricSpecificStyleProperties::loadSettings(const QSettings &settings, const QString &group, const JKQTGeometricSpecificStyleProperties &defaultStyle) { 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()); defaultFillStyle=jkqtp_String2QBrushStyle(settings.value(group+"fill_style", jkqtp_QBrushStyle2String(defaultFillStyle)).toString()); } 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)); settings.setValue(group+"fill_style", jkqtp_QBrushStyle2String(defaultFillStyle)); } JKQTAnnotationsSpecificStyleProperties::JKQTAnnotationsSpecificStyleProperties(const JKQTBasePlotterStyle& parent): JKQTGeometricSpecificStyleProperties(JKQTPPlotStyleType::Annotation, parent), defaultTextColor(parent.defaultTextColor), defaultFontSize(12), defaultFontName(parent.defaultFontName) { } JKQTAnnotationsSpecificStyleProperties::JKQTAnnotationsSpecificStyleProperties(const JKQTBasePlotterStyle& parent, const JKQTGraphsSpecificStyleProperties &other): JKQTGeometricSpecificStyleProperties(JKQTPPlotStyleType::Annotation, other, parent), 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); } JKQTGraphsBaseStyle::JKQTGraphsBaseStyle(const JKQTBasePlotterStyle& parent): useAntiAliasingForGraphs(true), defaultGraphStyle(JKQTPPlotStyleType::Default, parent), barchartStyle(JKQTPPlotStyleType::Barchart, parent), boxplotStyle(JKQTPPlotStyleType::Boxplot, parent), filledStyle(JKQTPPlotStyleType::Filled, parent), impulseStyle(JKQTPPlotStyleType::Impulses, parent), geometricStyle(parent), annotationStyle(parent), defaultPalette(JKQTPMathImageColorPalette::JKQTPMathImageMATLAB) { defaultGraphColors<(i)); defaultGraphFillStyles<=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"); 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) { defaultGraphFillStyles.push_back(jkqtp_String2QBrushStyle(settings.value(group+"auto_styles/fill_style"+QString::number(id), jkqtp_QBrushStyle2String(Qt::SolidPattern)).toString())); } } if (defaultGraphColors.size()==0) { for (int i=defaultGraphColors.size(); i