Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenFlipper-Free
OpenFlipper
Commits
3a1d814a
Commit
3a1d814a
authored
May 16, 2017
by
Martin Schultz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stripped the changes of QOpenGL branch to use QOpenGLWidgets on Qt5.4 or
newer.
parent
adb0116d
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
271 additions
and
35 deletions
+271
-35
BasePlugin/PluginFunctions.cc
BasePlugin/PluginFunctions.cc
+3
-3
BasePlugin/PluginFunctions.hh
BasePlugin/PluginFunctions.hh
+4
-3
OpenFlipper.cc
OpenFlipper.cc
+32
-0
common/OFGLWidget.hh
common/OFGLWidget.hh
+71
-0
widgets/coreWidget/CoreWidget.cc
widgets/coreWidget/CoreWidget.cc
+33
-11
widgets/coreWidget/CoreWidget.hh
widgets/coreWidget/CoreWidget.hh
+3
-1
widgets/glWidget/QtBaseViewer.cc
widgets/glWidget/QtBaseViewer.cc
+7
-7
widgets/glWidget/QtBaseViewer.hh
widgets/glWidget/QtBaseViewer.hh
+4
-3
widgets/glWidget/QtBaseViewer_qt.cc
widgets/glWidget/QtBaseViewer_qt.cc
+97
-0
widgets/glWidget/simpleViewer.cc
widgets/glWidget/simpleViewer.cc
+13
-4
widgets/glWidget/simpleViewer.hh
widgets/glWidget/simpleViewer.hh
+4
-3
No files found.
BasePlugin/PluginFunctions.cc
View file @
3a1d814a
...
...
@@ -128,7 +128,7 @@ static ViewObjectMarker* defaultMarker_ = 0;
*
* This pointer is used internally
*/
static
Q
GLWidget
*
shareGLWidget_
=
0
;
static
OF
GLWidget
*
shareGLWidget_
=
0
;
/** This is a unique id for the running OpenFlipper instance. Use it to identify yourself on the network
*/
...
...
@@ -594,12 +594,12 @@ void actionMode ( Viewer::ActionMode _mode) {
viewerProperties
().
actionMode
(
_mode
);
}
void
shareGLWidget
(
Q
GLWidget
*
_widget
)
void
shareGLWidget
(
OF
GLWidget
*
_widget
)
{
shareGLWidget_
=
_widget
;
}
Q
GLWidget
*
shareGLWidget
()
OF
GLWidget
*
shareGLWidget
()
{
return
shareGLWidget_
;
}
...
...
BasePlugin/PluginFunctions.hh
View file @
3a1d814a
...
...
@@ -70,12 +70,13 @@
#include <QPair>
#include <QFileDialog>
#include <OpenFlipper/common/OFGLWidget.hh>
#include <ACG/Scenegraph/SceneGraph.hh>
#include <OpenFlipper/BasePlugin/PluginFunctionsViewControls.hh>
//== FORWARDDECLARATIONS ======================================================
class
ViewObjectMarker
;
class
QGLWidget
;
/** The Namespace PluginFunctions contains functions for all plugins. These functions should be used to get the
* objects to work on or to set modes in the examiner widget. */
...
...
@@ -375,11 +376,11 @@ Viewer::ActionMode actionMode();
/// Sets the main QGLWidget for gl data sharing.
DLLEXPORT
void
shareGLWidget
(
Q
GLWidget
*
_widget
);
void
shareGLWidget
(
OF
GLWidget
*
_widget
);
/// Returns the main QGLWidget for gl data sharing.
DLLEXPORT
Q
GLWidget
*
shareGLWidget
();
OF
GLWidget
*
shareGLWidget
();
/** Lock scene rotation via mouse
*
...
...
OpenFlipper.cc
View file @
3a1d814a
...
...
@@ -459,9 +459,41 @@ int main(int argc, char **argv)
if
(
!
OpenFlipper
::
Options
::
nogui
()
)
{
// OpenGL check
#if (QT_VERSION >= QT_VERSION_CHECK(5,4,0))
QApplication
::
setAttribute
(
Qt
::
AA_ShareOpenGLContexts
);
#endif
QApplication
::
setColorSpec
(
QApplication
::
CustomColor
);
QApplication
app
(
argc
,
argv
);
#if QT_VERSION >= 0x050500
QSurfaceFormat
format
=
QSurfaceFormat
::
defaultFormat
();
format
.
setVersion
(
4
,
4
);
format
.
setProfile
(
QSurfaceFormat
::
CompatibilityProfile
);
format
.
setOption
(
QSurfaceFormat
::
DeprecatedFunctions
);
if
(
OpenFlipper
::
Options
::
debug
())
format
.
setOption
(
format
.
options
()
|
QSurfaceFormat
::
DebugContext
);
QSurfaceFormat
::
setDefaultFormat
(
format
);
QScreen
*
screen
=
app
.
primaryScreen
();
QOffscreenSurface
*
surface
=
new
QOffscreenSurface
();
surface
->
create
();
QOpenGLContext
context
;
context
.
setScreen
(
screen
);
context
.
create
();
context
.
makeCurrent
(
surface
);
#endif
// Set organization and application names
QCoreApplication
::
setOrganizationName
(
"rwth-aachen.de"
);
QCoreApplication
::
setApplicationName
(
TOSTRING
(
PRODUCT_STRING
));
...
...
common/OFGLWidget.hh
0 → 100644
View file @
3a1d814a
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. 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. *
* *
* 3. 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 A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
#pragma once
#include <QtGlobal>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
#include <QOpenGLWidget>
#include <QSurfaceFormat>
typedef
QOpenGLWidget
OFGLWidget
;
typedef
QSurfaceFormat
OFGLFormat
;
#else
#include <QGLWidget>
#include <QGLFormat>
typedef
QGLWidget
OFGLWidget
;
typedef
QGLFormat
OFGLFormat
;
#endif
widgets/coreWidget/CoreWidget.cc
View file @
3a1d814a
...
...
@@ -207,17 +207,23 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
splitter_
=
new
QSplitter
(
Qt
::
Vertical
,
toolSplitter_
);
stackedWidget_
=
new
QStackedWidget
(
splitter_
);
QGLFormat
format
=
QGLFormat
::
defaultFormat
();
#ifdef ARCH_DARWIN
OFGLFormat
format
=
OFGLFormat
::
defaultFormat
();
#ifdef ARCH_DARWIN
format
.
setStereo
(
false
);
#else
format
.
setStereo
(
OpenFlipper
::
Options
::
stereo
()
);
#endif
#else
format
.
setStereo
(
OpenFlipper
::
Options
::
stereo
());
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
format
.
setAlphaBufferSize
(
8
);
format
.
setStencilBufferSize
(
8
);
format
.
setSamples
(
4
);
// todo: get sample count from settings
#else
format
.
setAlpha
(
true
);
format
.
setStencil
(
true
);
format
.
setSampleBuffers
(
true
);
QGLFormat
::
setDefaultFormat
(
format
);
#endif
OFGLFormat
::
setDefaultFormat
(
format
);
// Construct GL context & widget
baseLayout_
=
new
QtMultiViewLayout
;
...
...
@@ -228,11 +234,17 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
// If we get stereo buffers, we use them .. which might disable multisampling
// If we don't have stereo, we disable it to not interfere with multisampling
// ===============================================================================
QGLWidget
*
test
=
new
QGLWidget
(
format
);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
OFGLWidget
*
test
=
new
OFGLWidget
();
test
->
setFormat
(
format
);
#else
OFGLWidget
*
test
=
new
OFGLWidget
(
format
);
#endif
if
(
!
test
->
format
().
stereo
()
)
{
// std::cerr << "No stereo ... disabling stereo for real context!" << std::endl;
format
.
setStereo
(
false
);
Q
GLFormat
::
setDefaultFormat
(
format
);
OF
GLFormat
::
setDefaultFormat
(
format
);
}
/* else {
std::cerr << "Stereo found ok" << std::endl;
}*/
...
...
@@ -241,7 +253,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
// force the compatibility profile since OpenFlipper does not work with the
// Core profile
format
.
setProfile
(
Q
GLFormat
::
CompatibilityProfile
);
format
.
setProfile
(
OF
GLFormat
::
CompatibilityProfile
);
#if QT_VERSION >= 0x050000
// request the highest OpenGL version
...
...
@@ -249,7 +261,17 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
format
.
setVersion
(
4
,
3
);
#endif
glWidget_
=
new
QGLWidget
(
format
,
0
);
if
(
OpenFlipper
::
Options
::
debug
())
format
.
setOption
(
format
.
options
()
|
QSurfaceFormat
::
DebugContext
);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 4))
glWidget_
=
new
OFGLWidget
();
glWidget_
->
setFormat
(
format
);
glWidget_
->
makeCurrent
();
#else
glWidget_
=
new
OFGLWidget
(
format
,
0
);
#endif
PluginFunctions
::
shareGLWidget
(
glWidget_
);
glView_
=
new
QtGLGraphicsView
(
stackedWidget_
);
...
...
widgets/coreWidget/CoreWidget.hh
View file @
3a1d814a
...
...
@@ -96,6 +96,8 @@
#include <QDockWidget>
#include <OpenFlipper/common/OFGLWidget.hh>
#include <OpenFlipper/widgets/aboutWidget/aboutWidget.hh>
#include <OpenFlipper/widgets/loggerWidget/loggerWidget.hh>
#include <OpenFlipper/widgets/optionsWidget/optionsWidget.hh>
...
...
@@ -696,7 +698,7 @@ public:
QAction
*
AC_ShowViewModeControls_
;
/// gl widget used as drawing area to paint the graphics scene
Q
GLWidget
*
glWidget_
;
OF
GLWidget
*
glWidget_
;
/// graphics scene used to paint gl context and widgets
QtGLGraphicsScene
*
glScene_
;
...
...
widgets/glWidget/QtBaseViewer.cc
View file @
3a1d814a
...
...
@@ -73,7 +73,6 @@
#include <QGraphicsWidget>
#include <QString>
#include <QGLFormat>
#include <QBoxLayout>
#include <QtNetwork/QUdpSocket>
#include <QToolBar>
...
...
@@ -126,7 +125,7 @@ static const char COPY_PASTE_VIEW_START_STRING[] =
glViewer
::
glViewer
(
QGraphicsScene
*
_scene
,
Q
GLWidget
*
_glWidget
,
OF
GLWidget
*
_glWidget
,
Viewer
::
ViewerProperties
&
_properties
,
QGraphicsWidget
*
_parent
)
:
QGraphicsWidget
(
_parent
),
...
...
@@ -230,10 +229,6 @@ void glViewer::makeCurrent() {
glWidget_
->
makeCurrent
();
}
void
glViewer
::
swapBuffers
()
{
glWidget_
->
swapBuffers
();
}
//-----------------------------------------------------------------------------
...
...
@@ -519,7 +514,12 @@ glViewer::copyToImage( QImage& _image,
// makeCurrent();
_image
=
glWidget_
->
grabFrameBuffer
(
true
).
copy
(
_l
,
_t
,
_w
,
_h
).
convertToFormat
(
QImage
::
Format_RGB32
);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
_image
=
glWidget_
->
grabFramebuffer
()
#else
_image
=
glWidget_
->
grabFrameBuffer
(
true
)
#endif
.
copy
(
_l
,
_t
,
_w
,
_h
).
convertToFormat
(
QImage
::
Format_RGB32
);
}
...
...
widgets/glWidget/QtBaseViewer.hh
View file @
3a1d814a
...
...
@@ -64,6 +64,8 @@
#include <OpenFlipper/common/Types.hh>
#include <OpenFlipper/common/ViewerProperties.hh>
#include <OpenFlipper/common/OFGLWidget.hh>
#include <ACG/GL/GLState.hh>
#include <ACG/GL/FBO.hh>
#include <ACG/Scenegraph/SceneGraph.hh>
...
...
@@ -90,7 +92,6 @@ class QSplitter;
class
QImage
;
class
QSocketNotifier
;
class
QPropertyAnimation
;
class
QGLWidget
;
struct
PostProcessorInput
;
...
...
@@ -145,7 +146,7 @@ public:
*
*/
glViewer
(
QGraphicsScene
*
_scene
,
Q
GLWidget
*
_glWidget
,
OF
GLWidget
*
_glWidget
,
Viewer
::
ViewerProperties
&
_properties
,
QGraphicsWidget
*
_parent
=
0
);
...
...
@@ -596,7 +597,7 @@ private:
QGraphicsScene
*
glScene_
;
// gl widget used as drawing area to paint the graphics scene
Q
GLWidget
*
glWidget_
;
OF
GLWidget
*
glWidget_
;
// Base graphics widget layout
QtGLViewerLayout
*
glBaseLayout_
;
...
...
widgets/glWidget/QtBaseViewer_qt.cc
0 → 100644
View file @
3a1d814a
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. 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. *
* *
* 3. 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 A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
// QOpenGL headers and glew are in conflict,
// so implement functions that make use of QOpenGL classes in separate file
//=============================================================================
//
// CLASS glViewer - IMPLEMENTATION
//
//=============================================================================
//== INCLUDES =================================================================
#include "QtBaseViewer.hh"
#include <OpenFlipper/common/GlobalOptions.hh>
#if (QT_VERSION >= QT_VERSION_CHECK(5,4,0))
#include <QOpenGLContext>
#endif
//== NAMESPACES ===============================================================
//== IMPLEMENTATION ==========================================================
void
glViewer
::
swapBuffers
()
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
glWidget_
->
context
()
->
swapBuffers
(
glWidget_
->
context
()
->
surface
());
#else
glWidget_
->
swapBuffers
();
#endif
}
//-----------------------------------------------------------------------------
//=============================================================================
//=============================================================================
widgets/glWidget/simpleViewer.cc
View file @
3a1d814a
...
...
@@ -67,6 +67,10 @@
#include "simpleViewer.hh"
#if (QT_VERSION >= QT_VERSION_CHECK(5,4,0))
#include <QOpenGLWidget>
#endif
//== NAMESPACES ===============================================================
...
...
@@ -78,9 +82,9 @@ SimpleViewer::SimpleViewer(QWidget* _parent, bool useDefaultSceneGraph) :
props_
(
-
1
),
actionMode_
(
Viewer
::
ExamineMode
)
{
Q
GLWidget
*
share
=
PluginFunctions
::
shareGLWidget
();
OF
GLWidget
*
share
=
PluginFunctions
::
shareGLWidget
();
if
(
!
share
)
initialize
(
Q
GLFormat
::
defaultFormat
(),
0
,
useDefaultSceneGraph
);
initialize
(
OF
GLFormat
::
defaultFormat
(),
0
,
useDefaultSceneGraph
);
else
initialize
(
share
->
format
(),
share
,
useDefaultSceneGraph
);
}
...
...
@@ -103,7 +107,7 @@ void SimpleViewer::resizeEvent(QResizeEvent *_event) {
//=============================================================================
//=============================================================================
void
SimpleViewer
::
initialize
(
const
Q
GLFormat
&
_format
,
Q
GLWidget
*
_shareWidget
,
bool
useDefaultSceneGraph
)
void
SimpleViewer
::
initialize
(
const
OF
GLFormat
&
_format
,
OF
GLWidget
*
_shareWidget
,
bool
useDefaultSceneGraph
)
{
connect
(
&
props_
,
SIGNAL
(
getPickMode
(
std
::
string
&
)
),
...
...
@@ -113,7 +117,12 @@ void SimpleViewer::initialize (const QGLFormat & _format, QGLWidget *_shareWidge
connect
(
&
props_
,
SIGNAL
(
setActionMode
(
const
Viewer
::
ActionMode
)
),
this
,
SLOT
(
setActionMode
(
const
Viewer
::
ActionMode
)),
Qt
::
DirectConnection
);
glWidget_
=
new
QGLWidget
(
_format
,
0
,
_shareWidget
);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
glWidget_
=
new
OFGLWidget
();
glWidget_
->
setFormat
(
_format
);
#else
glWidget_
=
new
OFGLWidget
(
_format
,
0
,
_shareWidget
);
#endif
setFocusPolicy
(
Qt
::
StrongFocus
);
setAcceptDrops
(
true
);
...
...
widgets/glWidget/simpleViewer.hh
View file @
3a1d814a
...
...
@@ -62,7 +62,8 @@
#include <OpenFlipper/common/ViewerProperties.hh>
#include <OpenFlipper/common/GlobalDefines.hh>
#include <QGraphicsView>
#include <QGLFormat>
#include <OpenFlipper/common/OFGLWidget.hh>
...
...
@@ -107,7 +108,7 @@ class DLLEXPORT SimpleViewer : public QGraphicsView
private:
// initalisation
void
initialize
(
const
Q
GLFormat
&
_format
,
Q
GLWidget
*
_shareWidget
=
NULL
,
bool
useDefaultSceneGraph
=
true
);
void
initialize
(
const
OF
GLFormat
&
_format
,
OF
GLWidget
*
_shareWidget
=
NULL
,
bool
useDefaultSceneGraph
=
true
);
private
slots
:
...
...
@@ -119,7 +120,7 @@ class DLLEXPORT SimpleViewer : public QGraphicsView
void
getPickMode
(
std
::
string
&
_name
);
private:
Q
GLWidget
*
glWidget_
;
OF
GLWidget
*
glWidget_
;
Viewer
::
ViewerProperties
props_
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment