Example #1
0
/*!
   Build a color map with two stops at 0.0 and 1.0.

   \param color1 Color used for the minimum value of the value interval
   \param color2 Color used for the maximum value of the value interval
   \param format Preferred format of the coor map
*/
LinearTransparentColorMap::LinearTransparentColorMap(const QColor& color1,
    const QColor& color2, QwtColorMap::Format format) : QwtColorMap(format)
{
    d_data = new PrivateData;
    d_data->mode = ScaledColors;
    setColorInterval(color1, color2);
}
Example #2
0
/*!
   Build a color map with two stops at 0.0 and 1.0. The color
   at 0.0 is Qt::blue, at 1.0 it is Qt::yellow.

   \param format Preferred format of the color map
*/
LinearTransparentColorMap::LinearTransparentColorMap(QwtColorMap::Format format) : QwtColorMap(format)
{
    d_data = new PrivateData;
    d_data->mode = ScaledColors;

    setColorInterval(Qt::blue, Qt::yellow);
}
Example #3
0
ColorMap::ColorMap(int colormap)
{
//    enum ColorMapForPlot {bluered = 1, blackwhite = 2};
    switch (colormap)
    {
    case 1:
        setColorInterval(Qt::darkBlue, Qt::darkRed);
        addColorStop(0.2, Qt::blue);
        addColorStop(0.4, Qt::cyan);
        addColorStop(0.6, Qt::yellow);
        addColorStop(0.8, Qt::red);
        break;
    case 2:
        setColorInterval(Qt::black, Qt::white);
        break;
    case 3:
        setColorInterval(QColor(0,0,0),QColor(0,255,255));
        break;
    default:
        setColorInterval(Qt::darkBlue, Qt::darkRed);
    }
}
Example #4
0
void FloodPlotColorMap::init()
{
  /// set color stops
  /// scale between 0 and 1
  unsigned int colormapLength = m_colorLevels.size();  // start and end colors
  int r, g, b;
  unsigned int i,j;
  QColor minColor, maxColor; // colors at interval ends
  double min = openstudio::minimum(m_colorLevels);
  double max = openstudio::maximum(m_colorLevels);
  if (max == min)
  {
    return;
  }
  switch (m_colorMap)
  {
    case Gray:
      double gray;
      minColor = QColor(0,0,0);
      maxColor = QColor(255,255,255);
      setColorInterval(minColor, maxColor); // end points
            for (i = 0; i < colormapLength; i++)
            {
                gray = 1.0 * i / (colormapLength - 1);
                r = (int)(255 * gray);
                g = (int)(255 * gray);
                b = (int)(255 * gray);
        addColorStop( (m_colorLevels(i) - min) / (max - min), QColor(r, g, b));
            }
      break;
    case Jet:
      Matrix cMatrix(colormapLength,3);
            unsigned int n = (int)ceil(colormapLength / 4.0);
            int nMod = 0;
            Vector  fArray(3 * n - 1);
      Vector  red(fArray.size());
            Vector  green(fArray.size());
            Vector  blue(fArray.size());


      for (i = 0; i < colormapLength; i++)
            {
        cMatrix(i, 0) = 0;
        cMatrix(i, 1) = 0;
        cMatrix(i, 2) = 0;
            }


            if (colormapLength % 4 == 1)
            {
                nMod = 1;
            }

      for (i = 0; i <fArray.size(); i++)
            {
                if (i < n)
                    fArray(i) = (float)(i + 1) / n;
                else if (i >= n && i < 2 * n - 1)
                    fArray(i) = 1.0;
                else if (i >= 2 * n - 1)
                    fArray(i) = (float)(3 * n - 1 - i) / n;
        green(i) = (int)ceil(n / 2.0) - nMod + i;
                red(i) = green(i) + n;
                blue(i) = green(i) - n;
            }

            int nb = 0;
            for (i = 0; i < blue.size(); i++)
            {
                if (blue(i) > 0)
                    nb++;
            }

            for (i = 0; i < colormapLength; i++)
            {
                for (j = 0; j < red.size(); j++)
                {
                    if (i == red(j) && red(j) < colormapLength)
                    {
                        cMatrix(i, 0) = fArray(i - red(0));
                    }
                }
                for (j = 0; j < green.size(); j++)
                {
                    if (i == green(j) && green(j) < colormapLength)
                        cMatrix(i, 1) = fArray(i - (int)green(0));
                }
                for ( j = 0; j < blue.size(); j++)
                {
                    if (i == blue(j) && blue(j) >= 0)
            cMatrix(i, 2) = fArray(fArray.size() - 1 - nb + i);
                }
            }

      // set before adding color stops
      // default from http://www.matthiaspospiech.de/blog/2008/06/16/qwt-spectrogramm-plot-with-data-arrays/
      minColor = QColor(0,0,189);
      maxColor = QColor(132,0,0);
      int bMin=256;
      int rMin=256;
            for (i = 0; i < colormapLength; i++)
            {
        r = (int)(cMatrix(i, 0) * 255);
        g = (int)(cMatrix(i, 1) * 255);
        b = (int)(cMatrix(i, 2) * 255);
        if ((r==0) && (g==0) && (b<bMin))
        {
          bMin=b;
          minColor = QColor(r,g,b);
        }
        if ((b==0) && (g==0) && (r<rMin))
        {
          rMin=r;
          maxColor = QColor(r,g,b);
        }
            }
      setColorInterval(minColor, maxColor); // end points


            for (i = 0; i < colormapLength; i++)
            {
        r = (int)(cMatrix(i, 0) * 255);
        g = (int)(cMatrix(i, 1) * 255);
        b = (int)(cMatrix(i, 2) * 255);
        addColorStop( (m_colorLevels(i) - min) / (max - min), QColor(r, g, b));
            }
      break;
  }

}