模板加载优化

This commit is contained in:
jiayulong 2025-10-30 11:55:37 +08:00
parent c06a876370
commit 71c120ba2f
14 changed files with 316 additions and 88 deletions

View File

@ -41,6 +41,8 @@ signals:
void sig_NewTrack(QString strWellName, QString strSlfName, QString strLineName);//新建道
void sig_NewTrack_No_Line(QString strWellName, QString strTrackName);//新建空白道,没有曲线
void sig_AddLine(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName);//新建曲线
void sig_AddLine_Property(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName,
double newLeftScale, double newRightScale, QColor lineColor, double width, Qt::PenStyle lineStyle);//新建曲线,带属性
void sig_delLine(QString strWellName, QString strTrackName, QString strLineName);//删除曲线
//属性
//左刻度

View File

@ -40,6 +40,7 @@ private:
QtVariantPropertyManager *m_pVariantManager;
public:
QString m_strUuid;
QString m_strSlfName;
QString m_strWellName;
QString m_strTrackName;

View File

@ -45,9 +45,11 @@ FormDraw::FormDraw(QWidget *parent, QString strWellName, QString strTrackName) :
connect(CallManage::getInstance(), SIGNAL(sig_AddLine(QString, QString, QString, QString)), this, SLOT(s_addLine(QString, QString, QString, QString)));
connect(CallManage::getInstance(), SIGNAL(sig_AddLine_Property(QString, QString, QString, QString, double, double, QColor, double, Qt::PenStyle)),
this, SLOT(s_AddLine_Property(QString, QString, QString, QString, double, double, QColor, double, Qt::PenStyle)));
connect(CallManage::getInstance(), SIGNAL(sig_delLine(QString, QString, QString)), this, SLOT(s_delLine(QString, QString, QString)));
connect(CallManage::getInstance(), SIGNAL(sig_MouseMove(QString, QString, float)), this, SLOT(s_MouseMove(QString, QString, float)));
connect(CallManage::getInstance(), SIGNAL(sig_addImageToPlot(QMyCustomPlot*, double, double, QString)), this, SLOT(s_addImageToPlot(QMyCustomPlot*, double, double, QString)));
//connect(CallManage::getInstance(), SIGNAL(sig_addImageToPlot(QMyCustomPlot*, double, double, QString)), this, SLOT(s_addImageToPlot(QMyCustomPlot*, double, double, QString)));
//s_addLine(1);
@ -134,6 +136,62 @@ void FormDraw::s_addLine(QString strSlfName, QString strWellName, QString strTra
m_listLineName.push_back(strLineName);
}
void FormDraw::s_AddLine_Property(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName,
double newLeftScale, double newRightScale, QColor lineColor, double width, Qt::PenStyle lineStyle)
{
qDebug() << "FormDraw s_addLine";
//井名&道名不一致
if(m_strWellName == strWellName && m_strTrackName == strTrackName)
{
}
else
{
return;
}
if(m_listLineName.contains(strLineName))
{
qDebug() << "FormDraw strLineName already exist! " << strLineName;
return;
}
//
QMyCustomPlot *curv = new QMyCustomPlot(this, strSlfName, strWellName, strTrackName, strLineName);
//背景设置成透明色
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 = (g_iY2-g_iY1)*100.0/(double)g_iScale * g_dPixelPerCm;
qDebug() << "FormDraw dHight=" << QString::number((int)dHight-3184);
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);
initForm(curv, strSlfName, strLineName,
newLeftScale, newRightScale, lineColor, width, lineStyle);
curv->show();
//
m_listLineName.push_back(strLineName);
}
void FormDraw::s_delLine(QString strWellName, QString strTrackName, QString strLineName)
{
qDebug() << "FormDraw s_delLine";
@ -236,8 +294,12 @@ void FormDraw::s_MouseMove(QString strWellName, QString strTrackName, float dep)
void FormDraw::s_addImageToPlot(QMyCustomPlot* customPlot, double left_Low, double right_Hight, const QString imagePath)
{
//井名&道名不一致
if(m_strWellName == customPlot->m_strWellName && m_strTrackName == customPlot->m_strTrackName)
if(this->isActiveWindow() //当前活动窗口
&& m_strWellName == customPlot->m_strWellName
&& m_strTrackName == customPlot->m_strTrackName
&& m_listLineName.contains(customPlot->m_strLineName))
{
}
else
{
@ -401,7 +463,8 @@ void FormDraw::setupSelectionDemo(QMyCustomPlot *customPlot)
if(right_Hight-left_Low>5)
{
//添加图形
emit CallManage::getInstance()->sig_addImageToPlot(customPlot, left_Low, right_Hight, ":/image/file.png");
//emit CallManage::getInstance()->sig_addImageToPlot(customPlot, left_Low, right_Hight, ":/image/file.png");
customPlot->addImageToPlot(left_Low, right_Hight, ":/image/file.png");
}
});
@ -431,7 +494,8 @@ void FormDraw::setupSelectionDemo(QMyCustomPlot *customPlot)
if(right_Hight-left_Low>1)
{
//添加图形
emit CallManage::getInstance()->sig_addImageToPlot(customPlot, left_Low, right_Hight, ":/image/file.png");
//emit CallManage::getInstance()->sig_addImageToPlot(customPlot, left_Low, right_Hight, ":/image/file.png");
customPlot->addImageToPlot(left_Low, right_Hight, ":/image/file.png");
}
}
@ -464,7 +528,8 @@ void FormDraw::s_selectionRectAccepted(const QRect &rect, QMouseEvent *event)
// double y2 = widget->yAxis->pixelToCoord(rect.bottom());
}
void FormDraw::initForm(QMyCustomPlot *widget, QString strSlfName, QString strLineName)
void FormDraw::initForm(QMyCustomPlot *widget, QString strSlfName, QString strLineName,
double newLeftScale, double newRightScale, QColor lineColor, double width, Qt::PenStyle lineStyle)
{
CLogIO *logio=new CLogIO();
logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead);
@ -502,12 +567,21 @@ void FormDraw::initForm(QMyCustomPlot *widget, QString strSlfName, QString strLi
QVector<double> x, y;
for(int i=0; i<count; i++)
{
if(vmax<val[i])vmax=val[i];
if(vmin>val[i])vmin=val[i];
if(newLeftScale==-9999)
{
if(vmax<val[i])vmax=val[i];
if(vmin>val[i])vmin=val[i];
}
//
x.append(-(sdep+ rlev*i));
y.append(val[i]);
}
if(newLeftScale!=-9999)
{
vmax = newRightScale;
vmin = newLeftScale;
}
//赋值
m_vmax = vmax;
m_vmin = vmin;
@ -566,8 +640,15 @@ void FormDraw::initForm(QMyCustomPlot *widget, QString strSlfName, QString strLi
// x.append(-(sdep+ rlev*i));
// y.append(val[i]);
// }
addRandomGraph(widget, x, y, strSlfName, strLineName);
if(newLeftScale!=-9999)
{
addRandomGraph(widget, x, y, strSlfName, strLineName,
newLeftScale, newRightScale, lineColor, width, lineStyle);
}
else {
addRandomGraph(widget, x, y, strSlfName, strLineName);
}
//支持框选
setupSelectionDemo(widget);
@ -576,7 +657,8 @@ void FormDraw::initForm(QMyCustomPlot *widget, QString strSlfName, QString strLi
widget->replot();
}
void FormDraw::addRandomGraph(QMyCustomPlot *widget, QVector<double> x, QVector<double> y, QString strSlfName, QString strLineName)
void FormDraw::addRandomGraph(QMyCustomPlot *widget, QVector<double> x, QVector<double> y, QString strSlfName, QString strLineName,
double newLeftScale, double newRightScale, QColor newlineColor, double width, Qt::PenStyle lineStyle)
{
widget->addGraph();
if(strLineName=="")
@ -586,31 +668,45 @@ void FormDraw::addRandomGraph(QMyCustomPlot *widget, QVector<double> x, QVector<
widget->graph()->setName(strLineName);
widget->graph()->setData(x, y);
widget->graph()->setLineStyle((QCPGraph::LineStyle)(1));//曲线
//widget->graph()->setLineStyle((QCPGraph::LineStyle)(std::rand()%5+1));
//widget->graph()->setLineStyle((QCPGraph::LineStyle)(QCPGraph::lsLine));//曲线
//widget->graph()->setLineStyle((QCPGraph::LineStyle)(QCPGraph::lsImpulse));//杆状
if(newLeftScale!=-9999)
{
widget->graph()->setLineStyle((QCPGraph::LineStyle)(lineStyle));//曲线
// if (std::rand()%100 > 50)
// widget->graph()->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(std::rand()%14+1)));
widget->graph()->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(1)));
widget->graph()->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(1)));
// widget->graph()->setScatterStyle(QCPScatterStyle(QPixmap(":/image/file.png")));
QPen graphPen;
graphPen.setColor(newlineColor);
graphPen.setWidthF(width);
graphPen.setStyle(lineStyle);//实线
widget->graph()->setPen(graphPen);
}
else
{
widget->graph()->setLineStyle((QCPGraph::LineStyle)(1));//曲线
//widget->graph()->setLineStyle((QCPGraph::LineStyle)(std::rand()%5+1));
//widget->graph()->setLineStyle((QCPGraph::LineStyle)(QCPGraph::lsLine));//曲线
//widget->graph()->setLineStyle((QCPGraph::LineStyle)(QCPGraph::lsImpulse));//杆状
//widget->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 5));
// if (std::rand()%100 > 50)
// widget->graph()->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(std::rand()%14+1)));
QPen graphPen;
QColor lineColor = QColor(std::rand()%245+10, std::rand()%245+10, std::rand()%245+10);
graphPen.setColor(lineColor);
//graphPen.setWidthF(std::rand()/(double)RAND_MAX*2+1);
double dWidth = 2;
graphPen.setWidthF(dWidth);
graphPen.setStyle(Qt::SolidLine);//实线
widget->graph()->setPen(graphPen);
//widget->replot();
widget->graph()->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(1)));
// widget->graph()->setScatterStyle(QCPScatterStyle(QPixmap(":/image/file.png")));
//widget->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 5));
QPen graphPen;
newlineColor = QColor(std::rand()%245+10, std::rand()%245+10, std::rand()%245+10);
graphPen.setColor(newlineColor);
//graphPen.setWidthF(std::rand()/(double)RAND_MAX*2+1);
width = 2;
graphPen.setWidthF(width);
graphPen.setStyle(Qt::SolidLine);//实线
widget->graph()->setPen(graphPen);
//widget->replot();
}
//道-对象
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strLineName, lineColor, dWidth, m_vmax, m_vmin);
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strLineName, newlineColor, width, m_vmax, m_vmin);
}

