mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-26 00:02:43 -04:00
Context menu support and implemented handlers for multiband gray and pseudocolour rendering.
git-svn-id: http://svn.osgeo.org/qgis/trunk@578 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
889420a8b8
commit
6b2b8fc273
@ -58,15 +58,18 @@ The [type] part of the variable should be the type class of the variable written
|
|||||||
#include <qfont.h>
|
#include <qfont.h>
|
||||||
#include <qfontmetrics.h>
|
#include <qfontmetrics.h>
|
||||||
#include <qwmatrix.h>
|
#include <qwmatrix.h>
|
||||||
|
#include <qpopupmenu.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "qgsrasterlayer.h"
|
#include "qgsrasterlayer.h"
|
||||||
#include "qgsrect.h"
|
#include "qgsrect.h"
|
||||||
|
#include "qgisapp.h"
|
||||||
#include "qgsrasterlayerproperties.h"
|
#include "qgsrasterlayerproperties.h"
|
||||||
#include "gdal_priv.h"
|
#include "gdal_priv.h"
|
||||||
|
|
||||||
QgsRasterLayer::QgsRasterLayer(QString path, QString baseName)
|
QgsRasterLayer::QgsRasterLayer(QString path, QString baseName)
|
||||||
:QgsMapLayer(RASTER, baseName, path)
|
:QgsMapLayer(RASTER, baseName, path)
|
||||||
{
|
{
|
||||||
|
popMenu=0;
|
||||||
//std::cout << "QgsRasterLayer::QgsRasterLayer()" << std::endl;
|
//std::cout << "QgsRasterLayer::QgsRasterLayer()" << std::endl;
|
||||||
|
|
||||||
GDALAllRegister();
|
GDALAllRegister();
|
||||||
@ -319,7 +322,6 @@ void QgsRasterLayer::draw(QPainter * theQPainter, QgsRect * theViewExtent, QgsCo
|
|||||||
QString myColorQString = GDALGetColorInterpretationName(myGdalBand->GetColorInterpretation());
|
QString myColorQString = GDALGetColorInterpretationName(myGdalBand->GetColorInterpretation());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// The goal here is to make as many decisions as possible early on (outside of the rendering loop)
|
// The goal here is to make as many decisions as possible early on (outside of the rendering loop)
|
||||||
@ -350,9 +352,11 @@ void QgsRasterLayer::draw(QPainter * theQPainter, QgsRect * theViewExtent, QgsCo
|
|||||||
break;
|
break;
|
||||||
// a layer containing 2 or more bands, but using only one band to produce a grayscale image
|
// a layer containing 2 or more bands, but using only one band to produce a grayscale image
|
||||||
case MULTI_BAND_SINGLE_BAND_GRAY:
|
case MULTI_BAND_SINGLE_BAND_GRAY:
|
||||||
|
drawMultiBandSingleBandGray(theQPainter, myRasterViewPort, myGdalBand);
|
||||||
break;
|
break;
|
||||||
//a layer containing 2 or more bands, but using only one band to produce a pseudocolor image
|
//a layer containing 2 or more bands, but using only one band to produce a pseudocolor image
|
||||||
case MULTI_BAND_SINGLE_BAND_PSEUDO_COLOR:
|
case MULTI_BAND_SINGLE_BAND_PSEUDO_COLOR:
|
||||||
|
drawMultiBandSingleBandPseudoColor(theQPainter, myRasterViewPort, myGdalBand);
|
||||||
break;
|
break;
|
||||||
//a layer containing 2 or more bands, mapped to the three RGBcolors.
|
//a layer containing 2 or more bands, mapped to the three RGBcolors.
|
||||||
//In the case of a multiband with only two bands, one band will have to be mapped to more than one color
|
//In the case of a multiband with only two bands, one band will have to be mapped to more than one color
|
||||||
@ -382,12 +386,8 @@ void QgsRasterLayer::drawSingleBandGray(QPainter * theQPainter,
|
|||||||
std::cout << "QgsRasterLayer::drawSingleBandGray called" << std::endl;
|
std::cout << "QgsRasterLayer::drawSingleBandGray called" << std::endl;
|
||||||
//create the outout image that the layer will be drawn on before placing it in the qcanvas
|
//create the outout image that the layer will be drawn on before placing it in the qcanvas
|
||||||
|
|
||||||
QPixmap * myQPixmap=new QPixmap(theRasterViewPort->drawableAreaXDimInt,theRasterViewPort->drawableAreaYDimInt);
|
// QPixmap * myQPixmap=new QPixmap(theRasterViewPort->drawableAreaXDimInt,theRasterViewPort->drawableAreaYDimInt);
|
||||||
//myQPixmap.setAlphaBuffer(true); //only supported for qimage
|
|
||||||
//create a temporary qpainter that can be used for xoring red, green and blue data onto
|
|
||||||
//the image.
|
|
||||||
QPainter myQPainter;
|
|
||||||
myQPainter.begin(myQPixmap);
|
|
||||||
// read entire clipped area of raster band
|
// read entire clipped area of raster band
|
||||||
// treat myGdalScanData as a pseudo-multidimensional array
|
// treat myGdalScanData as a pseudo-multidimensional array
|
||||||
// RasterIO() takes care of scaling down image
|
// RasterIO() takes care of scaling down image
|
||||||
@ -956,14 +956,16 @@ void QgsRasterLayer::drawPalettedMultiBandColor(QPainter * theQPainter,
|
|||||||
theQPainter->drawImage(theRasterViewPort->topLeftPoint.xToInt(), theRasterViewPort->topLeftPoint.yToInt(),myQImage);
|
theQPainter->drawImage(theRasterViewPort->topLeftPoint.xToInt(), theRasterViewPort->topLeftPoint.yToInt(),myQImage);
|
||||||
|
|
||||||
}
|
}
|
||||||
void drawMultiBandSingleBandGray(QPainter * theQPainter, RasterViewPort * theRasterViewPort)
|
void QgsRasterLayer::drawMultiBandSingleBandGray(QPainter * theQPainter, RasterViewPort * theRasterViewPort, GDALRasterBand * theGdalBand )
|
||||||
{
|
{
|
||||||
|
//delegate to drawSingleBandGray!
|
||||||
|
drawSingleBandGray(theQPainter, theRasterViewPort, theGdalBand);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawMultiBandSingleBandPseudoColor(QPainter * theQPainter, RasterViewPort * theRasterViewPort)
|
void QgsRasterLayer::drawMultiBandSingleBandPseudoColor(QPainter * theQPainter, RasterViewPort * theRasterViewPort, GDALRasterBand * theGdalBand)
|
||||||
{
|
{
|
||||||
|
//delegate to drawSinglePseudocolor!
|
||||||
|
drawSingleBandPseudoColor(theQPainter, theRasterViewPort, theGdalBand);
|
||||||
}
|
}
|
||||||
void QgsRasterLayer::drawMultiBandColor(QPainter * theQPainter,
|
void QgsRasterLayer::drawMultiBandColor(QPainter * theQPainter,
|
||||||
RasterViewPort * theRasterViewPort)
|
RasterViewPort * theRasterViewPort)
|
||||||
@ -1598,3 +1600,16 @@ QPixmap * QgsRasterLayer::legendPixmap()
|
|||||||
|
|
||||||
return new QPixmap(myQPixmap);
|
return new QPixmap(myQPixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Accessor for the superclass popmenu var*/
|
||||||
|
QPopupMenu *QgsRasterLayer::contextMenu(){
|
||||||
|
return popMenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QgsRasterLayer::initContextMenu(QgisApp *theApp){
|
||||||
|
popMenu = new QPopupMenu();
|
||||||
|
popMenu->insertItem(tr("&Zoom to extent of selected layer"), theApp, SLOT(zoomToLayerExtent()));
|
||||||
|
popMenu->insertItem(tr("&Properties"), theApp, SLOT(layerProperties()));
|
||||||
|
popMenu->insertSeparator();
|
||||||
|
popMenu->insertItem(tr("&Remove"), theApp, SLOT(removeLayer()));
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user