NEW: added "currentcolor" as color-placeholder in style.ini files and using it in conjunction with linear-gradient() in cyberpunk and dark styles

NEW: added style simple_noaxes.ini
This commit is contained in:
jkriege2 2024-01-22 21:31:09 +01:00
parent 1d013685bf
commit 8ccaaaebe6
22 changed files with 149 additions and 33 deletions

View File

@ -91,6 +91,10 @@ Here is a table with all available ready-made styles:
<td><a href="https://github.com/jkriege2/JKQtPlotter/tree/master/lib/jkqtplotter/resources/styles/simple_gridandticks.ini"><code>:/JKQTPlotter/styles/simple_gridandticks.ini</code></a>
<td>\image html simple_gridandticks.ini.png
<td>\image html simple_gridandticks.ini.symbols.png
<tr>
<td><a href="https://github.com/jkriege2/JKQtPlotter/tree/master/lib/jkqtplotter/resources/styles/simple_noaxes.ini"><code>:/JKQTPlotter/styles/simple_noaxes.ini</code></a>
<td>\image html simple_noaxes.ini.png
<td>\image html simple_noaxes.ini.symbols.png
</table>
<!--/include:styles.dox-->

View File

@ -118,7 +118,8 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
<li>NEW: Due to addition of JKQTMathText::setFontOptions() and the matchign extension of JKQTMathText::setFontSpecial() (see below) you can now add modifiers like <tt>+BOLD+ITALIC</tt> to any font-name provided to JKQTPlotter and in style INI-files</li>
<li>NEW: added JKQTPLabelMinBesides and JKQTPLabelMaxBesides to JKQTPLabelPosition, so labels can be set besides the axes</li>
<li>NEW/REWORKED all functions in JKQTBasePlotter are re-entrant, i.e. different instances can be used from different threads in parallel (although there is some overhead due to shared caches between the threads!). This is demonstrated and discussed in \ref JKQTPlotterMultiThreaded . </li>
<li>NEW: NEW allow linear-gradient()... in brush definitions of style.ini-file</li>
<li>NEW: allow linear-gradient(), currentcolor, ... in brush definitions of style.ini-file ... and using it is cyberpunk and dark styles</li>
<li>NEW: style simple_noaxes.ini</li>
</ul></li>
<li>JKQTMathText:<ul>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 KiB

After

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 141 KiB

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 KiB

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -21,6 +21,12 @@
#include <QDebug>
const double JKQTPlotterDrawingTools::ABS_MIN_LINEWIDTH= 0.02;
const QColor JKQTPlotterDrawingTools::CurrentColorPlaceholder = QColor::fromRgbF(0.1234,0.5678,0.9123,1.0);
const QColor JKQTPlotterDrawingTools::CurrentColorPlaceholder_Trans10 = QColor::fromRgbF(0.1234,0.5678,0.9123,0.1);
const QColor JKQTPlotterDrawingTools::CurrentColorPlaceholder_Trans25 = QColor::fromRgbF(0.1234,0.5678,0.9123,0.25);
const QColor JKQTPlotterDrawingTools::CurrentColorPlaceholder_Trans50 = QColor::fromRgbF(0.1234,0.5678,0.9123,0.5);
const QColor JKQTPlotterDrawingTools::CurrentColorPlaceholder_Trans75 = QColor::fromRgbF(0.1234,0.5678,0.9123,0.75);
const QColor JKQTPlotterDrawingTools::CurrentColorPlaceholder_Trans90 = QColor::fromRgbF(0.1234,0.5678,0.9123,0.9);
@ -567,3 +573,22 @@ JKQTPGraphSymbols JKQTPRegisterCustomGraphSymbol(const JKQTPCustomGraphSymbolFun
JKQTPlotterDrawingTools::JKQTPCustomGraphSymbolStore->push_back(f);
return static_cast<JKQTPGraphSymbols>(static_cast<uint64_t>(JKQTPFirstCustomSymbol)+static_cast<uint64_t>(JKQTPlotterDrawingTools::JKQTPCustomGraphSymbolStore->size()-1));
}
void JKQTPReplaceCurrentColor(QColor &col, const QColor &currentColor)
{
if (col==JKQTPlotterDrawingTools::CurrentColorPlaceholder) col=currentColor;
else if (col==JKQTPlotterDrawingTools::CurrentColorPlaceholder_Trans10) { col=currentColor; col.setAlphaF(0.9); }
else if (col==JKQTPlotterDrawingTools::CurrentColorPlaceholder_Trans25) { col=currentColor; col.setAlphaF(0.75); }
else if (col==JKQTPlotterDrawingTools::CurrentColorPlaceholder_Trans50) { col=currentColor; col.setAlphaF(0.5); }
else if (col==JKQTPlotterDrawingTools::CurrentColorPlaceholder_Trans75) { col=currentColor; col.setAlphaF(0.25); }
else if (col==JKQTPlotterDrawingTools::CurrentColorPlaceholder_Trans90) { col=currentColor; col.setAlphaF(0.1); }
}
void JKQTPReplaceCurrentColor(QGradient &grad, const QColor &currentColor)
{
auto stops=grad.stops();
for (auto& s: stops) {
JKQTPReplaceCurrentColor(s.second, currentColor);
}
grad.setStops(stops);
}

