解释结论道右键菜单,开始编辑解释结论,关闭编辑解释结论,从剪切板文本数据粘贴,分割为层内层,分割为独立层,拆分复合层成独立层,更新层号等菜单
This commit is contained in:
parent
912bcdc996
commit
746166482a
|
|
@ -245,26 +245,27 @@ QString TransparentDraggableResult::getResult()
|
|||
return m_Result;
|
||||
}
|
||||
|
||||
QString TransparentDraggableResult::getUuid()
|
||||
{
|
||||
return m_strUuid;
|
||||
}
|
||||
|
||||
// 删除框图
|
||||
void TransparentDraggableResult::deleteRect()
|
||||
void TransparentDraggableResult::deleteRect(bool breplot)
|
||||
{
|
||||
if(mPlot) {
|
||||
|
||||
// mRect->deleteLater();
|
||||
// mLeftHandle->deleteLater();
|
||||
// mRightHandle->deleteLater();
|
||||
// mPixmap->deleteLater();
|
||||
|
||||
mPlot->m_mapDraggable_Result.remove(m_strUuid);
|
||||
|
||||
mPlot->removeItem(mRect);
|
||||
if (mLeftHandle)
|
||||
mPlot->removeItem(mLeftHandle);
|
||||
//mPlot->removeItem(mRightHandle);
|
||||
if (mRightHandle)
|
||||
mPlot->removeItem(mRightHandle);
|
||||
mPlot->removeItem(mPixmap);
|
||||
mPlot->removeItem(mItemTitle);
|
||||
|
||||
mPlot->replot();
|
||||
if (breplot)
|
||||
mPlot->replot();
|
||||
this->deleteLater();
|
||||
|
||||
//
|
||||
|
|
@ -299,6 +300,16 @@ QCPItemRect * TransparentDraggableResult::getLeftHandle()
|
|||
return mLeftHandle;
|
||||
}
|
||||
|
||||
void TransparentDraggableResult::setUpResult(TransparentDraggableResult* pUp)
|
||||
{
|
||||
m_upDraggableResult = pUp;
|
||||
//将自己,设置为上方rect的下方
|
||||
if (m_upDraggableResult)
|
||||
{
|
||||
m_upDraggableResult->m_downDraggableResult = this;
|
||||
}
|
||||
}
|
||||
|
||||
TransparentDraggableResult* TransparentDraggableResult::getUpResult()
|
||||
{
|
||||
return m_upDraggableResult;
|
||||
|
|
@ -406,6 +417,9 @@ void TransparentDraggableResult::onDelRect()
|
|||
|
||||
void TransparentDraggableResult::onMousePress(QMouseEvent *event)
|
||||
{
|
||||
event->ignore();
|
||||
if (!mPlot->getIsEditor())
|
||||
return;
|
||||
// //右键
|
||||
// if(event->button() != Qt::LeftButton)
|
||||
// {
|
||||
|
|
@ -496,8 +510,6 @@ void TransparentDraggableResult::onMousePress(QMouseEvent *event)
|
|||
m_downDraggableResult->mDragStartRange = m_downDraggableResult->getRange();
|
||||
}
|
||||
}
|
||||
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
void TransparentDraggableResult::onMouseMove_in(QMouseEvent *event)
|
||||
|
|
@ -647,6 +659,8 @@ void TransparentDraggableResult::onMouseMove(QMouseEvent *event)
|
|||
|
||||
event->accept();
|
||||
|
||||
if (!mPlot->getIsEditor())
|
||||
return;
|
||||
onMouseMove_in(event);
|
||||
|
||||
//后面统一刷新上方和下方rect
|
||||
|
|
@ -676,7 +690,8 @@ void TransparentDraggableResult::onMouseRelease_in(QMouseEvent *event)
|
|||
|
||||
void TransparentDraggableResult::onMouseRelease(QMouseEvent *event)
|
||||
{
|
||||
|
||||
if (!mPlot->getIsEditor())
|
||||
return;
|
||||
if(event->button() == Qt::LeftButton && mDragMode != DragNone) {
|
||||
|
||||
if (mDragRect->visible())
|
||||
|
|
|
|||
|
|
@ -45,13 +45,17 @@ public:
|
|||
void setColor(const QColor &color);
|
||||
|
||||
QString getResult();
|
||||
|
||||
// 获取Uuid
|
||||
QString getUuid();
|
||||
|
||||
// 删除框图
|
||||
void deleteRect();
|
||||
void deleteRect(bool breplot = true);
|
||||
|
||||
void setSelectRect(bool bselect);
|
||||
|
||||
QCPItemRect * getLeftHandle();
|
||||
void setUpResult(TransparentDraggableResult* pUp);
|
||||
TransparentDraggableResult* getUpResult();
|
||||
signals:
|
||||
void rangeChanged(QCPRange newRange);
|
||||
|
|
@ -78,12 +82,12 @@ private:
|
|||
QMyCustomPlot *mPlot;
|
||||
QCPItemRect *mRect;
|
||||
QCPItemRect *mLeftHandle = NULL;
|
||||
QCPItemRect *mRightHandle;
|
||||
QCPItemRect *mRightHandle = NULL;
|
||||
|
||||
QCPItemRect *mDragRect;
|
||||
QCPItemRect *mDragRect = NULL;
|
||||
|
||||
QCPItemPixmap *mPixmap;
|
||||
QCPItemText *mItemTitle;
|
||||
QCPItemPixmap *mPixmap = NULL;
|
||||
QCPItemText *mItemTitle = NULL;
|
||||
QString mstrTitle="";
|
||||
QString m_strUuid = "";
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ TransparentGroupResult::~TransparentGroupResult()
|
|||
}
|
||||
}
|
||||
|
||||
void TransparentGroupResult::addResultToPlot(double left_Low, double right_Hight, QString myResult, QString &strUuid)
|
||||
void TransparentGroupResult::addResultToPlot(double left_Low, double right_Hight, QString myResult, QString &strUuid, int ninsertIdx)
|
||||
{
|
||||
//获取上方Rect
|
||||
TransparentDraggableResult *upDragRect = nullptr;
|
||||
|
|
@ -46,7 +46,22 @@ void TransparentGroupResult::addResultToPlot(double left_Low, double right_Hight
|
|||
dragRect->setMinWidth(0.1);
|
||||
//dragRect->setTitle(strText);
|
||||
|
||||
m_vecResult << strUuid;
|
||||
if (ninsertIdx < 0)
|
||||
m_vecResult << strUuid;
|
||||
else
|
||||
{
|
||||
// 插入设置上下Result
|
||||
int newIdx = ninsertIdx + 1;
|
||||
if (newIdx < m_vecResult.size())
|
||||
{
|
||||
TransparentDraggableResult* pret = qobject_cast<TransparentDraggableResult*>(m_mapDraggable_Result.value(m_vecResult.at(newIdx)));
|
||||
if (pret)
|
||||
{
|
||||
pret->setUpResult(dragRect);
|
||||
}
|
||||
}
|
||||
m_vecResult.insert(newIdx, strUuid);
|
||||
}
|
||||
m_mapDraggable_Result[strUuid] = dragRect;
|
||||
}
|
||||
|
||||
|
|
@ -124,6 +139,21 @@ void TransparentGroupResult::addAllResultToPlot(LAYER_DATA* pResult)
|
|||
|
||||
}
|
||||
|
||||
void TransparentGroupResult::removeAllResult()
|
||||
{
|
||||
mPlot->m_mapDragGroup.remove(m_strUuid);
|
||||
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;
|
||||
pret->deleteRect(false);
|
||||
}
|
||||
m_vecResult.clear();
|
||||
m_mapDraggable_Result.clear();
|
||||
this->deleteRect();
|
||||
}
|
||||
|
||||
//设置最小宽度
|
||||
void TransparentGroupResult::setMinWidth(double minWidth)
|
||||
{
|
||||
|
|
@ -401,6 +431,7 @@ void TransparentGroupResult::deleteRect()
|
|||
mPlot->removeItem(mLeftHandle);
|
||||
mPlot->removeItem(mRightHandle);
|
||||
mPlot->removeItem(mItemTitle);
|
||||
mPlot->removeItem(mDragLine);
|
||||
|
||||
mPlot->replot();
|
||||
this->deleteLater();
|
||||
|
|
@ -411,6 +442,7 @@ void TransparentGroupResult::deleteRect()
|
|||
|
||||
void TransparentGroupResult::setSelectRect(bool bselect)
|
||||
{
|
||||
m_bSelect = bselect;
|
||||
if (bselect)
|
||||
{
|
||||
mRect->setBrush(QColor(255, 0, 0, 80));
|
||||
|
|
@ -424,6 +456,93 @@ void TransparentGroupResult::setSelectRect(bool bselect)
|
|||
mPlot->replot();
|
||||
}
|
||||
|
||||
bool TransparentGroupResult::getSelect()
|
||||
{
|
||||
return m_bSelect;
|
||||
}
|
||||
|
||||
int TransparentGroupResult::getDraggableResultIndex(double depth)
|
||||
{
|
||||
int nidx = -1;
|
||||
// 根据depth获取当前深度的DraggableResult索引
|
||||
// upper---- 上
|
||||
// lower---- 下
|
||||
TransparentDraggableResult* pDret = NULL;
|
||||
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();
|
||||
if (depth <= rg.upper && depth >= rg.lower)
|
||||
{
|
||||
nidx = i;
|
||||
pDret = pret;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return nidx;
|
||||
}
|
||||
|
||||
void TransparentGroupResult::segmentationInnerLayer(double depth)
|
||||
{
|
||||
// 根据depth获取当前深度的DraggableResult索引
|
||||
// upper---- 上
|
||||
// lower---- 下
|
||||
int nidx = this->getDraggableResultIndex(depth);
|
||||
if (nidx < 0)
|
||||
return;
|
||||
TransparentDraggableResult* pDret = qobject_cast<TransparentDraggableResult*>(m_mapDraggable_Result.value(m_vecResult.at(nidx)));
|
||||
if (pDret == NULL)
|
||||
return;
|
||||
|
||||
QCPRange rg = pDret->getRange();
|
||||
// 分割层内层修改下边界坐标
|
||||
pDret->setRange(depth, rg.upper);
|
||||
QString strUuid = pDret->getUuid();
|
||||
// 新增层
|
||||
this->addResultToPlot(rg.lower, depth, ::GetOilSymbolDir() + "油层.svg", strUuid, nidx);
|
||||
mPlot->replot();
|
||||
}
|
||||
|
||||
void TransparentGroupResult::segmentationIndependentLayer(double depth)
|
||||
{
|
||||
int nidx = -1;
|
||||
// 根据depth获取当前深度的DraggableResult索引
|
||||
// upper---- 上
|
||||
// lower---- 下
|
||||
TransparentDraggableResult* pDret = NULL;
|
||||
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();
|
||||
if (depth <= rg.upper && depth >= rg.lower)
|
||||
{
|
||||
nidx = i;
|
||||
pDret = pret;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nidx < 0 || pDret == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
void TransparentGroupResult::splitIndependentLayer()
|
||||
{
|
||||
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();
|
||||
QString strUuid = "";
|
||||
TransparentGroupResult* pNew = mPlot->addResultGroup(rg.lower, rg.upper, strUuid);
|
||||
pNew->addResultToPlot(rg.lower, rg.upper, pret->getResult(), strUuid);
|
||||
}
|
||||
}
|
||||
|
||||
int TransparentGroupResult::getCursor()
|
||||
{
|
||||
if (m_bMoveRect)
|
||||
|
|
@ -468,6 +587,16 @@ QString TransparentGroupResult::getOilGasDepth(int nidx)
|
|||
return QString("%1").arg(-pDrag->getRange().upper);
|
||||
}
|
||||
|
||||
const QVector<QString>& TransparentGroupResult::getVecResult()
|
||||
{
|
||||
return m_vecResult;
|
||||
}
|
||||
|
||||
const QMap<QString, QObject*>& TransparentGroupResult::getMapDraggable_Result()
|
||||
{
|
||||
return m_mapDraggable_Result;
|
||||
}
|
||||
|
||||
void TransparentGroupResult::initRect()
|
||||
{
|
||||
// 创建透明矩形
|
||||
|
|
@ -567,6 +696,8 @@ void TransparentGroupResult::onDelRect()
|
|||
void TransparentGroupResult::onMousePress(QMouseEvent *event)
|
||||
{
|
||||
event->accept();
|
||||
if (!mPlot->getIsEditor())
|
||||
return;
|
||||
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
|
|
@ -683,6 +814,8 @@ void TransparentGroupResult::onMouseMove_in(QMouseEvent *event)
|
|||
|
||||
void TransparentGroupResult::onMouseMove(QMouseEvent *event)
|
||||
{
|
||||
if (!mPlot->getIsEditor())
|
||||
return;
|
||||
if (mDragMode == DragRect)
|
||||
{
|
||||
m_bMoveRect = true;
|
||||
|
|
@ -724,7 +857,8 @@ void TransparentGroupResult::onMouseRelease_in(QMouseEvent *event)
|
|||
|
||||
void TransparentGroupResult::onMouseRelease(QMouseEvent *event)
|
||||
{
|
||||
|
||||
if (!mPlot->getIsEditor())
|
||||
return;
|
||||
if(event->button() == Qt::LeftButton && mDragMode != DragNone) {
|
||||
{
|
||||
double low = mRect->topLeft->coords().x();
|
||||
|
|
|
|||
|
|
@ -21,12 +21,14 @@ public:
|
|||
|
||||
enum DragMode { DragNone, DragLeft, DragRight, DragItem, DragRect };
|
||||
|
||||
void addResultToPlot(double left_Low, double right_Hight, QString myResult, QString &strUuid);
|
||||
void addResultToPlot(double left_Low, double right_Hight, QString myResult, QString &strUuid, int ninsertIdx = -1);
|
||||
|
||||
QString getIconName(const QMap<QString, QString>& zoneOrder, const QString& result_str, int nidx, double dMDepth);
|
||||
|
||||
void addAllResultToPlot(LAYER_DATA* pResult);
|
||||
|
||||
void removeAllResult();
|
||||
|
||||
//设置最小宽度
|
||||
void setMinWidth(double minWidth);
|
||||
//设置标题
|
||||
|
|
@ -68,6 +70,17 @@ public:
|
|||
void deleteRect();
|
||||
|
||||
void setSelectRect(bool bselect);
|
||||
// 获取选定状态
|
||||
bool getSelect();
|
||||
// 获取组内解释结论索引
|
||||
int getDraggableResultIndex(double depth);
|
||||
|
||||
// 层内层
|
||||
void segmentationInnerLayer(double depth);
|
||||
// 分割为独立层
|
||||
void segmentationIndependentLayer(double depth);
|
||||
// 拆分复合层成独立层
|
||||
void splitIndependentLayer();
|
||||
|
||||
int getCursor();
|
||||
|
||||
|
|
@ -76,6 +89,9 @@ public:
|
|||
// 获取分段点深度
|
||||
QString getOilGasDepth(int nidx);
|
||||
|
||||
const QVector<QString>& getVecResult();
|
||||
const QMap<QString, QObject*>& getMapDraggable_Result();
|
||||
|
||||
signals:
|
||||
void rangeChanged(QCPRange newRange);
|
||||
|
||||
|
|
@ -114,6 +130,8 @@ private:
|
|||
QString m_Result;
|
||||
QString m_Remark="";
|
||||
|
||||
bool m_bSelect = false;
|
||||
|
||||
DragMode mDragMode = DragNone;
|
||||
//double mDragStartX = 0;
|
||||
double mDragStartY = 0;
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel
|
|||
xAxis2->setTickLabels(false);
|
||||
yAxis2->setTickLabels(false);
|
||||
|
||||
connect(this->selectionRect(), &QCPSelectionRect::accepted, this, &QMyCustomPlot::slotSelectionRectAccepted);
|
||||
// make bottom and left axes transfer their ranges to top and right axes:
|
||||
connect(xAxis, SIGNAL(rangeChanged(QCPRange)), xAxis2, SLOT(setRange(QCPRange)));
|
||||
connect(yAxis, SIGNAL(rangeChanged(QCPRange)), yAxis2, SLOT(setRange(QCPRange)));
|
||||
|
|
@ -704,6 +705,23 @@ void QMyCustomPlot::init(QString strName, QVector<double> xx, QVector<double> yy
|
|||
//raise(); //置于上层显示
|
||||
}
|
||||
|
||||
void QMyCustomPlot::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
// 检查是否是左键双击
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
//qDebug() << "左键双击发生!";
|
||||
// 在这里添加你的双击处理逻辑
|
||||
m_bEditor = true;
|
||||
|
||||
// 接受事件
|
||||
event->accept();
|
||||
}
|
||||
else {
|
||||
// 其他按钮的双击交给基类处理
|
||||
QWidget::mouseDoubleClickEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
//void QMyCustomPlot::mousePressEvent(QMouseEvent *event)
|
||||
//{
|
||||
// //qDebug() << "mousePress";
|
||||
|
|
@ -712,19 +730,50 @@ void QMyCustomPlot::init(QString strName, QVector<double> xx, QVector<double> yy
|
|||
|
||||
void QMyCustomPlot::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
// if (event->button() == Qt::LeftButton) {
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
if (m_strLineName == "RESULT")
|
||||
{
|
||||
if (m_bEditor)
|
||||
{
|
||||
//获取鼠标点位置
|
||||
double y_pos = event->pos().y();
|
||||
//转为图像位置
|
||||
double x_val = xAxis->pixelToCoord(y_pos);
|
||||
mMousePress = true;
|
||||
|
||||
// if (auto *item = itemAt(event->pos(), true)) {
|
||||
// emit mousePress(event); // 由于我们直接返回了,所以要负责将鼠标点击信号发送出去
|
||||
|
||||
// // deselectAll();
|
||||
// mMousePress = true;
|
||||
// mLastPos = event->pos();
|
||||
// item->setSelected(true);
|
||||
// replot();
|
||||
// return; // 如果点击的是一个item直接返回,不然QCustomPlot会把事件传递给其它的层对象(例如:轴矩形)
|
||||
// }
|
||||
// }
|
||||
QObjectList objList = m_mapDragGroup.values();
|
||||
for (int i = 0; i < objList.size(); i++)
|
||||
{
|
||||
TransparentGroupResult *pGroup = qobject_cast<TransparentGroupResult *>(objList.at(i));
|
||||
if (pGroup == nullptr)
|
||||
continue;
|
||||
QCPRange rg = pGroup->getRange();
|
||||
if (x_val <= rg.upper && x_val >= rg.lower)
|
||||
{
|
||||
mMousePress = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (mMousePress)
|
||||
{
|
||||
m_dPressX = x_val;
|
||||
if (m_pAddLine1 == NULL)
|
||||
{
|
||||
m_pAddLine1 = new QCPItemStraightLine(this);
|
||||
m_pAddLine1->setPen(QPen(Qt::red, 1, Qt::DashDotDotLine));
|
||||
m_pAddLine1->setVisible(false);
|
||||
}
|
||||
if (m_pAddLine2 == NULL)
|
||||
{
|
||||
m_pAddLine2 = new QCPItemStraightLine(this);
|
||||
m_pAddLine2->setPen(QPen(Qt::red, 1, Qt::DashDotDotLine));
|
||||
m_pAddLine2->setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(m_bDrawCore_PHYSICS)//岩心分析
|
||||
{
|
||||
|
|
@ -778,6 +827,28 @@ void QMyCustomPlot::mousePressEvent(QMouseEvent *event)
|
|||
|
||||
void QMyCustomPlot::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (m_strLineName == "RESULT")
|
||||
{
|
||||
if (mMousePress)
|
||||
{
|
||||
//获取鼠标点位置
|
||||
double y_pos = event->pos().y();
|
||||
//转为图像位置
|
||||
double x_val = xAxis->pixelToCoord(y_pos);
|
||||
double absval = abs(abs(m_dPressX) - abs(x_val));
|
||||
if (absval > 0.5 && !m_pAddLine1->visible())
|
||||
{
|
||||
m_pAddLine1->setVisible(true);
|
||||
m_pAddLine1->point1->setCoords(m_dPressX, 0);
|
||||
m_pAddLine1->point2->setCoords(m_dPressX, 1);
|
||||
m_pAddLine2->setVisible(true);
|
||||
}
|
||||
m_pAddLine2->point1->setCoords(x_val, 0);
|
||||
m_pAddLine2->point2->setCoords(x_val, 1);
|
||||
replot();
|
||||
}
|
||||
}
|
||||
|
||||
QCustomPlot::mouseMoveEvent(event);
|
||||
|
||||
int nmaxCursor = 0;
|
||||
|
|
@ -925,15 +996,25 @@ void QMyCustomPlot::mouseMoveEvent(QMouseEvent *event)
|
|||
|
||||
void QMyCustomPlot::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
// if (mMousePress) {
|
||||
// mMousePress = false;
|
||||
// if (auto *item = itemAt(event->pos(), true)) {
|
||||
// emit mouseReleaseEvent(event); // 由于我们直接返回了,所以要负责将鼠标点击信号发送出去
|
||||
// item->setSelected(false);
|
||||
// replot();
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
if (m_strLineName == "RESULT")
|
||||
{
|
||||
if (mMousePress)
|
||||
{
|
||||
//获取鼠标点位置
|
||||
double y_pos = event->pos().y();
|
||||
//转为图像位置
|
||||
double x_val = xAxis->pixelToCoord(y_pos);
|
||||
double absval = abs(abs(m_dPressX) - abs(x_val));
|
||||
if (absval < 0.4)
|
||||
{
|
||||
mMousePress = false;
|
||||
m_pAddLine1->setVisible(false);
|
||||
m_pAddLine2->setVisible(false);
|
||||
replot();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(m_bDrawCore_PHYSICS)//岩心分析
|
||||
{
|
||||
|
|
@ -998,6 +1079,55 @@ void QMyCustomPlot::executeSingle(QMouseEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
void QMyCustomPlot::slotSelectionRectAccepted(const QRect &rect, QMouseEvent *event)
|
||||
{
|
||||
if ("RESULT" == m_strLineName)
|
||||
{
|
||||
if (!mMousePress)
|
||||
return;
|
||||
|
||||
// 当选择完成时,获取矩形范围并放大
|
||||
QRectF rect = this->selectionRect()->rect(); // 获取选择的矩形区域(像素坐标)
|
||||
m_bEditRect = true;//当前是否正在编辑曲线。
|
||||
|
||||
// 转换为坐标轴范围
|
||||
double top = rect.top();
|
||||
double bottom = rect.bottom();
|
||||
|
||||
double right_Hight = this->xAxis->pixelToCoord(top); //上边界
|
||||
double left_Low = this->xAxis->pixelToCoord(bottom); //下边界
|
||||
|
||||
bool bAdd = true;
|
||||
QObjectList objList = m_mapDragGroup.values();
|
||||
for (int i = 0; i < objList.size(); i++)
|
||||
{
|
||||
TransparentGroupResult *pGroup = qobject_cast<TransparentGroupResult *>(objList.at(i));
|
||||
if (pGroup == nullptr)
|
||||
continue;
|
||||
QCPRange rg = pGroup->getRange();
|
||||
if (right_Hight <= rg.upper && right_Hight >= rg.lower
|
||||
|| left_Low <= rg.upper && left_Low >= rg.lower)
|
||||
{
|
||||
bAdd = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bAdd)
|
||||
{
|
||||
QString strUp = "";
|
||||
TransparentGroupResult* pGroup = this->addResultGroup(left_Low, right_Hight, strUp, "");
|
||||
strUp = "";
|
||||
pGroup->addResultToPlot(left_Low, right_Hight, ::GetOilSymbolDir() + "油层.svg", strUp);
|
||||
|
||||
}
|
||||
mMousePress = false;
|
||||
m_pAddLine1->setVisible(false);
|
||||
m_pAddLine2->setVisible(false);
|
||||
replot();
|
||||
}
|
||||
}
|
||||
|
||||
//槽函数,选中曲线
|
||||
void QMyCustomPlot::s_LineClicked(int index)
|
||||
{
|
||||
|
|
@ -1095,6 +1225,32 @@ void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event)
|
|||
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_Layer);
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
else if (m_strLineName == "RESULT") // 解释结论
|
||||
{
|
||||
QMenu menu(this);
|
||||
if (!m_bEditor)
|
||||
{
|
||||
menu.addAction(QIcon(::GetImagePath() + "curve.png"), "开始编辑解释结论", this, &QMyCustomPlot::onOpenEditResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
mLastPos = event->pos();
|
||||
qDebug() << "mLastPos:" << mLastPos;
|
||||
menu.addAction(QIcon(::GetImagePath() + "curve.png"), "关闭编辑解释结论", this, &QMyCustomPlot::onCloseEditResult);
|
||||
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItems_Layer);
|
||||
menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems);
|
||||
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "删除选中对象", this, &QMyCustomPlot::DeleteItemGroup);
|
||||
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::DeleteItems_Layer);
|
||||
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_Layer);
|
||||
menu.addAction(QIcon(::GetImagePath() + "icon/SetZone.png"), "更新层号", this, &QMyCustomPlot::updateGroupZone);
|
||||
|
||||
menu.addAction(QIcon(::GetImagePath() + "icon/Split.png"), "分割为层内层", this, &QMyCustomPlot::segmentationInnerLayer);
|
||||
menu.addAction(QIcon(::GetImagePath() + "icon/Split.png"), "分割为独立层", this, &QMyCustomPlot::segmentationIndependentLayer);
|
||||
menu.addAction(QIcon(::GetImagePath() + "icon/Split.png"), "拆分复合层成独立层", this, &QMyCustomPlot::splitIndependentLayer);
|
||||
}
|
||||
menu.exec(event->globalPos());
|
||||
|
||||
}
|
||||
else if (m_strLineName == "IMAGE_DATA")
|
||||
{
|
||||
QMenu menu(this);
|
||||
|
|
@ -4295,7 +4451,7 @@ TransparentGroupResult* QMyCustomPlot::addResultGroup(double left_Low, double ri
|
|||
TransparentGroupResult *upGroup = nullptr;
|
||||
if (strUuid != "")
|
||||
{
|
||||
upGroup = (TransparentGroupResult *)m_mapDragGroup[strUuid];
|
||||
upGroup = (TransparentGroupResult *)m_mapDragGroup.value(strUuid);
|
||||
}
|
||||
|
||||
strUuid = getUUid();
|
||||
|
|
@ -6691,3 +6847,223 @@ void QMyCustomPlot::RefreshItems_Jiegutext()
|
|||
PropertyService()->InitCurrentViewInfo();
|
||||
}
|
||||
|
||||
void QMyCustomPlot::onOpenEditResult()
|
||||
{
|
||||
m_bEditor = true;
|
||||
this->selectionRect()->setPen(Qt::NoPen);
|
||||
this->setInteractions(QCP::iSelectAxes | QCP::iSelectLegend | QCP::iSelectPlottables | QCP::iMultiSelect); // 轴、图例、图表可以被选择,并且是多选的方式
|
||||
this->setSelectionRectMode(QCP::srmSelect); // 鼠标框选
|
||||
}
|
||||
|
||||
void QMyCustomPlot::onCloseEditResult()
|
||||
{
|
||||
ClearSelectItems();
|
||||
m_bEditor = false;
|
||||
//取消框选
|
||||
this->setInteractions(QCP::iSelectLegend | QCP::iSelectPlottables);
|
||||
this->setSelectionRectMode(QCP::srmNone);
|
||||
}
|
||||
|
||||
void QMyCustomPlot::DeleteItemGroup()
|
||||
{
|
||||
if (m_strLineName == "RESULT")
|
||||
{
|
||||
QStringList listRemove;
|
||||
QMap<QString, QObject*>::iterator it = m_mapDragGroup.begin();
|
||||
for (; it != m_mapDragGroup.end(); ++it)
|
||||
{
|
||||
TransparentGroupResult *pGroup = qobject_cast<TransparentGroupResult *>(it.value());
|
||||
if (pGroup == nullptr)
|
||||
continue;
|
||||
if (pGroup->getSelect())
|
||||
listRemove << it.key();
|
||||
}
|
||||
|
||||
for (int i = 0; i < listRemove.size(); i++)
|
||||
{
|
||||
TransparentGroupResult *pGroup = qobject_cast<TransparentGroupResult *>(m_mapDragGroup.value(listRemove.at(i)));
|
||||
if (pGroup == nullptr)
|
||||
continue;
|
||||
pGroup->removeAllResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QMyCustomPlot::updateGroupZone()
|
||||
{
|
||||
QMap<double, QString> mapSort;
|
||||
QMap<QString, QObject*>::iterator it = m_mapDragGroup.begin();
|
||||
for (; it != m_mapDragGroup.end(); ++it)
|
||||
{
|
||||
TransparentGroupResult *pGroup = qobject_cast<TransparentGroupResult *>(it.value());
|
||||
if (pGroup == nullptr)
|
||||
continue;
|
||||
|
||||
mapSort.insert(pGroup->getRange().upper, it.key());
|
||||
}
|
||||
int nZid = 1;
|
||||
QList<double> listkey = mapSort.keys();
|
||||
for (int i = listkey.size() - 1; i >= 0; i--)
|
||||
{
|
||||
QString skey = mapSort.value(listkey.at(i));
|
||||
TransparentGroupResult *pGroup = qobject_cast<TransparentGroupResult *>(m_mapDragGroup.value(skey));
|
||||
if (pGroup == nullptr)
|
||||
continue;
|
||||
pGroup->setTitle(QString::number(nZid));
|
||||
nZid++;
|
||||
}
|
||||
this->replot();
|
||||
}
|
||||
|
||||
TransparentGroupResult* QMyCustomPlot::getCurGroupResult(double x_val)
|
||||
{
|
||||
TransparentGroupResult *pClickGroup = NULL;
|
||||
QObjectList objList = m_mapDragGroup.values();
|
||||
for (int i = 0; i < objList.size(); i++)
|
||||
{
|
||||
TransparentGroupResult *pGroup = qobject_cast<TransparentGroupResult *>(objList.at(i));
|
||||
if (pGroup == nullptr)
|
||||
continue;
|
||||
QCPRange rg = pGroup->getRange();
|
||||
if (x_val <= rg.upper && x_val >= rg.lower)
|
||||
{
|
||||
pClickGroup = pGroup;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return pClickGroup;
|
||||
}
|
||||
|
||||
void QMyCustomPlot::segmentationInnerLayer()
|
||||
{
|
||||
//获取鼠标点位置
|
||||
double y_pos = mLastPos.y();
|
||||
//转为图像位置
|
||||
double x_val = xAxis->pixelToCoord(y_pos);
|
||||
// 获取当前点击的解释结论组
|
||||
TransparentGroupResult *pClickGroup = getCurGroupResult(x_val);
|
||||
if (pClickGroup == NULL)
|
||||
return;
|
||||
pClickGroup->segmentationInnerLayer(x_val);
|
||||
|
||||
}
|
||||
|
||||
void QMyCustomPlot::segmentationIndependentLayer()
|
||||
{
|
||||
//获取鼠标点位置
|
||||
double y_pos = mLastPos.y();
|
||||
//转为图像位置
|
||||
double x_val = xAxis->pixelToCoord(y_pos);
|
||||
// 获取当前点击的解释结论组
|
||||
TransparentGroupResult *pClickGroup = getCurGroupResult(x_val);
|
||||
if (pClickGroup == NULL)
|
||||
return;
|
||||
|
||||
int nidx = pClickGroup->getDraggableResultIndex(x_val);
|
||||
if (nidx < 0)
|
||||
return;
|
||||
|
||||
double dupper;
|
||||
double dlower;
|
||||
|
||||
const QVector<QString>& vec = pClickGroup->getVecResult();
|
||||
const QMap<QString, QObject*>& mapResult = pClickGroup->getMapDraggable_Result();
|
||||
|
||||
QVector<QPair<QCPRange, QString>> g1;
|
||||
for (int i = 0; i <= nidx; i++)
|
||||
{
|
||||
TransparentDraggableResult* pret = qobject_cast<TransparentDraggableResult*>(mapResult.value(vec.at(i)));
|
||||
if (pret == NULL)
|
||||
continue;
|
||||
|
||||
QCPRange rg = pret->getRange();
|
||||
if (i == 0)
|
||||
dupper = rg.upper;
|
||||
|
||||
if (i == nidx)
|
||||
{
|
||||
dlower = x_val;
|
||||
rg.lower = x_val;
|
||||
g1 << qMakePair(rg, pret->getResult());
|
||||
}
|
||||
else
|
||||
{
|
||||
g1 << qMakePair(rg, pret->getResult());
|
||||
}
|
||||
}
|
||||
QString strUuid = "";
|
||||
if (g1.size() > 0)
|
||||
{
|
||||
TransparentGroupResult* pGroup = this->addResultGroup(dlower, dupper, strUuid);
|
||||
strUuid = "";
|
||||
for (int i = 0; i < g1.size(); i++)
|
||||
{
|
||||
const QPair<QCPRange, QString>& r = g1.at(i);
|
||||
pGroup->addResultToPlot(r.first.lower, r.first.upper, r.second, strUuid);
|
||||
}
|
||||
}
|
||||
|
||||
QVector<QPair<QCPRange, QString>> g2;
|
||||
for (int i = nidx; i < vec.size(); i++)
|
||||
{
|
||||
TransparentDraggableResult* pret = qobject_cast<TransparentDraggableResult*>(mapResult.value(vec.at(i)));
|
||||
if (pret == NULL)
|
||||
continue;
|
||||
|
||||
QCPRange rg = pret->getRange();
|
||||
if (i == vec.size() - 1)
|
||||
dlower = rg.lower;
|
||||
|
||||
if (i == nidx)
|
||||
{
|
||||
dupper = x_val;
|
||||
rg.upper = x_val;
|
||||
g2 << qMakePair(rg, pret->getResult());
|
||||
}
|
||||
else
|
||||
{
|
||||
g2 << qMakePair(rg, pret->getResult());
|
||||
}
|
||||
}
|
||||
if (g2.size() > 0)
|
||||
{
|
||||
TransparentGroupResult* pGroup2 = this->addResultGroup(dlower, dupper, strUuid);
|
||||
strUuid = "";
|
||||
for (int i = 0; i < g2.size(); i++)
|
||||
{
|
||||
const QPair<QCPRange, QString>& r = g2.at(i);
|
||||
pGroup2->addResultToPlot(r.first.lower, r.first.upper, r.second, strUuid);
|
||||
}
|
||||
}
|
||||
pClickGroup->removeAllResult();
|
||||
this->replot();
|
||||
|
||||
}
|
||||
|
||||
void QMyCustomPlot::splitIndependentLayer()
|
||||
{
|
||||
//获取鼠标点位置
|
||||
double y_pos = mLastPos.y();
|
||||
//转为图像位置
|
||||
double x_val = xAxis->pixelToCoord(y_pos);
|
||||
// 获取当前点击的解释结论组
|
||||
TransparentGroupResult *pClickGroup = getCurGroupResult(x_val);
|
||||
if (pClickGroup == NULL)
|
||||
return;
|
||||
|
||||
// 符合层拆分成独立层
|
||||
pClickGroup->splitIndependentLayer();
|
||||
// 删除原来的复合层
|
||||
pClickGroup->removeAllResult();
|
||||
this->replot();
|
||||
}
|
||||
|
||||
bool QMyCustomPlot::getIsEditor()
|
||||
{
|
||||
if (m_strLineName == "RESULT")
|
||||
{
|
||||
return m_bEditor;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -140,6 +140,10 @@ public:
|
|||
int m_nWaveJg = 100;
|
||||
int m_nWaveHei = 1;
|
||||
public:
|
||||
bool m_bEditor = false; // 编辑状态
|
||||
QCPItemStraightLine* m_pAddLine1 = NULL;
|
||||
QCPItemStraightLine* m_pAddLine2 = NULL;
|
||||
|
||||
QString m_strGroupUid = "";
|
||||
// 解释结论终止深度
|
||||
float m_fResultEndDepth = 0.0f;
|
||||
|
|
@ -284,6 +288,8 @@ public:
|
|||
void addRightListToPlot( QList<double> new_DepthList, QList<double> new_ValueList);
|
||||
|
||||
public slots:
|
||||
void slotSelectionRectAccepted(const QRect &rect, QMouseEvent *event);
|
||||
|
||||
void s_LineClicked(int index);
|
||||
void onResetZoom();
|
||||
void removeSelectedGraph();
|
||||
|
|
@ -393,6 +399,19 @@ public slots:
|
|||
void addItems_Jiegutext(); //从剪切板文本数据粘贴
|
||||
void DeleteItems_Jiegutext(); //全部清空
|
||||
void RefreshItems_Jiegutext(); //刷新数据
|
||||
|
||||
//右键--解释结论
|
||||
void onOpenEditResult();
|
||||
void onCloseEditResult();
|
||||
void DeleteItemGroup();
|
||||
void updateGroupZone(); //更新层号
|
||||
|
||||
TransparentGroupResult* getCurGroupResult(double x_val);
|
||||
void segmentationInnerLayer(); // 分割为层内层
|
||||
void segmentationIndependentLayer(); // 分割为独立层
|
||||
void splitIndependentLayer(); // 拆分复合层成独立层
|
||||
|
||||
bool getIsEditor();
|
||||
//
|
||||
void addItems_Core();
|
||||
|
||||
|
|
@ -435,8 +454,10 @@ public:
|
|||
bool mKedou = false;
|
||||
//
|
||||
bool mMousePress = false;
|
||||
double m_dPressX = 0;
|
||||
QPoint mLastPos;
|
||||
QCPSizeHandleManager *mSizeHandleManager;
|
||||
virtual void mouseDoubleClickEvent(QMouseEvent *event);
|
||||
virtual void mousePressEvent(QMouseEvent *event);
|
||||
virtual void mouseMoveEvent(QMouseEvent *event);
|
||||
virtual void mouseReleaseEvent(QMouseEvent *event);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user