Changeset View
Changeset View
Standalone View
Standalone View
layers/selections/image/kpEllipticalImageSelection.cpp
Show First 20 Lines • Show All 132 Lines • ▼ Show 20 Line(s) | 132 | { | |||
---|---|---|---|---|---|
133 | // The adjusting is to fight QPainterPath::addEllipse() making | 133 | // The adjusting is to fight QPainterPath::addEllipse() making | ||
134 | // the ellipse 1 pixel higher and wider than specified. | 134 | // the ellipse 1 pixel higher and wider than specified. | ||
135 | path.addEllipse (boundingRect ().adjusted (0, 0, -1, -1)); | 135 | path.addEllipse (boundingRect ().adjusted (0, 0, -1, -1)); | ||
136 | } | 136 | } | ||
137 | 137 | | |||
138 | const QList <QPolygonF> polygons = path.toSubpathPolygons (); | 138 | const QList <QPolygonF> polygons = path.toSubpathPolygons (); | ||
139 | Q_ASSERT (polygons.size () == 1); | 139 | Q_ASSERT (polygons.size () == 1); | ||
140 | 140 | | |||
141 | const QPolygonF firstPolygonF = polygons.first (); | 141 | const QPolygonF& firstPolygonF = polygons.first (); | ||
142 | return firstPolygonF.toPolygon (); | 142 | return firstPolygonF.toPolygon (); | ||
143 | } | 143 | } | ||
144 | 144 | | |||
145 | //--------------------------------------------------------------------- | 145 | //--------------------------------------------------------------------- | ||
146 | 146 | | |||
147 | 147 | | |||
148 | // protected virtual [kpAbstractImageSelection] | 148 | // protected virtual [kpAbstractImageSelection] | ||
149 | QRegion kpEllipticalImageSelection::shapeRegion () const | 149 | QRegion kpEllipticalImageSelection::shapeRegion () const | ||
150 | { | 150 | { | ||
151 | QRegion reg(calculatePoints()); | 151 | QRegion reg(calculatePoints()); | ||
152 | return reg; | 152 | return reg; | ||
153 | } | 153 | } | ||
154 | 154 | | |||
155 | //--------------------------------------------------------------------- | 155 | //--------------------------------------------------------------------- | ||
156 | 156 | | |||
157 | 157 | | |||
158 | // public virtual [kpAbstractSelection] | 158 | // public virtual [kpAbstractSelection] | ||
159 | bool kpEllipticalImageSelection::contains (const QPoint &point) const | 159 | bool kpEllipticalImageSelection::contains (const QPoint &point) const | ||
160 | { | 160 | { | ||
161 | if (!boundingRect ().contains (point)) | 161 | if (!boundingRect ().contains (point)) { | ||
162 | return false; | 162 | return false; | ||
163 | } | ||||
163 | 164 | | |||
164 | return shapeRegion ().contains (point); | 165 | return shapeRegion ().contains (point); | ||
165 | } | 166 | } | ||
166 | 167 | | |||
167 | //--------------------------------------------------------------------- | 168 | //--------------------------------------------------------------------- | ||
168 | 169 | | |||
169 | 170 | | |||
170 | // public virtual [kpAbstractSelection] | 171 | // public virtual [kpAbstractSelection] | ||
171 | void kpEllipticalImageSelection::paintBorder (QImage *destPixmap, const QRect &docRect, | 172 | void kpEllipticalImageSelection::paintBorder (QImage *destPixmap, const QRect &docRect, | ||
172 | bool selectionFinished) const | 173 | bool selectionFinished) const | ||
173 | { | 174 | { | ||
174 | if ( !boundingRect().isValid() ) | 175 | if ( !boundingRect().isValid() ) { | ||
175 | return; | 176 | return; | ||
177 | } | ||||
176 | 178 | | |||
177 | paintPolygonalBorder (calculatePoints (), | 179 | paintPolygonalBorder (calculatePoints (), | ||
178 | destPixmap, docRect, | 180 | destPixmap, docRect, | ||
179 | selectionFinished); | 181 | selectionFinished); | ||
180 | } | 182 | } | ||
181 | 183 | | |||
182 | 184 | |