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.
119 lines
3.4 KiB
C++
119 lines
3.4 KiB
C++
//////////////////////////////////////////////////////////////////////////////
|
|
//文件: 格式转换类
|
|
//主要功能:
|
|
// 转换GeoMap3.2的的线型库文件
|
|
//
|
|
//程序编写: 2009-8-04
|
|
//
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
#pragma once
|
|
#include "GeoMapDataType.h"
|
|
|
|
|
|
namespace NFormatReader
|
|
{
|
|
|
|
namespace NGeoMapReader
|
|
{
|
|
|
|
//*****************************************
|
|
// 线型数据结构定义(Geomap 3.2 lsl)
|
|
//*****************************************
|
|
|
|
// Geomap 线型索引
|
|
struct GMShapeLineIndex
|
|
{
|
|
int pos; // 数据开始位置
|
|
int len; // 数据长度
|
|
};
|
|
|
|
// Geomap 线型图元
|
|
struct GMShapeLineElement
|
|
{
|
|
::byte eType; // 图元类型(0:矩形,1:直线,2:椭圆,3:三角形,4:弧,5:半圆形)
|
|
::byte isFill; // 是否填充
|
|
GColor lineColor; // 线/边界颜色
|
|
GColor fillColor; // 填充颜色
|
|
char x1,y1,x2,y2; // 图元控制点坐标
|
|
};
|
|
|
|
// Geomap 线型层
|
|
struct GMShapeLineLayer
|
|
{
|
|
::byte yTop; // 上部高度
|
|
::byte yBottom; // 下部高度
|
|
::byte width; // 横向宽度
|
|
::byte nElement; // 图元个数
|
|
::byte type; // 层类型(1:开始层,2:循环层,4:结束层)
|
|
::byte res1; // 未知(?=1)
|
|
GMShapeLineElement *elem; // 图元数据
|
|
};
|
|
|
|
// Geomap 线型
|
|
struct GMShapeLine
|
|
{
|
|
::byte nameLen; // 线型名称长度
|
|
char name[256]; // 线型名称
|
|
int user; // 是否用户线型(0:系统线型,1:用户线型)
|
|
::byte nLayer; // 线型层数
|
|
GMShapeLineLayer *layer; // 图层数据
|
|
};
|
|
|
|
|
|
// Windows 系统缺省调色板
|
|
static GColor GMsysColors[48] = {
|
|
{255,128,128,0},{255,255,128,0},{128,255,128,0},{ 0,255,128,0},{128,255,255,0},{ 0,128,255,0},{255,128,192,0},{255,128,255,0},
|
|
{255, 0, 0,0},{255,255, 0,0},{128,255, 0,0},{ 0,255, 64,0},{ 0,255,255,0},{ 0,128,192,0},{128,128,192,0},{255, 0,255,0},
|
|
{128, 64, 64,0},{255,128, 64,0},{ 0,255, 0,0},{ 0,128,128,0},{ 0, 64,128,0},{128,128,255,0},{128, 0, 64,0},{255, 0,128,0},
|
|
{128, 0, 0,0},{255,128, 0,0},{ 0,128, 0,0},{ 0,128, 64,0},{ 0, 0,255,0},{ 0, 0,160,0},{128, 0,128,0},{128, 0,255,0},
|
|
{ 64, 0, 0,0},{128, 64, 0,0},{ 0, 64, 0,0},{ 0, 64, 64,0},{ 0, 0,128,0},{ 0, 0, 64,0},{ 64, 0, 64,0},{ 64, 0,128,0},
|
|
{ 0, 0, 0,0},{128,128, 0,0},{128,128, 64,0},{128,128,128,0},{ 64,128,128,0},{192,192,192,0},{ 64, 0, 64,0},{255,255,255,0}
|
|
};
|
|
|
|
class CGeoMapLineShapeLib
|
|
{
|
|
public:
|
|
CGeoMapLineShapeLib(void);
|
|
virtual ~CGeoMapLineShapeLib(void);
|
|
|
|
public:
|
|
// 用指定线型绘制折线(采用GDI坐标)(当前未作交点处理)
|
|
bool DrawLine( CDC *pDC, int lineID, bool useColor, GColor color, int size, int nVertex, CPoint *vertex);
|
|
|
|
public:
|
|
// 加载线型数据库
|
|
static bool LoadLine(CString *fname=NULL);
|
|
// 释放线型数据库
|
|
static void FreeLine();
|
|
private:
|
|
static GMShapeLine *lineShapes; // 当前线型数据
|
|
static int nLine; // 线型库中的线型个数
|
|
|
|
private:
|
|
void DrawLayer( GMShapeLineLayer layer); // 绘制一个层
|
|
void DrawLineSeg( GMShapeLineLayer layer, int DrawType ); // 绘制线段
|
|
void convert(CPoint &pt);
|
|
void convert(CPoint *pt, int n);
|
|
// 计算两条线段的交点
|
|
bool CalcIntersectedPoint( CPoint pt11,CPoint pt12, CPoint pt21, CPoint pt22, CPoint &pt);
|
|
|
|
private:
|
|
int lineID = 0; // 线型ID
|
|
IPoint ptStart{}; // 实际绘制的起点坐标
|
|
int BegPos = 0, EndPos = 0; // 绘制的部分在线型长度方向上的起止位置
|
|
double sina = 0,cosa = 0; // 当前线段倾角参数
|
|
|
|
private:
|
|
CDC *pDC = nullptr; // 画布
|
|
bool useColor = false; // 采用用户指定颜色绘制线型
|
|
GColor color{}; // 用户指定颜色
|
|
int size = 0; // 线宽
|
|
int nVertex = 0; // 折线的顶点数
|
|
CPoint *vertex = nullptr; // 折线的顶点坐标数组
|
|
};
|
|
|
|
};
|
|
};
|