+ add new render type to 3d viewer
This commit is contained in:
parent
980b17ca86
commit
a7157ce6a9
|
@ -55,8 +55,6 @@ void AbstractMouseSelection::grabMouseModel(Gui::View3DInventorViewer* viewer)
|
||||||
{
|
{
|
||||||
_pcView3D = viewer;
|
_pcView3D = viewer;
|
||||||
m_cPrevCursor = _pcView3D->getWidget()->cursor();
|
m_cPrevCursor = _pcView3D->getWidget()->cursor();
|
||||||
m_antiAliasing = (int)_pcView3D->getAntiAliasingMode();
|
|
||||||
_pcView3D->setAntiAliasingMode(View3DInventorViewer::None);
|
|
||||||
|
|
||||||
// do initialization of your mousemodel
|
// do initialization of your mousemodel
|
||||||
initialize();
|
initialize();
|
||||||
|
@ -64,12 +62,11 @@ void AbstractMouseSelection::grabMouseModel(Gui::View3DInventorViewer* viewer)
|
||||||
|
|
||||||
void AbstractMouseSelection::releaseMouseModel()
|
void AbstractMouseSelection::releaseMouseModel()
|
||||||
{
|
{
|
||||||
if(_pcView3D) {
|
if (_pcView3D) {
|
||||||
// do termination of your mousemodel
|
// do termination of your mousemodel
|
||||||
terminate();
|
terminate();
|
||||||
|
|
||||||
_pcView3D->getWidget()->setCursor(m_cPrevCursor);
|
_pcView3D->getWidget()->setCursor(m_cPrevCursor);
|
||||||
_pcView3D->setAntiAliasingMode(View3DInventorViewer::AntiAliasing(m_antiAliasing));
|
|
||||||
_pcView3D = 0;
|
_pcView3D = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,11 +92,11 @@ int AbstractMouseSelection::handleEvent(const SoEvent* const ev, const SbViewpor
|
||||||
loc.getValue(x,y);
|
loc.getValue(x,y);
|
||||||
y = h-y; // the origin is at the left bottom corner (instead of left top corner)
|
y = h-y; // the origin is at the left bottom corner (instead of left top corner)
|
||||||
|
|
||||||
if(ev->getTypeId().isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) {
|
if (ev->getTypeId().isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) {
|
||||||
const SoMouseButtonEvent* const event = (const SoMouseButtonEvent*) ev;
|
const SoMouseButtonEvent* const event = (const SoMouseButtonEvent*) ev;
|
||||||
const SbBool press = event->getState() == SoButtonEvent::DOWN ? TRUE : FALSE;
|
const SbBool press = event->getState() == SoButtonEvent::DOWN ? TRUE : FALSE;
|
||||||
|
|
||||||
if(press) {
|
if (press) {
|
||||||
_clPoly.push_back(ev->getPosition());
|
_clPoly.push_back(ev->getPosition());
|
||||||
ret = mouseButtonEvent(static_cast<const SoMouseButtonEvent*>(ev), QPoint(x,y));
|
ret = mouseButtonEvent(static_cast<const SoMouseButtonEvent*>(ev), QPoint(x,y));
|
||||||
}
|
}
|
||||||
|
@ -107,14 +104,14 @@ int AbstractMouseSelection::handleEvent(const SoEvent* const ev, const SbViewpor
|
||||||
ret = mouseButtonEvent(static_cast<const SoMouseButtonEvent*>(ev), QPoint(x,y));
|
ret = mouseButtonEvent(static_cast<const SoMouseButtonEvent*>(ev), QPoint(x,y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(ev->getTypeId().isDerivedFrom(SoLocation2Event::getClassTypeId())) {
|
else if (ev->getTypeId().isDerivedFrom(SoLocation2Event::getClassTypeId())) {
|
||||||
ret = locationEvent(static_cast<const SoLocation2Event*>(ev), QPoint(x,y));
|
ret = locationEvent(static_cast<const SoLocation2Event*>(ev), QPoint(x,y));
|
||||||
}
|
}
|
||||||
else if(ev->getTypeId().isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
|
else if (ev->getTypeId().isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
|
||||||
ret = keyboardEvent(static_cast<const SoKeyboardEvent*>(ev));
|
ret = keyboardEvent(static_cast<const SoKeyboardEvent*>(ev));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ret == Restart)
|
if (ret == Restart)
|
||||||
_clPoly.clear();
|
_clPoly.clear();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -264,14 +261,14 @@ void PolyPickerSelection::initialize()
|
||||||
polyline.setColor(0.0,0.0,1.0,1.0);
|
polyline.setColor(0.0,0.0,1.0,1.0);
|
||||||
|
|
||||||
_pcView3D->addGraphicsItem(&polyline);
|
_pcView3D->addGraphicsItem(&polyline);
|
||||||
_pcView3D->setRenderFramebuffer(true);
|
_pcView3D->setRenderType(View3DInventorViewer::Framebuffer);
|
||||||
_pcView3D->redraw();
|
_pcView3D->redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyPickerSelection::terminate()
|
void PolyPickerSelection::terminate()
|
||||||
{
|
{
|
||||||
_pcView3D->removeGraphicsItem(&polyline);
|
_pcView3D->removeGraphicsItem(&polyline);
|
||||||
_pcView3D->setRenderFramebuffer(false);
|
_pcView3D->setRenderType(View3DInventorViewer::Native);
|
||||||
_pcView3D->redraw();
|
_pcView3D->redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,9 +293,9 @@ int PolyPickerSelection::popupMenu()
|
||||||
|
|
||||||
QAction* id = menu.exec(QCursor::pos());
|
QAction* id = menu.exec(QCursor::pos());
|
||||||
|
|
||||||
if(id == fi)
|
if (id == fi)
|
||||||
return Finish;
|
return Finish;
|
||||||
else if(id == ca)
|
else if (id == ca)
|
||||||
return Cancel;
|
return Cancel;
|
||||||
else
|
else
|
||||||
return Restart;
|
return Restart;
|
||||||
|
@ -314,7 +311,7 @@ int PolyPickerSelection::mouseButtonEvent(const SoMouseButtonEvent* const e, con
|
||||||
{
|
{
|
||||||
case SoMouseButtonEvent::BUTTON1:
|
case SoMouseButtonEvent::BUTTON1:
|
||||||
{
|
{
|
||||||
if(!polyline.isWorking()) {
|
if (!polyline.isWorking()) {
|
||||||
polyline.setWorking(true);
|
polyline.setWorking(true);
|
||||||
polyline.clear();
|
polyline.clear();
|
||||||
};
|
};
|
||||||
|
@ -352,10 +349,10 @@ int PolyPickerSelection::mouseButtonEvent(const SoMouseButtonEvent* const e, con
|
||||||
// an inconsistent state.
|
// an inconsistent state.
|
||||||
int id = popupMenu();
|
int id = popupMenu();
|
||||||
|
|
||||||
if(id == Finish || id == Cancel) {
|
if (id == Finish || id == Cancel) {
|
||||||
releaseMouseModel();
|
releaseMouseModel();
|
||||||
}
|
}
|
||||||
else if(id == Restart) {
|
else if (id == Restart) {
|
||||||
_pcView3D->getWidget()->setCursor(cur);
|
_pcView3D->getWidget()->setCursor(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,21 +375,21 @@ int PolyPickerSelection::locationEvent(const SoLocation2Event* const e, const QP
|
||||||
// do all the drawing stuff for us
|
// do all the drawing stuff for us
|
||||||
QPoint clPoint = pos;
|
QPoint clPoint = pos;
|
||||||
|
|
||||||
if(polyline.isWorking()) {
|
if (polyline.isWorking()) {
|
||||||
// check the position
|
// check the position
|
||||||
QRect r = _pcView3D->getGLWidget()->rect();
|
QRect r = _pcView3D->getGLWidget()->rect();
|
||||||
|
|
||||||
if(!r.contains(clPoint)) {
|
if (!r.contains(clPoint)) {
|
||||||
if(clPoint.x() < r.left())
|
if (clPoint.x() < r.left())
|
||||||
clPoint.setX(r.left());
|
clPoint.setX(r.left());
|
||||||
|
|
||||||
if(clPoint.x() > r.right())
|
if (clPoint.x() > r.right())
|
||||||
clPoint.setX(r.right());
|
clPoint.setX(r.right());
|
||||||
|
|
||||||
if(clPoint.y() < r.top())
|
if (clPoint.y() < r.top())
|
||||||
clPoint.setY(r.top());
|
clPoint.setY(r.top());
|
||||||
|
|
||||||
if(clPoint.y() > r.bottom())
|
if (clPoint.y() > r.bottom())
|
||||||
clPoint.setY(r.bottom());
|
clPoint.setY(r.bottom());
|
||||||
|
|
||||||
#ifdef FC_OS_WINDOWS
|
#ifdef FC_OS_WINDOWS
|
||||||
|
@ -432,22 +429,22 @@ int PolyClipSelection::popupMenu()
|
||||||
QAction* co = menu.addAction(QObject::tr("Outer"));
|
QAction* co = menu.addAction(QObject::tr("Outer"));
|
||||||
QAction* ca = menu.addAction(QObject::tr("Cancel"));
|
QAction* ca = menu.addAction(QObject::tr("Cancel"));
|
||||||
|
|
||||||
if(getPositions().size() < 3) {
|
if (getPositions().size() < 3) {
|
||||||
ci->setEnabled(false);
|
ci->setEnabled(false);
|
||||||
co->setEnabled(false);
|
co->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QAction* id = menu.exec(QCursor::pos());
|
QAction* id = menu.exec(QCursor::pos());
|
||||||
|
|
||||||
if(id == ci) {
|
if (id == ci) {
|
||||||
m_bInner = true;
|
m_bInner = true;
|
||||||
return Finish;
|
return Finish;
|
||||||
}
|
}
|
||||||
else if(id == co) {
|
else if (id == co) {
|
||||||
m_bInner = false;
|
m_bInner = false;
|
||||||
return Finish;
|
return Finish;
|
||||||
}
|
}
|
||||||
else if(id == ca)
|
else if (id == ca)
|
||||||
return Cancel;
|
return Cancel;
|
||||||
else
|
else
|
||||||
return Restart;
|
return Restart;
|
||||||
|
@ -492,9 +489,9 @@ int BrushSelection::popupMenu()
|
||||||
|
|
||||||
QAction* id = menu.exec(QCursor::pos());
|
QAction* id = menu.exec(QCursor::pos());
|
||||||
|
|
||||||
if(id == fi)
|
if (id == fi)
|
||||||
return Finish;
|
return Finish;
|
||||||
else if(id == ca)
|
else if (id == ca)
|
||||||
return Cancel;
|
return Cancel;
|
||||||
else
|
else
|
||||||
return Restart;
|
return Restart;
|
||||||
|
@ -505,28 +502,28 @@ int BrushSelection::locationEvent(const SoLocation2Event* const e, const QPoint&
|
||||||
// do all the drawing stuff for us
|
// do all the drawing stuff for us
|
||||||
QPoint clPoint = pos;
|
QPoint clPoint = pos;
|
||||||
|
|
||||||
if(polyline.isWorking()) {
|
if (polyline.isWorking()) {
|
||||||
// check the position
|
// check the position
|
||||||
QRect r = _pcView3D->getGLWidget()->rect();
|
QRect r = _pcView3D->getGLWidget()->rect();
|
||||||
|
|
||||||
if(!r.contains(clPoint)) {
|
if (!r.contains(clPoint)) {
|
||||||
if(clPoint.x() < r.left())
|
if (clPoint.x() < r.left())
|
||||||
clPoint.setX(r.left());
|
clPoint.setX(r.left());
|
||||||
|
|
||||||
if(clPoint.x() > r.right())
|
if (clPoint.x() > r.right())
|
||||||
clPoint.setX(r.right());
|
clPoint.setX(r.right());
|
||||||
|
|
||||||
if(clPoint.y() < r.top())
|
if (clPoint.y() < r.top())
|
||||||
clPoint.setY(r.top());
|
clPoint.setY(r.top());
|
||||||
|
|
||||||
if(clPoint.y() > r.bottom())
|
if (clPoint.y() > r.bottom())
|
||||||
clPoint.setY(r.bottom());
|
clPoint.setY(r.bottom());
|
||||||
}
|
}
|
||||||
|
|
||||||
SbVec2s last = _clPoly.back();
|
SbVec2s last = _clPoly.back();
|
||||||
SbVec2s curr = e->getPosition();
|
SbVec2s curr = e->getPosition();
|
||||||
|
|
||||||
if(abs(last[0]-curr[0]) > 20 || abs(last[1]-curr[1]) > 20)
|
if (abs(last[0]-curr[0]) > 20 || abs(last[1]-curr[1]) > 20)
|
||||||
_clPoly.push_back(curr);
|
_clPoly.push_back(curr);
|
||||||
|
|
||||||
polyline.addNode(clPoint);
|
polyline.addNode(clPoint);
|
||||||
|
@ -570,7 +567,7 @@ void RubberbandSelection::initialize()
|
||||||
rubberband.setColor(1.0, 1.0, 0.0, 0.5);
|
rubberband.setColor(1.0, 1.0, 0.0, 0.5);
|
||||||
_pcView3D->addGraphicsItem(&rubberband);
|
_pcView3D->addGraphicsItem(&rubberband);
|
||||||
if (QGLFramebufferObject::hasOpenGLFramebufferObjects()) {
|
if (QGLFramebufferObject::hasOpenGLFramebufferObjects()) {
|
||||||
_pcView3D->setRenderFramebuffer(true);
|
_pcView3D->setRenderType(View3DInventorViewer::Image);
|
||||||
}
|
}
|
||||||
_pcView3D->redraw();
|
_pcView3D->redraw();
|
||||||
}
|
}
|
||||||
|
@ -579,7 +576,7 @@ void RubberbandSelection::terminate()
|
||||||
{
|
{
|
||||||
_pcView3D->removeGraphicsItem(&rubberband);
|
_pcView3D->removeGraphicsItem(&rubberband);
|
||||||
if (QGLFramebufferObject::hasOpenGLFramebufferObjects()) {
|
if (QGLFramebufferObject::hasOpenGLFramebufferObjects()) {
|
||||||
_pcView3D->setRenderFramebuffer(false);
|
_pcView3D->setRenderType(View3DInventorViewer::Native);
|
||||||
}
|
}
|
||||||
_pcView3D->redraw();
|
_pcView3D->redraw();
|
||||||
}
|
}
|
||||||
|
@ -596,7 +593,7 @@ int RubberbandSelection::mouseButtonEvent(const SoMouseButtonEvent* const e, con
|
||||||
|
|
||||||
int ret = Continue;
|
int ret = Continue;
|
||||||
|
|
||||||
if(press) {
|
if (press) {
|
||||||
switch(button)
|
switch(button)
|
||||||
{
|
{
|
||||||
case SoMouseButtonEvent::BUTTON1:
|
case SoMouseButtonEvent::BUTTON1:
|
||||||
|
|
|
@ -98,7 +98,6 @@ protected:
|
||||||
QCursor m_cPrevCursor;
|
QCursor m_cPrevCursor;
|
||||||
int m_iXold, m_iYold;
|
int m_iXold, m_iYold;
|
||||||
int m_iXnew, m_iYnew;
|
int m_iXnew, m_iYnew;
|
||||||
int m_antiAliasing;
|
|
||||||
SbBool m_bInner;
|
SbBool m_bInner;
|
||||||
SbBool mustRedraw;
|
SbBool mustRedraw;
|
||||||
std::vector<SbVec2s> _clPoly;
|
std::vector<SbVec2s> _clPoly;
|
||||||
|
|
|
@ -297,7 +297,7 @@ public:
|
||||||
// *************************************************************************
|
// *************************************************************************
|
||||||
View3DInventorViewer::View3DInventorViewer(QWidget* parent, const QGLWidget* sharewidget)
|
View3DInventorViewer::View3DInventorViewer(QWidget* parent, const QGLWidget* sharewidget)
|
||||||
: Quarter::SoQTQuarterAdaptor(parent, sharewidget), editViewProvider(0), navigation(0),
|
: Quarter::SoQTQuarterAdaptor(parent, sharewidget), editViewProvider(0), navigation(0),
|
||||||
framebuffer(0), axisCross(0), axisGroup(0), editing(FALSE), redirected(FALSE),
|
renderType(Native), framebuffer(0), axisCross(0), axisGroup(0), editing(FALSE), redirected(FALSE),
|
||||||
allowredir(FALSE), overrideMode("As Is"), _viewerPy(0)
|
allowredir(FALSE), overrideMode("As Is"), _viewerPy(0)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
@ -305,7 +305,7 @@ View3DInventorViewer::View3DInventorViewer(QWidget* parent, const QGLWidget* sha
|
||||||
|
|
||||||
View3DInventorViewer::View3DInventorViewer(const QGLFormat& format, QWidget* parent, const QGLWidget* sharewidget)
|
View3DInventorViewer::View3DInventorViewer(const QGLFormat& format, QWidget* parent, const QGLWidget* sharewidget)
|
||||||
: Quarter::SoQTQuarterAdaptor(format, parent, sharewidget), editViewProvider(0), navigation(0),
|
: Quarter::SoQTQuarterAdaptor(format, parent, sharewidget), editViewProvider(0), navigation(0),
|
||||||
framebuffer(0), axisCross(0), axisGroup(0), editing(FALSE), redirected(FALSE),
|
renderType(Native), framebuffer(0), axisCross(0), axisGroup(0), editing(FALSE), redirected(FALSE),
|
||||||
allowredir(FALSE), overrideMode("As Is"), _viewerPy(0)
|
allowredir(FALSE), overrideMode("As Is"), _viewerPy(0)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
@ -1186,25 +1186,45 @@ void View3DInventorViewer::clearGraphicsItems()
|
||||||
this->graphicsItems.clear();
|
this->graphicsItems.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void View3DInventorViewer::setRenderFramebuffer(const SbBool enable)
|
void View3DInventorViewer::setRenderType(const RenderType type)
|
||||||
{
|
{
|
||||||
if(!enable) {
|
renderType = type;
|
||||||
|
|
||||||
|
glImage = QImage();
|
||||||
|
if (type != Framebuffer) {
|
||||||
delete framebuffer;
|
delete framebuffer;
|
||||||
framebuffer = 0;
|
framebuffer = 0;
|
||||||
}
|
}
|
||||||
else if(!this->framebuffer) {
|
|
||||||
|
switch (type) {
|
||||||
|
case Native:
|
||||||
|
break;
|
||||||
|
case Framebuffer:
|
||||||
|
if (!framebuffer) {
|
||||||
const SbViewportRegion vp = this->getSoRenderManager()->getViewportRegion();
|
const SbViewportRegion vp = this->getSoRenderManager()->getViewportRegion();
|
||||||
SbVec2s size = vp.getViewportSizePixels();
|
SbVec2s size = vp.getViewportSizePixels();
|
||||||
|
|
||||||
static_cast<QGLWidget*>(this->viewport())->makeCurrent();
|
QGLWidget* gl = static_cast<QGLWidget*>(this->viewport());
|
||||||
this->framebuffer = new QGLFramebufferObject(size[0],size[1],QGLFramebufferObject::Depth);
|
gl->makeCurrent();
|
||||||
renderToFramebuffer(this->framebuffer);
|
framebuffer = new QGLFramebufferObject(size[0],size[1],QGLFramebufferObject::Depth);
|
||||||
|
renderToFramebuffer(framebuffer);
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
|
case Image:
|
||||||
|
{
|
||||||
|
const SbViewportRegion vp = this->getSoRenderManager()->getViewportRegion();
|
||||||
|
SbVec2s size = vp.getViewportSizePixels();
|
||||||
|
|
||||||
SbBool View3DInventorViewer::isRenderFramebuffer() const
|
QGLWidget* gl = static_cast<QGLWidget*>(this->viewport());
|
||||||
{
|
gl->makeCurrent();
|
||||||
return this->framebuffer != 0;
|
int w = gl->width();
|
||||||
|
int h = gl->height();
|
||||||
|
QImage img(QSize(w,h), QImage::Format_RGB32);
|
||||||
|
glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, img.bits());
|
||||||
|
glImage = img;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void View3DInventorViewer::renderToFramebuffer(QGLFramebufferObject* fbo)
|
void View3DInventorViewer::renderToFramebuffer(QGLFramebufferObject* fbo)
|
||||||
|
@ -1240,10 +1260,17 @@ void View3DInventorViewer::renderToFramebuffer(QGLFramebufferObject* fbo)
|
||||||
|
|
||||||
void View3DInventorViewer::actualRedraw()
|
void View3DInventorViewer::actualRedraw()
|
||||||
{
|
{
|
||||||
if(this->framebuffer)
|
switch (renderType) {
|
||||||
renderFramebuffer();
|
case Native:
|
||||||
else
|
|
||||||
renderScene();
|
renderScene();
|
||||||
|
break;
|
||||||
|
case Framebuffer:
|
||||||
|
renderFramebuffer();
|
||||||
|
break;
|
||||||
|
case Image:
|
||||||
|
renderGLImage();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void View3DInventorViewer::renderFramebuffer()
|
void View3DInventorViewer::renderFramebuffer()
|
||||||
|
@ -1278,7 +1305,33 @@ void View3DInventorViewer::renderFramebuffer()
|
||||||
printDimension();
|
printDimension();
|
||||||
navigation->redraw();
|
navigation->redraw();
|
||||||
|
|
||||||
for(std::list<GLGraphicsItem*>::iterator it = this->graphicsItems.begin(); it != this->graphicsItems.end(); ++it)
|
for (std::list<GLGraphicsItem*>::iterator it = this->graphicsItems.begin(); it != this->graphicsItems.end(); ++it)
|
||||||
|
(*it)->paintGL();
|
||||||
|
|
||||||
|
glEnable(GL_LIGHTING);
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
void View3DInventorViewer::renderGLImage()
|
||||||
|
{
|
||||||
|
const SbViewportRegion vp = this->getSoRenderManager()->getViewportRegion();
|
||||||
|
SbVec2s size = vp.getViewportSizePixels();
|
||||||
|
|
||||||
|
glDisable(GL_LIGHTING);
|
||||||
|
glViewport(0, 0, size[0], size[1]);
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
glDrawPixels(glImage.width(),glImage.height(),GL_RGBA,GL_UNSIGNED_BYTE,glImage.bits());
|
||||||
|
|
||||||
|
printDimension();
|
||||||
|
navigation->redraw();
|
||||||
|
|
||||||
|
for (std::list<GLGraphicsItem*>::iterator it = this->graphicsItems.begin(); it != this->graphicsItems.end(); ++it)
|
||||||
(*it)->paintGL();
|
(*it)->paintGL();
|
||||||
|
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
|
@ -1342,7 +1395,7 @@ void View3DInventorViewer::renderScene(void)
|
||||||
// Render overlay front scenegraph.
|
// Render overlay front scenegraph.
|
||||||
glra->apply(this->foregroundroot);
|
glra->apply(this->foregroundroot);
|
||||||
|
|
||||||
if(this->axiscrossEnabled) {
|
if (this->axiscrossEnabled) {
|
||||||
this->drawAxisCross();
|
this->drawAxisCross();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1352,7 +1405,7 @@ void View3DInventorViewer::renderScene(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Immediately reschedule to get continous spin animation.
|
// Immediately reschedule to get continous spin animation.
|
||||||
if(this->isAnimating()) {
|
if (this->isAnimating()) {
|
||||||
this->getSoRenderManager()->scheduleRedraw();
|
this->getSoRenderManager()->scheduleRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1364,7 +1417,7 @@ void View3DInventorViewer::renderScene(void)
|
||||||
printDimension();
|
printDimension();
|
||||||
navigation->redraw();
|
navigation->redraw();
|
||||||
|
|
||||||
for(std::list<GLGraphicsItem*>::iterator it = this->graphicsItems.begin(); it != this->graphicsItems.end(); ++it)
|
for (std::list<GLGraphicsItem*>::iterator it = this->graphicsItems.begin(); it != this->graphicsItems.end(); ++it)
|
||||||
(*it)->paintGL();
|
(*it)->paintGL();
|
||||||
|
|
||||||
//fps rendering
|
//fps rendering
|
||||||
|
@ -2640,66 +2693,6 @@ void View3DInventorViewer::turnDeltaDimensionsOff()
|
||||||
static_cast<SoSwitch*>(dimensionRoot->getChild(1))->whichChild = SO_SWITCH_NONE;
|
static_cast<SoSwitch*>(dimensionRoot->getChild(1))->whichChild = SO_SWITCH_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void View3DInventorViewer::setAntiAliasingMode(View3DInventorViewer::AntiAliasing mode)
|
|
||||||
{
|
|
||||||
int buffers = 1;
|
|
||||||
SbBool smoothing = false;
|
|
||||||
|
|
||||||
switch(mode) {
|
|
||||||
case Smoothing:
|
|
||||||
smoothing = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MSAA2x:
|
|
||||||
buffers = 2;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MSAA4x:
|
|
||||||
buffers = 4;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MSAA8x:
|
|
||||||
buffers = 8;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case None:
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (getSoRenderManager()->getGLRenderAction()->isSmoothing() != smoothing)
|
|
||||||
getSoRenderManager()->getGLRenderAction()->setSmoothing(smoothing);
|
|
||||||
|
|
||||||
if (static_cast<QGLWidget*>(this->viewport())->format().samples() != buffers)
|
|
||||||
Base::Console().Message("To change multisampling settings please close and open the 3d view again\n");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
View3DInventorViewer::AntiAliasing View3DInventorViewer::getAntiAliasingMode() const
|
|
||||||
{
|
|
||||||
if(getSoRenderManager()->getGLRenderAction()->isSmoothing())
|
|
||||||
return Smoothing;
|
|
||||||
|
|
||||||
int buffers = static_cast<QGLWidget*>(this->viewport())->format().samples();
|
|
||||||
|
|
||||||
switch(buffers) {
|
|
||||||
case 1:
|
|
||||||
return None;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
return MSAA2x;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
return MSAA4x;
|
|
||||||
|
|
||||||
case 8:
|
|
||||||
return MSAA8x;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return None;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject *View3DInventorViewer::getPyObject(void)
|
PyObject *View3DInventorViewer::getPyObject(void)
|
||||||
{
|
{
|
||||||
if (!_viewerPy)
|
if (!_viewerPy)
|
||||||
|
|
|
@ -33,8 +33,9 @@
|
||||||
#include <Inventor/nodes/SoEventCallback.h>
|
#include <Inventor/nodes/SoEventCallback.h>
|
||||||
#include <Inventor/nodes/SoSwitch.h>
|
#include <Inventor/nodes/SoSwitch.h>
|
||||||
#include <Inventor/SbRotation.h>
|
#include <Inventor/SbRotation.h>
|
||||||
#include "Gui/Quarter/SoQTQuarterAdaptor.h"
|
#include <Gui/Quarter/SoQTQuarterAdaptor.h>
|
||||||
#include <QCursor>
|
#include <QCursor>
|
||||||
|
#include <QImage>
|
||||||
|
|
||||||
#include <Gui/Selection.h>
|
#include <Gui/Selection.h>
|
||||||
|
|
||||||
|
@ -120,6 +121,16 @@ public:
|
||||||
};
|
};
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
/** @name Render mode
|
||||||
|
*/
|
||||||
|
//@{
|
||||||
|
enum RenderType {
|
||||||
|
Native,
|
||||||
|
Framebuffer,
|
||||||
|
Image
|
||||||
|
};
|
||||||
|
//@}
|
||||||
|
|
||||||
View3DInventorViewer (QWidget *parent, const QGLWidget* sharewidget = 0);
|
View3DInventorViewer (QWidget *parent, const QGLWidget* sharewidget = 0);
|
||||||
View3DInventorViewer (const QGLFormat& format, QWidget *parent, const QGLWidget* sharewidget = 0);
|
View3DInventorViewer (const QGLFormat& format, QWidget *parent, const QGLWidget* sharewidget = 0);
|
||||||
virtual ~View3DInventorViewer();
|
virtual ~View3DInventorViewer();
|
||||||
|
@ -151,8 +162,7 @@ public:
|
||||||
void setFeedbackSize(const int size);
|
void setFeedbackSize(const int size);
|
||||||
int getFeedbackSize(void) const;
|
int getFeedbackSize(void) const;
|
||||||
|
|
||||||
void setRenderFramebuffer(const SbBool enable);
|
void setRenderType(const RenderType type);
|
||||||
SbBool isRenderFramebuffer() const;
|
|
||||||
void renderToFramebuffer(QGLFramebufferObject*);
|
void renderToFramebuffer(QGLFramebufferObject*);
|
||||||
|
|
||||||
virtual void setViewing(SbBool enable);
|
virtual void setViewing(SbBool enable);
|
||||||
|
@ -294,15 +304,6 @@ public:
|
||||||
void addDimensionDelta(SoNode *node);
|
void addDimensionDelta(SoNode *node);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/** @name Anti-Aliasing Control
|
|
||||||
* the anti-aliasing mode is controled by parameters through view3dinventor.
|
|
||||||
* don't call them directly. Instead set the parameter View/AntiAliasing.
|
|
||||||
*/
|
|
||||||
//@{
|
|
||||||
void setAntiAliasingMode(AntiAliasing mode);
|
|
||||||
AntiAliasing getAntiAliasingMode() const;
|
|
||||||
//@}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the camera's orientation. If isAnimationEnabled() returns
|
* Set the camera's orientation. If isAnimationEnabled() returns
|
||||||
* \a TRUE the reorientation is animated, otherwise its directly
|
* \a TRUE the reorientation is animated, otherwise its directly
|
||||||
|
@ -354,6 +355,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void renderScene();
|
void renderScene();
|
||||||
void renderFramebuffer();
|
void renderFramebuffer();
|
||||||
|
void renderGLImage();
|
||||||
void animatedViewAll(int steps, int ms);
|
void animatedViewAll(int steps, int ms);
|
||||||
virtual void actualRedraw(void);
|
virtual void actualRedraw(void);
|
||||||
virtual void setSeekMode(SbBool enable);
|
virtual void setSeekMode(SbBool enable);
|
||||||
|
@ -394,7 +396,10 @@ private:
|
||||||
SoEventCallback* pEventCallback;
|
SoEventCallback* pEventCallback;
|
||||||
NavigationStyle* navigation;
|
NavigationStyle* navigation;
|
||||||
SoFCUnifiedSelection* selectionRoot;
|
SoFCUnifiedSelection* selectionRoot;
|
||||||
|
|
||||||
|
RenderType renderType;
|
||||||
QGLFramebufferObject* framebuffer;
|
QGLFramebufferObject* framebuffer;
|
||||||
|
QImage glImage;
|
||||||
SoSwitch *dimensionRoot;
|
SoSwitch *dimensionRoot;
|
||||||
|
|
||||||
// small axis cross in the corner
|
// small axis cross in the corner
|
||||||
|
|
|
@ -340,7 +340,7 @@ Rubberband(Gui::View3DInventorViewer* v) :view(v)
|
||||||
rubberBandCorner1.setY(200);
|
rubberBandCorner1.setY(200);
|
||||||
rubberBandCorner2.setX(800);
|
rubberBandCorner2.setX(800);
|
||||||
rubberBandCorner2.setY(600);
|
rubberBandCorner2.setY(600);
|
||||||
v->setRenderFramebuffer(true);
|
v->setRenderType(Gui::View3DInventorViewer::Image);
|
||||||
v->getSoRenderManager()->scheduleRedraw();
|
v->getSoRenderManager()->scheduleRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -752,8 +752,8 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe
|
||||||
rubberband->setWorking(false);
|
rubberband->setWorking(false);
|
||||||
|
|
||||||
//disable framebuffer drawing in viewer
|
//disable framebuffer drawing in viewer
|
||||||
if(Gui::Application::Instance->activeDocument()->getActiveView()) {
|
if (Gui::Application::Instance->activeDocument()->getActiveView()) {
|
||||||
static_cast<Gui::View3DInventor *>(Gui::Application::Instance->activeDocument()->getActiveView())->getViewer()->setRenderFramebuffer(false);
|
static_cast<Gui::View3DInventor *>(Gui::Application::Instance->activeDocument()->getActiveView())->getViewer()->setRenderType(Gui::View3DInventorViewer::Native);
|
||||||
}
|
}
|
||||||
|
|
||||||
// a redraw is required in order to clear the rubberband
|
// a redraw is required in order to clear the rubberband
|
||||||
|
@ -1085,7 +1085,7 @@ bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventor
|
||||||
case STATUS_SKETCH_StartRubberBand: {
|
case STATUS_SKETCH_StartRubberBand: {
|
||||||
Mode = STATUS_SKETCH_UseRubberBand;
|
Mode = STATUS_SKETCH_UseRubberBand;
|
||||||
rubberband->setWorking(true);
|
rubberband->setWorking(true);
|
||||||
viewer->setRenderFramebuffer(true);
|
viewer->setRenderType(Gui::View3DInventorViewer::Framebuffer);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case STATUS_SKETCH_UseRubberBand: {
|
case STATUS_SKETCH_UseRubberBand: {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user