////////////////////////////////////////////////////////////////////////////// //文件 XyDC.h //主要功能: // //程序编写: 2005-12-07 ///////////////////////////////////////////////////////////////////////////// #pragma once #include "afxcoll.h" #include "rect8ex.h" #include "insertdraw.h" #include "text.h" #include "curveex.h" #include "circle.h" #include "frame.h" #include "imageinsert.h" #include "mxn.h" #include "mesh.h" #include "colorruler.h" #include "proportion.h" #include "insertdrawrect.h" #include "arc.h" #include "net.h" #include "grid.h" #include "WellGroup.h" //#include "memdc.h" #include "section.h" #include "hyperlinkmulti.h" #include "..\SectionLib\OtherDraw.h" // Added by ClassView #include "oleobject.h" #include ".\tree.h" #include ".\metafile.h" #include ".\publicfunction.h" #include ".\station.h" #include ".\curvetv5.h" #include ".\mtextparse.h" #include ".\scaleruler.h" #include ".\curverect.h" #include ".\pointcrossname.h" #include ".\pathxy.h" #include "RectLabel.h" #include "HorizontalWell.h" #include "GDFLOGBRUSH.h" #include "GDFLOGPEN.h" #include "GDFLOGFONT.h" #include "GDFLOGPOINT.h" #include "XyDCBase.h" #include ".\3DFaultageSurface.h" #include "IDcDraw.h" #define XYDC_TYPE_DEFAULT 1 #define XYDC_TYPE_DXF 2 #define XYDC_TYPE_CGM 3 #define XYDC_TYPE_EPS 4 #define XYDC_TYPE_INSERT 5 #define XYDC_TYPE_UMAP_ASC 6 #define XYDC_TYPE_PDF 7 #define XYDC_TYPE_MAPGIS_ASC 8 #define XYDC_TYPE_GEOMAP_GDB_ASC 9 #define XYDC_TYPE_EMF 10 typedef struct _CustomColor { bool bUseCustom = false; COLORREF color; }CUSTOMCOLOR; class AFX_EXT_CLASS CXyDC : public CXyDCBase { public: CXyDC(void); virtual ~CXyDC(void); void ReleaseDC(); CUSTOMCOLOR __TempColorForMark; //当插入的符号没有时,就按照该颜色画十字叉 virtual void Serialize(CArchive& ar, const short &ver); virtual int Create(CDC* pDC, BOOL bSetViewRect = TRUE); virtual void SetPixel(double x, double y, COLORREF col); virtual void MoveTo(double x, double y); virtual void LineTo(double x, double y); virtual void MoveTo(const CPoint2D &point); virtual void LineTo(const CPoint2D &point); virtual void LineToEnd(){} //仅是为了导出其它图件格式时,能使MoveTo、LineTo形成一条连续的曲线 virtual void Ellipse(double x1, double y1, double x2, double y2); virtual void Ellipse(CRect8& rect); virtual void Arc(CRect8 rect, CPoint2D ptStart, CPoint2D ptEnd); virtual void Pie(CRect8 rcClient,CPoint2D ptStart,CPoint2D ptEnd); virtual void PaintRgn(LPPOINT sp, int count); void Pie(CRect8 rcClient,CPoint2D ptStart,CPoint2D ptEnd,COLORREF clrBkGnd,COLORREF clrPen); virtual void Rectangle(CRect8& rect); virtual void Rectangle(CRect& rect, COLORREF color); virtual void FillSolidRect(CRect8& rect, COLORREF color); virtual void PolyLine(CCurveEx& curve, bool bDirectOut=false); virtual void PolyLine(CPointList& dp); virtual void PaintRgn(CCurveEx& curve); virtual void PaintTransparentRgn(CCurveEx& curve); virtual void GradientFill(CRect8& rect, COLORREF crFrom, COLORREF crTo, BOOL bHorz); //填充矩形 virtual void GradientFill(CPoint2D& pt1, CPoint2D& pt2, CPoint2D& pt3, COLORREF cr1, COLORREF cr2, COLORREF cr3); //填充三角形 virtual void GradientFill(CPoint2D& pt1, CPoint2D& pt2, COLORREF cr1, COLORREF cr2, double width); //填充线段 BOOL CreatePolygonRgn(CRgn*& pRgn, LPPOINT &lpPoints, int &nCount, int nMode); virtual BOOL CreatePolygonRgn(CRgn*& pRgn, CCurveEx &curve, int nMode=WINDING); virtual void SelectClipRgn(CPointList* pPointList, int nMode=RGN_AND); //导出CGM或EPS等文件时,仅是为了填充符号时的边界剪辑问题 //将实际坐标转换为屏幕坐标,第一个参数为实际坐标,第二个参数为屏幕坐标 virtual int PolyLine(CCurveEx& curve, LPPOINT p); int PolyLine(CPointList& dp, LPPOINT lpPoint); virtual int PolyLine8(CCurveEx &curve, CPoint2D* pt); void operator=(CRect8& t); void operator=(CXyDC& dc); void SetCustomDPI(int nMode, double nExportDPI); //设置显示分辨率 //绘制各类元素 virtual void Draw(CText& text, CCurveEx* pCurveRect = NULL); // -当pCurveRect不为空时表示仅是为了获得显示范围 virtual void Draw(CEllipse &elp, COLORREF Color); //- void Draw(CCircle &circle, COLORREF Color); //- virtual void Draw(CInsertDraw& m_insert);//- virtual void Draw(CXyDC* pNewXyDC, CInsertDraw& m_insert);//- virtual void Draw(CInsertOld& m_insert);//- virtual void Draw(CXyDC* pInsertXyDC, CInsertOld& m_insert); // - virtual void Draw(CSection& section,CRect8* rect=NULL); // - virtual void Draw(CImageInsert& image);//- virtual void Draw(CMesh &mesh);//- virtual void Draw(CMetaFile& mf);//- virtual void Draw(CColorRuler& ruler, CColorBase& color);//- virtual void Draw(CPathFill& path, COLORREF fillColor, void* HowToViewCurve);//- virtual void Draw(C3DFaultageSurface& fs, COLORREF fillColor, void* HowToViewCurve);//- void Draw(CText& text, COLORREF color);// - void Draw(CMText& mtext);//- void Draw(CProportion& proportion, COLORREF color);//- virtual void Draw(CCurveEx &curve, double l1, double l2);//- virtual void Draw(CCurveEx& m_curve);//- virtual void Draw(CCurveEx& curve, void* HowToViewCurve);//- virtual void Draw(CCurveEx& curve, COLORREF color, BOOL bSmoothHead = TRUE);//- inline void DrawPackage(CCurveEx& curve, CRect8& range, COLORREF color); void DrawPackage(CMeshPackage* pMeshPackage); //void PaintRgnPack(CCurveEx& curve, COLORREF color); int PolyLinePack(CCurveEx& curve, CRect8& range, LPPOINT p); void Draw(CCurveRect& rt, void* HowToViewCurve);//- void Draw(CCurveRect& curve, COLORREF color);//- void Draw(CPointNameEx& point, void* HowToViewPoint);//- void Draw(CPointCrossName& point, void* HowToViewPoint);//- void Draw(CPointTwoName& point, void* HowToViewPoint);//- //void Draw(CDonut& dt,COLORREF Color); void Draw(CInsertDrawRect& idr);//- void Draw(CArc& arc, void* HowToViewCurve);//- void Draw(CArc& arc, COLORREF color);//- void Draw(CFrame& frame, COLORREF color);//- void Draw(CNet& net, COLORREF colText, COLORREF colLine);//- void Draw(CGridding& grid, COLORREF colText, COLORREF colLine);//- void Draw(COtherDraw& od, void* HowToViewCurve);//- void Draw(COtherDraw& od, COLORREF color);//- void Draw(COleObject& ole);//- void Draw(CTree& tree);//- void Draw(CStation& cs);//- void Draw(CCurveTV5& tv, void* HowToViewCurve); void Draw(CScaleRuler& sr, COLORREF color); virtual void Draw(CRectLabel& rl, COLORREF color, void* HowToViewCurve); /* @brief 根据画笔填充多边形 */ void DrawFillPolygon(CPoint2D *pPoints, int nCount, GDFLOGBRUSH & brush); /* @brief 根据画笔填充矩形 */ void DrawFillRect(CRect8 &rect, GDFLOGBRUSH &brush); /* @brief 线绘制函数 */ void DrawLine(CPoint2D pt1,CPoint2D pt2,const GDFLOGPEN& logPen); void DrawPolyLine(CPoint2D* pPoint,int iCount,const GDFLOGPEN& logPen); void DrawRect(CRect8 rect,const GDFLOGPEN& logPen); void DrawCurveLine(CPoint2D pt1, CPoint2D pt2, COLORREF color, double width); /* @brief 文本绘制函数 * iHorAlign = 0 居左 1 居中 2 居右 * iVerAlign = 0 居上 1 居中 2 居下 */ void DrawText(CPoint2D pt1, LPCTSTR str, GDFLOGFONT &font, double dAngle, int iHorAlign, int iVerAlign); void DrawText(CRect8 &rect, LPCTSTR str, GDFLOGFONT &font, int iHorAlign, int iVerAlign, BOOL bClip = FALSE); /* @brief 绘制点符号 */ void DrawPointSymbol(CPoint2D pt, GDFLOGPOINT &logPoint); /* @brief 矩形中绘制点符号 */ void DrawFillRect(CRect8 &rect, GDFLOGPOINT &logPoint); void DrawOld(CSection& section,CRect8* rect=NULL); void DrawDib(CSection& section,CRect8* rect=NULL); //draw mxn void DrawArray(CMxn& mxn, COLORREF colFront, COLORREF colBack); //前景色与背景色 void Draw(CMxn& mxn, COLORREF colFront, COLORREF colBack); void DrawGrid(CMxn& mxn); void Draw(CHorizontalWell &horizontalwell, void* HowToViewCurve); void Draw(CWellGroup &wellGroup); int GetDcType(void); virtual void Rotate(double &ww, double &wh, double &wa); // 抗锯齿开关 void SetAntiAlias(BOOL enable); BOOL GetAntiAlias(); void SetPrinting(BOOL isPrinting); BOOL GetIsPrinting(); //pdf打印 void SetPdfPrintState(BOOL state); BOOL GetPdfPrintState(); void SetPdfData(CXy* pXy, const CRect8& rect, int sType, int cType, int dType, int num); void SetPdfPCairo(void *pCairo, bool state = false); //保存 gdbx void SetGDBXState(BOOL state); BOOL GetGDBXState(); void SetGDBXData(CXy *xy); void SetFilePath(const CString &path); CString GetFilePath(); void CloseFile(); //处理Block组合块在输出到gdbx中找不到图层层级问题 void SetBlockLayer(CLayer * layer); CLayer * GetBlockLayer(); public: void DrawSeismic(CSection& section, CRect scrRect, CRect rtDraw, int nStep, int nMode); //显示地震剖面 void DrawColorRulerMarkV(CColorRuler& ruler, CColorBase &color); void DrawColorRulerMarkH(CColorRuler& ruler, CColorBase &color); void DrawColorRulerSmoothV(CColorRuler& ruler, CColorBase &color); void DrawColorRulerSmoothH(CColorRuler& ruler, CColorBase &color); //反转显示 void DrawColorRulerMarkV_Reversal(CColorRuler& ruler, CColorBase &color); void DrawColorRulerMarkH_Reversal(CColorRuler& ruler, CColorBase &color); void DrawColorRulerSmoothV_Reversal(CColorRuler& ruler, CColorBase &color); void DrawColorRulerSmoothH_Reversal(CColorRuler& ruler, CColorBase &color); void DrawOther(double x0, double y0, CSize8 sz, COLORREF col, UINT nMode, double a); protected: AFX_INLINE void LineTo(LPPOINT lpTwoPoints); //仅有两个点长度 AFX_INLINE void GetLineInScreen(long &x1, long &y1, long &x2, long &y2); int m_nDcType; POINT m_twoPoint[2]; //第一点为MoveTo设定的,第二点为LineTo临时使用的 IDcDraw* m_pDrawer; //CDcDrawPlus m_drawerPlus; //CDcDraw m_drawer; BOOL m_bAntiAlias = TRUE; BOOL m_bPrinting = FALSE; BOOL m_bPdfPrint = FALSE; BOOL m_bGDBXFile = FALSE; CString m_sFilePath = ""; CLayer *m_blockLayer = NULL; public://曲线修饰函数 void DrawCurveMark(CCurveEx &curve); void DrawPolyLineMidleFilter(CCurveEx &curve); void DrawVirtual(CCurveEx &curve); void DrawVirtualNode(CCurveEx &curve); void DrawTypeB(CCurveEx &curve,int isClose); void DrawCurveBezier(CCurveEx &curve,int isClose); void DrawCurveBezierSolid(CCurveEx& curve); void DrawCurveSplineSolid(CCurveEx& curve); void DrawSpline(CCurveEx &curve, int isClose); void DrawCurveWave(CCurveEx& curve); void DrawCurveWaveSolid(CCurveEx& curve); void DrawOffsetSolid(CCurveEx& curve,double offset); void DrawTypeOffset(CCurveEx& curve); void DrawTypeOffsetSolid(CCurveEx& curve,double offset); void DrawTypeOffsetB(CCurveEx& curve); /** * 获取透明度 * * \return */ int GetAlpha() const; /** * 设置透明度 * * \param alpha */ void SetAlpha(int alpha); public: double GetMiniSmoothStep(void); //获得最小平滑步长 BOOL IsPrinting(BOOL bOnlyPreviewDC); //是否CDC类是打印或打印预览模式 protected: void CreateDrawer(); private: /** * 透明度,目前只有曲线充填使用到它 */ int m_alpha = 255; /** * 判断抗锯齿补丁包是否需要渲染 * 抗锯齿补丁是以网格宽高为单位的,如果一格连一个像素点都占不到,那就没有必要再绘制补丁包了,白白浪费性能 * * \param pMeshPackage * \return */ bool ShouldRenderMeshPackage(const CMesh& mesh) const; bool m_shouldRenderMeshPackage = true; public: virtual void DrawCurveExOld(CCurveEx& m_curve); //ggff2025,绘制井曲线的线型 }; extern "C" AFX_EXT_API void WINAPI AfxGetText(CPointNameBase& point, CHowToViewPoint* HowToViewPoint, CText &text); extern "C" AFX_EXT_API void WINAPI AfxGetInsert(CPointNameBase& point, CHowToViewPoint* HowToViewPoint,CInsertDraw &insert);