1.解释结论修改,添加组的概念,一层属于一组,一组包含多个油气结论
2.组可以调整组的上下边界,同时调整靠近上下边界的油气高度,中间油气高度可调整 3.添加选中层效果,根据logplus效果调整拖动效果,以及鼠标光标状态。
This commit is contained in:
parent
8d555aebbe
commit
5fa39288a9
|
|
@ -13,6 +13,17 @@
|
||||||
float mLineWidth=0.75;
|
float mLineWidth=0.75;
|
||||||
QString OilField;
|
QString OilField;
|
||||||
|
|
||||||
|
QString getUUid()
|
||||||
|
{
|
||||||
|
QUuid id = QUuid::createUuid();
|
||||||
|
QString strId = id.toString();
|
||||||
|
strId.replace("{", "");
|
||||||
|
strId.replace("}", "");
|
||||||
|
strId.replace("-", "");
|
||||||
|
//qDebug() << strId;
|
||||||
|
return strId;
|
||||||
|
}
|
||||||
|
|
||||||
double GetData(int RepCode, char *buffer)
|
double GetData(int RepCode, char *buffer)
|
||||||
{
|
{
|
||||||
double yy;
|
double yy;
|
||||||
|
|
|
||||||
|
|
@ -168,6 +168,8 @@ typedef struct GEOLITH_Table
|
||||||
char Dest[64];
|
char Dest[64];
|
||||||
} GeoLith_DATA;
|
} GeoLith_DATA;
|
||||||
|
|
||||||
|
QString getUUid();
|
||||||
|
|
||||||
double GetData(int RepCode, char *buffer);
|
double GetData(int RepCode, char *buffer);
|
||||||
|
|
||||||
QString GetProjectFolder();
|
QString GetProjectFolder();
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,7 @@ void TransparentDraggableResult::drawResult(double left_Low, double right_Hight,
|
||||||
QImage image(y2-y1, x1-x2,QImage::Format_RGB32);
|
QImage image(y2-y1, x1-x2,QImage::Format_RGB32);
|
||||||
QPainter painter(&image);
|
QPainter painter(&image);
|
||||||
QRectF fillRect(0,0, y2-y1, x1-x2);
|
QRectF fillRect(0,0, y2-y1, x1-x2);
|
||||||
|
//painter.setPen(QPen(Qt::black));
|
||||||
painter.fillRect(fillRect,Qt::white);
|
painter.fillRect(fillRect,Qt::white);
|
||||||
//拉伸
|
//拉伸
|
||||||
DrawSVGSteched(&painter,filePath,fillRect,0);
|
DrawSVGSteched(&painter,filePath,fillRect,0);
|
||||||
|
|
@ -167,9 +168,9 @@ void TransparentDraggableResult::setRange(double left_Low, double right_Hight)
|
||||||
if(left_Low >= right_Hight) return;
|
if(left_Low >= right_Hight) return;
|
||||||
|
|
||||||
double lY1 = mPlot->yAxis->range().lower;//+10
|
double lY1 = mPlot->yAxis->range().lower;//+10
|
||||||
double lY2 = (mPlot->yAxis->range().upper-mPlot->yAxis->range().lower)/4;
|
double lY2 = (mPlot->yAxis->range().upper-mPlot->yAxis->range().lower)/2;
|
||||||
mRect->topLeft->setCoords(left_Low, lY1);
|
mRect->topLeft->setCoords(left_Low, lY1);
|
||||||
mRect->bottomRight->setCoords(right_Hight, lY2);
|
mRect->bottomRight->setCoords(right_Hight, mPlot->yAxis->range().upper);
|
||||||
|
|
||||||
//位置与rect不一样,否则图像反转
|
//位置与rect不一样,否则图像反转
|
||||||
// double dbCenterX = (right_Hight+left_Low)/2.0; //right_Hight; //
|
// double dbCenterX = (right_Hight+left_Low)/2.0; //right_Hight; //
|
||||||
|
|
@ -203,6 +204,16 @@ void TransparentDraggableResult::setRange(double left_Low, double right_Hight)
|
||||||
//mPlot->replot();
|
//mPlot->replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TransparentDraggableResult::setDragRange(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 - mPlot->yAxis->range().lower) / 2;
|
||||||
|
mDragRect->topLeft->setCoords(left_Low, lY1);
|
||||||
|
mDragRect->bottomRight->setCoords(right_Hight, mPlot->yAxis->range().upper);
|
||||||
|
}
|
||||||
|
|
||||||
// 获取当前范围
|
// 获取当前范围
|
||||||
QCPRange TransparentDraggableResult::getRange()
|
QCPRange TransparentDraggableResult::getRange()
|
||||||
{
|
{
|
||||||
|
|
@ -211,8 +222,8 @@ QCPRange TransparentDraggableResult::getRange()
|
||||||
|
|
||||||
// 设置矩形颜色
|
// 设置矩形颜色
|
||||||
void TransparentDraggableResult::setColor(const QColor &color) {
|
void TransparentDraggableResult::setColor(const QColor &color) {
|
||||||
mRect->setBrush(QBrush(color));
|
//mRect->setBrush(QBrush(color));
|
||||||
mRect->setPen(QPen(color.darker()));
|
//mRect->setPen(QPen(color.darker(), 1, Qt::DashLine));
|
||||||
//mPlot->replot();
|
//mPlot->replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -229,8 +240,9 @@ void TransparentDraggableResult::deleteRect()
|
||||||
mPlot->m_mapDraggable_Result.remove(m_strUuid);
|
mPlot->m_mapDraggable_Result.remove(m_strUuid);
|
||||||
|
|
||||||
mPlot->removeItem(mRect);
|
mPlot->removeItem(mRect);
|
||||||
mPlot->removeItem(mLeftHandle);
|
if (mLeftHandle)
|
||||||
mPlot->removeItem(mRightHandle);
|
mPlot->removeItem(mLeftHandle);
|
||||||
|
//mPlot->removeItem(mRightHandle);
|
||||||
mPlot->removeItem(mPixmap);
|
mPlot->removeItem(mPixmap);
|
||||||
mPlot->removeItem(mItemTitle);
|
mPlot->removeItem(mItemTitle);
|
||||||
|
|
||||||
|
|
@ -249,38 +261,76 @@ void TransparentDraggableResult::deleteRect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TransparentDraggableResult::setSelectRect(bool bselect)
|
||||||
|
{
|
||||||
|
if (bselect)
|
||||||
|
{
|
||||||
|
mRect->setBrush(QColor(255, 0, 0, 80));
|
||||||
|
mRect->setPen(QPen(Qt::black, 1, Qt::DashLine));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mRect->setBrush(Qt::NoBrush);
|
||||||
|
mRect->setPen(Qt::NoPen);
|
||||||
|
}
|
||||||
|
mPlot->replot();
|
||||||
|
}
|
||||||
|
|
||||||
|
QCPItemRect * TransparentDraggableResult::getLeftHandle()
|
||||||
|
{
|
||||||
|
return mLeftHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
TransparentDraggableResult* TransparentDraggableResult::getUpResult()
|
||||||
|
{
|
||||||
|
return m_upDraggableResult;
|
||||||
|
}
|
||||||
|
|
||||||
void TransparentDraggableResult::initRect()
|
void TransparentDraggableResult::initRect()
|
||||||
{
|
{
|
||||||
|
// 创建透明矩形
|
||||||
|
mDragRect = new QCPItemRect(mPlot);
|
||||||
|
mDragRect->setLayer("overlay"); // 确保在最上层
|
||||||
|
mDragRect->setBrush(Qt::NoBrush);
|
||||||
|
mDragRect->setPen(QPen(Qt::red, 1, Qt::DashDotDotLine));
|
||||||
|
mDragRect->setVisible(false);
|
||||||
|
|
||||||
// 创建透明矩形
|
// 创建透明矩形
|
||||||
mRect = new QCPItemRect(mPlot);
|
mRect = new QCPItemRect(mPlot);
|
||||||
mRect->setLayer("overlay"); // 确保在最上层
|
mRect->setLayer("overlay"); // 确保在最上层
|
||||||
mRect->setBrush(QBrush(QColor(255, 255, 255, 50))); // 半透明蓝色
|
mRect->setBrush(Qt::NoBrush);
|
||||||
mRect->setPen(QPen(QColor(70, 70, 255, 200)));
|
mRect->setPen(Qt::NoPen);
|
||||||
|
|
||||||
// 创建左右边界控制点
|
if (m_upDraggableResult)
|
||||||
mLeftHandle = new QCPItemRect(mPlot);
|
{
|
||||||
mLeftHandle->setLayer("overlay");
|
// 创建左右边界控制点
|
||||||
mLeftHandle->setBrush(QBrush(Qt::red));
|
mLeftHandle = new QCPItemRect(mPlot);
|
||||||
mLeftHandle->setPen(QPen(Qt::darkRed));
|
mLeftHandle->setLayer("overlay");
|
||||||
|
mLeftHandle->setBrush(Qt::NoBrush);
|
||||||
|
mLeftHandle->setPen(Qt::NoPen);
|
||||||
|
}
|
||||||
|
|
||||||
mRightHandle = new QCPItemRect(mPlot);
|
//mRightHandle = new QCPItemRect(mPlot);
|
||||||
mRightHandle->setLayer("overlay");
|
//mRightHandle->setLayer("overlay");
|
||||||
mRightHandle->setBrush(QBrush(Qt::red));
|
//mRightHandle->setBrush(Qt::NoBrush);
|
||||||
mRightHandle->setPen(QPen(Qt::darkRed));
|
//mRightHandle->setPen(Qt::NoPen);
|
||||||
|
|
||||||
// 设置初始位置
|
// 设置初始位置
|
||||||
//double center = mPlot->xAxis->range().center();
|
//double center = mPlot->xAxis->range().center();
|
||||||
// setRange(center - 10, center + 10);
|
// setRange(center - 10, center + 10);
|
||||||
|
|
||||||
// 连接鼠标事件
|
// 连接鼠标事件
|
||||||
connect(mPlot, &QCustomPlot::mousePress, this, &TransparentDraggableResult::onMousePress);
|
// connect(mPlot, &QCustomPlot::mousePress, this, &TransparentDraggableResult::onMousePress);
|
||||||
connect(mPlot, &QCustomPlot::mouseMove, this, &TransparentDraggableResult::onMouseMove);
|
// connect(mPlot, &QCustomPlot::mouseMove, this, &TransparentDraggableResult::onMouseMove);
|
||||||
connect(mPlot, &QCustomPlot::mouseRelease, this, &TransparentDraggableResult::onMouseRelease);
|
// connect(mPlot, &QCustomPlot::mouseRelease, this, &TransparentDraggableResult::onMouseRelease);
|
||||||
|
|
||||||
mPixmap = new QCPItemPixmap(mPlot);
|
mPixmap = new QCPItemPixmap(mPlot);
|
||||||
//mPixmap->setPixmap(QPixmap(":/image/file.png")); // 设置图片
|
//mPixmap->setPixmap(QPixmap(":/image/file.png")); // 设置图片
|
||||||
mPixmap->setScaled(true, Qt::IgnoreAspectRatio); // 设置缩放方式
|
mPixmap->setScaled(true, Qt::IgnoreAspectRatio); // 设置缩放方式
|
||||||
mPixmap->setLayer("overlay"); // 确保在最上层
|
mPixmap->setLayer("overlay"); // 确保在最上层
|
||||||
|
QPen pen = QPen(Qt::black);
|
||||||
|
pen.setWidth(1);
|
||||||
|
mPixmap->setPen(pen);
|
||||||
|
|
||||||
mItemTitle = new QCPItemText(mPlot);
|
mItemTitle = new QCPItemText(mPlot);
|
||||||
mItemTitle->setText(mstrTitle);
|
mItemTitle->setText(mstrTitle);
|
||||||
|
|
@ -297,16 +347,19 @@ void TransparentDraggableResult::initRect()
|
||||||
void TransparentDraggableResult::updateHandles()
|
void TransparentDraggableResult::updateHandles()
|
||||||
{
|
{
|
||||||
// 左边界矩形控制点
|
// 左边界矩形控制点
|
||||||
mLeftHandle->topLeft->setParentAnchor(mRect->topLeft);
|
// mLeftHandle->topLeft->setParentAnchor(mRect->topLeft);
|
||||||
mLeftHandle->bottomRight->setParentAnchor(mRect->topRight);//(mRect->bottomLeft);
|
// mLeftHandle->bottomRight->setParentAnchor(mRect->topRight);//(mRect->bottomLeft);
|
||||||
mLeftHandle->topLeft->setCoords(-0.5, 0.5); // 矩形大小
|
// mLeftHandle->topLeft->setCoords(-0.5, 0.5); // 矩形大小
|
||||||
mLeftHandle->bottomRight->setCoords(0.5, -0.5); // 矩形大小
|
// mLeftHandle->bottomRight->setCoords(0.5, -0.5); // 矩形大小
|
||||||
|
|
||||||
// 右边界矩形控制点
|
// 右边界矩形控制点
|
||||||
mRightHandle->topLeft->setParentAnchor(mRect->bottomLeft);
|
if (mLeftHandle)
|
||||||
mRightHandle->bottomRight->setParentAnchor(mRect->bottomRight);
|
{
|
||||||
mRightHandle->topLeft->setCoords(-0.5, 0.5); // 矩形大小
|
mLeftHandle->topLeft->setParentAnchor(mRect->bottomLeft);
|
||||||
mRightHandle->bottomRight->setCoords(0.5, -0.5); // 矩形大小
|
mLeftHandle->bottomRight->setParentAnchor(mRect->bottomRight);
|
||||||
|
mLeftHandle->topLeft->setCoords(-0.5, 0.5); // 矩形大小
|
||||||
|
mLeftHandle->bottomRight->setCoords(0.5, -0.5); // 矩形大
|
||||||
|
}
|
||||||
|
|
||||||
// if(m_upDraggableResult)
|
// if(m_upDraggableResult)
|
||||||
// {
|
// {
|
||||||
|
|
@ -370,7 +423,7 @@ void TransparentDraggableResult::onMousePress(QMouseEvent *event)
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
event->accept();
|
|
||||||
|
|
||||||
// 检查点击了哪个部分
|
// 检查点击了哪个部分
|
||||||
//double x = mPlot->xAxis->pixelToCoord(event->pos().x());
|
//double x = mPlot->xAxis->pixelToCoord(event->pos().x());
|
||||||
|
|
@ -380,20 +433,25 @@ void TransparentDraggableResult::onMousePress(QMouseEvent *event)
|
||||||
|
|
||||||
QCPRange currentRange = getRange();
|
QCPRange currentRange = getRange();
|
||||||
|
|
||||||
if(mLeftHandle->selectTest(event->pos(), false) < 5) {
|
if(mLeftHandle && mLeftHandle->selectTest(event->pos(), false) < 5) {
|
||||||
mDragMode = DragLeft;
|
mDragMode = DragLeft;
|
||||||
}
|
}
|
||||||
else if(mRightHandle->selectTest(event->pos(), false) < 5) {
|
else
|
||||||
mDragMode = DragRight;
|
{
|
||||||
}
|
|
||||||
//else if(x >= currentRange.lower && x <= currentRange.upper) {
|
|
||||||
else if(y >= currentRange.lower && y <= currentRange.upper) {
|
|
||||||
mDragMode = DragRect;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mDragMode = DragNone;
|
mDragMode = DragNone;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// 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;
|
//mDragStartX = x;
|
||||||
mDragStartY = y;
|
mDragStartY = y;
|
||||||
|
|
@ -420,6 +478,8 @@ void TransparentDraggableResult::onMousePress(QMouseEvent *event)
|
||||||
m_downDraggableResult->mDragStartRange = m_downDraggableResult->getRange();
|
m_downDraggableResult->mDragStartRange = m_downDraggableResult->getRange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event->ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransparentDraggableResult::onMouseMove_in(QMouseEvent *event)
|
void TransparentDraggableResult::onMouseMove_in(QMouseEvent *event)
|
||||||
|
|
@ -512,7 +572,12 @@ void TransparentDraggableResult::onMouseMove_in(QMouseEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setRange(newRange.lower, newRange.upper);
|
if (abs(dy) > 0.2)
|
||||||
|
{
|
||||||
|
mDragRect->setVisible(true);
|
||||||
|
setDragRange(newRange.lower, newRange.upper);
|
||||||
|
}
|
||||||
|
//setRange(newRange.lower, newRange.upper);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransparentDraggableResult::onMouseMove_in_DragLeft(QMouseEvent *event)
|
void TransparentDraggableResult::onMouseMove_in_DragLeft(QMouseEvent *event)
|
||||||
|
|
@ -566,26 +631,6 @@ void TransparentDraggableResult::onMouseMove(QMouseEvent *event)
|
||||||
|
|
||||||
onMouseMove_in(event);
|
onMouseMove_in(event);
|
||||||
|
|
||||||
//上方rect同步动
|
|
||||||
if(m_upDraggableResult)
|
|
||||||
{
|
|
||||||
if(mDragMode==DragRight || mDragMode==DragRect)
|
|
||||||
{
|
|
||||||
//m_upDraggableResult->mDragMode = DragLeft;
|
|
||||||
m_upDraggableResult->onMouseMove_in_DragLeft(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//下方rect同步动
|
|
||||||
if(m_downDraggableResult)
|
|
||||||
{
|
|
||||||
if(mDragMode==DragLeft || mDragMode==DragRect)
|
|
||||||
{
|
|
||||||
//m_downDraggableResult->mDragMode = DragRight;
|
|
||||||
m_downDraggableResult->onMouseMove_in_DragRight(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//后面统一刷新上方和下方rect
|
//后面统一刷新上方和下方rect
|
||||||
mPlot->replot();
|
mPlot->replot();
|
||||||
}
|
}
|
||||||
|
|
@ -598,6 +643,7 @@ void TransparentDraggableResult::onMouseRelease_in(QMouseEvent *event)
|
||||||
mPlot->m_bDrawRect = false;
|
mPlot->m_bDrawRect = false;
|
||||||
//emit rangeChanged(getRange());
|
//emit rangeChanged(getRange());
|
||||||
mDragMode = DragNone;
|
mDragMode = DragNone;
|
||||||
|
|
||||||
//取消选中状态
|
//取消选中状态
|
||||||
// QCPDataSelection emptySelection;
|
// QCPDataSelection emptySelection;
|
||||||
// mPlot->graph(0)->setSelection(emptySelection);
|
// mPlot->graph(0)->setSelection(emptySelection);
|
||||||
|
|
@ -614,19 +660,47 @@ void TransparentDraggableResult::onMouseRelease(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(event->button() == Qt::LeftButton && mDragMode != DragNone) {
|
if(event->button() == Qt::LeftButton && mDragMode != DragNone) {
|
||||||
//上方rect同步动
|
|
||||||
if(m_upDraggableResult)
|
if (mDragRect->visible())
|
||||||
{
|
{
|
||||||
if(mDragMode==DragRight || mDragMode==DragRect)
|
//上方rect同步动
|
||||||
|
if (m_upDraggableResult)
|
||||||
|
{
|
||||||
|
if (mDragMode == DragRight || mDragMode == DragRect)
|
||||||
|
{
|
||||||
|
//m_upDraggableResult->mDragMode = DragLeft;
|
||||||
|
m_upDraggableResult->onMouseMove_in_DragLeft(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//下方rect同步动
|
||||||
|
if (m_downDraggableResult)
|
||||||
|
{
|
||||||
|
if (mDragMode == DragLeft || mDragMode == DragRect)
|
||||||
|
{
|
||||||
|
//m_downDraggableResult->mDragMode = DragRight;
|
||||||
|
m_downDraggableResult->onMouseMove_in_DragRight(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mDragRect->setVisible(false);
|
||||||
|
setRange(mDragRect->topLeft->key(), mDragRect->bottomRight->key());
|
||||||
|
mPlot->replot();
|
||||||
|
}
|
||||||
|
|
||||||
|
//上方rect同步动
|
||||||
|
if (m_upDraggableResult)
|
||||||
|
{
|
||||||
|
if (mDragMode == DragRight || mDragMode == DragRect)
|
||||||
{
|
{
|
||||||
m_upDraggableResult->onMouseRelease_in(event);
|
m_upDraggableResult->onMouseRelease_in(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//下方rect同步动
|
//下方rect同步动
|
||||||
if(m_downDraggableResult)
|
if (m_downDraggableResult)
|
||||||
{
|
{
|
||||||
if(mDragMode==DragLeft || mDragMode==DragRect)
|
if (mDragMode == DragLeft || mDragMode == DragRect)
|
||||||
{
|
{
|
||||||
m_downDraggableResult->onMouseRelease_in(event);
|
m_downDraggableResult->onMouseRelease_in(event);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ public:
|
||||||
void drawResult(double left_Low, double right_Hight, double lY1, double lY2);
|
void drawResult(double left_Low, double right_Hight, double lY1, double lY2);
|
||||||
// 设置矩形范围
|
// 设置矩形范围
|
||||||
void setRange(double left_Low, double right_Hight);
|
void setRange(double left_Low, double right_Hight);
|
||||||
|
void setDragRange(double left_Low, double right_Hight);
|
||||||
// 获取当前范围
|
// 获取当前范围
|
||||||
QCPRange getRange();
|
QCPRange getRange();
|
||||||
|
|
||||||
|
|
@ -44,6 +45,10 @@ public:
|
||||||
// 删除框图
|
// 删除框图
|
||||||
void deleteRect();
|
void deleteRect();
|
||||||
|
|
||||||
|
void setSelectRect(bool bselect);
|
||||||
|
|
||||||
|
QCPItemRect * getLeftHandle();
|
||||||
|
TransparentDraggableResult* getUpResult();
|
||||||
signals:
|
signals:
|
||||||
void rangeChanged(QCPRange newRange);
|
void rangeChanged(QCPRange newRange);
|
||||||
|
|
||||||
|
|
@ -68,8 +73,10 @@ private slots:
|
||||||
private:
|
private:
|
||||||
QMyCustomPlot *mPlot;
|
QMyCustomPlot *mPlot;
|
||||||
QCPItemRect *mRect;
|
QCPItemRect *mRect;
|
||||||
QCPItemRect *mLeftHandle;
|
QCPItemRect *mLeftHandle = NULL;
|
||||||
QCPItemRect *mRightHandle;
|
QCPItemRect *mRightHandle;
|
||||||
|
|
||||||
|
QCPItemRect *mDragRect;
|
||||||
|
|
||||||
QCPItemPixmap *mPixmap;
|
QCPItemPixmap *mPixmap;
|
||||||
QCPItemText *mItemTitle;
|
QCPItemText *mItemTitle;
|
||||||
|
|
|
||||||
607
logPlus/TransparentGroupResult.cpp
Normal file
607
logPlus/TransparentGroupResult.cpp
Normal file
|
|
@ -0,0 +1,607 @@
|
||||||
|
#include "TransparentGroupResult.h"
|
||||||
|
#include "TransparentDraggableResult.h"
|
||||||
|
extern double g_dPixelPerCm;//每厘米像素数
|
||||||
|
|
||||||
|
TransparentGroupResult::TransparentGroupResult(QMyCustomPlot *parentPlot, TransparentGroupResult *upDraggableResult, QString strUuid, double minWidth, QString strTitle)
|
||||||
|
: QObject(parentPlot), mPlot(parentPlot), mstrTitle(strTitle), mMinWidth(minWidth)
|
||||||
|
{
|
||||||
|
m_strUuid = strUuid;
|
||||||
|
//
|
||||||
|
initRect();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TransparentGroupResult::~TransparentGroupResult()
|
||||||
|
{
|
||||||
|
if(mPlot) {
|
||||||
|
// mPlot->removeItem(mRect);
|
||||||
|
// mPlot->removeItem(mLeftHandle);
|
||||||
|
// mPlot->removeItem(mRightHandle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransparentGroupResult::addResultToPlot(double left_Low, double right_Hight, QString myResult, QString &strUuid)
|
||||||
|
{
|
||||||
|
//获取上方Rect
|
||||||
|
TransparentDraggableResult *upDragRect = nullptr;
|
||||||
|
if (strUuid != "")
|
||||||
|
{
|
||||||
|
upDragRect = (TransparentDraggableResult *)m_mapDraggable_Result[strUuid];
|
||||||
|
}
|
||||||
|
|
||||||
|
strUuid = getUUid();
|
||||||
|
|
||||||
|
// 在初始化代码中
|
||||||
|
TransparentDraggableResult *dragRect = new TransparentDraggableResult(mPlot, upDragRect, strUuid);
|
||||||
|
//图片,提前设值,后面setRange改变
|
||||||
|
dragRect->setResult(myResult);
|
||||||
|
// 设置初始范围
|
||||||
|
dragRect->setRange(left_Low, right_Hight);
|
||||||
|
// 可选:设置颜色
|
||||||
|
//dragRect->setColor(QColor(255, 0, 0, 80)); // 半透明红色
|
||||||
|
//最小宽度
|
||||||
|
dragRect->setMinWidth(0.1);
|
||||||
|
//dragRect->setTitle(strText);
|
||||||
|
|
||||||
|
m_vecResult << strUuid;
|
||||||
|
m_mapDraggable_Result[strUuid] = dragRect;
|
||||||
|
}
|
||||||
|
|
||||||
|
//设置最小宽度
|
||||||
|
void TransparentGroupResult::setMinWidth(double minWidth)
|
||||||
|
{
|
||||||
|
mMinWidth = minWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
//设置标题
|
||||||
|
void TransparentGroupResult::setTitle(QString strTitle)
|
||||||
|
{
|
||||||
|
mstrTitle = strTitle;
|
||||||
|
mItemTitle->setText(mstrTitle);
|
||||||
|
//mPlot->replot();
|
||||||
|
}
|
||||||
|
|
||||||
|
//设置解释结论
|
||||||
|
void TransparentGroupResult::setResult(QString filePath)
|
||||||
|
{
|
||||||
|
m_Result = filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置矩形范围
|
||||||
|
void TransparentGroupResult::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-mPlot->yAxis->range().lower)/2;
|
||||||
|
mRect->topLeft->setCoords(left_Low, lY1);
|
||||||
|
mRect->bottomRight->setCoords(right_Hight, mPlot->yAxis->range().upper);
|
||||||
|
|
||||||
|
mItemTitle->position->setCoords((mRect->topLeft->coords().x() + mRect->bottomRight->coords().x())/2,
|
||||||
|
lY2 + lY2/2);
|
||||||
|
|
||||||
|
updateHandles();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransparentGroupResult::setDragRange(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 - mPlot->yAxis->range().lower) / 2;
|
||||||
|
mDragRect->topLeft->setCoords(left_Low, lY1);
|
||||||
|
mDragRect->bottomRight->setCoords(right_Hight, mPlot->yAxis->range().upper);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取当前范围
|
||||||
|
QCPRange TransparentGroupResult::getRange()
|
||||||
|
{
|
||||||
|
return QCPRange(mRect->topLeft->coords().x(), mRect->bottomRight->coords().x());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除框图
|
||||||
|
void TransparentGroupResult::deleteRect()
|
||||||
|
{
|
||||||
|
if(mPlot) {
|
||||||
|
|
||||||
|
mPlot->m_mapDraggable_Result.remove(m_strUuid);
|
||||||
|
|
||||||
|
mPlot->removeItem(mRect);
|
||||||
|
mPlot->removeItem(mLeftHandle);
|
||||||
|
mPlot->removeItem(mRightHandle);
|
||||||
|
mPlot->removeItem(mItemTitle);
|
||||||
|
|
||||||
|
mPlot->replot();
|
||||||
|
this->deleteLater();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TransparentGroupResult::setSelectRect(bool bselect)
|
||||||
|
{
|
||||||
|
if (bselect)
|
||||||
|
{
|
||||||
|
mRect->setBrush(QColor(255, 0, 0, 80));
|
||||||
|
mRect->setPen(QPen(Qt::black, 1, Qt::DashLine));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mRect->setBrush(Qt::NoBrush);
|
||||||
|
mRect->setPen(Qt::NoPen);
|
||||||
|
}
|
||||||
|
mPlot->replot();
|
||||||
|
}
|
||||||
|
|
||||||
|
int TransparentGroupResult::getCursor()
|
||||||
|
{
|
||||||
|
if (m_bMoveRect)
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
if (m_bArrow)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransparentGroupResult::initRect()
|
||||||
|
{
|
||||||
|
// 创建透明矩形
|
||||||
|
mDragRect = new QCPItemRect(mPlot);
|
||||||
|
mDragRect->setLayer("overlay"); // 确保在最上层
|
||||||
|
mDragRect->setBrush(Qt::NoBrush);
|
||||||
|
mDragRect->setPen(QPen(Qt::red, 1, Qt::DashDotDotLine));
|
||||||
|
mDragRect->setVisible(false);
|
||||||
|
|
||||||
|
mDragLine = new QCPItemStraightLine(mPlot);
|
||||||
|
mDragLine->setPen(QPen(Qt::red, 1, Qt::DashDotDotLine));
|
||||||
|
mDragLine->setVisible(false);
|
||||||
|
|
||||||
|
// 创建透明矩形
|
||||||
|
mRect = new QCPItemRect(mPlot);
|
||||||
|
mRect->setLayer("overlay"); // 确保在最上层
|
||||||
|
mRect->setBrush(Qt::NoBrush);
|
||||||
|
mRect->setPen(Qt::NoPen);
|
||||||
|
|
||||||
|
// 创建左右边界控制点
|
||||||
|
mLeftHandle = new QCPItemRect(mPlot);
|
||||||
|
mLeftHandle->setLayer("overlay");
|
||||||
|
mLeftHandle->setBrush(Qt::NoBrush);
|
||||||
|
mLeftHandle->setPen(Qt::NoPen);
|
||||||
|
|
||||||
|
mRightHandle = new QCPItemRect(mPlot);
|
||||||
|
mRightHandle->setLayer("overlay");
|
||||||
|
mRightHandle->setBrush(Qt::NoBrush);
|
||||||
|
mRightHandle->setPen(Qt::NoPen);
|
||||||
|
|
||||||
|
// 连接鼠标事件
|
||||||
|
connect(mPlot, &QCustomPlot::mousePress, this, &TransparentGroupResult::onMousePress);
|
||||||
|
connect(mPlot, &QCustomPlot::mouseMove, this, &TransparentGroupResult::onMouseMove);
|
||||||
|
connect(mPlot, &QCustomPlot::mouseRelease, this, &TransparentGroupResult::onMouseRelease);
|
||||||
|
|
||||||
|
// mPixmap = new QCPItemPixmap(mPlot);
|
||||||
|
// //mPixmap->setPixmap(QPixmap(":/image/file.png")); // 设置图片
|
||||||
|
// mPixmap->setScaled(true, Qt::IgnoreAspectRatio); // 设置缩放方式
|
||||||
|
// mPixmap->setLayer("overlay"); // 确保在最上层
|
||||||
|
// QPen pen = QPen(Qt::black);
|
||||||
|
// pen.setWidth(1);
|
||||||
|
// mPixmap->setPen(pen);
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransparentGroupResult::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); // 矩形大小
|
||||||
|
}
|
||||||
|
|
||||||
|
TransparentDraggableResult* TransparentGroupResult::getSelectItemResult(QPoint pt)
|
||||||
|
{
|
||||||
|
TransparentDraggableResult* pret = NULL;
|
||||||
|
QObjectList objList = m_mapDraggable_Result.values();
|
||||||
|
for (int i = 0; i < objList.size(); i++)
|
||||||
|
{
|
||||||
|
TransparentDraggableResult* p = qobject_cast<TransparentDraggableResult*>(objList.at(i));
|
||||||
|
if (p && p->getLeftHandle())
|
||||||
|
{
|
||||||
|
if (p->getLeftHandle()->selectTest(pt, false) < 5) {
|
||||||
|
pret = p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransparentGroupResult::onDelRect()
|
||||||
|
{
|
||||||
|
//mDragMode = DragNone;
|
||||||
|
//删除框图
|
||||||
|
deleteRect();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransparentGroupResult::onMousePress(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
event->accept();
|
||||||
|
|
||||||
|
if (event->button() == Qt::LeftButton)
|
||||||
|
{
|
||||||
|
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
|
||||||
|
{
|
||||||
|
TransparentDraggableResult* p = this->getSelectItemResult(event->pos());
|
||||||
|
if (p)
|
||||||
|
{
|
||||||
|
m_pDragResult = p;
|
||||||
|
mDragMode = DragItem;
|
||||||
|
currentRange = p->getRange();
|
||||||
|
}
|
||||||
|
else if (y >= currentRange.lower && y <= currentRange.upper)
|
||||||
|
{
|
||||||
|
mDragMode = DragRect;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mDragMode = DragNone;
|
||||||
|
setSelectRect(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setSelectRect(true);
|
||||||
|
|
||||||
|
//mDragStartX = x;
|
||||||
|
mDragStartY = y;
|
||||||
|
mDragStartRange = currentRange;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransparentGroupResult::onMouseMove_in(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
//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 = proposedLeft;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DragRight: {
|
||||||
|
//double proposedRight = mDragStartRange.upper + dx;
|
||||||
|
double proposedRight = mDragStartRange.upper + dy;
|
||||||
|
// 确保不超出轴范围且不使宽度小于最小值
|
||||||
|
newRange.upper = proposedRight;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DragItem: {
|
||||||
|
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;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// 最终确保宽度不小于最小值(针对整体拖动的情况)
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (abs(dy) > 0.2)
|
||||||
|
{
|
||||||
|
if (mDragMode == DragItem)
|
||||||
|
{
|
||||||
|
mDragLine->setVisible(true);
|
||||||
|
mDragLine->point1->setCoords(mDragStartRange.upper+dy, 0);
|
||||||
|
mDragLine->point2->setCoords(mDragStartRange.upper+dy, 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mDragRect->setVisible(true);
|
||||||
|
setDragRange(newRange.lower, newRange.upper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//setRange(newRange.lower, newRange.upper);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransparentGroupResult::onMouseMove(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (mDragMode == DragRect)
|
||||||
|
{
|
||||||
|
m_bMoveRect = true;
|
||||||
|
}
|
||||||
|
else if (mLeftHandle->selectTest(event->pos(), false) < 5
|
||||||
|
|| mRightHandle->selectTest(event->pos(), false) < 5
|
||||||
|
|| this->getSelectItemResult(event->pos())
|
||||||
|
|| (mDragMode > DragNone && mDragMode <= DragItem))
|
||||||
|
{
|
||||||
|
m_bArrow = true;
|
||||||
|
m_bMoveRect = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_bArrow = false;
|
||||||
|
m_bMoveRect = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mDragMode == DragNone) return;
|
||||||
|
|
||||||
|
event->accept();
|
||||||
|
|
||||||
|
onMouseMove_in(event);
|
||||||
|
|
||||||
|
//后面统一刷新上方和下方rect
|
||||||
|
mPlot->replot();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransparentGroupResult::onMouseRelease_in(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if(event->button() == Qt::LeftButton && mDragMode != DragNone) {
|
||||||
|
event->accept();
|
||||||
|
//避免二次绘制框图
|
||||||
|
mPlot->m_bDrawRect = false;
|
||||||
|
//emit rangeChanged(getRange());
|
||||||
|
mDragMode = DragNone;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransparentGroupResult::onMouseRelease(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(event->button() == Qt::LeftButton && mDragMode != DragNone) {
|
||||||
|
|
||||||
|
if (mDragRect->visible())
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// 最终确保宽度不小于最小值(针对整体拖动的情况)
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mDragRect->setVisible(false);
|
||||||
|
mDragLine->setVisible(false);
|
||||||
|
setRange(newRange.lower, newRange.upper);
|
||||||
|
|
||||||
|
if (m_vecResult.size() == 1)
|
||||||
|
{
|
||||||
|
TransparentDraggableResult* pret = qobject_cast<TransparentDraggableResult*>(m_mapDraggable_Result.value(m_vecResult.at(0)));
|
||||||
|
if (pret)
|
||||||
|
{
|
||||||
|
pret->setRange(newRange.lower, newRange.upper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (mDragMode == DragRect)
|
||||||
|
{
|
||||||
|
float offset = mDragStartRange.lower - getRange().lower;
|
||||||
|
for (int i = 0; i < m_vecResult.size(); i++)
|
||||||
|
{
|
||||||
|
TransparentDraggableResult* pret = qobject_cast<TransparentDraggableResult*>(m_mapDraggable_Result.value(m_vecResult.at(i)));
|
||||||
|
if (pret == NULL)
|
||||||
|
continue;
|
||||||
|
QCPRange rg = pret->getRange();
|
||||||
|
pret->setRange(rg.lower - offset, rg.upper - offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TransparentDraggableResult* pret = qobject_cast<TransparentDraggableResult*>(m_mapDraggable_Result.value(m_vecResult.at(0)));
|
||||||
|
if (pret)
|
||||||
|
{
|
||||||
|
pret->setRange(pret->getRange().lower, newRange.upper);
|
||||||
|
}
|
||||||
|
pret = qobject_cast<TransparentDraggableResult*>(m_mapDraggable_Result.value(m_vecResult.last()));
|
||||||
|
if (pret)
|
||||||
|
{
|
||||||
|
pret->setRange(newRange.lower, pret->getRange().upper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (mDragLine->visible())
|
||||||
|
{
|
||||||
|
if (mDragMode == DragItem)
|
||||||
|
{
|
||||||
|
if (m_pDragResult)
|
||||||
|
{
|
||||||
|
double y = mPlot->xAxis->pixelToCoord(event->pos().y());
|
||||||
|
double dy = y - mDragStartY;
|
||||||
|
|
||||||
|
QCPRange rg = m_pDragResult->getRange();
|
||||||
|
m_pDragResult->setRange(rg.lower, rg.upper + dy);
|
||||||
|
|
||||||
|
TransparentDraggableResult* upr = m_pDragResult->getUpResult();
|
||||||
|
if (upr)
|
||||||
|
{
|
||||||
|
QCPRange rg = upr->getRange();
|
||||||
|
upr->setRange(rg.lower + dy, rg.upper);
|
||||||
|
}
|
||||||
|
m_pDragResult = NULL;
|
||||||
|
}
|
||||||
|
mDragLine->setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mPlot->replot();
|
||||||
|
}
|
||||||
|
|
||||||
|
onMouseRelease_in(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
double TransparentGroupResult::getMyLower()
|
||||||
|
{
|
||||||
|
double dLower = mPlot->xAxis->range().lower;
|
||||||
|
double proposedLeft = mDragStartRange.lower;
|
||||||
|
|
||||||
|
TransparentGroupResult *pDraggableRect =NULL;
|
||||||
|
{
|
||||||
|
QMap<QString,QObject *>::Iterator it = mPlot->m_mapDragGroup.begin();
|
||||||
|
while( it != mPlot->m_mapDragGroup.end() )
|
||||||
|
{
|
||||||
|
if(it.key() == m_strUuid)
|
||||||
|
{
|
||||||
|
it++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pDraggableRect = (TransparentGroupResult*)it.value();
|
||||||
|
//
|
||||||
|
QCPRange tmpRange = pDraggableRect->getRange();
|
||||||
|
if(tmpRange.upper >= dLower && tmpRange.upper <= proposedLeft)
|
||||||
|
{
|
||||||
|
dLower = tmpRange.upper;
|
||||||
|
}
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dLower;
|
||||||
|
}
|
||||||
|
|
||||||
|
double TransparentGroupResult::getMyUpper()
|
||||||
|
{
|
||||||
|
double dUpper = mPlot->xAxis->range().upper;
|
||||||
|
double proposedRight = mDragStartRange.upper;
|
||||||
|
|
||||||
|
TransparentGroupResult *pDraggableRect =NULL;
|
||||||
|
{
|
||||||
|
QMap<QString,QObject *>::Iterator it = mPlot->m_mapDragGroup.begin();
|
||||||
|
while( it != mPlot->m_mapDragGroup.end() )
|
||||||
|
{
|
||||||
|
if(it.key() == m_strUuid)
|
||||||
|
{
|
||||||
|
it++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pDraggableRect = (TransparentGroupResult*)it.value();
|
||||||
|
//
|
||||||
|
QCPRange tmpRange = pDraggableRect->getRange();
|
||||||
|
if(tmpRange.lower <= dUpper && tmpRange.lower >= proposedRight)
|
||||||
|
{
|
||||||
|
dUpper = tmpRange.lower;
|
||||||
|
}
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dUpper;
|
||||||
|
}
|
||||||
|
|
||||||
97
logPlus/TransparentGroupResult.h
Normal file
97
logPlus/TransparentGroupResult.h
Normal file
|
|
@ -0,0 +1,97 @@
|
||||||
|
#ifndef TRANSPARENTGROUPRESUL_H
|
||||||
|
#define TRANSPARENTGROUPRESUL_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include "qmycustomplot.h"
|
||||||
|
#include <QString>
|
||||||
|
#include <QMenu>
|
||||||
|
#include "geometryutils.h"
|
||||||
|
#include <QSvgRenderer>
|
||||||
|
|
||||||
|
#pragma execution_character_set("utf-8") // 强制指定执行字符集为 UTF-8
|
||||||
|
|
||||||
|
class TransparentDraggableResult;
|
||||||
|
class TransparentGroupResult : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit TransparentGroupResult(QMyCustomPlot *parentPlot, TransparentGroupResult *upDraggableResult=nullptr, QString strUuid="", double minWidth = 1.0, QString strTitle = "");
|
||||||
|
|
||||||
|
~TransparentGroupResult();
|
||||||
|
|
||||||
|
void addResultToPlot(double left_Low, double right_Hight, QString myResult, QString &strUuid);
|
||||||
|
|
||||||
|
//设置最小宽度
|
||||||
|
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);
|
||||||
|
void setDragRange(double left_Low, double right_Hight);
|
||||||
|
// 获取当前范围
|
||||||
|
QCPRange getRange();
|
||||||
|
|
||||||
|
// 删除框图
|
||||||
|
void deleteRect();
|
||||||
|
|
||||||
|
void setSelectRect(bool bselect);
|
||||||
|
|
||||||
|
int getCursor();
|
||||||
|
signals:
|
||||||
|
void rangeChanged(QCPRange newRange);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initRect();
|
||||||
|
void updateHandles() ;
|
||||||
|
|
||||||
|
TransparentDraggableResult* getSelectItemResult(QPoint pt);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onDelRect();
|
||||||
|
void onMousePress(QMouseEvent *event);
|
||||||
|
void onMouseMove(QMouseEvent *event);
|
||||||
|
void onMouseRelease(QMouseEvent *event);
|
||||||
|
//
|
||||||
|
void onMouseMove_in(QMouseEvent *event);
|
||||||
|
void onMouseRelease_in(QMouseEvent *event);
|
||||||
|
|
||||||
|
double getMyLower();
|
||||||
|
double getMyUpper();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QMyCustomPlot *mPlot;
|
||||||
|
QCPItemRect *mRect;
|
||||||
|
QCPItemRect *mLeftHandle;
|
||||||
|
QCPItemRect *mRightHandle;
|
||||||
|
|
||||||
|
QCPItemRect *mDragRect;
|
||||||
|
QCPItemStraightLine* mDragLine = NULL;
|
||||||
|
TransparentDraggableResult* m_pDragResult = NULL;
|
||||||
|
|
||||||
|
QCPItemText *mItemTitle;
|
||||||
|
QString mstrTitle="";
|
||||||
|
QString m_strUuid = "";
|
||||||
|
|
||||||
|
QString m_Result;
|
||||||
|
|
||||||
|
enum DragMode { DragNone, DragLeft, DragRight, DragItem, DragRect };
|
||||||
|
DragMode mDragMode = DragNone;
|
||||||
|
//double mDragStartX = 0;
|
||||||
|
double mDragStartY = 0;
|
||||||
|
QCPRange mDragStartRange;
|
||||||
|
|
||||||
|
// 添加最小宽度成员变量
|
||||||
|
double mMinWidth;
|
||||||
|
|
||||||
|
QVector<QString> m_vecResult;
|
||||||
|
QMap<QString, QObject*> m_mapDraggable_Result;
|
||||||
|
bool m_bArrow = false;
|
||||||
|
bool m_bMoveRect = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TRANSPARENTGROUPRESUL_H
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include "ConsoleOutputWidget.h"
|
#include "ConsoleOutputWidget.h"
|
||||||
#include "DraggablePixmap.h"
|
#include "DraggablePixmap.h"
|
||||||
#include "TransparentDraggableRect.h"
|
#include "TransparentDraggableRect.h"
|
||||||
|
#include "TransparentGroupResult.h"
|
||||||
#include <QtMath>
|
#include <QtMath>
|
||||||
#include "Gradient.h"
|
#include "Gradient.h"
|
||||||
#include "PickFrac.h"
|
#include "PickFrac.h"
|
||||||
|
|
@ -121,28 +122,25 @@ void FormDraw::setDrawData(QStringList listdt, QJsonObject objInfo)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ("tableObject" == strType)
|
||||||
|
{
|
||||||
|
QMyCustomPlot* plot = this->addTableLine(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
|
||||||
|
if (plot == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
QTimer::singleShot(200, this, [=]() {
|
||||||
|
emit CallManage::getInstance()->sig_changeDepth(m_strUuid, m_strSlfName, m_strWellName, m_iY1, m_iY2);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//道-对象
|
//道-对象
|
||||||
FormInfo* pInfo = m_formTrack->setDrawDt(listdt, objInfo);
|
FormInfo* pInfo = m_formTrack->setDrawDt(listdt, objInfo);
|
||||||
|
|
||||||
//
|
//
|
||||||
QMyCustomPlot *curv = new QMyCustomPlot(this, strSlfName, strWellName, m_strTrackName, strLineName);
|
QMyCustomPlot *curv = new QMyCustomPlot(this, strSlfName, strWellName, m_strTrackName, strLineName);
|
||||||
curv->m_strUuid = m_strUuid;
|
curv->initGeometry(m_strUuid, m_iScale, nW);
|
||||||
//背景设置成透明色
|
|
||||||
curv->setBackground(Qt::transparent);
|
|
||||||
curv->setStyleSheet("background: transparent;");
|
|
||||||
|
|
||||||
double dHight = 0;
|
|
||||||
dHight = (m_iY2-m_iY1)*100.0/(double)m_iScale * g_dPixelPerCm;
|
|
||||||
if(g_iShow==1)
|
|
||||||
{
|
|
||||||
//显示刻度
|
|
||||||
dHight = dHight+30;
|
|
||||||
}
|
|
||||||
if(dHight>32767)
|
|
||||||
{
|
|
||||||
dHight = 32767;
|
|
||||||
}
|
|
||||||
curv->setGeometry(0, 0, nW, (int)dHight);//7500-3184
|
|
||||||
curv->show();
|
curv->show();
|
||||||
|
|
||||||
if ("waveObject" == strType)
|
if ("waveObject" == strType)
|
||||||
|
|
@ -208,6 +206,11 @@ void FormDraw::setDrawData(QStringList listdt, QJsonObject objInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else if (strType == "tableObject")
|
||||||
|
{
|
||||||
|
//新建表格曲线
|
||||||
|
emit CallManage::getInstance()->sig_AddTableLine(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
|
||||||
|
}
|
||||||
curv->replot();
|
curv->replot();
|
||||||
|
|
||||||
connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*)));
|
connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*)));
|
||||||
|
|
@ -567,6 +570,91 @@ void FormDraw::paintEvent(QPaintEvent*)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QMyCustomPlot* FormDraw::addTableLine(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName)
|
||||||
|
{
|
||||||
|
if (strLineName == "FRAC_HOLE.TABLE" || strLineName == "WORDS_RELUST" || strLineName == "RESULT"
|
||||||
|
|| strLineName == "GEO_LITH" || strLineName == "SWALL_CORE"
|
||||||
|
|| strLineName == "GUJING1_RESULT" || strLineName == "GUJING2_RESULT" || strLineName == "GUJING3_RESULT"
|
||||||
|
|| strLineName == "CORE_PHYSICS" || strLineName == "IMAGE_DATA")
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
//井名&道名不一致
|
||||||
|
if (strUuid == m_strUuid && m_strWellName == strWellName && m_strTrackName == strTrackName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_listTableName.contains(strLineName))
|
||||||
|
{
|
||||||
|
qDebug() << "FormDraw strLineName already exist! " << strLineName;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
QMyCustomPlot *curv = new QMyCustomPlot(this, strSlfName, strWellName, strTrackName, strLineName);
|
||||||
|
curv->initGeometry(m_strUuid, m_iScale, g_iOneWidth);
|
||||||
|
curv->show();
|
||||||
|
|
||||||
|
if (strLineName == "FRAC_HOLE.TABLE")
|
||||||
|
{
|
||||||
|
//蝌蚪图
|
||||||
|
curv->mKedou = true;
|
||||||
|
//隐藏网格
|
||||||
|
curv->xAxis->grid()->setVisible(false);
|
||||||
|
curv->yAxis->grid()->setVisible(false);
|
||||||
|
|
||||||
|
initTableLine(curv, strSlfName, strLineName);
|
||||||
|
}
|
||||||
|
else if (strLineName == "WORDS_RELUST")
|
||||||
|
{
|
||||||
|
//文字结论
|
||||||
|
initWords(curv, strSlfName, strLineName);
|
||||||
|
}
|
||||||
|
else if (strLineName == "RESULT")
|
||||||
|
{
|
||||||
|
//解释结论
|
||||||
|
initResult(curv, strSlfName, strLineName);
|
||||||
|
}
|
||||||
|
else if (strLineName == "GEO_LITH")
|
||||||
|
{
|
||||||
|
//录井剖面
|
||||||
|
initGeoLith(curv, strSlfName, strLineName);
|
||||||
|
}
|
||||||
|
else if (strLineName == "SWALL_CORE")
|
||||||
|
{
|
||||||
|
//井壁取心
|
||||||
|
initSwallCore(curv, strSlfName, strLineName);
|
||||||
|
}
|
||||||
|
else if (strLineName == "GUJING1_RESULT" || strLineName == "GUJING2_RESULT" || strLineName == "GUJING3_RESULT")
|
||||||
|
{
|
||||||
|
//固井结论
|
||||||
|
initGujing(curv, strSlfName, strLineName);
|
||||||
|
}
|
||||||
|
else if (strLineName == "CORE_PHYSICS")
|
||||||
|
{
|
||||||
|
//岩心实验数据
|
||||||
|
initCorePhysics(curv, strSlfName, strLineName);
|
||||||
|
}
|
||||||
|
else if (strLineName == "IMAGE_DATA")
|
||||||
|
{
|
||||||
|
//岩心图片
|
||||||
|
initIMAGE_DATA(curv, strSlfName, strLineName);
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*)));
|
||||||
|
|
||||||
|
//
|
||||||
|
m_listTableName.push_back(strLineName);
|
||||||
|
return curv;
|
||||||
|
}
|
||||||
|
|
||||||
void FormDraw::s_addLine(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName)
|
void FormDraw::s_addLine(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName)
|
||||||
{
|
{
|
||||||
|
|
@ -775,119 +863,10 @@ void FormDraw::s_addWave(QString strUuid, QString strSlfName, QString strWellNam
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FormDraw::s_addTableLine(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName)
|
void FormDraw::s_addTableLine(QString strUuid, QString strSlfName, QString strWellName,
|
||||||
{
|
QString strTrackName, QString strLineName)
|
||||||
if(strLineName == "FRAC_HOLE.TABLE" || strLineName == "WORDS_RELUST" || strLineName == "RESULT"
|
{
|
||||||
|| strLineName == "GEO_LITH" || strLineName == "SWALL_CORE"
|
this->addTableLine(strUuid, strSlfName, strWellName, strTrackName, strLineName);
|
||||||
|| strLineName == "GUJING1_RESULT" || strLineName == "GUJING2_RESULT" || strLineName == "GUJING3_RESULT"
|
|
||||||
|| strLineName == "CORE_PHYSICS"|| strLineName == "IMAGE_DATA")
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//井名&道名不一致
|
|
||||||
if(strUuid == m_strUuid && m_strWellName == strWellName && m_strTrackName == strTrackName)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(m_listTableName.contains(strLineName))
|
|
||||||
{
|
|
||||||
qDebug() << "FormDraw strLineName already exist! " << strLineName;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
QMyCustomPlot *curv = new QMyCustomPlot(this, strSlfName, strWellName, strTrackName, strLineName);
|
|
||||||
curv->m_strUuid = m_strUuid;
|
|
||||||
//背景设置成透明色
|
|
||||||
curv->setBackground(Qt::transparent);
|
|
||||||
curv->setStyleSheet("background: transparent;");
|
|
||||||
//
|
|
||||||
//QRect rect = this->rect();
|
|
||||||
//curv->setGeometry(rect.left(),rect.top(), rect.width(), rect.height());
|
|
||||||
|
|
||||||
double dHight = 0;
|
|
||||||
dHight = (m_iY2-m_iY1)*100.0/(double)m_iScale * g_dPixelPerCm;
|
|
||||||
if(g_iShow==1)
|
|
||||||
{
|
|
||||||
//显示刻度
|
|
||||||
dHight = dHight+30;
|
|
||||||
}
|
|
||||||
|
|
||||||
qDebug() << "FormDraw dHight=" << QString::number((int)dHight);
|
|
||||||
if(dHight>32767)
|
|
||||||
{
|
|
||||||
dHight = 32767;
|
|
||||||
}
|
|
||||||
|
|
||||||
//curv->setMaximumHeight((int)dHight);
|
|
||||||
//curv->setViewport(QRect(0, 0, g_iOneWidth, (int)dHight));//7500-3184
|
|
||||||
curv->setGeometry(0, 0, g_iOneWidth, (int)dHight);//7500-3184
|
|
||||||
|
|
||||||
|
|
||||||
//curv->resize(INT_MAX, INT_MAX); // 使用 INT_MAX 来避免16位整数的限制
|
|
||||||
// QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
||||||
// curv->setSizePolicy(policy);
|
|
||||||
|
|
||||||
curv->show();
|
|
||||||
|
|
||||||
if(strLineName == "FRAC_HOLE.TABLE")
|
|
||||||
{
|
|
||||||
//蝌蚪图
|
|
||||||
curv->mKedou = true;
|
|
||||||
//隐藏网格
|
|
||||||
curv->xAxis->grid()->setVisible(false);
|
|
||||||
curv->yAxis->grid()->setVisible(false);
|
|
||||||
|
|
||||||
initTableLine(curv, strSlfName, strLineName);
|
|
||||||
}
|
|
||||||
else if(strLineName == "WORDS_RELUST")
|
|
||||||
{
|
|
||||||
//文字结论
|
|
||||||
initWords(curv, strSlfName, strLineName);
|
|
||||||
}
|
|
||||||
else if(strLineName == "RESULT")
|
|
||||||
{
|
|
||||||
//解释结论
|
|
||||||
initResult(curv, strSlfName, strLineName);
|
|
||||||
}
|
|
||||||
else if(strLineName == "GEO_LITH")
|
|
||||||
{
|
|
||||||
//录井剖面
|
|
||||||
initGeoLith(curv, strSlfName, strLineName);
|
|
||||||
}
|
|
||||||
else if(strLineName == "SWALL_CORE")
|
|
||||||
{
|
|
||||||
//井壁取心
|
|
||||||
initSwallCore(curv, strSlfName, strLineName);
|
|
||||||
}
|
|
||||||
else if(strLineName == "GUJING1_RESULT" || strLineName == "GUJING2_RESULT" || strLineName == "GUJING3_RESULT")
|
|
||||||
{
|
|
||||||
//固井结论
|
|
||||||
initGujing(curv, strSlfName, strLineName);
|
|
||||||
}
|
|
||||||
else if(strLineName == "CORE_PHYSICS")
|
|
||||||
{
|
|
||||||
//岩心实验数据
|
|
||||||
initCorePhysics(curv, strSlfName, strLineName);
|
|
||||||
}
|
|
||||||
else if(strLineName == "IMAGE_DATA")
|
|
||||||
{
|
|
||||||
//岩心图片
|
|
||||||
initIMAGE_DATA(curv, strSlfName, strLineName);
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*)));
|
|
||||||
|
|
||||||
//
|
|
||||||
m_listTableName.push_back(strLineName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormDraw::s_mouseWheel(QWheelEvent *event)
|
void FormDraw::s_mouseWheel(QWheelEvent *event)
|
||||||
|
|
@ -3337,10 +3316,14 @@ void FormDraw::initResult(QMyCustomPlot *widget, QString strSlfName, QString str
|
||||||
m_LeftVal = 0;
|
m_LeftVal = 0;
|
||||||
m_RightVal = 90;
|
m_RightVal = 90;
|
||||||
//隐藏刻度
|
//隐藏刻度
|
||||||
widget->xAxis->setTicks(false);
|
widget->xAxis->setTicks(true);
|
||||||
widget->yAxis->setTicks(false);
|
widget->yAxis->setTicks(true);
|
||||||
widget->xAxis2->setTicks(false);
|
widget->xAxis2->setTicks(true);
|
||||||
widget->yAxis2->setTicks(false);
|
widget->yAxis2->setTicks(true);
|
||||||
|
widget->xAxis->setTickLabels(true);
|
||||||
|
widget->yAxis->setTickLabels(true);
|
||||||
|
widget->xAxis2->setTickLabels(true);
|
||||||
|
widget->xAxis2->setTickLabels(true);
|
||||||
//
|
//
|
||||||
LoadFromSLF_Result(widget, strSlfName, strLineName);
|
LoadFromSLF_Result(widget, strSlfName, strLineName);
|
||||||
|
|
||||||
|
|
@ -3382,6 +3365,7 @@ bool FormDraw::LoadFromSLF_Result(QMyCustomPlot *widget, QString strSlfName, QSt
|
||||||
if(!i) zone=atoi(m_Result->Zone);
|
if(!i) zone=atoi(m_Result->Zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString strGroupUuid = "";
|
||||||
for(int i=0;i<count;i++)
|
for(int i=0;i<count;i++)
|
||||||
{
|
{
|
||||||
m_Result=(LAYER_DATA *)(pstr+i*len);
|
m_Result=(LAYER_DATA *)(pstr+i*len);
|
||||||
|
|
@ -3539,9 +3523,34 @@ bool FormDraw::LoadFromSLF_Result(QMyCustomPlot *widget, QString strSlfName, QSt
|
||||||
result10=::GetOilSymbolDir()+iconshotname+".png";
|
result10=::GetOilSymbolDir()+iconshotname+".png";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 设置解释结论终止深度
|
||||||
|
TransparentGroupResult* pGroup = widget->addResultGroup(-m_Result->EndDepth, -m_Result->StartDepth, strGroupUuid, strZone);
|
||||||
|
QString strUuid = "";
|
||||||
|
if (result != "")
|
||||||
|
{
|
||||||
|
if (m_Result->MDepth1 != 0)
|
||||||
|
{
|
||||||
|
//第一个加Zone解释层号
|
||||||
|
pGroup->addResultToPlot(-m_Result->MDepth1, -m_Result->StartDepth, result, strUuid);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pGroup->addResultToPlot(-m_Result->EndDepth, -m_Result->StartDepth, result, strUuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (result1 != "")
|
||||||
|
{
|
||||||
|
if (m_Result->MDepth2 != 0)
|
||||||
|
{
|
||||||
|
pGroup->addResultToPlot(-m_Result->MDepth2, -m_Result->MDepth1, result1, strUuid);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pGroup->addResultToPlot(-m_Result->EndDepth, -m_Result->MDepth1, result1, strUuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
//
|
//
|
||||||
QString strUuid = "";
|
strUuid = "";
|
||||||
if(result != "")
|
if(result != "")
|
||||||
{
|
{
|
||||||
if(m_Result->MDepth1!=0)
|
if(m_Result->MDepth1!=0)
|
||||||
|
|
@ -3549,11 +3558,12 @@ bool FormDraw::LoadFromSLF_Result(QMyCustomPlot *widget, QString strSlfName, QSt
|
||||||
//第一个加Zone解释层号
|
//第一个加Zone解释层号
|
||||||
widget->addResultToPlot(-m_Result->MDepth1, -m_Result->StartDepth, result, strUuid, strZone);
|
widget->addResultToPlot(-m_Result->MDepth1, -m_Result->StartDepth, result, strUuid, strZone);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
widget->addResultToPlot(-m_Result->EndDepth, -m_Result->StartDepth, result, strUuid, strZone);
|
widget->addResultToPlot(-m_Result->EndDepth, -m_Result->StartDepth, result, strUuid, strZone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//return true;
|
||||||
if(result1 != "")
|
if(result1 != "")
|
||||||
{
|
{
|
||||||
if(m_Result->MDepth2!=0)
|
if(m_Result->MDepth2!=0)
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,9 @@ private:
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
|
|
||||||
|
QMyCustomPlot* addTableLine(QString strUuid, QString strSlfName, QString strWellName,
|
||||||
|
QString strTrackName, QString strLineName);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void dragEnterEvent(QDragEnterEvent* event);
|
void dragEnterEvent(QDragEnterEvent* event);
|
||||||
void dragMoveEvent(QDragMoveEvent* event);
|
void dragMoveEvent(QDragMoveEvent* event);
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ SOURCES += \
|
||||||
TransparentDraggableRect.cpp \
|
TransparentDraggableRect.cpp \
|
||||||
TransparentDraggableResult.cpp \
|
TransparentDraggableResult.cpp \
|
||||||
TransparentDraggableSwallCore.cpp \
|
TransparentDraggableSwallCore.cpp \
|
||||||
|
TransparentGroupResult.cpp \
|
||||||
ViewInfo.cpp \
|
ViewInfo.cpp \
|
||||||
backgrounddelegate.cpp \
|
backgrounddelegate.cpp \
|
||||||
customtabbar.cpp \
|
customtabbar.cpp \
|
||||||
|
|
@ -120,6 +121,7 @@ HEADERS += \
|
||||||
TransparentDraggableRect.h \
|
TransparentDraggableRect.h \
|
||||||
TransparentDraggableResult.h \
|
TransparentDraggableResult.h \
|
||||||
TransparentDraggableSwallCore.h \
|
TransparentDraggableSwallCore.h \
|
||||||
|
TransparentGroupResult.h \
|
||||||
ViewInfo.h \
|
ViewInfo.h \
|
||||||
backgrounddelegate.h \
|
backgrounddelegate.h \
|
||||||
customtabbar.h \
|
customtabbar.h \
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#include "CallManage.h"
|
#include "CallManage.h"
|
||||||
#include "geometryutils.h"
|
#include "geometryutils.h"
|
||||||
#include "TransparentDraggableRect.h"
|
#include "TransparentDraggableRect.h"
|
||||||
|
#include "TransparentGroupResult.h"
|
||||||
#include "TransparentDraggableResult.h"
|
#include "TransparentDraggableResult.h"
|
||||||
#include "TransparentDraggableGeoLith.h"
|
#include "TransparentDraggableGeoLith.h"
|
||||||
#include "TransparentDraggableSwallCore.h"
|
#include "TransparentDraggableSwallCore.h"
|
||||||
|
|
@ -20,6 +21,7 @@
|
||||||
|
|
||||||
//是否隐藏刻度
|
//是否隐藏刻度
|
||||||
extern int g_iShow;
|
extern int g_iShow;
|
||||||
|
extern double g_dPixelPerCm;//每厘米像素数
|
||||||
|
|
||||||
QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName) :
|
QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName) :
|
||||||
QCustomPlot(parent)
|
QCustomPlot(parent)
|
||||||
|
|
@ -38,6 +40,10 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel
|
||||||
// 开启抗锯齿
|
// 开启抗锯齿
|
||||||
this->setAntialiasedElement(QCP::aeAll);
|
this->setAntialiasedElement(QCP::aeAll);
|
||||||
|
|
||||||
|
//背景设置成透明色
|
||||||
|
this->setBackground(Qt::transparent);
|
||||||
|
this->setStyleSheet("background: transparent;");
|
||||||
|
|
||||||
//jyl
|
//jyl
|
||||||
if(g_iShow==1)
|
if(g_iShow==1)
|
||||||
{
|
{
|
||||||
|
|
@ -104,6 +110,28 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel
|
||||||
connect(CallManage::getInstance(), SIGNAL(sig_changeDrawProperty(QVariantList)), this, SLOT(s_changeDrawProperty(QVariantList)));
|
connect(CallManage::getInstance(), SIGNAL(sig_changeDrawProperty(QVariantList)), this, SLOT(s_changeDrawProperty(QVariantList)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QMyCustomPlot::initGeometry(QString strUuid, int nscale, int nW)
|
||||||
|
{
|
||||||
|
this->m_strUuid = m_strUuid;
|
||||||
|
|
||||||
|
double dHight = (m_iY2 - m_iY1)*100.0 / (double)nscale * g_dPixelPerCm;
|
||||||
|
if (g_iShow == 1)
|
||||||
|
{
|
||||||
|
//显示刻度
|
||||||
|
dHight = dHight + 30;
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "FormDraw dHight=" << QString::number((int)dHight);
|
||||||
|
if (dHight > 32767)
|
||||||
|
{
|
||||||
|
dHight = 32767;
|
||||||
|
}
|
||||||
|
|
||||||
|
//curv->setMaximumHeight((int)dHight);
|
||||||
|
//curv->setViewport(QRect(0, 0, g_iOneWidth, (int)dHight));//7500-3184
|
||||||
|
this->setGeometry(0, 0, nW-20, (int)dHight);//7500-3184
|
||||||
|
}
|
||||||
|
|
||||||
void QMyCustomPlot::changePropertyWaveUpdate()
|
void QMyCustomPlot::changePropertyWaveUpdate()
|
||||||
{
|
{
|
||||||
if (m_nDrawType == 0 || m_nDrawType == 1)
|
if (m_nDrawType == 0 || m_nDrawType == 1)
|
||||||
|
|
@ -545,6 +573,19 @@ float QMyCustomPlot::getScaleV()
|
||||||
return m_fScaleV;
|
return m_fScaleV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QMyCustomPlot::groupBeginResult(float fEndDepth, float fStartDepth)
|
||||||
|
{
|
||||||
|
// 组ID
|
||||||
|
m_strGroupUid = getUUid();
|
||||||
|
m_fResultEndDepth = fEndDepth;
|
||||||
|
addResultGroup(fEndDepth, fStartDepth, m_strGroupUid, "11");
|
||||||
|
}
|
||||||
|
|
||||||
|
void QMyCustomPlot::groupEndResult()
|
||||||
|
{
|
||||||
|
m_strGroupUid = "";
|
||||||
|
}
|
||||||
|
|
||||||
//蝌蚪图,重绘网格线
|
//蝌蚪图,重绘网格线
|
||||||
void QMyCustomPlot::drawCustomElements()
|
void QMyCustomPlot::drawCustomElements()
|
||||||
{
|
{
|
||||||
|
|
@ -658,6 +699,31 @@ void QMyCustomPlot::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
QCustomPlot::mouseMoveEvent(event);
|
QCustomPlot::mouseMoveEvent(event);
|
||||||
|
|
||||||
|
int nmaxCursor = 0;
|
||||||
|
QObjectList objList = m_mapDragGroup.values();
|
||||||
|
for( int i = 0; i< objList.size(); i++)
|
||||||
|
{
|
||||||
|
TransparentGroupResult* group = qobject_cast<TransparentGroupResult*>(objList.at(i));
|
||||||
|
if (group)
|
||||||
|
{
|
||||||
|
if (group->getCursor() > nmaxCursor)
|
||||||
|
{
|
||||||
|
nmaxCursor = group->getCursor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nmaxCursor == 2)
|
||||||
|
{
|
||||||
|
this->setCursor(Qt::ClosedHandCursor);
|
||||||
|
}
|
||||||
|
else if (nmaxCursor == 1)
|
||||||
|
{
|
||||||
|
this->setCursor(Qt::SizeVerCursor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->setCursor(Qt::ArrowCursor);
|
||||||
|
}
|
||||||
// if (mMousePress) {
|
// if (mMousePress) {
|
||||||
// auto items = selectedItems();
|
// auto items = selectedItems();
|
||||||
|
|
||||||
|
|
@ -1432,6 +1498,29 @@ void QMyCustomPlot::addTextToPlot(double left_Low, double right_Hight, const QSt
|
||||||
m_mapDraggable_Rect[strUuid] = dragRect;
|
m_mapDraggable_Rect[strUuid] = dragRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TransparentGroupResult* QMyCustomPlot::addResultGroup(double left_Low, double right_Hight, QString &strUuid, QString strText /*= ""*/)
|
||||||
|
{
|
||||||
|
TransparentGroupResult *upGroup = nullptr;
|
||||||
|
if (strUuid != "")
|
||||||
|
{
|
||||||
|
upGroup = (TransparentGroupResult *)m_mapDragGroup[strUuid];
|
||||||
|
}
|
||||||
|
|
||||||
|
strUuid = getUUid();
|
||||||
|
|
||||||
|
// 在初始化代码中addResultToPlot
|
||||||
|
TransparentGroupResult *dragRect = new TransparentGroupResult(this, upGroup, strUuid);
|
||||||
|
// 设置初始范围
|
||||||
|
dragRect->setRange(left_Low, right_Hight);
|
||||||
|
//最小宽度
|
||||||
|
dragRect->setMinWidth(0.1);
|
||||||
|
dragRect->setTitle(strText);
|
||||||
|
|
||||||
|
m_mapDragGroup[strUuid] = dragRect;
|
||||||
|
|
||||||
|
return dragRect;
|
||||||
|
}
|
||||||
|
|
||||||
void QMyCustomPlot::addResultToPlot(double left_Low, double right_Hight, QString myResult, QString &strUuid, QString strText)
|
void QMyCustomPlot::addResultToPlot(double left_Low, double right_Hight, QString myResult, QString &strUuid, QString strText)
|
||||||
{
|
{
|
||||||
//获取上方Rect
|
//获取上方Rect
|
||||||
|
|
@ -1441,9 +1530,7 @@ void QMyCustomPlot::addResultToPlot(double left_Low, double right_Hight, QStrin
|
||||||
upDragRect = (TransparentDraggableResult *)m_mapDraggable_Result[strUuid];
|
upDragRect = (TransparentDraggableResult *)m_mapDraggable_Result[strUuid];
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
strUuid = getUUid();
|
||||||
QtCommonClass *qtCommon = new QtCommonClass(this);
|
|
||||||
strUuid = qtCommon->getUUid();
|
|
||||||
|
|
||||||
// 在初始化代码中
|
// 在初始化代码中
|
||||||
TransparentDraggableResult *dragRect = new TransparentDraggableResult(this, upDragRect, strUuid);
|
TransparentDraggableResult *dragRect = new TransparentDraggableResult(this, upDragRect, strUuid);
|
||||||
|
|
@ -1452,7 +1539,7 @@ void QMyCustomPlot::addResultToPlot(double left_Low, double right_Hight, QStrin
|
||||||
// 设置初始范围
|
// 设置初始范围
|
||||||
dragRect->setRange(left_Low, right_Hight);
|
dragRect->setRange(left_Low, right_Hight);
|
||||||
// 可选:设置颜色
|
// 可选:设置颜色
|
||||||
dragRect->setColor(QColor(255, 255, 255, 80)); // 半透明红色
|
//dragRect->setColor(QColor(255, 0, 0, 80)); // 半透明红色
|
||||||
//最小宽度
|
//最小宽度
|
||||||
dragRect->setMinWidth(0.1);
|
dragRect->setMinWidth(0.1);
|
||||||
dragRect->setTitle(strText);
|
dragRect->setTitle(strText);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
const int iFracType=15;
|
const int iFracType=15;
|
||||||
|
|
||||||
|
class TransparentGroupResult;
|
||||||
class QMyCustomPlot : public QCustomPlot
|
class QMyCustomPlot : public QCustomPlot
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
@ -21,6 +22,8 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void initGeometry(QString strUuid, int nscale, int nW);
|
||||||
|
|
||||||
void changePropertyWaveUpdate();
|
void changePropertyWaveUpdate();
|
||||||
// 绘图类型-变密度(成像)
|
// 绘图类型-变密度(成像)
|
||||||
void initWave(QString strSlfName, QString strWaveName);
|
void initWave(QString strSlfName, QString strWaveName);
|
||||||
|
|
@ -34,6 +37,10 @@ public:
|
||||||
QCPColorMap * updateWave();
|
QCPColorMap * updateWave();
|
||||||
|
|
||||||
float getScaleV();
|
float getScaleV();
|
||||||
|
|
||||||
|
void groupBeginResult(float fEndDepth, float fStartDepth);
|
||||||
|
void groupEndResult();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//virtual void mouseMoveEvent(QMouseEvent *event);
|
//virtual void mouseMoveEvent(QMouseEvent *event);
|
||||||
|
|
||||||
|
|
@ -97,6 +104,9 @@ public:
|
||||||
int m_nWaveHei = 1;
|
int m_nWaveHei = 1;
|
||||||
public:
|
public:
|
||||||
//分段刷新
|
//分段刷新
|
||||||
|
QString m_strGroupUid = "";
|
||||||
|
// 解释结论终止深度
|
||||||
|
float m_fResultEndDepth = 0.0f;
|
||||||
QVector<double> m_x;
|
QVector<double> m_x;
|
||||||
QVector<double> m_y;
|
QVector<double> m_y;
|
||||||
int m_iCurNum=0;
|
int m_iCurNum=0;
|
||||||
|
|
@ -106,6 +116,9 @@ public:
|
||||||
bool m_bFirstTimeConnect=true; //初次绑定编辑曲线信号槽。
|
bool m_bFirstTimeConnect=true; //初次绑定编辑曲线信号槽。
|
||||||
bool m_bPriviewRightList=false; //当前是否正在预览曲线。
|
bool m_bPriviewRightList=false; //当前是否正在预览曲线。
|
||||||
|
|
||||||
|
// 组
|
||||||
|
QMap<QString, QObject*> m_mapDragGroup;
|
||||||
|
|
||||||
QMap<QString, QObject*> m_mapDraggable_Rect;
|
QMap<QString, QObject*> m_mapDraggable_Rect;
|
||||||
QMap<QString, QObject*> m_mapDraggable_Result;
|
QMap<QString, QObject*> m_mapDraggable_Result;
|
||||||
QMap<QString, QObject*> m_mapDraggable_GeoLith;
|
QMap<QString, QObject*> m_mapDraggable_GeoLith;
|
||||||
|
|
@ -135,6 +148,8 @@ public:
|
||||||
|
|
||||||
void addTextToPlot(double left_Low, double right_Hight, const QString strText, QColor crColor=QColor(255, 255, 255, 80));
|
void addTextToPlot(double left_Low, double right_Hight, const QString strText, QColor crColor=QColor(255, 255, 255, 80));
|
||||||
|
|
||||||
|
TransparentGroupResult* addResultGroup(double left_Low, double right_Hight, QString &strUuid, QString strText = "");
|
||||||
|
|
||||||
void addResultToPlot(double left_Low, double right_Hight, QString myResult, QString &strUuid, QString strText="");
|
void addResultToPlot(double left_Low, double right_Hight, QString myResult, QString &strUuid, QString strText="");
|
||||||
|
|
||||||
void addGeoLithToPlot(double left_Low, double right_Hight, const QString myLith, const QString myOil, const QString myColor);
|
void addGeoLithToPlot(double left_Low, double right_Hight, const QString myLith, const QString myOil, const QString myColor);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user