View File

@ -79,6 +79,36 @@ typedef std::function<void(QPainter& p)> JKQTPCustomGraphSymbolFunctor;
\ingroup jkqtptools_drawing
*/
struct JKQTPlotterDrawingTools {
/** \brief a special placeholder that can be used to indicate that a color should be replaced by the "current color" in a certain context
*
* \see JKQTPReplaceCurrentColor()
*/
static JKQTCOMMON_LIB_EXPORT const QColor CurrentColorPlaceholder;
/** \brief a special placeholder that can be used to indicate that a color should be replaced by the "current color", but with 10% transparency in a certain context
*
* \see JKQTPReplaceCurrentColor(), JKQTPlotterDrawingTools::CurrentColorPlaceholder_Trans10, ...
*/
static JKQTCOMMON_LIB_EXPORT const QColor CurrentColorPlaceholder_Trans10;
/** \brief a special placeholder that can be used to indicate that a color should be replaced by the "current color", but with 25% transparency in a certain context
*
* \see JKQTPReplaceCurrentColor(), JKQTPlotterDrawingTools::CurrentColorPlaceholder, ...
*/
static JKQTCOMMON_LIB_EXPORT const QColor CurrentColorPlaceholder_Trans25;
/** \brief a special placeholder that can be used to indicate that a color should be replaced by the "current color", but with 50% transparency in a certain context
*
* \see JKQTPReplaceCurrentColor(), JKQTPlotterDrawingTools::CurrentColorPlaceholder, JKQTPlotterDrawingTools::CurrentColorPlaceholder_Trans10, ...
*/
static JKQTCOMMON_LIB_EXPORT const QColor CurrentColorPlaceholder_Trans50;
/** \brief a special placeholder that can be used to indicate that a color should be replaced by the "current color", but with 75% transparency in a certain context
*
* \see JKQTPReplaceCurrentColor(), JKQTPlotterDrawingTools::CurrentColorPlaceholder, JKQTPlotterDrawingTools::CurrentColorPlaceholder_Trans10, ...
*/
static JKQTCOMMON_LIB_EXPORT const QColor CurrentColorPlaceholder_Trans75;
/** \brief a special placeholder that can be used to indicate that a color should be replaced by the "current color", but with 90% transparency in a certain context
*
* \see JKQTPReplaceCurrentColor(), JKQTPlotterDrawingTools::CurrentColorPlaceholder, JKQTPlotterDrawingTools::CurrentColorPlaceholder_Trans10, ...
*/
static JKQTCOMMON_LIB_EXPORT const QColor CurrentColorPlaceholder_Trans90;
/** \brief smallest linewidth any line in JKQTPlotter/JKQTBasePlotter may have
*/
static JKQTCOMMON_LIB_EXPORT const double ABS_MIN_LINEWIDTH;
@ -93,6 +123,19 @@ struct JKQTPlotterDrawingTools {
/*! \brief check whether \a col equals JKQTPlotterDrawingTools::CurrentColorPlaceholder (or one of its variants) and then replace it by \a currentColor
\ingroup jkqtptools_drawing
\see JKQTPlotterDrawingTools::CurrentColorPlaceholder, JKQTPlotterDrawingTools::CurrentColorPlaceholder_Trans10, ...
*/
JKQTCOMMON_LIB_EXPORT void JKQTPReplaceCurrentColor(QColor& col, const QColor& currentColor);
/*! \brief check whether any color in \a grad equals JKQTPlotterDrawingTools::CurrentColorPlaceholder (or one of its variants) and then replace it by \a currentColor
\ingroup jkqtptools_drawing
\see JKQTPlotterDrawingTools::CurrentColorPlaceholder, JKQTPlotterDrawingTools::CurrentColorPlaceholder_Trans10, ...
*/
JKQTCOMMON_LIB_EXPORT void JKQTPReplaceCurrentColor(QGradient& grad, const QColor& currentColor);
/** \brief symbols that can be used to plot a datapoint for a graph
* \ingroup jkqtptools_drawing

View File

@ -21,6 +21,7 @@
#include "jkqtcommon/jkqtpstringtools.h"
#include "jkqtcommon/jkqtpmathtools.h"
#include "jkqtcommon/jkqtpcsstools.h"
#include "jkqtcommon/jkqtpdrawingtools.h"
#include <QDateTime>
#include <cmath>
#include <QDebug>
@ -653,6 +654,12 @@ QColor jkqtp_lookupQColorName(const QString &color, bool namesOnly, bool *nameFo
#if (QT_VERSION>=QT_VERSION_CHECK(5, 12, 0))
if (col=="placeholdertext") return QGuiApplication::palette().color(QPalette::PlaceholderText);
#endif
if (col=="currentcolor") return JKQTPlotterDrawingTools::CurrentColorPlaceholder;
if (col=="currentcolor10") return JKQTPlotterDrawingTools::CurrentColorPlaceholder_Trans10;
if (col=="currentcolor25") return JKQTPlotterDrawingTools::CurrentColorPlaceholder_Trans25;
if (col=="currentcolor50") return JKQTPlotterDrawingTools::CurrentColorPlaceholder_Trans50;
if (col=="currentcolor75") return JKQTPlotterDrawingTools::CurrentColorPlaceholder_Trans75;
if (col=="currentcolor90") return JKQTPlotterDrawingTools::CurrentColorPlaceholder_Trans90;
for (int i=0; i<rgbTblSize; i++) {
if (col==rgbTbl[i].name) return QColor(rgbTbl[i].value);

View File

@ -1155,12 +1155,18 @@ JKQTBasePlotter::JKQTPPen JKQTBasePlotter::getPlotStyle(int i, JKQTPPlotStyleTyp
JKQTPGraphSymbols baseSymbol=plotterStyle.graphsStyle.defaultGraphSymbols[symbolI];
QColor baseColor=plotterStyle.graphsStyle.defaultGraphColors[colorI];
double baseWidth=baseProps.defaultLineWidth;
if (type==JKQTPPlotStyleType::Annotation || type==JKQTPPlotStyleType::Geometric) {
if (type==JKQTPPlotStyleType::Annotation) {
baseColor=plotterStyle.graphsStyle.annotationStyle.defaultColor;
basePenStyle=plotterStyle.graphsStyle.annotationStyle.defaultLineStyle;
basebrushStyle=JKQTFillStyleSummmary(plotterStyle.graphsStyle.annotationStyle.defaultFillStyle);
basebrushStyle=plotterStyle.graphsStyle.annotationStyle.defaultFillStyle;
baseSymbol=plotterStyle.graphsStyle.annotationStyle.defaultSymbol;
}
if (type==JKQTPPlotStyleType::Geometric) {
baseColor=plotterStyle.graphsStyle.geometricStyle.defaultColor;
basePenStyle=plotterStyle.graphsStyle.geometricStyle.defaultLineStyle;
basebrushStyle=plotterStyle.graphsStyle.geometricStyle.defaultFillStyle;
baseSymbol=plotterStyle.graphsStyle.geometricStyle.defaultSymbol;
}
if (type==JKQTPPlotStyleType::Barchart || type==JKQTPPlotStyleType::Boxplot || type==JKQTPPlotStyleType::Impulses) {
basePenStyle=Qt::SolidLine;
}

View File

@ -146,7 +146,7 @@ void JKQTGeometricSpecificStyleProperties::loadSettings(const QSettings &setting
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());
defaultFillStyle=JKQTFillStyleSummmary::fromString(settings.value(group+"fill_style", defaultFillStyle.toCSSString()).toString());
}
void JKQTGeometricSpecificStyleProperties::saveSettings(QSettings &settings, const QString &group) const
@ -155,7 +155,7 @@ void JKQTGeometricSpecificStyleProperties::saveSettings(QSettings &settings, con
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));
settings.setValue(group+"fill_style", defaultFillStyle.toCSSString());
}
JKQTAnnotationsSpecificStyleProperties::JKQTAnnotationsSpecificStyleProperties(const JKQTBasePlotterStyle& parent):
@ -512,6 +512,7 @@ QBrush JKQTFillStyleSummmary::brush(const QColor &color) const
b.setColor(color);
if (brushStyle==Qt::LinearGradientPattern || brushStyle==Qt::RadialGradientPattern || brushStyle==Qt::ConicalGradientPattern) {
QGradient g=gradient;
JKQTPReplaceCurrentColor(g, color);
g.setCoordinateMode(QGradient::ObjectMode);
b=QBrush(g);
} else {
@ -523,6 +524,11 @@ QBrush JKQTFillStyleSummmary::brush(const QColor &color) const
JKQTFillStyleSummmary JKQTFillStyleSummmary::fromString(const QString &style)
{
JKQTFillStyleSummmary res;
res.brushStyle=jkqtp_String2QBrushStyleExt(style, nullptr, &(res.gradient), nullptr, &(res.rotationAngleDeg));
res.brushStyle=jkqtp_String2QBrushStyleExt(style, nullptr, &(res.gradient), &(res.texture), &(res.rotationAngleDeg));
return res;
}
QString JKQTFillStyleSummmary::toCSSString() const
{
return jkqtp_QBrushStyle2String(brushStyle);
}

View File

@ -39,6 +39,30 @@
class JKQTBasePlotterStyle; // forward
/** \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;
QPixmap texture;
double rotationAngleDeg;
QBrush brush(const QColor& color) const;
/** \brief reads object contents from a string representation, e.g. as created by JKQTFillStyleSummmary::toCSSString() */
static JKQTFillStyleSummmary fromString(const QString& style);
/** \brief converst the contents to a string representation */
QString toCSSString() const;
};
/** \brief Support Class for JKQTBasePlotter, which summarizes all properties that define the visual styling of graphs
* \ingroup jkqtpplotter_styling_classes
@ -155,7 +179,7 @@ public:
/** \brief graph symbol used */
JKQTPGraphSymbols defaultSymbol;
/** \brief graph fill style used */
Qt::BrushStyle defaultFillStyle;
JKQTFillStyleSummmary defaultFillStyle;
};
@ -292,26 +316,6 @@ 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

