LibreOffice Module svx (master)  1
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
XPolygon Class Referencefinal

#include <xpoly.hxx>

Collaboration diagram for XPolygon:
[legend]

Public Member Functions

 XPolygon (sal_uInt16 nSize=16)
 
 XPolygon (const XPolygon &)
 
 XPolygon (XPolygon &&)
 
 XPolygon (const tools::Polygon &rPoly)
 create a XPolygon out of a standard polygon More...
 
 XPolygon (const tools::Rectangle &rRect, long nRx=0, long nRy=0)
 create a rectangle (also with rounded corners) as a Bézier polygon More...
 
 XPolygon (const Point &rCenter, long nRx, long nRy, sal_uInt16 nStartAngle=0, sal_uInt16 nEndAngle=3600, bool bClose=true)
 create an ellipse (curve) as Bézier polygon More...
 
 ~XPolygon ()
 
sal_uInt16 GetSize () const
 
void SetPointCount (sal_uInt16 nPoints)
 
sal_uInt16 GetPointCount () const
 
void Insert (sal_uInt16 nPos, const Point &rPt, PolyFlags eFlags)
 
void Insert (sal_uInt16 nPos, const XPolygon &rXPoly)
 
void Remove (sal_uInt16 nPos, sal_uInt16 nCount)
 
void Move (long nHorzMove, long nVertMove)
 
tools::Rectangle GetBoundRect () const
 
const Pointoperator[] (sal_uInt16 nPos) const
 
Pointoperator[] (sal_uInt16 nPos)
 
XPolygonoperator= (const XPolygon &)
 
XPolygonoperator= (XPolygon &&)
 
bool operator== (const XPolygon &rXPoly) const
 
PolyFlags GetFlags (sal_uInt16 nPos) const
 get the flags for the point at the given position More...
 
void SetFlags (sal_uInt16 nPos, PolyFlags eFlags)
 set the flags for the point at the given position More...
 
bool IsControl (sal_uInt16 nPos) const
 short path to read the CONTROL flag directly (TODO: better explain what the sense behind this flag is!) More...
 
bool IsSmooth (sal_uInt16 nPos) const
 short path to read the SMOOTH and SYMMTR flag directly (TODO: better explain what the sense behind these flags is!) More...
 
double CalcDistance (sal_uInt16 nP1, sal_uInt16 nP2)
 calculate the euclidean distance between two points More...
 
void CalcSmoothJoin (sal_uInt16 nCenter, sal_uInt16 nDrag, sal_uInt16 nPnt)
 Calculate a smooth transition to connect two Bézier curves. More...
 
void CalcTangent (sal_uInt16 nCenter, sal_uInt16 nPrev, sal_uInt16 nNext)
 Calculate tangent between two Bézier curves. More...
 
void PointsToBezier (sal_uInt16 nFirst)
 convert four polygon points into a Bézier curve More...
 
void Scale (double fSx, double fSy)
 scale in X- and/or Y-direction More...
 
void Distort (const tools::Rectangle &rRefRect, const XPolygon &rDistortedRect)
 Distort a polygon by scaling its coordinates relative to a reference rectangle into an arbitrary rectangle. More...
 
basegfx::B2DPolygon getB2DPolygon () const
 
 XPolygon (const basegfx::B2DPolygon &rPolygon)
 

Private Member Functions

void SubdivideBezier (sal_uInt16 nPos, bool bCalcFirst, double fT)
 
void GenBezArc (const Point &rCenter, long nRx, long nRy, long nXHdl, long nYHdl, sal_uInt16 nStart, sal_uInt16 nEnd, sal_uInt16 nQuad, sal_uInt16 nFirst)
 Generate a Bézier arc. More...
 

Static Private Member Functions

static bool CheckAngles (sal_uInt16 &nStart, sal_uInt16 nEnd, sal_uInt16 &nA1, sal_uInt16 &nA2)
 

Private Attributes

o3tl::cow_wrapper< ImpXPolygonpImpXPolygon
 

