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

« back to all changes in this revision

Viewing changes to krita/image/kis_selection_mask.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <KoCompositeOp.h>
27
27
#include "kis_node_visitor.h"
28
28
#include "kis_pixel_selection.h"
 
29
#include "kis_undo_adapter.h"
29
30
 
30
31
class KisSelectionMask::Private
31
32
{
38
39
        : KisMask("selection")
39
40
        , m_d(new Private())
40
41
{
 
42
    setActive(true);
41
43
    m_d->image = image;
42
44
    m_d->deselectedSelection = 0;
43
45
}
58
60
        : KisMask(rhs)
59
61
        , m_d(new Private())
60
62
{
 
63
    m_d->image=rhs.image();
61
64
}
62
65
 
63
66
void KisSelectionMask::setSelection(KisSelectionSP selection)
98
101
    m_d->deselectedSelection = selection;
99
102
}
100
103
 
 
104
KoDocumentSectionModel::PropertyList KisSelectionMask::sectionModelProperties() const
 
105
{
 
106
    KoDocumentSectionModel::PropertyList l = KisBaseNode::sectionModelProperties();
 
107
    l << KoDocumentSectionModel::Property(i18n("Active"), KIcon("local_selection_active"),KIcon("local_selection_inactive"),active());
 
108
    return l;
 
109
}
 
110
 
 
111
void KisSelectionMask::setSectionModelProperties(const KoDocumentSectionModel::PropertyList &properties)
 
112
{
 
113
    setVisible(properties.at(0).state.toBool());
 
114
    setUserLocked(properties.at(1).state.toBool());
 
115
    setActive(properties.at(2).state.toBool());
 
116
}
 
117
 
 
118
void KisSelectionMask::setVisible(bool visible)
 
119
{
 
120
    nodeProperties().setProperty("visible", visible);
 
121
 
 
122
    if (selection())
 
123
        selection()->setVisible(visible);
 
124
    emit(visibilityChanged(visible));
 
125
}
 
126
 
 
127
bool KisSelectionMask::active() const
 
128
{
 
129
    return nodeProperties().boolProperty("active", true);
 
130
}
 
131
 
 
132
void KisSelectionMask::setActive(bool active)
 
133
{
 
134
    //the change needs to be done by the manager to deactive current active selectionMask
 
135
    emit changeActivity(this,active);
 
136
}
 
137
 
 
138
QImage KisSelectionMask::createThumbnail(qint32 w, qint32 h)
 
139
{
 
140
    KisPaintDeviceSP originalDevice = paintDevice();
 
141
    if (!originalDevice) return QImage();
 
142
 
 
143
    QRect boundRect;
 
144
    if (m_d->image)
 
145
        boundRect=m_d->image->bounds();
 
146
    else
 
147
        boundRect=originalDevice->exactBounds();
 
148
 
 
149
    if (boundRect.isEmpty()) return QImage();
 
150
 
 
151
    int wprop,hprop;
 
152
    double c=(double)boundRect.width()/(double)boundRect.height();
 
153
    hprop=(int)((double)w/c);
 
154
    if (hprop<=h)
 
155
        wprop=w;
 
156
    else {
 
157
        hprop=h;
 
158
        wprop=(int)(c*(double)h);
 
159
    }
 
160
 
 
161
    return originalDevice->createThumbnailDevice(w,h,0,boundRect)->convertToQImage(originalDevice->colorSpace()->profile(),0,0,wprop,hprop);
 
162
}
 
163