mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-24 17:41:39 +08:00
NEW allow linear-gradient()... in brush definitions of style.ini-file
This commit is contained in:
parent
eb7a068fb7
commit
e5821eee3f
@ -304,7 +304,7 @@ inline void buildLineSymbolSampler(JKQTBasePlotter* plotExtra, JKQTBasePlotter*
|
|||||||
double dx=(xmax-xlineend-1.0)/static_cast<double>(cntFillTests);
|
double dx=(xmax-xlineend-1.0)/static_cast<double>(cntFillTests);
|
||||||
for (int i=0; i<cntFillTests; i++) {
|
for (int i=0; i<cntFillTests; i++) {
|
||||||
const auto col=baseplot->getCurrentPlotterStyle().graphsStyle.defaultGraphColors.value(i%baseplot->getCurrentPlotterStyle().graphsStyle.defaultGraphColors.size(), Qt::black);
|
const auto col=baseplot->getCurrentPlotterStyle().graphsStyle.defaultGraphColors.value(i%baseplot->getCurrentPlotterStyle().graphsStyle.defaultGraphColors.size(), Qt::black);
|
||||||
const auto fs=baseplot->getCurrentPlotterStyle().graphsStyle.defaultGraphFillStyles.value(i%baseplot->getCurrentPlotterStyle().graphsStyle.defaultGraphFillStyles.size(), Qt::SolidPattern);
|
const auto fs=baseplot->getCurrentPlotterStyle().graphsStyle.defaultGraphFillStyles.value(i%baseplot->getCurrentPlotterStyle().graphsStyle.defaultGraphFillStyles.size(), JKQTFillStyleSummmary(Qt::SolidPattern));
|
||||||
JKQTPGeoLine* l;
|
JKQTPGeoLine* l;
|
||||||
plotExtra->addGraph(l=new JKQTPGeoLine(plotExtra, x,ycoltest,x,y-0.5)); l->setStyle(col,5);
|
plotExtra->addGraph(l=new JKQTPGeoLine(plotExtra, x,ycoltest,x,y-0.5)); l->setStyle(col,5);
|
||||||
JKQTPGeoRectangle* r;
|
JKQTPGeoRectangle* r;
|
||||||
|
@ -115,6 +115,14 @@ void JKQTPGeoBaseFilled::setStyle(QColor color, double lineWidth, Qt::PenStyle s
|
|||||||
setFillStyle(fillStyle);
|
setFillStyle(fillStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JKQTPGeoBaseFilled::setStyle(QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, const JKQTFillStyleSummmary &fillStyle)
|
||||||
|
{
|
||||||
|
setLineColor(color);
|
||||||
|
setLineWidth(lineWidth);
|
||||||
|
setLineStyle(style);
|
||||||
|
setFillBrush(fillStyle.brush(fillColor));
|
||||||
|
}
|
||||||
|
|
||||||
void JKQTPGeoBaseFilled::setStyle(QColor color, double lineWidth, Qt::PenStyle style)
|
void JKQTPGeoBaseFilled::setStyle(QColor color, double lineWidth, Qt::PenStyle style)
|
||||||
{
|
{
|
||||||
setLineColor(color);
|
setLineColor(color);
|
||||||
|
@ -193,6 +193,8 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGeoBaseFilled: public JKQTPGeoBaseLine, public
|
|||||||
/** \brief set several of the style properties with one call */
|
/** \brief set several of the style properties with one call */
|
||||||
virtual void setStyle(QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle) ;
|
virtual void setStyle(QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle) ;
|
||||||
/** \brief set several of the style properties with one call */
|
/** \brief set several of the style properties with one call */
|
||||||
|
virtual void setStyle(QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, const JKQTFillStyleSummmary& fillStyle) ;
|
||||||
|
/** \brief set several of the style properties with one call */
|
||||||
virtual void setStyle(QColor color, double lineWidth, Qt::PenStyle style) override;
|
virtual void setStyle(QColor color, double lineWidth, Qt::PenStyle style) override;
|
||||||
/** \brief set several of the style properties with one call */
|
/** \brief set several of the style properties with one call */
|
||||||
virtual void setStyle(QColor color, Qt::PenStyle style) override;
|
virtual void setStyle(QColor color, Qt::PenStyle style) override;
|
||||||
|
@ -1151,21 +1151,21 @@ JKQTBasePlotter::JKQTPPen JKQTBasePlotter::getPlotStyle(int i, JKQTPPlotStyleTyp
|
|||||||
//std::cout<<"style "<<styleI<<std::endl;
|
//std::cout<<"style "<<styleI<<std::endl;
|
||||||
const JKQTGraphsSpecificStyleProperties& baseProps=plotterStyle.graphsStyle.getGraphStyleByType(type);
|
const JKQTGraphsSpecificStyleProperties& baseProps=plotterStyle.graphsStyle.getGraphStyleByType(type);
|
||||||
Qt::PenStyle basePenStyle=plotterStyle.graphsStyle.defaultGraphPenStyles[styleI];
|
Qt::PenStyle basePenStyle=plotterStyle.graphsStyle.defaultGraphPenStyles[styleI];
|
||||||
Qt::BrushStyle basebrushStyle=plotterStyle.graphsStyle.defaultGraphFillStyles[brushI];
|
JKQTFillStyleSummmary basebrushStyle=plotterStyle.graphsStyle.defaultGraphFillStyles[brushI];
|
||||||
JKQTPGraphSymbols baseSymbol=plotterStyle.graphsStyle.defaultGraphSymbols[symbolI];
|
JKQTPGraphSymbols baseSymbol=plotterStyle.graphsStyle.defaultGraphSymbols[symbolI];
|
||||||
QColor baseColor=plotterStyle.graphsStyle.defaultGraphColors[colorI];
|
QColor baseColor=plotterStyle.graphsStyle.defaultGraphColors[colorI];
|
||||||
double baseWidth=baseProps.defaultLineWidth;
|
double baseWidth=baseProps.defaultLineWidth;
|
||||||
if (type==JKQTPPlotStyleType::Annotation || type==JKQTPPlotStyleType::Geometric) {
|
if (type==JKQTPPlotStyleType::Annotation || type==JKQTPPlotStyleType::Geometric) {
|
||||||
baseColor=plotterStyle.graphsStyle.annotationStyle.defaultColor;
|
baseColor=plotterStyle.graphsStyle.annotationStyle.defaultColor;
|
||||||
basePenStyle=plotterStyle.graphsStyle.annotationStyle.defaultLineStyle;
|
basePenStyle=plotterStyle.graphsStyle.annotationStyle.defaultLineStyle;
|
||||||
basebrushStyle=plotterStyle.graphsStyle.annotationStyle.defaultFillStyle;
|
basebrushStyle=JKQTFillStyleSummmary(plotterStyle.graphsStyle.annotationStyle.defaultFillStyle);
|
||||||
baseSymbol=plotterStyle.graphsStyle.annotationStyle.defaultSymbol;
|
baseSymbol=plotterStyle.graphsStyle.annotationStyle.defaultSymbol;
|
||||||
}
|
}
|
||||||
if (type==JKQTPPlotStyleType::Barchart || type==JKQTPPlotStyleType::Boxplot || type==JKQTPPlotStyleType::Impulses) {
|
if (type==JKQTPPlotStyleType::Barchart || type==JKQTPPlotStyleType::Boxplot || type==JKQTPPlotStyleType::Impulses) {
|
||||||
basePenStyle=Qt::SolidLine;
|
basePenStyle=Qt::SolidLine;
|
||||||
}
|
}
|
||||||
if (type==JKQTPPlotStyleType::Boxplot) {
|
if (type==JKQTPPlotStyleType::Boxplot) {
|
||||||
basebrushStyle=Qt::SolidPattern;
|
basebrushStyle=JKQTFillStyleSummmary(Qt::SolidPattern);
|
||||||
}
|
}
|
||||||
if (type==JKQTPPlotStyleType::Impulses) {
|
if (type==JKQTPPlotStyleType::Impulses) {
|
||||||
}
|
}
|
||||||
@ -4965,7 +4965,7 @@ void JKQTBasePlotter::JKQTPPen::setErrorLineColor(const QColor &col)
|
|||||||
m_errorColor=col;
|
m_errorColor=col;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTBasePlotter::JKQTPPen::setFillStyle(Qt::BrushStyle s) {
|
void JKQTBasePlotter::JKQTPPen::setFillStyle(const JKQTFillStyleSummmary &s) {
|
||||||
m_fillStyle=s;
|
m_fillStyle=s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4977,7 +4977,7 @@ void JKQTBasePlotter::JKQTPPen::setSymbolFillColor(QColor c) {
|
|||||||
m_symbolFillColor=c;
|
m_symbolFillColor=c;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::BrushStyle JKQTBasePlotter::JKQTPPen::fillStyle() const {
|
JKQTFillStyleSummmary JKQTBasePlotter::JKQTPPen::fillStyle() const {
|
||||||
return m_fillStyle;
|
return m_fillStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -773,7 +773,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
|
|||||||
double m_symbolLineWidth;
|
double m_symbolLineWidth;
|
||||||
Qt::PenStyle m_style;
|
Qt::PenStyle m_style;
|
||||||
double m_symbolSize;
|
double m_symbolSize;
|
||||||
Qt::BrushStyle m_fillStyle;
|
JKQTFillStyleSummmary m_fillStyle;
|
||||||
Qt::BrushStyle m_errorFillStyle;
|
Qt::BrushStyle m_errorFillStyle;
|
||||||
JKQTPGraphSymbols m_symbol;
|
JKQTPGraphSymbols m_symbol;
|
||||||
|
|
||||||
@ -800,9 +800,9 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
|
|||||||
void setFillColor(const QColor& col);
|
void setFillColor(const QColor& col);
|
||||||
void setErrorFillColor(const QColor& col);
|
void setErrorFillColor(const QColor& col);
|
||||||
void setErrorLineColor(const QColor& col);
|
void setErrorLineColor(const QColor& col);
|
||||||
void setFillStyle(Qt::BrushStyle s);
|
void setFillStyle(const JKQTFillStyleSummmary& s);
|
||||||
void setErrorFillStyle(Qt::BrushStyle s);
|
void setErrorFillStyle(Qt::BrushStyle s);
|
||||||
Qt::BrushStyle fillStyle() const;
|
JKQTFillStyleSummmary fillStyle() const;
|
||||||
Qt::BrushStyle errorFillStyle() const;
|
Qt::BrushStyle errorFillStyle() const;
|
||||||
JKQTPGraphSymbols symbol() const;
|
JKQTPGraphSymbols symbol() const;
|
||||||
void setSymbolType(JKQTPGraphSymbols symbol);
|
void setSymbolType(JKQTPGraphSymbols symbol);
|
||||||
|
@ -236,9 +236,9 @@ QVector<JKQTPGraphSymbols> JKQTGraphsBaseStyle::getDefaultGraphSymbols()
|
|||||||
return syms;
|
return syms;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<Qt::BrushStyle> JKQTGraphsBaseStyle::getDefaultGraphFillStyles()
|
QVector<JKQTFillStyleSummmary> JKQTGraphsBaseStyle::getDefaultGraphFillStyles()
|
||||||
{
|
{
|
||||||
return QVector<Qt::BrushStyle>()<<Qt::SolidPattern;
|
return QVector<JKQTFillStyleSummmary>()<<JKQTFillStyleSummmary(Qt::SolidPattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQTGraphsBaseStyle::loadSettings(const QSettings &settings, const QString &group, const JKQTGraphsBaseStyle &defaultStyle, const JKQTBasePlotterStyle& parent)
|
void JKQTGraphsBaseStyle::loadSettings(const QSettings &settings, const QString &group, const JKQTGraphsBaseStyle &defaultStyle, const JKQTBasePlotterStyle& parent)
|
||||||
@ -302,7 +302,7 @@ void JKQTGraphsBaseStyle::loadSettings(const QSettings &settings, const QString
|
|||||||
}
|
}
|
||||||
id=readID(k, group+"auto_styles/fill_style");
|
id=readID(k, group+"auto_styles/fill_style");
|
||||||
if (id>=0) {
|
if (id>=0) {
|
||||||
defaultGraphFillStyles.push_back(jkqtp_String2QBrushStyle(settings.value(group+"auto_styles/fill_style"+QString::number(id), jkqtp_QBrushStyle2String(Qt::SolidPattern)).toString()));
|
defaultGraphFillStyles.push_back(JKQTFillStyleSummmary::fromString(settings.value(group+"auto_styles/fill_style"+QString::number(id), jkqtp_QBrushStyle2String(Qt::SolidPattern)).toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (defaultGraphColors.size()==0) {
|
if (defaultGraphColors.size()==0) {
|
||||||
@ -398,7 +398,7 @@ void JKQTGraphsBaseStyle::saveSettings(QSettings &settings, const QString &group
|
|||||||
for (auto& gs: defaultGraphFillStyles) {
|
for (auto& gs: defaultGraphFillStyles) {
|
||||||
QString num=QString::number(cnt);
|
QString num=QString::number(cnt);
|
||||||
while (num.size()<maxnum.size()) num.prepend('0');
|
while (num.size()<maxnum.size()) num.prepend('0');
|
||||||
settings.setValue(group+"auto_styles/fill_style"+num, jkqtp_QBrushStyle2String(gs));
|
settings.setValue(group+"auto_styles/fill_style"+num, jkqtp_QBrushStyle2String(gs.brushStyle));
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -499,3 +499,30 @@ void JKQTImpulseSpecificStyleProperties::saveSettings(QSettings &settings, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
JKQTFillStyleSummmary::JKQTFillStyleSummmary(Qt::BrushStyle style, const QGradient& grad, double rotAngleDeg):
|
||||||
|
brushStyle(style), gradient(grad), rotationAngleDeg(rotAngleDeg)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
g.setCoordinateMode(QGradient::ObjectMode);
|
||||||
|
b=QBrush(g);
|
||||||
|
} else {
|
||||||
|
b.setStyle(brushStyle);
|
||||||
|
}
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
JKQTFillStyleSummmary JKQTFillStyleSummmary::fromString(const QString &style)
|
||||||
|
{
|
||||||
|
JKQTFillStyleSummmary res;
|
||||||
|
res.brushStyle=jkqtp_String2QBrushStyleExt(style, nullptr, &(res.gradient), nullptr, &(res.rotationAngleDeg));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
@ -291,6 +291,29 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** \brief Support Class for JKQTBasePlotter, which summarizes a fill style
|
||||||
|
* \ingroup jkqtpplotter_styling_classes
|
||||||
|
*
|
||||||
|
* \see JKQTBasePlotter, JKQTGraphsBaseStyle, \ref jkqtpplotter_styling
|
||||||
|
*/
|
||||||
|
class JKQTPLOTTER_LIB_EXPORT JKQTFillStyleSummmary {
|
||||||
|
#ifndef JKQTPLOTTER_WORKAROUND_QGADGET_BUG
|
||||||
|
Q_GADGET
|
||||||
|
#endif
|
||||||
|
public:
|
||||||
|
JKQTFillStyleSummmary(Qt::BrushStyle style=Qt::SolidPattern, const QGradient& grad=QGradient(), double rotAngleDeg=0.0);
|
||||||
|
|
||||||
|
Qt::BrushStyle brushStyle;
|
||||||
|
QGradient gradient;
|
||||||
|
double rotationAngleDeg;
|
||||||
|
|
||||||
|
QBrush brush(const QColor& color=QColor(Qt::black)) const;
|
||||||
|
|
||||||
|
static JKQTFillStyleSummmary fromString(const QString& style);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/** \brief Support Class for JKQTBasePlotter, which summarizes all properties that define the visual styling of a JKQTBasePlotter
|
/** \brief Support Class for JKQTBasePlotter, which summarizes all properties that define the visual styling of a JKQTBasePlotter
|
||||||
* \ingroup jkqtpplotter_styling_classes
|
* \ingroup jkqtpplotter_styling_classes
|
||||||
*
|
*
|
||||||
@ -358,7 +381,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTGraphsBaseStyle {
|
|||||||
/** \brief JKQTPGraphSymbols used to automatically assign to different graphs */
|
/** \brief JKQTPGraphSymbols used to automatically assign to different graphs */
|
||||||
QVector<JKQTPGraphSymbols> defaultGraphSymbols;
|
QVector<JKQTPGraphSymbols> defaultGraphSymbols;
|
||||||
/** \brief Qt::BrushStyle used to automatically style different graphs differently */
|
/** \brief Qt::BrushStyle used to automatically style different graphs differently */
|
||||||
QVector<Qt::BrushStyle> defaultGraphFillStyles;
|
QVector<JKQTFillStyleSummmary> defaultGraphFillStyles;
|
||||||
|
|
||||||
/** \brief standard color palette for the default style */
|
/** \brief standard color palette for the default style */
|
||||||
static QVector<QColor> getDefaultGraphColors();
|
static QVector<QColor> getDefaultGraphColors();
|
||||||
@ -367,7 +390,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTGraphsBaseStyle {
|
|||||||
/** \brief list of JKQTPGraphSymbols used to automatically assign to different graphs in the default style */
|
/** \brief list of JKQTPGraphSymbols used to automatically assign to different graphs in the default style */
|
||||||
static QVector<JKQTPGraphSymbols> getDefaultGraphSymbols();
|
static QVector<JKQTPGraphSymbols> getDefaultGraphSymbols();
|
||||||
/** \brief list of Qt::BrushStyle used to automatically style different graphs differently in the default style */
|
/** \brief list of Qt::BrushStyle used to automatically style different graphs differently in the default style */
|
||||||
static QVector<Qt::BrushStyle> getDefaultGraphFillStyles();
|
static QVector<JKQTFillStyleSummmary> getDefaultGraphFillStyles();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -398,8 +398,7 @@ void JKQTPGraphFillStyleMixin::initFillStyle(JKQTBasePlotter *parent, int &paren
|
|||||||
if (parentPlotStyle<0) parentPlotStyle=parent->getNextStyle();
|
if (parentPlotStyle<0) parentPlotStyle=parent->getNextStyle();
|
||||||
const JKQTBasePlotter::JKQTPPen pen=parent->getPlotStyle(parentPlotStyle, styletype);
|
const JKQTBasePlotter::JKQTPPen pen=parent->getPlotStyle(parentPlotStyle, styletype);
|
||||||
m_fillColor=pen.fillColor();
|
m_fillColor=pen.fillColor();
|
||||||
m_fillBrush.setColor(m_fillColor);
|
m_fillBrush=pen.fillStyle().brush(m_fillColor);
|
||||||
m_fillBrush.setStyle(pen.fillStyle());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user