Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add optional Qwt 6.0 support (including QwtPolar 1.0)
  • Loading branch information
jef-n committed Aug 12, 2011
1 parent 494c65b commit f71ecb9
Show file tree
Hide file tree
Showing 63 changed files with 7,886 additions and 34 deletions.
4 changes: 3 additions & 1 deletion cmake/FindQwt.cmake
Expand Up @@ -32,8 +32,10 @@ IF (QWT_INCLUDE_DIR AND QWT_LIBRARY)
ENDIF (QWT_INCLUDE_DIR AND QWT_LIBRARY)

IF (QWT_FOUND)
FILE(READ ${QWT_INCLUDE_DIR}/qwt_global.h qwt_header)
STRING(REGEX REPLACE "^.*QWT_VERSION +(0x[0-9a-f]+).*$" "\\1" QWT_VERSION "${qwt_header}")
IF (NOT QWT_FIND_QUIETLY)
MESSAGE(STATUS "Found Qwt: ${QWT_LIBRARY}")
MESSAGE(STATUS "Found Qwt: ${QWT_LIBRARY} (${QWT_VERSION})")
ENDIF (NOT QWT_FIND_QUIETLY)
ELSE (QWT_FOUND)
IF (QWT_FIND_REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion debian/control.sid
Expand Up @@ -17,7 +17,7 @@ Build-Depends:
libproj-dev,
libqt4-dev (>=4.4.0),
libqtwebkit-dev,
libqwt5-qt4-dev,
libqwt-dev,
libspatialite-dev,
libsqlite3-dev,
pkg-config,
Expand Down
95 changes: 64 additions & 31 deletions src/app/CMakeLists.txt
Expand Up @@ -127,12 +127,12 @@ SET(QGIS_APP_SRCS
ogr/qgsnewogrconnection.cpp
ogr/qgsogrsublayersdialog.cpp
ogr/qgsvectorlayersaveasdialog.cpp

attributetable/qgsattributetabledialog.cpp

gps/qgsgpsinformationwidget.cpp
gps/qgsgpsmarker.cpp
)
)


