sp-rect.cpp revision e918c2e4dcbcd27cf2a8259e53ba7b1196edb291
/*
* SVG <rect> implementation
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
*
* 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 "inkscape.h"
#include "document.h"
#include "attributes.h"
#include "style.h"
#include "sp-rect.h"
#include "sp-guide.h"
#include "preferences.h"
#define noRECT_VERBOSE
static void
{
}
}
}
static void
{
/* Initializing to zero is automatic */
/* sp_svg_length_unset(&rect->x, SP_SVG_UNIT_NONE, 0.0, 0.0); */
/* sp_svg_length_unset(&rect->y, SP_SVG_UNIT_NONE, 0.0, 0.0); */
/* sp_svg_length_unset(&rect->width, SP_SVG_UNIT_NONE, 0.0, 0.0); */
/* sp_svg_length_unset(&rect->height, SP_SVG_UNIT_NONE, 0.0, 0.0); */
/* sp_svg_length_unset(&rect->rx, SP_SVG_UNIT_NONE, 0.0, 0.0); */
/* sp_svg_length_unset(&rect->ry, SP_SVG_UNIT_NONE, 0.0, 0.0); */
}
}
/* fixme: We need real error processing some time */
switch (key) {
case SP_ATTR_X:
break;
case SP_ATTR_Y:
break;
case SP_ATTR_WIDTH:
}
break;
case SP_ATTR_HEIGHT:
}
break;
case SP_ATTR_RX:
}
break;
case SP_ATTR_RY:
}
break;
default:
break;
}
}
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
flags &= ~SP_OBJECT_USER_MODIFIED_FLAG_B; // since we change the description, it's not a "just translation" anymore
}
}
Inkscape::XML::Node * CRect::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
}
this->set_shape(); // evaluate SPCurve
return repr;
}
return g_strdup(_("<b>Rectangle</b>"));
}
#define C1 0.554
return;
}
double const w2 = w / 2;
double const h2 = h / 2;
: 0.0 ) ),
: 0.0 ) ),
/* TODO: Handle negative rx or ry as per
* http://www.w3.org/TR/SVG11/shapes.html#RectElementRXAttribute once Inkscape has proper error
* handling (see http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing).
*/
/* We don't use proper circular/elliptical arcs, but bezier curves can approximate a 90-degree
* arc fairly well.
*/
} else {
c->lineto(x + w, y + 0.0);
c->lineto(x + w, y + h);
c->lineto(x + 0.0, y + h);
}
c->closepath();
// LPE is not applied because result can generally not be represented as SPRect
c->unref();
}
/* fixme: Think (Lauris) */
this->x.computed = x;
this->y.computed = y;
}
if (set) {
}
}
if (set) {
}
}
/* Calculate rect start in parent coords. */
/* This function takes care of translation and scaling, we return whatever parts we can't
handle. */
if (sw > 1e-9) {
} else {
ret[0] = 1.0;
}
if (sh > 1e-9) {
} else {
}
/* fixme: Would be nice to preserve units here */
}
}
/* Find start in item coords */
this->set_shape();
// Adjust stroke width
// Adjust pattern fill
// Adjust gradient fill
return ret;
}
/**
Returns the ratio in which the vector from p0 to p1 is stretched by transform
*/
return 0;
}
}
if (rx == 0) {
} else {
this->transform);
}
this->updateRepr();
}
if (ry == 0) {
} else {
this->transform);
}
this->updateRepr();
}
return 0;
}
this->transform);
}
return 0;
}
this->transform);
}
Geom::Point p2 = Geom::Point(this->x.computed + this->width.computed, this->y.computed + this->height.computed);
}
return; // nothing to compensate
}
// test unit vectors to find out compensation:
// apply previous transform if any
c *= this->transform;
// find out stretches that we need to compensate
// If only one of the radii is set, set both radii so they have the same visible length
// This is needed because if we just set them the same length in SVG, they might end up unequal because of transform
} else {
}
// Note that a radius may end up larger than half-side if the rect is scaled down;
// that's ok because this preserves the intended radii in case the rect is enlarged again,
// and set_shape will take care of trimming too large radii when generating d=
}
this->transform);
this->updateRepr();
}
this->transform);
this->updateRepr();
}
return 0;
}
this->transform);
}
return 0;
}
this->transform);
}
void CRect::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) {
/* This method overrides sp_shape_snappoints, which is the default for any shape. The default method
returns all eight points along the path of a rounded rectangle, but not the real corners. Snapping
the startpoint and endpoint of each rounded corner is not very useful and really confusing. Instead
we could snap either the real corners, or not snap at all. Bulia Byak opted to snap the real corners,
but it should be noted that this might be confusing in some cases with relatively large radii. With
small radii though the user will easily understand which point is snapping. */
Geom::Point p2 = Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed) * i2dt;
p.push_back(Inkscape::SnapCandidatePoint(p0, Inkscape::SNAPSOURCE_RECT_CORNER, Inkscape::SNAPTARGET_RECT_CORNER));
p.push_back(Inkscape::SnapCandidatePoint(p1, Inkscape::SNAPSOURCE_RECT_CORNER, Inkscape::SNAPTARGET_RECT_CORNER));
p.push_back(Inkscape::SnapCandidatePoint(p2, Inkscape::SNAPSOURCE_RECT_CORNER, Inkscape::SNAPTARGET_RECT_CORNER));
p.push_back(Inkscape::SnapCandidatePoint(p3, Inkscape::SNAPSOURCE_RECT_CORNER, Inkscape::SNAPTARGET_RECT_CORNER));
}
p.push_back(Inkscape::SnapCandidatePoint((p0 + p1)/2, Inkscape::SNAPSOURCE_LINE_MIDPOINT, Inkscape::SNAPTARGET_LINE_MIDPOINT));
p.push_back(Inkscape::SnapCandidatePoint((p1 + p2)/2, Inkscape::SNAPSOURCE_LINE_MIDPOINT, Inkscape::SNAPTARGET_LINE_MIDPOINT));
p.push_back(Inkscape::SnapCandidatePoint((p2 + p3)/2, Inkscape::SNAPSOURCE_LINE_MIDPOINT, Inkscape::SNAPTARGET_LINE_MIDPOINT));
p.push_back(Inkscape::SnapCandidatePoint((p3 + p0)/2, Inkscape::SNAPSOURCE_LINE_MIDPOINT, Inkscape::SNAPTARGET_LINE_MIDPOINT));
}
p.push_back(Inkscape::SnapCandidatePoint((p0 + p2)/2, Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT));
}
}
void CRect::convert_to_guides() {
return;
}
Geom::Point A3(Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed) * i2dt);
}
/*
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 :