Skip to content

Commit

Permalink
Merge pull request #1847 from m-kuhn/oq
Browse files Browse the repository at this point in the history
Make QwtPolar optional
  • Loading branch information
m-kuhn committed Jan 21, 2015
2 parents ea54b3c + 3752be6 commit dbfe899
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -19,7 +19,7 @@ install:
- mkdir build
- cd build
- cmake -DWITH_SERVER=ON -DWITH_STAGED_PLUGINS=OFF -DWITH_GRASS=OFF \
-DSUPPRESS_QT_WARNINGS=ON -DENABLE_MODELTEST=ON ..
-DSUPPRESS_QT_WARNINGS=ON -DENABLE_MODELTEST=ON -DWITH_QWTPOLAR=OFF ..

script: xvfb-run ctest -V -E 'Atlas|atlas|PyQgsPalLabelingCanvas|PyQgsPalLabelingServer|qgis_wcsprovidertest' -S ../qgis-test-travis.ctest --output-on-failure

6 changes: 0 additions & 6 deletions CMakeLists.txt
Expand Up @@ -66,8 +66,6 @@ IF (WITH_POSTGRESQL)
SET (POSTGRESQL_PREFIX "" CACHE PATH "Path to POSTGRESQL base directory")
ENDIF (WITH_POSTGRESQL)

SET (WITH_INTERNAL_QWTPOLAR TRUE CACHE BOOL "Use internal build of QwtPolar")

SET (WITH_INTERNAL_QEXTSERIALPORT TRUE CACHE BOOL "Use internal build of Qextserialport")

SET (WITH_QSPATIALITE FALSE CACHE BOOL "Determines whether QSPATIALITE sql driver should be built")
Expand Down Expand Up @@ -183,10 +181,6 @@ FIND_PACKAGE(Expat REQUIRED)
FIND_PACKAGE(Spatialindex REQUIRED)
FIND_PACKAGE(Qwt REQUIRED)

IF (NOT WITH_INTERNAL_QWTPOLAR)
FIND_PACKAGE(QwtPolar REQUIRED)
ENDIF(NOT WITH_INTERNAL_QWTPOLAR)

IF (WITH_INTERNAL_QEXTSERIALPORT)
SET(QEXTSERIALPORT_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/src/core/gps/qextserialport)
ELSE (WITH_INTERNAL_QEXTSERIALPORT)
Expand Down
149 changes: 82 additions & 67 deletions src/app/CMakeLists.txt
Expand Up @@ -294,73 +294,88 @@ SET (QGIS_APP_MOC_HDRS
qgsnewspatialitelayerdialog.h
)

IF(WITH_INTERNAL_QWTPOLAR)
IF(QWT_VERSION_STR VERSION_LESS "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-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_STR VERSION_LESS "6.0.0")
IF(NOT QWT_VERSION_STR VERSION_LESS "6.1.0")
MESSAGE(FATAL_ERROR "Internal QwtPolar does not support Qwt 6.1 and above")
ENDIF(NOT QWT_VERSION_STR VERSION_LESS "6.1.0")

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_STR VERSION_LESS "6.0.0")

SET(QWTPOLAR_LIBRARY "")
ENDIF(WITH_INTERNAL_QWTPOLAR)

SET (WITH_QWTPOLAR TRUE CACHE BOOL "Determines whether QwtPolar should be built")

IF (WITH_QWTPOLAR)
ADD_DEFINITIONS(-DWITH_QWTPOLAR)
# Try to find QwtPolar on the system
FIND_PACKAGE(QwtPolar)
# If not found on the system, offer the possibility to build QwtPolar
# internally
IF(NOT FOUND_QwtPolar)
SET(DEFAULT_WITH_INTERNAL_QWTPOLAR TRUE)
ELSE(NOT FOUND_QwtPolar)
SET(DEFAULT_WITH_INTERNAL_QWTPOLAR FALSE)
ENDIF(NOT FOUND_QwtPolar)
SET (WITH_INTERNAL_QWTPOLAR DEFAULT_WITH_INTERNAL_QWTPOLAR CACHE BOOL "Use internal build of QwtPolar")

IF(WITH_INTERNAL_QWTPOLAR)
IF(QWT_VERSION_STR VERSION_LESS "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-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_STR VERSION_LESS "6.0.0")
IF(NOT QWT_VERSION_STR VERSION_LESS "6.1.0")
MESSAGE(FATAL_ERROR "Internal QwtPolar does not support Qwt 6.1 and above")
ENDIF(NOT QWT_VERSION_STR VERSION_LESS "6.1.0")

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_STR VERSION_LESS "6.0.0")

SET(QWTPOLAR_LIBRARY "")
ENDIF(WITH_INTERNAL_QWTPOLAR)
ENDIF(WITH_QWTPOLAR)

IF (POSTGRES_FOUND)
IF(HAVE_PGCONFIG)
Expand Down
27 changes: 18 additions & 9 deletions src/app/gps/qgsgpsinformationwidget.cpp
Expand Up @@ -38,6 +38,7 @@


// QWT Charting widget

#include <qwt_global.h>
#if (QWT_VERSION<0x060000)
#include <qwt_array.h>
Expand All @@ -47,11 +48,13 @@
#include <qwt_plot.h>
#include <qwt_plot_grid.h>

#if (WITH_QWTPOLAR)
// QWT Polar plot add on
#include <qwt_symbol.h>
#include <qwt_polar_grid.h>
#include <qwt_polar_curve.h>
#include <qwt_scale_engine.h>
#endif

