Re: [osg-users] OSG + QT and QTabWidget: Disappearing scene graph

2012-10-31 Thread Roman Grigoriev
Hi, I try also follow advice to make model on first tab visible but on ubuntu 
12.10 qt 4.8.3 and osg svn It doesn't work
I modify event method like this

Code:

virtual bool event( QEvent* event )
{
if (event-type() == QEvent::Timer)
{
if (static_castQTimerEvent*(event)-timerId() == _timerId)
{
frame();
return true;
}
}
if (event-type() == QEvent::Resize)
{
return false;
}
return QWidget::event(event);
}




Any hints?

... 

Thank you!

Cheers,
Roman

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50904#50904





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OSG + QT and QTabWidget: Disappearing scene graph

2012-09-11 Thread Lucas SART
Thanks a lot, with your tip it works !


Alistair Baxter wrote:
 -Original Message-
 
  From:  [mailto:] On Behalf Of Lucas SART
  Sent: 07 September 2012 11:08
  To: 
  Subject: Re:  OSG + QT and QTabWidget: Disappearing scene graph
  
  Hi, 
  
  I had looking for why it doesn't work. It seems that the first tab camera 
  projection 
  matrix and view matrix are not valid (components = -1.#IND) and 
  I 
  don't know why. I tryed to look into OSG code but I don't found what is 
  wrong... 
  If someone have an idea it would be great !
  
 
 Oddly, I think I just encountered this problem yesterday.
 
 If the QT widget ever gets resized to zero (as can happen sometimes during 
 setup and intermediate layout stages), and osgQt::GLWidget::resizeEvent is 
 called with width and height equal to zero, the camera projection matrix gets 
 screwed up due to divide-by-zeroes, and never recovers because resizing 
 always takes into account the existing camera matrix.
 
 I solved the problem by preventing osgQt::GLWidget::resizeEvent being called 
 by my GLWidget subclass if either dimension was zero. But I suppose it would 
 probably be better if a fix was made inside the osgQt library.
 
 ___
 osg-users mailing list
 
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 
  --
 Post generated by Mail2Forum


--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=49923#49923





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OSG + QT and QTabWidget: Disappearing scene graph

2012-09-07 Thread Lucas SART
Hi, 

I had looking for why it doesn't work. It seems that the first tab camera 
projection matrix and view matrix are not valid (components = 
-1.#IND) and I don't know why. I tryed to look into OSG code but I 
don't found what is wrong... If someone have an idea it would be great !

Here is the code I use (running on OSG 3.0.1 and qt 4.7.3) :


Code:

#include QtCore/QTimer
#include QtGui/QApplication
#include QtGui/QGridLayout
#include QTabWidget

#include osgViewer/CompositeViewer
#include osgViewer/ViewerEventHandlers

#include osgGA/TrackballManipulator

#include osgDB/ReadFile

#include osgQt/GraphicsWindowQt

#include iostream

class ViewerWidget : public QWidget, public osgViewer::CompositeViewer
{
public:
ViewerWidget(osgViewer::ViewerBase::ThreadingModel 
threadingModel=osgViewer::CompositeViewer::SingleThreaded) : QWidget()
{
setThreadingModel(threadingModel);

// Create tab widget
QTabWidget* tab = new QTabWidget();

// Add tabs
tab-addTab(addViewWidget( createCamera(0,0,100,100), 
osgDB::readNodeFile(cow.osg) ), tab 1) ;
tab-addTab(addViewWidget( createCamera(0,0,100,100), 
osgDB::readNodeFile(cessna.osg) ), tab 2) ;

// Set layout
QGridLayout* grid = new QGridLayout;
grid-addWidget(tab, 0, 0) ;
setLayout( grid );

setRunFrameScheme(osgViewer::ViewerBase::ON_DEMAND);
_timerId = startTimer(0); 
}

virtual ~ViewerWidget()
{
if (_timerId != 0)
killTimer(_timerId);
} 

QWidget* addViewWidget( osg::Camera* camera, osg::Node* scene )
{
osgViewer::View* view = new osgViewer::View;
view-setCamera( camera );
addView( view );

view-setSceneData( scene );
view-addEventHandler( new osgViewer::StatsHandler );
view-setCameraManipulator( new osgGA::TrackballManipulator );

osgQt::GraphicsWindowQt* gw = dynamic_castosgQt::GraphicsWindowQt*( 
camera-getGraphicsContext() );
return gw ? gw-getGLWidget() : NULL;
}

osg::Camera* createCamera( int x, int y, int w, int h, const std::string 
name=, bool windowDecoration=false )
{
osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
osg::ref_ptrosg::GraphicsContext::Traits traits = new 
osg::GraphicsContext::Traits;
traits-windowName = name;
traits-windowDecoration = windowDecoration;
traits-x = x;
traits-y = y;
traits-width = w;
traits-height = h;
traits-doubleBuffer = true;
traits-alpha = ds-getMinimumNumAlphaBits();
traits-stencil = ds-getMinimumNumStencilBits();
traits-sampleBuffers = ds-getMultiSamples();
traits-samples = ds-getNumMultiSamples();

osg::ref_ptrosg::Camera camera = new osg::Camera;
camera-setGraphicsContext( new osgQt::GraphicsWindowQt(traits.get()) );

camera-setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) );
camera-setViewport( new osg::Viewport(0, 0, traits-width, traits-height) );
camera-setProjectionMatrixAsPerspective(
30.0f, static_castdouble(traits-width)/static_castdouble(traits-height), 
1.0f, 1.0f );
return camera.release();
}

virtual bool event( QEvent* event )
{
if (event-type() == QEvent::Timer)
{
if (static_castQTimerEvent*(event)-timerId() == _timerId)
{
frame();
return true;
}
}
return QWidget::event(event);
} 

protected:
int _timerId;
};