SET (QGIS_APP_MOC_HDRS
Expand Down Expand Up @@ -231,44 +231,77 @@ SET (QGIS_APP_MOC_HDRS
legend/qgslegend.h
legend/qgsapplegendinterface.h
legend/qgslegendlayer.h

ogr/qgsopenvectorlayerdialog.h
ogr/qgsnewogrconnection.h
ogr/qgsogrsublayersdialog.h
ogr/qgsvectorlayersaveasdialog.h

attributetable/qgsattributetabledialog.h

gps/qgsgpsinformationwidget.h
)

IF(WITH_INTERNAL_QWTPOLAR)
SET(QGIS_APP_SRCS
${QGIS_APP_SRCS}
gps/qwtpolar/qwt_polar_canvas.cpp
gps/qwtpolar/qwt_polar_curve.cpp
gps/qwtpolar/qwt_polar_fitter.cpp
gps/qwtpolar/qwt_polar_grid.cpp
gps/qwtpolar/qwt_polar_itemdict.cpp
gps/qwtpolar/qwt_polar_item.cpp
gps/qwtpolar/qwt_polar_layout.cpp
gps/qwtpolar/qwt_polar_magnifier.cpp
gps/qwtpolar/qwt_polar_marker.cpp
gps/qwtpolar/qwt_polar_panner.cpp
gps/qwtpolar/qwt_polar_plot.cpp
gps/qwtpolar/qwt_polar_point.cpp
gps/qwtpolar/qwt_polar_spectrogram.cpp
)
IF(QWT_VERSION LESS 393216) # <6.0.0
SET(QGIS_APP_SRCS
${QGIS_APP_SRCS}
gps/qwtpolar-0.1/qwt_polar_canvas.cpp
gps/qwtpolar-0.1/qwt_polar_curve.cpp
gps/qwtpolar-0.1/qwt_polar_fitter.cpp
gps/qwtpolar-0.1/qwt_polar_grid.cpp
gps/qwtpolar-0.1/qwt_polar_itemdict.cpp
gps/qwtpolar-0.1/qwt_polar_item.cpp
gps/qwtpolar-0.1/qwt_polar_layout.cpp
gps/qwtpolar-0.1/qwt_polar_magnifier.cpp
gps/qwtpolar-0.1/qwt_polar_marker.cpp
gps/qwtpolar-0.1/qwt_polar_panner.cpp
gps/qwtpolar-0.1/qwt_polar_plot.cpp
gps/qwtpolar-0.1/qwt_polar_point.cpp
gps/qwtpolar-0.1/qwt_polar_spectrogram.cpp
)

SET (QGIS_APP_MOC_HDRS
${QGIS_APP_MOC_HDRS}
gps/qwtpolar/qwt_polar_canvas.h
gps/qwtpolar/qwt_polar_magnifier.h
gps/qwtpolar/qwt_polar_panner.h
gps/qwtpolar/qwt_polar_plot.h
)
SET (QGIS_APP_MOC_HDRS
${QGIS_APP_MOC_HDRS}
gps/qwtpolar-0.1/qwt_polar_canvas.h
gps/qwtpolar-0.1/qwt_polar_magnifier.h
gps/qwtpolar-0.1/qwt_polar_panner.h
gps/qwtpolar-0.1/qwt_polar_plot.h
)

SET(QWTPOLAR_INCLUDE_DIR gps/qwtpolar-0.1)
ELSE(QWT_VERSION LESS 393216)
SET(QGIS_APP_SRCS
${QGIS_APP_SRCS}
gps/qwtpolar-1.0/qwt_polar_canvas.cpp
gps/qwtpolar-1.0/qwt_polar_curve.cpp
gps/qwtpolar-1.0/qwt_polar_fitter.cpp
gps/qwtpolar-1.0/qwt_polar_grid.cpp
gps/qwtpolar-1.0/qwt_polar_item.cpp
gps/qwtpolar-1.0/qwt_polar_itemdict.cpp
gps/qwtpolar-1.0/qwt_polar_layout.cpp
gps/qwtpolar-1.0/qwt_polar_magnifier.cpp
gps/qwtpolar-1.0/qwt_polar_marker.cpp
gps/qwtpolar-1.0/qwt_polar_panner.cpp
gps/qwtpolar-1.0/qwt_polar_picker.cpp
gps/qwtpolar-1.0/qwt_polar_plot.cpp
gps/qwtpolar-1.0/qwt_polar_renderer.cpp
gps/qwtpolar-1.0/qwt_polar_spectrogram.cpp
)

SET (QGIS_APP_MOC_HDRS
${QGIS_APP_MOC_HDRS}
gps/qwtpolar-1.0/qwt_polar_canvas.h
gps/qwtpolar-1.0/qwt_polar_magnifier.h
gps/qwtpolar-1.0/qwt_polar_panner.h
gps/qwtpolar-1.0/qwt_polar_picker.h
gps/qwtpolar-1.0/qwt_polar_plot.h
gps/qwtpolar-1.0/qwt_polar_renderer.h
)

SET(QWTPOLAR_INCLUDE_DIR gps/qwtpolar-1.0)
ENDIF(QWT_VERSION LESS 393216)

SET(QWTPOLAR_INCLUDE_DIR gps/qwtpolar)
SET(QWTPOLAR_LIBRARY "")
ENDIF(WITH_INTERNAL_QWTPOLAR)

Expand Down Expand Up @@ -329,7 +362,7 @@ IF (WIN32)
# application icon
# resource compilation for MinGW
ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/icon.o
COMMAND ${WINDRES} -I${CMAKE_CURRENT_SOURCE_DIR} -i${CMAKE_CURRENT_SOURCE_DIR}/qgis_win32.rc
COMMAND ${WINDRES} -I${CMAKE_CURRENT_SOURCE_DIR} -i${CMAKE_CURRENT_SOURCE_DIR}/qgis_win32.rc
-o ${CMAKE_CURRENT_BINARY_DIR}/icon.o )
SET(QGIS_APP_SRCS ${QGIS_APP_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/icon.o)
ENDIF (MSVC)
Expand Down Expand Up @@ -389,7 +422,7 @@ TARGET_LINK_LIBRARIES(${QGIS_APP_NAME}
${QT_QTSQL_LIBRARY}
${QT_QTUITOOLS_LIBRARY}
#should only be needed for win
${QT_QTMAIN_LIBRARY}
${QT_QTMAIN_LIBRARY}
${QWTPOLAR_LIBRARY}
qgis_core
qgis_gui
Expand All @@ -398,7 +431,7 @@ TARGET_LINK_LIBRARIES(${QGIS_APP_NAME}

IF( WIN32 )
ADD_DEFINITIONS(-DQWT_DLL)
ENDIF( WIN32 )
ENDIF( WIN32 )

IF(NOT WITH_INTERNAL_SPATIALITE)
TARGET_LINK_LIBRARIES(${QGIS_APP_NAME} ${SQLITE_LIBRARY})
Expand Down
30 changes: 29 additions & 1 deletion src/app/gps/qgsgpsinformationwidget.cpp
Expand Up @@ -34,13 +34,17 @@
#include "qgsmaptooladdfeature.h"

// QWT Charting widget
#include <qwt_global.h>
#if (QWT_VERSION<0x060000)
#include <qwt_array.h>
#include <qwt_data.h>
#endif
#include <qwt_legend.h>
#include <qwt_plot.h>
#include <qwt_plot_grid.h>

// QWT Polar plot add on
#include <qpen.h>
#include <qwt_data.h>
#include <qwt_symbol.h>
#include <qwt_polar_grid.h>
#include <qwt_polar_curve.h>
Expand Down Expand Up @@ -374,8 +378,12 @@ void QgsGPSInformationWidget::displayGPSInformation( const QgsGPSInformation& in
{
mGPSTextEdit->clear();

#if QWT_VERSION<0x060000
QwtArray<double> myXData;//qwtarray is just a wrapped qvector
QwtArray<double> mySignalData;//qwtarray is just a wrapped qvector
#else
QVector<QPointF> data;
#endif
mpPlot->setAxisScale( QwtPlot::xBottom, 0, info.satellitesInView.size() );
while ( !mMarkerList.isEmpty() )
{
Expand All @@ -386,6 +394,7 @@ void QgsGPSInformationWidget::displayGPSInformation( const QgsGPSInformation& in
{
QgsSatelliteInfo currentInfo = info.satellitesInView.at( i );

#if QWT_VERSION<0x060000
myXData.append( i );
mySignalData.append( 0 );
myXData.append( i );
Expand All @@ -394,6 +403,12 @@ void QgsGPSInformationWidget::displayGPSInformation( const QgsGPSInformation& in
mySignalData.append( currentInfo.signal );
myXData.append( i + 1 );
mySignalData.append( 0 );
#else
data << QPointF( i, 0 );
data << QPointF( i, currentInfo.signal );
data << QPointF( i + 1, currentInfo.signal );
data << QPointF( i + 1, currentInfo.signal );
#endif
mGPSTextEdit->append( "Satellite" );
if ( currentInfo.inUse )
{
Expand All @@ -409,7 +424,11 @@ void QgsGPSInformationWidget::displayGPSInformation( const QgsGPSInformation& in
mGPSTextEdit->append( "signal: " + QString::number( currentInfo.signal ) );
// Add a marker to the polar plot
QwtPolarMarker *mypMarker = new QwtPolarMarker();
#if (QWT_POLAR_VERSION<0x010000)
mypMarker->setPosition( QwtPolarPoint( currentInfo.azimuth, currentInfo.elevation ) );
#else
mypMarker->setPosition( QwtPointPolar( currentInfo.azimuth, currentInfo.elevation ) );
#endif
QColor myColour;
if ( currentInfo.signal < 30 ) //weak signal
{
Expand All @@ -419,8 +438,13 @@ void QgsGPSInformationWidget::displayGPSInformation( const QgsGPSInformation& in
{
myColour = Qt::black; //strong signal
}
#if (QWT_POLAR_VERSION<0x010000)
mypMarker->setSymbol( QwtSymbol( QwtSymbol::Ellipse,
QBrush( Qt::black ), QPen( myColour ), QSize( 9, 9 ) ) );
#else
mypMarker->setSymbol( new QwtSymbol( QwtSymbol::Ellipse,
QBrush( Qt::black ), QPen( myColour ), QSize( 9, 9 ) ) );
#endif
mypMarker->setLabelAlignment( Qt::AlignHCenter | Qt::AlignTop );
QwtText text( QString::number( currentInfo.id ) );
text.setColor( myColour );
Expand All @@ -431,7 +455,11 @@ void QgsGPSInformationWidget::displayGPSInformation( const QgsGPSInformation& in
mypMarker->attach( mpSatellitesWidget );
mMarkerList << mypMarker;
}
#if (QWT_VERSION<0x060000)
mpCurve->setData( myXData, mySignalData );
#else
mpCurve->setSamples( data );
#endif
mpPlot->replot();
if ( mpMapMarker )
delete mpMapMarker;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
84 changes: 84 additions & 0 deletions src/app/gps/qwtpolar-1.0/qwt_polar.h
@@ -0,0 +1,84 @@
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* QwtPolar Widget Library
* Copyright (C) 2008 Uwe Rathmann
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Qwt License, Version 1.0
*****************************************************************************/

#ifndef QWT_POLAR_H
#define QWT_POLAR_H 1

#include "qwt_polar_global.h"

namespace QwtPolar
{
//! Unit of an angle
enum AngleUnit
{
//! 0.0 -> 2_M_PI
Radians,

//! 0.0 -> 360.0
Degrees,

//! 0.0 - 400.0
Gradians,

//! 0.0 - 1.0
Turns
};

//! An enum, that identifies the type of a coordinate
enum Coordinate
{
//! Azimuth
Azimuth,

//! Radius
Radius
};

/*!
Indices used to identify an axis.
\sa Scale
*/
enum Axis
{
//! Azimuth axis
AxisAzimuth,

//! Left axis
AxisLeft,

//! Right axis
AxisRight,

//! Top axis
AxisTop,

//! Bottom axis
AxisBottom,

//! Number of available axis
AxesCount
};

/*!
Indices used to identify a scale.
\sa Axis
*/
enum Scale
{
//! Azimuth scale
ScaleAzimuth = Azimuth,

//! Radial scale
ScaleRadius = Radius,

//! Number of scales
ScaleCount
};
}

#endif

0 comments on commit f71ecb9

Please sign in to comment.