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
jkqtmathtextfracnode.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 JKQTMATHTEXTFRACNODE_H
25#define JKQTMATHTEXTFRACNODE_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 a \\frac node
36 * \ingroup jkqtmathtext_items
37 *
38 * all fractions re drawn like this:
39 * \image html jkqtmathtext/jkqtmathtext_fracnode_geo.png
40 *
41 * slanted fractions are drawn like this:
42 * \image html jkqtmathtext/jkqtmathtext_sfracnode_geo.png
43 */
45 public:
46
47 /** \brief type of ffractions represented by JKQTMathTextFracNode
48 * \see JKQTMathTextFracNode, JKQTMathTextFracNode::FracType2String()
49 */
50 enum FracType {
51 MTFMfrac, /*!< \brief normal fraction \image html jkqtmathtext/MTFMfrac.png */
52 MTFMdfrac, /*!< \brief normal fraction, without scaling of under/over text \image html jkqtmathtext/MTFMdfrac.png */
53 MTFMtfrac, /*!< \brief text fraction (smaller than MTFMfrac) \image html jkqtmathtext/MTFMtfrac.png */
54 MTFMsfrac, /*!< \brief slanted fraction \image html jkqtmathtext/MTFMsfrac.png */
55 MTFMstfrac, /*!< \brief slanted text fraction \image html jkqtmathtext/MTFMstfrac.png */
56 MTFMunderbrace, /*!< \brief curly underbrace \image html jkqtmathtext/MTFMunderbrace.png */
57 MTFMoverbrace, /*!< \brief curly overbrace \image html jkqtmathtext/MTFMoverbrace.png */
58 MTFMunderbracket, /*!< \brief square underbracket \image html jkqtmathtext/MTFMunderbracket.png */
59 MTFMoverbracket, /*!< \brief square overbracket \image html jkqtmathtext/MTFMoverbracket.png */
60 MTFMstackrel, /*!< \brief binom/fraction without line \image html jkqtmathtext/MTFMstackrel.png */
61 MTFMunderset, /*!< \brief underset text \image html jkqtmathtext/MTFMunderset.png */
62 MTFMoverset /*!< \brief overset text \image html jkqtmathtext/MTFMoverset.png */
63 };
64
65 /** \brief convert a JKQTMathTextFracNode::FracType into a QString
66 * \see JKQTMathTextFracNode::FracType
67 */
68 static QString FracType2String(FracType mode);
69
70 /** \brief returns the FracType corresponding to \a instructionName
71 * \see JKQTMathTextFracNode::FracType
72 */
73 static FracType InstructionName2FracType(const QString& mode);
74
75 /** \brief returns true, if the given \a instructionName can be converted to a FracType
76 * \see JKQTMathTextFracNode::FracType
77 */
78 static bool supportsInstructionName(const QString& instructionName);
79
80
82 virtual ~JKQTMathTextFracNode() override;
83 /** \copydoc JKQTMathTextNode::getTypeName() */
84 virtual QString getTypeName() const override;
85 /** \copydoc JKQTMathTextNode::draw() */
86 virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
87 /** \copydoc JKQTMathTextNode::toHtml() */
88 virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
89 /** \copydoc mode */
91 protected:
92 /** \brief lists all supported instructions */
93 static const QHash<QString, FracType>& instructions();
94 /** \copydoc JKQTMathTextNode::getSizeInternal() */
95 virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
96 /** \brief actual display type of fraction object */
98 /** \brief returns the nesting level of the node (of same type of \a sameType \c ==true) */
99 int getNestingLevel(bool sameType=false) const;
100 /** \brief determines the scaling factor of the fraction (takes into account the nesting level) */
101 double getFracScalingFactor() const;
102};
103
104
105#endif // JKQTMATHTEXTFRACNODE_H
106
107
108
109
110
111
112
113
114
subclass representing a node in the syntax tree, that has two children
Definition jkqtmathtextnode.h:251
subclass representing a \frac node
Definition jkqtmathtextfracnode.h:44
JKQTMathTextFracNode::FracType mode
actual display type of fraction object
Definition jkqtmathtextfracnode.h:97
FracType
type of ffractions represented by JKQTMathTextFracNode
Definition jkqtmathtextfracnode.h:50
@ MTFMstackrel
binom/fraction without line
Definition jkqtmathtextfracnode.h:60
@ MTFMstfrac
slanted text fraction
Definition jkqtmathtextfracnode.h:55
@ MTFMunderset
underset text
Definition jkqtmathtextfracnode.h:61
@ MTFMoverbrace
curly overbrace
Definition jkqtmathtextfracnode.h:57
@ MTFMsfrac
slanted fraction
Definition jkqtmathtextfracnode.h:54
@ MTFMtfrac
text fraction (smaller than MTFMfrac)
Definition jkqtmathtextfracnode.h:53
@ MTFMunderbracket
square underbracket
Definition jkqtmathtextfracnode.h:58
@ MTFMdfrac
normal fraction, without scaling of under/over text
Definition jkqtmathtextfracnode.h:52
@ MTFMoverbracket
square overbracket
Definition jkqtmathtextfracnode.h:59
@ MTFMfrac
normal fraction
Definition jkqtmathtextfracnode.h:51
@ MTFMunderbrace
curly underbrace
Definition jkqtmathtextfracnode.h:56
static const QHash< QString, FracType > & instructions()
lists all supported instructions
virtual QString getTypeName() const override
return the name of this class as a string
JKQTMathTextFracNode(JKQTMathText *parent, JKQTMathTextNode *child_top, JKQTMathTextNode *child_bottom, JKQTMathTextFracNode::FracType mode)
static QString FracType2String(FracType mode)
convert a JKQTMathTextFracNode::FracType into a QString
virtual ~JKQTMathTextFracNode() override
virtual bool toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override
convert node to HTML and returns true on success
JKQTMathTextFracNode::FracType getMode() const
actual display type of fraction object
virtual double draw(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv) const override
draw the contents at the designated position
static bool supportsInstructionName(const QString &instructionName)
returns true, if the given instructionName can be converted to a FracType
int getNestingLevel(bool sameType=false) const
returns the nesting level of the node (of same type of sameType ==true)
double getFracScalingFactor() const
determines the scaling factor of the fraction (takes into account the nesting level)
static FracType InstructionName2FracType(const QString &mode)
returns the FracType corresponding to instructionName
virtual JKQTMathTextNodeSize getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv) const override
determine the size of the node, overwrite this function in derived classes
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
#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