diff --git a/plugins/tools/tool_transform2/kis_warp_transform_strategy.cpp b/plugins/tools/tool_transform2/kis_warp_transform_strategy.cpp --- a/plugins/tools/tool_transform2/kis_warp_transform_strategy.cpp +++ b/plugins/tools/tool_transform2/kis_warp_transform_strategy.cpp @@ -43,8 +43,8 @@ currentArgs(_currentArgs), transaction(_transaction), lastNumPoints(0), - drawConnectionLines(true), - drawOrigPoints(true), + drawConnectionLines(false), // useful while developing + drawOrigPoints(false), drawTransfPoints(true), closeOnStartPointClick(false), clipOriginalPointsPosition(true), @@ -247,12 +247,15 @@ m_d->currentArgs.isEditingTransformPoints()); } + + QPen mainPen(Qt::black); + QPen outlinePen(Qt::white); + // draw handles { const int numPoints = m_d->currentArgs.origPoints().size(); - QPen mainPen(Qt::black); - QPen outlinePen(Qt::white); + qreal handlesExtraScale = KisTransformUtils::scaleFromAffineMatrix(m_d->handlesTransform); @@ -313,6 +316,64 @@ } } + + // draw cage connection lines between transformed points + { + // see how many rows we have. we are only going to do lines up to 6 divisions/ + // it is almost impossible to use with 6 even. + int rowsInWarp = 2; + const int numPoints = m_d->currentArgs.origPoints().size(); + if (numPoints == 4) { + rowsInWarp = 2; + } else if (numPoints == 9) { + rowsInWarp = 3; + } else if (numPoints == 16) { + rowsInWarp = 4; + } else if (numPoints == 25) { + rowsInWarp = 5; + } else if (numPoints == 36) { + rowsInWarp = 6; + } + + + // don't draw lines if we have more than 4 subdivisions + if (rowsInWarp <= 6) { + + outlinePen.setWidth(2); + + // draw horizontal lines + for (int i = 0; i < numPoints; i++) { + if (i != 0 && i % rowsInWarp == rowsInWarp -1) { + // skip line if it is the last in the row + } else { + gc.setPen(mainPen); + gc.drawLine(m_d->currentArgs.transfPoints()[i],m_d->currentArgs.transfPoints()[i+1] ); + + gc.setPen(outlinePen); + gc.drawLine(m_d->currentArgs.transfPoints()[i],m_d->currentArgs.transfPoints()[i+1] ); + } + } + + // draw vertical lines + for (int i = 0; i < numPoints; i++) { + + if ( (numPoints - i - 1) < rowsInWarp ) { + // last row doesn't need to draw vertical lines + } else { + // where is the point directly below? + gc.setPen(mainPen); + gc.drawLine(m_d->currentArgs.transfPoints()[i],m_d->currentArgs.transfPoints()[i+rowsInWarp] ); + + gc.setPen(outlinePen); + gc.drawLine(m_d->currentArgs.transfPoints()[i],m_d->currentArgs.transfPoints()[i+rowsInWarp] ); + } + + } + + } // end if statement + } + + gc.restore(); } diff --git a/plugins/tools/tool_transform2/wdg_tool_transform.ui b/plugins/tools/tool_transform2/wdg_tool_transform.ui --- a/plugins/tools/tool_transform2/wdg_tool_transform.ui +++ b/plugins/tools/tool_transform2/wdg_tool_transform.ui @@ -6,7 +6,7 @@ 0 0 - 479 + 489 674 @@ -250,7 +250,7 @@ QFrame::Raised - 3 + 0 @@ -1535,7 +1535,10 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - 0 + 2 + + + 6 3 @@ -2198,7 +2201,7 @@ - +