diff --git a/doc/dox/whatsnew.dox b/doc/dox/whatsnew.dox
index 88b1042845..913d067f1b 100644
--- a/doc/dox/whatsnew.dox
+++ b/doc/dox/whatsnew.dox
@@ -24,6 +24,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
FIXED issue #70: Typo in jkqtplotter/CMakeLists.txt, thanks to user:tedlinlab
FIXED issue #80: Bug with multiple inheritance with Q_GDAGET with CLANG, thanks to user:igormironchik, caused by QTBUG-104874
FIXED: styling was not properly applied to coordinate axes of colorbars outside the plot
+ FIXED issue #73: Symbol thickness differs in actual plot and legend, thanks to user:sim186
REORGANIZED: separated line-graphs from jkqtpscatter.h/.cpp into jkqtplines.h/.cpp
IMPROVED: QT6-compatibility by removing deprecated warnings
NEW: JKQTPFilledCurveXGraph and JKQTPFilledCurveYGraph can now plot wiggle plots with different fill styles above and below the baseline (feature request #68 Wiggle Plots from user:xichaoqiang
diff --git a/doc/images/JKQTPXYScatterErrorGraph.png b/doc/images/JKQTPXYScatterErrorGraph.png
index 6031f2a825..b25283986c 100644
Binary files a/doc/images/JKQTPXYScatterErrorGraph.png and b/doc/images/JKQTPXYScatterErrorGraph.png differ
diff --git a/doc/images/JKQTPXYScatterErrorGraph_small.png b/doc/images/JKQTPXYScatterErrorGraph_small.png
index f85ea05d6c..01ff2e9551 100644
Binary files a/doc/images/JKQTPXYScatterErrorGraph_small.png and b/doc/images/JKQTPXYScatterErrorGraph_small.png differ
diff --git a/examples/scatter/scatter.cpp b/examples/scatter/scatter.cpp
index 35cf4ed6f8..4875d8b613 100644
--- a/examples/scatter/scatter.cpp
+++ b/examples/scatter/scatter.cpp
@@ -96,6 +96,7 @@ void createErrorScatterGraph(JKQTPlotter&plot) {
graph1->setYColumn(columnY);
graph1->setYErrorColumn(columnEY);
graph1->setYErrorStyle(JKQTPErrorSimpleBars);
+ graph1->setSymbolType(JKQTPCross);
graph1->setTitle(QObject::tr("y-errorlines"));
plot.addGraph(graph1);
@@ -107,6 +108,7 @@ void createErrorScatterGraph(JKQTPlotter&plot) {
graph2->setXErrorStyle(JKQTPErrorBars);
graph2->setYErrorStyle(JKQTPErrorBars);
graph2->setTitle(QObject::tr("xy-errorbars"));
+ graph2->setSymbolLineWidth(3);
plot.addGraph(graph2);
// 6. autoscale the plot so the graph is contained
@@ -114,6 +116,7 @@ void createErrorScatterGraph(JKQTPlotter&plot) {
// show plotter and make it a decent size
plot.getPlotter()->setPlotLabel(QObject::tr("Error Scatter Example"));
+ plot.setGrid(false);
plot.show();
plot.resize(600/plot.devicePixelRatioF(),400/plot.devicePixelRatioF());
}
diff --git a/lib/jkqtcommon/jkqtpdrawingtools.h b/lib/jkqtcommon/jkqtpdrawingtools.h
index fd2fb1f49c..3a778fa5c8 100644
--- a/lib/jkqtcommon/jkqtpdrawingtools.h
+++ b/lib/jkqtcommon/jkqtpdrawingtools.h
@@ -503,6 +503,8 @@ inline void JKQTPPlotSymbol(TPainter& painter, double x, double y, JKQTPGraphSym
}
}
+ painter.setBrush(QColor(Qt::transparent));
+ painter.setPen(p);
switch(symbol) {
case JKQTPDot:
painter.drawPoint(QPointF(x,y));
@@ -576,6 +578,7 @@ inline void JKQTPPlotSymbol(TPainter& painter, double x, double y, JKQTPGraphSym
}
break;
case JKQTPFemale:{
+ painter.setBrush(QColor(Qt::transparent));
QPainterPath path;
QRectF rectangle3(x-w2/2.0, y-w2, w2, w2);
path.addEllipse(rectangle3);
@@ -587,6 +590,7 @@ inline void JKQTPPlotSymbol(TPainter& painter, double x, double y, JKQTPGraphSym
}
break;
case JKQTPMale:{
+ painter.setBrush(QColor(Qt::transparent));
QPainterPath path;
QRectF rectangle3(x-w2/2.0, y-w2/2.0, w2, w2);
path.addEllipse(rectangle3);
diff --git a/lib/jkqtplotter/graphs/jkqtpevaluatedfunction.cpp b/lib/jkqtplotter/graphs/jkqtpevaluatedfunction.cpp
index 85ca9424c7..3880537e94 100644
--- a/lib/jkqtplotter/graphs/jkqtpevaluatedfunction.cpp
+++ b/lib/jkqtplotter/graphs/jkqtpevaluatedfunction.cpp
@@ -76,6 +76,7 @@ void JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase::drawKeyMarker(JKQTPEnhanc
QPen p=getLinePen(painter, parent);
p.setJoinStyle(Qt::RoundJoin);
p.setCapStyle(Qt::RoundCap);
+ p.setWidthF(getKeyLineWidthPx(painter, rect, parent));
QPen np(Qt::NoPen);
QBrush b=getFillBrush(painter, parent);
const double y=rect.top()+rect.height()/2.0;
diff --git a/lib/jkqtplotter/graphs/jkqtpevaluatedparametriccurve.cpp b/lib/jkqtplotter/graphs/jkqtpevaluatedparametriccurve.cpp
index 41683f8c5b..5e045d59ba 100644
--- a/lib/jkqtplotter/graphs/jkqtpevaluatedparametriccurve.cpp
+++ b/lib/jkqtplotter/graphs/jkqtpevaluatedparametriccurve.cpp
@@ -72,6 +72,7 @@ void JKQTPXYFunctionLineGraphBase::drawKeyMarker(JKQTPEnhancedPainter& painter,
QPen p=getLinePen(painter, parent);
p.setJoinStyle(Qt::RoundJoin);
p.setCapStyle(Qt::RoundCap);
+ p.setWidthF(getKeyLineWidthPx(painter, rect, parent));
QPen np(Qt::NoPen);
const double y=rect.top()+rect.height()/2.0;
painter.setPen(np);
diff --git a/lib/jkqtplotter/graphs/jkqtpfilledcurve.cpp b/lib/jkqtplotter/graphs/jkqtpfilledcurve.cpp
index 8e4e414f7d..12744129fb 100644
--- a/lib/jkqtplotter/graphs/jkqtpfilledcurve.cpp
+++ b/lib/jkqtplotter/graphs/jkqtpfilledcurve.cpp
@@ -52,6 +52,7 @@ void JKQTPFilledCurveGraphBase::drawKeyMarker(JKQTPEnhancedPainter &painter, QRe
{
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
QPen p=getLinePen(painter, parent);
+ p.setWidthF(getKeyLineWidthPx(painter, rect, parent));
QPen np(Qt::NoPen);
QBrush b=getFillBrush(painter, parent);
const double y=rect.top()+rect.height()/2.0;
@@ -488,7 +489,7 @@ void JKQTPFilledVerticalRangeGraph::drawKeyMarker(JKQTPEnhancedPainter &painter,
r.moveTo(r.x(), r.y()+r.height()-1);
painter.fillRect(r, getFillBrush(painter, parent));
if (getDrawLine()) {
- painter.setPen(getLinePen(painter, parent));
+ painter.setPen(getKeyLinePen(painter, rect, parent));
painter.drawLine(QLineF(r.topLeft(), r.topRight()));
}
@@ -603,7 +604,7 @@ void JKQTPFilledHorizontalRangeGraph::drawKeyMarker(JKQTPEnhancedPainter &painte
r.moveTo(r.x(), r.y()+r.height()-1);
painter.fillRect(r, getFillBrush(painter, parent));
if (getDrawLine()) {
- painter.setPen(getLinePen(painter, parent));
+ painter.setPen(getKeyLinePen(painter, rect, parent));
painter.drawLine(QLineF(r.topLeft(), r.topRight()));
}
diff --git a/lib/jkqtplotter/graphs/jkqtpgeoannotations.cpp b/lib/jkqtplotter/graphs/jkqtpgeoannotations.cpp
index b0dbf42f75..e413f76332 100644
--- a/lib/jkqtplotter/graphs/jkqtpgeoannotations.cpp
+++ b/lib/jkqtplotter/graphs/jkqtpgeoannotations.cpp
@@ -283,15 +283,8 @@ void JKQTPGeoSymbol::draw(JKQTPEnhancedPainter &painter)
void JKQTPGeoSymbol::drawKeyMarker(JKQTPEnhancedPainter &painter, QRectF &rect)
{
- const double minSize=qMin(rect.width(), rect.height());
- double symbolSize=parent->pt2px(painter, this->getSymbolSize());
- if (symbolSize>minSize*0.9) symbolSize=minSize*0.9;
- double symbolWidth=parent->pt2px(painter, this->getSymbolLineWidth()*parent->getLineWidthMultiplier());
- if (symbolWidth>0.3*symbolSize) symbolWidth=0.3*symbolSize;
-
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
- JKQTPPlotSymbol(painter, rect.left()+rect.width()/2.0, rect.top()+rect.height()/2.0, getSymbolType(), symbolSize, symbolWidth, getSymbolColor(), getSymbolFillColor());
-
+ JKQTPPlotSymbol(painter, rect.left()+rect.width()/2.0, rect.top()+rect.height()/2.0, getSymbolType(), getKeySymbolSizePx(painter, rect, parent), getKeySymbolLineWidthPx(painter, rect, parent), getKeyLabelColor(), getSymbolFillColor());
}
QColor JKQTPGeoSymbol::getKeyLabelColor() const
diff --git a/lib/jkqtplotter/graphs/jkqtpgeobase.cpp b/lib/jkqtplotter/graphs/jkqtpgeobase.cpp
index 25554a6e98..5f38dc9fe3 100644
--- a/lib/jkqtplotter/graphs/jkqtpgeobase.cpp
+++ b/lib/jkqtplotter/graphs/jkqtpgeobase.cpp
@@ -66,9 +66,9 @@ void JKQTPGeoBaseLine::setColor(QColor c)
void JKQTPGeoBaseLine::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) {
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
- painter.setPen(getLinePen(painter, parent));
- double y=rect.top()+rect.height()/2.0;
- if (rect.width()>0) painter.drawLine(QLineF(rect.left(), y, rect.right(), y));
+ painter.setPen(getKeyLinePen(painter, rect, parent));
+ const double y=rect.top()+rect.height()/2.0;
+ painter.drawLine(QLineF(rect.left(), y, rect.right(), y));
}
@@ -175,10 +175,9 @@ void JKQTPGeoBaseFilled::setStyleTransparentFill(QColor color)
void JKQTPGeoBaseFilled::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) {
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
- painter.setPen(getLinePen(painter, parent));
+ painter.setPen(getKeyLinePen(painter, rect, parent));
painter.setBrush(getFillBrush(painter, parent));
- painter.drawRect(rect);
-
+ painter.drawRect(rect-QMarginsF(1,1,1,1));
}
@@ -231,8 +230,8 @@ void JKQTPGeoBaseDecoratedHeadLine::drawKeyMarker(JKQTPEnhancedPainter &painter,
{
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
painter.setPen(getLinePen(painter, parent));
- double y=rect.top()+rect.height()/2.0;
- if (rect.width()>0) painter.drawLine(QLineF(rect.left(), y, rect.right(), y));
+ const double y=rect.top()+rect.height()/2.0;
+ painter.drawLine(QLineF(rect.left(), y, rect.right(), y));
}
QColor JKQTPGeoBaseDecoratedHeadLine::getKeyLabelColor() const
@@ -291,9 +290,12 @@ void JKQTPGeoBaseDecoratedLine::setColor(QColor c)
void JKQTPGeoBaseDecoratedLine::drawKeyMarker(JKQTPEnhancedPainter &painter, QRectF &rect)
{
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
- painter.setPen(getLinePen(painter, parent));
- double y=rect.top()+rect.height()/2.0;
- if (rect.width()>0) painter.drawLine(QLineF(rect.left(), y, rect.right(), y));
+ QPen p=getLinePen(painter, parent);
+ p.setColor(getKeyLabelColor());
+ p.setWidthF(getKeyLineWidthPx(painter,rect,parent));
+ painter.setPen(p);
+ const double y=rect.top()+rect.height()/2.0;
+ painter.drawLine(QLineF(rect.left(), y, rect.right(), y));
}
QColor JKQTPGeoBaseDecoratedLine::getKeyLabelColor() const
diff --git a/lib/jkqtplotter/graphs/jkqtpimageoverlays.cpp b/lib/jkqtplotter/graphs/jkqtpimageoverlays.cpp
index bb01af0ca2..8984a6bef0 100644
--- a/lib/jkqtplotter/graphs/jkqtpimageoverlays.cpp
+++ b/lib/jkqtplotter/graphs/jkqtpimageoverlays.cpp
@@ -126,8 +126,6 @@ void JKQTPOverlayImage::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rec
painter.fillRect(r1, QBrush(trueColor));
painter.setBrush(QBrush(falseColor));
painter.fillRect(r2, QBrush(falseColor));
-
-
}
QColor JKQTPOverlayImage::getKeyLabelColor() const {
diff --git a/lib/jkqtplotter/graphs/jkqtpimpulses.cpp b/lib/jkqtplotter/graphs/jkqtpimpulses.cpp
index 501820523c..5de2984641 100644
--- a/lib/jkqtplotter/graphs/jkqtpimpulses.cpp
+++ b/lib/jkqtplotter/graphs/jkqtpimpulses.cpp
@@ -136,7 +136,7 @@ void JKQTPImpulsesHorizontalGraph::drawKeyMarker(JKQTPEnhancedPainter& painter,
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
- QPen p=getLinePen(painter, parent);
+ QPen p=getKeyLinePen(painter, rect, parent);
p.setCapStyle(Qt::FlatCap);
painter.setPen(p);
@@ -170,7 +170,7 @@ void JKQTPImpulsesVerticalGraph::drawKeyMarker(JKQTPEnhancedPainter& painter, QR
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
- QPen p=getLinePen(painter, parent);
+ QPen p=getKeyLinePen(painter, rect, parent);
p.setCapStyle(Qt::FlatCap);
painter.setPen(p);
const int x=rect.left()+rect.width()/2.0;
diff --git a/lib/jkqtplotter/graphs/jkqtplines.cpp b/lib/jkqtplotter/graphs/jkqtplines.cpp
index 07ee5af09b..dbcb70b2bf 100644
--- a/lib/jkqtplotter/graphs/jkqtplines.cpp
+++ b/lib/jkqtplotter/graphs/jkqtplines.cpp
@@ -150,25 +150,13 @@ void JKQTPXYLineGraph::draw(JKQTPEnhancedPainter& painter) {
}
void JKQTPXYLineGraph::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) {
- const double minSize=qMin(rect.width(), rect.height());
- const double maxSize=qMax(rect.width(), rect.height());
- double symbolSize=parent->pt2px(painter, this->getSymbolSize());
- if (symbolSize>minSize*0.9) symbolSize=minSize*0.9;
- double symbolWidth=parent->pt2px(painter, this->getSymbolLineWidth()*parent->getLineWidthMultiplier());
- if (symbolWidth>0.3*symbolSize) symbolWidth=0.3*symbolSize;
- double lineWidth=parent->pt2px(painter, this->getLineWidth()*parent->getLineWidthMultiplier());
- if (lineWidth>0.5*maxSize) lineWidth=0.5*maxSize;
-
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
QPen p=getLinePen(painter, parent);
- p.setColor(getKeyLabelColor());
- p.setStyle(getLineStyle());
- p.setWidthF(lineWidth);
+ p.setWidthF(getKeyLineWidthPx(painter,rect,parent));
painter.setPen(p);
double y=rect.top()+rect.height()/2.0;
if (drawLine) painter.drawLine(QLineF(rect.left(), y, rect.right(), y));
- JKQTPPlotSymbol(painter, rect.left()+rect.width()/2.0, rect.top()+rect.height()/2.0, getSymbolType(), symbolSize, symbolWidth, getKeyLabelColor(), getSymbolFillColor());
-
+ JKQTPPlotSymbol(painter, rect.left()+rect.width()/2.0, rect.top()+rect.height()/2.0, getSymbolType(), getKeySymbolSizePx(painter, rect, parent), getKeySymbolLineWidthPx(painter, rect, parent), getKeyLabelColor(), getSymbolFillColor());
}
QColor JKQTPXYLineGraph::getKeyLabelColor() const {
diff --git a/lib/jkqtplotter/graphs/jkqtppeakstream.cpp b/lib/jkqtplotter/graphs/jkqtppeakstream.cpp
index 8a2f68a730..e0b04a292b 100644
--- a/lib/jkqtplotter/graphs/jkqtppeakstream.cpp
+++ b/lib/jkqtplotter/graphs/jkqtppeakstream.cpp
@@ -144,10 +144,10 @@ void JKQTPPeakStreamGraph::draw(JKQTPEnhancedPainter &painter)
void JKQTPPeakStreamGraph::drawKeyMarker(JKQTPEnhancedPainter &painter, QRectF &rect)
{
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
- QPen p=getLinePen(painter, parent);
+ QPen p=getKeyLinePen(painter, rect, parent);
painter.setPen(p);
if (yPeaks) {
- p.setWidthF(qMax(JKQTPlotterDrawingTools::ABS_MIN_LINEWIDTH,qMin(parent->pt2px(painter, p.widthF()), rect.width()/10.0)));
+ p.setWidthF(qMax(JKQTPlotterDrawingTools::ABS_MIN_LINEWIDTH,qMin(p.widthF(), rect.width()/10.0)));
if (drawBaseline) {
if (peakHeight>=0) painter.drawLine(rect.bottomLeft(), rect.bottomRight());
else painter.drawLine(rect.topLeft(), rect.topRight());
@@ -157,7 +157,7 @@ void JKQTPPeakStreamGraph::drawKeyMarker(JKQTPEnhancedPainter &painter, QRectF &
painter.drawLine(QPointF(rect.left()+rect.width()*0.75, rect.top()), QPointF(rect.left()+rect.width()*0.75, rect.bottom()));
painter.drawLine(QPointF(rect.left()+rect.width()*0.9, rect.top()), QPointF(rect.left()+rect.width()*0.9, rect.bottom()));
} else {
- p.setWidthF(qMax(JKQTPlotterDrawingTools::ABS_MIN_LINEWIDTH,qMin(parent->pt2px(painter, p.widthF()), rect.height()/15.0)));
+ p.setWidthF(qMax(JKQTPlotterDrawingTools::ABS_MIN_LINEWIDTH,qMin(p.widthF(), rect.height()/15.0)));
if (drawBaseline) {
if (peakHeight>=0) painter.drawLine(rect.bottomLeft(), rect.topLeft());
else painter.drawLine(rect.bottomRight(), rect.topRight());
diff --git a/lib/jkqtplotter/graphs/jkqtprange.cpp b/lib/jkqtplotter/graphs/jkqtprange.cpp
index dc2abeaa3a..05b66defcd 100644
--- a/lib/jkqtplotter/graphs/jkqtprange.cpp
+++ b/lib/jkqtplotter/graphs/jkqtprange.cpp
@@ -311,7 +311,7 @@ void JKQTPHorizontalRange::draw(JKQTPEnhancedPainter& painter) {
void JKQTPHorizontalRange::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) {
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
- QPen p=getLinePen(painter, parent);
+ QPen p=getKeyLinePen(painter, rect, parent);
QPen np(Qt::NoPen);
QBrush nb(Qt::NoBrush);
QBrush b=getFillBrush(painter, parent);
@@ -430,7 +430,7 @@ void JKQTPVerticalRange::draw(JKQTPEnhancedPainter& painter) {
void JKQTPVerticalRange::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) {
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
- QPen p=getLinePen(painter, parent);
+ QPen p=getKeyLinePen(painter, rect, parent);
QPen np(Qt::NoPen);
QBrush nb(Qt::NoBrush);
QBrush b=getFillBrush(painter, parent);
diff --git a/lib/jkqtplotter/graphs/jkqtpscatter.cpp b/lib/jkqtplotter/graphs/jkqtpscatter.cpp
index 2698097d01..5163de737f 100644
--- a/lib/jkqtplotter/graphs/jkqtpscatter.cpp
+++ b/lib/jkqtplotter/graphs/jkqtpscatter.cpp
@@ -116,17 +116,8 @@ void JKQTPXYScatterGraph::draw(JKQTPEnhancedPainter& painter) {
}
void JKQTPXYScatterGraph::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) {
- const double minSize=qMin(rect.width(), rect.height());
- const double maxSize=qMax(rect.width(), rect.height());
- double symbolSize=parent->pt2px(painter, this->getSymbolSize());
- if (symbolSize>minSize*0.9) symbolSize=minSize*0.9;
- double symbolWidth=parent->pt2px(painter, this->getSymbolLineWidth()*parent->getLineWidthMultiplier());
- if (symbolWidth>0.3*symbolSize) symbolWidth=0.3*symbolSize;
-
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
- double y=rect.top()+rect.height()/2.0;
- JKQTPPlotSymbol(painter, rect.left()+rect.width()/2.0, rect.top()+rect.height()/2.0, getSymbolType(), symbolSize, symbolWidth, getKeyLabelColor(), getSymbolFillColor());
-
+ JKQTPPlotSymbol(painter, rect.left()+rect.width()/2.0, rect.top()+rect.height()/2.0, getSymbolType(), getKeySymbolSizePx(painter, rect, parent), getKeySymbolLineWidthPx(painter, rect, parent), getKeyLabelColor(), getSymbolFillColor());
}
QColor JKQTPXYScatterGraph::getKeyLabelColor() const {
@@ -427,14 +418,8 @@ void JKQTPXYParametrizedScatterGraph::draw(JKQTPEnhancedPainter &painter)
void JKQTPXYParametrizedScatterGraph::drawKeyMarker(JKQTPEnhancedPainter &painter, QRectF &rect)
{
- const double minSize=qMin(rect.width(), rect.height());
- const double maxSize=qMax(rect.width(), rect.height());
- double symbolSize1=parent->pt2px(painter, this->getSymbolSize());
- if (symbolSize1>minSize*0.9) symbolSize1=minSize*0.9;
- if (symbolSize1pt2px(painter, this->getSymbolSize()*0.75);
- if (symbolSize2>minSize*0.6) symbolSize2=minSize*0.5;
- if (symbolSize2pt2px(painter, this->getSymbolLineWidth()*0.7*parent->getLineWidthMultiplier());
- if (symbolWidth>0.2*getSymbolLineWidth()) symbolWidth=0.3*getSymbolLineWidth();
- double lineWidth=parent->pt2px(painter, this->getSymbolLineWidth()*0.7*parent->getLineWidthMultiplier());
- if (lineWidth>0.1*maxSize) lineWidth=0.1*maxSize;
+ double lineWidth=getKeyLineWidthPx(painter, rect, parent)*0.75;
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
QPen p=painter.pen();
@@ -475,12 +457,12 @@ void JKQTPXYParametrizedScatterGraph::drawKeyMarker(JKQTPEnhancedPainter &painte
p.setStyle(getLineStyle());
p.setWidthF(lineWidth);
painter.setPen(p);
- double x1=rect.left()+symbolSize1/2.0;
- double y1=rect.top()+symbolSize1/2.0;
- double x2=rect.right()-symbolSize2/2.0;
- double y2=rect.bottom()-symbolSize2/2.0;
- JKQTPPlotSymbol(painter, x1, y1, symbol1, symbolSize1, symbolWidth, color1, JKQTPGetDerivedColor(symbolFillDerivationMode, color1));
- JKQTPPlotSymbol(painter, x2, y2, symbol2, symbolSize2, symbolWidth, color2, JKQTPGetDerivedColor(symbolFillDerivationMode, color2));
+ const double x1=rect.left()+symbolSize1/2.0;
+ const double y1=rect.top()+symbolSize1/2.0;
+ const double x2=rect.right()-symbolSize2/2.0;
+ const double y2=rect.bottom()-symbolSize2/2.0;
+ JKQTPPlotSymbol(painter, x1, y1, symbol1, symbolSize1, getKeySymbolLineWidthPx(painter, rect, parent,0.5), color1, JKQTPGetDerivedColor(symbolFillDerivationMode, color1));
+ JKQTPPlotSymbol(painter, x2, y2, symbol2, symbolSize2, getKeySymbolLineWidthPx(painter, rect, parent,0.5), color2, JKQTPGetDerivedColor(symbolFillDerivationMode, color2));
if (drawLine) painter.drawLine(QLineF(x1,y1, x2,y2));
}
diff --git a/lib/jkqtplotter/graphs/jkqtpspecialline.cpp b/lib/jkqtplotter/graphs/jkqtpspecialline.cpp
index 72294020e7..946eea7af0 100644
--- a/lib/jkqtplotter/graphs/jkqtpspecialline.cpp
+++ b/lib/jkqtplotter/graphs/jkqtpspecialline.cpp
@@ -46,7 +46,7 @@ JKQTPSpecialLineGraphBase::JKQTPSpecialLineGraphBase(JKQTBasePlotter* parent):
void JKQTPSpecialLineGraphBase::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) {
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
- QPen p=getLinePen(painter, parent);
+ QPen p=getKeyLinePen(painter, rect, parent);
QPen np(Qt::NoPen);
QBrush b=getFillBrush(painter, parent);
const double y=rect.top()+rect.height()/2.0;
@@ -56,7 +56,7 @@ void JKQTPSpecialLineGraphBase::drawKeyMarker(JKQTPEnhancedPainter& painter, QRe
if (getFillCurve()) painter.drawRect(rect);
if (!getFillCurve() && getDrawLine()) painter.drawLine(QLineF(rect.left(), y, rect.right(), y));
if (m_drawSymbols) {
- plotStyledSymbol(parent, painter, rect.center().x(), rect.center().y(), rect.width()*0.5);
+ JKQTPPlotSymbol(painter, rect.center().x(), rect.center().y(), getSymbolType(), getKeySymbolSizePx(painter, rect, parent), getKeySymbolLineWidthPx(painter, rect, parent), getKeyLabelColor(), getSymbolFillColor());
}
}
diff --git a/lib/jkqtplotter/jkqtpgraphsbasestylingmixins.cpp b/lib/jkqtplotter/jkqtpgraphsbasestylingmixins.cpp
index 6530912e41..6a0a8ac28b 100644
--- a/lib/jkqtplotter/jkqtpgraphsbasestylingmixins.cpp
+++ b/lib/jkqtplotter/jkqtpgraphsbasestylingmixins.cpp
@@ -140,6 +140,13 @@ QPen JKQTPGraphLineStyleMixin::getLinePen(JKQTPEnhancedPainter& painter, JKQTBas
return p;
}
+
+QPen JKQTPGraphLineStyleMixin::getKeyLinePen(JKQTPEnhancedPainter& painter, const QRectF& rect, JKQTBasePlotter* parent) const {
+ QPen p=m_linePen;
+ p.setWidthF(getKeyLineWidthPx(painter, rect, parent));
+ return p;
+}
+
QPen JKQTPGraphLineStyleMixin::getLinePenForRects(JKQTPEnhancedPainter &painter, JKQTBasePlotter *parent) const
{
QPen p=getLinePen(painter, parent);
@@ -270,6 +277,23 @@ double JKQTPGraphSymbolStyleMixin::getSymbolLineWidth() const
return m_symbolLineWidth;
}
+double JKQTPGraphSymbolStyleMixin::getKeySymbolLineWidthPx(JKQTPEnhancedPainter& painter, const QRectF& keyRect, const JKQTBasePlotter *parent, double maxSymbolSizeFracton) const
+{
+ const double minSize=qMin(keyRect.width(), keyRect.height());
+ double symbolWidth=parent->pt2px(painter, this->getSymbolLineWidth()*parent->getLineWidthMultiplier());
+ double symbolSize=getKeySymbolSizePx(painter, keyRect, parent, maxSymbolSizeFracton);
+ if (symbolWidth>0.3*symbolSize) symbolWidth=0.3*symbolSize;
+ return symbolWidth;
+}
+
+double JKQTPGraphSymbolStyleMixin::getKeySymbolSizePx(JKQTPEnhancedPainter& painter, const QRectF& keyRect, const JKQTBasePlotter *parent, double maxSymbolSizeFracton) const
+{
+ const double minSize=qMin(keyRect.width(), keyRect.height());
+ double symbolSize=parent->pt2px(painter, this->getSymbolSize());
+ if (symbolSize>minSize*maxSymbolSizeFracton) symbolSize=minSize*maxSymbolSizeFracton;
+ return symbolSize;
+}
+
QPen JKQTPGraphSymbolStyleMixin::getSymbolPen(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent) const {
QPen p;
p.setColor(m_symbolColor);
@@ -438,6 +462,14 @@ QColor JKQTPGraphLineStyleMixin::getHighlightingLineColor() const
return m_highlightingLineColor;
}
+double JKQTPGraphLineStyleMixin::getKeyLineWidthPx(JKQTPEnhancedPainter &painter, const QRectF &keyRect, const JKQTBasePlotter *parent) const
+{
+ const double minSize=qMin(keyRect.width(), keyRect.height());
+ double lineWidth=parent->pt2px(painter, this->getLineWidth()*parent->getLineWidthMultiplier());
+ if (lineWidth>0.4*minSize) lineWidth=0.4*minSize;
+ return lineWidth;
+}
+
QPen JKQTPGraphLineStyleMixin::getHighlightingLinePen(JKQTPEnhancedPainter &painter, JKQTBasePlotter *parent) const
{
QPen p=getLinePen(painter, parent);
diff --git a/lib/jkqtplotter/jkqtpgraphsbasestylingmixins.h b/lib/jkqtplotter/jkqtpgraphsbasestylingmixins.h
index b510997222..1930ab6941 100644
--- a/lib/jkqtplotter/jkqtpgraphsbasestylingmixins.h
+++ b/lib/jkqtplotter/jkqtpgraphsbasestylingmixins.h
@@ -135,6 +135,9 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGraphLineStyleMixin {
/** \brief line pen for the highlighted look */
QColor m_highlightingLineColor;
protected:
+ /** \brief returns the linewidth for drawing lines in a key entry with \a keyRect for the symbol, using \a painter and \a parent . */
+ double getKeyLineWidthPx(JKQTPEnhancedPainter &painter, const QRectF &keyRect, const JKQTBasePlotter *parent) const;
+
/** \brief constructs a QPen from the line styling properties */
QPen getLinePen(JKQTPEnhancedPainter &painter, JKQTBasePlotter* parent) const;
/** \brief constructs a QPen from the line styling properties, suitable for drawing rectangles with sharp edges */
@@ -143,6 +146,8 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGraphLineStyleMixin {
QPen getHighlightingLinePen(JKQTPEnhancedPainter &painter, JKQTBasePlotter* parent) const;
/** \brief constructs a QPen from the line styling properties, suitable for drawing rectangle with sharp corners */
QPen getHighlightingLinePenForRects(JKQTPEnhancedPainter &painter, JKQTBasePlotter* parent) const;
+ /** \brief constructs a QPen from the line styling properties, but uses getKeyLineWidthPx() for the width, i.e. constructs a pen for drawing lines in key-symbols */
+ QPen getKeyLinePen(JKQTPEnhancedPainter &painter, const QRectF &rect, JKQTBasePlotter *parent) const;
};
@@ -406,7 +411,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGraphSymbolStyleMixin {
Q_PROPERTY(double symbolSize MEMBER m_symbolSize READ getSymbolSize WRITE setSymbolSize)
Q_PROPERTY(double symbolLineWidth MEMBER m_symbolLineWidth READ getSymbolLineWidth WRITE setSymbolLineWidth)
#endif
- private:
+private:
/** \brief which symbol to use for the datapoints */
JKQTPGraphSymbols m_symbolType;
/** \brief size (diameter in pt) of the symbol for the data points, given in pt */
@@ -458,8 +463,10 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGraphSymbolStyleMixin {
\param fillColor fill color of the symbol
*/
void plotStyledSymbol(JKQTBasePlotter* parent, JKQTPEnhancedPainter& painter, double x, double y, QColor color, QColor fillColor) const;
-
-
+ /** \brief returns the symbol linewidth for drawing symbols in a key entry with \a keyRect for the symbol, using \a painter and \a parent . \a maxSymbolSizeFracton specifies the maximum fraction of \a keyRect to be used for the symbol. */
+ double getKeySymbolLineWidthPx(JKQTPEnhancedPainter &painter, const QRectF &keyRect, const JKQTBasePlotter *parent, double maxSymbolSizeFracton=0.9) const;
+ /** \brief returns the symbol size for drawing symbols in a key entry with \a keyRect for the symbol, using \a painter and \a parent . \a maxSymbolSizeFracton specifies the maximum fraction of \a keyRect to be used for the symbol. */
+ double getKeySymbolSizePx(JKQTPEnhancedPainter &painter, const QRectF &keyRect, const JKQTBasePlotter *parent, double maxSymbolSizeFracton=0.9) const;
};
diff --git a/screenshots/evalcurve.png b/screenshots/evalcurve.png
index 2f5a2798cd..8e595041c7 100644
Binary files a/screenshots/evalcurve.png and b/screenshots/evalcurve.png differ
diff --git a/screenshots/evalcurve_small.png b/screenshots/evalcurve_small.png
index 81f151e38d..1179f1919f 100644
Binary files a/screenshots/evalcurve_small.png and b/screenshots/evalcurve_small.png differ
diff --git a/screenshots/parametriccurve2.png b/screenshots/parametriccurve2.png
index 9aa695c117..fccc64e3d7 100644
Binary files a/screenshots/parametriccurve2.png and b/screenshots/parametriccurve2.png differ
diff --git a/screenshots/parametriccurve2_small.png b/screenshots/parametriccurve2_small.png
index db161fe610..6348f646e7 100644
Binary files a/screenshots/parametriccurve2_small.png and b/screenshots/parametriccurve2_small.png differ
diff --git a/screenshots/paramscatterplot.png b/screenshots/paramscatterplot.png
index 11aac42096..dabcc541a5 100644
Binary files a/screenshots/paramscatterplot.png and b/screenshots/paramscatterplot.png differ
diff --git a/screenshots/paramscatterplot_small.png b/screenshots/paramscatterplot_small.png
index 9443c59c54..50b80c659b 100644
Binary files a/screenshots/paramscatterplot_small.png and b/screenshots/paramscatterplot_small.png differ
diff --git a/screenshots/scatter_error.png b/screenshots/scatter_error.png
index 18ae8acbda..9bd32b44fc 100644
Binary files a/screenshots/scatter_error.png and b/screenshots/scatter_error.png differ
diff --git a/screenshots/scatter_error_small.png b/screenshots/scatter_error_small.png
index f85ea05d6c..01ff2e9551 100644
Binary files a/screenshots/scatter_error_small.png and b/screenshots/scatter_error_small.png differ
diff --git a/screenshots/stepplots.png b/screenshots/stepplots.png
index d2c3709d16..51db7ff09e 100644
Binary files a/screenshots/stepplots.png and b/screenshots/stepplots.png differ
diff --git a/screenshots/stepplots_small.png b/screenshots/stepplots_small.png
index 0f6fcf828e..2295c22976 100644
Binary files a/screenshots/stepplots_small.png and b/screenshots/stepplots_small.png differ