|
|||
|
|
||
news about download documentation FAQ contact |
DisclaimerYou may use this program on your own risk! I am not responsible for any damage. Installation
Startup
Mouse Navigation
|
virtual
void draw(Point3D *viewer, bool viewculling, QGLWidget *widget, Point3D
direction, int layer) = 0; |
In this example I will show how to add a new visual that displays a sphere at the coordinates 0N 0E. I will start with a patch file that shows what needs to be changed:
diff -uNr c2/clientQT/draw/treeDrawFactory.cpp c3/clientQT/draw/treeDrawFactory.cpp
--- c2/clientQT/draw/treeDrawFactory.cpp 2004-08-20 17:26:55.000000000 +0200
+++ c3/clientQT/draw/treeDrawFactory.cpp 2005-10-24 21:02:55.938611601 +0200
@@ -10,6 +10,7 @@
#include "drawScene.h"
#include "formview.h"
#include "moveToPositionEvent.h"
+#include "treeDrawTest.h"
using namespace std;
@@ -192,6 +193,9 @@
if (type == QString("gpsmark")) {
newDraw = tagGeometryGpsMark(geometryNode, newDraw);
}
+ if (type == QString("test")) {
+ newDraw = TreeDrawTest::tagGeometry(geometryNode, newDraw);
+ }
/* Insert Draw into GraphicsObjectsContainer */
if (newDraw) {
diff -uNr c2/clientQT/draw/treeDrawTest.cpp c3/clientQT/draw/treeDrawTest.cpp
--- c2/clientQT/draw/treeDrawTest.cpp 1970-01-01 01:00:00.000000000 +0100
+++ c3/clientQT/draw/treeDrawTest.cpp 2005-10-25 06:55:27.936483050 +0200
@@ -0,0 +1,27 @@
+#define GL_GLEXT_PROTOTYPES
+#include "draw/treeDrawTest.h"
+#include
+#include
+#include
+
+TreeDrawTest::TreeDrawTest() {
+ printf("TreeDrawTest new\n");
+}
+
+void TreeDrawTest::draw(Point3D *viewer, bool viewculling, QGLWidget *widget, Point3D direction, int phase) {
+ if (phase!=2) return;
+
+ printf("TreeDrawTest\n");
+ glPushMatrix();
+
+ // put a sphere at 0N, 0E
+ glTranslatef(-1,0,0);
+ glutSolidSphere(0.1, 10, 10);
+
+ glPopMatrix();
+}
+
+Draw *TreeDrawTest::tagGeometry(QDomNode geometryNode, Draw *newDraw) {
+ printf("TreeDrawTest tag\n");
+ return(new TreeDrawTest());
+}
diff -uNr c2/clientQT/draw/treeDrawTest.h c3/clientQT/draw/treeDrawTest.h
--- c2/clientQT/draw/treeDrawTest.h 1970-01-01 01:00:00.000000000 +0100
+++ c3/clientQT/draw/treeDrawTest.h 2005-10-24 21:02:23.360348103 +0200
@@ -0,0 +1,18 @@
+#ifndef TREEDRAWTEST_H
+#define TREEDRAWTEST_H
+#include "treeDraw.h"
+#include
+#include
+#include
+#include "imageList.h"
+
+class TreeDrawTest : public Draw {
+ public:
+ TreeDrawTest();
+
+ static Draw *tagGeometry(QDomNode geometryNode, Draw *newdraw);
+
+ virtual void draw(Point3D *viewer, bool viewculling, QGLWidget *widget, Point3D direction, int phase);
+};
+
+#endif
diff -uNr c2/clientQT/earth3d.pro c3/clientQT/earth3d.pro
--- c2/clientQT/earth3d.pro 2005-09-09 18:25:20.000000000 +0200
+++ c3/clientQT/earth3d.pro 2005-10-24 21:02:36.321065932 +0200
@@ -67,7 +67,7 @@
# QMAKE_CXXFLAGS_DEBUG += -D EARTH3DDEBUG
CONFIG += qt thread opengl warn_on release stl
-# LIBS += -lglut
+LIBS += -lglut
# DEFINES += STATISTIC_NODECOUNT
@@ -122,6 +122,7 @@
tree/textureTreeNodeCore.cpp \
draw/draw.cpp \
draw/treeDraw.cpp \
+ draw/treeDrawTest.cpp \
draw/treeDrawSphere.cpp \
draw/treeDrawPOI.cpp \
draw/treeDrawPOISign.cpp \
(Download it here: treeDrawTest.patch download).
In case you do not know how to read a patch file, here is a short explanation:
In this patch file several files were compared, each section starting with "diff -uNr...". Lines that start with "+" have to be added, lines with "-" removed. The other lines are to find the location in the file where to add or remove the "+" and "-" lines. To apply the patch to the project, change into the "clientQT" directory and call "patch -p1 < treeDrawTest.patch".
Now back to the example: We will create a new visual with the geometry type "test" (this will be explained later). We will add two files, treeDrawTest.cpp and treeDrawTest.h.
Lets go through the patch file step by step:
That are all necessary code changes. To use it, you need two XML files you can load. I will explain them later. The interesting part is in geometry.mxml:
<geometry type="test" name="Test object">
</geometry>
This defines a geometry that will create our visual of type "test".
After applying these changes compile the executable with
qmake earth3d.pro
make
Now download the files service.sxml and geometry.mxml in a ZIP file (geom.zip) and extract them into one directory. Load the service.sxml using the "Add service" icon at the top left of the window. In the tree view on the left our "Test object" should appear. Load it by double clicking it. If you have also loaded a view of the earth you should get a view similar to this:
The server software can be used to integrate own maps. It is currently available as source via CVS. A windows binary was released on request on 29.11.2005 and is available from here: earth3d_server_windows_1.zip. Please also read the corresponding paragraph in the FAQ on www.earth3d.org.
The server is not intended to be used by normal users since it is only command line based. It needs the libtif, libxml2, libpng12 and QT to compile. The source code for the windows version (or the patches to allow the normal version to compile under windows). are not yet available.
Example how to use the server software: You start with an empty map. The lines to add the initial Blue Marble (NASA) data look like this: