#include <QApplication>
#include <QMap>
#include <QDesktopWidget>
#include <QPainter>
#include <QDomNode>
#include "qwt_mml_document.h"
// *******************************************************************
// Declarations
// *******************************************************************
#define ROUND(a) (int)((a)+.5)
static bool g_draw_frames = false;
static const double g_mfrac_spacing = 0.1;
static const double g_mroot_base_margin = 0.1;
static const double g_script_size_multiplier = 0.7071; // sqrt(1/2)
static const int g_min_font_point_size = 8;
static const QChar g_radical_char = QChar( 0x1A, 0x22 );
static const unsigned g_oper_spec_rows = 9;
struct QwtMml
{
enum NodeType
{
NoNode = 0, MiNode, MnNode, MfracNode, MrowNode, MsqrtNode,
MrootNode, MsupNode, MsubNode, MsubsupNode, MoNode,
MstyleNode, TextNode, MphantomNode, MfencedNode,
MtableNode, MtrNode, MtdNode, MoverNode, MunderNode,
MunderoverNode, MerrorNode, MtextNode, MpaddedNode,
MspaceNode, MalignMarkNode, UnknownNode
};
enum MathVariant
{
NormalMV = 0x0000,
BoldMV = 0x0001,
ItalicMV = 0x0002,
DoubleStruckMV = 0x0004,
ScriptMV = 0x0008,
FrakturMV = 0x0010,
SansSerifMV = 0x0020,
MonospaceMV = 0x0040
};
enum FormType { PrefixForm, InfixForm, PostfixForm };
enum ColAlign { ColAlignLeft, ColAlignCenter, ColAlignRight };
enum RowAlign { RowAlignTop, RowAlignCenter, RowAlignBottom,
RowAlignAxis, RowAlignBaseline
};
enum FrameType { FrameNone, FrameSolid, FrameDashed };
struct FrameSpacing
{
FrameSpacing( int hor = 0, int ver = 0 )
: m_hor( hor ), m_ver( ver ) {}
int m_hor, m_ver;
};
};
struct QwtMmlOperSpec
{
enum StretchDir { NoStretch, HStretch, VStretch, HVStretch };
const char *name;
QwtMml::FormType form;
const char *attributes[g_oper_spec_rows];
StretchDir stretch_dir;
};
struct QwtMmlNodeSpec
{
QwtMml::NodeType type;
const char *tag;
const char *type_str;
int child_spec;
const char *child_types;
const char *attributes;
enum ChildSpec
{
ChildAny = -1, // any number of children allowed
ChildIgnore = -2, // do not build subexpression of children
ImplicitMrow = -3 // if more than one child, build mrow
};
};
struct QwtMmlEntitySpec
{
const char *name;
const char *value;
};
typedef QMap<QString, QString> QwtMmlAttributeMap;
class QwtMmlNode;
class QwtMmlDocument : public QwtMml
{
public:
QwtMmlDocument();
~QwtMmlDocument();
void clear();
bool setContent( QString text, QString *errorMsg = 0,
int *errorLine = 0, int *errorColumn = 0 );
void paint( QPainter *p, const QPoint &pos ) const;
void dump() const;
QSize size() const;
void layout();
QString fontName( QwtMathMLDocument::MmlFont type ) const;
void setFontName( QwtMathMLDocument::MmlFont type, const QString &name );
int baseFontPointSize() const
{ return m_base_font_point_size; }
void setBaseFontPointSize( int size )
{ m_base_font_point_size = size; }
QColor foregroundColor() const
{ return m_foreground_color; }
void setForegroundColor( const QColor &color )
{ m_foreground_color = color; }
QColor backgroundColor() const
{ return m_background_color; }
void setBackgroundColor( const QColor &color )
{ m_background_color = color; }
private:
void _dump( const QwtMmlNode *node, QString &indent ) const;
bool insertChild( QwtMmlNode *parent, QwtMmlNode *new_node, QString *errorMsg );
QwtMmlNode *domToMml( const QDomNode &dom_node, bool *ok, QString *errorMsg );
QwtMmlNode *createNode( NodeType type, const QwtMmlAttributeMap &mml_attr,
const QString &mml_value, QString *errorMsg );
QwtMmlNode *createImplicitMrowNode( const QDomNode &dom_node, bool *ok,
QString *errorMsg );
void insertOperator( QwtMmlNode *node, const QString &text );
QwtMmlNode *m_root_node;
QString m_normal_font_name;
QString m_fraktur_font_name;
QString m_sans_serif_font_name;
QString m_script_font_name;
QString m_monospace_font_name;
QString m_doublestruck_font_name;
int m_base_font_point_size;
QColor m_foreground_color;
QColor m_background_color;
};
class QwtMmlNode : public QwtMml
{
friend class QwtMmlDocument;
public:
QwtMmlNode( NodeType type, QwtMmlDocument *document, const QwtMmlAttributeMap &attribute_map );
virtual ~QwtMmlNode();
// Mml stuff
NodeType nodeType() const
{ return m_node_type; }
virtual QString toStr() const;
void setRelOrigin( const QPoint &rel_origin );
QPoint relOrigin() const
{ return m_rel_origin; }
void stretchTo( const QRect &rect );
bool isStretched() const
{ return m_stretched; }
QPoint devicePoint( const QPoint &p ) const;
QRect myRect() const
{ return m_my_rect; }
QRect parentRect() const;
virtual QRect deviceRect() const;
void updateMyRect();
virtual void setMyRect( const QRect &rect )
{ m_my_rect = rect; }
virtual void stretch();
virtual void layout();
virtual void paint( QPainter *p );
int basePos() const;
int overlinePos() const;
int underlinePos() const;
int em() const;
int ex() const;
QString explicitAttribute( const QString &name, const QString &def = QString::null ) const;
QString inheritAttributeFromMrow( const QString &name, const QString &def = QString::null ) const;
virtual QFont font() const;
virtual QColor color() const;
virtual QColor background() const;
virtual int scriptlevel( const QwtMmlNode *child = 0 ) const;
// Node stuff
QwtMmlDocument *document() const
{ return m_document; }
QwtMmlNode *parent() const
{ return m_parent; }
QwtMmlNode *firstChild() const
{ return m_first_child; }
QwtMmlNode *nextSibling() const
{ return m_next_sibling; }
QwtMmlNode *previousSibling() const
{ return m_previous_sibling; }
QwtMmlNode *lastSibling() const;
QwtMmlNode *firstSibling() const;
bool isLastSibling() const
{ return m_next_sibling == 0; }
bool isFirstSibling() const
{ return m_previous_sibling == 0; }
bool hasChildNodes() const
{ return m_first_child != 0; }
protected:
virtual void layoutSymbol();
virtual void paintSymbol( QPainter *p ) const;
virtual QRect symbolRect() const
{ return QRect( 0, 0, 0, 0 ); }
QwtMmlNode *parentWithExplicitAttribute( const QString &name, NodeType type = NoNode );
int interpretSpacing( const QString &value, bool *ok ) const;
private:
QwtMmlAttributeMap m_attribute_map;
bool m_stretched;
QRect m_my_rect, m_parent_rect;
QPoint m_rel_origin;
NodeType m_node_type;
QwtMmlDocument *m_document;
QwtMmlNode *m_parent,
*m_first_child,
*m_next_sibling,
*m_previous_sibling;
};
class QwtMmlTokenNode : public QwtMmlNode
{
public:
QwtMmlTokenNode( NodeType type, QwtMmlDocument *document,
const QwtMmlAttributeMap &attribute_map )
: QwtMmlNode( type, document, attribute_map ) {}
QString text() const;
};
class QwtMmlMphantomNode : public QwtMmlNode
{
public:
QwtMmlMphantomNode( QwtMmlDocument *document,
const QwtMmlAttributeMap &attribute_map )
: QwtMmlNode( MphantomNode, docu
huangyuancao
- 粉丝: 11
- 资源: 22
最新资源
- 地级市减碳重视程度及减碳词频-原始数据.xlsx
- 2025 新年快乐 音乐好听321.zip
- 地级市减碳重视程度及减碳词频-处理代码.do
- 基于springboot的大学志愿填报系统源码(java毕业设计完整源码).zip
- 基于threejs的3d编辑器
- Python 3.5分享一些实用的Python代码片段来解决常见编程问题
- 基于springboot的大学生创业项目的信息管理系统源码(java毕业设计完整源码).zip
- MATLAB仿真环境下Kalman滤波及相关算法的应用研究
- 机械设计遮阳板铝管贴膜机自动化设备sw2016可编辑全套设计资料100%好用.zip
- 基于springboot的大学生创新能力培养平台的设计源码(java毕业设计完整源码).zip
- 深度学习:使用python从原理到搭建基础模型
- CNN-LSTM多变量回归预测(Matlab) 基于卷积-长短期记忆网络(CNN-LSTM)的数据回归预测 1.CNN结合LSTM做拟合回归预测,数据多维输入单维输出,代码内注释详细,直接替数据就可以
- 机械设计真空管组装包装机sw21全套设计资料100%好用.zip
- 基于springboot的大学生就业信息管理系统源码(java毕业设计完整源码).zip
- 基于springboot的大学生心理测评与分析系统源码(java毕业设计完整源码+LW).zip
- DSP28335锁相环程序,STM32F407锁相环程序 锁住正弦波,输出相位可调的方波和spwm波 锁相环 PLL SPLL 单相锁相环 频率跟踪 相位跟踪 全桥逆变
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