You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
239 lines
6.9 KiB
C++
239 lines
6.9 KiB
C++
//////////////////////////////////////////////////////////////////////////////
|
|
//文件: 格式转换类
|
|
//主要功能:
|
|
// 转换GeoMap3.2的的符号库文件
|
|
//
|
|
//程序编写: 2009-8-04
|
|
//
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
#pragma once
|
|
#include "GeoMapDataType.h"
|
|
#include ".\symbolbaselib.h"
|
|
|
|
namespace NFormatReader
|
|
{
|
|
|
|
namespace NGeoMapReader
|
|
{
|
|
|
|
//*****************************************
|
|
// 符号数据结构定义(Geomap 3.2 slf)
|
|
//*****************************************
|
|
|
|
#pragma pack(1)
|
|
|
|
// 符号描述
|
|
struct GMShapeSymHead
|
|
{
|
|
int type; // 分类个数
|
|
int t2i1; // 0x44000000
|
|
int t3i1; // 0x00000000
|
|
char codeType[14]; // 编码方案(SY##.#.#.###)
|
|
int codeNum; // 编码方案级数(5)
|
|
int code1; // 0级数字位数(0:根级别,固定为SY=石油地质)
|
|
int code2; // 1级数字位数(2)
|
|
int code3; // 2级数字位数(1)
|
|
int code4; // 3级数字位数(1)
|
|
int code5; // 4级数字位数(3)(具体符号)
|
|
char id[20]; // 分类名
|
|
char name[30]; // 名称
|
|
};
|
|
|
|
// Geomap 符号分类描述
|
|
struct GMShapeSymSort
|
|
{
|
|
int sort; // 分类
|
|
int t1i1; // 0x01000000
|
|
char code[21]; // 分类代码
|
|
char name[31]; // 分类名称
|
|
};
|
|
|
|
//Geomap符号库中的0类图元(文字)
|
|
struct GMShapeSymText
|
|
{
|
|
short right; // 右
|
|
short bottom; // 底
|
|
short left; // 左
|
|
short top; // 顶
|
|
::byte t1c1; // 子图层数(无效)
|
|
::byte selectPen; // 是否选择画笔(1)
|
|
GColor penColor; // 前景颜色
|
|
::byte penWidth; // 画笔宽度
|
|
::byte selectBrush; // 是否选择画刷(0)
|
|
GColor brushColor; // 背景颜色
|
|
int t2i1;
|
|
::byte colorFlag; // 颜色是否可以被替换(1:前景,2:背景,3:前景和背景)
|
|
::byte shape; // 是否透明
|
|
LOGFONT font; // 字体
|
|
short len; // 文字长度
|
|
char text[20]; // 文字内容
|
|
};
|
|
|
|
//Geoamp符号库中的1类图元(直线,椭圆,矩形,圆角矩形)...................................
|
|
struct GMShapeSymRect
|
|
{
|
|
short right; // 右
|
|
short bottom; // 底
|
|
short left; // 左
|
|
short top; // 顶
|
|
::byte t1c1; // 子图层数(无效)
|
|
::byte selectPen; // 是否选择画笔
|
|
GColor penColor; // 画笔颜色
|
|
::byte penWidth; // 画笔宽度
|
|
::byte selectBrush; // 是否选择画刷
|
|
GColor brushColor; // 画刷颜色
|
|
int t2i1;
|
|
::byte colorFlag; // 颜色是否可以被替换(1:画笔,2:画刷,3:画笔和画刷)
|
|
::byte shape; // 形状类型(0:线段,1:椭圆,2:矩形,3:圆角矩形)
|
|
short cornorWidth; // 圆角矩形的圆角宽度
|
|
short cornorHeight; // 圆角矩形的圆角高度
|
|
};
|
|
|
|
//Geomap符号库中的2类图元(折线或区域)
|
|
struct GMShapeSymPoly
|
|
{
|
|
short right; // 右
|
|
short bottom; // 底
|
|
short left; // 左
|
|
short top; // 顶
|
|
::byte t1c1; // 子图层数(无效)
|
|
::byte selectPen; // 是否选择画笔
|
|
GColor penColor; // 画笔颜色
|
|
::byte penWidth; // 画笔宽度
|
|
::byte selectBrush; // 是否选择画刷
|
|
GColor brushColor; // 画刷颜色
|
|
int t2i1;
|
|
::byte colorFlag; // 颜色是否可以被替换(1:画笔,2:画刷,3:画笔和画刷)
|
|
short nPoint; // 顶点个数
|
|
};
|
|
|
|
//Geomap符号库中的3类图元(弧或饼)
|
|
//(起止角度按顺时针方向计算)
|
|
struct GMShapeSymArc
|
|
{
|
|
short right; // 右
|
|
short bottom; // 底
|
|
short left; // 左
|
|
short top; // 顶
|
|
::byte t1c1; // 子图层数(无效)
|
|
::byte selectPen; // 是否选择画笔(如果选择画笔,则绘制折线)
|
|
GColor penColor; // 画笔颜色
|
|
::byte penWidth; // 画笔宽度
|
|
::byte selectBrush; // 是否选择画刷(如果选择画刷,则绘制多边形填充区域)
|
|
GColor brushColor; // 画刷颜色
|
|
int t2i1;
|
|
::byte colorFlag; // 颜色是否可以被替换(1:画笔,2:画刷,3:画笔和画刷)
|
|
short cornorWidth; // 结束角度(单位为0.1度)
|
|
short cornorHeight; // 起始角度(单位为0.1度)
|
|
};
|
|
|
|
//Geomap符号库中的4类图元(组合图元)
|
|
struct GMShapeSymGroup
|
|
{
|
|
short right; // 右
|
|
short bottom; // 底
|
|
short left; // 左
|
|
short top; // 顶
|
|
::byte t1c1; // 子图层数(无效)
|
|
::byte selectPen; // 是否选择画笔(如果选择画笔,则绘制折线)
|
|
GColor penColor; // 画笔颜色
|
|
::byte penWidth; // 画笔宽度
|
|
::byte selectBrush; // 是否选择画刷(如果选择画刷,则绘制多边形填充区域)
|
|
GColor brushColor; // 画刷颜色
|
|
int t2i1;
|
|
::byte colorFlag; // 颜色是否可以被替换(1:画笔,2:画刷,3:画笔和画刷)
|
|
short nElem; // 组合图元中的子图元个数
|
|
};
|
|
// 符号图元数据结构
|
|
struct GMShapeSymElement
|
|
{
|
|
short left; // 左
|
|
short top; // 顶
|
|
short right; // 右
|
|
short bottom; // 底
|
|
::byte shape; // 图元类别 (0:文字,1:线段,2:椭圆,3:矩形,4:圆角矩形,5:折线,6:弧)
|
|
::byte edge; // 是否选择画笔(如果选择画笔,则绘制折线)
|
|
::byte fill; // 是否选择画刷(如果选择画刷,则绘制多边形填充区域)/文字是否透明
|
|
::byte cFlag; // 颜色是否可以被替换(1:画笔,2:画刷,3:画笔和画刷)
|
|
GColor color; // 画笔颜色
|
|
GColor bkColor; // 画刷颜色
|
|
short penWidth; // 画笔宽度
|
|
short aWidth; // 结束角度(单位为0.1度)/圆角矩形的圆角宽度
|
|
short aHeight; // 起始角度(单位为0.1度)/圆角矩形的圆角高度
|
|
short nPoint; // 顶点个数
|
|
SPoint *vertex; // 顶点数组
|
|
LOGFONT *font; // 字体
|
|
char *text; // 文字内容
|
|
BYTE subType; // 图元类别 -------------------------------------------------后添加
|
|
GMShapeSymRect symRect; // 符号基本元素----------------------------------------------后添加
|
|
GMShapeSymPoly symPoly; // 符号基本元素----------------------------------------------后添加
|
|
GMShapeSymArc symArc; // 符号基本元素----------------------------------------------后添加
|
|
GMShapeSymText symText; // 符号基本元素----------------------------------------------后添加
|
|
GMShapeSymGroup symGroup; // 符号基本元素----------------------------------------------后添加
|
|
};
|
|
|
|
// 符号数据结构
|
|
struct GMShapeSymbol
|
|
{
|
|
int id; // 符号ID
|
|
GColor bkColor; // 符号背景色
|
|
char name[50]; // 符号名称
|
|
int nSymNameLen; //符号名称长度---------------------------后添加
|
|
int nElem; // 符号中的图元个数
|
|
GMShapeSymElement *elems;// 符号中的图元数组
|
|
BYTE tmpInt1; // 扩展1----------------------------------后添加
|
|
BYTE tmpInt2; // 扩展2----------------------------------后添加
|
|
BYTE tmpInt3; // 扩展3----------------------------------后添加
|
|
};
|
|
|
|
// 符号库结构 符号总结构
|
|
struct GMSymbolLib
|
|
{
|
|
int nSymbol; // 符号总数
|
|
GMShapeSymbol *shapeSymbol; // 每个符号元素集
|
|
};
|
|
|
|
class CGeoMapSymbolLib : public CSymbolBaseLib
|
|
{
|
|
public:
|
|
CGeoMapSymbolLib(void);
|
|
virtual ~CGeoMapSymbolLib(void);
|
|
|
|
public:
|
|
// 加载符号数据库
|
|
static bool LoadSymbol(CString *fname=NULL);
|
|
// 释放符号数据库
|
|
static void FreeSymbol();
|
|
// 读取一个符号
|
|
static void ReadSymbol(CFile &m_File, GMShapeSymbol &symbol);
|
|
// 读取符号图元
|
|
static void ReadElement(CFile &m_File,GMShapeSymElement *elems, int nElem);
|
|
|
|
private:
|
|
static GMShapeSymSort *sorts; // 符号类别数据
|
|
static GMShapeSymbol *symbols; // 符号数据
|
|
static bool loaded; // 当前符号数据是否正常加载
|
|
static int nSymbol; // 符号库中的符号个数
|
|
static int nSort; // 符号类别个数
|
|
|
|
public:
|
|
// 绘制指定符号(采用GDI坐标)
|
|
bool DrawSymbol( CDC *pDC, int symID, bool useColor, GColor color, int size, CPoint posi);
|
|
|
|
private:
|
|
void convert(CPoint &pt);
|
|
void convert(CPoint *pt, int n);
|
|
int symID = 0; // 符号ID
|
|
CDC *pDC = nullptr; // 画布
|
|
bool useColor = false; // 采用用户指定颜色绘制符号
|
|
GColor color; // 用户指定颜色
|
|
int size = 0; // 符号大小
|
|
CPoint position; // 符号中心点位置
|
|
};
|
|
|
|
|
|
};
|
|
};
|