path-sink.h revision 684a5fa4464dc8650d34718e955869846b34bb3f
/**
* \file
* \brief callback interface for SVG path data
*//*
* Copyright 2007 MenTaLguY <mental@rydia.net>
*
* modify it either under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* (the "LGPL") or, at your option, under the terms of the Mozilla
* Public License Version 1.1 (the "MPL"). If you do not alter this
* notice, a recipient may use your version of this file under either
* the MPL or the LGPL.
*
* You should have received a copy of the LGPL along with this library
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* You should have received a copy of the MPL along with this library
* in the file COPYING-MPL-1.1
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
* the specific language governing rights and limitations.
*
*/
#ifndef LIB2GEOM_SEEN_PATH_SINK_H
#define LIB2GEOM_SEEN_PATH_SINK_H
#include <iterator>
/** @brief Callback interface for processing path data.
*
* PathSink provides an interface that allows one to easily write
* code which processes path data, for instance when converting
* between path formats used by different graphics libraries.
* It is also useful for writing algorithms which must do something
* for each curve in the path.
*
* To store a path in a new format, implement the virtual methods
* for segments in a derived class and call feed().
*
* @ingroup Paths
*/
/** @brief Move to a different point without creating a segment.
* Usually starts a new subpath. */
/// Output a line segment.
/// Output a quadratic Bezier segment.
/// Output a cubic Bezier segment.
/** @brief Output an elliptical arc segment.
* See the EllipticalArc class for the documentation of parameters. */
/// Close the current path with a line segment.
/** @brief Flush any internal state of the generator.
* This call should implicitly finish the current subpath.
* Calling this method should be idempotent, because the default
* implementations of path() and pathvector() will call it
* multiple times in a row. */
// Get the current point, e.g. where the initial point of the next segment will be.
//virtual Point currentPoint() const = 0;
/** @brief Undo the last segment.
* This method is optional.
* @return true true if a segment was erased, false otherwise. */
// these have a default implementation
/** @brief Output a subpath.
* Calls the appropriate segment methods according to the contents
* of the passed subpath. You can override this function.
* NOTE: if you override only some of the feed() functions,
* always write this in the derived class:
* @code
using PathSink::feed;
@endcode
* Otherwise the remaining methods will be hidden. */
/** @brief Output a path.
* Calls feed() on each path in the vector. You can override this function. */
/// Output an axis-aligned rectangle, using moveTo, lineTo and closePath.
};
/** @brief Store paths to an output iterator
* @ingroup Paths */
flush();
_start_p = p;
_in_path = true;
}
//TODO: what if _in_path = false?
// check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z"
if (!_in_path) {
}
}
// check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z"
if (!_in_path) {
}
}
// check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z"
if (!_in_path) {
}
}
{
// check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z"
if (!_in_path) {
}
}
bool backspace()
{
_path.erase_last();
return true;
}
return false;
}
{
if (!_in_path) {
}
}
void closePath() {
flush();
}
void flush() {
if (_in_path) {
_in_path = false;
}
}
void setStitching(bool s) {
_path.setStitching(s);
}
{
flush();
}
bool _in_path;
};
/** @brief Store paths to a PathVector
* @ingroup Paths */
/// Create a builder that outputs to an internal pathvector.
/// Create a builder that outputs to pathvector given by reference.
/// Retrieve the path
/// Clear the stored path vector
};
}
#endif
/*
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:fileencoding=utf-8:textwidth=99 :