~centralelyon2010/inkscape/imagelinks2

« back to all changes in this revision

Viewing changes to src/dropper-context.cpp

  • Committer: cilix42
  • Date: 2008-09-18 17:48:42 UTC
  • Revision ID: cilix42@users.sourceforge.net-20080918174842-1ad33a7d7gqhv2hq
Next roud of NR ==> Geom conversion

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
 
42
42
#include "dropper-context.h"
43
43
#include "message-context.h"
44
 
#include "libnr/nr-scale-translate-ops.h"
 
44
//#include "libnr/nr-scale-translate-ops.h"
45
45
 
46
46
static void sp_dropper_context_class_init(SPDropperContextClass *klass);
47
47
static void sp_dropper_context_init(SPDropperContext *dc);
164
164
    switch (event->type) {
165
165
        case GDK_BUTTON_PRESS:
166
166
            if (event->button.button == 1 && !event_context->space_panning) {
167
 
                dc->centre = NR::Point(event->button.x, event->button.y);
 
167
                dc->centre = Geom::Point(event->button.x, event->button.y);
168
168
                dc->dragging = TRUE;
169
169
                ret = TRUE;
170
170
            }
184
184
                    // calculate average
185
185
 
186
186
                    // radius
187
 
                    rw = std::min(NR::L2(NR::Point(event->button.x, event->button.y) - dc->centre), 400.0);
 
187
                    rw = std::min(Geom::L2(Geom::Point(event->button.x, event->button.y) - dc->centre), 400.0);
188
188
 
189
189
                    if (rw == 0) { // happens sometimes, little idea why...
190
190
                        break;
191
191
                    }
192
192
 
193
 
                    NR::Point const cd = desktop->w2d(dc->centre);
194
 
                    NR::Matrix const w2dt = desktop->w2d();
195
 
                    const double scale = rw * NR::expansion(w2dt);
196
 
                    NR::Matrix const sm( NR::scale(scale, scale) * NR::translate(cd) );
 
193
                    Geom::Point const cd = desktop->w2d(dc->centre);
 
194
                    Geom::Matrix const w2dt = desktop->w2d();
 
195
                    const double scale = rw * w2dt.descrim();
 
196
                    Geom::Matrix const sm( Geom::Scale(scale, scale) * Geom::Translate(cd) );
197
197
                    sp_canvas_item_affine_absolute(dc->area, sm);
198
198
                    sp_canvas_item_show(dc->area);
199
199
 
200
200
                    /* Get buffer */
201
 
                    const int x0 = (int) floor(dc->centre[NR::X] - rw);
202
 
                    const int y0 = (int) floor(dc->centre[NR::Y] - rw);
203
 
                    const int x1 = (int) ceil(dc->centre[NR::X] + rw);
204
 
                    const int y1 = (int) ceil(dc->centre[NR::Y] + rw);
 
201
                    const int x0 = (int) floor(dc->centre[Geom::X] - rw);
 
202
                    const int y0 = (int) floor(dc->centre[Geom::Y] - rw);
 
203
                    const int x1 = (int) ceil(dc->centre[Geom::X] + rw);
 
204
                    const int y1 = (int) ceil(dc->centre[Geom::Y] + rw);
205
205
 
206
206
                    if ((x1 > x0) && (y1 > y0)) {
207
207
                        NRPixBlock pb;
211
211
                        for (int y = y0; y < y1; y++) {
212
212
                            const unsigned char *s = NR_PIXBLOCK_PX(&pb) + (y - y0) * pb.rs;
213
213
                            for (int x = x0; x < x1; x++) {
214
 
                                const double dx = x - dc->centre[NR::X];
215
 
                                const double dy = y - dc->centre[NR::Y];
 
214
                                const double dx = x - dc->centre[Geom::X];
 
215
                                const double dy = y - dc->centre[Geom::Y];
216
216
                                const double w = exp(-((dx * dx) + (dy * dy)) / (rw * rw));
217
217
                                W += w;
218
218
                                R += w * s[0];