Quarter: Update Quarter code

* Removes unused default constructors of the device classes
* Changes several doc strings
This commit is contained in:
wmayer
2024-06-28 12:40:39 +02:00
committed by Chris Hennes
parent 12e8fb1695
commit 2b08586059
21 changed files with 84 additions and 118 deletions

View File

@@ -1,22 +1,22 @@
/**************************************************************************\
* Copyright (c) Kongsberg Oil & Gas Technologies AS
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
*
* Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -33,7 +33,7 @@
#ifndef QUARTER_CONTEXTMENUHANDLERP_H
#define QUARTER_CONTEXTMENUHANDLERP_H
#include <QtCore/QObject>
#include <QObject>
class QMenu;
class QAction;
@@ -45,7 +45,7 @@ class QuarterWidget;
class ContextMenu : public QObject {
Q_OBJECT
public:
ContextMenu(QuarterWidget * quarterwidget);
explicit ContextMenu(QuarterWidget * quarterwidget);
~ContextMenu() override;
QMenu * getMenu() const;

View File

@@ -1,22 +1,22 @@
/**************************************************************************\
* Copyright (c) Kongsberg Oil & Gas Technologies AS
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
*
* Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -54,7 +54,7 @@ namespace SIM { namespace Coin3D { namespace Quarter {
class DragDropHandlerP {
public:
DragDropHandlerP(DragDropHandler * master) {
explicit DragDropHandlerP(DragDropHandler * master) {
this->master = master;
}
void dragEnterEvent(QDragEnterEvent * event);
@@ -93,7 +93,7 @@ DragDropHandler::~DragDropHandler()
/*!
Detects a QDragEnterEvent and if the event is the dropping of a
valid Inventor or VRML it opens the file, reads in the scenegraph
valid Inventor or VRML file it opens the file, reads in the scene graph
and calls setSceneGraph on the QuarterWidget
*/
bool
@@ -158,7 +158,7 @@ DragDropHandlerP::dropEvent(QDropEvent * event)
if (!root)
return;
// set new scenegraph
// set new scene graph
this->quarterwidget->setSceneGraph(root);
this->quarterwidget->viewport()->update();
}

View File

@@ -66,10 +66,10 @@ public:
void trackPointerPosition(QMouseEvent * event)
{
assert(this->windowsize[1] != -1);
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
this->globalmousepos = event->globalPos();
#else
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
this->globalmousepos = event->globalPosition().toPoint();
#else
this->globalmousepos = event->globalPos();
#endif
SbVec2s mousepos(event->pos().x(), this->windowsize[1] - event->pos().y() - 1);
@@ -136,7 +136,7 @@ EventFilter::unregisterInputDevice(InputDevice * device)
}
/*! Translates Qt Events into Coin events and passes them on to the
event QuarterWidget for processing. If the event can not be
event QuarterWidget for processing. If the event cannot be
translated or processed, it is forwarded to Qt and the method
returns false.
*/
@@ -151,10 +151,10 @@ EventFilter::eventFilter(QObject * obj, QEvent * qevent)
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
case QEvent::MouseButtonDblClick:
PRIVATE(this)->trackPointerPosition(static_cast<QMouseEvent *>(qevent));
PRIVATE(this)->trackPointerPosition(dynamic_cast<QMouseEvent *>(qevent));
break;
case QEvent::Resize:
PRIVATE(this)->trackWindowSize(static_cast<QResizeEvent *>(qevent));
PRIVATE(this)->trackWindowSize(dynamic_cast<QResizeEvent *>(qevent));
break;
default:
break;

View File

@@ -33,8 +33,8 @@
/*!
\class SIM::Coin3D::Quarter::FocusHandler FocusHandler.h Quarter/devices/FocusHandler.h
\brief The FocusHandler eventfilter provides Coin with focus in and
focus out events, if installed on QuarterWidget.
\brief The FocusHandler event filter provides Coin with focus in and
focus out events, if installed on a QuarterWidget.
*/
#include <QEvent>

View File

