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.

418 lines
11 KiB
C

1 month ago
//////////////////////////////////////////////////////////////////////////////
//<2F>ļ<EFBFBD>: <20><>ʽת<CABD><D7AA><EFBFBD><EFBFBD>
//<2F><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>:
// ת<><D7AA>CGM<47><4D>ʽ
//
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д: 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; //<2F><><EFBFBD><EFBFBD>=0<><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=1
int exp;
int fract;
}CGMREALPREC;
typedef struct cgm_metafile_des
{
int version; //<2F><EFBFBD><E6B1BE>
int vdcType; //<2F><EFBFBD><E8B1B8><EFBFBD><EFBFBD>0=integer or 1=real, default: integer
CGMREALPREC realPrec; //ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int intPrec; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int idxPrec; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int colPrec; //<2F><>ɫֵ<C9AB><D6B5><EFBFBD><EFBFBD>
int colIdxPrec; //<2F><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int charCoding; //<2F>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>룺0 basic 7-bit<69><74>1 basic 8-bit<69><74>2 extended 7-bit<69><74>3 extended 8-bit
int colModel; //<2F><>ɫģ<C9AB>ͣ<EFBFBD>1=RGB,2=CIELAB,3=CIELUV,4=CMYK,5=RGB-related
int maxColIdx; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
CGMCOL min_cco; //<2F><>ɫ<EFBFBD><C9AB>Χ<EFBFBD><CEA7>Сֵ
CGMCOL max_cco; //<2F><>ɫ<EFBFBD><C9AB>Χ<EFBFBD><CEA7><EFBFBD><EFBFBD>ֵ
}CGMMFDES;
typedef struct cgm_control_des
{
int vdcIntPrec; //VDC<44><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CGMREALPREC vdcRealPrec; //VDCʵ<43><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
long auxColour;
int transparency;
CPoint2D clipMax;
CPoint2D clipMin;
int clipIndictor;
int lineClipMode;
int markerClipMode;
int edgeClipMode;
int textPathMode;
int cellTrans; //CELL<4C>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>͸<EFBFBD><CDB8><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB>0<EFBFBD><30>OFF<46><46>1<EFBFBD><31>ON
long cellTransColour; //CELL͸<4C><CDB8><EFBFBD><EFBFBD>ɫֵ
}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; //<2F><>ԭ<EFBFBD>㵽x1,y1<79><31>Ϊ<EFBFBD><CEAA>ʼ<EFBFBD><CABC> ԭ<>㵽(x2,y2)Ϊ<><CEAA><EFBFBD><EFBFBD><EFBFBD>ߵļн<C4BC>
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;//<2F><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}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; //ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}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); //<2F><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
protected:
double GetLineWidth(void);
CString GetPlineTypeString(void); //<2F><><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD>
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);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>Ϣ
void ELE_GetGDP_SeismicTrace(unsigned char** dat_ptr);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
//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);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
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; //<2F><><EFBFBD>Ŷ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD>
int m_Class; //<2F><><EFBFBD><EFBFBD>
int m_Element; //Ԫ<><D4AA>
int m_length; //<2F><>ȡ<EFBFBD><C8A1><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
long m_ard_read;
int m_nDefaultsReplacement; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>1<EFBFBD><31>12<31><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>Ϊ<EFBFBD><CEAA>ʹ<EFBFBD>õ<EFBFBD><C3B5>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>ó<EFBFBD><C3B3><EFBFBD>ʱ<EFBFBD><CAB1>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
COLTABLIST m_colTab; //<2F><>ɫ<EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF>
PATTERNLIST m_patTab; //ģ<><C4A3><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF>
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); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵĶ<D6B5><C4B6>ʽ
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); //<2F>ߵ<EFBFBD>λת<CEBB><D7AA>
void splitCmd(unsigned char * dat_ptr); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int get_int (unsigned char * dat_ptr, int precision); //<2F><>ȡ<EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
unsigned int get_uint(unsigned char * dat_ptr, int precision); //<2F><>ȡ<EFBFBD>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
double get_fixed(unsigned char* dat_ptr, CGMREALPREC *r_prec); //<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>
double get_float(unsigned char* dat_ptr, CGMREALPREC *r_prec); //<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>
double get_sdre(unsigned char* dat_ptr, int nType, int* pByteLength);
BOOL DriveCommand();
BOOL DriveMoreCommand();
BOOL ReadMoreData();
int m_nHasMoreData; //<2F><><EFBFBD><EFBFBD>Ϊ1˵<31><CBB5>Ԫ<EFBFBD>ػ<EFBFBD><D8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>ж<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0<CEAA><30><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
void SkipParameters(void); //Ϊ<><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߡ<EFBFBD>CELL<4C>ȣ<EFBFBD><C8A3><EFBFBD>Ԫ<EFBFBD><D4AA>
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);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
void SeismicTraceWiggleRight(void* pCurve, double x0); //<2F>ұ<EFBFBD><D2B1><EFBFBD><EFBFBD><EFBFBD>
void SeismicTraceWiggleLeft(void* pCurve, double x0); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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_)