24#include <tqvaluelist.h>
30#include <koffice_export.h>
42class KARBONBASE_EXPORT VSegment
44 friend class VSubpath;
45 friend class VSubpathIterator;
67 VSegment(
unsigned short deg = 3 );
69 VSegment(
const VSegment& segment );
86 void setDegree(
unsigned short deg );
92 bool isLine()
const {
return (degree() == 1) && prev(); }
93 bool isCurve()
const {
return degree() > 1; }
117 return m_nodes[ i ].m_vector;
125 const KoPoint&
p(
int i )
const
129 : m_nodes[ --i ].m_vector;
145 m_nodes[ i ].m_vector =
p;
153 void setP(
int i,
const KoPoint&
p )
156 prev()->setKnot(
p );
158 m_nodes[ --i ].m_vector =
p;
166 m_nodes[
degree() - 1 ].m_vector =
p;
175 return m_nodes[ i ].m_isSelected;
183 return m_nodes[
degree() - 1 ].m_isSelected;
191 m_nodes[ i ].m_isSelected = select;
199 m_nodes[
degree() - 1 ].m_isSelected = select;
208 uint nodeNear(
const KoPoint& p,
209 double isNearRange = VGlobal::isNearRange )
const;
228 bool isFlat(
double flatness = VGlobal::flatnessTolerance )
const;
235 KoPoint pointAt(
double t )
const;
241 void pointDerivativesAt(
double t, KoPoint* p = 0L,
242 KoPoint* d1 = 0L, KoPoint* d2 = 0L )
const;
252 KoPoint tangentAt(
double t )
const;
259 void pointTangentNormalAt(
double t, KoPoint* p = 0L,
260 KoPoint* tn = 0L, KoPoint* n = 0L )
const;
267 double length(
double t = 1.0 )
const;
273 double chordLength()
const;
278 double polyLength()
const;
285 double lengthParam(
double len )
const;
292 double nearestPointParam(
const KoPoint& p )
const;
300 bool isSmooth(
const VSegment& next )
const;
302 bool isSmooth()
const
305 ? isSmooth( *next() )
315 VSegment* revert()
const;
323 VSegment* splitAt(
double t );
329 static double height(
338 static bool linesIntersect(
347 bool intersects(
const VSegment& segment )
const;
362 (
knot().y() -
prev()->knot().y() );
368 KoRect boundingBox()
const;
371 void draw( VPainter* painter )
const;
374 void load(
const TQDomElement& element );
387 void rootParams( TQValueList<double>& params )
const;
392 int controlPolygonZeros()
const;
398 unsigned short m_degree : 6;
A class representing lines and beziers.
bool pointIsSelected(int i) const
Returns true if the point with index 0 <= i < degree() is selected.
bool knotIsSelected() const
Returns true if the knot is selected.
bool isBegin() const
Tests for the segment type ("begin", "line" or "curve").
double pointIsLeft(const KoPoint &p) const
Returns a number > 0 if the point p is left, 0 if it's on and a number < 0 if it's right of the infin...
void setKnot(const KoPoint &p)
Sets the knot.
void setState(VState state)
Sets the segment state.
void setPoint(int i, const KoPoint &p)
Sets the segment's point with index 0 <= i < degree() to "p".
void selectKnot(bool select=true)
Selects/deselects the knot of this segment.
const KoPoint & p(int i) const
This is a convenience function.
void selectPoint(int i, bool select=true)
Selects the point with index 0 <= i < degree().
VSegment * prev() const
Returns a pointer to the previous not deleted segment, if stored in a VSubpath.
unsigned short degree() const
Returns the segment's degree, which is identical to the number of nodes.
const KoPoint & point(int i) const
Returns the segment's point with index 0 <= i < degree().
const KoPoint & knot() const
Returns the knot.
VCtrlPointFixing
Tells which control point is "fixed" i.e.
VState state() const
Returns the segment state.
void setP(int i, const KoPoint &p)
This is a convenience function.