Skip to content

Commit dbfe899

Browse files
committedJan 21, 2015
Merge pull request #1847 from m-kuhn/oq
Make QwtPolar optional
2 parents ea54b3c + 3752be6 commit dbfe899

File tree

5 files changed

+105
-83
lines changed

5 files changed

+105
-83
lines changed
 

‎.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ install:
1919
- mkdir build
2020
- cd build
2121
- cmake -DWITH_SERVER=ON -DWITH_STAGED_PLUGINS=OFF -DWITH_GRASS=OFF \
22-
-DSUPPRESS_QT_WARNINGS=ON -DENABLE_MODELTEST=ON ..
22+
-DSUPPRESS_QT_WARNINGS=ON -DENABLE_MODELTEST=ON -DWITH_QWTPOLAR=OFF ..
2323

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

‎CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ IF (WITH_POSTGRESQL)
6666
SET (POSTGRESQL_PREFIX "" CACHE PATH "Path to POSTGRESQL base directory")
6767
ENDIF (WITH_POSTGRESQL)
6868

69-
SET (WITH_INTERNAL_QWTPOLAR TRUE CACHE BOOL "Use internal build of QwtPolar")
70-
7169
SET (WITH_INTERNAL_QEXTSERIALPORT TRUE CACHE BOOL "Use internal build of Qextserialport")
7270

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

186-
IF (NOT WITH_INTERNAL_QWTPOLAR)
187-
FIND_PACKAGE(QwtPolar REQUIRED)
188-
ENDIF(NOT WITH_INTERNAL_QWTPOLAR)
189-
190184
IF (WITH_INTERNAL_QEXTSERIALPORT)
191185
SET(QEXTSERIALPORT_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/src/core/gps/qextserialport)
192186
ELSE (WITH_INTERNAL_QEXTSERIALPORT)

‎src/app/CMakeLists.txt

Lines changed: 82 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -294,73 +294,88 @@ SET (QGIS_APP_MOC_HDRS
294294
qgsnewspatialitelayerdialog.h
295295
)
296296