View File

@ -9,6 +9,7 @@
<file>styles/simple_axesoffset_plotbox.ini</file>
<file>styles/simple_gridandticks.ini</file>
<file>styles/simple_arrowsaxes.ini</file>
<file>styles/simple_noaxes.ini</file>
<file>styles/legacy_default_style.ini</file>
<file>styles/cyberpunk.ini</file>
</qresource>

View File

@ -9,6 +9,7 @@ graphs\graphs_base\error_color_mode=lighter
graphs\graphs_base\error_fill_color_mode=even_lighter_and_transparent
graphs\graphs_base\symbol_fill_color_mode=grey75
graphs\graphs_annotation\fill_color_mode=transparent
graphs\graphs_geometric\color=black
graphs\graphs_barchart\linewidth=1
graphs\graphs_boxplot\fill_color_mode=white
text_default_size=10

View File

@ -55,6 +55,7 @@ graphs\auto_styles\color2=#F5D300
graphs\auto_styles\color3=#00ff41
graphs\auto_styles\color4=#FF0000
graphs\auto_styles\color5=#9467bd
graphs\auto_styles\fill_style0="linear-gradient(150deg,currentcolor10,currentcolor90)"
graphs\graphs_base\linewidth=2
graphs\graphs_base\symbol_size=10
graphs\graphs_base\symbol_line_width=1

