Coin, SoQt, and Qt5

617 views
Skip to first unread message

Tom Roberts

unread,
Sep 9, 2017, 12:59:29 AM9/9/17
to coin3d-discuss
I have been using Coin3D and SoXt since 2006, and SoQt with Qt4 for several years. But I fear I may have to abandon Coin3D altogether because I cannot get it to work with Qt5. I see there is work on SoQt to work with Qt5, and messages imply that it works for the developers. Ditto for Quarter. But when I download it it will not build. I have tried several variations involving both SoQt and Quarter; some say that it needs Qt4, and some say it cannot find CMake files for coin.

It looks like I need to get the source to the CMake branch of coin, and the default branch of SoQt. But I cannot figure out how to do that: "git clone https://tj...@bitbucket.org/Coin3D/coin" fails to find the repository (I can login there as tjrob). I have never used git so may not have this right (the Clone link uses a command "hg", which I don't have). For instance, do I need to join some team?

Is there any way I can get source for Coin and SoQt that will work with Qt5 and build on Mac OS X El Capitan (10.11.6)?

Pablo Stickar

unread,
Sep 9, 2017, 4:14:07 AM9/9/17
to coin3d-...@googlegroups.com

Hello

on Linux-Gentoo there is a package "media-libs/quarter-1.0.0-r1" (actually, an ebuild) that downloads and compiles quarter. I do not know how the ebuild works, or if version 1.0.0 is actually related to a "modern" version.

Regarding the code that can be obtained with the command "hg", I agree that it is essential to select the right branch (not the one suggested by default!). Otherwise one gets code that does not compile. The CMake branches seem to be the mainained ones. On Linux-Gentoo I managed to use "hg" without any special arrangements. Although I got to a point where things appeared to compile smoothly, I preferred to keep the ebuild, because Gentoo is rather allergic to install scripts.

I think a bit of clean up would be very helpful. Or at least a readme file that clearly states the last date at which something compiled (and on what platform), and what the goals of each branch are. Right now the only help seems to be the date of the latest commit, but even that is no safe bet.

Kind regards,
Pablo
--
You received this message because you are subscribed to the Google Groups "coin3d-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coin3d-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Markus Rickert

unread,
Oct 24, 2017, 2:06:39 PM10/24/17
to coin3d-discuss
Hi,

I've created a patch for SoQt a while ago to support Qt5 that is now part of the default branch. This works in combination with the CMake branch of Coin and the default branch of simage (which now also includes CMake support).

In order to use this, you will have to clone all three repositories via the following commands after installing Mercurial (https://www.mercurial-scm.org/) as Coin3D does not use Git:

hg clone https://bitbucket.org/Coin3D/simage
hg clone https://bitbucket.org/Coin3D/coin -r CMake
hg clone https://bitbucket.org/Coin3D/soqt

You can then build them in the order simage->coin->soqt using CMake (adapt the following command for coin and soqt). I've tested this on Yosemite and High Sierra. For Qt, you have to set the environment variable CMAKE_PREFIX_PATH to the lib\cmake folder of the Qt installation.

mkdir simage-build && cd simage-build
cmake ../simage && make install

As an alternative solution, I have set up corresponding packages descriptions for Homebrew (https://brew.sh/) a few days ago. After installing Homebrew, you can compile all three projects with this command:

brew tap roboticslibrary/rl
brew install soqt

Best regards,

Markus Rickert

Doug Epps

unread,
Oct 26, 2017, 1:41:44 PM10/26/17
to coin3d-discuss

I've got a trivial SoQtExaminerViewer test on a macbook pro that seems to have the gl -> qt window size wrong.
Possibly because of retina-display scaling issues  ?  

Basically my GL rendering happens in the lower-left corner of the window.
Mouse events seem to be correctly using the whole window coords.

resizes keep this behavior, and the empty parts of the window seem to be cleared properly (i.e. they stay black, not random stuff from the screen).

Anyone using the SoQt stuff on a mac having this issue ?

Randall O'Reilly

unread,
Oct 26, 2017, 1:53:36 PM10/26/17
to coin3d-...@googlegroups.com
I fixed this in our quarter fork: https://grey.colorado.edu/emergent/index.php/Coin3d — mostly in revision 33 — attaching the diffs in case this is helpful in porting over to SoQt. all the stuff about devicepixelratio.. Cheers,

- Randy

root@shadow:/usr/local/Coin3d/quarter/ # svn -r 33:32 diff
Index: include/Quarter/QuarterWidget.h
===================================================================
--- include/Quarter/QuarterWidget.h (revision 33)
+++ include/Quarter/QuarterWidget.h (revision 32)
@@ -74,7 +74,6 @@
Q_PROPERTY(TransparencyType transparencyType READ transparencyType WRITE setTransparencyType)
Q_PROPERTY(RenderMode renderMode READ renderMode WRITE setRenderMode)
Q_PROPERTY(StereoMode stereoMode READ stereoMode WRITE setStereoMode)
- Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio NOTIFY devicePixelRatioChanged)

Q_ENUMS(TransparencyType)
Q_ENUMS(RenderMode)
@@ -128,8 +127,6 @@
void setBackgroundColor(const QColor & color);
QColor backgroundColor(void) const;

- qreal devicePixelRatio(void) const;
-
void resetNavigationModeFile(void);
void setNavigationModeFile(const QUrl & url = QUrl(DEFAULT_NAVIGATIONFILE));
const QUrl & navigationModeFile(void) const;
@@ -190,15 +187,11 @@
void setStereoMode(StereoMode mode);
void setTransparencyType(TransparencyType type);

-signals:
- void devicePixelRatioChanged(qreal dev_pixel_ratio);
-
protected:
virtual void resizeGL(int width, int height);
virtual void initializeGL(void);
virtual void paintGL(void);
virtual void actualRedraw(void);
- virtual bool updateDevicePixelRatio(void);

private:
void constructor(const QT_GL_WIDGET * sharewidget);
Index: include/Quarter/devices/InputDevice.h
===================================================================
--- include/Quarter/devices/InputDevice.h (revision 33)
+++ include/Quarter/devices/InputDevice.h (revision 32)
@@ -32,11 +32,9 @@

namespace SIM { namespace Coin3D { namespace Quarter {

-class QuarterWidget;
-
class QUARTER_DLL_API InputDevice {
public:
- InputDevice(QuarterWidget* quarter);
+ InputDevice(void);
virtual ~InputDevice() {}

/*!
@@ -52,7 +50,6 @@
protected:
SbVec2s mousepos;
SbVec2s windowsize;
- QuarterWidget* quarter;
};

}}} // namespace
Index: include/Quarter/devices/Keyboard.h
===================================================================
--- include/Quarter/devices/Keyboard.h (revision 33)
+++ include/Quarter/devices/Keyboard.h (revision 32)
@@ -33,7 +33,7 @@

class QUARTER_DLL_API Keyboard : public InputDevice {
public:
- Keyboard(QuarterWidget* quarter);
+ Keyboard(void);
virtual ~Keyboard();

virtual const SoEvent * translateEvent(QEvent * event);
Index: include/Quarter/devices/SpaceNavigatorDevice.h
===================================================================
--- include/Quarter/devices/SpaceNavigatorDevice.h (revision 33)
+++ include/Quarter/devices/SpaceNavigatorDevice.h (revision 32)
@@ -33,7 +33,7 @@

class QUARTER_DLL_API SpaceNavigatorDevice : public InputDevice {
public:
- SpaceNavigatorDevice(QuarterWidget* quarter);
+ SpaceNavigatorDevice(void);
virtual ~SpaceNavigatorDevice();
virtual const SoEvent * translateEvent(QEvent * event);

Index: include/Quarter/devices/Mouse.h
===================================================================
--- include/Quarter/devices/Mouse.h (revision 33)
+++ include/Quarter/devices/Mouse.h (revision 32)
@@ -28,13 +28,12 @@

class QEvent;
class SoEvent;
-class QuarterWidget;

namespace SIM { namespace Coin3D { namespace Quarter {

class QUARTER_DLL_API Mouse : public InputDevice {
public:
- Mouse(QuarterWidget* quarter);
+ Mouse(void);
virtual ~Mouse();

virtual const SoEvent * translateEvent(QEvent * event);
Index: src/Quarter/Keyboard.cpp
===================================================================
--- src/Quarter/Keyboard.cpp (revision 33)
+++ src/Quarter/Keyboard.cpp (revision 32)
@@ -41,8 +41,7 @@

#define PRIVATE(obj) obj->pimpl

-Keyboard::Keyboard(QuarterWidget* quart) :
- InputDevice(quart)
+Keyboard::Keyboard(void)
{
PRIVATE(this) = new KeyboardP(this);
}
Index: src/Quarter/QuarterWidgetP.cpp
===================================================================
--- src/Quarter/QuarterWidgetP.cpp (revision 33)
+++ src/Quarter/QuarterWidgetP.cpp (revision 32)
@@ -72,7 +72,6 @@
interactionmodeenabled(false),
clearzbuffer(true),
clearwindow(true),
- device_pixel_ratio(1.0),
addactions(true)
{
this->cachecontext = findCacheContext(masterptr, sharewidget);
Index: src/Quarter/QuarterWidgetP.h
===================================================================
--- src/Quarter/QuarterWidgetP.h (revision 33)
+++ src/Quarter/QuarterWidgetP.h (revision 32)
@@ -90,7 +90,6 @@
bool processdelayqueue;
QUrl navigationModeFile;
SoScXMLStateMachine * currentStateMachine;
- qreal device_pixel_ratio;

static void rendercb(void * userdata, SoRenderManager *);
static void prerendercb(void * userdata, SoRenderManager * manager);
Index: src/Quarter/InputDevice.cpp
===================================================================
--- src/Quarter/InputDevice.cpp (revision 33)
+++ src/Quarter/InputDevice.cpp (revision 32)
@@ -23,7 +23,6 @@
#include <Quarter/devices/InputDevice.h>
#include <QInputEvent>
#include <Inventor/events/SoEvents.h>
-#include <Quarter/QuarterWidget.h>

using namespace SIM::Coin3D::Quarter;

@@ -35,8 +34,7 @@
devices.
*/

-InputDevice::InputDevice(QuarterWidget* quart) :
- quarter(quart)
+InputDevice::InputDevice(void)
{
this->mousepos = SbVec2s(0, 0);
}
Index: src/Quarter/SpaceNavigatorDevice.cpp
===================================================================
--- src/Quarter/SpaceNavigatorDevice.cpp (revision 33)
+++ src/Quarter/SpaceNavigatorDevice.cpp (revision 32)
@@ -72,8 +72,7 @@
#define PRIVATE(obj) obj->pimpl
using namespace SIM::Coin3D::Quarter;

-SpaceNavigatorDevice::SpaceNavigatorDevice(QuarterWidget* quart) :
- InputDevice(quart)
+SpaceNavigatorDevice::SpaceNavigatorDevice()
{
PRIVATE(this) = new SpaceNavigatorDeviceP(this);

Index: src/Quarter/QuarterWidget.cpp
===================================================================
--- src/Quarter/QuarterWidget.cpp (revision 33)
+++ src/Quarter/QuarterWidget.cpp (revision 32)
@@ -456,23 +456,6 @@
}

/*!
- \property QuarterWidget::devicePixelRatio
-
- \copydetails QuarterWidget::devicePixelRatio
-*/
-
-/*!
- The ratio between logical and physical pixel sizes -- obtained from the window that
-the widget is located within, and updated whenver any change occurs, emitting a devicePixelRatioChanged signal. Only available for version Qt 5.6 and above (will be 1.0 for all previous versions)
- */
-
-qreal
-QuarterWidget::devicePixelRatio(void) const
-{
- return PRIVATE(this)->device_pixel_ratio;
-}
-
-/*!
Sets the Inventor scenegraph to be rendered
*/
void
@@ -674,16 +657,15 @@
this->getSoRenderManager()->reinitialize();
}

-
-bool
-QuarterWidget::updateDevicePixelRatio(void) {
+/*!
+ Overridden from QGLWidget to resize the Coin scenegraph
+ */
+void
+QuarterWidget::resizeGL(int width, int height)
+{
#ifdef QT_OPEN_GL_WIDGET
- qreal dev_pix_ratio = 1.0;
- QWidget* winwidg = window();
- QWindow* win = NULL;
- if(winwidg) {
- win = winwidg->windowHandle();
- }
+ float dev_pix_ratio = 1.0f;
+ QWindow* win = windowHandle();
if(win) {
dev_pix_ratio = win->devicePixelRatio();
}
@@ -690,28 +672,9 @@
else {
dev_pix_ratio = ((QGuiApplication*)QGuiApplication::instance())->devicePixelRatio();
}
- if(PRIVATE(this)->device_pixel_ratio != dev_pix_ratio) {
- PRIVATE(this)->device_pixel_ratio = dev_pix_ratio;
- emit devicePixelRatioChanged(dev_pix_ratio);
- return true;
- }
-#endif
- return false;
-}
-
-/*!
- Overridden from QGLWidget to resize the Coin scenegraph
- */
-void
-QuarterWidget::resizeGL(int width, int height)
-{
-#ifdef QT_OPEN_GL_WIDGET
- updateDevicePixelRatio();
- qreal dev_pix_ratio = devicePixelRatio();
width = (int)(dev_pix_ratio * width);
height = (int)(dev_pix_ratio * height);
#endif
-
SbViewportRegion vp(width, height);
PRIVATE(this)->sorendermanager->setViewportRegion(vp);
PRIVATE(this)->soeventmanager->setViewportRegion(vp);
@@ -723,17 +686,6 @@
void
QuarterWidget::paintGL(void)
{
-#ifdef QT_OPEN_GL_WIDGET
- if(updateDevicePixelRatio()) {
- qreal dev_pix_ratio = devicePixelRatio();
- int width = (int)(dev_pix_ratio * this->width());
- int height = (int)(dev_pix_ratio * this->height());
- SbViewportRegion vp(width, height);
- PRIVATE(this)->sorendermanager->setViewportRegion(vp);
- PRIVATE(this)->soeventmanager->setViewportRegion(vp);
- }
-#endif
-
assert(this->isValid() && "No valid GL context found!");
// We might have to process the delay queue here since we don't know
// if paintGL() is called from Qt, and we might have some sensors
Index: src/Quarter/EventFilter.cpp
===================================================================
--- src/Quarter/EventFilter.cpp (revision 33)
+++ src/Quarter/EventFilter.cpp (revision 32)
@@ -67,7 +67,9 @@

SbVec2s mousepos(event->pos().x(), this->windowsize[1] - event->pos().y() - 1);
// the following corrects for high-dpi displays (e.g., mac retina)
- mousepos *= quarterwidget->devicePixelRatio();
+#if (QT_VERSION >= 0x050000)
+ mousepos *= ((QGuiApplication*)QGuiApplication::instance())->devicePixelRatio();
+#endif
foreach(InputDevice * device, this->devices) {
device->setMousePosition(mousepos);
}
@@ -86,19 +88,17 @@
{
PRIVATE(this) = new EventFilterP;

- QuarterWidget* quarter = dynamic_cast<QuarterWidget *>(parent);
-
- PRIVATE(this)->quarterwidget = quarter;
+ PRIVATE(this)->quarterwidget = dynamic_cast<QuarterWidget *>(parent);
assert(PRIVATE(this)->quarterwidget);

PRIVATE(this)->windowsize = SbVec2s(PRIVATE(this)->quarterwidget->width(),
PRIVATE(this)->quarterwidget->height());

- PRIVATE(this)->devices += new Mouse(quarter);
- PRIVATE(this)->devices += new Keyboard(quarter);
+ PRIVATE(this)->devices += new Mouse;
+ PRIVATE(this)->devices += new Keyboard;

#ifdef HAVE_SPACENAV_LIB
- PRIVATE(this)->devices += new SpaceNavigatorDevice(quarter);
+ PRIVATE(this)->devices += new SpaceNavigatorDevice;
#endif // HAVE_SPACENAV_LIB

}
Index: src/Quarter/Mouse.cpp
===================================================================
--- src/Quarter/Mouse.cpp (revision 33)
+++ src/Quarter/Mouse.cpp (revision 32)
@@ -32,8 +32,6 @@
#include <QEvent>
#include <QSize>
#include <QWheelEvent>
-#include <Quarter/QuarterWidget.h>
-
#if (QT_VERSION >= 0x050000)
#include <QGuiApplication>
#endif
@@ -76,8 +74,7 @@
#define PRIVATE(obj) obj->pimpl
#define PUBLIC(obj) obj->publ

-Mouse::Mouse(QuarterWidget* quart) :
- InputDevice(quart)
+Mouse::Mouse(void)
{
PRIVATE(this) = new MouseP(this);
}
@@ -128,7 +125,9 @@
assert(this->windowsize[1] != -1);
SbVec2s pos(event->pos().x(), this->windowsize[1] - event->pos().y() - 1);
// the following corrects for high-dpi displays (e.g., mac retina)
- pos *= publ->quarter->devicePixelRatio();
+#if (QT_VERSION >= 0x050000)
+ pos *= ((QGuiApplication*)QGuiApplication::instance())->devicePixelRatio();
+#endif
this->location2->setPosition(pos);
this->mousebutton->setPosition(pos);
return this->location2;
@@ -140,7 +139,9 @@
PUBLIC(this)->setModifiers(this->mousebutton, event);
SbVec2s pos(event->pos().x(), PUBLIC(this)->windowsize[1] - event->pos().y() - 1);
// the following corrects for high-dpi displays (e.g., mac retina)
- pos *= publ->quarter->devicePixelRatio();
+#if (QT_VERSION >= 0x050000)
+ pos *= ((QGuiApplication*)QGuiApplication::instance())->devicePixelRatio();
+#endif
this->location2->setPosition(pos);
this->mousebutton->setPosition(pos);

@@ -163,7 +164,9 @@
PUBLIC(this)->setModifiers(this->mousebutton, event);
SbVec2s pos(event->pos().x(), PUBLIC(this)->windowsize[1] - event->pos().y() - 1);
// the following corrects for high-dpi displays (e.g., mac retina)
- pos *= publ->quarter->devicePixelRatio();
+#if (QT_VERSION >= 0x050000)
+ pos *= ((QGuiApplication*)QGuiApplication::instance())->devicePixelRatio();
+#endif
this->location2->setPosition(pos);
this->mousebutton->setPosition(pos);

Bastiaan Veelo

unread,
Nov 4, 2017, 5:53:41 PM11/4/17
to coin3d-discuss
On Thursday, October 26, 2017 at 7:53:36 PM UTC+2, Randall O'Reilly wrote:
I fixed this in our quarter fork: https://grey.colorado.edu/emergent/index.php/Coin3d — mostly in revision 33 — attaching the diffs in case this is helpful in porting over to SoQt.  all the stuff about devicepixelratio.. Cheers,

- Randy

I am working on reintegrating those changes back into Quarter official. Since your fixes are licensed GPL, I kindly request your formal permission to port them over to code licensed according to the COPYING file in the repositories hosted on coin3d.org. Idem for Coin, retroactively.

:-)

Bastiaan.

Randall O'Reilly

unread,
Nov 5, 2017, 12:51:05 AM11/5/17
to coin3d-...@googlegroups.com
Yep you hereby have my permission! Cheers,

- Randy
Reply all
Reply to author
Forward
0 new messages