297-
IF(WITH_INTERNAL_QWTPOLAR)
298-
IF(QWT_VERSION_STR VERSION_LESS "6.0.0")
299-
SET(QGIS_APP_SRCS
300-
${QGIS_APP_SRCS}
301-
gps/qwtpolar-0.1/qwt_polar_canvas.cpp
302-
gps/qwtpolar-0.1/qwt_polar_curve.cpp
303-
gps/qwtpolar-0.1/qwt_polar_fitter.cpp
304-
gps/qwtpolar-0.1/qwt_polar_grid.cpp
305-
gps/qwtpolar-0.1/qwt_polar_itemdict.cpp
306-
gps/qwtpolar-0.1/qwt_polar_item.cpp
307-
gps/qwtpolar-0.1/qwt_polar_layout.cpp
308-
gps/qwtpolar-0.1/qwt_polar_magnifier.cpp
309-
gps/qwtpolar-0.1/qwt_polar_marker.cpp
310-
gps/qwtpolar-0.1/qwt_polar_panner.cpp
311-
gps/qwtpolar-0.1/qwt_polar_plot.cpp
312-
gps/qwtpolar-0.1/qwt_polar_point.cpp
313-
gps/qwtpolar-0.1/qwt_polar_spectrogram.cpp
314-
)
315-
316-
SET (QGIS_APP_MOC_HDRS
317-
${QGIS_APP_MOC_HDRS}
318-
gps/qwtpolar-0.1/qwt_polar_canvas.h
319-
gps/qwtpolar-0.1/qwt_polar_magnifier.h
320-
gps/qwtpolar-0.1/qwt_polar_panner.h
321-
gps/qwtpolar-0.1/qwt_polar_plot.h
322-
)
323-
324-
SET(QWTPOLAR_INCLUDE_DIR gps/qwtpolar-0.1)
325-
ELSE(QWT_VERSION_STR VERSION_LESS "6.0.0")
326-
IF(NOT QWT_VERSION_STR VERSION_LESS "6.1.0")
327-
MESSAGE(FATAL_ERROR "Internal QwtPolar does not support Qwt 6.1 and above")
328-
ENDIF(NOT QWT_VERSION_STR VERSION_LESS "6.1.0")
329-
330-
SET(QGIS_APP_SRCS
331-
${QGIS_APP_SRCS}
332-
gps/qwtpolar-1.0/qwt_polar_canvas.cpp
333-
gps/qwtpolar-1.0/qwt_polar_curve.cpp
334-
gps/qwtpolar-1.0/qwt_polar_fitter.cpp
335-
gps/qwtpolar-1.0/qwt_polar_grid.cpp
336-
gps/qwtpolar-1.0/qwt_polar_item.cpp
337-
gps/qwtpolar-1.0/qwt_polar_itemdict.cpp
338-
gps/qwtpolar-1.0/qwt_polar_layout.cpp
339-
gps/qwtpolar-1.0/qwt_polar_magnifier.cpp
340-
gps/qwtpolar-1.0/qwt_polar_marker.cpp
341-
gps/qwtpolar-1.0/qwt_polar_panner.cpp
342-
gps/qwtpolar-1.0/qwt_polar_picker.cpp
343-
gps/qwtpolar-1.0/qwt_polar_plot.cpp
344-
gps/qwtpolar-1.0/qwt_polar_renderer.cpp
345-
gps/qwtpolar-1.0/qwt_polar_spectrogram.cpp
346-
)
347-
348-
SET (QGIS_APP_MOC_HDRS
349-
${QGIS_APP_MOC_HDRS}
350-
gps/qwtpolar-1.0/qwt_polar_canvas.h
351-
gps/qwtpolar-1.0/qwt_polar_magnifier.h
352-
gps/qwtpolar-1.0/qwt_polar_panner.h
353-
gps/qwtpolar-1.0/qwt_polar_picker.h
354-
gps/qwtpolar-1.0/qwt_polar_plot.h
355-
gps/qwtpolar-1.0/qwt_polar_renderer.h
356-
)
357-
358-
SET(QWTPOLAR_INCLUDE_DIR gps/qwtpolar-1.0)
359-
ENDIF(QWT_VERSION_STR VERSION_LESS "6.0.0")
360-
361-
SET(QWTPOLAR_LIBRARY "")
362-
ENDIF(WITH_INTERNAL_QWTPOLAR)
363-
297+
SET (WITH_QWTPOLAR TRUE CACHE BOOL "Determines whether QwtPolar should be built")
298+
299+
IF (WITH_QWTPOLAR)
300+
ADD_DEFINITIONS(-DWITH_QWTPOLAR)
301+
# Try to find QwtPolar on the system
302+
FIND_PACKAGE(QwtPolar)
303+
# If not found on the system, offer the possibility to build QwtPolar
304+
# internally
305+
IF(NOT FOUND_QwtPolar)
306+
SET(DEFAULT_WITH_INTERNAL_QWTPOLAR TRUE)
307+
ELSE(NOT FOUND_QwtPolar)
308+
SET(DEFAULT_WITH_INTERNAL_QWTPOLAR FALSE)
309+
ENDIF(NOT FOUND_QwtPolar)
310+
SET (WITH_INTERNAL_QWTPOLAR DEFAULT_WITH_INTERNAL_QWTPOLAR CACHE BOOL "Use internal build of QwtPolar")
311+
312+
IF(WITH_INTERNAL_QWTPOLAR)
313+
IF(QWT_VERSION_STR VERSION_LESS "6.0.0")
314+
SET(QGIS_APP_SRCS
315+
${QGIS_APP_SRCS}
316+
gps/qwtpolar-0.1/qwt_polar_canvas.cpp
317+
gps/qwtpolar-0.1/qwt_polar_curve.cpp
318+
gps/qwtpolar-0.1/qwt_polar_fitter.cpp
319+
gps/qwtpolar-0.1/qwt_polar_grid.cpp
320+
gps/qwtpolar-0.1/qwt_polar_itemdict.cpp
321+
gps/qwtpolar-0.1/qwt_polar_item.cpp
322+
gps/qwtpolar-0.1/qwt_polar_layout.cpp
323+
gps/qwtpolar-0.1/qwt_polar_magnifier.cpp
324+
gps/qwtpolar-0.1/qwt_polar_marker.cpp
325+
gps/qwtpolar-0.1/qwt_polar_panner.cpp
326+
gps/qwtpolar-0.1/qwt_polar_plot.cpp
327+
gps/qwtpolar-0.1/qwt_polar_point.cpp
328+
gps/qwtpolar-0.1/qwt_polar_spectrogram.cpp
329+
)
330+
331+
SET (QGIS_APP_MOC_HDRS
332+
${QGIS_APP_MOC_HDRS}
333+
gps/qwtpolar-0.1/qwt_polar_canvas.h
334+
gps/qwtpolar-0.1/qwt_polar_magnifier.h
335+
gps/qwtpolar-0.1/qwt_polar_panner.h
336+
gps/qwtpolar-0.1/qwt_polar_plot.h
337+
)
338+
339+
SET(QWTPOLAR_INCLUDE_DIR gps/qwtpolar-0.1)
340+
ELSE(QWT_VERSION_STR VERSION_LESS "6.0.0")
341+
IF(NOT QWT_VERSION_STR VERSION_LESS "6.1.0")
342+
MESSAGE(FATAL_ERROR "Internal QwtPolar does not support Qwt 6.1 and above")
343+
ENDIF(NOT QWT_VERSION_STR VERSION_LESS "6.1.0")
344+
345+
SET(QGIS_APP_SRCS
346+
${QGIS_APP_SRCS}
347+
gps/qwtpolar-1.0/qwt_polar_canvas.cpp
348+
gps/qwtpolar-1.0/qwt_polar_curve.cpp
349+
gps/qwtpolar-1.0/qwt_polar_fitter.cpp
350+
gps/qwtpolar-1.0/qwt_polar_grid.cpp
351+
gps/qwtpolar-1.0/qwt_polar_item.cpp
352+
gps/qwtpolar-1.0/qwt_polar_itemdict.cpp
353+
gps/qwtpolar-1.0/qwt_polar_layout.cpp
354+
gps/qwtpolar-1.0/qwt_polar_magnifier.cpp
355+
gps/qwtpolar-1.0/qwt_polar_marker.cpp
356+
gps/qwtpolar-1.0/qwt_polar_panner.cpp
357+
gps/qwtpolar-1.0/qwt_polar_picker.cpp
358+
gps/qwtpolar-1.0/qwt_polar_plot.cpp
359+
gps/qwtpolar-1.0/qwt_polar_renderer.cpp
360+
gps/qwtpolar-1.0/qwt_polar_spectrogram.cpp
361+
)
362+
363+
SET (QGIS_APP_MOC_HDRS
364+
${QGIS_APP_MOC_HDRS}
365+
gps/qwtpolar-1.0/qwt_polar_canvas.h
366+
gps/qwtpolar-1.0/qwt_polar_magnifier.h
367+
gps/qwtpolar-1.0/qwt_polar_panner.h
368+
gps/qwtpolar-1.0/qwt_polar_picker.h
369+
gps/qwtpolar-1.0/qwt_polar_plot.h
370+
gps/qwtpolar-1.0/qwt_polar_renderer.h
371+
)
372+
373+
SET(QWTPOLAR_INCLUDE_DIR gps/qwtpolar-1.0)
374+
ENDIF(QWT_VERSION_STR VERSION_LESS "6.0.0")
375+
376+
SET(QWTPOLAR_LIBRARY "")
377+
ENDIF(WITH_INTERNAL_QWTPOLAR)
378+
ENDIF(WITH_QWTPOLAR)
364379

365380
IF (POSTGRES_FOUND)
366381
IF(HAVE_PGCONFIG)

‎src/app/gps/qgsgpsinformationwidget.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939

4040
// QWT Charting widget
41+
4142
#include <qwt_global.h>
4243
#if (QWT_VERSION<0x060000)
4344
#include <qwt_array.h>
@@ -47,11 +48,13 @@
4748
#include <qwt_plot.h>
4849
#include <qwt_plot_grid.h>
4950

51+
#if (WITH_QWTPOLAR)
5052
// QWT Polar plot add on
5153
#include <qwt_symbol.h>
5254
#include <qwt_polar_grid.h>
5355
#include <qwt_polar_curve.h>
5456
#include <qwt_scale_engine.h>
57+
#endif
5558

5659
#include <QMessageBox>
5760
#include <QSettings>
@@ -76,6 +79,9 @@ QgsGPSInformationWidget::QgsGPSInformationWidget( QgsMapCanvas * thepCanvas, QWi
7679
mpRubberBand = 0;
7780
populateDevices();
7881
QWidget * mpHistogramWidget = mStackedWidget->widget( 1 );
82+
#if (!WITH_QWTPOLAR)
83+
mBtnSatellites->setVisible( false );
84+
#endif
7985
//
8086
// Set up the graph for signal strength
8187
//
@@ -109,6 +115,7 @@ QgsGPSInformationWidget::QgsGPSInformationWidget( QgsMapCanvas * thepCanvas, QWi
109115
//
110116
// Set up the polar graph for satellite pos
111117
//
118+
#if (WITH_QWTPOLAR)
112119
QWidget * mpPolarWidget = mStackedWidget->widget( 2 );
113120
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
114121
mpSatellitesWidget->setAutoReplot( false ); // plot on demand (after all data has been handled)
@@ -129,7 +136,6 @@ QgsGPSInformationWidget::QgsGPSInformationWidget( QgsMapCanvas * thepCanvas, QWi
129136
);
130137

131138
// grids, axes
132-
133139
QwtPolarGrid * mypSatellitesGrid = new QwtPolarGrid();
134140
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!
135141
mypSatellitesGrid->setPen( QPen( Qt::black ) );
@@ -162,6 +168,7 @@ QgsGPSInformationWidget::QgsGPSInformationWidget( QgsMapCanvas * thepCanvas, QWi
162168

163169
// replot on command
164170
mpSatellitesWidget->replot();
171+
#endif
165172
mpPlot->replot();
166173

167174
// Restore state
@@ -534,15 +541,12 @@ void QgsGPSInformationWidget::displayGPSInformation( const QgsGPSInformation& in
534541
{
535542
mpPlot->setAxisScale( QwtPlot::xBottom, 0, info.satellitesInView.size() );
536543
} //signal
537-
544+
#if (WITH_QWTPOLAR)
538545
if ( mStackedWidget->currentIndex() == 2 && info.satInfoComplete ) //satellites
539546
{
540-
while ( !mMarkerList.isEmpty() )
541-
{
542-
delete mMarkerList.takeFirst();
543-
}
547+
qDeleteAll( mMarkerList );
544548
} //satellites
545-
549+
#endif
546550
if ( mStackedWidget->currentIndex() == 4 ) //debug
547551
{
548552
mGPSPlainTextEdit->clear();
@@ -582,11 +586,13 @@ void QgsGPSInformationWidget::displayGPSInformation( const QgsGPSInformation& in
582586
// Add a marker to the polar plot
583587
if ( currentInfo.id > 0 ) // don't show satellite if id=0 (no satellite indication)
584588
{
589+
#if (WITH_QWTPOLAR)
585590
QwtPolarMarker *mypMarker = new QwtPolarMarker();
586591
#if (QWT_POLAR_VERSION<0x010000)
587592
mypMarker->setPosition( QwtPolarPoint( currentInfo.azimuth, currentInfo.elevation ) );
588593
#else
589594
mypMarker->setPosition( QwtPointPolar( currentInfo.azimuth, currentInfo.elevation ) );
595+
#endif
590596
#endif
591597
if ( currentInfo.signal < 30 ) //weak signal
592598
{
@@ -596,20 +602,23 @@ void QgsGPSInformationWidget::displayGPSInformation( const QgsGPSInformation& in
596602
{
597603
myColor = Qt::black; //strong signal
598604
}
605+
#if (WITH_QWTPOLAR)
599606
#if (QWT_POLAR_VERSION<0x010000)
600607
mypMarker->setSymbol( QwtSymbol( QwtSymbol::Ellipse,
601608
symbolBrush, QPen( myColor ), markerSize ) );
602609
#else
603610
mypMarker->setSymbol( new QwtSymbol( QwtSymbol::Ellipse,
604611
symbolBrush, QPen( myColor ), markerSize ) );
605612
#endif
613+
606614
mypMarker->setLabelAlignment( Qt::AlignHCenter | Qt::AlignTop );
607615
QwtText text( QString::number( currentInfo.id ) );
608616
text.setColor( myColor );
609617
text.setBackgroundBrush( textBgBrush );
610618
mypMarker->setLabel( text );
611619
mypMarker->attach( mpSatellitesWidget );
612620
mMarkerList << mypMarker;
621+
#endif
613622
} // currentInfo.id > 0
614623
} //satellites
615624
} //satellite processing loop
@@ -623,12 +632,12 @@ void QgsGPSInformationWidget::displayGPSInformation( const QgsGPSInformation& in
623632
#endif
624633
mpPlot->replot();
625634
} //signal
626-
635+
#if (WITH_QWTPOLAR)
627636
if ( mStackedWidget->currentIndex() == 2 && info.satInfoComplete ) //satellites
628637
{
629638
mpSatellitesWidget->replot();
630639
} //satellites
631-
640+
#endif
632641
if ( validFlag )
633642
{
634643
validFlag = info.longitude >= -180.0 && info.longitude <= 180.0 && info.latitude >= -90.0 && info.latitude <= 90.0;

‎src/app/gps/qgsgpsinformationwidget.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
#include <qgsgpsmarker.h>
2424
#include <qgsmaptoolcapture.h>
2525
#include <qwt_plot_curve.h>
26+
#if (WITH_QWTPOLAR)
2627
#include <qwt_polar_plot.h>
2728
#include <qwt_polar_marker.h>
29+
#endif
2830

2931
class QextSerialPort;
3032
class QgsGPSConnection;
@@ -85,8 +87,10 @@ class QgsGPSInformationWidget: public QWidget, private Ui::QgsGPSInformationWidg
8587
QgsGpsMarker * mpMapMarker;
8688
QwtPlot * mpPlot;
8789
QwtPlotCurve * mpCurve;
90+
#if (WITH_QWTPOLAR)
8891
QwtPolarPlot * mpSatellitesWidget;
8992
QList< QwtPolarMarker * > mMarkerList;
93+
#endif
9094
void createRubberBand();
9195
QgsCoordinateReferenceSystem mWgs84CRS;
9296
// not used QPointF gpsToPixelPosition( const QgsPoint& point );

0 commit comments

Comments
 (0)