mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-24 09:31:40 +08:00
BUGFIX: JKQTMathText: corrected size-calculation and drawing of decorations
This commit is contained in:
parent
9a7e44889f
commit
8814523e63
@ -39,6 +39,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
|
||||
<li>IMPROVED: improved drawing of parantheses, square brackets ... , underbrace/overbrace</li>
|
||||
<li>IMPROVED: added x-correction for sub/superscript above/below/besides integrals</li>
|
||||
<li>IMPROVED: rendering of sqrt</li>
|
||||
<li>IMPROVED: rendering and size calculation of decorations</li>
|
||||
<li>remove/breaking: \v[a-zA-Z] and shorthand for \vec{a-zA-Z} was removed, implementation of \bbR,\bbC,... changed</li>
|
||||
<li>NEW: now supports new decoration instructions: \cancel, \xcancel, \bcancel, \sout, \ocirc, \widetilde, \widehat, \breve</li>
|
||||
<li>NEW: reworked drawing of decorations: improved appearance and positioning!</li>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 39 KiB |
@ -2,16 +2,16 @@
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="116.54318mm"
|
||||
width="129.06662mm"
|
||||
height="40.395004mm"
|
||||
viewBox="0 0 116.54318 40.395004"
|
||||
viewBox="0 0 129.06662 40.395004"
|
||||
version="1.1"
|
||||
id="svg5"
|
||||
inkscape:version="1.1.2 (b8e25be833, 2022-02-05)"
|
||||
sodipodi:docname="decoration_sizing.svg"
|
||||
inkscape:export-filename="C:\Jan\Programmieren\JKQtPlotter\doc\images\mathparser\decoration_sizing.png"
|
||||
inkscape:export-xdpi="132.17781"
|
||||
inkscape:export-ydpi="132.17781"
|
||||
inkscape:export-filename="decoration_sizing.png"
|
||||
inkscape:export-xdpi="169.77347"
|
||||
inkscape:export-ydpi="169.77347"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
@ -26,9 +26,9 @@
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:document-units="mm"
|
||||
showgrid="false"
|
||||
inkscape:zoom="7.2466938"
|
||||
inkscape:cx="281.57668"
|
||||
inkscape:cy="91.352004"
|
||||
inkscape:zoom="10.248373"
|
||||
inkscape:cx="11.367658"
|
||||
inkscape:cy="45.763363"
|
||||
inkscape:window-width="2240"
|
||||
inkscape:window-height="1294"
|
||||
inkscape:window-x="-11"
|
||||
@ -79,12 +79,40 @@
|
||||
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:0.625;stroke-linejoin:round"
|
||||
id="path41029" />
|
||||
</marker>
|
||||
<marker
|
||||
style="overflow:visible"
|
||||
id="Arrow2Sstart-9"
|
||||
refX="0"
|
||||
refY="0"
|
||||
orient="auto"
|
||||
inkscape:stockid="Arrow2Sstart"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
transform="matrix(0.3,0,0,0.3,-0.69,0)"
|
||||
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
|
||||
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:0.625;stroke-linejoin:round"
|
||||
id="path41032-3" />
|
||||
</marker>
|
||||
<marker
|
||||
style="overflow:visible"
|
||||
id="Arrow2Send-4"
|
||||
refX="0"
|
||||
refY="0"
|
||||
orient="auto"
|
||||
inkscape:stockid="Arrow2Send"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
|
||||
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
|
||||
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:0.625;stroke-linejoin:round"
|
||||
id="path41035-2" />
|
||||
</marker>
|
||||
</defs>
|
||||
<g
|
||||
inkscape:label="Ebene 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(0.37879707,-54.001381)">
|
||||
transform="translate(12.902231,-54.001381)">
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:29.5242px;line-height:1.25;font-family:serif;-inkscape-font-specification:serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.738106"
|
||||
@ -272,14 +300,24 @@
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="fill:none;stroke:#ff0000;stroke-width:0.15;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 43.308196,64.697419 H 16.432587"
|
||||
d="M 43.308196,65.226586 H 16.432587"
|
||||
id="path71291"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="fill:none;stroke:#00ff00;stroke-width:0.204488;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow2Sstart);marker-end:url(#Arrow2Send)"
|
||||
d="M 18.017019,66.004509 V 64.943516"
|
||||
style="fill:none;stroke:#ff0000;stroke-width:0.15;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 43.107481,62.727487 H 16.231872"
|
||||
id="path71291-9"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="fill:none;stroke:#00ff00;stroke-width:0.254784;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow2Sstart);marker-end:url(#Arrow2Send)"
|
||||
d="M 22.617393,64.818871 V 63.171772"
|
||||
id="path71457"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="fill:none;stroke:#0000ff;stroke-width:0.164726;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow2Sstart-9);marker-end:url(#Arrow2Send-4)"
|
||||
d="M 17.328991,66.102139 V 65.413644"
|
||||
id="path71457-2"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="fill:none;stroke:#ff0000;stroke-width:0.283136px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-start:url(#Arrow2Sstart);marker-end:url(#Arrow2Send)"
|
||||
d="M 17.204484,86.922066 17.240995,66.78305"
|
||||
@ -300,19 +338,14 @@
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.11667px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif Italic';fill:#008000;fill-opacity:1;stroke:none;stroke-width:0.264583"
|
||||
x="-0.48039722"
|
||||
y="63.43644"
|
||||
x="6.0915651"
|
||||
y="61.318806"
|
||||
id="text73109"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan73107"
|
||||
style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.11667px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Italic';fill:#00ff00;stroke-width:0.264583"
|
||||
x="-0.48039722"
|
||||
y="63.43644">decoration_height_factor </tspan><tspan
|
||||
sodipodi:role="line"
|
||||
style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.11667px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Italic';fill:#00ff00;stroke-width:0.264583"
|
||||
x="-0.48039722"
|
||||
y="66.082275"
|
||||
id="tspan78903">* baseline_height</tspan></text>
|
||||
x="6.0915651"
|
||||
y="61.318806"
|
||||
id="tspan78903">decoration_height_factor * ascent</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:29.5242px;line-height:1.25;font-family:serif;-inkscape-font-specification:serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.738106"
|
||||
@ -348,5 +381,21 @@
|
||||
x="63.685162"
|
||||
y="93.707977"
|
||||
id="tspan82712">- italic_xcorrection</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.11667px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif Italic';fill:#008000;fill-opacity:1;stroke:none;stroke-width:0.264583"
|
||||
x="-13.003831"
|
||||
y="66.42305"
|
||||
id="text73109-7"><tspan
|
||||
sodipodi:role="line"
|
||||
style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.11667px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Italic';fill:#0000ff;stroke-width:0.264583"
|
||||
x="-13.003831"
|
||||
y="66.42305"
|
||||
id="tspan78903-2">decoration_separation_xfactor </tspan><tspan
|
||||
sodipodi:role="line"
|
||||
style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.11667px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Italic';fill:#0000ff;stroke-width:0.264583"
|
||||
x="-13.003831"
|
||||
y="69.068886"
|
||||
id="tspan7032">* ascent</tspan></text>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 21 KiB |
@ -81,8 +81,9 @@ JKQTMathText::JKQTMathText(QObject* parent):
|
||||
underbrace_separation_xfactor=0.25;
|
||||
underbrace_bracesize_xfactor=0.5;
|
||||
underset_factor=0.7;
|
||||
decoration_height_factor=0.2;
|
||||
decoration_height_factor=0.3;
|
||||
decoration_width_reduction_Xfactor=0.2;
|
||||
decoration_separation_factor=0.1;
|
||||
|
||||
operatorsubsuper_size_factor=0.65;
|
||||
operatorsubsuper_distance_factor=0.25;
|
||||
@ -231,6 +232,7 @@ void JKQTMathText::loadSettings(const QSettings& settings, const QString& group)
|
||||
underset_factor=settings.value(group+"undersetFactor", underset_factor).toDouble();
|
||||
brace_y_shift_factor=settings.value(group+"brace_y_shift_factor", brace_y_shift_factor).toDouble();
|
||||
decoration_height_factor=settings.value(group+"decoration_height_factor", decoration_height_factor).toDouble();
|
||||
decoration_separation_factor=settings.value(group+"decoration_separation_factor", decoration_separation_factor).toDouble();
|
||||
decoration_width_reduction_Xfactor=settings.value(group+"decoration_width_reduction_xfactor", decoration_width_reduction_Xfactor).toDouble();
|
||||
operatorsubsuper_size_factor=settings.value(group+"operatorsubsuper_size_factor", operatorsubsuper_size_factor).toDouble();
|
||||
operatorsubsuper_distance_factor=settings.value(group+"operatorsubsuper_distance_factor", operatorsubsuper_distance_factor).toDouble();
|
||||
@ -275,6 +277,7 @@ void JKQTMathText::saveSettings(QSettings& settings, const QString& group) const
|
||||
settings.setValue(group+ "intsubbesides_xcorrection_xfactor", intsubbesides_xcorrection_xfactor);
|
||||
settings.setValue(group+ "brace_y_shift_factor", brace_y_shift_factor);
|
||||
settings.setValue(group+ "decoration_height_factor", decoration_height_factor);
|
||||
settings.setValue(group+ "decoration_separation_factor", decoration_separation_factor);
|
||||
settings.setValue(group+ "decoration_width_reduction_xfactor", decoration_width_reduction_Xfactor);
|
||||
settings.setValue(group+ "sqrt_width_Xfactor", sqrt_width_Xfactor);
|
||||
settings.setValue(group+ "sqrt_height_factor", sqrt_height_factor);
|
||||
@ -908,7 +911,17 @@ double JKQTMathText::getDecorationHeightFactor() const
|
||||
return this->decoration_height_factor;
|
||||
}
|
||||
|
||||
void JKQTMathText::setDecorationWidthReductionXFactor(double __value)
|
||||
void JKQTMathText::setDecorationSeparationXFactor(double __value)
|
||||
{
|
||||
decoration_separation_factor=__value;
|
||||
}
|
||||
|
||||
double JKQTMathText::getDecorationSeparationFactor() const
|
||||
{
|
||||
return decoration_separation_factor;
|
||||
}
|
||||
|
||||
void JKQTMathText::setDecorationWidthReductionFactor(double __value)
|
||||
{
|
||||
decoration_width_reduction_Xfactor=__value;
|
||||
}
|
||||
|
@ -537,8 +537,12 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject {
|
||||
void setDecorationHeightFactor(double __value);
|
||||
/** \copydoc decoration_height_factor */
|
||||
double getDecorationHeightFactor() const;
|
||||
/** \copydoc decoration_separation_factor */
|
||||
void setDecorationSeparationXFactor(double __value);
|
||||
/** \copydoc decoration_separation_factor */
|
||||
double getDecorationSeparationFactor() const;
|
||||
/** \copydoc decoration_width_reduction_Xfactor */
|
||||
void setDecorationWidthReductionXFactor(double __value);
|
||||
void setDecorationWidthReductionFactor(double __value);
|
||||
/** \copydoc decoration_width_reduction_Xfactor */
|
||||
double getDecorationWidthReductionXFactor() const;
|
||||
|
||||
@ -705,11 +709,16 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject {
|
||||
double underbrace_bracesize_xfactor;
|
||||
/** \brief fraction of the brace ascent that the brace is shifted downwards, when scaled */
|
||||
double brace_y_shift_factor;
|
||||
/** \brief size of the decorations (dot, tilde, ...), as fraction of the baselineheight
|
||||
/** \brief size of the decorations (dot, tilde, ...), as fraction of the ascent
|
||||
*
|
||||
* \image html jkqtmathtext/decoration_sizing.png
|
||||
*/
|
||||
double decoration_height_factor;
|
||||
/** \brief separation between the text and the decorations (dot, tilde, ...), as fraction of the ascent
|
||||
*
|
||||
* \image html jkqtmathtext/decoration_sizing.png
|
||||
*/
|
||||
double decoration_separation_factor;
|
||||
/** \brief a decoration has a size, which is slightly smaller than the text- width. the width is reduced by \c decoration_width_reduction_Xfactor*width("X") and the position is centered around the child-box. Also an italic correction is applied:
|
||||
*
|
||||
* \image html jkqtmathtext/decoration_sizing.png
|
||||
|
@ -98,68 +98,88 @@ JKQTMathTextDecoratedNode::~JKQTMathTextDecoratedNode() {
|
||||
}
|
||||
|
||||
void JKQTMathTextDecoratedNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const JKQTMathTextNodeSize* /*prevNodeSize*/) {
|
||||
const QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
||||
|
||||
getChild()->getSize(painter, currentEv, width, baselineHeight, overallHeight, strikeoutPos);
|
||||
|
||||
const double italic_xcorrection=getNonItalicXCorretion(painter, width, currentEv, getChild());
|
||||
const double decoheightfactor=parentMathText->getDecorationHeightFactor();
|
||||
JKQTMathTextEnvironment ev=currentEv;
|
||||
double cwidth=0, cbaselineHeight=0, coverallHeight=0, cstrikeoutPos=0;
|
||||
getChild()->getSize(painter, ev, cwidth, cbaselineHeight, coverallHeight, cstrikeoutPos);
|
||||
const double cDescent=coverallHeight-cbaselineHeight;
|
||||
const QFont font=ev.getFont(parentMathText);
|
||||
const QFontMetricsF fm(font, painter.device());
|
||||
const double decoSeparation=parentMathText->getDecorationSeparationFactor()*fm.ascent();
|
||||
const double deco_height=parentMathText->getDecorationHeightFactor()*fm.ascent();
|
||||
const double deco_ypos=cbaselineHeight+decoSeparation;
|
||||
const double decoAboveAscent_ypos=fm.ascent()+decoSeparation;
|
||||
const double decobelow_ypos=cDescent+decoSeparation;
|
||||
const double italic_xcorrection=getNonItalicXCorretion(painter, cwidth, ev, getChild());
|
||||
const double deco_miniwidth=((decoration==MTDtilde||decoration==MTDbreve)?fm.boundingRect("~").width():fm.boundingRect("^").width())-italic_xcorrection;
|
||||
|
||||
const double decoAboveAscent_yposdelta=fm.ascent()*(1.0+2.0*decoheightfactor);
|
||||
const double decoAboveBaselineheight_yposdelta=baselineHeight*(1.0+decoheightfactor);
|
||||
const double linewidth=qMax(parentMathText->ABS_MIN_LINEWIDTH, fm.lineWidth());
|
||||
|
||||
|
||||
const double descent=overallHeight-baselineHeight;
|
||||
baselineHeight=decoAboveBaselineheight_yposdelta;
|
||||
|
||||
double descent=coverallHeight-cbaselineHeight;
|
||||
double ascent=cbaselineHeight;
|
||||
if (decoration==MTDbar) {
|
||||
baselineHeight=std::max<double>(baselineHeight, decoAboveAscent_yposdelta);
|
||||
ascent=std::max<double>(baselineHeight+decoSeparation, decoAboveAscent_ypos)+linewidth/2.0;
|
||||
} else if (decoration==MTDunderline) {
|
||||
descent=std::max<double>(decobelow_ypos, cDescent)+linewidth/2.0;
|
||||
} else if (decoration==MTDdoubleunderline) {
|
||||
descent=std::max<double>(decobelow_ypos, cDescent)+2.5*linewidth;
|
||||
} else {
|
||||
ascent=deco_ypos+deco_height;
|
||||
}
|
||||
overallHeight=baselineHeight+descent;
|
||||
width=std::max<double>(deco_miniwidth,width);
|
||||
overallHeight=ascent+descent;
|
||||
baselineHeight=ascent;
|
||||
strikeoutPos=cstrikeoutPos;
|
||||
width=std::max<double>(deco_miniwidth,cwidth);
|
||||
}
|
||||
|
||||
double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* /*prevNodeSize*/) {
|
||||
doDrawBoxes(painter, x, y, currentEv);
|
||||
JKQTMathTextEnvironment ev=currentEv;
|
||||
double width=0, baselineHeight=0, overallHeight=0, strikeoutPos=0;
|
||||
getChild()->getSize(painter, ev, width, baselineHeight, overallHeight, strikeoutPos);
|
||||
double cwidth=0, cbaselineHeight=0, coverallHeight=0, cstrikeoutPos=0;
|
||||
getChild()->getSize(painter, ev, cwidth, cbaselineHeight, coverallHeight, cstrikeoutPos);
|
||||
const double cDescent=coverallHeight-cbaselineHeight;
|
||||
const QFont font=ev.getFont(parentMathText);
|
||||
const QFontMetricsF fm(font, painter.device());
|
||||
const double width_X=fm.boundingRect("X").width();
|
||||
const double width_x=fm.boundingRect("x").width();
|
||||
const double width_dot=fm.boundingRect(".").width()/2.0;
|
||||
const double decoheightfactor=parentMathText->getDecorationHeightFactor();
|
||||
const double deco_ypos=y-baselineHeight*(1.0+decoheightfactor);
|
||||
const double decoAboveAscent_ypos=y-fm.ascent()*(1.0+decoheightfactor);
|
||||
const double strike_ypos=y-baselineHeight/2.0;
|
||||
const double decobelow_ypos=y+qMax((overallHeight-baselineHeight)*(1.0+decoheightfactor), fm.xHeight()*decoheightfactor);
|
||||
const double deco_height=decoheightfactor*baselineHeight;
|
||||
const double italic_xcorrection=getNonItalicXCorretion(painter, width, ev, getChild());
|
||||
const double decoSeparation=parentMathText->getDecorationSeparationFactor()*fm.ascent();
|
||||
const double linewidth=qMax(parentMathText->ABS_MIN_LINEWIDTH, fm.lineWidth());
|
||||
const double deco_height=parentMathText->getDecorationHeightFactor()*fm.ascent();
|
||||
const double decoAboveAscent_ypos=y-fm.ascent()-decoSeparation;
|
||||
const double strike_ypos=y-cbaselineHeight/2.0;
|
||||
const double decobelow_ypos=y+cDescent+decoSeparation;
|
||||
const double italic_xcorrection=getNonItalicXCorretion(painter, cwidth, ev, getChild());
|
||||
const double deco_xoffset=parentMathText->getDecorationWidthReductionXFactor()*width_X/2.0;
|
||||
const double deco_width=std::max<double>(width_x*0.5,width-2.0*deco_xoffset-italic_xcorrection);
|
||||
const double deco_width=std::max<double>(width_x*0.5,cwidth-2.0*deco_xoffset-italic_xcorrection);
|
||||
const double deco_vecwidth=width_x*0.33;
|
||||
const double deco_miniwidth=((decoration==MTDtilde||decoration==MTDbreve)?fm.boundingRect("~").width():fm.boundingRect("^").width())-italic_xcorrection;
|
||||
const double decotop_xcenter=x+italic_xcorrection+(width-italic_xcorrection)/2.0;
|
||||
const double decotop_xstart=decotop_xcenter-deco_width/2.0;
|
||||
const double decotop_xend=decotop_xcenter+deco_width/2.0;
|
||||
const double decobot_xstart=x;
|
||||
const double decobot_xend=x+width-italic_xcorrection;
|
||||
const double deco_vecheight=deco_height*0.33;
|
||||
const double deco_miniwidth=((decoration==MTDtilde||decoration==MTDbreve)?fm.boundingRect("j").width():fm.boundingRect("^").width())-italic_xcorrection;
|
||||
const double decotop_xcenter=x+italic_xcorrection+(cwidth-italic_xcorrection)/2.0;
|
||||
const double decotop_xstart=decotop_xcenter-deco_width/2.0+linewidth/2.0;
|
||||
const double decotop_xend=decotop_xcenter+deco_width/2.0-linewidth/2.0;
|
||||
const double decobot_xstart=x+linewidth/2.0;
|
||||
const double decobot_xend=x+cwidth-italic_xcorrection-linewidth/2.0;
|
||||
const double decobot_xcenter=(decobot_xstart+decobot_xend)/2.0;
|
||||
const double deco_ypos=y-cbaselineHeight-decoSeparation-linewidth/2.0;
|
||||
const double deco_ytop=y-cbaselineHeight-decoSeparation-deco_height+linewidth/2.0;
|
||||
const double deco_ycenter=y-cbaselineHeight-decoSeparation-deco_height/2.0;
|
||||
|
||||
|
||||
|
||||
QPen pold=painter.pen();
|
||||
QPen p=pold;
|
||||
p.setColor(ev.color);
|
||||
p.setWidthF(qMax(parentMathText->ABS_MIN_LINEWIDTH, fm.lineWidth()));//ceil(currentEv.fontSize/16.0));
|
||||
p.setWidthF(linewidth);//ceil(currentEv.fontSize/16.0));
|
||||
p.setCapStyle(Qt::RoundCap);
|
||||
p.setJoinStyle(Qt::RoundJoin);
|
||||
|
||||
double xnew=getChild()->draw(painter, x, y, ev);
|
||||
|
||||
if (decoration==MTDvec) {
|
||||
painter.setPen(p);
|
||||
QPolygonF poly;
|
||||
poly<<QPointF(decotop_xstart, deco_ypos)<<QPointF(decotop_xend, deco_ypos)<<QPointF(decotop_xend-deco_vecwidth, deco_ypos-deco_height*2.0/3.0);
|
||||
poly<<QPointF(decotop_xstart, deco_ypos)<<QPointF(decotop_xend, deco_ypos)<<QPointF(decotop_xend-deco_vecwidth, deco_ypos-deco_vecheight);
|
||||
painter.drawPolyline(poly);
|
||||
painter.setPen(pold);
|
||||
} else if (decoration==MTDoverline) {
|
||||
@ -193,35 +213,35 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK
|
||||
painter.setPen(pold);
|
||||
} else if (decoration==MTDarrow) {
|
||||
painter.setPen(p);
|
||||
const QLineF l(decotop_xstart, deco_ypos+deco_height/2.0, decotop_xend, deco_ypos+deco_height/2.0);
|
||||
const QLineF l(decotop_xstart, deco_ycenter, decotop_xend, deco_ycenter);
|
||||
if (l.length()>0) painter.drawLine(l);
|
||||
QPolygonF poly;
|
||||
poly<<QPointF(decotop_xend-deco_vecwidth, deco_ypos)<<QPointF(decotop_xend, deco_ypos+deco_height/2.0)<<QPointF(decotop_xend-deco_vecwidth, deco_ypos+deco_height);
|
||||
poly<<QPointF(decotop_xend-deco_vecwidth, deco_ypos)<<QPointF(decotop_xend, deco_ycenter)<<QPointF(decotop_xend-deco_vecwidth, deco_ytop);
|
||||
painter.drawPolyline(poly);
|
||||
painter.setPen(pold);
|
||||
} else if (decoration==MTDhat) {
|
||||
painter.setPen(p);
|
||||
QPolygonF poly;
|
||||
poly<<QPointF(decotop_xcenter-0.5*deco_miniwidth, deco_ypos+deco_height/3.0)<<QPointF(decotop_xcenter, deco_ypos)<<QPointF(decotop_xcenter+0.5*deco_miniwidth, deco_ypos+deco_height/3.0);
|
||||
poly<<QPointF(decotop_xcenter-0.5*deco_miniwidth, deco_ypos)<<QPointF(decotop_xcenter, deco_ycenter)<<QPointF(decotop_xcenter+0.5*deco_miniwidth, deco_ypos);
|
||||
painter.drawPolyline(poly);
|
||||
painter.setPen(pold);
|
||||
} else if (decoration==MTDwidehat) {
|
||||
painter.setPen(p);
|
||||
QPolygonF poly;
|
||||
poly<<QPointF(decotop_xstart, deco_ypos+deco_height/2.0)<<QPointF(decotop_xcenter, deco_ypos+deco_height/3.0)<<QPointF(decotop_xend, deco_ypos+deco_height/2.0);
|
||||
poly<<QPointF(decotop_xstart, deco_ypos)<<QPointF(decotop_xcenter, deco_ytop)<<QPointF(decotop_xend, deco_ypos);
|
||||
painter.drawPolyline(poly);
|
||||
painter.setPen(pold);
|
||||
|
||||
} else if (decoration==MTDcheck) {
|
||||
painter.setPen(p);
|
||||
QPolygonF poly;
|
||||
poly<<QPointF(decotop_xcenter-0.5*deco_miniwidth, deco_ypos)<<QPointF(decotop_xcenter, deco_ypos+deco_height/3.0)<<QPointF(decotop_xcenter+0.5*deco_miniwidth, deco_ypos);
|
||||
poly<<QPointF(decotop_xcenter-0.5*deco_miniwidth, deco_ycenter)<<QPointF(decotop_xcenter, deco_ypos)<<QPointF(decotop_xcenter+0.5*deco_miniwidth, deco_ycenter);
|
||||
painter.drawPolyline(poly);
|
||||
painter.setPen(pold);
|
||||
} else if (decoration==MTDwidecheck) {
|
||||
painter.setPen(p);
|
||||
QPolygonF poly;
|
||||
poly<<QPointF(decotop_xstart, deco_ypos-deco_height/2.0)<<QPointF(decotop_xcenter, deco_ypos+deco_height/3.0)<<QPointF(decotop_xend, deco_ypos-deco_height/2.0);
|
||||
poly<<QPointF(decotop_xstart, deco_ytop)<<QPointF(decotop_xcenter, deco_ypos)<<QPointF(decotop_xend, deco_ytop);
|
||||
painter.drawPolyline(poly);
|
||||
painter.setPen(pold);
|
||||
} else if (decoration==MTDbreve) {
|
||||
@ -230,17 +250,18 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK
|
||||
const double x0=decotop_xcenter-deco_miniwidth/2.0;
|
||||
const double x1=decotop_xcenter+deco_miniwidth/2.0;
|
||||
path.moveTo(x0, deco_ypos);
|
||||
path.cubicTo(x0, deco_ypos+deco_height, x1, deco_ypos+deco_height , x1, deco_ypos);
|
||||
path.cubicTo(x0, deco_ytop, x1, deco_ytop , x1, deco_ypos);
|
||||
painter.drawPath(path);
|
||||
painter.setPen(pold);
|
||||
|
||||
} else if (decoration==MTDtilde) {
|
||||
|
||||
painter.setPen(p);
|
||||
QPainterPath path;
|
||||
const double x0=decotop_xcenter-deco_miniwidth/2.0;
|
||||
const double x1=decotop_xcenter+deco_miniwidth/2.0;
|
||||
path.moveTo(x0, deco_ypos);
|
||||
path.cubicTo((x0+x1)/2.0, deco_ypos+deco_height, (x0+x1)/2.0, deco_ypos-deco_height , x1, deco_ypos);
|
||||
path.moveTo(x0, deco_ycenter);
|
||||
path.cubicTo((x0+x1)/2.0, deco_ypos, (x0+x1)/2.0, deco_ytop , x1, deco_ycenter);
|
||||
painter.drawPath(path);
|
||||
painter.setPen(pold);
|
||||
|
||||
@ -249,8 +270,8 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK
|
||||
QPainterPath path;
|
||||
const double x0=decotop_xstart;
|
||||
const double x1=decotop_xend;
|
||||
path.moveTo(x0, deco_ypos);
|
||||
path.cubicTo((x0+x1)/2.0, deco_ypos+deco_height, (x0+x1)/2.0, deco_ypos-deco_height , x1, deco_ypos);
|
||||
path.moveTo(x0, deco_ycenter);
|
||||
path.cubicTo((x0+x1)/2.0, deco_ypos, (x0+x1)/2.0, deco_ytop , x1, deco_ycenter);
|
||||
painter.drawPath(path);
|
||||
painter.setPen(pold);
|
||||
|
||||
@ -258,7 +279,8 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK
|
||||
painter.setPen(p);
|
||||
const QBrush bold=painter.brush();
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
painter.drawEllipse(QPointF(decotop_xcenter, deco_ypos), width_dot/1.5, width_dot/1.5);
|
||||
const double r=qMin(width_dot/1.5, deco_height/2.0-linewidth/2.0);
|
||||
painter.drawEllipse(QPointF(decotop_xcenter, deco_ycenter), r, r);
|
||||
painter.setBrush(bold);
|
||||
painter.setPen(pold);
|
||||
} else if (decoration==MTDdot) {
|
||||
@ -269,7 +291,7 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK
|
||||
b.setColor(ev.color);
|
||||
b.setStyle(Qt::SolidPattern);
|
||||
painter.setBrush(b);
|
||||
painter.drawEllipse(QPointF(decotop_xcenter, deco_ypos), width_dot/2.0, width_dot/2.0);
|
||||
painter.drawEllipse(QPointF(decotop_xcenter, deco_ycenter), width_dot/2.0, width_dot/2.0);
|
||||
painter.setBrush(bold);
|
||||
painter.setPen(pold);
|
||||
} else if (decoration==MTDddot) {
|
||||
@ -280,8 +302,8 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK
|
||||
b.setColor(ev.color);
|
||||
b.setStyle(Qt::SolidPattern);
|
||||
painter.setBrush(b);
|
||||
painter.drawEllipse(QPointF(decotop_xcenter-width_dot, deco_ypos), width_dot/2.0, width_dot/2.0);
|
||||
painter.drawEllipse(QPointF(decotop_xcenter+width_dot, deco_ypos), width_dot/2.0, width_dot/2.0);
|
||||
painter.drawEllipse(QPointF(decotop_xcenter-width_dot, deco_ycenter), width_dot/2.0, width_dot/2.0);
|
||||
painter.drawEllipse(QPointF(decotop_xcenter+width_dot, deco_ycenter), width_dot/2.0, width_dot/2.0);
|
||||
painter.setBrush(bold);
|
||||
painter.setPen(pold);
|
||||
painter.setBrush(bold);
|
||||
@ -308,13 +330,6 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK
|
||||
if (l1.length()>0) painter.drawLine(l1);
|
||||
painter.setPen(pold);
|
||||
}
|
||||
|
||||
/*painter.setPen(QPen(Qt::red, 1.5));
|
||||
painter.drawLine(QLineF(x, deco_ypos, xnew, deco_ypos));
|
||||
painter.setPen(QPen(Qt::green, 1.5));
|
||||
painter.drawLine(QLineF(deco_xstart, deco_ypos+2, deco_xend, deco_ypos+2));
|
||||
painter.drawEllipse(QPointF(deco_xpos_center, deco_ypos+2), 5, 5);
|
||||
painter.setPen(pold);*/
|
||||
return xnew;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user