View File

@ -35,6 +35,7 @@ public slots:
void dropEvent(QDropEvent* event);
public:
QString m_strUuid;
QString m_strWellName;
QString m_strTrackName;
@ -47,8 +48,10 @@ public:
float m_vmin;
public:
void initForm(QMyCustomPlot *widget, QString strSlfName, QString strLineName);
void addRandomGraph(QMyCustomPlot *widget, QVector<double> x, QVector<double> y, QString strSlfName, QString strLineName);
void initForm(QMyCustomPlot *widget, QString strSlfName, QString strLineName,
double newLeftScale=-9999, double newRightScale=-9999, QColor lineColor=QColor(0,0,0), double width=1, Qt::PenStyle lineStyle=Qt::SolidLine);
void addRandomGraph(QMyCustomPlot *widget, QVector<double> x, QVector<double> y, QString strSlfName, QString strLineName,
double newLeftScale=-9999, double newRightScale=-9999, QColor lineColor=QColor(0,0,0), double width=1, Qt::PenStyle lineStyle=Qt::SolidLine);
void setupLineStyleDemo(QMyCustomPlot *customPlot);
void setupSelectionDemo(QMyCustomPlot *customPlot);
@ -58,6 +61,9 @@ signals:
public slots:
void s_addLine(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName);
void s_AddLine_Property(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName,
double newLeftScale, double newRightScale, QColor lineColor, double width, Qt::PenStyle lineStyle);//新建曲线,带属性
void s_delLine(QString strWellName, QString strTrackName, QString strLineName);
void s_MouseMove(QString strWellName, QString strTrackName, float dep);
void s_handleRectRangeChange(QCPRange newRange);

View File

@ -52,6 +52,7 @@ public slots:
float vMin, float vMax);
public:
QString m_strUuid;
QString m_strSlfName;
QString m_strWellName;
QString m_strTrackName;

View File

@ -22,6 +22,7 @@ private:
Ui::FormTrack *ui;
public:
QString m_strUuid;
QString m_strWellName;
QString m_strTrackName;

View File

@ -23,6 +23,7 @@ private:
Ui::FormWell *ui;
public:
QString m_strUuid;
QString m_strWellName;
public:

View File

@ -177,7 +177,7 @@ void MainWindow::initToolBar()
m_newAc = new QAction(newFileIcon, "新建项目", this);
m_openAc = new QAction(openFileIcon, "打开项目", this);
m_grepAc = new QAction(grepIcon, "启用缩放", this);
m_grepAc = new QAction(grepIcon, "可视解释", this);//启用缩放
m_compileAc = new QAction(compileIcon, "新建道", this);
m_runAc = new QAction(runIcon, "保存图像", this);
m_debugAc = new QAction(debugIcon, "画图", this);
@ -196,7 +196,7 @@ void MainWindow::initToolBar()
connect(m_newAc, &QAction::triggered, this, &MainWindow::s_New);
connect(m_openAc, &QAction::triggered, this, &MainWindow::s_Open);
connect(m_grepAc, &QAction::triggered, this, &MainWindow::s_Risize);
connect(m_grepAc, &QAction::triggered, this, &MainWindow::s_showView);//s_Risize
connect(m_compileAc, &QAction::triggered, this, &MainWindow::s_AddOne);
connect(m_runAc, &QAction::triggered, this, &MainWindow::s_SaveImage);
connect(m_debugAc, &QAction::triggered, this, &MainWindow::s_DrawImg);
@ -238,42 +238,42 @@ void MainWindow::initWorkSpaceView()
//----
MainWindowCurve *mainWindowNew2 = new MainWindowCurve();//中间工作区
m_centerWidgets->addTab(mainWindowNew2, "解释视图2");
//MainWindowCurve *mainWindowNew2 = new MainWindowCurve();//中间工作区
//m_centerWidgets->addTab(mainWindowNew2, "解释视图2");
//----
MainWindowNew *mainWindowNew = new MainWindowNew();//中间工作区
m_centerWidgets->addTab(mainWindowNew, "解释视图");
//MainWindowNew *mainWindowNew = new MainWindowNew();//中间工作区
//m_centerWidgets->addTab(mainWindowNew, "解释视图");
//
//加载插件显示
QWidget * pMyWidget = CallPlugin::getInstance()->getPluginWidget(MYUNITPLUGIN, NULL);
if (pMyWidget != nullptr)
{
//
//直方图获取当前工程下的slf
QVector<QString> vecSlfList;
QVector<QString> vecWellList;
bool bRet = getAllSlf(g_prjname, vecSlfList, vecWellList);
if(bRet)
{
for(int i=0; i<vecWellList.size(); i++)
{
qDebug() << "vecWellList:" << QString::number(i+1) << "=" << vecWellList[i];
}
for(int i=0; i<vecSlfList.size(); i++)
{
qDebug() << "vecSlfList:" << QString::number(i+1) << "=" << vecSlfList[i];
}
}
//关联信号槽数据传递vecSlfList, vecWellList
//...
// QWidget * pMyWidget = CallPlugin::getInstance()->getPluginWidget(MYUNITPLUGIN, NULL);
// if (pMyWidget != nullptr)
// {
// //
// //直方图获取当前工程下的slf
// QVector<QString> vecSlfList;
// QVector<QString> vecWellList;
// bool bRet = getAllSlf(g_prjname, vecSlfList, vecWellList);
// if(bRet)
// {
// for(int i=0; i<vecWellList.size(); i++)
// {
// qDebug() << "vecWellList:" << QString::number(i+1) << "=" << vecWellList[i];
// }
// for(int i=0; i<vecSlfList.size(); i++)
// {
// qDebug() << "vecSlfList:" << QString::number(i+1) << "=" << vecSlfList[i];
// }
// }
// //关联信号槽数据传递vecSlfList, vecWellList
// //...
//关联信号槽,数据查看
connect(CallManage::getInstance(), SIGNAL(sig_testPlugin(QString)), pMyWidget, SLOT(s_testPlugin(QString)));
//
m_centerWidgets->addTab(pMyWidget, "插件视图");
}
// //关联信号槽,数据查看
// connect(CallManage::getInstance(), SIGNAL(sig_testPlugin(QString)), pMyWidget, SLOT(s_testPlugin(QString)));
// //
// m_centerWidgets->addTab(pMyWidget, "插件视图");
// }
}
qDebug() << "工作区 id:" << m_stackedWidget_Center->winId() << ", name:" << m_stackedWidget_Center->windowTitle();
}
@ -327,6 +327,41 @@ void MainWindow::s_Open()
}
}
//可视解释
void MainWindow::s_showView()
{
if(g_prjname=="")
{
QMessageBox::information(nullptr, "提示", "请先打开项目!");
return;
}
//Logdata
QString folderPath;
folderPath = GetLogdataPath();
folderPath = folderPath + g_prjname;
//folderPath = folderPath + "/multiwell.json";
//打开
QString fileFull = "";
fileFull = QFileDialog::getOpenFileName(this,
tr("选择模板"),
folderPath,
tr("多井图文件(*.json)"));
if (fileFull.isEmpty())
{
//----
MainWindowCurve *mainWindowCurve = new MainWindowCurve();//中间工作区
m_centerWidgets->addTab(mainWindowCurve, "解释视图");
return;
}
//----
MainWindowCurve *mainWindowCurve = new MainWindowCurve();//中间工作区
m_centerWidgets->addTab(mainWindowCurve, "解释视图");
mainWindowCurve->s_Open(fileFull);
}
void MainWindow::s_Risize()
{
emit CallManage::getInstance()->sig_Risize();

View File

@ -81,7 +81,8 @@ public slots:
void s_DrawImg();
void s_DrawLine();
//可视解释
void s_showView();
void s_ShowCurve(QString strSlfName, QString strName);//曲线数据查看

View File

@ -4,6 +4,7 @@
#include <QTextStream>
#include "CallManage.h"
#include <QAbstractItemView>
#include "qtcommonclass.h"
extern int g_iOneWidth; //道宽
extern QString g_prjname;
@ -19,6 +20,9 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) :
{
ui->setupUi(this);
QtCommonClass *qtCommon = new QtCommonClass(this);
m_strUuid = qtCommon->getUUid();
// 设置工具栏的位置,此处设置为在左侧
addToolBar(Qt::LeftToolBarArea, ui->toolBar);
@ -90,7 +94,7 @@ void MainWindowCurve::initMainToolBar()
//Main工具栏
QAction* m_saveAc = nullptr; //保存
QAction* m_openAc = nullptr; //打开
//QAction* m_openAc = nullptr; //打开
QAction* m_compileAc = nullptr; //
QAction* m_runAc = nullptr;//
QAction* m_debugAc = nullptr; //
@ -98,7 +102,7 @@ void MainWindowCurve::initMainToolBar()
QAction* m_loadAc = nullptr; //加载
m_saveAc = new QAction(newFileIcon, "保存", this);
m_openAc = new QAction(openFileIcon, "打开", this);
//m_openAc = new QAction(openFileIcon, "打开", this);
m_grepAc = new QAction(grepIcon, "锁头", this);
m_compileAc = new QAction(compileIcon, "加载图文件", this);
m_runAc = new QAction(runIcon, "设置井", this);
@ -109,7 +113,7 @@ void MainWindowCurve::initMainToolBar()
//add QAction to Widget.
ui->mainToolBar->addAction(m_saveAc);
ui->mainToolBar->addAction(m_openAc);
//ui->mainToolBar->addAction(m_openAc);
ui->mainToolBar->addAction(m_grepAc);
ui->mainToolBar->addAction(m_compileAc);
ui->mainToolBar->addAction(m_runAc);
@ -117,7 +121,7 @@ void MainWindowCurve::initMainToolBar()
ui->mainToolBar->addAction(m_loadAc);
connect(m_saveAc, &QAction::triggered, this, &MainWindowCurve::s_Save);
connect(m_openAc, &QAction::triggered, this, &MainWindowCurve::s_Open);
//connect(m_openAc, &QAction::triggered, this, &MainWindowCurve::s_Open);
// connect(m_grepAc, &QAction::triggered, this, &MainWindow::s_Risize);
// connect(m_compileAc, &QAction::triggered, this, &MainWindow::s_AddOne);
@ -234,25 +238,8 @@ void MainWindowCurve::s_Save()
}
}
void MainWindowCurve::s_Open()
void MainWindowCurve::s_Open(QString fileFull)
{
//Logdata
QString folderPath;
folderPath = GetLogdataPath();
folderPath = folderPath + g_prjname;
//folderPath = folderPath + "/multiwell.json";
//打开
QString fileFull = "";
fileFull = QFileDialog::getOpenFileName(this,
tr("选择模板"),
folderPath,
tr("多井图文件(*.json)"));
if (fileFull.isEmpty())
{
return;
}
QString strPrjname = "";
QJsonArray wellsArray;
@ -356,6 +343,7 @@ void MainWindowCurve::DisplayWells(QJsonArray wellsArray)
}
}
//展示其中一口井
void MainWindowCurve::DisplayWell_One(QJsonObject wellObjInfo)
{
QString strWellName = "";
@ -534,6 +522,11 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QString strWellName = "";
QString strTrackName = "";
QString strLineName = "";
double newLeftScale = 0;
double newRightScale = 500;
QColor lineColor = QColor(0,0,0);
double width = 3;
Qt::PenStyle lineStyle = Qt::SolidLine;
if (lineObjInfo.contains("SlfName"))
{
@ -568,10 +561,82 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
}
}
if (lineObjInfo.contains("vmin"))
{
QJsonValue value = lineObjInfo.value("vmin");
if (value.isDouble()) {
newLeftScale = value.toDouble();
qDebug() << "vmin:" << QString::number(newLeftScale);
}
}
if (lineObjInfo.contains("vmax"))
{
QJsonValue value = lineObjInfo.value("vmax");
if (value.isDouble()) {
newRightScale = value.toDouble();
qDebug() << "vmax:" << QString::number(newRightScale);
}
}
if (lineObjInfo.contains("Width"))
{
QJsonValue value = lineObjInfo.value("Width");
if (value.isDouble()) {
width = value.toDouble();
qDebug() << "Width:" << QString::number(width);
}
}
if (lineObjInfo.contains("lineStyle"))
{
QJsonValue value = lineObjInfo.value("lineStyle");
if (value.isDouble()) {
lineStyle = (Qt::PenStyle)value.toInt();
qDebug() << "lineStyle:" << QString::number(lineStyle);
}
}
//
if (lineObjInfo.contains("lineColorRed"))
{
QJsonValue value = lineObjInfo.value("lineColorRed");
if (value.isDouble()) {
lineColor.setRed(value.toInt());
qDebug() << "lineColorRed:" << QString::number(value.toInt());
}
}
//
if (lineObjInfo.contains("lineColorGreen"))
{
QJsonValue value = lineObjInfo.value("lineColorGreen");
if (value.isDouble()) {
lineColor.setGreen(value.toInt());
qDebug() << "lineColorGreen:" << QString::number(value.toInt());
}
}
//
if (lineObjInfo.contains("lineColorBlue"))
{
QJsonValue value = lineObjInfo.value("lineColorBlue");
if (value.isDouble()) {
lineColor.setBlue(value.toInt());
qDebug() << "lineColorBlue:" << QString::number(value.toInt());
}
}
//
if (lineObjInfo.contains("lineColorAlpha"))
{
QJsonValue value = lineObjInfo.value("lineColorAlpha");
if (value.isDouble()) {
lineColor.setAlpha(value.toInt());
qDebug() << "lineColorAlpha:" << QString::number(value.toInt());
}
}
if(strLineName!="")
{
//新建曲线
emit CallManage::getInstance()->sig_AddLine(strSlfName, strWellName, strTrackName, strLineName);
//emit CallManage::getInstance()->sig_AddLine(strSlfName, strWellName, strTrackName, strLineName);
emit CallManage::getInstance()->sig_AddLine_Property(strSlfName, strWellName, strTrackName, strLineName,
newLeftScale, newRightScale, lineColor, width, lineStyle);
}
}
@ -673,6 +738,7 @@ void MainWindowCurve::s_NewWell(QString strWellName)
ui->tableWidget_2->setRowHeight(i, (int)dHight);//8020
//
FormWell *widgetWell = new FormWell(this, strWellName);
widgetWell->m_strUuid = m_strUuid;
ui->tableWidget_2->setCellWidget(i, columnCount, widgetWell);
}
}

