+ draw additional dashed line in brush tool
This commit is contained in:
parent
d3760deeeb
commit
81cbd2643f
|
@ -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);
|
||||
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -53,8 +53,10 @@ public:
|
|||
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 */
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -175,6 +175,7 @@ public:
|
|||
// 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 );
|
||||
|
@ -189,6 +190,7 @@ protected:
|
|||
std::vector<QPoint> _cNodeVector;
|
||||
int m_iNodes;
|
||||
bool m_bWorking;
|
||||
bool m_bClose;
|
||||
|
||||
private:
|
||||
float r,g,b,a,l;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user