|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
//文件: 格式转换类
|
|
|
//主要功能:
|
|
|
// 转换CGM格式
|
|
|
//
|
|
|
//程序编写: 2006-8-09
|
|
|
//
|
|
|
//
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
#if !defined(AFX_DFCGM_H__34E7F6BD_0033_4DFC_96B8_1E5AAC63A161__INCLUDED_)
|
|
|
#define AFX_DFCGM_H__34E7F6BD_0033_4DFC_96B8_1E5AAC63A161__INCLUDED_
|
|
|
|
|
|
#if _MSC_VER > 1000
|
|
|
#pragma once
|
|
|
#endif // _MSC_VER > 1000
|
|
|
|
|
|
#include <map>
|
|
|
#include <list>
|
|
|
using namespace std;
|
|
|
|
|
|
#include ".\otherformat.h"
|
|
|
#include "DrawOperator\curveex.h"
|
|
|
|
|
|
namespace NFormatReader
|
|
|
{
|
|
|
|
|
|
namespace NCgmReader
|
|
|
{
|
|
|
|
|
|
#define CMDSIZE 16
|
|
|
#define ENUMSIZE 16
|
|
|
#define BYTESIZE 8
|
|
|
|
|
|
typedef struct cgm_color
|
|
|
{
|
|
|
double red;
|
|
|
double green;
|
|
|
double blue;
|
|
|
}CGMCOL;
|
|
|
typedef struct cgm_scale
|
|
|
{
|
|
|
int mode;
|
|
|
double scaling;
|
|
|
}CGMSCALE;
|
|
|
|
|
|
typedef struct cgm_pic_des
|
|
|
{
|
|
|
CGMSCALE scaleMode;
|
|
|
int colourMode;
|
|
|
int lineWidthMode;
|
|
|
int markerSizeMode;
|
|
|
int edgeWidthMode;
|
|
|
|
|
|
CPoint2D vdcMax;
|
|
|
CPoint2D vdcMin;
|
|
|
|
|
|
long backGroundColour;
|
|
|
|
|
|
}CGMPICDES;
|
|
|
|
|
|
typedef struct cgm_device_viewport_des
|
|
|
{
|
|
|
CPoint2D firstConer;
|
|
|
CPoint2D secondConer;
|
|
|
|
|
|
int specificationMode;
|
|
|
double metricScaleFactor;
|
|
|
|
|
|
int isotropy;
|
|
|
int horizontal;
|
|
|
int vertical;
|
|
|
}CGMDEVICEVIEWPORTDES;
|
|
|
|
|
|
typedef struct cgm_real_prec
|
|
|
{
|
|
|
int fixed; //浮点=0;定点=1
|
|
|
int exp;
|
|
|
int fract;
|
|
|
}CGMREALPREC;
|
|
|
typedef struct cgm_metafile_des
|
|
|
{
|
|
|
int version; //版本号
|
|
|
|
|
|
int vdcType; //设备坐标0=integer or 1=real, default: integer
|
|
|
CGMREALPREC realPrec; //实数精度
|
|
|
int intPrec; //整数精度
|
|
|
int idxPrec; //索引精度
|
|
|
int colPrec; //颜色值精度
|
|
|
int colIdxPrec; //颜色索引精度
|
|
|
|
|
|
int charCoding; //字符编码:0 basic 7-bit,1 basic 8-bit,2 extended 7-bit,3 extended 8-bit
|
|
|
int colModel; //颜色模型,1=RGB,2=CIELAB,3=CIELUV,4=CMYK,5=RGB-related
|
|
|
int maxColIdx; //最大索引值
|
|
|
CGMCOL min_cco; //颜色范围最小值
|
|
|
CGMCOL max_cco; //颜色范围最大值
|
|
|
}CGMMFDES;
|
|
|
typedef struct cgm_control_des
|
|
|
{
|
|
|
int vdcIntPrec; //VDC整数精度
|
|
|
CGMREALPREC vdcRealPrec; //VDC实数精度
|
|
|
|
|
|
long auxColour;
|
|
|
int transparency;
|
|
|
CPoint2D clipMax;
|
|
|
CPoint2D clipMin;
|
|
|
int clipIndictor;
|
|
|
int lineClipMode;
|
|
|
int markerClipMode;
|
|
|
int edgeClipMode;
|
|
|
int textPathMode;
|
|
|
|
|
|
int cellTrans; //CELL是否打开透明颜色,0=OFF,1=ON
|
|
|
long cellTransColour; //CELL透明颜色值
|
|
|
}CGMCTRLDES;
|
|
|
typedef struct cgm_marker_attrib
|
|
|
{
|
|
|
int markerBoundIdx;
|
|
|
int markerType;
|
|
|
double markerWidth;
|
|
|
long markerColour;
|
|
|
}CGMMARKERATRB;
|
|
|
typedef struct cgm_text_aligen
|
|
|
{
|
|
|
int horizontal; //0=normal horizontal;1=left;2=center;3=right;4=continuous horizontal
|
|
|
int vertical; //0=normal vertical;1=top;2=cap;3=half;4=base;5=bottom;6=continuous vertical
|
|
|
double continueHor; //continuous horizontal alignment
|
|
|
double continueVer; //continuous vertical alignment
|
|
|
}CGMTEXTALIGEN;
|
|
|
typedef struct cgm_text_attrib
|
|
|
{
|
|
|
int textBoundIdx;
|
|
|
int textFontIdx;
|
|
|
int textPrec;
|
|
|
double charExpensionFactor;
|
|
|
double spacing;
|
|
|
long textColour;
|
|
|
double charHeight;
|
|
|
CPoint2D orientationMin; //从原点到x1,y1点为开始边 原点到(x2,y2)为结束边的夹角
|
|
|
CPoint2D orientationMax;
|
|
|
int textPath; //0=right;1=left;2=up;3=down;
|
|
|
CGMTEXTALIGEN textAligen;
|
|
|
int charSetIdx;
|
|
|
int alertCharSetIdx;
|
|
|
}CGMTEXTATRB;
|
|
|
typedef struct cgm_fill_attrib
|
|
|
{
|
|
|
int fillBountIdx;
|
|
|
int interiorStyle; //0=hollow, 1=solid, 2=pattern, 3=hatch, 4=empty, 5=geometric pattern, 6=interpolated
|
|
|
long fillColour;
|
|
|
int hatchIndex;
|
|
|
int patternIndex;
|
|
|
}CGMFILLATRB;
|
|
|
typedef struct cgm_edge_attrib
|
|
|
{
|
|
|
int edgeBoundIdx;
|
|
|
int edgeType;
|
|
|
double edgeWidth;
|
|
|
long edgeColour;
|
|
|
int edgeVisibility;
|
|
|
}CGMEDGEATRB;
|
|
|
|
|
|
typedef struct cgm_colour_table
|
|
|
{
|
|
|
int index;
|
|
|
long rgb;
|
|
|
}CGMCOLOURTABLE;
|
|
|
|
|
|
typedef struct cgm_pline_attrib
|
|
|
{
|
|
|
int lineBoundIdx;
|
|
|
int lineType; //1=solid,2=dash,3=dot,4=dash-dot,5=dash-dot-dot
|
|
|
double lineWidth;
|
|
|
long lineColour;
|
|
|
}CGMPLINEATRB;
|
|
|
|
|
|
typedef struct cgm_seismic
|
|
|
{
|
|
|
CPoint2D arv[4]; // 0=starting X position in VDC coordinates
|
|
|
// 1=baseline vector
|
|
|
// 2=amplitude vector
|
|
|
// 3=trace step vector
|
|
|
long val;
|
|
|
float basesc; /* base line scale factor */
|
|
|
float ampsc; /* amplitude scale factor */
|
|
|
float trstep; /* trace step scale factor */
|
|
|
float baseof; /* baseline offset(VA offset)*/
|
|
|
float mxclip; /* positive clipping limit */
|
|
|
float mnclip; /* negative clipping limit */
|
|
|
long fillType; /* seismic fill type */
|
|
|
|
|
|
//0=16 bit signed integers
|
|
|
//1=32 bit signed integers
|
|
|
//2=IEEE floating point
|
|
|
//3=8 bit signed integers
|
|
|
//4=multiplexed 16 bit integer sample and color indices
|
|
|
//5=multiplexed 8 bit integer sample and color indices
|
|
|
long sampleType;/* data sample type */
|
|
|
|
|
|
long nsamp; /* number of samples */
|
|
|
float mxcell; /* positive background fill boundary */
|
|
|
float mncell; /* negative background fill boundary */
|
|
|
long ival;
|
|
|
long wigmod; /* wiggle trace modulus */
|
|
|
long nullc; /* the null color index */
|
|
|
long ntrloc; /* number of traces per location*/
|
|
|
long nullSample;
|
|
|
|
|
|
int colMaxIndex;
|
|
|
int colMinIndex;//颜色的最大最小索引号
|
|
|
}CGMSEISMIC;
|
|
|
|
|
|
typedef struct cgm_pattern
|
|
|
{
|
|
|
long index;
|
|
|
long width;
|
|
|
long height;
|
|
|
long *pattern;
|
|
|
}CGMPATTERN;
|
|
|
typedef struct cgm_pattern_size
|
|
|
{
|
|
|
long xheight;
|
|
|
long yheight;
|
|
|
long xwidth;
|
|
|
long ywidth;
|
|
|
}CGMPATTERNSIZE;
|
|
|
typedef struct cgm_pattern_table
|
|
|
{
|
|
|
long index;
|
|
|
CString name; //模板符号名称
|
|
|
}CGMPATTERNTABLE;
|
|
|
|
|
|
typedef list<CGMCOLOURTABLE> COLTABLIST;
|
|
|
typedef list<CGMPATTERNTABLE> PATTERNLIST;
|
|
|
|
|
|
class CCgm : public COtherFormat
|
|
|
{
|
|
|
public:
|
|
|
CCgm();
|
|
|
virtual ~CCgm();
|
|
|
|
|
|
public:
|
|
|
BOOL Drive(BOOL bDefaultsReplacement=FALSE);
|
|
|
BOOL Read(CFile& fr);
|
|
|
BOOL Read(LPCTSTR lpszPathName);
|
|
|
void RemoveAll(void);
|
|
|
BOOL IsEmpty(unsigned char* pBuffer);
|
|
|
CGMSCALE GetScale(void); //获得图件的显示比例
|
|
|
|
|
|
protected:
|
|
|
double GetLineWidth(void);
|
|
|
CString GetPlineTypeString(void); //获得当前曲线的类型,用作类别名称分类
|
|
|
|
|
|
void ELE_Polyline();
|
|
|
void ELE_Rectangle();
|
|
|
void ELE_Polygon();
|
|
|
void ELE_PolygonSet(void);
|
|
|
void ELE_CellArray(void);
|
|
|
void ELE_DisPolyline();
|
|
|
void ELE_AppendText();
|
|
|
void ELE_RestrictedText();
|
|
|
void ELE_Text();
|
|
|
void ELE_PolyMarker();
|
|
|
void ELE_BitonalTile(void);
|
|
|
void ELE_Tile(void);
|
|
|
void ELE_GetGDP();
|
|
|
|
|
|
void ELE_Circle();
|
|
|
void ELE_CircleArc3Point();
|
|
|
void ELE_CircleArc3PointClose();
|
|
|
void ELE_CircleArcCenter();
|
|
|
void ELE_CircleArcCenterClose();
|
|
|
void ELE_Ellipse();
|
|
|
void ELE_EllipseArc();
|
|
|
void ELE_EllipseArcClose();
|
|
|
void ELE_CircleArcCenterReversed();
|
|
|
void ELE_PolySymbol();
|
|
|
|
|
|
void ELE_ConnectingEdge();
|
|
|
void ELE_HyperbolicArc();
|
|
|
void ELE_ParabolicArc();
|
|
|
void ELE_NonUniform_BSpline();
|
|
|
void ELE_NonUniform_Rational_BSpline();
|
|
|
|
|
|
void ELE_PolyBezier();
|
|
|
|
|
|
CArray<float*, float*> m_arrSection;
|
|
|
CArray<COLORREF*, COLORREF*> m_arrSectionCol;
|
|
|
void ELE_GetGDP_AddSection(void);
|
|
|
void ELE_GetGDP_SeismicHead(unsigned char** dat_ptr);//地震剖面头信息
|
|
|
void ELE_GetGDP_SeismicTrace(unsigned char** dat_ptr);//地震道数据(仅一道数据)
|
|
|
|
|
|
//PIP Seismic Format
|
|
|
BOOL ELE_GetPIP_EscapeSeismic(int esc_id, unsigned char** dat_ptr);
|
|
|
BOOL ELE_GetPIP_EscapeWell(int esc_id, unsigned char** dat_ptr);
|
|
|
void ELE_GetPIP_GdpSeismicTrace(unsigned char** dat_ptr);//地震道数据(仅一道数据)
|
|
|
|
|
|
void GetElementList(void);
|
|
|
int ReadToBuffer(int len);
|
|
|
|
|
|
void CoorExchange(double &x, double &y);
|
|
|
void CoorExchange(CPoint2D& point);
|
|
|
|
|
|
private:
|
|
|
CFile* m_pFile;
|
|
|
CGMMFDES m_mfdes;
|
|
|
CGMPICDES m_picdes;
|
|
|
CGMCTRLDES m_ctrldes;
|
|
|
CGMDEVICEVIEWPORTDES m_deviceViewport;
|
|
|
|
|
|
CGMTEXTATRB m_textAtrb;
|
|
|
CGMFILLATRB m_fillAtrb;
|
|
|
CGMEDGEATRB m_edgeAtrb;
|
|
|
CGMPLINEATRB m_plineAtrb;
|
|
|
CGMMARKERATRB m_markerAtrb;
|
|
|
CGMSEISMIC m_seismicAtrb;
|
|
|
|
|
|
unsigned char * m_pBuffer; //存放读取数据缓冲区
|
|
|
|
|
|
int m_Class; //类别
|
|
|
int m_Element; //元素
|
|
|
int m_length; //读取数据长度
|
|
|
long m_ard_read;
|
|
|
int m_nDefaultsReplacement; //仅在类型(1,12)中启用,为了使该调用读到该长度时终止并返回
|
|
|
|
|
|
COLTABLIST m_colTab; //颜色列表(索引查询)
|
|
|
PATTERNLIST m_patTab; //模板列表(索引查询)
|
|
|
CGMPATTERNSIZE m_patSize;
|
|
|
|
|
|
private:
|
|
|
CString FindPattern(int nPalIndex);
|
|
|
long GetIndexColor(int nColIndex);
|
|
|
void GetRealPrec(CGMREALPREC &r_prec);
|
|
|
long GetColour (int colourMode=-1, unsigned char** pBuffer=NULL);
|
|
|
void GetColourExtent();
|
|
|
long GetDirectColour(unsigned char ** dat_ptr);
|
|
|
void GetColourTable();
|
|
|
void GetCGMTextAlign(CGMTEXTALIGEN & aligen);
|
|
|
double GetVDC(unsigned char **dat_ptr);
|
|
|
double GetVDC();
|
|
|
int GetOnePointSize();
|
|
|
void GetTwoPoint(CPoint2D &pt1,CPoint2D & pt2);
|
|
|
int GetPointListOne(CPointList& pl, unsigned char ** dat_ptr, int jumpLength=0);
|
|
|
int GetPointListAll(CPointList& pl, unsigned char ** dat_ptr);
|
|
|
UINT GetTextAligen(void); //获得文字的对齐方式
|
|
|
void GetScaleMode();
|
|
|
//double ReadLineWidth();
|
|
|
//double ReadMarkerSize();
|
|
|
//double ReadEdgeWidth();
|
|
|
double ReadSize(int nType);
|
|
|
|
|
|
void GetPatternSize();
|
|
|
void GetPattern();
|
|
|
void* CreateImageWithPattern(CGMPATTERN& pat);
|
|
|
void SetCurrentPatternFill(CString patName);
|
|
|
|
|
|
int _ID (unsigned short k,short i1,short i2);
|
|
|
void swap (unsigned char * dat_ptr, int len=2); //高低位转换
|
|
|
void splitCmd(unsigned char * dat_ptr); //分离命令
|
|
|
int get_int (unsigned char * dat_ptr, int precision); //读取有符号整数
|
|
|
unsigned int get_uint(unsigned char * dat_ptr, int precision); //读取无符号整数
|
|
|
double get_fixed(unsigned char* dat_ptr, CGMREALPREC *r_prec); //读取定点实数
|
|
|
double get_float(unsigned char* dat_ptr, CGMREALPREC *r_prec); //读取浮点实数
|
|
|
double get_sdre(unsigned char* dat_ptr, int nType, int* pByteLength);
|
|
|
|
|
|
BOOL DriveCommand();
|
|
|
BOOL DriveMoreCommand();
|
|
|
|
|
|
BOOL ReadMoreData();
|
|
|
int m_nHasMoreData; //如果为1说明元素还有连续的数据没有读取,如果为0则表示结束
|
|
|
void SkipParameters(void); //为了跳过需要连续读取(如曲线、CELL等)的元素
|
|
|
|
|
|
CString GetString ();
|
|
|
CString GetString (unsigned char **dat_ptr);
|
|
|
int GetEnum ();
|
|
|
int GetEnum (unsigned char ** dat_ptr);
|
|
|
int GetIndex ();
|
|
|
int GetIndex (unsigned char** pBuffer);
|
|
|
int GetColIndex (unsigned char** pBuffer=NULL);
|
|
|
int GetSignInt ();
|
|
|
int GetSignInt (unsigned char ** dat_ptr);
|
|
|
int GetSignInt (unsigned char ** dat_ptr, int intPrec);
|
|
|
unsigned int GetUnsignInt();
|
|
|
unsigned int GetUnsignInt(unsigned char ** dat_ptr);
|
|
|
unsigned int GetUnsignInt(unsigned char ** dat_ptr, int intPrec);
|
|
|
unsigned int GetCCO (unsigned char ** dat_ptr);
|
|
|
unsigned int GetCCO (unsigned char ** dat_ptr, int precision);
|
|
|
double GetReal ();
|
|
|
double GetReal (unsigned char ** dat_ptr);
|
|
|
CPoint2D * GetPoint (unsigned char ** dat_ptr);
|
|
|
int GetVDCInt (unsigned char ** dat_ptr);
|
|
|
double GetVDCReal (unsigned char ** dat_ptr);
|
|
|
double GetSdre (unsigned char ** dat_ptr, int nType);
|
|
|
|
|
|
void GetSeismicTraceCurve(unsigned char** dat_ptr);//地震道数据(仅一道数据)
|
|
|
void SeismicTraceWiggleRight(void* pCurve, double x0); //右变面积
|
|
|
void SeismicTraceWiggleLeft(void* pCurve, double x0); //左变面积
|
|
|
|
|
|
BOOL Class0();
|
|
|
BOOL Class1();
|
|
|
BOOL Class2();
|
|
|
BOOL Class3();
|
|
|
BOOL Class4();
|
|
|
BOOL Class5();
|
|
|
BOOL Class6();
|
|
|
BOOL Class7();
|
|
|
BOOL Class8();
|
|
|
BOOL Class9();
|
|
|
};
|
|
|
|
|
|
};
|
|
|
|
|
|
};
|
|
|
using namespace NCgmReader;
|
|
|
|
|
|
#endif // !defined(AFX_DFCGM_H__34E7F6BD_0033_4DFC_96B8_1E5AAC63A161__INCLUDED_)
|