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
jkqtmathtextsqrtnode.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 JKQTMATHTEXTSQRTNODE_H
25#define JKQTMATHTEXTSQRTNODE_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
36/** \brief subclass representing a sqrt node
37 * \ingroup jkqtmathtext_items
38 *
39 * This node renders square roots without and with an explicitly shown degree:
40 * \image html jkqtmathtext/jkqtmathtext_sqrt.png
41 * \image html jkqtmathtext/jkqtmathtext_cbrt.png
42 */
44 public:
45 JKQTMathTextSqrtNode(JKQTMathText* parent, JKQTMathTextNode* child__, JKQTMathTextNode* childDegree__=nullptr);
46 virtual ~JKQTMathTextSqrtNode() override;
47 /** \copydoc JKQTMathTextNode::draw() */
48 virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
49 /** \copydoc JKQTMathTextNode::toHtml() */
50 virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
51 /** \copydoc JKQTMathTextNode::getTypeName() */
52 virtual QString getTypeName() const override ;
53
54 /** \copydoc child */
56 /** \copydoc child */
57 const JKQTMathTextNode* getChild() const;
58 /** \copydoc childDegree */
60 /** \copydoc childDegree */
62
63 /** \copydoc JKQTMathTextMultiChildNode::getChild() */
64 virtual JKQTMathTextNode* getChild(int i) override;
65 /** \copydoc JKQTMathTextMultiChildNode::getChild() */
66 virtual const JKQTMathTextNode* getChild(int i) const override;
67 /** \copydoc JKQTMathTextMultiChildNode::getChild() */
68 virtual JKQTMathTextNode* replaceChild(int i, JKQTMathTextNode* newChild) override;
69 /** \copydoc JKQTMathTextMultiChildNode::getChild() */
70 virtual int childCount() const override;
71 /** \copydoc JKQTMathTextMultiChildNode::getChild() */
72 virtual void clearChildren(bool deleteChildren=true) override;
73 /** \copydoc JKQTMathTextMultiChildNode::deleteChild() */
74 virtual void deleteChild(int i) override;
75
76 protected:
77 /** \copydoc JKQTMathTextNode::getSizeInternal() */
78 virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
79 /** \brief child node for the part under the root */
81 /** \brief second child node for the degree of the root (or nullptr if nothing) */
83};
84
85#endif // JKQTMATHTEXTSQRTNODE_H
86
87
88
89
90
91
92
93
94
this class parses a mathematical markup string and can then draw the contained text/equation onto a Q...
Definition jkqtmathtext.h:192
subclass representing a node in the syntax tree, that has two children
Definition jkqtmathtextnode.h:202
subclass representing one node in the syntax tree
Definition jkqtmathtextnode.h:37
subclass representing a sqrt node
Definition jkqtmathtextsqrtnode.h:43
virtual const JKQTMathTextNode * getChild(int i) const override
returns the i-th child node
virtual QString getTypeName() const override
return the name of this class as a string
virtual bool toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override
convert node to HTML and returns true on success
JKQTMathTextNode * getChildDegree()
second child node for the degree of the root (or nullptr if nothing)
JKQTMathTextSqrtNode(JKQTMathText *parent, JKQTMathTextNode *child__, JKQTMathTextNode *childDegree__=nullptr)
JKQTMathTextNode * child
child node for the part under the root
Definition jkqtmathtextsqrtnode.h:80
const JKQTMathTextNode * getChild() const
child node for the part under the root
virtual void clearChildren(bool deleteChildren=true) override
returns the i-th child node
virtual double draw(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv) const override
draw the contents at the designated position
virtual JKQTMathTextNode * getChild(int i) override
returns the i-th child node
virtual JKQTMathTextNode * replaceChild(int i, JKQTMathTextNode *newChild) override
returns the i-th child node
JKQTMathTextNode * childDegree
second child node for the degree of the root (or nullptr if nothing)
Definition jkqtmathtextsqrtnode.h:82
virtual JKQTMathTextNodeSize getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv) const override
determine the size of the node, overwrite this function in derived classes
const JKQTMathTextNode * getChildDegree() const
second child node for the degree of the root (or nullptr if nothing)
virtual ~JKQTMathTextSqrtNode() override
virtual void deleteChild(int i) override
delete the i-th child
JKQTMathTextNode * getChild()
child node for the part under the root
virtual int childCount() const override
returns the i-th child node
#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