Changeset View
Changeset View
Standalone View
Standalone View
plugins/tools/tool_transform2/kis_warp_transform_strategy.cpp
Context not available. | |||||
30 | #include "kis_cursor.h" | 30 | #include "kis_cursor.h" | ||
---|---|---|---|---|---|
31 | #include "kis_transform_utils.h" | 31 | #include "kis_transform_utils.h" | ||
32 | #include "kis_algebra_2d.h" | 32 | #include "kis_algebra_2d.h" | ||
33 | 33 | #include "KisHandlePainterHelper.h" | |||
34 | 34 | | |||
35 | struct KisWarpTransformStrategy::Private | 35 | struct KisWarpTransformStrategy::Private | ||
36 | { | 36 | { | ||
Context not available. | |||||
43 | currentArgs(_currentArgs), | 43 | currentArgs(_currentArgs), | ||
44 | transaction(_transaction), | 44 | transaction(_transaction), | ||
45 | lastNumPoints(0), | 45 | lastNumPoints(0), | ||
46 | drawConnectionLines(true), | 46 | drawConnectionLines(false), // useful while developing | ||
47 | drawOrigPoints(true), | 47 | drawOrigPoints(false), | ||
48 | drawTransfPoints(true), | 48 | drawTransfPoints(true), | ||
49 | closeOnStartPointClick(false), | 49 | closeOnStartPointClick(false), | ||
50 | clipOriginalPointsPosition(true), | 50 | clipOriginalPointsPosition(true), | ||
Context not available. | |||||
237 | gc.save(); | 237 | gc.save(); | ||
238 | gc.setTransform(m_d->handlesTransform, true); | 238 | gc.setTransform(m_d->handlesTransform, true); | ||
239 | 239 | | |||
240 | // draw connecting lines | | |||
241 | if (m_d->drawConnectionLines) { | 240 | if (m_d->drawConnectionLines) { | ||
242 | gc.setOpacity(0.5); | 241 | gc.setOpacity(0.5); | ||
243 | 242 | | |||
Context not available. | |||||
247 | m_d->currentArgs.isEditingTransformPoints()); | 246 | m_d->currentArgs.isEditingTransformPoints()); | ||
248 | } | 247 | } | ||
249 | 248 | | |||
249 | | ||||
250 | QPen mainPen(Qt::black); | ||||
251 | QPen outlinePen(Qt::white); | ||||
252 | | ||||
250 | // draw handles | 253 | // draw handles | ||
251 | { | 254 | { | ||
252 | const int numPoints = m_d->currentArgs.origPoints().size(); | 255 | const int numPoints = m_d->currentArgs.origPoints().size(); | ||
253 | 256 | | |||
254 | QPen mainPen(Qt::black); | 257 | | ||
255 | QPen outlinePen(Qt::white); | | |||
256 | 258 | | |||
257 | qreal handlesExtraScale = KisTransformUtils::scaleFromAffineMatrix(m_d->handlesTransform); | 259 | qreal handlesExtraScale = KisTransformUtils::scaleFromAffineMatrix(m_d->handlesTransform); | ||
258 | 260 | | |||
Context not available. | |||||
313 | } | 315 | } | ||
314 | 316 | | |||
315 | } | 317 | } | ||
318 | | ||||
319 | // draw grid lines only if we are using the GRID mode. | ||||
320 | if (m_d->currentArgs.warpCalculation() == KisWarpTransformWorker::WarpCalculation::GRID) { | ||||
321 | | ||||
322 | // see how many rows we have. we are only going to do lines up to 6 divisions/ | ||||
323 | // it is almost impossible to use with 6 even. | ||||
324 | const int numPoints = m_d->currentArgs.origPoints().size(); | ||||
325 | | ||||
326 | // grid is always square, so get the square root to find # of rows | ||||
327 | int rowsInWarp = sqrt(m_d->currentArgs.origPoints().size()); | ||||
328 | | ||||
329 | | ||||
330 | KisHandlePainterHelper handlePainter(&gc); | ||||
331 | handlePainter.setHandleStyle(KisHandleStyle::primarySelection()); | ||||
332 | | ||||
333 | // draw horizontal lines | ||||
334 | for (int i = 0; i < numPoints; i++) { | ||||
335 | if (i != 0 && i % rowsInWarp == rowsInWarp -1) { | ||||
336 | // skip line if it is the last in the row | ||||
337 | } else { | ||||
338 | handlePainter.drawConnectionLine(m_d->currentArgs.transfPoints()[i], m_d->currentArgs.transfPoints()[i+1] ); | ||||
339 | } | ||||
340 | } | ||||
341 | | ||||
342 | // draw vertical lines | ||||
343 | for (int i = 0; i < numPoints; i++) { | ||||
344 | | ||||
345 | if ( (numPoints - i - 1) < rowsInWarp ) { | ||||
346 | // last row doesn't need to draw vertical lines | ||||
347 | } else { | ||||
348 | handlePainter.drawConnectionLine(m_d->currentArgs.transfPoints()[i], m_d->currentArgs.transfPoints()[i+rowsInWarp] ); | ||||
349 | } | ||||
350 | } | ||||
351 | | ||||
352 | } // end if statement | ||||
353 | | ||||
316 | gc.restore(); | 354 | gc.restore(); | ||
317 | } | 355 | } | ||
318 | 356 | | |||
Context not available. |