天天看點

qcustomplot彩虹色 Rainbow

1.
在.h檔案
class QCPColorGradient枚舉enum GradientPreset最後添加一行
,gpRainbow
即:
  enum GradientPreset { gpGrayscale  ///< Continuous lightness from black to white (suited for non-biased data representation)
                        ,gpHot       ///< Continuous lightness from black over firey colors to white (suited for non-biased data representation)
                        ,gpCold      ///< Continuous lightness from black over icey colors to white (suited for non-biased data representation)
                        ,gpNight     ///< Continuous lightness from black over weak blueish colors to white (suited for non-biased data representation)
                        ,gpCandy     ///< Blue over pink to white
                        ,gpGeography ///< Colors suitable to represent different elevations on geographical maps
                        ,gpIon       ///< Half hue spectrum from black over purple to blue and finally green (creates banding illusion but allows more precise magnitude estimates)
                        ,gpThermal   ///< Colors suitable for thermal imaging, ranging from dark blue over purple to orange, yellow and white
                        ,gpPolar     ///< Colors suitable to emphasize polarity around the center, with blue for negative, black in the middle and red for positive values
                        ,gpSpectrum  ///< An approximation of the visible light spectrum (creates banding illusion but allows more precise magnitude estimates)
                        ,gpJet       ///< Hue variation similar to a spectrum, often used in numerical visualization (creates banding illusion but allows more precise magnitude estimates)
                        ,gpHues      ///< Full hue cycle, with highest and lowest color red (suitable for periodic data, such as angles and phases, see \ref setPeriodic)
                        ,gpRainbow   /// rainbow  add
                      };

2.
在.cpp檔案
void QCPColorGradient::loadPreset(GradientPreset preset)方法switch最後添加
  case gpRainbow: // rainbow
      //setColorInterpolation(ciRGB);
      //setColorStopAt(-1, QColor(0, 0, 255));
      //setColorStopAt(-0.5, QColor(0, 255, 255));
      //setColorStopAt(0, QColor(0, 255, 0));
      //setColorStopAt(0.5, QColor(255, 255, 0));
      //setColorStopAt(1, QColor(255, 0, 0));

      setColorInterpolation(ciRGB);
      setColorStopAt(0, QColor(0, 0, 255));
      setColorStopAt(0.25, QColor(0, 255, 255));
      setColorStopAt(0.5, QColor(0, 255, 0));
      setColorStopAt(0.75, QColor(255, 255, 0));
      setColorStopAt(1, QColor(255, 0, 0));
      break;

           
Qt

繼續閱讀