18#include <glibmm/i18n.h>
34#define SP_2PI (2 * M_PI)
55 const std::string typeString = newname;
56 if (typeString ==
"svg:circle") {
58 }
else if (typeString ==
"svg:ellipse") {
60 }
else if (typeString ==
"svg:path") {
98 std::cerr <<
"SPGenericEllipse::build() unknown defined type." << std::endl;
117 double const d = hypot(
w, h) / sqrt(2);
119 double const ex = em * 0.5;
170 this->
end = 2 * M_PI;
177 if ((!value) || strcmp(value,
"true")) {
192 if (!strcmp(value,
"arc")) {
194 }
else if (!strcmp(value,
"chord")) {
212 if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
215 double const dx = viewbox.
width();
216 double const dy = viewbox.
height();
217 double const dr = hypot(dx, dy) / sqrt(2);
219 double const ex = em * 0.5;
249 if ((flags & SP_OBJECT_WRITE_BUILD) && !
repr) {
251 switch ( new_type ) {
264 std::cerr <<
"SPGenericEllipse::write(): unknown type." << std::endl;
268 if (
type != new_type) {
280 std::cerr <<
"SPGenericEllipse::write(): unknown type." << std::endl;
292 auto const save_cx =
cx;
293 auto const save_cy =
cy;
294 auto const save_rx =
rx;
295 auto const save_ry =
ry;
307 if (flags & SP_OBJECT_WRITE_EXT) {
335 std::cerr <<
"SPGenericEllipse::write: unknown arc-type." << std::endl;
386 std::cerr <<
"SPGenericEllipse::write: unknown type." << std::endl;
432 return "Unknown ellipse: ERROR";
458 if (incr < 0.0) incr += 2.0*M_PI;
460 int numsegs = 1 + int(incr*2.0/M_PI);
461 if (numsegs > 4) numsegs = 4;
466 for (
int seg = 0; seg < numsegs; seg++) {
467 arc = circle.arc(Geom::Point::polar(
start + seg*incr), Geom::Point::polar(
start + (seg + 0.5)*incr), Geom::Point::polar(
start + (seg + 1.0)*incr));
507 gdouble
const sw = hypot(ret[0], ret[1]);
508 gdouble
const sh = hypot(ret[2], ret[3]);
542 if (!g_strcmp0(
getAttribute(
"sodipodi:arc-type"),
"slice") ||
543 !g_strcmp0(
getAttribute(
"sodipodi:arc-type"),
"chord") ||
570 for (
double angle = 0; angle < SP_2PI; angle += M_PI_2) {
614 if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
670 if (prefs->
getDouble(
"/tools/shapes/arc/start", 0.0) != 0) {
674 if (prefs->
getDouble(
"/tools/shapes/arc/end", 0.0) != 0) {
Various trigoniometric helper functions.
Lookup dictionary for attributes/properties.
3x3 matrix representing an affine transformation.
Coord descrim() const
Calculate the descriminant.
Affine inverse() const
Compute the inverse matrix.
Affine withoutTranslation() const
Directed angular interval.
Angle finalAngle() const
Get the end angle.
Coord extent() const
Extent of the angle interval.
Angle initialAngle() const
Get the start angle.
static Angle from_degrees(Coord d)
Create an angle from its measure in degrees.
Coord radians0() const
Get the angle as positive radians.
Set of all points at a fixed distance from the center.
C height() const
Get the vertical extent of the rectangle.
C width() const
Get the horizontal extent of the rectangle.
Store paths to a PathVector.
PathVector const & peek() const
Retrieve the path.
void append(Path const &other)
void lineTo(Point const &p) override
Output a line segment.
void flush() override
Flush any internal state of the generator.
void closePath() override
Close the current path with a line segment.
Sequence of contiguous curves, aka spline.
void append(Curve *curve)
Add a new curve to the end of the path.
Two-dimensional point that doubles as a vector.
Axis aligned, non-empty rectangle.
Preference storage class.
double getDouble(Glib::ustring const &pref_path, double def=0.0, Glib::ustring const &unit="")
Retrieve a floating point value.
static Preferences * get()
Access the singleton Preferences object.
int getInt(Glib::ustring const &pref_path, int def=0)
Retrieve an integer.
Storing of snapping preferences.
bool isTargetSnappable(Inkscape::SnapTargetType const target) const
Interface for refcounted XML nodes.
bool setAttributeSvgLength(Util::const_char_ptr key, SVGLength const &val)
virtual void setCodeUnsafe(int code)=0
Set the integer GQuark code for the name of the node.
void setAttribute(Util::const_char_ptr key, Util::const_char_ptr value)
Change an attribute of this node.
void removeAttribute(Inkscape::Util::const_char_ptr key)
Remove an attribute of this node.
bool setAttributeSvgDouble(Util::const_char_ptr key, double val)
For attributes where an exponent is allowed.
Wrapper around a Geom::PathVector object.
Typed SVG document implementation.
~SPGenericEllipse() override
const char * displayName() const override
The item's type name as a translated human string.
Geom::Point getPointAtAngle(double arg) const
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override
void modified(unsigned int flags) override
double getVisibleRy() const
void setVisibleRy(double ry)
void update_patheffect(bool write) override
void tag_name_changed(gchar const *oldname, gchar const *newname) override
void normalize()
Makes sure that start and end lie between 0 and 2 * PI.
void set_shape() override
void position_set(double x, double y, double rx, double ry)
bool set_elliptical_path_attribute(Inkscape::XML::Node *repr)
Geom::Affine set_transform(Geom::Affine const &xform) override
bool _isSlice() const
Determines whether the shape is a part of an ellipse.
void update(SPCtx *ctx, unsigned int flags) override
void setVisibleRx(double rx)
void build(SPDocument *document, Inkscape::XML::Node *repr) override
void set(SPAttr key, char const *value) override
const char * typeName() const override
The item's type name, not node tag name.
double getVisibleRx() const
GenericEllipseArcType arc_type
void snappoints(std::vector< Inkscape::SnapCandidatePoint > &p, Inkscape::SnapPreferences const *snapprefs) const override
Geom::Affine i2dt_affine() const
Returns the transformation from item to desktop coords.
void adjust_gradient(Geom::Affine const &postmul, bool set=false)
void adjust_stroke_width_recursive(double ex)
Recursively scale stroke width in item and its children by expansion.
void adjust_pattern(Geom::Affine const &postmul, bool set=false, PaintServerTransform=TRANSFORM_BOTH)
void adjust_stroke(double ex)
Geom::Affine i2doc_affine() const
Returns the accumulated transformation of the item and all its ancestors, including root's viewport.
bool hasPathEffectOnClipOrMaskRecursive(SPLPEItem *shape) const
returns true when any LPE apply to clip or mask.
bool pathEffectsEnabled() const
bool optimizeTransforms()
returns false when LPE write unoptimiced
Inkscape::XML::Node * repr
SPStyle * style
Represents the style properties, whether from presentation attributes, the style attribute,...
Inkscape::XML::Node * updateRepr(unsigned int flags=SP_OBJECT_WRITE_EXT)
Updates the object's repr based on the object's state.
void readAttr(char const *key)
Read value of key attribute from XML node into object.
char const * getAttribute(char const *name) const
void requestDisplayUpdate(unsigned int flags)
Queues an deferred update of this object's display.
Base class for shapes, including <path> element.
void update(SPCtx *ctx, unsigned int flags) override
void setCurveInsync(SPCurve const *)
bool prepareShapeForLPE(SPCurve const *c)
void modified(unsigned int flags) override
void set(SPAttr key, char const *value) override
void build(SPDocument *document, Inkscape::XML::Node *repr) override
void update_patheffect(bool write) override
std::shared_ptr< SPCurve const > _curve
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override
bool checkBrokenPathEffect()
T< SPAttr::FONT_SIZE, SPIFontSize > font_size
Size of the font.
void readOrUnset(char const *str, Unit u=NONE, float v=0, float c=0)
void unset(Unit u=NONE, float v=0, float c=0)
void update(double em, double ex, double scale)
constexpr Coord EPSILON
Default "acceptably small" value.
bool are_near(Affine const &a1, Affine const &a2, Coord eps=EPSILON)
@ SNAPSOURCE_OBJECT_MIDPOINT
@ SNAPSOURCE_ELLIPSE_QUADRANT_POINT
@ SNAPTARGET_ELLIPSE_QUADRANT_POINT
@ SNAPTARGET_OBJECT_MIDPOINT
static cairo_user_data_key_t key
callback interface for SVG path data
Singleton class to access the preferences file in a convenient way.
Some utility classes to store various kinds of snap candidates.
static double vectorStretch(Geom::Point const &n, Geom::Affine const &trans)
Returns the ratio in which a unit vector n is stretched by transform.
@ SP_GENERIC_ELLIPSE_ARC_TYPE_CHORD
@ SP_GENERIC_ELLIPSE_ARC_TYPE_SLICE
@ SP_GENERIC_ELLIPSE_ARC_TYPE_ARC
@ SP_GENERIC_ELLIPSE_CIRCLE
@ SP_GENERIC_ELLIPSE_UNDEFINED
@ SP_GENERIC_ELLIPSE_ELLIPSE
Interface for XML documents.
virtual Node * createElement(char const *name)=0
Contains transformations to document/viewport and the viewport size.
SPStyle - a style object for SPItem objects.
unsigned int sp_svg_number_read_d(gchar const *str, double *val)
static void sp_svg_write_path(Inkscape::SVG::PathString &str, Geom::Path const &p, bool normalize=false)