Skip to content

Commit

Permalink
Fix refresh of histogram when tab is already active
Browse files Browse the repository at this point in the history
  • Loading branch information
timlinux committed Nov 21, 2011
1 parent 0589daf commit 8d465ec
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
6 changes: 1 addition & 5 deletions resources/html/chart.html
Expand Up @@ -4,8 +4,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="javascript" type="text/javascript" src="../js/jquery.js"></script>
<script language="javascript" type="text/javascript" src="../js/jquery.flot.js"></script>
<!-- flot grow plugin: see http://jumware.com/Includes/jquery/Flot/Doc/JQuery.flot.grow.html -->
<script language="javascript" type="text/javascript" src="../js/jquery.flot.grow.js"></script>
<script language="javascript" type="text/javascript" src="../js/jquery.flot.navigate.js"></script>
</head>
<body>
Expand All @@ -16,9 +14,7 @@
{
var options = { series :
{
grow : { active : true },
points : { show : true },
grow : { stepMode : "maximum", steps: 120 },
points : { show : false },
lines : { show : true },
},
yaxis : { zoomRange: null, panRange: null },
Expand Down
12 changes: 10 additions & 2 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -68,6 +68,7 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
setupUi( this );
QString myChartPage = "file:///" + QgsApplication::pkgDataPath() + "/resources/html/chart.html";
mWebPlot->load(QUrl( myChartPage ));
connect( mWebPlot->page()->mainFrame(), SIGNAL( loadFinished( bool ) ), this, SLOT( histogramPageLoaded( bool ) ) );
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
connect( this, SIGNAL( accepted() ), this, SLOT( apply() ) );
connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) );
Expand Down Expand Up @@ -1853,6 +1854,14 @@ void QgsRasterLayerProperties::on_tabBar_currentChanged( int theTab )
}
}

void QgsRasterLayerProperties::histogramPageLoaded( bool theOkFlag )
{
if ( tabBar->currentIndex() == 6 && theOkFlag ) //yuk magick number
{
refreshHistogram();
}
}

void QgsRasterLayerProperties::refreshHistogram()
{
mHistogramProgress->show();
Expand All @@ -1876,7 +1885,6 @@ void QgsRasterLayerProperties::refreshHistogram()
//now draw actual graphs
//

bool myFirstIteration = true;
for ( int myIteratorInt = 1;
myIteratorInt <= myBandCountInt;
++myIteratorInt )
Expand All @@ -1896,7 +1904,7 @@ void QgsRasterLayerProperties::refreshHistogram()
myFirst = false;
}
mySeriesJS += "]);";
QgsDebugMsg( mySeriesJS );
//QgsDebugMsg( mySeriesJS );
mWebPlot->page()->mainFrame()->evaluateJavaScript( mySeriesJS );
}
disconnect( mRasterLayer, SIGNAL( progressUpdate( int ) ), mHistogramProgress, SLOT( setValue( int ) ) );
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgsrasterlayerproperties.h
Expand Up @@ -69,6 +69,9 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
void on_tabBar_currentChanged( int theTab );
/** \brief slot executed when user wishes to refresh raster histogram */
void refreshHistogram();
/** \brief slot executed when the web view for the histogram is loaded and ready to display charts
* @note added in 2.0 */
void histogramPageLoaded( bool theOkFlag );
/** \brief slow executed when user wishes to import transparency values */
void on_pbnImportTransparentPixelValues_clicked();
/** \brief slot executed when user presses "Remove Selected Row" button on the transparency page */
Expand Down

0 comments on commit 8d465ec

Please sign in to comment.