I've added a QWebView/Cesium based viewer. This requires the Qt WebKit module, which might not have come with your Qt distribution. When you click on the "Viewer" button in QtJSBSim you should get a new window which is an instance of QWebView. This is a web-enabled display widget which is hard coded to the URL: "http://localhost:8080/Apps/OTW". This will load the file at Cesium/Apps/OTW/index.html.
So, to make this work you first need to download the Cesium software, which is a collection of javascript and CSS files which displays a world view over the net. In the QtJSBSim repo you'll now find a new directory called OTW. It contains the two files (one html and one javascript) which create the world view. This directory needs to be put into your Cesium/Apps/ directory.
Next, you'll need a web server running on your local machine. The Cesium website recommends the nodejs server, so I installed that and it works well here. Once the Cesium directory is setup, and the OTW directory added, then it's time to start the server. If you're using nodejs, then just open a terminal, cd into Cesium, then run "nodejs server.js".
Now start QtJSBSim, and click on the "Server" button. A window just pop up with the world view (it may take a while depending on your computer). This is photoreal terrain, so it's going to load slow. I'm not sure how it'll behave once I start flying around in it. Hopefully not too slow.
The next step in development will be for QtJSBSim to write the aircraft position and orientation to a socket. The script at Cesium/Apps/OTW/viewer.js will then need a javascript socket added that will read the aircraft data and update the camera view.
[edit: see reply below for update]
Let me know if this works or doesn't work for you.
Phase two. I made the viewer a descendant of QDialog, which adds three more files - viewer.h, viewer.cpp and viewer.ui. Also a subtle change to the project file - QtWebKitWidgets is now required versus QtWebKit. The 737 init file has been updated to initialize on runway 25R at KLAX. The viewer now receives aircraft position data from JSBSim.
At first I wanted to set up UDP communication between QtJSBSim and the Ceisum viewer, but I couldn't figure out how to set up the socket at the Cesium end. Fortunately there is an even better way. Qt has the ability to share objects with the javascript environment of a given webpage frame. Here's how it's done:
On the Qt side, a new class called "aircraft" is derived from QObject. This class contains six doubles (3 for position and 3 for orientation) and uses the Q_INVOKABLE macro to allow code in the javascript environment to access the "aircraft" object. An instance of "aircraft" called Aircraft is instantiated in the viewer class, and it is then shared with the QFrame object in the QWebView. The QtJSBSim main loop now updates the Aircraft object to keep the six variables refreshed.
On the javascript side, the camera view is set using the "aircraft" object and its accessor functions. The camera view is refreshed 20 times per second (at least that's what the timer is set for. Actual Results may vary).
It works well here, although it's a bit choppy on my low-end computer. I don't know if it'll work well on a better machine, but even if it doesn't I'll keep it around as a technology demonstrator.
NOTE: QtWebKitWidgets requires Qt version 5.0+. You can check which version you have by running "qmake --version" in a console.
Last edit: David Culp 2015-11-19
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've added a QWebView/Cesium based viewer. This requires the Qt WebKit module, which might not have come with your Qt distribution. When you click on the "Viewer" button in QtJSBSim you should get a new window which is an instance of QWebView. This is a web-enabled display widget which is hard coded to the URL: "http://localhost:8080/Apps/OTW". This will load the file at Cesium/Apps/OTW/index.html.
So, to make this work you first need to download the Cesium software, which is a collection of javascript and CSS files which displays a world view over the net. In the QtJSBSim repo you'll now find a new directory called OTW. It contains the two files (one html and one javascript) which create the world view. This directory needs to be put into your Cesium/Apps/ directory.
Next, you'll need a web server running on your local machine. The Cesium website recommends the nodejs server, so I installed that and it works well here. Once the Cesium directory is setup, and the OTW directory added, then it's time to start the server. If you're using nodejs, then just open a terminal, cd into Cesium, then run "nodejs server.js".
Now start QtJSBSim, and click on the "Server" button. A window just pop up with the world view (it may take a while depending on your computer). This is photoreal terrain, so it's going to load slow. I'm not sure how it'll behave once I start flying around in it. Hopefully not too slow.
The next step in development will be for QtJSBSim to write the aircraft position and orientation to a socket. The script at Cesium/Apps/OTW/viewer.js will then need a javascript socket added that will read the aircraft data and update the camera view.
[edit: see reply below for update]
Let me know if this works or doesn't work for you.
Here's a screenshot: https://dl.dropboxusercontent.com/u/12562954/Cesium_OTW.jpg
Last edit: David Culp 2015-11-18
Phase two. I made the viewer a descendant of QDialog, which adds three more files - viewer.h, viewer.cpp and viewer.ui. Also a subtle change to the project file - QtWebKitWidgets is now required versus QtWebKit. The 737 init file has been updated to initialize on runway 25R at KLAX. The viewer now receives aircraft position data from JSBSim.
At first I wanted to set up UDP communication between QtJSBSim and the Ceisum viewer, but I couldn't figure out how to set up the socket at the Cesium end. Fortunately there is an even better way. Qt has the ability to share objects with the javascript environment of a given webpage frame. Here's how it's done:
On the Qt side, a new class called "aircraft" is derived from QObject. This class contains six doubles (3 for position and 3 for orientation) and uses the Q_INVOKABLE macro to allow code in the javascript environment to access the "aircraft" object. An instance of "aircraft" called Aircraft is instantiated in the viewer class, and it is then shared with the QFrame object in the QWebView. The QtJSBSim main loop now updates the Aircraft object to keep the six variables refreshed.
On the javascript side, the camera view is set using the "aircraft" object and its accessor functions. The camera view is refreshed 20 times per second (at least that's what the timer is set for. Actual Results may vary).
It works well here, although it's a bit choppy on my low-end computer. I don't know if it'll work well on a better machine, but even if it doesn't I'll keep it around as a technology demonstrator.
NOTE: QtWebKitWidgets requires Qt version 5.0+. You can check which version you have by running "qmake --version" in a console.
Last edit: David Culp 2015-11-19