JKQTPlotter trunk/v5.0.0
an extensive Qt5+Qt6 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
Loading...
Searching...
No Matches
jkqtmathtextsubsupernode.h
1/*
2 Copyright (c) 2008-2024 Jan W. Krieger (<jan@jkrieger.de>)
3 with contributions from: Razi Alavizadeh
4
5
6
7 This software is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License (LGPL) as published by
9 the Free Software Foundation, either version 2.1 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License (LGPL) for more details.
16
17 You should have received a copy of the GNU Lesser General Public License (LGPL)
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21
22
23
24#ifndef JKQTMATHTEXTSUBSUPERSCRIPTNODE_H
25#define JKQTMATHTEXTSUBSUPERSCRIPTNODE_H
26#include "jkqtmathtext/jkqtmathtext_imexport.h"
27#include "jkqtmathtext/jkqtmathtexttools.h"
28#include "jkqtmathtext/nodes/jkqtmathtextnode.h"
29#include <QPainter>
30
31class JKQTMathText; // forward
32// JKQTMATHTEXT_LIB_EXPORT
33
34
35/** \brief subclass representing an subscript node with exactly one argument in the syntax tree
36* \ingroup jkqtmathtext_items
37*
38* \image html jkqtmathtext/jkqtmathtext_subscriptnode_getSizeInternal.png
39*/
41public:
43 virtual ~JKQTMathTextSubscriptNode() override;
44 /** \brief like draw(), i.e. draws the node, but allows to draw the subscript with special placement rules after large blocks (e.g. braces), when \a prevNodeSizeForSpecialPlacement is not \c nullptr
45 *
46 * \param painter QPainter to use
47 * \param x x-position, where the drawing starts [Pixel]
48 * \param y Y-position of the baseline, where the drawing starts [Pixel]
49 * \param currentEv JKQTMathTextEnvironment object describing the current drawing environment/settings
50 * \param[in] prevNodeSizeForSpecialPlacement optional parameter, describing the size of the previous node (on the left). This may be used for layout of some nodes (e.g. sub/super to move correctly next to large parantheses ...)
51 *
52 * \return the x position which to use for the next part of the text
53 */
54 double drawWithSpecialPlacement(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSizeForSpecialPlacement) const;
55 /** \copydoc JKQTMathTextNode::draw() */
56 virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
57 /** \copydoc JKQTMathTextNode::getTypeName() */
58 virtual QString getTypeName() const override; /** \brief returns the child node */
59 /** \copydoc JKQTMathTextNode::toHtml() */
60 virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
61 /** \brief like getSize(), i.e. determine the size of the node, but cares for subscript with special placement rules after large blocks (e.g. braces), when \a prevNodeSizeForSpecialPlacement is not \c nullptr
62 *
63 * \param painter painter to use for determining the size
64 * \param currentEv current environment object
65 * \param[in] prevNodeSizeForSpecialPlacement optional parameter, describing the size of the previous node (on the left). This may be used for layout of some nodes (e.g. sub/super to move correctly next to large parantheses ...)
66 *
67 */
68 JKQTMathTextNodeSize getSizeWithSpecialPlacement(QPainter& painter, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSizeForSpecialPlacement) const;
69protected:
70 /** \copydoc JKQTMathTextNode::getSizeInternal() */
71 virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
72};
73
74
75
76
77
78/** \brief subclass representing an superscript node with exactly one argument in the syntax tree
79* \ingroup jkqtmathtext_items
80*
81* \image html jkqtmathtext/jkqtmathtext_subscriptnode_getSizeInternal.png
82*
83* \note a MTlistNode might modify the positioning slightly for special cases (e.g. \c \\int , \c \\sum ... or after braces)
84*/
86public:
88 virtual ~JKQTMathTextSuperscriptNode() override;
89 /** \brief like draw(), but allows to draw the superscript with special placement rules after large blocks (e.g. braces), when \a prevNodeSizeForSpecialPlacement is not \c nullptr
90 *
91 * \param painter QPainter to use
92 * \param x x-position, where the drawing starts [Pixel]
93 * \param y Y-position of the baseline, where the drawing starts [Pixel]
94 * \param currentEv JKQTMathTextEnvironment object describing the current drawing environment/settings
95 * \param[in] prevNodeSizeForSpecialPlacement optional parameter, describing the size of the previous node (on the left). This may be used for layout of some nodes (e.g. sub/super to move correctly next to large parantheses ...)
96 *
97 * \return the x position which to use for the next part of the text
98 */
99 double drawWithSpecialPlacement(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSizeForSpecialPlacement) const;
100 /** \copydoc JKQTMathTextNode::draw() */
101 virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
102 /** \copydoc JKQTMathTextNode::getTypeName() */
103 virtual QString getTypeName() const override;
104 /** \copydoc JKQTMathTextNode::toHtml() */
105 virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
106 /** \brief like getSize(), i.e. determine the size of the node, but cares for superscript with special placement rules after large blocks (e.g. braces), when \a prevNodeSizeForSpecialPlacement is not \c nullptr
107 *
108 * \param painter painter to use for determining the size
109 * \param currentEv current environment object
110 * \param[in] prevNodeSizeForSpecialPlacement optional parameter, describing the size of the previous node (on the left). This may be used for layout of some nodes (e.g. sub/super to move correctly next to large parantheses ...)
111 *
112 */
113 JKQTMathTextNodeSize getSizeWithSpecialPlacement(QPainter& painter, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* prevNodeSizeForSpecialPlacement) const;
114protected:
115 /** \copydoc JKQTMathTextNode::getSizeInternal() */
116 virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
117};
118
119#endif // JKQTMATHTEXTSUBSUPERSCRIPTNODE_H
120
121
122
123
124
125
126
127
128
this class parses a mathematical markup string and can then draw the contained text/equation onto a Q...
Definition jkqtmathtext.h:192
subclass representing one node in the syntax tree
Definition jkqtmathtextnode.h:37
subclass representing a node in the syntax tree, that has one child
Definition jkqtmathtextnode.h:174
subclass representing an subscript node with exactly one argument in the syntax tree
Definition jkqtmathtextsubsupernode.h:40
virtual bool toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override
returns the child node
virtual QString getTypeName() const override
return the name of this class as a string
virtual double draw(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv) const override
draw the contents at the designated position
JKQTMathTextSubscriptNode(JKQTMathText *parent, JKQTMathTextNode *child)
virtual JKQTMathTextNodeSize getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv) const override
determine the size of the node, overwrite this function in derived classes
JKQTMathTextNodeSize getSizeWithSpecialPlacement(QPainter &painter, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize *prevNodeSizeForSpecialPlacement) const
like getSize(), i.e. determine the size of the node, but cares for subscript with special placement r...
double drawWithSpecialPlacement(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize *prevNodeSizeForSpecialPlacement) const
like draw(), i.e. draws the node, but allows to draw the subscript with special placement rules after...
virtual ~JKQTMathTextSubscriptNode() override
subclass representing an superscript node with exactly one argument in the syntax tree
Definition jkqtmathtextsubsupernode.h:85
JKQTMathTextSuperscriptNode(JKQTMathText *parent, JKQTMathTextNode *child)
virtual JKQTMathTextNodeSize getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv) const override
determine the size of the node, overwrite this function in derived classes
double drawWithSpecialPlacement(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize *prevNodeSizeForSpecialPlacement) const
like draw(), but allows to draw the superscript with special placement rules after large blocks (e....
virtual bool toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override
convert node to HTML and returns true on success
virtual QString getTypeName() const override
return the name of this class as a string
virtual ~JKQTMathTextSuperscriptNode() override
virtual double draw(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv) const override
draw the contents at the designated position
JKQTMathTextNodeSize getSizeWithSpecialPlacement(QPainter &painter, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize *prevNodeSizeForSpecialPlacement) const
like getSize(), i.e. determine the size of the node, but cares for superscript with special placement...
#define JKQTMATHTEXT_LIB_EXPORT
Definition jkqtmathtext_imexport.h:108
describes the current drawing environment (base fontname ...)
Definition jkqtmathtexttools.h:304
beschreibt die Größe(n) eines Knotens
Definition jkqtmathtexttools.h:393