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

« back to all changes in this revision

Viewing changes to krita/plugins/paintops/deform/kis_deform_paintop_settings.cpp

  • 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:
21
21
 
22
22
#include <kis_brush_size_option.h>
23
23
 
 
24
#include <kis_airbrush_option.h>
 
25
#include <kis_deform_option.h>
 
26
 
24
27
bool KisDeformPaintOpSettings::paintIncremental()
25
28
{
26
29
    return true;
27
30
}
28
31
 
29
 
 
30
 
QRectF KisDeformPaintOpSettings::paintOutlineRect(const QPointF& pos, KisImageWSP image, OutlineMode _mode) const
31
 
{
32
 
    if (_mode != CURSOR_IS_OUTLINE) return QRectF();
33
 
    qreal width = getDouble(BRUSH_DIAMETER)  * getDouble(BRUSH_SCALE);
34
 
    qreal height = getDouble(BRUSH_DIAMETER) * getDouble(BRUSH_ASPECT)  * getDouble(BRUSH_SCALE);
35
 
    QRectF brush(0,0,width,height);
36
 
    brush.translate(-brush.center());
37
 
    QTransform m;
38
 
    m.reset();
39
 
    m.rotate(getDouble(BRUSH_ROTATION));
40
 
    brush = m.mapRect(brush);
41
 
    brush.adjust(-1,-1,1,1);
42
 
    return image->pixelToDocument(brush).translated(pos);
43
 
}
44
 
 
45
 
void KisDeformPaintOpSettings::paintOutline(const QPointF& pos, KisImageWSP image, QPainter &painter, OutlineMode _mode) const
46
 
{
47
 
    if (_mode != CURSOR_IS_OUTLINE) return;
48
 
    qreal width = getDouble(BRUSH_DIAMETER)  * getDouble(BRUSH_SCALE);
49
 
    qreal height = getDouble(BRUSH_DIAMETER) * getDouble(BRUSH_ASPECT)  * getDouble(BRUSH_SCALE);
50
 
 
51
 
    QRectF brush(0,0,width,height);
52
 
    brush.translate(-brush.center());
53
 
    painter.save();
54
 
    painter.translate( pos);
55
 
    painter.rotate(getDouble(BRUSH_ROTATION));
56
 
    painter.setPen(Qt::black);
57
 
    painter.drawEllipse(image->pixelToDocument(brush));
58
 
    painter.restore();
 
32
bool KisDeformPaintOpSettings::isAirbrushing() const
 
33
{
 
34
    // version 2.3
 
35
    if (hasProperty(AIRBRUSH_ENABLED)){
 
36
        return getBool(AIRBRUSH_ENABLED);
 
37
    }else{
 
38
        return getBool(DEFORM_USE_MOVEMENT_PAINT);
 
39
    }
 
40
}
 
41
 
 
42
int KisDeformPaintOpSettings::rate() const
 
43
{
 
44
    if (hasProperty(AIRBRUSH_RATE)){
 
45
        return getInt(AIRBRUSH_RATE);
 
46
    }else{
 
47
        return KisPaintOpSettings::rate();
 
48
    }
 
49
}
 
50
 
 
51
QPainterPath KisDeformPaintOpSettings::brushOutline(const QPointF& pos, KisPaintOpSettings::OutlineMode mode, qreal scale, qreal rotation) const
 
52
{
 
53
    QPainterPath path;
 
54
    if (mode == CursorIsOutline){
 
55
        qreal width = getInt(BRUSH_DIAMETER);
 
56
        qreal height = getInt(BRUSH_DIAMETER) * getDouble(BRUSH_ASPECT);
 
57
        path = ellipseOutline(width, height,getDouble(BRUSH_SCALE),getDouble(BRUSH_ROTATION) );
 
58
        QTransform m; m.reset(); m.scale(scale,scale); m.rotateRadians(rotation);
 
59
        path = m.map(path);
 
60
        path.translate(pos);
 
61
    }
 
62
    return path;
59
63
}