#include <QMessageBox>
#include <QSettings>
Expand All @@ -76,6 +79,9 @@ QgsGPSInformationWidget::QgsGPSInformationWidget( QgsMapCanvas * thepCanvas, QWi
mpRubberBand = 0;
populateDevices();
QWidget * mpHistogramWidget = mStackedWidget->widget( 1 );
#if (!WITH_QWTPOLAR)
mBtnSatellites->setVisible( false );
#endif
//
// Set up the graph for signal strength
//
Expand Down Expand Up @@ -109,6 +115,7 @@ QgsGPSInformationWidget::QgsGPSInformationWidget( QgsMapCanvas * thepCanvas, QWi
//
// Set up the polar graph for satellite pos
//
#if (WITH_QWTPOLAR)
QWidget * mpPolarWidget = mStackedWidget->widget( 2 );
mpSatellitesWidget = new QwtPolarPlot( /*QwtText( tr( "Satellite View" ), QwtText::PlainText ),*/ mpPolarWidget ); // possible title for graph removed for now as it is too large in small windows
mpSatellitesWidget->setAutoReplot( false ); // plot on demand (after all data has been handled)
Expand All @@ -129,7 +136,6 @@ QgsGPSInformationWidget::QgsGPSInformationWidget( QgsMapCanvas * thepCanvas, QWi
);

// grids, axes

QwtPolarGrid * mypSatellitesGrid = new QwtPolarGrid();
mypSatellitesGrid->setGridAttribute( QwtPolarGrid::AutoScaling, false ); // This fixes the issue of autoscaling on the Radius grid. It is ON by default AND is separate from the scaleData.doAutoScale in QwtPolarPlot::setScale(), etc. THIS IS VERY TRICKY!
mypSatellitesGrid->setPen( QPen( Qt::black ) );
Expand Down Expand Up @@ -162,6 +168,7 @@ QgsGPSInformationWidget::QgsGPSInformationWidget( QgsMapCanvas * thepCanvas, QWi

// replot on command
mpSatellitesWidget->replot();
#endif
mpPlot->replot();

// Restore state
Expand Down Expand Up @@ -534,15 +541,12 @@ void QgsGPSInformationWidget::displayGPSInformation( const QgsGPSInformation& in
{
mpPlot->setAxisScale( QwtPlot::xBottom, 0, info.satellitesInView.size() );
} //signal

#if (WITH_QWTPOLAR)
if ( mStackedWidget->currentIndex() == 2 && info.satInfoComplete ) //satellites
{
while ( !mMarkerList.isEmpty() )
{
delete mMarkerList.takeFirst();
}
qDeleteAll( mMarkerList );
} //satellites

#endif
if ( mStackedWidget->currentIndex() == 4 ) //debug
{
mGPSPlainTextEdit->clear();
Expand Down Expand Up @@ -582,11 +586,13 @@ void QgsGPSInformationWidget::displayGPSInformation( const QgsGPSInformation& in
// Add a marker to the polar plot
if ( currentInfo.id > 0 ) // don't show satellite if id=0 (no satellite indication)
{
#if (WITH_QWTPOLAR)
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
#endif
if ( currentInfo.signal < 30 ) //weak signal
{
Expand All @@ -596,20 +602,23 @@ void QgsGPSInformationWidget::displayGPSInformation( const QgsGPSInformation& in
{
myColor = Qt::black; //strong signal
}
#if (WITH_QWTPOLAR)
#if (QWT_POLAR_VERSION<0x010000)
mypMarker->setSymbol( QwtSymbol( QwtSymbol::Ellipse,
symbolBrush, QPen( myColor ), markerSize ) );
#else
mypMarker->setSymbol( new QwtSymbol( QwtSymbol::Ellipse,
symbolBrush, QPen( myColor ), markerSize ) );
#endif

mypMarker->setLabelAlignment( Qt::AlignHCenter | Qt::AlignTop );
QwtText text( QString::number( currentInfo.id ) );
text.setColor( myColor );
text.setBackgroundBrush( textBgBrush );
mypMarker->setLabel( text );
mypMarker->attach( mpSatellitesWidget );
mMarkerList << mypMarker;
#endif
} // currentInfo.id > 0
} //satellites
} //satellite processing loop
Expand All @@ -623,12 +632,12 @@ void QgsGPSInformationWidget::displayGPSInformation( const QgsGPSInformation& in
#endif
mpPlot->replot();
} //signal

#if (WITH_QWTPOLAR)
if ( mStackedWidget->currentIndex() == 2 && info.satInfoComplete ) //satellites
{
mpSatellitesWidget->replot();
} //satellites

#endif
if ( validFlag )
{
validFlag = info.longitude >= -180.0 && info.longitude <= 180.0 && info.latitude >= -90.0 && info.latitude <= 90.0;
Expand Down
4 changes: 4 additions & 0 deletions src/app/gps/qgsgpsinformationwidget.h
Expand Up @@ -23,8 +23,10 @@
#include <qgsgpsmarker.h>
#include <qgsmaptoolcapture.h>
#include <qwt_plot_curve.h>
#if (WITH_QWTPOLAR)
#include <qwt_polar_plot.h>
#include <qwt_polar_marker.h>
#endif

class QextSerialPort;
class QgsGPSConnection;
Expand Down Expand Up @@ -85,8 +87,10 @@ class QgsGPSInformationWidget: public QWidget, private Ui::QgsGPSInformationWidg
QgsGpsMarker * mpMapMarker;
QwtPlot * mpPlot;
QwtPlotCurve * mpCurve;
#if (WITH_QWTPOLAR)
QwtPolarPlot * mpSatellitesWidget;
QList< QwtPolarMarker * > mMarkerList;
#endif
void createRubberBand();
QgsCoordinateReferenceSystem mWgs84CRS;
// not used QPointF gpsToPixelPosition( const QgsPoint& point );
Expand Down

0 comments on commit dbfe899

Please sign in to comment.