Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
+ draw additional dashed line in brush tool
  • Loading branch information
wwmayer committed Feb 17, 2014
1 parent d3760de commit 81cbd26
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Gui/GLPainter.cpp
Expand Up @@ -138,6 +138,12 @@ void GLPainter::setLogicOp(GLenum mode)
this->logicOp = true;
}

void GLPainter::resetLogicOp()
{
glDisable(GL_COLOR_LOGIC_OP);
this->logicOp = false;
}

void GLPainter::setDrawBuffer(GLenum mode)
{
glDrawBuffer(mode);
Expand All @@ -150,6 +156,12 @@ void GLPainter::setLineStipple(GLint factor, GLushort pattern)
this->lineStipple = true;
}

void GLPainter::resetLineStipple()
{
glDisable(GL_LINE_STIPPLE);
this->lineStipple = false;
}

// Draw routines
void GLPainter::drawRect(int x1, int y1, int x2, int y2)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Gui/GLPainter.h
Expand Up @@ -53,8 +53,10 @@ class GuiExport GLPainter
void setPointSize(float);
void setColor(float, float, float, float=0);
void setLogicOp(GLenum);
void resetLogicOp();
void setDrawBuffer(GLenum);
void setLineStipple(GLint factor, GLushort pattern);
void resetLineStipple();
//@}

/** @name Draw routines */
Expand Down
21 changes: 21 additions & 0 deletions src/Gui/MouseSelection.cpp
Expand Up @@ -481,6 +481,7 @@ BrushSelection::BrushSelection()
{
m_iNodes = 0;
m_bWorking = false;
m_bClose = false;
}

void BrushSelection::initialize()
Expand All @@ -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){
Expand All @@ -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();
}
Expand Down
2 changes: 2 additions & 0 deletions src/Gui/MouseSelection.h
Expand Up @@ -175,6 +175,7 @@ class GuiExport BrushSelection : public BaseMouseSelection
// Settings
void setColor(float r, float g, float b, float a=0);
void setLineWidth(float);
void setClosed(bool);

protected:
virtual int mouseButtonEvent( const SoMouseButtonEvent * const e, const QPoint& pos );
Expand All @@ -189,6 +190,7 @@ class GuiExport BrushSelection : public BaseMouseSelection
std::vector<QPoint> _cNodeVector;
int m_iNodes;
bool m_bWorking;
bool m_bClose;

private:
float r,g,b,a,l;
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Mesh/Gui/MeshSelection.cpp
Expand Up @@ -171,6 +171,7 @@ void MeshSelection::prepareBrushSelection(bool add,SoEventCallbackCB *cb)
startInteractiveCallback(viewer, cb);
// set cross cursor
Gui::BrushSelection* brush = new Gui::BrushSelection();
brush->setClosed(true);
brush->setColor(1.0f,0.0f,0.0f);
brush->setLineWidth(3.0f);
viewer->navigationStyle()->startSelection(brush);
Expand Down

0 comments on commit 81cbd26

Please sign in to comment.