|
|
|
|
|
#ifndef SIGNPAINTERCACHETHREADLINUX_H
|
|
|
|
|
|
#define SIGNPAINTERCACHETHREADLINUX_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
#include <QThread>
|
|
|
|
|
|
#include <QSemaphore>
|
|
|
|
|
|
#include <QMutex>
|
|
|
|
|
|
#include <QImage>
|
|
|
|
|
|
#include <QColor>
|
|
|
|
|
|
#include "signpenstructs.h"
|
|
|
|
|
|
|
|
|
|
|
|
class SignPainterCacheThread_Linux : public QThread
|
|
|
|
|
|
{
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
public:
|
|
|
|
|
|
SignPainterCacheThread_Linux();
|
|
|
|
|
|
void SetPainterRect(QRect rect);
|
|
|
|
|
|
void SetCurrentPageIndex(int page){currentPageIndex = page;}
|
|
|
|
|
|
void AddPoint(QPointF currPoint,int type,float radius,double force,double maxForce);
|
|
|
|
|
|
void Paint(QPainter* painter,QRect currentVisibleRect);
|
|
|
|
|
|
void ClearDraw();
|
|
|
|
|
|
QList<SWAnnotPath*> GetAnnotPathLists(){return drawPaths;}
|
|
|
|
|
|
void SetStressSwitch(bool isStressSwitch) { stressSwitch = isStressSwitch; }
|
|
|
|
|
|
bool GetStressSwitch(){return stressSwitch;}
|
|
|
|
|
|
|
|
|
|
|
|
void SetPenType(int type){penType = type;}
|
|
|
|
|
|
|
|
|
|
|
|
void SetPenColor(QColor penColor){m_PenColor = penColor;}
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
void run();
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
void PaintWithPainter(QPainter* painter,QRect currentVisibleRect);
|
|
|
|
|
|
|
|
|
|
|
|
void SwPenSectionPathDraw(QList<SWRealPoint> points,SWRealPoint endRealPoint,int endFlag);
|
|
|
|
|
|
void SwPenSectionPathDrawRightWithBezier(QPainterPath* bPath ,QList<Element>& elementList,CGPoint prevPoint,QList<SWRealPoint> rPoints,
|
|
|
|
|
|
SWRealPoint endRealPoint,int endFlag,bool isEnd,bool isBegin);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SwPenPathDrawPoint(SWRealPoint point);
|
|
|
|
|
|
|
|
|
|
|
|
QPainterPath SwPenPathDraw(bool isEnd,bool flushSection);
|
|
|
|
|
|
QPainterPath SwPenPathDraw(SWAnnotPath *annotPath,bool isEnd,bool flushSection);
|
|
|
|
|
|
void SwPenPathDrawRightWithBezier(QPainterPath* bPath ,QList<Element>& elementList,SWRealPoint prePenPoint,
|
|
|
|
|
|
CGPoint prevPoint,QList<SWRealPoint> rPoints,bool end,bool isContinue,SWRealPoint lastPoint,bool isBegin);
|
|
|
|
|
|
|
|
|
|
|
|
void SwPenPathDrawLeftPoint(QList<SWRealPoint> points,SWRealPoint endRealPoint);
|
|
|
|
|
|
void SwPenPathDrawRightPoint(QPainterPath *bPath, QList<Element> &elementList,SWRealPoint prePenPoint,
|
|
|
|
|
|
CGPoint prevPoint, QList<SWRealPoint> rPoints,SWRealPoint endRealPoint);
|
|
|
|
|
|
|
|
|
|
|
|
void MouseMoved(const SWRealPoint& realPoint);
|
|
|
|
|
|
void MousePressd(const SWRealPoint& realPoint);
|
|
|
|
|
|
void MouseReleased(const SWRealPoint& realPoint);
|
|
|
|
|
|
|
|
|
|
|
|
void Init();
|
|
|
|
|
|
|
|
|
|
|
|
QPaintDevice *PaintingDevice();
|
|
|
|
|
|
QPaintDevice *PaintedDevice();
|
|
|
|
|
|
|
|
|
|
|
|
void DrawSignPath(QPainter* painter,const QPainterPath &path,bool isEnd);
|
|
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
void NeedsToRefresh(QRect rect);
|
|
|
|
|
|
void ReleasedExcuted();
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
QList<SWRealPoint> m_RealPoints;
|
|
|
|
|
|
//原始点的互斥锁
|
|
|
|
|
|
QMutex m_mutex;
|
|
|
|
|
|
QSemaphore m_Sem;
|
|
|
|
|
|
|
|
|
|
|
|
float preLineRadius;
|
|
|
|
|
|
int strokeSpl;
|
|
|
|
|
|
int stressSwitch;//是否开启压感 1开启 0关闭
|
|
|
|
|
|
float stressSpl;
|
|
|
|
|
|
|
|
|
|
|
|
int currentPageIndex;
|
|
|
|
|
|
|
|
|
|
|
|
qint64 previousTimestamp;
|
|
|
|
|
|
float pointSpeed;
|
|
|
|
|
|
|
|
|
|
|
|
SWAnnotPath *curAnnotPath;
|
|
|
|
|
|
qint64 lastPaintTimestamp;
|
|
|
|
|
|
int paintFreq;
|
|
|
|
|
|
|
|
|
|
|
|
//currentAnnot mutex
|
|
|
|
|
|
QMutex m_AnnotMutex;
|
|
|
|
|
|
|
|
|
|
|
|
QList<SWAnnotPath*> drawPaths;
|
|
|
|
|
|
|
|
|
|
|
|
QImage* m_BaseBuf;
|
|
|
|
|
|
//渲染bug,基于m_BaseBuf从上一次倒数10个点开始绘制,绘制到倒数10个点时,数据保存回m_BaseBuf
|
|
|
|
|
|
QImage* m_PaintingBuf;
|
|
|
|
|
|
|
|
|
|
|
|
QSize m_Size;
|
|
|
|
|
|
QRect m_PaintRect;
|
|
|
|
|
|
QRect m_OriRect;//新建画布原始
|
|
|
|
|
|
int m_ScrollH;
|
|
|
|
|
|
|
|
|
|
|
|
int drawStartIndex;
|
|
|
|
|
|
QMutex m_drawMutex;
|
|
|
|
|
|
|
|
|
|
|
|
int drawCount;
|
|
|
|
|
|
int drawCountOffset;
|
|
|
|
|
|
|
|
|
|
|
|
//标记上次计算贝塞尔点
|
|
|
|
|
|
CGPoint preBezierPoint;
|
|
|
|
|
|
|
|
|
|
|
|
bool isPressed;
|
|
|
|
|
|
float m_fPixmapZoom;
|
|
|
|
|
|
int m_fPixmaps;
|
|
|
|
|
|
|
|
|
|
|
|
int penType;//画笔类型1软笔2签字笔
|
|
|
|
|
|
QColor m_PenColor;
|
|
|
|
|
|
|
|
|
|
|
|
qint64 lasttimestamp;
|
|
|
|
|
|
|
|
|
|
|
|
int m_BufZoomWidth;
|
|
|
|
|
|
|
|
|
|
|
|
int m_lastSectionIndex;
|
|
|
|
|
|
SWRealPoint m_lastSectionPoint;
|
|
|
|
|
|
|
|
|
|
|
|
SWRealPoint tempPresspoint;//缓冲的按压点
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // SIGNPAINTERCACHETHREADLINUX_H
|