Detailed Description

Definition at line 44 of file xpoly.hxx.

Constructor & Destructor Documentation

XPolygon::XPolygon ( sal_uInt16  nSize = 16)

Definition at line 203 of file _xpoly.cxx.

XPolygon::XPolygon ( const XPolygon )
default
XPolygon::XPolygon ( XPolygon &&  )
default
XPolygon::XPolygon ( const tools::Polygon rPoly)
XPolygon::XPolygon ( const tools::Rectangle rRect,
long  nRx = 0,
long  nRy = 0 
)
XPolygon::XPolygon ( const Point rCenter,
long  nRx,
long  nRy,
sal_uInt16  nStartAngle = 0,
sal_uInt16  nEndAngle = 3600,
bool  bClose = true 
)

create an ellipse (curve) as Bézier polygon

Definition at line 287 of file _xpoly.cxx.

References CheckAngles(), GenBezArc(), ImpXPolygon::nPoints, nPos, ImpXPolygon::pFlagAry, pImpXPolygon, and ImpXPolygon::pPointAry.

XPolygon::~XPolygon ( )
default
XPolygon::XPolygon ( const basegfx::B2DPolygon rPolygon)
explicit

Member Function Documentation

double XPolygon::CalcDistance ( sal_uInt16  nP1,
sal_uInt16  nP2 
)

calculate the euclidean distance between two points

Parameters
nP1The first point
nP2The second point

Definition at line 488 of file _xpoly.cxx.

References pImpXPolygon, ImpXPolygon::pPointAry, Point::X(), and Point::Y().

Referenced by CalcSmoothJoin(), CalcTangent(), and PointsToBezier().

void XPolygon::CalcSmoothJoin ( sal_uInt16  nCenter,
sal_uInt16  nDrag,
sal_uInt16  nPnt 
)

Calculate a smooth transition to connect two Bézier curves.

This is done by projecting the corresponding point onto a line between two other points.

Parameters
nCenterThe point at the end or beginning of the curve. If nCenter is at the end of the polygon the point is moved to the opposite side.
nDragThe moved point that specifies the relocation.
nPntThe point to modify.

Definition at line 620 of file _xpoly.cxx.

References CalcDistance(), GetFlags(), IsControl(), pImpXPolygon, ImpXPolygon::pPointAry, Point::setX(), Point::setY(), Point::X(), and Point::Y().

void XPolygon::CalcTangent ( sal_uInt16  nCenter,
sal_uInt16  nPrev,
sal_uInt16  nNext 
)

Calculate tangent between two Bézier curves.

Parameters
nCenterstart or end point of the curves
nPrevprevious reference point
nNextnext reference point

Definition at line 653 of file _xpoly.cxx.

References CalcDistance(), GetFlags(), pImpXPolygon, ImpXPolygon::pPointAry, Point::setX(), Point::setY(), Point::X(), and Point::Y().

Referenced by ImpPathForDragAndCreate::EndCreate(), and ImpPathForDragAndCreate::MovCreate().

bool XPolygon::CheckAngles ( sal_uInt16 &  nStart,
sal_uInt16  nEnd,
sal_uInt16 &  nA1,
sal_uInt16 &  nA2 
)
staticprivate

Definition at line 592 of file _xpoly.cxx.

Referenced by XPolygon().

void XPolygon::Distort ( const tools::Rectangle rRefRect,
const XPolygon rDistortedRect 
)

Distort a polygon by scaling its coordinates relative to a reference rectangle into an arbitrary rectangle.

Mapping between polygon corners and reference rectangle: 0: top left 0-—1 1: top right | | 2: bottom right 3-—2 3: bottom left

Definition at line 771 of file _xpoly.cxx.

References ImpXPolygon::CheckPointDelete(), DBG_ASSERT, tools::Rectangle::GetHeight(), tools::Rectangle::GetWidth(), i, tools::Rectangle::Left(), ImpXPolygon::nPoints, pImpXPolygon, ImpXPolygon::pPointAry, Point::setX(), Point::setY(), tools::Rectangle::Top(), Point::X(), and Point::Y().

