DPS/include/report/baseGraphicDefinition.h

77 lines
2.7 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef BASEGRAPHICITEM_H
#define BASEGRAPHICITEM_H
#include <QGraphicsItem>
#include <QGraphicsLineItem>
#include <QFont>
#include <QPen>
namespace CCS_Report {
struct SCellText
{
QString m_strText = "";
Qt::AlignmentFlag m_qAlignmentFlag = Qt::AlignCenter; // 字符串对齐方式 Qt::AlignTop,Qt::AlignBottom,Qt::AlignVCenter
QFont m_qFont = QFont();
QPen m_qPen = QPen();
int m_iAddFirstSpaceFlag = 0; // =0 不加空格
int m_iFontSize = 20;
int m_iWrapFlag = 0; // -1 - 截取
// 0 - 以字母折行
// 1 - 以单词折行
int m_iCellType= 0; // =0 文本 =1 图片 = 2 SVG格式
QSize m_ImageSize = QSize();
QSize m_ImageRealSize = QSize();
qreal m_qHeight = 0;
int m_iLineNumber = 0;
int m_iDrawingX = 0;
int m_iDrawingY = 0;
public:
void CopyBy( SCellText sourceCellText );
void CopyBy( SCellText *pSourceCellText );
// 得到绘制一个字符串的基础矩形范围
static QRectF GetBaseDrawingRect( QFontMetricsF markFontMetricsF, QString strText );
// 得到在指定宽度范围内绘制一个字符串的矩形范围
static int GetDrawingCellTextList( int iCellWidth, int &iStartX, int& iEndX, int &iLineNumber,
SCellText *pCellText, QList < SCellText * > &pResultSCellTextList );
// 得到在指定宽度范围内绘制一组字符串的多行字符串
static int GetDrawingCellTextList( int iCellWidth, QList < SCellText* > pSourceCellTextList, QList < SCellText* > &pResultCellTextList ,int& iEndX);
// 得到在指定宽度范围内绘制一行一组字符串的高度
static int GetLineCellTextHeight( int &iTotalHeight, QList < int > &iLineHeightList, QList < SCellText* > &pLineCellTextList);
// 得到在指定宽度范围内绘制一组字符串的矩形范围
static int GetDrawingRect( int iCellWidth, int &iEndX, QRectF &drawingRect, QList < SCellText* > pSourceCellTextList,
QList < int > &iLineHeightList, QList < SCellText* > &pResultCellTextList );
static QMap<int,QList<SCellText*>> TransToMap(QList < SCellText* > &pResultCellTextList );
static QMap<int,QList<SCellText*>> TransSourceToMap(int width,QList < int >& iLineHeightList,QList < SCellText* > &pSourceCellTextList );
static SCellText* MakeupStringByWidth(QString strSource,qreal width);
static Qt::AlignmentFlag TransAlignment(int flag);
static SCellText* CreateCellText(QString strText,QFont font,QPen pen,Qt::AlignmentFlag alignflag,
int spaceflag,int fontsize,int wrapflag,int celltype=0);
static SCellText* CreateCellImage(QString strText,QSize imagesize,QSize realiamgesize,qreal height);
};
}
#endif // BASEGRAPHICITEM_H