mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-24 17:41:39 +08:00
JKQTPlottter: added the option to draw a character from a font as symbol (JKQTPCharacterSymbol+QChar('').unicode())
This commit is contained in:
parent
74d54abac5
commit
4f73fbbaed
@ -43,6 +43,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
|
||||
<li>NEW: made resize-timer status accessible from outside via JKQTPlotter::isResizeTimerRunning() </li>
|
||||
<li>NEW: made it's delay a global static variable that can be set and red with JKQTPlotter::setGlobalResizeDelay() and JKQTPlotter::getGlobalResizeDelay()</li>
|
||||
<li>NEW: Using JKQTMathText::useGuiFonts() for FONT rendering by default</li>
|
||||
<li>NEW: added the option to draw a character from a font as symbol (<code>JKQTPCharacterSymbol+QChar('C').unicode()</code>)</li>
|
||||
</ul></li>
|
||||
|
||||
<li>JKQTMathText:<ul>
|
||||
|
@ -91,6 +91,13 @@ QString JKQTPGraphSymbols2String(JKQTPGraphSymbols pos) {
|
||||
case JKQTPMale: return "symbol_male";
|
||||
case JKQTPCirclePeace: return "symbol_circle_peace";
|
||||
case JKQTPSymbolCount: JKQTPGraphSymbols2String(JKQTPMaxSymbolID);
|
||||
case JKQTPCharacterSymbol:
|
||||
break;
|
||||
}
|
||||
if (pos>=JKQTPCharacterSymbol && pos<=JKQTPCharacterSymbol+0xFF) {
|
||||
QString s=QString::number(pos-JKQTPCharacterSymbol,16);
|
||||
while (s.size()<4) s="0"+s;
|
||||
return "symbol_char"+s;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@ -162,11 +169,16 @@ QString JKQTPGraphSymbols2NameString(JKQTPGraphSymbols pos) {
|
||||
case JKQTPMale: return QObject::tr("male");
|
||||
case JKQTPCirclePeace: return QObject::tr("circled peace");
|
||||
case JKQTPSymbolCount: JKQTPGraphSymbols2NameString(JKQTPMaxSymbolID);
|
||||
case JKQTPCharacterSymbol: break;
|
||||
}
|
||||
if (pos>=JKQTPCharacterSymbol && pos<=JKQTPCharacterSymbol+0xFF) {
|
||||
return QObject::tr("character")+" '"+QChar(static_cast<uint16_t>(pos-JKQTPCharacterSymbol))+"'";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
JKQTPGraphSymbols String2JKQTPGraphSymbols(const QString& pos) {
|
||||
QString s=pos.trimmed().toLower();
|
||||
const QString posT=pos.trimmed();
|
||||
const QString s=posT.toLower();
|
||||
if (s=="symbol_dot"||s=="dot"||s==".") return JKQTPDot;
|
||||
if (s=="symbol_cross"||s=="cross"||s=="x") return JKQTPCross;
|
||||
if (s=="symbol_plus"||s=="plus"||s=="+") return JKQTPPlus;
|
||||
@ -230,7 +242,20 @@ JKQTPGraphSymbols String2JKQTPGraphSymbols(const QString& pos) {
|
||||
if (s=="symbol_circle_peace" || s=="circle_peace") return JKQTPCirclePeace;
|
||||
if (s=="symbol_female" || s=="female") return JKQTPFemale;
|
||||
if (s=="symbol_male" || s=="male") return JKQTPMale;
|
||||
|
||||
if (posT.startsWith("symbol_charsym") && posT.size()>14) {
|
||||
//qDebug()<<posT<<" --> "<<posT[14]<<" "<<posT[14].unicode();
|
||||
return JKQTPCharacterSymbol+posT[14].unicode();
|
||||
}
|
||||
if (posT.startsWith("charsym") && posT.size()>7) {
|
||||
//qDebug()<<posT<<" --> "<<posT[7]<<" "<<posT[7].unicode();
|
||||
return JKQTPCharacterSymbol+posT[7].unicode();
|
||||
}
|
||||
if (posT.startsWith("char")) {
|
||||
return JKQTPCharacterSymbol+posT.mid(4).toUInt(nullptr,16);
|
||||
}
|
||||
if (posT.startsWith("symbol_char")) {
|
||||
return JKQTPCharacterSymbol+posT.mid(11).toUInt(nullptr,16);
|
||||
}
|
||||
return JKQTPNoSymbol;
|
||||
}
|
||||
|
||||
@ -238,9 +263,9 @@ JKQTPGraphSymbols String2JKQTPGraphSymbols(const QString& pos) {
|
||||
|
||||
|
||||
|
||||
void JKQTPPlotSymbol(QPaintDevice &paintDevice, double x, double y, JKQTPGraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor) {
|
||||
void JKQTPPlotSymbol(QPaintDevice &paintDevice, double x, double y, JKQTPGraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor, const QFont& symbolFont) {
|
||||
JKQTPEnhancedPainter p(&paintDevice);
|
||||
JKQTPPlotSymbol(p, x, y, symbol, size, symbolLineWidth, color, fillColor);
|
||||
JKQTPPlotSymbol(p, x, y, symbol, size, symbolLineWidth, color, fillColor, symbolFont);
|
||||
}
|
||||
|
||||
QString JKQTPLineDecoratorStyle2String(JKQTPLineDecoratorStyle pos)
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include <cmath>
|
||||
#include <utility>
|
||||
#include <QDebug>
|
||||
#include <QGuiApplication>
|
||||
#include "jkqtcommon/jkqtpmathtools.h"
|
||||
#include "jkqtcommon/jkqtpcodestructuring.h"
|
||||
|
||||
@ -60,7 +61,7 @@ struct JKQTPlotterDrawingTools {
|
||||
/** \brief symbols that can be used to plot a datapoint for a graph
|
||||
* \ingroup jkqtptools_drawing
|
||||
*/
|
||||
enum JKQTPGraphSymbols {
|
||||
enum JKQTPGraphSymbols: uint64_t {
|
||||
JKQTPNoSymbol=0, /*!< \brief plots no symbol at all (usefull together with error bars) */
|
||||
JKQTPDot, /*!< \brief a small dot \image html symbols/symbol_dot.png */
|
||||
JKQTPCross, /*!< \brief a X cross \image html symbols/symbol_cross.png */
|
||||
@ -136,8 +137,42 @@ enum JKQTPGraphSymbols {
|
||||
JKQTPSymbolCount, /*!< \brief can be used to iterate over all symbols using: <code>for (int i=0; i<static_cast<int>(JKQTPSymbolCount); i++) { JKQTPGraphSymbols s=static_cast<JKQTPGraphSymbols>(i); ... }</code> */
|
||||
JKQTPMaxSymbolID=JKQTPSymbolCount-1, /*!< \brief points to the last available symbol, can be used to iterate over all symbols: <code>for (int i=0; i<=static_cast<int>(JKQTPMaxSymbolID); i++) { JKQTPGraphSymbols s=static_cast<JKQTPGraphSymbols>(i); ... }</code> */
|
||||
JKQTPDefaultSymbol=JKQTPCross, /*!< \brief a default symbol used for plotting */
|
||||
|
||||
JKQTPCharacterSymbol=0x100, /*!< \brief you can use any character from a QFont by supplying \c JKQTPCharacterSymbol+QChar('').unicode() as JKQTPGraphSymbols \image html symbols/symbol_char_at.png "generated by JKQTPCharacterSymbol+QChar('@').unicode()" */
|
||||
};
|
||||
|
||||
inline JKQTPGraphSymbols operator+(JKQTPGraphSymbols a, uint8_t b) {
|
||||
return static_cast<JKQTPGraphSymbols>(static_cast<uint64_t>(a)+b);
|
||||
}
|
||||
|
||||
inline JKQTPGraphSymbols operator+(JKQTPGraphSymbols a, uint16_t b) {
|
||||
return static_cast<JKQTPGraphSymbols>(static_cast<uint64_t>(a)+b);
|
||||
}
|
||||
|
||||
inline JKQTPGraphSymbols operator+(JKQTPGraphSymbols a, uint32_t b) {
|
||||
return static_cast<JKQTPGraphSymbols>(static_cast<uint64_t>(a)+b);
|
||||
}
|
||||
|
||||
inline JKQTPGraphSymbols operator+(JKQTPGraphSymbols a, uint64_t b) {
|
||||
return static_cast<JKQTPGraphSymbols>(static_cast<uint64_t>(a)+b);
|
||||
}
|
||||
|
||||
inline JKQTPGraphSymbols operator+(JKQTPGraphSymbols a, int8_t b) {
|
||||
return static_cast<JKQTPGraphSymbols>(static_cast<uint64_t>(a)+b);
|
||||
}
|
||||
|
||||
inline JKQTPGraphSymbols operator+(JKQTPGraphSymbols a, int16_t b) {
|
||||
return static_cast<JKQTPGraphSymbols>(static_cast<uint64_t>(a)+b);
|
||||
}
|
||||
|
||||
inline JKQTPGraphSymbols operator+(JKQTPGraphSymbols a, int32_t b) {
|
||||
return static_cast<JKQTPGraphSymbols>(static_cast<uint64_t>(a)+b);
|
||||
}
|
||||
|
||||
inline JKQTPGraphSymbols operator+(JKQTPGraphSymbols a, int64_t b) {
|
||||
return static_cast<JKQTPGraphSymbols>(static_cast<uint64_t>(a)+b);
|
||||
}
|
||||
|
||||
/** \brief converts a JKQTPGraphSymbols variable into a identifier string
|
||||
* \ingroup jkqtptools_drawing
|
||||
*/
|
||||
@ -243,9 +278,11 @@ JKQTCOMMON_LIB_EXPORT double JKQTPLineDecoratorStyleCalcDecoratorSize(double lin
|
||||
\param symbolLineWidth width of the lines used to draw the symbol
|
||||
\param color color of the symbol lines
|
||||
\param fillColor color of the symbol filling
|
||||
\param symbolFont font used to draw symbols like \c JKQTPCharacterSymbol+QChar('@').unicode()
|
||||
|
||||
*/
|
||||
template <class TPainter>
|
||||
inline void JKQTPPlotSymbol(TPainter& painter, double x, double y, JKQTPGraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor);
|
||||
inline void JKQTPPlotSymbol(TPainter& painter, double x, double y, JKQTPGraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor, QFont symbolFont);
|
||||
|
||||
/*! \brief plot the specified symbol at pixel position x,y
|
||||
\ingroup jkqtptools_drawing
|
||||
@ -258,8 +295,10 @@ inline void JKQTPPlotSymbol(TPainter& painter, double x, double y, JKQTPGraphSym
|
||||
\param symbolLineWidth width of the lines used to draw the symbol
|
||||
\param color color of the symbol lines
|
||||
\param fillColor color of the symbol filling
|
||||
\param symbolFont font used to draw symbols like \c JKQTPCharacterSymbol+QChar('@').unicode()
|
||||
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT void JKQTPPlotSymbol(QPaintDevice& paintDevice, double x, double y, JKQTPGraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor);
|
||||
JKQTCOMMON_LIB_EXPORT void JKQTPPlotSymbol(QPaintDevice& paintDevice, double x, double y, JKQTPGraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor, const QFont &symbolFont);
|
||||
|
||||
|
||||
|
||||
@ -443,7 +482,7 @@ inline void JKQTPDrawTooltip(TPainter& painter, double x, double y, const QRectF
|
||||
|
||||
|
||||
template <class TPainter>
|
||||
inline void JKQTPPlotSymbol(TPainter& painter, double x, double y, JKQTPGraphSymbols symbol, double symbolSize, double symbolLineWidth, QColor color, QColor fillColor) {
|
||||
inline void JKQTPPlotSymbol(TPainter& painter, double x, double y, JKQTPGraphSymbols symbol, double symbolSize, double symbolLineWidth, QColor color, QColor fillColor, QFont symbolFont) {
|
||||
if (symbol==JKQTPNoSymbol) return;
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
QPen p=painter.pen();
|
||||
@ -810,8 +849,31 @@ inline void JKQTPPlotSymbol(TPainter& painter, double x, double y, JKQTPGraphSym
|
||||
|
||||
case JKQTPNoSymbol:
|
||||
case JKQTPSymbolCount:
|
||||
case JKQTPCharacterSymbol:
|
||||
break;
|
||||
}
|
||||
if (symbol>=JKQTPCharacterSymbol && symbol<=JKQTPCharacterSymbol+0xFFFF) {
|
||||
symbolFont.setStyleStrategy(QFont::PreferDefault);
|
||||
const QChar ch(static_cast<uint16_t>(symbol-JKQTPCharacterSymbol));
|
||||
const QFontMetricsF fm(symbolFont);
|
||||
const QRectF tbr=fm.tightBoundingRect(ch);
|
||||
const double scale=symbolSize/qMax(tbr.width(), tbr.height());
|
||||
painter.translate(QPointF(x,y));
|
||||
//painter.setPen(QColor("yellow"));
|
||||
//painter.drawEllipse(QPointF(0,0),symbolSize/2.0,symbolSize/2.0);
|
||||
painter.scale(scale,scale);
|
||||
//painter.setPen(QColor("green"));
|
||||
//painter.drawRect(tbr);
|
||||
//painter.drawEllipse(QPointF(0,0),2,2);
|
||||
painter.translate(-tbr.center());//QPointF(-tbr.width()/2.0,-tbr.height()/2.0)+QPointF(tbr.x(),tbr.y()));
|
||||
//painter.setPen(QColor("red"));
|
||||
//painter.drawRect(tbr);
|
||||
//painter.drawEllipse(QPointF(0,0),2,2);
|
||||
painter.setBrush(QColor(Qt::transparent));
|
||||
painter.setPen(pDescaled.color());
|
||||
painter.setFont(symbolFont);
|
||||
painter.drawText(0.0,0.0,ch);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ QIcon JKQTPGraphSymbols2Icon(JKQTPGraphSymbols style)
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
p.setRenderHint(QPainter::TextAntialiasing);
|
||||
p.setPen(QPen(QColor(Qt::black), 1, Qt::SolidLine));
|
||||
JKQTPPlotSymbol(p, icon.width()/2, icon.height()/2, style, 15, 1, QColor("black"), QColor("silver"));
|
||||
JKQTPPlotSymbol(p, icon.width()/2, icon.height()/2, style, 15, 1, QColor("black"), QColor("silver"),QGuiApplication::font().family());
|
||||
p.end();
|
||||
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ JKQTPGraphBoxplotStyleMixin::JKQTPGraphBoxplotStyleMixin()
|
||||
m_meanSymbolType=JKQTPGraphSymbols::JKQTPDefaultSymbol;
|
||||
m_meanSymbolSize=12;
|
||||
m_meanSymbolFillColor=m_meanSymbolLinePen.color().lighter();
|
||||
m_meanSymbolFontName=QGuiApplication::font().family();
|
||||
|
||||
|
||||
boxWidthAbsolute=m_meanSymbolSize*3.0;
|
||||
@ -80,6 +81,7 @@ void JKQTPGraphBoxplotStyleMixin::initBoxplotStyle(JKQTBasePlotter *parent, int
|
||||
m_meanSymbolLineWidth=pen.symbolLineWidthF();
|
||||
m_meanSymbolType=pen.symbol();
|
||||
m_meanSymbolFillColor=pen.symbolFillColor();
|
||||
m_meanSymbolFontName=parent->getDefaultTextFontName();
|
||||
}
|
||||
|
||||
setWhiskerLineColor(getLineColor());
|
||||
@ -218,6 +220,23 @@ double JKQTPGraphBoxplotStyleMixin::getMeanLineWidth() const
|
||||
return m_meanSymbolLineWidth;
|
||||
}
|
||||
|
||||
void JKQTPGraphBoxplotStyleMixin::setMeanSymbolFontName(const QString &__value)
|
||||
{
|
||||
m_meanSymbolFontName=__value;
|
||||
}
|
||||
|
||||
QString JKQTPGraphBoxplotStyleMixin::getMeanSymbolFontName() const
|
||||
{
|
||||
return m_meanSymbolFontName;
|
||||
}
|
||||
|
||||
QFont JKQTPGraphBoxplotStyleMixin::getMeanSymbolFont() const
|
||||
{
|
||||
QFont f(m_meanSymbolFontName, m_meanSymbolSize);
|
||||
f.setStyleStrategy(QFont::PreferDefault);
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
void JKQTPGraphBoxplotStyleMixin::setMeanLineStyle(Qt::PenStyle __value)
|
||||
{
|
||||
@ -563,7 +582,7 @@ QBrush JKQTPGraphBoxplotStyleMixin::getMeanSymbolBrush(JKQTPEnhancedPainter& /*p
|
||||
|
||||
void JKQTPGraphBoxplotStyleMixin::plotStyledMeanSymbol(JKQTBasePlotter *parent, JKQTPEnhancedPainter &painter, double x, double y) const
|
||||
{
|
||||
JKQTPPlotSymbol(painter, x, y,m_meanSymbolType, parent->pt2px(painter, m_meanSymbolSize), parent->pt2px(painter, m_meanSymbolLineWidth*parent->getLineWidthMultiplier()), m_meanSymbolLinePen.color(), m_meanSymbolFillColor);
|
||||
JKQTPPlotSymbol(painter, x, y,m_meanSymbolType, parent->pt2px(painter, m_meanSymbolSize), parent->pt2px(painter, m_meanSymbolLineWidth*parent->getLineWidthMultiplier()), m_meanSymbolLinePen.color(), m_meanSymbolFillColor, getMeanSymbolFont());
|
||||
}
|
||||
|
||||
|
||||
|
@ -318,6 +318,13 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGraphBoxplotStyleMixin: public JKQTPGraphLineS
|
||||
void setMeanLineWidth(double __value);
|
||||
/** \brief get the line width of the symbol for the mean outline, or mean line (in pt) */
|
||||
double getMeanLineWidth() const;
|
||||
/** \brief set the font to be used for mean character symbols \c JKQTPCharacterSymbol+QChar('').unicode() */
|
||||
void setMeanSymbolFontName(const QString& __value);
|
||||
/** \brief get the font to be used for mean character symbols \c JKQTPCharacterSymbol+QChar('').unicode() */
|
||||
QString getMeanSymbolFontName() const;
|
||||
|
||||
/** \brief generate a QFont for darwing symbols */
|
||||
QFont getMeanSymbolFont() const;
|
||||
|
||||
/** \brief constructs a QPen from the line styling properties to draw the mean line */
|
||||
QPen getMeanLinePen(JKQTPEnhancedPainter &painter, JKQTBasePlotter* parent) const;
|
||||
@ -398,6 +405,8 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGraphBoxplotStyleMixin: public JKQTPGraphLineS
|
||||
QColor m_meanSymbolFillColor;
|
||||
/** \brief width (in pt) of the lines used to plot the symbol for the data points, given in pt */
|
||||
double m_meanSymbolLineWidth;
|
||||
/** \brief font to be used for character mean symbols \c JKQTPCharacterSymbol+QChar('').unicode() */
|
||||
QString m_meanSymbolFontName;
|
||||
/** \brief line style of the whisker lines */
|
||||
QPen m_whiskerLinePen;
|
||||
/** \brief line width (in pt) of the whisker lines */
|
||||
|
@ -66,7 +66,7 @@ void JKQTPEvaluatedFunctionGraphBase::drawSamplePoints(JKQTPEnhancedPainter& pai
|
||||
painter.save(); auto __finalpaintsamplepoints=JKQTPFinally([&painter]() {painter.restore();});
|
||||
for (const auto& d: data) {
|
||||
if (JKQTPIsOKFloat(d.x()) && JKQTPIsOKFloat(d.y())) {
|
||||
JKQTPPlotSymbol(painter, d.x(), d.y(), JKQTPCross, 6,1*parent->getLineWidthMultiplier(), c, QColor(Qt::transparent));
|
||||
JKQTPPlotSymbol(painter, d.x(), d.y(), JKQTPCross, 6,1*parent->getLineWidthMultiplier(), c, QColor(Qt::transparent), QGuiApplication::font().family());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ void JKQTPGeoSymbol::draw(JKQTPEnhancedPainter &painter)
|
||||
void JKQTPGeoSymbol::drawKeyMarker(JKQTPEnhancedPainter &painter, QRectF &rect)
|
||||
{
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
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());
|
||||
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(),getSymbolFont());
|
||||
}
|
||||
|
||||
QColor JKQTPGeoSymbol::getKeyLabelColor() const
|
||||
|
@ -143,9 +143,6 @@ void JKQTPGeoLine::draw(JKQTPEnhancedPainter& painter) {
|
||||
//points[0]=lx1;
|
||||
//points[points.size()-1]=lx2;
|
||||
painter.drawPolylineFast(points.data(), points.size());
|
||||
/*for (auto& p: points) {
|
||||
JKQTPPlotSymbol(painter, p.x(), p.y(), JKQTPPlus, 5, 1, QColor("green"), QColor("darkgreen"));
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -422,9 +419,6 @@ void JKQTPGeoInfiniteLine::draw(JKQTPEnhancedPainter& painter) {
|
||||
const QPointF xx1p=points[1];
|
||||
angle1=atan2(xx1p.y()-xx1.y(), xx1p.x()-xx1.x());
|
||||
painter.drawPolylineFast(points.data(), points.size());
|
||||
/*for (auto& p: points) {
|
||||
JKQTPPlotSymbol(painter, p.x(), p.y(), JKQTPPlus, 5, 1, QColor("green"), QColor("darkgreen"));
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@ -609,9 +603,6 @@ void JKQTPGeoPolyLines::draw(JKQTPEnhancedPainter& painter) {
|
||||
angle2=atan2(xx2p.y()-xx2.y(), xx2p.x()-xx2.x());
|
||||
painter.drawPolylineFast(points_poly.data(), points_poly.size());
|
||||
doDrawDecorator=true;
|
||||
/*for (auto& p: points_poly) {
|
||||
JKQTPPlotSymbol(painter, p.x(), p.y(), JKQTPPlus, 5, 1, QColor("green"), QColor("darkgreen"));
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -207,6 +207,8 @@ JKQTPOverlayImageEnhanced::JKQTPOverlayImageEnhanced(double x, double y, double
|
||||
symbolLineWidth=1;
|
||||
drawMode=OverlayImageEnhancedDrawMode::DrawAsRectangles;
|
||||
symbolSizeFactor=0.9;
|
||||
m_symbolFontName=parent->getDefaultTextFontName();
|
||||
|
||||
}
|
||||
|
||||
JKQTPOverlayImageEnhanced::JKQTPOverlayImageEnhanced(JKQTBasePlotter *parent):
|
||||
@ -216,6 +218,8 @@ JKQTPOverlayImageEnhanced::JKQTPOverlayImageEnhanced(JKQTBasePlotter *parent):
|
||||
symbolLineWidth=1;
|
||||
drawMode=OverlayImageEnhancedDrawMode::DrawAsRectangles;
|
||||
symbolSizeFactor=0.9;
|
||||
m_symbolFontName=parent->getDefaultTextFontName();
|
||||
|
||||
}
|
||||
|
||||
JKQTPOverlayImageEnhanced::JKQTPOverlayImageEnhanced(double x, double y, double width, double height, bool* data, int Nx, int Ny, QColor colTrue, JKQTPlotter* parent):
|
||||
@ -225,6 +229,8 @@ JKQTPOverlayImageEnhanced::JKQTPOverlayImageEnhanced(double x, double y, double
|
||||
symbolLineWidth=1;
|
||||
drawMode=OverlayImageEnhancedDrawMode::DrawAsRectangles;
|
||||
symbolSizeFactor=0.9;
|
||||
m_symbolFontName=parent->getPlotter()->getDefaultTextFontName();
|
||||
|
||||
}
|
||||
|
||||
JKQTPOverlayImageEnhanced::JKQTPOverlayImageEnhanced(JKQTPlotter *parent):
|
||||
@ -234,11 +240,13 @@ JKQTPOverlayImageEnhanced::JKQTPOverlayImageEnhanced(JKQTPlotter *parent):
|
||||
symbolLineWidth=1;
|
||||
drawMode=OverlayImageEnhancedDrawMode::DrawAsRectangles ;
|
||||
symbolSizeFactor=0.9;
|
||||
m_symbolFontName=parent->getPlotter()->getDefaultTextFontName();
|
||||
|
||||
}
|
||||
|
||||
void JKQTPOverlayImageEnhanced::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) {
|
||||
if (drawMode!=OverlayImageEnhancedDrawMode::DrawAsSymbols) JKQTPOverlayImage::drawKeyMarker(painter, rect);
|
||||
else JKQTPPlotSymbol(painter, rect.center().x(), rect.center().y(), symbol, qMin(rect.width(), rect.height()), parent->pt2px(painter, symbolLineWidth*parent->getLineWidthMultiplier()), trueColor, trueColor.lighter());
|
||||
else JKQTPPlotSymbol(painter, rect.center().x(), rect.center().y(), symbol, qMin(rect.width(), rect.height()), parent->pt2px(painter, symbolLineWidth*parent->getLineWidthMultiplier()), trueColor, trueColor.lighter(), m_symbolFontName);
|
||||
}
|
||||
|
||||
void JKQTPOverlayImageEnhanced::setSymbolType(JKQTPGraphSymbols __value)
|
||||
@ -251,6 +259,17 @@ JKQTPGraphSymbols JKQTPOverlayImageEnhanced::getSymbol() const
|
||||
return this->symbol;
|
||||
}
|
||||
|
||||
|
||||
void JKQTPOverlayImageEnhanced::setSymbolFontName(const QString& __value)
|
||||
{
|
||||
this->m_symbolFontName = __value;
|
||||
}
|
||||
|
||||
QString JKQTPOverlayImageEnhanced::getSymbolFontName() const
|
||||
{
|
||||
return this->m_symbolFontName;
|
||||
}
|
||||
|
||||
void JKQTPOverlayImageEnhanced::setSymbolLineWidth(double __value)
|
||||
{
|
||||
this->symbolLineWidth = __value;
|
||||
@ -314,7 +333,7 @@ void JKQTPOverlayImageEnhanced::draw(JKQTPEnhancedPainter& painter) {
|
||||
} else if (drawMode==DrawAsSymbols){
|
||||
QPointF p=(p1+p2)/2.0;
|
||||
if (data[ix+iy*Nx]) {
|
||||
JKQTPPlotSymbol(painter, p.x(), p.y(), symbol, fabs(p2.x()-p1.x())*symbolSizeFactor, parent->pt2px(painter, symbolLineWidth*parent->getLineWidthMultiplier()), trueColor, trueColor.lighter());
|
||||
JKQTPPlotSymbol(painter, p.x(), p.y(), symbol, fabs(p2.x()-p1.x())*symbolSizeFactor, parent->pt2px(painter, symbolLineWidth*parent->getLineWidthMultiplier()), trueColor, trueColor.lighter(),QFont(m_symbolFontName,10));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -173,6 +173,10 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPOverlayImageEnhanced: public JKQTPOverlayImage
|
||||
void setSymbolSizeFactor(double __value);
|
||||
/** \copydoc symbolSizeFactor */
|
||||
double getSymbolSizeFactor() const;
|
||||
/** \brief set the font to be used for character symbols \c JKQTPCharacterSymbol+QChar('').unicode() */
|
||||
void setSymbolFontName(const QString& __value);
|
||||
/** \brief get the font to be used for character symbols \c JKQTPCharacterSymbol+QChar('').unicode() */
|
||||
QString getSymbolFontName() const;
|
||||
|
||||
protected:
|
||||
/** \brief which symbol to use for the datapoints */
|
||||
@ -185,6 +189,8 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPOverlayImageEnhanced: public JKQTPOverlayImage
|
||||
|
||||
/** \brief a rescaling factor for the symbols */
|
||||
double symbolSizeFactor;
|
||||
/** \brief font to be used for character symbols \c JKQTPCharacterSymbol+QChar('').unicode() */
|
||||
QString m_symbolFontName;
|
||||
|
||||
|
||||
};
|
||||
|
@ -104,7 +104,7 @@ void JKQTPXYLineGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv) && JKQTPIsOKFloat(x) && JKQTPIsOKFloat(y)) {
|
||||
|
||||
//if (isHighlighted() && getSymbolType()!=JKQTPNoSymbol) {
|
||||
//JKQTPPlotSymbol(painter, x, y, JKQTPFilledCircle, parent->pt2px(painter, symbolSize*1.5), parent->pt2px(painter, symbolWidth*parent->getLineWidthMultiplier()), penSelection.color(), penSelection.color());
|
||||
//JKQTPPlotSymbol(painter, x, y, JKQTPFilledCircle, parent->pt2px(painter, symbolSize*1.5), parent->pt2px(painter, symbolWidth*parent->getLineWidthMultiplier()), penSelection.color(), penSelection.color(),getSymbolFont());
|
||||
//}
|
||||
if ((!parent->getXAxis()->isLogAxis() || xv>0.0) && (!parent->getYAxis()->isLogAxis() || yv>0.0) ) {
|
||||
if (symType!=JKQTPNoSymbol && cliprect.contains(x,y)) plotStyledSymbol(parent, painter, x, y);
|
||||
@ -156,7 +156,7 @@ void JKQTPXYLineGraph::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect
|
||||
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(), getKeySymbolSizePx(painter, rect, parent), getKeySymbolLineWidthPx(painter, rect, parent), 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(),getSymbolFont());
|
||||
}
|
||||
|
||||
QColor JKQTPXYLineGraph::getKeyLabelColor() const {
|
||||
|
@ -117,7 +117,7 @@ void JKQTPXYScatterGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
|
||||
void JKQTPXYScatterGraph::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) {
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
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());
|
||||
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(),getSymbolFont());
|
||||
}
|
||||
|
||||
QColor JKQTPXYScatterGraph::getKeyLabelColor() const {
|
||||
@ -364,9 +364,9 @@ void JKQTPXYParametrizedScatterGraph::draw(JKQTPEnhancedPainter &painter)
|
||||
|
||||
if ((!parent->getXAxis()->isLogAxis() || xv>0.0) && (!parent->getYAxis()->isLogAxis() || yv>0.0) ) {
|
||||
if (isHighlighted() && getSymbolType()!=JKQTPNoSymbol && symbolColumn<0) {
|
||||
JKQTPPlotSymbol(painter, x, y, JKQTPFilledCircle,symbSize, parent->pt2px(painter, getSymbolLineWidth()*parent->getLineWidthMultiplier()), penSelection.color(), penSelection.color());
|
||||
JKQTPPlotSymbol(painter, x, y, JKQTPFilledCircle,symbSize, parent->pt2px(painter, getSymbolLineWidth()*parent->getLineWidthMultiplier()), penSelection.color(), penSelection.color(),getSymbolFont());
|
||||
} else {
|
||||
JKQTPPlotSymbol(painter, x, y, getLocalSymbolType(i), symbSize, parent->pt2px(painter, getSymbolLineWidth()*parent->getLineWidthMultiplier()), symbColor, symbFillColor);
|
||||
JKQTPPlotSymbol(painter, x, y, getLocalSymbolType(i), symbSize, parent->pt2px(painter, getSymbolLineWidth()*parent->getLineWidthMultiplier()), symbColor, symbFillColor,getSymbolFont());
|
||||
}
|
||||
}
|
||||
|
||||
@ -461,8 +461,8 @@ void JKQTPXYParametrizedScatterGraph::drawKeyMarker(JKQTPEnhancedPainter &painte
|
||||
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));
|
||||
JKQTPPlotSymbol(painter, x1, y1, symbol1, symbolSize1, getKeySymbolLineWidthPx(painter, rect, parent,0.5), color1, JKQTPGetDerivedColor(symbolFillDerivationMode, color1),getSymbolFont());
|
||||
JKQTPPlotSymbol(painter, x2, y2, symbol2, symbolSize2, getKeySymbolLineWidthPx(painter, rect, parent,0.5), color2, JKQTPGetDerivedColor(symbolFillDerivationMode, color2),getSymbolFont());
|
||||
if (drawLine) painter.drawLine(QLineF(x1,y1, x2,y2));
|
||||
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ void JKQTPSingleColumnSymbolsGraph::drawKeyMarker(JKQTPEnhancedPainter &painter,
|
||||
QPen p=getSymbolPen(painter, parent);
|
||||
painter.setPen(p);
|
||||
if (positionScatterStyle!=RugPlot) {
|
||||
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(), symbolSize, symbolWidth, getKeyLabelColor(), getSymbolFillColor(),getSymbolFont());
|
||||
} else {
|
||||
painter.translate(rect.center());
|
||||
if (dataDirection==DataDirection::X) {
|
||||
|
@ -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) {
|
||||
JKQTPPlotSymbol(painter, rect.center().x(), rect.center().y(), getSymbolType(), getKeySymbolSizePx(painter, rect, parent), getKeySymbolLineWidthPx(painter, rect, parent), getKeyLabelColor(), getSymbolFillColor());
|
||||
JKQTPPlotSymbol(painter, rect.center().x(), rect.center().y(), getSymbolType(), getKeySymbolSizePx(painter, rect, parent), getKeySymbolLineWidthPx(painter, rect, parent), getKeyLabelColor(), getSymbolFillColor(),getSymbolFont());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ JKQTPGraphViolinplotStyleMixin::JKQTPGraphViolinplotStyleMixin()
|
||||
m_meanSymbolType=JKQTPGraphSymbols::JKQTPDefaultSymbol;
|
||||
m_meanSymbolSize=12;
|
||||
m_meanSymbolFillColor=m_meanSymbolLinePen.color().lighter();
|
||||
m_meanSymbolFontName=QGuiApplication::font().family();
|
||||
|
||||
|
||||
violinWidthAbsolute=m_meanSymbolSize*6.0;
|
||||
@ -78,6 +79,7 @@ void JKQTPGraphViolinplotStyleMixin::initViolinplotStyle(JKQTBasePlotter *parent
|
||||
m_meanSymbolLineWidth=pen.symbolLineWidthF();
|
||||
m_meanSymbolType=pen.symbol();
|
||||
m_meanSymbolFillColor=pen.symbolFillColor();
|
||||
m_meanSymbolFontName=parent->getDefaultTextFontName();
|
||||
}
|
||||
|
||||
setWhiskerLineColor(getLineColor());
|
||||
@ -147,6 +149,16 @@ JKQTPGraphSymbols JKQTPGraphViolinplotStyleMixin::getMeanSymbolType() const
|
||||
return m_meanSymbolType;
|
||||
}
|
||||
|
||||
void JKQTPGraphViolinplotStyleMixin::setMeanSymbolFontName(const QString &__value)
|
||||
{
|
||||
m_meanSymbolFontName=__value;
|
||||
}
|
||||
|
||||
QString JKQTPGraphViolinplotStyleMixin::getMeanSymbolFontName() const
|
||||
{
|
||||
return m_meanSymbolFontName;
|
||||
}
|
||||
|
||||
void JKQTPGraphViolinplotStyleMixin::setMeanSize(double __value)
|
||||
{
|
||||
m_meanSymbolSize=__value;
|
||||
@ -187,6 +199,13 @@ double JKQTPGraphViolinplotStyleMixin::getMeanLineWidth() const
|
||||
return m_meanSymbolLineWidth;
|
||||
}
|
||||
|
||||
QFont JKQTPGraphViolinplotStyleMixin::getMeanSymbolFont() const
|
||||
{
|
||||
QFont f(m_meanSymbolFontName, m_meanSymbolSize);
|
||||
f.setStyleStrategy(QFont::PreferDefault);
|
||||
return f;
|
||||
}
|
||||
|
||||
JKQTPGraphViolinplotStyleMixin::ViolinStyle JKQTPGraphViolinplotStyleMixin::getViolinStyle() const
|
||||
{
|
||||
return m_violinStyle;
|
||||
@ -552,7 +571,7 @@ QBrush JKQTPGraphViolinplotStyleMixin::getMeanSymbolBrush(JKQTPEnhancedPainter&
|
||||
|
||||
void JKQTPGraphViolinplotStyleMixin::plotStyledMeanSymbol(JKQTBasePlotter *parent, JKQTPEnhancedPainter &painter, double x, double y) const
|
||||
{
|
||||
JKQTPPlotSymbol(painter, x, y,m_meanSymbolType, parent->pt2px(painter, m_meanSymbolSize), parent->pt2px(painter, m_meanSymbolLineWidth*parent->getLineWidthMultiplier()), m_meanSymbolLinePen.color(), m_meanSymbolFillColor);
|
||||
JKQTPPlotSymbol(painter, x, y,m_meanSymbolType, parent->pt2px(painter, m_meanSymbolSize), parent->pt2px(painter, m_meanSymbolLineWidth*parent->getLineWidthMultiplier()), m_meanSymbolLinePen.color(), m_meanSymbolFillColor, getMeanSymbolFont());
|
||||
}
|
||||
|
||||
|
||||
|
@ -274,6 +274,10 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGraphViolinplotStyleMixin: public JKQTPGraphLi
|
||||
void setMeanSymbolType(JKQTPGraphSymbols __value);
|
||||
/** \brief get the type of the symbol for the mean */
|
||||
JKQTPGraphSymbols getMeanSymbolType() const;
|
||||
/** \brief set the font to be used for mean character symbols \c JKQTPCharacterSymbol+QChar('').unicode() */
|
||||
void setMeanSymbolFontName(const QString& __value);
|
||||
/** \brief get the font to be used for mean character symbols \c JKQTPCharacterSymbol+QChar('').unicode() */
|
||||
QString getMeanSymbolFontName() const;
|
||||
|
||||
/** \brief set the size (=diameter in pt) of the symbol for the mean (in pt) */
|
||||
void setMeanSize(double __value);
|
||||
@ -336,6 +340,8 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGraphViolinplotStyleMixin: public JKQTPGraphLi
|
||||
|
||||
/** \brief set the color of the graph (colors all elements, based on the given color \a c , sets background colors from \a bc ) */
|
||||
void setViolinplotColor(QColor c, QColor bc, JKQTBasePlotter *parent);
|
||||
/** \brief generate a QFont for darwing symbols */
|
||||
QFont getMeanSymbolFont() const;
|
||||
protected:
|
||||
/*! \brief plot a symbol at location x,y (in painter coordinates), using the current style
|
||||
|
||||
@ -397,6 +403,9 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGraphViolinplotStyleMixin: public JKQTPGraphLi
|
||||
QColor m_meanSymbolFillColor;
|
||||
/** \brief width (in pt) of the lines used to plot the symbol for the data points, given in pt */
|
||||
double m_meanSymbolLineWidth;
|
||||
/** \brief font to be used for character mean symbols \c JKQTPCharacterSymbol+QChar('').unicode() */
|
||||
QString m_meanSymbolFontName;
|
||||
|
||||
/** \brief line style of the whisker lines */
|
||||
QPen m_whiskerLinePen;
|
||||
/** \brief line width (in pt) of the whisker lines */
|
||||
|
@ -110,7 +110,7 @@ void JKQTPSymbolComboBox::addSymbol(JKQTPGraphSymbols symbol, const QString &nam
|
||||
p.begin(&pix);
|
||||
p.setRenderHint(JKQTPEnhancedPainter::Antialiasing);
|
||||
p.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing);
|
||||
JKQTPPlotSymbol(p, 6.0*dpr,6.0*dpr,symbol,10.0*dpr,1,QColor("blue"), QColor("blue").lighter());
|
||||
JKQTPPlotSymbol(p, 6.0*dpr,6.0*dpr,symbol,10.0*dpr,1,QColor("blue"), QColor("blue").lighter(),font().family());
|
||||
p.end();
|
||||
addItem(QIcon(pix), name, JKQTPGraphSymbols2String(symbol));
|
||||
}
|
||||
@ -186,7 +186,7 @@ void JKQTPLinePlotStyleComboBox::addSymbol(JKQTPGraphSymbols symbol, bool line,
|
||||
p.begin(&pix);
|
||||
p.setRenderHint(JKQTPEnhancedPainter::Antialiasing);
|
||||
p.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing);
|
||||
JKQTPPlotSymbol(p, 6.0*dpr,6.0*dpr,symbol,7.0*dpr,1,QColor("blue"), QColor("blue").lighter());
|
||||
JKQTPPlotSymbol(p, 6.0*dpr,6.0*dpr,symbol,7.0*dpr,1,QColor("blue"), QColor("blue").lighter(), font().family());
|
||||
p.setPen(QColor("blue"));
|
||||
if (line) p.drawLine(0,6*dpr,12*dpr,6*dpr);
|
||||
p.end();
|
||||
@ -505,7 +505,7 @@ void JKQTPLinePlotStyleWithSymbolSizeComboBox::addSymbol(JKQTPGraphSymbols symbo
|
||||
p.begin(&pix);
|
||||
p.setRenderHint(JKQTPEnhancedPainter::Antialiasing);
|
||||
p.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing);
|
||||
JKQTPPlotSymbol(p, double(pixSize)/2.0,double(pixSize)/2.0,symbol,symbolSize,1,QColor("blue"), QColor("blue").lighter());
|
||||
JKQTPPlotSymbol(p, double(pixSize)/2.0,double(pixSize)/2.0,symbol,symbolSize,1,QColor("blue"), QColor("blue").lighter(), font().family());
|
||||
p.setPen(QColor("blue"));
|
||||
if (line) p.drawLine(QLineF(0,double(pixSize)/2.0,pixSize,double(pixSize)/2.0));
|
||||
p.end();
|
||||
|
@ -207,6 +207,7 @@ JKQTPGraphSymbolStyleMixin::JKQTPGraphSymbolStyleMixin()
|
||||
m_symbolSize=12;
|
||||
m_symbolFillColor=m_symbolColor.lighter();
|
||||
m_symbolLineWidth=1;
|
||||
m_symbolFontName=QGuiApplication::font().family();
|
||||
}
|
||||
|
||||
void JKQTPGraphSymbolStyleMixin::initSymbolStyle(JKQTBasePlotter *parent, int& parentPlotStyle, JKQTPPlotStyleType styletype)
|
||||
@ -219,6 +220,7 @@ void JKQTPGraphSymbolStyleMixin::initSymbolStyle(JKQTBasePlotter *parent, int& p
|
||||
m_symbolLineWidth=pen.symbolLineWidthF();
|
||||
m_symbolType=pen.symbol();
|
||||
m_symbolFillColor=pen.symbolFillColor();
|
||||
m_symbolFontName=parent->getDefaultTextFontName();
|
||||
}
|
||||
}
|
||||
|
||||
@ -277,6 +279,16 @@ double JKQTPGraphSymbolStyleMixin::getSymbolLineWidth() const
|
||||
return m_symbolLineWidth;
|
||||
}
|
||||
|
||||
void JKQTPGraphSymbolStyleMixin::setSymbolFontName(const QString &__value)
|
||||
{
|
||||
m_symbolFontName=__value;
|
||||
}
|
||||
|
||||
QString JKQTPGraphSymbolStyleMixin::getSymbolFontName() const
|
||||
{
|
||||
return m_symbolFontName;
|
||||
}
|
||||
|
||||
double JKQTPGraphSymbolStyleMixin::getKeySymbolLineWidthPx(JKQTPEnhancedPainter& painter, const QRectF& keyRect, const JKQTBasePlotter *parent, double maxSymbolSizeFracton) const
|
||||
{
|
||||
const double minSize=qMin(keyRect.width(), keyRect.height());
|
||||
@ -310,25 +322,20 @@ QBrush JKQTPGraphSymbolStyleMixin::getSymbolBrush(JKQTPEnhancedPainter& /*painte
|
||||
return b;
|
||||
}
|
||||
|
||||
void JKQTPGraphSymbolStyleMixin::plotStyledSymbol(JKQTBasePlotter* parent, JKQTPEnhancedPainter &painter, double x, double y) const
|
||||
QFont JKQTPGraphSymbolStyleMixin::getSymbolFont() const
|
||||
{
|
||||
JKQTPPlotSymbol(painter, x, y,m_symbolType, parent->pt2px(painter, m_symbolSize), parent->pt2px(painter, m_symbolLineWidth*parent->getLineWidthMultiplier()), m_symbolColor, m_symbolFillColor);
|
||||
QFont f(m_symbolFontName, m_symbolSize);
|
||||
f.setStyleStrategy(QFont::PreferDefault);
|
||||
return f;
|
||||
}
|
||||
|
||||
void JKQTPGraphSymbolStyleMixin::plotStyledSymbol(JKQTBasePlotter* parent, JKQTPEnhancedPainter &painter, double x, double y, JKQTPGraphSymbols type) const
|
||||
{
|
||||
JKQTPPlotSymbol(painter, x, y,type, parent->pt2px(painter, m_symbolSize), parent->pt2px(painter, m_symbolLineWidth*parent->getLineWidthMultiplier()), m_symbolColor, m_symbolFillColor);
|
||||
}
|
||||
|
||||
void JKQTPGraphSymbolStyleMixin::plotStyledSymbol(JKQTBasePlotter* parent, JKQTPEnhancedPainter &painter, double x, double y, double symbolSize) const
|
||||
{
|
||||
JKQTPPlotSymbol(painter, x, y,m_symbolType, symbolSize, parent->pt2px(painter, m_symbolLineWidth*parent->getLineWidthMultiplier()), m_symbolColor, m_symbolFillColor);
|
||||
}
|
||||
|
||||
void JKQTPGraphSymbolStyleMixin::plotStyledSymbol(JKQTBasePlotter* parent, JKQTPEnhancedPainter &painter, double x, double y, QColor color, QColor fillColor) const
|
||||
{
|
||||
JKQTPPlotSymbol(painter, x, y,m_symbolType, parent->pt2px(painter, m_symbolSize), parent->pt2px(painter, m_symbolLineWidth*parent->getLineWidthMultiplier()), color, fillColor);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -363,6 +363,7 @@ private:
|
||||
- symbol (outline) color
|
||||
- symbol fill color (not required for all symbols)
|
||||
- symbol (line) width
|
||||
- symbol font name (family) for character symbols \c JKQTPCharacterSymbol+QChar('').unicode()
|
||||
.
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPGraphSymbolStyleMixin {
|
||||
@ -402,6 +403,11 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGraphSymbolStyleMixin {
|
||||
/** \brief get the line width of the graph symbol outline (in pt) */
|
||||
double getSymbolLineWidth() const;
|
||||
|
||||
/** \brief set the font to be used for character symbols \c JKQTPCharacterSymbol+QChar('').unicode() */
|
||||
void setSymbolFontName(const QString& __value);
|
||||
/** \brief get the font to be used for character symbols \c JKQTPCharacterSymbol+QChar('').unicode() */
|
||||
QString getSymbolFontName() const;
|
||||
|
||||
|
||||
|
||||
#ifndef JKQTPLOTTER_WORKAROUND_QGADGET_BUG
|
||||
@ -410,8 +416,9 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGraphSymbolStyleMixin {
|
||||
Q_PROPERTY(QColor symbolFillColor MEMBER m_symbolFillColor READ getSymbolFillColor WRITE setSymbolFillColor)
|
||||
Q_PROPERTY(double symbolSize MEMBER m_symbolSize READ getSymbolSize WRITE setSymbolSize)
|
||||
Q_PROPERTY(double symbolLineWidth MEMBER m_symbolLineWidth READ getSymbolLineWidth WRITE setSymbolLineWidth)
|
||||
Q_PROPERTY(QString symbolFontName MEMBER m_symbolFontName READ getSymbolFontName WRITE setSymbolFontName)
|
||||
#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 */
|
||||
@ -422,11 +429,15 @@ private:
|
||||
QColor m_symbolFillColor;
|
||||
/** \brief width (in pt) of the lines used to plot the symbol for the data points, given in pt */
|
||||
double m_symbolLineWidth;
|
||||
/** \brief font to be used for character symbols \c JKQTPCharacterSymbol+QChar('').unicode() */
|
||||
QString m_symbolFontName;
|
||||
protected:
|
||||
/** \brief constructs a QPen from the line styling properties */
|
||||
QPen getSymbolPen(JKQTPEnhancedPainter &painter, JKQTBasePlotter* parent) const;
|
||||
/** \brief constructs a QPen from the line styling properties */
|
||||
QBrush getSymbolBrush(JKQTPEnhancedPainter &painter, JKQTBasePlotter* parent) const;
|
||||
/** \brief generate a QFont for darwing symbols */
|
||||
QFont getSymbolFont() const;
|
||||
/*! \brief plot a symbol at location x,y (in painter coordinates), using the current style
|
||||
|
||||
\param parent parent JKQTBasePlotter of the graph that uses this mix-in (used e.g. for line-width transformation)
|
||||
@ -434,7 +445,10 @@ private:
|
||||
\param x x-coordinate of the symbol center
|
||||
\param y y-coordinate of the symbol center
|
||||
*/
|
||||
void plotStyledSymbol(JKQTBasePlotter* parent, JKQTPEnhancedPainter& painter, double x, double y) const;
|
||||
inline void plotStyledSymbol(JKQTBasePlotter* parent, JKQTPEnhancedPainter& painter, double x, double y) const
|
||||
{
|
||||
JKQTPPlotSymbol(painter, x, y,m_symbolType, parent->pt2px(painter, m_symbolSize), parent->pt2px(painter, m_symbolLineWidth*parent->getLineWidthMultiplier()), m_symbolColor, m_symbolFillColor, getSymbolFont());
|
||||
}
|
||||
/*! \brief plot a symbol at location x,y (in painter coordinates), using the current style
|
||||
|
||||
\param parent parent JKQTBasePlotter of the graph that uses this mix-in (used e.g. for line-width transformation)
|
||||
@ -443,7 +457,10 @@ private:
|
||||
\param y y-coordinate of the symbol center
|
||||
\param symbolSize size of the symbol
|
||||
*/
|
||||
void plotStyledSymbol(JKQTBasePlotter* parent, JKQTPEnhancedPainter& painter, double x, double y, double symbolSize) const;
|
||||
inline void plotStyledSymbol(JKQTBasePlotter* parent, JKQTPEnhancedPainter& painter, double x, double y, double symbolSize) const
|
||||
{
|
||||
JKQTPPlotSymbol(painter, x, y,m_symbolType, symbolSize, parent->pt2px(painter, m_symbolLineWidth*parent->getLineWidthMultiplier()), m_symbolColor, m_symbolFillColor, getSymbolFont());
|
||||
}
|
||||
/*! \brief plot a symbol at location x,y (in painter coordinates), using the current style
|
||||
|
||||
\param parent parent JKQTBasePlotter of the graph that uses this mix-in (used e.g. for line-width transformation)
|
||||
@ -452,7 +469,10 @@ private:
|
||||
\param y y-coordinate of the symbol center
|
||||
\param type type of the symbol
|
||||
*/
|
||||
void plotStyledSymbol(JKQTBasePlotter* parent, JKQTPEnhancedPainter& painter, double x, double y, JKQTPGraphSymbols type) const;
|
||||
inline void plotStyledSymbol(JKQTBasePlotter* parent, JKQTPEnhancedPainter& painter, double x, double y, JKQTPGraphSymbols type) const
|
||||
{
|
||||
JKQTPPlotSymbol(painter, x, y,type, parent->pt2px(painter, m_symbolSize), parent->pt2px(painter, m_symbolLineWidth*parent->getLineWidthMultiplier()), m_symbolColor, m_symbolFillColor, getSymbolFont());
|
||||
}
|
||||
/*! \brief plot a symbol at location x,y (in painter coordinates), using the current style
|
||||
|
||||
\param parent parent JKQTBasePlotter of the graph that uses this mix-in (used e.g. for line-width transformation)
|
||||
@ -462,7 +482,10 @@ private:
|
||||
\param color color of the symbol
|
||||
\param fillColor fill color of the symbol
|
||||
*/
|
||||
void plotStyledSymbol(JKQTBasePlotter* parent, JKQTPEnhancedPainter& painter, double x, double y, QColor color, QColor fillColor) const;
|
||||
inline void plotStyledSymbol(JKQTBasePlotter* parent, JKQTPEnhancedPainter& painter, double x, double y, QColor color, QColor fillColor) const
|
||||
{
|
||||
JKQTPPlotSymbol(painter, x, y,m_symbolType, parent->pt2px(painter, m_symbolSize), parent->pt2px(painter, m_symbolLineWidth*parent->getLineWidthMultiplier()), color, fillColor, getSymbolFont());
|
||||
}
|
||||
/** \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. */
|
||||
|
Loading…
Reference in New Issue
Block a user