diff --git a/tests/auto/other/lancelot/paintcommands.cpp b/tests/auto/other/lancelot/paintcommands.cpp index d8157f047f8..220b89ebb96 100644 --- a/tests/auto/other/lancelot/paintcommands.cpp +++ b/tests/auto/other/lancelot/paintcommands.cpp @@ -376,6 +376,10 @@ void PaintCommands::staticInit() "^drawLine\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)$", "drawLine ", "drawLine 10.0 10.0 20.0 20.0"); + DECL_PAINTCOMMAND("drawLines", command_drawLines, + "^drawLines\\s+\\[([\\w\\s\\-.]*)\\]$", + "drawLines <[ ... ]>", + "drawLines [ 10 10 50 10 50 20 10 20 ]"); DECL_PAINTCOMMAND("drawRect", command_drawRect, "^drawRect\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)$", "drawRect ", @@ -433,7 +437,7 @@ void PaintCommands::staticInit() "drawConvexPolygon <[ ... ]>", "drawConvexPolygon [ 1 4 6 8 5 3 ]"); DECL_PAINTCOMMAND("drawPolyline", command_drawPolyline, - "^drawPolyline\\s+\\[([\\w\\s]*)\\]$", + "^drawPolyline\\s+\\[([\\w\\s\\-.]*)\\]$", "drawPolyline <[ ... ]>", "drawPolyline [ 1 4 6 8 5 3 ]"); DECL_PAINTCOMMAND("drawText", command_drawText, @@ -978,6 +982,25 @@ void PaintCommands::command_drawLine(QRegularExpressionMatch re) m_painter->drawLine(QLineF(x1, y1, x2, y2)); } +/***************************************************************************************************/ +void PaintCommands::command_drawLines(QRegularExpressionMatch re) +{ + static QRegularExpression separators("\\s"); + QStringList numbers = re.captured(1).split(separators, Qt::SkipEmptyParts); + + QList array; + for (int i = 0; i + 3 < numbers.size(); i += 4) { + QPointF pt1(numbers.at(i).toFloat(), numbers.at(i + 1).toFloat()); + QPointF pt2(numbers.at(i + 2).toFloat(), numbers.at(i + 3).toFloat()); + array.append(QLineF(pt1, pt2)); + } + + if (m_verboseMode) + printf(" -(lance) drawLines(size=%zd)\n", size_t(array.size())); + + m_painter->drawLines(array); +} + /***************************************************************************************************/ void PaintCommands::command_drawPath(QRegularExpressionMatch re) { diff --git a/tests/auto/other/lancelot/paintcommands.h b/tests/auto/other/lancelot/paintcommands.h index e9468b1f42d..0f206884abe 100644 --- a/tests/auto/other/lancelot/paintcommands.h +++ b/tests/auto/other/lancelot/paintcommands.h @@ -191,6 +191,7 @@ private: void command_drawEllipse(QRegularExpressionMatch re); void command_drawImage(QRegularExpressionMatch re); void command_drawLine(QRegularExpressionMatch re); + void command_drawLines(QRegularExpressionMatch re); void command_drawPath(QRegularExpressionMatch re); void command_drawPie(QRegularExpressionMatch re); void command_drawPixmap(QRegularExpressionMatch re); diff --git a/tests/auto/other/lancelot/scripts/linedashes2.qps b/tests/auto/other/lancelot/scripts/linedashes2.qps index 1dc4fd310ee..b9a4cb95664 100644 --- a/tests/auto/other/lancelot/scripts/linedashes2.qps +++ b/tests/auto/other/lancelot/scripts/linedashes2.qps @@ -111,8 +111,9 @@ translate 0 780 repeat_block vertical resetMatrix -translate 40 400 -setPen 0xffff0000 5 dashdotline flatcap +translate 20 380 +setPen 0xffff00ff 5 dashdotline flatcap +begin_block offset pen_setDashPattern [1 1 4 1 1 4] pen_setDashOffset -4 drawLine 0 0 300 0 @@ -146,9 +147,50 @@ drawLine 0 0 300 0 translate 0 8 pen_setDashOffset 16 drawLine 0 0 300 0 +end_block offset + +resetMatrix +translate 420 380 +setPen 0xffff00ff 5 dashdotline roundcap +repeat_block offset resetMatrix setPen black 3 dashdotline pen_setCosmetic true translate 0 -150 -drawLine 500 160 500 410 \ No newline at end of file +drawLine 500 160 500 410 + +resetMatrix +translate 300 480 +setPen blue 0 + +begin_block clip_lines +pen_setDashPattern [ 20 4 5 4 1 4 ] +pen_setDashOffset 26.0 +drawLines [0 0 1000000 10 1000000 10 -1000000 20 -1000000 20 0 30] +end_block clip_lines + +translate 0 45 +setPen blue 5 +repeat_block clip_lines + +translate 0 45 +setPen blue 5 SolidLine RoundCap +repeat_block clip_lines + +translate 0 45 +setPen green 0 + +begin_block clip_poly +pen_setDashPattern [ 20 4 5 4 1 4 ] +pen_setDashOffset 26.0 +drawPolyline [0 0 1000000 10 -1000000 20 0 30] +end_block clip_poly + +translate 0 45 +setPen green 5 +repeat_block clip_poly + +translate 0 45 +setPen green 5 SolidLine RoundCap +repeat_block clip_poly