Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
6bb38bbd
Commit
6bb38bbd
authored
Nov 25, 2010
by
lm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed support for very outdated Qt3, relying only on Qt4.0 now
parent
bccbbb70
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
118 deletions
+82
-118
QOSGWidget.cc
src/ui/map3D/QOSGWidget.cc
+1
-23
QOSGWidget.h
src/ui/map3D/QOSGWidget.h
+81
-95
No files found.
src/ui/map3D/QOSGWidget.cc
View file @
6bb38bbd
...
...
@@ -19,22 +19,13 @@
#include "QOSGWidget.h"
QOSGWidget
::
QOSGWidget
(
QWidget
*
parent
,
const
char
*
name
,
WindowFlags
f
,
bool
overrideTraits
)
:
#if USE_QT4
QWidget
(
parent
,
f
),
_overrideTraits
(
overrideTraits
)
#else
QWidget
(
parent
,
name
,
f
),
_overrideTraits
(
overrideTraits
)
#endif
{
createContext
();
#if USE_QT4
setAttribute
(
Qt
::
WA_PaintOnScreen
);
setAttribute
(
Qt
::
WA_NoSystemBackground
);
setFocusPolicy
(
Qt
::
ClickFocus
);
#else
setBackgroundMode
(
Qt
::
NoBackground
);
#endif
setFocusPolicy
(
Qt
::
ClickFocus
);
}
void
QOSGWidget
::
createContext
()
...
...
@@ -106,9 +97,7 @@ void QOSGWidget::destroyEvent(bool destroyWindow, bool destroySubWindows)
void
QOSGWidget
::
closeEvent
(
QCloseEvent
*
event
)
{
#ifndef USE_QT4
event
->
accept
();
#endif
_gw
->
getEventQueue
()
->
closeWindow
();
}
...
...
@@ -123,20 +112,12 @@ void QOSGWidget::resizeEvent( QResizeEvent * event )
void
QOSGWidget
::
keyPressEvent
(
QKeyEvent
*
event
)
{
#if USE_QT4
_gw
->
getEventQueue
()
->
keyPress
(
(
osgGA
::
GUIEventAdapter
::
KeySymbol
)
*
(
event
->
text
().
toAscii
().
data
()
)
);
#else
_gw
->
getEventQueue
()
->
keyPress
(
(
osgGA
::
GUIEventAdapter
::
KeySymbol
)
event
->
ascii
()
);
#endif
}
void
QOSGWidget
::
keyReleaseEvent
(
QKeyEvent
*
event
)
{
#if USE_QT4
int
c
=
*
event
->
text
().
toAscii
().
data
();
#else
int
c
=
event
->
ascii
();
#endif
_gw
->
getEventQueue
()
->
keyRelease
(
(
osgGA
::
GUIEventAdapter
::
KeySymbol
)
(
c
)
);
}
...
...
@@ -229,8 +210,6 @@ void CompositeViewerQOSG::RemoveView()
Tile
();
}
#if USE_QT4
// we use this wrapper for CompositeViewer ONLY because of the timer
// NOTE: this is a workaround because we're not using QT's moc precompiler here.
//
...
...
@@ -259,7 +238,6 @@ class QViewerTimer : public QWidget
QTimer
_timer
;
};
#endif
void
setupHandlers
(
osgViewer
::
View
*
viewer
)
{
...
...
src/ui/map3D/QOSGWidget.h
View file @
6bb38bbd
...
...
@@ -19,31 +19,17 @@
#include <osg/Config>
#if defined(_MSC_VER) && defined(OSG_DISABLE_MSVC_WARNINGS)
// disable warning "'QtConcurrent::BlockSizeManager' : assignment operator could not be generated"
#pragma warning( disable : 4512 )
#endif
#if QT_VERSION >= 400
#include <QtCore/QString>
#include <QtCore/QTimer>
#include <QtGui/QKeyEvent>
#include <QtGui/QApplication>
#include <QtGui/QtGui>
#include <QtGui/QWidget>
using
Qt
::
WindowFlags
;
#else
class
QWidget
;
#include <qtimer.h>
#include <qgl.h>
#include <qapplication.h>
#define WindowFlags WFlags
// disable warning "'QtConcurrent::BlockSizeManager' : assignment operator could not be generated"
#pragma warning( disable : 4512 )
#endif
#include <QtCore/QString>
#include <QtCore/QTimer>
#include <QtGui/QKeyEvent>
#include <QtGui/QApplication>
#include <QtGui/QtGui>
#include <QtGui/QWidget>
using
Qt
::
WindowFlags
;
#include <osgViewer/Viewer>
#include <osgViewer/CompositeViewer>
...
...
@@ -85,119 +71,119 @@ typedef osgViewer::GraphicsWindowX11::WindowData WindowData;
class
QOSGWidget
:
public
QWidget
{
public:
public:
QOSGWidget
(
QWidget
*
parent
=
0
,
const
char
*
name
=
0
,
WindowFlags
f
=
0
,
bool
overrideTraits
=
false
);
QOSGWidget
(
QWidget
*
parent
=
0
,
const
char
*
name
=
0
,
WindowFlags
f
=
0
,
bool
overrideTraits
=
false
);
virtual
~
QOSGWidget
()
{}
virtual
~
QOSGWidget
()
{}
osgViewer
::
GraphicsWindow
*
getGraphicsWindow
()
{
return
_gw
.
get
();
}
const
osgViewer
::
GraphicsWindow
*
getGraphicsWindow
()
const
{
return
_gw
.
get
();
}
osgViewer
::
GraphicsWindow
*
getGraphicsWindow
()
{
return
_gw
.
get
();
}
const
osgViewer
::
GraphicsWindow
*
getGraphicsWindow
()
const
{
return
_gw
.
get
();
}
protected:
protected:
void
init
();
void
createContext
();
void
init
();
void
createContext
();
// The GraphincsWindowWin32 implementation already takes care of message handling.
// We don't want to relay these on Windows, it will just cause duplicate messages
// with further problems downstream (i.e. not being able to throw the trackball
// The GraphincsWindowWin32 implementation already takes care of message handling.
// We don't want to relay these on Windows, it will just cause duplicate messages
// with further problems downstream (i.e. not being able to throw the trackball
#ifndef WIN32
virtual
void
mouseDoubleClickEvent
(
QMouseEvent
*
event
);
virtual
void
closeEvent
(
QCloseEvent
*
event
);
virtual
void
destroyEvent
(
bool
destroyWindow
=
true
,
bool
destroySubWindows
=
true
);
virtual
void
resizeEvent
(
QResizeEvent
*
event
);
virtual
void
keyPressEvent
(
QKeyEvent
*
event
);
virtual
void
keyReleaseEvent
(
QKeyEvent
*
event
);
virtual
void
mousePressEvent
(
QMouseEvent
*
event
);
virtual
void
mouseReleaseEvent
(
QMouseEvent
*
event
);
virtual
void
mouseMoveEvent
(
QMouseEvent
*
event
);
virtual
void
mouseDoubleClickEvent
(
QMouseEvent
*
event
);
virtual
void
closeEvent
(
QCloseEvent
*
event
);
virtual
void
destroyEvent
(
bool
destroyWindow
=
true
,
bool
destroySubWindows
=
true
);
virtual
void
resizeEvent
(
QResizeEvent
*
event
);
virtual
void
keyPressEvent
(
QKeyEvent
*
event
);
virtual
void
keyReleaseEvent
(
QKeyEvent
*
event
);
virtual
void
mousePressEvent
(
QMouseEvent
*
event
);
virtual
void
mouseReleaseEvent
(
QMouseEvent
*
event
);
virtual
void
mouseMoveEvent
(
QMouseEvent
*
event
);
#endif
osg
::
ref_ptr
<
osgViewer
::
GraphicsWindow
>
_gw
;
osg
::
ref_ptr
<
osgViewer
::
GraphicsWindow
>
_gw
;
bool
_overrideTraits
;
};
class
ViewerQOSG
:
public
osgViewer
::
Viewer
,
public
QOSGWidget
{
public:
public:
ViewerQOSG
(
QWidget
*
parent
=
0
,
const
char
*
name
=
0
,
WindowFlags
f
=
0
,
int
fps
=
20
)
:
ViewerQOSG
(
QWidget
*
parent
=
0
,
const
char
*
name
=
0
,
WindowFlags
f
=
0
,
int
fps
=
20
)
:
QOSGWidget
(
parent
,
name
,
f
)
{
setThreadingModel
(
osgViewer
::
Viewer
::
SingleThreaded
);
{
setThreadingModel
(
osgViewer
::
Viewer
::
SingleThreaded
);
connect
(
&
_timer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
update
()));
_timer
.
start
(
1000
.
0
f
/
fps
);
}
connect
(
&
_timer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
update
()));
_timer
.
start
(
1000
.
0
f
/
fps
);
}
void
updateCamera
()
{
getCamera
()
->
setViewport
(
new
osg
::
Viewport
(
0
,
0
,
width
(),
height
()));
getCamera
()
->
setProjectionMatrixAsPerspective
(
30
.
0
f
,
1
.
0
f
,
static_cast
<
double
>
(
width
())
/
static_cast
<
double
>
(
height
()),
10000
.
0
f
);
getCamera
()
->
setGraphicsContext
(
getGraphicsWindow
());
}
void
updateCamera
()
{
getCamera
()
->
setViewport
(
new
osg
::
Viewport
(
0
,
0
,
width
(),
height
()));
getCamera
()
->
setProjectionMatrixAsPerspective
(
30
.
0
f
,
1
.
0
f
,
static_cast
<
double
>
(
width
())
/
static_cast
<
double
>
(
height
()),
10000
.
0
f
);
getCamera
()
->
setGraphicsContext
(
getGraphicsWindow
());
}
virtual
void
paintEvent
(
QPaintEvent
*
event
)
{
frame
();
}
virtual
void
paintEvent
(
QPaintEvent
*
event
)
{
frame
();
}
protected:
protected:
QTimer
_timer
;
QTimer
_timer
;
};
class
CompositeViewerQOSG
:
public
osgViewer
::
CompositeViewer
,
public
QOSGWidget
{
public:
CompositeViewerQOSG
(
QWidget
*
parent
=
0
,
const
char
*
name
=
0
,
WindowFlags
f
=
0
,
int
fps
=
20
)
public:
CompositeViewerQOSG
(
QWidget
*
parent
=
0
,
const
char
*
name
=
0
,
WindowFlags
f
=
0
,
int
fps
=
20
)
:
QOSGWidget
(
parent
,
name
,
f
)
{
setThreadingModel
(
osgViewer
::
CompositeViewer
::
SingleThreaded
);
{
setThreadingModel
(
osgViewer
::
CompositeViewer
::
SingleThreaded
);
connect
(
&
_timer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
repaint
()));
connect
(
&
_timer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
repaint
()));
// The composite viewer needs at least one view to work
// Create a dummy view with a zero sized viewport and no
// scene to keep the viewer alive.
osgViewer
::
View
*
pView
=
new
osgViewer
::
View
;
pView
->
getCamera
()
->
setGraphicsContext
(
getGraphicsWindow
()
);
pView
->
getCamera
()
->
setViewport
(
0
,
0
,
0
,
0
);
addView
(
pView
);
// The composite viewer needs at least one view to work
// Create a dummy view with a zero sized viewport and no
// scene to keep the viewer alive.
osgViewer
::
View
*
pView
=
new
osgViewer
::
View
;
pView
->
getCamera
()
->
setGraphicsContext
(
getGraphicsWindow
()
);
pView
->
getCamera
()
->
setViewport
(
0
,
0
,
0
,
0
);
addView
(
pView
);
// Clear the viewer of removed views
getGraphicsWindow
()
->
setClearMask
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
getGraphicsWindow
()
->
setClearColor
(
osg
::
Vec4
(
0
.
08
,
0
.
08
,
0
.
5
,
1
.
0
)
);
// Clear the viewer of removed views
getGraphicsWindow
()
->
setClearMask
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
getGraphicsWindow
()
->
setClearColor
(
osg
::
Vec4
(
0
.
08
,
0
.
08
,
0
.
5
,
1
.
0
)
);
// The app would hang on exit when using start(1). Behaves better with 10
// like the non-composite viewer. Was this just a typo?
_timer
.
start
(
1000
.
0
f
/
fps
);
}
// The app would hang on exit when using start(1). Behaves better with 10
// like the non-composite viewer. Was this just a typo?
_timer
.
start
(
1000
.
0
f
/
fps
);
}
virtual
void
paintEvent
(
QPaintEvent
*
event
)
{
frame
();
}
virtual
void
paintEvent
(
QPaintEvent
*
event
)
{
frame
();
}
void
keyPressEvent
(
QKeyEvent
*
event
)
void
keyPressEvent
(
QKeyEvent
*
event
)
{
if
(
event
->
text
()
==
"a"
)
{
if
(
event
->
text
()
==
"a"
)
{
AddView
(
_scene
.
get
()
);
}
}
if
(
event
->
text
()
==
"r"
)
{
if
(
event
->
text
()
==
"r"
)
{
RemoveView
();
}
QOSGWidget
::
keyPressEvent
(
event
);
}
QOSGWidget
::
keyPressEvent
(
event
);
}
void
AddView
(
osg
::
Node
*
scene
);
void
RemoveView
();
void
Tile
();
void
AddView
(
osg
::
Node
*
scene
);
void
RemoveView
();
void
Tile
();
osg
::
ref_ptr
<
osg
::
Node
>
_scene
;
osg
::
ref_ptr
<
osg
::
Node
>
_scene
;
protected:
QTimer
_timer
;
protected:
QTimer
_timer
;
};
void
setupHandlers
(
osgViewer
::
View
*
viewer
);
...
...
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