SimplePolygonSymbol.h 4.6 KB
#pragma once
#ifndef _SimplePolygonSymbol_H_
#define _SimplePolygonSymbol_H_
#include<string>

#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/foreach.hpp>
#include"Renderer.h"
#include"clsStruct.h"
#include <math.h>
using namespace std;
namespace DmapCore_30
{

   enum PolygonFillType
{
	dmapFillTypeSolid = 0,  //实体填充
	dmapFillTypeBDiagonal = 1,     //左下到右上
	dmapFillTypeFDiagonal = 2,     //左上到右下
	dmapFillTypeCross = 3,         //十字架
	dmapFillTypeDiagCross = 4,     //斜十字架
	dmapFillTypeHorizontal = 5,    //横线
	dmapFillTypeVertical = 6,      //竖线
	dmapFillTypeGray = 7,    //灰色
	dmapFillTypeLightGray = 8,   //浅灰色
	dmapFillTypeDarkGray = 9,     //深灰色

	dmapFillTypeIcon = 10,   //图片纹理
	dmapFillTypeCharacter = 11 //字体纹理
};

	class clsCrSurf;
	class DataCollection;
	class CORE_EXPORT SimplePolygonSymbol :public Renderer
	{
	public:
		SimplePolygonSymbol();
		~SimplePolygonSymbol();
		static SimplePolygonSymbol* CreateNew();
		virtual int RendererType();
		virtual bool Parse(boost::property_tree::ptree &pt, AppendBuffer *f);
		virtual bool DrawData(clsCrSurf* pClsCS, DataCollection* data, bool drawSimpleData, char* pFlag = NULL);
		virtual bool DrawData(clsCrSurf* pClsCS, DataCollection* data, int dataIndex, char* pFlag = NULL);
		virtual bool DrawLegend(clsCrSurf* pClsCS, shared_ptr<legendParamater> pLegendParamater,int layerType, char* pFlag = NULL);
		virtual void ToJson(AppendBuffer *ab);
		virtual bool ParsePtree( boost::property_tree::ptree &pt);
		int  m_iAntialiasing;

		bool TryFindHeatRenderer(){ return false; }
		
		string m_sPNG;
		string m_sJDPNG;
		double m_dWidth;
		bool m_bBoundary;
		unsigned int m_iBoundaryColor;
		int m_iLineType;
		int m_iFillType;
		int m_iBoundaryCapType;
		int m_iBoundaryJionType;
		long m_lFillInterval;

		bool m_bNeedBackground;
		unsigned int m_iBackgroundColor;


		string m_sFont;
		string m_sFontname;
		char m_sUTF8[5];
		long  m_lCharacter;
		long m_iFillsize;


		bool m_diagalignment;
		bool m_bNeedFill;
		//是否设置填充颜色
	//	bool m_bNeedFillTextureColor;
		unsigned int   m_iFillColor;

		double r, g, b, a;
		double r1, g1, b1, a1;
		double r_b, g_b, b_b, a_b;

		cairo_pattern_t* m_Pattern = nullptr;
		/*
		设置纯颜色填充时,重置为NULL
		*/
		clsCrSurf* m_pRepeatSurface;   //这个 surface 虽然不直接调用, 但也不能作为局部变量, 因为他必须在 pattern 的整个生命期存在, 他甚至比 Pattern 后销毁
		/*
		此变量小心维护:
		1. 只要不是简单的填充颜色, 都是使用 此 pattern平铺
		2. 初始化为 NULL
		3. 绘图时, 检测到有 png 字段, 构造 png surface , 只要 surface 长宽都不为0 , 使用 png 填充
		4. 在设置 Png或者 filltype 时 维护, 绘图时直接调用
		*/

		//cairo_surface_t* m_pRepeatSurface;


        bool                     SetCharacter(long lCharacter);

		int                      GetAntialiasing();
		bool                     SetAntialiasing(int newVal);
		unsigned int             GetColor();
		bool                     SetColor(unsigned int color);
		int                      GetLineType();
		bool                     SetLineType(int type);
		const char*              GetPNG();
		bool                     SetPNG(const char* png);
		double                   GetWidth();
		bool                     SetWidth(double width);
		bool                     GetBoundary();
		bool                     SetBoundary(bool boundary);
		unsigned int             GetBoundaryColor();
		bool                     SetBoundaryColor(unsigned int boundaryColor);
		/*const char*              GetLinePNG();
		bool                     SetLinePNG(const char* png);*/
		int                      GetFillType();
		bool                     SetFillType(int iFillType);
		int                      GetBoundaryCapType();
		bool                     SetBoundaryCapType(int iBoundaryCapType);
		int                      GetBoundaryJionType();
		bool                     SetBoundaryJionType(int iBoundaryJionType);
		long                     GetFillInterval();
		bool                     SetFillInterval(long iFillInterval);
		bool                     GetNeedFill();
		bool                     SetNeedFill(bool bNeedFill);



		bool GetRepeatSurface();
		bool SetBackground(cairo_t* cr,double dSurfW,double dSurfH);

		bool DrawRING(clsCrSurf* pClsCS, clsStruct::LINE* pRing);
		bool DrawPOLYGON(clsCrSurf* pClsCS, clsStruct::POLYGON* pPolygon);
		bool DrawMPOLYGON(clsCrSurf* pClsCS, clsStruct::MPOLYGON* pMPolygon);

		bool DrawTexture(clsCrSurf* pClsCS,clsStruct::MPOLYGON* pMPolygon);
	};
}

#endif