Update legend pyramid icon when pyramids are added to a raster layer.

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@1449 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
timlinux 2004-05-21 21:32:17 +00:00
parent c7318aa6d1
commit 251f566ca4
2 changed files with 14 additions and 0 deletions

View File

@ -2319,6 +2319,7 @@ QString QgsRasterLayer::getMetadata()
void QgsRasterLayer::buildPyramids(RasterPyramidList theRasterPyramidList) void QgsRasterLayer::buildPyramids(RasterPyramidList theRasterPyramidList)
{ {
emit setProgress(0,0);
//first test if the file is writeable //first test if the file is writeable
QFile myQFile(dataSource); QFile myQFile(dataSource);
if (!myQFile.open(IO_WriteOnly| IO_Append)) if (!myQFile.open(IO_WriteOnly| IO_Append))
@ -2344,6 +2345,8 @@ void QgsRasterLayer::buildPyramids(RasterPyramidList theRasterPyramidList)
// Iterate through the Raster Layer Pyramid Vector, building any pyramid // Iterate through the Raster Layer Pyramid Vector, building any pyramid
// marked as exists in eaxh RasterPyramid struct. // marked as exists in eaxh RasterPyramid struct.
// //
int myCountInt=1;
int myTotalInt=theRasterPyramidList.count();
RasterPyramidList::iterator myRasterPyramidIterator; RasterPyramidList::iterator myRasterPyramidIterator;
for ( myRasterPyramidIterator=theRasterPyramidList.begin(); for ( myRasterPyramidIterator=theRasterPyramidList.begin();
myRasterPyramidIterator != theRasterPyramidList.end(); myRasterPyramidIterator != theRasterPyramidList.end();
@ -2357,6 +2360,7 @@ void QgsRasterLayer::buildPyramids(RasterPyramidList theRasterPyramidList)
if ((*myRasterPyramidIterator).existsFlag) if ((*myRasterPyramidIterator).existsFlag)
{ {
std::cout << "Building....." << std::endl; std::cout << "Building....." << std::endl;
emit setProgress(myCountInt,myTotalInt);
int myOverviewLevelsIntArray[1] = {(*myRasterPyramidIterator).levelInt }; int myOverviewLevelsIntArray[1] = {(*myRasterPyramidIterator).levelInt };
/* From : http://remotesensing.org/gdal/classGDALDataset.html#a23 /* From : http://remotesensing.org/gdal/classGDALDataset.html#a23
* pszResampling : one of "NEAREST", "AVERAGE" or "MODE" controlling the downsampling method applied. * pszResampling : one of "NEAREST", "AVERAGE" or "MODE" controlling the downsampling method applied.
@ -2369,12 +2373,16 @@ void QgsRasterLayer::buildPyramids(RasterPyramidList theRasterPyramidList)
*/ */
gdalDataset->BuildOverviews( "NEAREST", 1, myOverviewLevelsIntArray, 0, NULL, gdalDataset->BuildOverviews( "NEAREST", 1, myOverviewLevelsIntArray, 0, NULL,
GDALTermProgress, NULL ); GDALTermProgress, NULL );
myCountInt++;
//make sure the raster knows it has pyramids
hasPyramidsFlag=true;
} }
std::cout << "Pyramid overviews built" << std::endl; std::cout << "Pyramid overviews built" << std::endl;
//close the gdal dataset and reopen it in read only mode //close the gdal dataset and reopen it in read only mode
delete gdalDataset; delete gdalDataset;
gdalDataset = (GDALDataset *) GDALOpen(dataSource, GA_ReadOnly); gdalDataset = (GDALDataset *) GDALOpen(dataSource, GA_ReadOnly);
emit setProgress(0,0);
} }
} }
RasterPyramidList QgsRasterLayer::buildRasterPyramidList() RasterPyramidList QgsRasterLayer::buildRasterPyramidList()

View File

@ -785,5 +785,11 @@ void QgsRasterLayerProperties::buttonBuildPyramids_clicked()
QString::number((*myRasterPyramidIterator).yDimInt)); QString::number((*myRasterPyramidIterator).yDimInt));
} }
} }
//update the legend pixmap
pixmapLegend->setPixmap(rasterLayer->getLegendQPixmap());
pixmapLegend->setScaledContents(true);
pixmapLegend->repaint(false);
QgsLegendItem *myLegendItem = rasterLayer->legendItem();
((QCheckListItem *) myLegendItem)->setPixmap(0, *rasterLayer->legendPixmap());
} }