mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
-Added ability to add new single entry to color map
-Added ability to sort color map -Reorder controls on the Colormap tab git-svn-id: http://svn.osgeo.org/qgis/trunk@9200 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
1682e90cc1
commit
f03667b506
@ -2622,6 +2622,14 @@ void QgsRasterLayerProperties::handleColormapTreeWidgetDoubleClick( QTreeWidgetI
|
||||
}
|
||||
}
|
||||
|
||||
void QgsRasterLayerProperties::on_pbtnAddColorMapEntry_clicked()
|
||||
{
|
||||
QTreeWidgetItem* newItem = new QTreeWidgetItem( mColormapTreeWidget );
|
||||
newItem->setText( 0, "0.0");
|
||||
newItem->setBackground( 1, QBrush( QColor(Qt::magenta) ) );
|
||||
newItem->setText( 2, tr("Custom color map entry"));
|
||||
}
|
||||
|
||||
void QgsRasterLayerProperties::on_pbtnExportColorMapToFile_clicked()
|
||||
{
|
||||
QString myFileName = QFileDialog::getSaveFileName( this, tr( "Save file" ), "/", tr( "Textfile (*.txt)" ) );
|
||||
@ -2883,6 +2891,54 @@ void QgsRasterLayerProperties::on_pbtnMakeContrastEnhancementAlgorithmDefault_cl
|
||||
}
|
||||
}
|
||||
|
||||
void QgsRasterLayerProperties::on_pbtnSortColorMap_clicked()
|
||||
{
|
||||
bool inserted = false;
|
||||
int myCurrentIndex = 0;
|
||||
int myTopLevelItemCount = mColormapTreeWidget->topLevelItemCount();
|
||||
QTreeWidgetItem* myCurrentItem;
|
||||
QList<QgsColorRampShader::ColorRampItem> myColorRampItems;
|
||||
for ( int i = 0; i < myTopLevelItemCount; ++i )
|
||||
{
|
||||
myCurrentItem = mColormapTreeWidget->topLevelItem( i );
|
||||
//If the item is null or does not have a pixel values set, skip
|
||||
if(!myCurrentItem || myCurrentItem->text(0) == "")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//Create a copy of the new Color ramp Item
|
||||
QgsColorRampShader::ColorRampItem myNewColorRampItem;
|
||||
myNewColorRampItem.value = myCurrentItem->text( 0 ).toDouble();
|
||||
myNewColorRampItem.color = myCurrentItem->background( 1 ).color();
|
||||
myNewColorRampItem.label = myCurrentItem->text( 2 );
|
||||
|
||||
//Simple insertion sort - speed is not a huge factor here
|
||||
inserted = false;
|
||||
myCurrentIndex = 0;
|
||||
while(!inserted)
|
||||
{
|
||||
if(0 == myColorRampItems.size() || myCurrentIndex == myColorRampItems.size())
|
||||
{
|
||||
myColorRampItems.push_back( myNewColorRampItem );
|
||||
inserted = true;
|
||||
}
|
||||
else if(myColorRampItems[myCurrentIndex].value <= myNewColorRampItem.value && myCurrentIndex == myColorRampItems.size() - 1)
|
||||
{
|
||||
myColorRampItems.push_back( myNewColorRampItem );
|
||||
inserted = true;
|
||||
}
|
||||
else if(myColorRampItems[myCurrentIndex].value <= myNewColorRampItem.value && myColorRampItems[myCurrentIndex+1].value > myNewColorRampItem.value)
|
||||
{
|
||||
myColorRampItems.insert(myCurrentIndex+1,myNewColorRampItem );
|
||||
inserted = true;
|
||||
}
|
||||
myCurrentIndex++;
|
||||
}
|
||||
}
|
||||
populateColorMapTable(myColorRampItems);
|
||||
}
|
||||
|
||||
QLinearGradient QgsRasterLayerProperties::redGradient()
|
||||
{
|
||||
//define a gradient
|
||||
|
@ -108,6 +108,8 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
|
||||
void on_mDeleteEntryButton_clicked();
|
||||
/**Callback for double clicks on the colormap entry widget*/
|
||||
void handleColormapTreeWidgetDoubleClick( QTreeWidgetItem* item, int column );
|
||||
/**This slot adds a new row to the color map table */
|
||||
void on_pbtnAddColorMapEntry_clicked();
|
||||
/**This slots saves the current color map to a file */
|
||||
void on_pbtnExportColorMapToFile_clicked();
|
||||
/**This slots loads the current color map from a band */
|
||||
@ -120,7 +122,8 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
|
||||
void on_pbtnMakeBandCombinationDefault_clicked();
|
||||
/**This slot sets the default contrast enhancement varaible to current contrast enhancement algorithm */
|
||||
void on_pbtnMakeContrastEnhancementAlgorithmDefault_clicked();
|
||||
|
||||
/**This slot will sort the color map in ascending order*/
|
||||
void on_pbtnSortColorMap_clicked();
|
||||
/** Load the default style when appriate button is pressed. */
|
||||
void on_pbnLoadDefaultStyle_clicked();
|
||||
/** Save the default style when appriate button is pressed. */
|
||||
|
@ -6,7 +6,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>596</width>
|
||||
<height>610</height>
|
||||
<height>658</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
@ -1199,56 +1199,7 @@
|
||||
<string>Colormap</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" >
|
||||
<item row="0" column="0" colspan="2" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="leftMargin" >
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>11</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="mNumberOfEntriesLabel" >
|
||||
<property name="text" >
|
||||
<string>Number of entries</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="sboxNumberOfEntries" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<number>256</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="2" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="3" colspan="4" >
|
||||
<item row="0" column="0" colspan="3" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="leftMargin" >
|
||||
<number>11</number>
|
||||
@ -1274,73 +1225,54 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3" >
|
||||
<item row="0" column="3" colspan="6" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
<width>321</width>
|
||||
<height>45</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="3" colspan="4" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="leftMargin" >
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>11</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="mClassificationModeLabel" >
|
||||
<property name="text" >
|
||||
<string>Classification mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cboxClassificationMode" />
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QPushButton" name="mClassifyButton" >
|
||||
<item row="1" column="0" >
|
||||
<widget class="QPushButton" name="pbtnAddColorMapEntry" >
|
||||
<property name="text" >
|
||||
<string>Classify</string>
|
||||
<string>Add entry</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<item row="1" column="1" >
|
||||
<widget class="QPushButton" name="mDeleteEntryButton" >
|
||||
<property name="text" >
|
||||
<string>Delete entry</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2" >
|
||||
<item row="1" column="2" colspan="2" >
|
||||
<widget class="QPushButton" name="pbtnSortColorMap" >
|
||||
<property name="text" >
|
||||
<string>Sort</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>211</width>
|
||||
<width>41</width>
|
||||
<height>27</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="3" >
|
||||
<item row="1" column="5" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="leftMargin" >
|
||||
<number>11</number>
|
||||
@ -1363,11 +1295,14 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="4" >
|
||||
<item row="1" column="6" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
@ -1376,7 +1311,7 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="5" >
|
||||
<item row="1" column="7" >
|
||||
<widget class="QToolButton" name="pbtnLoadColorMapFromFile" >
|
||||
<property name="toolTip" >
|
||||
<string>Load color map from file</string>
|
||||
@ -1389,7 +1324,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="6" >
|
||||
<item row="1" column="8" >
|
||||
<widget class="QToolButton" name="pbtnExportColorMapToFile" >
|
||||
<property name="toolTip" >
|
||||
<string>Export color map to file</string>
|
||||
@ -1402,7 +1337,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="7" >
|
||||
<item row="2" column="0" colspan="9" >
|
||||
<widget class="QTreeWidget" name="mColormapTreeWidget" >
|
||||
<property name="columnCount" >
|
||||
<number>3</number>
|
||||
@ -1424,6 +1359,84 @@
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="9" >
|
||||
<widget class="QGroupBox" name="groupBox_9" >
|
||||
<property name="title" >
|
||||
<string>Generate new color map</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="leftMargin" >
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>11</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="mNumberOfEntriesLabel" >
|
||||
<property name="text" >
|
||||
<string>Number of entries</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="sboxNumberOfEntries" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<number>256</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="leftMargin" >
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>11</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="mClassificationModeLabel" >
|
||||
<property name="text" >
|
||||
<string>Classification mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cboxClassificationMode" />
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="mClassifyButton" >
|
||||
<property name="text" >
|
||||
<string>Classify</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tabPageGeneral" >
|
||||
|
Loading…
x
Reference in New Issue
Block a user