sp-item-group.cpp revision 0de73848362e95b081e5fa85f910d6481094b2b9
/*
* SVG <g> implementation
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
* Jon A. Cruz <jon@joncruz.org>
* Abhishek Sharma
*
* Copyright (C) 1999-2006 authors
* 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 <cstring>
#include <string>
#include "display/drawing-group.h"
#include "document.h"
#include "document-undo.h"
#include "style.h"
#include "attributes.h"
#include "sp-item-transform.h"
#include "sp-root.h"
#include "sp-use.h"
#include "sp-offset.h"
#include "sp-clippath.h"
#include "sp-mask.h"
#include "sp-path.h"
#include "box3d.h"
#include "persp3d.h"
#include "inkscape.h"
#include "selection.h"
#include "live_effects/effect.h"
#include "live_effects/lpeobject.h"
#include "live_effects/lpeobject-reference.h"
#include "sp-title.h"
#include "sp-desc.h"
#include "sp-switch.h"
#include "sp-defs.h"
#include "verbs.h"
#include "layer-model.h"
#include "sp-textpath.h"
#include "sp-flowtext.h"
using Inkscape::DocumentUndo;
#include "sp-factory.h"
namespace {
SPObject* createGroup() {
return new SPGroup();
}
}
}
}
this->readAttr( "inkscape:groupmode" );
}
}
}
// optimization for the common special case where the child is being added at the end
if ( item ) {
/* TODO: this should be moved into SPItem somehow */
SPItemView *v;
if (ac) {
}
}
}
} else { // general case
if ( item ) {
/* TODO: this should be moved into SPItem somehow */
SPItemView *v;
if (ac) {
}
}
}
}
}
/* fixme: hide (Lauris) */
}
void SPGroup::order_changed (Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref)
{
if ( item ) {
/* TODO: this should be moved into SPItem somehow */
SPItemView *v;
}
}
}
// std::cout << "SPGroup::update(): " << (getId()?getId():"null") << std::endl;
unsigned childflags = flags;
if (flags & SP_OBJECT_MODIFIED_FLAG) {
}
l.reverse();
if (item) {
} else {
}
}
}
// For a group, we need to update ourselves *after* updating children.
// this is because the group might contain shapes such as rect or ellipse,
// which recompute their equivalent path (a.k.a curve) in the update callback,
// and this is in turn used when computing bbox.
if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) {
if( this->parent ) {
}
}
}
}
// std::cout << "SPGroup::modified(): " << (getId()?getId():"null") << std::endl;
if (flags & SP_OBJECT_MODIFIED_FLAG) {
}
SelContainer l=this->childList(true);
l.reverse();
}
}
}
Inkscape::XML::Node* SPGroup::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
if (flags & SP_OBJECT_WRITE_BUILD) {
if (!repr) {
if (dynamic_cast<SPSwitch *>(this)) {
} else {
}
}
l = NULL;
if (crepr) {
l = g_slist_prepend (l, crepr);
}
}
}
while (l) {
l = g_slist_remove (l, l->data);
}
} else {
}
}
}
if ( flags & SP_OBJECT_WRITE_EXT ) {
const char *value;
value = "layer";
value = "maskhelper";
} else if ( flags & SP_OBJECT_WRITE_ALL ) {
value = "group";
} else {
}
}
return repr;
}
{
// TODO CPPIFY: replace this const_cast later
}
}
return bbox;
}
SelContainer l=this->childList(false);
l.reverse();
if (item) {
}
}
}
const char *SPGroup::displayName() const {
return _("Group");
}
return g_strdup_printf(
}
switch (key) {
} else {
}
break;
default:
break;
}
}
Inkscape::DrawingItem *SPGroup::show (Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) {
// std::cout << "SPGroup::show(): " << (getId()?getId():"null") << std::endl;
if( this->parent ) {
}
return ai;
}
l.reverse();
if (item) {
}
}
// SPLPEItem::onHide(key);
}
void SPGroup::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const {
{
if (item) {
}
}
}
void
{
{
if (box) {
}
}
group->removeAllPathEffects(false);
/* Step 1 - generate lists of children objects */
if (citem) {
/* Merging of style */
// it here _before_ the new transform is set, so as to use the pre-transform bbox
/*
* fixme: We currently make no allowance for the case where child is cloned
* and the group has any style settings.
*
* (This should never occur with documents created solely with the current
* version of inkscape without using the XML editor: we usually apply group
* style changes to children rather than to the group itself.)
*
* If the group has no style settings, then style->merge() should be a no-op. Otherwise
* (i.e. if we change the child's style to compensate for its parent going away)
* then those changes will typically be reflected in any clones of child,
* whereas we'd prefer for Ungroup not to affect the visual appearance.
*
* The only way of preserving styling appearance in general is for child to
* be put into a new group -- a somewhat surprising response to an Ungroup
* command. We could add a new groupmode:transparent that would mostly
* hide the existence of such groups from the user (i.e. editing behaves as
* if the transparent group's children weren't in a group), though that's
* extra complication & maintenance burden and this case is rare.
*/
child->updateRepr();
// Merging transform
// make sure a clone's effective transform is the same as was under group
} else {
// We should not apply the group's transformation to both a linked offset AND to its source
if (dynamic_cast<SPOffset *>(citem)) { // Do we have an offset at hand (whether it's dynamic or linked)?
// When dealing with a chain of linked offsets, the transformation of an offset will be
// tied to the transformation of the top-most source, not to any of the intermediate
// offsets. So let's find the top-most source
}
ctrans = citem->transform * g; // then we should apply the transformation of the group to the offset
} else {
}
} else {
}
}
// FIXME: constructing a transform that would fully preserve the appearance of a
// textpath if it is ungrouped with its path seems to be impossible in general
// case. E.g. if the group was squeezed, to keep the ungrouped textpath squeezed
// as well, we'll need to relink it to some "virtual" path which is inversely
// stretched relative to the actual path, and then squeeze the textpath back so it
// would both fit the actual path _and_ be squeezed as before. It's a bummer.
// This is just a way to temporarily remember the transform in repr. When repr is
// reattached outside of the group, the transform will be written more properly
// (i.e. optimized into the object if the corresponding preference is set)
} else {
}
}
/* Step 2 - clear group */
// remember the position of the group
// the group is leaving forever, no heir, clones should take note; its children however are going to reemerge
group->deleteObject(true, false);
/* Step 3 - add nonitems */
if (objects) {
while (objects) {
if (!sp_repr_is_meta_element(repr)) {
}
}
}
/* Step 4 - add items */
while (items) {
// add item
// restore position; since the items list was prepended (i.e. reverse), we now add
// all children at the same pos, which inverts the order once again
// fill in the children list if non-null
if (item) {
} else {
}
}
}
if (do_done) {
}
}
/*
* some API for list aspect of SPGroup
*/
{
SelContainer s;
if ( dynamic_cast<SPItem *>(o) ) {
s.push_front(o);
}
}
s.reverse();
return s;
}
{
}
return child;
}
if ( _layer_mode != mode ) {
} else if ( _layer_mode == LAYER ) {
}
_layer_mode = mode;
}
}
} else {
return GROUP;
}
}
if ( _expanded != isexpanded ){
}
}
if ( _insertBottom != insertbottom) {
}
}
}
}
if (g) {
}
}
}
}
{
if ( hasChildren() ) {
if ( item ) {
}
}
}
}
// Recursively (or not) scale child items around a point
{
if ( hasChildren() ) {
if ( SPDefs *defs = dynamic_cast<SPDefs *>(o) ) { // select symbols from defs, ignore clips, masks, patterns
if (defsgroup)
}
/* Using recursion breaks clipping because transforms are applied
in coordinates for draws but nothing in defs is changed
instead change the transform on the entire group, and the transform
is applied after any references to clipping paths. However NOT using
recursion apparently breaks as of r13544 other parts of Inkscape
in different contexts.
*/
if(noRecurse) {
// used for EMF import
// When the rounding error persists it converts the simple
// transform=scale() to transform=matrix().
}
} else {
// used for other import
}
}
}
}
}
} else {
// Geom::OptRect bbox = item->desktopVisualBounds();
// if (bbox) { // test not needed, this was causing a failure to scale <circle> and <rect> in the clipboard, see LP Bug 1365451
// Scale item
bool isTextTextpath = textItem && textItem->firstChild() && dynamic_cast<SPTextPath *>(textItem->firstChild());
if (isTextTextpath) {
} else {
if (flowText) {
} else {
if (box) {
// Force recalculation from perspective
// Remove and store connector type for transform if disconnected
}
}
}
if (persp) {
// Save and reset current transform
// Apply scale
// Scale translation and restore original transform
// calculate the matrix we need to apply to the clone
// to cancel its induced transform from its original
} else {
}
}
item->updateRepr();
}
// }
}
}
}
}
}
if (dynamic_cast<SPItem const *>(o)) {
len++;
}
}
return len;
}
void SPGroup::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) {
l.reverse();
if (child) {
if (ac) {
}
}
}
}
#ifdef GROUP_VERBOSE
#endif
if (lpeItem) {
}
}
if (hasPathEffect() && pathEffectsEnabled()) {
for (PathEffectList::iterator it = this->path_effect_list->begin(); it != this->path_effect_list->end(); it++)
{
}
}
sp_group_perform_patheffect(this, this, write);
}
}
static void
{
if (subGroup) {
} else {
if (subShape) {
if (subPath) {
c = subPath->get_original_curve();
} else {
}
// only run LPEs when the shape has a curve defined
if (c) {
if (write) {
#ifdef GROUP_VERBOSE
g_message("sp_group_perform_patheffect writes 'd' attribute");
#endif
}
c->unref();
}
}
}
}
}
/*
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 :