|
|
#ifndef WellXYDCEXT_H
|
|
|
#define WellXYDCEXT_H
|
|
|
#pragma once
|
|
|
#include "NGraphExtend.h"
|
|
|
|
|
|
extern AFX_EXT_API COLORREF HexToColorRefExt(CString strHex);
|
|
|
extern AFX_EXT_API void DrawFrameLineExt(CXyDC* pDC, CPoint2D pt1, CPoint2D pt2, const GDFLOGPEN& logPen);
|
|
|
extern AFX_EXT_API void DrawFrameRectExt(CXyDC* pDC, CRect8 rect, const GDFLOGPEN& logPen);
|
|
|
extern AFX_EXT_API void DrawFillPolygonExt(CXyDC* pDC, CCurveEx& curve, GDFLOGBRUSH & brush);
|
|
|
extern AFX_EXT_API void DrawPolyLineExt(CXyDC* pDC, CCurveEx& curve, const GDFLOGPENEXT& logPen);
|
|
|
extern AFX_EXT_API void DrawPolyLineExt(CXyDC *pDC,CPoint2D* pPoint, int iCount, const GDFLOGPENEXT& logPen);
|
|
|
extern AFX_EXT_API void DrawFillRectExt(CXyDC *pDC,CRect8 &rect, GDFLOGBRUSH &brush);
|
|
|
extern AFX_EXT_API void DrawLineExt(CXyDC* pDC, CPoint2D pt1, CPoint2D pt2, const GDFLOGPENEXT& logPen);
|
|
|
extern AFX_EXT_API void SetClipPtsForPrint(CXyDC* pDC, int n, LPPOINT& pts);
|
|
|
extern AFX_EXT_API void DrawTextExt(CXyDC* pDC, CPoint2D pt1, LPCTSTR str, GDFLOGFONTEXT& font, double dAngle, int iHorAlign, int iVerAlign);
|
|
|
extern AFX_EXT_API void DrawTextExt(CXyDC* pDC, CText& text);
|
|
|
//曲线充填符号
|
|
|
#define PLINE_SOLID_BEZIER PLINE_BEZIER //B样条平滑充填
|
|
|
#define PLINE_SOLID_BCLOSE PLINE_BC //B样条闭合平滑充填
|
|
|
#define PLINE_SOLID_SPLINE PLINE_SPLINE //S样条平滑充填
|
|
|
#define PLINE_SOLID_SCLOSE PLINE_SPLINEC //S样条平滑充填闭合
|
|
|
#define PLINE_SOLID_CENTER 0x00001000 //居中充填
|
|
|
#define PLINE_SOLID_SINGLE 0x00002000 //单行充填
|
|
|
|
|
|
class AFX_EXT_CLASS CCurveFillSymbol : public CCurveView
|
|
|
{
|
|
|
public:
|
|
|
CCurveFillSymbol();
|
|
|
virtual ~CCurveFillSymbol();
|
|
|
|
|
|
protected:
|
|
|
virtual void DoFillContent(CXyDC& dc, CRect8 range);
|
|
|
|
|
|
public:
|
|
|
//初始化属性列表
|
|
|
//virtual void InitPropertiesList();
|
|
|
//在调用Set函数设置数值后自动调用,为了根据符号名称设置符号指针
|
|
|
//virtual void AfterSetPropertyValue(LPCTSTR proName);
|
|
|
|
|
|
public:
|
|
|
virtual void Serialize(CArchive& ar, const short &ver);
|
|
|
virtual int Read(CFile &fr, const short &ver);
|
|
|
virtual void Write(CFile &fw, const short &ver, double cc);
|
|
|
virtual void Draw(CXyDC &dc, CCurveEx *curve);
|
|
|
virtual void ScaleProperty(double sx, double sy);
|
|
|
|
|
|
virtual void WriteDML(CFile &fw, const short &ver, double cc, int nBaseTabNum);
|
|
|
virtual int ReadDML(CFile &fr, const short &ver, void* pXmlParse);
|
|
|
|
|
|
virtual void WritePCG(CFile &fw, const short &ver, double cc, int nBaseTabNum);
|
|
|
virtual int ReadPCG(CFile &fr, const short &ver, void* pXmlParse);
|
|
|
|
|
|
void operator=(CCurveFillSymbol& cr);
|
|
|
//int PositionNew(int bReplace);
|
|
|
|
|
|
void EnableFillCenter(BOOL bEnable);
|
|
|
BOOL IsFillCenter();
|
|
|
void EnableFillSingle(BOOL bEnable);
|
|
|
BOOL IsFillSingle();
|
|
|
|
|
|
CString MarkName; //符号名称
|
|
|
CSize8 m_space; //符号间的空白间隔
|
|
|
CSize8 m_size; //符号大小
|
|
|
CSize8 m_scale; //符号尺寸绽放比例
|
|
|
void* pDraw; //符号指针
|
|
|
|
|
|
BOOL m_bBitmap; //使用位图填充
|
|
|
};
|
|
|
|
|
|
class AFX_EXT_CLASS CFONT
|
|
|
{
|
|
|
public:
|
|
|
CFONT(void);
|
|
|
virtual ~CFONT(void);
|
|
|
|
|
|
virtual void SerializeFont(CArchive& ar, const short& ver);
|
|
|
virtual int ReadFont(CFile& fr, const short& ver);
|
|
|
virtual void WriteFont(CFile& fw, const short& ver);
|
|
|
|
|
|
int ReadFontOld(CFile& fr);
|
|
|
|
|
|
virtual void WriteDMLFont(CFile& fw, const short& ver, int nBaseTabNum);
|
|
|
virtual void WritePCGFont(CFile& fw, const short& ver, int nBaseTabNum);
|
|
|
|
|
|
//分析字体内容,返回分析的有效属性个数,为-1时表示分析错误
|
|
|
virtual int ReadDMLFont(CFile& fr, const short& ver, CXmlParse& xp);
|
|
|
virtual int ReadPCGFont(CFile& fr, const short& ver, CXmlParse& xp);
|
|
|
|
|
|
void operator=(const CFONT& font);
|
|
|
|
|
|
virtual void ScaleProperty(double sx, double sy);
|
|
|
|
|
|
void SetTitle(CString str) { m_strTitle = str; }
|
|
|
CString GetTitle() { return m_strTitle; }
|
|
|
|
|
|
|
|
|
public:
|
|
|
enum EScriptMode
|
|
|
{
|
|
|
modeNormal = 0,
|
|
|
modeSuper = 1, //上标
|
|
|
modeSub = 2 //下标
|
|
|
};
|
|
|
|
|
|
public:
|
|
|
LOGFONT m_logFont; //字型
|
|
|
COLORREF m_frColor; //字体颜色
|
|
|
COLORREF m_bkColor; //背景充填颜色
|
|
|
double m_dWidth; //字宽
|
|
|
double m_dHeight; //字高
|
|
|
double m_dTextSpace; //字间距
|
|
|
int m_nScript; //显示方式: 0常规,1上标,2下标
|
|
|
BOOL m_bTransparent;// 是否透明(仅在派生类GDFLOGFONT中使用)
|
|
|
|
|
|
protected:
|
|
|
CString m_strTitle; //节点名
|
|
|
};
|
|
|
class AFX_EXT_CLASS CTextSegment
|
|
|
{
|
|
|
public:
|
|
|
CTextSegment(void);
|
|
|
virtual ~CTextSegment(void);
|
|
|
|
|
|
CTextSegment* operator = (CTextSegment& ss);
|
|
|
|
|
|
CString DML_ToString(CFONT* pdt);
|
|
|
CString PCG_ToString(CFONT* pdt);
|
|
|
|
|
|
int PCG_ParseFont(CXmlParse& xp, const short& ver);
|
|
|
|
|
|
//对转义字符进行处理
|
|
|
void ToSaveString(CString& str); //转换为保存的串
|
|
|
void ToViewString(CString& str); //转换为可显示的串
|
|
|
|
|
|
public:
|
|
|
LOGFONT* m_pLogFont;//可以为NULL,为NULL时使用CText类的字体定义
|
|
|
COLORREF color; //文字的颜色
|
|
|
|
|
|
CString strText; //这段的显示文本
|
|
|
double scale_w; //宽度缩放因子
|
|
|
double scale_h; //高度缩放因子
|
|
|
CFONT::EScriptMode script; //上下标类型
|
|
|
};
|
|
|
|
|
|
class AFX_EXT_CLASS CDrawTextLine
|
|
|
{
|
|
|
public:
|
|
|
CDrawTextLine(void);
|
|
|
~CDrawTextLine(void);
|
|
|
|
|
|
//带有上下标或设置字体的文本例子:Script为Super时表示上标,为Sub时表示下标
|
|
|
//“新例子<Font W=40 H=100 B=400 I=0 U=0 S=0 PF=0 FN=Times_New_Roman C=#000000 Script=Super>上标内容</Font>恢复正常”
|
|
|
void Draw(void* pXyDC);
|
|
|
|
|
|
//将一行文字根据<Font>设置分隔为多个串
|
|
|
int SplitString(CString strText);
|
|
|
//“老上下标例子^u0.5 上标^n^d0.5 下标^n中华大地”
|
|
|
int SplitStringOld(CString strText);
|
|
|
double GetLineRealWidth(double textWidth); //获得一行的实际宽度
|
|
|
|
|
|
//将所有的文字串输出为一行文本
|
|
|
CString DML_ToString();
|
|
|
int GetSegmentCount();
|
|
|
CTextSegment* GetSegment(int n);
|
|
|
|
|
|
protected:
|
|
|
class AFX_EXT_CLASS CSegmentString : public CTextSegment
|
|
|
{
|
|
|
public:
|
|
|
CSegmentString(void);
|
|
|
~CSegmentString(void);
|
|
|
|
|
|
CSegmentString* operator = (CSegmentString& ss);
|
|
|
|
|
|
int DML_ParseFont(CString& strFont);
|
|
|
CString DML_ToString(CDrawTextLine* pdt = NULL);
|
|
|
|
|
|
public:
|
|
|
int StatisticsCount(); //统计文字个数
|
|
|
|
|
|
//内部统计得到
|
|
|
CSize m_size; //根据当前字体计算的高宽,为了加快计算
|
|
|
int count; //统计的字个数,汉字作为一个字处理,作为光标的定位使用
|
|
|
};
|
|
|
|
|
|
TObjectSet<CSegmentString> m_seg;
|
|
|
|
|
|
protected:
|
|
|
//新格式操作
|
|
|
int GetNextString(const CString& strText, CString& strOutText, bool& bFontSet, int nStart);
|
|
|
CString GetFontString(CString& txt);
|
|
|
//老格式操作
|
|
|
int GetNextString(const CString& strText, CString& strOutText, CFONT::EScriptMode& nScriptType, int nStart);
|
|
|
double GetFontSizeScale(CString& txt);
|
|
|
|
|
|
void TextOut(void* pXyDC, double x, double y, CString str);
|
|
|
bool TryToDeleteFont(CSegmentString* ps); //如果ps中的字体与m_pLogFont相同时删除
|
|
|
|
|
|
public:
|
|
|
|
|
|
//总的参数设置
|
|
|
LOGFONT* m_pLogFont; //一般指向CText类中的字体
|
|
|
COLORREF color; //文字的颜色
|
|
|
double angle;
|
|
|
double y0;
|
|
|
double x0;
|
|
|
CSize m_size; //显示文本的矩形尺寸
|
|
|
|
|
|
UINT m_textAlign;
|
|
|
};
|
|
|
|
|
|
|
|
|
class CDrawTextExt
|
|
|
{
|
|
|
public:
|
|
|
CDrawTextExt() {};
|
|
|
|
|
|
public:
|
|
|
void DrawTextExt(CXyDC* pDC,CPoint2D pt1, LPCTSTR str, GDFLOGFONT& font, double dAngle, int iHorAlign, int iVerAlign);
|
|
|
void Draw(CXyDC* pDC, CText& text, COLORREF color);
|
|
|
protected:
|
|
|
|
|
|
|
|
|
//BOOL CreateSelectBrush(CXyDC* pDC, COLORREF color, int type);
|
|
|
void DrawRect(CXyDC* pDC, CText& text, CCurveEx* pCurveRect = NULL /*=NULL*/);
|
|
|
|
|
|
int GetTextLineCount(CText& text);
|
|
|
void DrawScriptText(CString str, double x0, double y0, LOGFONT* lf, COLORREF color);
|
|
|
};
|
|
|
|
|
|
#endif |