mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-14 14:53:29 +08:00
123 lines
3.2 KiB
C++
123 lines
3.2 KiB
C++
#ifndef _SPATH_H
|
|
#define _SPATH_H
|
|
|
|
//-------------------------------------------------------------------------------------------------------------------------------
|
|
// SPathPoint
|
|
//-------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
struct SPathPoint
|
|
{
|
|
double dX;
|
|
double dY;
|
|
};
|
|
|
|
//-------------------------------------------------------------------------------------------------------------------------------
|
|
// SPath.nFlags
|
|
//-------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
// Ôëàã äëÿ ïåðâîé òî÷êè ëþáîãî subpath
|
|
#define SPathFirst 0x01
|
|
|
|
// Ôëàã äëÿ ïîñëåäíåé òî÷êè ëþáîãî subpath
|
|
#define SPathLast 0x02
|
|
|
|
// Åñëè subpath çàìêíóòûé, òîãäà åãî ïîñëåäíÿÿ è ïåðâàÿ òî÷êà äîëæíû ñîâïàäàòü, èõ ôëàã â äàííîì ñëó÷àå ñëåäóþùèé
|
|
#define SPathClosed 0x04
|
|
|
|
// Ôëàã, îçíà÷àþùèé, ÷òî äàííàÿ òî÷êà ÿâëÿåòñÿ êîíòðîëüíîé äëÿ êðèâîé Áåçüå
|
|
#define SPathCurve 0x08
|
|
|
|
//-------------------------------------------------------------------------------------------------------------------------------
|
|
// SPathHint
|
|
//-------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
struct SPathHint
|
|
{
|
|
int nFirstControl;
|
|
int nSecondControl;
|
|
int nFirstPoint;
|
|
int nLastPoint;
|
|
};
|
|
|
|
//-------------------------------------------------------------------------------------------------------------------------------
|
|
// SPath
|
|
//-------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
class SPath
|
|
{
|
|
public:
|
|
|
|
SPath();
|
|
|
|
SPath *Ñopy()
|
|
{
|
|
return new SPath(this);
|
|
}
|
|
|
|
~SPath();
|
|
|
|
void Append(SPath *pPath);
|
|
|
|
int MoveTo(double dX, double dY);
|
|
|
|
int LineTo(double dX, double dY);
|
|
|
|
int CurveTo(double dX1, double dY1, double dX2, double dY2, double dX3, double dY3);
|
|
|
|
int Close();
|
|
|
|
void Offset(double dDx, double dDy);
|
|
|
|
int GetCount()
|
|
{
|
|
return m_nPointsCount;
|
|
}
|
|
void GetPoint(int nIndex, double *pdX, double *pdY, unsigned char *punFlag)
|
|
{
|
|
*pdX = m_pPoints[nIndex].dX;
|
|
*pdY = m_pPoints[nIndex].dY;
|
|
*punFlag = m_pFlags[nIndex];
|
|
}
|
|
|
|
BOOL GetCurPoint(double *pdX, double *pdY);
|
|
|
|
// Äîáàâëÿåì ôëàã StrokeAdjust.
|
|
void AddStrokeAdjustHint(int nFirstControl, int nSecondControl, int nFirstPoint, int nLastPoint);
|
|
|
|
|
|
private:
|
|
|
|
SPath(SPath *pPath);
|
|
void Resize(int nPointsCount);
|
|
BOOL NoCurrentPoint()
|
|
{
|
|
return m_nCurSubpath == m_nPointsCount;
|
|
}
|
|
BOOL OnePointSubpath()
|
|
{
|
|
return m_nCurSubpath == m_nPointsCount - 1;
|
|
}
|
|
BOOL OpenSubpath()
|
|
{
|
|
return m_nCurSubpath < m_nPointsCount - 1;
|
|
}
|
|
|
|
private:
|
|
|
|
SPathPoint *m_pPoints; // Ìàññèâ òî÷åê
|
|
unsigned char *m_pFlags; // Ìàññèâ ôëàãîâ, óêàçûàþùèõ çíà÷åíèå òî÷êè â SubPath
|
|
int m_nPointsCount; // Êîëè÷åñòâî òî÷åê
|
|
int m_nSize; // Íåïîñðåäñòâåííûé ðàçìåð ìàññèâà
|
|
|
|
int m_nCurSubpath; // Íîìåð ïåðâîé òî÷êè ïîñëåäíåãî SubPath
|
|
|
|
SPathHint *m_pHints; //
|
|
int m_nHintsCount;
|
|
int m_nHintsSize;
|
|
|
|
friend class SXPath;
|
|
friend class SImage;
|
|
};
|
|
|
|
#endif /* _SPATH_H */
|