sp-ellipse.cpp revision d1d2f92b9650926225a68c89a7af3af5473a69c8
/*
* SVG <ellipse> and related implementations
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Mitsuru Oka
* bulia byak <buliabyak@users.sf.net>
* Abhishek Sharma
*
* Copyright (C) 1999-2002 Lauris Kaplinski
* Copyright (C) 2000-2001 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "svg/path-string.h"
#include "attributes.h"
#include "style.h"
#include "document.h"
#include "sp-ellipse.h"
#include "preferences.h"
#include "snap-candidate.h"
/* Common parent class */
#define noELLIPSE_VERBOSE
#include "sp-factory.h"
namespace {
SPObject* createEllipse() {
return new SPEllipse();
}
SPObject* createCircle() {
return new SPCircle();
}
return new SPArc();
}
}
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#if 1
/* Hmmm... shouldn't this also qualify */
/* Whether it is faster or not, well, nobody knows */
#define sp_round(v,m) (((v) < 0.0) ? ((ceil((v) / (m) - 0.5)) * (m)) : ((floor((v) / (m) + 0.5)) * (m)))
#else
/* we do not use C99 round(3) function yet */
static double sp_round(double x, double y)
{
double remain;
g_assert(y > 0.0);
/* return round(x/y) * y; */
if (remain >= 0.5*y)
return x - remain + y;
else
return x - remain;
}
#endif
this->citem = this;
this->cobject = this;
this->start = 0.0;
}
}
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
this->set_shape();
}
}
this->set_shape();
if (write) {
} else {
}
}
}
/* fixme: Think (Lauris) */
/* Can't we use arcto in this method? */
void SPGenericEllipse::set_shape() {
if (sp_lpe_item_has_broken_path_effect(this)) {
g_warning ("The ellipse shape has unknown LPE on it! Convert to path to make it editable preserving the appearance; editing it as ellipse will remove the bad LPE");
// unconditionally read the curve from d, if any, to preserve appearance
}
return;
}
double len;
// gint i;
return;
}
return;
}
sp_genericellipse_normalize(this);
// figure out if we have a slice, guarding against rounding errors
if (len < 0.0) {
}
} else {
}
e = s + M_PI_2;
if (e > this->end) {
e = this->end;
}
#ifdef ELLIPSE_VERBOSE
g_print("step %d s %f e %f coords %f %f %f %f %f %f\n",
#endif
}
}
if (this->closed) {
}
/* Reset the shape's curve to the "original_curve"
* This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/
this->setCurveBeforeLPE(curve);
if (sp_lpe_item_has_path_effect(this) && sp_lpe_item_path_effects_enabled(this)) {
if (success) {
}
}
}
void SPGenericEllipse::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) {
sp_genericellipse_normalize(this);
// figure out if we have a slice, while guarding against rounding errors
bool slice = false;
if (len < 0.0) {
}
slice = false;
} else {
slice = true;
}
// Snap to the 4 quadrant points of the this, but only if the arc
// spans far enough to include them
double angle = 0;
p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_ELLIPSE_QUADRANT_POINT, Inkscape::SNAPTARGET_ELLIPSE_QUADRANT_POINT));
}
}
}
// Add the centre, if we have a closed slice or when explicitly asked for
if (c1) {
p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP));
}
if (c2) {
p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT));
}
}
// And if we have a slice, also snap to the endpoints
// Add the start point, if it's not coincident with a quadrant point
p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP));
}
// Add the end point, if it's not coincident with a quadrant point
p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP));
}
}
}
void
{
}
if (diff >= 0.0) {
}
/* Now we keep: 0 <= start < end <= 2*PI */
}
Inkscape::XML::Node* SPGenericEllipse::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
if (flags & SP_OBJECT_WRITE_EXT) {
}
if (SP_IS_ARC(this)) {
}
}
this->set_shape(); // evaluate SPCurve
return repr;
}
/* SVG <ellipse> element */
this->citem = this;
this->cobject = this;
}
}
this->readAttr( "cx" );
this->readAttr( "cy" );
this->readAttr( "rx" );
this->readAttr( "ry" );
}
Inkscape::XML::Node* SPEllipse::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
}
return repr;
}
switch (key) {
case SP_ATTR_CX:
break;
case SP_ATTR_CY:
break;
case SP_ATTR_RX:
}
break;
case SP_ATTR_RY:
}
break;
default:
break;
}
}
return g_strdup(_("<b>Ellipse</b>"));
}
void
{
}
/* SVG <circle> element */
this->citem = this;
this->cobject = this;
}
}
this->readAttr( "cx" );
this->readAttr( "cy" );
this->readAttr( "r" );
}
Inkscape::XML::Node* SPCircle::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
}
return repr;
}
switch (key) {
case SP_ATTR_CX:
break;
case SP_ATTR_CY:
break;
case SP_ATTR_R:
}
break;
default:
break;
}
}
return g_strdup(_("<b>Circle</b>"));
}
/* <path sodipodi:type="arc"> element */
this->citem = this;
this->cobject = this;
}
}
this->readAttr( "sodipodi:cx" );
this->readAttr( "sodipodi:cy" );
this->readAttr( "sodipodi:rx" );
this->readAttr( "sodipodi:ry" );
this->readAttr( "sodipodi:start" );
this->readAttr( "sodipodi:end" );
this->readAttr( "sodipodi:open" );
}
/*
* sp_arc_set_elliptical_path_attribute:
*
* Convert center to endpoint parameterization and set it to repr.
*
* See SVG 1.0 Specification W3C Recommendation
* ``F.6 Ellptical arc implementation notes'' for more detail.
*/
static gboolean
{
.closePath();
} else {
}
}
return true;
}
Inkscape::XML::Node* SPArc::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
}
if (flags & SP_OBJECT_WRITE_EXT) {
// write start and end only if they are non-trivial; otherwise remove
if (len < 0.0) {
}
} else {
}
}
// write d=
return repr;
}
switch (key) {
case SP_ATTR_SODIPODI_CX:
break;
case SP_ATTR_SODIPODI_CY:
break;
case SP_ATTR_SODIPODI_RX:
}
break;
case SP_ATTR_SODIPODI_RY:
}
break;
case SP_ATTR_SODIPODI_START:
if (value) {
} else {
this->start = 0;
}
break;
case SP_ATTR_SODIPODI_END:
if (value) {
} else {
}
break;
case SP_ATTR_SODIPODI_OPEN:
break;
default:
break;
}
}
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
this->set_shape();
}
}
if (len < 0.0) {
}
if (this->closed) {
return g_strdup(_("<b>Segment</b>"));
} else {
return g_strdup(_("<b>Arc</b>"));
}
} else {
return g_strdup(_("<b>Ellipse</b>"));
}
}
void
{
// those pref values are in degrees, while we want radians
else
}
{
}
/*
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 :