保存曲线编辑结果到slf文件,并实时更新界面
This commit is contained in:
parent
ffa3925d23
commit
495af6493f
|
|
@ -173,6 +173,9 @@ signals:
|
||||||
//Plot重新加载数据
|
//Plot重新加载数据
|
||||||
void sig_ReloadPlot(QString strUuid, QString strSlfName, QString strLineName);
|
void sig_ReloadPlot(QString strUuid, QString strSlfName, QString strLineName);
|
||||||
|
|
||||||
|
//编辑曲线,框选拉伸/压缩
|
||||||
|
void sig_EShiftDepth(QString strSlfName, QString strLineName, int count, QList<double> left_Low_List, QList<double> right_Hight_List);
|
||||||
|
|
||||||
//
|
//
|
||||||
//void sig_addImageToPlot(QMyCustomPlot* customPlot, double left_Low, double right_Hight, QString imagePath);
|
//void sig_addImageToPlot(QMyCustomPlot* customPlot, double left_Low, double right_Hight, QString imagePath);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,9 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) :
|
||||||
//执行拼接
|
//执行拼接
|
||||||
connect(CallManage::getInstance(), SIGNAL(sig_Merge_List(QString, QList<double>, QList<double>)), this, SLOT(s_Merge_List(QString, QList<double>, QList<double>)));
|
connect(CallManage::getInstance(), SIGNAL(sig_Merge_List(QString, QList<double>, QList<double>)), this, SLOT(s_Merge_List(QString, QList<double>, QList<double>)));
|
||||||
|
|
||||||
|
//执行压缩/拉伸
|
||||||
|
connect(CallManage::getInstance(), SIGNAL(sig_EShiftDepth(QString, QString, int, QList<double>, QList<double>)), this, SLOT(s_EShiftDepth(QString, QString, int, QList<double>, QList<double>)));
|
||||||
|
|
||||||
//图头
|
//图头
|
||||||
m_dock1=new QDockWidget(tr(""),this);
|
m_dock1=new QDockWidget(tr(""),this);
|
||||||
m_dock1->setFeatures(QDockWidget::NoDockWidgetFeatures);//QDockWidget::DockWidgetMovable
|
m_dock1->setFeatures(QDockWidget::NoDockWidgetFeatures);//QDockWidget::DockWidgetMovable
|
||||||
|
|
@ -1368,6 +1371,48 @@ void MainWindowCurve::s_runcor()
|
||||||
emit CallManage::getInstance()->sig_RuncorFromPlot(m_strUuid, m_LeftCurve.m_strSlfName, m_LeftCurve.m_strWellName, m_LeftCurve.m_strTrackName, m_LeftCurve.m_strLineName);
|
emit CallManage::getInstance()->sig_RuncorFromPlot(m_strUuid, m_LeftCurve.m_strSlfName, m_LeftCurve.m_strWellName, m_LeftCurve.m_strTrackName, m_LeftCurve.m_strLineName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//编辑曲线,框选拉伸/压缩
|
||||||
|
void MainWindowCurve::s_EShiftDepth(QString strSlfName, QString strLineName, int count, QList<double> left_Low_List, QList<double> right_Hight_List)
|
||||||
|
{
|
||||||
|
if(strSlfName=="") return;
|
||||||
|
|
||||||
|
float sdeps[2],edeps[2];
|
||||||
|
sdeps[0]=right_Hight_List[0];
|
||||||
|
sdeps[1]=left_Low_List[0];
|
||||||
|
edeps[0]=right_Hight_List[1];
|
||||||
|
edeps[1]=left_Low_List[1];
|
||||||
|
|
||||||
|
CMemRdWt * logio=new CMemRdWt();
|
||||||
|
if(!logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead))
|
||||||
|
{
|
||||||
|
delete logio;
|
||||||
|
//AppendConsole(pai::log::PAI_ERROR,"SLF文件打开失败,请检查!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int curveindex=logio->FindObjectName((char*)strLineName.toStdString().c_str());
|
||||||
|
if(curveindex<0)
|
||||||
|
{
|
||||||
|
delete logio;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CString szBuffer1="";
|
||||||
|
CString szBuffer="";
|
||||||
|
for(int i=0;i<count;i++)
|
||||||
|
{
|
||||||
|
szBuffer1.Format("%10.3f %10.3f\r\n",sdeps[i],edeps[i]);
|
||||||
|
szBuffer+=szBuffer1;
|
||||||
|
}
|
||||||
|
WriteShiftMessage(*logio,szBuffer,strLineName);
|
||||||
|
logio->EShiftDepth((char*)strLineName.toStdString().c_str(),2, sdeps, edeps);
|
||||||
|
delete logio;
|
||||||
|
|
||||||
|
//Plot重新加载数据
|
||||||
|
emit CallManage::getInstance()->sig_ReloadPlot(m_strUuid, strSlfName, strLineName);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//分段线,拉伸/压缩
|
||||||
void MainWindowCurve::s_Runcor_List(QString strUuid, QList<double> left_Low_List, QList<double> right_Hight_List)
|
void MainWindowCurve::s_Runcor_List(QString strUuid, QList<double> left_Low_List, QList<double> right_Hight_List)
|
||||||
{
|
{
|
||||||
if(strUuid != m_strUuid)
|
if(strUuid != m_strUuid)
|
||||||
|
|
|
||||||
|
|
@ -219,6 +219,9 @@ public slots:
|
||||||
void s_merge();
|
void s_merge();
|
||||||
void s_Merge_List(QString strUuid, QList<double> left_Low_List, QList<double> right_Hight_List);
|
void s_Merge_List(QString strUuid, QList<double> left_Low_List, QList<double> right_Hight_List);
|
||||||
|
|
||||||
|
//编辑曲线,框选拉伸/压缩
|
||||||
|
void s_EShiftDepth(QString strSlfName, QString strLineName, int count, QList<double> left_Low_List, QList<double> right_Hight_List);
|
||||||
|
|
||||||
//
|
//
|
||||||
void s_showHeadTable(); //显示/隐藏图头
|
void s_showHeadTable(); //显示/隐藏图头
|
||||||
void s_currtemplite(); //加载图文件
|
void s_currtemplite(); //加载图文件
|
||||||
|
|
|
||||||
|
|
@ -402,113 +402,86 @@ void QMyCustomPlot::onEditLine()
|
||||||
QMessageBox::information(nullptr, "提示", "当前正在编辑曲线,请先完成编辑!");
|
QMessageBox::information(nullptr, "提示", "当前正在编辑曲线,请先完成编辑!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->setInteractions(QCP::iSelectAxes | QCP::iSelectLegend | QCP::iSelectPlottables | QCP::iMultiSelect); // 轴、图例、图表可以被选择,并且是多选的方式
|
this->setInteractions(QCP::iSelectAxes | QCP::iSelectLegend | QCP::iSelectPlottables | QCP::iMultiSelect); // 轴、图例、图表可以被选择,并且是多选的方式
|
||||||
this->setSelectionRectMode(QCP::srmCustom); // 鼠标框选
|
this->setSelectionRectMode(QCP::srmCustom); // 鼠标框选
|
||||||
|
|
||||||
for (int i=0; i < this->graphCount(); ++i) {
|
if(m_bFirstTimeConnect)
|
||||||
QCPGraph *graph = this->graph(i);
|
{
|
||||||
graph->setSelectable(QCP::stDataRange);
|
//信号槽只绑定一次,避免重复绑定
|
||||||
break;
|
m_bFirstTimeConnect = false;
|
||||||
|
|
||||||
|
for (int i=0; i < this->graphCount(); ++i) {
|
||||||
|
QCPGraph *graph = this->graph(i);
|
||||||
|
graph->setSelectable(QCP::stDataRange);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(this->selectionRect(), &QCPSelectionRect::accepted, [this](){
|
||||||
|
if(this->m_bDrawRect == false)
|
||||||
|
{
|
||||||
|
this->m_bDrawRect = true;
|
||||||
|
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);
|
||||||
|
|
||||||
|
float rlev=0;
|
||||||
|
if(m_x.size()>=2)
|
||||||
|
{
|
||||||
|
rlev = abs(m_x[1] - m_x[0]);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
int left_Low_Number=0;
|
||||||
|
int right_Hight_Number=0;
|
||||||
|
for(int i =0; i<m_x.size(); i++)
|
||||||
|
{
|
||||||
|
if(abs(m_x[i]-left_Low) <= rlev)
|
||||||
|
{
|
||||||
|
left_Low_Number = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int i =0; i<m_x.size(); i++)
|
||||||
|
{
|
||||||
|
if(abs(m_x[i]-right_Hight) <= rlev)
|
||||||
|
{
|
||||||
|
right_Hight_Number = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(abs(right_Hight-left_Low) >= (3*rlev) )//至少选中5个点
|
||||||
|
{
|
||||||
|
// for (int j=right_Hight_Number; j<left_Low_Number-1; j++)
|
||||||
|
// {
|
||||||
|
// QCPItemLine *qcpItemLine = new QCPItemLine(this);
|
||||||
|
// qcpItemLine->setPen(QPen(Qt::blue));
|
||||||
|
// qcpItemLine->setLayer("overlay"); // 确保在最上层
|
||||||
|
// qcpItemLine->start->setCoords(this->m_x[j], this->m_y[j]);
|
||||||
|
// qcpItemLine->end->setCoords(this->m_x[j+1], this->m_y[j+1]);
|
||||||
|
// }
|
||||||
|
// this->replot();
|
||||||
|
// QPixmap p = this->grab(QRect(rect.x(), rect.y(), rect.width(), rect.height()));
|
||||||
|
// p.save("./Rectpicture.png", "png");
|
||||||
|
|
||||||
|
//添加图形
|
||||||
|
this->addSelectRectToPlot(m_x[left_Low_Number], m_x[right_Hight_Number], left_Low_Number, right_Hight_Number);//left_Low, right_Hight
|
||||||
|
|
||||||
|
//取消框选
|
||||||
|
this->setInteractions(QCP::iSelectLegend | QCP::iSelectPlottables);
|
||||||
|
this->setSelectionRectMode(QCP::srmNone);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(this->selectionRect(), &QCPSelectionRect::accepted, [this](){
|
|
||||||
if(this->m_bDrawRect == false)
|
|
||||||
{
|
|
||||||
this->m_bDrawRect = true;
|
|
||||||
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);
|
|
||||||
|
|
||||||
float rlev=0;
|
|
||||||
if(m_x.size()>=2)
|
|
||||||
{
|
|
||||||
rlev = abs(m_x[1] - m_x[0]);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
int left_Low_Number=0;
|
|
||||||
int right_Hight_Number=0;
|
|
||||||
for(int i =0; i<m_x.size(); i++)
|
|
||||||
{
|
|
||||||
if(abs(m_x[i]-left_Low) <= rlev)
|
|
||||||
{
|
|
||||||
left_Low_Number = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(int i =0; i<m_x.size(); i++)
|
|
||||||
{
|
|
||||||
if(abs(m_x[i]-right_Hight) <= rlev)
|
|
||||||
{
|
|
||||||
right_Hight_Number = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(abs(right_Hight-left_Low) >= (3*rlev) )//至少选中5个点
|
|
||||||
{
|
|
||||||
// for (int j=right_Hight_Number; j<left_Low_Number-1; j++)
|
|
||||||
// {
|
|
||||||
// QCPItemLine *qcpItemLine = new QCPItemLine(this);
|
|
||||||
// qcpItemLine->setPen(QPen(Qt::blue));
|
|
||||||
// qcpItemLine->setLayer("overlay"); // 确保在最上层
|
|
||||||
// qcpItemLine->start->setCoords(this->m_x[j], this->m_y[j]);
|
|
||||||
// qcpItemLine->end->setCoords(this->m_x[j+1], this->m_y[j+1]);
|
|
||||||
// }
|
|
||||||
// this->replot();
|
|
||||||
// QPixmap p = this->grab(QRect(rect.x(), rect.y(), rect.width(), rect.height()));
|
|
||||||
// p.save("./Rectpicture.png", "png");
|
|
||||||
|
|
||||||
//添加图形
|
|
||||||
this->addSelectRectToPlot(m_x[left_Low_Number], m_x[right_Hight_Number], left_Low_Number, right_Hight_Number);//left_Low, right_Hight
|
|
||||||
|
|
||||||
//取消框选
|
|
||||||
this->setInteractions(QCP::iSelectLegend | QCP::iSelectPlottables);
|
|
||||||
this->setSelectionRectMode(QCP::srmNone);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 连接QCustomPlot的信号,selectionChangedByUser表明是由鼠标点击进行的选择
|
|
||||||
// 这里主要就是同步图表和图例的显示
|
|
||||||
// connect(this, &QMyCustomPlot::selectionChangedByUser, [this](){
|
|
||||||
// for (int i=0; i < this->graphCount(); ++i) {
|
|
||||||
// QCPGraph *graph = this->graph(i);
|
|
||||||
// QCPPlottableLegendItem *item = this->legend->itemWithPlottable(graph);
|
|
||||||
|
|
||||||
// if (item->selected() && !graph->selected())
|
|
||||||
// {
|
|
||||||
// graph->setSelection(QCPDataSelection(graph->data()->dataRange())); // 当图例项被选择时,选择图表全部的数据
|
|
||||||
// }
|
|
||||||
// else if (graph->selected())
|
|
||||||
// {
|
|
||||||
// item->setSelected(true);
|
|
||||||
|
|
||||||
// QCPDataSelection selection = this->graph(i)->selection();
|
|
||||||
// // 遍历选中的数据范围
|
|
||||||
// for (int j = 0; j < selection.dataRangeCount(); ++j)
|
|
||||||
// {
|
|
||||||
// QCPDataRange dataRange = selection.dataRange(j);
|
|
||||||
// double left_Low = this->graph(i)->data()->at(dataRange.begin())->key;
|
|
||||||
// double right_Hight = this->graph(i)->data()->at(dataRange.end())->key;
|
|
||||||
// if(right_Hight-left_Low>1)
|
|
||||||
// {
|
|
||||||
// //添加图形
|
|
||||||
// //emit CallManage::getInstance()->sig_addImageToPlot(customPlot, left_Low, right_Hight, ":/image/file.png");
|
|
||||||
// this->addImageToPlot(left_Low, right_Hight, ":/image/file.png");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QMyCustomPlot::onAddRect()
|
void QMyCustomPlot::onAddRect()
|
||||||
|
|
@ -543,6 +516,8 @@ void QMyCustomPlot::addImageToPlot(double left_Low, double right_Hight, const QS
|
||||||
|
|
||||||
void QMyCustomPlot::addSelectRectToPlot(double left_Low, double right_Hight, int left_Low_Number, int right_Hight_Number)
|
void QMyCustomPlot::addSelectRectToPlot(double left_Low, double right_Hight, int left_Low_Number, int right_Hight_Number)
|
||||||
{
|
{
|
||||||
|
//qDebug() << "QMyCustomPlot addSelectRectToPlot";
|
||||||
|
|
||||||
QtCommonClass *qtCommon = new QtCommonClass(this);
|
QtCommonClass *qtCommon = new QtCommonClass(this);
|
||||||
QString strUuid = qtCommon->getUUid();
|
QString strUuid = qtCommon->getUUid();
|
||||||
|
|
||||||
|
|
@ -558,7 +533,7 @@ void QMyCustomPlot::addSelectRectToPlot(double left_Low, double right_Hight, int
|
||||||
dragRect->setMinWidth(0.1);
|
dragRect->setMinWidth(0.1);
|
||||||
//dragRect->setTitle(strText);
|
//dragRect->setTitle(strText);
|
||||||
|
|
||||||
m_mapDraggable_Image[strUuid] = dragRect;
|
m_mapDraggable_SelectRect[strUuid] = dragRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
//校深线段
|
//校深线段
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ public:
|
||||||
int m_iSplitNum=2000; //2000000; //2000;
|
int m_iSplitNum=2000; //2000000; //2000;
|
||||||
bool m_addRandomGraph=false;//当前是否绘制曲线 true:是。
|
bool m_addRandomGraph=false;//当前是否绘制曲线 true:是。
|
||||||
bool m_bEditRect=false; //当前是否正在编辑曲线。
|
bool m_bEditRect=false; //当前是否正在编辑曲线。
|
||||||
|
bool m_bFirstTimeConnect=true; //初次绑定编辑曲线信号槽。
|
||||||
|
|
||||||
QMap<QString, QObject*> m_mapDraggable_Rect;
|
QMap<QString, QObject*> m_mapDraggable_Rect;
|
||||||
QMap<QString, QObject*> m_mapDraggable_Result;
|
QMap<QString, QObject*> m_mapDraggable_Result;
|
||||||
|
|
@ -86,6 +87,7 @@ public:
|
||||||
QMap<QString, QObject*> m_mapDraggable_SelectRect;
|
QMap<QString, QObject*> m_mapDraggable_SelectRect;
|
||||||
|
|
||||||
QObject* m_SelectShiftLine=nullptr;//当前选中的分段线
|
QObject* m_SelectShiftLine=nullptr;//当前选中的分段线
|
||||||
|
QObject* m_SelectRect=nullptr;//当前选中的曲线编辑框
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void slot_time();
|
void slot_time();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include "transparentdraggableSelectRect.h"
|
#include "transparentdraggableSelectRect.h"
|
||||||
|
#include "CallManage.h"
|
||||||
|
|
||||||
|
|
||||||
extern double g_dPixelPerCm;//每厘米像素数
|
extern double g_dPixelPerCm;//每厘米像素数
|
||||||
|
|
@ -102,20 +103,6 @@ void TransparentDraggableSelectRect::setNumber(int left_Low_Number, int right_Hi
|
||||||
//
|
//
|
||||||
m_qcpItemLine_List.append(qcpItemLine);
|
m_qcpItemLine_List.append(qcpItemLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
// //
|
|
||||||
// double lY1 = mPlot->yAxis->range().lower;//+10
|
|
||||||
// double lY2 = mPlot->yAxis->range().upper;
|
|
||||||
// double left_Low = mPlot->m_x[left_Low_Number];
|
|
||||||
// double right_Hight = mPlot->m_x[right_Hight_Number];
|
|
||||||
// //
|
|
||||||
// double x1 = mPlot->xAxis->coordToPixel(left_Low);
|
|
||||||
// double x2 = mPlot->xAxis->coordToPixel(right_Hight);
|
|
||||||
// double y1 = mPlot->yAxis->coordToPixel(lY1);
|
|
||||||
// double y2 = mPlot->yAxis->coordToPixel(lY2);
|
|
||||||
// //
|
|
||||||
// QPixmap p = this->grab(QRect(x2, x1, y2-y1, x1-x2));
|
|
||||||
// p.save("./Rectpicture.png","png");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//设置解释结论
|
//设置解释结论
|
||||||
|
|
@ -207,6 +194,9 @@ void TransparentDraggableSelectRect::setRange(double left_Low, double right_High
|
||||||
{
|
{
|
||||||
if(left_Low >= right_Hight) return;
|
if(left_Low >= right_Hight) return;
|
||||||
|
|
||||||
|
m_left_Low_Current = left_Low;
|
||||||
|
m_right_Hight_Current = right_Hight;
|
||||||
|
//
|
||||||
double lY1 = mPlot->yAxis->range().lower;//+10
|
double lY1 = mPlot->yAxis->range().lower;//+10
|
||||||
double lY2 = mPlot->yAxis->range().upper;
|
double lY2 = mPlot->yAxis->range().upper;
|
||||||
mRect->topLeft->setCoords(left_Low, lY1);
|
mRect->topLeft->setCoords(left_Low, lY1);
|
||||||
|
|
@ -265,7 +255,7 @@ void TransparentDraggableSelectRect::deleteRect()
|
||||||
// mRightHandle->deleteLater();
|
// mRightHandle->deleteLater();
|
||||||
// mPixmap->deleteLater();
|
// mPixmap->deleteLater();
|
||||||
|
|
||||||
mPlot->m_mapDraggable_Image.remove(m_strUuid);
|
mPlot->m_mapDraggable_SelectRect.remove(m_strUuid);
|
||||||
|
|
||||||
mPlot->removeItem(mRect);
|
mPlot->removeItem(mRect);
|
||||||
mPlot->removeItem(mLeftHandle);
|
mPlot->removeItem(mLeftHandle);
|
||||||
|
|
@ -355,6 +345,30 @@ void TransparentDraggableSelectRect::updateHandles()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TransparentDraggableSelectRect::slotSaveChange()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
QList<double> left_Low_List;
|
||||||
|
QList<double> right_Hight_List;
|
||||||
|
left_Low_List.append(0 - mPlot->m_x[m_left_Low_Number]);
|
||||||
|
right_Hight_List.append(0 - mPlot->m_x[m_right_Hight_Number]);
|
||||||
|
//
|
||||||
|
left_Low_List.append(0 - m_left_Low_Current);
|
||||||
|
right_Hight_List.append(0 - m_right_Hight_Current);
|
||||||
|
|
||||||
|
QString strSlfName = mPlot->m_strSlfName;
|
||||||
|
QString strLineName = mPlot->m_strLineName;
|
||||||
|
int count = 2;
|
||||||
|
|
||||||
|
//执行校正
|
||||||
|
emit CallManage::getInstance()->sig_EShiftDepth(strSlfName, strLineName, count, left_Low_List, right_Hight_List);
|
||||||
|
|
||||||
|
|
||||||
|
//删除框图
|
||||||
|
deleteRect();
|
||||||
|
//emit sig_DelRect();
|
||||||
|
}
|
||||||
|
|
||||||
void TransparentDraggableSelectRect::onDelRect()
|
void TransparentDraggableSelectRect::onDelRect()
|
||||||
{
|
{
|
||||||
//mDragMode = DragNone;
|
//mDragMode = DragNone;
|
||||||
|
|
@ -378,6 +392,11 @@ void TransparentDraggableSelectRect::onMousePress(QMouseEvent *event)
|
||||||
//else if(x >= currentRange.lower && x <= currentRange.upper) {
|
//else if(x >= currentRange.lower && x <= currentRange.upper) {
|
||||||
else if(y >= currentRange.lower && y <= currentRange.upper) {
|
else if(y >= currentRange.lower && y <= currentRange.upper) {
|
||||||
mDragMode = DragNone;
|
mDragMode = DragNone;
|
||||||
|
|
||||||
|
QMenu menu(mPlot);
|
||||||
|
menu.addAction(QIcon(::GetImagePath() + "icon/savecurve.png"), "保存当前数据修改", this, &TransparentDraggableSelectRect::slotSaveChange);
|
||||||
|
menu.addAction(QIcon(::GetImagePath() + "icon/ClearSel.png"), "放弃当前数据修改", this, &TransparentDraggableSelectRect::onDelRect);
|
||||||
|
menu.exec(event->globalPos());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mDragMode = DragNone;
|
mDragMode = DragNone;
|
||||||
|
|
@ -385,22 +404,6 @@ void TransparentDraggableSelectRect::onMousePress(QMouseEvent *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
//event->accept();
|
//event->accept();
|
||||||
|
|
||||||
QMenu menu(nullptr);
|
|
||||||
QAction *delAction = menu.addAction("删除框图");
|
|
||||||
//delAction->installEventFilter(this);
|
|
||||||
connect(delAction, &QAction::triggered, this, &TransparentDraggableSelectRect::onDelRect);
|
|
||||||
|
|
||||||
// QAction* pItem = menu.exec(event->globalPos());
|
|
||||||
// if(pItem == delAction)
|
|
||||||
// {
|
|
||||||
// //event->accept();
|
|
||||||
|
|
||||||
// int ii=0;
|
|
||||||
// ii++;
|
|
||||||
// }
|
|
||||||
menu.exec(event->globalPos());
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -455,7 +458,8 @@ void TransparentDraggableSelectRect::onMouseMove(QMouseEvent *event)
|
||||||
double proposedLeft = mDragStartRange.lower + dy;
|
double proposedLeft = mDragStartRange.lower + dy;
|
||||||
// 确保不超出轴范围且不使宽度小于最小值
|
// 确保不超出轴范围且不使宽度小于最小值
|
||||||
newRange.lower = qBound(
|
newRange.lower = qBound(
|
||||||
mPlot->xAxis->range().lower,
|
//mPlot->xAxis->range().lower,
|
||||||
|
getMyLower(),
|
||||||
proposedLeft,
|
proposedLeft,
|
||||||
mDragStartRange.upper - mMinWidth);
|
mDragStartRange.upper - mMinWidth);
|
||||||
break;
|
break;
|
||||||
|
|
@ -467,7 +471,8 @@ void TransparentDraggableSelectRect::onMouseMove(QMouseEvent *event)
|
||||||
newRange.upper = qBound(
|
newRange.upper = qBound(
|
||||||
mDragStartRange.lower + mMinWidth,
|
mDragStartRange.lower + mMinWidth,
|
||||||
proposedRight,
|
proposedRight,
|
||||||
mPlot->xAxis->range().upper);
|
getMyUpper());
|
||||||
|
//mPlot->xAxis->range().upper);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DragRect: {
|
case DragRect: {
|
||||||
|
|
@ -478,15 +483,24 @@ void TransparentDraggableSelectRect::onMouseMove(QMouseEvent *event)
|
||||||
newRange.upper = center + width/2;
|
newRange.upper = center + width/2;
|
||||||
|
|
||||||
// 检查是否超出轴范围
|
// 检查是否超出轴范围
|
||||||
QCPRange axisRange = mPlot->xAxis->range();
|
if(newRange.lower < getMyLower()) {
|
||||||
if(newRange.lower < axisRange.lower) {
|
newRange.lower = getMyLower();
|
||||||
newRange.lower = axisRange.lower;
|
newRange.upper = newRange.lower + width;
|
||||||
newRange.upper = newRange.lower + width;
|
|
||||||
}
|
}
|
||||||
else if(newRange.upper > axisRange.upper) {
|
else if(newRange.upper > getMyUpper()) {
|
||||||
newRange.upper = axisRange.upper;
|
newRange.upper = getMyUpper();
|
||||||
newRange.lower = newRange.upper - width;
|
newRange.lower = newRange.upper - width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// QCPRange axisRange = mPlot->xAxis->range();
|
||||||
|
// if(newRange.lower < axisRange.lower) {
|
||||||
|
// newRange.lower = axisRange.lower;
|
||||||
|
// newRange.upper = newRange.lower + width;
|
||||||
|
// }
|
||||||
|
// else if(newRange.upper > axisRange.upper) {
|
||||||
|
// newRange.upper = axisRange.upper;
|
||||||
|
// newRange.lower = newRange.upper - width;
|
||||||
|
// }
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
@ -541,3 +555,61 @@ void TransparentDraggableSelectRect::onMouseRelease(QMouseEvent *event)
|
||||||
mPlot->selectionRect()->mActive=true;
|
mPlot->selectionRect()->mActive=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double TransparentDraggableSelectRect::getMyLower()
|
||||||
|
{
|
||||||
|
double dLower = mPlot->xAxis->range().lower;
|
||||||
|
double proposedLeft = mDragStartRange.lower;
|
||||||
|
|
||||||
|
TransparentDraggableSelectRect *pDraggableRect =NULL;
|
||||||
|
{
|
||||||
|
QMap<QString,QObject *>::Iterator it = mPlot->m_mapDraggable_SelectRect.begin();
|
||||||
|
while( it != mPlot->m_mapDraggable_SelectRect.end() )
|
||||||
|
{
|
||||||
|
if(it.key() == m_strUuid)
|
||||||
|
{
|
||||||
|
it++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pDraggableRect = (TransparentDraggableSelectRect*)it.value();
|
||||||
|
//
|
||||||
|
QCPRange tmpRange = pDraggableRect->getRange();
|
||||||
|
if(tmpRange.upper >= dLower && tmpRange.upper <= proposedLeft)
|
||||||
|
{
|
||||||
|
dLower = tmpRange.upper;
|
||||||
|
}
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dLower;
|
||||||
|
}
|
||||||
|
|
||||||
|
double TransparentDraggableSelectRect::getMyUpper()
|
||||||
|
{
|
||||||
|
double dUpper = mPlot->xAxis->range().upper;
|
||||||
|
double proposedRight = mDragStartRange.upper;
|
||||||
|
|
||||||
|
TransparentDraggableSelectRect *pDraggableRect =NULL;
|
||||||
|
{
|
||||||
|
QMap<QString,QObject *>::Iterator it = mPlot->m_mapDraggable_SelectRect.begin();
|
||||||
|
while( it != mPlot->m_mapDraggable_SelectRect.end() )
|
||||||
|
{
|
||||||
|
if(it.key() == m_strUuid)
|
||||||
|
{
|
||||||
|
it++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pDraggableRect = (TransparentDraggableSelectRect*)it.value();
|
||||||
|
//
|
||||||
|
QCPRange tmpRange = pDraggableRect->getRange();
|
||||||
|
if(tmpRange.lower <= dUpper && tmpRange.lower >= proposedRight)
|
||||||
|
{
|
||||||
|
dUpper = tmpRange.lower;
|
||||||
|
}
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dUpper;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,16 +49,20 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void rangeChanged(QCPRange newRange);
|
void rangeChanged(QCPRange newRange);
|
||||||
|
void sig_DelRect();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initRect();
|
void initRect();
|
||||||
void updateHandles() ;
|
void updateHandles() ;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void slotSaveChange();
|
||||||
void onDelRect();
|
void onDelRect();
|
||||||
void onMousePress(QMouseEvent *event);
|
void onMousePress(QMouseEvent *event);
|
||||||
void onMouseMove(QMouseEvent *event);
|
void onMouseMove(QMouseEvent *event);
|
||||||
void onMouseRelease(QMouseEvent *event);
|
void onMouseRelease(QMouseEvent *event);
|
||||||
|
double getMyLower();
|
||||||
|
double getMyUpper();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMyCustomPlot *mPlot;
|
QMyCustomPlot *mPlot;
|
||||||
|
|
@ -75,6 +79,8 @@ private:
|
||||||
QList<QCPItemLine*> m_qcpItemLine_List;
|
QList<QCPItemLine*> m_qcpItemLine_List;
|
||||||
int m_left_Low_Number;
|
int m_left_Low_Number;
|
||||||
int m_right_Hight_Number;
|
int m_right_Hight_Number;
|
||||||
|
double m_left_Low_Current;
|
||||||
|
double m_right_Hight_Current;
|
||||||
|
|
||||||
enum DragMode { DragNone, DragLeft, DragRight, DragRect };
|
enum DragMode { DragNone, DragLeft, DragRight, DragRect };
|
||||||
DragMode mDragMode = DragNone;
|
DragMode mDragMode = DragNone;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user