View File

@ -56,6 +56,7 @@ graphs\auto_styles\color3="hsv(164,100%,90%)"
graphs\auto_styles\color4="hsv(42,100%,90%)"
graphs\auto_styles\color5="hsv(202,63%,90%)"
graphs\auto_styles\color6="hsv(0,0%,90%)"
graphs\auto_styles\fill_style0="linear-gradient(150deg,currentcolor10,currentcolor50)"
graphs\graphs_base\linewidth=1
graphs\graphs_base\symbol_size=8
graphs\graphs_base\symbol_line_width=0.75

View File

@ -70,10 +70,12 @@ key\xoffset=1
key\yoffset=1
key\xmargin=0.5
key\ymargin=0.5
key\xseparation=0.75
key\yseparation=0.75
key\xseparation=0.85
key\yseparation=0.35
key\column_separation=0.75
key\frame_visible=true
key\frame_color=black
key\frame_linestyle=solid
key\frame_width=1
key\frame_rounding=0
key\background_color=white
@ -81,11 +83,10 @@ key\visible=true
key\position=inside_topright
key\layout=one_column
key\fontsize=9
key\fontname=GUI
key\text_color=black
key\item_width=20
key\item_height=2.2
key\line_width=3
key\autosize=true
key\sample_width=3
key\sample_height=1
axis_x\color=black
axis_x\draw_mode1=complete
axis_x\draw_mode2=line+ticks

View File

@ -0,0 +1,15 @@
[plots]
widget_background_color=white
axis_x\draw_mode1=none
axis_x\draw_mode2=none
axis_x\zero_line\enabled=false
axis_x\grid\enabled=false
axis_y\draw_mode1=none
axis_y\draw_mode2=none
axis_y\grid\enabled=false
axis_colorbar_right\draw_mode1=none
axis_colorbar_right\draw_mode2=ticks+labels+axislabel
axis_colorbar_top\draw_mode1=none
axis_colorbar_top\draw_mode2=ticks+labels+axislabel
graphs\graphs_geometric\color=black
graphs\graphs_annotation\color=black