#ifndef TRANSPARENTDRAGGABLEIMAGE_H #define TRANSPARENTDRAGGABLEIMAGE_H #include #include "qmycustomplot.h" #include #include #include "geometryutils.h" #include #pragma execution_character_set("utf-8") // 强制指定执行字符集为 UTF-8 class TransparentDraggableImage : public QObject { Q_OBJECT public: QMyCustomPlot *mPlot; explicit TransparentDraggableImage(QMyCustomPlot *parentPlot, QString strUuid="", double minWidth = 1.0, QString strTitle = ""); ~TransparentDraggableImage(); void DrawSVGNormal(QPainter* painter,QString svgFileName,QRectF borderRect,bool IsWellSectonHorizonLayout); //拉伸 void DrawSVGSteched(QPainter* painter,QString svgFileName,QRectF borderRect,bool IsWellSectonHorizonLayout); //平铺 void DrawSVGTiled(QPainter* painter,QString svgFileName,QRectF borderRect,bool IsWellSectonHorizonLayout); //设置最小宽度 void setMinWidth(double minWidth); //设置标题 void setTitle(QString strTitle); //设置解释结论 void setResult(QString filePath); void drawResult(double left_Low, double right_Hight, double lY1, double lY2); // 设置矩形范围 void setRange(double left_Low, double right_Hight, bool bReplot=true); // flag=0边距修改 1宽度修改 void setRange(double left_Low, double right_Hight,double left, double width, int flag = 0, bool bReplot=true); // 获取当前范围 QCPRange getRange(); QString getMResult(); // 设置矩形颜色 void setColor(const QColor &color); // 删除框图 void deleteRect(); void setUpper(double upper); void setLower(double lower); void setMMinWidth(double mMinWidth); void setLeft(double left); double getLeft(); void setWidth(double width); double getWidth(); // 设置边框颜色 void setBorderColor(const QColor &color); // 设置边框线型(实线、虚线、点线等) void setBorderStyle(Qt::PenStyle style); // 设置边框线宽 void setBorderWidth(int width); QColor geBorderColor(); Qt::PenStyle getBorderStyle(); int getBorderWidth(); signals: void rangeChanged(QCPRange newRange); private: void initRect(); void updateHandles() ; private slots: void onDelRect(); void onMousePress(QMouseEvent *event); void onMouseMove(QMouseEvent *event); void onMouseRelease(QMouseEvent *event); double getMyLower(); double getMyUpper(); private: QCPItemRect *mRect; QCPItemRect *mLeftHandle; QCPItemRect *mRightHandle; QCPItemPixmap *mPixmap; QCPItemText *mItemTitle; QString mstrTitle=""; QString m_strUuid = ""; QString m_Result; enum DragMode { DragNone, DragLeft, DragRight, DragRect }; DragMode mDragMode = DragNone; //double mDragStartX = 0; double mDragStartY = 0; QCPRange mDragStartRange; // 添加最小宽度成员变量 double mMinWidth; // 左边距 宽度 都是百分比 double m_left = 0, m_width = 100; // ========== 新增:边框样式成员变量 ========== QColor m_BorderColor; // 边框颜色 Qt::PenStyle m_BorderStyle; // 边框线型 int m_BorderWidth; // 边框线宽(像素) }; #endif // TRANSPARENTDRAGGABLEIMAGE_H