Commit 494941b3 authored by Christoffer Ackelman's avatar Christoffer Ackelman

QT: Fix rendering of dashed lines.

parent 712f4c9a
......@@ -1699,11 +1699,11 @@ GeQt::GeQt(void* x_parent_ctx, ldh_tSesContext x_ldhses, int x_exit_when_close,
// Line type option menu
QComboBox* tools_linetype
= addToolMenu(toplevel, tools3, SLOT(activate_linetype(int)));
for (int i = 1; i <= 7; i++) {
for (int i = 0; i < 7; i++) {
std::ostringstream txt;
txt << "Linetype " << i;
txt << "Linetype " << (i + 1);
std::ostringstream fname;
fname << "$pwr_exe/ge_linetype_" << i << ".png";
fname << "$pwr_exe/ge_linetype_" << (i + 1) << ".png";
tools_linetype->addItem(
get_icon(fname.str().c_str()), txt.str().c_str(), i);
}
......
......@@ -926,7 +926,8 @@ void GlowDrawQt::line(int x1, int y1, int x2, int y2,
if (line_type != glow_eLineType_Solid) {
QPen pen = painter.pen();
pen.setWidth(idx + 1);
pen.setStyle(Qt::DashLine);
pen.setStyle(Qt::CustomDashLine);
pen.setCapStyle(Qt::FlatCap);
pen.setJoinStyle(Qt::MiterJoin);
QVector<double> dashes;
switch (line_type) {
......@@ -943,26 +944,22 @@ void GlowDrawQt::line(int x1, int y1, int x2, int y2,
break;
}
case glow_eLineType_Dotted: {
dashes << 1 + idx << 1 + idx;
dashes << 1 + 4 * idx << 1 + 4 * idx;
dashes << 1 + idx << 1 + 4 * idx;
break;
}
case glow_eLineType_DotDashed1: {
dashes << 1 + 3 * idx << 1 + 3 * idx;
dashes << 1 + 2 * idx << 1 + 2 * idx;
dashes << 1 + idx << 1 + idx;
dashes << 1 + 2 * idx << 1 + 2 * idx;
dashes << 1 + 3 * idx << 1 + 2 * idx << 1 + idx << 1 + 2 * idx;
break;
}
case glow_eLineType_DotDashed2: {
dashes << 1 + 6 * idx << 1 + 6 * idx;
dashes << 1 + 3 * idx << 1 + 3 * idx;
dashes << 1 + idx << 1 + idx;
dashes << 1 + 3 * idx << 1 + 3 * idx;
dashes << 1 + 6 * idx << 1 + 3 * idx << 1 + idx << 1 + 3 * idx;
break;
}
default:;
}
for (int i = 0; i < dashes.size(); i++) {
dashes[i] /= (1 + idx);
}
pen.setDashPattern(dashes);
painter.setPen(pen);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment