#ifndef SIGNPAINTERCACHETHREAD_H #define SIGNPAINTERCACHETHREAD_H #include #include #include #include #include #include #include "signpenstructs.h" class SignPainterCacheThread : public QThread { Q_OBJECT public: SignPainterCacheThread(); 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 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 points,SWRealPoint endRealPoint,int endFlag); void SwPenSectionPathDrawRightWithBezier(QPainterPath* bPath ,QList& elementList,CGPoint prevPoint,QList 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& elementList,SWRealPoint prePenPoint, CGPoint prevPoint,QList rPoints,bool end,bool isContinue,SWRealPoint lastPoint,bool isBegin); void SwPenPathDrawLeftPoint(QList points,SWRealPoint endRealPoint); void SwPenPathDrawRightPoint(QPainterPath *bPath, QList &elementList,SWRealPoint prePenPoint, CGPoint prevPoint, QList 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 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 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; }; #endif // SIGNPAINTERCACHETHREAD_H