My Project
GDIGraphicsPath.h
1 #pragma once
2 #include <vector>
3 #include "GDIPen.h"
4 #include "GDIRegion.h"
5 namespace ParaEngine
6 {
7  struct GUITextureElement;
8  struct GDIPathElement{
9  public:
10  Vector3 point;
11  Color color;
12  //the element's drawing pen, this value is meaningful only when the element's pointtype is PathPointTypeStart
13  CGDIPen pen;
14  byte pointtype;
15  CGDIRegion region;//the clip region for the figure, it is only useful when point type is PathPointTypeStart;
16  };
17  struct GDIFigure{
18  public:
19  vector<DXUT_SCREEN_VERTEX> vertices;
20  D3DPRIMITIVETYPE PrimitiveType;
21  const GDIPathElement *pElement;//pointer to the start element of this figure
22  byte operationtype;
23  Matrix4 matTransform;
24  };
26  {
27  public:
29  CGDIGraphicsPath(const Vector3* points,const BYTE* types,int count);
30  ~CGDIGraphicsPath(){};
31 
32  CGDIGraphicsPath* Clone()const ;
33 
35  void Undo(int nStep=1);
37  void Redo(int nStep=1);
38 
40  void Reset();
41 
46  void AddLine(const Vector3 &point1,const Vector3& point2,const CGDIPen &pen);
47 
51  void AddLines(const Vector3 *points,int nNumPoints,const CGDIPen &pen);
55  void AddPoint(const Vector3 &point,const CGDIPen &pPen);
56 
60  void AddRectangle(const Vector3 *points,const CGDIPen &pen);
64  int GetPointCount()const {return (int)m_elements.size();};
65 
69  void AddClear(const Color &color);
74 // bool GetChanged()const{return m_bNeedUpdate;}
79 // void SetChanged(bool changed){m_bHasChanged=changed;}
84  GDIPathElement& operator [](int index);
85 
89  void Optimize() ;
90 
94  void UpdateVertices(int nOption=0);
95  //void UpdateVertices(const GDIPathElement *pElement,D3DPRIMITIVETYPE PrimitiveType,const DXUT_SCREEN_VERTEX *pVertices, int nNumVertices,int nOption=0);
99  void AddOperation(const GDIPathElement *pElement,byte operationtype);
100 
104  void SetClip(const CGDIRegion &region);
105  const CGDIRegion* GetClip()const{return &m_region;}
109  vector<GDIPathElement>::iterator PathBegin(){return m_elements.begin();}
110  vector<GDIPathElement>::iterator PathEnd(){return m_elements.end();}
114  list<GDIFigure>::iterator FigureBegin(){return m_figures.begin();}
115  list<GDIFigure>::iterator FigureEnd(){return m_figures.end();}
116  protected:
117  void ClearFigures(){m_figures.clear();m_bNeedUpdate=true;}
118  void CalculateLineVertex(const Vector3 *points,int nNumPoints, vector<DXUT_SCREEN_VERTEX> &vertices, const CGDIPen &pPen);
119  void CalculateRectVertex(const Vector3 *points,int nNumPoints, vector<DXUT_SCREEN_VERTEX> &vertices, const CGDIPen &pPen);
120  void UpdateFigures(const GDIPathElement *pElement, D3DPRIMITIVETYPE PrimitiveType, const vector<DXUT_SCREEN_VERTEX> &vertices, const Matrix4 *matTransform, int nOption = 0, int index = 0);
121  vector<GDIPathElement> m_elements;
122  list<GDIFigure> m_figures;
123  LPDIRECT3DVERTEXBUFFER9 m_pVB;
124  bool m_bNeedUpdate;
125  CGDIRegion m_region;
126  };
127 }
vector< GDIPathElement >::iterator PathBegin()
The following two are for iteration of the GDIPathElement.
Definition: GDIGraphicsPath.h:109
list< GDIFigure >::iterator FigureBegin()
The following two are for iteration of the GDIFigure.
Definition: GDIGraphicsPath.h:114
Definition: GDIGraphicsPath.h:25
different physics engine has different winding order.
Definition: EventBinding.h:32
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
Definition: GDIGraphicsPath.h:8
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: ParaMatrix4.h:23
a pen object in the GDI class
Definition: GDIPen.h:9
Definition: GDIGraphicsPath.h:17
We always shape the region points and edges in clockwise.
Definition: GDIRegion.h:29
Definition: ParaColor.h:275
int GetPointCount() const
Get the number of points in the path.
Definition: GDIGraphicsPath.h:64