Added getPalletteAsPixmap method to rasterlayer class so that the palette of a paletted raster layer can be retrieved and visualised.

Rearranged 'General' tab on raster props dialog, including adding a
palette view that uses the above mentioned call to rasterlayer class.


git-svn-id: http://svn.osgeo.org/qgis/trunk@1521 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
timlinux 2004-06-04 09:53:30 +00:00
parent ae60bc7744
commit e7d3f0e7b3
4 changed files with 1872 additions and 1711 deletions

File diff suppressed because it is too large Load Diff

View File

@ -215,6 +215,8 @@ struct RasterBandStats
/** \brief The number of cells in the band. Equivalent to height x width.
* TODO: check if NO_DATA are excluded!*/
int elementCountInt;
/** \brief A histogram storing the distribution of values within the raster. */
int histogram[256];
};
/** \brief A vector containing one RasterBandStats struct per raster band in this raster layer.
@ -333,6 +335,9 @@ public:
void showLayerProperties();
/** \brief Draws a thumbnail of the rasterlayer into the supplied pixmap pointer */
void drawThumbnail(QPixmap * theQPixmap);
/** \brief Get an 8x8 pixmap of the colour palette. If the layer has no palette a white pixmap will be returned. */
QPixmap getPaletteAsPixmap();
/** \brief This is called when the view on the rasterlayer needs to be refreshed (redrawn). */
void draw(QPainter * theQPainter, QgsRect * theViewExtent, QgsCoordinateTransform * theQgsCoordinateTransform, QPaintDevice* dst);
/** \brief This is an overloaded version of the above function that is called by both draw above and drawThumbnail */

View File

@ -59,8 +59,8 @@ QgsRasterLayerProperties::QgsRasterLayerProperties(QgsMapLayer * lyr):QgsRasterL
txtbMetadata->setText(rasterLayer->getMetadata());
//tabSymbology->removePage(tabMetadata);
//display the raster dimensions and no data value
lblColumns->setText(tr("<p align=\"center\">Columns:") + QString::number(rasterLayer->getRasterXDim()) + "</p>");
lblRows->setText(tr("<p align=\"right\">Rows:") + QString::number(rasterLayer->getRasterYDim()) + "</p>");
lblColumns->setText(tr("Columns:") + QString::number(rasterLayer->getRasterXDim()));
lblRows->setText(tr("Rows:") + QString::number(rasterLayer->getRasterYDim()));
lblNoData->setText(tr("No Data:") + QString::number(rasterLayer->getNoDataValue()));
//these properties (layername and label) are provided by the qgsmaplayer superclass
leLayerSource->setText(rasterLayer->source());
@ -74,6 +74,11 @@ QgsRasterLayerProperties::QgsRasterLayerProperties(QgsMapLayer * lyr):QgsRasterL
pixmapLegend->setScaledContents(true);
pixmapLegend->repaint(false);
//set the palette pixmap
pixmapPalette->setPixmap(rasterLayer->getPaletteAsPixmap());
pixmapPalette->setScaledContents(true);
pixmapPalette->repaint(false);
//set the transparency slider
sliderTransparency->setValue(255 - rasterLayer->getTransparency());
//update the transparency percentage label

View File

@ -9,7 +9,7 @@
<x>0</x>
<y>0</y>
<width>636</width>
<height>456</height>
<height>458</height>
</rect>
</property>
<property name="caption">
@ -424,20 +424,12 @@
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLabel" row="0" column="0" rowspan="1" colspan="3">
<property name="name">
<cstring>lblLayerSource</cstring>
</property>
<property name="text">
<string>Layer Source:</string>
</property>
</widget>
<widget class="QLineEdit" row="3" column="0" rowspan="1" colspan="5">
<widget class="QLineEdit" row="3" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>leDisplayName</cstring>
</property>
</widget>
<widget class="QLineEdit" row="1" column="0" rowspan="1" colspan="5">
<widget class="QLineEdit" row="1" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>leLayerSource</cstring>
</property>
@ -445,7 +437,7 @@
<bool>false</bool>
</property>
</widget>
<widget class="QLabel" row="2" column="0" rowspan="1" colspan="3">
<widget class="QLabel" row="2" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>lblDisplayName</cstring>
</property>
@ -453,29 +445,7 @@
<string>Display Name:</string>
</property>
</widget>
<widget class="QLabel" row="4" column="0" rowspan="1" colspan="3">
<property name="name">
<cstring>lblDisplayName_2</cstring>
</property>
<property name="text">
<string>Legend:</string>
</property>
</widget>
<widget class="QLabel" row="5" column="0" rowspan="1" colspan="5">
<property name="name">
<cstring>pixmapLegend</cstring>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>10</height>
</size>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
<widget class="QCheckBox" row="6" column="0" rowspan="1" colspan="5">
<widget class="QCheckBox" row="0" column="1">
<property name="name">
<cstring>cboxShowDebugInfo</cstring>
</property>
@ -483,132 +453,189 @@
<string>Show debug info as overlay on raster?</string>
</property>
</widget>
<widget class="QLabel" row="7" column="2">
<widget class="QLabel" row="0" column="0">
<property name="name">
<cstring>lblColumns</cstring>
<cstring>lblLayerSource</cstring>
</property>
<property name="text">
<string>&lt;p align="center"&gt;Columns: &lt;/p&gt;</string>
<string>Layer Source:</string>
</property>
</widget>
<widget class="QLabel" row="8" column="2">
<widget class="QLayoutWidget" row="4" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>pixmapThumbnail</cstring>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>120</height>
</size>
</property>
<property name="frameShape">
<enum>StyledPanel</enum>
</property>
<property name="scaledContents">
<bool>true</bool>
<cstring>layout2</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QGroupBox">
<property name="name">
<cstring>groupBox10</cstring>
</property>
<property name="title">
<string>Thumbnail</string>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLabel" row="0" column="0">
<property name="name">
<cstring>lblColumns</cstring>
</property>
<property name="text">
<string>Columns:</string>
</property>
</widget>
<widget class="QLabel" row="2" column="0">
<property name="name">
<cstring>lblNoData</cstring>
</property>
<property name="text">
<string>No Data:</string>
</property>
</widget>
<widget class="QLabel" row="1" column="0">
<property name="name">
<cstring>lblRows</cstring>
</property>
<property name="text">
<string>Rows:</string>
</property>
</widget>
<widget class="QLabel" row="4" column="0">
<property name="name">
<cstring>pixmapThumbnail</cstring>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>120</height>
</size>
</property>
<property name="frameShape">
<enum>StyledPanel</enum>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
<spacer row="3" column="0">
<property name="name">
<cstring>spacer17</cstring>
</property>
<property name="orientation">
<enum>Vertical</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>31</height>
</size>
</property>
</spacer>
</grid>
</widget>
<widget class="QGroupBox">
<property name="name">
<cstring>groupBox9</cstring>
</property>
<property name="title">
<string>Legend:</string>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLabel" row="1" column="0">
<property name="name">
<cstring>pixmapLegend</cstring>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>120</height>
</size>
</property>
<property name="frameShape">
<enum>Box</enum>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
<spacer row="0" column="0">
<property name="name">
<cstring>spacer15</cstring>
</property>
<property name="orientation">
<enum>Vertical</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>71</height>
</size>
</property>
</spacer>
</grid>
</widget>
<widget class="QGroupBox">
<property name="name">
<cstring>groupBox8</cstring>
</property>
<property name="title">
<string>Palette:</string>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLabel" row="1" column="0">
<property name="name">
<cstring>pixmapPalette</cstring>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>120</height>
</size>
</property>
<property name="frameShape">
<enum>Box</enum>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
<spacer row="0" column="0">
<property name="name">
<cstring>spacer14</cstring>
</property>
<property name="orientation">
<enum>Vertical</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>61</height>
</size>
</property>
</spacer>
</grid>
</widget>
</hbox>
</widget>
<widget class="QLabel" row="8" column="1">
<property name="name">
<cstring>lblRows</cstring>
</property>
<property name="text">
<string>&lt;p align="right"&gt;Rows: &lt;/p&gt;</string>
</property>
</widget>
<widget class="QLabel" row="8" column="3">
<property name="name">
<cstring>lblNoData</cstring>
</property>
<property name="text">
<string>No Data:</string>
</property>
</widget>
<spacer row="7" column="3">
<property name="name">
<cstring>spacer6</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>81</width>
<height>21</height>
</size>
</property>
</spacer>
<spacer row="7" column="1">
<property name="name">
<cstring>spacer7</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>121</width>
<height>21</height>
</size>
</property>
</spacer>
<spacer row="8" column="4">
<property name="name">
<cstring>spacer8</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>41</width>
<height>21</height>
</size>
</property>
</spacer>
<spacer row="8" column="0">
<property name="name">
<cstring>spacer9</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>21</width>
<height>20</height>
</size>
</property>
</spacer>
<spacer row="9" column="2">
<property name="name">
<cstring>spacer2</cstring>
</property>
<property name="orientation">
<enum>Vertical</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>21</width>
<height>20</height>
</size>
</property>
</spacer>
</grid>
</widget>
<widget class="QWidget">