@@ -54,10 +54,6 @@ ImageReader::readImage(const SbString & filename, SbImage & sbimage) const
{
QImage image;
if (image.load(filename.getString())) {
//int c;
//int w = image.width();
//int h = image.height();
// Keep in 8-bits mode if that was what we read
if (image.depth() != 8 || !image.isGrayscale()) {
// FIXME: consider if we should detect allGrayscale() and alpha (c = 2)

View File

@@ -46,26 +46,20 @@ using namespace SIM::Coin3D::Quarter;
\class SIM::Coin3D::Quarter::InputDevice InputDevice.h Quarter/devices/InputDevice.h
\brief The InputDevice class is the base class for devices such as
the Keyboard and Mouse. It can be subclassed to support other
devices.
keyboard and mouse. It can be subclassed to support other devices.
*/
InputDevice::InputDevice() : quarter(nullptr)
InputDevice::InputDevice(QuarterWidget* quarter) :
quarter(quarter)
{
this->mousepos = SbVec2s(0, 0);
}
InputDevice::InputDevice(QuarterWidget *quarter) : quarter(quarter)
{
this->mousepos = SbVec2s(0, 0);
}
/*!
Sets the mouseposition
Sets the mouse position
\param[in] pos position of mouse in pixelcoordinates
\param[in] pos position of mouse in pixel coordinates
*/
void
InputDevice::setMousePosition(const SbVec2s & pos)
{
@@ -84,10 +78,10 @@ InputDevice::setWindowSize(const SbVec2s & size)
}
/*!
Transforms a qevent into an soevent
Transforms a QEvent into an SoEvent
\param[in,out] soevent the transformed event
\param[in] qevent incoming qevent
\param[in,out] SoEvent the transformed event
\param[in] QEvent incoming QEvent
*/
void
InputDevice::setModifiers(SoEvent * soevent, const QInputEvent * qevent)

View File

@@ -53,17 +53,12 @@ using namespace SIM::Coin3D::Quarter;
#define PRIVATE(obj) obj->pimpl
Keyboard::Keyboard()
Keyboard::Keyboard(QuarterWidget* quarter) :
InputDevice(quarter)
{
PRIVATE(this) = new KeyboardP(this);
}
Keyboard::Keyboard(QuarterWidget* quarter) :
InputDevice(quarter)
{
PRIVATE(this) = new KeyboardP(this);
}
Keyboard::~Keyboard()
{
delete PRIVATE(this);

View File

@@ -37,8 +37,6 @@
QuarterWidget.
*/
#include "PreCompiled.h"
#ifdef _MSC_VER
#pragma warning(disable : 4267)
#endif
@@ -60,7 +58,7 @@ namespace SIM { namespace Coin3D { namespace Quarter {
class MouseP {
public:
MouseP(Mouse * publ) {
explicit MouseP(Mouse * publ) {
this->publ = publ;
this->location2 = new SoLocation2Event;
this->mousebutton = new SoMouseButtonEvent;
@@ -93,17 +91,12 @@ using namespace SIM::Coin3D::Quarter;
#define PRIVATE(obj) obj->pimpl
#define PUBLIC(obj) obj->publ
Mouse::Mouse()
Mouse::Mouse(QuarterWidget* quarter) :
InputDevice(quarter)
{
PRIVATE(this) = new MouseP(this);
}
Mouse::Mouse(QuarterWidget *quarter) :
InputDevice(quarter)
{
PRIVATE(this) = new MouseP(this);
}
Mouse::~Mouse()
{
delete PRIVATE(this);

View File

@@ -776,7 +776,7 @@ QuarterWidget::viewAll()
}
/*!
Sets the current camera in seekmode, if supported by the underlying navigation system.
Sets the current camera in seek mode, if supported by the underlying navigation system.
Camera typically seeks towards what the mouse is pointing at.
*/
void
@@ -995,7 +995,7 @@ QuarterWidget::actualRedraw()
/*!
Passes an event to the eventmanager.
Passes an event to the event manager.
\param[in] event to pass
\retval Returns true if the event was successfully processed
@@ -1015,10 +1015,10 @@ QuarterWidget::processSoEvent(const SoEvent * event)
*/
/*!
Set backgroundcolor to a given QColor
Set background color to a given QColor
Remember that QColors are given in integers between 0 and 255, as
opposed to SbColor4f which is in [0 ,1]. The default alpha value for
opposed to SbColor4f which is in [0, 1]. The default alpha value for
a QColor is 255, but you'll probably want to set it to zero before
using it as an OpenGL clear color.
*/
@@ -1074,7 +1074,7 @@ QuarterWidget::contextMenuEnabled() const
*/
/*!
Controls the display of the contextmenu
Controls the display of the context menu
\param[in] yes Context menu on?
*/
@@ -1103,7 +1103,7 @@ QuarterWidget::addStateMachine(SoScXMLStateMachine * statemachine)
}
/*!
Convenience method that removes a state machine to the current
Convenience method that removes a state machine from the current
SoEventManager.
\sa addStateMachine
@@ -1166,8 +1166,8 @@ QuarterWidget::renderModeActions() const
that defines the possible states for the Coin navigation system
Supports:
\li \b coin for internal coinresources
\li \b file for filesystem path to resources
\li \b coin for internal Coin resources
\li \b file for file system path to resources
\sa scxml
*/
@@ -1180,10 +1180,25 @@ QuarterWidget::resetNavigationModeFile() {
this->setNavigationModeFile(QUrl());
}
/**
* Sets up the default cursors for the widget.
*/
void QuarterWidget::setupDefaultCursors()
{
this->setStateCursor("interact", Qt::ArrowCursor);
this->setStateCursor("idle", Qt::OpenHandCursor);
this->setStateCursor("rotate", Qt::ClosedHandCursor);
this->setStateCursor("pan", Qt::SizeAllCursor);
this->setStateCursor("zoom", Qt::SizeVerCursor);
this->setStateCursor("dolly", Qt::SizeVerCursor);
this->setStateCursor("seek", Qt::CrossCursor);
this->setStateCursor("spin", Qt::OpenHandCursor);
}
/*!
Sets a navigation mode file. Supports the schemes "coin" and "file"
\param[in] url Url to the resource
\param[in] url URL to the resource
*/
void
QuarterWidget::setNavigationModeFile(const QUrl & url)
@@ -1250,8 +1265,8 @@ QuarterWidget::setNavigationModeFile(const QUrl & url)
PRIVATE(this)->currentStateMachine = newsm;
}
else {
if (stateMachine)
delete stateMachine;
delete stateMachine;
stateMachine = nullptr;
qDebug()<<filename;
qDebug()<<"Unable to load"<<url;
return;
@@ -1266,19 +1281,12 @@ QuarterWidget::setNavigationModeFile(const QUrl & url)
// set up default cursors for the examiner navigation states
//FIXME: It may be overly restrictive to not do this for arbitrary
//navigation systems? - BFG 20090117
this->setStateCursor("interact", Qt::ArrowCursor);
this->setStateCursor("idle", Qt::OpenHandCursor);
this->setStateCursor("rotate", Qt::ClosedHandCursor);
this->setStateCursor("pan", Qt::SizeAllCursor);
this->setStateCursor("zoom", Qt::SizeVerCursor);
this->setStateCursor("dolly", Qt::SizeVerCursor);
this->setStateCursor("seek", Qt::CrossCursor);
this->setStateCursor("spin", Qt::OpenHandCursor);
setupDefaultCursors();
}
}
/*!
\retval The current navigationModeFile
\retval The current navigation mode file
*/
const QUrl &
QuarterWidget::navigationModeFile() const

View File

@@ -131,6 +131,7 @@ public:
void resetNavigationModeFile();
void setNavigationModeFile(const QUrl & url = QUrl(QString::fromLatin1(DEFAULT_NAVIGATIONFILE)));
const QUrl & navigationModeFile() const;
void setupDefaultCursors();
void setContextMenuEnabled(bool yes);
bool contextMenuEnabled() const;

View File

@@ -106,9 +106,7 @@ QuarterWidgetP::~QuarterWidgetP()
{
QtGLWidget* glMaster = static_cast<QtGLWidget*>(this->master->viewport());
removeFromCacheContext(this->cachecontext, glMaster);
if (this->contextmenu) {
delete this->contextmenu;
}
delete this->contextmenu;
}
SoCamera *

View File

@@ -53,7 +53,7 @@
namespace SIM { namespace Coin3D { namespace Quarter {
class SpaceNavigatorDeviceP {
public:
SpaceNavigatorDeviceP(SpaceNavigatorDevice * master) {
explicit SpaceNavigatorDeviceP(SpaceNavigatorDevice * master) {
this->master = master;
this->hasdevice = false;
this->windowid = 0;
@@ -81,7 +81,8 @@ public:
#define PRIVATE(obj) obj->pimpl
using namespace SIM::Coin3D::Quarter;
SpaceNavigatorDevice::SpaceNavigatorDevice()
SpaceNavigatorDevice::SpaceNavigatorDevice(QuarterWidget* quarter) :
InputDevice(quarter)
{
PRIVATE(this) = new SpaceNavigatorDeviceP(this);
@@ -97,23 +98,6 @@ SpaceNavigatorDevice::SpaceNavigatorDevice()
#endif // HAVE_SPACENAV_LIB
}
SpaceNavigatorDevice::SpaceNavigatorDevice(QuarterWidget *quarter) :
InputDevice(quarter)
{
PRIVATE(this) = new SpaceNavigatorDeviceP(this);
#ifdef HAVE_SPACENAV_LIB
PRIVATE(this)->hasdevice =
spnav_x11_open(QX11Info::display(), PRIVATE(this)->windowid) == -1 ? false : true;
// FIXME: Use a debugmessage mechanism instead? (20101020 handegar)
if (!PRIVATE(this)->hasdevice) {
fprintf(stderr, "Quarter:: Could not hook up to Spacenav device.\n");
}
#endif // HAVE_SPACENAV_LIB
}
SpaceNavigatorDevice::~SpaceNavigatorDevice()
{
delete PRIVATE(this);

View File

@@ -4,22 +4,22 @@
/**************************************************************************\
* Copyright (c) Kongsberg Oil & Gas Technologies AS
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
*
* Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -46,8 +46,7 @@ class QuarterWidget;
class QUARTER_DLL_API InputDevice {
public:
InputDevice(QuarterWidget * quarter);
InputDevice();
explicit InputDevice(QuarterWidget* quarter);
virtual ~InputDevice() {}
/*!

View File

@@ -43,8 +43,7 @@ namespace SIM { namespace Coin3D { namespace Quarter {
class QUARTER_DLL_API Keyboard : public InputDevice {
public:
Keyboard(QuarterWidget* quarter);
Keyboard();
explicit Keyboard(QuarterWidget* quarter);
~Keyboard() override;
const SoEvent * translateEvent(QEvent * event) override;

View File

@@ -43,8 +43,7 @@ namespace SIM { namespace Coin3D { namespace Quarter {
class QUARTER_DLL_API Mouse : public InputDevice {
public:
Mouse(QuarterWidget* quarter);
Mouse();
explicit Mouse(QuarterWidget* quarter);
~Mouse() override;
const SoEvent * translateEvent(QEvent * event) override;

View File

@@ -42,8 +42,7 @@ namespace SIM { namespace Coin3D { namespace Quarter {
class QUARTER_DLL_API SpaceNavigatorDevice : public InputDevice {
public:
SpaceNavigatorDevice(QuarterWidget* quarter);
SpaceNavigatorDevice();
explicit SpaceNavigatorDevice(QuarterWidget* quarter);
~SpaceNavigatorDevice() override;
const SoEvent * translateEvent(QEvent * event) override;

View File

@@ -33,7 +33,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\**************************************************************************/
#include <QtCore/QObject>
#include <QObject>
#include <Quarter/Basic.h>
class QEvent;
@@ -46,7 +46,7 @@ class QuarterWidget;
class QUARTER_DLL_API DragDropHandler : public QObject {
Q_OBJECT
public:
DragDropHandler(QuarterWidget * parent);
explicit DragDropHandler(QuarterWidget * parent);
~DragDropHandler() override;
protected:

View File

@@ -34,7 +34,7 @@
\**************************************************************************/
#include <Quarter/Basic.h>
#include <QtCore/QObject>
#include <QObject>
class QEvent;
class QPoint;

View File

@@ -33,7 +33,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\**************************************************************************/
#include <QtCore/QObject>
#include <QObject>
#include <Inventor/SbName.h>
class QEvent;

View File

@@ -164,6 +164,7 @@ SbBool SoGestureSwipeEvent::isSoGestureSwipeEvent(const SoEvent *ev) const
//----------------------------GesturesDevice-------------------------------
GesturesDevice::GesturesDevice(QWidget* widget)
: InputDevice(nullptr)
{
if (SoGestureEvent::getClassTypeId().isBad()){
SoGestureEvent::initClass();

View File

@@ -262,7 +262,7 @@ public:
class SpaceNavigatorDevice : public Quarter::InputDevice {
public:
SpaceNavigatorDevice() = default;
SpaceNavigatorDevice() : InputDevice(nullptr) {}
~SpaceNavigatorDevice() override = default;
const SoEvent* translateEvent(QEvent* event) override {