sp-rect.cpp revision 72ea4c0c8c73f2159bd19761dd1fb0fcf8ceb4f9
#define __SP_RECT_C__
/*
* 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 <libnr/nr-matrix-div.h>
#include <libnr/nr-matrix-fns.h>
#include "document.h"
#include "attributes.h"
#include "style.h"
#include "sp-rect.h"
#include "sp-guide.h"
#include "prefs-utils.h"
#define noRECT_VERBOSE
static Inkscape::XML::Node *sp_rect_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
static SPShapeClass *parent_class;
sp_rect_get_type(void)
{
if (!type) {
sizeof(SPRectClass),
NULL, /* base_init */
NULL, /* base_finalize */
NULL, /* class_finalize */
NULL, /* class_data */
sizeof(SPRect),
16, /* n_preallocs */
NULL, /* value_table */
};
}
return type;
}
static void
{
item_class->snappoints = sp_rect_snappoints; //override the default sp_shape_snappoints; see sp_rect_snappoints for details
}
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); */
}
static void
{
/* 0.29 treated 0.0 radius as missing value */
}
}
}
}
static void
{
/* 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;
}
}
static void
{
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
}
}
{
}
return repr;
}
static gchar *
{
return g_strdup(_("<b>Rectangle</b>"));
}
#define C1 0.554
static void
{
SPCurve *c = sp_curve_new();
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.
*/
sp_curve_moveto(c, x + rx, y);
} else {
sp_curve_lineto(c, x + w, y + 0.0);
sp_curve_lineto(c, x + w, y + h);
sp_curve_lineto(c, x + 0.0, y + h);
}
sp_curve_unref(c);
}
/* fixme: Think (Lauris) */
void
{
}
void
{
}
void
{
}
/*
* Initially we'll do:
* Transform x, y, set x, y, clear translation
*/
/* fixme: Use preferred units somehow (Lauris) */
/* fixme: Alternately preserve whatever units there are (lauris) */
{
/* 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 */
// 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
*/
static gdouble
{
return 0;
}
void
{
if (rx == 0) {
} else {
}
}
void
{
if (ry == 0) {
} else {
}
}
{
return 0;
}
{
return 0;
}
void
{
return; // nothing to compensate
// test unit vectors to find out compensation:
// apply previous transform if any
// 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=
}
void
{
}
void
{
}
{
return 0;
}
{
return 0;
}
/**
* Sets the snappoint p to the unrounded corners of the rectangle
*/
{
/* 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 usefull 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. */
*p = NR::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed) * i2d;
}
void
return;
}
NR::Point A3(NR::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed) * i2d);
if (write_undo) {
}
}
/*
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 :