Add framebuffer support to Inventor viewer

This commit is contained in:
wmayer
2013-05-02 17:37:56 +02:00
parent 3d5799d66e
commit 2f2b2e8a1b
13 changed files with 470 additions and 68 deletions

View File

@@ -755,6 +755,118 @@ int RectangleSelection::keyboardEvent( const SoKeyboardEvent * const e )
// -----------------------------------------------------------------------------------
Rubberband::Rubberband()
{
m_bWorking = false;
}
Rubberband::~Rubberband()
{
}
void Rubberband::initialize()
{
_pcView3D->setRenderFramebuffer(true);
_pcView3D->scheduleRedraw();
}
void Rubberband::terminate()
{
_pcView3D->setRenderFramebuffer(false);
_pcView3D->scheduleRedraw();
}
void Rubberband::redraw()
{
draw();
}
void Rubberband::draw ()
{
if (m_bWorking) {
const SbViewportRegion vp = _pcView3D->getViewportRegion();
SbVec2s size = vp.getViewportSizePixels();
glMatrixMode(GL_PROJECTION);
glOrtho(0, size[0], size[1], 0, 0, 100);
glMatrixMode(GL_MODELVIEW);
glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glLineWidth(4.0);
glColor4f(1.0f, 1.0f, 1.0f, 0.2f);
glRecti(m_iXold, m_iYold, m_iXnew, m_iYnew);
glColor4f(1.0, 1.0, 0.0, 0.5);
glLineStipple(3, 0xAAAA);
glEnable(GL_LINE_STIPPLE);
glBegin(GL_LINE_LOOP);
glVertex2i(m_iXold, m_iYold);
glVertex2i(m_iXnew, m_iYold);
glVertex2i(m_iXnew, m_iYnew);
glVertex2i(m_iXold, m_iYnew);
glEnd();
glLineWidth(1.0);
glDisable(GL_LINE_STIPPLE);
glDisable(GL_BLEND);
}
}
int Rubberband::mouseButtonEvent(const SoMouseButtonEvent * const e, const QPoint& pos)
{
const int button = e->getButton();
const SbBool press = e->getState() == SoButtonEvent::DOWN ? TRUE : FALSE;
int ret = Continue;
if (press) {
switch (button)
{
case SoMouseButtonEvent::BUTTON1:
{
m_bWorking = true;
m_iXold = m_iXnew = pos.x();
m_iYold = m_iYnew = pos.y();
} break;
default:
{
} break;
}
}
else {
switch (button) {
case SoMouseButtonEvent::BUTTON1:
{
releaseMouseModel();
m_bWorking = false;
_clPoly.push_back(e->getPosition());
ret = Finish;
} break;
default:
{
} break;
}
}
return ret;
}
int Rubberband::locationEvent(const SoLocation2Event * const e, const QPoint& pos)
{
m_iXnew = pos.x();
m_iYnew = pos.y();
_pcView3D->render();
return Continue;
}
int Rubberband::keyboardEvent(const SoKeyboardEvent * const e)
{
return Continue;
}
// -----------------------------------------------------------------------------------
BoxZoomSelection::BoxZoomSelection()
{
}
@@ -765,6 +877,8 @@ BoxZoomSelection::~BoxZoomSelection()
void BoxZoomSelection::terminate()
{
Rubberband::terminate();
int xmin = std::min<int>(m_iXold, m_iXnew);
int xmax = std::max<int>(m_iXold, m_iXnew);
int ymin = std::min<int>(m_iYold, m_iYnew);