[QGIS Commit] r9200 - in trunk/qgis/src: app ui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Aug 28 09:58:22 EDT 2008


Author: ersts
Date: 2008-08-28 09:58:22 -0400 (Thu, 28 Aug 2008)
New Revision: 9200

Modified:
   trunk/qgis/src/app/qgsrasterlayerproperties.cpp
   trunk/qgis/src/app/qgsrasterlayerproperties.h
   trunk/qgis/src/ui/qgsrasterlayerpropertiesbase.ui
Log:
-Added ability to add new single entry to color map
-Added ability to sort color map
-Reorder controls on the Colormap tab 

Modified: trunk/qgis/src/app/qgsrasterlayerproperties.cpp
===================================================================
--- trunk/qgis/src/app/qgsrasterlayerproperties.cpp	2008-08-28 07:57:32 UTC (rev 9199)
+++ trunk/qgis/src/app/qgsrasterlayerproperties.cpp	2008-08-28 13:58:22 UTC (rev 9200)
@@ -2622,6 +2622,14 @@
   }
 }
 
+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_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

Modified: trunk/qgis/src/app/qgsrasterlayerproperties.h
===================================================================
--- trunk/qgis/src/app/qgsrasterlayerproperties.h	2008-08-28 07:57:32 UTC (rev 9199)
+++ trunk/qgis/src/app/qgsrasterlayerproperties.h	2008-08-28 13:58:22 UTC (rev 9200)
@@ -108,6 +108,8 @@
     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 @@
     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. */

Modified: trunk/qgis/src/ui/qgsrasterlayerpropertiesbase.ui
===================================================================
--- trunk/qgis/src/ui/qgsrasterlayerpropertiesbase.ui	2008-08-28 07:57:32 UTC (rev 9199)
+++ trunk/qgis/src/ui/qgsrasterlayerpropertiesbase.ui	2008-08-28 13:58:22 UTC (rev 9200)
@@ -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,7 +1199,7 @@
        <string>Colormap</string>
       </attribute>
       <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>
@@ -1214,55 +1214,6 @@
           <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" >
-         <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="mColorInterpolationLabel" >
            <property name="text" >
             <string>Color interpolation</string>
@@ -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" >



More information about the QGIS-commit mailing list