View File

@ -28,6 +28,7 @@ public slots:
void dropEvent(QDropEvent* event);
public:
QString m_strUuid;
QStringList m_listWell;
@ -67,7 +68,7 @@ public slots:
void s_NewTrack();//新建道
//
void s_Save();//保存
void s_Open();//打开
void s_Open(QString fileFull);//打开
};
#endif // MAINWINDOWCURVE_H

View File

@ -29,6 +29,7 @@ private:
QPoint startPos;
public:
QString m_strUuid;
QString m_strWellName;
QString m_strTrackName;
bool m_press;//判断鼠标是否按下

View File

@ -1,6 +1,7 @@
#include "qmycustomplot.h"
#include "CallManage.h"
#include "geometryutils.h"
#include "TransparentDraggableRect.h"
QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName) :
QCustomPlot(parent)
@ -103,10 +104,23 @@ void QMyCustomPlot::onAddRect()
double right_Hight = xAxis->pixelToCoord(m_event->pos().y());//x轴展示深度
double left_Low = right_Hight-5;
//添加图形
emit CallManage::getInstance()->sig_addImageToPlot(this, left_Low, right_Hight, ":/image/file.png");
//emit CallManage::getInstance()->sig_addImageToPlot(this, left_Low, right_Hight, ":/image/file.png");
addImageToPlot(left_Low, right_Hight, ":/image/file.png");
}
void QMyCustomPlot::addImageToPlot(double left_Low, double right_Hight, const QString imagePath)
{
// 在初始化代码中
TransparentDraggableRect *dragRect = new TransparentDraggableRect(this);
// 设置初始范围
dragRect->setRange(left_Low, right_Hight);
// 可选:设置颜色
dragRect->setColor(QColor(255, 100, 100, 80)); // 半透明红色
//最小宽度
dragRect->setMinWidth(5);
}
void QMyCustomPlot::onResetZoom()
{

View File

@ -20,6 +20,7 @@ protected:
virtual void mouseMoveEvent(QMouseEvent *event);
public:
QString m_strUuid;
QString m_strSlfName;
QString m_strWellName;
QString m_strTrackName;
@ -43,6 +44,7 @@ public:
bool m_bDrawRect = true;
public:
void init(QString strName, QVector<double> x, QVector<double> y);
void addImageToPlot(double left_Low, double right_Hight, const QString imagePath);
public slots:
void s_LineClicked(int index);