Commit 9bc4a88f authored by Lionel Heng's avatar Lionel Heng

3D View perspective now uses the OpenSceneGraph framework. Imagery feature is based on osgEarth.

parent c043b38a
#------------------------------------------------- # -------------------------------------------------
#
# QGroundControl - Micro Air Vehicle Groundstation # QGroundControl - Micro Air Vehicle Groundstation
#
# Please see our website at <http://qgroundcontrol.org> # Please see our website at <http://qgroundcontrol.org>
#
# Author: # Author:
# Lorenz Meier <mavteam@student.ethz.ch> # Lorenz Meier <mavteam@student.ethz.ch>
#
# (c) 2009-2010 PIXHAWK Team # (c) 2009-2010 PIXHAWK Team
#
# This file is part of the mav groundstation project # This file is part of the mav groundstation project
# QGroundControl is free software: you can redistribute it and/or modify # QGroundControl is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
...@@ -20,10 +15,7 @@ ...@@ -20,10 +15,7 @@
# GNU General Public License for more details. # GNU General Public License for more details.
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with QGroundControl. If not, see <http://www.gnu.org/licenses/>. # along with QGroundControl. If not, see <http://www.gnu.org/licenses/>.
# # -------------------------------------------------
#-------------------------------------------------
# Include QMapControl map library # Include QMapControl map library
# prefer version from external directory / # prefer version from external directory /
# from http://github.com/pixhawk/qmapcontrol/ # from http://github.com/pixhawk/qmapcontrol/
...@@ -31,7 +23,6 @@ ...@@ -31,7 +23,6 @@
# Version from GIT repository is preferred # Version from GIT repository is preferred
# include ( "../qmapcontrol/QMapControl/QMapControl.pri" ) #{ # include ( "../qmapcontrol/QMapControl/QMapControl.pri" ) #{
# Include bundled version if necessary # Include bundled version if necessary
include(lib/QMapControl/QMapControl.pri) include(lib/QMapControl/QMapControl.pri)
# message("Including bundled QMapControl version as FALLBACK. This is fine on Linux and MacOS, but not the best choice in Windows") # message("Including bundled QMapControl version as FALLBACK. This is fine on Linux and MacOS, but not the best choice in Windows")
...@@ -50,40 +41,43 @@ CONFIG += debug_and_release \ ...@@ -50,40 +41,43 @@ CONFIG += debug_and_release \
OBJECTS_DIR = $$BUILDDIR/obj OBJECTS_DIR = $$BUILDDIR/obj
MOC_DIR = $$BUILDDIR/moc MOC_DIR = $$BUILDDIR/moc
UI_HEADERS_DIR = src/ui/generated UI_HEADERS_DIR = src/ui/generated
MAVLINK_CONF = "" MAVLINK_CONF = ""
exists(user_config.pri) {
exists(user_config.pri) {
message("----- USING USER QGROUNDCONTROL CONFIG FROM user_config.pri -----") message("----- USING USER QGROUNDCONTROL CONFIG FROM user_config.pri -----")
include(user_config.pri) include(user_config.pri)
} }
INCLUDEPATH += $$BASEDIR/../mavlink/include/common INCLUDEPATH += $$BASEDIR/../mavlink/include/common
contains(MAVLINK_CONF, pixhawk) {
contains(MAVLINK_CONF, pixhawk) { # Remove the default set - it is included anyway
# Remove the default set - it is included anyway INCLUDEPATH -= $$BASEDIR/../mavlink/include/common
INCLUDEPATH -= $$BASEDIR/../mavlink/include/common
# PIXHAWK SPECIAL MESSAGES # PIXHAWK SPECIAL MESSAGES
INCLUDEPATH += $$BASEDIR/../mavlink/include/pixhawk INCLUDEPATH += $$BASEDIR/../mavlink/include/pixhawk
DEFINES += QGC_USE_PIXHAWK_MESSAGES DEFINES += QGC_USE_PIXHAWK_MESSAGES
} }
contains(MAVLINK_CONF, slugs) {
contains(MAVLINK_CONF, slugs) { # Remove the default set - it is included anyway
# Remove the default set - it is included anyway INCLUDEPATH -= $$BASEDIR/../mavlink/include/common
INCLUDEPATH -= $$BASEDIR/../mavlink/include/common
# SLUGS SPECIAL MESSAGES # SLUGS SPECIAL MESSAGES
INCLUDEPATH += $$BASEDIR/../mavlink/include/slugs INCLUDEPATH += $$BASEDIR/../mavlink/include/slugs
DEFINES += QGC_USE_SLUGS_MESSAGES DEFINES += QGC_USE_SLUGS_MESSAGES
} }
contains(MAVLINK_CONF, ualberta) {
contains(MAVLINK_CONF, ualberta) { # Remove the default set - it is included anyway
# Remove the default set - it is included anyway INCLUDEPATH -= $$BASEDIR/../mavlink/include/common
INCLUDEPATH -= $$BASEDIR/../mavlink/include/common
# UALBERTA SPECIAL MESSAGES # UALBERTA SPECIAL MESSAGES
INCLUDEPATH += $$BASEDIR/../mavlink/include/ualberta INCLUDEPATH += $$BASEDIR/../mavlink/include/ualberta
DEFINES += QGC_USE_UALBERTA_MESSAGES DEFINES += QGC_USE_UALBERTA_MESSAGES
} }
# Include OpenSceneGraph and osgEarth libraries
LIBS += -losg \
-losgViewer \
-losgEarth
QMAKE_CXXFLAGS += -Wl,-E
# } # }
# Include general settings for MAVGround # Include general settings for MAVGround
# necessary as last include to override any non-acceptable settings # necessary as last include to override any non-acceptable settings
...@@ -226,15 +220,15 @@ HEADERS += src/MG.h \ ...@@ -226,15 +220,15 @@ HEADERS += src/MG.h \
src/ui/RadioCalibration/CurveCalibrator.h \ src/ui/RadioCalibration/CurveCalibrator.h \
src/ui/RadioCalibration/AbstractCalibrator.h \ src/ui/RadioCalibration/AbstractCalibrator.h \
src/ui/map3D/Q3DWidget.h \ src/ui/map3D/Q3DWidget.h \
src/ui/map3D/CheetahModel.h \ src/ui/map3D/PixhawkCheetahGeode.h \
src/ui/map3D/CheetahGL.h \
src/ui/map3D/QMap3DWidget.h \
src/ui/map3D/Texture.h \ src/ui/map3D/Texture.h \
src/ui/map3D/TextureCache.h \ src/ui/map3D/TextureCache.h \
src/ui/map3D/WebImage.h \ src/ui/map3D/WebImage.h \
src/ui/map3D/WebImageCache.h \ src/ui/map3D/WebImageCache.h \
src/ui/map3D/Imagery.h \ src/ui/map3D/Imagery.h \
src/comm/QGCMAVLink.h src/comm/QGCMAVLink.h \
src/ui/map3D/Pixhawk3DWidget.h \
src/ui/map3D/Q3DWidgetFactory.h
SOURCES += src/main.cc \ SOURCES += src/main.cc \
src/Core.cc \ src/Core.cc \
src/uas/UASManager.cc \ src/uas/UASManager.cc \
...@@ -306,14 +300,14 @@ SOURCES += src/main.cc \ ...@@ -306,14 +300,14 @@ SOURCES += src/main.cc \
src/ui/RadioCalibration/RadioCalibrationData.cc \ src/ui/RadioCalibration/RadioCalibrationData.cc \
src/ui/WaypointGlobalView.cc \ src/ui/WaypointGlobalView.cc \
src/ui/map3D/Q3DWidget.cc \ src/ui/map3D/Q3DWidget.cc \
src/ui/map3D/CheetahModel.cc \ src/ui/map3D/PixhawkCheetahGeode.cc \
src/ui/map3D/CheetahGL.cc \
src/ui/map3D/QMap3DWidget.cc \
src/ui/map3D/Texture.cc \ src/ui/map3D/Texture.cc \
src/ui/map3D/TextureCache.cc \ src/ui/map3D/TextureCache.cc \
src/ui/map3D/WebImageCache.cc \ src/ui/map3D/WebImageCache.cc \
src/ui/map3D/WebImage.cc \ src/ui/map3D/WebImage.cc \
src/ui/map3D/Imagery.cc src/ui/map3D/Imagery.cc \
src/ui/map3D/Pixhawk3DWidget.cc \
src/ui/map3D/Q3DWidgetFactory.cc
RESOURCES = mavground.qrc RESOURCES = mavground.qrc
# Include RT-LAB Library # Include RT-LAB Library
......
...@@ -45,7 +45,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -45,7 +45,7 @@ This file is part of the QGROUNDCONTROL project
#include "MainWindow.h" #include "MainWindow.h"
#include "JoystickWidget.h" #include "JoystickWidget.h"
#include "GAudioOutput.h" #include "GAudioOutput.h"
#include "QMap3DWidget.h" #include "Q3DWidgetFactory.h"
// FIXME Move // FIXME Move
#include "PxQuadMAV.h" #include "PxQuadMAV.h"
...@@ -132,7 +132,7 @@ void MainWindow::buildWidgets() ...@@ -132,7 +132,7 @@ void MainWindow::buildWidgets()
mapWidget = new MapWidget(this); mapWidget = new MapWidget(this);
protocolWidget = new XMLCommProtocolWidget(this); protocolWidget = new XMLCommProtocolWidget(this);
dataplotWidget = new QGCDataPlot2D(this); dataplotWidget = new QGCDataPlot2D(this);
map3DWidget = new QMap3DWidget(this); _3DWidget = Q3DWidgetFactory::get("PIXHAWK");
// Dock widgets // Dock widgets
controlDockWidget = new QDockWidget(tr("Control"), this); controlDockWidget = new QDockWidget(tr("Control"), this);
...@@ -224,7 +224,7 @@ void MainWindow::arrangeCenterStack() ...@@ -224,7 +224,7 @@ void MainWindow::arrangeCenterStack()
if (linechartWidget) centerStack->addWidget(linechartWidget); if (linechartWidget) centerStack->addWidget(linechartWidget);
if (protocolWidget) centerStack->addWidget(protocolWidget); if (protocolWidget) centerStack->addWidget(protocolWidget);
if (mapWidget) centerStack->addWidget(mapWidget); if (mapWidget) centerStack->addWidget(mapWidget);
if (map3DWidget) centerStack->addWidget(map3DWidget); if (_3DWidget) centerStack->addWidget(_3DWidget);
if (hudWidget) centerStack->addWidget(hudWidget); if (hudWidget) centerStack->addWidget(hudWidget);
if (dataplotWidget) centerStack->addWidget(dataplotWidget); if (dataplotWidget) centerStack->addWidget(dataplotWidget);
...@@ -665,13 +665,13 @@ void MainWindow::loadPixhawkView() ...@@ -665,13 +665,13 @@ void MainWindow::loadPixhawkView()
// Engineer view, used in EMAV2009 // Engineer view, used in EMAV2009
// 3D map // 3D map
if (map3DWidget) if (_3DWidget)
{ {
QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget()); QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
if (centerStack) if (centerStack)
{ {
//map3DWidget->setActive(true); //map3DWidget->setActive(true);
centerStack->setCurrentWidget(map3DWidget); centerStack->setCurrentWidget(_3DWidget);
} }
} }
...@@ -955,13 +955,13 @@ void MainWindow::load3DView() ...@@ -955,13 +955,13 @@ void MainWindow::load3DView()
clearView(); clearView();
// 3D map // 3D map
if (map3DWidget) if (_3DWidget)
{ {
QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget()); QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
if (centerStack) if (centerStack)
{ {
//map3DWidget->setActive(true); //map3DWidget->setActive(true);
centerStack->setCurrentWidget(map3DWidget); centerStack->setCurrentWidget(_3DWidget);
} }
} }
......
...@@ -63,7 +63,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -63,7 +63,7 @@ This file is part of the QGROUNDCONTROL project
#include "HSIDisplay.h" #include "HSIDisplay.h"
#include "QGCDataPlot2D.h" #include "QGCDataPlot2D.h"
#include "QGCRemoteControlView.h" #include "QGCRemoteControlView.h"
#include "QMap3DWidget.h" #include "Q3DWidget.h"
#include "LogCompressor.h" #include "LogCompressor.h"
...@@ -163,7 +163,7 @@ protected: ...@@ -163,7 +163,7 @@ protected:
QPointer<MapWidget> mapWidget; QPointer<MapWidget> mapWidget;
QPointer<XMLCommProtocolWidget> protocolWidget; QPointer<XMLCommProtocolWidget> protocolWidget;
QPointer<QGCDataPlot2D> dataplotWidget; QPointer<QGCDataPlot2D> dataplotWidget;
QPointer<QMap3DWidget> map3DWidget; QPointer<Q3DWidget> _3DWidget;
// Dock widgets // Dock widgets
QPointer<QDockWidget> controlDockWidget; QPointer<QDockWidget> controlDockWidget;
QPointer<QDockWidget> infoDockWidget; QPointer<QDockWidget> infoDockWidget;
......
This diff is collapsed.
///*=====================================================================
//
//QGroundControl Open Source Ground Control Station
//
//(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
//
//This file is part of the QGROUNDCONTROL project
//
// QGROUNDCONTROL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// QGROUNDCONTROL is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
//
//======================================================================*/
/**
* @file
* @brief Definition of the class Pixhawk3DWidget.
*
* @author Lionel Heng <hengli@student.ethz.ch>
*
*/
#ifndef PIXHAWK3DWIDGET_H
#define PIXHAWK3DWIDGET_H
#include <osgText/Text>
#include "Q3DWidget.h"
class UASInterface;
/**
* @brief A 3D View widget which displays vehicle-centric information.
**/
class Pixhawk3DWidget : public Q3DWidget
{
Q_OBJECT
public:
explicit Pixhawk3DWidget(QWidget* parent = 0);
~Pixhawk3DWidget();
void buildLayout(void);
static void display(void* clientData);
void displayHandler(void);
static void mouse(Qt::MouseButton button, MouseState state,
int32_t x, int32_t y, void* clientData);
void mouseHandler(Qt::MouseButton button, MouseState state,
int32_t x, int32_t y);
static void timer(void* clientData);
void timerHandler(void);
double getTime(void) const;
public slots:
void setActiveUAS(UASInterface* uas);
void markTarget(void);
private slots:
void showGrid(int state);
void showTrail(int state);
void recenterCamera(void);
void toggleLockCamera(int state);
protected:
UASInterface* uas;
private:
osg::ref_ptr<osg::Geode> createGrid(void);
osg::ref_ptr<osg::Geode> createTrail(void);
osg::ref_ptr<osg::Group> createTarget(void);
osg::ref_ptr<osg::Group> createWaypoints(void);
void setupHUD(void);
void updateHUD(float robotX, float robotY, float robotZ,
float robotRoll, float robotPitch, float robotYaw);
void updateTrail(float robotX, float robotY, float robotZ);
void updateTarget(float robotX, float robotY, float robotZ);
void updateWaypoints(void);
double lastRedrawTime;
bool displayGrid;
bool displayTrail;
bool displayTarget;
bool displayWaypoints;
typedef struct
{
float x;
float y;
float z;
} Pose3D;
bool lockCamera;
osg::ref_ptr<osg::Vec3Array> trailVertices;
QVarLengthArray<osg::Vec3, 10000> trail;
osg::Vec3 targetPosition;
osg::ref_ptr<osg::Geometry> hudBackgroundGeometry;
osg::ref_ptr<osgText::Text> statusText;
osg::ref_ptr<osg::Geode> gridNode;
osg::ref_ptr<osg::Geode> trailNode;
osg::ref_ptr<osg::Geometry> trailGeometry;
osg::ref_ptr<osg::DrawArrays> trailDrawArrays;
osg::ref_ptr<osg::Group> targetNode;
osg::ref_ptr<osg::Group> waypointsNode;
};
#endif // PIXHAWK3DWIDGET_H
This diff is collapsed.
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Generates a geode which renders a Pixhawk Cheetah MAV.
*
* @author Lionel Heng <hengli@student.ethz.ch>
*
*/
#ifndef PIXHAWKCHEETAHGEODE_H_
#define PIXHAWKCHEETAHGEODE_H_
#include <osg/Geode>
/**
* @brief Creates a geode which renders a Pixhawk Cheetah MAV.
* @param red Red intensity of the MAV model
* @param green Green intensity of the MAV model
* @param blue Blue intensity of the MAV model
*
* @return The pointer to the geode.
**/
class PixhawkCheetahGeode
{
public:
PixhawkCheetahGeode();
static osg::ref_ptr<osg::Geode> instance(void);
private:
static osg::ref_ptr<osg::Geode> create(float red, float green, float blue);
static osg::ref_ptr<osg::Geode> _instance;
};
#endif
This diff is collapsed.
...@@ -29,47 +29,14 @@ This file is part of the QGROUNDCONTROL project ...@@ -29,47 +29,14 @@ This file is part of the QGROUNDCONTROL project
* *
*/ */
#ifndef Q3DWIDGET_H_ #ifndef Q3DWIDGET_H
#define Q3DWIDGET_H_ #define Q3DWIDGET_H
#include <inttypes.h>
#include <string>
#include <QtOpenGL> #include <QtOpenGL>
#include <QtGui>
//class GLUquadricObj; #include <osg/LineSegment>
#include <osg/PositionAttitudeTransform>
enum CameraState #include <osgViewer/Viewer>
{
IDLE = 0,
ROTATING = 1,
MOVING = 2,
ZOOMING = 3
};
struct CameraPose
{
CameraState state;
float pan, tilt, distance;
float xOffset, yOffset, zOffset;
float xOffset2D, yOffset2D, rotation2D, zoom, warpX, warpY;
};
struct CameraParams
{
float zoomSensitivity;
float rotateSensitivity;
float moveSensitivity;
float minZoomRange;
float cameraFov;
float minClipRange;
float maxClipRange;
float zoomSensitivity2D;
float rotateSensitivity2D;
float moveSensitivity2D;
};
enum MouseState enum MouseState
{ {
...@@ -79,148 +46,113 @@ enum MouseState ...@@ -79,148 +46,113 @@ enum MouseState
typedef void (*DisplayFunc)(void *); typedef void (*DisplayFunc)(void *);
typedef void (*KeyboardFunc)(char, void *); typedef void (*KeyboardFunc)(char, void *);
typedef void (*MouseFunc)(Qt::MouseButton, MouseState, int32_t, int32_t, void *); typedef void (*MouseFunc)(Qt::MouseButton, MouseState, int, int, void *);
typedef void (*MotionFunc)(int32_t, int32_t, void *); typedef void (*MotionFunc)(int, int, void *);
/** class Q3DWidget : public QGLWidget, public osgViewer::Viewer
* @brief A base 3D widget which executes OpenGL commands.
**/
class Q3DWidget: public QGLWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit Q3DWidget(QWidget* parent); Q3DWidget(QWidget* parent = 0);
~Q3DWidget(); virtual ~Q3DWidget();
void initialize(int32_t windowX, int32_t windowY, void init(float fps);
int32_t windowWidth, int32_t windowHeight, float fps); void setCameraParams(float minZoomRange, float cameraFov,
float minClipRange,
void setCameraParams(float zoomSensitivity, float rotateSensitivity,
float moveSensitivity, float minZoomRange,
float cameraFov, float minClipRange,
float maxClipRange); float maxClipRange);
void setCameraLimit(bool onoff); void forceRedraw(void);
void recenter(void);
void set2DCameraParams(float zoomSensitivity, void setDisplayMode3D(void);
float rotateSensitivity,
float moveSensitivity);
void set3D(bool onoff);
bool is3D(void) const;
void setInitialCameraPos(float pan, float tilt, float range,
float xOffset, float yOffset, float zOffset);
void setInitial2DCameraPos(float xOffset, float yOffset,
float rotation, float zoom);
void setCameraPose(const CameraPose& cameraPose);
CameraPose getCameraPose(void) const;
void setDisplayFunc(DisplayFunc func, void* clientData); void setDisplayFunc(DisplayFunc func, void* clientData);
void setKeyboardFunc(KeyboardFunc func, void* clientData); void setKeyboardFunc(KeyboardFunc func, void* clientData);
void setMouseFunc(MouseFunc func, void* clientData); void setMouseFunc(MouseFunc func, void* clientData);
void setMotionFunc(MotionFunc func, void* clientData); void setMotionFunc(MotionFunc func, void* clientData);
void addTimerFunc(uint32_t msecs, void(*func)(void *), void addTimerFunc(uint msecs, void(*func)(void *),
void* clientData); void* clientData);
void forceRedraw(void); std::pair<float,float> getGlobalCursorPosition(int32_t mouseX,
int32_t mouseY);
void set2DWarping(float warpX, float warpY);
void recenter(void);
void recenter2D(void);
void set2DRotation(bool onoff);
void setDisplayMode2D(void);
std::pair<float,float> getPositionIn3DMode(int32_t mouseX, protected slots:
int32_t mouseY); void redraw(void);
std::pair<float,float> getPositionIn2DMode(int32_t mouseX,
int32_t mouseY);
int32_t getWindowWidth(void);
int32_t getWindowHeight(void);
int32_t getLastMouseX(void);
int32_t getLastMouseY(void);
int32_t getMouseX(void);
int32_t getMouseY(void);
private Q_SLOTS:
void userTimer(void); void userTimer(void);
protected: protected:
void rotateCamera(float dx, float dy); osg::ref_ptr<osg::Geode> createRobot(void);
void zoomCamera(float dy); osg::ref_ptr<osg::Node> createHUD(void);
void moveCamera(float dx, float dy);
void rotateCamera2D(float dx); int getMouseX(void);
void zoomCamera2D(float dx); int getMouseY(void);
void moveCamera2D(float dx, float dy); int getLastMouseX(void);
int getLastMouseY(void);
void switchTo3DMode(void);
void setDisplayMode3D(void); osgViewer::GraphicsWindow* getGraphicsWindow(void);
const osgViewer::GraphicsWindow* getGraphicsWindow(void) const;
float r2d(float angle) const;
float d2r(float angle) const; virtual void resizeGL(int width, int height);
virtual void paintGL(void);
void wireSphere(double radius, int slices, int stacks) const; virtual void keyPressEvent(QKeyEvent* event);
void solidSphere(double radius, int slices, int stacks) const; virtual void keyReleaseEvent(QKeyEvent* event);
void wireCone(double base, double height, int slices, int stacks) const; virtual void mousePressEvent(QMouseEvent* event);
void solidCone(double base, double height, int slices, int stacks) const; virtual void mouseReleaseEvent(QMouseEvent* event);
void drawBox(float size, GLenum type) const; virtual void mouseMoveEvent(QMouseEvent* event);
void wireCube(double size) const; virtual void wheelEvent(QWheelEvent* event);
void solidCube(double size) const;
void doughnut(float r, float R, int nsides, int rings) const; float r2d(float angle);
void wireTorus(double innerRadius, double outerRadius, float d2r(float angle);
int nsides, int rings) const; osgGA::GUIEventAdapter::KeySymbol convertKey(int key) const;
void solidTorus(double innerRadius, double outerRadius, osg::ref_ptr<osg::LineSegment> projectNormalizedXYIntoObjectCoordinates(
int nsides, int rings) const; const osg::Matrix& projectionMatrix,
const osg::Matrix& viewMatrix,
GLUquadricObj* quadObj; float x,
float y) const;
// QGLWidget events bool getPlaneLineIntersection(const osg::Vec4d& plane,
void initializeGL(void); const osg::LineSegment& line,
void paintGL(void); osg::Vec3d& isect);
void resizeGL(int32_t width, int32_t height);
osg::ref_ptr<osg::Group> root;
// Qt events osg::ref_ptr<osg::Switch> allocentricMap;
void keyPressEvent(QKeyEvent* event); osg::ref_ptr<osg::Switch> rollingMap;
void mousePressEvent(QMouseEvent* event); osg::ref_ptr<osg::Switch> egocentricMap;
void mouseReleaseEvent(QMouseEvent* event); osg::ref_ptr<osg::PositionAttitudeTransform> robotPosition;
void mouseMoveEvent(QMouseEvent* event); osg::ref_ptr<osg::PositionAttitudeTransform> robotAttitude;
void wheelEvent(QWheelEvent *wheel);
void timerEvent(QTimerEvent* event); osg::ref_ptr<osg::Geode> hudGeode;
void closeEvent(QCloseEvent* event); osg::ref_ptr<osg::Projection> hudProjectionMatrix;
DisplayFunc userDisplayFunc; DisplayFunc userDisplayFunc;
KeyboardFunc userKeyboardFunc; KeyboardFunc userKeyboardFunc;
MouseFunc userMouseFunc; MouseFunc userMouseFunc;
MotionFunc userMotionFunc; MotionFunc userMotionFunc;
void (*userTimerFunc)(void *);
void* userDisplayFuncData; void* userDisplayFuncData;
void* userKeyboardFuncData; void* userKeyboardFuncData;
void* userMouseFuncData; void* userMouseFuncData;
void* userMotionFuncData; void* userMotionFuncData;
void* userTimerFuncData;
int32_t windowWidth, windowHeight; osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> osgGW;
float requestedFps;
CameraPose cameraPose;
int32_t lastMouseX, lastMouseY;
bool _is3D; QTimer timer;
bool _forceRedraw; struct CameraParams
bool allow2DRotation; {
bool limitCamera; float minZoomRange;
float cameraFov;
float minClipRange;
float maxClipRange;
};
CameraParams cameraParams; CameraParams cameraParams;
QBasicTimer timer; int lastMouseX;
int lastMouseY;
void (*timerFunc)(void *); bool _forceRedraw;
void* timerFuncData;
}; };
#endif #endif // Q3DWIDGET_H
#include "Q3DWidgetFactory.h"
#include "Pixhawk3DWidget.h"
QPointer<Q3DWidget>
Q3DWidgetFactory::get(const std::string& type)
{
if (type == "PIXHAWK")
{
return QPointer<Q3DWidget>(new Pixhawk3DWidget);
}
else
{
return QPointer<Q3DWidget>(new Q3DWidget);
}
}
#ifndef Q3DWIDGETFACTORY_H
#define Q3DWIDGETFACTORY_H
#include <QPointer>
#include "Q3DWidget.h"
class Q3DWidgetFactory
{
public:
static QPointer<Q3DWidget> get(const std::string& type);
};
#endif // Q3DWIDGETFACTORY_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment