51
51
#include < QSettings>
52
52
#include < QMouseEvent>
53
53
#include < QVector>
54
+ #include < QWebView>
54
55
55
- // QWT Charting widget
56
- #include < qwt_global.h>
57
- #include < qwt_plot_canvas.h>
58
- #include < qwt_legend.h>
59
- #include < qwt_plot.h>
60
- #include < qwt_plot_curve.h>
61
- #include < qwt_plot_grid.h>
62
56
63
57
QgsRasterLayerProperties::QgsRasterLayerProperties ( QgsMapLayer* lyr, QgsMapCanvas* theCanvas, QWidget *parent, Qt::WFlags fl )
64
58
: QDialog( parent, fl ),
@@ -1858,25 +1852,10 @@ void QgsRasterLayerProperties::on_tabBar_currentChanged( int theTab )
1858
1852
1859
1853
void QgsRasterLayerProperties::refreshHistogram ()
1860
1854
{
1861
- #if !defined(QWT_VERSION) || QWT_VERSION<0x060000
1862
- mpPlot->clear ();
1863
- #endif
1864
1855
mHistogramProgress ->show ();
1865
1856
connect ( mRasterLayer , SIGNAL ( progressUpdate ( int ) ), mHistogramProgress , SLOT ( setValue ( int ) ) );
1866
1857
QApplication::setOverrideCursor ( Qt::WaitCursor );
1867
- QgsDebugMsg ( " entered." );
1868
- // ensure all children get removed
1869
- mpPlot->setAutoDelete ( true );
1870
- mpPlot->setTitle ( QObject::tr ( " Raster Histogram" ) );
1871
- mpPlot->insertLegend ( new QwtLegend (), QwtPlot::BottomLegend );
1872
- // Set axis titles
1873
- mpPlot->setAxisTitle ( QwtPlot::xBottom, QObject::tr ( " Pixel Value" ) );
1874
- mpPlot->setAxisTitle ( QwtPlot::yLeft, QObject::tr ( " Frequency" ) );
1875
- mpPlot->setAxisAutoScale ( QwtPlot::yLeft );
1876
- // x axis scale only set after computing global min/max across bands (see below)
1877
- // add a grid
1878
- QwtPlotGrid * myGrid = new QwtPlotGrid ();
1879
- myGrid->attach ( mpPlot );
1858
+ mWebPlot ->setHtml (" <h1>Hellow World</h1>" );
1880
1859
// Explanation:
1881
1860
// We use the gdal histogram creation routine is called for each selected
1882
1861
// layer. Currently the hist is hardcoded
@@ -1891,115 +1870,44 @@ void QgsRasterLayerProperties::refreshHistogram()
1891
1870
bool myIgnoreOutOfRangeFlag = true ;
1892
1871
bool myThoroughBandScanFlag = false ;
1893
1872
int myBandCountInt = mRasterLayer ->bandCount ();
1894
- QList<QColor> myColors;
1895
- myColors << Qt::black << Qt::red << Qt::green << Qt::blue << Qt::magenta << Qt::darkRed << Qt::darkGreen << Qt::darkBlue;
1896
-
1897
- while ( myColors.size () <= myBandCountInt )
1898
- {
1899
- myColors <<
1900
- QColor ( 1 + ( int )( 255.0 * rand () / ( RAND_MAX + 1.0 ) ),
1901
- 1 + ( int )( 255.0 * rand () / ( RAND_MAX + 1.0 ) ),
1902
- 1 + ( int )( 255.0 * rand () / ( RAND_MAX + 1.0 ) ) );
1903
- }
1904
-
1905
1873
//
1906
1874
// now draw actual graphs
1907
1875
//
1908
1876
1909
- // somtimes there are more bins than needed
1910
- // we find out the last one that actually has data in it
1911
- // so we can discard the rest and set the x-axis scales correctly
1912
- //
1913
- // scan through to get counts from layers' histograms
1914
- //
1915
- float myGlobalMin = 0 ;
1916
- float myGlobalMax = 0 ;
1917
1877
bool myFirstIteration = true ;
1918
1878
for ( int myIteratorInt = 1 ;
1919
- myIteratorInt <= myBandCountInt;
1920
- ++myIteratorInt )
1879
+ myIteratorInt <= myBandCountInt;
1880
+ ++myIteratorInt )
1921
1881
{
1922
1882
QgsRasterBandStats myRasterBandStats = mRasterLayer ->bandStatistics ( myIteratorInt );
1923
1883
mRasterLayer ->populateHistogram ( myIteratorInt, BINCOUNT, myIgnoreOutOfRangeFlag, myThoroughBandScanFlag );
1924
- QwtPlotCurve * mypCurve = new QwtPlotCurve ( tr ( " Band %1" ).arg ( myIteratorInt ) );
1925
- mypCurve->setCurveAttribute ( QwtPlotCurve::Fitted );
1926
- mypCurve->setRenderHint ( QwtPlotItem::RenderAntialiased );
1927
- mypCurve->setPen ( QPen ( myColors.at ( myIteratorInt ) ) );
1928
- #if defined(QWT_VERSION) && QWT_VERSION>=0x060000
1929
- QVector<QPointF> data;
1930
- #else
1931
- QVector<double > myX2Data;
1932
- QVector<double > myY2Data;
1933
- #endif
1934
1884
for ( int myBin = 0 ; myBin < BINCOUNT; myBin++ )
1935
1885
{
1936
1886
int myBinValue = myRasterBandStats.histogramVector ->at ( myBin );
1937
- #if defined(QWT_VERSION) && QWT_VERSION>=0x060000
1938
- data << QPointF ( myBin, myBinValue );
1939
- #else
1940
- myX2Data.append ( double ( myBin ) );
1941
- myY2Data.append ( double ( myBinValue ) );
1942
- #endif
1943
- }
1944
- #if defined(QWT_VERSION) && QWT_VERSION>=0x060000
1945
- mypCurve->setSamples ( data );
1946
- #else
1947
- mypCurve->setData ( myX2Data, myY2Data );
1948
- #endif
1949
- mypCurve->attach ( mpPlot );
1950
- if ( myFirstIteration || myGlobalMin < myRasterBandStats.minimumValue )
1951
- {
1952
- myGlobalMin = myRasterBandStats.minimumValue ;
1953
- }
1954
- if ( myFirstIteration || myGlobalMax < myRasterBandStats.maximumValue )
1955
- {
1956
- myGlobalMax = myRasterBandStats.maximumValue ;
1957
1887
}
1958
- myFirstIteration = false ;
1959
1888
}
1960
- // for x axis use band pixel values rather than gdal hist. bin values
1961
- // subtract -0.5 to prevent rounding errors
1962
- // see http://www.gdal.org/classGDALRasterBand.html#3f8889607d3b2294f7e0f11181c201c8
1963
- mpPlot->setAxisScale ( QwtPlot::xBottom,
1964
- myGlobalMin - 0.5 ,
1965
- myGlobalMax + 0.5 );
1966
- mpPlot->replot ();
1967
1889
disconnect ( mRasterLayer , SIGNAL ( progressUpdate ( int ) ), mHistogramProgress , SLOT ( setValue ( int ) ) );
1968
1890
mHistogramProgress ->hide ();
1969
- mpPlot->canvas ()->setCursor ( Qt::ArrowCursor );
1970
1891
QApplication::restoreOverrideCursor ();
1971
1892
}
1972
1893
1973
1894
void QgsRasterLayerProperties::on_mSaveAsImageButton_clicked ()
1974
1895
{
1975
- if ( mpPlot == 0 )
1976
- {
1977
- return ;
1978
- }
1979
1896
1980
1897
QPixmap myPixmap ( 600 , 600 );
1981
1898
myPixmap.fill ( Qt::white ); // Qt::transparent ?
1982
1899
1983
- #if (QWT_VERSION<0x060000)
1984
- QwtPlotPrintFilter myFilter;
1985
- int myOptions = QwtPlotPrintFilter::PrintAll;
1986
- myOptions &= ~QwtPlotPrintFilter::PrintBackground;
1987
- myOptions |= QwtPlotPrintFilter::PrintFrameWithScales;
1988
- myFilter.setOptions ( myOptions );
1989
-
1990
- mpPlot->print ( myPixmap, myFilter );
1991
- #else
1992
1900
QPainter painter;
1993
1901
painter.begin ( &myPixmap );
1994
- mpPlot ->drawCanvas ( &painter );
1902
+ // mWebPlot ->drawCanvas( &painter );
1995
1903
painter.end ();
1996
- #endif
1997
1904
QPair< QString, QString> myFileNameAndFilter = QgisGui::getSaveAsImageName ( this , tr ( " Choose a file name to save the map image as" ) );
1998
1905
if ( myFileNameAndFilter.first != " " )
1999
1906
{
2000
1907
myPixmap.save ( myFileNameAndFilter.first );
2001
1908
}
2002
1909
}
1910
+
2003
1911
void QgsRasterLayerProperties::on_pbnImportTransparentPixelValues_clicked ()
2004
1912
{
2005
1913
int myLineCounter = 0 ;
@@ -2864,6 +2772,7 @@ QLinearGradient QgsRasterLayerProperties::grayGradient()
2864
2772
myGradient.setColorAt ( 1.0 , QColor ( 220 , 220 , 220 , 190 ) );
2865
2773
return myGradient;
2866
2774
}
2775
+
2867
2776
QLinearGradient QgsRasterLayerProperties::highlightGradient ()
2868
2777
{
2869
2778
// define another gradient for the highlight
@@ -3074,4 +2983,3 @@ void QgsRasterLayerProperties::toggleBuildPyramidsButton()
3074
2983
buttonBuildPyramids->setEnabled ( true );
3075
2984
}
3076
2985
}
3077
-
0 commit comments