Compare commits

...

3 Commits

20 changed files with 373 additions and 35 deletions

View File

@ -199,7 +199,10 @@ QVariant PythonHandler::pythonObjectToQVariant(PyObject *obj)
map[key] = pythonObjectToQVariant(pValue); map[key] = pythonObjectToQVariant(pValue);
} }
} }
#ifdef _RELEASE
Py_DECREF(pKeys); Py_DECREF(pKeys);
#endif
return map; return map;
} }
else if (obj == Py_None) { else if (obj == Py_None) {
@ -222,14 +225,17 @@ QString PythonHandler::capturePythonError() {
PyObject* pstr = PyObject_Str(pvalue); PyObject* pstr = PyObject_Str(pvalue);
if (pstr) { if (pstr) {
errorMsg = QString::fromUtf8(PyUnicode_AsUTF8(pstr)); errorMsg = QString::fromUtf8(PyUnicode_AsUTF8(pstr));
#ifdef _RELEASE
Py_DECREF(pstr); Py_DECREF(pstr);
#endif
} }
} }
#ifdef _RELEASE
// 清理 // 清理
Py_XDECREF(ptype); Py_XDECREF(ptype);
Py_XDECREF(pvalue); Py_XDECREF(pvalue);
Py_XDECREF(ptraceback); Py_XDECREF(ptraceback);
#endif
return errorMsg; return errorMsg;
} }
@ -284,8 +290,11 @@ QVariant PythonHandler::executeScript(const QString &scriptPath,
PyErr_Print(); PyErr_Print();
} }
emit addLog("无法找到函数:" + functionName); emit addLog("无法找到函数:" + functionName);
#ifdef _RELEASE
Py_XDECREF(pFunc); Py_XDECREF(pFunc);
Py_DECREF(pModule); Py_DECREF(pModule);
#endif
return QVariant(); return QVariant();
} }
@ -427,7 +436,10 @@ QVariant PythonHandler::executeCode(const QString &code)
if (pResult) { if (pResult) {
QVariant result = pythonObjectToQVariant(pResult); QVariant result = pythonObjectToQVariant(pResult);
#ifdef _RELEASE
Py_DECREF(pResult); Py_DECREF(pResult);
#endif
return result; return result;
} else { } else {
PyErr_Print(); PyErr_Print();

16
common/common.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef LOG_COMMON_H
#define LOG_COMMON_H
#include <QObject>
// 定义一个枚举,方便位操作(可选)
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

View File

@ -0,0 +1,64 @@
#pragma once
#include <QPainter>
#include <QTableWidgetItem>
#include <QStyledItemDelegate>
#include "common.h"
#pragma execution_character_set("utf-8")
// 设置某个单元格的边框状态
void setItemBorderFlags(QTableWidgetItem *item, BorderFlags flags) {
item->setData(Qt::UserRole, static_cast<int>(flags));
}
// 获取边框状态
BorderFlags getItemBorderFlags(const QTableWidgetItem *item) {
return static_cast<BorderFlags>(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<QTableWidget*>(const_cast<QWidget*>(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();
}
};

View File

@ -176,7 +176,7 @@ void TransparentDraggableGujing::setRange(double left_Low, double right_Hight, b
if(left_Low >= right_Hight) return; if(left_Low >= right_Hight) return;
double lY1 = mPlot->yAxis->range().lower;//+10 double lY1 = mPlot->yAxis->range().lower;//+10
double lY2 = mPlot->yAxis->range().upper; double lY2 = mPlot->yAxis->range().upper-3;
mRect->topLeft->setCoords(left_Low, lY1); mRect->topLeft->setCoords(left_Low, lY1);
mRect->bottomRight->setCoords(right_Hight, lY2); mRect->bottomRight->setCoords(right_Hight, lY2);

View File

@ -2710,15 +2710,39 @@ void FormDraw::crossTrackSetting()
} }
void FormDraw::setBorderFlags(BorderFlags flags)
{
m_BorderFlags = flags;
}
void FormDraw::paintEvent(QPaintEvent*) void FormDraw::paintEvent(QPaintEvent*)
{ {
//if (m_listLineName.size() > 0 && m_listLineName.at(0) == "AC") QPainter painter(this);
//{ QRect rect = this->rect();
// QPainter painter(this); rect.setLeft(rect.left() + 1);
// QRect rect = this->rect(); rect.setTop(rect.top() + 1);
// //背景透明 // 3. 准备绘制边框
// painter.fillRect(rect.left(), rect.top(), rect.width(), rect.height(), QColor(200, 0, 0)); //QColor(67, 67, 67, 100) 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();
} }
@ -3710,6 +3734,10 @@ void FormDraw::s_addGanZuangTu(QString strUuid, QString strSlfName, QString strW
curv->yAxis->setTicks(false); curv->yAxis->setTicks(false);
curv->xAxis2->setTicks(false); curv->xAxis2->setTicks(false);
curv->yAxis2->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; // curv->mKedou = true;
//隐藏网格 //隐藏网格
@ -4173,6 +4201,10 @@ void FormDraw::s_addJiegutext(QString strUuid, QString strSlfName, QString strWe
curv->yAxis->setTicks(false); curv->yAxis->setTicks(false);
curv->xAxis2->setTicks(false); curv->xAxis2->setTicks(false);
curv->yAxis2->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); QColor newlineColor=QColor(0,0,0);
QString strAliasName = "气测-FMT-射孔-文本"; QString strAliasName = "气测-FMT-射孔-文本";
@ -4571,6 +4603,10 @@ void FormDraw::s_addTubingstring(QString strUuid, QString strSlfName, QString st
curv->yAxis->setTicks(false); curv->yAxis->setTicks(false);
curv->xAxis2->setTicks(false); curv->xAxis2->setTicks(false);
curv->yAxis2->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"; //QString strWaveName = "TUBTOOLS";
@ -4774,6 +4810,11 @@ void FormDraw::initForm(QMyCustomPlot *widget, QString strSlfName, QString strLi
widget->xAxis->ticker()->setTickCount(10);//x个主刻度 widget->xAxis->ticker()->setTickCount(10);//x个主刻度
widget->yAxis->ticker()->setTickCount(60);//y个主刻度 widget->yAxis->ticker()->setTickCount(60);//y个主刻度
widget->xAxis->setVisible(false);
widget->xAxis2->setVisible(false);
widget->yAxis->setVisible(false);
widget->yAxis2->setVisible(false);
//对调XY轴在最前面设置 //对调XY轴在最前面设置
QCPAxis *yAxis = widget->yAxis; QCPAxis *yAxis = widget->yAxis;
QCPAxis *xAxis = widget->xAxis; QCPAxis *xAxis = widget->xAxis;
@ -5442,6 +5483,10 @@ void FormDraw::initTableLine(QMyCustomPlot *widget, QString strSlfName, QString
widget->yAxis->setTicks(false); widget->yAxis->setTicks(false);
widget->xAxis2->setTicks(false); widget->xAxis2->setTicks(false);
widget->yAxis2->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) if (m_bTableData)
{ {
@ -5493,6 +5538,10 @@ void FormDraw::initWords(QMyCustomPlot *widget, QString strSlfName, QString strL
widget->yAxis->setTicks(false); widget->yAxis->setTicks(false);
widget->xAxis2->setTicks(false); widget->xAxis2->setTicks(false);
widget->yAxis2->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); widget->LoadFromSLF_Text(strSlfName, strLineName);
@ -5539,6 +5588,10 @@ void FormDraw::initLayer(QMyCustomPlot *widget, QString strSlfName, QString strL
widget->yAxis->setTicks(false); widget->yAxis->setTicks(false);
widget->xAxis2->setTicks(false); widget->xAxis2->setTicks(false);
widget->yAxis2->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); widget->LoadFromSLF_Layer(strSlfName, strLineName);
@ -5588,6 +5641,10 @@ void FormDraw::initIMAGE_DATA(QMyCustomPlot *widget, QString strSlfName, QString
widget->yAxis->setTicks(false); widget->yAxis->setTicks(false);
widget->xAxis2->setTicks(false); widget->xAxis2->setTicks(false);
widget->yAxis2->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); widget->LoadFromIMAGE_SLF(strSlfName, strLineName);
//显示文本 //显示文本
@ -5699,6 +5756,10 @@ void FormDraw::initResult(QMyCustomPlot *widget, QString strSlfName, QString str
widget->yAxis->setTickLabels(false); widget->yAxis->setTickLabels(false);
widget->xAxis2->setTickLabels(false); widget->xAxis2->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); LoadFromSLF_Result(widget, strSlfName, strLineName);
@ -5793,6 +5854,10 @@ void FormDraw::initGeoLith(QMyCustomPlot *widget, QString strSlfName, QString st
widget->yAxis->setTicks(false); widget->yAxis->setTicks(false);
widget->xAxis2->setTicks(false); widget->xAxis2->setTicks(false);
widget->yAxis2->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) if(listOtherProperty.size()>=12)
@ -5903,6 +5968,10 @@ void FormDraw::initSwallCore(QMyCustomPlot *widget, QString strSlfName, QString
widget->yAxis->setTicks(false); widget->yAxis->setTicks(false);
widget->xAxis2->setTicks(false); widget->xAxis2->setTicks(false);
widget->yAxis2->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); widget->LoadFromSLF_SwallCore(strSlfName, strLineName);
@ -5950,6 +6019,10 @@ void FormDraw::initGujing(QMyCustomPlot *widget, QString strSlfName, QString str
widget->yAxis->setTicks(false); widget->yAxis->setTicks(false);
widget->xAxis2->setTicks(false); widget->xAxis2->setTicks(false);
widget->yAxis2->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); widget->LoadFromSLF_Gujing(strSlfName, strLineName);
@ -6826,6 +6899,10 @@ void FormDraw::initCorePhysics(QMyCustomPlot *widget, QString strSlfName, QStrin
widget->yAxis->setTicks(false); widget->yAxis->setTicks(false);
widget->xAxis2->setTicks(false); widget->xAxis2->setTicks(false);
widget->yAxis2->setTicks(false); widget->yAxis2->setTicks(false);
widget->xAxis->setVisible(false);
widget->xAxis2->setVisible(false);
widget->yAxis->setVisible(false);
widget->yAxis2->setVisible(false);
QVector<double> x, y; QVector<double> x, y;
@ -7072,6 +7149,10 @@ void FormDraw::DrawJykt(QMyCustomPlot *widget, QString strSlfName)
widget->yAxis->setTicks(false); widget->yAxis->setTicks(false);
widget->xAxis2->setTicks(false); widget->xAxis2->setTicks(false);
widget->yAxis2->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; float tempf,flVal;
@ -7198,6 +7279,10 @@ void FormDraw::DrawDenv(QMyCustomPlot *widget, QString strSlfName)
widget->yAxis->setTicks(false); widget->yAxis->setTicks(false);
widget->xAxis2->setTicks(false); widget->xAxis2->setTicks(false);
widget->yAxis2->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); QPen pPen(m_TailColor,m_nTailWidth);

View File

@ -10,6 +10,7 @@
#include "LogIO.h" #include "LogIO.h"
#include "MemRdWt.h" #include "MemRdWt.h"
#include "FormLine.h" #include "FormLine.h"
#include "common.h"
#pragma execution_character_set("utf-8") #pragma execution_character_set("utf-8")
@ -86,6 +87,8 @@ public:
// 跨道设置 // 跨道设置
void crossTrackSetting(); void crossTrackSetting();
void setBorderFlags(BorderFlags flags);
private: private:
Ui::FormDraw *ui; Ui::FormDraw *ui;
@ -126,6 +129,8 @@ public:
QStringList m_listWaveName; QStringList m_listWaveName;
QStringList m_listTableName; QStringList m_listTableName;
BorderFlags m_BorderFlags;
//X坐标 //X坐标
float m_vmax; float m_vmax;
float m_vmin; float m_vmin;

View File

@ -732,7 +732,7 @@ void FormInfo::paintEvent(QPaintEvent* event)
QRect rectRound(rect.left()+2,rect.top()+4, rect.width()-4, rect.height()-8); QRect rectRound(rect.left()+2,rect.top()+4, rect.width()-4, rect.height()-8);
painter.setPen(QPen(m_lineColor, m_dWidth, m_lineStyle)); painter.setPen(QPen(m_lineColor, m_dWidth, m_lineStyle));
//painter.drawRoundRect(rectRound);//利用画刷(颜色/岩性图片),画框 //painter.drawRoundRect(rectRound);//利用画刷(颜色/岩性图片),画框
painter.drawRect(rectRound); //painter.drawRect(rectRound);
QString strShowTxt = ""; QString strShowTxt = "";
painter.setBrush(Qt::NoBrush); // 确保文字不被填充色遮挡 painter.setBrush(Qt::NoBrush); // 确保文字不被填充色遮挡

View File

@ -171,6 +171,44 @@ FormInfo* FormTrack::getFormInfoByParameters(QString strUuid, QString strWellNam
return NULL; 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) // void FormTrack::setTrackPropert(QJsonObject trackObj)
// { // {

View File

@ -4,6 +4,7 @@
#include <QWidget> #include <QWidget>
#include "forminfo.h" #include "forminfo.h"
#include <QStyledItemDelegate> #include <QStyledItemDelegate>
#include "common.h"
#pragma execution_character_set("utf-8") #pragma execution_character_set("utf-8")
@ -56,9 +57,14 @@ public:
FormInfo* getFormInfoByParameters(QString strUuid, QString strWellName, FormInfo* getFormInfoByParameters(QString strUuid, QString strWellName,
QString strTrackName, QString strLineName); QString strTrackName, QString strLineName);
void setBorderFlags(BorderFlags flags);
private: private:
Ui::FormTrack *ui; Ui::FormTrack *ui;
protected:
void paintEvent(QPaintEvent *event);
public: public:
QString m_strUuid; QString m_strUuid;
// 道ID // 道ID
@ -69,7 +75,7 @@ public:
FormInfo *m_formInfo = NULL; FormInfo *m_formInfo = NULL;
// 创建自定义单元格委托 // 创建自定义单元格委托
//NoLRBorderDelegate *m_delegate; //NoLRBorderDelegate *m_delegate;
BorderFlags m_BorderFlags;
public: 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={}); 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={});

View File

@ -15,16 +15,16 @@
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>2</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>0</number> <number>2</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>0</number> <number>2</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>2</number>
</property> </property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="PreQTableWidget" name="tableWidget"/> <widget class="PreQTableWidget" name="tableWidget"/>

View File

@ -30,6 +30,11 @@ FormTrackTop::~FormTrackTop()
delete ui; delete ui;
} }
void FormTrackTop::setBorderFlags(BorderFlags flags)
{
m_BorderFlags = flags;
}
void FormTrackTop::setTrackTopPropert(QJsonObject topObj) void FormTrackTop::setTrackTopPropert(QJsonObject topObj)
{ {
if (topObj.contains("Font")) if (topObj.contains("Font"))
@ -60,6 +65,8 @@ QJsonObject FormTrackTop::makeJson()
void FormTrackTop::paintEvent(QPaintEvent* event) void FormTrackTop::paintEvent(QPaintEvent* event)
{ {
QWidget::paintEvent(event);
QPainter painter(this); QPainter painter(this);
QRect rect = this->rect(); QRect rect = this->rect();
//背景透明 //背景透明
@ -70,7 +77,33 @@ void FormTrackTop::paintEvent(QPaintEvent* event)
painter.setPen(m_fontColor); // fontColor QColor(220, 220, 220) painter.setPen(m_fontColor); // fontColor QColor(220, 220, 220)
painter.drawText(rect.left(), rect.top(), rect.width(), rect.height(), Qt::AlignCenter, m_strTrackName); 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) void FormTrackTop::dragEnterEvent(QDragEnterEvent* event)

View File

@ -8,6 +8,7 @@
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>
#include <QJsonArray> #include <QJsonArray>
#include "common.h"
#pragma execution_character_set("utf-8") #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)); explicit FormTrackTop(QWidget *parent = nullptr, QString strSlfName="", QString strWellName="", QString strTrackName="", QString strLineName="", QColor lineColor=QColor(255,0,0));
~FormTrackTop(); ~FormTrackTop();
void setBorderFlags(BorderFlags flags);
void setTrackTopPropert(QJsonObject topObj); void setTrackTopPropert(QJsonObject topObj);
private: private:
Ui::FormTrackTop *ui; Ui::FormTrackTop *ui;
@ -50,6 +53,7 @@ public:
QFont m_font; QFont m_font;
QColor m_fontColor;//颜色 QColor m_fontColor;//颜色
BorderFlags m_BorderFlags;
public: public:

View File

@ -23,17 +23,15 @@ FormWell::FormWell(QWidget *parent, QString strWellName) :
// //
ui->tableWidget->verticalHeader()->hide(); //行 ui->tableWidget->verticalHeader()->hide(); //行
//ui->tableWidget->horizontalHeader()->hide();//列 ui->tableWidget->horizontalHeader()->hide();//列
int rowcount = 3; //总行数 int rowcount = 3; //总行数
ui->tableWidget->setRowCount(rowcount); //动态设置行数 ui->tableWidget->setRowCount(rowcount); //动态设置行数
//ui->tableWidget->verticalHeader()->setFixedWidth(3);//标题栏宽度 //ui->tableWidget->verticalHeader()->setFixedWidth(3);//标题栏宽度
ui->tableWidget->horizontalHeader()->setFixedHeight(3); ui->tableWidget->horizontalHeader()->setFixedHeight(3);
//左右边框隐藏
ui->tableWidget->setStyleSheet("QTableView::item {border-left: 0px solid black;} \ ui->tableWidget->setShowGrid(false);
QTableView::item:selected {border-left: 0px solid black; color:#57595B; background:#E4E4E4;}\ ui->tableWidget->setStyleSheet("QTableView {border: 0px solid black;} QTableView::item {border: 0px solid black;} \
QTableView::item {border-right: 0px solid black;} \ QTableView::item:selected {color:#57595B; background:#E4E4E4;}");
QTableView::item:selected {border-right: 0px solid black;}");
//"QTableView::item:selected {color:#57595B; background:#E4E4E4;}"
// 假设你的类中有一个槽函数onTableRowsInserted(QModelIndex parent, int first, int last) // 假设你的类中有一个槽函数onTableRowsInserted(QModelIndex parent, int first, int last)
//connect(ui->tableWidget->model(), &QAbstractItemModel::columnsInserted, //connect(ui->tableWidget->model(), &QAbstractItemModel::columnsInserted,
@ -189,6 +187,7 @@ QVector<QWidget *> FormWell::new_track(QStringList listdt, QString strTrackName)
ui->tableWidget->setRowHeight(i, 100); ui->tableWidget->setRowHeight(i, 100);
// //
FormTrackTop* trackTop= new FormTrackTop(this, strSlfName, strWellName, strTrackName); FormTrackTop* trackTop= new FormTrackTop(this, strSlfName, strWellName, strTrackName);
trackTop->setBorderFlags(BorderFlags(BottomBorder | RightBorder));
// if ("curveObject" == strType) // if ("curveObject" == strType)
// trackTop->setFixedWidth(nW/2); // trackTop->setFixedWidth(nW/2);
vec << trackTop; vec << trackTop;
@ -203,6 +202,7 @@ QVector<QWidget *> FormWell::new_track(QStringList listdt, QString strTrackName)
//曲线名称栏 //曲线名称栏
formTrack = new FormTrack(this, strWellName, strTrackName); formTrack = new FormTrack(this, strWellName, strTrackName);
formTrack->setBorderFlags(BorderFlags(BottomBorder | RightBorder));
// if ("curveObject" == strType) // if ("curveObject" == strType)
// formTrack->setFixedWidth(nW / 2); // formTrack->setFixedWidth(nW / 2);
vec << formTrack; vec << formTrack;
@ -228,6 +228,7 @@ QVector<QWidget *> FormWell::new_track(QStringList listdt, QString strTrackName)
ui->tableWidget->setRowHeight(i, (int)dHight);//7582 ui->tableWidget->setRowHeight(i, (int)dHight);//7582
//曲线绘制栏 //曲线绘制栏
FormDraw *formDraw = new FormDraw(this, strWellName, strTrackName); FormDraw *formDraw = new FormDraw(this, strWellName, strTrackName);
formDraw->setBorderFlags(BorderFlags(BottomBorder | RightBorder));
vec << formDraw; vec << formDraw;
formDraw->m_iY1 = m_iY1; formDraw->m_iY1 = m_iY1;
formDraw->m_iY2 = m_iY2; formDraw->m_iY2 = m_iY2;
@ -244,6 +245,11 @@ QVector<QWidget *> FormWell::new_track(QStringList listdt, QString strTrackName)
return vec; return vec;
} }
void FormWell::setBorderFlags(BorderFlags flags)
{
m_BorderFlags = flags;
}
int FormWell::getTableWidgetColumn(QString strTrackUuid) int FormWell::getTableWidgetColumn(QString strTrackUuid)
{ {
int nret = -1; int nret = -1;
@ -260,6 +266,36 @@ int FormWell::getTableWidgetColumn(QString strTrackUuid)
return nret; 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) void FormWell::s_Raise(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int iTableType, QString strFormInfoType)
{ {
if(m_strUuid == strUuid && if(m_strUuid == strUuid &&

View File

@ -5,6 +5,7 @@
#include "formtrack.h" #include "formtrack.h"
#include "formdraw.h" #include "formdraw.h"
#include "formtracktop.h" #include "formtracktop.h"
#include "common.h"
#pragma execution_character_set("utf-8") #pragma execution_character_set("utf-8")
@ -25,9 +26,12 @@ public:
QVector<QWidget*> new_track(QStringList listdt, QString strTrackName = ""); QVector<QWidget*> new_track(QStringList listdt, QString strTrackName = "");
void setBorderFlags(BorderFlags flags);
// 根据道ID获取列索引 // 根据道ID获取列索引
int getTableWidgetColumn(QString strTrackUuid); int getTableWidgetColumn(QString strTrackUuid);
protected:
void paintEvent(QPaintEvent *event);
private: private:
Ui::FormWell *ui; Ui::FormWell *ui;
@ -43,6 +47,8 @@ public:
// 道图形 // 道图形
QMap<QString, QVector<QWidget*>> m_mapFormDraw; QMap<QString, QVector<QWidget*>> m_mapFormDraw;
BorderFlags m_BorderFlags;
public: public:
QJsonObject makeJson(); QJsonObject makeJson();
QStringList getLineList(QString strWellName, QString strTrackName); QStringList getLineList(QString strWellName, QString strTrackName);

View File

@ -15,16 +15,16 @@
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>2</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>0</number> <number>2</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>0</number> <number>2</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>2</number>
</property> </property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QMyTableWidget" name="tableWidget"/> <widget class="QMyTableWidget" name="tableWidget"/>

View File

@ -20,6 +20,7 @@
<QtMoc Include="transparentdraggableSelectRect.h" /> <QtMoc Include="transparentdraggableSelectRect.h" />
<QtMoc Include="..\CallManage\CallManage.h" /> <QtMoc Include="..\CallManage\CallManage.h" />
<QtMoc Include="..\common\dropdownbutton.h" /> <QtMoc Include="..\common\dropdownbutton.h" />
<ClInclude Include="..\common\common.h" />
<ClInclude Include="..\common\geometryutils.h" /> <ClInclude Include="..\common\geometryutils.h" />
<ClInclude Include="3rd_qcustomplot\smoothcurve.h" /> <ClInclude Include="3rd_qcustomplot\smoothcurve.h" />
<QtMoc Include="3rd_qcustomplot\v2_1\qcustomplot.h" /> <QtMoc Include="3rd_qcustomplot\v2_1\qcustomplot.h" />
@ -35,6 +36,7 @@
<ClInclude Include="GeoIndicatorGenerator.h" /> <ClInclude Include="GeoIndicatorGenerator.h" />
<ClInclude Include="Gradient.h" /> <ClInclude Include="Gradient.h" />
<QtMoc Include="mainwindowsplitter.h" /> <QtMoc Include="mainwindowsplitter.h" />
<ClInclude Include="ItemBorderDelegate.h" />
<ClInclude Include="ObjectArchive.h" /> <ClInclude Include="ObjectArchive.h" />
<QtMoc Include="ViewInfo.h" /> <QtMoc Include="ViewInfo.h" />
<QtMoc Include="variantmanager.h" /> <QtMoc Include="variantmanager.h" />

View File

@ -68,6 +68,12 @@
<ClInclude Include="..\common\geometryutils.h"> <ClInclude Include="..\common\geometryutils.h">
<Filter>common</Filter> <Filter>common</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="ItemBorderDelegate.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\common\common.h">
<Filter>common</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<QtMoc Include="ConsoleOutputWidget.h"> <QtMoc Include="ConsoleOutputWidget.h">

View File

@ -17,6 +17,7 @@
#include "selectwelldialog.h" #include "selectwelldialog.h"
#include "mainwindow.h" #include "mainwindow.h"
#include <QSvgGenerator> #include <QSvgGenerator>
#include "ItemBorderDelegate.h"
//主窗口为了方便获取tab当前页 //主窗口为了方便获取tab当前页
extern MainWindow *g_mainWindow; extern MainWindow *g_mainWindow;
@ -66,17 +67,19 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) :
ui->toolBar_3->hide(); ui->toolBar_3->hide();
ui->toolBar_plugin->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->setFrameShape(QFrame::NoFrame); //设置无边框
//隐藏网格线 //隐藏网格线
ui->tableWidget_2->setShowGrid(false); ui->tableWidget_2->setShowGrid(false);
//设置样式表,只显示竖直边框 ui->tableWidget_2->setItemDelegate(new ItemBorderDelegate(ui->tableWidget_2));
ui->tableWidget_2->setStyleSheet( "QTableView::item {border-left: 1px solid black;} \
QTableView::item:selected {border-left: 1px solid black; color:#57595B; background:#E4E4E4;}\ ui->tableWidget_2->setStyleSheet("QTableView {border: 0px solid black;} QTableView::item {border: 0px solid black;} \
QTableView::item {border-right: 1px solid black;} \ QTableView::item:selected {color:#57595B; background:#E4E4E4;}");
QTableView::item:selected {border-right: 1px solid black;}");
ui->tableWidget_2->verticalHeader()->hide(); //行 ui->tableWidget_2->verticalHeader()->hide(); //行
@ -2904,6 +2907,7 @@ void MainWindowCurve::s_NewWell(QString strWellName, QString strSlfName)
ui->tableWidget_2->setRowHeight(i, 100); ui->tableWidget_2->setRowHeight(i, 100);
// //
QTableWidgetItem* item = new QTableWidgetItem(strWellName); QTableWidgetItem* item = new QTableWidgetItem(strWellName);
setItemBorderFlags(item, BorderFlags(TopBorder | BottomBorder | LeftBorder | RightBorder));
item->setData(Qt::UserRole + 1, strSlfName); item->setData(Qt::UserRole + 1, strSlfName);
item->setFlags(item->flags() & (~Qt::ItemIsEditable)); item->setFlags(item->flags() & (~Qt::ItemIsEditable));
item->setTextAlignment(Qt::AlignCenter); //设置文本居中 item->setTextAlignment(Qt::AlignCenter); //设置文本居中
@ -2928,6 +2932,7 @@ void MainWindowCurve::s_NewWell(QString strWellName, QString strSlfName)
ui->tableWidget_2->setRowHeight(i, (int)dHight);//8020 ui->tableWidget_2->setRowHeight(i, (int)dHight);//8020
// //
FormWell *widgetWell = new FormWell(this, strWellName); FormWell *widgetWell = new FormWell(this, strWellName);
widgetWell->setBorderFlags(BorderFlags(BottomBorder | LeftBorder | RightBorder));
widgetWell->m_iY1 = m_iY1; widgetWell->m_iY1 = m_iY1;
widgetWell->m_iY2 = m_iY2; widgetWell->m_iY2 = m_iY2;
widgetWell->m_strUuid = m_strUuid; widgetWell->m_strUuid = m_strUuid;

View File

@ -15,14 +15,26 @@
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin"> <property name="rightMargin">
<number>3</number> <number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property> </property>
<item row="1" column="1"> <item row="1" column="1">
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QTableWidget" name="tableWidget_2"/> <widget class="QTableWidget" name="tableWidget_2"/>
</item> </item>
<item>
<widget class="QWidget" name="widget" native="true"/>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>

View File

@ -73,6 +73,10 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel
yAxis->setTickLabels(false); yAxis->setTickLabels(false);
xAxis2->setTickLabels(false); xAxis2->setTickLabels(false);
xAxis2->setTickLabels(false); xAxis2->setTickLabels(false);
xAxis->setVisible(false);
xAxis2->setVisible(false);
yAxis->setVisible(false);
yAxis2->setVisible(false);
xAxis->grid()->setVisible(false); xAxis->grid()->setVisible(false);
yAxis->grid()->setVisible(false); yAxis->grid()->setVisible(false);
@ -358,6 +362,10 @@ void QMyCustomPlot::initWave(QString strSlfName, QString strWaveName)
widget->yAxis->setTickLabels(false); widget->yAxis->setTickLabels(false);
widget->xAxis2->setTickLabels(false); widget->xAxis2->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轴在最前面设置 //对调XY轴在最前面设置
QCPAxis *yAxis = widget->yAxis; QCPAxis *yAxis = widget->yAxis;