Changeset View
Changeset View
Standalone View
Standalone View
plugins/assistants/Assistants/VanishingPointAssistant.cc
Context not available. | |||||
177 | } | 177 | } | ||
---|---|---|---|---|---|
178 | 178 | | |||
179 | 179 | | |||
180 | gc.restore(); | 180 | // draw references guide for vanishing points at specified density | ||
181 | // this is shown as part of the preview, so don't show if preview is off | ||||
182 | if( canvas->paintingAssistantsDecoration()->outlineVisibility() && this->isSnappingActive() ) { | ||||
181 | 183 | | |||
182 | KisPaintingAssistant::drawAssistant(gc, updateRect, converter, cached, canvas, assistantVisible, previewVisible); | 184 | // cycle through degrees from 0 to 180. We are doing an infinite line, so we don't need to go 360 | ||
185 | QTransform initialTransform = converter->documentToWidgetTransform(); | ||||
186 | QPointF p0 = initialTransform.map(*handles()[0]); // main vanishing point | ||||
183 | 187 | | |||
188 | for (int currentAngle=0; currentAngle <= 180; currentAngle = currentAngle + m_referenceLineDensity ) { | ||||
189 | | ||||
190 | // determine the correct angle based on the iteration | ||||
191 | float xPos = cos(currentAngle * M_PI / 180); | ||||
192 | float yPos = sin(currentAngle * M_PI / 180); | ||||
193 | QPointF unitAngle; | ||||
194 | unitAngle.setX(p0.x() + xPos); | ||||
195 | unitAngle.setY(p0.y() + yPos); | ||||
196 | | ||||
197 | // find point | ||||
198 | QLineF snapLine= QLineF(p0, unitAngle); | ||||
199 | QRect viewport= gc.viewport(); | ||||
200 | KisAlgebra2D::intersectLineRect(snapLine, viewport); | ||||
201 | | ||||
202 | // make a line from VP center to edge of canvas with that angle | ||||
203 | QPainterPath path; | ||||
204 | path.moveTo(snapLine.p1()); | ||||
205 | path.lineTo(snapLine.p2()); | ||||
206 | drawPreview(gc, path);//and we draw the preview. | ||||
207 | } | ||||
208 | } | ||||
184 | 209 | | |||
185 | 210 | | |||
211 | gc.restore(); | ||||
212 | | ||||
213 | KisPaintingAssistant::drawAssistant(gc, updateRect, converter, cached, canvas, assistantVisible, previewVisible); | ||||
186 | } | 214 | } | ||
187 | 215 | | |||
188 | void VanishingPointAssistant::drawCache(QPainter& gc, const KisCoordinatesConverter *converter, bool assistantVisible) | 216 | void VanishingPointAssistant::drawCache(QPainter& gc, const KisCoordinatesConverter *converter, bool assistantVisible) | ||
Context not available. | |||||
215 | return (*handles()[0]); | 243 | return (*handles()[0]); | ||
216 | } | 244 | } | ||
217 | 245 | | |||
246 | void VanishingPointAssistant::setCustomPropertyFloat(QString propertyName, float value) | ||||
247 | { | ||||
248 | if (propertyName == "angleDensity") { | ||||
249 | // cannot have less than a 1 degree | ||||
250 | if (value < 1.0) { | ||||
251 | value = 1.0; | ||||
252 | } | ||||
253 | | ||||
254 | m_referenceLineDensity = value; | ||||
255 | } | ||||
256 | | ||||
257 | KisPaintingAssistant::setCustomPropertyFloat(propertyName, value); | ||||
258 | } | ||||
259 | | ||||
218 | bool VanishingPointAssistant::isAssistantComplete() const | 260 | bool VanishingPointAssistant::isAssistantComplete() const | ||
219 | { | 261 | { | ||
220 | return handles().size() > 0; // only need one point to be ready | 262 | return handles().size() > 0; // only need one point to be ready | ||
Context not available. |