changed backgroundColor-properties for plot/widget/key to backgroundBrush, modified example to demonstrate this

This commit is contained in:
jkriege2 2019-04-24 19:33:51 +02:00
parent 1064050b65
commit 3dc56510e9
11 changed files with 276 additions and 74 deletions

View File

@ -87,8 +87,19 @@ Finally two vertical barcharts with different filling options are added:
linearG.setColorAt(1, cl12); linearG.setColorAt(1, cl12);
linearG.setCoordinateMode(QGradient::ObjectMode); linearG.setCoordinateMode(QGradient::ObjectMode);
graphBF->setFillGradient(linearG); graphBF->setFillGradient(linearG);
graphBF->setLineColor(Qt::transparent);``` graphBF->setLineColor(Qt::transparent);
```
In addition to the graph background properties, also the plot/widget/key backgrounds can be defined using a QBrush:
```.cpp
// 7. set plot background with a gradient
QLinearGradient backGrad(QPointF(0, 0), QPointF(1, 1));
backGrad.setColorAt(0, QColor("salmon"));
backGrad.setColorAt(1, QColor("white"));
backGrad.setCoordinateMode(QGradient::ObjectMode);
plot.getPlotter()->setPlotBackgroundGradient(backGrad);
```
The result looks like this: The result looks like this:

View File

@ -138,17 +138,24 @@ int main(int argc, char* argv[])
plot.addGraph(graphBE); plot.addGraph(graphBE);
plot.addGraph(graphBF); plot.addGraph(graphBF);
// 7. set axis labels // 7. set plot background with a gradient
QLinearGradient backGrad(QPointF(0, 0), QPointF(1, 1));
backGrad.setColorAt(0, QColor("salmon"));
backGrad.setColorAt(1, QColor("white"));
backGrad.setCoordinateMode(QGradient::ObjectMode);
plot.getPlotter()->setPlotBackgroundGradient(backGrad);
// 8. set axis labels
plot.getXAxis()->setAxisLabel("x axis"); plot.getXAxis()->setAxisLabel("x axis");
plot.getYAxis()->setAxisLabel("y axis"); plot.getYAxis()->setAxisLabel("y axis");
plot.setGrid(true); plot.setGrid(true);
plot.getPlotter()->setShowKey(false); plot.getPlotter()->setShowKey(false);
// 8. scale plot automatically // 9. scale plot
plot.setXY(0,11.9,-2.5,5.5); plot.setXY(0,11.9,-2.5,5.5);
// 9. show plotter and make it a decent size // 10. show plotter and make it a decent size
plot.show(); plot.show();
plot.resize(600,600); plot.resize(600,600);

View File