int main( int argc, char** argv )
{
osg::ArgumentParser arguments(argc, argv);

osgViewer::ViewerBase::ThreadingModel threadingModel = 
osgViewer::ViewerBase::CullThreadPerCameraDrawThreadPerContext;
while (arguments.read(--SingleThreaded)) threadingModel = 
osgViewer::ViewerBase::SingleThreaded;
while (arguments.read(--CullDrawThreadPerContext)) threadingModel = 
osgViewer::ViewerBase::CullDrawThreadPerContext;
while (arguments.read(--DrawThreadPerContext)) threadingModel = 
osgViewer::ViewerBase::DrawThreadPerContext;
while (arguments.read(--CullThreadPerCameraDrawThreadPerContext)) 
threadingModel = osgViewer::ViewerBase::CullThreadPerCameraDrawThreadPerContext;

QApplication app(argc, argv);
ViewerWidget* viewWidget = new ViewerWidget(threadingModel);
viewWidget-setGeometry( 100, 100, 800, 600 );
viewWidget-show();
return app.exec();
}




Thanks,
Lucas

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=49837#49837





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OSG + QT and QTabWidget: Disappearing scene graph

2012-09-07 Thread Alistair Baxter
-Original Message-
 From: osg-users-boun...@lists.openscenegraph.org 
 [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Lucas SART
 Sent: 07 September 2012 11:08
 To: osg-users@lists.openscenegraph.org
 Subject: Re: [osg-users] OSG + QT and QTabWidget: Disappearing scene graph

Hi, 

 I had looking for why it doesn't work. It seems that the first tab camera 
 projection 
 matrix and view matrix are not valid (components = -1.#IND) and I 
 don't know why. I tryed to look into OSG code but I don't found what is 
 wrong... 
 If someone have an idea it would be great !

Oddly, I think I just encountered this problem yesterday.

If the QT widget ever gets resized to zero (as can happen sometimes during 
setup and intermediate layout stages), and osgQt::GLWidget::resizeEvent is 
called with width and height equal to zero, the camera projection matrix gets 
screwed up due to divide-by-zeroes, and never recovers because resizing always 
takes into account the existing camera matrix.

I solved the problem by preventing osgQt::GLWidget::resizeEvent being called by 
my GLWidget subclass if either dimension was zero. But I suppose it would 
probably be better if a fix was made inside the osgQt library.

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OSG + QT and QTabWidget: Disappearing scene graph

2012-09-07 Thread Roman Grigoriev
under qt 5.0.0beta1 - it doesn't work
I've got this error

Qt at-spi: error getting the accessibility dbus address:  The name 
org.a11y.Bus was not provided by any .service files 
Accessibility DBus not found. Falling back to session bus.
Registered DEC:  true 
Error in contacting registry 
org.freedesktop.DBus.Error.ServiceUnknown 
The name org.a11y.atspi.Registry was not provided by any .service files 
This plugin does not support setting window opacity
QXcbConnection: XCB error: 3 (BadWindow), sequence: 576, resource id: 46137375, 
major code: 18 (ChangeProperty), minor code: 0
QXcbConnection: XCB error: 3 (BadWindow), sequence: 577, resource id: 46137375, 
major code: 12 (ConfigureWindow), minor code: 0
QXcbConnection: XCB error: 3 (BadWindow), sequence: 578, resource id: 46137375, 
major code: 8 (MapWindow), minor code: 0
QXcbConnection: XCB error: 3 (BadWindow), sequence: 596, resource id: 46137375, 
major code: 18 (ChangeProperty), minor code: 0
QXcbConnection: XCB error: 3 (BadWindow), sequence: 597, resource id: 46137375, 
major code: 12 (ConfigureWindow), minor code: 0
Cannot make QOpenGLContext current in a different thread

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=49844#49844





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OSG + QT and QTabWidget: Disappearing scene graph

2012-09-07 Thread Roman Grigoriev
PS 
if I use singlethreaded
I got errors
QOpenGLContext::swapBuffers() called with non-exposed window, behavior is 
undefined 
QOpenGLContext::swapBuffers() called with non-exposed window, behavior is 
undefined

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=49845#49845





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OSG + QT and QTabWidget: Disappearing scene graph

2012-09-06 Thread Lucas SART

jlouis2k4 wrote:
 Hello Robert,
 
 Thank you for that example. It works great when I use the QTabWidget instead 
 of the QGridLayout. However there is a problem that the first node (In the 
 first tab) Does not show when the program is run. I can open the other tabs 
 and see the nodes in all of them. Am I missing something here?
 
 Thank you!
 
 Cheers,
 Joseph


I got the same problem (the first tab is empty), anyone knows how solve it ?

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=49798#49798





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OSG + QT and QTabWidget: Disappearing scene graph

2011-09-12 Thread Joseph Louis
Hello Robert,

Thank you for that example. It works great when I use the QTabWidget instead of 
the QGridLayout. However there is a problem that the first node (In the first 
tab) Does not show when the program is run. I can open the other tabs and see 
the nodes in all of them. Am I missing something here?

Thank you!

Cheers,
Joseph

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=42636#42636





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OSG + QT and QTabWidget: Disappearing scene graph

2011-09-06 Thread Robert Milharcic
();
return app.exec();
}

Robert Milharcic

-Original Message-
From: osg-users-boun...@lists.openscenegraph.org 
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Joseph Louis
Sent: Tuesday, September 06, 2011 1:10 AM
To: osg-users@lists.openscenegraph.org
Subject: Re: [osg-users] OSG + QT and QTabWidget: Disappearing scene graph

Hi Angus,

I am trying to do the same with my program but the scene does not even appear 
in any of the tbs. I am also using the osgviewerQT example. Were you able to 
get your's to work?

Thank you!

Cheers,
Joseph

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=42433#42433





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OSG + QT and QTabWidget: Disappearing scene graph

2011-09-05 Thread Joseph Louis
Hi Angus,

I am trying to do the same with my program but the scene does not even appear 
in any of the tbs. I am also using the osgviewerQT example. Were you able to 
get your's to work?

Thank you!

Cheers,
Joseph

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=42433#42433





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org