void XPolygon::GenBezArc ( const Point rCenter,
long  nRx,
long  nRy,
long  nXHdl,
long  nYHdl,
sal_uInt16  nStart,
sal_uInt16  nEnd,
sal_uInt16  nQuad,
sal_uInt16  nFirst 
)
private

Generate a Bézier arc.

Definition at line 544 of file _xpoly.cxx.

References Point::AdjustX(), Point::AdjustY(), pImpXPolygon, ImpXPolygon::pPointAry, SetFlags(), and SubdivideBezier().

Referenced by XPolygon().

basegfx::B2DPolygon XPolygon::getB2DPolygon ( ) const
tools::Rectangle XPolygon::GetBoundRect ( ) const
PolyFlags XPolygon::GetFlags ( sal_uInt16  nPos) const
sal_uInt16 XPolygon::GetPointCount ( ) const
sal_uInt16 XPolygon::GetSize ( ) const

Definition at line 345 of file _xpoly.cxx.

References ImpXPolygon::CheckPointDelete(), ImpXPolygon::nSize, and pImpXPolygon.

void XPolygon::Insert ( sal_uInt16  nPos,
const Point rPt,
PolyFlags  eFlags 
)
void XPolygon::Insert ( sal_uInt16  nPos,
const XPolygon rXPoly 
)
bool XPolygon::IsControl ( sal_uInt16  nPos) const
bool XPolygon::IsSmooth ( sal_uInt16  nPos) const

short path to read the SMOOTH and SYMMTR flag directly (TODO: better explain what the sense behind these flags is!)

Definition at line 477 of file _xpoly.cxx.

References ImpXPolygon::pFlagAry, and pImpXPolygon.

void XPolygon::Move ( long  nHorzMove,
long  nVertMove 
)

Definition at line 386 of file _xpoly.cxx.

References Point::AdjustX(), Point::AdjustY(), i, ImpXPolygon::nPoints, pImpXPolygon, and ImpXPolygon::pPointAry.

Referenced by MoveXPoly().

XPolygon & XPolygon::operator= ( const XPolygon )
default
XPolygon & XPolygon::operator= ( XPolygon &&  )
default
bool XPolygon::operator== ( const XPolygon rXPoly) const

Definition at line 450 of file _xpoly.cxx.

References ImpXPolygon::CheckPointDelete(), and pImpXPolygon.

const Point & XPolygon::operator[] ( sal_uInt16  nPos) const
Point & XPolygon::operator[] ( sal_uInt16  nPos)
void XPolygon::PointsToBezier ( sal_uInt16  nFirst)

convert four polygon points into a Bézier curve

Definition at line 680 of file _xpoly.cxx.

References CalcDistance(), IsControl(), ImpXPolygon::nPoints, pImpXPolygon, ImpXPolygon::pPointAry, SetFlags(), Point::X(), and Point::Y().

Referenced by ImpPathForDragAndCreate::EndCreate(), and ImpPathForDragAndCreate::MovCreate().

void XPolygon::Remove ( sal_uInt16  nPos,
sal_uInt16  nCount 
)
void XPolygon::Scale ( double  fSx,
double  fSy 
)
void XPolygon::SetFlags ( sal_uInt16  nPos,
PolyFlags  eFlags 
)
void XPolygon::SetPointCount ( sal_uInt16  nPoints)
void XPolygon::SubdivideBezier ( sal_uInt16  nPos,
bool  bCalcFirst,
double  fT 
)
private

Definition at line 497 of file _xpoly.cxx.

References pImpXPolygon, ImpXPolygon::pPointAry, Point::setX(), Point::setY(), X, and Y.

Referenced by GenBezArc().

Member Data Documentation

o3tl::cow_wrapper< ImpXPolygon > XPolygon::pImpXPolygon
private

The documentation for this class was generated from the following files: