/*
* Path.cpp
* nlivarot
*
* Created by fred on Tue Jun 17 2003.
*
*/
#include <glib.h>
#include "Path.h"
#include "livarot/path-description.h"
/*
* manipulation of the path data: path description and polyline
* grunt work...
* at the end of this file, 2 utilitary functions to get the point and tangent to path associated with a (command no;abcissis)
*/
{
descr_flags = 0;
pending_bezier_cmd = -1;
pending_moveto_cmd = -1;
back = false;
}
{
delete *i;
}
}
// debug function do dump the path contents on stdout
{
}
}
{
delete *i;
}
pending_bezier_cmd = -1;
pending_moveto_cmd = -1;
descr_flags = 0;
}
{
ResetPoints();
delete *i;
}
++i)
{
}
}
{
descr_flags &= ~(descr_doing_subpath);
pending_moveto_cmd = -1;
}
{
if (descr_flags & descr_adding_bezier) {
EndBezierTo ();
}
if ( (descr_flags & descr_doing_subpath) == 0 ) {
return -1;
}
return -1;
}
}
{
return;
}
ForcePoint();
return;
}
}
{
if ( descr_flags & descr_adding_bezier ) {
CancelBezier();
}
if ( descr_flags & descr_doing_subpath ) {
CloseSubpath();
} else {
// Nothing to close.
return -1;
}
descr_flags &= ~(descr_doing_subpath);
pending_moveto_cmd = -1;
}
{
if ( descr_flags & descr_adding_bezier ) {
}
if ( descr_flags & descr_doing_subpath ) {
CloseSubpath();
}
}
{
return;
}
return;
}
}
{
if (descr_flags & descr_adding_bezier) {
EndBezierTo (iPt);
}
if (!( descr_flags & descr_doing_subpath )) {
}
}
{
return;
}
return;
}
}
{
if (descr_flags & descr_adding_bezier) {
}
if ( (descr_flags & descr_doing_subpath) == 0) {
}
}
void Path::InsertCubicTo(Geom::Point const &iPt, Geom::Point const &iStD, Geom::Point const &iEnD, int at)
{
return;
}
return;
}
}
bool iLargeArc, bool iClockwise)
{
if (descr_flags & descr_adding_bezier) {
}
if ( (descr_flags & descr_doing_subpath) == 0 ) {
}
}
{
return;
}
return;
}
}
{
if (descr_flags & descr_adding_bezier) {
CancelBezier();
}
if ( (descr_flags & descr_doing_subpath) == 0) {
// No starting point -> bad.
return -1;
}
}
{
descr_flags &= ~(descr_adding_bezier);
descr_flags &= ~(descr_delayed_bezier);
if (pending_bezier_cmd < 0) {
return;
}
/* FIXME: I think there's a memory leak here */
pending_bezier_cmd = -1;
}
{
if (descr_flags & descr_delayed_bezier) {
CancelBezier ();
} else {
pending_bezier_cmd = -1;
descr_flags &= ~(descr_adding_bezier);
descr_flags &= ~(descr_delayed_bezier);
}
return -1;
}
{
if ( (descr_flags & descr_adding_bezier) == 0 ) {
}
if ( (descr_flags & descr_doing_subpath) == 0 ) {
}
if ( (descr_flags & descr_delayed_bezier) == 0 ) {
return EndBezierTo();
}
pending_bezier_cmd = -1;
descr_flags &= ~(descr_adding_bezier);
descr_flags &= ~(descr_delayed_bezier);
return -1;
}
{
if ( (descr_flags & descr_adding_bezier) == 0 ) {
}
if ( (descr_flags & descr_doing_subpath) == 0) {
}
}
{
return;
}
return;
}
}
{
if ( descr_flags & descr_adding_bezier ) {
}
if ( (descr_flags & descr_doing_subpath) == 0 ) {
}
descr_flags &= ~(descr_delayed_bezier);
}
{
return;
}
return;
}
}
/*
* points de la polyligne
*/
void
{
if (back == false) {
back = true;
ResetPoints();
back = false;
ResetPoints();
}
} else {
back = true;
ResetPoints();
back = false;
ResetPoints();
}
}
}
{
}
{
if (back) {
}
return -1;
}
return n;
}
{
return -1;
}
return n;
}
{
if (back == false) {
}
return -1;
}
return n;
}
{
if (back) {
}
return -1;
}
return n;
}
{
/* FIXME: ip & it aren't used. Is this deliberate? */
if (!back) {
return AddForcedPoint (iPt);
}
return -1;
}
return n;
}
{
l = t = r = b = 0.0;
return;
}
l = r = i->p[Geom::X];
t = b = i->p[Geom::Y];
++i;
}
}
/**
* \param piece Index of a one of our commands.
* \param at Distance along the segment that corresponds to `piece' (0 <= at <= 1)
* \param pos Filled in with the point at `at' on `piece'.
*/
{
// this shouldn't happen: the piece we are asked for doesn't
// exist in the path
return;
}
double len;
double rad;
if (typ == descr_moveto) {
} else if (typ == descr_lineto) {
} else if (typ == descr_arcto) {
} else if (typ == descr_cubicto) {
while (bez_st >= 0) {
if (nt == descr_bezierto)
break;
bez_st--;
}
if ( bez_st < 0 ) {
// Didn't find the beginning of the spline (bad).
// [pas trouvé le dubut de la spline (mauvais)]
}
// The spline goes past the authorized number of commands (bad).
// [la spline sort du nombre de commandes autorisé (mauvais)]
}
} else {
// forcement plus grand que 1
if (k == 1) {
PathDescrIntermBezierTo *prevI = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[bez_st + k - 1]);
} else {
PathDescrIntermBezierTo *prevI = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[bez_st + k - 1]);
PathDescrIntermBezierTo *nnextI = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[bez_st + k + 1]);
}
}
}
}
{
// this shouldn't happen: the piece we are asked for doesn't exist in the path
return;
}
double len;
double rad;
if (typ == descr_moveto) {
} else if (typ == descr_close ) {
cp--;
}
if ( cp >= 0 ) {
}
} else if ( typ == descr_forced) {
} else if (typ == descr_lineto) {
} else if (typ == descr_arcto) {
} else if (typ == descr_cubicto) {
while (bez_st >= 0) {
if (nt == descr_bezierto) break;
bez_st--;
}
if ( bez_st < 0 ) {
// Didn't find the beginning of the spline (bad).
// [pas trouvé le dubut de la spline (mauvais)]
}
// The spline goes past the number of authorized commands (bad).
// [la spline sort du nombre de commandes autorisé (mauvais)]
}
} else {
// forcement plus grand que 1
if (k == 1) {
PathDescrIntermBezierTo *prevI = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[bez_st + k - 1]);
} else {
PathDescrIntermBezierTo *prevI = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[bez_st + k - 1]);
PathDescrIntermBezierTo *nnextI = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[bez_st + k + 1]);
}
}
}
}
{
}
}
{
l = t = r = b = 0;
bool empty = true;
switch ( typ ) {
case descr_lineto:
{
if ( empty ) {
empty = false;
} else {
}
}
}
}
}
}
break;
case descr_moveto:
{
if ( empty ) {
empty = false;
} else {
}
}
}
}
}
}
break;
case descr_arcto:
{
if ( empty ) {
empty = false;
} else {
}
}
}
}
}
}
break;
case descr_cubicto:
{
if ( empty ) {
empty = false;
} else {
}
}
}
}
}
/* bug 249665: "...the calculation of the bounding-box for cubic-paths
has some extra steps to make it work corretly in Win32 that unfortunately
are unnecessary in Linux, generating wrong results. This only shows in
Type1 fonts because they use cubic-paths instead of the
bezier-paths used by True-Type fonts."
*/
#ifdef WIN32
}
}
}
}
}
}
}
}
#endif
}
break;
case descr_bezierto:
{
if ( empty ) {
empty = false;
} else {
}
}
}
}
}
}
break;
case descr_interm_bezier:
{
if ( empty ) {
empty = false;
} else {
}
}
}
}
}
}
break;
}
}
}
{
}
}
// Find out if the segment that corresponds to 'piece' is a straight line
{
return false;
}
return (typ == descr_lineto);
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :