~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to krita/image/kis_selection.cc

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-27 17:52:57 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101027175257-s04zqqk5bs8ckm9o
Tags: 1:2.2.83-0ubuntu1
* Merge with Debian git remaining changes:
 - Add build-deps on librcps-dev, opengtl-dev, libqtgtl-dev, freetds-dev,
   create-resources, libspnav-dev
 - Remove needless build-dep on libwv2-dev
 - koffice-libs recommends create-resources
 - krita recommends pstoedit
 - Keep our patches
* New upstream release 2.3 beta 3
  - Remove debian/patches fixed by upstream
  - Update install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
    KisSelectionComponent* shapeSelection;
53
53
};
54
54
 
55
 
KisSelection::KisSelection(KisPaintDeviceSP dev, KisDefaultBounds defaultBounds)
 
55
KisSelection::KisSelection(KisPaintDeviceSP dev, KisDefaultBoundsSP defaultBounds)
56
56
        : KisPaintDevice(0, KoColorSpaceRegistry::instance()->alpha8(), defaultBounds)
57
57
        , m_d(new Private)
58
58
{
69
69
}
70
70
 
71
71
 
72
 
KisSelection::KisSelection(KisPaintDeviceSP parent, KisMaskSP mask, KisDefaultBounds defaultBounds)
 
72
KisSelection::KisSelection(KisPaintDeviceSP parent, KisMaskSP mask, KisDefaultBoundsSP defaultBounds)
73
73
        : KisPaintDevice(0, KoColorSpaceRegistry::instance()->alpha8(), defaultBounds)
74
74
        , m_d(new Private)
75
75
{
96
96
     * with the pixel selection until we get an additional
97
97
     * selection component
98
98
     */
99
 
    m_datamanager = m_d->pixelSelection->dataManager();
 
99
    setDataManager(m_d->pixelSelection->dataManager());
100
100
}
101
101
 
102
102
KisSelection::KisSelection()
122
122
    m_d->interestedInDirtyness = false;
123
123
    if (rhs.m_d->hasPixelSelection) {
124
124
        m_d->pixelSelection = new KisPixelSelection(*rhs.m_d->pixelSelection.data());
125
 
        m_d->pixelSelection->dataManager()->setDefaultPixel(rhs.m_d->pixelSelection->dataManager()->defaultPixel());
 
125
        m_d->pixelSelection->setDefaultPixel(rhs.m_d->pixelSelection->defaultPixel());
126
126
    }
127
127
    m_d->hasPixelSelection = rhs.m_d->hasPixelSelection;
128
128
    m_d->isDeselected = rhs.m_d->isDeselected;
160
160
void KisSelection::clear()
161
161
{
162
162
    quint8 defPixel = MIN_SELECTED;
163
 
    dataManager()->setDefaultPixel(&defPixel);
164
 
    dataManager()->clear();
 
163
    setDefaultPixel(&defPixel);
 
164
    KisPaintDevice::clear();
165
165
}
166
166
 
167
167
void KisSelection::clear(const QRect& r)
169
169
 
170
170
    KisFillPainter painter(KisPaintDeviceSP(this));
171
171
    const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
172
 
    painter.fillRect(r, KoColor(Qt::white, cs), *(dataManager()->defaultPixel()));
 
172
    painter.fillRect(r, KoColor(Qt::white, cs), *(defaultPixel()));
173
173
}
174
174
 
175
175
 
176
176
bool KisSelection::isTotallyUnselected(const QRect & r) const
177
177
{
178
 
    if (*(dataManager()->defaultPixel()) != MIN_SELECTED)
 
178
    if (*defaultPixel() != MIN_SELECTED)
179
179
        return false;
180
180
    QRect sr = selectedExactRect();
181
181
    return ! r.intersects(sr);
183
183
 
184
184
bool KisSelection::isProbablyTotallyUnselected(const QRect & r) const
185
185
{
186
 
    if (*(dataManager()->defaultPixel()) != MIN_SELECTED)
 
186
    if (*defaultPixel() != MIN_SELECTED)
187
187
        return false;
188
188
    QRect sr = selectedRect();
189
189
    return ! r.intersects(sr);
191
191
 
192
192
QRect KisSelection::selectedRect() const
193
193
{
194
 
    if (*(m_datamanager->defaultPixel()) == MIN_SELECTED) {
195
 
        return extent().intersected(defaultBounds().bounds());
196
 
    } else {
197
 
        return defaultBounds().bounds();
198
 
    }
 
194
    return extent();
199
195
}
200
196
 
201
197
QRect KisSelection::selectedExactRect() const
202
198
{
203
 
    if (*(m_datamanager->defaultPixel()) == MIN_SELECTED) {
204
 
        return exactBounds().intersected(defaultBounds().bounds());
205
 
    } else {
206
 
        return defaultBounds().bounds();
207
 
    }
 
199
    return exactBounds();
208
200
}
209
201
 
210
202
void KisSelection::setInterestedInDirtyness(bool b)
269
261
    }
270
262
    // Share the datamanager unless there's a shape selection
271
263
    if (!m_d->hasShapeSelection) {
272
 
        m_datamanager = m_d->pixelSelection->dataManager();
 
264
        setDataManager(m_d->pixelSelection->dataManager());
273
265
    }
274
266
    return m_d->pixelSelection;
275
267
}
280
272
    m_d->hasPixelSelection = true;
281
273
    // Share the datamanager unless there's a shape selection
282
274
    if (!m_d->hasShapeSelection) {
283
 
        m_datamanager = pixelSelection->dataManager();
 
275
        setDataManager(pixelSelection->dataManager());
284
276
    }
285
277
}
286
278
 
290
282
    m_d->hasShapeSelection = true;
291
283
    Q_ASSERT(m_d->shapeSelection);
292
284
    // Unshare the data manager of the pixel selection
293
 
    if (m_d->hasPixelSelection && m_datamanager == m_d->pixelSelection->dataManager()) {
294
 
        m_datamanager = new KisDataManager(1, m_d->pixelSelection->dataManager()->defaultPixel());
 
285
    if (m_d->hasPixelSelection && dataManager() == m_d->pixelSelection->dataManager()) {
 
286
        setDataManager(new KisDataManager(1, m_d->pixelSelection->defaultPixel()));
295
287
    }
296
288
}
297
289
 
303
295
 
304
296
    clear();
305
297
    if (m_d->hasPixelSelection) {
306
 
        quint8 defPixel = *(m_d->pixelSelection->dataManager()->defaultPixel());
307
 
        dataManager()->setDefaultPixel(&defPixel);
 
298
        quint8 defPixel = *(m_d->pixelSelection->defaultPixel());
 
299
        setDefaultPixel(&defPixel);
308
300
        m_d->pixelSelection->renderToProjection(this);
309
301
    }
310
302
    m_d->shapeSelection->renderToProjection(this);
320
312
 
321
313
    clear(r);
322
314
    if (m_d->hasPixelSelection) {
323
 
        quint8 defPixel = *(m_d->pixelSelection->dataManager()->defaultPixel());
324
 
        dataManager()->setDefaultPixel(&defPixel);
 
315
        quint8 defPixel = *(m_d->pixelSelection->defaultPixel());
 
316
        setDefaultPixel(&defPixel);
325
317
 
326
318
        m_d->pixelSelection->renderToProjection(this, r);
327
319
    }
348
340
    return m_d->isVisible;
349
341
}
350
342
 
351
 
void KisSelection::setDefaultBounds(KisDefaultBounds bounds)
 
343
void KisSelection::setDefaultBounds(KisDefaultBoundsSP bounds)
352
344
{
353
345
    KisPaintDevice::setDefaultBounds(bounds);
354
346
    if(m_d->hasPixelSelection) {
356
348
    }
357
349
}
358
350
 
 
351
void KisSelection::setX(qint32 x)
 
352
{
 
353
    qint32 delta = x - this->x();
 
354
    KisPaintDevice::setX(x);
 
355
    if (hasPixelSelection()) {
 
356
        m_d->pixelSelection->setX(x);
 
357
    }
 
358
    if (hasShapeSelection()) {
 
359
        m_d->shapeSelection->moveX(delta);
 
360
    }
 
361
}
 
362
 
 
363
void KisSelection::setY(qint32 y)
 
364
{
 
365
    qint32 delta = y - this->y();
 
366
    KisPaintDevice::setY(y);
 
367
    if (hasPixelSelection()) {
 
368
        m_d->pixelSelection->setY(y);
 
369
    }
 
370
    if (hasShapeSelection()) {
 
371
        m_d->shapeSelection->moveY(delta);
 
372
    }
 
373
}
 
374
 
 
375