logplus/logPlus/transparentdraggableimage.h

117 lines
3.3 KiB
C
Raw Normal View History

#ifndef TRANSPARENTDRAGGABLEIMAGE_H
#define TRANSPARENTDRAGGABLEIMAGE_H
#include <QObject>
#include "qmycustomplot.h"
#include <QString>
#include <QMenu>
#include "geometryutils.h"
#include <QSvgRenderer>
#pragma execution_character_set("utf-8") // 强制指定执行字符集为 UTF-8
class TransparentDraggableImage : public QObject
{
Q_OBJECT
public:
2026-03-16 18:09:26 +08:00
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);
// 设置矩形范围
2026-03-20 18:04:15 +08:00
void setRange(double left_Low, double right_Hight, bool bReplot=true);
2026-03-18 11:48:00 +08:00
// flag=0边距修改 1宽度修改
2026-03-20 18:04:15 +08:00
void setRange(double left_Low, double right_Hight,double left, double width, int flag = 0, bool bReplot=true);
// 获取当前范围
QCPRange getRange();
2026-03-13 17:34:02 +08:00
QString getMResult();
// 设置矩形颜色
void setColor(const QColor &color);
// 删除框图
void deleteRect();
2026-03-16 18:09:26 +08:00
void setUpper(double upper);
void setLower(double lower);
2026-03-18 11:19:55 +08:00
void setMMinWidth(double mMinWidth);
void setLeft(double left);
double getLeft();
void setWidth(double width);
double getWidth();
2026-03-16 18:09:26 +08:00
2026-03-19 09:44:09 +08:00
// 设置边框颜色
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:
2026-03-16 18:09:26 +08:00
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;
2026-03-18 11:19:55 +08:00
// 左边距 宽度 都是百分比
double m_left = 0, m_width = 100;
2026-03-19 09:44:09 +08:00
// ========== 新增:边框样式成员变量 ==========
QColor m_BorderColor; // 边框颜色
Qt::PenStyle m_BorderStyle; // 边框线型
int m_BorderWidth; // 边框线宽(像素)
};
#endif // TRANSPARENTDRAGGABLEIMAGE_H