Hi, All.
I send first version of 3D plots for tracks.
it work, but have many defects.
it's optional now and out-of-work by default. you can set the variable
PLOT_3D in cmake for turn on it.
I will develop it gradually. if you don't object, I will commit the
attached patch.
Oliver Eichler wrote:
Somehow sf.net did not process my mail. Once again...
Hi, All
My friend request me create a new feature in qlandkarte.
if we have the tack and set of photographies from the same walk, we can
upload image to "track", qlandkarte find point with date the same as
image and set a way point with this image.
What do you think about it?
That's definetly a good idea. :) If you keep on doing you soon will take
this closed software http://www.gps-freeware.de/Beschreibung.aspx out of
business (screenshots are at the end of the page).
Oliver
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QLandkarte-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qlandkarte-users
>From 6d901dcdbd982cdab9a1989653f60874feb59811 Mon Sep 17 00:00:00 2001
From: Adnrew <[EMAIL PROTECTED]>
Date: Tue, 7 Oct 2008 02:14:18 +0400
Subject: [PATCH] add 3D plots for tracks
this feature isn't finished yet, so disabled by default
you can't set varible PLOT_3D in cmake and compile, than
click edit track and see map, speed, profile and track 3D
you can move, zoom and rotate a plot
thank Dmitry Guryanov for help.
he made some work in this patch.
---
src/CMakeLists.txt | 17 ++-
src/CTrack3DWidget.cpp | 337 ++++++++++++++++++++++++++++++++++++++++++++++
src/CTrack3DWidget.h | 80 +++++++++++
src/CTrackEditWidget.cpp | 18 +++
src/CTrackEditWidget.h | 6 +
5 files changed, 455 insertions(+), 3 deletions(-)
create mode 100644 src/CTrack3DWidget.cpp
create mode 100644 src/CTrack3DWidget.h
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5aa31b6..70d78cd 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -227,23 +227,34 @@ SET(qlandkarte_RCS
resources.qrc
)
+SET (PLOT_3D OFF CACHE BOOL "this feature isn't finished yet, so disable by default")
+SET (QL_OPENGL_INCLUDE_DIR "")
+SET (QL_OPENGL_LIBRARIES "")
+IF(PLOT_3D)
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPLOT_3D")
+ SET(qlandkarte_HDRS ${qlandkarte_HDRS} CTrack3DWidget.h)
+ SET(qlandkarte_SRCS ${qlandkarte_SRCS} CTrack3DWidget.cpp)
+ SET(QL_OPENGL_INCLUDE_DIR ${QT_QTOPENGL_INCLUDE_DIR})
+ SET(QL_OPENGL_LIBRARIES ${QT_QTOPENGL_LIBRARIES})
+ENDIF(PLOT_3D)
+
qt4_wrap_cpp(qlandkarte_MOC_SRCS ${qlandkarte_HDRS})
qt4_wrap_ui(qlandkarte_UI_HDRS ${qlandkarte_UIS})
qt4_add_resources(qlandkarte_RC_SRCS ${qlandkarte_RCS} )
-include_directories(${CMAKE_CURRENT_BINARY_DIR} ${QT_QTXML_INCLUDE_DIR} ../include)
+include_directories(${CMAKE_CURRENT_BINARY_DIR} ${QT_QTXML_INCLUDE_DIR} ${QT_QTOPENGL_INCLUDE_DIR} ${QL_OPENGL_INCLUDE_DIR} ../include)
add_executable( qlandkartegt ${qlandkarte_SRCS} ${qlandkarte_HDRS} ${qlandkarte_UI_HDRS} ${qlandkarte_RC_SRCS} ${qlandkarte_MOC_SRCS})
IF(UNIX)
add_definitions(-Wall -O2 -DQL_LIBDIR=${QL_LIBDIR} -DSOEXT=${SOEXT})
- target_link_libraries(qlandkartegt gdal proj ${QT_LIBRARIES} ${QT_QTNETWORK_LIBRARIES} ${QT_QTXML_LIBRARIES})
+ target_link_libraries(qlandkartegt gdal proj ${QT_LIBRARIES} ${QT_QTNETWORK_LIBRARIES} ${QT_QTXML_LIBRARIES} ${QL_OPENGL_LIBRARIES})
ENDIF(UNIX)
IF(WIN32)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /subsystem:windows")
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
- target_link_libraries(qlandkartegt gdal_i proj_i qtmain.lib ${QT_LIBRARIES} ${QT_QTNETWORK_LIBRARIES} ${QT_QTXML_LIBRARIES})
+ target_link_libraries(qlandkartegt gdal_i proj_i qtmain.lib ${QT_LIBRARIES} ${QT_QTNETWORK_LIBRARIES} ${QT_QTXML_LIBRARIES} ${QL_OPENGL_LIBRARIES})
ENDIF(WIN32)
diff --git a/src/CTrack3DWidget.cpp b/src/CTrack3DWidget.cpp
new file mode 100644
index 0000000..143435a
--- /dev/null
+++ b/src/CTrack3DWidget.cpp
@@ -0,0 +1,337 @@
+/**********************************************************************************************
+ Copyright (C) 2008 Andrew Vagin <[EMAIL PROTECTED]>
+
+ This program 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 2 of the License, or
+ (at your option) any later version.
+
+ This program 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 this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
+
+**********************************************************************************************/
+#include "CTrack3DWidget.h"
+#include "CTrackDB.h"
+#include "CTrack.h"
+#include "IUnit.h"
+#include "IMap.h"
+#include "CMapDB.h"
+#include "CResources.h"
+
+#include <QtGui>
+#include <QtOpenGL>
+#include <QPixmap>
+#include <QPainter>
+#include <QGLPixelBuffer>
+
+#include <math.h>
+
+CTrack3DWidget::CTrack3DWidget(QWidget * parent)
+ : QGLWidget(parent)
+{
+ object = 0;
+ xRot = 45;
+ zRot = 0;
+ xRotSens = 0.3;
+ zRotSens = 0.3;
+
+ xShift = 0;
+ yShift = 0;
+ zoomFactor = 1;
+ eleZoomFactor = 1;
+
+ wallCollor = QColor::fromCmykF(0.40, 0.0, 1.0, 0);
+ highBorderColor = QColor::fromRgbF(0.0, 0.0, 1.0, 0);
+
+ connect(&CTrackDB::self(),SIGNAL(sigChanged()),this,SLOT(slotChanged()));
+}
+
+
+CTrack3DWidget::~CTrack3DWidget()
+{
+ makeCurrent();
+ deleteTexture(mapTexture);
+ glDeleteLists(object, 1);
+}
+
+void CTrack3DWidget::setMapTexture()
+{
+ QPixmap pm(width(), height());
+ QPainter p(&pm);
+ CMapDB::self().draw(p,pm.rect());
+ mapTexture = bindTexture(pm, GL_TEXTURE_2D);
+ track = CTrackDB::self().highlightedTrack();
+}
+
+void CTrack3DWidget::slotChanged()
+{
+ deleteTexture(mapTexture);
+ setMapTexture();
+ glDeleteLists(object, 1);
+ object = makeObject();
+ updateGL();
+}
+
+GLuint CTrack3DWidget::makeObject()
+{
+ int w = width();
+ int h = height();
+ double ele1, ele2;
+
+ GLuint list = glGenLists(1);
+ glNewList(list, GL_COMPILE);
+ glLineWidth(2.0);
+
+ if(! track.isNull()) {
+ IMap& map = CMapDB::self().getMap();
+ XY pt1, pt2;
+
+ QList<CTrack::pt_t>& trkpts = track->getTrackPoints();
+ QList<CTrack::pt_t>::const_iterator trkpt = trkpts.begin();
+ maxElevation = trkpt->ele;
+ minElevation = trkpt->ele;
+ while(trkpt != trkpts.end()) {
+ if(trkpt->flags & CTrack::pt_t::eDeleted) {
+ ++trkpt; continue;
+ }
+ if (trkpt->ele > maxElevation)
+ maxElevation = trkpt->ele;
+ if (trkpt->ele < minElevation)
+ minElevation = trkpt->ele;
+ ++trkpt;
+ }
+
+ trkpt = trkpts.begin();
+ pt1.u = trkpt->lon * DEG_TO_RAD;
+ pt1.v = trkpt->lat * DEG_TO_RAD;
+ ele1 = trkpt->ele * eleZoomFactor * (width() / 10.0) / maxElevation;
+ map.convertRad2Pt(pt1.u, pt1.v);
+ pt1.u -= w/2;
+ pt1.v = h/2 - pt1.v;
+
+ while(trkpt != trkpts.end()) {
+ if(trkpt->flags & CTrack::pt_t::eDeleted) {
+ ++trkpt; continue;
+ }
+ pt2.u = trkpt->lon * DEG_TO_RAD;
+ pt2.v = trkpt->lat * DEG_TO_RAD;
+ map.convertRad2Pt(pt2.u, pt2.v);
+ pt2.u -= w/2;
+ pt2.v = h/2 - pt2.v;
+ ele2 = trkpt->ele * eleZoomFactor * (width() / 10.0) / maxElevation;
+ quad(pt1.u, pt1.v, ele1, pt2.u, pt2.v, ele2);
+ ele1 = ele2;
+ pt1 = pt2;
+ ++trkpt;
+ }
+ }
+
+ // restore line width by default
+ glLineWidth(1);
+
+ //draw map
+ glEnable(GL_TEXTURE_2D);
+ glBegin(GL_QUADS);
+ glBindTexture(GL_TEXTURE_2D, mapTexture);
+ glTexCoord2d(0.0, 0.0);
+ glVertex3d(-width()/2, -height()/2, 0);
+ glTexCoord2d(1.0, 0.0);
+ glVertex3d(width()/2, -height()/2, 0);
+ glTexCoord2d(1.0, 1.0);
+ glVertex3d(width()/2, height()/2, 0);
+ glTexCoord2d(0.0, 1.0);
+ glVertex3d(-width()/2, height()/2, 0);
+ glEnd();
+ glDisable(GL_TEXTURE_2D);
+
+
+ glEndList();
+
+ return list;
+}
+
+QSize CTrack3DWidget::minimumSizeHint() const
+{
+ return QSize(400, 400);
+}
+
+QSize CTrack3DWidget::sizeHint() const
+{
+ return QSize(700, 700);
+}
+
+void CTrack3DWidget::setXRotation(double angle)
+{
+ normalizeAngle(&angle);
+ if (angle > 0 && angle < 90) {
+ xRot = angle;
+ emit xRotationChanged(angle);
+ updateGL();
+ }
+}
+
+void CTrack3DWidget::setZRotation(double angle)
+{
+ normalizeAngle(&angle);
+ if (angle != zRot) {
+ zRot = angle;
+ emit zRotationChanged(angle);
+ updateGL();
+ }
+}
+
+void CTrack3DWidget::initializeGL()
+{
+ glClearColor(1.0, 1.0, 1.0, 0.0);
+ setMapTexture();
+ object = makeObject();
+ glShadeModel(GL_SMOOTH);
+ glEnable(GL_LINE_SMOOTH);
+
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
+
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_CULL_FACE);
+ slotChanged();
+}
+
+void CTrack3DWidget::paintGL()
+{
+ int side = qMax(width(), height());
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glLoadIdentity();
+ glTranslated(0.0, -0.25 * side, 0.0);
+ glTranslated(0.0, 0.0, - 3 * side);
+ glRotated(-xRot, 1.0, 0.0, 0.0);
+ glScalef(zoomFactor, zoomFactor, zoomFactor);
+ glTranslated(xShift * 2, 2 * yShift, 0.0);
+
+ glRotated(zRot, 0.0, 0.0, 1.0);
+ glCallList(object);
+
+ /*draw axis*/
+ glBegin(GL_LINES);
+
+ glColor3f(1.0, 0.0, 0.0);
+ glVertex3f(0.0, 0.0, 0.0);
+ glVertex3f(100.0, 0.0, 0.0);
+
+ glColor3f(0.0, 1.0, 0.0);
+ glVertex3f(0.0, 0.0, 0.0);
+ glVertex3f(0.0, 100.0, 0.0);
+
+ glColor3f(0.0, 0.0, 1.0);
+ glVertex3f(0.0, 0.0, 0.0);
+ glVertex3f(0.0, 0.0, 100.0);
+
+ glEnd();
+
+ /*draw the grid*/
+ int i, d = 100, n = 10;
+ glBegin(GL_LINES);
+ glColor3f(0.5, 0.5, 0.5);
+ for(i = -n; i <= n; i ++) {
+ glVertex3f(-d * n, i * d, 0.0);
+ glVertex3f(d * n, i * d, 0.0);
+
+ glVertex3f(i * d, -d * n, 0.0);
+ glVertex3f(i * d, d * n, 0.0);
+ }
+ glEnd();
+
+
+}
+
+void CTrack3DWidget::resizeGL(int width, int height)
+{
+ int side = qMax(width, height);
+ glViewport(0, 0, width, height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustum(-width, width, -height, height, 2 * side, 6 * side);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+void CTrack3DWidget::mousePressEvent(QMouseEvent *event)
+{
+ lastPos = event->pos();
+}
+
+void CTrack3DWidget::mouseMoveEvent(QMouseEvent *event)
+{
+ int dx = event->x() - lastPos.x();
+ int dy = event->y() - lastPos.y();
+
+ if (event->buttons() & Qt::LeftButton) {
+ setXRotation(xRot - xRotSens * dy);
+ setZRotation(zRot + zRotSens * dx);
+ } else if (event->buttons() & Qt::RightButton) {
+ xShift += dx;
+ yShift -= dy;
+ updateGL();
+ }
+ lastPos = event->pos();
+}
+
+void CTrack3DWidget::quad(GLdouble x1, GLdouble y1, GLdouble z1, GLdouble x2, GLdouble y2, GLdouble z2)
+{
+ glBegin(GL_QUADS);
+ double c1, c2;
+ // compute colors
+ c1 = z1 / maxElevation * 255;
+ c2 = z2 / maxElevation * 255;
+
+ qglColor(wallCollor);
+ glVertex3d(x2, y2, 0);
+ glVertex3d(x1, y1, 0);
+ qglColor(wallCollor.dark(c1));
+ glVertex3d(x1, y1, z1);
+ qglColor(wallCollor.dark(c2));
+ glVertex3d(x2, y2, z2);
+
+ qglColor(wallCollor.dark(c2));
+ glVertex3d(x2, y2, z2);
+ qglColor(wallCollor.dark(c1));
+ glVertex3d(x1, y1, z1);
+ qglColor(wallCollor);
+ glVertex3d(x1, y1, 0);
+ glVertex3d(x2, y2, 0);
+
+ glEnd();
+
+ glBegin(GL_LINES);
+ qglColor(highBorderColor);
+ glVertex3d(x1, y1, z1);
+ glVertex3d(x2, y2, z2);
+ glEnd();
+}
+
+void CTrack3DWidget::normalizeAngle(double *angle)
+{
+ while (*angle < 0)
+ *angle += 360;
+ while (*angle > 360)
+ *angle -= 360;
+}
+
+void CTrack3DWidget::wheelEvent ( QWheelEvent * e )
+{
+ bool in = CResources::self().flipMouseWheel() ? (e->delta() > 0) : (e->delta() < 0);
+ if (in) {
+ qDebug() << "in" << endl;
+ zoomFactor *= 1.1;
+ } else {
+ qDebug() << "out" << endl;
+ zoomFactor /= 1.1;
+ }
+ updateGL();
+}
diff --git a/src/CTrack3DWidget.h b/src/CTrack3DWidget.h
new file mode 100644
index 0000000..064652c
--- /dev/null
+++ b/src/CTrack3DWidget.h
@@ -0,0 +1,80 @@
+/**********************************************************************************************
+ Copyright (C) 2008 Oliver Eichler [EMAIL PROTECTED]
+
+ This program 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 2 of the License, or
+ (at your option) any later version.
+
+ This program 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 this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
+
+**********************************************************************************************/
+#ifndef CTRACK3DWIDGET_H
+#define CTRACK3DWIDGET_H
+
+#include <QGLWidget>
+#include <QPointer>
+#include <QWidget>
+
+#include "CTrack.h"
+
+class CTrack3DWidget: public QGLWidget
+{
+ Q_OBJECT;
+ public:
+ CTrack3DWidget(QWidget * parent);
+ virtual ~CTrack3DWidget();
+ QSize minimumSizeHint() const;
+ QSize sizeHint() const;
+
+ protected:
+ QPointer<CTrack> track;
+ void initializeGL();
+ void paintGL();
+ void resizeGL(int width, int height);
+ void mousePressEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+ void wheelEvent ( QWheelEvent * e );
+
+ private:
+ GLuint makeObject();
+ void setMapTexture();
+ void quad(GLdouble x1, GLdouble y1, GLdouble z1, GLdouble x2, GLdouble y2, GLdouble z2);
+ void normalizeAngle(double *angle);
+
+ GLuint object;
+ double xRot;
+ double zRot;
+ double xRotSens;
+ double zRotSens;
+ GLuint mapTexture;
+ double xShift, yShift, zoomFactor, eleZoomFactor;
+
+ double maxElevation, minElevation;
+
+ QPoint lastPos;
+ QColor wallCollor;
+ QColor highBorderColor;
+
+
+ private slots:
+ void slotChanged();
+
+ public slots:
+ void setXRotation(double angle);
+ void setZRotation(double angle);
+
+ signals:
+ void xRotationChanged(double angle);
+ void zRotationChanged(double angle);
+};
+
+#endif //CTRACK3DWIDGET_H
+
diff --git a/src/CTrackEditWidget.cpp b/src/CTrackEditWidget.cpp
index ffb2855..c17eec0 100644
--- a/src/CTrackEditWidget.cpp
+++ b/src/CTrackEditWidget.cpp
@@ -22,6 +22,9 @@
#include "CTrackStatProfileWidget.h"
#include "CTrackStatSpeedWidget.h"
#include "CTrackStatTraineeWidget.h"
+#ifdef PLOT_3D
+# include "CTrack3DWidget.h"
+#endif
#include "CTrack.h"
#include "CTrackDB.h"
#include "CResources.h"
@@ -73,6 +76,12 @@ CTrackEditWidget::~CTrackEditWidget()
if(!trackStatTrainee.isNull()){
delete trackStatTrainee;
}
+#ifdef PLOT_3D
+ if(!track3D.isNull()){
+ delete track3D;
+ }
+#endif
+
}
@@ -378,6 +387,15 @@ void CTrackEditWidget::slotToggleStat()
else{
delete trackStatProfile;
}
+#ifdef PLOT_3D
+ if(track3D.isNull()){
+ track3D = new CTrack3DWidget(this);
+ theMainWindow->getCanvasTab()->addTab(track3D, tr("Plot 3D"));
+ }
+ else{
+ delete track3D;
+ }
+#endif
}
void CTrackEditWidget::slotToggleTrainee()
diff --git a/src/CTrackEditWidget.h b/src/CTrackEditWidget.h
index 3aba626..ab53fbb 100644
--- a/src/CTrackEditWidget.h
+++ b/src/CTrackEditWidget.h
@@ -27,6 +27,9 @@ class CTrack;
class CTrackStatProfileWidget;
class CTrackStatSpeedWidget;
class CTrackStatTraineeWidget;
+#ifdef PLOT_3D
+class CTrack3DWidget;
+#endif
class CTrackEditWidget : public QWidget, private Ui::ITrackEditWidget
{
@@ -73,6 +76,9 @@ class CTrackEditWidget : public QWidget, private Ui::ITrackEditWidget
QPointer<CTrackStatProfileWidget> trackStatProfile;
QPointer<CTrackStatSpeedWidget> trackStatSpeed;
QPointer<CTrackStatTraineeWidget> trackStatTrainee;
+#ifdef PLOT_3D
+ QPointer<CTrack3DWidget> track3D;
+#endif
};
#endif //CTRACKEDITWIDGET_H
--
1.5.5.2
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QLandkarte-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qlandkarte-users