2025-06-23 10:41:33 +08:00
|
|
|
|
#ifndef BASEGRAPHICITEM_H
|
|
|
|
|
#define BASEGRAPHICITEM_H
|
|
|
|
|
|
|
|
|
|
#include <QGraphicsItem>
|
|
|
|
|
#include <QGraphicsLineItem>
|
|
|
|
|
#include <QFont>
|
|
|
|
|
#include <QPen>
|
|
|
|
|
|
|
|
|
|
namespace CCS_Report {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct SCellText
|
|
|
|
|
{
|
|
|
|
|
QString m_strText = "";
|
|
|
|
|
|
2025-06-23 18:01:09 +08:00
|
|
|
|
Qt::AlignmentFlag m_qAlignmentFlag = Qt::AlignCenter; // 字符串对齐方式 :Qt::AlignTop,Qt::AlignBottom,Qt::AlignVCenter
|
2025-06-23 10:41:33 +08:00
|
|
|
|
|
|
|
|
|
QFont m_qFont = QFont();
|
|
|
|
|
QPen m_qPen = QPen();
|
|
|
|
|
|
2025-06-23 18:01:09 +08:00
|
|
|
|
int m_iAddFirstSpaceFlag = 0; // =0 不加空格
|
2025-06-23 10:41:33 +08:00
|
|
|
|
|
|
|
|
|
int m_iFontSize = 20;
|
|
|
|
|
|
2025-06-23 18:01:09 +08:00
|
|
|
|
int m_iWrapFlag = 0; // -1 - 截取
|
|
|
|
|
// 0 - 以字母折行
|
|
|
|
|
// 1 - 以单词折行
|
2025-06-23 10:41:33 +08:00
|
|
|
|
|
2025-06-23 18:01:09 +08:00
|
|
|
|
int m_iCellType= 0; // =0 文本 =1 图片 = 2 SVG格式
|
2025-06-23 10:41:33 +08:00
|
|
|
|
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 );
|
|
|
|
|
|
2025-06-23 18:01:09 +08:00
|
|
|
|
// 得到绘制一个字符串的基础矩形范围
|
2025-06-23 10:41:33 +08:00
|
|
|
|
|
|
|
|
|
static QRectF GetBaseDrawingRect( QFontMetricsF markFontMetricsF, QString strText );
|
|
|
|
|
|
2025-06-23 18:01:09 +08:00
|
|
|
|
// 得到在指定宽度范围内绘制一个字符串的矩形范围
|
2025-06-23 10:41:33 +08:00
|
|
|
|
|
|
|
|
|
static int GetDrawingCellTextList( int iCellWidth, int &iStartX, int& iEndX, int &iLineNumber,
|
|
|
|
|
SCellText *pCellText, QList < SCellText * > &pResultSCellTextList );
|
|
|
|
|
|
2025-06-23 18:01:09 +08:00
|
|
|
|
// 得到在指定宽度范围内绘制一组字符串的多行字符串
|
2025-06-23 10:41:33 +08:00
|
|
|
|
|
|
|
|
|
static int GetDrawingCellTextList( int iCellWidth, QList < SCellText* > pSourceCellTextList, QList < SCellText* > &pResultCellTextList ,int& iEndX);
|
|
|
|
|
|
2025-06-23 18:01:09 +08:00
|
|
|
|
// 得到在指定宽度范围内绘制一行一组字符串的高度
|
2025-06-23 10:41:33 +08:00
|
|
|
|
|
|
|
|
|
static int GetLineCellTextHeight( int &iTotalHeight, QList < int > &iLineHeightList, QList < SCellText* > &pLineCellTextList);
|
|
|
|
|
|
2025-06-23 18:01:09 +08:00
|
|
|
|
// 得到在指定宽度范围内绘制一组字符串的矩形范围
|
2025-06-23 10:41:33 +08:00
|
|
|
|
|
|
|
|
|
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
|