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
jkqtmathtextbracenode.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 JKQTMATHTEXTBRACENODE_H
25#define JKQTMATHTEXTBRACENODE_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 brace node
36 * \ingroup jkqtmathtext_items
37 *
38 * \image html jkqtmathtext/jkqtmathtext_bracenode_geo.png
39 *
40 * This node supports the brace-types encoded by JKQTMathTextBraceType:
41 * \copydetails JKQTMathTextBraceType
42 *
43 * In addition it is possible to switch the opening and the closing braces independently on and off.
44 */
46 public:
47
49 virtual ~JKQTMathTextBraceNode() override;
50 /** \copydoc JKQTMathTextNode::draw() */
51 virtual double draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const override;
52 /** \copydoc JKQTMathTextNode::toHtml() */
53 virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override;
54 /** \copydoc JKQTMathTextNode::getTypeName() */
55 virtual QString getTypeName() const override;
56 /** \copydoc openbrace */
58 /** \copydoc closebrace */
60 protected:
61 /** \brief defines the size of the node (JKQTMathTextNodeSize) and additional information */
64 NodeSize(const NodeSize& other);
66 NodeSize& operator=(const NodeSize& other);
68 /** \brief width of the opening brace */
70 /** \brief height of the opening brace */
72 /** \brief width of the closing brace */
74 /** \brief height of the closing brace */
76 };
77 /** \copydoc JKQTMathTextNode::getSizeInternal()
78 *
79 * \note This function internally calls getSizeInternalAndBrace() and returns part of its results.
80 */
81 virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override;
82 /** calculates the size of this node (also returned by getSizeInternal() ) and of the brace */
83 NodeSize getSizeInternalAndBrace(QPainter& painter, JKQTMathTextEnvironment currentEv) const;
84 /**\brief opening brace */
86 /**\brief closing brace */
88 /** \brief calculate the width of the braces, fills JKQTMathTextBraceNode::NodeSize::openBraceWidth/JKQTMathTextBraceNode::NodeSize::closeBraceWidth and JKQTMathTextBraceNode::NodeSize::openBraceHeight/JKQTMathTextBraceNode::NodeSize::closeBraceHeight in \a out, based on \a childSize
89 *
90 * \param[out] out this function fills JKQTMathTextBraceNode::NodeSize::openBraceWidth/JKQTMathTextBraceNode::NodeSize::closeBraceWidth and JKQTMathTextBraceNode::NodeSize::openBraceHeight/JKQTMathTextBraceNode::NodeSize::closeBraceHeight in \a out
91 * \param painter a QPainter used for size-calculation/drawing
92 * \param currentEv font environment
93 * \param childSize size of the child node surrounded by the node
94 */
95 void calcBraceSizes(NodeSize& out, QPainter& painter, const JKQTMathTextEnvironment& currentEv, const JKQTMathTextNodeSize &childSize) const;
96 /** \brief calculate the width and height of a brace, based on \a childSize
97 *
98 * \param fm QFontMetricsF object describing the font of the current environment
99 * \param bracetype brace type
100 * \param childSize size of the child node surrounded by the node
101 *
102 * \return width and hieght of the brace
103 */
104 QSizeF calcBraceSize(const QFont& fm, QPaintDevice* pd, JKQTMathTextBraceType bracetype, const JKQTMathTextNodeSize &childSize) const;
105};
106
107#endif // JKQTMATHTEXTBRACENODE_H
108
109
110
111
112
113
114
115
116
subclass representing a brace node
Definition jkqtmathtextbracenode.h:45
JKQTMathTextBraceType openbrace
opening brace
Definition jkqtmathtextbracenode.h:85
NodeSize getSizeInternalAndBrace(QPainter &painter, JKQTMathTextEnvironment currentEv) const
void calcBraceSizes(NodeSize &out, QPainter &painter, const JKQTMathTextEnvironment &currentEv, const JKQTMathTextNodeSize &childSize) const
calculate the width of the braces, fills JKQTMathTextBraceNode::NodeSize::openBraceWidth/JKQTMathText...
JKQTMathTextBraceType closebrace
closing brace
Definition jkqtmathtextbracenode.h:87
virtual JKQTMathTextNodeSize getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv) const override
determine the size of the node, overwrite this function in derived classes
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
QSizeF calcBraceSize(const QFont &fm, QPaintDevice *pd, JKQTMathTextBraceType bracetype, const JKQTMathTextNodeSize &childSize) const
calculate the width and height of a brace, based on childSize
virtual ~JKQTMathTextBraceNode() override
JKQTMathTextBraceNode(JKQTMathText *parent, JKQTMathTextBraceType openbrace, JKQTMathTextBraceType closebrace, JKQTMathTextNode *child)
JKQTMathTextBraceType getClosebrace() const
closing brace
virtual double draw(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv) const override
draw the contents at the designated position
JKQTMathTextBraceType getOpenbrace() const
opening brace
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
#define JKQTMATHTEXT_LIB_EXPORT
Definition jkqtmathtext_imexport.h:108
JKQTMathTextBraceType
types of available braces
Definition jkqtmathtexttools.h:222
defines the size of the node (JKQTMathTextNodeSize) and additional information
Definition jkqtmathtextbracenode.h:62
double openBraceHeight
height of the opening brace
Definition jkqtmathtextbracenode.h:71
double openBraceWidth
width of the opening brace
Definition jkqtmathtextbracenode.h:69
NodeSize(const JKQTMathTextNodeSize &other)
double closeBraceWidth
width of the closing brace
Definition jkqtmathtextbracenode.h:73
double closeBraceHeight
height of the closing brace
Definition jkqtmathtextbracenode.h:75
NodeSize & operator=(const JKQTMathTextNodeSize &other)
NodeSize(const NodeSize &other)
NodeSize & operator=(const NodeSize &other)
describes the current drawing environment (base fontname ...)
Definition jkqtmathtexttools.h:304
beschreibt die Größe(n) eines Knotens
Definition jkqtmathtexttools.h:393