mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-22 00:14:55 -05: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()
|
void QgsRasterLayerProperties::on_pbtnExportColorMapToFile_clicked()
|
||||||
{
|
{
|
||||||
QString myFileName = QFileDialog::getSaveFileName( this, tr( "Save file" ), "/", tr( "Textfile (*.txt)" ) );
|
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()
|
QLinearGradient QgsRasterLayerProperties::redGradient()
|
||||||
{
|
{
|
||||||
//define a gradient
|
//define a gradient
|
||||||
|
|||||||
@ -108,6 +108,8 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
|
|||||||
void on_mDeleteEntryButton_clicked();
|
void on_mDeleteEntryButton_clicked();
|
||||||
/**Callback for double clicks on the colormap entry widget*/
|
/**Callback for double clicks on the colormap entry widget*/
|
||||||
void handleColormapTreeWidgetDoubleClick( QTreeWidgetItem* item, int column );
|
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 */
|
/**This slots saves the current color map to a file */
|
||||||
void on_pbtnExportColorMapToFile_clicked();
|
void on_pbtnExportColorMapToFile_clicked();
|
||||||
/**This slots loads the current color map from a band */
|
/**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();
|
void on_pbtnMakeBandCombinationDefault_clicked();
|
||||||
/**This slot sets the default contrast enhancement varaible to current contrast enhancement algorithm */
|
/**This slot sets the default contrast enhancement varaible to current contrast enhancement algorithm */
|
||||||
void on_pbtnMakeContrastEnhancementAlgorithmDefault_clicked();
|
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. */
|
/** Load the default style when appriate button is pressed. */
|
||||||
void on_pbnLoadDefaultStyle_clicked();
|
void on_pbnLoadDefaultStyle_clicked();
|
||||||
/** Save the default style when appriate button is pressed. */
|
/** Save the default style when appriate button is pressed. */
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>596</width>
|
<width>596</width>
|
||||||
<height>610</height>
|
<height>658</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle" >
|
||||||
@ -1199,56 +1199,7 @@
|
|||||||
<string>Colormap</string>
|
<string>Colormap</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" >
|
<layout class="QGridLayout" >
|
||||||
<item row="0" column="0" colspan="2" >
|
<item row="0" column="0" colspan="3" >
|
||||||
<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" >
|
|
||||||
<layout class="QHBoxLayout" >
|
<layout class="QHBoxLayout" >
|
||||||
<property name="leftMargin" >
|
<property name="leftMargin" >
|
||||||
<number>11</number>
|
<number>11</number>
|
||||||
@ -1274,73 +1225,54 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" colspan="3" >
|
<item row="0" column="3" colspan="6" >
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" >
|
||||||
<size>
|
<size>
|
||||||
<width>61</width>
|
<width>321</width>
|
||||||
<height>20</height>
|
<height>45</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="3" colspan="4" >
|
<item row="1" column="0" >
|
||||||
<layout class="QHBoxLayout" >
|
<widget class="QPushButton" name="pbtnAddColorMapEntry" >
|
||||||
<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" >
|
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Classify</string>
|
<string>Add entry</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1" >
|
<item row="1" column="1" >
|
||||||
<widget class="QPushButton" name="mDeleteEntryButton" >
|
<widget class="QPushButton" name="mDeleteEntryButton" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Delete entry</string>
|
<string>Delete entry</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
<spacer>
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" >
|
||||||
<size>
|
<size>
|
||||||
<width>211</width>
|
<width>41</width>
|
||||||
<height>27</height>
|
<height>27</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="3" >
|
<item row="1" column="5" >
|
||||||
<layout class="QHBoxLayout" >
|
<layout class="QHBoxLayout" >
|
||||||
<property name="leftMargin" >
|
<property name="leftMargin" >
|
||||||
<number>11</number>
|
<number>11</number>
|
||||||
@ -1363,11 +1295,14 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="4" >
|
<item row="1" column="6" >
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizeType" >
|
||||||
|
<enum>QSizePolicy::Minimum</enum>
|
||||||
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" >
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>20</width>
|
||||||
@ -1376,7 +1311,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="5" >
|
<item row="1" column="7" >
|
||||||
<widget class="QToolButton" name="pbtnLoadColorMapFromFile" >
|
<widget class="QToolButton" name="pbtnLoadColorMapFromFile" >
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
<string>Load color map from file</string>
|
<string>Load color map from file</string>
|
||||||
@ -1389,7 +1324,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="6" >
|
<item row="1" column="8" >
|
||||||
<widget class="QToolButton" name="pbtnExportColorMapToFile" >
|
<widget class="QToolButton" name="pbtnExportColorMapToFile" >
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
<string>Export color map to file</string>
|
<string>Export color map to file</string>
|
||||||
@ -1402,7 +1337,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0" colspan="7" >
|
<item row="2" column="0" colspan="9" >
|
||||||
<widget class="QTreeWidget" name="mColormapTreeWidget" >
|
<widget class="QTreeWidget" name="mColormapTreeWidget" >
|
||||||
<property name="columnCount" >
|
<property name="columnCount" >
|
||||||
<number>3</number>
|
<number>3</number>
|
||||||
@ -1424,6 +1359,84 @@
|
|||||||
</column>
|
</column>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tabPageGeneral" >
|
<widget class="QWidget" name="tabPageGeneral" >
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user