|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
//文件 CGDBXDraw.h
|
|
|
//主要功能:
|
|
|
//
|
|
|
//程序编写:
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
#pragma once
|
|
|
#include "formatdc.h"
|
|
|
#include "../IDcDraw.h"
|
|
|
//#include "ClibPDF\cpdflib.h"
|
|
|
#ifndef M_PI
|
|
|
# define M_PI 3.14159265358979323846 /* pi */
|
|
|
#endif
|
|
|
|
|
|
#include "..\GdbxDefine.h"
|
|
|
#include "GeoMapGdbxWriter.h"
|
|
|
#include <unordered_map>
|
|
|
|
|
|
class CGDBXDraw :
|
|
|
public IDcDraw
|
|
|
{
|
|
|
public:
|
|
|
CGDBXDraw();
|
|
|
CGDBXDraw(CXyDC* pXyDC);
|
|
|
~CGDBXDraw();
|
|
|
void Create(CXyDC* pXyDC);
|
|
|
|
|
|
void InitDC();
|
|
|
void ReleaseDC();
|
|
|
void Close();
|
|
|
|
|
|
void SetGDBXData(CXy *xy);
|
|
|
void SetGDBXFilePath(const CString &path);
|
|
|
|
|
|
void Draw(CText& text, CCurveEx* pCurveRect = NULL) override;
|
|
|
void Draw(CText& text, COLORREF color) override; //文字
|
|
|
void Draw(CMText& mtext) override;
|
|
|
|
|
|
void Draw(CEllipse& elp, COLORREF Color) override;
|
|
|
void Draw(CCircle& circle, COLORREF Color) override;
|
|
|
void Draw(CInsertDraw& m_insert) override; //- 组合块 符号
|
|
|
void Draw(CXyDC* pNewXyDC, CInsertDraw& m_insert) override;
|
|
|
void Draw(CInsertOld& m_insert) override;
|
|
|
void Draw(CXyDC* pInsertXyDC, CInsertOld& m_insert) override;
|
|
|
void Draw(CSection& section, CRect8* rect = NULL) override;
|
|
|
void Draw(CImageInsert& image) override; //-背景图
|
|
|
void Draw(CMesh& mesh) override;
|
|
|
void Draw(CMetaFile& mf) override; //原文件(emf整张插入)
|
|
|
void Draw(CColorRuler& ruler, CColorBase& color) override;
|
|
|
void Draw(CPathFill& path, COLORREF fillColor, void* HowToViewCurve) override;
|
|
|
void Draw(C3DFaultageSurface& fs, COLORREF fillColor, void* HowToViewCurve) override;
|
|
|
|
|
|
void Draw(CProportion& proportion, COLORREF color) override;
|
|
|
|
|
|
void Draw(CCurveEx& curve, double l1, double l2) override;
|
|
|
void Draw(CCurveEx& m_curve) override;
|
|
|
void Draw(CCurveEx& curve, void* HowToViewCurve) override; //-
|
|
|
void Draw(CCurveEx& curve, COLORREF color, BOOL bSmoothHead = TRUE) override; //-
|
|
|
|
|
|
void Draw(CCurveRect& rt, void* HowToViewCurve) override;
|
|
|
void Draw(CCurveRect& curve, COLORREF color) override;
|
|
|
|
|
|
void Draw(CPointNameEx& point, void* HowToViewPoint) override; //-
|
|
|
void Draw(CPointCrossName& point, void* HowToViewPoint) override; //
|
|
|
void Draw(CPointTwoName& point, void* HowToViewPoint) override;
|
|
|
|
|
|
void Draw(CInsertDrawRect& idr) override;
|
|
|
void Draw(CArc& arc, void* HowToViewCurve) override;
|
|
|
void Draw(CArc& arc, COLORREF color) override;
|
|
|
void Draw(CFrame& frame, COLORREF color) override; //- 边框(不处理)
|
|
|
void Draw(CNet& net, COLORREF colText, COLORREF colLine) override;
|
|
|
void Draw(CGridding& grid, COLORREF colText, COLORREF colLine) override; //- 边框经纬网(不处理)
|
|
|
void Draw(COtherDraw& od, void* HowToViewCurve) override;
|
|
|
void Draw(COtherDraw& od, COLORREF color) override;
|
|
|
void Draw(COleObject& ole) override;
|
|
|
void Draw(CTree& tree) override;
|
|
|
void Draw(CStation& cs) override;
|
|
|
void Draw(CCurveTV5& tv, void* HowToViewCurve) override;
|
|
|
void Draw(CScaleRuler& sr, COLORREF color) override;
|
|
|
void Draw(CRectLabel& rl, COLORREF color, void* HowToViewCurve) override;
|
|
|
|
|
|
void DrawArray(CMxn& mxn, COLORREF colFront, COLORREF colBack); //前景色与背景色
|
|
|
void Draw(CMxn& mxn, COLORREF colFront, COLORREF colBack);
|
|
|
void DrawGrid(CMxn& mxn);
|
|
|
|
|
|
void Draw(CHorizontalWell& horizontalwell, void* HowToViewCurve);
|
|
|
void Draw(CWellGroup& wellGroup);
|
|
|
|
|
|
void PolyLine(CPointList& dp);
|
|
|
void PaintRgn(LPPOINT sp, int count);
|
|
|
|
|
|
//绘制当前GDBX文件符号(需要单独写入到CustomSymbol字段中)
|
|
|
void DrawCurrentGDBXSymbol();
|
|
|
void WriteCurrentMarkXML(void *pDraw);
|
|
|
|
|
|
//绘制符号线段
|
|
|
void DrawSymbolCCurve(CCurveEx& curve, COLORREF color, pugi::xml_node& node);
|
|
|
//绘制符号圆
|
|
|
void DrawSymbolEllipse(CEllipse& ellipse, COLORREF color, pugi::xml_node& node);
|
|
|
|
|
|
//矩形充填
|
|
|
void DrawGDBXFillRect(CRect8& rect, COLORREF color, const CString &lyerName);
|
|
|
//绘制比例尺线段
|
|
|
void DrawGDBXProportionLine(std::vector<GDBXLINETO>& pointVec, CProportion& proportion, COLORREF color = 0);
|
|
|
|
|
|
//文字绘制(色标等)
|
|
|
void DrawGDBXText(CText& text, COLORREF color, const CString &layerName, pugi::xml_node *parentNode = nullptr, int state = 0);
|
|
|
//绘制线段(色标)
|
|
|
void DrawGDBXLine(std::vector<GDBXLINETO>& pointVec, const CString &layerName, COLORREF color = 0);
|
|
|
//色标绘制
|
|
|
void DrawGDBXRulerImage(CColorRuler& ruler, CColorBase &color, COne *pOne);
|
|
|
void DrawGDBXRulerImage_Reversal(CColorRuler& ruler, CColorBase& color, COne* pOne);
|
|
|
//符号绘制
|
|
|
void DrawGDBXCInserDraw(CPointNameEx& point, COne *pOne, CHowToViewPoint* hp);
|
|
|
//处理Mesh
|
|
|
void DrawGDBXCImageInsert(CImageInsert& image, COne *pOne);
|
|
|
//处理Mesh
|
|
|
void DrawGDBXCColorRuler(CColorRuler& ruler, CColorBase& color, COne *pOne);
|
|
|
//绘制边框
|
|
|
void DrawGDBXNormalGrid();
|
|
|
//绘制比例尺(GDBX比例尺绘制 转换有差异)
|
|
|
void DrawGDBXScale(CProportion& proportion, COLORREF color);
|
|
|
//绘制边框
|
|
|
void DrawGDBXGrid(CGridding& grid, COLORREF colText, COLORREF colLine);
|
|
|
//边框文字
|
|
|
void DrawGDBXGridPline(CGridding& grid, BOOL bDraw);
|
|
|
|
|
|
//矢量图位图
|
|
|
void DrawGDBXMeshVectorImage(CMesh& mesh);
|
|
|
//处理矢量图Mesh
|
|
|
void DrawGDBXMeshVectorInsert(CxImage& image, CRect8 rtReal, CSize8 size8, COne* pOne);
|
|
|
|
|
|
private:
|
|
|
void Clear();
|
|
|
|
|
|
//将角度转换为弧度
|
|
|
double DegreesToRadians(double degrees);
|
|
|
|
|
|
/**
|
|
|
* libarchive 压缩文件
|
|
|
*
|
|
|
* \param gdbxPath gdbx全路径
|
|
|
* \param outPath 输出压缩文件全路径
|
|
|
* \return
|
|
|
*/
|
|
|
int CompressGdbxDirectory(const CString& gdbxPath, const CString& outPath);
|
|
|
|
|
|
//gdbx头部信息
|
|
|
int createGDBXHead();
|
|
|
|
|
|
/**
|
|
|
* 加密函数:序列化、压缩、Base64 编码
|
|
|
*
|
|
|
* \param lineList 点集合
|
|
|
* \param length 数据长度
|
|
|
* \return
|
|
|
*/
|
|
|
CString PolyDataMemoryBlock(const std::vector<GDBXLINETO>& lineList, int &length);
|
|
|
|
|
|
/**
|
|
|
* 将字节数组转换为十六进制字符串,每个字节转换为 2 个大写十六进制字符
|
|
|
*
|
|
|
* \param pData
|
|
|
* \param nLength
|
|
|
* \return
|
|
|
*/
|
|
|
CString ByteArrayToHexString(const BYTE* pData, size_t nLength);
|
|
|
|
|
|
/**
|
|
|
* 加密函数:将 vector<GDBXLINETO> 序列化为二进制数据块,再转换为十六进制字符串
|
|
|
*
|
|
|
* \param lineList 点集合
|
|
|
* \return
|
|
|
*/
|
|
|
CString EncryptBigPts(const vector<GDBXLINETO>& lineList);
|
|
|
|
|
|
/**
|
|
|
* 加密函数:按行宽插入换行符
|
|
|
*
|
|
|
* \param input 需要截断字符
|
|
|
* \param num 每行截断长度
|
|
|
* \param lineCount 总行数
|
|
|
* \return
|
|
|
*/
|
|
|
CString FormatStringWithLineBreaks(const CString &input,int lineWidth, int& lineCount);
|
|
|
|
|
|
/**
|
|
|
* 查找ElementMap
|
|
|
*
|
|
|
* \param void *
|
|
|
* \return COne *
|
|
|
*/
|
|
|
COne* FindElementMap(void *pValue);
|
|
|
|
|
|
/**
|
|
|
* 将上下标字符转换
|
|
|
*
|
|
|
* \param cmd
|
|
|
* \return 转换后的字符
|
|
|
*/
|
|
|
CString ReverseSuperAndSubConversion(CString cmd);
|
|
|
|
|
|
/**
|
|
|
* 查找
|
|
|
*
|
|
|
* \param markName
|
|
|
* \return int
|
|
|
*/
|
|
|
int FindMarkNumberMap(const CString& markName);
|
|
|
|
|
|
/**
|
|
|
* 颜色转换RGB->RGBA
|
|
|
*
|
|
|
* \param markName
|
|
|
* \return int
|
|
|
*/
|
|
|
COLORREF RGBToRGBA(COLORREF color);
|
|
|
|
|
|
/**
|
|
|
* 查找m_layerElement
|
|
|
*
|
|
|
* \param layerName
|
|
|
* \return pugi::xml_node
|
|
|
*/
|
|
|
pugi::xml_node FindLayerElementMap(const CString &layerName);
|
|
|
|
|
|
/**
|
|
|
* 设置图层层级顺序
|
|
|
*
|
|
|
* \return CString
|
|
|
*/
|
|
|
CString GetLayerListOrder();
|
|
|
|
|
|
/**
|
|
|
* 删除解压后的文件
|
|
|
* \return int
|
|
|
*/
|
|
|
int RemoveAllGDBXDirPath();
|
|
|
|
|
|
/**
|
|
|
* 新增xml层级元素
|
|
|
*
|
|
|
*/
|
|
|
void NewXmlElementLayer(const CString& strLayer);
|
|
|
|
|
|
/**
|
|
|
* 查找层级元素
|
|
|
*
|
|
|
*/
|
|
|
CString FindLayerName(COne *pOne);
|
|
|
|
|
|
/**
|
|
|
* 计算线段名字属性位置
|
|
|
*
|
|
|
*/
|
|
|
void ComputeCurveName(CCurveEx &curve, CCurveName *pName, int state, const CString& layerName);
|
|
|
|
|
|
/**
|
|
|
* 处理geomap4.5版本符号名称不兼容
|
|
|
*
|
|
|
*/
|
|
|
CString EnsureCsPrefix(const CString& synbolName);
|
|
|
|
|
|
/**
|
|
|
* 处理block组合块无层级
|
|
|
*
|
|
|
*/
|
|
|
CString FindBlockLayerName();
|
|
|
|
|
|
private:
|
|
|
int m_metaFileNum; //元文件个数
|
|
|
int m_version;
|
|
|
int m_layerIndex; //记录层级顺序
|
|
|
long n_shapeIdCount;
|
|
|
long n_markShapeID; //符号ShapeID计数
|
|
|
double m_scale;
|
|
|
double m_paperW, m_paperH; //图纸宽高mm
|
|
|
CRect8 m_rect;
|
|
|
CSize8 m_unit;
|
|
|
CSize8 m_markscale;
|
|
|
CRect8 m_gdbxMarkRect; //gdbx符号范围
|
|
|
|
|
|
CString m_xmlPath; //gdbx xml文件生成位置
|
|
|
CString m_gdbxDirPath; //gdbx 文件夹
|
|
|
CString m_filePath; //gdbx 压缩后的文件路径
|
|
|
|
|
|
CGeoMapGdbxWriter* p_gdbx;
|
|
|
|
|
|
pugi::xml_document m_doc;
|
|
|
pugi::xml_node m_mapNode;
|
|
|
pugi::xml_node m_layersNode;
|
|
|
pugi::xml_node m_customSymbolNode;
|
|
|
|
|
|
int m_markNumber;
|
|
|
std::unordered_map<std::string, int> m_markNumberMap;
|
|
|
|
|
|
std::unordered_map<void*, COne*> m_elementMap;
|
|
|
CMapStringToPtrNoCase* p_CurrentGlobalMark = nullptr; //当前符号
|
|
|
|
|
|
CLayerList* p_LayerList;
|
|
|
std::unordered_map<std::string, pugi::xml_node> m_layerElementMap; //图层层级
|
|
|
|
|
|
};
|