mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-11-15 18:15:52 +08:00
add symbol JKQTPFilledCharacterSymbol
This commit is contained in:
parent
2831dcbfb5
commit
f6def4b9d1
@ -43,7 +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 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: 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: 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>
|
<li>NEW: added the option to draw a character from a font as symbol (<code>JKQTPCharacterSymbol+QChar('C').unicode()</code> and <code>JKQTPFilledCharacterSymbol+QChar('C').unicode()</code>)</li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
|
|
||||||
<li>JKQTMathText:<ul>
|
<li>JKQTMathText:<ul>
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 457 B After Width: | Height: | Size: 1.1 KiB |
BIN
doc/images/symbols/symbol_char_club.png
Normal file
BIN
doc/images/symbols/symbol_char_club.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 610 B |
BIN
doc/images/symbols/symbol_filled_char_at.png
Normal file
BIN
doc/images/symbols/symbol_filled_char_at.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
BIN
doc/images/symbols/symbol_filled_char_club.png
Normal file
BIN
doc/images/symbols/symbol_filled_char_club.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
@ -92,13 +92,19 @@ QString JKQTPGraphSymbols2String(JKQTPGraphSymbols pos) {
|
|||||||
case JKQTPCirclePeace: return "symbol_circle_peace";
|
case JKQTPCirclePeace: return "symbol_circle_peace";
|
||||||
case JKQTPSymbolCount: JKQTPGraphSymbols2String(JKQTPMaxSymbolID);
|
case JKQTPSymbolCount: JKQTPGraphSymbols2String(JKQTPMaxSymbolID);
|
||||||
case JKQTPCharacterSymbol:
|
case JKQTPCharacterSymbol:
|
||||||
|
case JKQTPFilledCharacterSymbol:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (pos>=JKQTPCharacterSymbol && pos<=JKQTPCharacterSymbol+0xFF) {
|
if (pos>=JKQTPCharacterSymbol && pos<=JKQTPCharacterSymbol+0xFFFF) {
|
||||||
QString s=QString::number(pos-JKQTPCharacterSymbol,16);
|
QString s=QString::number(pos-JKQTPCharacterSymbol,16);
|
||||||
while (s.size()<4) s="0"+s;
|
while (s.size()<4) s="0"+s;
|
||||||
return "symbol_char"+s;
|
return "symbol_char"+s;
|
||||||
}
|
}
|
||||||
|
if (pos>=JKQTPFilledCharacterSymbol && pos<=JKQTPFilledCharacterSymbol+0xFFFF) {
|
||||||
|
QString s=QString::number(pos-JKQTPFilledCharacterSymbol,16);
|
||||||
|
while (s.size()<4) s="0"+s;
|
||||||
|
return "symbol_filled_char"+s;
|
||||||
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,11 +175,16 @@ QString JKQTPGraphSymbols2NameString(JKQTPGraphSymbols pos) {
|
|||||||
case JKQTPMale: return QObject::tr("male");
|
case JKQTPMale: return QObject::tr("male");
|
||||||
case JKQTPCirclePeace: return QObject::tr("circled peace");
|
case JKQTPCirclePeace: return QObject::tr("circled peace");
|
||||||
case JKQTPSymbolCount: JKQTPGraphSymbols2NameString(JKQTPMaxSymbolID);
|
case JKQTPSymbolCount: JKQTPGraphSymbols2NameString(JKQTPMaxSymbolID);
|
||||||
case JKQTPCharacterSymbol: break;
|
case JKQTPCharacterSymbol:
|
||||||
|
case JKQTPFilledCharacterSymbol:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (pos>=JKQTPCharacterSymbol && pos<=JKQTPCharacterSymbol+0xFF) {
|
if (pos>=JKQTPCharacterSymbol && pos<=JKQTPCharacterSymbol+0xFFFF) {
|
||||||
return QObject::tr("character")+" '"+QChar(static_cast<uint16_t>(pos-JKQTPCharacterSymbol))+"'";
|
return QObject::tr("character")+" '"+QChar(static_cast<uint16_t>(pos-JKQTPCharacterSymbol))+"'";
|
||||||
}
|
}
|
||||||
|
if (pos>=JKQTPFilledCharacterSymbol && pos<=JKQTPFilledCharacterSymbol+0xFFFF) {
|
||||||
|
return QObject::tr("filled character")+" '"+QChar(static_cast<uint16_t>(pos-JKQTPFilledCharacterSymbol))+"'";
|
||||||
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
JKQTPGraphSymbols String2JKQTPGraphSymbols(const QString& pos) {
|
JKQTPGraphSymbols String2JKQTPGraphSymbols(const QString& pos) {
|
||||||
@ -256,6 +267,18 @@ JKQTPGraphSymbols String2JKQTPGraphSymbols(const QString& pos) {
|
|||||||
if (posT.startsWith("symbol_char")) {
|
if (posT.startsWith("symbol_char")) {
|
||||||
return JKQTPCharacterSymbol+posT.mid(11).toUInt(nullptr,16);
|
return JKQTPCharacterSymbol+posT.mid(11).toUInt(nullptr,16);
|
||||||
}
|
}
|
||||||
|
if (posT.startsWith("symbol_fillcharsym") && posT.size()>18) {
|
||||||
|
return JKQTPFilledCharacterSymbol+posT[18].unicode();
|
||||||
|
}
|
||||||
|
if (posT.startsWith("fillcharsym") && posT.size()>11) {
|
||||||
|
return JKQTPFilledCharacterSymbol+posT[11].unicode();
|
||||||
|
}
|
||||||
|
if (posT.startsWith("filled_char")) {
|
||||||
|
return JKQTPFilledCharacterSymbol+posT.mid(11).toUInt(nullptr,16);
|
||||||
|
}
|
||||||
|
if (posT.startsWith("symbol_filled_char")) {
|
||||||
|
return JKQTPFilledCharacterSymbol+posT.mid(18).toUInt(nullptr,16);
|
||||||
|
}
|
||||||
return JKQTPNoSymbol;
|
return JKQTPNoSymbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,13 @@ enum JKQTPGraphSymbols: uint64_t {
|
|||||||
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> */
|
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 */
|
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()" */
|
JKQTPCharacterSymbol=0x100, /*!< \brief draw a font-character as symbol with defined fill-brush (taken from symbol-color), 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()"
|
||||||
|
\image html symbols/symbol_char_club.png "generated by JKQTPCharacterSymbol+QChar(0x2663).unicode()" */
|
||||||
|
JKQTPFilledCharacterSymbol=JKQTPCharacterSymbol+0xFFFF+0xF, /*!< \brief draw a font-character as symbol with defined outline-pen and fill-brush, you can use any character from a QFont by supplying \c JKQTPFilledCharacterSymbol+QChar('').unicode() as JKQTPGraphSymbols
|
||||||
|
\image html symbols/symbol_filled_char_at.png "generated by JKQTPFilledCharacterSymbol+QChar('@').unicode()"
|
||||||
|
\image html symbols/symbol_filled_char_club.png "generated by JKQTPFilledCharacterSymbol+QChar(0x2663).unicode()"
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
inline JKQTPGraphSymbols operator+(JKQTPGraphSymbols a, uint8_t b) {
|
inline JKQTPGraphSymbols operator+(JKQTPGraphSymbols a, uint8_t b) {
|
||||||
@ -506,6 +512,8 @@ inline void JKQTPPlotSymbol(TPainter& painter, double x, double y, JKQTPGraphSym
|
|||||||
p.setCapStyle(Qt::FlatCap);
|
p.setCapStyle(Qt::FlatCap);
|
||||||
QPen pDescaled=p;
|
QPen pDescaled=p;
|
||||||
pDescaled.setWidthF(pDescaled.widthF()/symbolSize);
|
pDescaled.setWidthF(pDescaled.widthF()/symbolSize);
|
||||||
|
QFont fDescaled=symbolFont;
|
||||||
|
fDescaled.setPointSizeF(fDescaled.pointSizeF()/symbolSize);
|
||||||
const QBrush b=QBrush(fillColor, Qt::SolidPattern);
|
const QBrush b=QBrush(fillColor, Qt::SolidPattern);
|
||||||
|
|
||||||
|
|
||||||
@ -864,6 +872,7 @@ inline void JKQTPPlotSymbol(TPainter& painter, double x, double y, JKQTPGraphSym
|
|||||||
case JKQTPNoSymbol:
|
case JKQTPNoSymbol:
|
||||||
case JKQTPSymbolCount:
|
case JKQTPSymbolCount:
|
||||||
case JKQTPCharacterSymbol:
|
case JKQTPCharacterSymbol:
|
||||||
|
case JKQTPFilledCharacterSymbol:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (symbol>=JKQTPCharacterSymbol && symbol<=JKQTPCharacterSymbol+0xFFFF) {
|
if (symbol>=JKQTPCharacterSymbol && symbol<=JKQTPCharacterSymbol+0xFFFF) {
|
||||||
@ -883,12 +892,27 @@ inline void JKQTPPlotSymbol(TPainter& painter, double x, double y, JKQTPGraphSym
|
|||||||
//painter.setPen(QColor("red"));
|
//painter.setPen(QColor("red"));
|
||||||
//painter.drawRect(tbr);
|
//painter.drawRect(tbr);
|
||||||
//painter.drawEllipse(QPointF(0,0),2,2);
|
//painter.drawEllipse(QPointF(0,0),2,2);
|
||||||
painter.setBrush(QColor(Qt::transparent));
|
painter.setBrush(color);
|
||||||
painter.setPen(pDescaled.color());
|
painter.setPen(Qt::NoPen);
|
||||||
painter.setFont(symbolFont);
|
QPainterPath path;
|
||||||
painter.drawText(0.0,0.0,ch);
|
path.addText(0,0,symbolFont, ch),
|
||||||
|
painter.drawPath(path);
|
||||||
|
}
|
||||||
|
if (symbol>=JKQTPFilledCharacterSymbol && symbol<=JKQTPFilledCharacterSymbol+0xFFFF) {
|
||||||
|
symbolFont.setStyleStrategy(QFont::PreferDefault);
|
||||||
|
const QChar ch(static_cast<uint16_t>(symbol-JKQTPFilledCharacterSymbol));
|
||||||
|
const QFontMetricsF fm(symbolFont);
|
||||||
|
const QRectF tbr=fm.tightBoundingRect(ch);
|
||||||
|
const double scale=symbolSize/qMax(tbr.width(), tbr.height());
|
||||||
|
painter.setPen(p);
|
||||||
|
painter.translate(QPointF(x,y));
|
||||||
|
painter.scale(scale,scale);
|
||||||
|
painter.translate(-tbr.center());//QPointF(-tbr.width()/2.0,-tbr.height()/2.0)+QPointF(tbr.x(),tbr.y()));
|
||||||
|
painter.setBrush(b);
|
||||||
|
QPainterPath path;
|
||||||
|
path.addText(0,0,symbolFont, ch),
|
||||||
|
painter.drawPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class TPainter>
|
template <class TPainter>
|
||||||
|
@ -79,13 +79,32 @@ int main(int argc, char* argv[])
|
|||||||
JKQTPEnhancedPainter p;
|
JKQTPEnhancedPainter p;
|
||||||
startPainting(img, p, iconsize, backgroundColor);
|
startPainting(img, p, iconsize, backgroundColor);
|
||||||
JKQTPPlotSymbol(p, iconsize/2,iconsize/2,s,iconsize-4,2,QColor("blue"), QColor("salmon").lighter(120),QGuiApplication::font().family());
|
JKQTPPlotSymbol(p, iconsize/2,iconsize/2,s,iconsize-4,2,QColor("blue"), QColor("salmon").lighter(120),QGuiApplication::font().family());
|
||||||
|
p.setPen(QPen(QColor("green"),0.5));
|
||||||
|
//p.drawRect(2,2,iconsize-4,iconsize-4);
|
||||||
stopPaintingAndSave(img, p, outputDir.absoluteFilePath(JKQTPGraphSymbols2String(s)+".png"));
|
stopPaintingAndSave(img, p, outputDir.absoluteFilePath(JKQTPGraphSymbols2String(s)+".png"));
|
||||||
}
|
}
|
||||||
QImage img;
|
QImage img;
|
||||||
JKQTPEnhancedPainter p;
|
JKQTPEnhancedPainter p;
|
||||||
startPainting(img, p, iconsize, backgroundColor);
|
startPainting(img, p, iconsize, backgroundColor);
|
||||||
JKQTPPlotSymbol(p, iconsize/2,iconsize/2,JKQTPCharacterSymbol+QChar('@').unicode(),iconsize-4,2,QColor("blue"), QColor("blue").lighter(),QGuiApplication::font().family());
|
JKQTPPlotSymbol(p, iconsize/2,iconsize/2,JKQTPCharacterSymbol+QChar('@').unicode(),iconsize-4,1,QColor("blue"), QColor("salmon").lighter(120),QGuiApplication::font().family());
|
||||||
|
p.setPen(QPen(QColor("green"),0.5));
|
||||||
|
//p.drawRect(2,2,iconsize-4,iconsize-4);
|
||||||
stopPaintingAndSave(img, p, outputDir.absoluteFilePath("symbol_char_at.png"));
|
stopPaintingAndSave(img, p, outputDir.absoluteFilePath("symbol_char_at.png"));
|
||||||
|
startPainting(img, p, iconsize, backgroundColor);
|
||||||
|
JKQTPPlotSymbol(p, iconsize/2,iconsize/2,JKQTPFilledCharacterSymbol+QChar('@').unicode(),iconsize-4,0.5,QColor("blue"), QColor("salmon").lighter(120),QGuiApplication::font().family());
|
||||||
|
p.setPen(QPen(QColor("green"),0.5));
|
||||||
|
//p.drawRect(2,2,iconsize-4,iconsize-4);
|
||||||
|
stopPaintingAndSave(img, p, outputDir.absoluteFilePath("symbol_filled_char_at.png"));
|
||||||
|
startPainting(img, p, iconsize, backgroundColor);
|
||||||
|
JKQTPPlotSymbol(p, iconsize/2,iconsize/2,JKQTPCharacterSymbol+QChar(0x2663).unicode(),iconsize-4,1,QColor("blue"), QColor("salmon").lighter(120),QGuiApplication::font().family());
|
||||||
|
p.setPen(QPen(QColor("green"),0.5));
|
||||||
|
//p.drawRect(2,2,iconsize-4,iconsize-4);
|
||||||
|
stopPaintingAndSave(img, p, outputDir.absoluteFilePath("symbol_char_club.png"));
|
||||||
|
startPainting(img, p, iconsize, backgroundColor);
|
||||||
|
JKQTPPlotSymbol(p, iconsize/2,iconsize/2,JKQTPFilledCharacterSymbol+QChar(0x2663).unicode(),iconsize-4,0.5,QColor("blue"), QColor("salmon").lighter(120),QGuiApplication::font().family());
|
||||||
|
p.setPen(QPen(QColor("green"),0.5));
|
||||||
|
//p.drawRect(2,2,iconsize-4,iconsize-4);
|
||||||
|
stopPaintingAndSave(img, p, outputDir.absoluteFilePath("symbol_filled_char_club.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listlinedecorators) {
|
if (listlinedecorators) {
|
||||||
|
Loading…
Reference in New Issue
Block a user