1
/**************************************************************************\
2
* Copyright (c) Kongsberg Oil & Gas Technologies AS
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are
9
* Redistributions of source code must retain the above copyright notice,
10
* this list of conditions and the following disclaimer.
12
* Redistributions in binary form must reproduce the above copyright
13
* notice, this list of conditions and the following disclaimer in the
14
* documentation and/or other materials provided with the distribution.
16
* Neither the name of the copyright holder nor the names of its
17
* contributors may be used to endorse or promote products derived from
18
* this software without specific prior written permission.
20
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
\**************************************************************************/
35
Quarter is a light-weight glue library that provides seamless
36
integration between Systems in Motions's \COIN high-level 3D
37
visualization library and Trolltech's \QT 2D user interface
40
\QT and \COIN is a perfect match since they are both open source,
41
widely portable and easy to use. Quarter has evolved from Systems in
42
Motion's own experiences using \COIN and \QT together in our
45
The functionality in Quarter revolves around QuarterWidget, a
46
subclass of QGLWidget. This widget provides functionality for
47
rendering of Coin scenegraphs and translation of QEvents into
48
SoEvents. Using this widget is as easy as using any other QWidget.
50
\subpage QuarterWidgetPlugin
52
Quarter also comes with a plugin for Qt Designer, Trolltech's tool
53
for designing and building GUIs. Once you install Quarter, the
54
QuarterWidget becomes accessible in Qt Designer, and you can include
55
it in the user interfaces you create. The plugin facility also
56
provides you with the capability of dynamically loading ui files
57
containing a QuarterWidget in your application.
59
By using \COIN, \QT and Quarter to build your 3D graphics
60
applications, you have the power to write software that is portable
61
across the whole range of UNIX, Linux, Microsoft Windows and Mac OS
62
X operating systems, from a 100% common codebase.
64
For a small, completely stand-alone usage example on how to
65
initialize the library and set up a viewer instance window, see the
69
#include <QtGui/QApplication>
71
#include <Inventor/nodes/SoBaseColor.h>
72
#include <Inventor/nodes/SoCone.h>
73
#include <Inventor/nodes/SoSeparator.h>
75
#include <Quarter/Quarter.h>
76
#include <Quarter/QuarterWidget.h>
78
using namespace SIM::Coin3D::Quarter;
81
main(int argc, char ** argv)
83
QApplication app(argc, argv);
84
// Initializes Quarter library (and implicitly also the Coin and Qt
88
// Make a dead simple scene graph by using the Coin library, only
89
// containing a single yellow cone under the scenegraph root.
90
SoSeparator * root = new SoSeparator;
93
SoBaseColor * col = new SoBaseColor;
94
col->rgb = SbColor(1, 1, 0);
97
root->addChild(new SoCone);
99
// Create a QuarterWidget for displaying a Coin scene graph
100
QuarterWidget * viewer = new QuarterWidget;
101
viewer->setSceneGraph(root);
103
// make the viewer react to input events similar to the good old
105
viewer->setNavigationModeFile(QUrl("coin:///scxml/navigation/examiner.xml"));
107
// Pop up the QuarterWidget
111
// Clean up resources.
124
// The subsequent doxygen referenced page/subpages do not exist in the copy of Quarter used within FreeCad.
125
// To preserve the history and their origin the doxygen commands have been disabled but left in the file.
127
// \page examples More Examples
129
// The examples code is included in Quarter and can be found in the
130
// src/examples subdirectory.
143
#include <Inventor/SoDB.h>
144
#include <Inventor/SoInteraction.h>
145
#include <Inventor/nodekits/SoNodeKit.h>
147
#include "SensorManager.h"
153
using namespace SIM::Coin3D::Quarter;
155
static QuarterP * self = nullptr;
158
initialize Quarter, and implicitly Coin
161
Quarter::init(bool initCoin)
163
COMPILE_ONLY_BEFORE(2,0,0,"Should not be encapsulated in double Quarter namespace");
165
// FIXME: Use SoDebugError
166
fprintf(stderr, "Quarter is already initialized\n");
173
SoInteraction::init();
177
self->initCoin = initCoin;
187
COMPILE_ONLY_BEFORE(2,0,0,"Should not be encapsulated in double Quarter namespace");
189
bool initCoin = self->initCoin;
195
// SoDB::finish() will clean up everything that has been
196
// initialized. There's no need to add SoNodeKit::finish() and
197
// SoInteraction::finish() like in TGS Inventor
203
override lower refresh rate limit
206
Quarter::setTimerEpsilon(double sec)
208
COMPILE_ONLY_BEFORE(2,0,0,"Should not be encapsulated in double Quarter namespace");
210
fprintf(stderr, "Quarter is not initialized!\n");
214
self->sensormanager->setTimerEpsilon(sec);