1.曲线类型支持对数曲线 2.支持右填充 3.图头支持从excel复制粘贴
This commit is contained in:
parent
aa88e2dd1d
commit
d9afdd2a05
|
|
@ -49,6 +49,8 @@ signals:
|
|||
void sig_ChangeLeftScale(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, double newLeftScale);
|
||||
//右刻度
|
||||
void sig_ChangeRightScale(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, double newRightScale);
|
||||
//刻度类型
|
||||
void sig_ChangeScaleType(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strScaleType);
|
||||
|
||||
//线颜色
|
||||
void sig_ChangeLineColor(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QColor lineColor);
|
||||
|
|
@ -61,7 +63,7 @@ signals:
|
|||
//岩性填充-填充
|
||||
void sig_ChangeFillMode(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName,
|
||||
QString newFillType, QString newTargetLine, QColor newColor, QString newLithosImage, QString newHeadFill,
|
||||
float vMin, float vMax, QColor frontColor, QColor backColor);
|
||||
float vMin, float vMax, QColor frontColor, QColor backColor, QString newFillMode);
|
||||
//置顶层
|
||||
void sig_Raise(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName);
|
||||
|
||||
|
|
|
|||
|
|
@ -121,6 +121,16 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
|
|||
ChangFillProperty();
|
||||
}
|
||||
}
|
||||
else if("刻度类型" == m_propertyData[pProperty])
|
||||
{
|
||||
qDebug() << "刻度类型->改变";
|
||||
//当前属性类型
|
||||
if(m_strCurrentProperty == Curve_Property)
|
||||
{
|
||||
QString newScaleType = pProperty->valueText();
|
||||
emit CallManage::getInstance()->sig_ChangeScaleType(m_strSlfName, m_strWellName, m_strTrackName, m_strLineName, newScaleType);
|
||||
}
|
||||
}
|
||||
else if("颜色" == m_propertyData[pProperty])
|
||||
{
|
||||
qDebug() << "颜色->改变";
|
||||
|
|
@ -365,11 +375,11 @@ void PropertyWidget::ChangFillProperty()
|
|||
{
|
||||
emit CallManage::getInstance()->sig_ClearFillMode(m_strSlfName, m_strWellName, m_strTrackName, m_strLineName);
|
||||
}
|
||||
else if(newFillMode=="填充")
|
||||
else //if(newFillMode=="填充")
|
||||
{
|
||||
emit CallManage::getInstance()->sig_ChangeFillMode(m_strSlfName, m_strWellName, m_strTrackName, m_strLineName,
|
||||
newFillType, newTargetLine, newColor, newLithosImage, newHeadFill,
|
||||
vMin, vMax, frontColor, backColor);
|
||||
vMin, vMax, frontColor, backColor, newFillMode);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -525,8 +535,13 @@ void PropertyWidget::initCurveProperty(FormInfo *formInfo, QStringList strListOt
|
|||
//
|
||||
QStringList listFillMode;
|
||||
listFillMode.append("无填充");
|
||||
listFillMode.append("填充");
|
||||
|
||||
listFillMode.append("左填充");
|
||||
listFillMode.append("右填充");
|
||||
listFillMode.append("左右填充");
|
||||
//
|
||||
QStringList listScaleType;
|
||||
listScaleType.append("线性");
|
||||
listScaleType.append("对数");
|
||||
|
||||
//
|
||||
_CreateVariantPropertyItem("通常", "井曲线", strLineName + "@"+strSlfName, QVariant::String);
|
||||
|
|
@ -535,6 +550,7 @@ void PropertyWidget::initCurveProperty(FormInfo *formInfo, QStringList strListOt
|
|||
//
|
||||
_CreateVariantPropertyItem("刻度设置", "左刻度", vmin, QVariant::Double);
|
||||
_CreateVariantPropertyItem("刻度设置", "右刻度", vmax, QVariant::Double);
|
||||
_CreateEnumPropertyItem("刻度设置", "刻度类型", 0, listScaleType);
|
||||
//
|
||||
_CreateVariantPropertyItem("曲线线型", "线宽", dWidth, QVariant::Double, 1, 20);
|
||||
_CreateVariantPropertyItem("曲线线型", "颜色", lineColor, QVariant::Color);
|
||||
|
|
|
|||
|
|
@ -377,40 +377,40 @@ void FormDraw::s_handleRectRangeChange(QCPRange newRange)
|
|||
|
||||
void FormDraw::setupLineStyleDemo(QMyCustomPlot *customPlot)
|
||||
{
|
||||
customPlot->legend->setVisible(true);
|
||||
customPlot->legend->setFont(QFont("Helvetica", 9));
|
||||
QPen pen;
|
||||
QStringList lineNames;
|
||||
lineNames << "lsNone" << "lsLine" << "lsStepLeft" << "lsStepRight" << "lsStepCenter" << "lsImpulse";
|
||||
// customPlot->legend->setVisible(true);
|
||||
// customPlot->legend->setFont(QFont("Helvetica", 9));
|
||||
// QPen pen;
|
||||
// QStringList lineNames;
|
||||
// lineNames << "lsNone" << "lsLine" << "lsStepLeft" << "lsStepRight" << "lsStepCenter" << "lsImpulse";
|
||||
|
||||
for (int i = QCPGraph::lsNone; i <= QCPGraph::lsImpulse; ++i)
|
||||
{
|
||||
customPlot->addGraph();
|
||||
pen.setColor(QColor(qSin(i*1+1.2)*80+80, qSin(i*0.3+0)*80+80, qSin(i*0.3+1.5)*80+80));
|
||||
customPlot->graph()->setPen(pen); // 设置图表的画笔
|
||||
customPlot->graph()->setName(lineNames.at(i-QCPGraph::lsNone));
|
||||
customPlot->graph()->setLineStyle((QCPGraph::LineStyle)i); // 设置图表线段的风格
|
||||
customPlot->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, 5)); // 设置图表散点图的样式
|
||||
// for (int i = QCPGraph::lsNone; i <= QCPGraph::lsImpulse; ++i)
|
||||
// {
|
||||
// customPlot->addGraph();
|
||||
// pen.setColor(QColor(qSin(i*1+1.2)*80+80, qSin(i*0.3+0)*80+80, qSin(i*0.3+1.5)*80+80));
|
||||
// customPlot->graph()->setPen(pen); // 设置图表的画笔
|
||||
// customPlot->graph()->setName(lineNames.at(i-QCPGraph::lsNone));
|
||||
// customPlot->graph()->setLineStyle((QCPGraph::LineStyle)i); // 设置图表线段的风格
|
||||
// customPlot->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, 5)); // 设置图表散点图的样式
|
||||
|
||||
QVector<double> x(15), y(15);
|
||||
for (int j=0; j<15; ++j)
|
||||
{
|
||||
x[j] = j/15.0 * 5*3.14 + 0.01;
|
||||
y[j] = 7*qSin(x[j])/x[j] - (i-QCPGraph::lsNone)*5 + (QCPGraph::lsImpulse)*5 + 2;
|
||||
}
|
||||
customPlot->graph()->setData(x, y);
|
||||
customPlot->graph()->rescaleAxes(true);
|
||||
}
|
||||
// 放大一点
|
||||
customPlot->yAxis->scaleRange(1.1, customPlot->yAxis->range().center());
|
||||
customPlot->xAxis->scaleRange(1.1, customPlot->xAxis->range().center());
|
||||
// QVector<double> x(15), y(15);
|
||||
// for (int j=0; j<15; ++j)
|
||||
// {
|
||||
// x[j] = j/15.0 * 5*3.14 + 0.01;
|
||||
// y[j] = 7*qSin(x[j])/x[j] - (i-QCPGraph::lsNone)*5 + (QCPGraph::lsImpulse)*5 + 2;
|
||||
// }
|
||||
// customPlot->graph()->setData(x, y);
|
||||
// customPlot->graph()->rescaleAxes(true);
|
||||
// }
|
||||
// // 放大一点
|
||||
// customPlot->yAxis->scaleRange(1.1, customPlot->yAxis->range().center());
|
||||
// customPlot->xAxis->scaleRange(1.1, customPlot->xAxis->range().center());
|
||||
|
||||
customPlot->xAxis->setTicks(true);
|
||||
customPlot->yAxis->setTicks(true);
|
||||
customPlot->xAxis->setTickLabels(true);
|
||||
customPlot->yAxis->setTickLabels(true);
|
||||
// customPlot->xAxis->setTicks(true);
|
||||
// customPlot->yAxis->setTicks(true);
|
||||
// customPlot->xAxis->setTickLabels(true);
|
||||
// customPlot->yAxis->setTickLabels(true);
|
||||
|
||||
customPlot->axisRect()->setupFullAxesBox();
|
||||
// customPlot->axisRect()->setupFullAxesBox();
|
||||
}
|
||||
|
||||
void FormDraw::setupSelectionDemo(QMyCustomPlot *customPlot)
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ FormInfo::FormInfo(QWidget *parent, QString strSlfName, QString strWellName, QSt
|
|||
connect(CallManage::getInstance(), SIGNAL(sig_ChangeLeftScale(QString, QString, QString, QString, double)), this, SLOT(s_ChangeLeftScale(QString, QString, QString, QString, double)));
|
||||
//右刻度
|
||||
connect(CallManage::getInstance(), SIGNAL(sig_ChangeRightScale(QString, QString, QString, QString, double)), this, SLOT(s_ChangeRightScale(QString, QString, QString, QString, double)));
|
||||
//刻度类型
|
||||
connect(CallManage::getInstance(), SIGNAL(sig_ChangeScaleType(QString, QString, QString, QString, QString)), this, SLOT(s_ChangeScaleType(QString, QString, QString, QString, QString)));
|
||||
|
||||
//颜色
|
||||
connect(CallManage::getInstance(), SIGNAL(sig_ChangeLineColor(QString, QString, QString, QString, QColor)), this, SLOT(s_ChangeLineColor(QString, QString, QString, QString, QColor)));
|
||||
|
|
@ -49,8 +51,8 @@ FormInfo::FormInfo(QWidget *parent, QString strSlfName, QString strWellName, QSt
|
|||
//岩性填充-不填充
|
||||
connect(CallManage::getInstance(), SIGNAL(sig_ClearFillMode(QString, QString, QString, QString)), this, SLOT(s_ClearFillMode(QString, QString, QString, QString)));
|
||||
//岩性填充-填充
|
||||
connect(CallManage::getInstance(), SIGNAL(sig_ChangeFillMode(QString, QString, QString, QString, QString, QString, QColor, QString, QString, float, float, QColor, QColor)),
|
||||
this, SLOT(s_ChangeFillMode(QString, QString, QString, QString, QString, QString, QColor, QString, QString, float, float, QColor, QColor)));
|
||||
connect(CallManage::getInstance(), SIGNAL(sig_ChangeFillMode(QString, QString, QString, QString, QString, QString, QColor, QString, QString, float, float, QColor, QColor, QString)),
|
||||
this, SLOT(s_ChangeFillMode(QString, QString, QString, QString, QString, QString, QColor, QString, QString, float, float, QColor, QColor, QString)));
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -101,7 +103,7 @@ void FormInfo::paintEvent(QPaintEvent* event)
|
|||
{
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
}
|
||||
else if(m_newFillMode=="填充" && m_newHeadFill == "绘制")
|
||||
else //if(m_newFillMode=="填充" && m_newHeadFill == "绘制")
|
||||
{
|
||||
if(m_newFillType == "岩性模式")
|
||||
{
|
||||
|
|
@ -320,6 +322,18 @@ void FormInfo::s_ChangeRightScale(QString strSlfName, QString strWellName, QStri
|
|||
}
|
||||
}
|
||||
|
||||
//属性-刻度类型
|
||||
void FormInfo::s_ChangeScaleType(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strScaleType)
|
||||
{
|
||||
if(m_strSlfName == strSlfName &&
|
||||
m_strWellName == strWellName &&
|
||||
m_strTrackName == strTrackName &&
|
||||
m_strLineName == strLineName)
|
||||
{
|
||||
m_strScaleType = strScaleType;
|
||||
}
|
||||
}
|
||||
|
||||
//属性-颜色
|
||||
void FormInfo::s_ChangeLineColor(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QColor lineColor)
|
||||
{
|
||||
|
|
@ -375,14 +389,14 @@ void FormInfo::s_ClearFillMode(QString strSlfName, QString strWellName, QString
|
|||
//岩性填充-填充
|
||||
void FormInfo::s_ChangeFillMode(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName,
|
||||
QString newFillType, QString newTargetLine, QColor newColor, QString newLithosImage, QString newHeadFill,
|
||||
float vMin, float vMax, QColor frontColor, QColor backColor)
|
||||
float vMin, float vMax, QColor frontColor, QColor backColor, QString newFillMode)
|
||||
{
|
||||
if(m_strSlfName == strSlfName &&
|
||||
m_strWellName == strWellName &&
|
||||
m_strTrackName == strTrackName &&
|
||||
m_strLineName == strLineName)
|
||||
{
|
||||
m_newFillMode = "填充";
|
||||
m_newFillMode = newFillMode;//"填充";
|
||||
m_newHeadFill = newHeadFill;
|
||||
m_newFillType = newFillType;
|
||||
m_newColor = newColor;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@ public slots:
|
|||
void s_ChangeLeftScale(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, double newLeftScale);
|
||||
//右刻度
|
||||
void s_ChangeRightScale(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, double newRightScale);
|
||||
//刻度类型
|
||||
void s_ChangeScaleType(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strScaleType);
|
||||
|
||||
//线颜色
|
||||
void s_ChangeLineColor(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QColor lineColor);
|
||||
//线宽
|
||||
|
|
@ -49,7 +52,7 @@ public slots:
|
|||
//岩性填充-填充
|
||||
void s_ChangeFillMode(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName,
|
||||
QString newFillType, QString newTargetLine, QColor newColor, QString newLithosImage, QString newHeadFill,
|
||||
float vMin, float vMax, QColor frontColor, QColor backColor);
|
||||
float vMin, float vMax, QColor frontColor, QColor backColor, QString newFillMode);
|
||||
|
||||
public:
|
||||
QString m_strUuid;
|
||||
|
|
@ -64,6 +67,7 @@ public:
|
|||
//X坐标
|
||||
float m_vmax;
|
||||
float m_vmin;
|
||||
QString m_strScaleType;//刻度类型(线性,对数)
|
||||
|
||||
//岩性填充
|
||||
QString m_newFillMode;
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ SOURCES += \
|
|||
mainwindowcurve.cpp \
|
||||
mainwindownew.cpp \
|
||||
mycustomplot.cpp \
|
||||
newheaddialog.cpp \
|
||||
preqtablewidget.cpp \
|
||||
qmycustomplot.cpp \
|
||||
qmytablewidget.cpp \
|
||||
|
|
@ -86,6 +87,7 @@ HEADERS += \
|
|||
mainwindowcurve.h \
|
||||
mainwindownew.h \
|
||||
mycustomplot.h \
|
||||
newheaddialog.h \
|
||||
preqtablewidget.h \
|
||||
qmycustomplot.h \
|
||||
qmytablewidget.h \
|
||||
|
|
@ -110,6 +112,7 @@ FORMS += \
|
|||
mainwindow.ui \
|
||||
mainwindowcurve.ui \
|
||||
mainwindownew.ui \
|
||||
newheaddialog.ui \
|
||||
qtcenterwidgets.ui \
|
||||
qtprojectwidgets.ui
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include "qtcommonclass.h"
|
||||
#include <QFuture>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
#include "newheaddialog.h"
|
||||
|
||||
extern int g_iOneWidth; //道宽
|
||||
extern QString g_prjname;
|
||||
|
|
@ -16,6 +17,9 @@ extern int g_iY2;
|
|||
extern double g_dPixelPerCm;//每厘米像素数
|
||||
extern int g_iScale;
|
||||
|
||||
extern int g_iRows;
|
||||
extern int g_iCols;
|
||||
|
||||
MainWindowCurve::MainWindowCurve(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindowCurve)
|
||||
|
|
@ -35,14 +39,18 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) :
|
|||
//加载样式
|
||||
loadStyle(":/qrc/qss/flatgray.css");
|
||||
|
||||
//-------------------------------------
|
||||
ui->tableWidget->hide();
|
||||
ui->tableWidget_3->hide();
|
||||
//
|
||||
//
|
||||
ui->tableWidget->verticalHeader()->hide();
|
||||
ui->tableWidget->horizontalHeader()->hide();
|
||||
// 设置右键菜单策略
|
||||
ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenu(QPoint)));
|
||||
// 在窗口构造函数中
|
||||
//ui->tableWidget->installEventFilter(this);
|
||||
|
||||
//
|
||||
//-------------------------------------
|
||||
//ui->tableWidget_2->setFrameShape(QFrame::NoFrame); //设置无边框
|
||||
//隐藏网格线
|
||||
ui->tableWidget_2->setShowGrid(false);
|
||||
|
|
@ -66,7 +74,8 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) :
|
|||
// list << "" << "" << "" << "";
|
||||
// ui->tableWidget->setHorizontalHeaderLabels(list);
|
||||
|
||||
////
|
||||
//-------------------------------------
|
||||
ui->tableWidget_3->hide();
|
||||
ui->tableWidget_3->verticalHeader()->hide();
|
||||
ui->tableWidget_3->horizontalHeader()->hide();
|
||||
|
||||
|
|
@ -106,7 +115,7 @@ void MainWindowCurve::initMainToolBar()
|
|||
|
||||
m_saveAc = 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);
|
||||
|
|
@ -125,6 +134,7 @@ void MainWindowCurve::initMainToolBar()
|
|||
|
||||
connect(m_saveAc, &QAction::triggered, this, &MainWindowCurve::s_Save);
|
||||
//connect(m_openAc, &QAction::triggered, this, &MainWindowCurve::s_Open);
|
||||
connect(m_grepAc, &QAction::triggered, this, &MainWindowCurve::s_showHeadTable);
|
||||
|
||||
// connect(m_grepAc, &QAction::triggered, this, &MainWindow::s_Risize);
|
||||
// connect(m_compileAc, &QAction::triggered, this, &MainWindow::s_AddOne);
|
||||
|
|
@ -246,6 +256,18 @@ void MainWindowCurve::s_Open(QString fileFull)
|
|||
|
||||
}
|
||||
|
||||
//显示/隐藏图头
|
||||
void MainWindowCurve::s_showHeadTable()
|
||||
{
|
||||
if(ui->tableWidget->isVisible())
|
||||
{
|
||||
ui->tableWidget->hide();
|
||||
}
|
||||
else {
|
||||
ui->tableWidget->show();
|
||||
}
|
||||
}
|
||||
|
||||
QJsonObject MainWindowCurve::makeJson()
|
||||
{
|
||||
// 创建根对象
|
||||
|
|
@ -322,7 +344,7 @@ void MainWindowCurve::s_NewWell(QString strWellName)
|
|||
if(i==0)
|
||||
{
|
||||
//设置高度
|
||||
ui->tableWidget->setRowHeight(i, 100);
|
||||
ui->tableWidget_2->setRowHeight(i, 100);
|
||||
//
|
||||
QTableWidgetItem* item = new QTableWidgetItem(strWellName);
|
||||
item->setFlags(item->flags() & (~Qt::ItemIsEditable));
|
||||
|
|
@ -466,13 +488,13 @@ void MainWindowCurve::dragEnterEvent(QDragEnterEvent* event)
|
|||
else
|
||||
{
|
||||
event->ignore();
|
||||
QApplication::setOverrideCursor(Qt::ForbiddenCursor); // 设置鼠标为不可添加状态
|
||||
//QApplication::setOverrideCursor(Qt::ForbiddenCursor); // 设置鼠标为不可添加状态
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindowCurve::dragMoveEvent(QDragMoveEvent* event)
|
||||
{
|
||||
qDebug() << "MainWindowCurve dragMoveEvent";
|
||||
//qDebug() << "MainWindowCurve dragMoveEvent";
|
||||
|
||||
// 可以在这里更新鼠标的位置,根据位置判断是否可以放置
|
||||
// ...
|
||||
|
|
@ -518,3 +540,294 @@ void MainWindowCurve::dropEvent(QDropEvent* event)
|
|||
// 恢复鼠标光标
|
||||
//QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
|
||||
void MainWindowCurve::slotContextMenu(QPoint pos)
|
||||
{
|
||||
if(ui->tableWidget->rowCount()==0 && ui->tableWidget->rowCount()==0)
|
||||
{
|
||||
QMenu menu(ui->tableWidget);
|
||||
QAction *newAction = menu.addAction("新建图头");
|
||||
// 弹出菜单
|
||||
QAction *selectedAction = menu.exec(ui->tableWidget->mapToGlobal(pos));
|
||||
if (selectedAction == newAction) {
|
||||
NewHeadDialog *dlg = new NewHeadDialog(this);
|
||||
//
|
||||
dlg->setAttribute(Qt::WA_DeleteOnClose);//关闭时,自动删除窗口对象
|
||||
int result = dlg->exec();//模态对话框
|
||||
if (result == QDialog::Accepted) {
|
||||
// 处理用户点击了确定按钮的逻辑
|
||||
qDebug() << "Accepted=";
|
||||
//
|
||||
ui->tableWidget->clear();
|
||||
//
|
||||
ui->tableWidget->setColumnCount(g_iCols);
|
||||
ui->tableWidget->setRowCount(g_iRows); //动态设置行数
|
||||
for(int i=0; i<g_iRows; i++)
|
||||
{
|
||||
for(int j=0; j<g_iCols; j++)
|
||||
{
|
||||
QTableWidgetItem* item = new QTableWidgetItem("");
|
||||
ui->tableWidget->setItem(i, j, item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (result == QDialog::Rejected) {
|
||||
// 处理用户点击了取消按钮的逻辑
|
||||
qDebug() << "Rejected=";
|
||||
}
|
||||
else {
|
||||
// 处理其他情况的逻辑
|
||||
qDebug() << "other=";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QMenu menu(ui->tableWidget);
|
||||
QAction *mergeAction = menu.addAction("合并表格");
|
||||
QAction *refreshAction = menu.addAction("拆分表格");
|
||||
QAction *deleteAction = menu.addAction("删除行");
|
||||
QAction *addAction = menu.addAction("添加行");
|
||||
|
||||
// 弹出菜单
|
||||
QAction *selectedAction = menu.exec(ui->tableWidget->mapToGlobal(pos));
|
||||
|
||||
if (selectedAction == mergeAction) {
|
||||
qDebug() << "合并表格";
|
||||
slotMerge();
|
||||
} else if (selectedAction == deleteAction) {
|
||||
//删除1行
|
||||
int row = ui->tableWidget->currentRow();
|
||||
ui->tableWidget->removeRow(row);
|
||||
} else if (selectedAction == refreshAction) {
|
||||
qDebug() << "拆分表格";
|
||||
slotSplit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//合并
|
||||
void MainWindowCurve::slotMerge()
|
||||
{
|
||||
QModelIndexList list = ui->tableWidget->selectionModel()->selectedIndexes();
|
||||
if (list.size() < 2)
|
||||
{
|
||||
QMessageBox::warning(this, "单元格合并", "所选中单元格中为单个单元格,无法合并", "确定");
|
||||
return;
|
||||
}
|
||||
|
||||
int topRow = 0;
|
||||
int leftCol = 0;
|
||||
int bottomRow = 0;
|
||||
int rightCol = 0;
|
||||
|
||||
QList<QTableWidgetSelectionRange> selectRanges = ui->tableWidget->selectedRanges();
|
||||
|
||||
if (selectRanges.size() > 0)
|
||||
{
|
||||
topRow = selectRanges[0].topRow();
|
||||
leftCol = selectRanges[0].leftColumn();
|
||||
bottomRow = selectRanges[0].bottomRow();
|
||||
rightCol = selectRanges[0].rightColumn();
|
||||
}
|
||||
for(auto range:selectRanges)
|
||||
{
|
||||
if(range.topRow()<topRow)
|
||||
topRow=range.topRow();
|
||||
if(range.leftColumn()<leftCol)
|
||||
leftCol=range.leftColumn();
|
||||
if(range.bottomRow()> bottomRow)
|
||||
bottomRow=range.bottomRow();
|
||||
if(range.rightColumn()>rightCol)
|
||||
rightCol=range.rightColumn();
|
||||
}
|
||||
|
||||
int rowSpan = (bottomRow - topRow) + 1;
|
||||
int colSpan = (rightCol - leftCol) + 1;
|
||||
ui->tableWidget->setSpan(topRow, leftCol, rowSpan, colSpan);
|
||||
}
|
||||
|
||||
|
||||
//拆分
|
||||
void MainWindowCurve::slotSplit()
|
||||
{
|
||||
int row,col;
|
||||
QList<QTableWidgetSelectionRange> selectRanges = ui->tableWidget->selectedRanges();
|
||||
if (selectRanges.size() < 2)
|
||||
{
|
||||
QMessageBox::warning(this, "拆分表格失败", "单元格已是最小单位,不能再进行拆分", "确定");
|
||||
return;
|
||||
}
|
||||
QList<QTableWidgetItem*> selectItems = ui->tableWidget->selectedItems();
|
||||
if(selectItems.size()==0)
|
||||
{
|
||||
QMessageBox::warning(this, "拆分表格失败", "请先为表格设置元素item", "确定");
|
||||
return;
|
||||
}
|
||||
if(selectItems.size()>1)
|
||||
{
|
||||
QMessageBox::warning(this, "拆分表格失败", "非法选择", "确定");
|
||||
return;
|
||||
}
|
||||
for(auto item:selectItems)
|
||||
{
|
||||
row= item->row();
|
||||
col=item->column();
|
||||
}
|
||||
|
||||
ui->tableWidget->setSpan(row, col, 1, 1); // 设置跨度为1
|
||||
}
|
||||
|
||||
bool MainWindowCurve::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
if (obj == ui->tableWidget && event->type() == QEvent::KeyPress) {
|
||||
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
|
||||
if (keyEvent->matches(QKeySequence::Paste)) {
|
||||
onPasteExcelData();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return QMainWindow::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
//复制粘贴事件
|
||||
void MainWindowCurve::keyPressEvent(QKeyEvent * event)
|
||||
{
|
||||
//excel 行分是 "\n" ; 列分是 "\t"
|
||||
if (event->matches(QKeySequence::Copy))
|
||||
{
|
||||
copy();
|
||||
}
|
||||
else if (event->matches(QKeySequence::Paste))
|
||||
{
|
||||
Paste();
|
||||
}
|
||||
else if (event->matches(QKeySequence::SelectAll))
|
||||
{
|
||||
ui->tableWidget->selectAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
QWidget::keyPressEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindowCurve::copy()
|
||||
{
|
||||
QMap<int, QList<int>> selMap;//行,列
|
||||
QList<QTableWidgetItem*> list = ui->tableWidget->selectedItems();
|
||||
if (list.count() <= 0)
|
||||
return;
|
||||
for (QTableWidgetItem* item : list)
|
||||
{
|
||||
int rowN = ui->tableWidget->row(item);
|
||||
int colN = ui->tableWidget->column(item);
|
||||
selMap[rowN].append(colN);
|
||||
}
|
||||
QString cpStr;
|
||||
QMap<int, QList<int>>::iterator it = selMap.begin();
|
||||
while (it != selMap.end())
|
||||
{
|
||||
for (int i = 0; i < (*it).count(); i++)
|
||||
{
|
||||
QTableWidgetItem* item = ui->tableWidget->item(it.key(), (*it).at(i));
|
||||
if (item)
|
||||
{
|
||||
cpStr.append(item->text().trimmed());
|
||||
}
|
||||
if (i != (*it).count() - 1)
|
||||
cpStr.append("\t");
|
||||
}
|
||||
it++;
|
||||
if (it != selMap.end())
|
||||
{
|
||||
cpStr.append("\n");
|
||||
}
|
||||
}
|
||||
QApplication::clipboard()->setText(cpStr);
|
||||
}
|
||||
|
||||
void MainWindowCurve::Paste()
|
||||
{
|
||||
QString pastText = QApplication::clipboard()->text();
|
||||
QStringList rowList = pastText.split("\n", QString::KeepEmptyParts);
|
||||
if(rowList.size()==0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(rowList.at(rowList.size()-1)=="")
|
||||
{
|
||||
rowList.removeAt(rowList.size()-1);
|
||||
}
|
||||
QTableWidgetItem* crtItem = ui->tableWidget->currentItem();
|
||||
int rowN, colN;
|
||||
if (!crtItem)
|
||||
{
|
||||
rowN = ui->tableWidget->currentRow();
|
||||
colN = ui->tableWidget->currentColumn();
|
||||
}
|
||||
else
|
||||
{
|
||||
rowN = ui->tableWidget->row(crtItem);
|
||||
colN = ui->tableWidget->column(crtItem);
|
||||
}
|
||||
for (int i = 0; i < (ui->tableWidget->rowCount() - rowN) && (i < rowList.length()); i++)
|
||||
{
|
||||
QStringList rowDataList = rowList.at(i).split("\t", QString::KeepEmptyParts);
|
||||
for (int j = 0; j < (ui->tableWidget->columnCount() - colN) && (j < rowDataList.length()); j++)
|
||||
{
|
||||
int x = i + rowN;
|
||||
int y = j + colN;
|
||||
|
||||
QTableWidgetItem* item = ui->tableWidget->item(x, y);
|
||||
if (item)
|
||||
{
|
||||
item->setText(rowDataList.at(j));
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->tableWidget->setItem(x, y, new QTableWidgetItem(rowDataList.at(j)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindowCurve::onPasteExcelData()
|
||||
{
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
const QString clipData = clipboard->text();
|
||||
|
||||
if (clipData.isEmpty()) return;
|
||||
|
||||
QList<QStringList> rowsData;
|
||||
const QStringList rows = clipData.split('\n', QString::SkipEmptyParts);
|
||||
for (const QString row:rows) {
|
||||
rowsData << row.split('\t', QString::SkipEmptyParts);
|
||||
}
|
||||
|
||||
QTableWidget* table = ui->tableWidget;
|
||||
const QModelIndex currentIndex = table->currentIndex();
|
||||
const int startRow = currentIndex.isValid() ? currentIndex.row() : 0;
|
||||
const int startCol = currentIndex.isValid() ? currentIndex.column() : 0;
|
||||
|
||||
table->setUpdatesEnabled(false);
|
||||
table->setRowCount(std::max(table->rowCount(), startRow + rowsData.size()));
|
||||
table->setColumnCount(std::max(table->columnCount(), startCol + rowsData[0].size()));
|
||||
|
||||
for (int i = 0; i < rowsData.size(); ++i) {
|
||||
for (int j = 0; j < rowsData[i].size(); ++j) {
|
||||
if (startRow + i >= table->rowCount()) break;
|
||||
if (startCol + j >= table->columnCount()) break;
|
||||
|
||||
QTableWidgetItem* item = table->item(startRow + i, startCol + j);
|
||||
if (!item) {
|
||||
item = new QTableWidgetItem();
|
||||
table->setItem(startRow + i, startCol + j, item);
|
||||
}
|
||||
item->setText(rowsData[i][j]);
|
||||
}
|
||||
}
|
||||
table->setUpdatesEnabled(true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,11 +22,22 @@ public:
|
|||
private:
|
||||
Ui::MainWindowCurve *ui;
|
||||
|
||||
protected:
|
||||
//支持复制粘贴,暂时还未实现
|
||||
void keyPressEvent(QKeyEvent * e);
|
||||
|
||||
public:
|
||||
//图头
|
||||
bool eventFilter(QObject* obj, QEvent* event);
|
||||
void onPasteExcelData();
|
||||
|
||||
public slots:
|
||||
void dragEnterEvent(QDragEnterEvent* event);
|
||||
void dragMoveEvent(QDragMoveEvent* event);
|
||||
void dropEvent(QDropEvent* event);
|
||||
|
||||
//图头
|
||||
void copy();
|
||||
void Paste();
|
||||
public:
|
||||
QString m_strUuid;
|
||||
QStringList m_listWell;
|
||||
|
|
@ -62,6 +73,13 @@ public slots:
|
|||
//
|
||||
void s_Save();//保存
|
||||
void s_Open(QString fileFull);//打开
|
||||
|
||||
|
||||
void s_showHeadTable();//显示/隐藏图头
|
||||
//图头右键菜单响应函数
|
||||
void slotContextMenu(QPoint pos);
|
||||
void slotMerge();//合并
|
||||
void slotSplit();//拆分
|
||||
};
|
||||
|
||||
#endif // MAINWINDOWCURVE_H
|
||||
|
|
|
|||
|
|
@ -15,10 +15,14 @@
|
|||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<item row="0" column="1">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTableWidget" name="tableWidget"/>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0">
|
||||
<item>
|
||||
<widget class="QTableWidget" name="tableWidget"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="tableWidget_2"/>
|
||||
|
|
|
|||
34
logPlus/newheaddialog.cpp
Normal file
34
logPlus/newheaddialog.cpp
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#include "newheaddialog.h"
|
||||
#include "ui_newheaddialog.h"
|
||||
|
||||
int g_iRows=1;
|
||||
int g_iCols=1;
|
||||
|
||||
NewHeadDialog::NewHeadDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::NewHeadDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &NewHeadDialog::accepted_OK);
|
||||
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &NewHeadDialog::rejected_Cancel);
|
||||
}
|
||||
|
||||
NewHeadDialog::~NewHeadDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void NewHeadDialog::accepted_OK()
|
||||
{
|
||||
g_iRows = ui->spinBox->value();
|
||||
g_iCols = ui->spinBox_2->value();
|
||||
//
|
||||
accepted();
|
||||
}
|
||||
|
||||
void NewHeadDialog::rejected_Cancel()
|
||||
{
|
||||
reject();
|
||||
}
|
||||
26
logPlus/newheaddialog.h
Normal file
26
logPlus/newheaddialog.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef NEWHEADDIALOG_H
|
||||
#define NEWHEADDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class NewHeadDialog;
|
||||
}
|
||||
|
||||
class NewHeadDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NewHeadDialog(QWidget *parent = nullptr);
|
||||
~NewHeadDialog();
|
||||
|
||||
private:
|
||||
Ui::NewHeadDialog *ui;
|
||||
|
||||
public slots:
|
||||
void accepted_OK();
|
||||
void rejected_Cancel();
|
||||
};
|
||||
|
||||
#endif // NEWHEADDIALOG_H
|
||||
110
logPlus/newheaddialog.ui
Normal file
110
logPlus/newheaddialog.ui
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>NewHeadDialog</class>
|
||||
<widget class="QDialog" name="NewHeadDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>表格行数:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>表格列数:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_2">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>NewHeadDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>NewHeadDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
|
@ -30,6 +30,8 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel
|
|||
connect(CallManage::getInstance(), SIGNAL(sig_ChangeLeftScale(QString, QString, QString, QString, double)), this, SLOT(s_ChangeLeftScale(QString, QString, QString, QString, double)));
|
||||
//右刻度
|
||||
connect(CallManage::getInstance(), SIGNAL(sig_ChangeRightScale(QString, QString, QString, QString, double)), this, SLOT(s_ChangeRightScale(QString, QString, QString, QString, double)));
|
||||
//刻度类型
|
||||
connect(CallManage::getInstance(), SIGNAL(sig_ChangeScaleType(QString, QString, QString, QString, QString)), this, SLOT(s_ChangeScaleType(QString, QString, QString, QString, QString)));
|
||||
|
||||
connect(CallManage::getInstance(), SIGNAL(sig_Raise(QString, QString, QString, QString)), this, SLOT(s_Raise(QString, QString, QString, QString)));
|
||||
//颜色
|
||||
|
|
@ -41,8 +43,8 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel
|
|||
//岩性填充-不填充
|
||||
connect(CallManage::getInstance(), SIGNAL(sig_ClearFillMode(QString, QString, QString, QString)), this, SLOT(s_ClearFillMode(QString, QString, QString, QString)));
|
||||
//岩性填充-填充
|
||||
connect(CallManage::getInstance(), SIGNAL(sig_ChangeFillMode(QString, QString, QString, QString, QString, QString, QColor, QString, QString, float, float, QColor, QColor)),
|
||||
this, SLOT(s_ChangeFillMode(QString, QString, QString, QString, QString, QString, QColor, QString, QString, float, float, QColor, QColor)));
|
||||
connect(CallManage::getInstance(), SIGNAL(sig_ChangeFillMode(QString, QString, QString, QString, QString, QString, QColor, QString, QString, float, float, QColor, QColor, QString)),
|
||||
this, SLOT(s_ChangeFillMode(QString, QString, QString, QString, QString, QString, QColor, QString, QString, float, float, QColor, QColor, QString)));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -192,7 +194,7 @@ void QMyCustomPlot::s_ChangeLeftScale(QString strSlfName, QString strWellName, Q
|
|||
//其他曲线
|
||||
s_ChangeFillMode(m_strSlfName, m_strWellName, m_strTrackName, m_strLineName,
|
||||
m_newFillType, m_newTargetLine, m_newColor, m_newLithosImage, m_newHeadFill,
|
||||
newLeftScale, m_vMax, m_frontColor, m_backColor);
|
||||
newLeftScale, m_vMax, m_frontColor, m_backColor, m_newFillMode);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -217,7 +219,40 @@ void QMyCustomPlot::s_ChangeRightScale(QString strSlfName, QString strWellName,
|
|||
//其他曲线
|
||||
s_ChangeFillMode(m_strSlfName, m_strWellName, m_strTrackName, m_strLineName,
|
||||
m_newFillType, m_newTargetLine, m_newColor, m_newLithosImage, m_newHeadFill,
|
||||
m_vMin, newRightScale, m_frontColor, m_backColor);
|
||||
m_vMin, newRightScale, m_frontColor, m_backColor, m_newFillMode);
|
||||
}
|
||||
}
|
||||
|
||||
//属性-刻度类型
|
||||
void QMyCustomPlot::s_ChangeScaleType(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strScaleType)
|
||||
{
|
||||
if(m_strSlfName == strSlfName &&
|
||||
m_strWellName == strWellName &&
|
||||
m_strTrackName == strTrackName &&
|
||||
m_strLineName == strLineName)
|
||||
{
|
||||
m_strScaleType = strScaleType;
|
||||
|
||||
if(m_strScaleType=="线性")
|
||||
{
|
||||
yAxis->setScaleType(QCPAxis::stLinear);
|
||||
}
|
||||
else if(m_strScaleType=="对数")
|
||||
{
|
||||
yAxis->setScaleType(QCPAxis::stLogarithmic);
|
||||
}
|
||||
//
|
||||
replot();
|
||||
}
|
||||
else if(m_strSlfName == strSlfName &&
|
||||
m_strWellName == strWellName &&
|
||||
m_strTrackName == strTrackName &&
|
||||
m_newTargetLine == strLineName)
|
||||
{
|
||||
//其他曲线
|
||||
//s_ChangeFillMode(m_strSlfName, m_strWellName, m_strTrackName, m_strLineName,
|
||||
// m_newFillType, m_newTargetLine, m_newColor, m_newLithosImage, m_newHeadFill,
|
||||
// m_vMin, newRightScale, m_frontColor, m_backColor, m_newFillMode);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -291,7 +326,7 @@ void QMyCustomPlot::s_ClearFillMode(QString strSlfName, QString strWellName, QSt
|
|||
//岩性填充-填充
|
||||
void QMyCustomPlot::s_ChangeFillMode(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName,
|
||||
QString newFillType, QString newTargetLine, QColor newColor, QString newLithosImage, QString newHeadFill,
|
||||
float vMin, float vMax, QColor frontColor, QColor backColor)
|
||||
float vMin, float vMax, QColor frontColor, QColor backColor, QString newFillMode)
|
||||
{
|
||||
|
||||
if(m_strSlfName == strSlfName &&
|
||||
|
|
@ -309,6 +344,7 @@ void QMyCustomPlot::s_ChangeFillMode(QString strSlfName, QString strWellName, QS
|
|||
m_vMax = vMax;
|
||||
m_frontColor = frontColor;
|
||||
m_backColor = backColor;
|
||||
m_newFillMode = newFillMode;
|
||||
|
||||
//填充
|
||||
if(this->graphCount() > 1)
|
||||
|
|
@ -376,23 +412,280 @@ void QMyCustomPlot::s_ChangeFillMode(QString strSlfName, QString strWellName, QS
|
|||
}
|
||||
else
|
||||
{
|
||||
//其他曲线(左填充)
|
||||
CLogIO *logio=new CLogIO();
|
||||
logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead);
|
||||
if(newFillMode=="左填充")
|
||||
{
|
||||
//其他曲线(左填充)
|
||||
CLogIO *logio=new CLogIO();
|
||||
logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead);
|
||||
|
||||
//读取基线信息
|
||||
int indexBaseCurv = logio->OpenCurve(strLineName.toStdString().c_str());
|
||||
if(indexBaseCurv < 0) {
|
||||
this->addGraph();//空曲线
|
||||
delete logio;
|
||||
//读取基线信息
|
||||
int indexBaseCurv = logio->OpenCurve(strLineName.toStdString().c_str());
|
||||
if(indexBaseCurv < 0) {
|
||||
this->addGraph();//空曲线
|
||||
delete logio;
|
||||
}
|
||||
else
|
||||
{
|
||||
//其他曲线
|
||||
int index=logio->OpenCurve(newTargetLine.toStdString().c_str());
|
||||
if(index<0)
|
||||
{
|
||||
this->addGraph();//空曲线
|
||||
delete logio;
|
||||
}
|
||||
else
|
||||
{
|
||||
Slf_CURVE curveinfo;
|
||||
float *val;
|
||||
float sdep,edep,rlev;
|
||||
//
|
||||
logio->GetCurveInfo(index,&curveinfo);
|
||||
sdep=curveinfo.StartDepth;
|
||||
edep=curveinfo.EndDepth;
|
||||
rlev=curveinfo.DepLevel;
|
||||
//
|
||||
int count=(curveinfo.EndDepth-curveinfo.StartDepth)/curveinfo.DepLevel+1.5;
|
||||
val=new float[count];
|
||||
logio->ReadCurve(index,curveinfo.StartDepth,count,&val[0]);
|
||||
logio->CloseCurve(index);
|
||||
//读完基线再关闭
|
||||
// delete logio;
|
||||
|
||||
float newVal = 0.0;
|
||||
for(int i=0; i<count; i++)
|
||||
{
|
||||
float x0=-(sdep+ rlev*i);
|
||||
float y0_old=val[i];
|
||||
float y0 = (m_iX2-m_iX1)*(val[i]-vMin)/(vMax-vMin) + m_iX1;
|
||||
|
||||
//读取基线
|
||||
float BaseY0=0;
|
||||
logio->ReadCurve(indexBaseCurv, 0-x0, 1, &BaseY0);
|
||||
//
|
||||
if(i+1<count)
|
||||
{
|
||||
float x1=-(sdep+ rlev*(i+1));
|
||||
//float y1=val[i+1];
|
||||
float y1 = (m_iX2-m_iX1)*(val[i+1]-vMin)/(vMax-vMin) + m_iX1;
|
||||
//读取基线
|
||||
float BaseY1=0;
|
||||
logio->ReadCurve(indexBaseCurv, 0-x1, 1, &BaseY1);
|
||||
|
||||
if(BaseY0<=y0 && BaseY1<=y1)
|
||||
{
|
||||
//基线在左,采用基线值
|
||||
//y0=BaseY0;
|
||||
y0_old = (BaseY0-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
||||
//
|
||||
x.append(x0);
|
||||
y.append(y0_old);
|
||||
}
|
||||
else if(BaseY0>=y0 && BaseY1>=y1)
|
||||
{
|
||||
//基线在右,直接赋值
|
||||
x.append(x0);
|
||||
y.append(y0_old);
|
||||
}
|
||||
else if(BaseY0<=y0 && BaseY1>=y1)
|
||||
{
|
||||
//基线起点在左,采用基线值
|
||||
//y0=BaseY0;
|
||||
y0_old = (BaseY0-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
||||
//
|
||||
x.append(x0);
|
||||
y.append(y0_old);
|
||||
|
||||
//插值
|
||||
float xNew=x0-rlev*(y0-BaseY0)/(BaseY1-y1);
|
||||
float yNew=(y0-y1)/(x0-x1)*(xNew-x1) + y1;
|
||||
float yNew_Old=(yNew-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
||||
//
|
||||
x.append(xNew);
|
||||
y.append(yNew_Old);
|
||||
}
|
||||
else if(BaseY0>=y0 && BaseY1<=y1)
|
||||
{
|
||||
//基线在右,直接赋值
|
||||
x.append(x0);
|
||||
y.append(y0_old);
|
||||
|
||||
//插值
|
||||
float xNew=x0-rlev*(y0-BaseY0)/(BaseY1-y1);
|
||||
float yNew=(BaseY0-BaseY1)/(x0-x1)*(xNew-x1) + BaseY1;
|
||||
float yNew_Old=(yNew-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
||||
//
|
||||
x.append(xNew);
|
||||
y.append(yNew_Old);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//最后一个点
|
||||
if(BaseY0<y0)
|
||||
{
|
||||
//基线在左,采用基线值
|
||||
//y0=BaseY0;
|
||||
y0_old = (BaseY0-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
||||
}
|
||||
x.append(x0);
|
||||
y.append(y0_old);
|
||||
}
|
||||
|
||||
//newVal = (m_iX2-m_iX1)*(val[i]-vMin)/(vMax-vMin) + m_iX1;
|
||||
//newVal = val[i];
|
||||
//y.append(newVal);
|
||||
}
|
||||
logio->CloseCurve(indexBaseCurv);
|
||||
delete logio;
|
||||
//
|
||||
this->yAxis2->setRange(m_iY1, m_iY2);
|
||||
this->xAxis2->setRange(vMin, vMax);
|
||||
this->addGraph(yAxis2, xAxis2);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
else if(newFillMode=="右填充")
|
||||
{
|
||||
//其他曲线(右填充)
|
||||
CLogIO *logio=new CLogIO();
|
||||
logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead);
|
||||
|
||||
//读取基线信息
|
||||
int indexBaseCurv = logio->OpenCurve(strLineName.toStdString().c_str());
|
||||
if(indexBaseCurv < 0) {
|
||||
this->addGraph();//空曲线
|
||||
delete logio;
|
||||
}
|
||||
else
|
||||
{
|
||||
//其他曲线
|
||||
int index=logio->OpenCurve(newTargetLine.toStdString().c_str());
|
||||
if(index<0)
|
||||
{
|
||||
this->addGraph();//空曲线
|
||||
delete logio;
|
||||
}
|
||||
else
|
||||
{
|
||||
Slf_CURVE curveinfo;
|
||||
float *val;
|
||||
float sdep,edep,rlev;
|
||||
//
|
||||
logio->GetCurveInfo(index,&curveinfo);
|
||||
sdep=curveinfo.StartDepth;
|
||||
edep=curveinfo.EndDepth;
|
||||
rlev=curveinfo.DepLevel;
|
||||
//
|
||||
int count=(curveinfo.EndDepth-curveinfo.StartDepth)/curveinfo.DepLevel+1.5;
|
||||
val=new float[count];
|
||||
logio->ReadCurve(index,curveinfo.StartDepth,count,&val[0]);
|
||||
logio->CloseCurve(index);
|
||||
//读完基线再关闭
|
||||
// delete logio;
|
||||
|
||||
float newVal = 0.0;
|
||||
for(int i=0; i<count; i++)
|
||||
{
|
||||
float x0=-(sdep+ rlev*i);
|
||||
float y0_old=val[i];
|
||||
float y0 = (m_iX2-m_iX1)*(val[i]-vMin)/(vMax-vMin) + m_iX1;
|
||||
|
||||
//读取基线
|
||||
float BaseY0=0;
|
||||
logio->ReadCurve(indexBaseCurv, 0-x0, 1, &BaseY0);
|
||||
//
|
||||
if(i+1<count)
|
||||
{
|
||||
float x1=-(sdep+ rlev*(i+1));
|
||||
//float y1=val[i+1];
|
||||
float y1 = (m_iX2-m_iX1)*(val[i+1]-vMin)/(vMax-vMin) + m_iX1;
|
||||
//读取基线
|
||||
float BaseY1=0;
|
||||
logio->ReadCurve(indexBaseCurv, 0-x1, 1, &BaseY1);
|
||||
|
||||
if(BaseY0<=y0 && BaseY1<=y1)
|
||||
{
|
||||
//基线在左,直接赋值
|
||||
x.append(x0);
|
||||
y.append(y0_old);
|
||||
}
|
||||
else if(BaseY0>=y0 && BaseY1>=y1)
|
||||
{
|
||||
//基线在右,采用基线值
|
||||
//y0=BaseY0;
|
||||
y0_old = (BaseY0-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
||||
//
|
||||
x.append(x0);
|
||||
y.append(y0_old);
|
||||
}
|
||||
else if(BaseY0<=y0 && BaseY1>=y1)
|
||||
{
|
||||
//基线起点在左,直接赋值
|
||||
x.append(x0);
|
||||
y.append(y0_old);
|
||||
|
||||
//插值
|
||||
float xNew=x0-rlev*(y0-BaseY0)/(BaseY1-y1);
|
||||
float yNew=(y0-y1)/(x0-x1)*(xNew-x1) + y1;
|
||||
float yNew_Old=(yNew-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
||||
//
|
||||
x.append(xNew);
|
||||
y.append(yNew_Old);
|
||||
}
|
||||
else if(BaseY0>=y0 && BaseY1<=y1)
|
||||
{
|
||||
//基线在右,采用基线值
|
||||
//y0=BaseY0;
|
||||
y0_old = (BaseY0-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
||||
//
|
||||
x.append(x0);
|
||||
y.append(y0_old);
|
||||
|
||||
//插值
|
||||
float xNew=x0-rlev*(y0-BaseY0)/(BaseY1-y1);
|
||||
float yNew=(BaseY0-BaseY1)/(x0-x1)*(xNew-x1) + BaseY1;
|
||||
float yNew_Old=(yNew-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
||||
//
|
||||
x.append(xNew);
|
||||
y.append(yNew_Old);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//最后一个点
|
||||
if(BaseY0>y0)
|
||||
{
|
||||
//基线在右,采用基线值
|
||||
//y0=BaseY0;
|
||||
y0_old = (BaseY0-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
||||
}
|
||||
x.append(x0);
|
||||
y.append(y0_old);
|
||||
}
|
||||
|
||||
//newVal = (m_iX2-m_iX1)*(val[i]-vMin)/(vMax-vMin) + m_iX1;
|
||||
//newVal = val[i];
|
||||
//y.append(newVal);
|
||||
}
|
||||
logio->CloseCurve(indexBaseCurv);
|
||||
delete logio;
|
||||
//
|
||||
this->yAxis2->setRange(m_iY1, m_iY2);
|
||||
this->xAxis2->setRange(vMin, vMax);
|
||||
this->addGraph(yAxis2, xAxis2);
|
||||
}
|
||||
}
|
||||
}
|
||||
else //填充
|
||||
{
|
||||
//其他曲线
|
||||
CLogIO *logio=new CLogIO();
|
||||
logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead);
|
||||
int index=logio->OpenCurve(newTargetLine.toStdString().c_str());
|
||||
if(index<0)
|
||||
{
|
||||
this->addGraph();//空曲线
|
||||
this->addGraph();
|
||||
|
||||
delete logio;
|
||||
}
|
||||
else
|
||||
|
|
@ -410,148 +703,28 @@ void QMyCustomPlot::s_ChangeFillMode(QString strSlfName, QString strWellName, QS
|
|||
val=new float[count];
|
||||
logio->ReadCurve(index,curveinfo.StartDepth,count,&val[0]);
|
||||
logio->CloseCurve(index);
|
||||
//读完基线再关闭
|
||||
// delete logio;
|
||||
delete logio;
|
||||
|
||||
float newVal = 0.0;
|
||||
for(int i=0; i<count; i++)
|
||||
{
|
||||
float x0=-(sdep+ rlev*i);
|
||||
float y0_old=val[i];
|
||||
float y0 = (m_iX2-m_iX1)*(val[i]-vMin)/(vMax-vMin) + m_iX1;
|
||||
|
||||
//读取基线
|
||||
float BaseY0=0;
|
||||
logio->ReadCurve(indexBaseCurv, 0-x0, 1, &BaseY0);
|
||||
//
|
||||
if(i+1<count)
|
||||
{
|
||||
float x1=-(sdep+ rlev*(i+1));
|
||||
//float y1=val[i+1];
|
||||
float y1 = (m_iX2-m_iX1)*(val[i+1]-vMin)/(vMax-vMin) + m_iX1;
|
||||
//读取基线
|
||||
float BaseY1=0;
|
||||
logio->ReadCurve(indexBaseCurv, 0-x1, 1, &BaseY1);
|
||||
|
||||
if(BaseY0<=y0 && BaseY1<=y1)
|
||||
{
|
||||
//基线在左,采用基线值
|
||||
//y0=BaseY0;
|
||||
y0_old = (BaseY0-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
||||
//
|
||||
x.append(x0);
|
||||
y.append(y0_old);
|
||||
}
|
||||
else if(BaseY0>=y0 && BaseY1>=y1)
|
||||
{
|
||||
//基线在右,直接赋值
|
||||
x.append(x0);
|
||||
y.append(y0_old);
|
||||
}
|
||||
else if(BaseY0<=y0 && BaseY1>=y1)
|
||||
{
|
||||
//基线起点在左,采用基线值
|
||||
//y0=BaseY0;
|
||||
y0_old = (BaseY0-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
||||
//
|
||||
x.append(x0);
|
||||
y.append(y0_old);
|
||||
|
||||
//插值
|
||||
float xNew=x0-rlev*(y0-BaseY0)/(BaseY1-y1);
|
||||
float yNew=(y0-y1)/(x0-x1)*(xNew-x1) + y1;
|
||||
float yNew_Old=(yNew-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
||||
//
|
||||
x.append(xNew);
|
||||
y.append(yNew_Old);
|
||||
}
|
||||
else if(BaseY0>=y0 && BaseY1<=y1)
|
||||
{
|
||||
//基线在右,直接赋值
|
||||
x.append(x0);
|
||||
y.append(y0_old);
|
||||
|
||||
//插值
|
||||
float xNew=x0-rlev*(y0-BaseY0)/(BaseY1-y1);
|
||||
float yNew=(BaseY0-BaseY1)/(x0-x1)*(xNew-x1) + BaseY1;
|
||||
float yNew_Old=(yNew-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
||||
//
|
||||
x.append(xNew);
|
||||
y.append(yNew_Old);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//最后一个点
|
||||
if(BaseY0<y0)
|
||||
{
|
||||
//基线在左,采用基线值
|
||||
//y0=BaseY0;
|
||||
y0_old = (BaseY0-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
||||
}
|
||||
x.append(x0);
|
||||
y.append(y0_old);
|
||||
}
|
||||
|
||||
x.append(-(sdep+ rlev*i));
|
||||
//newVal = (m_iX2-m_iX1)*(val[i]-vMin)/(vMax-vMin) + m_iX1;
|
||||
//newVal = val[i];
|
||||
//y.append(newVal);
|
||||
newVal = val[i];
|
||||
y.append(newVal);
|
||||
}
|
||||
logio->CloseCurve(indexBaseCurv);
|
||||
delete logio;
|
||||
//
|
||||
this->yAxis2->setRange(m_iY1, m_iY2);
|
||||
this->xAxis2->setRange(vMin, vMax);
|
||||
this->addGraph(yAxis2, xAxis2);
|
||||
}
|
||||
}
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// //其他曲线
|
||||
// CLogIO *logio=new CLogIO();
|
||||
// logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead);
|
||||
// int index=logio->OpenCurve(newTargetLine.toStdString().c_str());
|
||||
// if(index<0)
|
||||
// {
|
||||
// this->addGraph();
|
||||
|
||||
// delete logio;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Slf_CURVE curveinfo;
|
||||
// float *val;
|
||||
// float sdep,edep,rlev;
|
||||
// //
|
||||
// logio->GetCurveInfo(index,&curveinfo);
|
||||
// sdep=curveinfo.StartDepth;
|
||||
// edep=curveinfo.EndDepth;
|
||||
// rlev=curveinfo.DepLevel;
|
||||
// //
|
||||
// int count=(curveinfo.EndDepth-curveinfo.StartDepth)/curveinfo.DepLevel+1.5;
|
||||
// val=new float[count];
|
||||
// logio->ReadCurve(index,curveinfo.StartDepth,count,&val[0]);
|
||||
// logio->CloseCurve(index);
|
||||
// delete logio;
|
||||
|
||||
// float newVal = 0.0;
|
||||
// for(int i=0; i<count; i++)
|
||||
// {
|
||||
// x.append(-(sdep+ rlev*i));
|
||||
// //newVal = (m_iX2-m_iX1)*(val[i]-vMin)/(vMax-vMin) + m_iX1;
|
||||
// newVal = val[i];
|
||||
// y.append(newVal);
|
||||
// }
|
||||
// this->yAxis2->setRange(m_iY1, m_iY2);
|
||||
// this->xAxis2->setRange(vMin, vMax);
|
||||
// this->addGraph(yAxis2, xAxis2);
|
||||
// }
|
||||
// }
|
||||
|
||||
this->graph(1)->setData(x, y);
|
||||
graph(1)->setLineStyle(graph(0)->lineStyle());//曲线
|
||||
graph(1)->setScatterStyle(graph(0)->scatterStyle());
|
||||
//graph(1)->setPen(QColor(255, 255, 255));
|
||||
graph(1)->setPen(QColor(0, 0, 0));//(graph(0)->pen());
|
||||
|
||||
//
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ public:
|
|||
QString m_strLineName;
|
||||
|
||||
//
|
||||
int m_iX1, m_iX2;
|
||||
int m_iY1, m_iY2;
|
||||
float m_iX1, m_iX2;
|
||||
float m_iY1, m_iY2;
|
||||
|
||||
//其他曲线
|
||||
QString m_newFillType;
|
||||
|
|
@ -37,9 +37,12 @@ public:
|
|||
QString m_newLithosImage;
|
||||
QString m_newHeadFill;
|
||||
float m_vMin;
|
||||
float m_vMax;
|
||||
float m_vMax;
|
||||
QString m_strScaleType;//刻度类型(线性,对数)
|
||||
|
||||
QColor m_frontColor;//岩性前景色
|
||||
QColor m_backColor;//岩性背景色
|
||||
QString m_newFillMode;
|
||||
|
||||
QContextMenuEvent *m_event;
|
||||
|
||||
|
|
@ -61,6 +64,9 @@ public slots:
|
|||
void s_ChangeLeftScale(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, double newLeftScale);
|
||||
//右刻度
|
||||
void s_ChangeRightScale(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, double newRightScale);
|
||||
//刻度类型
|
||||
void s_ChangeScaleType(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strScaleType);
|
||||
|
||||
//线颜色
|
||||
void s_ChangeLineColor(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QColor lineColor);
|
||||
//线宽
|
||||
|
|
@ -72,7 +78,7 @@ public slots:
|
|||
//岩性填充-填充
|
||||
void s_ChangeFillMode(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName,
|
||||
QString newFillType, QString newTargetLine, QColor newColor, QString newLithosImage, QString newHeadFill,
|
||||
float vMin, float vMax, QColor frontColor, QColor backColor);
|
||||
float vMin, float vMax, QColor frontColor, QColor backColor, QString newFillMode);
|
||||
|
||||
void onAddRect();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user