@ -1079,18 +1079,13 @@ void JKQTBasePlotter::drawKey(JKQTPEnhancedPainter& painter) {
// save old brushes and pens // save old brushes and pens
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
QPen pf=painter.pen(); QPen pf=painter.pen();
QBrush bf=painter.brush();
pf.setColor(plotterStyle.keyStyle.frameColor); pf.setColor(plotterStyle.keyStyle.frameColor);
pf.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, pt2px(painter, plotterStyle.keyStyle.frameWidth*lineWidthMultiplier))); pf.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, pt2px(painter, plotterStyle.keyStyle.frameWidth*lineWidthMultiplier)));
pf.setStyle(Qt::SolidLine); pf.setStyle(Qt::SolidLine);
bf.setColor(plotterStyle.keyStyle.backgroundColor);
bf.setStyle(Qt::SolidPattern); painter.setBrush(plotterStyle.keyStyle.backgroundBrush);
painter.setBrush(bf);
if (!plotterStyle.keyStyle.frameVisible) { if (!plotterStyle.keyStyle.frameVisible) {
QPen pff=pf; painter.setPen(Qt::NoPen);
pff.setColor(plotterStyle.keyStyle.backgroundColor);
pff.setWidthF(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH);
painter.setPen(pff);
} else { } else {
painter.setPen(pf); painter.setPen(pf);
} }
@ -1149,8 +1144,8 @@ void JKQTBasePlotter::drawPlot(JKQTPEnhancedPainter& painter, bool showOverlays)
// draw background // draw background
{ {
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
painter.setPen(plotterStyle.widgetBackgroundColor); painter.setPen(Qt::NoPen);
if (plotterStyle.widgetBackgroundColor!=Qt::transparent) painter.fillRect(QRectF(0,0,widgetWidth/paintMagnification, widgetHeight/paintMagnification), QBrush(plotterStyle.widgetBackgroundColor)); if (plotterStyle.widgetBackgroundBrush!=QBrush(Qt::transparent)) painter.fillRect(QRectF(0,0,widgetWidth/paintMagnification, widgetHeight/paintMagnification), plotterStyle.widgetBackgroundBrush);
} }
QRectF rPlotBack(internalPlotBorderLeft, internalPlotBorderTop, internalPlotWidth, internalPlotHeight); QRectF rPlotBack(internalPlotBorderLeft, internalPlotBorderTop, internalPlotWidth, internalPlotHeight);
painter.setRenderHint(JKQTPEnhancedPainter::NonCosmeticDefaultPen, true); painter.setRenderHint(JKQTPEnhancedPainter::NonCosmeticDefaultPen, true);
@ -1161,7 +1156,7 @@ void JKQTBasePlotter::drawPlot(JKQTPEnhancedPainter& painter, bool showOverlays)
QPen p(plotterStyle.plotFrameColor); QPen p(plotterStyle.plotFrameColor);
p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, pt2px(painter, plotterStyle.plotFrameWidth*lineWidthMultiplier))); p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, pt2px(painter, plotterStyle.plotFrameWidth*lineWidthMultiplier)));
painter.setPen(p); painter.setPen(p);
painter.setBrush(QBrush(plotterStyle.plotBackgroundColor)); painter.setBrush(plotterStyle.plotBackgroundBrush);
if (plotterStyle.plotFrameRounding<=0) { if (plotterStyle.plotFrameRounding<=0) {
painter.drawRect(rPlotBack); painter.drawRect(rPlotBack);
} else { } else {
@ -1170,10 +1165,8 @@ void JKQTBasePlotter::drawPlot(JKQTPEnhancedPainter& painter, bool showOverlays)
} else { } else {
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
painter.setBrush(QBrush(plotterStyle.plotBackgroundColor)); painter.setBrush(plotterStyle.plotBackgroundBrush);
QPen p(plotterStyle.plotBackgroundColor); painter.setPen(Qt::NoPen);
p.setWidthF(0);
painter.setPen(p);
if (plotterStyle.plotFrameRounding<=0) { if (plotterStyle.plotFrameRounding<=0) {
painter.drawRect(rPlotBack); painter.drawRect(rPlotBack);
} else { } else {
@ -1342,16 +1335,16 @@ void JKQTBasePlotter::gridPaint(JKQTPEnhancedPainter& painter, QSizeF pageRect,
} else { } else {
QList<double> fsm, lwm, pm; QList<double> fsm, lwm, pm;
QList<QColor> backg; QList<QBrush> backg;
for (int i=0; i< gridPrintingList.size(); i++) { for (int i=0; i< gridPrintingList.size(); i++) {
fsm.append(gridPrintingList[i].plotter->getFontSizeMultiplier()); fsm.append(gridPrintingList[i].plotter->getFontSizeMultiplier());
lwm.append(gridPrintingList[i].plotter->getLineWidthMultiplier()); lwm.append(gridPrintingList[i].plotter->getLineWidthMultiplier());
pm.append(gridPrintingList[i].plotter->getPaintMagnification()); pm.append(gridPrintingList[i].plotter->getPaintMagnification());
backg.append(gridPrintingList[i].plotter->getExportBackgroundColor()); backg.append(gridPrintingList[i].plotter->getExportBackgroundBrush());
gridPrintingList[i].plotter->setFontSizeMultiplier(fontSizeMultiplier); gridPrintingList[i].plotter->setFontSizeMultiplier(fontSizeMultiplier);
gridPrintingList[i].plotter->setLineWidthMultiplier(lineWidthMultiplier); gridPrintingList[i].plotter->setLineWidthMultiplier(lineWidthMultiplier);
gridPrintingList[i].plotter->setPaintMagnification(paintMagnification); gridPrintingList[i].plotter->setPaintMagnification(paintMagnification);
gridPrintingList[i].plotter->setBackgroundColor(gridPrintingList[i].plotter->getExportBackgroundColor()); gridPrintingList[i].plotter->setBackgroundBrush(gridPrintingList[i].plotter->getExportBackgroundBrush());
gridPrintingList[i].plotter->calcPlotScaling(painter); gridPrintingList[i].plotter->calcPlotScaling(painter);
} }
gridPrintingCalc(); // ensure the grid plot has been calculated gridPrintingCalc(); // ensure the grid plot has been calculated
@ -1404,7 +1397,7 @@ void JKQTBasePlotter::gridPaint(JKQTPEnhancedPainter& painter, QSizeF pageRect,
gridPrintingList[i].plotter->setFontSizeMultiplier(fsm[i]); gridPrintingList[i].plotter->setFontSizeMultiplier(fsm[i]);
gridPrintingList[i].plotter->setLineWidthMultiplier(lwm[i]); gridPrintingList[i].plotter->setLineWidthMultiplier(lwm[i]);
gridPrintingList[i].plotter->setPaintMagnification(pm[i]); gridPrintingList[i].plotter->setPaintMagnification(pm[i]);
gridPrintingList[i].plotter->setBackgroundColor(backg[i]); gridPrintingList[i].plotter->setBackgroundBrush(backg[i]);
gridPrintingList[i].plotter->redrawPlot(); gridPrintingList[i].plotter->redrawPlot();
} }
} }
@ -1517,8 +1510,8 @@ bool JKQTBasePlotter::printpreviewNew(QPaintDevice* paintDevice, bool setAbsolut
double lw=lineWidthMultiplier; double lw=lineWidthMultiplier;
double fs=fontSizeMultiplier; double fs=fontSizeMultiplier;
double oldP=paintMagnification; double oldP=paintMagnification;
QColor bc=plotterStyle.widgetBackgroundColor; QBrush bc=plotterStyle.widgetBackgroundBrush;
plotterStyle.widgetBackgroundColor=plotterStyle.exportBackgroundColor; plotterStyle.widgetBackgroundBrush=plotterStyle.exportBackgroundBrush;
lineWidthMultiplier=lineWidthPrintMultiplier; lineWidthMultiplier=lineWidthPrintMultiplier;
fontSizeMultiplier=fontSizePrintMultiplier; fontSizeMultiplier=fontSizePrintMultiplier;
exportPreviewLabel=nullptr; exportPreviewLabel=nullptr;
@ -1722,7 +1715,7 @@ bool JKQTBasePlotter::printpreviewNew(QPaintDevice* paintDevice, bool setAbsolut
printPreview=nullptr; printPreview=nullptr;
lineWidthMultiplier=lw; lineWidthMultiplier=lw;
fontSizeMultiplier=fs; fontSizeMultiplier=fs;
plotterStyle.widgetBackgroundColor=bc; plotterStyle.widgetBackgroundBrush=bc;
paintMagnification=oldP; paintMagnification=oldP;
mathText.setUseUnparsed(false); mathText.setUseUnparsed(false);
@ -1925,8 +1918,8 @@ void JKQTBasePlotter::updatePreviewLabel() {
void JKQTBasePlotter::printpreviewPaintRequested(QPrinter* printer) { void JKQTBasePlotter::printpreviewPaintRequested(QPrinter* printer) {
double lw=lineWidthMultiplier; double lw=lineWidthMultiplier;
double fs=fontSizeMultiplier; double fs=fontSizeMultiplier;
QColor bc=plotterStyle.widgetBackgroundColor; QBrush bc=plotterStyle.widgetBackgroundBrush;
plotterStyle.widgetBackgroundColor=plotterStyle.exportBackgroundColor; plotterStyle.widgetBackgroundBrush=plotterStyle.exportBackgroundBrush;
lineWidthMultiplier=lineWidthPrintMultiplier; lineWidthMultiplier=lineWidthPrintMultiplier;
fontSizeMultiplier=fontSizePrintMultiplier; fontSizeMultiplier=fontSizePrintMultiplier;
@ -1993,7 +1986,7 @@ void JKQTBasePlotter::printpreviewPaintRequested(QPrinter* printer) {
lineWidthMultiplier=lw; lineWidthMultiplier=lw;
fontSizeMultiplier=fs; fontSizeMultiplier=fs;
paintMagnification=oldpm; paintMagnification=oldpm;
plotterStyle.widgetBackgroundColor=bc; plotterStyle.widgetBackgroundBrush=bc;
} }
@ -2012,8 +2005,8 @@ void JKQTBasePlotter::printpreviewPaintRequestedNew(QPaintDevice *paintDevice)
double lw=lineWidthMultiplier; double lw=lineWidthMultiplier;
double fs=fontSizeMultiplier; double fs=fontSizeMultiplier;
QColor bc=plotterStyle.widgetBackgroundColor; QBrush bc=plotterStyle.widgetBackgroundBrush;
plotterStyle.widgetBackgroundColor=plotterStyle.exportBackgroundColor; plotterStyle.widgetBackgroundBrush=plotterStyle.exportBackgroundBrush;
lineWidthMultiplier=lineWidthPrintMultiplier; lineWidthMultiplier=lineWidthPrintMultiplier;
fontSizeMultiplier=fontSizePrintMultiplier; fontSizeMultiplier=fontSizePrintMultiplier;
@ -2095,14 +2088,14 @@ void JKQTBasePlotter::printpreviewPaintRequestedNew(QPaintDevice *paintDevice)
lineWidthMultiplier=lw; lineWidthMultiplier=lw;
fontSizeMultiplier=fs; fontSizeMultiplier=fs;
paintMagnification=oldpm; paintMagnification=oldpm;
plotterStyle.widgetBackgroundColor=bc; plotterStyle.widgetBackgroundBrush=bc;
} }
void JKQTBasePlotter::exportpreviewPaintRequested(JKQTPEnhancedPainter &painter, QSize size) { void JKQTBasePlotter::exportpreviewPaintRequested(JKQTPEnhancedPainter &painter, QSize size) {
double lw=lineWidthMultiplier; double lw=lineWidthMultiplier;
double fs=fontSizeMultiplier; double fs=fontSizeMultiplier;
QColor bc=plotterStyle.widgetBackgroundColor; QBrush bc=plotterStyle.widgetBackgroundBrush;
plotterStyle.widgetBackgroundColor=plotterStyle.exportBackgroundColor; plotterStyle.widgetBackgroundBrush=plotterStyle.exportBackgroundBrush;
lineWidthMultiplier=lineWidthPrintMultiplier; lineWidthMultiplier=lineWidthPrintMultiplier;
fontSizeMultiplier=fontSizePrintMultiplier; fontSizeMultiplier=fontSizePrintMultiplier;
bool oldEmitPlotSignals=emitPlotSignals; bool oldEmitPlotSignals=emitPlotSignals;
@ -2122,7 +2115,7 @@ void JKQTBasePlotter::exportpreviewPaintRequested(JKQTPEnhancedPainter &painter,
emitPlotSignals=oldEmitPlotSignals; emitPlotSignals=oldEmitPlotSignals;
lineWidthMultiplier=lw; lineWidthMultiplier=lw;
fontSizeMultiplier=fs; fontSizeMultiplier=fs;
plotterStyle.widgetBackgroundColor=bc; plotterStyle.widgetBackgroundBrush=bc;
} }
void JKQTBasePlotter::printpreviewSetZoom(double value) { void JKQTBasePlotter::printpreviewSetZoom(double value) {
@ -2489,33 +2482,48 @@ double JKQTBasePlotter::getGraphWidth() const
void JKQTBasePlotter::setBackgroundColor(const QColor &__value) void JKQTBasePlotter::setBackgroundColor(const QColor &__value)
{ {
if (this->plotterStyle.widgetBackgroundColor != __value) { if (this->plotterStyle.widgetBackgroundBrush != QBrush(__value)) {
this->plotterStyle.widgetBackgroundColor = __value; this->plotterStyle.widgetBackgroundBrush=QBrush(__value);
redrawPlot(); redrawPlot();
} }
} }
QColor JKQTBasePlotter::getBackgroundColor() const QColor JKQTBasePlotter::getBackgroundColor() const
{ {
return this->plotterStyle.widgetBackgroundColor; return this->plotterStyle.widgetBackgroundBrush.color();
} }
void JKQTBasePlotter::setExportBackgroundColor(const QColor &__value) void JKQTBasePlotter::setExportBackgroundColor(const QColor &__value)
{ {
if (this->plotterStyle.exportBackgroundColor != __value) { if (this->plotterStyle.exportBackgroundBrush != QBrush(__value)) {
this->plotterStyle.exportBackgroundColor = __value; this->plotterStyle.exportBackgroundBrush=QBrush(__value);
redrawPlot(); redrawPlot();
} }
} }
QColor JKQTBasePlotter::getExportBackgroundColor() const QColor JKQTBasePlotter::getExportBackgroundColor() const
{ {
return this->plotterStyle.exportBackgroundColor; return this->plotterStyle.exportBackgroundBrush.color();
} }
QColor JKQTBasePlotter::getPlotBackgroundColor() const QColor JKQTBasePlotter::getPlotBackgroundColor() const
{ {
return this->plotterStyle.plotBackgroundColor; return this->plotterStyle.plotBackgroundBrush.color();
}
QBrush JKQTBasePlotter::getBackgroundBrush() const
{
return this->plotterStyle.widgetBackgroundBrush;
}
QBrush JKQTBasePlotter::getExportBackgroundBrush() const
{
return this->plotterStyle.exportBackgroundBrush;
}
QBrush JKQTBasePlotter::getPlotBackgroundBrush() const
{
return this->plotterStyle.plotBackgroundBrush;
} }
@ -2703,14 +2711,47 @@ QColor JKQTBasePlotter::getKeyFrameColor() const
return this->plotterStyle.keyStyle.frameColor; return this->plotterStyle.keyStyle.frameColor;
} }
void JKQTBasePlotter::setKeyBackgroundColor(const QColor &__value) void JKQTBasePlotter::setKeyBackgroundColor(const QColor &__value, Qt::BrushStyle __style)
{ {
if (this->plotterStyle.keyStyle.backgroundColor != __value) { if (this->plotterStyle.keyStyle.backgroundBrush != QBrush(__value, __style)) {
this->plotterStyle.keyStyle.backgroundColor = __value; this->plotterStyle.keyStyle.backgroundBrush = QBrush(__value, __style);
redrawPlot(); redrawPlot();
} }
} }
void JKQTBasePlotter::setKeyBackgroundBrush(const QBrush &__value)
{
if (this->plotterStyle.keyStyle.backgroundBrush != __value) {
this->plotterStyle.keyStyle.backgroundBrush = __value;
redrawPlot();
}
}
void JKQTBasePlotter::setKeyBackgroundGradient(const QGradient &__value)
{
if (this->plotterStyle.keyStyle.backgroundBrush != QBrush(__value)) {
this->plotterStyle.keyStyle.backgroundBrush = QBrush(__value);
redrawPlot();
}
}
void JKQTBasePlotter::setKeyBackgroundTexture(const QImage &__value)
{
if (this->plotterStyle.keyStyle.backgroundBrush != QBrush(__value)) {
this->plotterStyle.keyStyle.backgroundBrush = QBrush(__value);
redrawPlot();
}
}
void JKQTBasePlotter::setKeyBackgroundTexture(const QPixmap &__value)
{
if (this->plotterStyle.keyStyle.backgroundBrush != QBrush(__value)) {
this->plotterStyle.keyStyle.backgroundBrush = QBrush(__value);
redrawPlot();
}
}
void JKQTBasePlotter::setKeyFrameWidth(double __value) void JKQTBasePlotter::setKeyFrameWidth(double __value)
{ {
if (this->plotterStyle.keyStyle.frameWidth != __value) { if (this->plotterStyle.keyStyle.frameWidth != __value) {
@ -2856,13 +2897,115 @@ QString JKQTBasePlotter::getPlotLabel() const
QColor JKQTBasePlotter::getKeyBackgroundColor() const QColor JKQTBasePlotter::getKeyBackgroundColor() const
{ {
return this->plotterStyle.keyStyle.backgroundColor; return this->plotterStyle.keyStyle.backgroundBrush.color();
}
QBrush JKQTBasePlotter::getKeyBackgroundBrush() const
{
return this->plotterStyle.keyStyle.backgroundBrush;
} }
void JKQTBasePlotter::setPlotBackgroundColor(const QColor &__value) void JKQTBasePlotter::setPlotBackgroundColor(const QColor &__value)
{ {
if (this->plotterStyle.plotBackgroundColor != __value) { if (this->plotterStyle.plotBackgroundBrush != QBrush(__value)) {
this->plotterStyle.plotBackgroundColor = __value; this->plotterStyle.plotBackgroundBrush=QBrush(__value);
redrawPlot();
}
}
void JKQTBasePlotter::setBackgroundBrush(const QBrush &__value)
{
if (this->plotterStyle.widgetBackgroundBrush != (__value)) {
this->plotterStyle.widgetBackgroundBrush=(__value);
redrawPlot();
}
}
void JKQTBasePlotter::setExportBackgroundBrush(const QBrush &__value)
{
if (this->plotterStyle.exportBackgroundBrush != (__value)) {
this->plotterStyle.exportBackgroundBrush=(__value);
redrawPlot();
}
}
void JKQTBasePlotter::setPlotBackgroundBrush(const QBrush &__value)
{
if (this->plotterStyle.plotBackgroundBrush != (__value)) {
this->plotterStyle.plotBackgroundBrush=(__value);
redrawPlot();
}
}
void JKQTBasePlotter::setBackgroundGradient(const QGradient &__value)
{
if (this->plotterStyle.widgetBackgroundBrush != QBrush(__value)) {
this->plotterStyle.widgetBackgroundBrush=QBrush(__value);
redrawPlot();
}
}
void JKQTBasePlotter::setExportBackgroundGradient(const QGradient &__value)
{
if (this->plotterStyle.exportBackgroundBrush != QBrush(__value)) {
this->plotterStyle.exportBackgroundBrush=QBrush(__value);
redrawPlot();
}
}
void JKQTBasePlotter::setPlotBackgroundGradient(const QGradient &__value)
{
if (this->plotterStyle.plotBackgroundBrush != QBrush(__value)) {
this->plotterStyle.plotBackgroundBrush=QBrush(__value);
redrawPlot();
}
}
void JKQTBasePlotter::setBackgroundTexture(const QPixmap &__value)
{
if (this->plotterStyle.widgetBackgroundBrush != QBrush(__value)) {
this->plotterStyle.widgetBackgroundBrush=QBrush(__value);
redrawPlot();
}
}
void JKQTBasePlotter::setExportBackgroundTexture(const QPixmap &__value)
{
if (this->plotterStyle.exportBackgroundBrush != QBrush(__value)) {
this->plotterStyle.exportBackgroundBrush=QBrush(__value);
redrawPlot();
}
}
void JKQTBasePlotter::setPlotBackgroundTexture(const QPixmap &__value)
{
if (this->plotterStyle.plotBackgroundBrush != QBrush(__value)) {
this->plotterStyle.plotBackgroundBrush=QBrush(__value);
redrawPlot();
}
}
void JKQTBasePlotter::setBackgroundTexture(const QImage &__value)
{
if (this->plotterStyle.widgetBackgroundBrush != QBrush(__value)) {
this->plotterStyle.widgetBackgroundBrush=QBrush(__value);
redrawPlot();
}
}
void JKQTBasePlotter::setExportBackgroundTexture(const QImage &__value)
{
if (this->plotterStyle.exportBackgroundBrush != QBrush(__value)) {
this->plotterStyle.exportBackgroundBrush=QBrush(__value);
redrawPlot();
}
}
void JKQTBasePlotter::setPlotBackgroundTexture(const QImage &__value)
{
if (this->plotterStyle.plotBackgroundBrush != QBrush(__value)) {
this->plotterStyle.plotBackgroundBrush=QBrush(__value);
redrawPlot(); redrawPlot();
} }
} }

View File

@ -683,12 +683,18 @@ class JKQTP_LIB_EXPORT JKQTBasePlotter: public QObject {
bool isUsingAntiAliasingForText() const; bool isUsingAntiAliasingForText() const;
/** \copydoc JKQTBasePlotterStyle:defaultGraphWidth: */ /** \copydoc JKQTBasePlotterStyle:defaultGraphWidth: */
double getGraphWidth() const; double getGraphWidth() const;
/** \copydoc JKQTBasePlotterStyle::widgetBackgroundColor */ /** \copydoc JKQTBasePlotterStyle::widgetBackgroundBrush */
QColor getBackgroundColor() const; QColor getBackgroundColor() const;
/** \copydoc JKQTBasePlotterStyle::exportBackgroundColor */ /** \copydoc JKQTBasePlotterStyle::exportBackgroundBrush */
QColor getExportBackgroundColor() const; QColor getExportBackgroundColor() const;
/** \copydoc JKQTBasePlotterStyle::plotBackgroundColor */ /** \copydoc JKQTBasePlotterStyle::plotBackgroundBrush */
QColor getPlotBackgroundColor() const; QColor getPlotBackgroundColor() const;
/** \copydoc JKQTBasePlotterStyle::widgetBackgroundBrush */
QBrush getBackgroundBrush() const;
/** \copydoc JKQTBasePlotterStyle::exportBackgroundBrush */
QBrush getExportBackgroundBrush() const;
/** \copydoc JKQTBasePlotterStyle::plotBackgroundBrush */
QBrush getPlotBackgroundBrush() const;
/*! \copydoc JKQTPKeyStyle::fontSize */ /*! \copydoc JKQTPKeyStyle::fontSize */
double getKeyFontSize() const; double getKeyFontSize() const;
/*! \copydoc JKQTPKeyStyle::itemWidth */ /*! \copydoc JKQTPKeyStyle::itemWidth */
@ -715,8 +721,11 @@ class JKQTP_LIB_EXPORT JKQTBasePlotter: public QObject {
bool getShowKeyFrame() const; bool getShowKeyFrame() const;
/*! \copydoc JKQTPKeyStyle::frameColor */ /*! \copydoc JKQTPKeyStyle::frameColor */
QColor getKeyFrameColor() const; QColor getKeyFrameColor() const;
/*! \copydoc JKQTPKeyStyle::backgroundColor */ /*! \copydoc JKQTPKeyStyle::backgroundBrush */
QColor getKeyBackgroundColor() const; QColor getKeyBackgroundColor() const;
/*! \copydoc JKQTPKeyStyle::backgroundBrush */
QBrush getKeyBackgroundBrush() const;
/*! \copydoc JKQTPKeyStyle::textColor */ /*! \copydoc JKQTPKeyStyle::textColor */
QColor getKeyTextColor() const; QColor getKeyTextColor() const;
/*! \copydoc JKQTPKeyStyle::frameWidth */ /*! \copydoc JKQTPKeyStyle::frameWidth */
@ -1611,12 +1620,36 @@ class JKQTP_LIB_EXPORT JKQTBasePlotter: public QObject {
void setUseAntiAliasingForText(bool __value); void setUseAntiAliasingForText(bool __value);
/*! \copydoc JKQTBasePlotterStyle::defaultGraphWidth */ /*! \copydoc JKQTBasePlotterStyle::defaultGraphWidth */
void setGraphWidth(double __value); void setGraphWidth(double __value);
/*! \copydoc JKQTBasePlotterStyle::widgetBackgroundColor */ /*! \copydoc JKQTBasePlotterStyle::widgetBackgroundBrush */
void setBackgroundColor(const QColor & __value); void setBackgroundColor(const QColor & __value);
/*! \copydoc JKQTBasePlotterStyle::exportBackgroundColor */ /*! \copydoc JKQTBasePlotterStyle::exportBackgroundBrush */
void setExportBackgroundColor(const QColor & __value); void setExportBackgroundColor(const QColor & __value);
/*! \copydoc JKQTBasePlotterStyle::plotBackgroundColor */ /*! \copydoc JKQTBasePlotterStyle::plotBackgroundBrush */
void setPlotBackgroundColor(const QColor & __value); void setPlotBackgroundColor(const QColor & __value);
/*! \copydoc JKQTBasePlotterStyle::widgetBackgroundBrush */
void setBackgroundBrush(const QBrush & __value);
/*! \copydoc JKQTBasePlotterStyle::exportBackgroundBrush */
void setExportBackgroundBrush(const QBrush & __value);
/*! \copydoc JKQTBasePlotterStyle::plotBackgroundBrush */
void setPlotBackgroundBrush(const QBrush & __value);
/*! \copydoc JKQTBasePlotterStyle::widgetBackgroundBrush */
void setBackgroundGradient(const QGradient & __value);
/*! \copydoc JKQTBasePlotterStyle::exportBackgroundBrush */
void setExportBackgroundGradient(const QGradient & __value);
/*! \copydoc JKQTBasePlotterStyle::plotBackgroundBrush */
void setPlotBackgroundGradient(const QGradient & __value);
/*! \copydoc JKQTBasePlotterStyle::widgetBackgroundBrush */
void setBackgroundTexture(const QPixmap & __value);
/*! \copydoc JKQTBasePlotterStyle::exportBackgroundBrush */
void setExportBackgroundTexture(const QPixmap & __value);
/*! \copydoc JKQTBasePlotterStyle::plotBackgroundBrush */
void setPlotBackgroundTexture(const QPixmap & __value);
/*! \copydoc JKQTBasePlotterStyle::widgetBackgroundBrush */
void setBackgroundTexture(const QImage & __value);
/*! \copydoc JKQTBasePlotterStyle::exportBackgroundBrush */
void setExportBackgroundTexture(const QImage & __value);
/*! \copydoc JKQTBasePlotterStyle::plotBackgroundBrush */
void setPlotBackgroundTexture(const QImage & __value);
/*! \copydoc JKQTPKeyStyle::textColor */ /*! \copydoc JKQTPKeyStyle::textColor */
void setKeyTextColor(const QColor & __value); void setKeyTextColor(const QColor & __value);
@ -1657,8 +1690,16 @@ class JKQTP_LIB_EXPORT JKQTBasePlotter: public QObject {
void setShowKeyFrame(bool __value); void setShowKeyFrame(bool __value);
/*! \copydoc JKQTPKeyStyle::frameColor */ /*! \copydoc JKQTPKeyStyle::frameColor */
void setKeyFrameColor(const QColor & __value); void setKeyFrameColor(const QColor & __value);
/*! \copydoc JKQTPKeyStyle::backgroundColor */ /*! \copydoc JKQTPKeyStyle::backgroundBrush */
void setKeyBackgroundColor(const QColor & __value); void setKeyBackgroundColor(const QColor & __value, Qt::BrushStyle __style);
/*! \copydoc JKQTPKeyStyle::backgroundBrush */
void setKeyBackgroundBrush(const QBrush & __value);
/*! \copydoc JKQTPKeyStyle::backgroundBrush */
void setKeyBackgroundGradient(const QGradient & __value);
/*! \copydoc JKQTPKeyStyle::backgroundBrush */
void setKeyBackgroundTexture(const QImage & __value);
/*! \copydoc JKQTPKeyStyle::backgroundBrush */
void setKeyBackgroundTexture(const QPixmap & __value);
/*! \copydoc JKQTPKeyStyle::frameWidth */ /*! \copydoc JKQTPKeyStyle::frameWidth */
void setKeyFrameWidth(double __value); void setKeyFrameWidth(double __value);
/*! \copydoc JKQTPKeyStyle::frameRounding */ /*! \copydoc JKQTPKeyStyle::frameRounding */

View File

@ -15,9 +15,9 @@ JKQTBasePlotterStyle::JKQTBasePlotterStyle():
defaultGraphWidth(2), defaultGraphWidth(2),
defaultGraphSymbolSize(10), defaultGraphSymbolSize(10),
defaultGraphSymbolLineWidth(1), defaultGraphSymbolLineWidth(1),
widgetBackgroundColor(QApplication::palette().color(QPalette::Window)), widgetBackgroundBrush(QApplication::palette().color(QPalette::Window)),
exportBackgroundColor(QColor("white")), exportBackgroundBrush(QColor("white")),
plotBackgroundColor(QColor("white")), plotBackgroundBrush(QColor("white")),
plotFrameColor(QColor("black")), plotFrameColor(QColor("black")),
plotFrameWidth(2), plotFrameWidth(2),
plotFrameRounding(0), plotFrameRounding(0),
@ -69,9 +69,9 @@ void JKQTBasePlotterStyle::loadSettings(const QSettings &settings, const QString
debugRegionLineWidth=settings.value(group+"debug_region_linewidth", defaultStyle.debugRegionLineWidth).toDouble(); debugRegionLineWidth=settings.value(group+"debug_region_linewidth", defaultStyle.debugRegionLineWidth).toDouble();
plotLabelFontName=settings.value(group+"plot_label_font_name", defaultStyle.plotLabelFontName).toString(); plotLabelFontName=settings.value(group+"plot_label_font_name", defaultStyle.plotLabelFontName).toString();
plotLabelFontSize=settings.value(group+"plot_label_font_size", defaultStyle.debugRegionLineWidth).toDouble(); plotLabelFontSize=settings.value(group+"plot_label_font_size", defaultStyle.debugRegionLineWidth).toDouble();
widgetBackgroundColor=jkqtp_String2QColor(settings.value(group+"widget_background_color", jkqtp_QColor2String(defaultStyle.widgetBackgroundColor)).toString()); widgetBackgroundBrush=QBrush(jkqtp_String2QColor(settings.value(group+"widget_background_color", jkqtp_QColor2String(defaultStyle.widgetBackgroundBrush.color())).toString()));
exportBackgroundColor=jkqtp_String2QColor(settings.value(group+"widget_background_color_for_export", jkqtp_QColor2String(defaultStyle.exportBackgroundColor)).toString()); exportBackgroundBrush=QBrush(jkqtp_String2QColor(settings.value(group+"widget_background_color_for_export", jkqtp_QColor2String(defaultStyle.exportBackgroundBrush.color())).toString()));
plotBackgroundColor=jkqtp_String2QColor(settings.value(group+"plot_background_color", jkqtp_QColor2String(defaultStyle.plotBackgroundColor)).toString()); plotBackgroundBrush=QBrush(jkqtp_String2QColor(settings.value(group+"plot_background_color", jkqtp_QColor2String(defaultStyle.plotBackgroundBrush.color())).toString()));
plotFrameColor=jkqtp_String2QColor(settings.value(group+"plot_frame_color", jkqtp_QColor2String(defaultStyle.plotFrameColor)).toString()); plotFrameColor=jkqtp_String2QColor(settings.value(group+"plot_frame_color", jkqtp_QColor2String(defaultStyle.plotFrameColor)).toString());
plotFrameWidth=settings.value(group+"plot_frame_width", defaultStyle.plotFrameWidth).toDouble(); plotFrameWidth=settings.value(group+"plot_frame_width", defaultStyle.plotFrameWidth).toDouble();
plotFrameVisible=settings.value(group+"plot_frame_visible", defaultStyle.plotFrameVisible).toBool(); plotFrameVisible=settings.value(group+"plot_frame_visible", defaultStyle.plotFrameVisible).toBool();
@ -171,9 +171,9 @@ void JKQTBasePlotterStyle::saveSettings(QSettings &settings, const QString &grou
settings.setValue(group+"antialiase_system", useAntiAliasingForSystem); settings.setValue(group+"antialiase_system", useAntiAliasingForSystem);
settings.setValue(group+"antialiase_graphs", useAntiAliasingForGraphs); settings.setValue(group+"antialiase_graphs", useAntiAliasingForGraphs);
settings.setValue(group+"antialiase_text", useAntiAliasingForText); settings.setValue(group+"antialiase_text", useAntiAliasingForText);
settings.setValue(group+"widget_background_color", jkqtp_QColor2String(widgetBackgroundColor)); settings.setValue(group+"widget_background_color", jkqtp_QColor2String(widgetBackgroundBrush.color()));
settings.setValue(group+"widget_background_color_for_export", jkqtp_QColor2String(exportBackgroundColor)); settings.setValue(group+"widget_background_color_for_export", jkqtp_QColor2String(exportBackgroundBrush.color()));
settings.setValue(group+"plot_background_color", jkqtp_QColor2String(plotBackgroundColor)); settings.setValue(group+"plot_background_color", jkqtp_QColor2String(plotBackgroundBrush.color()));
settings.setValue(group+"plot_border_left", plotBorderLeft); settings.setValue(group+"plot_border_left", plotBorderLeft);
settings.setValue(group+"plot_border_right", plotBorderRight); settings.setValue(group+"plot_border_right", plotBorderRight);
settings.setValue(group+"plot_border_top", plotBorderTop); settings.setValue(group+"plot_border_top", plotBorderTop);

View File

@ -111,11 +111,11 @@ class JKQTP_LIB_EXPORT JKQTBasePlotterStyle {
/** \brief with (in pt) of symbol lines used for newly added graphs */ /** \brief with (in pt) of symbol lines used for newly added graphs */
double defaultGraphSymbolLineWidth; double defaultGraphSymbolLineWidth;
/** \brief color of the background of the plot (widget area) when drawing (to the screen) */ /** \brief color of the background of the plot (widget area) when drawing (to the screen) */
QColor widgetBackgroundColor; QBrush widgetBackgroundBrush;
/** \brief color of the background of the plot (widget area) when exporting*/ /** \brief color of the background of the plot (widget area) when exporting*/
QColor exportBackgroundColor; QBrush exportBackgroundBrush;
/** \brief color of the plot's background (i.e. of the area within the coordinate axes rectangle) */ /** \brief color of the plot's background (i.e. of the area within the coordinate axes rectangle) */
QColor plotBackgroundColor; QBrush plotBackgroundBrush;
/** \brief if \c plotFrameVisible==true, JKQTBasePlotter will draw a rectangle/frame around the plot in this color */ /** \brief if \c plotFrameVisible==true, JKQTBasePlotter will draw a rectangle/frame around the plot in this color */
QColor plotFrameColor; QColor plotFrameColor;
/** \brief if \c plotFrameVisible==true, JKQTBasePlotter will draw a rectangle/frame around the plot in this width [pt] */ /** \brief if \c plotFrameVisible==true, JKQTBasePlotter will draw a rectangle/frame around the plot in this width [pt] */

View File

@ -62,7 +62,7 @@ JKQTPGraph::JKQTPGraph(JKQTPlotter *parent):
QImage JKQTPPlotElement::generateKeyMarker(QSize size) QImage JKQTPPlotElement::generateKeyMarker(QSize size)
{ {
QImage img(size.width(),size.height(),QImage::Format_ARGB32); QImage img(size.width(),size.height(),QImage::Format_ARGB32);
if (parent) img.fill(parent->getKeyBackgroundColor()); if (parent) img.fill(Qt::transparent);//->getKeyBackgroundColor());
{ {
JKQTPEnhancedPainter painter(&img); JKQTPEnhancedPainter painter(&img);
painter.setRenderHint(QPainter::Antialiasing, true); painter.setRenderHint(QPainter::Antialiasing, true);

View File

@ -27,7 +27,7 @@ JKQTPKeyStyle::JKQTPKeyStyle():
frameColor(QColor("black")), frameColor(QColor("black")),
frameWidth(1), frameWidth(1),
frameRounding(0), frameRounding(0),
backgroundColor(QColor("white")), backgroundBrush(QColor("white")),
visible(true), visible(true),
fontSize(9), fontSize(9),
textColor(QColor("black")), textColor(QColor("black")),
@ -69,7 +69,7 @@ void JKQTPKeyStyle::loadSettings(const QSettings &settings, const QString &group
frameWidth = settings.value(group+"frame_width", defaultStyle.frameWidth).toDouble(); frameWidth = settings.value(group+"frame_width", defaultStyle.frameWidth).toDouble();
frameRounding = settings.value(group+"frame_rounding", defaultStyle.frameRounding).toDouble(); frameRounding = settings.value(group+"frame_rounding", defaultStyle.frameRounding).toDouble();
frameVisible = settings.value(group+"frame_visible", defaultStyle.frameVisible).toBool(); frameVisible = settings.value(group+"frame_visible", defaultStyle.frameVisible).toBool();
backgroundColor = jkqtp_String2QColor(settings.value(group+"background_color", jkqtp_QColor2String(defaultStyle.backgroundColor)).toString()); backgroundBrush = QBrush(jkqtp_String2QColor(settings.value(group+"background_color", jkqtp_QColor2String(defaultStyle.backgroundBrush.color())).toString()));
visible = settings.value(group+"visible", defaultStyle.visible).toBool(); visible = settings.value(group+"visible", defaultStyle.visible).toBool();
position = String2JKQTPKeyPosition(settings.value(group+"position", JKQTPKeyPosition2String(defaultStyle.position)).toString()); position = String2JKQTPKeyPosition(settings.value(group+"position", JKQTPKeyPosition2String(defaultStyle.position)).toString());
layout = String2JKQTPKeyLayout(settings.value(group+"layout", JKQTPKeyLayout2String(defaultStyle.layout)).toString()); layout = String2JKQTPKeyLayout(settings.value(group+"layout", JKQTPKeyLayout2String(defaultStyle.layout)).toString());
@ -92,7 +92,7 @@ void JKQTPKeyStyle::saveSettings(QSettings &settings, const QString &group) cons
settings.setValue(group+"frame_color", jkqtp_QColor2String(frameColor)); settings.setValue(group+"frame_color", jkqtp_QColor2String(frameColor));
settings.setValue(group+"frame_width", frameWidth); settings.setValue(group+"frame_width", frameWidth);
settings.setValue(group+"frame_rounding", frameRounding); settings.setValue(group+"frame_rounding", frameRounding);
settings.setValue(group+"background_color", jkqtp_QColor2String(backgroundColor)); settings.setValue(group+"background_color", jkqtp_QColor2String(backgroundBrush.color()));
settings.setValue(group+"visible", visible); settings.setValue(group+"visible", visible);
settings.setValue(group+"position", JKQTPKeyPosition2String(position)); settings.setValue(group+"position", JKQTPKeyPosition2String(position));
settings.setValue(group+"layout", JKQTPKeyLayout2String(layout)); settings.setValue(group+"layout", JKQTPKeyLayout2String(layout));

View File

@ -66,7 +66,7 @@ class JKQTP_LIB_EXPORT JKQTPKeyStyle {
/** \brief rounding radius of the key frame rectangle (<=0 -> no rounded rectangle) [pt] */ /** \brief rounding radius of the key frame rectangle (<=0 -> no rounded rectangle) [pt] */
double frameRounding; double frameRounding;
/** \brief color of the key background */ /** \brief color of the key background */
QColor backgroundColor; QBrush backgroundBrush;
/** \brief indicates whether to plot a key */ /** \brief indicates whether to plot a key */
bool visible; bool visible;
/** \brief font size for key labels [in points] */ /** \brief font size for key labels [in points] */

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 KiB

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 28 KiB