[QGIS Commit] r9091 - trunk/qgis/src/core/raster

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Aug 20 08:04:03 EDT 2008


Author: jef
Date: 2008-08-20 08:04:03 -0400 (Wed, 20 Aug 2008)
New Revision: 9091

Modified:
   trunk/qgis/src/core/raster/qgscolortable.cpp
   trunk/qgis/src/core/raster/qgscolortable.h
Log:
fix msvc warning (std::vector=>QVector)

Modified: trunk/qgis/src/core/raster/qgscolortable.cpp
===================================================================
--- trunk/qgis/src/core/raster/qgscolortable.cpp	2008-08-20 11:49:11 UTC (rev 9090)
+++ trunk/qgis/src/core/raster/qgscolortable.cpp	2008-08-20 12:04:03 UTC (rev 9091)
@@ -23,191 +23,190 @@
 /* compare ramps */
 bool compareRampSort ( const RAMP &a, const RAMP &b) 
 { 
-    if ( a.min < b.min || a.max < b.max ) return true;
+  if ( a.min < b.min || a.max < b.max ) return true;
 
-    return false;
+  return false;
 } 
 
 bool compareRampSearch ( const RAMP &a, const RAMP &b)
 {
-    if( a.max < b.min ) return true;
-    return false;
+  if( a.max < b.min ) return true;
+  return false;
 }
 
 
 QgsColorTable::QgsColorTable ( int interp ) 
 {
-    QgsDebugMsg("QgsColorTable::QgsColorTable()");
-    mInterp = interp;
+  QgsDebugMsg("QgsColorTable::QgsColorTable()");
+  mInterp = interp;
 }
 
 QgsColorTable::~QgsColorTable()
 {
 }
 
