Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Mouse wheel zooming scene graph error #72

@Huajian4444

Description

@Huajian4444

Using the web page's example to display a quarter, the default example is:
root->addChild(new SoCone);
At this point, the mouse wheel zooms the scene graph correctly. However, when I do this:
SoCone* cone = new SoCone;
cone->height = 100.0f;
cone->bottomRadius = 50.0f;
root->addChild(cone);
The scene graph zooms correctly when the mouse wheel is scrolled forward;
The scene graph zooms incorrectly when the mouse wheel is scrolled backward.

Please tell me how to fix this. Thank you.

#include <QApplication>
#include <qmainwindow.h>

#include <Inventor/nodes/SoBaseColor.h>
#include <Inventor/nodes/SoCone.h>
#include <Inventor/nodes/SoSeparator.h>

#include <Quarter/Quarter.h>
#include <Quarter/QuarterWidget.h>

int main(int argc, char** argv)
{
	QApplication app(argc, argv);
	// Initializes Quarter library (and implicitly also the Coin and Qt
	// libraries).
	Quarter::init();

	// Make a dead simple scene graph by using the Coin library, only
	// containing a single yellow cone under the scene graph root.
	SoSeparator* root = new SoSeparator;
	root->ref();

	SoBaseColor* col = new SoBaseColor;
	col->rgb = SbColor(1, 1, 0);
	root->addChild(col);

	// Introduce a deliberate error here by setting an invalid value
	bool error{ false };
	if(error)
	{
		SoCone* cone = new SoCone;
		cone->height = 100.0f;
		cone->bottomRadius = 50.0f;
		root->addChild(cone);
	}
	else {
		root->addChild(new SoCone);
	}

	// Create a QuarterWidget for displaying a Coin scene graph
	QuarterWidget* viewer = new QuarterWidget;
	viewer->setSceneGraph(root);

	// make the viewer react to input events similar to the good old
	// ExaminerViewer
	viewer->setNavigationModeFile(QUrl("coin:///scxml/navigation/examiner.xml"));

	QMainWindow* mainWin = new QMainWindow;
	mainWin->setCentralWidget(viewer);
	mainWin->show();

	// Pop up the QuarterWidget
	//viewer->show();
	// Loop until exit.
	app.exec();
	// Clean up resources.
	root->unref();
	delete viewer;

	Quarter::clean();

	return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions