~centralelyon2010/inkscape/imagelinks2

« back to all changes in this revision

Viewing changes to src/knotholder.cpp

  • Committer: JazzyNico
  • Date: 2011-08-29 20:25:30 UTC
  • Revision ID: nicoduf@yahoo.fr-20110829202530-6deuoz11q90usldv
Code refactoring and merging with trunk (revision 10599).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#define __KNOT_HOLDER_C__
2
 
 
3
1
/*
4
2
 * Container for SPKnot visual handles
5
3
 *
7
5
 *   Mitsuru Oka <oka326@parkcity.ne.jp>
8
6
 *   bulia byak <buliabyak@users.sf.net>
9
7
 *   Maximilian Albert <maximilian.albert@gmail.com>
 
8
 *   Abhishek Sharma
10
9
 *
11
10
 * Copyright (C) 2001-2008 authors
12
11
 *
13
12
 * Released under GNU GPL, read the file 'COPYING' for more information
14
13
 */
15
14
 
 
15
#include <glibmm/i18n.h>
 
16
 
16
17
#include "document.h"
17
18
#include "sp-shape.h"
18
19
#include "knot.h"
36
37
 
37
38
#include "xml/repr.h" // for debugging only
38
39
 
39
 
#include <glibmm/i18n.h>
 
40
using Inkscape::DocumentUndo;
40
41
 
41
42
class SPDesktop;
42
43
 
43
44
KnotHolder::KnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler)
44
45
{
45
 
    Inkscape::XML::Node *repr = SP_OBJECT(item)->repr;
 
46
    //XML Tree being used directly here while it shouldn't be...
 
47
    Inkscape::XML::Node *repr = item->getRepr();
46
48
 
47
49
    if (!desktop || !item || !SP_IS_ITEM(item)) {
48
50
        g_print ("Error! Throw an exception, please!\n");
83
85
void
84
86
KnotHolder::update_knots()
85
87
{
86
 
    Geom::Matrix const i2d(sp_item_i2d_affine(item));
87
 
 
88
88
    for(std::list<KnotHolderEntity *>::iterator i = entity.begin(); i != entity.end(); ++i) {
89
89
        KnotHolderEntity *e = *i;
90
90
        e->update_knot();
121
121
    }
122
122
 
123
123
    if (SP_IS_SHAPE(item)) {
124
 
        sp_shape_set_shape(SP_SHAPE(item));
 
124
        SP_SHAPE(item)->setShape();
125
125
    }
126
126
 
127
127
    knot_holder->update_knots();
146
146
    }
147
147
 
148
148
    // for drag, this is done by ungrabbed_handler, but for click we must do it here
149
 
    sp_document_done(SP_OBJECT_DOCUMENT(item), object_verb,
150
 
                     _("Change handle"));
 
149
    DocumentUndo::done(item->document, object_verb,
 
150
                       _("Change handle"));
151
151
}
152
152
 
153
153
void
163
163
    for(std::list<KnotHolderEntity *>::iterator i = this->entity.begin(); i != this->entity.end(); ++i) {
164
164
        KnotHolderEntity *e = *i;
165
165
        if (e->knot == knot) {
166
 
            Geom::Point const q = p * sp_item_i2d_affine(item).inverse();
167
 
            e->knot_set(q, e->knot->drag_origin * sp_item_i2d_affine(item).inverse(), state);
 
166
            Geom::Point const q = p * item->i2dt_affine().inverse();
 
167
            e->knot_set(q, e->knot->drag_origin * item->i2dt_affine().inverse(), state);
168
168
            break;
169
169
        }
170
170
    }
171
171
 
172
172
    if (SP_IS_SHAPE (item)) {
173
 
        sp_shape_set_shape(SP_SHAPE (item));
 
173
        SP_SHAPE (item)->setShape();
174
174
    }
175
175
 
176
176
    this->update_knots();
202
202
            Inkscape::LivePathEffect::Effect *lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(object));
203
203
            if (lpe) {
204
204
                LivePathEffectObject *lpeobj = lpe->getLPEObj();
205
 
                SP_OBJECT(lpeobj)->updateRepr();
 
205
                lpeobj->updateRepr();
206
206
            }
207
207
        }
208
208
 
225
225
                object_verb = SP_VERB_SELECTION_DYNAMIC_OFFSET;
226
226
        }
227
227
 
228
 
        sp_document_done(SP_OBJECT_DOCUMENT (object), object_verb,
229
 
                         _("Move handle"));
 
228
        DocumentUndo::done(object->document, object_verb,
 
229
                           _("Move handle"));
230
230
    }
231
231
}
232
232
 
239
239
void
240
240
KnotHolder::add_pattern_knotholder()
241
241
{
242
 
    if ((SP_OBJECT(item)->style->fill.isPaintserver())
243
 
        && SP_IS_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style)))
 
242
    if ((item->style->fill.isPaintserver())
 
243
        && SP_IS_PATTERN(item->style->getFillPaintServer()))
244
244
    {
245
245
        PatternKnotHolderEntityXY *entity_xy = new PatternKnotHolderEntityXY();
246
246
        PatternKnotHolderEntityAngle *entity_angle = new PatternKnotHolderEntityAngle();
270
270
  fill-column:99
271
271
  End:
272
272
*/
273
 
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 
273
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :