|
|
|
|
|
#pragma once
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
|
|
|
|
|
|
class CSigmaView;
|
|
|
|
|
|
class CXy;
|
|
|
|
|
|
#include "TsvParser.h"
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 表格数据导入类型(与流式 API 的 importType 对应)
|
|
|
|
|
|
*/
|
|
|
|
|
|
enum TableImportType
|
|
|
|
|
|
{
|
|
|
|
|
|
TableImport_Points = 1, // 普通点(井点),列:X,Y 必需;Z, 名称, 图层 可选
|
|
|
|
|
|
TableImport_XyzPoints = 2, // XYZ 散点,列:X,Y 必需;Z, 图层 可选
|
|
|
|
|
|
TableImport_Curves = 3 // 曲线,列:X,Y 必需;Z, L, 名称, 图层 可选
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 从已解析的表格数据导入普通点(井点)
|
|
|
|
|
|
* @return 导入数量,失败返回 -1
|
|
|
|
|
|
*/
|
|
|
|
|
|
int ImportTableAsPoints(CSigmaView* pView, const TsvParser::TableData& tableData);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 从已解析的表格数据导入 XYZ 散点
|
|
|
|
|
|
* @return 导入数量,失败返回 -1
|
|
|
|
|
|
*/
|
|
|
|
|
|
int ImportTableAsXyzPoints(CSigmaView* pView, const TsvParser::TableData& tableData);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 从已解析的表格数据导入曲线
|
|
|
|
|
|
* @return 导入曲线条数,失败返回 -1
|
|
|
|
|
|
*/
|
|
|
|
|
|
int ImportTableAsCurves(CSigmaView* pView, const TsvParser::TableData& tableData);
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
// 流式按行导入(真流式:每行解析完即导入,不攒整表)
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
void BuildColumnIndexMapFromHeaders(const std::vector<CString>& headers, std::map<CString, int>& outMap);
|
|
|
|
|
|
CString GetRowValue(const std::vector<CString>& row, const std::map<CString, int>& columnIndexMap, const CString& columnName);
|
|
|
|
|
|
double GetRowDoubleValue(const std::vector<CString>& row, const std::map<CString, int>& columnIndexMap, const CString& columnName, double defaultValue = 0.0);
|
|
|
|
|
|
|
|
|
|
|
|
bool ImportPointRow(CSigmaView* pView, const std::map<CString, int>& columnIndexMap, const std::vector<CString>& row);
|
|
|
|
|
|
bool ImportXyzPointRow(CSigmaView* pView, const std::map<CString, int>& columnIndexMap, const std::vector<CString>& row);
|
|
|
|
|
|
|
|
|
|
|
|
/** 曲线流式导入:有状态,每行 OnRow,结束时 End() 提交最后一条曲线 */
|
|
|
|
|
|
class CurveStreamImporter
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
explicit CurveStreamImporter(CSigmaView* pView);
|
|
|
|
|
|
void OnRow(const std::map<CString, int>& columnIndexMap, const std::vector<CString>& row);
|
|
|
|
|
|
void End();
|
|
|
|
|
|
int GetImportCount() const { return m_importCount; }
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
void FlushCurrentCurve();
|
|
|
|
|
|
|
|
|
|
|
|
CSigmaView* m_pView = nullptr;
|
|
|
|
|
|
CXy* m_pXy = nullptr;
|
|
|
|
|
|
CString m_currentLayer;
|
|
|
|
|
|
CString m_currentName;
|
|
|
|
|
|
std::vector<double> m_curX, m_curY, m_curZ, m_curL;
|
|
|
|
|
|
CString m_curName;
|
|
|
|
|
|
int m_importCount = 0;
|
|
|
|
|
|
};
|