|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <QRectF>
|
|
|
|
|
#include <QPainter>
|
|
|
|
|
#include "ZxDot.h"
|
|
|
|
|
#include <LlUtils_global.h>
|
|
|
|
|
|
|
|
|
|
/// 一些简单而通用的图元绘制
|
|
|
|
|
class I_UTILSSHARED_EXPORT ZxDrawHelper
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
ZxDrawHelper();
|
|
|
|
|
~ZxDrawHelper();
|
|
|
|
|
|
|
|
|
|
// 返回DRAWING_TYPE的类型描述
|
|
|
|
|
static QStringList getDotStyleDescs();
|
|
|
|
|
|
|
|
|
|
/// 绘制焦点
|
|
|
|
|
static void drawFocus(QPainter* painter,QRectF rect);
|
|
|
|
|
|
|
|
|
|
/// 绘制点
|
|
|
|
|
static void drawPoint(QPainter* painter,QPointF point[],int cnt,int nDotStyle,float fRadius,bool isFill,QColor clr);
|
|
|
|
|
static void drawPoint(QPainter* painter, QPointF point[], int cnt, ZxDot o);
|
|
|
|
|
|
|
|
|
|
/// 绘制点
|
|
|
|
|
static void drawPoint(QPainter* painter,QPointF point,int nDotStyle,float fRadius,bool isFill,QColor clr);
|
|
|
|
|
static void drawPoint(QPainter* painter, QPointF point, ZxDot o);
|
|
|
|
|
|
|
|
|
|
/// 绘制圆
|
|
|
|
|
static void drawCircle(QPainter* painter,QPointF point,float fRadius,bool isFill,QColor clr);
|
|
|
|
|
|
|
|
|
|
/// 绘制正方形
|
|
|
|
|
static void drawSquare(QPainter* painter,QPointF point,float fRadius,bool isFill,QColor clr);
|
|
|
|
|
|
|
|
|
|
/// 绘制上三角
|
|
|
|
|
static void drawUpTriangle(QPainter* painter,QPointF point,float fRadius,bool isFill,QColor clr);
|
|
|
|
|
|
|
|
|
|
/// 绘制下三角
|
|
|
|
|
static void drawDownTriangle(QPainter* painter,QPointF point,float fRadius,bool isFill,QColor clr);
|
|
|
|
|
|
|
|
|
|
/// 绘制左三角
|
|
|
|
|
static void drawLeftTriangle(QPainter* painter,QPointF point,float fRadius,bool isFill,QColor clr);
|
|
|
|
|
|
|
|
|
|
/// 绘制右三角
|
|
|
|
|
static void drawRightTriangle(QPainter* painter,QPointF point,float fRadius,bool isFill,QColor clr);
|
|
|
|
|
|
|
|
|
|
/// 绘制菱形
|
|
|
|
|
static void drawDiamond(QPainter* painter,QPointF point,float fRadius,bool isFill,QColor clr);
|
|
|
|
|
|
|
|
|
|
/// 绘制叉
|
|
|
|
|
static void drawCross(QPainter* painter,QPointF point,float fRadius,bool isFill,QColor clr);
|
|
|
|
|
|
|
|
|
|
/// 绘制十字架
|
|
|
|
|
static void drawPlus(QPainter* painter,QPointF point,float fRadius,bool isFill,QColor clr);
|
|
|
|
|
|
|
|
|
|
/// 绘制六角星
|
|
|
|
|
static void drawStar(QPainter* painter,QPointF point,float fRadius,bool isFill,QColor clr);
|
|
|
|
|
|
|
|
|
|
/// 绘制梯形塔台
|
|
|
|
|
static void drawRig(QPainter* painter,QPointF point,float fRadius,bool isFill,QColor clr);
|
|
|
|
|
|
|
|
|
|
/// 绘制带线的三角形
|
|
|
|
|
static void drawTriangleWithLine(QPainter* painter,QPointF point,float fRadius,bool isFill,QColor clr,float fAngle = 0);
|
|
|
|
|
|
|
|
|
|
/// 绘制带线的圆
|
|
|
|
|
static void drawCricleWithLine(QPainter* painter,QPointF point,float fRadius,bool isFill,QColor clr,float fAngle = 0);
|
|
|
|
|
|
|
|
|
|
/// 绘制箭头
|
|
|
|
|
static void drawArrow(QPainter* painter,QPointF point,float fRadius,bool isFill,QColor clr,float fAngle = 0);
|
|
|
|
|
|
|
|
|
|
/// 求两条线段的夹角
|
|
|
|
|
static float straightAngle(QPointF ptLine1Start,QPointF ptLine1End,QPointF ptLine2Start,QPointF ptLine2End);
|
|
|
|
|
|
|
|
|
|
/// 绘制文本
|
|
|
|
|
static void drawText(QPainter* painter, const QRectF& rt, \
|
|
|
|
|
int flags, const QString& s, bool bTrimStr = true);
|
|
|
|
|
static void drawText(QPainter* painter, const QPointF& pt, \
|
|
|
|
|
const QString& s, bool bTrimStr = true); //该函数用的很少,不建议使用
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////
|
|
|
|
|
// TODO 如下几个函数可以考虑放入zxAlgMath类库之中,目前为了减少类库依赖,暂时放在此处
|
|
|
|
|
/// 点是否在附近
|
|
|
|
|
static bool isPointNearPoint(QPointF point1,QPointF point2,float nMinDist=1.f);
|
|
|
|
|
/// 点是否在直线附近
|
|
|
|
|
static bool isPointNearLine(QPointF pt1,QPointF pt2,QPointF pt3,float nMinDist=1.f);
|
|
|
|
|
static double pointToLineDis(QPointF pt1,QPointF pt2,QPointF pt3);
|
|
|
|
|
///////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|