Improve lancelot test of dashed line painting
Add painting of sets of lines, both connected and unconnected, that go outside the device area. This prepares for fixes & improvements in the painting code. Change-Id: I9cffc760524e9ade42362c9a04949270ac24180f Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit 587fe1a95ad2789c2f284fb1384f19b7f5b09917) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
91d53ba22e
commit
14e7813f12
@ -376,6 +376,10 @@ void PaintCommands::staticInit()
|
||||
"^drawLine\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)$",
|
||||
"drawLine <x1> <y1> <x2> <y2>",
|
||||
"drawLine 10.0 10.0 20.0 20.0");
|
||||
DECL_PAINTCOMMAND("drawLines", command_drawLines,
|
||||
"^drawLines\\s+\\[([\\w\\s\\-.]*)\\]$",
|
||||
"drawLines <[ <l1x1> <l1y1> <l1x2> <l1y2> <l2x1> <l2y1> ... ]>",
|
||||
"drawLines [ 10 10 50 10 50 20 10 20 ]");
|
||||
DECL_PAINTCOMMAND("drawRect", command_drawRect,
|
||||
"^drawRect\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)$",
|
||||
"drawRect <x> <y> <w> <h>",
|
||||
@ -433,7 +437,7 @@ void PaintCommands::staticInit()
|
||||
"drawConvexPolygon <[ <x1> <y1> ... <xn> <yn> ]>",
|
||||
"drawConvexPolygon [ 1 4 6 8 5 3 ]");
|
||||
DECL_PAINTCOMMAND("drawPolyline", command_drawPolyline,
|
||||
"^drawPolyline\\s+\\[([\\w\\s]*)\\]$",
|
||||
"^drawPolyline\\s+\\[([\\w\\s\\-.]*)\\]$",
|
||||
"drawPolyline <[ <x1> <y1> ... <xn> <yn> ]>",
|
||||
"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<QLineF> 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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user