98 lines
2.4 KiB
C++
98 lines
2.4 KiB
C++
#ifndef TRANSPARENTDRAGGABLELAYER_H
|
|
#define TRANSPARENTDRAGGABLELAYER_H
|
|
|
|
#include <QObject>
|
|
#include "qmycustomplot.h"
|
|
#include <QString>
|
|
#include <QMenu>
|
|
|
|
#pragma execution_character_set("utf-8") // 强制指定执行字符集为 UTF-8
|
|
|
|
class TransparentDraggableLayer : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit TransparentDraggableLayer(QMyCustomPlot *parentPlot, QString strUuid="", double minWidth = 1.0, QString strTitle = "");
|
|
|
|
|
|
~TransparentDraggableLayer();
|
|
|
|
//设置最小宽度
|
|
void setMinWidth(double minWidth);
|
|
//设置标题
|
|
void setTitle(QString strTitle);
|
|
|
|
// 设置矩形范围
|
|
void setRange(double left_Low, double right_Hight);
|
|
// 获取当前范围
|
|
QCPRange getRange();
|
|
|
|
// 设置矩形颜色
|
|
void setColor(const QColor &color);
|
|
|
|
// 删除框图
|
|
void deleteRect();
|
|
|
|
//设置顶深
|
|
void setUpper(double upper);
|
|
//设置底深
|
|
void setLower(double lower);
|
|
|
|
signals:
|
|
void rangeChanged(QCPRange newRange);
|
|
|
|
private:
|
|
void initRect();
|
|
void updateHandles() ;
|
|
|
|
private slots:
|
|
void onDelRect(); //删除
|
|
void setItemDepthOffset(); //设置深度移动量
|
|
void onMousePress(QMouseEvent *event);
|
|
void onMouseMove(QMouseEvent *event);
|
|
void onMouseRelease(QMouseEvent *event);
|
|
double getMyLower();
|
|
double getMyUpper();
|
|
|
|
public:
|
|
QMyCustomPlot *mPlot;
|
|
QCPItemRect *mRect;
|
|
QCPItemRect *mLeftHandle;
|
|
QCPItemRect *mRightHandle;
|
|
|
|
QCPItemPixmap *mPixmap;
|
|
QCPItemText *mItemTitle;
|
|
QString mstrTitle="";
|
|
QString m_strUuid = "";
|
|
|
|
//以下字段为临时添加,后面需要数据组集成
|
|
QFont wordfont; //文字字体
|
|
QColor fontColor; //字体颜色
|
|
QColor backgroundColor; //背景颜色
|
|
int leftAndRightAlign; //左右对齐方式
|
|
int upAndDownAlign; //上下对齐方式
|
|
|
|
// BEGIN_ENUM(LeftAndRightDesc)
|
|
// { 0,L"中间对齐" },
|
|
// { 1,L"左对齐" },
|
|
// { 2,L"右对齐" }
|
|
// END_ENUM(LeftAndRightDesc);
|
|
|
|
// BEGIN_ENUM(UpAndDownDesc)
|
|
// { 0,L"上对齐" },
|
|
// { 1,L"中间对齐" },
|
|
// { 2,L"下对齐" }
|
|
// END_ENUM(UpAndDownDesc);
|
|
|
|
enum DragMode { DragNone, DragLeft, DragRight, DragRect };
|
|
DragMode mDragMode = DragNone;
|
|
//double mDragStartX = 0;
|
|
double mDragStartY = 0;
|
|
QCPRange mDragStartRange;
|
|
|
|
// 添加最小宽度成员变量
|
|
double mMinWidth;
|
|
};
|
|
|
|
#endif // TRANSPARENTDRAGGABLELAYER_H
|