+ draw additional dashed line in brush tool

This commit is contained in:
wmayer
2014-02-17 15:27:59 +01:00
parent 2eb40b4fd8
commit 018ead2be3
5 changed files with 38 additions and 0 deletions

View File

@@ -481,6 +481,7 @@ BrushSelection::BrushSelection()
{
m_iNodes = 0;
m_bWorking = false;
m_bClose = false;
}
void BrushSelection::initialize()
@@ -507,6 +508,11 @@ void BrushSelection::setLineWidth(float l)
this->l = l;
}
void BrushSelection::setClosed(bool on)
{
this->m_bClose = on;
}
void BrushSelection::draw ()
{
if (mustRedraw){
@@ -532,6 +538,21 @@ void BrushSelection::draw ()
p.begin(_pcView3D);
p.setLineWidth(this->l);
p.setColor(this->r, this->g, this->b, this->a);
if (m_bClose && !_cNodeVector.empty()) {
// We have to redraw the whole polyline when using XOR because otherwise the curve looks 'dirty'.
QPoint start = _cNodeVector.front();
for (std::vector<QPoint>::iterator it = _cNodeVector.begin()+1; it != _cNodeVector.end(); ++it) {
p.drawLine(start.x(),start.y(),it->x(), it->y());
start = *it;
}
start = _cNodeVector.front();
p.setLineStipple(2, 0x3F3F);
p.setLogicOp(GL_XOR);
p.drawLine(m_iXold, m_iYold, start.x(),start.y());
p.drawLine(m_iXnew, m_iYnew, start.x(),start.y());
p.resetLogicOp();
p.resetLineStipple();
}
p.drawLine(m_iXnew, m_iYnew, m_iXold, m_iYold);
p.end();
}