Skip to content

Commit d75d8b5

Browse files
committed
Further updates to flot graphing for raster histogram
1 parent 4f0a35f commit d75d8b5

File tree

3 files changed

+34
-18
lines changed

3 files changed

+34
-18
lines changed

resources/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ INSTALL(FILES srs.db qgis.db qgis_help.db symbology-ng-style.xml spatialite.db c
33

44
ADD_SUBDIRECTORY(context_help)
55
ADD_SUBDIRECTORY(js)
6+
ADD_SUBDIRECTORY(html)

src/app/qgsrasterlayerproperties.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#include <QMouseEvent>
5353
#include <QVector>
5454
#include <QWebView>
55+
#include <QWebFrame>
5556

5657

5758
QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanvas* theCanvas, QWidget *parent, Qt::WFlags fl )
@@ -65,6 +66,8 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
6566
mRGBMinimumMaximumEstimated = true;
6667

6768
setupUi( this );
69+
QString myChartPage = "file:///" + QgsApplication::pkgDataPath() + "/resources/html/chart.html";
70+
mWebPlot->load(QUrl( myChartPage ));
6871
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
6972
connect( this, SIGNAL( accepted() ), this, SLOT( apply() ) );
7073
connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) );
@@ -1855,14 +1858,13 @@ void QgsRasterLayerProperties::refreshHistogram()
18551858
mHistogramProgress->show();
18561859
connect( mRasterLayer, SIGNAL( progressUpdate( int ) ), mHistogramProgress, SLOT( setValue( int ) ) );
18571860
QApplication::setOverrideCursor( Qt::WaitCursor );
1858-
mWebPlot->setHtml("<h1>Hellow World</h1>");
18591861
// Explanation:
18601862
// We use the gdal histogram creation routine is called for each selected
18611863
// layer. Currently the hist is hardcoded
18621864
// to create 256 bins. Each bin stores the total number of cells that
18631865
// fit into the range defined by that bin.
18641866
//
1865-
// The graph routine below determines the greatest number of pixesl in any given
1867+
// The graph routine below determines the greatest number of pixels in any given
18661868
// bin in all selected layers, and the min. It then draws a scaled line between min
18671869
// and max - scaled to image height. 1 line drawn per selected band
18681870
//
@@ -1881,10 +1883,21 @@ void QgsRasterLayerProperties::refreshHistogram()
18811883
{
18821884
QgsRasterBandStats myRasterBandStats = mRasterLayer->bandStatistics( myIteratorInt );
18831885
mRasterLayer->populateHistogram( myIteratorInt, BINCOUNT, myIgnoreOutOfRangeFlag, myThoroughBandScanFlag );
1886+
QString mySeriesJS = "addSeries([";
1887+
bool myFirst = true;
18841888
for ( int myBin = 0; myBin < BINCOUNT; myBin++ )
18851889
{
1890+
if ( ! myFirst )
1891+
{
1892+
mySeriesJS += ",";
1893+
}
18861894
int myBinValue = myRasterBandStats.histogramVector->at( myBin );
1895+
mySeriesJS += QString("[%1,%2]").arg(myBin).arg(myBinValue);
1896+
myFirst = false;
18871897
}
1898+
mySeriesJS += "]);";
1899+
QgsDebugMsg( mySeriesJS );
1900+
mWebPlot->page()->mainFrame()->evaluateJavaScript( mySeriesJS );
18881901
}
18891902
disconnect( mRasterLayer, SIGNAL( progressUpdate( int ) ), mHistogramProgress, SLOT( setValue( int ) ) );
18901903
mHistogramProgress->hide();

src/ui/qgsrasterlayerpropertiesbase.ui

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
</property>
1616
<property name="windowIcon">
1717
<iconset>
18-
<normaloff/>
19-
</iconset>
18+
<normaloff>../../../../../.designer/backup</normaloff>../../../../../.designer/backup</iconset>
2019
</property>
2120
<property name="sizeGripEnabled">
2221
<bool>true</bool>
@@ -234,7 +233,7 @@
234233
</property>
235234
<property name="icon">
236235
<iconset>
237-
<normaloff>../../images/themes/default/mActionFileSave.png</normaloff>../../images/themes/default/mActionFileSave.png</iconset>
236+
<normaloff>../../../../../images/themes/default/mActionFileSave.png</normaloff>../../../../../images/themes/default/mActionFileSave.png</iconset>
238237
</property>
239238
</widget>
240239
</item>
@@ -542,7 +541,7 @@
542541
</property>
543542
<property name="icon">
544543
<iconset>
545-
<normaloff>../../images/themes/default/mActionFileSave.png</normaloff>../../images/themes/default/mActionFileSave.png</iconset>
544+
<normaloff>../../../../../images/themes/default/mActionFileSave.png</normaloff>../../../../../images/themes/default/mActionFileSave.png</iconset>
546545
</property>
547546
</widget>
548547
</item>
@@ -898,7 +897,7 @@
898897
</property>
899898
<property name="icon">
900899
<iconset>
901-
<normaloff>../../images/themes/default/mActionFileSave.png</normaloff>../../images/themes/default/mActionFileSave.png</iconset>
900+
<normaloff>../../../../../images/themes/default/mActionFileSave.png</normaloff>../../../../../images/themes/default/mActionFileSave.png</iconset>
902901
</property>
903902
</widget>
904903
</item>
@@ -1093,7 +1092,7 @@
10931092
</property>
10941093
<property name="icon">
10951094
<iconset>
1096-
<normaloff>../../images/themes/default/mActionNewAttribute.png</normaloff>../../images/themes/default/mActionNewAttribute.png</iconset>
1095+
<normaloff>../../../../../images/themes/default/mActionNewAttribute.png</normaloff>../../../../../images/themes/default/mActionNewAttribute.png</iconset>
10971096
</property>
10981097
</widget>
10991098
</item>
@@ -1110,7 +1109,7 @@
11101109
</property>
11111110
<property name="icon">
11121111
<iconset>
1113-
<normaloff>../../images/themes/default/mActionContextHelp.png</normaloff>../../images/themes/default/mActionContextHelp.png</iconset>
1112+
<normaloff>../../../../../images/themes/default/mActionContextHelp.png</normaloff>../../../../../images/themes/default/mActionContextHelp.png</iconset>
11141113
</property>
11151114
</widget>
11161115
</item>
@@ -1124,7 +1123,7 @@
11241123
</property>
11251124
<property name="icon">
11261125
<iconset>
1127-
<normaloff>../../images/themes/default/mActionDeleteAttribute.png</normaloff>../../images/themes/default/mActionDeleteAttribute.png</iconset>
1126+
<normaloff>../../../../../images/themes/default/mActionDeleteAttribute.png</normaloff>../../../../../images/themes/default/mActionDeleteAttribute.png</iconset>
11281127
</property>
11291128
</widget>
11301129
</item>
@@ -1138,7 +1137,7 @@
11381137
</property>
11391138
<property name="icon">
11401139
<iconset>
1141-
<normaloff>../../images/themes/default/mActionCopySelected.png</normaloff>../../images/themes/default/mActionCopySelected.png</iconset>
1140+
<normaloff>../../../../../images/themes/default/mActionCopySelected.png</normaloff>../../../../../images/themes/default/mActionCopySelected.png</iconset>
11421141
</property>
11431142
</widget>
11441143
</item>
@@ -1165,7 +1164,7 @@
11651164
</property>
11661165
<property name="icon">
11671166
<iconset>
1168-
<normaloff>../../images/themes/default/mActionFolder.png</normaloff>../../images/themes/default/mActionFolder.png</iconset>
1167+
<normaloff>../../../../../images/themes/default/mActionFolder.png</normaloff>../../../../../images/themes/default/mActionFolder.png</iconset>
11691168
</property>
11701169
</widget>
11711170
</item>
@@ -1179,7 +1178,7 @@
11791178
</property>
11801179
<property name="icon">
11811180
<iconset>
1182-
<normaloff>../../images/themes/default/mActionFileSave.png</normaloff>../../images/themes/default/mActionFileSave.png</iconset>
1181+
<normaloff>../../../../../images/themes/default/mActionFileSave.png</normaloff>../../../../../images/themes/default/mActionFileSave.png</iconset>
11831182
</property>
11841183
</widget>
11851184
</item>
@@ -1350,7 +1349,7 @@
13501349
</property>
13511350
<property name="icon">
13521351
<iconset>
1353-
<normaloff>../../images/themes/default/mActionNewAttribute.png</normaloff>../../images/themes/default/mActionNewAttribute.png</iconset>
1352+
<normaloff>../../../../../images/themes/default/mActionNewAttribute.png</normaloff>../../../../../images/themes/default/mActionNewAttribute.png</iconset>
13541353
</property>
13551354
</widget>
13561355
</item>
@@ -1380,7 +1379,7 @@
13801379
</property>
13811380
<property name="icon">
13821381
<iconset>
1383-
<normaloff>../../images/themes/default/mActionFolder.png</normaloff>../../images/themes/default/mActionFolder.png</iconset>
1382+
<normaloff>../../../../../images/themes/default/mActionFolder.png</normaloff>../../../../../images/themes/default/mActionFolder.png</iconset>
13841383
</property>
13851384
</widget>
13861385
</item>
@@ -1394,7 +1393,7 @@
13941393
</property>
13951394
<property name="icon">
13961395
<iconset>
1397-
<normaloff>../../images/themes/default/mActionFileSave.png</normaloff>../../images/themes/default/mActionFileSave.png</iconset>
1396+
<normaloff>../../../../../images/themes/default/mActionFileSave.png</normaloff>../../../../../images/themes/default/mActionFileSave.png</iconset>
13981397
</property>
13991398
</widget>
14001399
</item>
@@ -1775,6 +1774,9 @@ p, li { white-space: pre-wrap; }
17751774
&lt;table border=&quot;0&quot; style=&quot;-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;&quot;&gt;
17761775
&lt;tr&gt;
17771776
&lt;td style=&quot;border: none;&quot;&gt;
1777+
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
1778+
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
1779+
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
17781780
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;&quot;&gt;&lt;/p&gt;
17791781
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;&quot;&gt;&lt;/p&gt;
17801782
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
@@ -1880,11 +1882,11 @@ p, li { white-space: pre-wrap; }
18801882
</property>
18811883
<property name="icon">
18821884
<iconset>
1883-
<normaloff>../../images/themes/default/mActionFileSave.png</normaloff>../../images/themes/default/mActionFileSave.png</iconset>
1885+
<normaloff>../../../../../images/themes/default/mActionFileSave.png</normaloff>../../../../../images/themes/default/mActionFileSave.png</iconset>
18841886
</property>
18851887
</widget>
18861888
</item>
1887-
<item row="0" column="0">
1889+
<item row="0" column="0" colspan="2">
18881890
<widget class="QWebView" name="mWebPlot">
18891891
<property name="url">
18901892
<url>

0 commit comments

Comments
 (0)