From 5d054c35db9edcac53f3fcd0d33fcd3e409c49cc Mon Sep 17 00:00:00 2001 From: "DESKTOP-450PEFP\\mainc" Date: Fri, 10 Apr 2026 10:24:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BE=B9=E6=A1=86=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E6=98=BE=E7=A4=BA=EF=BC=8C=E9=87=8D=E7=BB=98=E8=BE=B9?= =?UTF-8?q?=E6=A1=86=EF=BC=8C=E9=9A=90=E8=97=8Ftablewidget=E7=9A=84?= =?UTF-8?q?=E8=BE=B9=E6=A1=86=EF=BC=8C=E8=B0=83=E6=95=B4=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=95=88=E6=9E=9C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/common.h | 16 +++++ logPlus/ItemBorderDelegate.h | 64 +++++++++++++++++ logPlus/TransparentDraggableGujing.cpp | 2 +- logPlus/formdraw.cpp | 99 ++++++++++++++++++++++++-- logPlus/formdraw.h | 5 ++ logPlus/forminfo.cpp | 2 +- logPlus/formtrack.cpp | 38 ++++++++++ logPlus/formtrack.h | 8 ++- logPlus/formtrack.ui | 8 +-- logPlus/formtracktop.cpp | 35 ++++++++- logPlus/formtracktop.h | 4 ++ logPlus/formwell.cpp | 50 +++++++++++-- logPlus/formwell.h | 8 ++- logPlus/formwell.ui | 8 +-- logPlus/logplus.vcxproj | 2 + logPlus/logplus.vcxproj.filters | 6 ++ logPlus/mainwindowcurve.cpp | 17 +++-- logPlus/mainwindowcurve.ui | 14 +++- logPlus/qmycustomplot.cpp | 8 +++ 19 files changed, 360 insertions(+), 34 deletions(-) create mode 100644 common/common.h create mode 100644 logPlus/ItemBorderDelegate.h diff --git a/common/common.h b/common/common.h new file mode 100644 index 0000000..0bb41e2 --- /dev/null +++ b/common/common.h @@ -0,0 +1,16 @@ +#ifndef LOG_COMMON_H +#define LOG_COMMON_H + +#include + +// 定义一个枚举,方便位操作(可选) +enum BorderFlag { + NoBorder = 0, + TopBorder = 1 << 0, + BottomBorder = 1 << 1, + LeftBorder = 1 << 2, + RightBorder = 1 << 3 +}; +Q_DECLARE_FLAGS(BorderFlags, BorderFlag) + +#endif // LOG_COMMON_H diff --git a/logPlus/ItemBorderDelegate.h b/logPlus/ItemBorderDelegate.h new file mode 100644 index 0000000..ab4d056 --- /dev/null +++ b/logPlus/ItemBorderDelegate.h @@ -0,0 +1,64 @@ +#pragma once + +#include +#include +#include +#include "common.h" + +#pragma execution_character_set("utf-8") + + +// 设置某个单元格的边框状态 +void setItemBorderFlags(QTableWidgetItem *item, BorderFlags flags) { + item->setData(Qt::UserRole, static_cast(flags)); +} + +// 获取边框状态 +BorderFlags getItemBorderFlags(const QTableWidgetItem *item) { + return static_cast(item->data(Qt::UserRole).toInt()); +} + +class ItemBorderDelegate : public QStyledItemDelegate { +public: + using QStyledItemDelegate::QStyledItemDelegate; + + void paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const override { + // 1. 绘制默认内容(文本、图标等) + QStyledItemDelegate::paint(painter, option, index); + + const QTableWidget* ptabWgt = qobject_cast(const_cast(option.widget)); + if (!ptabWgt) return; + // 2. 获取该单元格存储的边框标志 + QTableWidgetItem *item = ptabWgt->item(index.row(), index.column()); + if (!item) return; + + BorderFlags flags = getItemBorderFlags(item); + if (flags == NoBorder) return; + + // 3. 准备绘制边框 + painter->save(); + painter->setPen(QPen(Qt::black, 2)); // 颜色、宽度可自定义 + QRect rect = option.rect; + rect.setLeft(rect.left() + 1); + rect.setTop(rect.top() + 1); + // 上边框 + if (flags & TopBorder) { + painter->drawLine(rect.topLeft(), rect.topRight()); + } + // 下边框 + if (flags & BottomBorder) { + painter->drawLine(rect.bottomLeft(), rect.bottomRight()); + } + // 左边框 + if (flags & LeftBorder) { + painter->drawLine(rect.topLeft(), rect.bottomLeft()); + } + // 右边框 + if (flags & RightBorder) { + painter->drawLine(rect.topRight(), rect.bottomRight()); + } + + painter->restore(); + } +}; \ No newline at end of file diff --git a/logPlus/TransparentDraggableGujing.cpp b/logPlus/TransparentDraggableGujing.cpp index 0130135..0a7a17d 100644 --- a/logPlus/TransparentDraggableGujing.cpp +++ b/logPlus/TransparentDraggableGujing.cpp @@ -176,7 +176,7 @@ void TransparentDraggableGujing::setRange(double left_Low, double right_Hight, b if(left_Low >= right_Hight) return; double lY1 = mPlot->yAxis->range().lower;//+10 - double lY2 = mPlot->yAxis->range().upper; + double lY2 = mPlot->yAxis->range().upper-3; mRect->topLeft->setCoords(left_Low, lY1); mRect->bottomRight->setCoords(right_Hight, lY2); diff --git a/logPlus/formdraw.cpp b/logPlus/formdraw.cpp index 3068ce3..f83d97e 100644 --- a/logPlus/formdraw.cpp +++ b/logPlus/formdraw.cpp @@ -2677,15 +2677,39 @@ void FormDraw::crossTrackSetting() } +void FormDraw::setBorderFlags(BorderFlags flags) +{ + m_BorderFlags = flags; +} + void FormDraw::paintEvent(QPaintEvent*) { - //if (m_listLineName.size() > 0 && m_listLineName.at(0) == "AC") - //{ - // QPainter painter(this); - // QRect rect = this->rect(); - // //背景透明 - // painter.fillRect(rect.left(), rect.top(), rect.width(), rect.height(), QColor(200, 0, 0)); //QColor(67, 67, 67, 100) - //} + QPainter painter(this); + QRect rect = this->rect(); + rect.setLeft(rect.left() + 1); + rect.setTop(rect.top() + 1); + // 3. 准备绘制边框 + painter.save(); + painter.setPen(QPen(Qt::black, 2)); // 颜色、宽度可自定义 + + // 上边框 + if (m_BorderFlags & TopBorder) { + painter.drawLine(rect.topLeft(), rect.topRight()); + } + // 下边框 + if (m_BorderFlags & BottomBorder) { + painter.drawLine(rect.bottomLeft(), rect.bottomRight()); + } + // 左边框 + if (m_BorderFlags & LeftBorder) { + painter.drawLine(rect.topLeft(), rect.bottomLeft()); + } + // 右边框 + if (m_BorderFlags & RightBorder) { + painter.drawLine(rect.topRight(), rect.bottomRight()); + } + + painter.restore(); } @@ -3677,6 +3701,10 @@ void FormDraw::s_addGanZuangTu(QString strUuid, QString strSlfName, QString strW curv->yAxis->setTicks(false); curv->xAxis2->setTicks(false); curv->yAxis2->setTicks(false); + curv->xAxis->setVisible(false); + curv->xAxis2->setVisible(false); + curv->yAxis->setVisible(false); + curv->yAxis2->setVisible(false); //蝌蚪图 // curv->mKedou = true; //隐藏网格 @@ -4140,6 +4168,10 @@ void FormDraw::s_addJiegutext(QString strUuid, QString strSlfName, QString strWe curv->yAxis->setTicks(false); curv->xAxis2->setTicks(false); curv->yAxis2->setTicks(false); + curv->xAxis->setVisible(false); + curv->xAxis2->setVisible(false); + curv->yAxis->setVisible(false); + curv->yAxis2->setVisible(false); QColor newlineColor=QColor(0,0,0); QString strAliasName = "气测-FMT-射孔-文本"; @@ -4538,6 +4570,10 @@ void FormDraw::s_addTubingstring(QString strUuid, QString strSlfName, QString st curv->yAxis->setTicks(false); curv->xAxis2->setTicks(false); curv->yAxis2->setTicks(false); + curv->xAxis->setVisible(false); + curv->xAxis2->setVisible(false); + curv->yAxis->setVisible(false); + curv->yAxis2->setVisible(false); //套管组件 //QString strWaveName = "TUBTOOLS"; @@ -4741,6 +4777,11 @@ void FormDraw::initForm(QMyCustomPlot *widget, QString strSlfName, QString strLi widget->xAxis->ticker()->setTickCount(10);//x个主刻度 widget->yAxis->ticker()->setTickCount(60);//y个主刻度 + widget->xAxis->setVisible(false); + widget->xAxis2->setVisible(false); + widget->yAxis->setVisible(false); + widget->yAxis2->setVisible(false); + //对调XY轴,在最前面设置 QCPAxis *yAxis = widget->yAxis; QCPAxis *xAxis = widget->xAxis; @@ -5409,6 +5450,10 @@ void FormDraw::initTableLine(QMyCustomPlot *widget, QString strSlfName, QString widget->yAxis->setTicks(false); widget->xAxis2->setTicks(false); widget->yAxis2->setTicks(false); + widget->xAxis->setVisible(false); + widget->xAxis2->setVisible(false); + widget->yAxis->setVisible(false); + widget->yAxis2->setVisible(false); // if (m_bTableData) { @@ -5460,6 +5505,10 @@ void FormDraw::initWords(QMyCustomPlot *widget, QString strSlfName, QString strL widget->yAxis->setTicks(false); widget->xAxis2->setTicks(false); widget->yAxis2->setTicks(false); + widget->xAxis->setVisible(false); + widget->xAxis2->setVisible(false); + widget->yAxis->setVisible(false); + widget->yAxis2->setVisible(false); // widget->LoadFromSLF_Text(strSlfName, strLineName); @@ -5506,6 +5555,10 @@ void FormDraw::initLayer(QMyCustomPlot *widget, QString strSlfName, QString strL widget->yAxis->setTicks(false); widget->xAxis2->setTicks(false); widget->yAxis2->setTicks(false); + widget->xAxis->setVisible(false); + widget->xAxis2->setVisible(false); + widget->yAxis->setVisible(false); + widget->yAxis2->setVisible(false); //地质层位道 widget->LoadFromSLF_Layer(strSlfName, strLineName); @@ -5555,6 +5608,10 @@ void FormDraw::initIMAGE_DATA(QMyCustomPlot *widget, QString strSlfName, QString widget->yAxis->setTicks(false); widget->xAxis2->setTicks(false); widget->yAxis2->setTicks(false); + widget->xAxis->setVisible(false); + widget->xAxis2->setVisible(false); + widget->yAxis->setVisible(false); + widget->yAxis2->setVisible(false); // widget->LoadFromIMAGE_SLF(strSlfName, strLineName); //显示文本 @@ -5666,6 +5723,10 @@ void FormDraw::initResult(QMyCustomPlot *widget, QString strSlfName, QString str widget->yAxis->setTickLabels(false); widget->xAxis2->setTickLabels(false); widget->xAxis2->setTickLabels(false); + widget->xAxis->setVisible(false); + widget->xAxis2->setVisible(false); + widget->yAxis->setVisible(false); + widget->yAxis2->setVisible(false); // LoadFromSLF_Result(widget, strSlfName, strLineName); @@ -5760,6 +5821,10 @@ void FormDraw::initGeoLith(QMyCustomPlot *widget, QString strSlfName, QString st widget->yAxis->setTicks(false); widget->xAxis2->setTicks(false); widget->yAxis2->setTicks(false); + widget->xAxis->setVisible(false); + widget->xAxis2->setVisible(false); + widget->yAxis->setVisible(false); + widget->yAxis2->setVisible(false); //含油占比 if(listOtherProperty.size()>=12) @@ -5870,6 +5935,10 @@ void FormDraw::initSwallCore(QMyCustomPlot *widget, QString strSlfName, QString widget->yAxis->setTicks(false); widget->xAxis2->setTicks(false); widget->yAxis2->setTicks(false); + widget->xAxis->setVisible(false); + widget->xAxis2->setVisible(false); + widget->yAxis->setVisible(false); + widget->yAxis2->setVisible(false); // widget->LoadFromSLF_SwallCore(strSlfName, strLineName); @@ -5917,6 +5986,10 @@ void FormDraw::initGujing(QMyCustomPlot *widget, QString strSlfName, QString str widget->yAxis->setTicks(false); widget->xAxis2->setTicks(false); widget->yAxis2->setTicks(false); + widget->xAxis->setVisible(false); + widget->xAxis2->setVisible(false); + widget->yAxis->setVisible(false); + widget->yAxis2->setVisible(false); // widget->LoadFromSLF_Gujing(strSlfName, strLineName); @@ -6793,6 +6866,10 @@ void FormDraw::initCorePhysics(QMyCustomPlot *widget, QString strSlfName, QStrin widget->yAxis->setTicks(false); widget->xAxis2->setTicks(false); widget->yAxis2->setTicks(false); + widget->xAxis->setVisible(false); + widget->xAxis2->setVisible(false); + widget->yAxis->setVisible(false); + widget->yAxis2->setVisible(false); QVector x, y; @@ -7039,6 +7116,10 @@ void FormDraw::DrawJykt(QMyCustomPlot *widget, QString strSlfName) widget->yAxis->setTicks(false); widget->xAxis2->setTicks(false); widget->yAxis2->setTicks(false); + widget->xAxis->setVisible(false); + widget->xAxis2->setVisible(false); + widget->yAxis->setVisible(false); + widget->yAxis2->setVisible(false); //------------- float tempf,flVal; @@ -7165,6 +7246,10 @@ void FormDraw::DrawDenv(QMyCustomPlot *widget, QString strSlfName) widget->yAxis->setTicks(false); widget->xAxis2->setTicks(false); widget->yAxis2->setTicks(false); + widget->xAxis->setVisible(false); + widget->xAxis2->setVisible(false); + widget->yAxis->setVisible(false); + widget->yAxis2->setVisible(false); // QPen pPen(m_TailColor,m_nTailWidth); diff --git a/logPlus/formdraw.h b/logPlus/formdraw.h index e79f050..66aacbe 100644 --- a/logPlus/formdraw.h +++ b/logPlus/formdraw.h @@ -10,6 +10,7 @@ #include "LogIO.h" #include "MemRdWt.h" #include "FormLine.h" +#include "common.h" #pragma execution_character_set("utf-8") @@ -86,6 +87,8 @@ public: // 跨道设置 void crossTrackSetting(); + void setBorderFlags(BorderFlags flags); + private: Ui::FormDraw *ui; @@ -126,6 +129,8 @@ public: QStringList m_listWaveName; QStringList m_listTableName; + BorderFlags m_BorderFlags; + //X坐标 float m_vmax; float m_vmin; diff --git a/logPlus/forminfo.cpp b/logPlus/forminfo.cpp index 8c2ccf4..d0fd551 100644 --- a/logPlus/forminfo.cpp +++ b/logPlus/forminfo.cpp @@ -715,7 +715,7 @@ void FormInfo::paintEvent(QPaintEvent* event) QRect rectRound(rect.left()+2,rect.top()+4, rect.width()-4, rect.height()-8); painter.setPen(QPen(m_lineColor, m_dWidth, m_lineStyle)); //painter.drawRoundRect(rectRound);//利用画刷(颜色/岩性图片),画框 - painter.drawRect(rectRound); + //painter.drawRect(rectRound); QString strShowTxt = ""; painter.setBrush(Qt::NoBrush); // 确保文字不被填充色遮挡 diff --git a/logPlus/formtrack.cpp b/logPlus/formtrack.cpp index 09b42d4..6139713 100644 --- a/logPlus/formtrack.cpp +++ b/logPlus/formtrack.cpp @@ -171,6 +171,44 @@ FormInfo* FormTrack::getFormInfoByParameters(QString strUuid, QString strWellNam return NULL; } +void FormTrack::setBorderFlags(BorderFlags flags) +{ + m_BorderFlags = flags; +} + +void FormTrack::paintEvent(QPaintEvent *event) +{ + QWidget::paintEvent(event); + + QPainter painter(this); + QRect rect = this->rect(); + + rect.setLeft(rect.left() + 1); + rect.setTop(rect.top() + 1); + // 绘制边框 + painter.save(); + painter.setPen(QPen(Qt::black, 2)); // 颜色、宽度可自定义 + + // 上边框 + if (m_BorderFlags & TopBorder) { + painter.drawLine(rect.topLeft(), rect.topRight()); + } + // 下边框 + if (m_BorderFlags & BottomBorder) { + painter.drawLine(rect.bottomLeft(), rect.bottomRight()); + } + // 左边框 + if (m_BorderFlags & LeftBorder) { + painter.drawLine(rect.topLeft(), rect.bottomLeft()); + } + // 右边框 + if (m_BorderFlags & RightBorder) { + painter.drawLine(rect.topRight(), rect.bottomRight()); + } + + painter.restore(); +} + // // void FormTrack::setTrackPropert(QJsonObject trackObj) // { diff --git a/logPlus/formtrack.h b/logPlus/formtrack.h index 56a9c59..a10f8bc 100644 --- a/logPlus/formtrack.h +++ b/logPlus/formtrack.h @@ -4,6 +4,7 @@ #include #include "forminfo.h" #include +#include "common.h" #pragma execution_character_set("utf-8") @@ -56,9 +57,14 @@ public: FormInfo* getFormInfoByParameters(QString strUuid, QString strWellName, QString strTrackName, QString strLineName); + void setBorderFlags(BorderFlags flags); + private: Ui::FormTrack *ui; +protected: + void paintEvent(QPaintEvent *event); + public: QString m_strUuid; // 道ID @@ -69,7 +75,7 @@ public: FormInfo *m_formInfo = NULL; // 创建自定义单元格委托 //NoLRBorderDelegate *m_delegate; - + BorderFlags m_BorderFlags; public: void Add(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType, QString strType, QStringList listOtherProperty={}); diff --git a/logPlus/formtrack.ui b/logPlus/formtrack.ui index 3b43ebb..81ecae2 100644 --- a/logPlus/formtrack.ui +++ b/logPlus/formtrack.ui @@ -15,16 +15,16 @@ - 0 + 2 - 0 + 2 - 0 + 2 - 0 + 2 diff --git a/logPlus/formtracktop.cpp b/logPlus/formtracktop.cpp index e5e3b07..79d5c10 100644 --- a/logPlus/formtracktop.cpp +++ b/logPlus/formtracktop.cpp @@ -30,6 +30,11 @@ FormTrackTop::~FormTrackTop() delete ui; } +void FormTrackTop::setBorderFlags(BorderFlags flags) +{ + m_BorderFlags = flags; +} + void FormTrackTop::setTrackTopPropert(QJsonObject topObj) { if (topObj.contains("Font")) @@ -60,6 +65,8 @@ QJsonObject FormTrackTop::makeJson() void FormTrackTop::paintEvent(QPaintEvent* event) { + QWidget::paintEvent(event); + QPainter painter(this); QRect rect = this->rect(); //背景透明 @@ -70,7 +77,33 @@ void FormTrackTop::paintEvent(QPaintEvent* event) painter.setPen(m_fontColor); // fontColor QColor(220, 220, 220) painter.drawText(rect.left(), rect.top(), rect.width(), rect.height(), Qt::AlignCenter, m_strTrackName); - QWidget::paintEvent(event); + rect.setLeft(rect.left() + 1); + rect.setTop(rect.top() + 1); + // 3. 准备绘制边框 + painter.save(); + painter.setPen(QPen(Qt::black, 2)); // 颜色、宽度可自定义 + + // 上边框 + if (m_BorderFlags & TopBorder) { + painter.drawLine(rect.topLeft(), rect.topRight()); + } + // 下边框 + if (m_BorderFlags & BottomBorder) { + painter.drawLine(rect.bottomLeft(), rect.bottomRight()); + } + // 左边框 + if (m_BorderFlags & LeftBorder) { + painter.drawLine(rect.topLeft(), rect.bottomLeft()); + } + // 右边框 + if (m_BorderFlags & RightBorder) { + painter.drawLine(rect.topRight(), rect.bottomRight()); + } + + painter.restore(); + + + } void FormTrackTop::dragEnterEvent(QDragEnterEvent* event) diff --git a/logPlus/formtracktop.h b/logPlus/formtracktop.h index 516ab2e..ae99714 100644 --- a/logPlus/formtracktop.h +++ b/logPlus/formtracktop.h @@ -8,6 +8,7 @@ #include #include #include +#include "common.h" #pragma execution_character_set("utf-8") @@ -23,6 +24,8 @@ public: explicit FormTrackTop(QWidget *parent = nullptr, QString strSlfName="", QString strWellName="", QString strTrackName="", QString strLineName="", QColor lineColor=QColor(255,0,0)); ~FormTrackTop(); + void setBorderFlags(BorderFlags flags); + void setTrackTopPropert(QJsonObject topObj); private: Ui::FormTrackTop *ui; @@ -50,6 +53,7 @@ public: QFont m_font; QColor m_fontColor;//颜色 + BorderFlags m_BorderFlags; public: diff --git a/logPlus/formwell.cpp b/logPlus/formwell.cpp index c094be7..2bbfb3a 100644 --- a/logPlus/formwell.cpp +++ b/logPlus/formwell.cpp @@ -23,17 +23,15 @@ FormWell::FormWell(QWidget *parent, QString strWellName) : // ui->tableWidget->verticalHeader()->hide(); //行 - //ui->tableWidget->horizontalHeader()->hide();//列 + ui->tableWidget->horizontalHeader()->hide();//列 int rowcount = 3; //总行数 ui->tableWidget->setRowCount(rowcount); //动态设置行数 //ui->tableWidget->verticalHeader()->setFixedWidth(3);//标题栏宽度 ui->tableWidget->horizontalHeader()->setFixedHeight(3); - //左右边框隐藏 - ui->tableWidget->setStyleSheet("QTableView::item {border-left: 0px solid black;} \ - QTableView::item:selected {border-left: 0px solid black; color:#57595B; background:#E4E4E4;}\ - QTableView::item {border-right: 0px solid black;} \ - QTableView::item:selected {border-right: 0px solid black;}"); - //"QTableView::item:selected {color:#57595B; background:#E4E4E4;}" + + ui->tableWidget->setShowGrid(false); + ui->tableWidget->setStyleSheet("QTableView {border: 0px solid black;} QTableView::item {border: 0px solid black;} \ + QTableView::item:selected {color:#57595B; background:#E4E4E4;}"); // 假设你的类中有一个槽函数:onTableRowsInserted(QModelIndex parent, int first, int last) //connect(ui->tableWidget->model(), &QAbstractItemModel::columnsInserted, @@ -189,6 +187,7 @@ QVector FormWell::new_track(QStringList listdt, QString strTrackName) ui->tableWidget->setRowHeight(i, 100); // FormTrackTop* trackTop= new FormTrackTop(this, strSlfName, strWellName, strTrackName); + trackTop->setBorderFlags(BorderFlags(BottomBorder | RightBorder)); // if ("curveObject" == strType) // trackTop->setFixedWidth(nW/2); vec << trackTop; @@ -203,6 +202,7 @@ QVector FormWell::new_track(QStringList listdt, QString strTrackName) //曲线名称栏 formTrack = new FormTrack(this, strWellName, strTrackName); + formTrack->setBorderFlags(BorderFlags(BottomBorder | RightBorder)); // if ("curveObject" == strType) // formTrack->setFixedWidth(nW / 2); vec << formTrack; @@ -228,6 +228,7 @@ QVector FormWell::new_track(QStringList listdt, QString strTrackName) ui->tableWidget->setRowHeight(i, (int)dHight);//7582 //曲线绘制栏 FormDraw *formDraw = new FormDraw(this, strWellName, strTrackName); + formDraw->setBorderFlags(BorderFlags(BottomBorder | RightBorder)); vec << formDraw; formDraw->m_iY1 = m_iY1; formDraw->m_iY2 = m_iY2; @@ -244,6 +245,11 @@ QVector FormWell::new_track(QStringList listdt, QString strTrackName) return vec; } +void FormWell::setBorderFlags(BorderFlags flags) +{ + m_BorderFlags = flags; +} + int FormWell::getTableWidgetColumn(QString strTrackUuid) { int nret = -1; @@ -260,6 +266,36 @@ int FormWell::getTableWidgetColumn(QString strTrackUuid) return nret; } +void FormWell::paintEvent(QPaintEvent *event) +{ + QPainter painter(this); + QRect rect = this->rect(); + rect.setLeft(rect.left() + 1); + rect.setTop(rect.top() + 1); + // 3. 准备绘制边框 + painter.save(); + painter.setPen(QPen(Qt::black, 2)); // 颜色、宽度可自定义 + + // 上边框 + if (m_BorderFlags & TopBorder) { + painter.drawLine(rect.topLeft(), rect.topRight()); + } + // 下边框 + if (m_BorderFlags & BottomBorder) { + painter.drawLine(rect.bottomLeft(), rect.bottomRight()); + } + // 左边框 + if (m_BorderFlags & LeftBorder) { + painter.drawLine(rect.topLeft(), rect.bottomLeft()); + } + // 右边框 + if (m_BorderFlags & RightBorder) { + painter.drawLine(rect.topRight(), rect.bottomRight()); + } + + painter.restore(); +} + void FormWell::s_Raise(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int iTableType, QString strFormInfoType) { if(m_strUuid == strUuid && diff --git a/logPlus/formwell.h b/logPlus/formwell.h index 2f577d7..4068140 100644 --- a/logPlus/formwell.h +++ b/logPlus/formwell.h @@ -5,6 +5,7 @@ #include "formtrack.h" #include "formdraw.h" #include "formtracktop.h" +#include "common.h" #pragma execution_character_set("utf-8") @@ -25,9 +26,12 @@ public: QVector new_track(QStringList listdt, QString strTrackName = ""); + void setBorderFlags(BorderFlags flags); + // 根据道ID,获取列索引 int getTableWidgetColumn(QString strTrackUuid); - +protected: + void paintEvent(QPaintEvent *event); private: Ui::FormWell *ui; @@ -43,6 +47,8 @@ public: // 道图形 QMap> m_mapFormDraw; + BorderFlags m_BorderFlags; + public: QJsonObject makeJson(); QStringList getLineList(QString strWellName, QString strTrackName); diff --git a/logPlus/formwell.ui b/logPlus/formwell.ui index 7d16172..b653466 100644 --- a/logPlus/formwell.ui +++ b/logPlus/formwell.ui @@ -15,16 +15,16 @@ - 0 + 2 - 0 + 2 - 0 + 2 - 0 + 2 diff --git a/logPlus/logplus.vcxproj b/logPlus/logplus.vcxproj index 8eebb17..4de351d 100644 --- a/logPlus/logplus.vcxproj +++ b/logPlus/logplus.vcxproj @@ -20,6 +20,7 @@ + @@ -35,6 +36,7 @@ + diff --git a/logPlus/logplus.vcxproj.filters b/logPlus/logplus.vcxproj.filters index 11e9e29..7457f9b 100644 --- a/logPlus/logplus.vcxproj.filters +++ b/logPlus/logplus.vcxproj.filters @@ -68,6 +68,12 @@ common + + Header Files + + + common + diff --git a/logPlus/mainwindowcurve.cpp b/logPlus/mainwindowcurve.cpp index fa0e346..9918739 100644 --- a/logPlus/mainwindowcurve.cpp +++ b/logPlus/mainwindowcurve.cpp @@ -17,6 +17,7 @@ #include "selectwelldialog.h" #include "mainwindow.h" #include +#include "ItemBorderDelegate.h" //主窗口,为了方便获取tab当前页 extern MainWindow *g_mainWindow; @@ -66,17 +67,19 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) : ui->toolBar_3->hide(); ui->toolBar_plugin->hide(); //加载样式 - loadStyle(":/qrc/qss/flatgray.css"); + //loadStyle(":/qrc/qss/flatgray.css"); + //this->setStyleSheet("QWidget{border: 1px solid black;}"); + //ui->centralwidget->setVisible(false); + //ui->tableWidget_2->setVisible(false); //------------------------------------- //ui->tableWidget_2->setFrameShape(QFrame::NoFrame); //设置无边框 //隐藏网格线 ui->tableWidget_2->setShowGrid(false); - //设置样式表,只显示竖直边框 - ui->tableWidget_2->setStyleSheet( "QTableView::item {border-left: 1px solid black;} \ - QTableView::item:selected {border-left: 1px solid black; color:#57595B; background:#E4E4E4;}\ - QTableView::item {border-right: 1px solid black;} \ - QTableView::item:selected {border-right: 1px solid black;}"); + ui->tableWidget_2->setItemDelegate(new ItemBorderDelegate(ui->tableWidget_2)); + + ui->tableWidget_2->setStyleSheet("QTableView {border: 0px solid black;} QTableView::item {border: 0px solid black;} \ + QTableView::item:selected {color:#57595B; background:#E4E4E4;}"); ui->tableWidget_2->verticalHeader()->hide(); //行 @@ -2904,6 +2907,7 @@ void MainWindowCurve::s_NewWell(QString strWellName, QString strSlfName) ui->tableWidget_2->setRowHeight(i, 100); // QTableWidgetItem* item = new QTableWidgetItem(strWellName); + setItemBorderFlags(item, BorderFlags(TopBorder | BottomBorder | LeftBorder | RightBorder)); item->setData(Qt::UserRole + 1, strSlfName); item->setFlags(item->flags() & (~Qt::ItemIsEditable)); item->setTextAlignment(Qt::AlignCenter); //设置文本居中 @@ -2928,6 +2932,7 @@ void MainWindowCurve::s_NewWell(QString strWellName, QString strSlfName) ui->tableWidget_2->setRowHeight(i, (int)dHight);//8020 // FormWell *widgetWell = new FormWell(this, strWellName); + widgetWell->setBorderFlags(BorderFlags(BottomBorder | LeftBorder | RightBorder)); widgetWell->m_iY1 = m_iY1; widgetWell->m_iY2 = m_iY2; widgetWell->m_strUuid = m_strUuid; diff --git a/logPlus/mainwindowcurve.ui b/logPlus/mainwindowcurve.ui index 1542b5b..f802e24 100644 --- a/logPlus/mainwindowcurve.ui +++ b/logPlus/mainwindowcurve.ui @@ -15,14 +15,26 @@ + + 9 + + + 9 + - 3 + 9 + + + 9 + + + diff --git a/logPlus/qmycustomplot.cpp b/logPlus/qmycustomplot.cpp index f8b2253..41f236c 100644 --- a/logPlus/qmycustomplot.cpp +++ b/logPlus/qmycustomplot.cpp @@ -73,6 +73,10 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel yAxis->setTickLabels(false); xAxis2->setTickLabels(false); xAxis2->setTickLabels(false); + xAxis->setVisible(false); + xAxis2->setVisible(false); + yAxis->setVisible(false); + yAxis2->setVisible(false); xAxis->grid()->setVisible(false); yAxis->grid()->setVisible(false); @@ -358,6 +362,10 @@ void QMyCustomPlot::initWave(QString strSlfName, QString strWaveName) widget->yAxis->setTickLabels(false); widget->xAxis2->setTickLabels(false); widget->xAxis2->setTickLabels(false); + widget->xAxis->setVisible(false); + widget->xAxis2->setVisible(false); + widget->yAxis->setVisible(false); + widget->yAxis2->setVisible(false); //对调XY轴,在最前面设置 QCPAxis *yAxis = widget->yAxis;