-void QgsColorTable::add ( uint index, unsigned char c1, unsigned char c2, unsigned char c3, unsigned char c4 )
+void QgsColorTable::add ( int index, unsigned char c1, unsigned char c2, unsigned char c3, unsigned char c4 )
 {
 #ifdef QGISDEBUG
-    QgsLogger::debug("QgsColorTable::add() index", (int)index, 1, __FILE__, __FUNCTION__, __LINE__);
+  QgsLogger::debug("QgsColorTable::add() index", (int)index, 1, __FILE__, __FUNCTION__, __LINE__);
 #endif
 
-    if ( mDiscrete.size() == 0 ) {
-	mMin = index;
-	mMax = index;
-    } else { 
-	if ( index < mMin ) mMin = index;
-	if ( index > mMax ) mMax = index;
-    }
+  if ( mDiscrete.size() == 0 ) {
+    mMin = index;
+    mMax = index;
+  } else { 
+    if ( index < mMin ) mMin = index;
+    if ( index > mMax ) mMax = index;
+  }
 
-    if ( mDiscrete.size() <= index ) {
-       mDiscrete.resize ( index + 1 ); 
-    }
+  if ( mDiscrete.size() <= index ) {
+    mDiscrete.resize ( index + 1 ); 
+  }
 
-    mDiscrete[index].c1 = c1;
-    mDiscrete[index].c2 = c2;
-    mDiscrete[index].c3 = c3;
-    mDiscrete[index].c4 = c4;
+  mDiscrete[index].c1 = c1;
+  mDiscrete[index].c2 = c2;
+  mDiscrete[index].c3 = c3;
+  mDiscrete[index].c4 = c4;
 }
 
 void QgsColorTable::clear()
 {
-    QgsDebugMsg("QgsColorTable::clear() called ");
-    mDiscrete.clear();
-    mRamp.clear();
-    mMax=0;
-    mMin=0;
+  QgsDebugMsg("QgsColorTable::clear() called ");
+  mDiscrete.clear();
+  mRamp.clear();
+  mMax=0;
+  mMin=0;
 }
 
 
 void QgsColorTable::add ( double min,  double max,
-                  unsigned char min_c1, unsigned char min_c2, unsigned char min_c3, unsigned char min_c4,
+      unsigned char min_c1, unsigned char min_c2, unsigned char min_c3, unsigned char min_c4,
 		  unsigned char max_c1, unsigned char max_c2, unsigned char max_c3, unsigned char max_c4 )
 {
-    RAMP ramp;    
+  RAMP ramp;    
 #ifdef QGISDEBUG
-    QgsLogger::debug("QgsColorTable::add() min", min, 1, __FILE__, __FUNCTION__, __LINE__);
-    QgsLogger::debug("QgsColorTable::add() max", max, 1, __FILE__, __FUNCTION__, __LINE__);
+  QgsLogger::debug("QgsColorTable::add() min", min, 1, __FILE__, __FUNCTION__, __LINE__);
+  QgsLogger::debug("QgsColorTable::add() max", max, 1, __FILE__, __FUNCTION__, __LINE__);
 #endif
 
-    if ( mRamp.size() == 0 ) {
-	mMin = min;
-	mMax = max;
-    } else { 
-	if ( min < mMin ) mMin = min;
-	if ( max > mMax ) mMax = max;
-    }
+  if ( mRamp.size() == 0 ) {
+    mMin = min;
+    mMax = max;
+  } else { 
+    if ( min < mMin ) mMin = min;
+    if ( max > mMax ) mMax = max;
+  }
 
-    ramp.min = min;
-    ramp.max = max;
-    ramp.min_c1 = min_c1;
-    ramp.min_c2 = min_c2;
-    ramp.min_c3 = min_c3;
-    ramp.min_c4 = min_c4;
-    ramp.max_c1 = max_c1;
-    ramp.max_c2 = max_c2;
-    ramp.max_c3 = max_c3;
-    ramp.max_c4 = max_c4;
+  ramp.min = min;
+  ramp.max = max;
+  ramp.min_c1 = min_c1;
+  ramp.min_c2 = min_c2;
+  ramp.min_c3 = min_c3;
+  ramp.min_c4 = min_c4;
+  ramp.max_c1 = max_c1;
+  ramp.max_c2 = max_c2;
+  ramp.max_c3 = max_c3;
+  ramp.max_c4 = max_c4;
 
-    mRamp.push_back ( ramp );
+  mRamp.push_back ( ramp );
 }
 
 bool QgsColorTable::color ( double value, int *c1, int *c2, int *c3 )
 {
-    if ( mRamp.size() > 0 ) {
-	std::vector<RAMP>::iterator it;
+  if ( mRamp.size() > 0 ) {
+    QVector<RAMP>::iterator it;
 
-	RAMP ramp;
-	ramp.min = ramp.max = value;
-	
-	it = std::lower_bound ( mRamp.begin(), mRamp.end(), ramp, compareRampSearch );
+    RAMP ramp;
+    ramp.min = ramp.max = value;
 
-	if ( it != mRamp.end() ) { // Found
-	    double k, d;
-            d = it->max - it->min;
-	    
-	    if ( d <= 0 ) { 
-		k = 0;
-	    } else {
-	        k = (value - it->min)/d;
-	    }
+    it = qLowerBound ( mRamp.begin(), mRamp.end(), ramp, compareRampSearch );
 
-	    *c1 = (int) (it->min_c1 + k * (it->max_c1 - it->min_c1));
-	    *c2 = (int) (it->min_c2 + k * (it->max_c2 - it->min_c2));
-	    *c3 = (int) (it->min_c3 + k * (it->max_c3 - it->min_c3));
-	    
-	    return true;
-	}
-    } else if ( mDiscrete.size() > 0 ) {
-	uint index = (uint) value;
-	if ( index < mDiscrete.size() ) {
-	    *c1 = mDiscrete[index].c1;
-	    *c2 = mDiscrete[index].c2;
-	    *c3 = mDiscrete[index].c3;
-	    return true;
-	}
+    if ( it != mRamp.end() ) { // Found
+      double k, d;
+      d = it->max - it->min;
+
+      if ( d <= 0 ) { 
+        k = 0;
+      } else {
+        k = (value - it->min)/d;
+      }
+
+      *c1 = (int) (it->min_c1 + k * (it->max_c1 - it->min_c1));
+      *c2 = (int) (it->min_c2 + k * (it->max_c2 - it->min_c2));
+      *c3 = (int) (it->min_c3 + k * (it->max_c3 - it->min_c3));
+
+      return true;
     }
+  } else if ( mDiscrete.size() > 0 ) {
+    int index = (uint) value;
+    if ( index < mDiscrete.size() ) {
+      *c1 = mDiscrete[index].c1;
+      *c2 = mDiscrete[index].c2;
+      *c3 = mDiscrete[index].c3;
+      return true;
+    }
+  }
 
-    *c1 = 0; *c2 = 0; *c3 = 0;
-    return false;
+  *c1 = 0; *c2 = 0; *c3 = 0;
+  return false;
 }
 
 void QgsColorTable::sort ( void )
 {
-    std::sort ( mRamp.begin(), mRamp.end(), compareRampSort );
+  qSort ( mRamp.begin(), mRamp.end(), compareRampSort );
 }
 
 bool QgsColorTable::defined ( void )
 {
-    if ( mDiscrete.size() > 0 || mRamp.size() > 0 ) {
-	return true;
-    }
-    return false;
+  if ( mDiscrete.size() > 0 || mRamp.size() > 0 ) {
+    return true;
+  }
+  return false;
 }
 
 int QgsColorTable::interpretation ( void )
 {
-    return mInterp;
+  return mInterp;
 }
 
 double QgsColorTable::rmin ( void )
 {
-    return mMin;
+  return mMin;
 }
 
 double QgsColorTable::rmax ( void )
 {
-    return mMax;  
+  return mMax;  
 }
 
 
 void QgsColorTable::print ( void )
 {
 #ifdef QGISDEBUG
-    QgsLogger::debug("******** Color table ********", 1, __FILE__, __FUNCTION__,  __LINE__);
-    QgsLogger::debug("Discrete table size", (int)mDiscrete.size(), 1, __FILE__, __FUNCTION__,  __LINE__);
+  QgsLogger::debug("******** Color table ********", 1, __FILE__, __FUNCTION__,  __LINE__);
+  QgsLogger::debug("Discrete table size", (int)mDiscrete.size(), 1, __FILE__, __FUNCTION__,  __LINE__);
 
-    for ( uint i = 0; i < mDiscrete.size(); i++ ) {
-      QgsLogger::debug("i", (int)i, 2, __FILE__, __FUNCTION__,  __LINE__);
-	QgsLogger::debug("c1", (int) mDiscrete[i].c1, 2, __FILE__, __FUNCTION__,  __LINE__);
-	QgsLogger::debug("c2", (int) mDiscrete[i].c2, 2, __FILE__, __FUNCTION__,  __LINE__);
-	QgsLogger::debug("c3", (int) mDiscrete[i].c3, 2, __FILE__, __FUNCTION__,  __LINE__);
-    }
+  for ( int i = 0; i < mDiscrete.size(); i++ ) {
+    QgsLogger::debug("i", (int)i, 2, __FILE__, __FUNCTION__,  __LINE__);
+    QgsLogger::debug("c1", (int) mDiscrete[i].c1, 2, __FILE__, __FUNCTION__,  __LINE__);
+    QgsLogger::debug("c2", (int) mDiscrete[i].c2, 2, __FILE__, __FUNCTION__,  __LINE__);
+    QgsLogger::debug("c3", (int) mDiscrete[i].c3, 2, __FILE__, __FUNCTION__,  __LINE__);
+  }
 
-    QgsLogger::debug("Ramp table size", (int)mRamp.size(), 1, __FILE__, __FUNCTION__,  __LINE__);
-    for ( uint i = 0; i < mRamp.size(); i++ ) {
-        std::cerr << "  min = " << mRamp[i].min << " max = " << mRamp[i].max 
-	          << " min_c1 = " << (int)mRamp[i].min_c1 << " min_c2 = " << (int)mRamp[i].min_c2 
-	          << " min_c3 = " << (int)mRamp[i].min_c3 << " max_c1 = " << (int)mRamp[i].max_c1
-		  << " max_c2 = " << (int)mRamp[i].max_c2 << " max_c3 = " << (int)mRamp[i].max_c3 
-		  << std::endl;
-	QgsLogger::debug("min", mRamp[i].min, 2, __FILE__, __FUNCTION__,  __LINE__);
-	QgsLogger::debug("min_c1", (int)mRamp[i].min_c1, 2, __FILE__, __FUNCTION__,  __LINE__);
-	QgsLogger::debug("min_c2", (int)mRamp[i].min_c2, 2, __FILE__, __FUNCTION__,  __LINE__);
-	QgsLogger::debug("min_c3", (int)mRamp[i].min_c3, 2, __FILE__, __FUNCTION__,  __LINE__);
-	QgsLogger::debug("max_c1", (int)mRamp[i].max_c1, 2, __FILE__, __FUNCTION__,  __LINE__);
-	QgsLogger::debug("max_c2", (int)mRamp[i].max_c2, 2, __FILE__, __FUNCTION__,  __LINE__);
-	QgsLogger::debug("max_c3", (int)mRamp[i].max_c3, 2, __FILE__, __FUNCTION__,  __LINE__);
-    }
+  QgsLogger::debug("Ramp table size", (int)mRamp.size(), 1, __FILE__, __FUNCTION__,  __LINE__);
+  for ( int i = 0; i < mRamp.size(); i++ ) {
+    std::cerr << "  min = " << mRamp[i].min << " max = " << mRamp[i].max 
+      << " min_c1 = " << (int)mRamp[i].min_c1 << " min_c2 = " << (int)mRamp[i].min_c2 
+      << " min_c3 = " << (int)mRamp[i].min_c3 << " max_c1 = " << (int)mRamp[i].max_c1
+      << " max_c2 = " << (int)mRamp[i].max_c2 << " max_c3 = " << (int)mRamp[i].max_c3 
+      << std::endl;
+    QgsLogger::debug("min", mRamp[i].min, 2, __FILE__, __FUNCTION__,  __LINE__);
+    QgsLogger::debug("min_c1", (int)mRamp[i].min_c1, 2, __FILE__, __FUNCTION__,  __LINE__);
+    QgsLogger::debug("min_c2", (int)mRamp[i].min_c2, 2, __FILE__, __FUNCTION__,  __LINE__);
+    QgsLogger::debug("min_c3", (int)mRamp[i].min_c3, 2, __FILE__, __FUNCTION__,  __LINE__);
+    QgsLogger::debug("max_c1", (int)mRamp[i].max_c1, 2, __FILE__, __FUNCTION__,  __LINE__);
+    QgsLogger::debug("max_c2", (int)mRamp[i].max_c2, 2, __FILE__, __FUNCTION__,  __LINE__);
+    QgsLogger::debug("max_c3", (int)mRamp[i].max_c3, 2, __FILE__, __FUNCTION__,  __LINE__);
+  }
 #endif
 }
-

Modified: trunk/qgis/src/core/raster/qgscolortable.h
===================================================================
--- trunk/qgis/src/core/raster/qgscolortable.h	2008-08-20 11:49:11 UTC (rev 9090)
+++ trunk/qgis/src/core/raster/qgscolortable.h	2008-08-20 12:04:03 UTC (rev 9091)
@@ -17,8 +17,7 @@
 #ifndef QGSCOLORTABLE_H
 #define QGSCOLORTABLE_H
 
-#include <vector>
-#include <algorithm>
+#include <QVector>
 
 /* 
  * Because of performance, this class can store color rules in 2 forms:
@@ -43,79 +42,79 @@
 class CORE_EXPORT QgsColorTable
 {
 public:
-    /** 
-     *  \brief Constructor.
-     *  \param interp color table interpretation
-     */
-    QgsColorTable ( int interp = Rgb ); 
+  /** 
+  *  \brief Constructor.
+  *  \param interp color table interpretation
+  */
+  QgsColorTable ( int interp = Rgb ); 
 
-    /** \brief The destuctor.  */
-    ~QgsColorTable();
+  /** \brief The destuctor.  */
+  ~QgsColorTable();
 
-    /** \brief Color table interpretation. */
-    // This is taken from GDAL, GPI_RGB is mapped to Rgba 
-    enum Interp {
-	Gray = 0, // Use c1 as grayscale value.
-	Rgb,      // Use c1 as red, c2 as green, c3 as blue
-	Rgba,     // Use c1 as red, c2 as green, c3 as blue and c4 as alpha.
-	Cmyk,     // Use c1 as cyan, c2 as magenta, c3 as yellow and c4 as black.
-	Hls       // c1 hue, c2 lightness, c3 saturation; should be His ? 
-    };
+  /** \brief Color table interpretation. */
+  // This is taken from GDAL, GPI_RGB is mapped to Rgba 
+  enum Interp {
+    Gray = 0, // Use c1 as grayscale value.
+    Rgb,      // Use c1 as red, c2 as green, c3 as blue
+    Rgba,     // Use c1 as red, c2 as green, c3 as blue and c4 as alpha.
+    Cmyk,     // Use c1 as cyan, c2 as magenta, c3 as yellow and c4 as black.
+    Hls       // c1 hue, c2 lightness, c3 saturation; should be His ? 
+  };
 
-    /** 
-     *  \brief Color table is defined 
-     *  \return true if at least one rule is defined 
-     *  \false no rule defined
-     */
-    bool defined ( void );
+  /** 
+  *  \brief Color table is defined 
+  *  \return true if at least one rule is defined 
+  *  \false no rule defined
+  */
+  bool defined ( void );
 
-    /** \brief Get color table interpretation */
-    int interpretation ( void );
+  /** \brief Get color table interpretation */
+  int interpretation ( void );
 
-    /** \brief Add a discrete color */
-    void add ( unsigned int index, unsigned char c1, unsigned char c2, unsigned char c3, unsigned char c4 = 0 );
+  /** \brief Add a discrete color */
+  void add ( int index, unsigned char c1, unsigned char c2, unsigned char c3, unsigned char c4 = 0 );
 
-    /** \brief Add a ramp rule */ 
-    void add ( double min,  double max,
-	       unsigned char min_c1, unsigned char min_c2, unsigned char min_c3, unsigned char min_c4,
-               unsigned char max_c1, unsigned char max_c2, unsigned char max_c3, unsigned char max_c4);
-    
-    /** \brief Get color 
-     *  \return true color was found
-     *  \return false color was no found
-     */
-    bool color ( double value, int *c1, int *c2, int *c3 );
-    
-    /** \brief Sort ramp rules */
-    void sort ( void ); 
+  /** \brief Add a ramp rule */ 
+  void add ( double min,  double max,
+    unsigned char min_c1, unsigned char min_c2, unsigned char min_c3, unsigned char min_c4,
+    unsigned char max_c1, unsigned char max_c2, unsigned char max_c3, unsigned char max_c4);
 
-    /** \brief Print to stderr - for debuging */
-    void print ( void );
+  /** \brief Get color 
+  *  \return true color was found
+  *  \return false color was no found
+  */
+  bool color ( double value, int *c1, int *c2, int *c3 );
 
-    /** \brief Minimum value */
-    double rmin();
-   
-    /** \brief Maximum value */
-    double rmax();
+  /** \brief Sort ramp rules */
+  void sort ( void ); 
 
-    /** \brief Clear the color table */
-    void clear();
+  /** \brief Print to stderr - for debuging */
+  void print ( void );
 
+  /** \brief Minimum value */
+  double rmin();
+
+  /** \brief Maximum value */
+  double rmax();
+
+  /** \brief Clear the color table */
+  void clear();
+
 private:
-    /** \brief vector of discrete values */
-    std::vector<DISCRETE> mDiscrete;
+  /** \brief vector of discrete values */    
+  QVector<DISCRETE> mDiscrete;
 
-    /** \brief vector of ramp rules */
-    std::vector<RAMP> mRamp;
+  /** \brief vector of ramp rules */
+  QVector<RAMP> mRamp;
 
-    /** \brief color table interpretation */
-    int  mInterp;
+  /** \brief color table interpretation */
+  int  mInterp;
 
-    /** \brief min value */
-    double mMin;
+  /** \brief min value */
+  double mMin;
 
-    /** \brief max value */
-    double mMax;
+  /** \brief max value */
+  double mMax;
 };
 
 #endif



More information about the QGIS-commit mailing list