Hi,
I wrote a little sample program to test selection using Coin3D and the
SoQt lib on SuSE Linux Pro 8.0.
The program compiles without any problem but as I click to select an
object, it crashes with a "Memory Access Error".
The sample program is similar to the sample code that comes with the
Coin Do***entation.
Here's the code:
#include <Inventor/Qt/SoQt.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
#include <Inventor/nodes/SoBaseColor.h>
#include <Inventor/nodes/SoCone.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoSelection.h>
#include <Inventor/nodes/SoGroup.h>
#include <Inventor/actions/SoBoxHighlightRenderAction.h>
static SoSelection *group_node=NULL;
void made_selection( void * userdata, SoPath * path )
{
(void)fprintf( stdout, "%sselected %s\n",
userdata == (void *)1L ? "" : "de",
path->getTail()->getTypeId().getName().getString() );
group_node->touch(); // to redraw
}
int main(int argc, char ** argv) {
// Initializes SoQt library (and implicitly also the Coin and Qt
// libraries). Returns a top-level / shell Qt window to use.
QWidget * mainwin = SoQt::init(argc, argv, argv[0]);
// Make a dead simple scene graph by using the Coin library, only
// containing a single yellow cone under the scenegraph root.
SoSeparator * root = new SoSeparator;
SoSelection *group_node=new SoSelection;
group_node->policy = SoSelection::****FT;
group_node->ref();
SoBaseColor * col = new SoBaseColor;
col->rgb = SbColor(1, 1, 0);
group_node->addChild(col);
group_node->addChild(new SoCone);
group_node->addSelectionCallback( made_selection, (void *)1L );
//group_node->touch();
group_node->addDeselectionCallback( made_selection, (void *)0L );
//group_node->touch();
// Use one of the convenient SoQt viewer cl*****.
SoQtExaminerViewer * eviewer = new SoQtExaminerViewer(mainwin);
eviewer->setSceneGraph(group_node);
eviewer->setGLRenderAction( new SoBoxHighlightRenderAction );
eviewer->setViewing( FALSE );
eviewer->show();
// Pop up the main window.
SoQt::show(mainwin);
// Loop until exit.
SoQt::mainLoop();
// Clean up resources.
delete eviewer;
group_node->unref();
return 0;
}
Anyone can help?
Thanks in advance,
Dennis Schramm
--
batchtranscode.sourceforge.net
"Sie war so fett, ich musste sie in Mehl waelzen, um die feuchte Stelle
zu finden!"


|