335 lines
8.4 KiB
C++
335 lines
8.4 KiB
C++
#ifndef GRIDDATAADAPTER_H
|
|
#define GRIDDATAADAPTER_H
|
|
#include "CStringType.h"
|
|
#include <QObject>
|
|
#include <QVariant>
|
|
#include <QList>
|
|
#include <QPair>
|
|
#include <QAbstractTableModel>
|
|
#include <QMultiMap>
|
|
#include <QRunnable>
|
|
#include <QEvent>
|
|
#include <QPaintEvent>
|
|
#include <QFutureWatcher>
|
|
#include <QMouseEvent>
|
|
#include <QScrollBar>
|
|
#include <QHeaderView>
|
|
#include <PaiTableWidget.h>
|
|
#include <QTableWidgetSelectionRange>
|
|
#include <QMutex>
|
|
#include <QMenu>
|
|
#include <QApplication>
|
|
#include "BaseFun.h"
|
|
// #include "ObjCoreImage.h"
|
|
#include "GeometryUtils.h"
|
|
// #include "ObjWellLogWavefile.h"
|
|
#include "ObjWelllog.h"
|
|
#include "LogIO.h"
|
|
// #include "CurveLineLog.h"
|
|
// #include "ObjWelllogTABLE.h"
|
|
// #include "ObjWelllogTDT.h"
|
|
// #include "ObjWelllogFMT.h"
|
|
#include "DepthProgress.h"
|
|
#include "adapter_defs.h"
|
|
|
|
/**
|
|
* @file GridDataAdapter.h
|
|
* @date 2020/03/02
|
|
* @auto luol add
|
|
* 局部刷新填充数据 编辑时实保存 导出 导入
|
|
*/
|
|
|
|
using namespace pai::datamodel;
|
|
using namespace pai::gui;
|
|
|
|
|
|
class QTableWidgetItem;
|
|
class CDataManagger;
|
|
class TipPop;
|
|
class AssetCopy;
|
|
|
|
class WellLogHeaderView:public QHeaderView
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
WellLogHeaderView(Qt::Orientation orientation=Qt::Horizontal, QWidget *parent = 0);
|
|
~WellLogHeaderView();
|
|
signals:
|
|
void signalClickedSectionLogicalIndex(int logincalIndex);
|
|
//void setSelectionChecked(const QModelIndex &index);
|
|
protected:
|
|
void mouseReleaseEvent(QMouseEvent *evt);
|
|
|
|
void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const;
|
|
void paintEvent(QPaintEvent *pevt);
|
|
private:
|
|
int m_logicalIndex;
|
|
|
|
};
|
|
|
|
class TableModel : public QAbstractTableModel
|
|
{
|
|
public:
|
|
TableModel(QObject* parent=NULL);
|
|
|
|
// QAbstractItemModel interface
|
|
public:
|
|
int rowCount(const QModelIndex &parent) const;
|
|
int columnCount(const QModelIndex &parent) const;
|
|
QVariant data(const QModelIndex &index, int role) const;
|
|
|
|
QStringList tableHeaderData();
|
|
|
|
void setModelData(const QList< QList<DataPair> > &model );
|
|
void setTableHeaderData(const QStringList &headerLst);
|
|
void clearBuffer();
|
|
void clearHeader();
|
|
|
|
private:
|
|
QList< QList<DataPair> > m_dataBuffer;
|
|
QStringList m_headerData;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class GridDataAdapter : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
typedef void (GridDataAdapter::*pChangeComplete)();
|
|
GridDataAdapter(QTableWidget* table,QScrollBar *horizontalScrollBar,QScrollBar *verticalScrollBar,QObject* parent=NULL);
|
|
~GridDataAdapter();
|
|
|
|
|
|
|
|
void setModelData(const QList< QList<DataPair> > &model);
|
|
void setTableHeaderData(const QStringList &headerLst);
|
|
//清空缓存
|
|
void clearBuffer();
|
|
//设置总行数
|
|
void setRowCount(int rowCount);
|
|
//设置总列数
|
|
void setColCount(int colCount);
|
|
//绑定数据并初始数据
|
|
void bindData();
|
|
|
|
void initWellData(DType type,CObjWell* pwell);
|
|
void updateWellData();
|
|
|
|
void initWellLogData(DType type,QList<CObjWellLog*> WellLogs);
|
|
void updatetWellLogData();
|
|
|
|
void initMultWellLogData(DType type,QList<CObjWellLog*> WellLogs);
|
|
void initFMTWellLogData(DType type,QList<CObjWellLog*> WellLogs);
|
|
void initTDTWellLogData(DType type,QList<CObjWellLog*> WellLogs);
|
|
void updatetMultWellLogData();
|
|
void updatetTDTWellLogData();
|
|
void updatetFMTWellLogData();
|
|
|
|
void initTableWellLogData(DType type,QList<CObjWellLog*> WellLogs);
|
|
void updatetTableWellLogData();
|
|
|
|
void addActonMenu(int type);
|
|
|
|
void ReFreshWindow(int type);
|
|
|
|
int dataRowCount();
|
|
int dataColCount();
|
|
|
|
void CommitToSave();
|
|
//导出数据
|
|
bool tableToCSVFile();
|
|
bool dataInfoHeader(CLogIO *logio,QStringList &fieldList,QString &wellName,int &rowCount);
|
|
//导入数据
|
|
bool importToFile();
|
|
|
|
void switchLogView(bool isSwitch);
|
|
void reqCustomComtextMenu(const QPoint &pos);
|
|
|
|
void ReFreshDisplayCurve();
|
|
|
|
int getRecordCount();
|
|
|
|
protected:
|
|
virtual bool eventFilter(QObject *pSender, QEvent * pEvent) override;
|
|
|
|
public:
|
|
DType m_dtype;
|
|
int m_middleWidth;
|
|
int m_gridWidth;
|
|
|
|
signals:
|
|
void signalCommitToSave();
|
|
void signalReqCustomContextMenu(const QPoint &pos);
|
|
|
|
public slots:
|
|
void onDeleteLinesData();
|
|
void addALine_SLOT();
|
|
void addALine_SLOT(int);
|
|
void sortSequence_SLOT();
|
|
void sortCompute_SLOT();
|
|
|
|
private slots:
|
|
void slotVerScrollValueChange(int value);
|
|
void slotHorScrollValueChange(int value);
|
|
|
|
void slotScrollChangeComplete();
|
|
void slotCellDoubleClicked(int row,int col);
|
|
void slotCellClicked(int row,int col);
|
|
//保存
|
|
void slotCommitToSave();
|
|
//void slotModelDataComplete(DType type,const QList< QList<DataPair> >& dataBuffer);
|
|
void slotVerScrollBarPressed();
|
|
void slotVerScrollBarReleased();
|
|
void slotHorScrollBarPressed();
|
|
void slotHorScrollBarReleased();
|
|
//
|
|
void slotSectionClicked(int logincIndex);
|
|
void onParseData(const QTableWidgetSelectionRange &parseRange);
|
|
|
|
void refreshTempModel_SLOT();
|
|
void itemChange_SLOT(int, int);
|
|
private:
|
|
bool VerScrollUp;
|
|
bool VerScrollChanged;
|
|
|
|
int DefRowHeight;
|
|
int DefColWidth;
|
|
void initColWH();
|
|
bool haveDoubleClicked;
|
|
|
|
void buildItemList();
|
|
bool isCellChanged();
|
|
//更新缓存数据并刷新视图
|
|
void updateTableView();
|
|
//滚动刷新
|
|
void valueChange();
|
|
//计算行列
|
|
void calcuPageRowsCols();
|
|
//重置编辑范围
|
|
void resetEditRange();
|
|
//更新pagerow
|
|
void calNewPageRow();
|
|
//保存井数据 数据行
|
|
void saveWellData(QList<QList<double> > data,QList<int> modifyRows);
|
|
//提取井数据
|
|
void extractWellData(QList<QList<double> > &editData,QList<int> &modifyRows ,bool &isScuccess);
|
|
void getWellData(int row,int col,QList<double>& wellXYZ,bool& covSuccss);
|
|
//保存曲线数据
|
|
void saveWellLogData(QList<QList<float> > depthList);
|
|
|
|
void fillDefaultTitle(QStringList& fields,int pageCol);
|
|
//提取曲线数据
|
|
void extractWellLogData(QList<QList<float> > &editData ,bool &isScuccess);
|
|
////////////////////////////////////////////////////
|
|
//保存波列数据
|
|
void saveMultWellLogData(bool &isScuccess);
|
|
//提取波列数据
|
|
//void extractMultWellLogData(int &row,int &col,float &value,bool &isScuccess);
|
|
void extractMultWellLogData(QList<QList<float> > &editData,bool &isScuccess);
|
|
//////////////////////////////////////////////////
|
|
//保存表
|
|
void saveTableWellLogData(bool &isScuccess);
|
|
//导入表格数据
|
|
void importTableWellLogData(QFile &importFile);
|
|
|
|
//导出井眼轨迹数据
|
|
void exportWellData(FILE *fp, DepthProgress& process);
|
|
//导出曲线数据
|
|
void exportWellLogData(FILE *fp, DepthProgress& process);
|
|
//导入曲线数据
|
|
void importWellLogData(QFile &importFile, DepthProgress& process);
|
|
|
|
//导出多维数据
|
|
void exportMultWellLogData(FILE *fp, DepthProgress& process);
|
|
//导出表格数据
|
|
void exportTableWellLogData(FILE *fp, DepthProgress& process);
|
|
//获取头信息行列
|
|
bool getRowsColumnsByHeader(QFile &importFile,int &rows,int &columns,QString &contentLine);
|
|
float getData(int repCode,char *buffer);
|
|
void setData(int repCode,char *buffer,double yy);
|
|
|
|
//附加曲线统计、属性编辑、计算视图
|
|
void attachWellLogView();
|
|
void hideWellLogView();
|
|
void bindWellLogData(int wellLogIndex);
|
|
|
|
//更新临时存储
|
|
void refreshTempModel();
|
|
|
|
//插入一行
|
|
void addALine(int);
|
|
private:
|
|
int m_pageRow;
|
|
int m_pageCol;
|
|
int m_dataRowCount;
|
|
int m_dataColCount;
|
|
int *itemWidth;//单元格宽度
|
|
bool ifItemWidth;
|
|
|
|
int m_verScrolValue;
|
|
int m_horScrolValue;
|
|
QScrollBar *m_verScrolBar;
|
|
QScrollBar *m_horScrolBar;
|
|
PFLOATPROPERTY *m_MutiVM;
|
|
// CObjWellLogWavefile *m_pWave;
|
|
// CObjWellLogTDT *m_pTDT;
|
|
// CObjWellLogFMT *m_pFMT;
|
|
QList<QTableWidgetItem*> m_pageItems;
|
|
QTableWidget* m_table;
|
|
TableModel* m_tmodel;
|
|
//////////////initWellData///////////////////////////
|
|
CObjWell* m_pWell;
|
|
//////////////initWellLogData///////////////////////////
|
|
QStringList m_TitleField;
|
|
QList<CObjWellLog*> m_pWellLogs;
|
|
|
|
PFLOATPROPERTY **vP;
|
|
////////////////////initTableWellLogData////////////////////////////////
|
|
int recordcount;
|
|
//修改后的行列值
|
|
QMultiMap<int ,int> modifyRowCols;
|
|
private:
|
|
QString fileName;
|
|
QString curveName;
|
|
int StartDepth;
|
|
int EndDepth;
|
|
int StartDim;
|
|
int EndDim;
|
|
///
|
|
int DepLevel;
|
|
|
|
float m_SDep;
|
|
float m_EDep;
|
|
float m_Rlev;
|
|
int m_nSamples;
|
|
int m_flRlev2;
|
|
int m_PointNum;
|
|
int m_RepCode;
|
|
int m_CodeLen;
|
|
int m_SamplePoint;
|
|
private:
|
|
|
|
QFutureWatcher<void> watcher;
|
|
QMutex m_mutex;
|
|
pChangeComplete m_pComplete;
|
|
//记录编辑选中范围
|
|
QTableWidgetSelectionRange m_editRange;
|
|
//用于比较是否修改判定字符
|
|
QString m_cellText;
|
|
CDataManagger *m_mgr;
|
|
TipPop *m_popTip;
|
|
bool m_switch;
|
|
int m_nVerScrollValue;
|
|
AssetCopy* m_pAssetCopy;
|
|
QMenu *m_menu;
|
|
|
|
bool canLoadFromSLF;
|
|
FLOATPROPERTY tempdata;
|
|
};
|
|
|
|
#endif // GRIDDATAADAPTER_H
|