2025-12-22 18:22:45 +08:00
|
|
|
|
#include "TransparentDraggableSwallCore.h"
|
2026-03-04 18:03:54 +08:00
|
|
|
|
#include "PropertyWidget.h"
|
|
|
|
|
|
#include "CallManage.h"
|
2025-12-22 18:22:45 +08:00
|
|
|
|
|
|
|
|
|
|
extern double g_dPixelPerCm;//每厘米像素数
|
|
|
|
|
|
//static GeoIndicatorGenerator m_drawGeo;
|
|
|
|
|
|
|
|
|
|
|
|
TransparentDraggableSwallCore::TransparentDraggableSwallCore(QMyCustomPlot *parentPlot, QString strUuid, double minWidth, QString strTitle)
|
|
|
|
|
|
: QObject(parentPlot), mPlot(parentPlot), mstrTitle(strTitle), mMinWidth(minWidth)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_strUuid = strUuid;
|
2026-03-05 16:45:06 +08:00
|
|
|
|
|
|
|
|
|
|
//图片高度(需要根据高度宏定义,重新计算)
|
2026-03-10 18:21:29 +08:00
|
|
|
|
double h = SideWallCoreHeight * g_dPixelPerCm; //0.4cm //40;
|
|
|
|
|
|
m_fImageHeight = h/2.0;
|
2026-03-05 16:45:06 +08:00
|
|
|
|
|
2025-12-22 18:22:45 +08:00
|
|
|
|
//
|
|
|
|
|
|
initRect();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TransparentDraggableSwallCore::~TransparentDraggableSwallCore()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(mPlot) {
|
|
|
|
|
|
// mPlot->removeItem(mRect);
|
|
|
|
|
|
// mPlot->removeItem(mLeftHandle);
|
|
|
|
|
|
// mPlot->removeItem(mRightHandle);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TransparentDraggableSwallCore::DrawSVGNormal(QPainter* painter,QString svgFileName,QRectF borderRect,bool IsWellSectonHorizonLayout)
|
|
|
|
|
|
{
|
|
|
|
|
|
QString svg=svgFileName;
|
|
|
|
|
|
QRectF boundingRect = painter->transform().mapRect(borderRect);
|
|
|
|
|
|
painter->save();
|
|
|
|
|
|
QTransform transform;
|
|
|
|
|
|
transform.reset();
|
|
|
|
|
|
if (!IsWellSectonHorizonLayout)
|
|
|
|
|
|
{
|
|
|
|
|
|
painter->setWorldTransform(transform);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
QPixmap tiledmap(svg);
|
|
|
|
|
|
QRect border(boundingRect.left(),boundingRect.top(),boundingRect.width(),boundingRect.height());
|
|
|
|
|
|
painter->drawPixmap(border,tiledmap);
|
|
|
|
|
|
painter->restore();
|
|
|
|
|
|
}
|
|
|
|
|
|
//拉伸
|
|
|
|
|
|
void TransparentDraggableSwallCore::DrawSVGSteched(QPainter* painter,QString svgFileName,QRectF borderRect,bool IsWellSectonHorizonLayout)
|
|
|
|
|
|
{
|
|
|
|
|
|
QString svg=svgFileName;
|
|
|
|
|
|
QSvgRenderer m_SvgRenderer;
|
|
|
|
|
|
m_SvgRenderer.load(svg);
|
|
|
|
|
|
m_SvgRenderer.render(painter,borderRect);
|
|
|
|
|
|
}
|
|
|
|
|
|
//平铺
|
|
|
|
|
|
void TransparentDraggableSwallCore::DrawSVGTiled(QPainter* painter,QString svgFileName,QRectF borderRect,bool IsWellSectonHorizonLayout)
|
|
|
|
|
|
{
|
|
|
|
|
|
QString svg=svgFileName;
|
|
|
|
|
|
QRectF boundingRect = painter->transform().mapRect(borderRect);
|
|
|
|
|
|
painter->save();
|
|
|
|
|
|
QTransform transform;
|
|
|
|
|
|
transform.reset();
|
|
|
|
|
|
if (!IsWellSectonHorizonLayout)
|
|
|
|
|
|
{
|
|
|
|
|
|
painter->setWorldTransform(transform);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
QPixmap tiledmap(svg);
|
|
|
|
|
|
painter->drawTiledPixmap(boundingRect,tiledmap);
|
|
|
|
|
|
painter->restore();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//设置最小宽度
|
|
|
|
|
|
void TransparentDraggableSwallCore::setMinWidth(double minWidth)
|
|
|
|
|
|
{
|
|
|
|
|
|
mMinWidth = minWidth;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//设置标题
|
|
|
|
|
|
void TransparentDraggableSwallCore::setTitle(QString strTitle)
|
|
|
|
|
|
{
|
|
|
|
|
|
mstrTitle = strTitle;
|
|
|
|
|
|
mItemTitle->setText(mstrTitle);
|
2025-12-23 17:15:39 +08:00
|
|
|
|
//mPlot->replot();
|
2025-12-22 18:22:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//设置解释结论
|
|
|
|
|
|
void TransparentDraggableSwallCore::setLith(QString filePath)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_Lith = filePath;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TransparentDraggableSwallCore::drawLith(double left_Low, double right_Hight, double lY1, double lY2)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(m_Lith=="")
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-30 11:18:02 +08:00
|
|
|
|
double x1 = mPlot->xAxis->coordToPixel((left_Low+right_Hight)/2)+m_fImageHeight;
|
2025-12-22 18:22:45 +08:00
|
|
|
|
double x2 = mPlot->xAxis->coordToPixel((left_Low+right_Hight)/2);
|
2025-12-30 11:18:02 +08:00
|
|
|
|
double y1 = mPlot->yAxis->coordToPixel(lY1)+(m_fLeftSpace+m_fTriangleLen);
|
|
|
|
|
|
double y2 = mPlot->yAxis->coordToPixel(lY1)+m_fImageWidth+(m_fLeftSpace+m_fTriangleLen);
|
2025-12-22 18:22:45 +08:00
|
|
|
|
|
|
|
|
|
|
bool bWidthBig = false;
|
2026-03-10 18:21:29 +08:00
|
|
|
|
double newWidth = y2-y1;
|
|
|
|
|
|
double newHeight = x1-x2;
|
2025-12-22 18:22:45 +08:00
|
|
|
|
// if(newWidth>newHeight)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// //取小,画正方形框
|
|
|
|
|
|
// newWidth = newHeight;
|
|
|
|
|
|
// bWidthBig = true;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
QString filePath = m_Lith;
|
|
|
|
|
|
QString strLast = filePath.right(4);
|
|
|
|
|
|
if(strLast.toLower()==".svg")
|
|
|
|
|
|
{
|
|
|
|
|
|
QString path,filename;
|
|
|
|
|
|
GetWellNameAndPath(filePath, filename, path);
|
|
|
|
|
|
QString basename = filename;
|
|
|
|
|
|
|
|
|
|
|
|
QString val=filePath;
|
|
|
|
|
|
QImage image(newWidth, newHeight, QImage::Format_RGB32);
|
|
|
|
|
|
QPainter painter(&image);
|
|
|
|
|
|
QRectF fillRect(0,0,newWidth, newHeight);
|
2026-03-10 18:21:29 +08:00
|
|
|
|
painter.fillRect(fillRect,Qt::white);
|
2025-12-22 18:22:45 +08:00
|
|
|
|
|
|
|
|
|
|
//拉伸
|
|
|
|
|
|
DrawSVGSteched(&painter,filePath,fillRect,0);
|
|
|
|
|
|
//平铺
|
|
|
|
|
|
//DrawSVGTiled(&painter,filePath,fillRect,0);
|
|
|
|
|
|
//正常
|
|
|
|
|
|
//DrawSVGNormal(&painter,filePath,fillRect,0);
|
|
|
|
|
|
|
|
|
|
|
|
val=GetImagePath()+"TempNew";
|
|
|
|
|
|
QDir ss;
|
|
|
|
|
|
if(!ss.exists(val)) {
|
|
|
|
|
|
ss.mkdir(val);
|
|
|
|
|
|
}
|
|
|
|
|
|
val+=QDir::separator();
|
|
|
|
|
|
val+=basename+".png";
|
|
|
|
|
|
image.save(val);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
2026-03-10 18:21:29 +08:00
|
|
|
|
mPixmap_Lith->setPixmap(QPixmap(val)); // 设置图片
|
2025-12-22 18:22:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
2026-03-10 18:21:29 +08:00
|
|
|
|
{
|
2025-12-22 18:22:45 +08:00
|
|
|
|
QString path,filename;
|
|
|
|
|
|
GetWellNameAndPath(filePath, filename, path);
|
|
|
|
|
|
QString basename = filename;
|
|
|
|
|
|
|
|
|
|
|
|
QString val=filePath;
|
|
|
|
|
|
QImage image(newWidth, newHeight, QImage::Format_RGB32);
|
|
|
|
|
|
QPainter painter(&image);
|
|
|
|
|
|
QRectF fillRect(0,0,newWidth, newHeight);
|
2026-03-10 18:21:29 +08:00
|
|
|
|
painter.fillRect(fillRect,Qt::white);
|
|
|
|
|
|
//
|
|
|
|
|
|
bool isOne=true;
|
|
|
|
|
|
bool isStech=true;
|
|
|
|
|
|
bool isHorizon=false;
|
2025-12-22 18:22:45 +08:00
|
|
|
|
float cm = g_dPixelPerCm;//一厘米对应的像素个数
|
|
|
|
|
|
QColor bkColor = QColor(255,255,255,0);
|
|
|
|
|
|
|
|
|
|
|
|
float GeoResult = m_drawGeo.seleGeo("岩性符号库", basename, &painter, fillRect, isOne, isStech, isHorizon, cm, bkColor);
|
|
|
|
|
|
|
|
|
|
|
|
val=GetImagePath()+"TempNew";
|
|
|
|
|
|
QDir ss;
|
|
|
|
|
|
if(!ss.exists(val)) {
|
|
|
|
|
|
ss.mkdir(val);
|
|
|
|
|
|
}
|
|
|
|
|
|
val+=QDir::separator();
|
|
|
|
|
|
val+=basename+".png";
|
|
|
|
|
|
image.save(val);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
mPixmap_Lith->setPixmap(QPixmap(val)); // 设置图片
|
|
|
|
|
|
}
|
2026-03-10 18:21:29 +08:00
|
|
|
|
mPixmap_Lith->topLeft->setCoords(mPlot->xAxis->pixelToCoord(x2), mPlot->yAxis->pixelToCoord(y1));//right_Hight+1
|
|
|
|
|
|
mPixmap_Lith->bottomRight->setCoords(mPlot->xAxis->pixelToCoord(x1), mPlot->yAxis->pixelToCoord(y2));//left_Low-1
|
2025-12-22 18:22:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//设置m_Oil
|
|
|
|
|
|
void TransparentDraggableSwallCore::setOil(QString filePath)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_Oil = filePath;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TransparentDraggableSwallCore::drawOil(double left_Low, double right_Hight, double lY1, double lY2)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(m_Oil=="")
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double x1 = mPlot->xAxis->coordToPixel((left_Low+right_Hight)/2);
|
2025-12-30 11:18:02 +08:00
|
|
|
|
double x2 = mPlot->xAxis->coordToPixel((left_Low+right_Hight)/2)-m_fImageHeight;
|
|
|
|
|
|
double y1 = mPlot->yAxis->coordToPixel(lY1)+(m_fLeftSpace+m_fTriangleLen);
|
|
|
|
|
|
double y2 = mPlot->yAxis->coordToPixel(lY1)+m_fImageWidth+(m_fLeftSpace+m_fTriangleLen);
|
2025-12-22 18:22:45 +08:00
|
|
|
|
|
|
|
|
|
|
bool bWidthBig = false;
|
|
|
|
|
|
double newWidth = y2-y1;
|
|
|
|
|
|
double newHeight = x1-x2;
|
|
|
|
|
|
if(newWidth>newHeight)
|
|
|
|
|
|
{
|
|
|
|
|
|
//取小,画正方形框
|
|
|
|
|
|
newWidth = newHeight;
|
|
|
|
|
|
bWidthBig = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float rect_xRight = x2 + newHeight/ 2 - newWidth/ 2;
|
|
|
|
|
|
double xNewRight = mPlot->xAxis->pixelToCoord(rect_xRight+1);
|
|
|
|
|
|
//
|
|
|
|
|
|
float rect_xLeft = rect_xRight + newWidth;
|
|
|
|
|
|
double xNewLeft = mPlot->xAxis->pixelToCoord(rect_xLeft-1);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
QString filePath = m_Oil;
|
|
|
|
|
|
//
|
|
|
|
|
|
QString strLast = filePath.right(4);
|
|
|
|
|
|
if(strLast.toLower()==".svg")
|
|
|
|
|
|
{
|
|
|
|
|
|
QString path,filename;
|
|
|
|
|
|
GetWellNameAndPath(filePath, filename, path);
|
|
|
|
|
|
QString basename = filename;
|
|
|
|
|
|
|
|
|
|
|
|
QString val=filePath;
|
|
|
|
|
|
QImage image(newWidth, newWidth,QImage::Format_RGB32);
|
|
|
|
|
|
QPainter painter(&image);
|
|
|
|
|
|
QRectF fillRect(0,0, newWidth, newWidth);
|
|
|
|
|
|
painter.fillRect(fillRect,Qt::white);
|
|
|
|
|
|
//拉伸
|
|
|
|
|
|
DrawSVGSteched(&painter,filePath,fillRect,0);
|
|
|
|
|
|
//平铺
|
|
|
|
|
|
//DrawSVGTiled(&painter,filePath,fillRect,0);
|
|
|
|
|
|
//正常
|
|
|
|
|
|
//DrawSVGNormal(&painter,filePath,fillRect,0);
|
|
|
|
|
|
|
|
|
|
|
|
val=GetImagePath()+"TempNew";
|
|
|
|
|
|
QDir ss;
|
|
|
|
|
|
if(!ss.exists(val)) {
|
|
|
|
|
|
ss.mkdir(val);
|
|
|
|
|
|
}
|
|
|
|
|
|
val+=QDir::separator();
|
|
|
|
|
|
val+=basename+".png";
|
|
|
|
|
|
image.save(val);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
mPixmap_Oil->setPixmap(QPixmap(val)); // 设置图片
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
mPixmap_Oil->setPixmap(QPixmap(filePath)); // 设置图片
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mPixmap_Oil->topLeft->setCoords(xNewRight, mPlot->yAxis->pixelToCoord(y1+1)); //right_Hight, lY1
|
|
|
|
|
|
mPixmap_Oil->bottomRight->setCoords(xNewLeft, mPlot->yAxis->pixelToCoord(y2-1)); //left_Low
|
|
|
|
|
|
|
|
|
|
|
|
//mPlot->replot();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置矩形范围
|
|
|
|
|
|
void TransparentDraggableSwallCore::setRange(double left_Low, double right_Hight)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(left_Low >= right_Hight) return;
|
|
|
|
|
|
|
|
|
|
|
|
double lY1 = mPlot->yAxis->range().lower;//+10
|
|
|
|
|
|
double lY2 = mPlot->yAxis->range().upper;
|
|
|
|
|
|
|
2025-12-30 11:18:02 +08:00
|
|
|
|
mRect->topLeft->setCoords(left_Low, lY1+(m_fLeftSpace+m_fTriangleLen));
|
|
|
|
|
|
mRect->bottomRight->setCoords(right_Hight, lY1+(m_fLeftSpace+m_fTriangleLen)+m_fImageWidth+m_fColorWordLen);
|
2025-12-22 18:22:45 +08:00
|
|
|
|
|
2025-12-23 17:15:39 +08:00
|
|
|
|
// //位置与rect不一样,否则图像反转
|
|
|
|
|
|
// mPixmap_Color->topLeft->setCoords(right_Hight, lY1+(lY2-lY1)/4);
|
|
|
|
|
|
// mPixmap_Color->bottomRight->setCoords(left_Low, lY2);
|
2025-12-22 18:22:45 +08:00
|
|
|
|
//
|
|
|
|
|
|
//mPixmap_Lith->topLeft->setCoords(right_Hight, lY1+(lY2-lY1)/4);
|
|
|
|
|
|
//mPixmap_Lith->bottomRight->setCoords(left_Low, lY2);
|
|
|
|
|
|
drawLith(left_Low, right_Hight, lY1, lY2);
|
|
|
|
|
|
|
|
|
|
|
|
//位置与rect不一样,否则图像反转
|
|
|
|
|
|
//mPixmap_Oil->topLeft->setCoords(right_Hight, lY1);
|
|
|
|
|
|
//mPixmap_Oil->bottomRight->setCoords(left_Low, lY1+(lY2-lY1)/4);
|
|
|
|
|
|
drawOil(left_Low, right_Hight, lY1, lY2);
|
|
|
|
|
|
|
|
|
|
|
|
//mItemTitle->position->setCoords(0.5, 0.5);
|
|
|
|
|
|
// 设置父锚点,定位点
|
|
|
|
|
|
//mItemTitle->position->setParentAnchor(mRect->bottom);
|
2025-12-23 17:15:39 +08:00
|
|
|
|
mItemTitle->position->setCoords(mRect->bottomRight->coords().x(), //(mRect->topLeft->coords().x() + mRect->bottomRight->coords().x())/2,
|
2025-12-30 11:18:02 +08:00
|
|
|
|
lY1+(m_fLeftSpace+m_fTriangleLen)+m_fImageWidth+20); //(mRect->topLeft->coords().y() + mRect->bottomRight->coords().y())/2); // 设置文本在矩形中心位置
|
2025-12-22 18:22:45 +08:00
|
|
|
|
|
|
|
|
|
|
//mRect->topLeft->setCoords(left, mPlot->yAxis->range().upper);
|
|
|
|
|
|
//mRect->bottomRight->setCoords(right, mPlot->yAxis->range().lower);
|
|
|
|
|
|
|
2025-12-30 11:18:02 +08:00
|
|
|
|
//三角形2边
|
|
|
|
|
|
m_qcpItemLine1->start->setCoords((left_Low+right_Hight)/2, lY1+m_fLeftSpace);
|
|
|
|
|
|
m_qcpItemLine1->end->setCoords(left_Low, lY1+(m_fLeftSpace+m_fTriangleLen));
|
|
|
|
|
|
//
|
|
|
|
|
|
m_qcpItemLine2->start->setCoords((left_Low+right_Hight)/2, lY1+m_fLeftSpace);
|
|
|
|
|
|
m_qcpItemLine2->end->setCoords(right_Hight, lY1+(m_fLeftSpace+m_fTriangleLen));
|
|
|
|
|
|
//
|
|
|
|
|
|
m_qcpItemLine3->start->setCoords((left_Low+right_Hight)/2, lY1+m_fLeftSpace);
|
|
|
|
|
|
m_qcpItemLine3->end->setCoords((left_Low+right_Hight)/2, lY1+(m_fLeftSpace+m_fTriangleLen));
|
|
|
|
|
|
|
2025-12-22 18:22:45 +08:00
|
|
|
|
updateHandles();
|
|
|
|
|
|
mPlot->replot();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取当前范围
|
|
|
|
|
|
QCPRange TransparentDraggableSwallCore::getRange()
|
|
|
|
|
|
{
|
|
|
|
|
|
return QCPRange(mRect->topLeft->coords().x(), mRect->bottomRight->coords().x());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 设置矩形颜色
|
|
|
|
|
|
void TransparentDraggableSwallCore::setColor(const QColor &color)
|
|
|
|
|
|
{
|
|
|
|
|
|
mRect->setBrush(QBrush(color));
|
|
|
|
|
|
mRect->setPen(QPen(color.darker()));
|
2026-01-07 17:39:27 +08:00
|
|
|
|
//mPlot->replot();
|
2025-12-22 18:22:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 删除框图
|
|
|
|
|
|
void TransparentDraggableSwallCore::deleteRect()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(mPlot) {
|
|
|
|
|
|
|
|
|
|
|
|
// mRect->deleteLater();
|
|
|
|
|
|
// mLeftHandle->deleteLater();
|
|
|
|
|
|
// mRightHandle->deleteLater();
|
|
|
|
|
|
// mPixmap->deleteLater();
|
|
|
|
|
|
|
|
|
|
|
|
mPlot->m_mapDraggable_SwallCore.remove(m_strUuid);
|
|
|
|
|
|
|
|
|
|
|
|
mPlot->removeItem(mRect);
|
|
|
|
|
|
// mPlot->removeItem(mLeftHandle);
|
|
|
|
|
|
// mPlot->removeItem(mRightHandle);
|
|
|
|
|
|
mPlot->removeItem(mPixmap_Lith);
|
|
|
|
|
|
mPlot->removeItem(mPixmap_Oil);
|
2025-12-23 17:15:39 +08:00
|
|
|
|
//mPlot->removeItem(mPixmap_Color);
|
2025-12-22 18:22:45 +08:00
|
|
|
|
mPlot->removeItem(mItemTitle);
|
2025-12-30 11:18:02 +08:00
|
|
|
|
//三角形2边
|
|
|
|
|
|
mPlot->removeItem(m_qcpItemLine1);
|
|
|
|
|
|
mPlot->removeItem(m_qcpItemLine2);
|
|
|
|
|
|
mPlot->removeItem(m_qcpItemLine3);
|
2025-12-22 18:22:45 +08:00
|
|
|
|
|
2026-03-18 17:55:43 +08:00
|
|
|
|
//mPlot->replot();
|
2025-12-22 18:22:45 +08:00
|
|
|
|
this->deleteLater();
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
// //避免二次绘制框图
|
|
|
|
|
|
// mPlot->m_bDrawRect = false;
|
|
|
|
|
|
// mDragMode = DragNone;
|
|
|
|
|
|
// //取消选中框
|
|
|
|
|
|
// mPlot->selectionRect()->cancel();
|
|
|
|
|
|
// mPlot->replot();
|
|
|
|
|
|
// mPlot->selectionRect()->mActive=true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TransparentDraggableSwallCore::initRect()
|
|
|
|
|
|
{
|
|
|
|
|
|
// 创建透明矩形
|
|
|
|
|
|
mRect = new QCPItemRect(mPlot);
|
|
|
|
|
|
mRect->setLayer("overlay"); // 确保在最上层
|
|
|
|
|
|
mRect->setBrush(QBrush(QColor(255, 255, 255, 50))); // 半透明蓝色100, 100, 255, 50
|
2025-12-30 11:18:02 +08:00
|
|
|
|
mRect->setPen(QPen(QColor(0, 0, 0, 200)));
|
2025-12-22 18:22:45 +08:00
|
|
|
|
|
|
|
|
|
|
// // 创建左右边界控制点
|
|
|
|
|
|
// mLeftHandle = new QCPItemRect(mPlot);
|
|
|
|
|
|
// mLeftHandle->setLayer("overlay");
|
2026-03-10 18:21:29 +08:00
|
|
|
|
// mLeftHandle->setBrush(QBrush(Qt::black));
|
|
|
|
|
|
// mLeftHandle->setPen(QPen(Qt::black));
|
2025-12-22 18:22:45 +08:00
|
|
|
|
|
|
|
|
|
|
// mRightHandle = new QCPItemRect(mPlot);
|
|
|
|
|
|
// mRightHandle->setLayer("overlay");
|
2026-03-10 18:21:29 +08:00
|
|
|
|
// mRightHandle->setBrush(QBrush(Qt::black));
|
|
|
|
|
|
// mRightHandle->setPen(QPen(Qt::black));
|
2025-12-22 18:22:45 +08:00
|
|
|
|
|
|
|
|
|
|
// 设置初始位置
|
|
|
|
|
|
//double center = mPlot->xAxis->range().center();
|
|
|
|
|
|
// setRange(center - 10, center + 10);
|
|
|
|
|
|
|
|
|
|
|
|
// 连接鼠标事件
|
|
|
|
|
|
connect(mPlot, &QCustomPlot::mousePress, this, &TransparentDraggableSwallCore::onMousePress);
|
|
|
|
|
|
connect(mPlot, &QCustomPlot::mouseMove, this, &TransparentDraggableSwallCore::onMouseMove);
|
|
|
|
|
|
connect(mPlot, &QCustomPlot::mouseRelease, this, &TransparentDraggableSwallCore::onMouseRelease);
|
|
|
|
|
|
|
|
|
|
|
|
mPixmap_Lith = new QCPItemPixmap(mPlot);
|
|
|
|
|
|
//mPixmap->setPixmap(QPixmap(":/image/file.png")); // 设置图片
|
|
|
|
|
|
mPixmap_Lith->setScaled(true, Qt::IgnoreAspectRatio); // 设置缩放方式 KeepAspectRatio
|
|
|
|
|
|
mPixmap_Lith->setLayer("overlay"); // 确保在最上层
|
|
|
|
|
|
|
|
|
|
|
|
mPixmap_Oil = new QCPItemPixmap(mPlot);
|
|
|
|
|
|
//mPixmap_Oil->setPixmap(QPixmap(":/image/file.png")); // 设置图片
|
|
|
|
|
|
mPixmap_Oil->setScaled(true, Qt::IgnoreAspectRatio); // 设置缩放方式 KeepAspectRatio
|
|
|
|
|
|
mPixmap_Oil->setLayer("overlay"); // 确保在最上层
|
|
|
|
|
|
|
2025-12-23 17:15:39 +08:00
|
|
|
|
// mPixmap_Color = new QCPItemPixmap(mPlot);
|
|
|
|
|
|
// //mPixmap_Color->setPixmap(QPixmap(":/image/file.png")); // 设置图片
|
|
|
|
|
|
// mPixmap_Color->setScaled(true, Qt::IgnoreAspectRatio); // 设置缩放方式 KeepAspectRatio
|
|
|
|
|
|
// mPixmap_Color->setLayer("overlay"); // 确保在最上层
|
2025-12-22 18:22:45 +08:00
|
|
|
|
|
|
|
|
|
|
mItemTitle = new QCPItemText(mPlot);
|
|
|
|
|
|
mItemTitle->setText(mstrTitle);
|
|
|
|
|
|
//mItemTitle->setBrush(QBrush(Qt::red));
|
|
|
|
|
|
mItemTitle->setFont(QFont("Arial", 12, QFont::Bold));
|
|
|
|
|
|
mItemTitle->setColor(Qt::black);
|
|
|
|
|
|
mItemTitle->setPositionAlignment(Qt::AlignTop | Qt::AlignHCenter);
|
|
|
|
|
|
mItemTitle->position->setType(QCPItemPosition::ptPlotCoords);
|
|
|
|
|
|
//mItemTitle->position->setType(QCPItemPosition::ptAxisRectRatio);
|
|
|
|
|
|
mItemTitle->position->setCoords(0.5, 0);
|
|
|
|
|
|
mItemTitle->setLayer("overlay");
|
2025-12-30 11:18:02 +08:00
|
|
|
|
|
|
|
|
|
|
//三角形2边
|
|
|
|
|
|
m_qcpItemLine1 = new QCPItemLine(mPlot);
|
|
|
|
|
|
m_qcpItemLine1->setPen(QPen(QColor(0, 0, 0, 200)));
|
|
|
|
|
|
//
|
|
|
|
|
|
m_qcpItemLine2 = new QCPItemLine(mPlot);
|
|
|
|
|
|
m_qcpItemLine2->setPen(QPen(QColor(0, 0, 0, 200)));
|
|
|
|
|
|
//
|
|
|
|
|
|
m_qcpItemLine3 = new QCPItemLine(mPlot);
|
|
|
|
|
|
m_qcpItemLine3->setPen(QPen(QColor(0, 0, 0, 200)));
|
2025-12-22 18:22:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TransparentDraggableSwallCore::updateHandles()
|
|
|
|
|
|
{
|
|
|
|
|
|
// // 左边界矩形控制点
|
|
|
|
|
|
// mLeftHandle->topLeft->setParentAnchor(mRect->topLeft);
|
|
|
|
|
|
// mLeftHandle->bottomRight->setParentAnchor(mRect->topRight);//(mRect->bottomLeft);
|
|
|
|
|
|
// mLeftHandle->topLeft->setCoords(-0.5, 0.5); // 矩形大小
|
|
|
|
|
|
// mLeftHandle->bottomRight->setCoords(0.5, -0.5); // 矩形大小
|
|
|
|
|
|
|
|
|
|
|
|
// // 右边界矩形控制点
|
|
|
|
|
|
// mRightHandle->topLeft->setParentAnchor(mRect->bottomLeft);
|
|
|
|
|
|
// mRightHandle->bottomRight->setParentAnchor(mRect->bottomRight);
|
|
|
|
|
|
// mRightHandle->topLeft->setCoords(-0.5, 0.5); // 矩形大小
|
|
|
|
|
|
// mRightHandle->bottomRight->setCoords(0.5, -0.5); // 矩形大小
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TransparentDraggableSwallCore::onDelRect()
|
|
|
|
|
|
{
|
|
|
|
|
|
//mDragMode = DragNone;
|
|
|
|
|
|
//删除框图
|
|
|
|
|
|
deleteRect();
|
2026-03-18 17:55:43 +08:00
|
|
|
|
mPlot->replot();
|
2026-03-04 18:03:54 +08:00
|
|
|
|
//保存
|
|
|
|
|
|
mPlot->SaveToSLF_SwallCore();
|
|
|
|
|
|
//属性清空
|
|
|
|
|
|
PropertyService()->InitCurrentViewInfo();
|
2025-12-22 18:22:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TransparentDraggableSwallCore::onMousePress(QMouseEvent *event)
|
|
|
|
|
|
{
|
2026-03-04 18:03:54 +08:00
|
|
|
|
//右键
|
|
|
|
|
|
if(event->button() != Qt::LeftButton)
|
|
|
|
|
|
{
|
|
|
|
|
|
double y = mPlot->xAxis->pixelToCoord(event->pos().y());//x轴展示深度
|
|
|
|
|
|
QCPRange currentRange = getRange();
|
|
|
|
|
|
if(y >= currentRange.lower && y <= currentRange.upper) {
|
|
|
|
|
|
mDragMode = DragNone;
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
mDragMode = DragNone;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
//event->accept();
|
|
|
|
|
|
|
|
|
|
|
|
double low = mRect->topLeft->coords().x();
|
2026-03-05 16:45:06 +08:00
|
|
|
|
//double hight = mRect->bottomRight->coords().x();
|
|
|
|
|
|
QString ColorImage = "";
|
|
|
|
|
|
int ind=mPlot->colorinds_SWallCore.indexOf(mstrTitle);
|
|
|
|
|
|
if (ind>-1&&ind<mPlot->colors_SWallCore.size())
|
|
|
|
|
|
{
|
|
|
|
|
|
ColorImage=::GetColorSymbolDir()+""+mPlot->colors_SWallCore[ind]+".svg";
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
ColorImage="";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PropertyService()->initSwallCoreItemProperty(this, low, m_Lith, m_Oil, ColorImage, m_fLeftSpace / g_dPixelPerCm, 1, mstrTitle.toInt());
|
2026-03-04 18:03:54 +08:00
|
|
|
|
|
|
|
|
|
|
QMenu menu(nullptr);
|
|
|
|
|
|
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "删除选中对象", this, &TransparentDraggableSwallCore::onDelRect);
|
|
|
|
|
|
menu.addAction(QIcon(::GetImagePath() + "icon/Shift.png"), "设置深度移动量", this, &TransparentDraggableSwallCore::setItemDepthOffset);
|
|
|
|
|
|
menu.exec(event->globalPos());
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-12-22 18:22:45 +08:00
|
|
|
|
|
|
|
|
|
|
event->accept();
|
|
|
|
|
|
|
|
|
|
|
|
// 检查点击了哪个部分
|
|
|
|
|
|
//double x = mPlot->xAxis->pixelToCoord(event->pos().x());
|
|
|
|
|
|
//double y = mPlot->yAxis->pixelToCoord(event->pos().y());
|
|
|
|
|
|
|
|
|
|
|
|
double y = mPlot->xAxis->pixelToCoord(event->pos().y());//x轴展示深度
|
|
|
|
|
|
|
|
|
|
|
|
QCPRange currentRange = getRange();
|
|
|
|
|
|
|
|
|
|
|
|
/*if(mLeftHandle->selectTest(event->pos(), false) < 5) {
|
|
|
|
|
|
mDragMode = DragLeft;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(mRightHandle->selectTest(event->pos(), false) < 5) {
|
|
|
|
|
|
mDragMode = DragRight;
|
|
|
|
|
|
}
|
|
|
|
|
|
//else if(x >= currentRange.lower && x <= currentRange.upper) {
|
|
|
|
|
|
else */
|
|
|
|
|
|
if(y >= currentRange.lower && y <= currentRange.upper) {
|
|
|
|
|
|
mDragMode = DragRect;
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
mDragMode = DragNone;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//mDragStartX = x;
|
|
|
|
|
|
mDragStartY = y;
|
|
|
|
|
|
mDragStartRange = currentRange;
|
2026-03-13 09:00:26 +08:00
|
|
|
|
}
|
2025-12-22 18:22:45 +08:00
|
|
|
|
|
2026-03-13 09:00:26 +08:00
|
|
|
|
int TransparentDraggableSwallCore::getCursor()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_bMoveRect)
|
|
|
|
|
|
{
|
|
|
|
|
|
return 2;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (m_bArrow)
|
|
|
|
|
|
{
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
return 0;
|
2025-12-22 18:22:45 +08:00
|
|
|
|
}
|
2026-03-13 09:00:26 +08:00
|
|
|
|
|
|
|
|
|
|
void TransparentDraggableSwallCore::onMouseMove(QMouseEvent *event)
|
2025-12-22 18:22:45 +08:00
|
|
|
|
{
|
2026-03-13 09:00:26 +08:00
|
|
|
|
if (mDragMode == DragRect)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_bMoveRect = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
m_bArrow = false;
|
|
|
|
|
|
m_bMoveRect = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------
|
2025-12-22 18:22:45 +08:00
|
|
|
|
if(mDragMode == DragNone) return;
|
|
|
|
|
|
|
|
|
|
|
|
event->accept();
|
|
|
|
|
|
|
|
|
|
|
|
//double x = mPlot->xAxis->pixelToCoord(event->pos().x());
|
|
|
|
|
|
//double dx = x - mDragStartX;
|
|
|
|
|
|
|
|
|
|
|
|
double y = mPlot->xAxis->pixelToCoord(event->pos().y());
|
|
|
|
|
|
double dy = y - mDragStartY;
|
|
|
|
|
|
|
|
|
|
|
|
QCPRange newRange = mDragStartRange;
|
|
|
|
|
|
|
|
|
|
|
|
switch(mDragMode) {
|
|
|
|
|
|
case DragLeft: {
|
|
|
|
|
|
//double proposedLeft = mDragStartRange.lower + dx;
|
|
|
|
|
|
double proposedLeft = mDragStartRange.lower + dy;
|
|
|
|
|
|
// 确保不超出轴范围且不使宽度小于最小值
|
|
|
|
|
|
newRange.lower = qBound(
|
|
|
|
|
|
//mPlot->xAxis->range().lower,
|
|
|
|
|
|
getMyLower(),
|
|
|
|
|
|
proposedLeft,
|
|
|
|
|
|
mDragStartRange.upper - mMinWidth);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
case DragRight: {
|
|
|
|
|
|
//double proposedRight = mDragStartRange.upper + dx;
|
|
|
|
|
|
double proposedRight = mDragStartRange.upper + dy;
|
|
|
|
|
|
// 确保不超出轴范围且不使宽度小于最小值
|
|
|
|
|
|
newRange.upper = qBound(
|
|
|
|
|
|
mDragStartRange.lower + mMinWidth,
|
|
|
|
|
|
proposedRight,
|
|
|
|
|
|
getMyUpper());
|
|
|
|
|
|
//mPlot->xAxis->range().upper);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
case DragRect: {
|
|
|
|
|
|
double width = mDragStartRange.size();
|
|
|
|
|
|
//double center = mDragStartRange.center() + dx;
|
|
|
|
|
|
double center = mDragStartRange.center() + dy;
|
|
|
|
|
|
newRange.lower = center - width/2;
|
|
|
|
|
|
newRange.upper = center + width/2;
|
|
|
|
|
|
|
|
|
|
|
|
// 检查是否超出轴范围
|
|
|
|
|
|
if(newRange.lower < getMyLower()) {
|
|
|
|
|
|
newRange.lower = getMyLower();
|
|
|
|
|
|
newRange.upper = newRange.lower + width;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(newRange.upper > getMyUpper()) {
|
|
|
|
|
|
newRange.upper = getMyUpper();
|
|
|
|
|
|
newRange.lower = newRange.upper - width;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// QCPRange axisRange = mPlot->xAxis->range();
|
|
|
|
|
|
// if(newRange.lower < axisRange.lower) {
|
|
|
|
|
|
// newRange.lower = axisRange.lower;
|
|
|
|
|
|
// newRange.upper = newRange.lower + width;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// else if(newRange.upper > axisRange.upper) {
|
|
|
|
|
|
// newRange.upper = axisRange.upper;
|
|
|
|
|
|
// newRange.lower = newRange.upper - width;
|
|
|
|
|
|
// }
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
default:
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// //取整数(方便显示统计,左右边界整数显示。)
|
|
|
|
|
|
// newRange.lower = (int)newRange.lower;
|
|
|
|
|
|
// QCPRange rangeByFile = mPlot->xAxis->range();
|
|
|
|
|
|
// if (std::fabs(rangeByFile.upper - (int)newRange.upper) >= 1.0)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// newRange.upper = (int)newRange.upper;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// 最终确保宽度不小于最小值(针对整体拖动的情况)
|
|
|
|
|
|
if(newRange.size() < mMinWidth) {
|
|
|
|
|
|
if(mDragMode == DragRect) {
|
|
|
|
|
|
// 如果是整体拖动,保持中心点不变
|
|
|
|
|
|
double center = newRange.center();
|
|
|
|
|
|
newRange.lower = center - mMinWidth/2;
|
|
|
|
|
|
newRange.upper = center + mMinWidth/2;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 如果是边界拖动,强制设置最小宽度
|
|
|
|
|
|
if(mDragMode == DragLeft) {
|
|
|
|
|
|
newRange.lower = newRange.upper - mMinWidth;
|
|
|
|
|
|
} else if(mDragMode == DragRight) {
|
|
|
|
|
|
newRange.upper = newRange.lower + mMinWidth;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-17 16:57:24 +08:00
|
|
|
|
//位置改变,鼠标拖动item
|
|
|
|
|
|
if(newRange.lower!= mDragStartRange.lower || newRange.upper!= mDragStartRange.upper)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_bChange = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-22 18:22:45 +08:00
|
|
|
|
setRange(newRange.lower, newRange.upper);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-04 18:03:54 +08:00
|
|
|
|
//设置深度移动量
|
|
|
|
|
|
void TransparentDraggableSwallCore::setItemDepthOffset()
|
|
|
|
|
|
{
|
|
|
|
|
|
bool ok=0;
|
|
|
|
|
|
double depthshift=QInputDialog::getDouble(NULL,"深度移动","请输入移动的深度量(上移-,下移+)",0.0,-2147483647, 2147483647,4,&ok);
|
|
|
|
|
|
if(!ok) return;
|
|
|
|
|
|
|
|
|
|
|
|
QCPRange currentRange = getRange();
|
|
|
|
|
|
QCPRange newRange = currentRange;
|
|
|
|
|
|
|
|
|
|
|
|
newRange.lower = currentRange.lower-depthshift;
|
|
|
|
|
|
newRange.upper = currentRange.upper-depthshift;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
double width = currentRange.size();
|
|
|
|
|
|
// //double center = mDragStartRange.center() + dx;
|
|
|
|
|
|
// double center = currentRange.center() - depthshift;
|
|
|
|
|
|
// newRange.lower = center - width/2;
|
|
|
|
|
|
// newRange.upper = center + width/2;
|
|
|
|
|
|
|
|
|
|
|
|
// 检查是否超出轴范围
|
|
|
|
|
|
if(newRange.lower < getMyLower()) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(newRange.upper > getMyUpper()) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
//
|
|
|
|
|
|
setRange(newRange.lower, newRange.upper);
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
//保存
|
|
|
|
|
|
mPlot->SaveToSLF_SwallCore();
|
|
|
|
|
|
|
|
|
|
|
|
//属性清空
|
|
|
|
|
|
PropertyService()->InitCurrentViewInfo();
|
|
|
|
|
|
|
|
|
|
|
|
//取消所有选中单元格
|
2026-03-05 16:45:06 +08:00
|
|
|
|
emit CallManage::getInstance()->sig_Raise(mPlot->m_strUuid, "", "", "", "", 0, "");
|
2026-03-04 18:03:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-22 18:22:45 +08:00
|
|
|
|
void TransparentDraggableSwallCore::onMouseRelease(QMouseEvent *event)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(event->button() == Qt::LeftButton && mDragMode != DragNone) {
|
|
|
|
|
|
event->accept();
|
2026-03-05 16:45:06 +08:00
|
|
|
|
//属性
|
2026-03-17 16:57:24 +08:00
|
|
|
|
|
2026-03-05 16:45:06 +08:00
|
|
|
|
{
|
|
|
|
|
|
double low = mRect->topLeft->coords().x();
|
|
|
|
|
|
QString ColorImage = "";
|
|
|
|
|
|
int ind=mPlot->colorinds_SWallCore.indexOf(mstrTitle);
|
|
|
|
|
|
if (ind>-1&&ind<mPlot->colors_SWallCore.size())
|
|
|
|
|
|
{
|
|
|
|
|
|
ColorImage=::GetColorSymbolDir()+""+mPlot->colors_SWallCore[ind]+".svg";
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
ColorImage="";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PropertyService()->initSwallCoreItemProperty(this, low, m_Lith, m_Oil, ColorImage, m_fLeftSpace / g_dPixelPerCm, 1, mstrTitle.toInt());
|
|
|
|
|
|
|
2026-03-17 16:57:24 +08:00
|
|
|
|
if(m_bChange)
|
|
|
|
|
|
{
|
|
|
|
|
|
//保存
|
|
|
|
|
|
mPlot->SaveToSLF_SwallCore();
|
|
|
|
|
|
}
|
2026-03-05 16:45:06 +08:00
|
|
|
|
|
|
|
|
|
|
//取消所有选中单元格
|
|
|
|
|
|
emit CallManage::getInstance()->sig_Raise(mPlot->m_strUuid, "", "", "", "", 0, "");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-22 18:22:45 +08:00
|
|
|
|
//避免二次绘制框图
|
|
|
|
|
|
mPlot->m_bDrawRect = false;
|
|
|
|
|
|
//emit rangeChanged(getRange());
|
|
|
|
|
|
mDragMode = DragNone;
|
|
|
|
|
|
//取消选中状态
|
|
|
|
|
|
// QCPDataSelection emptySelection;
|
|
|
|
|
|
// mPlot->graph(0)->setSelection(emptySelection);
|
|
|
|
|
|
// mPlot->replot();
|
|
|
|
|
|
|
|
|
|
|
|
//取消选中框
|
|
|
|
|
|
mPlot->selectionRect()->cancel();
|
|
|
|
|
|
mPlot->replot();
|
|
|
|
|
|
mPlot->selectionRect()->mActive=true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double TransparentDraggableSwallCore::getMyLower()
|
|
|
|
|
|
{
|
|
|
|
|
|
double dLower = mPlot->xAxis->range().lower;
|
|
|
|
|
|
double proposedLeft = mDragStartRange.lower;
|
|
|
|
|
|
|
|
|
|
|
|
TransparentDraggableSwallCore *pDraggableRect =NULL;
|
|
|
|
|
|
{
|
|
|
|
|
|
QMap<QString,QObject *>::Iterator it = mPlot->m_mapDraggable_SwallCore.begin();
|
|
|
|
|
|
while( it != mPlot->m_mapDraggable_SwallCore.end() )
|
|
|
|
|
|
{
|
|
|
|
|
|
if(it.key() == m_strUuid)
|
|
|
|
|
|
{
|
|
|
|
|
|
it++;
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
pDraggableRect = (TransparentDraggableSwallCore*)it.value();
|
|
|
|
|
|
//
|
|
|
|
|
|
QCPRange tmpRange = pDraggableRect->getRange();
|
|
|
|
|
|
if(tmpRange.upper >= dLower && tmpRange.upper <= proposedLeft)
|
|
|
|
|
|
{
|
|
|
|
|
|
dLower = tmpRange.upper;
|
|
|
|
|
|
}
|
|
|
|
|
|
it++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return dLower;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double TransparentDraggableSwallCore::getMyUpper()
|
|
|
|
|
|
{
|
|
|
|
|
|
double dUpper = mPlot->xAxis->range().upper;
|
|
|
|
|
|
double proposedRight = mDragStartRange.upper;
|
|
|
|
|
|
|
|
|
|
|
|
TransparentDraggableSwallCore *pDraggableRect =NULL;
|
|
|
|
|
|
{
|
|
|
|
|
|
QMap<QString,QObject *>::Iterator it = mPlot->m_mapDraggable_SwallCore.begin();
|
|
|
|
|
|
while( it != mPlot->m_mapDraggable_SwallCore.end() )
|
|
|
|
|
|
{
|
|
|
|
|
|
if(it.key() == m_strUuid)
|
|
|
|
|
|
{
|
|
|
|
|
|
it++;
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
pDraggableRect = (TransparentDraggableSwallCore*)it.value();
|
|
|
|
|
|
//
|
|
|
|
|
|
QCPRange tmpRange = pDraggableRect->getRange();
|
|
|
|
|
|
if(tmpRange.lower <= dUpper && tmpRange.lower >= proposedRight)
|
|
|
|
|
|
{
|
|
|
|
|
|
dUpper = tmpRange.lower;
|
|
|
|
|
|
}
|
|
|
|
|
|
it++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return dUpper;
|
|
|
|
|
|
}
|