From a77987488bb21aa691cb8e5d818ee57869b73c88 Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Tue, 6 Aug 2024 10:52:06 +0300 Subject: [PATCH] Refactoring --- DesktopEditor/graphics/BooleanOperations.h | 385 ++++++++---------- DesktopEditor/graphics/GraphicsPath.h | 210 +++++----- .../tests/{TestClip => booleanPaths}/main.cpp | 0 .../{TestClip => booleanPaths}/mainwindow.cpp | 2 +- .../{TestClip => booleanPaths}/mainwindow.h | 0 .../{TestClip => booleanPaths}/mainwindow.ui | 0 .../TestClip.pro => booleanPaths/test.pro} | 0 7 files changed, 290 insertions(+), 307 deletions(-) rename DesktopEditor/graphics/tests/{TestClip => booleanPaths}/main.cpp (100%) rename DesktopEditor/graphics/tests/{TestClip => booleanPaths}/mainwindow.cpp (99%) rename DesktopEditor/graphics/tests/{TestClip => booleanPaths}/mainwindow.h (100%) rename DesktopEditor/graphics/tests/{TestClip => booleanPaths}/mainwindow.ui (100%) rename DesktopEditor/graphics/tests/{TestClip/TestClip.pro => booleanPaths/test.pro} (100%) diff --git a/DesktopEditor/graphics/BooleanOperations.h b/DesktopEditor/graphics/BooleanOperations.h index 36bf80ae75..1b6d10c89f 100644 --- a/DesktopEditor/graphics/BooleanOperations.h +++ b/DesktopEditor/graphics/BooleanOperations.h @@ -5,245 +5,218 @@ #include "boolean_operations_math.h" #include -namespace Aggplus { -enum BooleanOpType +namespace Aggplus { - Intersection = 2, - Union = 1, - Subtraction = 1, - Exclusion = 3, - Division = 4 -}; + struct Location; + struct Winding; -struct Location; -struct Winding; + struct Segment + { + PointD P; + PointD HI; + PointD HO; -struct Segment -{ - PointD P; - PointD HI; - PointD HO; - - bool IsCurve; - bool Visited; + bool IsCurve; + bool Visited; - size_t Index; - size_t Id; + size_t Index; + size_t Id; - CGraphicsPath *Path; - std::shared_ptr Inters; - std::shared_ptr Wind; + CGraphicsPath* Path; + std::shared_ptr Inters; + std::shared_ptr Wind; - Segment(); - Segment(const std::vector& points, bool isCurve, - size_t index, size_t id, CGraphicsPath* path); - Segment(const PointD& p, const PointD& hi, const PointD& ho); + Segment(); + Segment(const std::vector& points, bool isCurve, size_t index, size_t id, CGraphicsPath* path); + Segment(const PointD& p, const PointD& hi, const PointD& ho); - bool IsValid(BooleanOpType op) const; - bool operator==(const Segment& other) const; - bool operator!=(const Segment& other) const; -}; - -struct Curve -{ - Segment Segment1; - Segment Segment2; - - Curve(); - Curve(const Segment& segment1, const Segment& segment2); - Curve(const std::vector& values); - Curve(double x0, double y0, double x1, double y1, - double x2, double y2, double x3, double y3); + bool IsValid(BooleanOpType op) const; + bool operator==(const Segment& other) const; + bool operator!=(const Segment& other) const; + }; - std::vector GetXValues() const; - std::vector GetYValues() const; - std::vector GetPeeks() const; + struct Curve + { + Segment Segment1; + Segment Segment2; - double GetLength(double a = 0, double b = 1) const; - double GetSquaredLineLength() const; - double GetTimeOf(const PointD& point) const ; - double GetTimeAt(double offset) const; - PointD Get(double t, int type) const; - PointD GetPoint(double t) const; - PointD GetTangent(double t) const; - PointD GetTangent(double t, double offset, bool inside, const PointD& p) const; - Curve GetPart(double from, double to) const; - std::vector GetMonoCurves(bool dir) const; - std::vector> GetOverlaps(const Curve& curve) const; - std::vector GetCurveLineIntersection(double px, double py, - double vx, double vy) const; - - std::vector Subdivide(double t) const; - Curve DivideAtTime(double time, std::vector& segments, - std::vector& curves); - - int SolveCubic(size_t coord, int value, std::vector& roots, - double mn, double mx) const; - int SolveCubic(double a, double b, double c, double d, std::vector& roots, - double mn, double mx) const; + Curve(); + Curve(const Segment& segment1, const Segment& segment2); + Curve(const std::vector& values); + Curve(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3); - void Flip(); - void ClearHandles(); + std::vector GetXValues() const; + std::vector GetYValues() const; + std::vector GetPeeks() const; - bool IsStraight() const; - bool HasHandle() const ; + double GetLength(double a = 0, double b = 1) const; + double GetSquaredLineLength() const; + double GetTimeOf(const PointD& point) const; + double GetTimeAt(double offset) const; + PointD Get(double t, int type) const; + PointD GetPoint(double t) const; + PointD GetTangent(double t) const; + PointD GetTangent(double t, double offset, bool inside, const PointD& p) const; + Curve GetPart(double from, double to) const; + std::vector GetMonoCurves(bool dir) const; + std::vector> GetOverlaps(const Curve& curve) const; + std::vector GetCurveLineIntersection(double px, double py, double vx, double vy) const; - bool operator==(const Curve& other) const; - bool operator!=(const Curve& other) const; -}; + std::vector Subdivide(double t) const; + Curve DivideAtTime(double time, std::vector& segments, std::vector& curves); -struct Location -{ - Curve C; - Segment S; - double Time; - bool Overlap; + int SolveCubic(size_t coord, int value, std::vector& roots, double mn, double mx) const; + int SolveCubic(double a, double b, double c, double d, std::vector& roots, double mn, double mx) const; - std::shared_ptr Inters; - std::shared_ptr Next; - std::shared_ptr Prev; - - Location(); - Location(const Curve& curve, double time, bool overlap); + void Flip(); + void ClearHandles(); - bool IsTouching(); - bool operator==(const Location& other); -}; + bool IsStraight() const; + bool HasHandle() const; -struct Branch -{ - double Start; - std::vector Crossings; - std::vector Visited; - PointD HI; + bool operator==(const Curve& other) const; + bool operator!=(const Curve& other) const; + }; - Branch(); - Branch(double start, const std::vector& crosings, const PointD& hi); -}; + struct Location + { + Curve C; + Segment S; + double Time; + bool Overlap; -struct Winding -{ - std::vector Roots; - std::vector Curves; - std::vector Curves1; - std::vector Curves2; - std::vector CurvesHor; - std::vector CurvesVer; + std::shared_ptr Inters; + std::shared_ptr Next; + std::shared_ptr Prev; - Curve Prev; + Location(); + Location(const Curve& curve, double time, bool overlap); - bool OnPath; - bool OnAnyPath; - bool Direction; - bool DontFlip; + bool IsTouching(); + bool operator==(const Location& other); + }; - double W; - double Quality; - double WindingLeft; - double WindingRight; - double PointAbscissas; - double PointOrdinat; - double PathWindingLeft; - double PathWindingRight; - double PointAbscissasLeft; - double PointAbscissasRight; + struct Branch + { + double Start; + std::vector Crossings; + std::vector Visited; + PointD HI; - Winding(); + Branch(); + Branch(double start, const std::vector& crosings, const PointD& hi); + }; - void Copy(Winding* wind); - void Reset(); - void SetDirection(bool direction); - void SetPoint(const PointD& point); - void SetCurves(const std::vector& curvesHor, const std::vector& curveVer); + struct Winding + { + std::vector Roots; + std::vector Curves; + std::vector Curves1; + std::vector Curves2; + std::vector CurvesHor; + std::vector CurvesVer; - Winding* AddWinding(const Curve& curve); - Winding* HandleCurve(const Curve& curve); - void GetWinding(); + Curve Prev; - // bool IsFirst(Curve curve); - Curve GetPreviousCurve(const Curve& curve) const; -}; + bool OnPath; + bool OnAnyPath; + bool Direction; + bool DontFlip; -class CBooleanOperations -{ -public: - CBooleanOperations(CGraphicsPath* path1, CGraphicsPath* path2, BooleanOpType op); - CGraphicsPath* GetResult(); - - //BooleanOp - void TraceBoolean(); - void TracePaths(); - //void reorientPaths(); + double W; + double Quality; + double WindingLeft; + double WindingRight; + double PointAbscissas; + double PointOrdinat; + double PathWindingLeft; + double PathWindingRight; + double PointAbscissasLeft; + double PointAbscissasRight; - //Path - void PreparePath(CGraphicsPath *path, size_t id, std::vector& segments, - std::vector& curves); - void InsertSegment(const Segment& segment); - Curve GetCurve(const Segment& segment) const; - Curve GetPreviousCurve(const Curve& curve) const; - Curve GetNextCurve(const Curve& curve) const; - Segment GetNextSegment(const Segment& segment) const; - std::vector GetCurves(const std::vector& indices) const; - std::vector GetCrossing(const Segment& seg, std::vector& starts, - bool collectStart) const; + Winding(); - //Bounds - std::vector> GetBoundsForCurves(const std::vector& curves) const; - std::vector> FindCurveBoundsCollisions(const std::vector& curves1, - const std::vector& curves2, - double tolerance, - bool bothAxis = false); - std::vector> FindBoundsCollisions(const std::vector>& bounds1, - const std::vector>& bounds2, - double tolerance, - bool sweepVertical = false, - bool onlySweep = false); + void Copy(Winding* wind); + void Reset(); + void SetDirection(bool direction); + void SetPoint(const PointD& point); + void SetCurves(const std::vector& curvesHor, const std::vector& curveVer); - //Intersection - bool IsCrossing(std::shared_ptr loc); - bool FilterIntersections(std::shared_ptr loc); - bool IntersectsBounds(); - void GetIntersection(); - void GetCurveIntersection(const Curve& curve1, const Curve& curve2); - void LinkIntersection(std::shared_ptr form, std::shared_ptr to); - void AddLineIntersection(const Curve& curve1, const Curve& curve2, bool flip); - void AddCurveLineIntersection(const Curve& curve1, const Curve& curve2, bool flip); - int AddCurveIntersection(const Curve& curve1, const Curve& curve2, bool flip, - int recursion = 0, int calls = 0, double tMin = 0, - double tMax = 1, double uMin = 0, double uMax = 1); + Winding* AddWinding(const Curve& curve); + Winding* HandleCurve(const Curve& curve); + void GetWinding(); - //Location - void DivideLocations(); - void AddLocation(Curve curve1,Curve curve2, double t1, double t2, bool overlap = false); - void InsertLocation(std::shared_ptr loc); + // bool IsFirst(Curve curve); + Curve GetPreviousCurve(const Curve& curve) const; + }; - //Util - void ClearCurveHandles(std::vector& curves); - void AddOffsets(std::vector& offsets, const Curve& curve, bool end); - void PropagateWinding(Segment segment, std::vector> map); - void Collect(const Segment& seg, std::vector& crossing, std::vector& starts, - std::shared_ptr inter, std::shared_ptr end, - bool collectStarts) const; -private: - BooleanOpType Op; + class CBooleanOperations + { + public: + CBooleanOperations(CGraphicsPath* path1, CGraphicsPath* path2, BooleanOpType op); + CGraphicsPath* GetResult(); - CGraphicsPath *Path1; - CGraphicsPath *Path2; - CGraphicsPath *Result; + // BooleanOp + void TraceBoolean(); + void TracePaths(); + // void reorientPaths(); - std::vector Segments; - std::vector Segments1; - std::vector Segments2; - - std::vector Curves; - std::vector Curves1; - std::vector Curves2; + // Path + void PreparePath(CGraphicsPath* path, size_t id, std::vector& segments, std::vector& curves); + void InsertSegment(const Segment& segment); + Curve GetCurve(const Segment& segment) const; + Curve GetPreviousCurve(const Curve& curve) const; + Curve GetNextCurve(const Curve& curve) const; + Segment GetNextSegment(const Segment& segment) const; + std::vector GetCurves(const std::vector& indices) const; + std::vector GetCrossing(const Segment& seg, std::vector& starts, bool collectStart) const; - std::vector> Locations; - bool OverlapOnly[2] = {true, true}; -}; + // Bounds + std::vector> GetBoundsForCurves(const std::vector& curves) const; + std::vector> FindCurveBoundsCollisions(const std::vector& curves1, const std::vector& curves2, double tolerance, bool bothAxis = false); + std::vector> + FindBoundsCollisions(const std::vector>& bounds1, const std::vector>& bounds2, double tolerance, bool sweepVertical = false, bool onlySweep = false); -GRAPHICS_DECL CGraphicsPath* BooleanOperation(CGraphicsPath* path1, CGraphicsPath* path2, BooleanOpType op); -} + // Intersection + bool IsCrossing(std::shared_ptr loc); + bool FilterIntersections(std::shared_ptr loc); + bool IntersectsBounds(); + void GetIntersection(); + void GetCurveIntersection(const Curve& curve1, const Curve& curve2); + void LinkIntersection(std::shared_ptr form, std::shared_ptr to); + void AddLineIntersection(const Curve& curve1, const Curve& curve2, bool flip); + void AddCurveLineIntersection(const Curve& curve1, const Curve& curve2, bool flip); + int AddCurveIntersection(const Curve& curve1, const Curve& curve2, bool flip, int recursion = 0, int calls = 0, double tMin = 0, double tMax = 1, double uMin = 0, double uMax = 1); -#endif //BOOLEANOPERATIONS_H + // Location + void DivideLocations(); + void AddLocation(Curve curve1, Curve curve2, double t1, double t2, bool overlap = false); + void InsertLocation(std::shared_ptr loc); + + // Util + void ClearCurveHandles(std::vector& curves); + void AddOffsets(std::vector& offsets, const Curve& curve, bool end); + void PropagateWinding(Segment segment, std::vector> map); + void Collect(const Segment& seg, std::vector& crossing, std::vector& starts, std::shared_ptr inter, std::shared_ptr end, bool collectStarts) const; + + private: + BooleanOpType Op; + + CGraphicsPath* Path1; + CGraphicsPath* Path2; + CGraphicsPath* Result; + + std::vector Segments; + std::vector Segments1; + std::vector Segments2; + + std::vector Curves; + std::vector Curves1; + std::vector Curves2; + + std::vector> Locations; + bool OverlapOnly[2] = {true, true}; + }; +} // namespace Aggplus + +#endif // BOOLEANOPERATIONS_H diff --git a/DesktopEditor/graphics/GraphicsPath.h b/DesktopEditor/graphics/GraphicsPath.h index eedc30fa77..233601ba7b 100644 --- a/DesktopEditor/graphics/GraphicsPath.h +++ b/DesktopEditor/graphics/GraphicsPath.h @@ -42,64 +42,64 @@ namespace Aggplus { - class CGraphicsPath_private; - class GRAPHICS_DECL CGraphicsPath : public NSFonts::ISimpleGraphicsPath - { - public: - CGraphicsPath(); - ~CGraphicsPath(); + class CGraphicsPath_private; + class GRAPHICS_DECL CGraphicsPath : public NSFonts::ISimpleGraphicsPath + { + public: + CGraphicsPath(); + ~CGraphicsPath(); - CGraphicsPath* Clone(); + CGraphicsPath* Clone(); - Status Reset(); - void SetRuler(bool bEvenOdd); + Status Reset(); + void SetRuler(bool bEvenOdd); - Status StartFigure(); - Status CloseFigure(); - bool Is_poly_closed(); - Status MoveTo(double x, double y); - Status LineTo(double x, double y); - Status CurveTo(double x1, double y1, double x2, double y2, double x3, double y3); + Status StartFigure(); + Status CloseFigure(); + bool Is_poly_closed(); + Status MoveTo(double x, double y); + Status LineTo(double x, double y); + Status CurveTo(double x1, double y1, double x2, double y2, double x3, double y3); - // методы, которые просто будем сводить к трем основным - Status AddLine(double x1, double y1, double x2, double y2); - Status AddLines(double* pPoints, int nCount); - Status AddBezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4); - Status AddBeziers(double* pPoints, int nCount); - Status AddCurve(double* pPoints, int nCount); - Status AddEllipse(double x, double y, double width, double height); - Status AddRectangle(double x, double y, double width, double height); - Status AddPolygon(double* pPoints, int nCount); - Status AddPath(const CGraphicsPath& oPath); - Status AddArc(double x, double y, double width, double height, double startAngle, double sweepAngle); + // методы, которые просто будем сводить к трем основным + Status AddLine(double x1, double y1, double x2, double y2); + Status AddLines(double* pPoints, int nCount); + Status AddBezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4); + Status AddBeziers(double* pPoints, int nCount); + Status AddCurve(double* pPoints, int nCount); + Status AddEllipse(double x, double y, double width, double height); + Status AddRectangle(double x, double y, double width, double height); + Status AddPolygon(double* pPoints, int nCount); + Status AddPath(const CGraphicsPath& oPath); + Status AddArc(double x, double y, double width, double height, double startAngle, double sweepAngle); - ULONG GetPointCount() const; - Status GetPathPoints(PointF* points, int count) const; - Status GetLastPoint(double& x, double& y); - Status GetPathPoints(double* points, int count) const; - void GetBounds(double& left, double& top, double& width, double& height); + ULONG GetPointCount() const; + Status GetPathPoints(PointF* points, int count) const; + Status GetLastPoint(double& x, double& y); + Status GetPathPoints(double* points, int count) const; + void GetBounds(double& left, double& top, double& width, double& height); - Status Transform(const CMatrix* matrix); - virtual bool _MoveTo(double x, double y); - virtual bool _LineTo(double x, double y); - virtual bool _CurveTo(double x1, double y1, double x2, double y2, double x3, double y3); - virtual bool _Close(); + Status Transform(const CMatrix* matrix); + virtual bool _MoveTo(double x, double y); + virtual bool _LineTo(double x, double y); + virtual bool _CurveTo(double x1, double y1, double x2, double y2, double x3, double y3); + virtual bool _Close(); - Status AddString(const std::wstring& strText, NSFonts::IFontManager* pFont, double x, double y); - Status AddString(const unsigned int* pGids, const unsigned int nGidsCount, NSFonts::IFontManager* pFont, double x, double y); - Status AddStringC(const LONG& lText, NSFonts::IFontManager* pFont, double x, double y); - void z_Stroke(const double& size); - void Widen(const double& size, const Aggplus::LineJoin& join, const CMatrix* matrix, float flatness); + Status AddString(const std::wstring& strText, NSFonts::IFontManager* pFont, double x, double y); + Status AddString(const unsigned int* pGids, const unsigned int nGidsCount, NSFonts::IFontManager* pFont, double x, double y); + Status AddStringC(const LONG& lText, NSFonts::IFontManager* pFont, double x, double y); + void z_Stroke(const double& size); + void Widen(const double& size, const Aggplus::LineJoin& join, const CMatrix* matrix, float flatness); - int EllipseArc(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection); - double AngToEllPrm(double fAngle, double fXRad, double fYRad); - int EllipseArc2(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection); - int EllipseArc3(double fX, double fY, double fXRad, double fYRad, double dAngle1, double dAngle2, double *pfXCur, double *pfYCur, INT bClockDirection = FALSE); - int Ellipse(double fX, double fY, double fXRad, double fYRad); - Status AddArc2(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle); - bool IsPointInPath(const double& x, const double& y); + int EllipseArc(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection); + double AngToEllPrm(double fAngle, double fXRad, double fYRad); + int EllipseArc2(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection); + int EllipseArc3(double fX, double fY, double fXRad, double fYRad, double dAngle1, double dAngle2, double* pfXCur, double* pfYCur, INT bClockDirection = FALSE); + int Ellipse(double fX, double fY, double fXRad, double fYRad); + Status AddArc2(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle); + bool IsPointInPath(const double& x, const double& y); - //Methods for Path Clip + // Methods for Path Clip bool IsClockwise() const; void Reverse(); bool IsCurvePoint(size_t idx) const; @@ -107,68 +107,78 @@ namespace Aggplus double GetArea() const; double GetArea(size_t idx, bool isCurve) const; - public: - CGraphicsPath_private* m_internal; - }; + public: + CGraphicsPath_private* m_internal; + }; - class CGraphicsPathSimpleConverter_private; - class GRAPHICS_DECL CGraphicsPathSimpleConverter : public NSFonts::ISimpleGraphicsPath - { - private: - IRenderer* m_pRenderer; - CGraphicsPathSimpleConverter_private* m_internal; + class CGraphicsPathSimpleConverter_private; + class GRAPHICS_DECL CGraphicsPathSimpleConverter : public NSFonts::ISimpleGraphicsPath + { + private: + IRenderer* m_pRenderer; + CGraphicsPathSimpleConverter_private* m_internal; - public: - CGraphicsPathSimpleConverter(); - ~CGraphicsPathSimpleConverter(); + public: + CGraphicsPathSimpleConverter(); + ~CGraphicsPathSimpleConverter(); - public: - void SetRenderer(IRenderer* pRenderer); - IRenderer* GetRenderer(INT bIsAddref = FALSE); + public: + void SetRenderer(IRenderer* pRenderer); + IRenderer* GetRenderer(INT bIsAddref = FALSE); - public: - bool PathCommandMoveTo(double fX, double fY); - bool PathCommandLineTo(double fX, double fY); - bool PathCommandLinesTo(double* pPoints, LONG lCount); - bool PathCommandCurveTo(double fX1, double fY1, double fX2, double fY2, double fX3, double fY3); - bool PathCommandCurvesTo(double* pData, LONG lCount); - bool PathCommandArcTo(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle); - bool PathCommandClose(); - bool PathCommandEnd(); - bool PathCommandStart(); - bool PathCommandGetCurrentPoint(double* fX, double* fY); - bool PathCommandText(const std::wstring& bsText, NSFonts::IFontManager* pManager, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset); - bool PathCommandTextEx(std::wstring& bsText, std::wstring& bsGidText, NSFonts::IFontManager* pManager, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset, DWORD lFlags); + public: + bool PathCommandMoveTo(double fX, double fY); + bool PathCommandLineTo(double fX, double fY); + bool PathCommandLinesTo(double* pPoints, LONG lCount); + bool PathCommandCurveTo(double fX1, double fY1, double fX2, double fY2, double fX3, double fY3); + bool PathCommandCurvesTo(double* pData, LONG lCount); + bool PathCommandArcTo(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle); + bool PathCommandClose(); + bool PathCommandEnd(); + bool PathCommandStart(); + bool PathCommandGetCurrentPoint(double* fX, double* fY); + bool PathCommandText(const std::wstring& bsText, NSFonts::IFontManager* pManager, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset); + bool + PathCommandTextEx(std::wstring& bsText, std::wstring& bsGidText, NSFonts::IFontManager* pManager, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset, DWORD lFlags); - bool PathCommandText2(const int* pUnicodes, const int* pGids, const int& nCount, NSFonts::IFontManager* pManager, - const double& x, const double& y, const double& w, const double& h); - bool PathCommandText2(const std::wstring& sUnicodes, const int* pGids, const int& nCount, NSFonts::IFontManager* pManager, - const double& x, const double& y, const double& w, const double& h); + bool PathCommandText2(const int* pUnicodes, const int* pGids, const int& nCount, NSFonts::IFontManager* pManager, const double& x, const double& y, const double& w, const double& h); + bool PathCommandText2(const std::wstring& sUnicodes, const int* pGids, const int& nCount, NSFonts::IFontManager* pManager, const double& x, const double& y, const double& w, const double& h); - bool PathCommandGetBounds(double& left, double& top, double& width, double &height); + bool PathCommandGetBounds(double& left, double& top, double& width, double& height); - public: + public: + virtual bool _MoveTo(double x, double y); + virtual bool _LineTo(double x, double y); + virtual bool _CurveTo(double x1, double y1, double x2, double y2, double x3, double y3); + virtual bool _Close(); + bool _Reset(); + bool _Start(); - virtual bool _MoveTo(double x, double y); - virtual bool _LineTo(double x, double y); - virtual bool _CurveTo(double x1, double y1, double x2, double y2, double x3, double y3); - virtual bool _Close(); - bool _Reset(); - bool _Start(); + protected: + bool AddString(const std::wstring& bstrText, NSFonts::IFontManager* pFont, double x, double y); - protected: - bool AddString(const std::wstring& bstrText, NSFonts::IFontManager* pFont, double x, double y); + int EllipseArc(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection); + double AngToEllPrm(double fAngle, double fXRad, double fYRad); + int EllipseArc2(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection); + int EllipseArc3(double fX, double fY, double fXRad, double fYRad, double dAngle1, double dAngle2, double* pfXCur, double* pfYCur, INT bClockDirection = FALSE); + int Ellipse(double fX, double fY, double fXRad, double fYRad); - int EllipseArc(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection); - double AngToEllPrm(double fAngle, double fXRad, double fYRad); - int EllipseArc2(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection); - int EllipseArc3(double fX, double fY, double fXRad, double fYRad, double dAngle1, double dAngle2, double *pfXCur, double *pfYCur, INT bClockDirection = FALSE); - int Ellipse(double fX, double fY, double fXRad, double fYRad); + bool AddArc(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle); - bool AddArc(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle); + bool Is_poly_closed(); + }; - bool Is_poly_closed(); - }; -} + enum BooleanOpType + { + Intersection = 2, + Union = 1, + Subtraction = 1, + Exclusion = 3, + Division = 4 + }; + + GRAPHICS_DECL CGraphicsPath* BooleanOperation(CGraphicsPath* path1, CGraphicsPath* path2, BooleanOpType op); + +} // namespace Aggplus #endif // _BUILD_GRAPHICSPATH_H_ diff --git a/DesktopEditor/graphics/tests/TestClip/main.cpp b/DesktopEditor/graphics/tests/booleanPaths/main.cpp similarity index 100% rename from DesktopEditor/graphics/tests/TestClip/main.cpp rename to DesktopEditor/graphics/tests/booleanPaths/main.cpp diff --git a/DesktopEditor/graphics/tests/TestClip/mainwindow.cpp b/DesktopEditor/graphics/tests/booleanPaths/mainwindow.cpp similarity index 99% rename from DesktopEditor/graphics/tests/TestClip/mainwindow.cpp rename to DesktopEditor/graphics/tests/booleanPaths/mainwindow.cpp index 53514bb984..207a526451 100644 --- a/DesktopEditor/graphics/tests/TestClip/mainwindow.cpp +++ b/DesktopEditor/graphics/tests/booleanPaths/mainwindow.cpp @@ -1,6 +1,6 @@ #include "mainwindow.h" #include "ui_mainwindow.h" -#include "../../BooleanOperations.h" +#include "../../GraphicsPath.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) diff --git a/DesktopEditor/graphics/tests/TestClip/mainwindow.h b/DesktopEditor/graphics/tests/booleanPaths/mainwindow.h similarity index 100% rename from DesktopEditor/graphics/tests/TestClip/mainwindow.h rename to DesktopEditor/graphics/tests/booleanPaths/mainwindow.h diff --git a/DesktopEditor/graphics/tests/TestClip/mainwindow.ui b/DesktopEditor/graphics/tests/booleanPaths/mainwindow.ui similarity index 100% rename from DesktopEditor/graphics/tests/TestClip/mainwindow.ui rename to DesktopEditor/graphics/tests/booleanPaths/mainwindow.ui diff --git a/DesktopEditor/graphics/tests/TestClip/TestClip.pro b/DesktopEditor/graphics/tests/booleanPaths/test.pro similarity index 100% rename from DesktopEditor/graphics/tests/TestClip/TestClip.pro rename to DesktopEditor/graphics/tests/booleanPaths/test.pro