From cf80a84c9e449c91658ecf09b2d5e8e8c6dc0d08 Mon Sep 17 00:00:00 2001 From: jiayulong Date: Tue, 11 Nov 2025 09:02:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E5=A4=B4=E6=A1=86=E6=9E=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=8C=E6=94=AF=E6=8C=81=E5=B1=85=E4=B8=AD=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=EF=BC=8C=E4=B8=8A=E4=B8=8B=E6=8B=96=E6=8B=89=E6=94=BE?= =?UTF-8?q?=E5=A4=A7=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WellLogUI/include/CStringType.h | 167 ++ WellLogUI/include/PaiTableWidget.h | 192 ++ WellLogUI/include/assetcopy.h | 71 + WellLogUI/include/griddataadapter.h | 334 +++ WellLogUI/src/CStringType.cpp | 324 +++ WellLogUI/src/TipPop.cpp | 109 + WellLogUI/src/TipPop.h | 29 + WellLogUI/src/adapter_defs.h | 51 + WellLogUI/src/assetcopy.cpp | 705 ++++++ WellLogUI/src/griddataadapter.cpp | 3576 +++++++++++++++++++++++++++ logPlus/formhead.cpp | 289 ++- logPlus/formhead.h | 17 +- logPlus/formmultiheads.cpp | 172 ++ logPlus/formmultiheads.h | 29 + logPlus/formmultiheads.ui | 36 + logPlus/logPlus.pro | 3 + logPlus/mainwindow.h | 9 +- logPlus/mainwindowcurve.cpp | 194 +- logPlus/mainwindowcurve.h | 6 + 19 files changed, 6211 insertions(+), 102 deletions(-) create mode 100644 WellLogUI/include/CStringType.h create mode 100644 WellLogUI/include/PaiTableWidget.h create mode 100644 WellLogUI/include/assetcopy.h create mode 100644 WellLogUI/include/griddataadapter.h create mode 100644 WellLogUI/src/CStringType.cpp create mode 100644 WellLogUI/src/TipPop.cpp create mode 100644 WellLogUI/src/TipPop.h create mode 100644 WellLogUI/src/adapter_defs.h create mode 100644 WellLogUI/src/assetcopy.cpp create mode 100644 WellLogUI/src/griddataadapter.cpp create mode 100644 logPlus/formmultiheads.cpp create mode 100644 logPlus/formmultiheads.h create mode 100644 logPlus/formmultiheads.ui diff --git a/WellLogUI/include/CStringType.h b/WellLogUI/include/CStringType.h new file mode 100644 index 0000000..ab98f90 --- /dev/null +++ b/WellLogUI/include/CStringType.h @@ -0,0 +1,167 @@ +/** +* @file CStringTyle.h +* @brief CString数据自定义、井以及井次结构体 +* @date 2014-10-10 +* @author: ZhouWenfei +*/ + +#ifndef PAI_FRAME_CSTRING_H__ +#define PAI_FRAME_CSTRING_H__ +#pragma once +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#pragma execution_character_set("utf-8") +#pragma warning( push ,0) +//#include "BaseFunExport.h" +#pragma warning( pop ) +//#ifdef MessageBox +//#define MessageBox MessageBox +//#endif +#define MAX_PATH 1024 +//#define _MAX_PATH 1024 +#define MaxCurve 1024 +#define curve_name_len 256 +#define curve_unit_len 256 +#define MIN_RANK rank_char +#define MAX_RANK rank_longlong + +#define INTMAX_RANK rank_longlong +#define SIZE_T_RANK rank_long +#define PTRDIFF_T_RANK rank_long +#define MB_OK QMessageBox::Ok +typedef unsigned short WORD; +#ifdef WIN32 +typedef unsigned long DWORD; +typedef DWORD *LPDWORD; +typedef void *HANDLE; +#else +typedef unsigned int DWORD; +typedef DWORD *LPDWORD; +typedef void *HANDLE; +#endif +typedef unsigned char BYTE; +typedef char* LPSTR; +typedef void* LPVOID; + +class CString; +typedef QList CStringList; + +using namespace std; + + + +//#define REPR_INT 1 +//#define REPR_SHORT 2 +//#define REPR_LONG 3 +//#define REPR_FLOAT 4 +//#define REPR_DOUBLE 5 +//#define REPR_STRING 6 +//#define REPR_CHAR 7 +//#define REPR_UCHAR 8 +//#define REPR_USHORT 9 +//#define REPR_UINT 10 +//#define REPR_ULONG 11 +//class BASEFUN_EXPORT CString; + +//构建CString +class CString +{ +public: + CString(const char *str = nullptr); + CString(const QString str); + CString(const CString &other); + ~CString(); + + int GetLength()const; + int Find(char *str); + int Find(char str); + int Find(CString &another); + int Find(char str[],int start); + int ReverseFind(char ch); + int Insert(int pos ,const CString Sctr); + int Replace(const char *Src,const char *Dest); + CString & TrimLeft(); + CString & MakeUpper(); + CString& MakeLower(); + CString & TrimRight(); + bool operator==(const char* other ); + bool operator!=(const char* other ); + bool operator==(const CString& other ); + bool operator!=(const CString& other ); + char operator[](int i); + CString Right(int count)const; + CString Left(int count)const; +// CString operator = (const QString& SrcStr) ; + CString operator + (const CString& SrcStr) ; + CString operator += (CString& SrcStr) ; + CString operator += (const CString& SrcStr) ; + char* GetString()const; + char GetChar(int n); + char GetAt(int n); + CString Mid(int pos,int count)const; + CString Mid(int pos)const; + void Format(const char *format,...); + void Delete(int fromIndex,int length); +// const char *m_temp; + void Alloc(int len); + void Empty(); +private: + QString m_data; +}; + + + + + +enum flags { +FL_SPLAT0 = 0x00,/* Drop the value, do not assign */ + +FL_SPLAT = 0x01,/* Drop the value, do not assign */ +FL_INV = 0x02,/* Character-set with inverse */ +FL_WIDTH = 0x04,/* Field width specified */ +FL_MINUS = 0x08,/* Negative number */ + +}; + +enum ranks { + +rank_char = -2, +rank_short = -1, +rank_int = 0, +rank_long = 1, +rank_longlong = 2, +rank_ptr = INT_MAX/* Special value used for pointers */ + +}; + + + +enum bail { + + bail_none = 0,/* No error condition */ + bail_eof,/* Hit EOF */ + bail_err/* Conversion mismatch */ + +}; +int AfxMessageBox(CString str); +int MessageBox(QWidget *parent,char lpText[128],char*lpCaption, int UINTuType); +void ShowMessage(QString mess); + +//构建AfxMessageBox()函数 +//extern int BASEFUN_EXPORT AfxMessageBox(CString str); +//extern int BASEFUN_EXPORT MessageBox(QWidget *parent,char lpText[128],char*lpCaption, int UINTuType); +// using namespace pai::graphics; +#endif + diff --git a/WellLogUI/include/PaiTableWidget.h b/WellLogUI/include/PaiTableWidget.h new file mode 100644 index 0000000..cfc657b --- /dev/null +++ b/WellLogUI/include/PaiTableWidget.h @@ -0,0 +1,192 @@ + +#ifndef PAI_FRAME_ICONSOLE_PAITABLEWIDGET_H +#define PAI_FRAME_ICONSOLE_PAITABLEWIDGET_H + +#include +#include +#include +#include +namespace pai +{ +namespace gui +{ + +//class PaiCheckBox; + +/** + * @class PaiTableWidget + * @brief PaiTableWidget 是P.A.I系统定制发布的表格控件 + */ +class PaiTableWidget : public QTableWidget +{ + Q_OBJECT +public: + PaiTableWidget(QWidget* pParent = NULL); + virtual ~PaiTableWidget(); + + /** + * @brief 表格高度自增加,不会出现滚动条 + * @param[in] ok 是否自动增加 + * @param[in] maxRowCount 当行数超过该数字时高度不再增加,出现滚动条 + */ + void SetAutoHeight(const bool ok, const int maxRowCount = 10); + + /** + * @brief 删除多行 + * @param[in] rowIndex 从该行开始删除 + * @param[in] count 删除的行数, 如果越界将到最大行时终止 + */ + void RemoveRows(const int rowIndex, const int count); + + /** + * @brief 删除所有行 + */ + void RemoveRows(); + + /** + * @brief 设置是否显示单元格边框 + * @param[in] hor 水平方向线 + * @param[in] ver 垂直方向线 + */ + void setShowGrid(bool hor, bool ver); + + /** + * @brief 设置当表格内容为空时要显示的提示字符串 + * @param msg 提示信息 + */ + void ShowPromptMessage(const QString &msg); + + /** + * @brief 设置当表格内容为空时要显示的提示字符串 + * @param str 字符串 + */ + void SetFilterEmptyMessage(const QString &str); + + /** + * @brief 设置是否可以在表格上可以有选择行的显示某些列的功能 + * @param[in] selectable 是否打开该功能 + */ + void SetColumnVisibleSelectable(bool selectable); + + /** + * @brief 设置不可以被隐藏的列 + * @param[in] columnList 不可以被隐藏的列的名字列表 + */ + void SetUnselectableColumns(const QStringList& columnList); + + /** + *@brief 恢复记录的非隐藏表头 + */ + void RecallMemberedSections(); + + /** + * @brief 设置是否可选中列,如果可选中则会在指定列的左侧添加一个CheckBox.(只可作用于水平表头) + * @param[in] logicalIndex 目标列的逻辑索引 + * @param[in] checkable 是否可选中 + * @param[in] pCheckBox 需要添加的CheckBox,如果checkable为false,则可不传递此参数。 + */ + void SetColumnCheckable(const int logicalIndex, const bool checkable, QCheckBox *pCheckBox = NULL); + +public slots: + /** + * @brief 根据关键字搜索 + * @param[in] keyword 搜索的关键字 + * @param[in] col 要搜索的列 + */ + void Filter(const QString & keyword, int col = 0); + + /** + * @brief 根据关键字搜索 + * @param[in] keyword 搜索的关键字 + * @param[in] cols 要搜索的列 + */ + void Filter(const QString & keyword, QList cols); + + /** + * @brief 重写添加列函数,使及时调整HeaderView的CheckBox + * @param[in] column 要插入的列位置 + */ + void insertColumn(int column); + + /** + * @brief 重写移除列函数,使及时调整HeaderView的CheckBox + * @prama[in] column 要删除的位置 + */ + void removeColumn(int column); + +private: + /** + *@brief 记录非隐藏表头 + */ + void RememberCurrentSections(); + +protected: + + /** + * @brief 按照上一次的过滤规则,对某一行惊醒过滤 + * @param[in] rowIndex 要过滤的行索引 + * @return 是否通过过滤 + */ + virtual bool Filter(int rowIndex); + + /** + * @brief 实现该函数用来写字符串 + */ + void paintEvent(QPaintEvent *event); + + /** + * @brief 实现鼠标右键菜单 + */ + void contextMenuEvent(QContextMenuEvent *event); + + /** + * @brief 实现快捷键功能 + */ + void keyPressEvent(QKeyEvent *event); + +private slots: + /** + * @brief 重新设置高度以适应自动变化 + */ + void ResetTableHeight(); + + /** + * @brief 行数发生变化 + */ + void RowCountChanged(); + + /** + * @brief 设置剪切板内容 + */ + void setClipboard(); + + /** + * @brief 当单元格的数据发送改变室的槽函数 + * @param[in] pItem 对应的单元格 + */ + void TableItemChanged(QTableWidgetItem *pItem); + +private: + bool m_AutoHeight; + bool m_ShowFilterEmptyMsg; + int m_AutoHeightMaxRowCount; + QString m_MsgWhileFilterEmpty; + QString m_PromptMsg; + + QList m_FilterCols; // 最近一次过滤的的列 + +protected: + QString m_FilterKeyword; // 最近一次过滤的关键字 + +signals: + /** + * @brief 行数发生变化 + * @param count 变化后的行数 + */ + void RowCountChanged(const int count); +}; + +} +} + +#endif /* PAITABLEWIDGET_H_ */ diff --git a/WellLogUI/include/assetcopy.h b/WellLogUI/include/assetcopy.h new file mode 100644 index 0000000..c608bb1 --- /dev/null +++ b/WellLogUI/include/assetcopy.h @@ -0,0 +1,71 @@ +#ifndef ASSETCOPY_H +#define ASSETCOPY_H +#include +#include +#include +#include +#include +// #include "ObjWellLogWavefile.h" +#include "ObjWellLog.h" +#include "adapter_defs.h" + +class AssetCopy : public QObject +{ + Q_OBJECT + +public: + AssetCopy(QObject *parent=NULL); + ~AssetCopy(); + void initPopMenu(QTableWidget *pTable, QMenu *pmenu = NULL); + void setDataType(DType type); + void reqCustomComtextMenu(const QPoint &pos); + QString itemParseText(int row,int col); + void setVerScrollValue(int value); + void setHorScrollValue(int value); + void restParse(); + bool isParse(); + void SetWellLogs(DType type1,QList&pWellLogs); +public slots: + void onCopyData(); + void onParseData(); + void onCopyLinesData(); + void onCopyColnumsData(); +signals: + void signalReqCustomContextMenu(const QPoint& point); + void signalParseData(const QTableWidgetSelectionRange &parseRange); + + void saveToTempModel(); + + void needANewLine(int); + +private slots: + void onCustomContextMenuRequested(const QPoint& pos); + +private: + QString itemText(int row,int col); + void changeCacheRowCol(int orgRow,int orgCol,int movRow,int movCol); +private: + //////////////////�鸴��/ճ��////////////////// + QByteArray seriseSelectRange(const QTableWidgetSelectionRange& selectRange); + QTableWidgetSelectionRange deseriseSelectRange( QByteArray& selectByte); + //ճ������ + void parseData(const QTableWidgetSelectionRange& parse); + void cacheGridData(const QTableWidgetSelectionRange& m_selectionRange); + + + +private: + ///////////////////����/ճ��//////////// + QMenu* m_menu; + static AssetCopy *p_assCopy; + + QMap > m_cacheData; + QMap > m_parseCacheData; + bool m_isParse; + int m_verScrolValue; + int m_horScrolValue; + QListm_pWellLogs; + DType type; +}; + +#endif // ASSETCOPY_H diff --git a/WellLogUI/include/griddataadapter.h b/WellLogUI/include/griddataadapter.h new file mode 100644 index 0000000..b1e4eae --- /dev/null +++ b/WellLogUI/include/griddataadapter.h @@ -0,0 +1,334 @@ +#ifndef GRIDDATAADAPTER_H +#define GRIDDATAADAPTER_H +#include "CStringType.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#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 > &model ); + void setTableHeaderData(const QStringList &headerLst); + void clearBuffer(); + void clearHeader(); + +private: + QList< QList > 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 > &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 WellLogs); + void updatetWellLogData(); + + void initMultWellLogData(DType type,QList WellLogs); + void initFMTWellLogData(DType type,QList WellLogs); + void initTDTWellLogData(DType type,QList WellLogs); + void updatetMultWellLogData(); + void updatetTDTWellLogData(); + void updatetFMTWellLogData(); + + void initTableWellLogData(DType type,QList 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 >& 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 > data,QList modifyRows); + //提取井数据 + void extractWellData(QList > &editData,QList &modifyRows ,bool &isScuccess); + void getWellData(int row,int col,QList& wellXYZ,bool& covSuccss); + //保存曲线数据 + void saveWellLogData(QList > depthList); + + void fillDefaultTitle(QStringList& fields,int pageCol); + //提取曲线数据 + void extractWellLogData(QList > &editData ,bool &isScuccess); + //////////////////////////////////////////////////// + //保存波列数据 + void saveMultWellLogData(bool &isScuccess); + //提取波列数据 + //void extractMultWellLogData(int &row,int &col,float &value,bool &isScuccess); + void extractMultWellLogData(QList > &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 m_pageItems; + QTableWidget* m_table; + TableModel* m_tmodel; + //////////////initWellData/////////////////////////// + CObjWell* m_pWell; + //////////////initWellLogData/////////////////////////// + QStringList m_TitleField; + QList m_pWellLogs; + + PFLOATPROPERTY **vP; + ////////////////////initTableWellLogData//////////////////////////////// + int recordcount; + //修改后的行列值 + QMultiMap 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 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 diff --git a/WellLogUI/src/CStringType.cpp b/WellLogUI/src/CStringType.cpp new file mode 100644 index 0000000..cd429f7 --- /dev/null +++ b/WellLogUI/src/CStringType.cpp @@ -0,0 +1,324 @@ +#include "CStringType.h" +#include +char *m_temp=NULL; +CString::CString(const char *str) +{ + m_temp=NULL; + if(str==NULL) + m_data =""; + else + m_data=QString::fromLocal8Bit(str); +} +CString::CString(const QString str) +{ + m_temp=NULL; + if(str==NULL) + m_data =""; + else + m_data=str; +} + +CString::~CString() +{ + if(m_temp) delete m_temp; + m_temp=NULL; +}; +void CString::Empty() +{ + m_data =""; +} + +CString::CString(const CString &other) +{ + m_temp=NULL; + m_data=other.m_data; +} +int CString::GetLength()const +{ + return m_data.length(); +} +int CString::Find(char *str) +{ + std::string dataStr=m_data.toStdString(); + return dataStr.find(str); +} +int CString::Find(CString &another) +{ + return m_data.toStdString().find(another.m_data.toStdString()); +} +int CString::Find(char str) +{ + std::string dataStr=m_data.toStdString(); + return dataStr.find(str); +} + +int CString::Find(char str[],int start) +{ + std::string dataStr=m_data.toStdString(); + int npos=dataStr.find(str); + if(npos==-1) + return -1; + if(nposStrVector; + int left=0; + for (int i=0;i-1;i--) + { + if(tempstr[i]==findStr.at(0)) { + continue; + } + else { + flag=i; + break; + } + } + m_data=temp.left(flag+1); + return *this; +} +bool CString::operator==(const char* other ) +{ + QString srcStr=QString::fromLocal8Bit(other); + if(this->m_data==srcStr) + return true; + return false; +} +bool CString::operator!=(const char* other ) +{ + QString srcStr=QString::fromLocal8Bit(other); + if(this->m_data!=srcStr) + return true; + return false; +} +char CString::operator[](int i) +{ + char ch=GetChar(i); + return ch; +} +CString CString::Right(int count)const +{ + if (count<0) + { + count=0; + } + if (count>m_data.length()) + { + return *this; + } + int length=m_data.length(); + QString temp=m_data; + QString lastdata=temp.remove(0,length-count); + CString RightStr(lastdata); + return RightStr; +} +CString CString::Mid(int pos,int count)const +{ + if (count<0) + { + count=0; + } + QString temp=m_data.mid(pos,count); + CString mstr(temp); + return mstr; +} +CString CString::Mid(int pos)const +{ + QString temp=m_data.mid(pos); + CString mstr(temp); + return mstr; +} + +CString CString::Left(int count)const +{ + if (count<0) + { + count=0; + } + if (count>m_data.length()) + { + return *this; + } + int length=m_data.length(); + QString temp=m_data; + QString lastdata=temp.remove(count,length-count); + CString leftStr(lastdata); + return leftStr; +} + +CString CString::operator + (const CString& SrcStr) +{ + CString str; + str.m_data=m_data+SrcStr.m_data; + return str; +} +/* +CString CString::operator = (const QString& SrcStr) +{ +CString str; +str.m_data=SrcStr; +return str; +} +*/ +CString CString::operator += (CString& SrcStr) +{ + m_data = m_data+SrcStr.m_data ; + return *this; +} +CString CString::operator += (const CString& SrcStr) +{ + m_data = m_data+SrcStr.m_data ; + return *this; +} +bool CString::operator!=(const CString& other ) +{ + return m_data!=other.m_data; +} +bool CString::operator==(const CString& other ) +{ + return m_data==other.m_data; +} + +void CString::Alloc(int len) +{ +} +char* CString::GetString() const +{ + int length=((string)(m_data.toLocal8Bit().data())).length(); + if(m_temp) delete m_temp; + m_temp=new char[length+1]; + // Alloc(length); + strcpy(m_temp,m_data.toLocal8Bit().data()); + return m_temp; +} +char CString::GetChar(int n) +{ + return GetString()[n]; +} +char CString::GetAt(int n) +{ + return GetChar(n); +} + +void CString::Format(const char *format,...) +{ + //char *str=GetString(); + va_list args; + va_start(args,format); + m_data.vsprintf(format,args); + char *buf=new char[2*strlen(m_data.toStdString().c_str())+1]; + vsprintf(buf,format,args); + m_data=buf; + delete buf; + va_end(args); +} +void ShowMessage(QString mess) +{ + QDialog dialog(NULL); + dialog.setModal(false); + Qt::WindowFlags flags = dialog.windowFlags(); + flags |= Qt::WindowStaysOnTopHint; + flags &= ~Qt::WindowContextHelpButtonHint; + dialog.setWindowFlags(flags); + dialog.setWindowTitle("提示"); + QFormLayout form(&dialog); + QLabel edit(&dialog); + form.addRow(&edit); + edit.setText(mess); +// QDialogButtonBox buttonBox(QDialogButtonBox::Yes,Qt::Horizontal, &dialog); +// form.addRow(&buttonBox); +// if(buttonBox.button(QDialogButtonBox::Yes)) buttonBox.button(QDialogButtonBox::Yes)->setText("退出"); +// QObject::connect(buttonBox.button(QDialogButtonBox::Yes), SIGNAL(clicked()), NULL, SLOT(reject())); + dialog.show(); + dialog.exec(); +} +int AfxMessageBox(CString str) +{ + QDialog dialog(NULL); + dialog.setModal(false); + Qt::WindowFlags flags = dialog.windowFlags(); + flags |= Qt::WindowStaysOnTopHint; + flags &= ~Qt::WindowContextHelpButtonHint; + dialog.setWindowFlags(flags); + dialog.setWindowTitle("提示"); + QFormLayout form(&dialog); + form.addWidget(new QLabel(str.GetString())); +// dialog.show(); + if (dialog.exec() == QDialog::Accepted) { + // Do something here + } +// return MessageBox(NULL,"提示",str.GetString(),NULL ); +// QString cstr=str.GetString(); +// QMessageBox msgBox; +// msgBox.setText(cstr); +// return msgBox.exec(); + return 1; +} + +int MessageBox(QWidget *parent,char lpText[128],char*lpCaption, int UINTuType) +{ + if (!parent) + { + char *tempName=lpCaption; + QString addStr=QString::fromLocal8Bit(tempName); + return QMessageBox::information(NULL,lpText,addStr,QMessageBox::Ok); + } + return 0; +} diff --git a/WellLogUI/src/TipPop.cpp b/WellLogUI/src/TipPop.cpp new file mode 100644 index 0000000..7d97943 --- /dev/null +++ b/WellLogUI/src/TipPop.cpp @@ -0,0 +1,109 @@ +#include "TipPop.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#define TIP_WIDTH 110 +#define TIP_HEIGHT 45 +#define TIP_CONTENTWIDTH 80 +#define TIP_BORDER 2 + +#define TIP_LINECOUNT 5 +#define TIP_RIGHTMARGIN 2 + + +TipPop::TipPop(QWidget *parent) + : QWidget(parent) +{ + this->setFixedSize(TIP_WIDTH,TIP_HEIGHT); + m_Lst=new QLine[TIP_LINECOUNT]; + init(); + +} + +TipPop::~TipPop() +{ + delete []m_Lst; +} + + void TipPop::init() + { + + QPolygon polygon; + int offset=TIP_WIDTH-TIP_CONTENTWIDTH; + QRect newRect=this->rect().adjusted(0,0,-offset,0); + QPoint centerP=QPoint(TIP_WIDTH,newRect.center().y()); + + m_Lst[0]=QLine(newRect.topLeft(),newRect.bottomLeft()); + m_Lst[1]=QLine(newRect.bottomLeft(),newRect.bottomRight()); + m_Lst[2]=QLine(newRect.topRight(),centerP); + m_Lst[3]=QLine(centerP,newRect.bottomRight()); + m_Lst[4]=QLine(newRect.topRight(),newRect.topLeft()); + + + QLine line; + + for(int i=0;isetMask(region); + QLabel *lbl=new QLabel(this); + lbl->setObjectName("deplbl"); + QFont font; + font.setPixelSize(9); + font.setBold(true); + lbl->setFont(font); + lbl->setStyleSheet("color:white"); + + lbl->setAlignment(Qt::AlignLeft|Qt::AlignVCenter); + QHBoxLayout *vLayout=new QHBoxLayout(this); + vLayout->addWidget(lbl); + QSpacerItem *item=new QSpacerItem(1,1,QSizePolicy::Expanding); + vLayout->addSpacerItem(item); + vLayout->setContentsMargins(0,0,0,0); + } + void TipPopdrawBorder() + { + + } + void TipPop::moveCursorPoint(const float &dept) + { + QPoint point= QCursor::pos(); + int posX=point.x()-width()-TIP_RIGHTMARGIN; + int posY=point.y()-height()/2.0; + this->setGeometry(QRect(posX,posY,width(),height())); + m_dept=dept; + QLabel* lbl=this->findChild("deplbl"); + lbl->setText(QString(" MD:%1").arg(m_dept)); + QFont ft( "Microsoft YaHei", 9, 75); + lbl->setFont(ft); + + update(); + } + +void TipPop::paintEvent(QPaintEvent *) +{ + QPainter paint; + paint.begin(this); + int val=TIP_BORDER; + paint.save(); + paint.setPen(Qt::NoPen); + + paint.setBrush(QColor(75,75,75,100));/*Qt::lightGray*/ + paint.drawRect(rect()); + paint.restore(); + paint.end(); + +} diff --git a/WellLogUI/src/TipPop.h b/WellLogUI/src/TipPop.h new file mode 100644 index 0000000..3e4b163 --- /dev/null +++ b/WellLogUI/src/TipPop.h @@ -0,0 +1,29 @@ +#ifndef TIPPOP_H +#define TIPPOP_H + +#include + +class TipPop : public QWidget +{ + Q_OBJECT + +public: + TipPop(QWidget *parent=NULL); + ~TipPop(); + + void paintEvent(QPaintEvent *); + void init(); + void moveCursorPoint(const float &dept); + void drawBorder(); +private: + float m_deptValue; + float m_value; + + +private: + QLine *m_Lst; + float m_dept; + +}; + +#endif // TIPPOP_H diff --git a/WellLogUI/src/adapter_defs.h b/WellLogUI/src/adapter_defs.h new file mode 100644 index 0000000..e45474d --- /dev/null +++ b/WellLogUI/src/adapter_defs.h @@ -0,0 +1,51 @@ +#ifndef ADAPTER_DEFS_H +#define ADAPTER_DEFS_H +#include +#include + +struct DataPair +{ +public: + DataPair() + { + + } + DataPair(QVariant val,Qt::ItemFlag flg=Qt::NoItemFlags) + { + value=val; + itemflag=flg; + } + + DataPair(const DataPair& pair) + { + itemflag=pair.itemflag; + value=pair.value; + } + Qt::ItemFlag itemflag; + QVariant value; + DataPair operator =(const DataPair& pair ) + { + + itemflag=pair.itemflag; + value=pair.value; + return *this; + + } +}; + +Q_DECLARE_METATYPE(DataPair) + + enum DType + { + D_WellData=0, + D_WellLogData, + D_MultWellLogData, + D_TableWellLogData, + D_TDTWellLogData, + D_FMTWellLogData, + D_NONE + }; + + + +#endif \ No newline at end of file diff --git a/WellLogUI/src/assetcopy.cpp b/WellLogUI/src/assetcopy.cpp new file mode 100644 index 0000000..cd4da77 --- /dev/null +++ b/WellLogUI/src/assetcopy.cpp @@ -0,0 +1,705 @@ +#include "assetcopy.h" +#include +#include +#include +#include +#include +// #include "ObjWellLogTABLE.h" +// #include "ObjDiscreteWellLog.h" +// #include "BaseDialog.h" +#include "DepthProgress.h" +#define DECIMALPLACESNUM 8 + +//定义表格的行高 +#define DefRowHeight 20 +//列宽 +#define DefColWidth 180 + +AssetCopy* AssetCopy::p_assCopy =NULL; + +AssetCopy::AssetCopy(QObject *parent) + : QObject(parent),m_menu(NULL) +{ + m_isParse=false; +} + +AssetCopy::~AssetCopy() +{ + if(NULL != m_menu) + { + m_menu=NULL; + } + if(NULL !=p_assCopy) + { + p_assCopy=NULL; + } +} +void AssetCopy::SetWellLogs(DType type1,QList&pWellLogs) +{ + type=type1; + m_pWellLogs=pWellLogs; +} +void AssetCopy::onCustomContextMenuRequested(const QPoint &pos) +{ + if(NULL != m_menu) + { + m_menu->exec(pos); + } +} + +void AssetCopy::onCopyData() +{ + m_isParse=false; + if(NULL == m_menu || NULL == m_menu->parent()) + return; + + QTableWidget *m_table=qobject_cast(m_menu->parent()); + if(NULL == m_table) + return; + //if(m_table->isVisible()) + + QList selItems=m_table->selectedItems(); + QList selRanges=m_table->selectedRanges(); + if(selItems.size()>0) + { + QTableWidgetSelectionRange copyRange=selRanges.value(0); + + int top = copyRange.topRow(); + int bottom = copyRange.bottomRow(); + int left = copyRange.leftColumn(); + int right = copyRange.rightColumn(); + + QString szClipText; + for(int nRow = top;nRow <=bottom;nRow++) + { + for(int nCol = left;nCol <=right;nCol++) + { + QString szTmp; + auto pItem = m_table->item(nRow,nCol); + if(pItem) + szTmp = pItem->text(); + szClipText.append(szTmp); + szClipText.append("\t"); + } + szClipText.chop(1); + szClipText.append("\n"); + } + + QClipboard* clip=QApplication::clipboard(); + clip->setText(szClipText); + + } +} +void AssetCopy::onCopyLinesData() +{ + // if(!m_pWellLogs.size()) return; + // m_isParse=false; + // if(NULL == m_menu || NULL == m_menu->parent()) return; + // QTableWidget *m_table=qobject_cast(m_menu->parent()); + // if(NULL == m_table) + // return; + // //if(m_table->isVisible()) + + // QList selItems=m_table->selectedItems(); + // QList selRanges=m_table->selectedRanges(); + + // CObjWellLogWavefile *pWaveValue=NULL; + // pWaveValue=dynamic_cast(m_pWellLogs[0]); + // CObjWellLogTABLE *pTableValue=NULL; + // pTableValue=dynamic_cast(m_pWellLogs[0]); + // if(selItems.size()>0) + // { + // QTableWidgetSelectionRange copyRange=selRanges.value(0); + + // int top = m_verScrolValue+copyRange.topRow(); + // int bottom = m_verScrolValue+copyRange.bottomRow(); + // int left = 0;//copyRange.leftColumn(); + // int right = m_horScrolValue+m_table->columnCount(); + + // if(pWaveValue) right =pWaveValue->waveinfo.TimeSamples; + // else if(!pTableValue) right=m_pWellLogs.size(); + // char buffer[200]; + // QString szClipText; + // float stdep=999999; + // for(int i = 0; i < m_pWellLogs.size(); i++) { + // if(m_pWellLogs[i]->acurveinfo.StartDepthacurveinfo.StartDepth; + // } + // double dep=0; + // int nCurrentRow = m_table->currentRow(); + + // for(int nRow = top;nRow <= bottom; nRow++) + // { + // if(!pTableValue) + // dep=stdep+nRow*m_pWellLogs[0]->acurveinfo.DepLevel; + + // for(int nCol = left;nCol < right; nCol++) + // { + // QString szTmp; + // if(nCol==0||pTableValue) { + // auto pItem = m_table->item(nRow,nCol); + // if(pItem) + // szTmp = pItem->text(); + // else + // szTmp=toString(dep,'f',5,0); + // } + // else { + // if(pWaveValue) szTmp=toString(pWaveValue->GetData((float)dep,nCol-1,buffer),'f',DECIMALPLACESNUM,0); + // else szTmp=toString(m_pWellLogs[nCol-1]->GetData((float)dep),'f',DECIMALPLACESNUM,0); + // } + // szClipText.append(szTmp); + // szClipText.append("\t"); + // } + // szClipText.chop(1); + // szClipText.append("\n"); + // } + + // QClipboard* clip=QApplication::clipboard(); + // clip->setText(szClipText); + + // } +} +void AssetCopy::onCopyColnumsData() +{ + // if(!m_pWellLogs.size()) return; + // m_isParse=false; + // if(NULL == m_menu || NULL == m_menu->parent()) + // return; + + // QTableWidget *m_table=qobject_cast(m_menu->parent()); + // if(NULL == m_table) + // return; + // //if(m_table->isVisible()) + + // CObjWellLogWavefile *pWaveValue=NULL; + // pWaveValue=dynamic_cast(m_pWellLogs[0]); + // CObjWellLogTABLE *pTableValue=NULL; + // CObjDiscreteWellLog *pTableValue1=NULL; + // pTableValue=dynamic_cast(m_pWellLogs[0]); + // pTableValue1=dynamic_cast(m_pWellLogs[0]); + // QList selItems=m_table->selectedItems(); + // QList selRanges=m_table->selectedRanges(); + // float stdep=999999; + // for(int i=0;iacurveinfo.StartDepthacurveinfo.StartDepth; + // } + // if(selItems.size()>0) + // { + // QTableWidgetSelectionRange copyRange=selRanges.value(0); + + // int top = 0;//copyRange.topRow(); + // int bottom = m_table->rowCount();//copyRange.bottomRow(); + // int left = m_horScrolValue+copyRange.leftColumn(); + // int right =m_horScrolValue+copyRange.rightColumn(); + + // if(!pTableValue&&!pTableValue1&&!pWaveValue) + // { + // bottom=(m_pWellLogs[0]->acurveinfo.EndDepth-m_pWellLogs[0]->acurveinfo.StartDepth)/m_pWellLogs[0]->acurveinfo.DepLevel+0.5; + // } + // else if(pWaveValue) { + // bottom=(pWaveValue->waveinfo.EndDepth-pWaveValue->waveinfo.StartDepth)/pWaveValue->waveinfo.DepLevel+0.5; + // } + // QString szClipText; + // char buffer[200]; + // QString szTmp; + // float dep=0; + // for(int nRow = top;nRow <=bottom;nRow++) + // { + // if(!pTableValue&&!pTableValue1)dep=stdep+nRow*m_pWellLogs[0]->acurveinfo.DepLevel; + // for(int nCol = left;nCol <=right;nCol++) + // { + // if(nCol==0||pTableValue||pTableValue1) { + // auto pItem = m_table->item(nRow,nCol); + // if(pItem) + // szTmp = pItem->text(); + // else if(nCol==0) { + // float val=szTmp.toFloat(); + // sprintf(buffer,"%8.3f",val+m_pWellLogs[0]->acurveinfo.DepLevel); + // szTmp =buffer ; + // } + // } + // else { + // if(pWaveValue) szTmp=toString(pWaveValue->GetData(dep,nCol-1,buffer),'f',0); + // else szTmp=toString(m_pWellLogs[nCol-1]->GetData(dep),'f',DECIMALPLACESNUM,0); + // } + // szClipText.append(szTmp); + // szClipText.append("\t"); + // } + // szClipText.chop(1); + // szClipText.append("\n"); + // } + // QClipboard* clip=QApplication::clipboard(); + // clip->setText(szClipText); + // } +} + +void AssetCopy::cacheGridData(const QTableWidgetSelectionRange& m_selectionRange) +{ + if(m_selectionRange.columnCount() ==0 + || m_selectionRange.rowCount() == 0 + || NULL == m_menu + || NULL== m_menu->parent()) + { + return; + } + QTableWidget *p_table=qobject_cast( m_menu->parent()); + if(NULL == p_table) + { + return; + } + m_cacheData.clear(); + QTableWidgetItem *item=NULL; + + int sRow= m_selectionRange.topRow(); + int sCol= m_selectionRange.leftColumn(); + int eRow=m_selectionRange.bottomRow(); + int eCol=m_selectionRange.rightColumn(); + int costCols=m_selectionRange.columnCount(); + int costRows=m_selectionRange.rowCount(); + + QString value; + for(int r=sRow;r<=eRow;r++) + { + QMap colCache; + for(int c=sCol;c<=eCol;c++) + { + item=p_table->item(r,c); + if(NULL != item) + { + value=item->text(); + colCache.insert(c,value); + } + } + m_cacheData.insert(r,colCache); + } + +} + +QString AssetCopy::itemText(int row,int col) +{ + QString result=""; + if( 0== m_cacheData.count()) + { + return result; + } + + QMap colMap; + if(m_cacheData.contains(row) ) + { + colMap=m_cacheData.value(row); + if(colMap.contains(col)) + { + result=colMap.value(col); + } + } + + return result; +} +QString AssetCopy::itemParseText(int row,int col) +{ + QString result=""; + if( 0== m_parseCacheData.count()) + { + return result; + } + + QMap colMap; + if(m_parseCacheData.contains(row) ) + { + colMap=m_parseCacheData.value(row); + if(colMap.contains(col)) + { + result=colMap.value(col); + } + } + + return result; +} +//////////////复制、粘贴//////////////////////////////////////////////////// +QByteArray AssetCopy::seriseSelectRange(const QTableWidgetSelectionRange& selectRange) +{ + QByteArray barr; + QDataStream ds(&barr,QIODevice::WriteOnly); + ds.setByteOrder(QDataStream::BigEndian); + ds<>top>>left>>bottom>>right; + + return QTableWidgetSelectionRange(top,left,bottom,right); +} +void AssetCopy::setVerScrollValue(int value) +{ + m_verScrolValue=value; + +} +void AssetCopy::setHorScrollValue(int value) +{ + m_horScrolValue=value; +} +void AssetCopy::parseData(const QTableWidgetSelectionRange& parse) +{ + if(NULL == m_menu || NULL == m_menu->parent()) + { + return; + } + + QTableWidget *m_table=qobject_cast(m_menu->parent()); + if(NULL == m_table) + { + return; + } + QList rangeLst=m_table->selectedRanges(); + if(rangeLst.size()==0) + { + return; + } + + QTableWidgetSelectionRange selRange=rangeLst.value(0); + + int tableRowCount=m_table->rowCount(); + int tbaleColCount=m_table->columnCount(); + int top,left,bottom,right; + int selRows=selRange.rowCount(); + int selCols=selRange.columnCount(); + //选择一格自动填充 + if(selRows==selCols && selRows==1) + { + top=selRange.topRow(); + left=selRange.leftColumn(); + + int parRows=parse.rowCount(); + int parCols=parse.columnCount(); + + bottom=top+parRows-1; + right=left+parCols-1; + + //裁剪区域大小总行 + if(parRows+top>tableRowCount) + { + bottom=tableRowCount-1; + } + //大于总列 + if(parCols+left>tbaleColCount) + { + right=tbaleColCount-1; + + } + + }else //选择方式 + { + + top=selRange.topRow(); + left=selRange.leftColumn(); + + + int scCount= selRange.columnCount(); + int srCount=selRange.rowCount(); + int pcCount=parse.columnCount(); + int prcCount=parse.rowCount(); + //选中区域大于粘贴区域 + if(scCount>pcCount && srCount>prcCount) + { + bottom=top+prcCount-1; + right=left+pcCount-1; + //选中区域列大于粘贴区域 + }else if( scCount>pcCount && srCountprcCount) + { + bottom=top+prcCount-1; + right=selRange.rightColumn(); + } + + } + + int begRow=parse.topRow(); + int endRow=begRow+bottom-top; + int begCol=parse.leftColumn(); + int endCol=begCol+right-left; + + int moveRows=top- begRow; + int moveCols=left-begCol; + + QString text; + int row,col; + m_parseCacheData.clear(); + //取原数据粘贴数据 + for(int i=begRow;i<=endRow;i++) + { + QMap colMap; + row=i+moveRows; + for(int j=begCol;j<=endCol;j++) + { + text=itemText(i,j);//m_table->item(i,j)->text(); + + col=j+moveCols; + colMap.insert(col,text); + m_table->item(row,col)->setText(text); + + } + m_parseCacheData.insert(row,colMap); + } + //int top=begRow+moveRows+m_verScrolValue; + //int bottom=endRow+moveRows+m_verScrolValue; + //int left=begCol+moveCols+m_horScrolValue; + //int right=endCol+moveCols+m_horScrolValue; + + int topRow=begRow+moveRows; + int bottomRow=endRow+moveRows; + int leftCol=begCol+moveCols; + int rightCol=endCol+moveCols; + + + QTableWidgetSelectionRange parselRange(topRow,leftCol,bottomRow,rightCol); + m_isParse=true; + emit signalParseData(parselRange); +} +void AssetCopy::restParse() +{ + m_isParse=false; +} +bool AssetCopy::isParse() +{ + return m_isParse; +} +void AssetCopy::changeCacheRowCol(int orgRow,int orgCol,int movRow,int movCol) +{ + QMap >::iterator mItor=m_cacheData.begin(); + QMap::iterator itor; + QMap mapValue; + QString value; + + for(;mItor!=m_cacheData.end();mItor++) + { + if(mItor.key()==orgRow) + { + mapValue=mItor.value(); + m_cacheData.erase(mItor); + m_cacheData.insert(movRow,mapValue); + mItor=m_cacheData.begin(); + } + itor=mItor->begin(); + for(;itor!=mItor->end();itor++) + { + if(itor.key()==orgCol) + { + value=itor.value(); + mItor->erase(itor); + mItor->insert(movCol,value); + itor=mItor->begin(); + } + } + } +} + +void AssetCopy::reqCustomComtextMenu(const QPoint &pos) +{ + emit signalReqCustomContextMenu(pos); +} + +void AssetCopy::onParseData() +{ + // if(type == D_MultWellLogData) + // { + // int choose = QMessageBox::question(NULL, tr("提示"), + // QString(tr("该数据格式下,粘贴后将直接存储,是否粘贴?")), + // QMessageBox::Yes | QMessageBox::No); + // if(choose == QMessageBox::No) + // return; + // } + + + // if(!m_pWellLogs.size()) return; + // if(NULL == m_menu || NULL == m_menu->parent()) + // return; + + // QTableWidget *m_table=qobject_cast(m_menu->parent()); + // if(NULL == m_table) + // return; + + // QClipboard* pClip = QApplication::clipboard(); + // QString szText = pClip->text(); + + // if(szText.isEmpty()) + // return; + + // int nSpace = 0; + // int nDou=0; + // int nTab =0; + + // DepthProgress MyDepthProgress2; + // MyDepthProgress2.CreatProgress(0, szText.size(), "粘贴内容检查中..."); + + // for(int nIndex =0;nIndexnDou ? nSpace : nDou; + // nMax = nMax>nTab ? nMax : nTab; + + // char rFlag; + // if(nMax==nTab) + // { + // rFlag ='\t'; + // } + // else if(nMax==nSpace) + // { + // rFlag =' '; + // } + // else if(nMax==nDou) + // { + // rFlag =','; + // } + // m_table->clearSelection(); + // QStringList rSplitList = szText.split('\n'); + // if(rSplitList.size()&&rSplitList[rSplitList.size()-1]=="") rSplitList.removeAt(rSplitList.size()-1); + // CObjWellLogWavefile *pWaveValue=NULL; + // pWaveValue=dynamic_cast(m_pWellLogs[0]); + // CObjWellLogTABLE *pTableValue=NULL; + // pTableValue=dynamic_cast(m_pWellLogs[0]); + // CObjDiscreteWellLog *pTableValue1=NULL; + // pTableValue1=dynamic_cast(m_pWellLogs[0]); + // float stdep=999999; + + // for(int i=0;iacurveinfo.StartDepthacurveinfo.StartDepth; + // } + // float dep=0; + + // //起始行 + // int nCurrentRow = m_table->currentRow(); + + // //纵向扩充表格 + // MyDepthProgress2.CreatProgress(0, rSplitList.size(), "表格建设中..."); + // MyDepthProgress2.SetDepth(0); + // for(int cTemp = nCurrentRow; cTemp < (nCurrentRow + rSplitList.size()); cTemp++){ + // if(cTemp >= m_table->rowCount()) + // needANewLine(cTemp); + + // MyDepthProgress2.SetDepth(cTemp - nCurrentRow); + // } + + // //进度条 + // int curprogre = 0; + // MyDepthProgress2.CreatProgress(0, rSplitList.size(), "数据归位..."); + // MyDepthProgress2.SetDepth(0); + + // for(int nRow = 0; nRow < rSplitList.size(); ++nRow) + // { + // if(!pTableValue) + // dep = stdep + (m_verScrolValue + nCurrentRow) * m_pWellLogs[0]->acurveinfo.DepLevel; + + // //起始列 + // int nCurrentColumn = m_table->currentColumn(); + + // QStringList rColumnList = rSplitList[nRow].split(rFlag); + + // for(int nCol = 0; nCol < rColumnList.size(); nCol++) + // { + // if(pTableValue||pTableValue1) { + // //空替换 + // if(rColumnList[nCol].isEmpty() ) rColumnList[nCol] = ""; + // auto pItem = m_table->item(nCurrentRow, nCurrentColumn); + + // //写值 + // if(pItem) + // pItem->setText(rColumnList[nCol]); + // else + // { + // QTableWidgetItem* pItem = new QTableWidgetItem; + // pItem->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsTristate); + // pItem->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);//对齐 + // if(nCurrentColumn == 0) pItem->setFlags(pItem->flags() & (~Qt::ItemIsEditable)); + // pItem->setFont(QFont("Times",10)); + + // m_table->setItem(nCurrentRow, nCurrentColumn, pItem); + + // pItem->setText(rColumnList[nCol]); + // } + + // } + // else if(nCurrentColumn){ + // float val=rColumnList[nCol].toFloat(); + // if(pWaveValue) pWaveValue->SetData(dep,m_horScrolValue+nCurrentColumn-1,&val); + // else m_pWellLogs[m_horScrolValue+nCurrentColumn-1]->SetData(dep,&val); + // } + + // nCurrentColumn++; + + // MyDepthProgress2.SetDepth(++curprogre); + // } + // nCurrentRow++; + // } + + + // if(!pTableValue) + // for(int i=0;iSetModify(true); + // m_pWellLogs[i]->SaveToSLF(); + // } + + // emit saveToTempModel(); + + /* + CBaseDialog *pTableDialog=(CBaseDialog*)(m_table->parent()); + if(pTableDialog) { + //粘贴操作不直接保存,刷新操作会重新读表格数据 + //pTableDialog->ReFreshWindow(type); + } + */ +} + +void AssetCopy::initPopMenu(QTableWidget *pTable, QMenu *pmenu) +{ + if(pmenu == NULL) + m_menu = new QMenu(pTable); + else + m_menu = pmenu; + + QIcon icon = QIcon(::GetImagePath() + "/UIMake/fuzhi.png"); + QAction* action = m_menu->addAction(icon, "复制选中数据"); + connect(action,SIGNAL(triggered()),this,SLOT(onCopyData())); + + icon = QIcon(::GetImagePath() + "/UIMake/Hfuzhi.png"); + action = m_menu->addAction(icon, "复制选中行数据"); + connect(action,SIGNAL(triggered()),this,SLOT(onCopyLinesData())); + + icon = QIcon(::GetImagePath() + "/UIMake/Vfuzhi.png"); + action = m_menu->addAction(icon, "复制选中列数据"); + connect(action,SIGNAL(triggered()),this,SLOT(onCopyColnumsData())); + + icon = QIcon(::GetImagePath() + "/UIMake/pas.png"); + action = m_menu->addAction(icon, "粘贴"); + connect(action,SIGNAL(triggered()),this,SLOT(onParseData())); + + connect(this,SIGNAL(signalReqCustomContextMenu(QPoint)),this,SLOT(onCustomContextMenuRequested(QPoint)),Qt::UniqueConnection); +} diff --git a/WellLogUI/src/griddataadapter.cpp b/WellLogUI/src/griddataadapter.cpp new file mode 100644 index 0000000..53aff88 --- /dev/null +++ b/WellLogUI/src/griddataadapter.cpp @@ -0,0 +1,3576 @@ +// #include +#include "../include/griddataadapter.h" +#include "WellLogTableDialogNew.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "TipPop.h" +// #include "ObjProject.h" +// #include "DataTree.h" +// #include +// #include "ObjWellLogWavefile.h" +#include "DataManagger.h" +#include "assetcopy.h" +// #include +// #include +#include "ObjectID.h" + +//QtConcurrent +#define FLOATPREC 4 + +Slf_WAVE WaveInfo; +Slf_TDT TDT; +Slf_FMT FMT; +//定义表格的行高 +//#define DefRowHeight 25 +//列宽 +//#define DefColWidth 100 +//表格显示小数点后位数f +#define DECIMALPLACESNUM 8 + +#define DefSelection_Color "lightblue" + +#define DefBgSelection_Color "lightgray" + +#define CurveViewVerRange 200 + + +WellLogHeaderView::WellLogHeaderView(Qt::Orientation orientation, QWidget *parent ): +QHeaderView(orientation,parent) +{ + m_logicalIndex=-1; +} +WellLogHeaderView::~WellLogHeaderView() +{ + +} + +void WellLogHeaderView::mouseReleaseEvent(QMouseEvent *evt) +{ + QHeaderView::mouseReleaseEvent(evt); + QPoint point=evt->pos(); + m_logicalIndex=QHeaderView::logicalIndexAt(point); + + //this->update(); + emit signalClickedSectionLogicalIndex(m_logicalIndex); + +} +void WellLogHeaderView::paintEvent(QPaintEvent *pevt) +{ + + QHeaderView::paintEvent(pevt); + QPainter painter; + painter.begin(this); + painter.save(); + QPen pen=QPen(QColor(213,239,255),1); + painter.setPen(pen); + //painter.setBrush(); + QRect bgRect=rect(); + painter.drawRect(bgRect); + painter.restore(); + painter.end(); + +} + +void WellLogHeaderView::paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const +{ + QVariant value=model()->headerData(logicalIndex,Qt::Horizontal,Qt::DisplayRole); + QModelIndex mindex= model()->index(0,0); + + painter->save(); + QHeaderView::paintSection(painter,rect,logicalIndex); + painter->restore(); + + + + QBrush bgBrush=QColor(qRgb(231,231,231)); + + if(logicalIndex == m_logicalIndex && logicalIndex >0 ) + { + bgBrush=QColor(qRgb(213,213,213)); + + } + + painter->save(); + + painter->fillRect(rect,bgBrush); + painter->restore(); + + if(value.isValid()) + { + painter->drawText(rect,Qt::AlignHCenter|Qt::AlignVCenter,value.value()); + } +} + +//void WellLogHeaderView::setSelectionChecked(const QModelIndex &index) +//{ +// QRect selectionRect=QHeaderView::visualRect(index); +// setSelection(selectionRect,QItemSelectionModel::ToggleCurrent); +// +//} + +GridDataAdapter::GridDataAdapter(QTableWidget* table, + QScrollBar *horizontalScrollBar, + QScrollBar *verticalScrollBar, + QObject* parent) + : QObject(parent) + ,m_verScrolValue(0) + ,m_horScrolValue(0) + ,m_pageRow(1) + ,m_pageCol(0) + ,m_tmodel(NULL) + // ,m_pWell(NULL) + ,m_mgr(NULL) + ,ifItemWidth(true) + ,m_nVerScrollValue(0) + ,m_pAssetCopy(new AssetCopy(this)) + ,DefRowHeight(20) + ,DefColWidth(180) + ,canLoadFromSLF(true) + ,haveDoubleClicked(false) + ,VerScrollUp(false) + ,VerScrollChanged(true) +{ + initColWH(); + + qRegisterMetaType("DataPair"); + resetEditRange(); + m_horScrolBar=horizontalScrollBar; + m_verScrolBar=verticalScrollBar; + m_table=table; + + m_table->installEventFilter(this); + connect(m_verScrolBar,SIGNAL(valueChanged(int)),this,SLOT(slotVerScrollValueChange(int))); + connect(m_horScrolBar,SIGNAL(valueChanged(int)),this,SLOT(slotHorScrollValueChange(int))); + + connect(m_verScrolBar,SIGNAL(sliderPressed()),this,SLOT(slotVerScrollBarPressed())); + connect(m_verScrolBar,SIGNAL(sliderReleased()),this,SLOT(slotVerScrollBarReleased())); + connect(m_horScrolBar,SIGNAL(sliderPressed()),this,SLOT(slotHorScrollBarPressed())); + connect(m_horScrolBar,SIGNAL(sliderReleased()),this,SLOT(slotHorScrollBarReleased())); + + m_table->verticalScrollBar()->setVisible(true); + m_table->horizontalScrollBar()->setVisible(true); + m_table->horizontalHeader()->setSortIndicatorShown(false); + m_table->setGridStyle(Qt::PenStyle::SolidLine); + m_table->setHorizontalHeader(new WellLogHeaderView(Qt::Horizontal, m_table)); + + m_dtype = D_NONE; + m_tmodel = new TableModel(); + if(NULL == m_mgr) + { + m_mgr = new CDataManagger(); + } + vP = NULL; + m_dataRowCount = 0; + m_dataColCount = 0; + recordcount = 0; + m_switch = false; + m_table->setMouseTracking(true); + m_table->horizontalHeader()->setMouseTracking(true); + WellLogHeaderView *wellHeader=dynamic_cast( m_table->horizontalHeader()); + + connect(wellHeader, SIGNAL(signalClickedSectionLogicalIndex(int)), this, SLOT(slotSectionClicked(int))); + connect(&watcher, SIGNAL(finished()), this, SLOT(slotScrollChangeComplete())); + + connect(m_table, SIGNAL(cellDoubleClicked(int, int)), this, SLOT(slotCellDoubleClicked(int, int))); + connect(m_table, SIGNAL(cellClicked(int, int)), this, SLOT(slotCellClicked(int, int))); + connect(m_table, SIGNAL(cellChanged(int,int)), this, SLOT(itemChange_SLOT(int, int))); + + connect(this, SIGNAL(signalCommitToSave()), this, SLOT(slotCommitToSave())); + hideWellLogView(); + + m_popTip = new TipPop(); + + m_menu = new QMenu(m_table); + +} + +void GridDataAdapter::slotSectionClicked(int logincIndex) +{ + if(logincIndex==0) + { + return; + } + m_table->horizontalHeader()->setFocus(); + bindWellLogData(logincIndex-1); +} + +void GridDataAdapter::slotCellDoubleClicked(int row,int col) +{ + if(NULL == m_table) + return; + + QTableWidgetItem* item = m_table->item(row,col); + if(NULL == item) + return; + + haveDoubleClicked = true; + + m_cellText = item->text(); + m_editRange = QTableWidgetSelectionRange(row,col,row,col); +} + +void GridDataAdapter::slotCellClicked(int row,int col) +{ + if(NULL == m_table) + return; + + QTableWidgetItem* itemDepth = m_table->item(row,0); + QTableWidgetItem* itemValue = m_table->item(row,1); + if(NULL == itemDepth || NULL == itemValue) + return; + QString m_depthText = itemDepth->text(); + QString m_valueText = itemValue->text(); + float m_depthV = m_depthText.toFloat(); + float m_valueV = m_valueText.toFloat(); + + switch(m_dtype) + { + case D_WellData: + break; + case D_WellLogData: //常规 + { + // QWidget* parent=qobject_cast(m_table->parent()); + // QWidget* pvPage=parent->findChild("curvePreViewPage"); + // int value = (m_EDep-m_depthV)*100/(m_EDep-m_SDep)+1; + // if(value >= 0 && value <= 100 && pvPage != NULL) + // m_mgr->CallDisplayCurveVerChange(0,fileName,curveName,pvPage,value,m_depthV); + } + break; + case D_MultWellLogData: + break; + case D_TDTWellLogData: + haveDoubleClicked = false; + break; + case D_FMTWellLogData: + haveDoubleClicked = false; + break; + case D_TableWellLogData: + { + haveDoubleClicked = false; + } + default: + break; + } +} + +void GridDataAdapter::itemChange_SLOT(int rowP, int colP) +{ + if(haveDoubleClicked) + { + refreshTempModel(); + haveDoubleClicked = false; + } +} + +void GridDataAdapter::resetEditRange() +{ + m_editRange=QTableWidgetSelectionRange(-1,-1,-1,-1); + + +} +GridDataAdapter::~GridDataAdapter() +{ + for(int i = 0; i < m_pWellLogs.size(); i++){ + m_pWellLogs[i]->isUsing = false; + } + + qDeleteAll(m_pageItems); + clearBuffer(); + //delete m_pAssetCopy; + delete m_tmodel; + m_tmodel=NULL; + m_table=NULL; + if(NULL != vP) + { + delete vP; + vP=NULL; + } + if(NULL != m_mgr) + { + delete m_mgr; + m_mgr=NULL; + } + if(NULL != m_popTip) + { + delete m_popTip; + m_popTip=NULL; + } + if(NULL != m_menu) + { + delete m_menu; + m_menu = NULL; + } + if(!ifItemWidth){ + delete []itemWidth; + itemWidth = NULL; + } +} + +int GridDataAdapter::dataRowCount() +{ + return m_dataRowCount; + +} + +int GridDataAdapter::dataColCount() +{ + return m_dataColCount; +} + + + +void GridDataAdapter::setModelData(const QList< QList >& model ) +{ + + m_tmodel->setModelData(model); + +} +void GridDataAdapter::setTableHeaderData(const QStringList &headerLst) +{ + m_tmodel->setTableHeaderData(headerLst); +} +//清空 +void GridDataAdapter::clearBuffer() +{ + m_tmodel->clearBuffer(); +} + +void GridDataAdapter::initColWH() +{ + int nScreenW = 2560;//GetSystemMetrics(SM_CXSCREEN);//2560;// + int nScreenH = 1440;//GetSystemMetrics(SM_CYSCREEN);//1440;// + + // QScreen *screen = QGuiApplication::screen(); + // int width = screen->geometry().width(); + // int height = screen->geometry().height(); + if(nScreenW > 0 && nScreenH > 0){ + int wNew = nScreenW/50; + int hNew = nScreenH/20; + DefRowHeight = (hNew > DefRowHeight) ? hNew:DefRowHeight; + DefColWidth = (wNew > DefColWidth) ? wNew:DefColWidth; + } + return; +} + +//构建表格页显示项 +void GridDataAdapter::buildItemList() +{ + if(NULL == m_table) + { + return; + } + + for(int i=0;iitem(i,j)) + { + QTableWidgetItem* item=new QTableWidgetItem(); + item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsTristate); + //if(j == 0) + // item->setFlags(item->flags() & (~Qt::ItemIsEditable)); + item->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);//对齐 + item->setFont(QFont("Times",10)); + m_table->setItem(i,j,item); + + } + } + } +} +//更新缓存数据并刷新视图 +void GridDataAdapter::updateTableView() +{ + + if(NULL == m_table) + { + return; + } + + m_pAssetCopy->setVerScrollValue(m_verScrolValue); + m_pAssetCopy->setHorScrollValue(m_horScrolValue); + + int rcount=m_verScrolValue+m_pageRow; + int ccount=m_horScrolValue+m_pageCol; + //补充单页数据 + int rowCount=m_verScrolBar->maximum()+m_pageRow; + int colCount=m_horScrolBar->maximum()+m_pageCol; + if(m_dtype==D_TableWellLogData|| + m_dtype==D_TDTWellLogData|| + m_dtype==D_FMTWellLogData) + rcount = m_table->rowCount(); + if(rcount>rowCount) + { + rcount=rowCount; + } + if(ccount>colCount) + { + ccount=colCount; + } + int index=0; + DataPair dpair; + + QTableWidgetItem* Item=NULL; + + if(rcount < m_table->rowCount()) + { + for(int i=0;iitem(i,j); + if(NULL != Item) + { + Item->setData(Qt::DisplayRole,QVariant()); + } + } + } + } + + + //update + + + m_table->setHorizontalHeaderLabels(m_tmodel->tableHeaderData()); + + for(int i=m_verScrolValue; i < rcount; i++) + { + for(int j=m_horScrolValue;j < ccount;j++) + { + QModelIndex ind=m_tmodel->index(i-m_verScrolValue,j-m_horScrolValue); + + QVariant mdata; + if(ind.isValid()) + mdata = m_tmodel->data(ind,Qt::DisplayRole); + dpair=mdata.value(); + + Item = m_table->item(i-m_verScrolValue, j-m_horScrolValue); + if(NULL != Item) + { + Item->setData(Qt::DisplayRole,dpair.value); + } + } + } + + +} + +//绑定数据并初始数据 +void GridDataAdapter::bindData() +{ + + m_pageRow=0; + m_pageCol=0; + m_dataRowCount=0; + m_dataColCount=0; + + if(canLoadFromSLF) + calcuPageRowsCols(); + if(NULL == m_table) + { + return; + } + //获取数据 + switch(m_dtype) + { + case D_WellData: + { + updateWellData(); + } + break; + case D_WellLogData: + { + updatetWellLogData(); + attachWellLogView(); + } + break; + case D_MultWellLogData: + { + updatetMultWellLogData(); + attachWellLogView();//whp add 2020.5.11 for 波列数据编辑和管理 + } + break; + case D_FMTWellLogData: + { + if(canLoadFromSLF) + updatetFMTWellLogData(); + canLoadFromSLF = false; + m_horScrolBar->setVisible(false); + m_verScrolBar->setVisible(false); + } + break; + case D_TDTWellLogData: + { + if(canLoadFromSLF) + updatetTDTWellLogData(); + canLoadFromSLF = false; + m_horScrolBar->setVisible(false); + m_verScrolBar->setVisible(false); + } + break; + case D_TableWellLogData: + { + if(canLoadFromSLF) + updatetTableWellLogData(); + canLoadFromSLF = false; + m_horScrolBar->setVisible(false); + m_verScrolBar->setVisible(false); + } + break; + default: + break; + } + + buildItemList(); + //刷新视图 + updateTableView(); + + m_verScrolBar->setValue(m_nVerScrollValue); +} + +void GridDataAdapter::switchLogView(bool isSwitch) +{ + m_switch=isSwitch; + +} +//附加曲线统计、属性编辑、计算 +void GridDataAdapter::attachWellLogView() +{ + if(NULL == m_mgr) + { + return; + } + if(!m_pWellLogs.size()) return; + if(m_pWellLogs.size() > 1) + { + if(!m_switch ) return; + }else + { + // m_table->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); + } + + bindWellLogData(0); +} + +void GridDataAdapter::bindWellLogData(int wellLogIndex) +{ + // if(wellLogIndex>=m_pWellLogs.size()) return; + // if(m_horScrolValue /*+wellLogIndex*/ >= m_nSamples/*m_pWellLogs.size()*/) { + // m_horScrolValue=m_nSamples/*m_pWellLogs.size()-wellLogIndex*/-1; + // if(m_horScrolValue<0) m_horScrolValue=0; + // } + // if(wellLogIndex > m_pWellLogs.size()){ + // wellLogIndex = m_pWellLogs.size() - 1; + // } + // int index=/*m_horScrolValue+*/wellLogIndex; + // if(index<0) return; + // CObjWellLogTABLE* pTable = dynamic_cast(m_pWellLogs[index]); + // if(pTable) return; + // CObjWellLog* pround = dynamic_cast(m_pWellLogs[index]); + // if(pround && pround->GetSlfFileName()!="") + // { + // CString TypeName=pround->GetParent()->GetName(); + // int Type=0; + // //if(TypeName=="波列数据")Type=1; + // if(m_pWellLogs[0]->GetTypeID()==GetClassID_WellLogWavefile())Type=1;//whp add 2020.5.11 for 波列数据编辑和管理 + // QString CurveName=pround->GetName(); + // curveName = CurveName; + // QString FileName=pround->GetSlfFileName(); + // fileName = FileName; + // QWidget* parent=qobject_cast(m_table->parent()); + // if(NULL == parent) + // { + // return; + // } + // QWidget* sPage=parent->findChild("statisticsPage"); + // QWidget* pPage=parent->findChild("protoprtyPage"); + // QWidget* cPage=parent->findChild("computePage"); + // QWidget* pvPage=parent->findChild("curvePreViewPage"); + // QTabWidget* tabWidget=parent->findChild("tabWidget"); + // if(NULL != sPage && NULL != pPage && NULL != cPage && NULL != pvPage) + // { + // if(NULL != tabWidget) + // { + // if(Type==0) + // { + // tabWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); + // //tabWidget->setMinimumWidth(0); + // //tabWidget->setMaximumWidth(16777215); + // } + // else + // { + // tabWidget->setSizePolicy(QSizePolicy::Fixed/*Preferred*/,QSizePolicy::Expanding);//whp add 2020.5.11 for 波列数据编辑和管理 + // //tabWidget->setMinimumWidth(1216); + // //tabWidget->setMaximumWidth(1216); + // } + // QScrollArea* sScrollArea=tabWidget->findChild("sScrollArea"); + // QScrollArea* pScrollArea=tabWidget->findChild("pScrollArea"); + // QScrollArea* cScrollArea=tabWidget->findChild("cscrollArea"); + // QScrollArea* curveScrollArea=tabWidget->findChild("curveScrollArea"); + // if(NULL != sScrollArea) + // { + // sScrollArea->setWidget(sPage); + // } + + // if(NULL != pScrollArea) + // { + // pScrollArea->setWidget(pPage); + // } + + // if(NULL != cScrollArea) + // { + // if(Type==0)cScrollArea->setWidget(cPage); + // } + + // if(NULL != curveScrollArea) + // { + // curveScrollArea->setWidget(pvPage); + // } + + // sPage->show(); + // pPage->show(); + // pvPage->show(); + // if(Type==0) + // { + // cPage->show();//whp change 2020.5.11 for 波列数据编辑和管理 波列曲线不计算 + // } + + // tabWidget->show(); + // //调用 + // m_mgr->DataStatistics(Type,FileName,CurveName,sPage); + // m_mgr->CurvePropertyEdit(Type,FileName,CurveName,pPage); + // m_mgr->CallDisplayWaveOrCurve(Type,FileName,CurveName,pvPage); + // if(Type==0) + // { + // m_mgr->CurveCompute(FileName,QStringList()<isLoad=false; + m_pWellLogs[i]->LoadFromSLF(); + } + updatetWellLogData(); + } + + break; + case D_MultWellLogData: + { + // m_pWave->isLoad=false; + // m_pWave->LoadFromSLF(); + // updatetMultWellLogData(); + } + break; + case D_TableWellLogData: + { + updatetTableWellLogData(); + } + break; + case D_TDTWellLogData: + { + updatetTDTWellLogData(); + } + break; + case D_FMTWellLogData: + { + updatetFMTWellLogData(); + } + break; + } + updateTableView(); +} + + + +void GridDataAdapter::slotScrollChangeComplete() +{ + { + QMutexLocker locker(&m_mutex); + updateTableView(); + } + +} + +void GridDataAdapter::calcuPageRowsCols() +{ + hideWellLogView(); + + QRect tableRect=m_table->rect();//窗口范围 + + if(m_pWellLogs.size() > 1&& m_pWellLogs[0]->GetTypeID()==GetClassID_WellLog() ) + { + if(m_switch) + { + if(0 == m_middleWidth) + { + m_middleWidth=tableRect.width(); + } + tableRect.setWidth(m_middleWidth); + + }else + { + if(0 == m_gridWidth) + { + m_gridWidth=tableRect.width(); + } + tableRect.setWidth(m_gridWidth); + } + + } + + else if(m_pWellLogs[0]->GetTypeID()==GetClassID_WellLogWavefile()) + { + if(m_switch) + { + if(0==m_middleWidth) + { + m_middleWidth =tableRect.width(); + } + tableRect.setWidth(m_middleWidth); + } + else + { + if(0==m_middleWidth) + { + m_gridWidth =tableRect.width(); + } + tableRect.setWidth(m_gridWidth); + } + } + if(tableRect.isEmpty()) + { + return; + } + int tableWidth=tableRect.width(); + int tableHeight=tableRect.height() - 3*DefRowHeight; + if(tableHeight < 0) tableHeight = 1; + + + m_pageRow = (tableHeight % DefRowHeight == 0) ? (tableHeight / DefRowHeight) : (tableHeight / DefRowHeight + 1); + + if(m_pWellLogs[0]->GetTypeID()==GetClassID_WellLogWavefile()) + m_pageCol=(tableWidth%DefColWidth==0)?(tableWidth/DefColWidth):(tableWidth/DefColWidth); + else if(m_pWellLogs[0]->GetTypeID()==GetClassID_WellLogTDT()){ + m_pageCol=TDT.TotalLogNumber*3; + } + else if(m_pWellLogs[0]->GetTypeID()==GetClassID_WellLogFMT()){ + m_pageCol=FMT.TotalPointNum; + } + else { + m_pageCol = m_pWellLogs.size() + 1; + //m_pageCol = (tableWidth%DefColWidth==0)?(tableWidth/DefColWidth):(tableWidth/DefColWidth+1); + } + + + + if(m_dtype == D_TableWellLogData|| + m_dtype==D_TDTWellLogData|| + m_dtype==D_FMTWellLogData){ + m_pageRow = recordcount/*(m_pageRow > recordcount) ? m_pageRow : recordcount + m_pageRow*/; + m_pageCol = m_TitleField.size()-1; + } + + m_table->setRowCount(m_pageRow); + m_table->setColumnCount(m_pageCol); + + for(int i = 0; i < m_pageRow; i++) + m_table->setRowHeight(i, DefRowHeight); + if(m_dtype != D_TableWellLogData&& + m_dtype!=D_TDTWellLogData&& + m_dtype!=D_FMTWellLogData) + m_table->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch); + + for(int i = 0; i < m_pageCol; i++) + m_table->setColumnWidth(i,DefColWidth); + + if(m_dtype == D_TableWellLogData|| + m_dtype == D_TDTWellLogData|| + m_dtype == D_FMTWellLogData) + { + m_table->horizontalHeader()->setDefaultSectionSize(DefColWidth); + } + else if(m_pageCol * DefColWidth <= tableWidth) + m_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); + else + { + m_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed); + m_table->horizontalHeader()->setDefaultSectionSize(DefColWidth); + } + +} +void GridDataAdapter::hideWellLogView() +{ + QWidget* parent=qobject_cast(m_table->parent()); + if(NULL == parent) + { + return; + } + QWidget* sPage=parent->findChild("statisticsPage"); + QWidget* pPage=parent->findChild("protoprtyPage"); + QWidget* cPage=parent->findChild("computePage"); + QWidget* pvPage=parent->findChild("curvePreViewPage"); + QTabWidget* tabWidget=parent->findChild("tabWidget"); + + if(NULL != sPage && NULL != pPage) + { + if(NULL != tabWidget) + { + sPage->hide(); + pPage->hide(); + cPage->hide(); + pvPage->hide(); + tabWidget->hide(); + + } + + } + m_table->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); +} +/////////////////////////////begin==TableModel//////////////////////////////////////////// + +TableModel::TableModel(QObject* parent) + :QAbstractTableModel(parent) +{ + + + + +} + +void TableModel::clearBuffer() +{ + m_dataBuffer.clear(); +} + +int TableModel::rowCount(const QModelIndex &parent) const +{ + return m_dataBuffer.size(); +} + +int TableModel::columnCount(const QModelIndex &parent) const +{ + if(m_dataBuffer.size()>0) + return m_dataBuffer.value(0).size(); + else + return 0; + +} + +QVariant TableModel::data(const QModelIndex &index, int role) const +{ + if(!index.isValid()||role!=Qt::DisplayRole) + { + return QVariant(); + } + + int row=index.row(); + int col=index.column(); + QList colData=m_dataBuffer.value(row); + + if(col>= colData.size()|| col<0) + { + return QVariant(); + } + DataPair dp= colData.value(col); + return QVariant::fromValue(dp); + +} + +QStringList TableModel::tableHeaderData() +{ + return m_headerData; +} + +void TableModel::setTableHeaderData(const QStringList &headerLst) +{ + m_headerData.clear(); + m_headerData=headerLst; +} +void TableModel::clearHeader() +{ + m_headerData.clear(); +} +void TableModel::setModelData(const QList< QList >& model ) +{ + + m_dataBuffer=model; + +} + +//////////////////end==TableModel/////////////////////////////////////////////////////// + +//初始化井眼轨迹 +void GridDataAdapter::initWellData(DType type,pai::datamodel::CObjWell* pwell) +{ + m_pWell=pwell; + m_dtype=type; +} +//单元格是否更改 +bool GridDataAdapter::isCellChanged() +{ + bool editSingleModify= m_editRange.rowCount()==m_editRange.columnCount(); + + editSingleModify &= m_editRange.rowCount()==1; + QTableWidgetItem* item=NULL; + bool isParse=m_pAssetCopy->isParse(); + if(isParse) + { + return isParse; + } + if(editSingleModify) + { + item=m_table->item(m_editRange.topRow(),m_editRange.leftColumn()); + if(NULL == item) + { + return false; + } + if(item->text()==m_cellText) + { + return false; + } + } + + return true; +} +//发起保存 +void GridDataAdapter::CommitToSave() +{ + emit signalCommitToSave(); +} + +//排序 +void BubbleSort(int *a, int n) +{ + int i, j; + for (i = 1; i < n; i++) + for (j = 0; j <= n - 1 - i; j++) + if (a[j] > a[j + 1]) + swap(a[j], a[j + 1]); +} + +void GridDataAdapter::calNewPageRow() +{ + + m_pageRow = m_table->rowCount(); + int rowCount = m_pageRow; + int count=rowCount; + + for(int row = 0; row < rowCount; row++) + { + if(!m_table->item(row,0)) { + count = row; + break; + } + /* + else{ + if(m_table->item(row,0)->text() == ""){ + count = row; + break; + } + } + */ + } + recordcount = count; +} + +void GridDataAdapter::sortSequence_SLOT() +{ + if(m_table->horizontalHeaderItem(0)->text() != "NO") + { + QMessageBox::about(NULL, "提示", "无法修改该表序列!"); + return; + } + + for(int rTemp = 0; rTemp < m_table->rowCount(); rTemp++) + { + m_table->item(rTemp, 0)->setText(QString("%1").arg(rTemp + 1)); + } + + refreshTempModel(); +} + +void GridDataAdapter::sortCompute_SLOT() +{ + // if(!m_pWellLogs.size()) return; + // QList selItems = m_table->selectedItems(); + + // if(selItems.size() > 0){ + // int curRow = m_table->column(selItems.at(0)); + // CDataTree *pDatatree=(CDataTree *)::GetProject()->m_pDataTree; + // pDatatree->magr->CurveCompute(m_pWellLogs,curRow); + // } +} + +void GridDataAdapter::onDeleteLinesData() +{ + if(NULL == m_menu || NULL == m_table) + return; + + //删除操作不再直接执行保存 + + QList selItems = m_table->selectedItems(); + QList selRanges = m_table->selectedRanges(); + + if(selItems.size() > 0){ + calNewPageRow(); + + int *drow = new int[selItems.size()]; + int drowNum = 0; + for(int ri = 0; ri < selItems.size(); ri++) + drow[ri] = -1; + + for(int i = 0; i < selItems.size(); i++){ + int curRow = m_table->row(selItems.at(i)); + if(curRow == -1 || curRow + 1 > m_pageRow) + continue; + + int ri = 0; + for(ri; ri < selItems.size(); ri++) + if(drow[ri] == curRow) + break; + if(ri == selItems.size()){ + drow[drowNum++] = curRow; + } + } + + BubbleSort(drow, drowNum); + + QList> data; + for(int nRow = 0; nRow < m_pageRow; nRow++) + { + bool f = false; + for(int i = 0; i < drowNum; i++){ + if(nRow == drow[i]) + f = true; + } + if(f) continue; + + if(nRow >= recordcount) + break; + + QList lstData; + for(int nCol = 0; nCol < m_table->columnCount(); nCol++) + { + QString Qbug = m_table->item(nRow, nCol)->text(); + + lstData<setRowCount(recordcount); + + delete []drow; + } + + //updatetTableWellLogData(); + m_pageRow = recordcount; + m_pageCol = m_table->columnCount(); + updateTableView(); +} + +void GridDataAdapter::addALine_SLOT() +{ + if(NULL == m_menu || NULL == m_table) return; + + QList selRanges = m_table->selectedRanges(); + + QTableWidgetSelectionRange copyRange = selRanges.value(0); + int X = copyRange.topRow() + 1; + + addALine(X); +} + +void GridDataAdapter::addALine_SLOT(int X) +{ + addALine(X); +} + +void GridDataAdapter::addALine(int X) +{ + m_table->insertRow(X); + m_table->setRowHeight(X, m_table->rowHeight(0)); + + for(int nCol = 0; nCol < m_table->columnCount(); nCol++){ + QTableWidgetItem* pItem = new QTableWidgetItem; + pItem->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsTristate); + pItem->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter); + //if(nCol == 0) + //pItem->setFlags(pItem->flags() & (~Qt::ItemIsEditable)); + pItem->setFont(QFont("Times", 10)); + pItem->setText(""); + + m_table->setItem(X, nCol, pItem); + } + + m_pageRow++; + recordcount++; + m_pageCol = m_table->columnCount(); + + refreshTempModel(); + + //updateTableView(); +} + +void GridDataAdapter::refreshTempModel_SLOT() +{ + refreshTempModel(); +} + +void GridDataAdapter::refreshTempModel() +{ + QList> data; + for(int nRow = 0; nRow < m_table->rowCount(); nRow++) + { + QList lstData; + for(int nCol = 0; nCol < m_table->columnCount(); nCol++) + { + if(!m_table->item(nRow, nCol)) continue; + QString iText = m_table->item(nRow, nCol)->text(); + lstData << DataPair(iText); + } + data<rowCount(); + recordcount = m_pageRow; + m_pageCol = m_table->columnCount(); +} + +int GridDataAdapter::getRecordCount() +{ + return recordcount; +} + +//右键菜单 +void GridDataAdapter::addActonMenu(int type){ + if(m_menu == NULL) + return; + + if(type == 2) //表格数据 的 菜单 + { + m_pAssetCopy->initPopMenu(m_table, m_menu); + connect(m_pAssetCopy, SIGNAL(signalParseData(const QTableWidgetSelectionRange&)), this, SLOT(onParseData(const QTableWidgetSelectionRange&))); + connect(m_pAssetCopy, SIGNAL(saveToTempModel()), this, SLOT(refreshTempModel_SLOT())); + connect(m_pAssetCopy, SIGNAL(needANewLine(int)), this, SLOT(addALine_SLOT(int))); + + QIcon icon = QIcon(::GetImagePath() + "/UIMake/addLine.png"); + QAction* action = m_menu->addAction(icon, "插入一行"); + connect(action, SIGNAL(triggered()), this, SLOT(addALine_SLOT())); + + icon = QIcon(::GetImagePath() + "/UIMake/delete.png"); + action = m_menu->addAction(icon, "删除选中行"); + connect(action, SIGNAL(triggered()), this, SLOT(onDeleteLinesData())); + + icon = QIcon(::GetImagePath() + "/UIMake/sortCol.png"); + action = m_menu->addAction(icon, "整理序列数"); + connect(action, SIGNAL(triggered()), this,SLOT(sortSequence_SLOT())); + + icon = QIcon(::GetImagePath() + "/icon/AddToTrack.png"); + action = m_menu->addAction(icon, "计算"); + connect(action, SIGNAL(triggered()), this,SLOT(sortCompute_SLOT())); + } +} + +void GridDataAdapter::reqCustomComtextMenu(const QPoint &pos) +{ + m_pAssetCopy->reqCustomComtextMenu(pos); +} +void GridDataAdapter::onParseData(const QTableWidgetSelectionRange &parseRange) +{ + m_editRange=parseRange; + slotCommitToSave(); +} +//保存 +void GridDataAdapter::slotCommitToSave() +{ + if(m_editRange.topRow()<0 + || NULL == m_table + || !isCellChanged()) + { + return; + } + + + + bool isExtract=false; + switch(m_dtype) + { + //保存井眼轨迹 + case D_WellData: + { + QList > editWellData; + QList modifyRows; + extractWellData(editWellData,modifyRows,isExtract); + if(isExtract) + { + saveWellData(editWellData,modifyRows); + } + } + break; + //保存曲线数据 + case D_WellLogData: + { + QList > editWellLogData; + extractWellLogData(editWellLogData,isExtract); + if(isExtract) + { + saveWellLogData(editWellLogData); + } + } + break; + //保存多维曲线数据 + case D_MultWellLogData: + { + saveMultWellLogData(isExtract); + } + + break; + //保存表格 + case D_TableWellLogData: + { + //saveTableWellLogData(isExtract); + } + break; + default: + break; + + } + resetEditRange(); + if(!isExtract && m_dtype != D_TableWellLogData) + { + QMessageBox::information(m_table,"提示","保存失败!"); + } +} + +//提取井眼轨迹 +void GridDataAdapter::extractWellData(QList > &editData,QList &modifyRows ,bool &isScuccess) +{ + int sRow=m_editRange.topRow(); + int eRow=m_editRange.bottomRow(); + int sCol=m_editRange.leftColumn(); + int eCol=m_editRange.rightColumn(); + QList wellXYZ; + QString textValue; + bool isMatch=true; + for(int i=sRow;i<=eRow;i++) + { + getWellData(i,2,wellXYZ,isMatch); + getWellData(i,3,wellXYZ,isMatch); + getWellData(i,4,wellXYZ,isMatch); + modifyRows<value(); + if(!isMatch) + { + break; + } + editData<& wellXYZ,bool& covSuccss) +{ + QTableWidgetItem* item=m_table->item(row,col); + QString textValue; + QRegExp rx("[0-9.0-9]*"); + if(NULL != item) + { + textValue=item->text(); + covSuccss=rx.exactMatch(textValue); + if(!covSuccss) + { + return; + } + wellXYZ<(m_table->parent()); + // QWidget* pvPage=parent->findChild("curvePreViewPage"); + // if(pvPage!=NULL) + // m_mgr->CallDisplayWaveOrCurve(0,fileName,curveName,pvPage); + // } + break; + case D_MultWellLogData: + break; + case D_TableWellLogData: + break; + case D_TDTWellLogData: + break; + case D_FMTWellLogData: + break; + default: + break; + } + +} + +//井眼轨迹 +void GridDataAdapter::updateWellData() +{ + // QMutexLocker locker(&m_mutex); + // if(NULL == m_pWell) + // { + // return; + // } + + + // m_pWell->LoadXYZ(); + // DOUBLEPROPERTY& vX = m_pWell->GetX(); + // DOUBLEPROPERTY& vY = m_pWell->GetY(); + // DOUBLEPROPERTY& vZ = m_pWell->GetZ(); + // float sdep=m_pWell->GetStartDep(); + // float rlev=m_pWell->GetRlev(); + // m_TitleField.clear(); + // m_TitleField<<"No" << "depth" << "X" << "Y" << "Z" <<" "; + // clearBuffer(); + // setColCount(m_TitleField.size()); + + // if(m_pageCol!=m_TitleField.size()) + // { + // fillDefaultTitle(m_TitleField,m_pageCol); + // } + + + // setTableHeaderData(m_TitleField); + + + // QList > data; + // if( (vX.empty() == false) && (vX.size() == vY.size()) && (vY.size()== vZ.size()) ) + // { + // vector::size_type tempVxSize = vX.size(); + // setRowCount((int)tempVxSize); + // if(m_pageCol>m_TitleField.size()) + // { + // m_pageCol=m_TitleField.size(); + // } + + // if(m_pageRow>tempVxSize) + // { + // m_pageRow=tempVxSize; + // } + // //calcuItemCount(m_pageRow,m_pageCol); + // QList lstData; + // int maxRecord=m_verScrolValue+m_pageRow; + // if(maxRecord>tempVxSize) + // { + // maxRecord=tempVxSize; + // } + // QString no,dept,x,y,z; + // m_pAssetCopy->setVerScrollValue(m_verScrolValue); + // m_pAssetCopy->setHorScrollValue(m_horScrolValue); + + // for(vector::size_type ix = m_verScrolValue; ix < maxRecord; ++ix) + // { + // lstData.clear(); + // double ixa=ix; + // no=toString(ixa,'d',0,0); + // dept=toString(sdep+ix*rlev,'f',5,0); + // if( (vX.size() > ix) && (vY.size() > ix) && (vZ.size() > ix) ) + // { + // x=toString(vX.m_vProperty[ix],'f',DECIMALPLACESNUM,0); + // y=toString(vY.m_vProperty[ix],'f',DECIMALPLACESNUM,0); + // z=toString(vZ.m_vProperty[ix],'f',DECIMALPLACESNUM,0); + + // }else + // { + // x=QString("-9999.000"); + // y=x; + // z=x; + + // } + // lstData<ClearXYZ(); +} + +//井眼轨迹 +void GridDataAdapter::saveWellData(QList > data,QList modifyRows) +{ + // m_pWell->LoadXYZ(); + // DOUBLEPROPERTY& vX = m_pWell->GetX(); + // DOUBLEPROPERTY& vY = m_pWell->GetY(); + // DOUBLEPROPERTY& vZ = m_pWell->GetZ(); + + // // DOUBLEPROPERTY vX(rowCount),vY(rowCount),vZ(rowCount); + // for(int i = 0; i < modifyRows.size(); i++) + // { + // double xColumn =data.value(i).value(0); //m_pUI->tableWidget->item(rows[i], 2)->text(); + // double yColumn =data.value(i).value(1); //m_pUI->tableWidget->item(rows[i], 3)->text(); + // double zColumn =data.value(i).value(2); // m_pUI->tableWidget->item(rows[i], 4)->text(); + // vX.m_vProperty[modifyRows[i]] = xColumn; + // vY.m_vProperty[modifyRows[i]] = yColumn; + // vZ.m_vProperty[modifyRows[i]] = zColumn; + // } + // m_pWell->SetX( &vX ); + // m_pWell->SetY( &vY ); + // m_pWell->SetZ( &vZ ); + + // m_pWell->ClearXYZ(); +} +//导出井眼轨迹 +void GridDataAdapter::exportWellData(FILE *fp, DepthProgress& process) +{ + // if(NULL == m_pWell) + // { + // return; + // } + + // m_pWell->LoadXYZ(); + // DOUBLEPROPERTY& vX = m_pWell->GetX(); + // DOUBLEPROPERTY& vY = m_pWell->GetY(); + // DOUBLEPROPERTY& vZ = m_pWell->GetZ(); + // float sdep=m_pWell->GetStartDep(); + // float rlev=m_pWell->GetRlev(); + + // if( (vX.empty() == false) && (vX.size() == vY.size()) && (vY.size()== vZ.size()) ) + // { + // vector::size_type tempVxSize = vX.size(); + // QString conTents; + // process.CreatProgress(0,tempVxSize,"正在导出数据..."); + + // for(vector::size_type ix = 0; ix < tempVxSize; ++ix) + // { + // conTents=""; + // QStringList colList; + // double ixa=ix; + // colList<ClearXYZ(); +} + +//初始化曲线 +void GridDataAdapter::initWellLogData(DType type,QList WellLogs) +{ + m_pWellLogs=WellLogs; + m_pAssetCopy->SetWellLogs(type,WellLogs); + if(!m_pWellLogs.size()) return; + + for(int i = 0; i < m_pWellLogs.size(); i++){ + m_pWellLogs[i]->isUsing = true; + } + + m_dtype=type; + vP=new PFLOATPROPERTY *[m_pWellLogs.size()]; + for(int i=0;iisLoad=false; + m_pWellLogs[i]->LoadFromSLF(); + vP[i]=&m_pWellLogs[i]->GetProperty(); + } + m_TitleField.clear(); + QString depthUnit=m_pWellLogs[0]->GetDepthUnit(); + if(m_pWellLogs[0]->GetDepthUnit()=="m"&&depthUnit!="m"&&depthUnit!="米") depthUnit=""; + else if(m_pWellLogs[0]->GetDepthUnit()=="ft"&&depthUnit!="ft"&&depthUnit!="英尺") depthUnit=""; + if(depthUnit.isEmpty()) m_pWellLogs[0]->GetDepthAliasUnit(); + if(depthUnit.isEmpty()) depthUnit="米"; + + m_TitleField << "MD\n"+depthUnit; + + double nStart =m_pWellLogs[0]->GetTopDepth(); + double nEnd =m_pWellLogs[0]->GetBottomDepth(); + for(int i=1;im_pWellLogs[i]->GetTopDepth()) nStart=m_pWellLogs[i]->GetTopDepth(); + if(nEndGetBottomDepth()) nEnd=m_pWellLogs[i]->GetBottomDepth(); + } + m_SDep = nStart; + m_EDep = nEnd; + WellLogTableDialogNew* parent=qobject_cast(m_table->parent()); + if(NULL == parent) + { + return; + } + QTabWidget* tabWidget=parent->findChild("tabWidget"); + for(int i=0;iGetUnit(); + if(m_Unit.isEmpty()) m_Unit=m_pWellLogs[i]->GetAliasUnit(); + if(m_Unit.isEmpty()) + { + char strTmp[16] = "CurveFamily.ini"; + QStringList cs=GetSimilarCurves(m_pWellLogs[i]->GetName(),strTmp,false); + if(cs.size()>3) { + m_Unit=cs[3]; + } + } + int pos=0,pos1=0; + if((pos=m_Unit.indexOf("^"))>-1&&(pos1=m_Unit.indexOf("^",pos+1))>-1) { + QStringList fh=GetSimilarCurves(m_Unit.mid(pos,pos1-pos+1)); + if(fh.size())m_Unit.replace(m_Unit.mid(pos,pos1-pos+1),fh[0]); + } + pos=0,pos1=0; + if((pos=m_Unit.indexOf("!"))>-1&&(pos1=m_Unit.indexOf("!",pos+1))>-1) { + QStringList fh=GetSimilarCurves(m_Unit.mid(pos,pos1-pos+1)); + if(fh.size())m_Unit.replace(m_Unit.mid(pos,pos1-pos+1),fh[0]); + } + + + m_TitleField <GetName() +"\n"+m_Unit; + } + + PFLOATPROPERTY &vM=m_pWellLogs[0]->GetMD(); + if(vM.size()<1) return ; + m_TitleField << " "; + //luol 20200302 + clearBuffer(); + + //setColCount(m_TitleField.size()); + + +} +//提取曲线数据 +void GridDataAdapter::extractWellLogData(QList > &editData ,bool &isScuccess) +{ + int sRow=m_editRange.topRow(); + int eRow=m_editRange.bottomRow(); + int sCol=m_editRange.leftColumn(); + int eCol=m_editRange.rightColumn(); + QString textValue; + bool isMatch=true; + QRegExp rx("-?[0-9.0-9]*"); + QTableWidgetItem* item=NULL; + for(int i=sRow;i<=eRow;i++) + { + QList rowList; + for(int j=sCol;j<=eCol;j++) + { + if(m_pAssetCopy->isParse()) + { + textValue=m_pAssetCopy->itemParseText(i,j); + isScuccess=rx.exactMatch(textValue); + if(!isScuccess) + { + break; + } + rowList<item(i,j); + + if(NULL != item) + { + textValue=item->text(); + isScuccess=rx.exactMatch(textValue); + if(!isScuccess) + { + break; + } + rowList<restParse(); + +} +//保存曲线 +void GridDataAdapter::saveWellLogData(QList > depthList) +{ + int sRow=m_editRange.topRow(); + int eRow=m_editRange.bottomRow(); + int sCol=m_editRange.leftColumn(); + int eCol=m_editRange.rightColumn(); + PFLOATPROPERTY &vM=m_pWellLogs[0]->GetMD(); + double nStart =m_pWellLogs[0]->GetTopDepth(); + double nEnd =m_pWellLogs[0]->GetBottomDepth(); + for(int i=1;im_pWellLogs[i]->GetTopDepth()) nStart=m_pWellLogs[i]->GetTopDepth(); + if(nEndGetBottomDepth()) nEnd=m_pWellLogs[i]->GetBottomDepth(); + } + int col,row,pos,cindex; + float dep,val; + col=row=pos=cindex=0; + dep=val=0; + QList cindexs; + for(int i=sRow;i<=eRow;i++) + { + dep=nStart+(i+m_verScrolValue)*vM.m_vProperty[2]; + col=0; + for(int j=sCol;j<=eCol;j++) + { + //屏蔽深度修改 + if(0==j) + { + continue; + } + cindex=j+m_horScrolValue-1; + //单曲线类型更新 + if(1==m_pWellLogs.size()) + { + cindex=0; + }//else 多曲线更新 + if(cindexs.indexOf(cindex)<=0) + cindexs.append(cindex); + + val=depthList.value(row).value(col); + m_pWellLogs[cindex]->SetData(i+m_verScrolValue,&val); + // vP[cindex]->m_vProperty[i+m_verScrolValue]=val; + col++; + } + row++; + } + for(int i=0;iSaveToSLF(); + } +} +//刷新曲线 +void GridDataAdapter::updatetWellLogData() +{ + + QMutexLocker locker(&m_mutex); + if(VerScrollUp && !VerScrollChanged) return; + + PFLOATPROPERTY &vM = m_pWellLogs[0]->GetMD(); + if(vM.size() < 1) return ; + m_Rlev = vM.m_vProperty[2]; + + double nStart = m_pWellLogs[0]->GetTopDepth(); + double nEnd = m_pWellLogs[0]->GetBottomDepth(); + for(int i=1;i m_pWellLogs[i]->GetTopDepth()) + nStart = m_pWellLogs[i]->GetTopDepth(); + if(nEnd < m_pWellLogs[i]->GetBottomDepth()) + nEnd = m_pWellLogs[i]->GetBottomDepth(); + } + + m_PointNum = (nEnd - nStart) / m_Rlev; + int horScrollOffset = m_horScrolValue; + if(m_horScrolValue > 0) + { + horScrollOffset--; + } + char buffer[200]; + buffer[0] = 0; + if(!vP||!vP[0]) return; + if(vP[0]->empty() == false) + { + vector::size_type tempVxSize = vP[0]->size(); + m_PointNum = vP[0]->size(); + setColCount(m_TitleField.size()); + setRowCount(tempVxSize); + QStringList tempFields; + int pageCol=m_pageCol; + + if(m_pageCol>m_TitleField.size()) + { + m_pageCol=m_TitleField.size(); + } + if(m_pageRow>tempVxSize) + { + m_pageRow=tempVxSize; + } + for(int i=0;i= m_TitleField.size()) + { + break; + } + tempFields << m_TitleField[m_horScrolValue + i]; + } + if(pageCol != m_pageCol) + { + fillDefaultTitle(tempFields,pageCol); + } + setTableHeaderData(tempFields); + + + float val=0; + double dep=0; + int pos=0; + int rowSize=0; + QList > data; + + int maxRowRecord = m_verScrolValue + m_pageRow; + int maxColRecord = m_horScrolValue + m_pageCol; + if(maxRowRecord > tempVxSize) + { + maxRowRecord = tempVxSize; + } + if(maxColRecord > m_pWellLogs.size()) + { + maxColRecord = m_pWellLogs.size(); + } + data.reserve(maxRowRecord - m_verScrolValue); + m_pAssetCopy->setVerScrollValue(m_verScrolValue); + m_pAssetCopy->setHorScrollValue(m_horScrolValue); + for(vector::size_type ix = m_verScrolValue; ix < maxRowRecord; ix++) + { + dep = nStart + ix * vM.m_vProperty[2]; + QList lstData; + //lstData.reserve(maxColRecord-m_horScrolValue); + if(m_horScrolValue == 0) + { + lstData<= 0 && horScrollOffset < m_pWellLogs.size()) + { + if(vP && vP[horScrollOffset]) + { + rowSize = vP[horScrollOffset]->m_size; + pos = (dep - m_pWellLogs[horScrollOffset]->GetTopDepth()) / m_pWellLogs[horScrollOffset]->GetRlev() + 0.5; + if(pos >= 0 && pos < rowSize) + { + val = m_pWellLogs[horScrollOffset]->GetData(pos, buffer); + //val=vP[horScrollOffset]->m_vProperty[pos]; + } + else + { + buffer[0] = 0; + val = -9999; + } + + if(m_pWellLogs[horScrollOffset]->acurveinfo.RepCode != REPR_STRING) + lstData<GetTopDepth()) / m_pWellLogs[i]->GetRlev()+0.5; + rowSize = vP[i]->m_size; + if(pos >= 0 && pos < vP[i]->size()) + { + val = m_pWellLogs[i]->GetData(pos, buffer); + } + else + { + buffer[0] = 0; + val = -9999; + } + if(m_pWellLogs[i]->acurveinfo.RepCode != REPR_STRING) + lstData << DataPair(toString(val, 'f', FLOATPREC, 0,false)); + else + lstData << DataPair(buffer); + } + data<fields.size()?pageCol-fields.size():0; + for(int i=0;iGetMD(); + if(vM.size()<1) return ; + char buffer[200]; + if(!vP||!vP[0]) return; + if(!vP[0]->empty()) + { + float val=0; + int maxColRecord=m_TitleField.size(); + vector::size_type tempVxSize = vP[0]->size(); + QString conTents; + progress.CreatProgress(0,tempVxSize,"正在导出数据..."); + if(maxColRecord>m_pWellLogs.size()) + { + maxColRecord=m_pWellLogs.size(); + } + for(vector::size_type ix = 0; ix !=tempVxSize; ix++) + { + conTents=""; + for(int i=0;im_size; + if(ixGetData((int)ix,buffer); + // vP[i]->m_vProperty[ix]; + }else + { + buffer[0]=0; + val=-9999; + } + QString str=buffer; + if(m_pWellLogs[i]->acurveinfo.RepCode!=REPR_STRING) str= toString(val,'f',DECIMALPLACESNUM,0,false); + str.replace(","," "); + if(i ==maxColRecord-1) + { + conTents += str ; + } + else + { + conTents += str + " "; + } + } + fprintf(fp,"%s\n",conTents.toStdString().c_str()); + progress.SetDepth(ix+1); + } + } +} + +////////////////////////////////////////////////////////// +void GridDataAdapter::initMultWellLogData(DType type,QList WellLogs) +{ + // m_pWellLogs=WellLogs; + + // for(int i = 0; i < m_pWellLogs.size(); i++){ + // m_pWellLogs[i]->isUsing = true; + // } + + // m_pAssetCopy->SetWellLogs(type,WellLogs); + // m_pWave=(CObjWellLogWavefile *)m_pWellLogs[0]; + // if(!m_pWave)return; + // m_pWave->isLoad=false; + // m_pWave->LoadFromSLF(); + // m_MutiVM=&m_pWave->GetProperty(); + // WaveInfo=m_pWave->waveinfo; + // m_dtype=type; + // m_SDep = WaveInfo.StartDepth; + // m_EDep = WaveInfo.EndDepth; + // m_Rlev = WaveInfo.DepLevel; + // m_RepCode = WaveInfo.RepCode; + // m_CodeLen = WaveInfo.CodeLen; + // m_SamplePoint = WaveInfo.SamplePoint; + // m_nSamples = WaveInfo.SamplePoint*WaveInfo.ArrayNum; + // m_flRlev2 = WaveInfo.TimeLevel; + // m_PointNum = (float)(fabs((m_EDep-m_SDep)/m_Rlev+1.5)); + // m_TitleField.clear(); + // QString depthUnit=m_pWellLogs[0]->GetDepthUnit(); + // if(m_pWellLogs[0]->GetDepthUnit()=="m"&&depthUnit!="m"&&depthUnit!="米") depthUnit=""; + // else if(m_pWellLogs[0]->GetDepthUnit()=="ft"&&depthUnit!="ft"&&depthUnit!="英尺") depthUnit=""; + // if(depthUnit.isEmpty()) depthUnit=m_pWellLogs[0]->GetDepthAliasUnit(); + // if(depthUnit.isEmpty()) depthUnit="米"; + // m_TitleField << "MD\n"+depthUnit; + // char buf[100]; + // for(int j=0;j WellLogs) +{ + m_pWellLogs=WellLogs; + + for(int i = 0; i < m_pWellLogs.size(); i++){ + m_pWellLogs[i]->isUsing = true; + } + + m_dtype=type; + m_pAssetCopy->SetWellLogs(type,WellLogs); + m_TitleField.clear(); + int a=0; + //获得表格头 + CLogIO *logio=new CLogIO; + if(!logio->Open(m_pWellLogs[0]->GetSlfFileName().toStdString().c_str(),CLogIO::modeRead)) { + delete logio; + return ; + } + char name[100]; + strcpy(name,m_pWellLogs[0]->GetName().toStdString().c_str()); + int iIndex=logio->OpenTDT(name); + if (iIndex >=0) + { + a=1; + logio->GetTDTInfo(iIndex,&TDT); + + int fc=3*TDT.TotalLogNumber; + if(fc<1) { + delete logio; + return; + } + for(int j=0;jCloseTDT(iIndex); + delete logio; +} +////////////////////////////////////////////////////////// +void GridDataAdapter::initFMTWellLogData(DType type,QList WellLogs) +{ + // m_pWellLogs=WellLogs; + + // for(int i = 0; i < m_pWellLogs.size(); i++){ + // m_pWellLogs[i]->isUsing = true; + // } + + // m_pAssetCopy->SetWellLogs(type,WellLogs); + // m_pWave=(CObjWellLogWavefile *)m_pWellLogs[0]; + // if(!m_pWave)return; + // m_pWave->isLoad=false; + // m_pWave->LoadFromSLF(); + // m_MutiVM=&m_pWave->GetProperty(); + // WaveInfo=m_pWave->waveinfo; + // m_dtype=type; + // m_SDep = WaveInfo.StartDepth; + // m_EDep = WaveInfo.EndDepth; + // m_Rlev = WaveInfo.DepLevel; + // m_RepCode = WaveInfo.RepCode; + // m_CodeLen = WaveInfo.CodeLen; + // m_SamplePoint = WaveInfo.SamplePoint; + // m_nSamples = WaveInfo.SamplePoint*WaveInfo.ArrayNum; + // m_flRlev2 = WaveInfo.TimeLevel; + // m_PointNum = (float)(fabs((m_EDep-m_SDep)/m_Rlev+1.5)); + // m_TitleField.clear(); + // QString depthUnit=m_pWellLogs[0]->GetDepthUnit(); + // if(m_pWellLogs[0]->GetDepthUnit()=="m"&&depthUnit!="m"&&depthUnit!="米") depthUnit=""; + // else if(m_pWellLogs[0]->GetDepthUnit()=="ft"&&depthUnit!="ft"&&depthUnit!="英尺") depthUnit=""; + // if(depthUnit.isEmpty()) depthUnit=m_pWellLogs[0]->GetDepthAliasUnit(); + // if(depthUnit.isEmpty()) depthUnit="米"; + // m_TitleField << "MD\n"+depthUnit; + // char buf[100]; + // for(int j=0;jGetSlfFileName(); + // CLogIO * logio=new CLogIO(); + // if(!logio->Open(filePath.toStdString().c_str(),CSlfIO::modeReadWrite)) + // { + // delete logio; + // return; + // } + + // int iIndex = logio->OpenWave(m_pWave->GetName().toStdString().c_str()); + // if (iIndex >= 0) + // { + // int row,col,pos; + // row=0; + // col=pos=row; + // float value,dep; + // value=dep=0; + // int actRow=0; + // int actCol=0; + // char *vchar=(char*)m_MutiVM->m_vProperty; + + // int sRow=m_editRange.topRow(); + // int eRow=m_editRange.bottomRow(); + // int sCol=m_editRange.leftColumn(); + // int eCol=m_editRange.rightColumn(); + // QList > editlist; + // extractMultWellLogData(editlist,isScuccess); + // for(int i=sRow;i<=eRow;i++) + // { + // actRow=m_verScrolValue+i; + // col=0; + // for(int j=sCol;j<=eCol;j++) + // { + // actCol=m_horScrolValue+j; + // if(isScuccess) + // { + // pos=actRow*m_nSamples+(actCol-1); + // value=editlist.value(row).value(col); + // setData(m_RepCode,(char*)&vchar[pos*m_CodeLen],value); + // DWORD result=logio->WriteWave(iIndex,m_SDep,m_PointNum,(void*)m_MutiVM->m_vProperty); + + + // } + // col++; + // } + // row++; + // } + // logio->CloseWave(iIndex); + // } + // delete logio; +} + +//void GridDataAdapter::extractMultWellLogData(int &row,int &col,float &value,bool &isScuccess) +void GridDataAdapter::extractMultWellLogData(QList > &editData,bool &isScuccess) +{ + int sRow=m_editRange.topRow(); + int eRow=m_editRange.bottomRow(); + int sCol=m_editRange.leftColumn(); + int eCol=m_editRange.rightColumn(); + QString textValue; + bool isMatch=true; + QRegExp rx("[0-9.0-9]*"); + QTableWidgetItem* item=NULL; + //需要更新行数 + FLOATPROPERTY vM; + vM.SetSize(3); + vM.m_vProperty[0]=m_SDep; + vM.m_vProperty[1]=m_EDep; + vM.m_vProperty[2]=m_Rlev; + if(m_PointNum>0) + { + + for(int i=sRow;i<=eRow;i++) + { + QList rowList; + for(int j=sCol;j<=eCol;j++) + { + if(m_pAssetCopy->isParse()) + { + textValue=m_pAssetCopy->itemParseText(i,j); + isScuccess=rx.exactMatch(textValue); + if(!isScuccess) + { + break; + } + rowList<item(i,j); + + if(NULL != item) + { + textValue=item->text(); + isScuccess=rx.exactMatch(textValue); + if(!isScuccess) + { + break; + } + rowList<restParse(); +} +void GridDataAdapter::setData(int repCode,char *buffer,double yy) +{ + if(!buffer) + { + return; + } + switch(repCode) + { + case REPR_INT: //0 + (*((int*)buffer))=(int)yy; + break; + case REPR_SHORT: //1 + (*((short *)buffer))=(short)yy; + break; + case REPR_LONG://2 + (*((long *)buffer))=(long)yy; + break; + case REPR_FLOAT://3 + (*((float *)buffer))=yy; + break; + case REPR_DOUBLE://4 + (*((double *)buffer))=(double)yy; + break; + case REPR_CHAR://5 + (*((char *)buffer))=(char)yy; + break; + case REPR_UCHAR://6 + (*((unsigned char *)buffer))=(unsigned char)yy; + break; + case REPR_USHORT://7 + (*((unsigned short *)buffer))=(unsigned short)yy; + break; + case REPR_UINT://8 + (*((unsigned int *)buffer))=(unsigned int)yy; + break; + case REPR_ULONG://9 + (*((unsigned long *)buffer))=(unsigned long )yy; + break; + case REPR_STRING://10 + // *yy=-99999; + break; + } + return; +} + +float GridDataAdapter::getData(int repCode,char *buffer) +{ + float yy; + if(!buffer) + { + return 0; + } + switch(repCode) + { + case REPR_INT: //0 + yy=(double)(*((int*)buffer)); + break; + case REPR_SHORT: //1 + yy=(double)(*((short *)buffer)); + break; + case REPR_LONG://2 + yy=(double)(*((long *)buffer)); + break; + case REPR_FLOAT://3 + yy=(double)(*((float *)buffer)); + break; + case REPR_DOUBLE://4 + yy=(double)(*((double *)buffer)); + break; + case REPR_CHAR://5 + yy=(double)(*((char *)buffer)); + break; + case REPR_UCHAR://6 + yy=(double)(*((unsigned char *)buffer)); + break; + case REPR_USHORT://7 + yy=(double)(*((unsigned short *)buffer)); + break; + case REPR_UINT://8 + yy=(double)(*((unsigned int *)buffer)); + break; + case REPR_ULONG://9 + yy=(double)(*((unsigned long *)buffer)); + break; + case REPR_STRING://10 + yy=-99999; + break; } + return yy; +} +void GridDataAdapter::updatetMultWellLogData() +{ + QMutexLocker locker(&m_mutex); + FLOATPROPERTY vM; + vM.SetSize(3); + vM.m_vProperty[0]=m_SDep; + vM.m_vProperty[1]=m_EDep; + vM.m_vProperty[2]=m_Rlev; + int pageCol=m_pageCol; + if(m_pageCol>m_TitleField.size()) + { + m_pageCol=m_TitleField.size(); + } + + QStringList tempFields; + for(int i=0;i= m_TitleField.size()) + { + break; + } + tempFields<0) + { + horScrollOffset--; + } + if(m_PointNum>0) + { + vector::size_type tempVxSize = m_PointNum; + if(m_pageRow>tempVxSize) + { + m_pageRow=tempVxSize; + } + setRowCount(tempVxSize); + + float val=0; + double dep=0; + int pos=0; + char *vchar=(char*)m_MutiVM->m_vProperty; //m_MutiVM已在initMultWellLogData()中获取曲线信息 + QList > data; + int maxRowRecord=m_verScrolValue+m_pageRow; + int maxColRecord=m_horScrolValue+m_pageCol; + if(maxRowRecord>tempVxSize) + { + maxRowRecord=tempVxSize; + } + if(maxColRecord>m_nSamples) + { + maxColRecord=m_nSamples; + } + m_pAssetCopy->setVerScrollValue(m_verScrolValue); + m_pAssetCopy->setHorScrollValue(m_horScrolValue); + for(vector::size_type ix = m_verScrolValue; ix < maxRowRecord; ++ix) + { + dep=vM.m_vProperty[0]+ix*vM.m_vProperty[2];//cur depth + QList lstData; + if(m_horScrolValue==0) //The first col is depthValue + { + lstData<size()) val =getData(m_RepCode,(char*)&vchar[pos*m_CodeLen]); + else val=-9999; + lstData<size()) val =getData(m_RepCode,(char*)&vchar[pos*m_CodeLen]); + else val=-9999; + lstData<setColumnWidth(i, itemWidth[m_horScrolValue + i]); + */ + } +} +void GridDataAdapter::updatetTDTWellLogData() +{ + QMutexLocker locker(&m_mutex); + QStringList tempFields; + + if(m_pageCol>m_TitleField.size()) + { + m_pageCol=m_TitleField.size(); + } + + if(m_pageRow > recordcount) + { + m_pageRow=recordcount; + } + + for(int i=0;i= m_TitleField.size()) + { + break; + } + + tempFields<recordcount) + { + maxRowRecord=recordcount; + } + if(maxColRecord>m_TitleField.size()) + { + maxColRecord=m_TitleField.size(); + } + + //获得表格头 + CLogIO *logio=new CLogIO; + if(!logio->Open(m_pWellLogs[0]->GetSlfFileName().toStdString().c_str(),CLogIO::modeRead)) { + delete logio; + return ; + } + char name[100]; + strcpy(name,m_pWellLogs[0]->GetName().toStdString().c_str()); + int iIndex=logio->OpenTDT(name); + if (iIndex >=0) + { + logio->GetTDTInfo(iIndex,&TDT); + TDT_DATA**pTDT=new TDT_DATA*[TDT.TotalLogNumber]; + int *num=new int[TDT.TotalLogNumber]; + for(int i=0;iReadTDT(iIndex,i+1,&t,pTDT[i]); + } + int fc=TDT.TotalLogNumber*3; + //读取数据 + char buf[513]; + memset(buf,0,513); + //int c=m_TitleField.size(); + QList > data; + for(int rowindex=/*m_verScrolValue*/ 0;rowindex lstData; + for(int columnindex=/*m_horScrolValue*/ 0 ;columnindexCloseTDT(iIndex); + delete logio; + + if(!ifItemWidth) + for(int i = 0; i < m_pageCol; i++) + m_table->setColumnWidth(i, itemWidth[/*m_horScrolValue*/ + i]); +} +void GridDataAdapter::updatetFMTWellLogData() +{ + QMutexLocker locker(&m_mutex); + FLOATPROPERTY vM; + vM.SetSize(3); + vM.m_vProperty[0]=m_SDep; + vM.m_vProperty[1]=m_EDep; + vM.m_vProperty[2]=m_Rlev; + int pageCol=m_pageCol; + if(m_pageCol>m_TitleField.size()) + { + m_pageCol=m_TitleField.size(); + } + + QStringList tempFields; + for(int i=0;i= m_TitleField.size()) + { + break; + } + tempFields<0) + { + horScrollOffset--; + } + if(m_PointNum>0) + { + vector::size_type tempVxSize = m_PointNum; + if(m_pageRow>tempVxSize) + { + m_pageRow=tempVxSize; + } + setRowCount(tempVxSize); + + float val=0; + double dep=0; + int pos=0; + char *vchar=(char*)m_MutiVM->m_vProperty; //m_MutiVM已在initMultWellLogData()中获取曲线信息 + QList > data; + int maxRowRecord=m_verScrolValue+m_pageRow; + int maxColRecord=m_horScrolValue+m_pageCol; + if(maxRowRecord>tempVxSize) + { + maxRowRecord=tempVxSize; + } + if(maxColRecord>m_nSamples) + { + maxColRecord=m_nSamples; + } + m_pAssetCopy->setVerScrollValue(m_verScrolValue); + m_pAssetCopy->setHorScrollValue(m_horScrolValue); + for(vector::size_type ix = m_verScrolValue; ix < maxRowRecord; ++ix) + { + dep=vM.m_vProperty[0]+ix*vM.m_vProperty[2];//cur depth + QList lstData; + if(m_horScrolValue==0) //The first col is depthValue + { + lstData<size()) val =getData(m_RepCode,(char*)&vchar[pos*m_CodeLen]); + else val=-9999; + lstData<size()) val =getData(m_RepCode,(char*)&vchar[pos*m_CodeLen]); + else val=-9999; + lstData<0) + { + vector::size_type tempVxSize = m_PointNum; + float val=0; + int pos=0; + QString conTents; + process.CreatProgress(0,tempVxSize,"正在导出数据..."); + char *vchar=(char*)m_MutiVM->m_vProperty; + for(vector::size_type ix = 0; ix < tempVxSize; ++ix) + { + conTents.clear(); + for(int i=0;i WellLogs) +{ + m_pWellLogs=WellLogs; + + for(int i = 0; i < m_pWellLogs.size(); i++){ + m_pWellLogs[i]->isUsing = true; + } + + m_dtype=type; + m_pAssetCopy->SetWellLogs(type,WellLogs); + m_TitleField.clear(); + int a=0; + //获得表格头 + CLogIO *logio=new CLogIO; + if(!logio->Open(m_pWellLogs[0]->GetSlfFileName().toStdString().c_str(),CLogIO::modeRead)) { + delete logio; + return ; + } + char name[100]; + strcpy(name,m_pWellLogs[0]->GetName().toStdString().c_str()); + int iIndex=logio->OpenTable(name); + if (iIndex >=0) + { + a=1; + int fc=logio->GetTableFieldCount(iIndex); + if(fc<1) { + delete logio; + return; + } + Slf_TABLE_FIELD *field=new Slf_TABLE_FIELD[fc+1]; + logio->GetTableFieldInfo(iIndex,field); + for(int j=0;j3) { + unit=cs[3]; + } + } + fieldName=field[j].Name; + + int pos=0,pos1=0; + if((pos=unit.indexOf("^"))>-1&&(pos1=unit.indexOf("^",pos+1))>-1) { + QStringList fh=GetSimilarCurves(unit.mid(pos,pos1-pos+1)); + if(fh.size())unit.replace(unit.mid(pos,pos1-pos+1),fh[0]); + } + pos=0,pos1=0; + if((pos=unit.indexOf("!"))>-1&&(pos1=unit.indexOf("!",pos+1))>-1) { + QStringList fh=GetSimilarCurves(unit.mid(pos,pos1-pos+1)); + if(fh.size())unit.replace(unit.mid(pos,pos1-pos+1),fh[0]); + } + + fieldName+="\n"+unit; + m_TitleField.push_back(fieldName); + } + m_TitleField.push_back(" "); + delete[] field; + recordcount=logio->GetTableRecordCount(iIndex); + { + clearBuffer(); + setRowCount(recordcount); + setColCount(m_TitleField.size()); + + } + } + logio->CloseTable(iIndex); + delete logio; +} + +QString digDec(QString cs) +{ + int index=cs.indexOf("."); + if(index >= 0) { + QStringList css=cs.split('e'); + if(css.size() > 1) + cs = css[0]; + + int len = cs.length(); + int j=0; + for(int i = len - 1; i >= index; i--) { + if(cs.at(i)=='0') j++; + else{ + if(cs.at(i) == '.') /*j++*/j = len - (index + 1) - DECIMALPLACESNUM;//暂时都保留3位 + else j = len - (index + 1) - DECIMALPLACESNUM; + break; + } + } + cs = cs.left(len - j); + if(css.size() > 1) { + css[0] = cs; + cs = css.join("e"); + } + } + return cs; +} +//刷新表格数据 +void GridDataAdapter::updatetTableWellLogData() +{ + + QMutexLocker locker(&m_mutex); + QStringList tempFields; + + if(m_pageCol>m_TitleField.size()) + { + m_pageCol=m_TitleField.size(); + } + + if(m_pageRow > recordcount) + { + m_pageRow=recordcount; + } + + for(int i=0;i= m_TitleField.size()) + { + break; + } + + tempFields<recordcount) + { + maxRowRecord=recordcount; + } + if(maxColRecord>m_TitleField.size()) + { + maxColRecord=m_TitleField.size(); + } + + //获得表格头 + CLogIO *logio=new CLogIO; + if(!logio->Open(m_pWellLogs[0]->GetSlfFileName().toStdString().c_str(),CLogIO::modeRead)) { + delete logio; + return ; + } + char name[100]; + strcpy(name,m_pWellLogs[0]->GetName().toStdString().c_str()); + int iIndex=logio->OpenTable(name); + if (iIndex >=0) + { + int fc=logio->GetTableFieldCount(iIndex); + //读取数据 + char buf[513]; + memset(buf,0,513); + //int c=m_TitleField.size(); + QList > data; + for(int rowindex=/*m_verScrolValue*/ 0;rowindex lstData; + for(int columnindex=/*m_horScrolValue*/ 0 ;columnindexGetTableFieldData(iIndex,columnindex,buf,rowindex+1,true); + } + else strcpy(buf,""); + if(strlen(buf)>512) buf[512]=0; + if(ty==0) { + strcpy(buf,""); + lstData<CloseTable(iIndex); + delete logio; + + if(!ifItemWidth) + for(int i = 0; i < m_pageCol; i++) + m_table->setColumnWidth(i, itemWidth[/*m_horScrolValue*/ + i]); +} +//保存表格数据 +void GridDataAdapter::saveTableWellLogData(bool &isScuccess) +{ + int sRow=m_editRange.topRow(); + int eRow=m_editRange.bottomRow(); + int sCol=m_editRange.leftColumn(); + int eCol=m_editRange.rightColumn(); + int actRow=0; + int actCol=0; + QString textValue; + //QRegExp rx("[0-9.0-9]*"); + + CLogIO *logio=new CLogIO; + if(!logio->Open(m_pWellLogs[0]->GetSlfFileName().toStdString().c_str(),CLogIO::modeReadWrite)) { + delete logio; + return; + } + int iIndex=logio->OpenTable(m_pWellLogs[0]->GetName().toStdString().c_str()); + if (iIndex >=0) + { + + int fc=logio->GetTableFieldCount(iIndex); + Slf_TABLE_FIELD *field=new Slf_TABLE_FIELD[fc+1]; + logio->GetTableFieldInfo(iIndex,field); + for(int r=sRow;r<=eRow;r++) + { + actRow=m_verScrolValue+r; + for(int c=sCol;c<=eCol;c++) + { + actCol=m_horScrolValue+c; + QTableWidgetItem* item= m_table->item(r, c); + //QString mColumn =""; + char buf[513]; + if(NULL != item) + { + isScuccess=true; + textValue=item->text(); + + if(field[actCol].RepCode==6||field[actCol].Reserved) { + strcpy(buf,textValue.toStdString().c_str()); + logio->SetTableFieldData(iIndex,actCol,buf,actRow+1); + } + else { + float val=textValue.toFloat(); + logio->SetTableFieldData(iIndex,actCol,(char *)&val,actRow+1); + } + }else + { + isScuccess=false; + } + } + } + + logio->CloseTable(iIndex); + delete[] field; + } + delete logio; +} + +void GridDataAdapter::importWellLogData(QFile &importFile, DepthProgress& process) +{ + int columns=0; + int rows=0; + int cindex=0; + QString textValue; + QString strLine=""; + PFLOATPROPERTY &vM=m_pWellLogs[0]->GetMD(); + + //获取行列及数据 + getRowsColumnsByHeader(importFile,rows,columns,strLine); + QStringList colContents=strLine.split(" ",QString::KeepEmptyParts); + if(colContents.size() != columns) + { + colContents.removeLast(); + } + + if(colContents.size() != columns) + { + return; + } + float val=0; + process.CreatProgress(0,rows,"正在导入数据..."); + for(int i=0;iSetData(i,&val); + } + process.SetDepth(i+1); + if(i+1 != rows) + { + strLine=importFile.readLine(); + colContents=strLine.split(" ",QString::KeepEmptyParts); + if(colContents.size() != columns) + { + colContents.removeLast(); + } + } + } + for(int i=0;iSaveToSLF(); +} + +void GridDataAdapter::importTableWellLogData(QFile &importFile) +{ + CLogIO *logio=new CLogIO; + if(!logio->Open(m_pWellLogs[0]->GetSlfFileName().toStdString().c_str(),CLogIO::modeReadWrite)) { + delete logio; + return; + } + int iIndex=logio->OpenTable(m_pWellLogs[0]->GetName().toStdString().c_str()); + if (iIndex >=0) + { + int fc=logio->GetTableFieldCount(iIndex); + Slf_TABLE_FIELD *field=new Slf_TABLE_FIELD[fc+1]; + logio->GetTableFieldInfo(iIndex,field); + if(!importFile.seek(0)) + { + delete logio; + return; + } + int rows; + int columns; + QString textValue; + QString strLine=""; + //获取行列及数据 + + if(!getRowsColumnsByHeader(importFile,rows,columns,strLine)) { + delete logio; + return; + } + QStringList colContents=strLine.split(" ",QString::KeepEmptyParts); + colContents.removeLast(); + rows=0; + while(!importFile.atEnd()) + { + strLine=importFile.readLine(); + colContents=strLine.split("\t",QString::KeepEmptyParts); + rows++; + for(int c=0;cSetTableFieldData(iIndex,c,buf,rows); + } + else + { + float val=textValue.toFloat(); + logio->SetTableFieldData(iIndex,c,(char *)&val,rows); + } + } + } + logio->CloseTable(iIndex); + delete[] field; + } + delete logio; +} + +void GridDataAdapter::exportTableWellLogData(FILE *fp, DepthProgress& process) +{ + //获得表格头 + CLogIO *logio=new CLogIO; + if(!logio->Open(m_pWellLogs[0]->GetSlfFileName().toStdString().c_str(),CLogIO::modeRead)) { + delete logio; + return ; + } + char name[100]; + strcpy(name,m_pWellLogs[0]->GetName().toStdString().c_str()); + int iIndex=logio->OpenTable(name); + if (iIndex >=0) + { + int fc=logio->GetTableFieldCount(iIndex); + Slf_TABLE_FIELD*pFiled=new Slf_TABLE_FIELD[fc+1]; + logio->GetTableFieldInfo(iIndex,pFiled); + + for(int columnindex=0;columnindexGetTableFieldData(iIndex,columnindex,rowindex+1,buf); + if(pFiled[columnindex].RepCode==6) + { + if(strlen(buf)>512) + { + buf[512]=0; + } + } + if(type!=6&&type512) + { + buf[512]=0; + } + + QString str(buf); + if(columnindex ==m_TitleField.size()-1) + { + conTents += str ; + } + else + { + conTents += str + "\t"; + } + } + fprintf(fp,"%s\n",conTents.toStdString().c_str()); + process.SetDepth(rowindex+1); + } + delete pFiled; + } + logio->CloseTable(iIndex); + delete logio; +} + +bool GridDataAdapter::dataInfoHeader(CLogIO *logio,QStringList &fieldList,QString &wellName,int &rowCount) +{ + int wellLogSize= m_pWellLogs.size(); + char name[100]; + QByteArray buffer; + buffer.resize(100); + QStringList tempFields; + QString fieldName,fieldType,fieldStr; + for(int i=0;iGetName().toStdString().c_str()); + if(!logio->Open(m_pWellLogs[i]->GetSlfFileName().toStdString().c_str(),CLogIO::modeRead)) { + return false; + } + int iIndex=logio->OpenTable(name); + + //导出头信息 + if (iIndex >=0) + { + Slf_FILE_MESSAGE mssage; + logio->GetFileMessage(mssage); + wellName=mssage.WellName; + if(m_dtype != D_MultWellLogData) + { + int fc=logio->GetTableFieldCount(iIndex); + Slf_TABLE_FIELD *field=new Slf_TABLE_FIELD[fc+1]; + logio->GetTableFieldInfo(iIndex,field); + const char *Rep_STR[]={ + "INT","SHORT","LONG","FLOAT","DOUBLE","STRING","CHAR","UCHAR","USHORT","UINT","ULONG" + }; + for(int i=0;i3) { + unit=cs[3]; + } + } + int pos=0,pos1=0; + if((pos=unit.indexOf("^"))>-1&&(pos1=unit.indexOf("^",pos+1))>-1) { + QStringList fh=GetSimilarCurves(unit.mid(pos,pos1-pos+1)); + if(fh.size())unit.replace(unit.mid(pos,pos1-pos+1),fh[0]); + } + pos=0,pos1=0; + if((pos=unit.indexOf("!"))>-1&&(pos1=unit.indexOf("!",pos+1))>-1) { + QStringList fh=GetSimilarCurves(unit.mid(pos,pos1-pos+1)); + if(fh.size())unit.replace(unit.mid(pos,pos1-pos+1),fh[0]); + } + fieldName=field[i].Name; + fieldList<CloseTable(iIndex); + logio->Close(); + } + //获取行数 + switch(m_dtype) + { + case D_WellData: + + + // if(NULL != m_pWell) + // { + // m_pWell->LoadXYZ(); + // DOUBLEPROPERTY& vX = m_pWell->GetX(); + // DOUBLEPROPERTY& vY = m_pWell->GetY(); + // DOUBLEPROPERTY& vZ = m_pWell->GetZ(); + + // if( (vX.empty() == false) && (vX.size() == vY.size()) && (vY.size()== vZ.size()) ) + // { + // rowCount= vX.size(); + // } + // m_pWell->ClearXYZ(); + // } + + break; + case D_WellLogData: + { + PFLOATPROPERTY &vM=m_pWellLogs[0]->GetMD(); + if(vM.size()>0) { + if(vP[0]->empty() == false) + { + rowCount = vP[0]->size(); + } + } + + } + break; + case D_MultWellLogData: + { + if(m_PointNum>0) + { + rowCount = m_PointNum; + } + + } + break; + case D_TableWellLogData: + { + rowCount=recordcount; + } + break; + default: + break; + } + return false; +} + +//导出数据 +bool GridDataAdapter::tableToCSVFile() +{ + char name[100]; + int wellLogSize= m_pWellLogs.size(); + if(wellLogSize==0) + { + return false; + } + bool isMultCure=wellLogSize>1; + + QString filename=m_pWellLogs[0]->GetSlfFileName().toStdString().c_str(); + int a=filename.lastIndexOf("\\"); + int b=filename.lastIndexOf("/"); + if(b>a) a=b; + if(a>-1) filename=filename.mid(a+1); + a=filename.lastIndexOf("."); + if(a>-1) filename=filename.left(a); + QString logdata=""; + if(isMultCure) + { + strcpy(name,filename.toStdString().c_str()); + logdata=GetOutDataPath()+filename+".txt"; + }else + { + strcpy(name,m_pWellLogs[0]->GetName().toStdString().c_str()); + logdata=GetOutDataPath()+"\\"+filename+"_"+name+".txt"; + } + + CLogIO *logio=new CLogIO; + QStringList fieldList; + QString wellName=""; + int rowCount=0; + QString dirFile = QFileDialog::getSaveFileName(m_table, ("Export File"),logdata, ("txt File(*.txt)")); + FILE *fp=fopen(dirFile.toStdString().c_str(),"wt"); + + if(!fp) + { + delete logio; + return false; + } + dataInfoHeader(logio,fieldList,wellName,rowCount); + + for(int i=0;ishow(); + + float m_popTipValue; + int m_verScrolValueNew; + if(m_SDep > 0 && m_Rlev > 0){ + if(m_PointNum > 0){ + m_verScrolValueNew = m_verScrolValue + m_pageRow * m_verScrolValue / m_PointNum; + m_popTipValue = m_SDep + m_verScrolValueNew * m_Rlev; + m_popTipValue = float(int(m_popTipValue * 10)) / 10; + } + else{ + m_popTipValue = m_SDep + m_verScrolValue * m_Rlev; + m_popTipValue = float(int(m_popTipValue * 10)) / 10; + } + m_popTip->moveCursorPoint(m_popTipValue); + } + else{ + int offset= m_verScrolValue % m_pageRow; + QTableWidgetItem *item= m_table->item(offset,0); + + if(NULL != item) + { + m_popTip->moveCursorPoint(item->text().toFloat()); + } + } + +} + +void GridDataAdapter::slotVerScrollBarReleased() +{ + if(m_dtype == D_TableWellLogData|| + m_dtype==D_TDTWellLogData|| + m_dtype==D_FMTWellLogData) + return; + m_popTip->hide(); + + VerScrollUp = true; +} + +void GridDataAdapter::slotHorScrollBarPressed() +{ + VerScrollUp = false; +} + +void GridDataAdapter::slotHorScrollBarReleased() +{ + VerScrollUp = true; +} + +void GridDataAdapter::setRowCount(int rowCount) +{ + if(NULL != m_table) + { + //qDebug()<setRange(0,rowCount-m_pageRow); + } +} + +void GridDataAdapter::setColCount(int colCount) +{ + if(NULL != m_table) + { + m_horScrolBar->setRange(0,colCount-m_pageCol+1); + } +} + +void GridDataAdapter::slotVerScrollValueChange(int nValue) +{ + if(NULL == m_table) + return; + if(m_table->isVisible()) + m_nVerScrollValue = nValue; + m_pAssetCopy->setVerScrollValue(nValue); + m_verScrolValue=nValue; + valueChange(); + + if(m_dtype == D_TableWellLogData|| + m_dtype==D_TDTWellLogData|| + m_dtype==D_FMTWellLogData) + return; + float m_popTipValue; + int m_verScrolValueNew; + if(m_SDep > 0 && m_Rlev > 0){ + if(m_PointNum > 0){ + m_verScrolValueNew = m_verScrolValue + m_pageRow * m_verScrolValue / m_PointNum; + m_popTipValue = m_SDep + m_verScrolValueNew * m_Rlev; + m_popTipValue = float(int(m_popTipValue * 10)) / 10; + } + else{ + m_popTipValue = m_SDep + m_verScrolValue * m_Rlev; + m_popTipValue = float(int(m_popTipValue * 10)) / 10; + } + m_popTip->moveCursorPoint(m_popTipValue); + + if(m_dtype == D_WellLogData){ + // //20210111 GZL add 联动 + // QWidget* parent=qobject_cast(m_table->parent()); + // QWidget* pvPage=parent->findChild("curvePreViewPage"); + // int value = (m_EDep-m_popTipValue)*CurveViewVerRange/(m_EDep-m_SDep)+1; + // if(value >= 0 && value <= CurveViewVerRange){ + // m_mgr->CallDisplayCurveVerChange(0,fileName,curveName,pvPage,value,m_popTipValue); + + // m_mgr->sendTableP2Mgr(pvPage, m_verScrolBar, m_table); + // } + + // //updateTableView(); + } + } + else{ + int offset= m_verScrolValue % m_pageRow; + QTableWidgetItem *item= m_table->item(offset,0); + if(NULL != item) + { + m_popTip->moveCursorPoint(item->text().toFloat()); + } + } + /* + if(m_pageRow<1) m_pageRow=1; + int offset= nValue % m_pageRow; + QTableWidgetItem *item=m_table->item(offset,0); + if(item!=NULL) + m_popTip->moveCursorPoint(item->text().toFloat()); + */ +} + +void GridDataAdapter::slotHorScrollValueChange(int nValue) +{ + QMutexLocker locker(&m_mutex); + if(NULL == m_table) + return; + + if(ifItemWidth){ + itemWidth = new int[m_TitleField.size()+1]; + for(int i = 0; i < m_TitleField.size(); i++) + itemWidth[i] = DefColWidth; + ifItemWidth = false; + } + for(int i = 0; i < m_pageCol; i++) + itemWidth[m_horScrolValue + i] = m_table->columnWidth(i); + + m_horScrolValue=nValue; + m_pAssetCopy->setHorScrollValue(nValue); + valueChange(); +} + +//滚动刷新 +void GridDataAdapter::valueChange() +{ + if(NULL == m_table) + return; + + VerScrollChanged = true; + QFuture future; + m_pComplete=NULL; + switch(m_dtype) + { + case D_WellData: + { + m_pComplete=&GridDataAdapter::updateWellData; + } + break; + case D_WellLogData: + { + m_pComplete=&GridDataAdapter::updatetWellLogData; + } + break; + case D_MultWellLogData: + { + m_pComplete=&GridDataAdapter::updatetMultWellLogData; + } + break; + case D_TableWellLogData: + { + m_pComplete=&GridDataAdapter::updatetTableWellLogData; + } + break; + case D_TDTWellLogData: + { + m_pComplete=&GridDataAdapter::updatetTDTWellLogData; + } + break; + case D_FMTWellLogData: + { + m_pComplete=&GridDataAdapter::updatetFMTWellLogData; + } + break; + default: + break; + } + + // if(NULL != m_pComplete) + // { + // future= QtConcurrent::run(this,m_pComplete); + // watcher.setFuture(future); + // } + +} + +bool GridDataAdapter::eventFilter(QObject *pSender, QEvent * pEvent) +{ + if(m_table == pSender) + { + if(pEvent->type()==QEvent::KeyPress) + { + QKeyEvent* pKeyEvent =(QKeyEvent*)pEvent; + + if((pKeyEvent->modifiers()&Qt::ControlModifier)!=0 && pKeyEvent->key()==Qt::Key_C) + { + m_pAssetCopy->onCopyData(); + return true; + } + else if((pKeyEvent->modifiers()&Qt::ControlModifier)!=0 && pKeyEvent->key()==Qt::Key_V) + { + m_pAssetCopy->onParseData(); + return true; + } + } + + } + return false; +} diff --git a/logPlus/formhead.cpp b/logPlus/formhead.cpp index 5a3e311..031d8ef 100644 --- a/logPlus/formhead.cpp +++ b/logPlus/formhead.cpp @@ -1,7 +1,9 @@ #include "formhead.h" #include "ui_formhead.h" #include +#include #include +#include #include "CallManage.h" #include @@ -26,15 +28,27 @@ FormHead::FormHead(QWidget *parent, int indexID) : QTableView::item {border-right: 0px solid black;} \ QTableView::item:selected {border-right: 0px solid black;}"); - //使能右键菜单功能 + // + //ui->tableWidget->verticalHeader()->hide(); //行 + //ui->tableWidget->horizontalHeader()->hide(); //列 + ui->tableWidget->verticalHeader()->setFixedWidth(3);//标题栏宽度 + ui->tableWidget->horizontalHeader()->setFixedHeight(3);//标题栏高度 + //ui->tableWidget->setColumnCount(1); //动态设置列数 + //ui->tableWidget->horizontalHeader()->setStretchLastSection(true);//最后一列铺满最后 + //标题 +// QTableWidgetItem *headerItem = new QTableWidgetItem(""); +// ui->tableWidget->setHorizontalHeaderItem(0, headerItem); + //我们让一列也可以滑动 + ui->tableWidget->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); + ui->tableWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); + // 设置右键菜单策略 ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu); + connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenu(QPoint))); + // 在窗口构造函数中 + //ui->tableWidget->installEventFilter(this); // 连接信号和槽 - - // 创建并设置定时器 -// m_timer = new QTimer(this); -// connect(m_timer, &QTimer::timeout, this, &FormHead::resizeWindow); -// m_timer->start(5); // 设置定时器为5毫秒 + connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenu(QPoint))); } FormHead::~FormHead() @@ -48,13 +62,12 @@ void FormHead::resizeWindow() //调整大小 if(rect.width()>m_iCols*g_iColsWidth) { - ui->tableWidget->setGeometry((rect.width()-(m_iCols*g_iColsWidth+1))/2, 0, m_iCols*(g_iColsWidth+1), m_iRows*(g_iRowsHight+2)); + ui->tableWidget->setGeometry((rect.width()-(m_iCols*g_iColsWidth+1))/2, 0, m_iCols*(g_iColsWidth+1)+4, m_iRows*(g_iRowsHight+2)+4); } else { - ui->tableWidget->setGeometry(0, 0, m_iCols*(g_iColsWidth+1), m_iRows*(g_iRowsHight+2)); + ui->tableWidget->setGeometry(0, 0, m_iCols*(g_iColsWidth+1)+4, m_iRows*(g_iRowsHight+2)+4); } - //m_timer->stop(); } void FormHead::resizeEvent(QResizeEvent *event) @@ -69,8 +82,8 @@ void FormHead::Init(int iRows, int iCols, int iWidth) //清空 ui->tableWidget->clearContents(); - ui->tableWidget->verticalHeader()->hide();//隐藏左侧系统序号栏 - ui->tableWidget->horizontalHeader()->hide();//隐藏上方系统序号栏 + //ui->tableWidget->verticalHeader()->hide();//隐藏左侧系统序号栏 + //ui->tableWidget->horizontalHeader()->hide();//隐藏上方系统序号栏 //ui->tableWidget->verticalHeader()->setFixedWidth(3);//标题栏宽度 //ui->tableWidget->horizontalHeader()->setFixedHeight(3);//标题栏高度 @@ -95,3 +108,257 @@ void FormHead::Init(int iRows, int iCols, int iWidth) } } } + +void FormHead::slotContextMenu(QPoint pos) +{ + 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 FormHead::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 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() 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 FormHead::slotSplit() +{ + int row,col; + QList selectRanges = ui->tableWidget->selectedRanges(); + if (selectRanges.size() < 2) + { + QMessageBox::warning(this, "拆分表格失败", "单元格已是最小单位,不能再进行拆分", "确定"); + return; + } + QList 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 FormHead::eventFilter(QObject* obj, QEvent* event) +{ + if (obj == ui->tableWidget && event->type() == QEvent::KeyPress) { + QKeyEvent* keyEvent = static_cast(event); + if (keyEvent->matches(QKeySequence::Paste)) { + onPasteExcelData(); + return true; + } + } + return QWidget::eventFilter(obj, event); +} + +//复制粘贴事件 +void FormHead::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 FormHead::copy() +{ + QMap> selMap;//行,列 + QList 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>::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 FormHead::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 FormHead::onPasteExcelData() +{ +// QClipboard* clipboard = QApplication::clipboard(); +// const QString clipData = clipboard->text(); + +// if (clipData.isEmpty()) return; + +// QList 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())); +// //更新行数,列数 +// m_iRows = table->rowCount(); +// m_iCols = table->columnCount(); + +// 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); +// //改变大小 +// resizeWindow(); +} + diff --git a/logPlus/formhead.h b/logPlus/formhead.h index 2833e4a..ff0b298 100644 --- a/logPlus/formhead.h +++ b/logPlus/formhead.h @@ -21,11 +21,19 @@ public: private: Ui::FormHead *ui; +protected: + //支持复制粘贴,暂时还未实现 + void keyPressEvent(QKeyEvent * e); + +public: + //图头 + bool eventFilter(QObject* obj, QEvent* event); + void onPasteExcelData(); + public: int m_indexID; int m_iRows; int m_iCols; - QTimer *m_timer; public: void Init(int iRows, int iCols, int iWidth); @@ -34,6 +42,13 @@ public: public slots: void resizeWindow(); + //图头右键菜单响应函数 + void slotContextMenu(QPoint pos); + void slotMerge();//合并 + void slotSplit();//拆分 + //图头 + void copy(); + void Paste(); }; #endif // FORMHEAD_H diff --git a/logPlus/formmultiheads.cpp b/logPlus/formmultiheads.cpp new file mode 100644 index 0000000..5c3b08d --- /dev/null +++ b/logPlus/formmultiheads.cpp @@ -0,0 +1,172 @@ +#include "formmultiheads.h" +#include "ui_formmultiheads.h" + +#include +#include +#include "newheaddialog.h" +#include "formhead.h" + +extern int g_iRows; +extern int g_iCols; +extern int g_iColsWidth; +extern int g_iRowsHight; + +FormMultiHeads::FormMultiHeads(QWidget *parent) : + QWidget(parent), + ui(new Ui::FormMultiHeads) +{ + ui->setupUi(this); + + //------------------------------------- + //ui->tableWidget->hide(); + //隐藏网格线 + ui->tableWidget->setShowGrid(false); + //设置样式表,不显示竖直边框 + ui->tableWidget->setStyleSheet( "QTableView::item {border-left: 0px solid black;} \ + QTableView::item:selected {border-left: 0px solid black;}\ + QTableView::item {border-right: 0px solid black;} \ + QTableView::item:selected {border-right: 0px solid black;}"); + // + //ui->tableWidget->verticalHeader()->hide(); //行 + //ui->tableWidget->horizontalHeader()->hide(); //列 + ui->tableWidget->verticalHeader()->setFixedWidth(3);//标题栏宽度 + ui->tableWidget->horizontalHeader()->setFixedHeight(3);//标题栏高度 + ui->tableWidget->setColumnCount(1); //动态设置列数 + ui->tableWidget->horizontalHeader()->setStretchLastSection(true);//最后一列铺满最后 + //标题 + QTableWidgetItem *headerItem = new QTableWidgetItem(""); + ui->tableWidget->setHorizontalHeaderItem(0, headerItem); + //我们让一列也可以滑动 + ui->tableWidget->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); + ui->tableWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); + // 设置右键菜单策略 + ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu); + connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenu(QPoint))); + // 在窗口构造函数中 + //ui->tableWidget->installEventFilter(this); +} + +FormMultiHeads::~FormMultiHeads() +{ + delete ui; +} + +void FormMultiHeads::slotContextMenu(QPoint pos) +{ + 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="; + + int rowcount = ui->tableWidget->rowCount(); //总行数 + //增加1行 + ui->tableWidget->setRowCount(rowcount+1); + //行标题 + QTableWidgetItem *headerItem = new QTableWidgetItem(""); + ui->tableWidget->setVerticalHeaderItem(rowcount, headerItem); + + int iWidth=0; + //设置行高度 + ui->tableWidget->setRowHeight(rowcount, g_iRows*(g_iRowsHight+2)+1); + if(rowcount==0) + { + iWidth=g_iCols*g_iColsWidth; + //设置列宽 + ui->tableWidget->setColumnWidth(0, g_iCols*(g_iColsWidth+1)+1); + } + else + { + iWidth=ui->tableWidget->columnWidth(0); + if(iWidthtableWidget->setColumnWidth(0, g_iCols*(g_iColsWidth+1)+1); + } + } + // + FormHead *widgetHead = new FormHead(this, 1); + widgetHead->Init(g_iRows, g_iCols, iWidth); + ui->tableWidget->setCellWidget(rowcount, 0, widgetHead); + } + else if (result == QDialog::Rejected) { + // 处理用户点击了取消按钮的逻辑 + qDebug() << "Rejected="; + } + else { + // 处理其他情况的逻辑 + qDebug() << "other="; + } + } + +// 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; itableWidget->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(); +// } +// } +} diff --git a/logPlus/formmultiheads.h b/logPlus/formmultiheads.h new file mode 100644 index 0000000..904f2f5 --- /dev/null +++ b/logPlus/formmultiheads.h @@ -0,0 +1,29 @@ +#ifndef FORMMULTIHEADS_H +#define FORMMULTIHEADS_H + +#include + +namespace Ui { +class FormMultiHeads; +} + +class FormMultiHeads : public QWidget +{ + Q_OBJECT + +public: + explicit FormMultiHeads(QWidget *parent = nullptr); + ~FormMultiHeads(); + +private: + Ui::FormMultiHeads *ui; + + +public slots: + //图头右键菜单响应函数 + void slotContextMenu(QPoint pos); + + +}; + +#endif // FORMMULTIHEADS_H diff --git a/logPlus/formmultiheads.ui b/logPlus/formmultiheads.ui new file mode 100644 index 0000000..657b899 --- /dev/null +++ b/logPlus/formmultiheads.ui @@ -0,0 +1,36 @@ + + + FormMultiHeads + + + + 0 + 0 + 400 + 300 + + + + Form + + + + 18 + + + 9 + + + 18 + + + 0 + + + + + + + + + diff --git a/logPlus/logPlus.pro b/logPlus/logPlus.pro index 0caefd0..4c09908 100644 --- a/logPlus/logPlus.pro +++ b/logPlus/logPlus.pro @@ -40,6 +40,7 @@ SOURCES += \ formhead.cpp \ forminfo.cpp \ formline.cpp \ + formmultiheads.cpp \ formtrack.cpp \ formwell.cpp \ mainwindow.cpp \ @@ -72,6 +73,7 @@ HEADERS += \ formhead.h \ forminfo.h \ formline.h \ + formmultiheads.h \ formtrack.h \ formwell.h \ mainwindow.h \ @@ -93,6 +95,7 @@ FORMS += \ formhead.ui \ forminfo.ui \ formline.ui \ + formmultiheads.ui \ formtrack.ui \ formwell.ui \ interfaceWidget.ui \ diff --git a/logPlus/mainwindow.h b/logPlus/mainwindow.h index f6cf632..b8f8d06 100644 --- a/logPlus/mainwindow.h +++ b/logPlus/mainwindow.h @@ -10,7 +10,6 @@ #include "qtprojectwidgets.h" #include "qtcenterwidgets.h" -#include "mainwindownew.h" #include "mainwindowcurve.h" #include "customtabwidget.h" #include "ConsoleOutputWidget.h" @@ -47,10 +46,10 @@ public: //停靠栏 QStackedWidget *m_stackedWidget_Center = nullptr;//中间工作区stack - QDockWidget *m_projectView = nullptr; //左侧工程区 - QDockWidget *m_propertyView = nullptr; //右侧属性区 - QDockWidget *m_logView = nullptr; //下方日志区 - QDockWidget *m_gdbView = nullptr; //下方调试区 + //QDockWidget *m_projectView = nullptr; //左侧工程区 + //QDockWidget *m_propertyView = nullptr; //属性区 + //QDockWidget *m_logView = nullptr; //日志区 + //QDockWidget *m_gdbView = nullptr; //调试区 //子页面 QtProjectWidgets *m_projectWidgets; //左侧工程区 diff --git a/logPlus/mainwindowcurve.cpp b/logPlus/mainwindowcurve.cpp index ee52d75..f2c7df1 100644 --- a/logPlus/mainwindowcurve.cpp +++ b/logPlus/mainwindowcurve.cpp @@ -9,7 +9,7 @@ #include #include "newheaddialog.h" #include "formhead.h" -#include "qmytablewidget.h" +//#include "qmytablewidget.h" extern int g_iOneWidth; //道宽 extern QString g_prjname; @@ -45,31 +45,31 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) : //------------------------------------- ui->tableWidget->hide(); - //隐藏网格线 - ui->tableWidget->setShowGrid(false); - //设置样式表,不显示竖直边框 - ui->tableWidget->setStyleSheet( "QTableView::item {border-left: 0px solid black;} \ - QTableView::item:selected {border-left: 0px solid black;}\ - QTableView::item {border-right: 0px solid black;} \ - QTableView::item:selected {border-right: 0px solid black;}"); - // - ui->tableWidget->verticalHeader()->hide(); //行 - ui->tableWidget->horizontalHeader()->hide(); //列 - //ui->tableWidget->verticalHeader()->setFixedWidth(3);//标题栏宽度 - //ui->tableWidget->horizontalHeader()->setFixedHeight(3);//标题栏高度 - ui->tableWidget->setColumnCount(1); //动态设置列数 - ui->tableWidget->horizontalHeader()->setStretchLastSection(true);//最后一列铺满最后 - //标题 - QTableWidgetItem *headerItem = new QTableWidgetItem(""); - ui->tableWidget->setHorizontalHeaderItem(0, headerItem); - //我们让一列也可以滑动 - ui->tableWidget->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); - ui->tableWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); - // 设置右键菜单策略 - ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu); - connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenu(QPoint))); - // 在窗口构造函数中 - //ui->tableWidget->installEventFilter(this); +// //隐藏网格线 +// ui->tableWidget->setShowGrid(false); +// //设置样式表,不显示竖直边框 +// ui->tableWidget->setStyleSheet( "QTableView::item {border-left: 0px solid black;} \ +// QTableView::item:selected {border-left: 0px solid black;}\ +// QTableView::item {border-right: 0px solid black;} \ +// QTableView::item:selected {border-right: 0px solid black;}"); +// // +// ui->tableWidget->verticalHeader()->hide(); //行 +// ui->tableWidget->horizontalHeader()->hide(); //列 +// //ui->tableWidget->verticalHeader()->setFixedWidth(3);//标题栏宽度 +// //ui->tableWidget->horizontalHeader()->setFixedHeight(3);//标题栏高度 +// ui->tableWidget->setColumnCount(1); //动态设置列数 +// ui->tableWidget->horizontalHeader()->setStretchLastSection(true);//最后一列铺满最后 +// //标题 +// QTableWidgetItem *headerItem = new QTableWidgetItem(""); +// ui->tableWidget->setHorizontalHeaderItem(0, headerItem); +// //我们让一列也可以滑动 +// ui->tableWidget->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); +// ui->tableWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); +// // 设置右键菜单策略 +// 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); //设置无边框 @@ -91,11 +91,6 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) : ui->tableWidget_2->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); ui->tableWidget_2->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); -// //表头 -// QStringList list; -// list << "" << "" << "" << ""; -// ui->tableWidget->setHorizontalHeaderLabels(list); - //------------------------------------- ui->tableWidget_3->hide(); ui->tableWidget_3->verticalHeader()->hide(); @@ -106,6 +101,26 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) : connect(this, SIGNAL(sig_NewWell(QString)), this, SLOT(s_NewWell(QString))); connect(CallManage::getInstance(), SIGNAL(sig_mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*))); + + //数据组织与管理树 + m_dock1=new QDockWidget(tr(""),this); + m_dock1->setFeatures(QDockWidget::NoDockWidgetFeatures);//QDockWidget::DockWidgetMovable + //dock1->setAllowedAreas(Qt::TopDockWidgetArea); + // + m_formMultiHeads = new FormMultiHeads(this); + m_dock1->setWidget(m_formMultiHeads); + addDockWidget(Qt::TopDockWidgetArea,m_dock1); + //移除标题栏 + QWidget* lTitleBar = m_dock1->titleBarWidget(); + QWidget* lEmptyWidget = new QWidget(); + m_dock1->setTitleBarWidget(lEmptyWidget); + delete lTitleBar; + + //属性编辑器 +// m_propertyWidget = PropertyService(); +// m_propertyWidget->setWindowTitle("属性编辑器"); +// m_propertyWidget->setParent(this); +// addDockWidget( Qt::TopDockWidgetArea, m_propertyWidget); } MainWindowCurve::~MainWindowCurve() @@ -295,14 +310,22 @@ void MainWindowCurve::s_Save() //显示/隐藏图头 void MainWindowCurve::s_showHeadTable() { - if(ui->tableWidget->isVisible()) + if(m_dock1->isVisible()) { - ui->tableWidget->hide(); + m_dock1->hide(); } else { - ui->tableWidget->show(); + m_dock1->show(); } +// if(ui->tableWidget->isVisible()) +// { +// ui->tableWidget->hide(); +// } +// else { +// ui->tableWidget->show(); +// } + // QTableWidget *tableWidget = new QTableWidget(); // tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); @@ -603,59 +626,60 @@ void MainWindowCurve::dropEvent(QDropEvent* event) void MainWindowCurve::slotContextMenu(QPoint pos) { - 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="; +// 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="; - int rowcount = ui->tableWidget->rowCount(); //总行数 - //增加1行 - ui->tableWidget->setRowCount(rowcount+1); - //行标题 - QTableWidgetItem *headerItem = new QTableWidgetItem(""); - ui->tableWidget->setVerticalHeaderItem(rowcount, headerItem); +// int rowcount = ui->tableWidget->rowCount(); //总行数 +// //增加1行 +// ui->tableWidget->setRowCount(rowcount+1); +// //行标题 +// QTableWidgetItem *headerItem = new QTableWidgetItem(""); +// ui->tableWidget->setVerticalHeaderItem(rowcount, headerItem); + +// int iWidth=0; +// //设置行高度 +// ui->tableWidget->setRowHeight(rowcount, g_iRows*(g_iRowsHight+2)+1); +// if(rowcount==0) +// { +// iWidth=g_iCols*g_iColsWidth; +// //设置列宽 +// ui->tableWidget->setColumnWidth(0, g_iCols*(g_iColsWidth+1)+1); +// } +// else +// { +// iWidth=ui->tableWidget->columnWidth(0); +// if(iWidthtableWidget->setColumnWidth(0, g_iCols*(g_iColsWidth+1)+1); +// } +// } +// // +// FormHead *widgetHead = new FormHead(this, 1); +// widgetHead->Init(g_iRows, g_iCols, iWidth); +// ui->tableWidget->setCellWidget(rowcount, 0, widgetHead); +// } +// else if (result == QDialog::Rejected) { +// // 处理用户点击了取消按钮的逻辑 +// qDebug() << "Rejected="; +// } +// else { +// // 处理其他情况的逻辑 +// qDebug() << "other="; +// } +// } - int iWidth=0; - //设置行高度 - ui->tableWidget->setRowHeight(rowcount, g_iRows*(g_iRowsHight+2)+1); - if(rowcount==0) - { - iWidth=g_iCols*g_iColsWidth; - //设置列宽 - ui->tableWidget->setColumnWidth(0, g_iCols*(g_iColsWidth+1)+1); - } - else - { - iWidth=ui->tableWidget->columnWidth(0); - if(iWidthtableWidget->setColumnWidth(0, g_iCols*(g_iColsWidth+1)+1); - } - } - // - FormHead *widgetHead = new FormHead(this, 1); - widgetHead->Init(g_iRows, g_iCols, iWidth); - ui->tableWidget->setCellWidget(rowcount, 0, widgetHead); - } - else if (result == QDialog::Rejected) { - // 处理用户点击了取消按钮的逻辑 - qDebug() << "Rejected="; - } - else { - // 处理其他情况的逻辑 - qDebug() << "other="; - } - } // if(ui->tableWidget->rowCount()==0 && ui->tableWidget->rowCount()==0) // { diff --git a/logPlus/mainwindowcurve.h b/logPlus/mainwindowcurve.h index 14ef464..cd0d905 100644 --- a/logPlus/mainwindowcurve.h +++ b/logPlus/mainwindowcurve.h @@ -4,6 +4,7 @@ #include #include "formwell.h" #include "geometryutils.h" +#include "formmultiheads.h" #pragma execution_character_set("utf-8") @@ -41,10 +42,15 @@ public slots: //鼠标滚动,通知可视解释窗口 void s_mouseWheel(QWheelEvent *event); + public: QString m_strUuid; QStringList m_listWell; + FormMultiHeads *m_formMultiHeads; //左侧工程区 + + QDockWidget *m_dock1; + public: //展示所有井 void DisplayWells(QJsonArray wellsArray);